@playcanvas/supersplat-viewer 1.17.0 → 1.17.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/dist/index.js +1 -1
- package/package.json +1 -1
- package/public/index.js +55 -28
- package/public/index.js.map +1 -1
package/package.json
CHANGED
package/public/index.js
CHANGED
|
@@ -73563,6 +73563,7 @@ class AnimState {
|
|
|
73563
73563
|
result = [];
|
|
73564
73564
|
position = new Vec3();
|
|
73565
73565
|
target = new Vec3();
|
|
73566
|
+
fov = 90;
|
|
73566
73567
|
constructor(spline, duration, loopMode, frameRate) {
|
|
73567
73568
|
this.spline = spline;
|
|
73568
73569
|
this.cursor.reset(duration, loopMode);
|
|
@@ -73578,18 +73579,20 @@ class AnimState {
|
|
|
73578
73579
|
if (result.every(isFinite)) {
|
|
73579
73580
|
position.set(result[0], result[1], result[2]);
|
|
73580
73581
|
target.set(result[3], result[4], result[5]);
|
|
73582
|
+
this.fov = result[6];
|
|
73581
73583
|
}
|
|
73582
73584
|
}
|
|
73583
73585
|
// construct an animation from a settings track
|
|
73584
73586
|
static fromTrack(track) {
|
|
73585
73587
|
const { keyframes, duration, frameRate, loopMode, smoothness } = track;
|
|
73586
73588
|
const { times, values } = keyframes;
|
|
73587
|
-
const { position, target } = values;
|
|
73588
|
-
// construct the points array containing position and
|
|
73589
|
+
const { position, target, fov } = values;
|
|
73590
|
+
// construct the points array containing position, target and fov
|
|
73589
73591
|
const points = [];
|
|
73590
73592
|
for (let i = 0; i < times.length; i++) {
|
|
73591
73593
|
points.push(position[i * 3], position[i * 3 + 1], position[i * 3 + 2]);
|
|
73592
73594
|
points.push(target[i * 3], target[i * 3 + 1], target[i * 3 + 2]);
|
|
73595
|
+
points.push(fov[i]);
|
|
73593
73596
|
}
|
|
73594
73597
|
const extra = (duration === times[times.length - 1] / frameRate) ? 1 : 0;
|
|
73595
73598
|
const spline = CubicSpline.fromPointsLooping((duration + extra) * frameRate, times, points, smoothness);
|
|
@@ -73604,14 +73607,13 @@ class AnimController {
|
|
|
73604
73607
|
this.animState.update(0);
|
|
73605
73608
|
}
|
|
73606
73609
|
onEnter(camera) {
|
|
73607
|
-
// snap camera to start position
|
|
73608
73610
|
camera.look(this.animState.position, this.animState.target);
|
|
73611
|
+
camera.fov = this.animState.fov;
|
|
73609
73612
|
}
|
|
73610
73613
|
update(deltaTime, inputFrame, camera) {
|
|
73611
73614
|
this.animState.update(deltaTime);
|
|
73612
|
-
// update camera pose
|
|
73613
73615
|
camera.look(this.animState.position, this.animState.target);
|
|
73614
|
-
|
|
73616
|
+
camera.fov = this.animState.fov;
|
|
73615
73617
|
inputFrame.read();
|
|
73616
73618
|
}
|
|
73617
73619
|
onExit(camera) {
|
|
@@ -73667,6 +73669,7 @@ const p$1 = new Pose();
|
|
|
73667
73669
|
const pushOut = { x: 0, y: 0, z: 0 };
|
|
73668
73670
|
class FlyController {
|
|
73669
73671
|
controller;
|
|
73672
|
+
fov = 90;
|
|
73670
73673
|
/** Optional voxel collider for sphere collision with sliding */
|
|
73671
73674
|
collider = null;
|
|
73672
73675
|
constructor() {
|
|
@@ -73710,6 +73713,7 @@ class FlyController {
|
|
|
73710
73713
|
}
|
|
73711
73714
|
}
|
|
73712
73715
|
camera.position.copy(pose.position);
|
|
73716
|
+
camera.fov = this.fov;
|
|
73713
73717
|
}
|
|
73714
73718
|
onExit(camera) {
|
|
73715
73719
|
}
|
|
@@ -73721,6 +73725,7 @@ class FlyController {
|
|
|
73721
73725
|
const p = new Pose();
|
|
73722
73726
|
class OrbitController {
|
|
73723
73727
|
controller;
|
|
73728
|
+
fov = 90;
|
|
73724
73729
|
constructor() {
|
|
73725
73730
|
this.controller = new OrbitController$1();
|
|
73726
73731
|
this.controller.zoomRange = new Vec2(0.01, Infinity);
|
|
@@ -73740,6 +73745,7 @@ class OrbitController {
|
|
|
73740
73745
|
camera.position.copy(pose.position);
|
|
73741
73746
|
camera.angles.copy(pose.angles);
|
|
73742
73747
|
camera.distance = pose.distance;
|
|
73748
|
+
camera.fov = this.fov;
|
|
73743
73749
|
}
|
|
73744
73750
|
onExit(camera) {
|
|
73745
73751
|
}
|
|
@@ -73747,16 +73753,20 @@ class OrbitController {
|
|
|
73747
73753
|
p.position.copy(camera.position);
|
|
73748
73754
|
p.angles.copy(camera.angles);
|
|
73749
73755
|
p.distance = camera.distance;
|
|
73756
|
+
this.fov = camera.fov;
|
|
73750
73757
|
this.controller.attach(p, false);
|
|
73751
73758
|
}
|
|
73752
73759
|
}
|
|
73753
73760
|
|
|
73761
|
+
const FIXED_DT = 1 / 60;
|
|
73762
|
+
const MAX_SUBSTEPS = 10;
|
|
73754
73763
|
/** Pre-allocated push-out vector for capsule collision */
|
|
73755
73764
|
const out = { x: 0, y: 0, z: 0 };
|
|
73756
73765
|
const v = new Vec3();
|
|
73757
73766
|
const d = new Vec3();
|
|
73758
73767
|
const forward = new Vec3();
|
|
73759
73768
|
const right$1 = new Vec3();
|
|
73769
|
+
const moveStep = [0, 0, 0];
|
|
73760
73770
|
const offset = new Vec3();
|
|
73761
73771
|
const rotation = new Quat();
|
|
73762
73772
|
/**
|
|
@@ -73775,7 +73785,7 @@ class WalkController {
|
|
|
73775
73785
|
/**
|
|
73776
73786
|
* Field of view in degrees for walk mode.
|
|
73777
73787
|
*/
|
|
73778
|
-
fov =
|
|
73788
|
+
fov = 96;
|
|
73779
73789
|
/**
|
|
73780
73790
|
* Total capsule height in meters (default: human proportion)
|
|
73781
73791
|
*/
|
|
@@ -73824,7 +73834,7 @@ class WalkController {
|
|
|
73824
73834
|
/**
|
|
73825
73835
|
* Velocity damping factor when in the air (0 = no damping, 1 = full damping)
|
|
73826
73836
|
*/
|
|
73827
|
-
velocityDampingAir = 0.
|
|
73837
|
+
velocityDampingAir = 0.998;
|
|
73828
73838
|
/**
|
|
73829
73839
|
* Target clearance from capsule bottom to ground surface in meters.
|
|
73830
73840
|
* The capsule hovers this far above terrain to avoid bouncing on noisy voxels.
|
|
@@ -73844,8 +73854,10 @@ class WalkController {
|
|
|
73844
73854
|
*/
|
|
73845
73855
|
groundProbeRange = 1.0;
|
|
73846
73856
|
_position = new Vec3();
|
|
73857
|
+
_prevPosition = new Vec3();
|
|
73847
73858
|
_angles = new Vec3();
|
|
73848
73859
|
_velocity = new Vec3();
|
|
73860
|
+
_accumulator = 0;
|
|
73849
73861
|
_grounded = false;
|
|
73850
73862
|
_jumping = false;
|
|
73851
73863
|
_jumpHeld = false;
|
|
@@ -73857,11 +73869,34 @@ class WalkController {
|
|
|
73857
73869
|
this._grounded = true;
|
|
73858
73870
|
this._velocity.y = 0;
|
|
73859
73871
|
this._position.y = groundY + this.hoverHeight + this.eyeHeight;
|
|
73872
|
+
this._prevPosition.copy(this._position);
|
|
73860
73873
|
}
|
|
73861
73874
|
}
|
|
73862
73875
|
}
|
|
73863
73876
|
update(deltaTime, inputFrame, camera) {
|
|
73864
73877
|
const { move, rotate } = inputFrame.read();
|
|
73878
|
+
// apply rotation at display rate for responsive mouse look
|
|
73879
|
+
this._angles.add(v.set(-rotate[1], -rotate[0], 0));
|
|
73880
|
+
this._angles.x = math.clamp(this._angles.x, -90, 90);
|
|
73881
|
+
this._accumulator = Math.min(this._accumulator + deltaTime, MAX_SUBSTEPS * FIXED_DT);
|
|
73882
|
+
const numSteps = Math.floor(this._accumulator / FIXED_DT);
|
|
73883
|
+
if (numSteps > 0) {
|
|
73884
|
+
const invSteps = 1 / numSteps;
|
|
73885
|
+
moveStep[0] = move[0] * invSteps;
|
|
73886
|
+
moveStep[1] = move[1];
|
|
73887
|
+
moveStep[2] = move[2] * invSteps;
|
|
73888
|
+
for (let i = 0; i < numSteps; i++) {
|
|
73889
|
+
this._prevPosition.copy(this._position);
|
|
73890
|
+
this._step(FIXED_DT, moveStep);
|
|
73891
|
+
this._accumulator -= FIXED_DT;
|
|
73892
|
+
}
|
|
73893
|
+
}
|
|
73894
|
+
const alpha = this._accumulator / FIXED_DT;
|
|
73895
|
+
camera.position.lerp(this._prevPosition, this._position, alpha);
|
|
73896
|
+
camera.angles.set(this._angles.x, this._angles.y, 0);
|
|
73897
|
+
camera.fov = this.fov;
|
|
73898
|
+
}
|
|
73899
|
+
_step(dt, move) {
|
|
73865
73900
|
const hasInput = move[0] !== 0 || move[2] !== 0;
|
|
73866
73901
|
// ground probe: cast a ray downward to find the terrain surface
|
|
73867
73902
|
const groundY = this._probeGround(this._position);
|
|
@@ -73882,8 +73917,8 @@ class WalkController {
|
|
|
73882
73917
|
const displacement = this._position.y - targetY;
|
|
73883
73918
|
if (displacement > 0.1) {
|
|
73884
73919
|
// well above target (jump/ledge): freefall, snap to rest height on arrival
|
|
73885
|
-
this._velocity.y -= this.gravity *
|
|
73886
|
-
const nextY = this._position.y + this._velocity.y *
|
|
73920
|
+
this._velocity.y -= this.gravity * dt;
|
|
73921
|
+
const nextY = this._position.y + this._velocity.y * dt;
|
|
73887
73922
|
if (nextY <= targetY) {
|
|
73888
73923
|
this._position.y = targetY;
|
|
73889
73924
|
this._velocity.y = 0;
|
|
@@ -73893,17 +73928,14 @@ class WalkController {
|
|
|
73893
73928
|
else {
|
|
73894
73929
|
// at or near target (walking/slopes): spring tracks terrain
|
|
73895
73930
|
const springForce = -this.springStiffness * displacement - this.springDamping * this._velocity.y;
|
|
73896
|
-
this._velocity.y += springForce *
|
|
73931
|
+
this._velocity.y += springForce * dt;
|
|
73897
73932
|
this._grounded = true;
|
|
73898
73933
|
}
|
|
73899
73934
|
}
|
|
73900
73935
|
else {
|
|
73901
|
-
this._velocity.y -= this.gravity *
|
|
73936
|
+
this._velocity.y -= this.gravity * dt;
|
|
73902
73937
|
this._grounded = false;
|
|
73903
73938
|
}
|
|
73904
|
-
// rotate
|
|
73905
|
-
this._angles.add(v.set(-rotate[1], -rotate[0], 0));
|
|
73906
|
-
this._angles.x = math.clamp(this._angles.x, -90, 90);
|
|
73907
73939
|
// move
|
|
73908
73940
|
rotation.setFromEulerAngles(0, this._angles.y, 0);
|
|
73909
73941
|
rotation.transformVector(Vec3.FORWARD, forward);
|
|
@@ -73916,16 +73948,12 @@ class WalkController {
|
|
|
73916
73948
|
const dampFactor = this._grounded ?
|
|
73917
73949
|
(hasInput ? this.velocityDampingGround : this.velocityDampingIdle) :
|
|
73918
73950
|
this.velocityDampingAir;
|
|
73919
|
-
const alpha = damp(dampFactor,
|
|
73951
|
+
const alpha = damp(dampFactor, dt);
|
|
73920
73952
|
this._velocity.x = math.lerp(this._velocity.x, 0, alpha);
|
|
73921
73953
|
this._velocity.z = math.lerp(this._velocity.z, 0, alpha);
|
|
73922
|
-
this._position.add(v.copy(this._velocity).mulScalar(
|
|
73954
|
+
this._position.add(v.copy(this._velocity).mulScalar(dt));
|
|
73923
73955
|
// capsule collision: walls, ceiling, and fallback floor contact
|
|
73924
73956
|
this._checkCollision(this._position, d);
|
|
73925
|
-
// update camera
|
|
73926
|
-
camera.position.copy(this._position);
|
|
73927
|
-
camera.angles.set(this._angles.x, this._angles.y, 0);
|
|
73928
|
-
camera.fov = this.fov;
|
|
73929
73957
|
}
|
|
73930
73958
|
onExit(_camera) {
|
|
73931
73959
|
// nothing to clean up
|
|
@@ -73938,12 +73966,14 @@ class WalkController {
|
|
|
73938
73966
|
goto(camera) {
|
|
73939
73967
|
// position
|
|
73940
73968
|
this._position.copy(camera.position);
|
|
73969
|
+
this._prevPosition.copy(this._position);
|
|
73941
73970
|
// angles (clamp pitch to avoid gimbal lock)
|
|
73942
73971
|
this._angles.set(camera.angles.x, camera.angles.y, 0);
|
|
73943
73972
|
// reset velocity and state
|
|
73944
73973
|
this._velocity.set(0, 0, 0);
|
|
73945
73974
|
this._grounded = false;
|
|
73946
73975
|
this._jumping = false;
|
|
73976
|
+
this._accumulator = 0;
|
|
73947
73977
|
}
|
|
73948
73978
|
/**
|
|
73949
73979
|
* Cast multiple rays downward to find the average ground surface height.
|
|
@@ -74161,6 +74191,8 @@ class CameraManager {
|
|
|
74161
74191
|
walk: new WalkController(),
|
|
74162
74192
|
anim: animTrack ? new AnimController(animTrack) : null
|
|
74163
74193
|
};
|
|
74194
|
+
controllers.orbit.fov = resetCamera.fov;
|
|
74195
|
+
controllers.fly.fov = resetCamera.fov;
|
|
74164
74196
|
controllers.fly.collider = collider;
|
|
74165
74197
|
controllers.walk.collider = collider;
|
|
74166
74198
|
const walkSource = new WalkSource();
|
|
@@ -74180,8 +74212,8 @@ class CameraManager {
|
|
|
74180
74212
|
const from = new Camera(this.camera); // stores the previous camera state during transition
|
|
74181
74213
|
const defaultMode = isObjectExperience ? 'orbit' : (collider ? 'walk' : 'fly');
|
|
74182
74214
|
let fromMode = defaultMode;
|
|
74183
|
-
// tracks the mode to restore when exiting
|
|
74184
|
-
let preWalkMode =
|
|
74215
|
+
// tracks the mode to restore when exiting walk
|
|
74216
|
+
let preWalkMode = isObjectExperience ? 'orbit' : 'fly';
|
|
74185
74217
|
// enter the initial controller
|
|
74186
74218
|
getController(state.cameraMode).onEnter(this.camera);
|
|
74187
74219
|
// transition state
|
|
@@ -74203,10 +74235,6 @@ class CameraManager {
|
|
|
74203
74235
|
walkSource.update(dt, this.camera.position, this.camera.angles, frame);
|
|
74204
74236
|
}
|
|
74205
74237
|
controller.update(dt, frame, target);
|
|
74206
|
-
// walk controller sets its own FOV; all other modes use the authored FOV
|
|
74207
|
-
if (state.cameraMode !== 'walk') {
|
|
74208
|
-
target.fov = resetCamera.fov;
|
|
74209
|
-
}
|
|
74210
74238
|
if (transitionTimer < 1) {
|
|
74211
74239
|
// lerp away from previous camera during transition
|
|
74212
74240
|
this.camera.lerp(from, target, easeOut(transitionTimer));
|
|
@@ -74315,7 +74343,6 @@ class CameraManager {
|
|
|
74315
74343
|
tmpCamera.fov = initial.fov;
|
|
74316
74344
|
tmpCamera.look(new Vec3(initial.position), new Vec3(initial.target));
|
|
74317
74345
|
controllers.orbit.goto(tmpCamera);
|
|
74318
|
-
target.fov = tmpCamera.fov;
|
|
74319
74346
|
startTransition();
|
|
74320
74347
|
});
|
|
74321
74348
|
// tap-to-walk: start auto-walking toward a picked 3D position
|
|
@@ -78086,7 +78113,7 @@ const initXr = (global) => {
|
|
|
78086
78113
|
});
|
|
78087
78114
|
};
|
|
78088
78115
|
|
|
78089
|
-
var version = "1.17.
|
|
78116
|
+
var version = "1.17.1";
|
|
78090
78117
|
|
|
78091
78118
|
const loadGsplat = async (app, config, progressCallback) => {
|
|
78092
78119
|
const { contents, contentUrl, unified, aa } = config;
|