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

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.
@@ -140037,7 +140037,7 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
140037
140037
  this.focus(result.entity);
140038
140038
  setTimeout(() => {
140039
140039
  const info = this.debugInfo();
140040
- console.log(info);
140040
+ // no-op
140041
140041
  if (!info.boundsRadius) {
140042
140042
  this.focus(result.entity);
140043
140043
  }
@@ -140833,6 +140833,7 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
140833
140833
  if (!this.app)
140834
140834
  return;
140835
140835
  const canvas = this.app.graphicsDevice.canvas;
140836
+ // debug removed
140836
140837
  // Ensure canvas and its parent fill available space by default (non-destructive)
140837
140838
  if (!canvas.style.display)
140838
140839
  canvas.style.display = 'block';
@@ -140846,18 +140847,22 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
140846
140847
  ps.width = '100%';
140847
140848
  if (!ps.height)
140848
140849
  ps.height = '100%';
140850
+ // debug removed
140849
140851
  }
140850
140852
  // Helper: apply resolution and notify dependents
140851
140853
  const applyResolution = (width, height) => {
140852
140854
  if (canvas.width === width && canvas.height === height)
140853
140855
  return;
140856
+ // track previous size if needed in future
140854
140857
  canvas.width = width;
140855
140858
  canvas.height = height;
140856
140859
  this.app.resizeCanvas(width, height);
140860
+ // debug removed
140857
140861
  if (this._orbit &&
140858
140862
  this._orbit.navigationCube &&
140859
140863
  typeof this._orbit.navigationCube.onCanvasResize === 'function') {
140860
140864
  this._orbit.navigationCube.onCanvasResize();
140865
+ // debug removed
140861
140866
  }
140862
140867
  };
140863
140868
  // Fallback: compute from CSS box * devicePixelRatio
@@ -140866,6 +140871,7 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
140866
140871
  const pixelRatio = window.devicePixelRatio || 1;
140867
140872
  const width = Math.floor(rect.width * pixelRatio);
140868
140873
  const height = Math.floor(rect.height * pixelRatio);
140874
+ // debug removed
140869
140875
  applyResolution(width, height);
140870
140876
  };
140871
140877
  // Prefer ResizeObserver entry data (devicePixelContentBoxSize when available)
@@ -140876,6 +140882,7 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
140876
140882
  if (dpcb && dpcb.length > 0) {
140877
140883
  width = Math.ceil(dpcb[0].inlineSize);
140878
140884
  height = Math.ceil(dpcb[0].blockSize);
140885
+ // debug removed
140879
140886
  }
140880
140887
  else {
140881
140888
  const cbs = entry.contentBoxSize;
@@ -140883,6 +140890,7 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
140883
140890
  const pixelRatio = window.devicePixelRatio || 1;
140884
140891
  width = Math.ceil(cbs[0].inlineSize * pixelRatio);
140885
140892
  height = Math.ceil(cbs[0].blockSize * pixelRatio);
140893
+ // debug removed
140886
140894
  }
140887
140895
  }
140888
140896
  if (width !== null && height !== null) {
@@ -140894,6 +140902,7 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
140894
140902
  };
140895
140903
  // Initial resolution setup
140896
140904
  updateResolution();
140905
+ // debug removed
140897
140906
  // Set up resize observer for automatic resolution updates
140898
140907
  if (window.ResizeObserver) {
140899
140908
  this._resizeObserver = new ResizeObserver((entries) => {
@@ -140922,16 +140931,53 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
140922
140931
  }
140923
140932
  });
140924
140933
  // Observe both the canvas and its parent container for resize events
140925
- this._resizeObserver.observe(canvas);
140934
+ try {
140935
+ // Prefer device-pixel-content-box for pixel-perfect canvas sizing
140936
+ ;
140937
+ this._resizeObserver.observe(canvas, {
140938
+ box: 'device-pixel-content-box',
140939
+ });
140940
+ }
140941
+ catch {
140942
+ this._resizeObserver.observe(canvas);
140943
+ }
140944
+ // debug removed
140926
140945
  if (canvas.parentElement) {
140927
140946
  this._resizeObserver.observe(canvas.parentElement);
140947
+ // debug removed
140928
140948
  }
