@heliguy-xyz/splat-viewer 1.0.0-rc.6 → 1.0.0-rc.8

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.
Files changed (31) hide show
  1. package/dist/web-component/FlyCameraScript.d.ts.map +1 -1
  2. package/dist/web-component/ModelManager.d.ts +12 -0
  3. package/dist/web-component/ModelManager.d.ts.map +1 -1
  4. package/dist/web-component/SplatViewerCore.d.ts +12 -0
  5. package/dist/web-component/SplatViewerCore.d.ts.map +1 -1
  6. package/dist/web-component/SplatViewerElement.d.ts +12 -0
  7. package/dist/web-component/SplatViewerElement.d.ts.map +1 -1
  8. package/dist/web-component/splat-viewer.esm.js +120 -13
  9. package/dist/web-component/splat-viewer.esm.min.js +2 -2
  10. package/dist/web-component/splat-viewer.js +120 -13
  11. package/dist/web-component/splat-viewer.min.js +2 -2
  12. package/dist/web-component/types/FlyCameraScript.d.ts.map +1 -1
  13. package/dist/web-component/types/ModelManager.d.ts +12 -0
  14. package/dist/web-component/types/ModelManager.d.ts.map +1 -1
  15. package/dist/web-component/types/SplatViewerCore.d.ts +12 -0
  16. package/dist/web-component/types/SplatViewerCore.d.ts.map +1 -1
  17. package/dist/web-component/types/SplatViewerElement.d.ts +12 -0
  18. package/dist/web-component/types/SplatViewerElement.d.ts.map +1 -1
  19. package/dist/web-component/types/core.d.ts +2 -0
  20. package/dist/web-component/types/core.d.ts.map +1 -1
  21. package/dist/web-component/types/enhanced-viewer.d.ts +13 -1
  22. package/dist/web-component/types/enhanced-viewer.d.ts.map +1 -1
  23. package/dist/web-component/types/events.d.ts +8 -1
  24. package/dist/web-component/types/events.d.ts.map +1 -1
  25. package/dist/web-component/types/types/core.d.ts +2 -0
  26. package/dist/web-component/types/types/core.d.ts.map +1 -1
  27. package/dist/web-component/types/types/enhanced-viewer.d.ts +13 -1
  28. package/dist/web-component/types/types/enhanced-viewer.d.ts.map +1 -1
  29. package/dist/web-component/types/types/events.d.ts +8 -1
  30. package/dist/web-component/types/types/events.d.ts.map +1 -1
  31. package/package.json +1 -1
@@ -104550,6 +104550,7 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
104550
104550
  FlyCamera.prototype.initialize = function () {
104551
104551
  this._isActive = true;
104552
104552
  this._isPointerLocked = false;
104553
+ this._isLooking = false;
104553
104554
  this._pressed = new Set();
104554
104555
  this._velocity = new Vec3(0, 0, 0);
104555
104556
  this._targetVelocity = new Vec3(0, 0, 0);
@@ -104571,21 +104572,24 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
104571
104572
  this._onKeyUp = this._handleKeyUp.bind(this);
104572
104573
  document.addEventListener('keydown', this._onKeyDown);
104573
104574
  document.addEventListener('keyup', this._onKeyUp);
104574
- // Mouse move when pointer locked
104575
+ // Mouse move for look (while mouse button held)
104575
104576
  this._onMouseMove = this._handleMouseMove.bind(this);
104576
104577
  document.addEventListener('mousemove', this._onMouseMove);
104577
- // Pointer lock change
104578
- this._onPointerLockChange = this._handlePointerLockChange.bind(this);
104579
- document.addEventListener('pointerlockchange', this._onPointerLockChange);
104580
- // Click on canvas to lock pointer
104578
+ // Mouse button handling: click + hold to look, release to stop
104581
104579
  const canvas = this.app.graphicsDevice.canvas;
104582
104580
  this._onClickToLock = (e) => {
104583
- // Left button to engage pointer lock
104581
+ // Left button enables look while held (no pointer lock)
104584
104582
  if (e.button === 0 && this._isActive) {
104585
- this._requestPointerLock();
104583
+ this._isLooking = true;
104586
104584
  }
104587
104585
  };
104588
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);
104589
104593
  };
104590
104594
  FlyCamera.prototype.update = function (dt) {
104591
104595
  if (!this._isActive)
@@ -104630,16 +104634,26 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
104630
104634
  this._onKeyDown = this._onKeyDown || this._handleKeyDown.bind(this);
104631
104635
  this._onKeyUp = this._onKeyUp || this._handleKeyUp.bind(this);
104632
104636
  this._onMouseMove = this._onMouseMove || this._handleMouseMove.bind(this);
104633
- this._onPointerLockChange =
104634
- this._onPointerLockChange || this._handlePointerLockChange.bind(this);
104635
104637
  document.addEventListener('keydown', this._onKeyDown);
104636
104638
  document.addEventListener('keyup', this._onKeyUp);
104637
104639
  document.addEventListener('mousemove', this._onMouseMove);
104638
- document.addEventListener('pointerlockchange', this._onPointerLockChange);
104639
104640
  const canvas = this.app.graphicsDevice.canvas;
104640
104641
  this._onClickToLock =
104641
- this._onClickToLock || (() => this._requestPointerLock());
104642
+ this._onClickToLock ||
104643
+ ((e) => {
104644
+ if (e.button === 0 && this._isActive) {
104645
+ this._isLooking = true;
104646
+ }
104647
+ });
104642
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);
104643
104657
  };
