@playcanvas/supersplat-viewer 1.15.1 → 1.16.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 +3 -3
- package/package.json +1 -1
- package/public/index.css +61 -37
- package/public/index.html +56 -14
- package/public/index.js +389 -213
- package/public/index.js.map +1 -1
package/public/index.js
CHANGED
|
@@ -19215,7 +19215,7 @@ const tmpMat4 = new Mat4();
|
|
|
19215
19215
|
const tmpQuat = new Quat();
|
|
19216
19216
|
const position = new Vec3();
|
|
19217
19217
|
const invParentWtm = new Mat4();
|
|
19218
|
-
const rotation$
|
|
19218
|
+
const rotation$5 = new Quat();
|
|
19219
19219
|
const invParentRot = new Quat();
|
|
19220
19220
|
const matrix = new Mat4();
|
|
19221
19221
|
const target = new Vec3();
|
|
@@ -19589,16 +19589,16 @@ class GraphNode extends EventHandler {
|
|
|
19589
19589
|
}
|
|
19590
19590
|
setRotation(x, y, z, w) {
|
|
19591
19591
|
if (x instanceof Quat) {
|
|
19592
|
-
rotation$
|
|
19592
|
+
rotation$5.copy(x);
|
|
19593
19593
|
} else {
|
|
19594
|
-
rotation$
|
|
19594
|
+
rotation$5.set(x, y, z, w);
|
|
19595
19595
|
}
|
|
19596
19596
|
if (this._parent === null) {
|
|
19597
|
-
this.localRotation.copy(rotation$
|
|
19597
|
+
this.localRotation.copy(rotation$5);
|
|
19598
19598
|
} else {
|
|
19599
19599
|
const parentRot = this._parent.getRotation();
|
|
19600
19600
|
invParentRot.copy(parentRot).invert();
|
|
19601
|
-
this.localRotation.copy(invParentRot).mul(rotation$
|
|
19601
|
+
this.localRotation.copy(invParentRot).mul(rotation$5);
|
|
19602
19602
|
}
|
|
19603
19603
|
if (!this._dirtyLocal) {
|
|
19604
19604
|
this._dirtifyLocal();
|
|
@@ -19763,8 +19763,8 @@ class GraphNode extends EventHandler {
|
|
|
19763
19763
|
up$1.set(ux, uy, uz);
|
|
19764
19764
|
}
|
|
19765
19765
|
matrix.setLookAt(this.getPosition(), target, up$1);
|
|
19766
|
-
rotation$
|
|
19767
|
-
this.setRotation(rotation$
|
|
19766
|
+
rotation$5.setFromMat4(matrix);
|
|
19767
|
+
this.setRotation(rotation$5);
|
|
19768
19768
|
}
|
|
19769
19769
|
translate(x, y, z) {
|
|
19770
19770
|
if (x instanceof Vec3) {
|
|
@@ -19788,23 +19788,23 @@ class GraphNode extends EventHandler {
|
|
|
19788
19788
|
}
|
|
19789
19789
|
}
|
|
19790
19790
|
rotate(x, y, z) {
|
|
19791
|
-
rotation$
|
|
19791
|
+
rotation$5.setFromEulerAngles(x, y, z);
|
|
19792
19792
|
if (this._parent === null) {
|
|
19793
|
-
this.localRotation.mul2(rotation$
|
|
19793
|
+
this.localRotation.mul2(rotation$5, this.localRotation);
|
|
19794
19794
|
} else {
|
|
19795
19795
|
const rot = this.getRotation();
|
|
19796
19796
|
const parentRot = this._parent.getRotation();
|
|
19797
19797
|
invParentRot.copy(parentRot).invert();
|
|
19798
|
-
rotation$
|
|
19799
|
-
this.localRotation.mul2(rotation$
|
|
19798
|
+
rotation$5.mul2(invParentRot, rotation$5);
|
|
19799
|
+
this.localRotation.mul2(rotation$5, rot);
|
|
19800
19800
|
}
|
|
19801
19801
|
if (!this._dirtyLocal) {
|
|
19802
19802
|
this._dirtifyLocal();
|
|
19803
19803
|
}
|
|
19804
19804
|
}
|
|
19805
19805
|
rotateLocal(x, y, z) {
|
|
19806
|
-
rotation$
|
|
19807
|
-
this.localRotation.mul(rotation$
|
|
19806
|
+
rotation$5.setFromEulerAngles(x, y, z);
|
|
19807
|
+
this.localRotation.mul(rotation$5);
|
|
19808
19808
|
if (!this._dirtyLocal) {
|
|
19809
19809
|
this._dirtifyLocal();
|
|
19810
19810
|
}
|
|
@@ -68464,7 +68464,7 @@ class CameraFrame {
|
|
|
68464
68464
|
}
|
|
68465
68465
|
|
|
68466
68466
|
const tmpV1$1 = new Vec3();
|
|
68467
|
-
const rotation$
|
|
68467
|
+
const rotation$4 = new Quat();
|
|
68468
68468
|
class Pose {
|
|
68469
68469
|
copy(other) {
|
|
68470
68470
|
return this.set(other.position, other.angles, other.distance);
|
|
@@ -68515,7 +68515,7 @@ class Pose {
|
|
|
68515
68515
|
return this;
|
|
68516
68516
|
}
|
|
68517
68517
|
getFocus(out) {
|
|
68518
|
-
return rotation$
|
|
68518
|
+
return rotation$4.setFromEulerAngles(this.angles).transformVector(Vec3.FORWARD, out).mulScalar(this.distance).add(this.position);
|
|
68519
68519
|
}
|
|
68520
68520
|
constructor(position = Vec3.ZERO, angles = Vec3.ZERO, distance = 0){
|
|
68521
68521
|
this.position = new Vec3();
|
|
@@ -69094,12 +69094,12 @@ GamepadSource.buttonCode = BUTTON_CODES;
|
|
|
69094
69094
|
|
|
69095
69095
|
const damp$1 = (damping, dt)=>1 - Math.pow(damping, dt * 1000);
|
|
69096
69096
|
|
|
69097
|
-
const offset$
|
|
69097
|
+
const offset$2 = new Vec3();
|
|
69098
69098
|
const angles$1 = new Vec3();
|
|
69099
|
-
const forward = new Vec3();
|
|
69100
|
-
const right = new Vec3();
|
|
69099
|
+
const forward$1 = new Vec3();
|
|
69100
|
+
const right$1 = new Vec3();
|
|
69101
69101
|
const up = new Vec3();
|
|
69102
|
-
const rotation$
|
|
69102
|
+
const rotation$3 = new Quat();
|
|
69103
69103
|
let FlyController$1 = class FlyController extends InputController$1 {
|
|
69104
69104
|
set pitchRange(value) {
|
|
69105
69105
|
this._targetPose.pitchRange.copy(value);
|
|
@@ -69127,15 +69127,15 @@ let FlyController$1 = class FlyController extends InputController$1 {
|
|
|
69127
69127
|
update(frame, dt) {
|
|
69128
69128
|
const { move, rotate } = frame.read();
|
|
69129
69129
|
this._targetPose.rotate(angles$1.set(-rotate[1], -rotate[0], 0));
|
|
69130
|
-
rotation$
|
|
69131
|
-
rotation$
|
|
69132
|
-
rotation$
|
|
69133
|
-
rotation$
|
|
69134
|
-
offset$
|
|
69135
|
-
offset$
|
|
69136
|
-
offset$
|
|
69137
|
-
offset$
|
|
69138
|
-
this._targetPose.move(offset$
|
|
69130
|
+
rotation$3.setFromEulerAngles(this._pose.angles);
|
|
69131
|
+
rotation$3.transformVector(Vec3.FORWARD, forward$1);
|
|
69132
|
+
rotation$3.transformVector(Vec3.RIGHT, right$1);
|
|
69133
|
+
rotation$3.transformVector(Vec3.UP, up);
|
|
69134
|
+
offset$2.set(0, 0, 0);
|
|
69135
|
+
offset$2.add(forward$1.mulScalar(move[2]));
|
|
69136
|
+
offset$2.add(right$1.mulScalar(move[0]));
|
|
69137
|
+
offset$2.add(up.mulScalar(move[1]));
|
|
69138
|
+
this._targetPose.move(offset$2);
|
|
69139
69139
|
return this._pose.lerp(this._pose, this._targetPose, damp$1(this.moveDamping, dt), damp$1(this.rotateDamping, dt));
|
|
69140
69140
|
}
|
|
69141
69141
|
destroy() {
|
|
@@ -69147,9 +69147,9 @@ let FlyController$1 = class FlyController extends InputController$1 {
|
|
|
69147
69147
|
};
|
|
69148
69148
|
|
|
69149
69149
|
const dir = new Vec3();
|
|
69150
|
-
const offset = new Vec3();
|
|
69150
|
+
const offset$1 = new Vec3();
|
|
69151
69151
|
const angles = new Vec3();
|
|
69152
|
-
const rotation$
|
|
69152
|
+
const rotation$2 = new Quat();
|
|
69153
69153
|
let OrbitController$1 = class OrbitController extends InputController$1 {
|
|
69154
69154
|
set pitchRange(range) {
|
|
69155
69155
|
this._targetRootPose.pitchRange.copy(range);
|
|
@@ -69186,16 +69186,16 @@ let OrbitController$1 = class OrbitController extends InputController$1 {
|
|
|
69186
69186
|
}
|
|
69187
69187
|
update(frame, dt) {
|
|
69188
69188
|
const { move, rotate } = frame.read();
|
|
69189
|
-
offset.set(move[0], move[1], 0);
|
|
69190
|
-
rotation$
|
|
69191
|
-
this._targetRootPose.move(offset);
|
|
69189
|
+
offset$1.set(move[0], move[1], 0);
|
|
69190
|
+
rotation$2.setFromEulerAngles(this._rootPose.angles).transformVector(offset$1, offset$1);
|
|
69191
|
+
this._targetRootPose.move(offset$1);
|
|
69192
69192
|
const { z: dist } = this._targetChildPose.position;
|
|
69193
|
-
this._targetChildPose.move(offset.set(0, 0, dist * (1 + move[2]) - dist));
|
|
69193
|
+
this._targetChildPose.move(offset$1.set(0, 0, dist * (1 + move[2]) - dist));
|
|
69194
69194
|
this._targetRootPose.rotate(angles.set(-rotate[1], -rotate[0], 0));
|
|
69195
69195
|
this._rootPose.lerp(this._rootPose, this._targetRootPose, damp$1(this.moveDamping, dt), damp$1(this.rotateDamping, dt), 1);
|
|
69196
69196
|
this._childPose.lerp(this._childPose, this._targetChildPose, damp$1(this.zoomDamping, dt), 1, 1);
|
|
69197
|
-
rotation$
|
|
69198
|
-
return this._pose.set(offset, this._rootPose.angles, this._childPose.position.z);
|
|
69197
|
+
rotation$2.setFromEulerAngles(this._rootPose.angles).transformVector(this._childPose.position, offset$1).add(this._rootPose.position);
|
|
69198
|
+
return this._pose.set(offset$1, this._rootPose.angles, this._childPose.position.z);
|
|
69199
69199
|
}
|
|
69200
69200
|
destroy() {
|
|
69201
69201
|
this.detach();
|
|
@@ -69459,12 +69459,12 @@ class Tooltip {
|
|
|
69459
69459
|
|
|
69460
69460
|
// Initialize the touch joystick for fly mode camera control
|
|
69461
69461
|
const initJoystick = (dom, events, state) => {
|
|
69462
|
-
// Joystick dimensions (matches SCSS: base height=
|
|
69463
|
-
const joystickHeight =
|
|
69464
|
-
const stickSize =
|
|
69465
|
-
const stickCenterY = (joystickHeight - stickSize) / 2; //
|
|
69466
|
-
const stickCenterX = (joystickHeight - stickSize) / 2; //
|
|
69467
|
-
const maxStickTravel = stickCenterY; // can travel
|
|
69462
|
+
// Joystick dimensions (matches SCSS: base height=100, stick size=40)
|
|
69463
|
+
const joystickHeight = 100;
|
|
69464
|
+
const stickSize = 40;
|
|
69465
|
+
const stickCenterY = (joystickHeight - stickSize) / 2; // 30px - top position when centered
|
|
69466
|
+
const stickCenterX = (joystickHeight - stickSize) / 2; // 30px - left position when centered (for 2D mode)
|
|
69467
|
+
const maxStickTravel = stickCenterY; // can travel 30px up or down from center
|
|
69468
69468
|
// Fixed joystick position (bottom-left corner with safe area)
|
|
69469
69469
|
const joystickFixedX = 70;
|
|
69470
69470
|
const joystickFixedY = () => window.innerHeight - 140;
|
|
@@ -69478,7 +69478,7 @@ const initJoystick = (dom, events, state) => {
|
|
|
69478
69478
|
let lastTapTime = 0;
|
|
69479
69479
|
// Update joystick visibility based on camera mode and input mode
|
|
69480
69480
|
const updateJoystickVisibility = () => {
|
|
69481
|
-
if ((state.cameraMode === 'fly' || state.cameraMode === 'fps') && state.inputMode === 'touch') {
|
|
69481
|
+
if ((state.cameraMode === 'fly' || state.cameraMode === 'fps') && state.inputMode === 'touch' && state.touchControlScheme === 'joystick') {
|
|
69482
69482
|
dom.joystickBase.classList.remove('hidden');
|
|
69483
69483
|
dom.joystickBase.classList.toggle('mode-2d', joystickMode === '2d');
|
|
69484
69484
|
dom.joystickBase.style.left = `${joystickFixedX}px`;
|
|
@@ -69498,6 +69498,7 @@ const initJoystick = (dom, events, state) => {
|
|
|
69498
69498
|
};
|
|
69499
69499
|
events.on('cameraMode:changed', updateJoystickVisibility);
|
|
69500
69500
|
events.on('inputMode:changed', updateJoystickVisibility);
|
|
69501
|
+
events.on('touchControlScheme:changed', updateJoystickVisibility);
|
|
69501
69502
|
window.addEventListener('resize', updateJoystickVisibility);
|
|
69502
69503
|
// Handle joystick touch input directly on the joystick element
|
|
69503
69504
|
const updateJoystickStick = (clientX, clientY) => {
|
|
@@ -69648,6 +69649,9 @@ const initUI = (global) => {
|
|
|
69648
69649
|
'settings', 'settingsPanel',
|
|
69649
69650
|
'orbitCamera', 'flyCamera', 'fpsCamera',
|
|
69650
69651
|
'hqCheck', 'hqOption', 'lqCheck', 'lqOption',
|
|
69652
|
+
'touchControlsDivider', 'joystickSchemeRow', 'pinchSchemeRow',
|
|
69653
|
+
'joystickSchemeCheck', 'joystickSchemeOption', 'pinchSchemeCheck', 'pinchSchemeOption',
|
|
69654
|
+
'touchFlyJoystick', 'touchFlyPinch',
|
|
69651
69655
|
'reset', 'frame',
|
|
69652
69656
|
'loadingText', 'loadingBar',
|
|
69653
69657
|
'joystickBase', 'joystick',
|
|
@@ -69706,9 +69710,17 @@ const initUI = (global) => {
|
|
|
69706
69710
|
state.isFullscreen = false;
|
|
69707
69711
|
}
|
|
69708
69712
|
};
|
|
69713
|
+
let shouldRestoreFullscreen = false;
|
|
69714
|
+
events.on('restoreFullscreen', () => {
|
|
69715
|
+
shouldRestoreFullscreen = true;
|
|
69716
|
+
});
|
|
69709
69717
|
if (hasFullscreenAPI) {
|
|
69710
69718
|
document.addEventListener('fullscreenchange', () => {
|
|
69711
69719
|
state.isFullscreen = !!document.fullscreenElement;
|
|
69720
|
+
if (!document.fullscreenElement && shouldRestoreFullscreen) {
|
|
69721
|
+
shouldRestoreFullscreen = false;
|
|
69722
|
+
requestFullscreen();
|
|
69723
|
+
}
|
|
69712
69724
|
});
|
|
69713
69725
|
}
|
|
69714
69726
|
dom.enterFullscreen.addEventListener('click', requestFullscreen);
|
|
@@ -69739,10 +69751,36 @@ const initUI = (global) => {
|
|
|
69739
69751
|
dom.hqCheck.classList[state.hqMode ? 'add' : 'remove']('active');
|
|
69740
69752
|
dom.lqCheck.classList[state.hqMode ? 'remove' : 'add']('active');
|
|
69741
69753
|
};
|
|
69742
|
-
events.on('hqMode:changed', (
|
|
69754
|
+
events.on('hqMode:changed', () => {
|
|
69743
69755
|
updateHQ();
|
|
69756
|
+
localStorage.setItem('hqMode', String(state.hqMode));
|
|
69744
69757
|
});
|
|
69745
69758
|
updateHQ();
|
|
69759
|
+
// Touch control scheme toggle (only visible on touch devices)
|
|
69760
|
+
dom.joystickSchemeOption.addEventListener('click', () => {
|
|
69761
|
+
state.touchControlScheme = 'joystick';
|
|
69762
|
+
});
|
|
69763
|
+
dom.pinchSchemeOption.addEventListener('click', () => {
|
|
69764
|
+
state.touchControlScheme = 'pinch';
|
|
69765
|
+
});
|
|
69766
|
+
const updateTouchControlScheme = () => {
|
|
69767
|
+
const isJoystick = state.touchControlScheme === 'joystick';
|
|
69768
|
+
dom.joystickSchemeCheck.classList.toggle('active', isJoystick);
|
|
69769
|
+
dom.pinchSchemeCheck.classList.toggle('active', !isJoystick);
|
|
69770
|
+
dom.touchFlyJoystick.classList.toggle('hidden', !isJoystick);
|
|
69771
|
+
dom.touchFlyPinch.classList.toggle('hidden', isJoystick);
|
|
69772
|
+
localStorage.setItem('touchControlScheme', state.touchControlScheme);
|
|
69773
|
+
};
|
|
69774
|
+
const updateTouchControlsVisibility = () => {
|
|
69775
|
+
const isTouch = state.inputMode === 'touch';
|
|
69776
|
+
dom.touchControlsDivider.classList.toggle('hidden', !isTouch);
|
|
69777
|
+
dom.joystickSchemeRow.classList.toggle('hidden', !isTouch);
|
|
69778
|
+
dom.pinchSchemeRow.classList.toggle('hidden', !isTouch);
|
|
69779
|
+
};
|
|
69780
|
+
events.on('touchControlScheme:changed', updateTouchControlScheme);
|
|
69781
|
+
events.on('inputMode:changed', updateTouchControlsVisibility);
|
|
69782
|
+
updateTouchControlScheme();
|
|
69783
|
+
updateTouchControlsVisibility();
|
|
69746
69784
|
// AR/VR
|
|
69747
69785
|
const arChanged = () => dom.arMode.classList[state.hasAR ? 'remove' : 'add']('hidden');
|
|
69748
69786
|
const vrChanged = () => dom.vrMode.classList[state.hasVR ? 'remove' : 'add']('hidden');
|
|
@@ -70861,7 +70899,7 @@ class AnimController {
|
|
|
70861
70899
|
}
|
|
70862
70900
|
}
|
|
70863
70901
|
|
|
70864
|
-
const rotation = new Quat();
|
|
70902
|
+
const rotation$1 = new Quat();
|
|
70865
70903
|
const avec = new Vec3();
|
|
70866
70904
|
const bvec = new Vec3();
|
|
70867
70905
|
class Camera {
|
|
@@ -70896,7 +70934,7 @@ class Camera {
|
|
|
70896
70934
|
vecToAngles(this.angles, dir);
|
|
70897
70935
|
}
|
|
70898
70936
|
calcFocusPoint(result) {
|
|
70899
|
-
rotation.setFromEulerAngles(this.angles)
|
|
70937
|
+
rotation$1.setFromEulerAngles(this.angles)
|
|
70900
70938
|
.transformVector(Vec3.FORWARD, result)
|
|
70901
70939
|
.mulScalar(this.distance)
|
|
70902
70940
|
.add(this.position);
|
|
@@ -70907,7 +70945,7 @@ class Camera {
|
|
|
70907
70945
|
const CAMERA_RADIUS = 0.2;
|
|
70908
70946
|
const p$1 = new Pose();
|
|
70909
70947
|
/** Pre-allocated push-out vector for sphere collision */
|
|
70910
|
-
const pushOut
|
|
70948
|
+
const pushOut = { x: 0, y: 0, z: 0 };
|
|
70911
70949
|
class FlyController {
|
|
70912
70950
|
controller;
|
|
70913
70951
|
/** Optional voxel collider for sphere collision with sliding */
|
|
@@ -70937,19 +70975,19 @@ class FlyController {
|
|
|
70937
70975
|
const tvx = -target.position.x;
|
|
70938
70976
|
const tvy = -target.position.y;
|
|
70939
70977
|
const tvz = target.position.z;
|
|
70940
|
-
if (this.collider.querySphere(tvx, tvy, tvz, CAMERA_RADIUS, pushOut
|
|
70941
|
-
target.position.x += -pushOut
|
|
70942
|
-
target.position.y += -pushOut
|
|
70943
|
-
target.position.z += pushOut
|
|
70978
|
+
if (this.collider.querySphere(tvx, tvy, tvz, CAMERA_RADIUS, pushOut)) {
|
|
70979
|
+
target.position.x += -pushOut.x;
|
|
70980
|
+
target.position.y += -pushOut.y;
|
|
70981
|
+
target.position.z += pushOut.z;
|
|
70944
70982
|
}
|
|
70945
70983
|
// Now resolve collision on the interpolated pose (_pose).
|
|
70946
70984
|
const vx = -pose.position.x;
|
|
70947
70985
|
const vy = -pose.position.y;
|
|
70948
70986
|
const vz = pose.position.z;
|
|
70949
|
-
if (this.collider.querySphere(vx, vy, vz, CAMERA_RADIUS, pushOut
|
|
70950
|
-
pose.position.x += -pushOut
|
|
70951
|
-
pose.position.y += -pushOut
|
|
70952
|
-
pose.position.z += pushOut
|
|
70987
|
+
if (this.collider.querySphere(vx, vy, vz, CAMERA_RADIUS, pushOut)) {
|
|
70988
|
+
pose.position.x += -pushOut.x;
|
|
70989
|
+
pose.position.y += -pushOut.y;
|
|
70990
|
+
pose.position.z += pushOut.z;
|
|
70953
70991
|
}
|
|
70954
70992
|
}
|
|
70955
70993
|
camera.position.copy(pose.position);
|
|
@@ -70962,7 +71000,13 @@ class FlyController {
|
|
|
70962
71000
|
}
|
|
70963
71001
|
|
|
70964
71002
|
/** Pre-allocated push-out vector for capsule collision */
|
|
70965
|
-
const
|
|
71003
|
+
const out = { x: 0, y: 0, z: 0 };
|
|
71004
|
+
const v = new Vec3();
|
|
71005
|
+
const d = new Vec3();
|
|
71006
|
+
const forward = new Vec3();
|
|
71007
|
+
const right = new Vec3();
|
|
71008
|
+
const offset = new Vec3();
|
|
71009
|
+
const rotation = new Quat();
|
|
70966
71010
|
/**
|
|
70967
71011
|
* First-person shooter style camera controller with gravity and capsule collision.
|
|
70968
71012
|
*
|
|
@@ -70971,97 +71015,102 @@ const pushOut = { x: 0, y: 0, z: 0 };
|
|
|
70971
71015
|
* voxel grid. The camera is positioned at eye height within the capsule.
|
|
70972
71016
|
*/
|
|
70973
71017
|
class FpsController {
|
|
70974
|
-
/**
|
|
71018
|
+
/**
|
|
71019
|
+
* Optional voxel collider for capsule collision with sliding
|
|
71020
|
+
*/
|
|
70975
71021
|
collider = null;
|
|
70976
|
-
/**
|
|
71022
|
+
/**
|
|
71023
|
+
* Total capsule height in meters (default: human proportion)
|
|
71024
|
+
*/
|
|
70977
71025
|
capsuleHeight = 1.8;
|
|
70978
|
-
/**
|
|
71026
|
+
/**
|
|
71027
|
+
* Capsule radius in meters
|
|
71028
|
+
*/
|
|
70979
71029
|
capsuleRadius = 0.3;
|
|
70980
|
-
/**
|
|
71030
|
+
/**
|
|
71031
|
+
* Camera height from the bottom of the capsule in meters
|
|
71032
|
+
*/
|
|
70981
71033
|
eyeHeight = 1.6;
|
|
70982
|
-
/**
|
|
71034
|
+
/**
|
|
71035
|
+
* Gravity acceleration in m/s^2
|
|
71036
|
+
*/
|
|
70983
71037
|
gravity = 9.8;
|
|
70984
|
-
/**
|
|
71038
|
+
/**
|
|
71039
|
+
* Jump velocity in m/s
|
|
71040
|
+
*/
|
|
70985
71041
|
jumpSpeed = 5;
|
|
70986
|
-
/**
|
|
71042
|
+
/**
|
|
71043
|
+
* Movement speed in m/s when grounded
|
|
71044
|
+
*/
|
|
71045
|
+
moveGroundSpeed = 10;
|
|
71046
|
+
/**
|
|
71047
|
+
* Movement speed in m/s when in the air (for air control)
|
|
71048
|
+
*/
|
|
71049
|
+
moveAirSpeed = 1;
|
|
71050
|
+
/**
|
|
71051
|
+
* Movement damping factor (0 = no damping, 1 = full damping)
|
|
71052
|
+
*/
|
|
70987
71053
|
moveDamping = 0.97;
|
|
70988
|
-
/**
|
|
71054
|
+
/**
|
|
71055
|
+
* Rotation damping factor (0 = no damping, 1 = full damping)
|
|
71056
|
+
*/
|
|
70989
71057
|
rotateDamping = 0.97;
|
|
70990
|
-
|
|
70991
|
-
|
|
70992
|
-
|
|
70993
|
-
|
|
70994
|
-
|
|
71058
|
+
/**
|
|
71059
|
+
* Velocity damping factor when grounded (0 = no damping, 1 = full damping)
|
|
71060
|
+
*/
|
|
71061
|
+
velocityDampingGround = 0.99;
|
|
71062
|
+
/**
|
|
71063
|
+
* Velocity damping factor when in the air (0 = no damping, 1 = full damping)
|
|
71064
|
+
*/
|
|
71065
|
+
velocityDampingAir = 0.99925;
|
|
70995
71066
|
_position = new Vec3();
|
|
70996
|
-
|
|
70997
|
-
|
|
70998
|
-
|
|
70999
|
-
|
|
71000
|
-
// Whether the capsule is resting on the ground
|
|
71001
|
-
_onGround = false;
|
|
71067
|
+
_angles = new Vec3();
|
|
71068
|
+
_velocity = new Vec3();
|
|
71069
|
+
_grounded = false;
|
|
71070
|
+
_jumping = false;
|
|
71002
71071
|
onEnter(camera) {
|
|
71003
|
-
this.
|
|
71004
|
-
this.
|
|
71005
|
-
|
|
71006
|
-
|
|
71007
|
-
|
|
71008
|
-
|
|
71009
|
-
|
|
71010
|
-
|
|
71011
|
-
this._onGround = false;
|
|
71072
|
+
this.goto(camera);
|
|
71073
|
+
if (this.collider) {
|
|
71074
|
+
this._checkCollision(this._position, d);
|
|
71075
|
+
if (d.y > 0) {
|
|
71076
|
+
this._grounded = true;
|
|
71077
|
+
this._velocity.y = 0;
|
|
71078
|
+
}
|
|
71079
|
+
}
|
|
71012
71080
|
}
|
|
71013
71081
|
update(deltaTime, inputFrame, camera) {
|
|
71014
71082
|
const { move, rotate } = inputFrame.read();
|
|
71015
|
-
//
|
|
71016
|
-
this.
|
|
71017
|
-
|
|
71018
|
-
const rotateLerp = damp(this.rotateDamping, deltaTime);
|
|
71019
|
-
this._yaw = math.lerpAngle(this._yaw, this._targetYaw, rotateLerp);
|
|
71020
|
-
this._pitch = math.lerp(this._pitch, this._targetPitch, rotateLerp);
|
|
71021
|
-
// Normalize yaw to prevent floating-point drift over long sessions.
|
|
71022
|
-
// Shift both values by the same multiple of 360 to preserve their delta.
|
|
71023
|
-
const yawOffset = Math.round(this._yaw / 360) * 360;
|
|
71024
|
-
if (yawOffset !== 0) {
|
|
71025
|
-
this._yaw -= yawOffset;
|
|
71026
|
-
this._targetYaw -= yawOffset;
|
|
71027
|
-
}
|
|
71028
|
-
// --- Horizontal movement ---
|
|
71029
|
-
// Compute forward/right from yaw only (ignore pitch for movement)
|
|
71030
|
-
const yawRad = this._targetYaw * math.DEG_TO_RAD;
|
|
71031
|
-
const sinYaw = Math.sin(yawRad);
|
|
71032
|
-
const cosYaw = Math.cos(yawRad);
|
|
71033
|
-
// PlayCanvas convention: forward = -Z, right = +X
|
|
71034
|
-
const forwardX = -sinYaw;
|
|
71035
|
-
const forwardZ = -cosYaw;
|
|
71036
|
-
const rightX = cosYaw;
|
|
71037
|
-
const rightZ = -sinYaw;
|
|
71038
|
-
const moveLerp = damp(this.moveDamping, deltaTime);
|
|
71039
|
-
this._targetPosition.x += rightX * move[0] + forwardX * move[2];
|
|
71040
|
-
this._targetPosition.z += rightZ * move[0] + forwardZ * move[2];
|
|
71041
|
-
// --- Jump ---
|
|
71042
|
-
if (move[1] > 0 && this._onGround) {
|
|
71043
|
-
this._velocityY = this.jumpSpeed;
|
|
71044
|
-
this._onGround = false;
|
|
71083
|
+
// jump
|
|
71084
|
+
if (this._velocity.y < 0) {
|
|
71085
|
+
this._jumping = false;
|
|
71045
71086
|
}
|
|
71046
|
-
|
|
71047
|
-
|
|
71048
|
-
|
|
71049
|
-
|
|
71050
|
-
if (this.collider) {
|
|
71051
|
-
this._resolveCapsuleCollision(this._targetPosition, true);
|
|
71087
|
+
if (move[1] && !this._jumping && this._grounded) {
|
|
71088
|
+
this._jumping = true;
|
|
71089
|
+
this._velocity.y = this.jumpSpeed;
|
|
71090
|
+
this._grounded = false;
|
|
71052
71091
|
}
|
|
71053
|
-
//
|
|
71054
|
-
this.
|
|
71055
|
-
|
|
71056
|
-
|
|
71057
|
-
this.
|
|
71058
|
-
//
|
|
71059
|
-
|
|
71060
|
-
|
|
71061
|
-
|
|
71062
|
-
|
|
71092
|
+
// gravity
|
|
71093
|
+
this._velocity.y -= this.gravity * deltaTime;
|
|
71094
|
+
// rotate
|
|
71095
|
+
this._angles.add(v.set(-rotate[1], -rotate[0], 0));
|
|
71096
|
+
this._angles.x = math.clamp(this._angles.x, -90, 90);
|
|
71097
|
+
// move
|
|
71098
|
+
rotation.setFromEulerAngles(0, this._angles.y, 0);
|
|
71099
|
+
rotation.transformVector(Vec3.FORWARD, forward);
|
|
71100
|
+
rotation.transformVector(Vec3.RIGHT, right);
|
|
71101
|
+
offset.set(0, 0, 0);
|
|
71102
|
+
offset.add(forward.mulScalar(move[2]));
|
|
71103
|
+
offset.add(right.mulScalar(move[0]));
|
|
71104
|
+
this._velocity.add(offset.mulScalar(this._grounded ? this.moveGroundSpeed : this.moveAirSpeed));
|
|
71105
|
+
const alpha = damp(this._grounded ? this.velocityDampingGround : this.velocityDampingAir, deltaTime);
|
|
71106
|
+
this._velocity.x = math.lerp(this._velocity.x, 0, alpha);
|
|
71107
|
+
this._velocity.z = math.lerp(this._velocity.z, 0, alpha);
|
|
71108
|
+
this._position.add(v.copy(this._velocity).mulScalar(deltaTime));
|
|
71109
|
+
// collision check
|
|
71110
|
+
this._checkCollision(this._position, d);
|
|
71111
|
+
// update camera
|
|
71063
71112
|
camera.position.copy(this._position);
|
|
71064
|
-
camera.angles.set(this.
|
|
71113
|
+
camera.angles.set(this._angles.x, this._angles.y, 0);
|
|
71065
71114
|
}
|
|
71066
71115
|
onExit(_camera) {
|
|
71067
71116
|
// nothing to clean up
|
|
@@ -71072,54 +71121,48 @@ class FpsController {
|
|
|
71072
71121
|
* @param camera - The camera state to jump to.
|
|
71073
71122
|
*/
|
|
71074
71123
|
goto(camera) {
|
|
71124
|
+
// position
|
|
71075
71125
|
this._position.copy(camera.position);
|
|
71076
|
-
|
|
71077
|
-
this.
|
|
71078
|
-
|
|
71079
|
-
this.
|
|
71080
|
-
this.
|
|
71081
|
-
this.
|
|
71082
|
-
this._onGround = false;
|
|
71126
|
+
// angles (clamp pitch to avoid gimbal lock)
|
|
71127
|
+
this._angles.set(camera.angles.x, camera.angles.y, 0);
|
|
71128
|
+
// reset velocity and state
|
|
71129
|
+
this._velocity.set(0, 0, 0);
|
|
71130
|
+
this._grounded = false;
|
|
71131
|
+
this._jumping = false;
|
|
71083
71132
|
}
|
|
71084
71133
|
/**
|
|
71085
|
-
*
|
|
71086
|
-
* Converts from PlayCanvas space to voxel space, queries the capsule, and
|
|
71087
|
-
* applies the push-out vector back to PlayCanvas space.
|
|
71134
|
+
* Check for collision and apply displacement to the position.
|
|
71088
71135
|
*
|
|
71089
|
-
* @param
|
|
71090
|
-
* @param
|
|
71136
|
+
* @param pos - eye position in playcanvas world space
|
|
71137
|
+
* @param disp - pre-allocated vector to receive the collision push-out displacement
|
|
71138
|
+
* @returns - the displaced position (same as input position vector for chaining)
|
|
71091
71139
|
*/
|
|
71092
|
-
|
|
71093
|
-
//
|
|
71140
|
+
_checkCollision(pos, disp) {
|
|
71141
|
+
// derive capsule center from eye position in PlayCanvas space:
|
|
71094
71142
|
// bottom of capsule = eyePos.y - eyeHeight
|
|
71095
71143
|
// capsule center = eyePos.y - eyeHeight + capsuleHeight / 2
|
|
71096
|
-
const
|
|
71097
|
-
const
|
|
71098
|
-
//
|
|
71099
|
-
const vx = -
|
|
71100
|
-
const vy = -
|
|
71101
|
-
const vz =
|
|
71102
|
-
if (this.collider.queryCapsule(vx, vy, vz,
|
|
71103
|
-
//
|
|
71104
|
-
|
|
71105
|
-
|
|
71106
|
-
|
|
71107
|
-
|
|
71108
|
-
|
|
71109
|
-
|
|
71110
|
-
|
|
71111
|
-
|
|
71112
|
-
if
|
|
71113
|
-
|
|
71114
|
-
|
|
71115
|
-
this._onGround = true;
|
|
71116
|
-
}
|
|
71117
|
-
// Ceiling detection: if pushed downward and rising, cancel upward velocity
|
|
71118
|
-
if (pushPCY < 0 && this._velocityY > 0) {
|
|
71119
|
-
this._velocityY = 0;
|
|
71120
|
-
}
|
|
71144
|
+
const center = pos.y - this.eyeHeight + this.capsuleHeight * 0.5;
|
|
71145
|
+
const half = this.capsuleHeight * 0.5 - this.capsuleRadius;
|
|
71146
|
+
// convert to voxel space (negate X, negate Y, keep Z)
|
|
71147
|
+
const vx = -pos.x;
|
|
71148
|
+
const vy = -center;
|
|
71149
|
+
const vz = pos.z;
|
|
71150
|
+
if (this.collider.queryCapsule(vx, vy, vz, half, this.capsuleRadius, out)) {
|
|
71151
|
+
// push out vector to playcanvas space
|
|
71152
|
+
disp.set(-out.x, -out.y, out.z);
|
|
71153
|
+
// apply displacement
|
|
71154
|
+
pos.add(disp);
|
|
71155
|
+
// ground collision: if pushed upward and falling, cancel downward velocity and set grounded
|
|
71156
|
+
if (disp.y > 0 && this._velocity.y < 0) {
|
|
71157
|
+
this._velocity.y = 0;
|
|
71158
|
+
this._grounded = true;
|
|
71159
|
+
}
|
|
71160
|
+
// ceiling collision: if pushed downward and rising, cancel upward velocity
|
|
71161
|
+
if (disp.y < 0 && this._velocity.y > 0) {
|
|
71162
|
+
this._velocity.y = 0;
|
|
71121
71163
|
}
|
|
71122
71164
|
}
|
|
71165
|
+
return disp;
|
|
71123
71166
|
}
|
|
71124
71167
|
}
|
|
71125
71168
|
|
|
@@ -71285,13 +71328,15 @@ class CameraManager {
|
|
|
71285
71328
|
}
|
|
71286
71329
|
}
|
|
71287
71330
|
break;
|
|
71331
|
+
case 'exitFps':
|
|
71332
|
+
if (state.cameraMode === 'fps') {
|
|
71333
|
+
state.cameraMode = preFpsMode;
|
|
71334
|
+
}
|
|
71335
|
+
break;
|
|
71288
71336
|
case 'cancel':
|
|
71289
71337
|
if (state.cameraMode === 'anim') {
|
|
71290
71338
|
state.cameraMode = fromMode;
|
|
71291
71339
|
}
|
|
71292
|
-
else if (state.cameraMode === 'fps') {
|
|
71293
|
-
state.cameraMode = preFpsMode;
|
|
71294
|
-
}
|
|
71295
71340
|
break;
|
|
71296
71341
|
case 'interrupt':
|
|
71297
71342
|
if (state.cameraMode === 'anim') {
|
|
@@ -71512,11 +71557,14 @@ const tmpV1 = new Vec3();
|
|
|
71512
71557
|
const tmpV2 = new Vec3();
|
|
71513
71558
|
const mouseRotate = new Vec3();
|
|
71514
71559
|
const flyMove = new Vec3();
|
|
71560
|
+
const flyTouchPan = new Vec3();
|
|
71515
71561
|
const pinchMove = new Vec3();
|
|
71516
71562
|
const orbitRotate = new Vec3();
|
|
71517
71563
|
const flyRotate = new Vec3();
|
|
71518
71564
|
const stickMove = new Vec3();
|
|
71519
71565
|
const stickRotate = new Vec3();
|
|
71566
|
+
/** Maximum accumulated touch movement (px) to still count as a tap */
|
|
71567
|
+
const TAP_EPSILON = 15;
|
|
71520
71568
|
/**
|
|
71521
71569
|
* Converts screen space mouse deltas to world space pan vector.
|
|
71522
71570
|
*
|
|
@@ -71590,9 +71638,20 @@ class InputController {
|
|
|
71590
71638
|
move: [0, 0, 0],
|
|
71591
71639
|
rotate: [0, 0, 0]
|
|
71592
71640
|
});
|
|
71593
|
-
// Touch joystick input values (-1 to 1)
|
|
71594
|
-
|
|
71595
|
-
|
|
71641
|
+
// Touch joystick input values [x, y] (-1 to 1)
|
|
71642
|
+
_touchJoystick = [0, 0];
|
|
71643
|
+
// Accumulated forward/backward velocity from pinch gesture (-1 to 1)
|
|
71644
|
+
_pinchVelocity = 0;
|
|
71645
|
+
// Accumulated strafe/vertical velocity from two-finger pan [x, y] (-1 to 1)
|
|
71646
|
+
_panVelocity = [0, 0];
|
|
71647
|
+
// Sensitivity for pinch delta → velocity conversion
|
|
71648
|
+
pinchVelocitySensitivity = 0.006;
|
|
71649
|
+
// Sensitivity for two-finger pan delta → velocity conversion
|
|
71650
|
+
panVelocitySensitivity = 0.005;
|
|
71651
|
+
// Tap-to-jump state (uses existing MultiTouchSource count/touch deltas)
|
|
71652
|
+
_tapTouches = 0;
|
|
71653
|
+
_tapDelta = 0;
|
|
71654
|
+
_tapJump = false;
|
|
71596
71655
|
// this gets overridden by the viewer based on scene size
|
|
71597
71656
|
moveSpeed = 4;
|
|
71598
71657
|
orbitSpeed = 18;
|
|
@@ -71606,8 +71665,8 @@ class InputController {
|
|
|
71606
71665
|
this._orbitInput.attach(canvas);
|
|
71607
71666
|
// Listen for joystick input from the UI (touch joystick element)
|
|
71608
71667
|
events.on('joystickInput', (value) => {
|
|
71609
|
-
this.
|
|
71610
|
-
this.
|
|
71668
|
+
this._touchJoystick[0] = value.x;
|
|
71669
|
+
this._touchJoystick[1] = value.y;
|
|
71611
71670
|
});
|
|
71612
71671
|
this.global = global;
|
|
71613
71672
|
// Generate input events
|
|
@@ -71641,6 +71700,8 @@ class InputController {
|
|
|
71641
71700
|
events.on('inputEvent', async (eventName, event) => {
|
|
71642
71701
|
switch (eventName) {
|
|
71643
71702
|
case 'dblclick': {
|
|
71703
|
+
if (state.cameraMode === 'fps')
|
|
71704
|
+
break;
|
|
71644
71705
|
if (!picker) {
|
|
71645
71706
|
picker = new Picker(app, camera);
|
|
71646
71707
|
}
|
|
@@ -71658,48 +71719,97 @@ class InputController {
|
|
|
71658
71719
|
state.inputMode = event.pointerType === 'touch' ? 'touch' : 'desktop';
|
|
71659
71720
|
});
|
|
71660
71721
|
});
|
|
71722
|
+
let recentlyExitedFps = false;
|
|
71661
71723
|
// handle keyboard events
|
|
71662
71724
|
window.addEventListener('keydown', (event) => {
|
|
71663
71725
|
if (event.key === 'Escape') {
|
|
71664
|
-
|
|
71726
|
+
if (recentlyExitedFps) ;
|
|
71727
|
+
else if (state.cameraMode === 'fps') {
|
|
71728
|
+
events.fire('inputEvent', 'exitFps', event);
|
|
71729
|
+
}
|
|
71730
|
+
else {
|
|
71731
|
+
events.fire('inputEvent', 'cancel', event);
|
|
71732
|
+
}
|
|
71665
71733
|
}
|
|
71666
|
-
else if (
|
|
71734
|
+
else if (!event.ctrlKey && !event.altKey && !event.metaKey) {
|
|
71667
71735
|
switch (event.key) {
|
|
71668
|
-
case '
|
|
71669
|
-
|
|
71736
|
+
case '1':
|
|
71737
|
+
state.cameraMode = 'orbit';
|
|
71670
71738
|
break;
|
|
71671
|
-
case '
|
|
71672
|
-
|
|
71739
|
+
case '2':
|
|
71740
|
+
state.cameraMode = 'fly';
|
|
71673
71741
|
break;
|
|
71674
|
-
case '
|
|
71675
|
-
events.fire('inputEvent', '
|
|
71742
|
+
case '3':
|
|
71743
|
+
events.fire('inputEvent', 'toggleFps');
|
|
71676
71744
|
break;
|
|
71677
71745
|
}
|
|
71746
|
+
if (state.cameraMode !== 'fps') {
|
|
71747
|
+
switch (event.key) {
|
|
71748
|
+
case 'f':
|
|
71749
|
+
events.fire('inputEvent', 'frame', event);
|
|
71750
|
+
break;
|
|
71751
|
+
case 'r':
|
|
71752
|
+
events.fire('inputEvent', 'reset', event);
|
|
71753
|
+
break;
|
|
71754
|
+
case ' ':
|
|
71755
|
+
events.fire('inputEvent', 'playPause', event);
|
|
71756
|
+
break;
|
|
71757
|
+
}
|
|
71758
|
+
}
|
|
71678
71759
|
}
|
|
71679
71760
|
});
|
|
71761
|
+
// Lock/unlock Escape key in fullscreen to prevent the browser from
|
|
71762
|
+
// exiting both pointer lock and fullscreen on the same Escape press.
|
|
71763
|
+
const lockEscape = () => {
|
|
71764
|
+
if ('keyboard' in navigator && 'lock' in navigator.keyboard) {
|
|
71765
|
+
navigator.keyboard.lock(['Escape']).catch(() => { });
|
|
71766
|
+
}
|
|
71767
|
+
};
|
|
71768
|
+
const unlockKeyboard = () => {
|
|
71769
|
+
if ('keyboard' in navigator && 'unlock' in navigator.keyboard) {
|
|
71770
|
+
navigator.keyboard.unlock();
|
|
71771
|
+
}
|
|
71772
|
+
};
|
|
71680
71773
|
// Pointer lock management for FPS mode on desktop
|
|
71681
71774
|
events.on('cameraMode:changed', (value, prev) => {
|
|
71682
71775
|
if (value === 'fps' && state.inputMode === 'desktop') {
|
|
71683
71776
|
this._desktopInput._pointerLock = true;
|
|
71684
71777
|
canvas.requestPointerLock();
|
|
71778
|
+
if (state.isFullscreen) {
|
|
71779
|
+
lockEscape();
|
|
71780
|
+
}
|
|
71685
71781
|
}
|
|
71686
71782
|
else if (prev === 'fps') {
|
|
71783
|
+
unlockKeyboard();
|
|
71687
71784
|
this._desktopInput._pointerLock = false;
|
|
71688
71785
|
if (document.pointerLockElement === canvas) {
|
|
71786
|
+
if (state.isFullscreen) {
|
|
71787
|
+
events.fire('restoreFullscreen');
|
|
71788
|
+
}
|
|
71689
71789
|
document.exitPointerLock();
|
|
71690
71790
|
}
|
|
71691
71791
|
}
|
|
71692
71792
|
});
|
|
71793
|
+
// Also lock Escape if entering fullscreen while already in FPS mode
|
|
71794
|
+
events.on('isFullscreen:changed', (value) => {
|
|
71795
|
+
if (value && state.cameraMode === 'fps' && state.inputMode === 'desktop') {
|
|
71796
|
+
lockEscape();
|
|
71797
|
+
}
|
|
71798
|
+
});
|
|
71693
71799
|
document.addEventListener('pointerlockchange', () => {
|
|
71694
71800
|
if (!document.pointerLockElement && state.cameraMode === 'fps') {
|
|
71695
|
-
|
|
71801
|
+
recentlyExitedFps = true;
|
|
71802
|
+
requestAnimationFrame(() => {
|
|
71803
|
+
recentlyExitedFps = false;
|
|
71804
|
+
});
|
|
71805
|
+
events.fire('inputEvent', 'exitFps');
|
|
71696
71806
|
}
|
|
71697
71807
|
});
|
|
71698
71808
|
// Pointer lock request rejected (e.g., no user gesture, document hidden).
|
|
71699
71809
|
// Revert to avoid being stuck in FPS mode without mouse capture.
|
|
71700
71810
|
document.addEventListener('pointerlockerror', () => {
|
|
71701
71811
|
this._desktopInput._pointerLock = false;
|
|
71702
|
-
events.fire('inputEvent', '
|
|
71812
|
+
events.fire('inputEvent', 'exitFps');
|
|
71703
71813
|
});
|
|
71704
71814
|
}
|
|
71705
71815
|
/**
|
|
@@ -71725,7 +71835,45 @@ class InputController {
|
|
|
71725
71835
|
this._state.shift += key[keyCode.SHIFT];
|
|
71726
71836
|
this._state.ctrl += key[keyCode.CTRL];
|
|
71727
71837
|
const isFps = state.cameraMode === 'fps';
|
|
71838
|
+
// Tap-to-jump detection using existing MultiTouchSource deltas
|
|
71839
|
+
if (isFps) {
|
|
71840
|
+
const prevTaps = this._tapTouches;
|
|
71841
|
+
this._tapTouches = Math.max(0, this._tapTouches + count[0]);
|
|
71842
|
+
// Touch just started (0 → 1+)
|
|
71843
|
+
if (prevTaps === 0 && this._tapTouches > 0) {
|
|
71844
|
+
this._tapDelta = 0;
|
|
71845
|
+
}
|
|
71846
|
+
// Accumulate movement while touch is active
|
|
71847
|
+
if (this._tapTouches > 0) {
|
|
71848
|
+
this._tapDelta += Math.abs(touch[0]) + Math.abs(touch[1]);
|
|
71849
|
+
}
|
|
71850
|
+
// Touch just ended (1+ → 0): check if it was a tap
|
|
71851
|
+
if (prevTaps > 0 && this._tapTouches === 0) {
|
|
71852
|
+
if (this._tapDelta < TAP_EPSILON) {
|
|
71853
|
+
this._tapJump = true;
|
|
71854
|
+
}
|
|
71855
|
+
}
|
|
71856
|
+
}
|
|
71857
|
+
else {
|
|
71858
|
+
this._tapTouches = 0;
|
|
71859
|
+
}
|
|
71728
71860
|
const isFirstPerson = state.cameraMode === 'fly' || isFps;
|
|
71861
|
+
// Accumulate pinch and pan deltas into velocity when using pinch control scheme
|
|
71862
|
+
// pinch[0] = oldDist - newDist: negative when spreading, positive when closing
|
|
71863
|
+
// Spreading = forward → subtract pinch delta
|
|
71864
|
+
if (isFirstPerson && state.touchControlScheme === 'pinch' && this._state.touches > 1) {
|
|
71865
|
+
this._pinchVelocity -= pinch[0] * this.pinchVelocitySensitivity;
|
|
71866
|
+
this._pinchVelocity = math.clamp(this._pinchVelocity, -1, 1.0);
|
|
71867
|
+
this._panVelocity[0] += touch[0] * this.panVelocitySensitivity;
|
|
71868
|
+
this._panVelocity[0] = math.clamp(this._panVelocity[0], -1, 1.0);
|
|
71869
|
+
this._panVelocity[1] += touch[1] * this.panVelocitySensitivity;
|
|
71870
|
+
this._panVelocity[1] = math.clamp(this._panVelocity[1], -1, 1.0);
|
|
71871
|
+
}
|
|
71872
|
+
else if (isFirstPerson && this._state.touches <= 1) {
|
|
71873
|
+
this._pinchVelocity = 0;
|
|
71874
|
+
this._panVelocity[0] = 0;
|
|
71875
|
+
this._panVelocity[1] = 0;
|
|
71876
|
+
}
|
|
71729
71877
|
if (!isFirstPerson && this._state.axis.length() > 0) {
|
|
71730
71878
|
events.fire('inputEvent', 'requestFirstPerson');
|
|
71731
71879
|
}
|
|
@@ -71743,7 +71891,10 @@ class InputController {
|
|
|
71743
71891
|
keyMove.y = 0;
|
|
71744
71892
|
}
|
|
71745
71893
|
keyMove.normalize();
|
|
71746
|
-
|
|
71894
|
+
const shiftMul = isFps ? 2 : 4;
|
|
71895
|
+
const ctrlMul = isFps ? 0.5 : 0.25;
|
|
71896
|
+
const speed = this.moveSpeed * (this._state.shift ? shiftMul : this._state.ctrl ? ctrlMul : 1);
|
|
71897
|
+
v.add(keyMove.mulScalar(fly * speed * dt));
|
|
71747
71898
|
if (isFps) {
|
|
71748
71899
|
// Pass jump signal as raw Y; FPS controller uses move[1] > 0 as boolean trigger
|
|
71749
71900
|
v.y = this._state.jump > 0 ? 1 : 0;
|
|
@@ -71763,19 +71914,33 @@ class InputController {
|
|
|
71763
71914
|
v.set(0, 0, 0);
|
|
71764
71915
|
const orbitMove = screenToWorld(camera, touch[0], touch[1], distance);
|
|
71765
71916
|
v.add(orbitMove.mulScalar(orbit * pan));
|
|
71766
|
-
|
|
71767
|
-
|
|
71768
|
-
|
|
71917
|
+
if (state.touchControlScheme === 'joystick') {
|
|
71918
|
+
// Use touch joystick values for fly movement (X = strafe, Y = forward/backward)
|
|
71919
|
+
flyMove.set(this._touchJoystick[0], 0, -this._touchJoystick[1]);
|
|
71920
|
+
v.add(flyMove.mulScalar(fly * this.moveSpeed * dt));
|
|
71921
|
+
}
|
|
71922
|
+
else {
|
|
71923
|
+
// Pan velocity → strafe (X) and vertical (Y, fly only — FPS uses gravity)
|
|
71924
|
+
flyTouchPan.set(this._panVelocity[0], isFps ? 0 : -this._panVelocity[1], 0);
|
|
71925
|
+
v.add(flyTouchPan.mulScalar(fly * 1.5 * this.moveSpeed * dt));
|
|
71926
|
+
// Pinch velocity → forward/backward
|
|
71927
|
+
flyMove.set(0, 0, this._pinchVelocity);
|
|
71928
|
+
v.add(flyMove.mulScalar(fly * 1.5 * this.moveSpeed * dt));
|
|
71929
|
+
}
|
|
71769
71930
|
pinchMove.set(0, 0, pinch[0]);
|
|
71770
71931
|
v.add(pinchMove.mulScalar(orbit * double * this.pinchSpeed * dt));
|
|
71932
|
+
// Tap-to-jump for mobile FPS mode
|
|
71933
|
+
if (isFps && this._tapJump) {
|
|
71934
|
+
v.y = 1;
|
|
71935
|
+
this._tapJump = false;
|
|
71936
|
+
}
|
|
71771
71937
|
deltas.move.append([v.x, v.y, v.z]);
|
|
71772
71938
|
// mobile rotate
|
|
71773
71939
|
v.set(0, 0, 0);
|
|
71774
71940
|
orbitRotate.set(touch[0], touch[1], 0);
|
|
71775
71941
|
v.add(orbitRotate.mulScalar(orbit * (1 - pan) * this.orbitSpeed * dt));
|
|
71776
|
-
// In fly mode, use
|
|
71777
|
-
// Exclude multi-touch (double) to avoid interference with pinch gestures
|
|
71778
|
-
// 1.25x sensitivity for touch look-around
|
|
71942
|
+
// In fly mode, use single touch for look-around (inverted direction)
|
|
71943
|
+
// Exclude multi-touch (double) to avoid interference with pinch/strafe gestures
|
|
71779
71944
|
flyRotate.set(touch[0], touch[1], 0);
|
|
71780
71945
|
v.add(flyRotate.mulScalar(fly * (1 - double) * this.orbitSpeed * orbitFactor * 1.25 * dt));
|
|
71781
71946
|
deltas.rotate.append([v.x, v.y, v.z]);
|
|
@@ -72495,20 +72660,11 @@ class Viewer {
|
|
|
72495
72660
|
wgsl.set('skyboxPS', wgsl.get('skyboxPS').replace('mapRoughnessUv(uv, uniform.mipLevel)', 'uv'));
|
|
72496
72661
|
// disable auto render, we'll render only when camera changes
|
|
72497
72662
|
app.autoRender = false;
|
|
72498
|
-
// apply camera animation settings
|
|
72499
|
-
camera.camera.aspectRatio = graphicsDevice.width / graphicsDevice.height;
|
|
72500
72663
|
// configure the camera
|
|
72501
72664
|
this.configureCamera(settings);
|
|
72502
72665
|
// reconfigure camera when entering/exiting XR
|
|
72503
72666
|
app.xr.on('start', () => this.configureCamera(settings));
|
|
72504
72667
|
app.xr.on('end', () => this.configureCamera(settings));
|
|
72505
|
-
// handle horizontal fov on canvas resize
|
|
72506
|
-
const updateHorizontalFov = () => {
|
|
72507
|
-
camera.camera.horizontalFov = graphicsDevice.width > graphicsDevice.height;
|
|
72508
|
-
app.renderNextFrame = true;
|
|
72509
|
-
};
|
|
72510
|
-
graphicsDevice.on('resizecanvas', updateHorizontalFov);
|
|
72511
|
-
updateHorizontalFov();
|
|
72512
72668
|
// construct debug ministats
|
|
72513
72669
|
if (config.ministats) {
|
|
72514
72670
|
const options = MiniStats.getDefaultOptions();
|
|
@@ -72563,6 +72719,7 @@ class Viewer {
|
|
|
72563
72719
|
cameraEntity.setPosition(camera.position);
|
|
72564
72720
|
cameraEntity.setEulerAngles(camera.angles);
|
|
72565
72721
|
cameraEntity.camera.fov = camera.fov;
|
|
72722
|
+
cameraEntity.camera.horizontalFov = graphicsDevice.width > graphicsDevice.height;
|
|
72566
72723
|
// fit clipping planes to bounding box
|
|
72567
72724
|
const boundRadius = sceneBound.halfExtents.length();
|
|
72568
72725
|
// calculate the forward distance between the camera to the bound center
|
|
@@ -73302,7 +73459,7 @@ class VoxelCollider {
|
|
|
73302
73459
|
const distNegZ = cz - vMinZ;
|
|
73303
73460
|
const distPosZ = vMaxZ - cz;
|
|
73304
73461
|
const escapeX = distNegX < distPosX ? -(distNegX + radius) : (distPosX + radius);
|
|
73305
|
-
const escapeY = distNegY
|
|
73462
|
+
const escapeY = distNegY <= distPosY ? -(distNegY + radius) : (distPosY + radius);
|
|
73306
73463
|
const escapeZ = distNegZ < distPosZ ? -(distNegZ + radius) : (distPosZ + radius);
|
|
73307
73464
|
const absX = Math.abs(escapeX);
|
|
73308
73465
|
const absY = Math.abs(escapeY);
|
|
@@ -73310,14 +73467,14 @@ class VoxelCollider {
|
|
|
73310
73467
|
px = 0;
|
|
73311
73468
|
py = 0;
|
|
73312
73469
|
pz = 0;
|
|
73313
|
-
if (
|
|
73314
|
-
px = escapeX;
|
|
73315
|
-
penetration = absX;
|
|
73316
|
-
}
|
|
73317
|
-
else if (absY <= absZ) {
|
|
73470
|
+
if (absY <= absX && absY <= absZ) {
|
|
73318
73471
|
py = escapeY;
|
|
73319
73472
|
penetration = absY;
|
|
73320
73473
|
}
|
|
73474
|
+
else if (absX <= absZ) {
|
|
73475
|
+
px = escapeX;
|
|
73476
|
+
penetration = absX;
|
|
73477
|
+
}
|
|
73321
73478
|
else {
|
|
73322
73479
|
pz = escapeZ;
|
|
73323
73480
|
penetration = absZ;
|
|
@@ -73333,6 +73490,24 @@ class VoxelCollider {
|
|
|
73333
73490
|
}
|
|
73334
73491
|
}
|
|
73335
73492
|
}
|
|
73493
|
+
// Column-based Y fallback: the per-voxel sphere test loses Y information
|
|
73494
|
+
// when the capsule segment passes through a voxel (segY lands inside the
|
|
73495
|
+
// AABB, zeroing dy). Recover it by finding the topmost solid voxel in the
|
|
73496
|
+
// capsule-center column and computing a direct capsule-bottom push.
|
|
73497
|
+
if (found && Math.abs(bestPushY) <= PENETRATION_EPSILON) {
|
|
73498
|
+
const icx = Math.floor((cx - gridMinX) / voxelResolution);
|
|
73499
|
+
const icz = Math.floor((cz - gridMinZ) / voxelResolution);
|
|
73500
|
+
const capsuleBottom = segTopY + radius;
|
|
73501
|
+
for (let iy = iyMin; iy <= iyMax; iy++) {
|
|
73502
|
+
if (this.isVoxelSolid(icx, iy, icz)) {
|
|
73503
|
+
const surfaceY = gridMinY + iy * voxelResolution;
|
|
73504
|
+
if (capsuleBottom > surfaceY + PENETRATION_EPSILON) {
|
|
73505
|
+
bestPushY = surfaceY - capsuleBottom;
|
|
73506
|
+
}
|
|
73507
|
+
break;
|
|
73508
|
+
}
|
|
73509
|
+
}
|
|
73510
|
+
}
|
|
73336
73511
|
if (found) {
|
|
73337
73512
|
this._push.x = bestPushX;
|
|
73338
73513
|
this._push.y = bestPushY;
|
|
@@ -74328,7 +74503,7 @@ const initXr = (global) => {
|
|
|
74328
74503
|
});
|
|
74329
74504
|
};
|
|
74330
74505
|
|
|
74331
|
-
var version = "1.
|
|
74506
|
+
var version = "1.16.1";
|
|
74332
74507
|
|
|
74333
74508
|
const loadGsplat = async (app, config, progressCallback) => {
|
|
74334
74509
|
const { contents, contentUrl, unified, aa } = config;
|
|
@@ -74476,7 +74651,7 @@ const main = async (canvas, settingsJson, config) => {
|
|
|
74476
74651
|
const state = observe(events, {
|
|
74477
74652
|
loaded: false,
|
|
74478
74653
|
readyToRender: false,
|
|
74479
|
-
hqMode:
|
|
74654
|
+
hqMode: localStorage.getItem('hqMode') !== 'false',
|
|
74480
74655
|
progress: 0,
|
|
74481
74656
|
inputMode: platform.mobile ? 'touch' : 'desktop',
|
|
74482
74657
|
cameraMode: 'orbit',
|
|
@@ -74490,7 +74665,8 @@ const main = async (canvas, settingsJson, config) => {
|
|
|
74490
74665
|
hasVoxelOverlay: false,
|
|
74491
74666
|
voxelOverlayEnabled: false,
|
|
74492
74667
|
isFullscreen: false,
|
|
74493
|
-
controlsHidden: false
|
|
74668
|
+
controlsHidden: false,
|
|
74669
|
+
touchControlScheme: localStorage.getItem('touchControlScheme') || 'joystick'
|
|
74494
74670
|
});
|
|
74495
74671
|
const global = {
|
|
74496
74672
|
app,
|