140929
140949
  }
140930
140950
  // Additionally listen to window resize to handle viewport changes
140931
140951
  // (e.g., when resizing dev tools). This mirrors superSplat behavior
140932
140952
  // and ensures the canvas always matches the available space.
140933
- window.addEventListener('resize', updateResolution);
140934
- this._resizeHandler = updateResolution;
140953
+ const onWindowResize = () => {
140954
+ updateResolution();
140955
+ };
140956
+ window.addEventListener('resize', onWindowResize);
140957
+ this._resizeHandler = onWindowResize;
140958
+ }
140959
+ /**
140960
+ * Force recalculation of canvas resolution based on current DOM size.
140961
+ * Useful when container layout changes are not captured by the observer.
140962
+ */
140963
+ updateCanvasResolution() {
140964
+ if (!this.app)
140965
+ return;
140966
+ const canvas = this.app.graphicsDevice.canvas;
140967
+ const rect = canvas.getBoundingClientRect();
140968
+ const pixelRatio = window.devicePixelRatio || 1;
140969
+ const width = Math.floor(rect.width * pixelRatio);
140970
+ const height = Math.floor(rect.height * pixelRatio);
140971
+ if (canvas.width !== width || canvas.height !== height) {
140972
+ canvas.width = width;
140973
+ canvas.height = height;
140974
+ this.app.resizeCanvas(width, height);
140975
+ if (this._orbit &&
140976
+ this._orbit.navigationCube &&
140977
+ typeof this._orbit.navigationCube.onCanvasResize === 'function') {
140978
+ this._orbit.navigationCube.onCanvasResize();
140979
+ }
140980
+ }
140935
140981
  }
140936
140982
  }
140937
140983
 
@@ -140962,6 +141008,7 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
140962
141008
  this._config = { ...DEFAULT_CONFIG };
140963
141009
  this._isInitialized = false;
140964
141010
  this._isDestroyed = false;
141011
+ this._hostResizeObserver = null;
140965
141012
  }
140966
141013
  // Observed attributes that trigger attributeChangedCallback
140967
141014
  static get observedAttributes() {
@@ -141309,6 +141356,22 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
141309
141356
  this._canvas.setAttribute('role', 'img');
141310
141357
  this._canvas.setAttribute('aria-label', '3D Splat Viewer');
141311
141358
  this.appendChild(this._canvas);
141359
+ // Observe host element for size changes and force canvas resolution update
141360
+ try {
141361
+ if (window.ResizeObserver) {
141362
+ this._hostResizeObserver = new ResizeObserver(() => {
141363
+ // Force resolution update in core to sync canvas with host/container
141364
+ try {
141365
+ this._core?.updateCanvasResolution();
141366
+ }
141367
+ catch { }
141368
+ });
141369
+ this._hostResizeObserver.observe(this);
141370
+ if (this.parentElement)
141371
+ this._hostResizeObserver.observe(this.parentElement);
141372
+ }
141373
+ }
141374
+ catch { }
141312
141375
  // Update configuration from attributes
141313
141376
  this._updateConfigFromAttributes();
141314
141377
  // Initialize the core viewer
@@ -141365,6 +141428,11 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
141365
141428
  return;
141366
141429
  }
141367
141430
  try {
141431
+ // Disconnect host resize observer
141432
+ if (this._hostResizeObserver) {
141433
+ this._hostResizeObserver.disconnect();
141434
+ this._hostResizeObserver = null;
141435
+ }
141368
141436
  // Clean up core
141369
141437
  if (this._core) {
141370
141438
  this._core.destroy();
@@ -141484,7 +141552,6 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
141484
141552
  return;
141485
141553
  }
141486
141554
  // Stats handling will be implemented when we add stats functionality
141487
- console.log('Stats change requested:', this.enableStats);
141488
141555
  }
141489
141556
  /**
141490
141557
  * Set up event listeners for the core viewer