SplatViewer — an interactive 3D Gaussian splat viewer, drawn by gsplat.
A splat is stored in the capture's own ARKit world frame, where Y points up;
gsplat draws the 3DGS convention, where Y points down. The loaded splat turns
half a turn about X to cross between them.
SplatViewer
Bases: Component
A model (a cg.Splat PLY, staged into the page) in an orbit viewer.
cg.ui.SplatViewer(reconstruct(target.sessions.photo)) # a recipe returning cg.Splat
Source code in capturegraph-lib/capturegraph/ui/splat_viewer.py
| class SplatViewer(Component):
"""A ``model`` (a ``cg.Splat`` PLY, staged into the page) in an orbit viewer.
```python
cg.ui.SplatViewer(reconstruct(target.sessions.photo)) # a recipe returning cg.Splat
```
"""
model: Splat
def html(self, render: Render) -> str:
"""A canvas and the module script that loads the staged PLY into it."""
identifier = render.identifier("splat")
return element("canvas", {"class": "cg-splat", "id": identifier}) + element(
"script",
{"type": "module"},
_ORBIT
% {
"module": inline_json("./" + render.lib("gsplat/index.es.js")),
"id": inline_json(identifier),
"model": inline_json(render.stage(self.model)),
},
)
|
html(render)
A canvas and the module script that loads the staged PLY into it.
Source code in capturegraph-lib/capturegraph/ui/splat_viewer.py
| def html(self, render: Render) -> str:
"""A canvas and the module script that loads the staged PLY into it."""
identifier = render.identifier("splat")
return element("canvas", {"class": "cg-splat", "id": identifier}) + element(
"script",
{"type": "module"},
_ORBIT
% {
"module": inline_json("./" + render.lib("gsplat/index.es.js")),
"id": inline_json(identifier),
"model": inline_json(render.stage(self.model)),
},
)
|