@playcanvas/supersplat-viewer 1.40.0 → 1.42.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/THIRD_PARTY_NOTICES.md +436 -0
- package/dist/gsaf-decoder.d.ts +4 -0
- package/dist/gsaf-decoder.js +10 -0
- package/dist/gsaf-decoder.wasm +0 -0
- package/dist/index.d.ts +6 -88
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/viewer.css +7 -34
- package/dist/viewer.d.ts +19 -11
- package/dist/viewer.js +4218 -1832
- package/dist/viewer.js.map +1 -1
- package/docs/api.md +18 -2
- package/package.json +8 -3
- package/public/gsaf-decoder.wasm +0 -0
- package/public/index.css +7 -34
- package/public/index.html +3 -7
- package/public/index.js +3609 -1941
- package/public/index.js.map +1 -1
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
|
-
`
|
|
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.
|
|
3
|
+
"version": "1.42.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
|
],
|
|
@@ -59,14 +65,13 @@
|
|
|
59
65
|
}
|
|
60
66
|
},
|
|
61
67
|
"devDependencies": {
|
|
62
|
-
"@playcanvas/eslint-config": "3.0.0
|
|
68
|
+
"@playcanvas/eslint-config": "3.0.0",
|
|
63
69
|
"@rollup/plugin-json": "6.1.0",
|
|
64
70
|
"@rollup/plugin-node-resolve": "16.0.3",
|
|
65
71
|
"@rollup/plugin-typescript": "12.3.0",
|
|
66
72
|
"autoprefixer": "10.6.1",
|
|
67
73
|
"concurrently": "9.2.5",
|
|
68
74
|
"eslint": "9.39.5",
|
|
69
|
-
"globals": "17.13.0",
|
|
70
75
|
"playcanvas": "2.23.3",
|
|
71
76
|
"postcss": "8.5.31",
|
|
72
77
|
"prettier": "3.9.10",
|
|
Binary file
|
package/public/index.css
CHANGED
|
@@ -11,14 +11,6 @@
|
|
|
11
11
|
--sse-bkg-darkest: #141414;
|
|
12
12
|
--sse-bkg-light: #444;
|
|
13
13
|
--canvas-opacity: 1;
|
|
14
|
-
--sse-lift: 0px;
|
|
15
|
-
}
|
|
16
|
-
@media (pointer: coarse) {
|
|
17
|
-
.sse-viewer {
|
|
18
|
-
--sse-lift: var(--sse-experimental-touch-inset-bottom, 0px);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
.sse-viewer {
|
|
22
14
|
position: relative;
|
|
23
15
|
width: 100%;
|
|
24
16
|
height: 100%;
|
|
@@ -138,19 +130,10 @@
|
|
|
138
130
|
.sse-viewer .sse-controlsHint {
|
|
139
131
|
position: absolute;
|
|
140
132
|
right: max(16px, env(safe-area-inset-right));
|
|
141
|
-
bottom: calc(max(16px, env(safe-area-inset-bottom)) + 70px
|
|
142
|
-
max-height: calc(100% - 16px - calc(max(16px, env(safe-area-inset-bottom)) + 70px + var(--sse-lift)));
|
|
143
|
-
box-sizing: border-box;
|
|
144
|
-
overflow-y: auto;
|
|
145
|
-
overscroll-behavior: contain;
|
|
146
|
-
}
|
|
147
|
-
.sse-viewer .sse-controlsHint,
|
|
148
|
-
.sse-viewer .sse-controlsHint * {
|
|
149
|
-
touch-action: pan-y;
|
|
150
|
-
}
|
|
151
|
-
.sse-viewer .sse-controlsHint {
|
|
133
|
+
bottom: calc(max(16px, env(safe-area-inset-bottom)) + 70px);
|
|
152
134
|
min-width: 200px;
|
|
153
135
|
max-width: calc(100% - 32px);
|
|
136
|
+
box-sizing: border-box;
|
|
154
137
|
padding: 8px 8px 8px 12px;
|
|
155
138
|
border-radius: 16px;
|
|
156
139
|
border: 1px solid rgba(255, 255, 255, 0.08);
|
|
@@ -324,7 +307,7 @@
|
|
|
324
307
|
}
|
|
325
308
|
.sse-viewer .sse-loadingWrap {
|
|
326
309
|
position: absolute;
|
|
327
|
-
bottom:
|
|
310
|
+
bottom: 120px;
|
|
328
311
|
left: 50%;
|
|
329
312
|
transform: translate(-50%, 0);
|
|
330
313
|
width: min(380px, 100% - 32px);
|
|
@@ -352,7 +335,7 @@
|
|
|
352
335
|
position: absolute;
|
|
353
336
|
left: max(16px, env(safe-area-inset-left));
|
|
354
337
|
right: max(16px, env(safe-area-inset-right));
|
|
355
|
-
bottom:
|
|
338
|
+
bottom: max(16px, env(safe-area-inset-bottom));
|
|
356
339
|
display: flex;
|
|
357
340
|
flex-direction: column;
|
|
358
341
|
}
|
|
@@ -484,17 +467,7 @@
|
|
|
484
467
|
.sse-viewer .sse-settingsPanel {
|
|
485
468
|
position: absolute;
|
|
486
469
|
right: max(16px, env(safe-area-inset-right));
|
|
487
|
-
bottom: calc(max(16px, env(safe-area-inset-bottom)) + 70px
|
|
488
|
-
max-height: calc(100% - 16px - calc(max(16px, env(safe-area-inset-bottom)) + 70px + var(--sse-lift)));
|
|
489
|
-
box-sizing: border-box;
|
|
490
|
-
overflow-y: auto;
|
|
491
|
-
overscroll-behavior: contain;
|
|
492
|
-
}
|
|
493
|
-
.sse-viewer .sse-settingsPanel,
|
|
494
|
-
.sse-viewer .sse-settingsPanel * {
|
|
495
|
-
touch-action: pan-y;
|
|
496
|
-
}
|
|
497
|
-
.sse-viewer .sse-settingsPanel {
|
|
470
|
+
bottom: calc(max(16px, env(safe-area-inset-bottom)) + 70px);
|
|
498
471
|
padding: 12px;
|
|
499
472
|
border-radius: 16px;
|
|
500
473
|
border: 1px solid rgba(255, 255, 255, 0.08);
|
|
@@ -790,7 +763,7 @@
|
|
|
790
763
|
.sse-viewer .sse-joystickBase {
|
|
791
764
|
position: absolute;
|
|
792
765
|
left: 70px;
|
|
793
|
-
bottom:
|
|
766
|
+
bottom: 140px;
|
|
794
767
|
width: 56px;
|
|
795
768
|
height: 100px;
|
|
796
769
|
transform: translate(-50%, 50%);
|
|
@@ -942,7 +915,7 @@
|
|
|
942
915
|
.sse-viewer .sse-xrHint {
|
|
943
916
|
position: absolute;
|
|
944
917
|
left: 50%;
|
|
945
|
-
bottom:
|
|
918
|
+
bottom: 96px;
|
|
946
919
|
transform: translateX(-50%);
|
|
947
920
|
padding: 12px 20px;
|
|
948
921
|
border-radius: 20px;
|
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
|
|
@@ -63,12 +65,6 @@
|
|
|
63
65
|
|
|
64
66
|
const renderer = url.searchParams.has('webgl') ? 'webgl' : 'webgpu';
|
|
65
67
|
|
|
66
|
-
// css pixels to lift the toolbar by on touch devices; createViewer clamps it, and treats
|
|
67
|
-
// a value that is not a number as 0
|
|
68
|
-
const experimentalTouchInsetBottom = url.searchParams.has('experimental-touch-inset-bottom')
|
|
69
|
-
? Number(url.searchParams.get('experimental-touch-inset-bottom'))
|
|
70
|
-
: undefined;
|
|
71
|
-
|
|
72
68
|
const budgetParam = url.searchParams.get('budget');
|
|
73
69
|
const budget = budgetParam !== null ? Number(budgetParam) : undefined;
|
|
74
70
|
|
|
@@ -87,10 +83,10 @@
|
|
|
87
83
|
posterUrl,
|
|
88
84
|
skyboxUrl,
|
|
89
85
|
collisionUrl,
|
|
86
|
+
gsafDecoderUrl,
|
|
90
87
|
poster: posterUrl && createImage(posterUrl),
|
|
91
88
|
contents: prefetchContent ? fetch(contentUrl) : undefined,
|
|
92
89
|
ui: !url.searchParams.has('noui'),
|
|
93
|
-
experimentalTouchInsetBottom,
|
|
94
90
|
reticle: url.searchParams.has('reticle'),
|
|
95
91
|
noanim: url.searchParams.has('noanim'),
|
|
96
92
|
nofx: url.searchParams.has('nofx'),
|