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

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.
@@ -104343,10 +104343,13 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
104343
104343
  if (nextMode === this.mode)
104344
104344
  return;
104345
104345
  const prev = this.mode;
104346
- // Preserve camera transform
104346
+ // Preserve camera transform (position + rotation)
104347
104347
  const pos = this.camera.getPosition
104348
104348
  ? this.camera.getPosition().clone()
104349
104349
  : { x: 0, y: 0, z: 10 };
104350
+ const rot = this.camera.getRotation
104351
+ ? this.camera.getRotation().clone()
104352
+ : null;
104350
104353
  // Switch
104351
104354
  if (nextMode === 'fly') {
104352
104355
  this.deactivateOrbitMode();
@@ -104357,6 +104360,9 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
104357
104360
  this.activateOrbitMode();
104358
104361
  }
104359
104362
  this.camera.setPosition(pos);
104363
+ if (rot && this.camera.setRotation) {
104364
+ this.camera.setRotation(rot);
104365
+ }
104360
104366
  this.mode = nextMode;
104361
104367
  // Emit camera-mode-changed
104362
104368
  this.emit('camera-mode-changed', { mode: nextMode, previousMode: prev });
@@ -104461,6 +104467,22 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
104461
104467
  return;
104462
104468
  if (typeof this.fly.activate === 'function')
104463
104469
  this.fly.activate();
104470
+ // Align fly camera internal orientation with the current camera rotation so that
104471
+ // switching from orbit -> fly does not snap the view back to the initial direction.
104472
+ try {
104473
+ const euler = this.camera.getEulerAngles
104474
+ ? this.camera.getEulerAngles()
104475
+ : null;
104476
+ if (euler) {
104477
+ // These properties are part of the FlyCamera runtime state
104478
+ ;
104479
+ this.fly._pitch = euler.x || 0;
104480
+ this.fly._yaw = euler.y || 0;
104481
+ }
104482
+ }
104483
+ catch {
104484
+ // Best-effort sync; ignore if camera or script API differs
104485
+ }
104464
104486
  }
104465
104487
  deactivateFlyMode() {
104466
104488
  if (!this.fly)
@@ -104528,6 +104550,7 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
104528
104550
  FlyCamera.prototype.initialize = function () {
104529
104551
  this._isActive = true;
104530
104552
  this._isPointerLocked = false;
104553
+ this._isLooking = false;
104531
104554
  this._pressed = new Set();
104532
104555
  this._velocity = new Vec3(0, 0, 0);
104533
104556
  this._targetVelocity = new Vec3(0, 0, 0);
@@ -104549,21 +104572,24 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
104549
104572
  this._onKeyUp = this._handleKeyUp.bind(this);
104550
104573
  document.addEventListener('keydown', this._onKeyDown);
104551
104574
  document.addEventListener('keyup', this._onKeyUp);
104552
- // Mouse move when pointer locked
104575
+ // Mouse move for look (while mouse button held)
104553
104576
  this._onMouseMove = this._handleMouseMove.bind(this);
104554
104577
  document.addEventListener('mousemove', this._onMouseMove);
104555
- // Pointer lock change
104556
- this._onPointerLockChange = this._handlePointerLockChange.bind(this);
104557
- document.addEventListener('pointerlockchange', this._onPointerLockChange);
104558
- // Click on canvas to lock pointer
104578
+ // Mouse button handling: click + hold to look, release to stop
104559
104579
  const canvas = this.app.graphicsDevice.canvas;
104560
104580
  this._onClickToLock = (e) => {
104561
- // Left button to engage pointer lock
104581
+ // Left button enables look while held (no pointer lock)
104562
104582
  if (e.button === 0 && this._isActive) {
104563
- this._requestPointerLock();
104583
+ this._isLooking = true;
104564
104584
  }
104565
104585
  };
104566
104586
  canvas.addEventListener('mousedown', this._onClickToLock);
104587
+ this._onMouseUp = (e) => {
104588
+ if (e.button === 0) {
104589
+ this._isLooking = false;
104590
+ }
104591
+ };
104592
+ document.addEventListener('mouseup', this._onMouseUp);
104567
104593
  };
104568
104594
  FlyCamera.prototype.update = function (dt) {
104569
104595
  if (!this._isActive)
@@ -104608,16 +104634,26 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
104608
104634
  this._onKeyDown = this._onKeyDown || this._handleKeyDown.bind(this);
104609
104635
  this._onKeyUp = this._onKeyUp || this._handleKeyUp.bind(this);
104610
104636
  this._onMouseMove = this._onMouseMove || this._handleMouseMove.bind(this);
104611
- this._onPointerLockChange =
104612
- this._onPointerLockChange || this._handlePointerLockChange.bind(this);
104613
104637
  document.addEventListener('keydown', this._onKeyDown);
104614
104638
  document.addEventListener('keyup', this._onKeyUp);
104615
104639
  document.addEventListener('mousemove', this._onMouseMove);
104616
- document.addEventListener('pointerlockchange', this._onPointerLockChange);
104617
104640
  const canvas = this.app.graphicsDevice.canvas;
104618
104641
  this._onClickToLock =
104619
- this._onClickToLock || (() => this._requestPointerLock());
104642
+ this._onClickToLock ||
104643
+ ((e) => {
104644
+ if (e.button === 0 && this._isActive) {
104645
+ this._isLooking = true;
104646
+ }
104647
+ });
104620
104648
  canvas.addEventListener('mousedown', this._onClickToLock);
104649
+ this._onMouseUp =
104650
+ this._onMouseUp ||
104651
+ ((e) => {
104652
+ if (e.button === 0) {
104653
+ this._isLooking = false;
104654
+ }
104655
+ });
104656
+ document.addEventListener('mouseup', this._onMouseUp);
104621
104657
  };
104622
104658
  FlyCamera.prototype.deactivate = function () {
104623
104659
  if (!this._isActive)
@@ -104629,7 +104665,7 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
104629
104665
  document.removeEventListener('keydown', this._onKeyDown);
104630
104666
  document.removeEventListener('keyup', this._onKeyUp);
104631
104667
  document.removeEventListener('mousemove', this._onMouseMove);
104632
- document.removeEventListener('pointerlockchange', this._onPointerLockChange);
104668
+ document.removeEventListener('mouseup', this._onMouseUp);
104633
104669
  const canvas = this.app?.graphicsDevice?.canvas;
104634
104670
  if (canvas && this._onClickToLock) {
104635
104671
  canvas.removeEventListener('mousedown', this._onClickToLock);
@@ -104713,7 +104749,7 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
104713
104749
  }
104714
104750
  };
104715
104751
  FlyCamera.prototype._handleMouseMove = function (e) {
104716
- if (!this._isPointerLocked || !this._isActive)
104752
+ if (!this._isLooking || !this._isActive)
104717
104753
  return;
104718
104754
  // Invert horizontal (yaw) rotation: moving mouse right rotates view left, and vice versa
104719
104755
  const dx = e.movementX * this.lookSensitivity;