@heliguy-xyz/splat-viewer 1.0.0-rc.4 → 1.0.0-rc.5

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.
@@ -1 +1 @@
1
- {"version":3,"file":"FlyCameraScript.d.ts","sourceRoot":"","sources":["../../src/web-component/FlyCameraScript.ts"],"names":[],"mappings":"AAsEA,wBAAgB,uBAAuB,IAAI,IAAI,CA0X9C"}
1
+ {"version":3,"file":"FlyCameraScript.d.ts","sourceRoot":"","sources":["../../src/web-component/FlyCameraScript.ts"],"names":[],"mappings":"AAsEA,wBAAgB,uBAAuB,IAAI,IAAI,CAua9C"}
@@ -104573,7 +104573,11 @@ function registerFlyCameraScript() {
104573
104573
  : { x: 0, y: 0, z: 0 };
104574
104574
  this.emitFlyEvent?.('fly-camera-move', {
104575
104575
  position: { x: pos.x, y: pos.y, z: pos.z },
104576
- velocity: { x: this._velocity.x, y: this._velocity.y, z: this._velocity.z },
104576
+ velocity: {
104577
+ x: this._velocity.x,
104578
+ y: this._velocity.y,
104579
+ z: this._velocity.z,
104580
+ },
104577
104581
  });
104578
104582
  this._lastMoveEmitTime = now;
104579
104583
  }
@@ -104604,7 +104608,8 @@ function registerFlyCameraScript() {
104604
104608
  document.addEventListener('mousemove', this._onMouseMove);
104605
104609
  document.addEventListener('pointerlockchange', this._onPointerLockChange);
104606
104610
  const canvas = this.app.graphicsDevice.canvas;
104607
- this._onClickToLock = this._onClickToLock || (() => this._requestPointerLock());
104611
+ this._onClickToLock =
104612
+ this._onClickToLock || (() => this._requestPointerLock());
104608
104613
  canvas.addEventListener('mousedown', this._onClickToLock);
104609
104614
  };
