@heliguy-xyz/splat-viewer 1.0.0-rc.26 → 1.0.0-rc.27

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 (23) hide show
  1. package/dist/web-component/splat-viewer.esm.js +88 -19
  2. package/dist/web-component/splat-viewer.esm.min.js +1 -1
  3. package/dist/web-component/splat-viewer.js +88 -19
  4. package/dist/web-component/splat-viewer.min.js +1 -1
  5. package/dist/web-component/supersplat-core/controllers.d.ts +5 -0
  6. package/dist/web-component/supersplat-core/controllers.d.ts.map +1 -1
  7. package/dist/web-component/supersplat-core/splat.d.ts.map +1 -1
  8. package/dist/web-component/types/supersplat-core/controllers.d.ts +5 -0
  9. package/dist/web-component/types/supersplat-core/controllers.d.ts.map +1 -1
  10. package/dist/web-component/types/supersplat-core/splat.d.ts.map +1 -1
  11. package/dist/web-component/types/web-component/OrbitCameraScript.d.ts.map +1 -1
  12. package/dist/web-component/types/web-component/SplatViewerCore.d.ts.map +1 -1
  13. package/dist/web-component/types/web-component/SupersplatAdapter.d.ts +9 -0
  14. package/dist/web-component/types/web-component/SupersplatAdapter.d.ts.map +1 -1
  15. package/dist/web-component/types/web-component/utils/config.d.ts +1 -0
  16. package/dist/web-component/types/web-component/utils/config.d.ts.map +1 -1
  17. package/dist/web-component/web-component/OrbitCameraScript.d.ts.map +1 -1
  18. package/dist/web-component/web-component/SplatViewerCore.d.ts.map +1 -1
  19. package/dist/web-component/web-component/SupersplatAdapter.d.ts +9 -0
  20. package/dist/web-component/web-component/SupersplatAdapter.d.ts.map +1 -1
  21. package/dist/web-component/web-component/utils/config.d.ts +1 -0
  22. package/dist/web-component/web-component/utils/config.d.ts.map +1 -1
  23. package/package.json +1 -1
@@ -139557,11 +139557,15 @@ function parseJsonSafely(jsonString) {
139557
139557
  }
139558
139558
  /**
139559
139559
  * Convert a string to a boolean value
139560
+ * For HTML boolean attributes, an empty string means the attribute is present (true)
139560
139561
  */
