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 cgr.Splat PLY, staged into the page) in an orbit viewer.
cgr.SplatViewer(reconstruct(target.sessions.photo)) # a recipe returning cgr.Splat
Source code in capturegraph-recipes/capturegraph_recipes/splats/viewer.py
| class SplatViewer(cgui.Component):
"""A ``model`` (a ``cgr.Splat`` PLY, staged into the page) in an orbit viewer.
```python
cgr.SplatViewer(reconstruct(target.sessions.photo)) # a recipe returning cgr.Splat
```
"""
model: Splat
def html(self, render: cgui.Render) -> str:
"""A canvas and the module script that loads the staged PLY into it."""
identifier = render.identifier("splat")
return cgui.element("canvas", {"class": "cg-splat", "id": identifier}) + cgui.element(
"script",
{"type": "module"},
_ORBIT
% {
"module": cgui.inline_json("./" + render.lib(GSPLAT, "index.es.js")),
"id": cgui.inline_json(identifier),
"model": cgui.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-recipes/capturegraph_recipes/splats/viewer.py
| def html(self, render: cgui.Render) -> str:
"""A canvas and the module script that loads the staged PLY into it."""
identifier = render.identifier("splat")
return cgui.element("canvas", {"class": "cg-splat", "id": identifier}) + cgui.element(
"script",
{"type": "module"},
_ORBIT
% {
"module": cgui.inline_json("./" + render.lib(GSPLAT, "index.es.js")),
"id": cgui.inline_json(identifier),
"model": cgui.inline_json(render.stage(self.model)),
},
)
|