@playcanvas/supersplat-viewer 1.18.1 → 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/dist/index.js +1 -1
- package/package.json +1 -1
- package/public/index.js +84 -2
- package/public/index.js.map +1 -1
package/package.json
CHANGED
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
|
-
|
|
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);
|
|
@@ -76086,6 +76156,18 @@ class Viewer {
|
|
|
76086
76156
|
events.on('firstFrame', () => {
|
|
76087
76157
|
state.loaded = true;
|
|
76088
76158
|
state.animationPaused = !!config.noanim;
|
|
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);
|
|
76166
|
+
app.renderNextFrame = true;
|
|
76167
|
+
app.once('frameend', () => resolve());
|
|
76168
|
+
});
|
|
76169
|
+
};
|
|
76170
|
+
window.animationDuration = state.animationDuration;
|
|
76089
76171
|
});
|
|
76090
76172
|
// wait for the model to load
|
|
76091
76173
|
Promise.all([gsplatLoad, skyboxLoad, voxelLoad]).then((results) => {
|
|
@@ -78133,7 +78215,7 @@ const initXr = (global) => {
|
|
|
78133
78215
|
});
|
|
78134
78216
|
};
|
|
78135
78217
|
|
|
78136
|
-
var version = "1.18.
|
|
78218
|
+
var version = "1.18.2";
|
|
78137
78219
|
|
|
78138
78220
|
const loadGsplat = async (app, config, progressCallback) => {
|
|
78139
78221
|
const { contents, contentUrl, unified, aa } = config;
|