139561
139562
  function parseBoolean(value) {
139562
139563
  if (typeof value === 'boolean')
139563
139564
  return value;
139564
139565
  if (typeof value === 'string') {
139566
+ // Empty string means attribute is present without value (should be true for boolean attributes)
139567
+ if (value === '')
139568
+ return true;
139565
139569
  return value.toLowerCase() === 'true' || value === '1';
139566
139570
  }
139567
139571
  return false;
@@ -140452,6 +140456,10 @@ function registerOrbitCameraScript() {
140452
140456
  this.isPanning = false;
140453
140457
  // Allow host to temporarily disable camera input (e.g., while dragging gizmos)
140454
140458
  this._inputEnabled = true;
140459
+ // Granular control over specific input types
140460
+ this._orbitEnabled = true;
140461
+ this._panEnabled = true;
140462
+ this._zoomEnabled = true;
140455
140463
  // Setup context menu prevention
140456
140464
  this.setupContextMenuPrevention();
140457
140465
  // Use PlayCanvas mouse events for reliable input handling
@@ -140489,6 +140497,19 @@ function registerOrbitCameraScript() {
140489
140497
  this.isPanning = false;
140490
140498
  }
140491
140499
  };
140500
+ OrbitCamera.prototype.setInputControls = function (options) {
140501
+ if (options.orbit !== undefined)
140502
+ this._orbitEnabled = !!options.orbit;
140503
+ if (options.pan !== undefined)
140504
+ this._panEnabled = !!options.pan;
140505
+ if (options.zoom !== undefined)
140506
+ this._zoomEnabled = !!options.zoom;
140507
+ // Clear any in-progress interactions if being disabled
140508
+ if (this._orbitEnabled === false)
140509
+ this.isOrbiting = false;
140510
+ if (this._panEnabled === false)
140511
+ this.isPanning = false;
140512
+ };
140492
140513
  OrbitCamera.prototype.update = function (dt) {
140493
140514
  // Update navigation cube if enabled
140494
140515
  if (this.navigationCube &&
@@ -140505,12 +140526,13 @@ function registerOrbitCameraScript() {
140505
140526
  typeof this.navigationCube.cancelTransition === 'function') {
140506
140527
  this.navigationCube.cancelTransition('manual-interaction');
140507
140528
  }
140508
- if (event.button === MOUSEBUTTON_LEFT) {
140529
+ if (event.button === MOUSEBUTTON_LEFT && this._orbitEnabled !== false) {
140509
140530
  this.isOrbiting = true;
140510
140531
  this.emitInteractionEvent?.('interaction-start', 'rotate');
140511
140532
  }
140512
- else if (event.button === MOUSEBUTTON_RIGHT ||
140513
- event.button === MOUSEBUTTON_MIDDLE) {
140533
+ else if ((event.button === MOUSEBUTTON_RIGHT ||
140534
+ event.button === MOUSEBUTTON_MIDDLE) &&
140535
+ this._panEnabled !== false) {
140514
140536
  this.isPanning = true;
140515
140537
  this.emitInteractionEvent?.('interaction-start', 'pan');
140516
140538
  }
@@ -140558,7 +140580,7 @@ function registerOrbitCameraScript() {
140558
140580
  }
140559
140581
  };
140560
140582
  OrbitCamera.prototype.onMouseWheel = function (event) {
140561
- if (this._inputEnabled === false)
140583
+ if (this._inputEnabled === false || this._zoomEnabled === false)
140562
140584
  return;
140563
140585
  // Cancel any ongoing navigation cube transition when manual zoom interaction starts
140564
140586
  if (this.navigationCube &&
@@ -142694,6 +142716,10 @@ class Splat extends Element$1 {
142694
142716
  this.entity.setEulerAngles(orientation);
142695
142717
  this.entity.addComponent('gsplat', { asset });
142696
142718
  const instance = this.entity.gsplat.instance;
142719
+ // Check if the gsplat component initialized properly
142720
+ if (!instance || !instance.meshInstance) {
142721
+ throw new Error('Failed to initialize gsplat component. The file may not contain valid Gaussian Splatting data.');
142722
+ }
142697
142723
  // use custom render order distance calculation for splats
142698
142724
  instance.meshInstance.calculateSortDistance = (meshInstance, pos, dir) => {
142699
142725
  const bound = this.localBound;
@@ -143802,6 +143828,10 @@ class PointerController {
143802
143828
  };
143803
143829
  // Allow temporarily disabling camera controls (e.g. while dragging gizmos).
143804
143830
  let enabled = true;
143831
+ // Granular control over specific input types
143832
+ let orbitEnabled = true;
143833
+ let panEnabled = true;
143834
+ let zoomEnabled = true;
143805
143835
  const resetState = () => {
143806
143836
  pressedButton = -1;
143807
143837
  touches = [];
@@ -143908,13 +143938,13 @@ class PointerController {
143908
143938
  (event.shiftKey || event.ctrlKey ? 'orbit' :
143909
143939
  (event.altKey || event.metaKey ? 'zoom' : null)) :
143910
143940
  null;
143911
- if (mod === 'orbit' || (mod === null && pressedButton === 0)) {
143941
+ if ((mod === 'orbit' || (mod === null && pressedButton === 0)) && orbitEnabled) {
143912
143942
  orbit(dx, dy);
143913
143943
  }
143914
- else if (mod === 'zoom' || (mod === null && pressedButton === 1)) {
143944
+ else if ((mod === 'zoom' || (mod === null && pressedButton === 1)) && zoomEnabled) {
143915
143945
  zoom(dy * -0.02);
143916
143946
  }
143917
- else if (mod === 'pan' || (mod === null && pressedButton === 2)) {
143947
+ else if ((mod === 'pan' || (mod === null && pressedButton === 2)) && panEnabled) {
143918
143948
  pan(x, y, dx, dy);
143919
143949
  }
143920
143950
  }
@@ -143925,7 +143955,9 @@ class PointerController {
143925
143955
  const dy = event.offsetY - touch.y;
143926
143956
  touch.x = event.offsetX;
143927
143957
  touch.y = event.offsetY;
143928
- orbit(dx, dy);
143958
+ if (orbitEnabled) {
143959
+ orbit(dx, dy);
143960
+ }
143929
143961
  }
143930
143962
  else if (touches.length === 2) {
143931
143963
  const touch = touches[touches.map(t => t.id).indexOf(event.pointerId)];
@@ -143934,8 +143966,12 @@ class PointerController {
143934
143966
  const mx = (touches[0].x + touches[1].x) * 0.5;
143935
143967
  const my = (touches[0].y + touches[1].y) * 0.5;
143936
143968
  const ml = dist(touches[0].x, touches[0].y, touches[1].x, touches[1].y);
143937
- pan(mx, my, (mx - midx), (my - midy));
143938
- zoom((ml - midlen) * 0.01);
143969
+ if (panEnabled) {
143970
+ pan(mx, my, (mx - midx), (my - midy));
143971
+ }
143972
+ if (zoomEnabled) {
143973
+ zoom((ml - midlen) * 0.01);
143974
+ }
143939
143975
  midx = mx;
143940
143976
  midy = my;
143941
143977
  midlen = ml;
@@ -143953,16 +143989,20 @@ class PointerController {
143953
143989
  return;
143954
143990
  const { deltaX, deltaY } = event;
143955
143991
  if (isMouseEvent(deltaX, deltaY)) {
143956
- zoom(deltaY * -2e-3);
143992
+ if (zoomEnabled)
143993
+ zoom(deltaY * -2e-3);
143957
143994
  }
143958
143995
  else if (event.ctrlKey || event.metaKey) {
143959
- zoom(deltaY * -0.02);
143996
+ if (zoomEnabled)
143997
+ zoom(deltaY * -0.02);
143960
143998
  }
143961
143999
  else if (event.shiftKey) {
143962
- pan(event.offsetX, event.offsetY, deltaX, deltaY);
144000
+ if (panEnabled)
144001
+ pan(event.offsetX, event.offsetY, deltaX, deltaY);
143963
144002
  }
143964
144003
  else {
143965
- orbit(deltaX, deltaY);
144004
+ if (orbitEnabled)
144005
+ orbit(deltaX, deltaY);
143966
144006
  }
143967
144007
  event.preventDefault();
143968
144008
  };
@@ -144030,6 +144070,14 @@ class PointerController {
144030
144070
  resetState();
144031
144071
  }
144032
144072
  };
144073
+ this.setInputControls = (options) => {
144074
+ if (options.orbit !== undefined)
144075
+ orbitEnabled = !!options.orbit;
144076
+ if (options.pan !== undefined)
144077
+ panEnabled = !!options.pan;
144078
+ if (options.zoom !== undefined)
144079
+ zoomEnabled = !!options.zoom;
144080
+ };
144033
144081
  }
144034
144082
  }
144035
144083
 
@@ -147334,6 +147382,26 @@ class SupersplatAdapter {
147334
147382
  console.warn('SupersplatAdapter: Failed to toggle camera controls', e);
147335
147383
  }
147336
147384
  }
147385
+ /**
147386
+ * Configure granular control over specific camera input types.
147387
+ * Allows enabling/disabling orbit, pan, and zoom independently.
147388
+ */
147389
+ setCameraInputControls(options) {
147390
+ const controller = this.scene?.camera?.controller;
147391
+ if (!controller)
147392
+ return;
147393
+ try {
147394
+ if (typeof controller.setInputControls === 'function') {
147395
+ controller.setInputControls(options);
147396
+ }
147397
+ else {
147398
+ console.warn('SupersplatAdapter: Camera controller does not support setInputControls');
147399
+ }
147400
+ }
147401
+ catch (e) {
147402
+ console.warn('SupersplatAdapter: Failed to set camera input controls', e);
147403
+ }
147404
+ }
147337
147405
  /**
147338
147406
  * Enable/disable supersplat-core camera auto-update (orbit tweens).
147339
147407
  * When enabled, the camera entity transform may be driven by an external controller (fly mode).
@@ -147792,9 +147860,9 @@ class SplatViewerCore {
147792
147860
  this._supersplatReady = this._supersplat.init();
147793
147861
  this._supersplatReady
147794
147862
  ?.then(() => {
147795
- // Disable camera controls in preview mode
147863
+ // In preview mode, enable zoom only (disable orbit and pan)
147796
147864
  if (this.previewMode && this._supersplat) {
147797
- this._supersplat.setCameraControlsEnabled?.(false);
147865
+ this._supersplat.setCameraInputControls?.({ orbit: false, pan: false, zoom: true });
147798
147866
  }
147799
147867
  // Only set up fly camera if not in preview mode
147800
147868
  if (!this.previewMode) {
@@ -150007,11 +150075,12 @@ class SplatViewerCore {
150007
150075
  detail: { type: interactionType },
150008
150076
  });
150009
150077
  };
150010
- // Disable camera controls in preview mode
150078
+ // In preview mode, enable zoom only (disable orbit and pan)
150011
150079
  if (this.previewMode && this._orbit) {
150012
150080
  const orbitAny = this._orbit;
150013
- if (typeof orbitAny.setEnabled === 'function') {
150014
- orbitAny.setEnabled(false);
150081
+ if (typeof orbitAny.setInputControls === 'function') {
150082
+ // Enable zoom, disable orbit and pan
150083
+ orbitAny.setInputControls({ orbit: false, pan: false, zoom: true });
150015
150084
  }
150016
150085
  }
150017
150086
  this.entities.camera.setPosition(0, 0, 10);