@playcanvas/supersplat-viewer 1.27.0 → 1.27.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@playcanvas/supersplat-viewer",
3
- "version": "1.27.0",
3
+ "version": "1.27.1",
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",
@@ -45,13 +45,13 @@
45
45
  "@rollup/plugin-json": "6.1.0",
46
46
  "@rollup/plugin-node-resolve": "16.0.3",
47
47
  "@rollup/plugin-typescript": "12.3.0",
48
- "@typescript-eslint/eslint-plugin": "8.62.1",
49
- "@typescript-eslint/parser": "8.62.1",
48
+ "@typescript-eslint/eslint-plugin": "8.63.0",
49
+ "@typescript-eslint/parser": "8.63.0",
50
50
  "autoprefixer": "10.5.2",
51
51
  "concurrently": "9.2.3",
52
52
  "eslint": "9.39.4",
53
53
  "globals": "17.7.0",
54
- "playcanvas": "2.20.4",
54
+ "playcanvas": "2.20.6",
55
55
  "postcss": "8.5.16",
56
56
  "publint": "0.3.21",
57
57
  "rollup": "4.62.2",
package/public/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  const TRACEID_GPU_TIMINGS = "GpuTimings";
2
2
 
3
- const version$1 = "2.20.4";
4
- const revision = "0756c51";
3
+ const version$1 = "2.20.6";
4
+ const revision = "9a2a8ef";
5
5
  function extend(target, ex) {
6
6
  for (const prop in ex) {
7
7
  const copy = ex[prop];
@@ -6209,13 +6209,13 @@ class GraphicsDevice extends EventHandler {
6209
6209
  this.updateClientRect();
6210
6210
  }
6211
6211
  updateClientRect() {
6212
- if (platform.worker) {
6213
- this.clientRect.width = this.canvas.width;
6214
- this.clientRect.height = this.canvas.height;
6215
- } else {
6212
+ if (typeof this.canvas.getBoundingClientRect === "function") {
6216
6213
  const rect = this.canvas.getBoundingClientRect();
6217
6214
  this.clientRect.width = rect.width;
6218
6215
  this.clientRect.height = rect.height;
6216
+ } else {
6217
+ this.clientRect.width = this.canvas.width ?? 0;
6218
+ this.clientRect.height = this.canvas.height ?? 0;
6219
6219
  }
6220
6220
  }
6221
6221
  get width() {
@@ -18406,8 +18406,8 @@ class Mesh extends RefCountedObject {
18406
18406
  this._geometryData.recreate = true;
18407
18407
  this._geometryData.maxVertices = maxVertices;
18408
18408
  this._geometryData.maxIndices = maxIndices;
18409
- this._geometryData.verticesUsage = verticesDynamic ? BUFFER_STATIC : BUFFER_DYNAMIC;
18410
- this._geometryData.indicesUsage = indicesDynamic ? BUFFER_STATIC : BUFFER_DYNAMIC;
18409
+ this._geometryData.verticesUsage = verticesDynamic ? BUFFER_DYNAMIC : BUFFER_STATIC;
18410
+ this._geometryData.indicesUsage = indicesDynamic ? BUFFER_DYNAMIC : BUFFER_STATIC;
18411
18411
  }
18412
18412
  setVertexStream(semantic, data, componentCount, numVertices, dataType = TYPE_FLOAT32, dataTypeNormalize = false, asInt = false) {
18413
18413
  this._initGeometryData();
@@ -57972,6 +57972,9 @@ class GSplatOctree {
57972
57972
  }
57973
57973
  }
57974
57974
  ensureFileResource(fileIndex) {
57975
+ if (!this.assetLoader) {
57976
+ return;
57977
+ }
57975
57978
  if (this.fileResources.has(fileIndex)) {
57976
57979
  return;
57977
57980
  }
@@ -58569,6 +58572,14 @@ class GSplatWorld {
58569
58572
  result.newVersion = false;
58570
58573
  result.overdrawDirty = false;
58571
58574
  result.sortNeeded = false;
58575
+ for (const [placement, inst] of this._octreeInstances) {
58576
+ if (inst.octree.destroyed || !placement.resource) {
58577
+ this._octreeInstances.delete(placement);
58578
+ this._layerPlacementsDirty = true;
58579
+ this._placementSetChanged = true;
58580
+ this._octreeInstancesToDestroy.push(inst);
58581
+ }
58582
+ }
58572
58583
  if (--this._framesTillFullUpdate <= 0) {
58573
58584
  this._framesTillFullUpdate = 10;
58574
58585
  this._lodUpdateRequested = true;
@@ -61100,6 +61111,9 @@ class GSplatHybridRenderer extends GSplatRenderer {
61100
61111
  ic.sortElementCountBuffer,
61101
61112
  sortIndirectInfo
61102
61113
  );
61114
+ if (pickMode) {
61115
+ this.device.submit();
61116
+ }
61103
61117
  return gpuSorter.sortIndirect(
61104
61118
  projector.sortKeys,
61105
61119
  elementCount,
@@ -68929,11 +68943,16 @@ class SogParser {
68929
68943
  });
68930
68944
  const textureAssets = subs.map((sub) => textures[sub]).flat();
68931
68945
  let unloaded = false;
68946
+ let ownedByResource = false;
68932
68947
  asset.once("unload", () => {
68933
68948
  unloaded = true;
68934
68949
  textureAssets.forEach((t) => {
68935
68950
  assets.remove(t);
68936
- t.unload();
68951
+ if (!ownedByResource) {
68952
+ t.unload();
68953
+ } else {
68954
+ assets._loader.clearCache(t.getFileUrl(), t.type);
68955
+ }
68937
68956
  });
68938
68957
  });
68939
68958
  combineProgress(asset, textureAssets);
@@ -68978,6 +68997,7 @@ class SogParser {
68978
68997
  }
68979
68998
  const prepareCenters = gsplatCentersEnabledAtLoad;
68980
68999
  const resource = decompress ? new GSplatResource(this.app.graphicsDevice, await data.decompress(), { prepareCenters }) : new GSplatSogResource(this.app.graphicsDevice, data, { prepareCenters });
69000
+ ownedByResource = !decompress;
68981
69001
  if (this._shouldAbort(asset, unloaded)) {
68982
69002
  resource.destroy();
68983
69003
  callback(null, null);
@@ -69124,10 +69144,34 @@ class SogBundleParser {
69124
69144
  this.app = app;
69125
69145
  this.maxRetries = maxRetries;
69126
69146
  }
69147
+ _shouldAbort(asset, unloaded) {
69148
+ if (unloaded || !this.app.assets.get(asset.id)) return true;
69149
+ if (!this.app?.graphicsDevice || this.app.graphicsDevice._destroyed) return true;
69150
+ return false;
69151
+ }
69127
69152
  async load(url, callback, asset) {
69128
69153
  const gsplatCentersEnabledAtLoad = this.app.scene?.gsplatCentersEnabled !== false;
69129
69154
  try {
69155
+ const { assets } = this.app;
69156
+ let unloaded = false;
69157
+ let ownedByResource = false;
69158
+ const textures = {};
69159
+ asset.once("unload", () => {
69160
+ unloaded = true;
69161
+ Object.values(textures).forEach((t) => {
69162
+ assets.remove(t);
69163
+ if (!ownedByResource) {
69164
+ t.unload();
69165
+ } else {
69166
+ assets._loader.clearCache(t.getFileUrl(), t.type);
69167
+ }
69168
+ });
69169
+ });
69130
69170
  const arrayBuffer = await downloadArrayBuffer(url, asset);
69171
+ if (this._shouldAbort(asset, unloaded)) {
69172
+ callback(null, null);
69173
+ return;
69174
+ }
69131
69175
  const files = parseZipArchive(arrayBuffer);
69132
69176
  for (const file of files) {
69133
69177
  if (file.compression === "deflate") {
@@ -69147,7 +69191,6 @@ class SogBundleParser {
69147
69191
  return;
69148
69192
  }
69149
69193
  const filenames = ["means", "scales", "quats", "sh0", "shN"].map((key) => meta[key]?.files ?? []).flat();
69150
- const textures = {};
69151
69194
  const promises = [];
69152
69195
  for (const filename of filenames) {
69153
69196
  const file = files.find((f) => f.filename === filename);
@@ -69183,17 +69226,18 @@ class SogBundleParser {
69183
69226
  }
69184
69227
  Object.values(textures).forEach((t) => this.app.assets.load(t));
69185
69228
  await Promise.allSettled(promises);
69186
- Object.values(textures).forEach((t) => {
69187
- if (t.file) {
69188
- t.file.contents = null;
69189
- }
69190
- });
69191
- const { assets } = this.app;
69192
- asset.once("unload", () => {
69229
+ if (this._shouldAbort(asset, unloaded)) {
69193
69230
  Object.values(textures).forEach((t) => {
69194
69231
  assets.remove(t);
69195
69232
  t.unload();
69196
69233
  });
69234
+ callback(null, null);
69235
+ return;
69236
+ }
69237
+ Object.values(textures).forEach((t) => {
69238
+ if (t.file) {
69239
+ t.file.contents = null;
69240
+ }
69197
69241
  });
69198
69242
  const decompress = asset.data?.decompress;
69199
69243
  const data = new GSplatSogData();
@@ -69209,13 +69253,29 @@ class SogBundleParser {
69209
69253
  data.sh_labels = textures[meta.shN?.files[1]]?.resource;
69210
69254
  data.shBands = GSplatSogData.calcBands(data.sh_centroids?.width);
69211
69255
  if (!decompress) {
69256
+ if (this._shouldAbort(asset, unloaded)) {
69257
+ data.destroy();
69258
+ callback(null, null);
69259
+ return;
69260
+ }
69212
69261
  data.prepareCodebook();
69213
69262
  if (gsplatCentersEnabledAtLoad) {
69214
69263
  await data.prepareGpuData();
69215
69264
  }
69216
69265
  }
69266
+ if (this._shouldAbort(asset, unloaded)) {
69267
+ data.destroy();
69268
+ callback(null, null);
69269
+ return;
69270
+ }
69217
69271
  const prepareCenters = gsplatCentersEnabledAtLoad;
69218
69272
  const resource = decompress ? new GSplatResource(this.app.graphicsDevice, await data.decompress(), { prepareCenters }) : new GSplatSogResource(this.app.graphicsDevice, data, { prepareCenters });
69273
+ ownedByResource = !decompress;
69274
+ if (this._shouldAbort(asset, unloaded)) {
69275
+ resource.destroy();
69276
+ callback(null, null);
69277
+ return;
69278
+ }
69219
69279
  callback(null, resource);
69220
69280
  } catch (err) {
69221
69281
  callback(err);
@@ -81141,7 +81201,7 @@ const importSettings = (settings) => {
81141
81201
  return result;
81142
81202
  };
81143
81203
 
81144
- var version = "1.27.0";
81204
+ var version = "1.27.1";
81145
81205
 
81146
81206
  class Tooltip {
81147
81207
  register;
@@ -81561,10 +81621,11 @@ const initUI = (global) => {
81561
81621
  // AR/VR
81562
81622
  const arChanged = () => dom.arMode.classList[state.hasAR ? 'remove' : 'add']('hidden');
81563
81623
  const vrChanged = () => dom.vrMode.classList[state.hasVR ? 'remove' : 'add']('hidden');
81564
- // XR sessions require a WebGL device. Under WebGPU, prompt the user to reload
81565
- // the viewer with the WebGL renderer before starting AR/VR. Use replace() so
81566
- // the renderer-switch reload doesn't add a back-button entry — important
81567
- // because the viewer often runs inside an iframe (e.g. superspl.at /scene).
81624
+ // When a session can't start on the current (WebGPU) device but would work on
81625
+ // WebGL, prompt the user to reload the viewer with the WebGL renderer before
81626
+ // starting AR/VR. Use replace() so the renderer-switch reload doesn't add a
81627
+ // back-button entry — important because the viewer often runs inside an
81628
+ // iframe (e.g. superspl.at /scene).
81568
81629
  const reloadWithWebgl = () => {
81569
81630
  const reloadUrl = new URL(location.href);
81570
81631
  reloadUrl.searchParams.set('webgl', '');
@@ -81576,11 +81637,14 @@ const initUI = (global) => {
81576
81637
  dom.xrModalCancel.addEventListener('click', hideXrModal);
81577
81638
  dom.xrModal.addEventListener('pointerdown', hideXrModal);
81578
81639
  const handleXrClick = (type) => {
81579
- if (global.renderer !== 'webgl') {
81580
- showXrModal();
81640
+ // Availability is backend-aware: when the session can start on the current
81641
+ // device (WebGPU included), start it directly. Otherwise the button is only
81642
+ // visible because the session would work on WebGL, so offer the reload.
81643
+ if (global.app.xr.isAvailable(type === 'AR' ? 'immersive-ar' : 'immersive-vr')) {
81644
+ events.fire(type === 'AR' ? 'startAR' : 'startVR');
81581
81645
  }
81582
81646
  else {
81583
- events.fire(type === 'AR' ? 'startAR' : 'startVR');
81647
+ showXrModal();
81584
81648
  }
81585
81649
  };
81586
81650
  dom.arMode.addEventListener('click', () => handleXrClick('AR'));
@@ -89432,19 +89496,28 @@ class XrNavigation extends Script {
89432
89496
  // On entering/exiting AR, we need to set the camera clear color to transparent black
89433
89497
  const initXr = (global) => {
89434
89498
  const { app, events, state, camera, renderer } = global;
89435
- state.hasAR = app.xr.isAvailable('immersive-ar');
89436
- state.hasVR = app.xr.isAvailable('immersive-vr');
89437
- // initialize ar/vr
89438
- app.xr.on('available:immersive-ar', (available) => {
89439
- state.hasAR = available;
89440
- });
89441
- app.xr.on('available:immersive-vr', (available) => {
89442
- state.hasVR = available;
89443
- });
89444
- // XR sessions require a WebGL device; under WebGPU we only expose availability so
89445
- // the UI can offer to reload the viewer in WebGL mode.
89446
- if (renderer !== 'webgl') {
89447
- return;
89499
+ // Engine availability is backend-aware (2.20+): under WebGPU a session is only
89500
+ // reported available when it can start on the current device (browser exposes
89501
+ // XRGPUBinding, e.g. Safari on Apple Vision Pro). A session the WebGPU device
89502
+ // can't host may still run after reloading into WebGL, so keep the buttons
89503
+ // visible then — the UI offers that reload when the session can't start directly.
89504
+ let webglAR = false;
89505
+ let webglVR = false;
89506
+ const updateAvailable = () => {
89507
+ state.hasAR = app.xr.isAvailable('immersive-ar') || webglAR;
89508
+ state.hasVR = app.xr.isAvailable('immersive-vr') || webglVR;
89509
+ };
89510
+ updateAvailable();
89511
+ app.xr.on('available', updateAvailable);
89512
+ if (renderer === 'webgpu') {
89513
+ Promise.all([
89514
+ XrManager.isDeviceSupported(DEVICETYPE_WEBGL2, 'immersive-ar'),
89515
+ XrManager.isDeviceSupported(DEVICETYPE_WEBGL2, 'immersive-vr')
89516
+ ]).then(([ar, vr]) => {
89517
+ webglAR = ar;
89518
+ webglVR = vr;
89519
+ updateAvailable();
89520
+ });
89448
89521
  }
89449
89522
  const parent = camera.parent;
89450
89523
  const clearColor = new Color();
@@ -89561,8 +89634,8 @@ const loadSkybox = (app, url) => {
89561
89634
  const createApp = async (canvas, config) => {
89562
89635
  const useWebGPU = config.renderer === 'webgpu';
89563
89636
  // Create the graphics device. The engine auto-appends WebGL2/null fallbacks
89564
- // when WebGPU isn't supported, so request xrCompatible so the WebGL fallback
89565
- // is also usable for AR/VR.
89637
+ // when WebGPU isn't supported. Request xrCompatible so the device — WebGPU
89638
+ // (via XRGPUBinding) or the WebGL fallback — is usable for AR/VR.
89566
89639
  const device = await createGraphicsDevice(canvas, {
89567
89640
  deviceTypes: useWebGPU ? ['webgpu'] : [],
89568
89641
  antialias: false,
@@ -89699,8 +89772,8 @@ const main = async (canvas, settingsJson, config) => {
89699
89772
  initPoster(events);
89700
89773
  }
89701
89774
  camera.addComponent('camera');
89702
- // Initialize XR support (availability detection always runs so the UI can offer
89703
- // a reload into WebGL when the user requests AR/VR under WebGPU)
89775
+ // Initialize XR support (any backend; when the current device can't host a
89776
+ // session the UI can offer a reload into WebGL instead)
89704
89777
  initXr(global);
89705
89778
  // Initialize user interface
89706
89779
  initLocalization();