104610
104615
  FlyCamera.prototype.deactivate = function () {
@@ -104654,7 +104659,11 @@ function registerFlyCameraScript() {
104654
104659
  return {
104655
104660
  position: { x: pos.x, y: pos.y, z: pos.z },
104656
104661
  rotation: { pitch: this._pitch, yaw: this._yaw },
104657
- velocity: { x: this._velocity.x, y: this._velocity.y, z: this._velocity.z },
104662
+ velocity: {
104663
+ x: this._velocity.x,
104664
+ y: this._velocity.y,
104665
+ z: this._velocity.z,
104666
+ },
104658
104667
  isMoving: Math.abs(this._velocity.x) +
104659
104668
  Math.abs(this._velocity.y) +
104660
104669
  Math.abs(this._velocity.z) >
@@ -104662,17 +104671,47 @@ function registerFlyCameraScript() {
104662
104671
  };
104663
104672
  };
104664
104673
  FlyCamera.prototype._handleKeyDown = function (e) {
104665
- this._pressed.add(e.code);
104674
+ const keys = [];
104675
+ if (e.code) {
104676
+ keys.push(e.code);
104677
+ }
104678
+ if (e.key) {
104679
+ keys.push(e.key);
104680
+ if (e.key.length === 1) {
104681
+ // Allow matching against both `KeyW` style codes and plain characters
104682
+ keys.push(`Key${e.key.toUpperCase()}`);
104683
+ keys.push(e.key.toUpperCase());
104684
+ keys.push(e.key.toLowerCase());
104685
+ }
104686
+ }
104687
+ for (const k of keys) {
104688
+ this._pressed.add(k);
104689
+ }
104666
104690
  };
104667
104691
  FlyCamera.prototype._handleKeyUp = function (e) {
104668
- this._pressed.delete(e.code);
104692
+ const keys = [];
104693
+ if (e.code) {
104694
+ keys.push(e.code);
104695
+ }
104696
+ if (e.key) {
104697
+ keys.push(e.key);
104698
+ if (e.key.length === 1) {
104699
+ keys.push(`Key${e.key.toUpperCase()}`);
104700
+ keys.push(e.key.toUpperCase());
104701
+ keys.push(e.key.toLowerCase());
104702
+ }
104703
+ }
104704
+ for (const k of keys) {
104705
+ this._pressed.delete(k);
104706
+ }
104669
104707
  };
104670
104708
  FlyCamera.prototype._handleMouseMove = function (e) {
104671
104709
  if (!this._isPointerLocked || !this._isActive)
104672
104710
  return;
104711
+ // Invert horizontal (yaw) rotation: moving mouse right rotates view left, and vice versa
104673
104712
  const dx = e.movementX * this.lookSensitivity;
104674
104713
  const dy = e.movementY * this.lookSensitivity * (this.invertY ? 1 : -1);
104675
- this._yaw = (this._yaw + dx) % 360;
104714
+ this._yaw = (this._yaw - dx) % 360;
104676
104715
  this._pitch = Math.max(-89, Math.min(89, this._pitch + dy));
104677
104716
  };
104678
104717
  FlyCamera.prototype._handlePointerLockChange = function () {
@@ -104695,15 +104734,19 @@ function registerFlyCameraScript() {
104695
104734
  }
104696
104735
  }
104697
104736
  };
104698
- FlyCamera.prototype._updateVelocity = function (dt) {
104737
+ FlyCamera.prototype._updateVelocity = function (_dt) {
104699
104738
  // Input direction (local space)
104700
104739
  const kb = this.keyBindings;
104701
- const forward = this._pressed.has(kb.forward) ? 1 : 0;
104702
- const backward = this._pressed.has(kb.backward) ? 1 : 0;
104703
- const left = this._pressed.has(kb.left) ? 1 : 0;
104704
- const right = this._pressed.has(kb.right) ? 1 : 0;
104705
- const up = this._pressed.has(kb.up) ? 1 : 0;
104706
- const down = this._pressed.has(kb.down) ? 1 : 0;
104740
+ const isPressed = (binding, fallbacks) => {
104741
+ const all = [binding, ...fallbacks].filter(Boolean);
104742
+ return all.some(k => this._pressed.has(k));
104743
+ };
104744
+ const forward = isPressed(kb.forward, ['KeyW', 'w', 'W']) ? 1 : 0;
104745
+ const backward = isPressed(kb.backward, ['KeyS', 's', 'S']) ? 1 : 0;
104746
+ const left = isPressed(kb.left, ['KeyA', 'a', 'A']) ? 1 : 0;
104747
+ const right = isPressed(kb.right, ['KeyD', 'd', 'D']) ? 1 : 0;
104748
+ const up = isPressed(kb.up, ['KeyE', 'e', 'E']) ? 1 : 0;
104749
+ const down = isPressed(kb.down, ['KeyQ', 'q', 'Q']) ? 1 : 0;
104707
104750
  const inputZ = forward - backward;
104708
104751
  const inputX = right - left;
104709
104752
  const inputY = up - down;
@@ -104711,17 +104754,25 @@ function registerFlyCameraScript() {
104711
104754
  const planarLen = Math.hypot(inputX, inputZ);
104712
104755
  const nx = planarLen > 0 ? inputX / planarLen : 0;
104713
104756
  const nz = planarLen > 0 ? inputZ / planarLen : 0;
104714
- // Effective speed with modifiers
104715
- const speed = this._getEffectiveSpeed();
104716
- // Compute direction vectors from current yaw/pitch
104717
- const yawRad = (this._yaw * Math.PI) / 180;
104718
- const pitchRad = (this._pitch * Math.PI) / 180;
104719
- // Forward vector (normalized)
104720
- const fwd = new Vec3(Math.cos(pitchRad) * Math.sin(yawRad), Math.sin(pitchRad), Math.cos(pitchRad) * Math.cos(yawRad));
104721
- // Right vector (perpendicular to yaw on horizontal plane)
104722
- const rightVec = new Vec3(Math.sin(yawRad - Math.PI / 2), 0, Math.cos(yawRad - Math.PI / 2));
104723
- // Up vector (world up)
104724
- const upVec = Vec3.UP.clone();
104757
+ // Effective speed with modifiers (scaled x2 as requested)
104758
+ const speed = this._getEffectiveSpeed() * 2;
104759
+ // Compute direction vectors from the camera entity so movement matches look direction
104760
+ const entity = this.entity;
104761
+ const fwd = entity?.forward && entity.forward.clone
104762
+ ? entity.forward.clone()
104763
+ : entity?.forward
104764
+ ? new Vec3(entity.forward.x, entity.forward.y, entity.forward.z)
104765
+ : new Vec3(0, 0, -1);
104766
+ const rightVec = entity?.right && entity.right.clone
104767
+ ? entity.right.clone()
104768
+ : entity?.right
104769
+ ? new Vec3(entity.right.x, entity.right.y, entity.right.z)
104770
+ : new Vec3(1, 0, 0);
104771
+ const upVec = entity?.up && entity.up.clone
104772
+ ? entity.up.clone()
104773
+ : entity?.up
104774
+ ? new Vec3(entity.up.x, entity.up.y, entity.up.z)
104775
+ : Vec3.UP.clone();
104725
104776
  // Target velocity in world space
104726
104777
  const target = new Vec3(0, 0, 0);
104727
104778
  target.add(fwd.mulScalar(nz * speed));
@@ -104756,7 +104807,9 @@ function registerFlyCameraScript() {
104756
104807
  }
104757
104808
  };
104758
104809
  FlyCamera.prototype._applyConstraints = function () {
104759
- if (!this.enableCollision && this.minHeight == null && this.maxHeight == null) {
104810
+ if (!this.enableCollision &&
104811
+ this.minHeight == null &&
104812
+ this.maxHeight == null) {
104760
104813
  return;
104761
104814
  }
104762
104815
  const pos = this.entity.getPosition