@playcanvas/supersplat-viewer 1.40.0 → 1.41.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
@@ -35,6 +35,20 @@ name's extension, so name its content with the bootstrap's `contentFilename` (e.
35
35
  `scene.sog`). The flags are independent, so a server that serves the bundle from its own
36
36
  route can inline only the stylesheet.
37
37
 
38
+ A `.gsaf` sequence is decoded by a wasm module, `gsaf-decoder.wasm`, which ships beside `index.js` (and beside `dist/viewer.js`) and is fetched only when gsaf content loads, so serve it with the bundle as `application/wasm`. A document with no sibling files has nowhere to fetch it from: set the bootstrap's `gsafDecoderUrl` to the `data:` url the `@playcanvas/supersplat-viewer/gsaf-decoder` export provides, a separate entry so that nothing else bundles it.
39
+
40
+ ```js
41
+ import { gsafDecoderDataUrl } from '@playcanvas/supersplat-viewer/gsaf-decoder';
42
+
43
+ renderViewerHtml({
44
+ bootstrap: { settings, contentUrl: gsafDataUri, contentFilename: 'scene.gsaf', gsafDecoderUrl: gsafDecoderDataUrl },
45
+ inlineCss: true,
46
+ inlineJs: true
47
+ });
48
+ ```
49
+
50
+ `gsafDecoderUrl` is also a `createViewer` option, for a host serving the wasm from elsewhere. It has no URL parameter, since a link could then run any wasm in the page's origin.
51
+
38
52
  `html` is still exported as a raw string, but is **deprecated**: its formatting is not part of
39
53
  this package's API and changes between releases, so pattern-matching it is unsupported. `css`
40
54
  and `js` remain exported for serving (or writing) the stylesheet and bundle alongside a
@@ -72,7 +86,7 @@ scene is visible. It returns:
72
86
  | `events` | Fires `<key>:changed` with `(value, previous)` for every key of `state` |
73
87
  | `annotations` | Annotation data in settings order, available as soon as creation resolves. Editing entries is unsupported |
74
88
  | `captureFrame(options?)` | Renders offscreen, supersampled, and resolves to `{ width, height, data }` with `data` base64. Waits for the first frame |
75
- | `seek(time)` | Selects the animation camera and seeks in seconds, preserving pause state. Requires a loaded viewer with an animation; throws for non-finite time or after destruction. Requests rendering without waiting for a frame |
89
+ | `seek(time)` | Selects the animation camera and seeks in seconds, preserving pause state; for an animated splat sequence, seeks the sequence and leaves the camera alone. Requires a loaded viewer with an animation; throws for non-finite time or after destruction. Requests rendering without waiting for a frame |
76
90
  | `frameScene()` | Frames the whole scene, in orbit mode; requires `state.loaded` |
77
91
  | `resetCamera()` | Restores the fly/walk entry spawn, or the authored initial view in orbit mode; requires `state.loaded` |
78
92
  | `toggleWalk()` | Enters walk mode or restores the previous mode. Does nothing if `walkAllowed` is false; requires `state.loaded` |
@@ -123,7 +137,9 @@ const play = () => {
123
137
  };
124
138
  ```
125
139
 
126
- `animationTime`, `animationDuration` and `hasAnimation` are read-only observations. Seeking wraps repeat tracks and clamps once and ping-pong tracks to their duration. It preserves pause state; pause first to stop at the requested time. Hosts can pause from `animationTime:changed` to respond to a playback threshold, at the viewer's update cadence.
140
+ An animated splat sequence (a `.gsaf` content url) is the timeline instead: `hasSequence` is true, `hasAnimation`, `animationDuration`, `animationTime`, `animationPaused` and `seek()` describe the sequence's frames, which play in every camera mode, and the camera has no animation of its own, so setting `cameraMode` to `'anim'` is undone. A sequence loops. On WebGL it shows its first frame only and has no timeline.
141
+
142
+ `animationTime`, `animationDuration`, `hasAnimation` and `hasSequence` are read-only observations. Seeking wraps repeat tracks and clamps once and ping-pong tracks to their duration. It preserves pause state; pause first to stop at the requested time. Hosts can pause from `animationTime:changed` to respond to a playback threshold, at the viewer's update cadence.
127
143
 
128
144
  Dragging the built-in timeline pauses playback. Releasing or cancelling the drag does not restore an earlier pause flag, so it cannot undo a host command issued during scrubbing. Use Play to resume. The standalone `window.scrubTo` hook retains its pause-and-wait-for-frame behavior; `seek()` itself is synchronous.
129
145
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@playcanvas/supersplat-viewer",
3
- "version": "1.40.0",
3
+ "version": "1.41.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",
@@ -27,6 +27,10 @@
27
27
  "import": "./dist/viewer.js"
28
28
  },
29
29
  "./viewer.css": "./dist/viewer.css",
30
+ "./gsaf-decoder": {
31
+ "types": "./dist/gsaf-decoder.d.ts",
32
+ "import": "./dist/gsaf-decoder.js"
33
+ },
30
34
  "./settings": {
31
35
  "types": "./dist/settings.d.ts",
32
36
  "import": "./dist/settings.js"
@@ -45,8 +49,10 @@
45
49
  "public/index.css",
46
50
  "public/index.js",
47
51
  "public/index.js.map",
52
+ "public/gsaf-decoder.wasm",
48
53
  "docs/api.md",
49
54
  "LICENSE",
55
+ "THIRD_PARTY_NOTICES.md",
50
56
  "package.json",
51
57
  "README.md"
52
58
  ],
Binary file
package/public/index.html CHANGED
@@ -55,6 +55,8 @@
55
55
  url.searchParams.get('collision') ?? url.searchParams.get('voxel') ?? bootstrap.collisionUrl ?? null;
56
56
  const settingsUrl = url.searchParams.get('settings') ?? bootstrap.settingsUrl ?? './settings.json';
57
57
  const contentUrl = url.searchParams.get('content') ?? bootstrap.contentUrl ?? './scene.compressed.ply';
58
+ // the bootstrap's alone: a url param would let a link run any wasm in this origin
59
+ const gsafDecoderUrl = bootstrap.gsafDecoderUrl ?? null;
58
60
 
59
61
  // Names the bootstrap's contentUrl when the url itself has no usable name (a data:
60
62
  // uri, say) — the splat format is chosen by the name's extension. Ignored when a
@@ -87,6 +89,7 @@
87
89
  posterUrl,
88
90
  skyboxUrl,
89
91
  collisionUrl,
92
+ gsafDecoderUrl,
90
93
  poster: posterUrl && createImage(posterUrl),
91
94
  contents: prefetchContent ? fetch(contentUrl) : undefined,
92
95
  ui: !url.searchParams.has('noui'),