@playcanvas/supersplat-viewer 1.15.1 → 1.16.0
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 +354 -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);
|
|
71052
|
-
}
|
|
71053
|
-
// --- Smooth horizontal position toward target ---
|
|
71054
|
-
this._position.x = math.lerp(this._position.x, this._targetPosition.x, moveLerp);
|
|
71055
|
-
this._position.z = math.lerp(this._position.z, this._targetPosition.z, moveLerp);
|
|
71056
|
-
// No smoothing on Y for crisp ground contact
|
|
71057
|
-
this._position.y = this._targetPosition.y;
|
|
71058
|
-
// --- Capsule collision on smoothed position ---
|
|
71059
|
-
if (this.collider) {
|
|
71060
|
-
this._resolveCapsuleCollision(this._position, false);
|
|
71087
|
+
if (move[1] && !this._jumping && this._grounded) {
|
|
71088
|
+
this._jumping = true;
|
|
71089
|
+
this._velocity.y = this.jumpSpeed;
|
|
71090
|
+
this._grounded = false;
|
|
71061
71091
|
}
|
|
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,6 +71557,7 @@ 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();
|
|
@@ -71590,9 +71636,16 @@ class InputController {
|
|
|
71590
71636
|
move: [0, 0, 0],
|
|
71591
71637
|
rotate: [0, 0, 0]
|
|
71592
71638
|
});
|
|
71593
|
-
// Touch joystick input values (-1 to 1)
|
|
71594
|
-
|
|
71595
|
-
|
|
71639
|
+
// Touch joystick input values [x, y] (-1 to 1)
|
|
71640
|
+
_touchJoystick = [0, 0];
|
|
71641
|
+
// Accumulated forward/backward velocity from pinch gesture (-1 to 1)
|
|
71642
|
+
_pinchVelocity = 0;
|
|
71643
|
+
// Accumulated strafe/vertical velocity from two-finger pan [x, y] (-1 to 1)
|
|
71644
|
+
_panVelocity = [0, 0];
|
|
71645
|
+
// Sensitivity for pinch delta → velocity conversion
|
|
71646
|
+
pinchVelocitySensitivity = 0.006;
|
|
71647
|
+
// Sensitivity for two-finger pan delta → velocity conversion
|
|
71648
|
+
panVelocitySensitivity = 0.005;
|
|
71596
71649
|
// this gets overridden by the viewer based on scene size
|
|
71597
71650
|
moveSpeed = 4;
|
|
71598
71651
|
orbitSpeed = 18;
|
|
@@ -71606,8 +71659,8 @@ class InputController {
|
|
|
71606
71659
|
this._orbitInput.attach(canvas);
|
|
71607
71660
|
// Listen for joystick input from the UI (touch joystick element)
|
|
71608
71661
|
events.on('joystickInput', (value) => {
|
|
71609
|
-
this.
|
|
71610
|
-
this.
|
|
71662
|
+
this._touchJoystick[0] = value.x;
|
|
71663
|
+
this._touchJoystick[1] = value.y;
|
|
71611
71664
|
});
|
|
71612
71665
|
this.global = global;
|
|
71613
71666
|
// Generate input events
|
|
@@ -71658,48 +71711,97 @@ class InputController {
|
|
|
71658
71711
|
state.inputMode = event.pointerType === 'touch' ? 'touch' : 'desktop';
|
|
71659
71712
|
});
|
|
71660
71713
|
});
|
|
71714
|
+
let recentlyExitedFps = false;
|
|
71661
71715
|
// handle keyboard events
|
|
71662
71716
|
window.addEventListener('keydown', (event) => {
|
|
71663
71717
|
if (event.key === 'Escape') {
|
|
71664
|
-
|
|
71718
|
+
if (recentlyExitedFps) ;
|
|
71719
|
+
else if (state.cameraMode === 'fps') {
|
|
71720
|
+
events.fire('inputEvent', 'exitFps', event);
|
|
71721
|
+
}
|
|
71722
|
+
else {
|
|
71723
|
+
events.fire('inputEvent', 'cancel', event);
|
|
71724
|
+
}
|
|
71665
71725
|
}
|
|
71666
|
-
else if (
|
|
71726
|
+
else if (!event.ctrlKey && !event.altKey && !event.metaKey) {
|
|
71667
71727
|
switch (event.key) {
|
|
71668
|
-
case '
|
|
71669
|
-
|
|
71728
|
+
case '1':
|
|
71729
|
+
state.cameraMode = 'orbit';
|
|
71670
71730
|
break;
|
|
71671
|
-
case '
|
|
71672
|
-
|
|
71731
|
+
case '2':
|
|
71732
|
+
state.cameraMode = 'fly';
|
|
71673
71733
|
break;
|
|
71674
|
-
case '
|
|
71675
|
-
events.fire('inputEvent', '
|
|
71734
|
+
case '3':
|
|
71735
|
+
events.fire('inputEvent', 'toggleFps');
|
|
71676
71736
|
break;
|
|
71677
71737
|
}
|
|
71738
|
+
if (state.cameraMode !== 'fps') {
|
|
71739
|
+
switch (event.key) {
|
|
71740
|
+
case 'f':
|
|
71741
|
+
events.fire('inputEvent', 'frame', event);
|
|
71742
|
+
break;
|
|
71743
|
+
case 'r':
|
|
71744
|
+
events.fire('inputEvent', 'reset', event);
|
|
71745
|
+
break;
|
|
71746
|
+
case ' ':
|
|
71747
|
+
events.fire('inputEvent', 'playPause', event);
|
|
71748
|
+
break;
|
|
71749
|
+
}
|
|
71750
|
+
}
|
|
71678
71751
|
}
|
|
71679
71752
|
});
|
|
71753
|
+
// Lock/unlock Escape key in fullscreen to prevent the browser from
|
|
71754
|
+
// exiting both pointer lock and fullscreen on the same Escape press.
|
|
71755
|
+
const lockEscape = () => {
|
|
71756
|
+
if ('keyboard' in navigator && 'lock' in navigator.keyboard) {
|
|
71757
|
+
navigator.keyboard.lock(['Escape']).catch(() => { });
|
|
71758
|
+
}
|
|
71759
|
+
};
|
|
71760
|
+
const unlockKeyboard = () => {
|
|
71761
|
+
if ('keyboard' in navigator && 'unlock' in navigator.keyboard) {
|
|
71762
|
+
navigator.keyboard.unlock();
|
|
71763
|
+
}
|
|
71764
|
+
};
|
|
71680
71765
|
// Pointer lock management for FPS mode on desktop
|
|
71681
71766
|
events.on('cameraMode:changed', (value, prev) => {
|
|
71682
71767
|
if (value === 'fps' && state.inputMode === 'desktop') {
|
|
71683
71768
|
this._desktopInput._pointerLock = true;
|
|
71684
71769
|
canvas.requestPointerLock();
|
|
71770
|
+
if (state.isFullscreen) {
|
|
71771
|
+
lockEscape();
|
|
71772
|
+
}
|
|
71685
71773
|
}
|
|
71686
71774
|
else if (prev === 'fps') {
|
|
71775
|
+
unlockKeyboard();
|
|
71687
71776
|
this._desktopInput._pointerLock = false;
|
|
71688
71777
|
if (document.pointerLockElement === canvas) {
|
|
71778
|
+
if (state.isFullscreen) {
|
|
71779
|
+
events.fire('restoreFullscreen');
|
|
71780
|
+
}
|
|
71689
71781
|
document.exitPointerLock();
|
|
71690
71782
|
}
|
|
71691
71783
|
}
|
|
71692
71784
|
});
|
|
71785
|
+
// Also lock Escape if entering fullscreen while already in FPS mode
|
|
71786
|
+
events.on('isFullscreen:changed', (value) => {
|
|
71787
|
+
if (value && state.cameraMode === 'fps' && state.inputMode === 'desktop') {
|
|
71788
|
+
lockEscape();
|
|
71789
|
+
}
|
|
71790
|
+
});
|
|
71693
71791
|
document.addEventListener('pointerlockchange', () => {
|
|
71694
71792
|
if (!document.pointerLockElement && state.cameraMode === 'fps') {
|
|
71695
|
-
|
|
71793
|
+
recentlyExitedFps = true;
|
|
71794
|
+
requestAnimationFrame(() => {
|
|
71795
|
+
recentlyExitedFps = false;
|
|
71796
|
+
});
|
|
71797
|
+
events.fire('inputEvent', 'exitFps');
|
|
71696
71798
|
}
|
|
71697
71799
|
});
|
|
71698
71800
|
// Pointer lock request rejected (e.g., no user gesture, document hidden).
|
|
71699
71801
|
// Revert to avoid being stuck in FPS mode without mouse capture.
|
|
71700
71802
|
document.addEventListener('pointerlockerror', () => {
|
|
71701
71803
|
this._desktopInput._pointerLock = false;
|
|
71702
|
-
events.fire('inputEvent', '
|
|
71804
|
+
events.fire('inputEvent', 'exitFps');
|
|
71703
71805
|
});
|
|
71704
71806
|
}
|
|
71705
71807
|
/**
|
|
@@ -71726,6 +71828,22 @@ class InputController {
|
|
|
71726
71828
|
this._state.ctrl += key[keyCode.CTRL];
|
|
71727
71829
|
const isFps = state.cameraMode === 'fps';
|
|
71728
71830
|
const isFirstPerson = state.cameraMode === 'fly' || isFps;
|
|
71831
|
+
// Accumulate pinch and pan deltas into velocity when using pinch control scheme
|
|
71832
|
+
// pinch[0] = oldDist - newDist: negative when spreading, positive when closing
|
|
71833
|
+
// Spreading = forward → subtract pinch delta
|
|
71834
|
+
if (isFirstPerson && state.touchControlScheme === 'pinch' && this._state.touches > 1) {
|
|
71835
|
+
this._pinchVelocity -= pinch[0] * this.pinchVelocitySensitivity;
|
|
71836
|
+
this._pinchVelocity = math.clamp(this._pinchVelocity, -1, 1.0);
|
|
71837
|
+
this._panVelocity[0] += touch[0] * this.panVelocitySensitivity;
|
|
71838
|
+
this._panVelocity[0] = math.clamp(this._panVelocity[0], -1, 1.0);
|
|
71839
|
+
this._panVelocity[1] += touch[1] * this.panVelocitySensitivity;
|
|
71840
|
+
this._panVelocity[1] = math.clamp(this._panVelocity[1], -1, 1.0);
|
|
71841
|
+
}
|
|
71842
|
+
else if (isFirstPerson && this._state.touches <= 1) {
|
|
71843
|
+
this._pinchVelocity = 0;
|
|
71844
|
+
this._panVelocity[0] = 0;
|
|
71845
|
+
this._panVelocity[1] = 0;
|
|
71846
|
+
}
|
|
71729
71847
|
if (!isFirstPerson && this._state.axis.length() > 0) {
|
|
71730
71848
|
events.fire('inputEvent', 'requestFirstPerson');
|
|
71731
71849
|
}
|
|
@@ -71743,7 +71861,10 @@ class InputController {
|
|
|
71743
71861
|
keyMove.y = 0;
|
|
71744
71862
|
}
|
|
71745
71863
|
keyMove.normalize();
|
|
71746
|
-
|
|
71864
|
+
const shiftMul = isFps ? 2 : 4;
|
|
71865
|
+
const ctrlMul = isFps ? 0.5 : 0.25;
|
|
71866
|
+
const speed = this.moveSpeed * (this._state.shift ? shiftMul : this._state.ctrl ? ctrlMul : 1);
|
|
71867
|
+
v.add(keyMove.mulScalar(fly * speed * dt));
|
|
71747
71868
|
if (isFps) {
|
|
71748
71869
|
// Pass jump signal as raw Y; FPS controller uses move[1] > 0 as boolean trigger
|
|
71749
71870
|
v.y = this._state.jump > 0 ? 1 : 0;
|
|
@@ -71763,9 +71884,19 @@ class InputController {
|
|
|
71763
71884
|
v.set(0, 0, 0);
|
|
71764
71885
|
const orbitMove = screenToWorld(camera, touch[0], touch[1], distance);
|
|
71765
71886
|
v.add(orbitMove.mulScalar(orbit * pan));
|
|
71766
|
-
|
|
71767
|
-
|
|
71768
|
-
|
|
71887
|
+
if (state.touchControlScheme === 'joystick') {
|
|
71888
|
+
// Use touch joystick values for fly movement (X = strafe, Y = forward/backward)
|
|
71889
|
+
flyMove.set(this._touchJoystick[0], 0, -this._touchJoystick[1]);
|
|
71890
|
+
v.add(flyMove.mulScalar(fly * this.moveSpeed * dt));
|
|
71891
|
+
}
|
|
71892
|
+
else {
|
|
71893
|
+
// Pan velocity → strafe (X) and vertical (Y, fly only — FPS uses gravity)
|
|
71894
|
+
flyTouchPan.set(this._panVelocity[0], isFps ? 0 : -this._panVelocity[1], 0);
|
|
71895
|
+
v.add(flyTouchPan.mulScalar(fly * 1.5 * this.moveSpeed * dt));
|
|
71896
|
+
// Pinch velocity → forward/backward
|
|
71897
|
+
flyMove.set(0, 0, this._pinchVelocity);
|
|
71898
|
+
v.add(flyMove.mulScalar(fly * 1.5 * this.moveSpeed * dt));
|
|
71899
|
+
}
|
|
71769
71900
|
pinchMove.set(0, 0, pinch[0]);
|
|
71770
71901
|
v.add(pinchMove.mulScalar(orbit * double * this.pinchSpeed * dt));
|
|
71771
71902
|
deltas.move.append([v.x, v.y, v.z]);
|
|
@@ -71773,9 +71904,8 @@ class InputController {
|
|
|
71773
71904
|
v.set(0, 0, 0);
|
|
71774
71905
|
orbitRotate.set(touch[0], touch[1], 0);
|
|
71775
71906
|
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
|
|
71907
|
+
// In fly mode, use single touch for look-around (inverted direction)
|
|
71908
|
+
// Exclude multi-touch (double) to avoid interference with pinch/strafe gestures
|
|
71779
71909
|
flyRotate.set(touch[0], touch[1], 0);
|
|
71780
71910
|
v.add(flyRotate.mulScalar(fly * (1 - double) * this.orbitSpeed * orbitFactor * 1.25 * dt));
|
|
71781
71911
|
deltas.rotate.append([v.x, v.y, v.z]);
|
|
@@ -72495,20 +72625,11 @@ class Viewer {
|
|
|
72495
72625
|
wgsl.set('skyboxPS', wgsl.get('skyboxPS').replace('mapRoughnessUv(uv, uniform.mipLevel)', 'uv'));
|
|
72496
72626
|
// disable auto render, we'll render only when camera changes
|
|
72497
72627
|
app.autoRender = false;
|
|
72498
|
-
// apply camera animation settings
|
|
72499
|
-
camera.camera.aspectRatio = graphicsDevice.width / graphicsDevice.height;
|
|
72500
72628
|
// configure the camera
|
|
72501
72629
|
this.configureCamera(settings);
|
|
72502
72630
|
// reconfigure camera when entering/exiting XR
|
|
72503
72631
|
app.xr.on('start', () => this.configureCamera(settings));
|
|
72504
72632
|
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
72633
|
// construct debug ministats
|
|
72513
72634
|
if (config.ministats) {
|
|
72514
72635
|
const options = MiniStats.getDefaultOptions();
|
|
@@ -72563,6 +72684,7 @@ class Viewer {
|
|
|
72563
72684
|
cameraEntity.setPosition(camera.position);
|
|
72564
72685
|
cameraEntity.setEulerAngles(camera.angles);
|
|
72565
72686
|
cameraEntity.camera.fov = camera.fov;
|
|
72687
|
+
cameraEntity.camera.horizontalFov = graphicsDevice.width > graphicsDevice.height;
|
|
72566
72688
|
// fit clipping planes to bounding box
|
|
72567
72689
|
const boundRadius = sceneBound.halfExtents.length();
|
|
72568
72690
|
// calculate the forward distance between the camera to the bound center
|
|
@@ -73302,7 +73424,7 @@ class VoxelCollider {
|
|
|
73302
73424
|
const distNegZ = cz - vMinZ;
|
|
73303
73425
|
const distPosZ = vMaxZ - cz;
|
|
73304
73426
|
const escapeX = distNegX < distPosX ? -(distNegX + radius) : (distPosX + radius);
|
|
73305
|
-
const escapeY = distNegY
|
|
73427
|
+
const escapeY = distNegY <= distPosY ? -(distNegY + radius) : (distPosY + radius);
|
|
73306
73428
|
const escapeZ = distNegZ < distPosZ ? -(distNegZ + radius) : (distPosZ + radius);
|
|
73307
73429
|
const absX = Math.abs(escapeX);
|
|
73308
73430
|
const absY = Math.abs(escapeY);
|
|
@@ -73310,14 +73432,14 @@ class VoxelCollider {
|
|
|
73310
73432
|
px = 0;
|
|
73311
73433
|
py = 0;
|
|
73312
73434
|
pz = 0;
|
|
73313
|
-
if (
|
|
73314
|
-
px = escapeX;
|
|
73315
|
-
penetration = absX;
|
|
73316
|
-
}
|
|
73317
|
-
else if (absY <= absZ) {
|
|
73435
|
+
if (absY <= absX && absY <= absZ) {
|
|
73318
73436
|
py = escapeY;
|
|
73319
73437
|
penetration = absY;
|
|
73320
73438
|
}
|
|
73439
|
+
else if (absX <= absZ) {
|
|
73440
|
+
px = escapeX;
|
|
73441
|
+
penetration = absX;
|
|
73442
|
+
}
|
|
73321
73443
|
else {
|
|
73322
73444
|
pz = escapeZ;
|
|
73323
73445
|
penetration = absZ;
|
|
@@ -73333,6 +73455,24 @@ class VoxelCollider {
|
|
|
73333
73455
|
}
|
|
73334
73456
|
}
|
|
73335
73457
|
}
|
|
73458
|
+
// Column-based Y fallback: the per-voxel sphere test loses Y information
|
|
73459
|
+
// when the capsule segment passes through a voxel (segY lands inside the
|
|
73460
|
+
// AABB, zeroing dy). Recover it by finding the topmost solid voxel in the
|
|
73461
|
+
// capsule-center column and computing a direct capsule-bottom push.
|
|
73462
|
+
if (found && Math.abs(bestPushY) <= PENETRATION_EPSILON) {
|
|
73463
|
+
const icx = Math.floor((cx - gridMinX) / voxelResolution);
|
|
73464
|
+
const icz = Math.floor((cz - gridMinZ) / voxelResolution);
|
|
73465
|
+
const capsuleBottom = segTopY + radius;
|
|
73466
|
+
for (let iy = iyMin; iy <= iyMax; iy++) {
|
|
73467
|
+
if (this.isVoxelSolid(icx, iy, icz)) {
|
|
73468
|
+
const surfaceY = gridMinY + iy * voxelResolution;
|
|
73469
|
+
if (capsuleBottom > surfaceY + PENETRATION_EPSILON) {
|
|
73470
|
+
bestPushY = surfaceY - capsuleBottom;
|
|
73471
|
+
}
|
|
73472
|
+
break;
|
|
73473
|
+
}
|
|
73474
|
+
}
|
|
73475
|
+
}
|
|
73336
73476
|
if (found) {
|
|
73337
73477
|
this._push.x = bestPushX;
|
|
73338
73478
|
this._push.y = bestPushY;
|
|
@@ -74328,7 +74468,7 @@ const initXr = (global) => {
|
|
|
74328
74468
|
});
|
|
74329
74469
|
};
|
|
74330
74470
|
|
|
74331
|
-
var version = "1.
|
|
74471
|
+
var version = "1.16.0";
|
|
74332
74472
|
|
|
74333
74473
|
const loadGsplat = async (app, config, progressCallback) => {
|
|
74334
74474
|
const { contents, contentUrl, unified, aa } = config;
|
|
@@ -74476,7 +74616,7 @@ const main = async (canvas, settingsJson, config) => {
|
|
|
74476
74616
|
const state = observe(events, {
|
|
74477
74617
|
loaded: false,
|
|
74478
74618
|
readyToRender: false,
|
|
74479
|
-
hqMode:
|
|
74619
|
+
hqMode: localStorage.getItem('hqMode') !== 'false',
|
|
74480
74620
|
progress: 0,
|
|
74481
74621
|
inputMode: platform.mobile ? 'touch' : 'desktop',
|
|
74482
74622
|
cameraMode: 'orbit',
|
|
@@ -74490,7 +74630,8 @@ const main = async (canvas, settingsJson, config) => {
|
|
|
74490
74630
|
hasVoxelOverlay: false,
|
|
74491
74631
|
voxelOverlayEnabled: false,
|
|
74492
74632
|
isFullscreen: false,
|
|
74493
|
-
controlsHidden: false
|
|
74633
|
+
controlsHidden: false,
|
|
74634
|
+
touchControlScheme: localStorage.getItem('touchControlScheme') || 'joystick'
|
|
74494
74635
|
});
|
|
74495
74636
|
const global = {
|
|
74496
74637
|
app,
|