@playcanvas/supersplat-viewer 1.18.2-beta.0 → 1.18.2

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.18.2-beta.0",
3
+ "version": "1.18.2",
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",
@@ -63,7 +63,6 @@
63
63
  "typescript": "5.9.3"
64
64
  },
65
65
  "scripts": {
66
- "prepare": "rollup -c",
67
66
  "build": "rollup -c",
68
67
  "develop": "concurrently --kill-others \"npm run watch\" \"npm run serve\"",
69
68
  "lint": "eslint src rollup.config.mjs eslint.config.mjs",
package/public/index.html CHANGED
@@ -38,7 +38,6 @@
38
38
  gpusort: url.searchParams.has('gpusort'),
39
39
  aa: url.searchParams.has('aa'),
40
40
  heatmap: url.searchParams.has('heatmap'),
41
- stepMode: url.searchParams.has('stepMode'),
42
41
  };
43
42
 
44
43
  window.sse = {
package/public/index.js CHANGED
@@ -73303,6 +73303,74 @@ class Annotations {
73303
73303
  }
73304
73304
  }
73305
73305
 
73306
+ /**
73307
+ * Creates a figure-8 (lemniscate / infinity sign) camera animation track.
73308
+ * The camera traces a horizontal figure-8 centered at its initial position
73309
+ * while looking at the target point.
73310
+ *
73311
+ * @param position - Starting location of the camera.
73312
+ * @param target - Target point the camera looks at.
73313
+ * @param fov - The camera field of view.
73314
+ * @param size - Controls the scale of the figure-8 path. The left-right extent equals `size`
73315
+ * and the forward-back extent is half that (`size * 0.5`).
73316
+ * @param keys - The number of keyframes in the animation.
73317
+ * @param duration - The duration of the animation in seconds.
73318
+ * @returns The animation track object containing position and target keyframes.
73319
+ */
73320
+ const createFigure8Track = (position, target, fov, size = 1, keys = 24, duration = 20) => {
73321
+ const times = new Array(keys).fill(0).map((_, i) => i / keys * duration);
73322
+ const positions = [];
73323
+ const targets = [];
73324
+ const fovs = new Array(keys).fill(fov);
73325
+ const amplitude = size * 0.5;
73326
+ const dx = position.x - target.x;
73327
+ const dz = position.z - target.z;
73328
+ const horizontalDist = Math.sqrt(dx * dx + dz * dz);
73329
+ // compute local horizontal axes relative to camera-target direction
73330
+ let rightX, rightZ;
73331
+ let fwdX, fwdZ;
73332
+ if (horizontalDist > 0.001) {
73333
+ fwdX = dx / horizontalDist;
73334
+ fwdZ = dz / horizontalDist;
73335
+ rightX = -fwdZ;
73336
+ rightZ = fwdX;
73337
+ }
73338
+ else {
73339
+ fwdX = 0;
73340
+ fwdZ = 1;
73341
+ rightX = 1;
73342
+ rightZ = 0;
73343
+ }
73344
+ for (let i = 0; i < keys; ++i) {
73345
+ const t = i / keys * Math.PI * 2;
73346
+ // lemniscate offsets: sin(t) for left-right, sin(2t)/2 for forward-back
73347
+ const offsetRight = amplitude * Math.sin(t);
73348
+ const offsetFwd = amplitude * Math.sin(2 * t) / 2;
73349
+ positions.push(position.x + rightX * offsetRight + fwdX * offsetFwd);
73350
+ positions.push(position.y);
73351
+ positions.push(position.z + rightZ * offsetRight + fwdZ * offsetFwd);
73352
+ targets.push(target.x);
73353
+ targets.push(target.y);
73354
+ targets.push(target.z);
73355
+ }
73356
+ return {
73357
+ name: 'figure8',
73358
+ duration,
73359
+ frameRate: 1,
73360
+ loopMode: 'repeat',
73361
+ interpolation: 'spline',
73362
+ smoothness: 1,
73363
+ keyframes: {
73364
+ times,
73365
+ values: {
73366
+ position: positions,
73367
+ target: targets,
73368
+ fov: fovs
73369
+ }
73370
+ }
73371
+ };
73372
+ };
73373
+
73306
73374
  /**
73307
73375
  * Creates a rotation animation track
73308
73376
  *
@@ -74184,7 +74252,9 @@ class CameraManager {
74184
74252
  initial.calcFocusPoint(tmpv);
74185
74253
  return createRotateTrack(initial.position, tmpv, initial.fov);
74186
74254
  }
74187
- return null;
74255
+ // non-object experience: gentle figure-8 motion from inside the scene
74256
+ initial.calcFocusPoint(tmpv);
74257
+ return createFigure8Track(initial.position, tmpv, initial.fov);
74188
74258
  };
74189
74259
  // object experience starts outside the bounding box
74190
74260
  const isObjectExperience = !bbox.containsPoint(resetCamera.position);
@@ -76063,20 +76133,20 @@ class Viewer {
76063
76133
  cameraEntity.camera.farClip = far;
76064
76134
  cameraEntity.camera.nearClip = near;
76065
76135
  };
76066
- const stepCamera = (dt) => {
76067
- if (this.inputController && this.cameraManager) {
76068
- this.inputController.update(dt, this.cameraManager.camera.distance);
76069
- this.cameraManager.update(dt, this.inputController.frame);
76070
- applyCamera(this.cameraManager.camera);
76071
- }
76072
- };
76073
76136
  // handle application update
76074
76137
  app.on('update', (deltaTime) => {
76138
+ // in xr mode we leave the camera alone
76075
76139
  if (app.xr.active) {
76076
76140
  return;
76077
76141
  }
76078
- // in step mode the scene is frozen; only window.stepFrame advances it
76079
- stepCamera(config.stepMode ? 0 : deltaTime);
76142
+ if (this.inputController && this.cameraManager) {
76143
+ // update inputs
76144
+ this.inputController.update(deltaTime, this.cameraManager.camera.distance);
76145
+ // update cameras
76146
+ this.cameraManager.update(deltaTime, this.inputController.frame);
76147
+ // apply to the camera entity
76148
+ applyCamera(this.cameraManager.camera);
76149
+ }
76080
76150
  });
76081
76151
  // Render voxel debug overlay
76082
76152
  app.on('prerender', () => {
@@ -76086,12 +76156,18 @@ class Viewer {
76086
76156
  events.on('firstFrame', () => {
76087
76157
  state.loaded = true;
76088
76158
  state.animationPaused = !!config.noanim;
76089
- if (config.stepMode) {
76090
- window.stepFrame = (dtMs) => {
76091
- stepCamera(dtMs / 1000);
76159
+ window.scrubTo = (time) => {
76160
+ if (!state.hasAnimation) {
76161
+ return Promise.reject(new Error('No animation track'));
76162
+ }
76163
+ state.animationPaused = true;
76164
+ return new Promise((resolve) => {
76165
+ events.fire('scrubAnim', time);
76092
76166
  app.renderNextFrame = true;
76093
- };
76094
- }
76167
+ app.once('frameend', () => resolve());
76168
+ });
76169
+ };
76170
+ window.animationDuration = state.animationDuration;
76095
76171
  });
76096
76172
  // wait for the model to load
76097
76173
  Promise.all([gsplatLoad, skyboxLoad, voxelLoad]).then((results) => {
@@ -78139,7 +78215,7 @@ const initXr = (global) => {
78139
78215
  });
78140
78216
  };
78141
78217
 
78142
- var version = "1.18.2-beta.0";
78218
+ var version = "1.18.2";
78143
78219
 
78144
78220
  const loadGsplat = async (app, config, progressCallback) => {
78145
78221
  const { contents, contentUrl, unified, aa } = config;