@heliguy-xyz/splat-viewer 1.0.0-rc.4 → 1.0.0-rc.6
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/web-component/CameraModeManager.d.ts.map +1 -1
- package/dist/web-component/FlyCameraScript.d.ts.map +1 -1
- package/dist/web-component/splat-viewer.esm.js +101 -26
- package/dist/web-component/splat-viewer.esm.min.js +2 -2
- package/dist/web-component/splat-viewer.js +101 -26
- package/dist/web-component/splat-viewer.min.js +2 -2
- package/dist/web-component/types/CameraModeManager.d.ts.map +1 -1
- package/dist/web-component/types/FlyCameraScript.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CameraModeManager.d.ts","sourceRoot":"","sources":["../../src/web-component/CameraModeManager.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,UAAU,EACV,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,qBAAqB,EACrB,gBAAgB,EACjB,MAAM,SAAS,CAAA;AAEhB,KAAK,MAAM,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,KAAK,IAAI,CAAA;AAEvD,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,GAAG,CAAuB;IAClC,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,KAAK,CAA0B;IACvC,OAAO,CAAC,GAAG,CAAY;IACvB,OAAO,CAAC,IAAI,CAAY;IACxB,OAAO,CAAC,IAAI,CAAQ;gBAGlB,GAAG,EAAE,qBAAqB,EAC1B,MAAM,EAAE,gBAAgB,EACxB,KAAK,EAAE,iBAAiB,GAAG,IAAI,EAC/B,GAAG,EAAE,GAAG,GAAG,IAAI,EACf,IAAI,EAAE,MAAM,EACZ,WAAW,GAAE,UAAkC;IAmB1C,OAAO,IAAI,UAAU;IAIrB,OAAO,CAAC,QAAQ,EAAE,UAAU,GAAG,IAAI;
|
|
1
|
+
{"version":3,"file":"CameraModeManager.d.ts","sourceRoot":"","sources":["../../src/web-component/CameraModeManager.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,UAAU,EACV,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,qBAAqB,EACrB,gBAAgB,EACjB,MAAM,SAAS,CAAA;AAEhB,KAAK,MAAM,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,KAAK,IAAI,CAAA;AAEvD,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,GAAG,CAAuB;IAClC,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,KAAK,CAA0B;IACvC,OAAO,CAAC,GAAG,CAAY;IACvB,OAAO,CAAC,IAAI,CAAY;IACxB,OAAO,CAAC,IAAI,CAAQ;gBAGlB,GAAG,EAAE,qBAAqB,EAC1B,MAAM,EAAE,gBAAgB,EACxB,KAAK,EAAE,iBAAiB,GAAG,IAAI,EAC/B,GAAG,EAAE,GAAG,GAAG,IAAI,EACf,IAAI,EAAE,MAAM,EACZ,WAAW,GAAE,UAAkC;IAmB1C,OAAO,IAAI,UAAU;IAIrB,OAAO,CAAC,QAAQ,EAAE,UAAU,GAAG,IAAI;IAgCnC,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,IAAI;IAMpD,YAAY,IAAI,eAAe,GAAG,IAAI;IAmBtC,WAAW,IAAI,cAAc,GAAG,IAAI;IAe3C,OAAO,CAAC,iBAAiB;IA+BzB,OAAO,CAAC,mBAAmB;IA4B3B,OAAO,CAAC,eAAe;IAoBvB,OAAO,CAAC,iBAAiB;CAI1B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FlyCameraScript.d.ts","sourceRoot":"","sources":["../../src/web-component/FlyCameraScript.ts"],"names":[],"mappings":"AAsEA,wBAAgB,uBAAuB,IAAI,IAAI,
|
|
1
|
+
{"version":3,"file":"FlyCameraScript.d.ts","sourceRoot":"","sources":["../../src/web-component/FlyCameraScript.ts"],"names":[],"mappings":"AAsEA,wBAAgB,uBAAuB,IAAI,IAAI,CAua9C"}
|
|
@@ -104336,10 +104336,13 @@ class CameraModeManager {
|
|
|
104336
104336
|
if (nextMode === this.mode)
|
|
104337
104337
|
return;
|
|
104338
104338
|
const prev = this.mode;
|
|
104339
|
-
// Preserve camera transform
|
|
104339
|
+
// Preserve camera transform (position + rotation)
|
|
104340
104340
|
const pos = this.camera.getPosition
|
|
104341
104341
|
? this.camera.getPosition().clone()
|
|
104342
104342
|
: { x: 0, y: 0, z: 10 };
|
|
104343
|
+
const rot = this.camera.getRotation
|
|
104344
|
+
? this.camera.getRotation().clone()
|
|
104345
|
+
: null;
|
|
104343
104346
|
// Switch
|
|
104344
104347
|
if (nextMode === 'fly') {
|
|
104345
104348
|
this.deactivateOrbitMode();
|
|
@@ -104350,6 +104353,9 @@ class CameraModeManager {
|
|
|
104350
104353
|
this.activateOrbitMode();
|
|
104351
104354
|
}
|
|
104352
104355
|
this.camera.setPosition(pos);
|
|
104356
|
+
if (rot && this.camera.setRotation) {
|
|
104357
|
+
this.camera.setRotation(rot);
|
|
104358
|
+
}
|
|
104353
104359
|
this.mode = nextMode;
|
|
104354
104360
|
// Emit camera-mode-changed
|
|
104355
104361
|
this.emit('camera-mode-changed', { mode: nextMode, previousMode: prev });
|
|
@@ -104454,6 +104460,22 @@ class CameraModeManager {
|
|
|
104454
104460
|
return;
|
|
104455
104461
|
if (typeof this.fly.activate === 'function')
|
|
104456
104462
|
this.fly.activate();
|
|
104463
|
+
// Align fly camera internal orientation with the current camera rotation so that
|
|
104464
|
+
// switching from orbit -> fly does not snap the view back to the initial direction.
|
|
104465
|
+
try {
|
|
104466
|
+
const euler = this.camera.getEulerAngles
|
|
104467
|
+
? this.camera.getEulerAngles()
|
|
104468
|
+
: null;
|
|
104469
|
+
if (euler) {
|
|
104470
|
+
// These properties are part of the FlyCamera runtime state
|
|
104471
|
+
;
|
|
104472
|
+
this.fly._pitch = euler.x || 0;
|
|
104473
|
+
this.fly._yaw = euler.y || 0;
|
|
104474
|
+
}
|
|
104475
|
+
}
|
|
104476
|
+
catch {
|
|
104477
|
+
// Best-effort sync; ignore if camera or script API differs
|
|
104478
|
+
}
|
|
104457
104479
|
}
|
|
104458
104480
|
deactivateFlyMode() {
|
|
104459
104481
|
if (!this.fly)
|
|
@@ -104573,7 +104595,11 @@ function registerFlyCameraScript() {
|
|
|
104573
104595
|
: { x: 0, y: 0, z: 0 };
|
|
104574
104596
|
this.emitFlyEvent?.('fly-camera-move', {
|
|
104575
104597
|
position: { x: pos.x, y: pos.y, z: pos.z },
|
|
104576
|
-
velocity: {
|
|
104598
|
+
velocity: {
|
|
104599
|
+
x: this._velocity.x,
|
|
104600
|
+
y: this._velocity.y,
|
|
104601
|
+
z: this._velocity.z,
|
|
104602
|
+
},
|
|
104577
104603
|
});
|
|
104578
104604
|
this._lastMoveEmitTime = now;
|
|
104579
104605
|
}
|
|
@@ -104604,7 +104630,8 @@ function registerFlyCameraScript() {
|
|
|
104604
104630
|
document.addEventListener('mousemove', this._onMouseMove);
|
|
104605
104631
|
document.addEventListener('pointerlockchange', this._onPointerLockChange);
|
|
104606
104632
|
const canvas = this.app.graphicsDevice.canvas;
|
|
104607
|
-
this._onClickToLock =
|
|
104633
|
+
this._onClickToLock =
|
|
104634
|
+
this._onClickToLock || (() => this._requestPointerLock());
|
|
104608
104635
|
canvas.addEventListener('mousedown', this._onClickToLock);
|
|
104609
104636
|
};
|
|
104610
104637
|
FlyCamera.prototype.deactivate = function () {
|
|
@@ -104654,7 +104681,11 @@ function registerFlyCameraScript() {
|
|
|
104654
104681
|
return {
|
|
104655
104682
|
position: { x: pos.x, y: pos.y, z: pos.z },
|
|
104656
104683
|
rotation: { pitch: this._pitch, yaw: this._yaw },
|
|
104657
|
-
velocity: {
|
|
104684
|
+
velocity: {
|
|
104685
|
+
x: this._velocity.x,
|
|
104686
|
+
y: this._velocity.y,
|
|
104687
|
+
z: this._velocity.z,
|
|
104688
|
+
},
|
|
104658
104689
|
isMoving: Math.abs(this._velocity.x) +
|
|
104659
104690
|
Math.abs(this._velocity.y) +
|
|
104660
104691
|
Math.abs(this._velocity.z) >
|
|
@@ -104662,17 +104693,47 @@ function registerFlyCameraScript() {
|
|
|
104662
104693
|
};
|
|
104663
104694
|
};
|
|
104664
104695
|
FlyCamera.prototype._handleKeyDown = function (e) {
|
|
104665
|
-
|
|
104696
|
+
const keys = [];
|
|
104697
|
+
if (e.code) {
|
|
104698
|
+
keys.push(e.code);
|
|
104699
|
+
}
|
|
104700
|
+
if (e.key) {
|
|
104701
|
+
keys.push(e.key);
|
|
104702
|
+
if (e.key.length === 1) {
|
|
104703
|
+
// Allow matching against both `KeyW` style codes and plain characters
|
|
104704
|
+
keys.push(`Key${e.key.toUpperCase()}`);
|
|
104705
|
+
keys.push(e.key.toUpperCase());
|
|
104706
|
+
keys.push(e.key.toLowerCase());
|
|
104707
|
+
}
|
|
104708
|
+
}
|
|
104709
|
+
for (const k of keys) {
|
|
104710
|
+
this._pressed.add(k);
|
|
104711
|
+
}
|
|
104666
104712
|
};
|
|
104667
104713
|
FlyCamera.prototype._handleKeyUp = function (e) {
|
|
104668
|
-
|
|
104714
|
+
const keys = [];
|
|
104715
|
+
if (e.code) {
|
|
104716
|
+
keys.push(e.code);
|
|
104717
|
+
}
|
|
104718
|
+
if (e.key) {
|
|
104719
|
+
keys.push(e.key);
|
|
104720
|
+
if (e.key.length === 1) {
|
|
104721
|
+
keys.push(`Key${e.key.toUpperCase()}`);
|
|
104722
|
+
keys.push(e.key.toUpperCase());
|
|
104723
|
+
keys.push(e.key.toLowerCase());
|
|
104724
|
+
}
|
|
104725
|
+
}
|
|
104726
|
+
for (const k of keys) {
|
|
104727
|
+
this._pressed.delete(k);
|
|
104728
|
+
}
|
|
104669
104729
|
};
|
|
104670
104730
|
FlyCamera.prototype._handleMouseMove = function (e) {
|
|
104671
104731
|
if (!this._isPointerLocked || !this._isActive)
|
|
104672
104732
|
return;
|
|
104733
|
+
// Invert horizontal (yaw) rotation: moving mouse right rotates view left, and vice versa
|
|
104673
104734
|
const dx = e.movementX * this.lookSensitivity;
|
|
104674
104735
|
const dy = e.movementY * this.lookSensitivity * (this.invertY ? 1 : -1);
|
|
104675
|
-
this._yaw = (this._yaw
|
|
104736
|
+
this._yaw = (this._yaw - dx) % 360;
|
|
104676
104737
|
this._pitch = Math.max(-89, Math.min(89, this._pitch + dy));
|
|
104677
104738
|
};
|
|
104678
104739
|
FlyCamera.prototype._handlePointerLockChange = function () {
|
|
@@ -104695,15 +104756,19 @@ function registerFlyCameraScript() {
|
|
|
104695
104756
|
}
|
|
104696
104757
|
}
|
|
104697
104758
|
};
|
|
104698
|
-
FlyCamera.prototype._updateVelocity = function (
|
|
104759
|
+
FlyCamera.prototype._updateVelocity = function (_dt) {
|
|
104699
104760
|
// Input direction (local space)
|
|
104700
104761
|
const kb = this.keyBindings;
|
|
104701
|
-
const
|
|
104702
|
-
|
|
104703
|
-
|
|
104704
|
-
|
|
104705
|
-
const
|
|
104706
|
-
const
|
|
104762
|
+
const isPressed = (binding, fallbacks) => {
|
|
104763
|
+
const all = [binding, ...fallbacks].filter(Boolean);
|
|
104764
|
+
return all.some(k => this._pressed.has(k));
|
|
104765
|
+
};
|
|
104766
|
+
const forward = isPressed(kb.forward, ['KeyW', 'w', 'W']) ? 1 : 0;
|
|
104767
|
+
const backward = isPressed(kb.backward, ['KeyS', 's', 'S']) ? 1 : 0;
|
|
104768
|
+
const left = isPressed(kb.left, ['KeyA', 'a', 'A']) ? 1 : 0;
|
|
104769
|
+
const right = isPressed(kb.right, ['KeyD', 'd', 'D']) ? 1 : 0;
|
|
104770
|
+
const up = isPressed(kb.up, ['KeyE', 'e', 'E']) ? 1 : 0;
|
|
104771
|
+
const down = isPressed(kb.down, ['KeyQ', 'q', 'Q']) ? 1 : 0;
|
|
104707
104772
|
const inputZ = forward - backward;
|
|
104708
104773
|
const inputX = right - left;
|
|
104709
104774
|
const inputY = up - down;
|
|
@@ -104711,17 +104776,25 @@ function registerFlyCameraScript() {
|
|
|
104711
104776
|
const planarLen = Math.hypot(inputX, inputZ);
|
|
104712
104777
|
const nx = planarLen > 0 ? inputX / planarLen : 0;
|
|
104713
104778
|
const nz = planarLen > 0 ? inputZ / planarLen : 0;
|
|
104714
|
-
// Effective speed with modifiers
|
|
104715
|
-
const speed = this._getEffectiveSpeed();
|
|
104716
|
-
// Compute direction vectors from
|
|
104717
|
-
const
|
|
104718
|
-
const
|
|
104719
|
-
|
|
104720
|
-
|
|
104721
|
-
|
|
104722
|
-
|
|
104723
|
-
|
|
104724
|
-
|
|
104779
|
+
// Effective speed with modifiers (scaled x2 as requested)
|
|
104780
|
+
const speed = this._getEffectiveSpeed() * 2;
|
|
104781
|
+
// Compute direction vectors from the camera entity so movement matches look direction
|
|
104782
|
+
const entity = this.entity;
|
|
104783
|
+
const fwd = entity?.forward && entity.forward.clone
|
|
104784
|
+
? entity.forward.clone()
|
|
104785
|
+
: entity?.forward
|
|
104786
|
+
? new Vec3(entity.forward.x, entity.forward.y, entity.forward.z)
|
|
104787
|
+
: new Vec3(0, 0, -1);
|
|
104788
|
+
const rightVec = entity?.right && entity.right.clone
|
|
104789
|
+
? entity.right.clone()
|
|
104790
|
+
: entity?.right
|
|
104791
|
+
? new Vec3(entity.right.x, entity.right.y, entity.right.z)
|
|
104792
|
+
: new Vec3(1, 0, 0);
|
|
104793
|
+
const upVec = entity?.up && entity.up.clone
|
|
104794
|
+
? entity.up.clone()
|
|
104795
|
+
: entity?.up
|
|
104796
|
+
? new Vec3(entity.up.x, entity.up.y, entity.up.z)
|
|
104797
|
+
: Vec3.UP.clone();
|
|
104725
104798
|
// Target velocity in world space
|
|
104726
104799
|
const target = new Vec3(0, 0, 0);
|
|
104727
104800
|
target.add(fwd.mulScalar(nz * speed));
|
|
@@ -104756,7 +104829,9 @@ function registerFlyCameraScript() {
|
|
|
104756
104829
|
}
|
|
104757
104830
|
};
|
|
104758
104831
|
FlyCamera.prototype._applyConstraints = function () {
|
|
104759
|
-
if (!this.enableCollision &&
|
|
104832
|
+
if (!this.enableCollision &&
|
|
104833
|
+
this.minHeight == null &&
|
|
104834
|
+
this.maxHeight == null) {
|
|
104760
104835
|
return;
|
|
104761
104836
|
}
|
|
104762
104837
|
const pos = this.entity.getPosition
|