@playcanvas/supersplat-viewer 1.43.2 → 1.44.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/docs/api.md CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  Embedding, runtime control and settings for `@playcanvas/supersplat-viewer`.
4
4
 
5
+ ## Choosing how to instance the viewer
6
+
7
+ There are two ways to put the viewer on a page. Both run the same viewer; they differ in who owns the page around it.
8
+
9
+ - **`renderViewerHtml` returns a complete page**, the SuperSplat viewer as shipped, which you serve on its own, usually in an iframe. It runs anywhere that can call a function at build or serve time, needs no engine in your bundle, and is isolated from your page's styles, scripts and globals. It is configured with data only: asset URLs, settings, defaults for the viewer's flags, theme tokens in `headExtras` and URL parameters. Once served you have no handle on it.
10
+ - **`createViewer` mounts the viewer in an element of your own page.** You bundle it with your app and the engine, and it returns a handle with observable state, events and commands. It is the way to integrate with the viewer and to own its surroundings: your own controls, overlays inside the container, your own info panel or none (`onInfo`), or no built-in UI at all (`ui: false`).
11
+
12
+ Choose `renderViewerHtml` for an embed you hand over or drop into a page, such as a CMS, a static site, a single self-contained file or someone else's site. Choose `createViewer` for an app built around the viewer, or a product that wants its own look and identity around it. Options that customise or replace the built-in UI belong to `createViewer`; a generated page stays the SuperSplat viewer as shipped.
13
+
5
14
  ## Embedding the viewer
6
15
 
7
16
  If you generate a page around the viewer, use `renderViewerHtml`. It returns a complete
