@playcanvas/supersplat-viewer 1.31.2 → 1.33.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/README.md +3 -171
- package/dist/index.d.ts +28 -18
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/viewer.css +761 -0
- package/dist/viewer.d.ts +274 -0
- package/dist/viewer.js +11471 -0
- package/dist/viewer.js.map +1 -0
- package/docs/api.md +356 -0
- package/package.json +20 -6
- package/public/index.css +221 -211
- package/public/index.html +40 -618
- package/public/index.js +2697 -1610
- package/public/index.js.map +1 -1
package/README.md
CHANGED
|
@@ -33,7 +33,8 @@ The app supports a number of URL parameters (these are subject to change):
|
|
|
33
33
|
|
|
34
34
|
| Parameter | Description |
|
|
35
35
|
| --------- | ----------- |
|
|
36
|
-
| `noui` | Hide the UI overlay |
|
|
36
|
+
| `noui` | Hide the UI overlay (the programmatic form is `ui: false`, which skips building it) |
|
|
37
|
+
| `reticle` | Show the centre reticle in captured desktop fly/walk mode (off by default; programmatic form: `reticle: true`) |
|
|
37
38
|
| `noanim` | Start with animation paused |
|
|
38
39
|
| `ministats` | Show runtime CPU/GPU performance graphs |
|
|
39
40
|
| `lang` | Override the UI language (`de`, `en`, `es`, `fr`, `ja`, `ko`, `pt-BR`, `ru`, `zh-CN`; default: detect from browser) |
|
|
@@ -56,79 +57,7 @@ By default the viewer uses WebGPU when available (falling back automatically whe
|
|
|
56
57
|
|
|
57
58
|
## NPM Package
|
|
58
59
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
If you generate a page around the viewer, use `renderViewerHtml`. It returns a complete
|
|
62
|
-
document, with your asset URLs and settings supplied through a single JSON block:
|
|
63
|
-
|
|
64
|
-
```ts
|
|
65
|
-
import { renderViewerHtml } from '@playcanvas/supersplat-viewer';
|
|
66
|
-
|
|
67
|
-
const document = renderViewerHtml({
|
|
68
|
-
bootstrap: {
|
|
69
|
-
settings, // an object, or omit and set settingsUrl
|
|
70
|
-
contentUrl: 'scene.sog',
|
|
71
|
-
posterUrl: 'poster.jpg'
|
|
72
|
-
},
|
|
73
|
-
baseHref: '/viewer/', // serving from a sub-path
|
|
74
|
-
backgroundColor: [0, 0, 0], // components are 0..1, not 0..255
|
|
75
|
-
headExtras: '<script src="analytics.js"></script>',
|
|
76
|
-
inlineCss: true // no sibling index.css needed
|
|
77
|
-
});
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
Called with no options it returns the document the package ships, unmodified. URL parameters
|
|
81
|
-
on the served page override the bootstrap's asset URLs, so an embed stays overridable per
|
|
82
|
-
instance — except an inline `settings` object, which takes precedence over `?settings=`.
|
|
83
|
-
|
|
84
|
-
Set both `inlineCss` and `inlineJs` for a single self-contained file, with the splat passed as
|
|
85
|
-
a `data:` URI in `contentUrl` and the settings supplied inline through the bootstrap's
|
|
86
|
-
`settings` object — without an inline settings object the page still fetches `./settings.json`
|
|
87
|
-
from a sibling file. A `data:` URI has no filename and the splat format is chosen by the
|
|
88
|
-
name's extension, so name its content with the bootstrap's `contentFilename` (e.g.
|
|
89
|
-
`scene.sog`). The flags are independent, so a server that serves the bundle from its own
|
|
90
|
-
route can inline only the stylesheet.
|
|
91
|
-
|
|
92
|
-
`html` is still exported as a raw string, but is **deprecated**: its formatting is not part of
|
|
93
|
-
this package's API and changes between releases, so pattern-matching it is unsupported. `css`
|
|
94
|
-
and `js` remain exported for serving (or writing) the stylesheet and bundle alongside a
|
|
95
|
-
rendered document that doesn't inline them.
|
|
96
|
-
|
|
97
|
-
### Settings
|
|
98
|
-
|
|
99
|
-
The `/settings` subpath exports the schema types plus helpers for generating, validating and
|
|
100
|
-
migrating a `settings.json` file:
|
|
101
|
-
|
|
102
|
-
```ts
|
|
103
|
-
import {
|
|
104
|
-
defaultSettings,
|
|
105
|
-
importSettings,
|
|
106
|
-
validateSettings,
|
|
107
|
-
POST_EFFECT_RANGES,
|
|
108
|
-
type ExperienceSettings
|
|
109
|
-
} from '@playcanvas/supersplat-viewer/settings';
|
|
110
|
-
|
|
111
|
-
// a complete settings object every tool agrees on; pass 'object' to frame a subject
|
|
112
|
-
// from outside rather than a captured space from within
|
|
113
|
-
const settings: ExperienceSettings = defaultSettings();
|
|
114
|
-
|
|
115
|
-
// throws on invalid input, naming the offending field
|
|
116
|
-
validateSettings(json);
|
|
117
|
-
|
|
118
|
-
// additionally check the authoring bounds — stricter than what the viewer will render,
|
|
119
|
-
// so existing files may fail. Producers writing new settings should enable it
|
|
120
|
-
validateSettings(json, { limits: true });
|
|
121
|
-
|
|
122
|
-
// migrates older versions forward; does not mutate its argument
|
|
123
|
-
const migrated = importSettings(json);
|
|
124
|
-
|
|
125
|
-
// the bounds are data, so an editor UI can drive a slider from the same numbers
|
|
126
|
-
const { min, max, step } = POST_EFFECT_RANGES.bloom.intensity;
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
`CAMERA_FOV_RANGE`, `POST_EFFECT_RANGES`, `ANIM_TRACK_LIMITS` and `ANNOTATION_LIMITS` are
|
|
130
|
-
exported as data, so an editor UI can drive sliders from the same bounds the validator uses.
|
|
131
|
-
They are frozen at runtime.
|
|
60
|
+
See the [API reference](docs/api.md) for embedding, runtime control, UI customization and settings.
|
|
132
61
|
|
|
133
62
|
## Local Development
|
|
134
63
|
|
|
@@ -164,100 +93,3 @@ ENGINE=debug npm run develop
|
|
|
164
93
|
```
|
|
165
94
|
|
|
166
95
|
This also works with `npm run build` and `npm run watch`.
|
|
167
|
-
|
|
168
|
-
## Settings Schema
|
|
169
|
-
|
|
170
|
-
The `settings.json` file uses the schema below (defined in TypeScript and exported from `@playcanvas/supersplat-viewer/settings`). Legacy v1 settings produced by older SuperSplat releases are automatically migrated to v2 on load.
|
|
171
|
-
|
|
172
|
-
```typescript
|
|
173
|
-
type AnimTrack = {
|
|
174
|
-
name: string,
|
|
175
|
-
duration: number,
|
|
176
|
-
frameRate: number,
|
|
177
|
-
loopMode: 'none' | 'repeat' | 'pingpong',
|
|
178
|
-
interpolation: 'step' | 'spline',
|
|
179
|
-
smoothness: number,
|
|
180
|
-
keyframes: {
|
|
181
|
-
times: number[],
|
|
182
|
-
values: {
|
|
183
|
-
position: number[],
|
|
184
|
-
target: number[],
|
|
185
|
-
fov: number[],
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
type CameraPose = {
|
|
191
|
-
position: [number, number, number],
|
|
192
|
-
target: [number, number, number],
|
|
193
|
-
fov: number
|
|
194
|
-
};
|
|
195
|
-
|
|
196
|
-
type Camera = {
|
|
197
|
-
initial: CameraPose
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
type Annotation = {
|
|
201
|
-
position: [number, number, number],
|
|
202
|
-
title: string,
|
|
203
|
-
text: string,
|
|
204
|
-
extras?: any,
|
|
205
|
-
camera: Camera
|
|
206
|
-
};
|
|
207
|
-
|
|
208
|
-
type PostEffectSettings = {
|
|
209
|
-
sharpness: { enabled: boolean, amount: number },
|
|
210
|
-
bloom: { enabled: boolean, intensity: number, blurLevel: number },
|
|
211
|
-
grading: { enabled: boolean, brightness: number, contrast: number, saturation: number, tint: [number, number, number] },
|
|
212
|
-
vignette: { enabled: boolean, intensity: number, inner: number, outer: number, curvature: number },
|
|
213
|
-
fringing: { enabled: boolean, intensity: number }
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
type ExperienceSettings = {
|
|
217
|
-
version: 2,
|
|
218
|
-
tonemapping: 'none' | 'linear' | 'filmic' | 'hejl' | 'aces' | 'aces2' | 'neutral',
|
|
219
|
-
highPrecisionRendering: boolean,
|
|
220
|
-
soundUrl?: string,
|
|
221
|
-
background: {
|
|
222
|
-
color: [number, number, number],
|
|
223
|
-
skyboxUrl?: string
|
|
224
|
-
},
|
|
225
|
-
postEffectSettings: PostEffectSettings,
|
|
226
|
-
animTracks: AnimTrack[],
|
|
227
|
-
cameras: Camera[],
|
|
228
|
-
annotations: Annotation[],
|
|
229
|
-
startMode: 'default' | 'animTrack' | 'annotation'
|
|
230
|
-
};
|
|
231
|
-
```
|
|
232
|
-
|
|
233
|
-
### Example settings.json
|
|
234
|
-
|
|
235
|
-
```json
|
|
236
|
-
{
|
|
237
|
-
"version": 2,
|
|
238
|
-
"tonemapping": "none",
|
|
239
|
-
"highPrecisionRendering": false,
|
|
240
|
-
"background": {
|
|
241
|
-
"color": [0, 0, 0]
|
|
242
|
-
},
|
|
243
|
-
"postEffectSettings": {
|
|
244
|
-
"sharpness": { "enabled": false, "amount": 0 },
|
|
245
|
-
"bloom": { "enabled": false, "intensity": 0.1, "blurLevel": 2 },
|
|
246
|
-
"grading": { "enabled": false, "brightness": 1, "contrast": 1, "saturation": 1, "tint": [1, 1, 1] },
|
|
247
|
-
"vignette": { "enabled": false, "intensity": 0.5, "inner": 0.3, "outer": 0.75, "curvature": 1 },
|
|
248
|
-
"fringing": { "enabled": false, "intensity": 0.5 }
|
|
249
|
-
},
|
|
250
|
-
"animTracks": [],
|
|
251
|
-
"cameras": [
|
|
252
|
-
{
|
|
253
|
-
"initial": {
|
|
254
|
-
"position": [0, 1, -1],
|
|
255
|
-
"target": [0, 0, 0],
|
|
256
|
-
"fov": 60
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
],
|
|
260
|
-
"annotations": [],
|
|
261
|
-
"startMode": "default"
|
|
262
|
-
}
|
|
263
|
-
```
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,36 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Asset urls
|
|
2
|
+
* Asset urls an embedder supplies. Shared by the two ways of instantiating the viewer — as
|
|
3
|
+
* fields of {@link CreateViewerOptions} in a page, and serialised into a generated document by
|
|
4
|
+
* `renderViewerHtml` — so the two surfaces cannot drift.
|
|
5
|
+
*/
|
|
6
|
+
type ViewerAssets = {
|
|
7
|
+
/** Splat url. May be a `data:` uri, for a document with no sibling files. */
|
|
8
|
+
contentUrl: string;
|
|
9
|
+
/**
|
|
10
|
+
* Filename describing {@link ViewerAssets.contentUrl}, e.g. `scene.sog`. The splat format
|
|
11
|
+
* is chosen by the name's extension, so this is required when the url itself has no usable
|
|
12
|
+
* name — a `data:` uri.
|
|
13
|
+
*/
|
|
14
|
+
contentFilename?: string;
|
|
15
|
+
/** Poster image shown, blurred, while the splat loads. */
|
|
16
|
+
posterUrl?: string;
|
|
17
|
+
/** Equirectangular skybox texture url. */
|
|
18
|
+
skyboxUrl?: string;
|
|
19
|
+
/** Collision data url, for walk mode. A `.glb` is treated as a mesh, otherwise voxels. */
|
|
20
|
+
collisionUrl?: string;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Asset urls and settings the embedder supplies to the viewer. The asset urls are the same
|
|
25
|
+
* fields `createViewer` takes in a page ({@link ViewerAssets}); here every one is optional,
|
|
26
|
+
* because the document has a default for each.
|
|
3
27
|
*
|
|
4
28
|
* Url params on the served page take precedence over every url here, so an embed stays
|
|
5
29
|
* overridable per instance. Inline {@link ViewerBootstrap.settings} is the exception: it wins
|
|
6
30
|
* over `?settings=`, so a published experience cannot be repointed at another settings file.
|
|
31
|
+
* `contentFilename` is ignored when a `?content=` param overrides the url it describes.
|
|
7
32
|
*/
|
|
8
|
-
type ViewerBootstrap = {
|
|
33
|
+
type ViewerBootstrap = Partial<ViewerAssets> & {
|
|
9
34
|
/**
|
|
10
35
|
* Experience settings as an object, avoiding a round trip. When omitted the viewer
|
|
11
36
|
* fetches {@link ViewerBootstrap.settingsUrl}.
|
|
@@ -13,21 +38,6 @@ type ViewerBootstrap = {
|
|
|
13
38
|
settings?: unknown;
|
|
14
39
|
/** Where to fetch settings from. Defaults to `./settings.json`. */
|
|
15
40
|
settingsUrl?: string;
|
|
16
|
-
/** Splat url. May be a `data:` uri, for a document with no sibling files. */
|
|
17
|
-
contentUrl?: string;
|
|
18
|
-
/**
|
|
19
|
-
* Filename describing {@link ViewerBootstrap.contentUrl}, e.g. `scene.sog`. The splat
|
|
20
|
-
* format is chosen by the name's extension, so this is required when the url itself has
|
|
21
|
-
* no usable name — a `data:` uri. Ignored when a `?content=` url param overrides the url
|
|
22
|
-
* it describes.
|
|
23
|
-
*/
|
|
24
|
-
contentFilename?: string;
|
|
25
|
-
/** Poster image shown, blurred, while the splat loads. */
|
|
26
|
-
posterUrl?: string;
|
|
27
|
-
/** Equirectangular skybox texture url. */
|
|
28
|
-
skyboxUrl?: string;
|
|
29
|
-
/** Collision data url, for walk mode. A `.glb` is treated as a mesh, otherwise voxels. */
|
|
30
|
-
collisionUrl?: string;
|
|
31
41
|
};
|
|
32
42
|
/** Options for {@link renderViewerHtml}. */
|
|
33
43
|
type RenderViewerHtmlOptions = {
|
|
@@ -83,4 +93,4 @@ declare const css: string;
|
|
|
83
93
|
declare const js: string;
|
|
84
94
|
|
|
85
95
|
export { css, html, js, renderViewerHtml };
|
|
86
|
-
export type { RenderViewerHtmlOptions, ViewerBootstrap };
|
|
96
|
+
export type { RenderViewerHtmlOptions, ViewerAssets, ViewerBootstrap };
|