@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/public/index.html CHANGED
@@ -64,10 +64,18 @@
64
64
  // ?content= override replaces the url it describes.
65
65
  const contentFilename = url.searchParams.has('content') ? null : (bootstrap.contentFilename ?? null);
66
66
 
67
- const renderer = url.searchParams.has('webgl') ? 'webgl' : 'webgpu';
67
+ // Flags: a url param wins, then the bootstrap's flags (the embedder's defaults for this
68
+ // document), then createViewer's own default. A switch param such as `?noanim` can only
69
+ // turn its flag on; `hpr` and `aa` take a value, so they can turn it either way
70
+ const flags = bootstrap.flags ?? {};
71
+ const param = (name) => url.searchParams.get(name);
72
+ const has = (name) => url.searchParams.has(name);
73
+ const enabled = (name) => ['', '1', 'true', 'enable'].includes(param(name));
74
+ const flag = (name) => (has(name) ? true : flags[name]);
68
75
 
69
- const budgetParam = url.searchParams.get('budget');
70
- const budget = budgetParam !== null ? Number(budgetParam) : undefined;
76
+ const renderer = has('webgl') ? 'webgl' : (flags.renderer ?? 'webgpu');
77
+
78
+ const budget = has('budget') ? Number(param('budget')) : flags.budget;
71
79
 
72
80
  // The engine's octree and lcc2 parsers fetch lod-meta.json and .lcc2 files themselves
73
81
  // and ignore a prefetched response, so starting one here would download the metadata
@@ -94,35 +102,31 @@
94
102
  zstdDecoderUrl,
95
103
  poster: posterUrl && createImage(posterUrl),
96
104
  contents: prefetchContent ? fetch(contentUrl) : undefined,
97
- ui: !url.searchParams.has('noui'),
98
- reticle: url.searchParams.has('reticle'),
99
- noanim: url.searchParams.has('noanim'),
100
- nofx: url.searchParams.has('nofx'),
101
- hpr: url.searchParams.has('hpr')
102
- ? ['', '1', 'true', 'enable'].includes(url.searchParams.get('hpr'))
103
- : undefined,
104
- ministats: url.searchParams.has('ministats'),
105
- colorize: url.searchParams.has('colorize'),
105
+ ui: has('noui') ? false : flags.ui,
106
+ reticle: flag('reticle'),
107
+ noanim: flag('noanim'),
108
+ nofx: flag('nofx'),
109
+ hpr: has('hpr') ? enabled('hpr') : flags.hpr,
110
+ ministats: flag('ministats'),
111
+ colorize: flag('colorize'),
106
112
  renderer,
107
- aa: url.searchParams.has('aa')
108
- ? ['', '1', 'true', 'enable'].includes(url.searchParams.get('aa'))
109
- : undefined,
110
- stochastic: url.searchParams.has('stochastic')
111
- ? url.searchParams.get('stochastic') === 'mobile'
113
+ aa: has('aa') ? enabled('aa') : flags.aa,
114
+ stochastic: has('stochastic')
115
+ ? param('stochastic') === 'mobile'
112
116
  ? 'mobile'
113
- : url.searchParams.get('stochastic') === 'off'
117
+ : param('stochastic') === 'off'
114
118
  ? 'off'
115
119
  : true
116
- : false,
117
- splatSource: url.searchParams.get('splatSource') ?? undefined,
118
- variant: url.searchParams.get('variant') ?? undefined,
120
+ : flags.stochastic,
121
+ splatSource: param('splatSource') ?? flags.splatSource,
122
+ variant: param('variant') ?? flags.variant,
119
123
  budget,
120
- framesInFlight: url.searchParams.has('fif') ? Number(url.searchParams.get('fif')) : undefined,
121
- heatmap: url.searchParams.has('heatmap'),
122
- fullload: url.searchParams.has('fullload'),
123
- vr: url.searchParams.has('vr'),
124
- debug: url.searchParams.has('debug'),
125
- lang: url.searchParams.get('lang'),
124
+ framesInFlight: has('fif') ? Number(param('fif')) : flags.framesInFlight,
125
+ heatmap: flag('heatmap'),
126
+ fullload: flag('fullload'),
127
+ vr: flag('vr'),
128
+ debug: flag('debug'),
129
+ lang: param('lang') ?? flags.lang,
126
130
  // the standalone document is the one place the window.* hooks belong
127
131
  exposeGlobals: true
128
132
  };