@@ -14,8 +23,10 @@ const document = renderViewerHtml({
14
23
  bootstrap: {
15
24
  settings, // an object, or omit and set settingsUrl
16
25
  contentUrl: 'scene.sog',
17
- posterUrl: 'poster.jpg'
26
+ posterUrl: 'poster.jpg',
27
+ flags: { lang: 'de', noanim: true } // defaults for the viewer's switches
18
28
  },
29
+ title: 'My scene', // the browser tab's title
19
30
  baseHref: '/viewer/', // serving from a sub-path
20
31
  backgroundColor: [0, 0, 0], // components are 0..1, not 0..255
21
32
  headExtras: '<script src="analytics.js"></script>',
@@ -27,6 +38,8 @@ Called with no options it returns the document the package ships, unmodified. UR
27
38
  on the served page override the bootstrap's asset URLs, so an embed stays overridable per
28
39
  instance — except an inline `settings` object, which takes precedence over `?settings=`.
29
40
 
41
+ The bootstrap's `flags` are the document's defaults for the same switches `createViewer` takes (`ui`, `noanim`, `lang`, `aa`, `budget` and the rest), so a page that should always open in German or paused does not depend on every link carrying `?lang=de&noanim`. URL parameters still win: a switch parameter such as `?noanim` can turn its flag on but not off, while `?hpr` and `?aa` take a value and so work either way. `exposeGlobals` is not a bootstrap flag, as the document always publishes the `window.*` hooks.
42
+
30
43
  Set both `inlineCss` and `inlineJs` for a single self-contained file, with the splat passed as
31
44
  a `data:` URI in `contentUrl` and the settings supplied inline through the bootstrap's
32
45
  `settings` object — without an inline settings object the page still fetches `./settings.json`
@@ -170,7 +183,7 @@ The value stays active until replaced. The viewer clears it on camera/XR mode ch
170
183
 
171
184
  ### Saved preferences
172
185
 
173
- `performanceMode`, `gamingControls` and `showAnnotations` load from and write changes to the existing origin-wide local-storage keys, with or without the built-in UI. Creation does not write defaults; the legacy `retinaDisplay` migration is preserved. A new viewer reads the saved values; already-mounted viewers keep their own state rather than synchronizing through storage. The host can change these preferences through the corresponding writable state fields. Storage denial or quota errors leave the viewer usable, and destruction removes its persistence subscriptions. The built-in UI also remembers whether its controls panel is open, under the origin-wide key `controlsPanelOpen`; it is open for a new visitor until they close it.
186
+ `performanceMode`, `gamingControls` and `showAnnotations` load from and write changes to the existing origin-wide local-storage keys, with or without the built-in UI. Creation does not write defaults; the legacy `retinaDisplay` migration is preserved. A new viewer reads the saved values; already-mounted viewers keep their own state rather than synchronizing through storage. The host can change these preferences through the corresponding writable state fields. Storage denial or quota errors leave the viewer usable, and destruction removes its persistence subscriptions. The built-in UI also remembers whether its controls panel is open, under the origin-wide key `controlsPanelOpen`; it is open for a new visitor until they close it. The XR menu remembers whether the floor grid shows in a scene without collision, under `xrGrid`; it shows until the user turns it off.
174
187
 
175
188
  ### Controlling annotations
176
189
 
@@ -210,7 +223,7 @@ viewer.events.on('isFullscreen:changed', updateControls);
210
223
  viewer.events.on('xrMode:changed', updateControls);
211
224
  ```
212
225
 
213
- Native fullscreen targets this viewer's root. Read-only `state.isFullscreen` follows browser entry and exit, including Escape, and the built-in buttons follow host commands. `exitFullscreen()` is a no-op when another element owns fullscreen. Without native fullscreen support, an iframe retains the legacy `requestFullscreen` / `exitFullscreen` parent messages: the promise resolves when sent and `isFullscreen` reports the requested state, because that bridge has no acknowledgement. An unsupported top-level page rejects entry. Automatic entry/exit on orientation changes remains a built-in UI policy; replacement controls choose their own policy.
226
+ Native fullscreen targets the container you passed to `createViewer`, so anything you show over the viewer inside it, such as your own info panel, stays visible. Read-only `state.isFullscreen` follows browser entry and exit, including Escape, and the built-in buttons follow host commands. `exitFullscreen()` is a no-op when another element owns fullscreen. Without native fullscreen support, an iframe retains the legacy `requestFullscreen` / `exitFullscreen` parent messages: the promise resolves when sent and `isFullscreen` reports the requested state, because that bridge has no acknowledgement. An unsupported top-level page rejects entry. Automatic entry/exit on orientation changes remains a built-in UI policy; replacement controls choose their own policy.
214
227
 
215
228
  `state.canStartAR` and `state.canStartVR` report availability on the current renderer. `hasAR` and `hasVR` also include sessions that could work after a WebGL reload. Subscribe to their change events because capability checks can finish after creation. The built-in UI offers the reload prompt; `startXR()` itself never reloads the page and rejects when the current renderer cannot host the session. Browser permission and device availability can still prevent entry.
216
229
 
@@ -222,27 +235,46 @@ During a session, squeezing both grips, or making fists with tracked hands, drag
222
235
 
223
236
  ### Restyling
224
237
 
225
- The colours the UI is built from are CSS custom properties on the instance root, so you can
226
- retheme it without replacing anything:
238
+ Set CSS custom properties on the instance root to change the built-in UI's palette and font.
227
239
 
228
240
  ```css
229
241
  #viewer .sse-viewer {
230
- --sse-accent: #09f; /* highlights, active toggles, the timeline */
231
- --sse-bkg: #204; /* panels; translucent surfaces derive from it */
242
+ --sse-accent: #09f;
243
+ --sse-bkg: #204;
232
244
  --sse-text-light: #fff;
245
+ --sse-font: system-ui, sans-serif;
233
246
  }
234
247
  ```
235
248
 
236
- The full set is `--sse-text`, `--sse-text-light`, `--sse-text-dark`, `--sse-text-darkest`,
237
- `--sse-accent`, `--sse-grip`, `--sse-bkg`, `--sse-bkg-dark`, `--sse-bkg-darkest` and
238
- `--sse-bkg-light`.
249
+ Use `--sse-text` for normal text, `--sse-text-light` for the strongest emphasis, and `--sse-text-dark` and `--sse-text-darkest` for lower emphasis. The background palette is `--sse-bkg`, `--sse-bkg-light`, `--sse-bkg-dark` and `--sse-bkg-darkest`. Use `--sse-accent` for highlights, `--sse-grip` for drag handles and `--sse-font` for the font family. If your accent is close to `--sse-text-light`, set `--sse-loading-track` to a contrasting colour so loading progress stays visible.
250
+
251
+ These properties are the supported styling API. The built-in layout, its internal selectors and the way individual controls use the palette can change between releases.
239
252
 
240
253
  For more than a retheme, pass `ui: false`. The viewer creates the canvas and retains core input handling, including keyboard/gamepad input gated by `state.inputEnabled`. It omits the overlay, annotation presentation and built-in controls; render your own controls through the viewer handle. Note that the touch joystick, the fullscreen button and
241
254
  the AR/VR fallback prompt are part of the UI you are replacing, so those affordances become
242
255
  yours too. Everything between the two, replacing some of the UI but keeping the rest, is not
243
- supported yet; the class names inside the viewer are not API and do change.
256
+ supported yet, apart from the info panel below.
257
+
258
+ ### Your own info panel
259
+
260
+ The toolbar's info button opens the viewer's info panel: what is running, its version and the GPU. Pass `onInfo` to show your own panel instead. The viewer then calls it when the button is pressed and never opens its own.
261
+
262
+ ```ts
263
+ const viewer = await createViewer({
264
+ container,
265
+ settings,
266
+ contentUrl,
267
+ onInfo: () => myInfoPanel.toggle()
268
+ });
269
+ ```
270
+
271
+ Render the panel inside `container` so it stays visible in fullscreen. Its contents, open state and closing are yours; the keyboard shortcuts stay in the viewer's controls panel, on its Global page (Shift+H).
272
+
273
+ Pass `onInfo: false` for no info at all. The info button is removed from the toolbar and the viewer's info panel never opens, however the built-in UI changes in future.
274
+
275
+ `onInfo` is a `createViewer` option only: a document from `renderViewerHtml` cannot carry a function, and is the viewer as shipped, info panel included.
244
276
 
245
- [The custom UI example](https://github.com/playcanvas/supersplat-viewer/blob/main/src/dev/custom-ui.html) demonstrates loading, playback, camera modes, directional movement, annotations, preferences and fullscreen/XR using only the handle and documented state events. Run it locally at `/custom-ui?content=./scene.ply&settings=./settings.json` (`&webgl` selects WebGL). It is a development example, not a React package or a published UI component. Its controls live outside the fullscreen viewer root, so use Escape or the browser's exit affordance to leave fullscreen.
277
+ [The custom UI example](https://github.com/playcanvas/supersplat-viewer/blob/main/src/dev/custom-ui.html) demonstrates loading, playback, camera modes, directional movement, annotations, preferences and fullscreen/XR using only the handle and documented state events. Run it locally at `/custom-ui?content=./scene.ply&settings=./settings.json` (`&webgl` selects WebGL). It is a development example, not a React package or a published UI component. Its controls live outside the fullscreen container, so use Escape or the browser's exit affordance to leave fullscreen.
246
278
 
247
279
  ## Settings
248
280
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@playcanvas/supersplat-viewer",
3
- "version": "1.43.2",
3
+ "version": "1.44.0",
4
4
  "author": "PlayCanvas <support@playcanvas.com>",
5
5
  "homepage": "https://github.com/playcanvas/supersplat-viewer#readme",
6
6
  "description": "Viewer for https://superspl.at",
@@ -70,19 +70,19 @@
70
70
  "@rollup/plugin-json": "6.1.0",
71
71
  "@rollup/plugin-node-resolve": "16.0.3",
72
72
  "@rollup/plugin-typescript": "12.3.1",
73
- "autoprefixer": "10.6.2",
73
+ "autoprefixer": "10.7.0",
74
74
  "concurrently": "9.2.5",
75
75
  "eslint": "9.39.5",
76
- "playcanvas": "2.24.1",
77
- "postcss": "8.5.32",
78
- "prettier": "3.9.10",
76
+ "playcanvas": "2.24.3",
77
+ "postcss": "8.5.33",
78
+ "prettier": "3.10.1",
79
79
  "publint": "0.3.25",
80
- "rollup": "4.68.2",
80
+ "rollup": "4.68.8",
81
81
  "rollup-plugin-dts": "6.5.1",
82
82
  "rollup-plugin-scss": "4.0.1",
83
83
  "rollup-plugin-string": "3.0.0",
84
- "sass": "1.108.1",
85
- "serve": "14.2.7",
84
+ "sass": "1.108.2",
85
+ "serve": "14.2.8",
86
86
  "typescript": "5.9.3"
87
87
  },
88
88
  "scripts": {