104644
104658
  FlyCamera.prototype.deactivate = function () {
104645
104659
  if (!this._isActive)
@@ -104651,7 +104665,7 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
104651
104665
  document.removeEventListener('keydown', this._onKeyDown);
104652
104666
  document.removeEventListener('keyup', this._onKeyUp);
104653
104667
  document.removeEventListener('mousemove', this._onMouseMove);
104654
- document.removeEventListener('pointerlockchange', this._onPointerLockChange);
104668
+ document.removeEventListener('mouseup', this._onMouseUp);
104655
104669
  const canvas = this.app?.graphicsDevice?.canvas;
104656
104670
  if (canvas && this._onClickToLock) {
104657
104671
  canvas.removeEventListener('mousedown', this._onClickToLock);
@@ -104735,7 +104749,7 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
104735
104749
  }
104736
104750
  };
104737
104751
  FlyCamera.prototype._handleMouseMove = function (e) {
104738
- if (!this._isPointerLocked || !this._isActive)
104752
+ if (!this._isLooking || !this._isActive)
104739
104753
  return;
104740
104754
  // Invert horizontal (yaw) rotation: moving mouse right rotates view left, and vice versa
104741
104755
  const dx = e.movementX * this.lookSensitivity;
@@ -105343,6 +105357,7 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
105343
105357
  transform,
105344
105358
  metadata,
105345
105359
  loadStartTime,
105360
+ visible: true,
105346
105361
  };
105347
105362
  if (blobUrl !== undefined) {
105348
105363
  modelInfo.blobUrl = blobUrl;
@@ -105546,6 +105561,54 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
105546
105561
  model.transform = transform;
105547
105562
  model.metadata.transform = transform;
105548
105563
  }
105564
+ /**
105565
+ * Set visibility for a specific model by ID
105566
+ * @param modelId ID of the model
105567
+ * @param visible True to show, false to hide
105568
+ */
105569
+ setModelVisible(modelId, visible) {
105570
+ const model = this.models.get(modelId);
105571
+ if (!model) {
105572
+ throw new Error(`Model with ID "${modelId}" not found`);
105573
+ }
105574
+ // Apply visibility to underlying entity
105575
+ if (model.entity) {
105576
+ model.entity.enabled = visible;
105577
+ }
105578
+ model.visible = visible;
105579
+ // Emit model-visibility-changed event
105580
+ if (this._eventEmitter) {
105581
+ this._eventEmitter('model-visibility-changed', {
105582
+ modelId: model.id,
105583
+ name: model.name,
105584
+ visible,
105585
+ });
105586
+ }
105587
+ }
105588
+ /**
105589
+ * Set visibility for all models matching a given name
105590
+ * @param name Model name to match (case-sensitive)
105591
+ * @param visible True to show, false to hide
105592
+ */
105593
+ setModelsVisibleByName(name, visible) {
105594
+ for (const model of this.models.values()) {
105595
+ if (model.name === name) {
105596
+ // Apply visibility to entity
105597
+ if (model.entity) {
105598
+ model.entity.enabled = visible;
105599
+ }
105600
+ model.visible = visible;
105601
+ // Emit model-visibility-changed event for each affected model
105602
+ if (this._eventEmitter) {
105603
+ this._eventEmitter('model-visibility-changed', {
105604
+ modelId: model.id,
105605
+ name: model.name,
105606
+ visible,
105607
+ });
105608
+ }
105609
+ }
105610
+ }
105611
+ }
105549
105612
  }
105550
105613
 
105551
105614
  // Core type definitions for the Web Component
@@ -140393,6 +140456,28 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
140393
140456
  }
140394
140457
  return this._modelManager.getSceneStats();
140395
140458
  }
140459
+ /**
140460
+ * Set visibility for a specific model by ID
140461
+ * @param modelId ID of the model
140462
+ * @param visible True to show, false to hide
140463
+ */
140464
+ setModelVisible(modelId, visible) {
140465
+ if (!this._modelManager) {
140466
+ throw new Error('SplatViewerCore.setModelVisible: ModelManager not initialized');
140467
+ }
140468
+ this._modelManager.setModelVisible(modelId, visible);
140469
+ }
140470
+ /**
140471
+ * Set visibility for all models matching a given name
140472
+ * @param name Model name to match (case-sensitive)
140473
+ * @param visible True to show, false to hide
140474
+ */
140475
+ setModelsVisibleByName(name, visible) {
140476
+ if (!this._modelManager) {
140477
+ throw new Error('SplatViewerCore.setModelsVisibleByName: ModelManager not initialized');
140478
+ }
140479
+ this._modelManager.setModelsVisibleByName(name, visible);
140480
+ }
140396
140481
  // ==========================================
140397
140482
  // Transform System API
140398
140483
  // ==========================================
@@ -141885,6 +141970,28 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
141885
141970
  }
141886
141971
  return this._core.getSceneStats();
141887
141972
  }
141973
+ /**
141974
+ * Set visibility for a specific model by ID
141975
+ * @param modelId ID of the model
141976
+ * @param visible True to show, false to hide
141977
+ */
141978
+ setModelVisible(modelId, visible) {
141979
+ if (!this._core) {
141980
+ throw new Error('SplatViewerElement: Core not initialized. Call connectedCallback first.');
141981
+ }
141982
+ this._core.setModelVisible(modelId, visible);
141983
+ }
141984
+ /**
141985
+ * Set visibility for all models matching a given name
141986
+ * @param name Model name to match (case-sensitive)
141987
+ * @param visible True to show, false to hide
141988
+ */
141989
+ setModelsVisibleByName(name, visible) {
141990
+ if (!this._core) {
141991
+ throw new Error('SplatViewerElement: Core not initialized. Call connectedCallback first.');
141992
+ }
141993
+ this._core.setModelsVisibleByName(name, visible);
141994
+ }
141888
141995
  // ==========================================
141889
141996
  // Camera Mode / Fly Camera API
141890
141997
  // ==========================================