@playcanvas/supersplat-viewer 1.17.1 → 1.17.3
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 +46 -25
- package/public/index.js.map +1 -1
package/package.json
CHANGED
package/public/index.js
CHANGED
|
@@ -73826,11 +73826,6 @@ class WalkController {
|
|
|
73826
73826
|
* Velocity damping factor when grounded (0 = no damping, 1 = full damping)
|
|
73827
73827
|
*/
|
|
73828
73828
|
velocityDampingGround = 0.99;
|
|
73829
|
-
/**
|
|
73830
|
-
* Velocity damping factor when grounded with no movement input.
|
|
73831
|
-
* More aggressive than normal ground damping to prevent slope drift.
|
|
73832
|
-
*/
|
|
73833
|
-
velocityDampingIdle = 0.9;
|
|
73834
73829
|
/**
|
|
73835
73830
|
* Velocity damping factor when in the air (0 = no damping, 1 = full damping)
|
|
73836
73831
|
*/
|
|
@@ -73857,6 +73852,7 @@ class WalkController {
|
|
|
73857
73852
|
_prevPosition = new Vec3();
|
|
73858
73853
|
_angles = new Vec3();
|
|
73859
73854
|
_velocity = new Vec3();
|
|
73855
|
+
_pendingMove = [0, 0, 0];
|
|
73860
73856
|
_accumulator = 0;
|
|
73861
73857
|
_grounded = false;
|
|
73862
73858
|
_jumping = false;
|
|
@@ -73878,18 +73874,25 @@ class WalkController {
|
|
|
73878
73874
|
// apply rotation at display rate for responsive mouse look
|
|
73879
73875
|
this._angles.add(v.set(-rotate[1], -rotate[0], 0));
|
|
73880
73876
|
this._angles.x = math.clamp(this._angles.x, -90, 90);
|
|
73877
|
+
// accumulate movement input so frames without a physics step don't lose input
|
|
73878
|
+
this._pendingMove[0] += move[0];
|
|
73879
|
+
this._pendingMove[1] = this._pendingMove[1] || move[1];
|
|
73880
|
+
this._pendingMove[2] += move[2];
|
|
73881
73881
|
this._accumulator = Math.min(this._accumulator + deltaTime, MAX_SUBSTEPS * FIXED_DT);
|
|
73882
73882
|
const numSteps = Math.floor(this._accumulator / FIXED_DT);
|
|
73883
73883
|
if (numSteps > 0) {
|
|
73884
73884
|
const invSteps = 1 / numSteps;
|
|
73885
|
-
moveStep[0] =
|
|
73886
|
-
moveStep[1] =
|
|
73887
|
-
moveStep[2] =
|
|
73885
|
+
moveStep[0] = this._pendingMove[0] * invSteps;
|
|
73886
|
+
moveStep[1] = this._pendingMove[1];
|
|
73887
|
+
moveStep[2] = this._pendingMove[2] * invSteps;
|
|
73888
73888
|
for (let i = 0; i < numSteps; i++) {
|
|
73889
73889
|
this._prevPosition.copy(this._position);
|
|
73890
73890
|
this._step(FIXED_DT, moveStep);
|
|
73891
73891
|
this._accumulator -= FIXED_DT;
|
|
73892
73892
|
}
|
|
73893
|
+
this._pendingMove[0] = 0;
|
|
73894
|
+
this._pendingMove[1] = 0;
|
|
73895
|
+
this._pendingMove[2] = 0;
|
|
73893
73896
|
}
|
|
73894
73897
|
const alpha = this._accumulator / FIXED_DT;
|
|
73895
73898
|
camera.position.lerp(this._prevPosition, this._position, alpha);
|
|
@@ -73897,7 +73900,6 @@ class WalkController {
|
|
|
73897
73900
|
camera.fov = this.fov;
|
|
73898
73901
|
}
|
|
73899
73902
|
_step(dt, move) {
|
|
73900
|
-
const hasInput = move[0] !== 0 || move[2] !== 0;
|
|
73901
73903
|
// ground probe: cast a ray downward to find the terrain surface
|
|
73902
73904
|
const groundY = this._probeGround(this._position);
|
|
73903
73905
|
const hasGround = groundY !== null;
|
|
@@ -73944,10 +73946,7 @@ class WalkController {
|
|
|
73944
73946
|
offset.add(forward.mulScalar(move[2]));
|
|
73945
73947
|
offset.add(right$1.mulScalar(move[0]));
|
|
73946
73948
|
this._velocity.add(offset.mulScalar(this._grounded ? this.moveGroundSpeed : this.moveAirSpeed));
|
|
73947
|
-
|
|
73948
|
-
const dampFactor = this._grounded ?
|
|
73949
|
-
(hasInput ? this.velocityDampingGround : this.velocityDampingIdle) :
|
|
73950
|
-
this.velocityDampingAir;
|
|
73949
|
+
const dampFactor = this._grounded ? this.velocityDampingGround : this.velocityDampingAir;
|
|
73951
73950
|
const alpha = damp(dampFactor, dt);
|
|
73952
73951
|
this._velocity.x = math.lerp(this._velocity.x, 0, alpha);
|
|
73953
73952
|
this._velocity.z = math.lerp(this._velocity.z, 0, alpha);
|
|
@@ -73973,6 +73972,9 @@ class WalkController {
|
|
|
73973
73972
|
this._velocity.set(0, 0, 0);
|
|
73974
73973
|
this._grounded = false;
|
|
73975
73974
|
this._jumping = false;
|
|
73975
|
+
this._pendingMove[0] = 0;
|
|
73976
|
+
this._pendingMove[1] = 0;
|
|
73977
|
+
this._pendingMove[2] = 0;
|
|
73976
73978
|
this._accumulator = 0;
|
|
73977
73979
|
}
|
|
73978
73980
|
/**
|
|
@@ -74061,14 +74063,22 @@ class WalkSource {
|
|
|
74061
74063
|
*/
|
|
74062
74064
|
walkSpeed = 4;
|
|
74063
74065
|
/**
|
|
74064
|
-
*
|
|
74066
|
+
* Maximum yaw turn rate in degrees per second.
|
|
74065
74067
|
*/
|
|
74066
|
-
|
|
74068
|
+
maxTurnRate = 192;
|
|
74069
|
+
/**
|
|
74070
|
+
* Proportional gain mapping yaw error (degrees) to desired turn rate.
|
|
74071
|
+
* Below maxTurnRate / turnGain degrees the turn rate scales linearly;
|
|
74072
|
+
* above that it is capped at maxTurnRate. The rate filter is
|
|
74073
|
+
* automatically critically damped so there is no overshoot.
|
|
74074
|
+
*/
|
|
74075
|
+
turnGain = 5;
|
|
74067
74076
|
/**
|
|
74068
74077
|
* Callback fired when an auto-walk completes (arrival or obstacle).
|
|
74069
74078
|
*/
|
|
74070
74079
|
onComplete = null;
|
|
74071
74080
|
_target = null;
|
|
74081
|
+
_yawRate = 0;
|
|
74072
74082
|
_blockedTime = 0;
|
|
74073
74083
|
_prevDist = Infinity;
|
|
74074
74084
|
get isWalking() {
|
|
@@ -74093,6 +74103,7 @@ class WalkSource {
|
|
|
74093
74103
|
cancelWalk() {
|
|
74094
74104
|
if (this._target) {
|
|
74095
74105
|
this._target = null;
|
|
74106
|
+
this._yawRate = 0;
|
|
74096
74107
|
this._blockedTime = 0;
|
|
74097
74108
|
this.onComplete?.();
|
|
74098
74109
|
}
|
|
@@ -74133,13 +74144,15 @@ class WalkSource {
|
|
|
74133
74144
|
}
|
|
74134
74145
|
}
|
|
74135
74146
|
this._prevDist = xzDist;
|
|
74136
|
-
// yaw toward target
|
|
74147
|
+
// yaw toward target with smoothed turn rate
|
|
74137
74148
|
const targetYaw = Math.atan2(-dx, -dz) * RAD_TO_DEG;
|
|
74138
74149
|
let yawDiff = targetYaw - cameraAngles.y;
|
|
74139
74150
|
yawDiff = ((yawDiff % 360) + 540) % 360 - 180;
|
|
74140
|
-
const
|
|
74151
|
+
const desiredRate = Math.max(-this.maxTurnRate, Math.min(yawDiff * this.turnGain, this.maxTurnRate));
|
|
74152
|
+
const smoothing = 1 - Math.exp(-4 * this.turnGain * dt);
|
|
74153
|
+
this._yawRate += (desiredRate - this._yawRate) * smoothing;
|
|
74141
74154
|
// WalkController applies: _angles.y += -rotate[0]
|
|
74142
|
-
frame.deltas.rotate.append([-(
|
|
74155
|
+
frame.deltas.rotate.append([-(this._yawRate * dt), 0, 0]);
|
|
74143
74156
|
// scale forward speed by alignment: turn in place first, then accelerate
|
|
74144
74157
|
const alignment = Math.max(0, Math.cos(yawDiff * Math.PI / 180));
|
|
74145
74158
|
frame.deltas.move.append([0, 0, this.walkSpeed * dt * alignment]);
|
|
@@ -74164,7 +74177,7 @@ class CameraManager {
|
|
|
74164
74177
|
// holds the camera state
|
|
74165
74178
|
camera = new Camera();
|
|
74166
74179
|
constructor(global, bbox, collider = null) {
|
|
74167
|
-
const { events, settings, state } = global;
|
|
74180
|
+
const { config, events, settings, state } = global;
|
|
74168
74181
|
const camera0 = settings.cameras[0].initial;
|
|
74169
74182
|
const frameCamera = createFrameCamera(bbox, camera0.fov);
|
|
74170
74183
|
const resetCamera = createCamera(new Vec3(camera0.position), new Vec3(camera0.target), camera0.fov);
|
|
@@ -74206,7 +74219,7 @@ class CameraManager {
|
|
|
74206
74219
|
state.hasAnimation = !!controllers.anim;
|
|
74207
74220
|
state.animationDuration = controllers.anim ? controllers.anim.animState.cursor.duration : 0;
|
|
74208
74221
|
// initialize camera mode and initial camera position
|
|
74209
|
-
state.cameraMode = state.hasAnimation ? 'anim' : (isObjectExperience ? 'orbit' : (collider ? 'walk' : 'fly'));
|
|
74222
|
+
state.cameraMode = (state.hasAnimation && !config.noanim) ? 'anim' : (isObjectExperience ? 'orbit' : (collider ? 'walk' : 'fly'));
|
|
74210
74223
|
this.camera.copy(resetCamera);
|
|
74211
74224
|
const target = new Camera(this.camera); // the active controller updates this
|
|
74212
74225
|
const from = new Camera(this.camera); // stores the previous camera state during transition
|
|
@@ -74685,10 +74698,6 @@ class InputController {
|
|
|
74685
74698
|
// Store coordinates for click/tap-to-walk picking
|
|
74686
74699
|
this._lastPointerOffsetX = event.offsetX;
|
|
74687
74700
|
this._lastPointerOffsetY = event.offsetY;
|
|
74688
|
-
// Cancel any active auto-walk in click-to-walk mode
|
|
74689
|
-
if (state.cameraMode === 'walk' && !state.gamingControls) {
|
|
74690
|
-
events.fire('walkCancel');
|
|
74691
|
-
}
|
|
74692
74701
|
// Start desktop click-to-walk tracking
|
|
74693
74702
|
if (event.pointerType !== 'touch' && event.button === 0) {
|
|
74694
74703
|
this._mouseClickTracking = true;
|
|
@@ -74712,7 +74721,13 @@ class InputController {
|
|
|
74712
74721
|
// Desktop click-to-walk: accumulate displacement during mouse drag
|
|
74713
74722
|
canvas.addEventListener('pointermove', (event) => {
|
|
74714
74723
|
if (this._mouseClickTracking && event.pointerType !== 'touch') {
|
|
74724
|
+
const prev = this._mouseClickDelta;
|
|
74715
74725
|
this._mouseClickDelta += Math.abs(event.movementX) + Math.abs(event.movementY);
|
|
74726
|
+
if (prev < TAP_EPSILON && this._mouseClickDelta >= TAP_EPSILON) {
|
|
74727
|
+
if (state.cameraMode === 'walk' && !state.gamingControls) {
|
|
74728
|
+
events.fire('walkCancel');
|
|
74729
|
+
}
|
|
74730
|
+
}
|
|
74716
74731
|
}
|
|
74717
74732
|
});
|
|
74718
74733
|
// Desktop click-to-walk: detect click (low displacement) on mouse button release
|
|
@@ -74925,7 +74940,13 @@ class InputController {
|
|
|
74925
74940
|
}
|
|
74926
74941
|
// Accumulate movement while touch is active
|
|
74927
74942
|
if (this._tapTouches > 0) {
|
|
74943
|
+
const prevDelta = this._tapDelta;
|
|
74928
74944
|
this._tapDelta += Math.abs(touch[0]) + Math.abs(touch[1]);
|
|
74945
|
+
if (prevDelta < TAP_EPSILON && this._tapDelta >= TAP_EPSILON) {
|
|
74946
|
+
if (!state.gamingControls) {
|
|
74947
|
+
events.fire('walkCancel');
|
|
74948
|
+
}
|
|
74949
|
+
}
|
|
74929
74950
|
}
|
|
74930
74951
|
// Touch just ended (1+ → 0): check if it was a tap
|
|
74931
74952
|
if (prevTaps > 0 && this._tapTouches === 0) {
|
|
@@ -78113,7 +78134,7 @@ const initXr = (global) => {
|
|
|
78113
78134
|
});
|
|
78114
78135
|
};
|
|
78115
78136
|
|
|
78116
|
-
var version = "1.17.
|
|
78137
|
+
var version = "1.17.3";
|
|
78117
78138
|
|
|
78118
78139
|
const loadGsplat = async (app, config, progressCallback) => {
|
|
78119
78140
|
const { contents, contentUrl, unified, aa } = config;
|