The SH4 Viewer on your own website
← DownloadsShow your Gaussian splats on your own web pages, with spherical harmonics up to degree 4 and the SH slider. It takes one folder, your splat file and one line of HTML.
What you need
- The SH4 Viewer zip. It holds the viewer as plain web files.
- Your splat file.
.sogis best: small and fast to load. Make an SH4.sogwith the SH4 Converter..ply(up to degree 4),.compressed.plyand.spzwork too, but a raw PLY is large: every visitor downloads all of it.
- A website where you can upload files. Any ordinary web hosting will do. The viewer needs no server software, no database and no account anywhere.
Four steps
- Unzip
SH4-Viewer.zip. Inside is a folder namedapp:app/ default-settings.json the viewer's settings (background colour, …) index.html the drop page of the Windows app (not needed on a website) viewer/ index.html the viewer index.js, index.css LICENSE-supersplat-viewer.txt - Upload the
appfolder to your website and give it a clear name, for examplesh4-viewer. Keep the files inside as they are. - Upload your splat file to the same website, for example to
/splats/my-specimen.sog. - Paste this line where the viewer should appear on your page, with your own file name after
content=:<iframe src="/sh4-viewer/viewer/index.html?content=/splats/my-specimen.sog&settings=../default-settings.json" style="width: 100%; aspect-ratio: 4 / 3; border: 0;" allow="fullscreen; xr-spatial-tracking" title="3D model"></iframe>
Open the page: the splat appears in the frame, with the SH slider at the top right. At the bottom right are the fit button (the target icon, or the F key: the object back in the middle, for visitors who got lost) and the full-screen button.
The address, part by part
Everything after the ? tells the viewer what to show. Parts are joined with &.
| Part | What it does |
|---|---|
content= | Required. The splat file to show. Best as a path from the root of
your site (/splats/…). |
settings= | Required. The settings file. ../default-settings.json
is the one from the zip, seen from the viewer folder. Without it the viewer stays empty. |
poster= | Optional. An image (.jpg, .webp) shown while the
splat loads. Useful for a large file. |
noui | Optional. Hides every control, the SH slider included: only the splat and the mouse or touch navigation remain. |
noanim | Optional. Does not play the camera animation of the settings file. |
Example with a poster image and without controls:
/sh4-viewer/viewer/index.html?content=/splats/my-specimen.sog&settings=../default-settings.json&poster=/splats/my-specimen.webp&noui
The settings file
- Background colour:
"background": { "color": [0, 0, 0] }indefault-settings.json. Red, green and blue from 0 to 1:[1, 1, 1]is white. - Different settings per splat: make a copy of the file for each splat (for example
my-specimen.json) and pointsettings=at it. - The start view: without a camera the viewer frames the object itself, whole and in the middle (stray
splats far away are left out of that). To start from another angle or closer by, set a camera in
"cameras":"cameras": [{ "initial": { "position": [6.1, 4.2, 5.3], "target": [-0.3, -0.1, -1.1], "fov": 45 } }]target: the point the camera looks at, usually the centre of your specimen;position: where the camera stands. Further from the target = the specimen smaller in the frame;fov: the camera's field of view in degrees (45 is a normal lens).
targetandposition, flip the sign of the first two numbers you read from your file.
Good to know
- Splat file on another website? Then that website must allow it: it has to send the header
Access-Control-Allow-Originwith the splat file. The simplest is to keep the viewer and the splat on the same website. - Browsers. The viewer uses WebGPU where the browser has it and falls back to WebGL 2 by itself: current Chrome, Edge, Safari and Firefox, on computers, tablets and phones.
- Large files and phones. A visitor downloads the whole splat before it appears. Our SH4 pyrite is
75 MB as
.sogagainst 1.7 GB as.ply. Phones have less memory: for them a version with fewer splats is safer. - Updating the viewer. Replace the files in the
viewerfolder with those from a newer zip. Your settings files and splats stay as they are.
Licence
- MIT licence: free to use, also commercially. Keep the file
LICENSE-supersplat-viewer.txtwith the viewer. - The viewer is the open-source SuperSplat Viewer by PlayCanvas; the degree-4 extension and the SH slider are by MICROscanR.
- A mention of MICROscanR with a link to www.microscanr.com is appreciated.