@spatial-elements/core 0.1.0-beta.2 → 1.0.0-beta.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.
Files changed (140) hide show
  1. package/README.md +9 -3
  2. package/dist/catalog/CatalogGeometryFade.d.ts.map +1 -1
  3. package/dist/catalog/CatalogGeometryFade.js +6 -2
  4. package/dist/catalog/CatalogGeometryFade.js.map +1 -1
  5. package/dist/catalog/CatalogPreparation.d.ts +3 -3
  6. package/dist/catalog/CatalogPreparation.d.ts.map +1 -1
  7. package/dist/catalog/CatalogPreparation.js +2 -1
  8. package/dist/catalog/CatalogPreparation.js.map +1 -1
  9. package/dist/catalog/CatalogSpatialElementLayer.d.ts +1 -0
  10. package/dist/catalog/CatalogSpatialElementLayer.d.ts.map +1 -1
  11. package/dist/catalog/CatalogSpatialElementLayer.js +46 -18
  12. package/dist/catalog/CatalogSpatialElementLayer.js.map +1 -1
  13. package/dist/catalog/CatalogTransition.d.ts.map +1 -1
  14. package/dist/catalog/CatalogTransition.js +25 -7
  15. package/dist/catalog/CatalogTransition.js.map +1 -1
  16. package/dist/catalog/SpatialPageRegistry.d.ts +17 -0
  17. package/dist/catalog/SpatialPageRegistry.d.ts.map +1 -0
  18. package/dist/catalog/SpatialPageRegistry.js +21 -0
  19. package/dist/catalog/SpatialPageRegistry.js.map +1 -0
  20. package/dist/catalog/carouselMotion.d.ts +39 -0
  21. package/dist/catalog/carouselMotion.d.ts.map +1 -0
  22. package/dist/catalog/carouselMotion.js +104 -0
  23. package/dist/catalog/carouselMotion.js.map +1 -0
  24. package/dist/catalog/catalogPage.d.ts +7 -3
  25. package/dist/catalog/catalogPage.d.ts.map +1 -1
  26. package/dist/catalog/catalogPage.js.map +1 -1
  27. package/dist/catalog/spatialElementAssets.d.ts +5 -5
  28. package/dist/catalog/spatialElementAssets.d.ts.map +1 -1
  29. package/dist/catalog/spatialElementAssets.js.map +1 -1
  30. package/dist/catalog/spatialElementLodPair.d.ts +2 -1
  31. package/dist/catalog/spatialElementLodPair.d.ts.map +1 -1
  32. package/dist/catalog/spatialElementLodPair.js.map +1 -1
  33. package/dist/index.d.ts +5 -2
  34. package/dist/index.d.ts.map +1 -1
  35. package/dist/index.js +4 -1
  36. package/dist/index.js.map +1 -1
  37. package/dist/spatial-element/SpatialElementDockController.d.ts.map +1 -1
  38. package/dist/spatial-element/SpatialElementDockController.js +4 -3
  39. package/dist/spatial-element/SpatialElementDockController.js.map +1 -1
  40. package/dist/spatial-element/messages.d.ts +32 -0
  41. package/dist/spatial-element/messages.d.ts.map +1 -0
  42. package/dist/spatial-element/messages.js +34 -0
  43. package/dist/spatial-element/messages.js.map +1 -0
  44. package/dist/spatial-element/spatialElement.d.ts +16 -12
  45. package/dist/spatial-element/spatialElement.d.ts.map +1 -1
  46. package/dist/spatial-element/spatialElement.js +32 -6
  47. package/dist/spatial-element/spatialElement.js.map +1 -1
  48. package/dist/spatial-element/spatialElementGeometry.d.ts +22 -0
  49. package/dist/spatial-element/spatialElementGeometry.d.ts.map +1 -0
  50. package/dist/spatial-element/spatialElementGeometry.js +40 -0
  51. package/dist/spatial-element/spatialElementGeometry.js.map +1 -0
  52. package/dist/spatial-element/spatialElementScene.d.ts +16 -0
  53. package/dist/spatial-element/spatialElementScene.d.ts.map +1 -0
  54. package/dist/spatial-element/spatialElementScene.js +22 -0
  55. package/dist/spatial-element/spatialElementScene.js.map +1 -0
  56. package/dist/spatial-element/spatialTheme.d.ts +16 -0
  57. package/dist/spatial-element/spatialTheme.d.ts.map +1 -0
  58. package/dist/spatial-element/spatialTheme.js +53 -0
  59. package/dist/spatial-element/spatialTheme.js.map +1 -0
  60. package/dist/spatial-element/types.d.ts +63 -33
  61. package/dist/spatial-element/types.d.ts.map +1 -1
  62. package/dist/spatial-element/types.js.map +1 -1
  63. package/dist/stage/LiquidGlassPanel.d.ts +2 -0
  64. package/dist/stage/LiquidGlassPanel.d.ts.map +1 -1
  65. package/dist/stage/LiquidGlassPanel.js +11 -2
  66. package/dist/stage/LiquidGlassPanel.js.map +1 -1
  67. package/dist/stage/MinimapController.js +1 -1
  68. package/dist/stage/MinimapController.js.map +1 -1
  69. package/dist/stage/ModelPointerPreview.d.ts +22 -0
  70. package/dist/stage/ModelPointerPreview.d.ts.map +1 -0
  71. package/dist/stage/ModelPointerPreview.js +71 -0
  72. package/dist/stage/ModelPointerPreview.js.map +1 -0
  73. package/dist/stage/PageBindingController.d.ts.map +1 -1
  74. package/dist/stage/PageBindingController.js +3 -1
  75. package/dist/stage/PageBindingController.js.map +1 -1
  76. package/dist/stage/PanelPresentationController.d.ts +3 -1
  77. package/dist/stage/PanelPresentationController.d.ts.map +1 -1
  78. package/dist/stage/PanelPresentationController.js +69 -12
  79. package/dist/stage/PanelPresentationController.js.map +1 -1
  80. package/dist/stage/SpatialElementInteractionController.d.ts +10 -1
  81. package/dist/stage/SpatialElementInteractionController.d.ts.map +1 -1
  82. package/dist/stage/SpatialElementInteractionController.js +104 -10
  83. package/dist/stage/SpatialElementInteractionController.js.map +1 -1
  84. package/dist/stage/StageExperience.d.ts +22 -4
  85. package/dist/stage/StageExperience.d.ts.map +1 -1
  86. package/dist/stage/StageExperience.js +131 -57
  87. package/dist/stage/StageExperience.js.map +1 -1
  88. package/dist/stage/StagePanelRuntime.d.ts +2 -1
  89. package/dist/stage/StagePanelRuntime.d.ts.map +1 -1
  90. package/dist/stage/StagePanelRuntime.js.map +1 -1
  91. package/dist/stage/StageRenderPipeline.d.ts +8 -1
  92. package/dist/stage/StageRenderPipeline.d.ts.map +1 -1
  93. package/dist/stage/StageRenderPipeline.js +24 -7
  94. package/dist/stage/StageRenderPipeline.js.map +1 -1
  95. package/dist/stage/VirtualScrollController.d.ts.map +1 -1
  96. package/dist/stage/VirtualScrollController.js +0 -2
  97. package/dist/stage/VirtualScrollController.js.map +1 -1
  98. package/dist/stage/interactionGuidance.d.ts +22 -0
  99. package/dist/stage/interactionGuidance.d.ts.map +1 -0
  100. package/dist/stage/interactionGuidance.js +53 -0
  101. package/dist/stage/interactionGuidance.js.map +1 -0
  102. package/dist/stage/minimap/MinimapGeometry.d.ts.map +1 -1
  103. package/dist/stage/minimap/MinimapGeometry.js +29 -0
  104. package/dist/stage/minimap/MinimapGeometry.js.map +1 -1
  105. package/dist/stage/mouseHover.d.ts +9 -0
  106. package/dist/stage/mouseHover.d.ts.map +1 -0
  107. package/dist/stage/mouseHover.js +55 -0
  108. package/dist/stage/mouseHover.js.map +1 -0
  109. package/dist/stage/panelContext.d.ts +9 -2
  110. package/dist/stage/panelContext.d.ts.map +1 -1
  111. package/dist/stage/panelContext.js.map +1 -1
  112. package/dist/stage/renderSettings.d.ts +10 -0
  113. package/dist/stage/renderSettings.d.ts.map +1 -0
  114. package/dist/stage/renderSettings.js +27 -0
  115. package/dist/stage/renderSettings.js.map +1 -0
  116. package/dist/stage/renderTargetInventory.d.ts +1 -1
  117. package/dist/stage/renderTargetInventory.js +1 -1
  118. package/dist/stage/renderTargetInventory.js.map +1 -1
  119. package/dist/stage/scrollFrame.d.ts +2 -0
  120. package/dist/stage/scrollFrame.d.ts.map +1 -1
  121. package/dist/stage/scrollFrame.js +18 -5
  122. package/dist/stage/scrollFrame.js.map +1 -1
  123. package/dist/stage/spatialElementFrame.d.ts.map +1 -1
  124. package/dist/stage/spatialElementFrame.js +5 -1
  125. package/dist/stage/spatialElementFrame.js.map +1 -1
  126. package/dist/stage/stageConstants.d.ts +3 -3
  127. package/dist/stage/stageConstants.d.ts.map +1 -1
  128. package/dist/stage/stageConstants.js +3 -3
  129. package/dist/stage/stageConstants.js.map +1 -1
  130. package/dist/stage/stageMath.d.ts +6 -7
  131. package/dist/stage/stageMath.d.ts.map +1 -1
  132. package/dist/stage/stageMath.js +12 -11
  133. package/dist/stage/stageMath.js.map +1 -1
  134. package/dist/stage/stageTypes.d.ts +21 -2
  135. package/dist/stage/stageTypes.d.ts.map +1 -1
  136. package/dist/stage/stageTypes.js.map +1 -1
  137. package/dist/stage/stageVisualTest.d.ts +3 -1
  138. package/dist/stage/stageVisualTest.d.ts.map +1 -1
  139. package/dist/stage/stageVisualTest.js.map +1 -1
  140. package/package.json +3 -3
@@ -23,7 +23,7 @@ import { LiquidGlassPanel, resolveLiquidGlassPanelOptions } from './LiquidGlassP
23
23
  import { STAGE_PANEL_LAYOUT_EVENT, STAGE_PANEL_VISUAL_EVENT } from './panelContext.js';
24
24
  import { DEFAULT_INTERACTION_THEME, DEFAULT_PANELS, PANEL_CAMERA_FOV, PANEL_CONTENT_Z, SPATIAL_ELEMENT_CAMERA_FIT_MARGIN, ZOOM_FOCUS_NOTIFY_EPSILON } from './stageConstants.js';
25
25
  import { getStagePositionFromRect, isViewportRectVisible } from './stageDom.js';
26
- import { STAGE_SCROLL_PRIORITY, getStageVisualScrollPosition, subscribeStageScrollFrame } from './scrollFrame.js';
26
+ import { STAGE_SCROLL_PRIORITY, getStageVisualScrollPosition, hasPendingStageScrollFrame, subscribeStageScrollFrame } from './scrollFrame.js';
27
27
  import { getCameraFitDistance, getCameraOrbitDirection, getBoxCorners, getPanelFocusOpacity, getPerspectiveDistance, getSequencedMinimapFocus, getStageUiFocus, getZoomFocusDistanceRange, hasPanelGeometryChanged } from './stageMath.js';
28
28
  import {} from './SpaceMouseAdapter.js';
29
29
  import { disposeMinimapModelMaterials } from './minimap/MinimapModel.js';
@@ -180,6 +180,10 @@ export class StageExperience {
180
180
  resize = () => this.resizeRenderer();
181
181
  render = () => {
182
182
  this.renderRequestId = 0;
183
+ // The shared callback will draw after updating DOM/dock positions. Avoid
184
+ // submitting an older camera/scroll frame immediately before that draw.
185
+ if (this.stopScrollFrames && hasPendingStageScrollFrame())
186
+ return;
183
187
  this.renderFrame();
184
188
  };
185
189
  visibilityChange = () => {
@@ -187,9 +191,15 @@ export class StageExperience {
187
191
  this.requestRender();
188
192
  };
189
193
  pointerMove = (event) => this.handlePointerMove(event);
190
- pointerLeave = () => this.handlePointerLeave();
194
+ pointerLeave = (event) => {
195
+ if (event.type === 'blur' || event.pointerType === 'mouse') {
196
+ this.handlePointerLeave();
197
+ }
198
+ };
199
+ pointerContact = (event) => this.interaction.handlePointerContact(event);
191
200
  pointerDown = (event) => this.handlePointerDown(event);
192
201
  pointerUp = (event) => this.handlePointerUp(event);
202
+ touchStart = (event) => this.interaction.handleTouchStart(event);
193
203
  wheel = (event) => this.handleWheel(event);
194
204
  scroll = (frame) => this.handleScrollFrame(frame);
195
205
  finishScroll = () => {
@@ -244,7 +254,9 @@ export class StageExperience {
244
254
  animationActive = false;
245
255
  scrollActive = false;
246
256
  scrollEndTimer = 0;
247
- lastInteractionTime = performance.now();
257
+ // Input events must not reset the frame clock: high-rate wheel/SpaceMouse
258
+ // events can arrive just before RAF and otherwise starve the damping delta.
259
+ lastFrameTime = performance.now();
248
260
  layoutDirty = true;
249
261
  panelMeasurementsDirty = true;
250
262
  viewportMeasurementDirty = true;
@@ -310,9 +322,6 @@ export class StageExperience {
310
322
  container,
311
323
  cssRoot: this.cssRenderer.domElement,
312
324
  requestRender: () => this.requestRender(),
313
- markActivity: () => {
314
- this.lastInteractionTime = performance.now();
315
- },
316
325
  updateProjection: () => this.updateStageCameraProjection(),
317
326
  readGeometry: () => ({
318
327
  poseOwner: this.catalogHandoff || this.spatialCapture
@@ -401,6 +410,7 @@ export class StageExperience {
401
410
  : DEFAULT_PANELS;
402
411
  this.pipeline = new StageRenderPipeline({
403
412
  pageBackground: (this.pageBackground = options.pageBackground ?? '#ffffff'),
413
+ renderSettings: options.renderSettings,
404
414
  renderer: this.renderer,
405
415
  container: this.container,
406
416
  backgroundCanvas: this.backgroundCanvas,
@@ -505,12 +515,14 @@ export class StageExperience {
505
515
  window.addEventListener(STAGE_PANEL_LAYOUT_EVENT, this.requestPanelSync);
506
516
  window.addEventListener(STAGE_PANEL_VISUAL_EVENT, this.requestPanelVisualSync);
507
517
  window.addEventListener('pointermove', this.pointerMove);
518
+ window.addEventListener('pointerdown', this.pointerContact, { capture: true, passive: true });
508
519
  window.addEventListener('pointerup', this.pointerUp);
509
520
  window.addEventListener('pointercancel', this.pointerUp);
510
521
  window.addEventListener('pointerleave', this.pointerLeave);
511
522
  window.addEventListener('blur', this.pointerLeave);
512
523
  document.addEventListener('visibilitychange', this.visibilityChange);
513
524
  this.backgroundCanvas.addEventListener('pointerdown', this.pointerDown, { capture: true });
525
+ this.backgroundCanvas.addEventListener('touchstart', this.touchStart, { passive: false });
514
526
  this.backgroundCanvas.addEventListener('wheel', this.wheel, {
515
527
  capture: true,
516
528
  passive: false
@@ -532,6 +544,7 @@ export class StageExperience {
532
544
  window.removeEventListener(STAGE_PANEL_LAYOUT_EVENT, this.requestPanelSync);
533
545
  window.removeEventListener(STAGE_PANEL_VISUAL_EVENT, this.requestPanelVisualSync);
534
546
  window.removeEventListener('pointermove', this.pointerMove);
547
+ window.removeEventListener('pointerdown', this.pointerContact, { capture: true });
535
548
  window.removeEventListener('pointerup', this.pointerUp);
536
549
  window.removeEventListener('pointercancel', this.pointerUp);
537
550
  window.removeEventListener('pointerleave', this.pointerLeave);
@@ -541,6 +554,7 @@ export class StageExperience {
541
554
  capture: true
542
555
  });
543
556
  this.backgroundCanvas.removeEventListener('wheel', this.wheel, { capture: true });
557
+ this.backgroundCanvas.removeEventListener('touchstart', this.touchStart);
544
558
  if (this.renderRequestId)
545
559
  cancelAnimationFrame(this.renderRequestId);
546
560
  this.renderRequestId = 0;
@@ -677,6 +691,8 @@ export class StageExperience {
677
691
  async updatePage(options) {
678
692
  if (this.disposed)
679
693
  return;
694
+ if ('renderSettings' in options)
695
+ this.pipeline.setRenderSettings(options.renderSettings);
680
696
  this.pageBackground = options.pageBackground ?? '#ffffff';
681
697
  this.pipeline.setPageBackground(this.pageBackground);
682
698
  this.catalogLayer?.setPageBackground(this.pageBackground);
@@ -733,6 +749,9 @@ export class StageExperience {
733
749
  this.createPanels();
734
750
  this.observePanelTargets();
735
751
  this.resizeRenderer();
752
+ // New page targets must be GPU-ready before navigation or the first zoom.
753
+ // Resting frosted panels do not otherwise submit their hidden backdrop blur.
754
+ this.pipeline.warmRenderTargetSets();
736
755
  this.renderFrame(true);
737
756
  await this.pipeline.prepareZoomEffects();
738
757
  if (this.disposed || !this.pageBinding.isCurrent(generation))
@@ -1368,7 +1387,7 @@ export class StageExperience {
1368
1387
  this.panelUiFocus = getStageUiFocus(this.panelFocus);
1369
1388
  this.minimapFocus = getSequencedMinimapFocus(this.panelFocus, this.panelUiFocus);
1370
1389
  this.layoutDirty = true;
1371
- this.lastInteractionTime = performance.now();
1390
+ this.lastFrameTime = performance.now();
1372
1391
  this.requestRender();
1373
1392
  }
1374
1393
  /** Applies the camera/target dolly produced by a real SpaceMouse zoom transaction. */
@@ -1406,6 +1425,26 @@ export class StageExperience {
1406
1425
  stopVisualTestSpaceMouseMotion() {
1407
1426
  this.setSpaceMouseMoving(false);
1408
1427
  }
1428
+ /** Projects a registered panel surface for frame-by-frame DOM/GPU alignment checks. */
1429
+ getVisualTestPanelRect(frame) {
1430
+ const index = this.panelTargets.findIndex((target) => target.frame === frame);
1431
+ const panel = this.panelRuntimes[index];
1432
+ if (!panel || !panel.group.visible)
1433
+ return null;
1434
+ panel.group.updateWorldMatrix(true, false);
1435
+ this.panelCamera.updateMatrixWorld(true);
1436
+ const { width, height } = panel.options;
1437
+ const points = [
1438
+ new THREE.Vector3(-width / 2, height / 2, 0),
1439
+ new THREE.Vector3(width / 2, height / 2, 0),
1440
+ new THREE.Vector3(width / 2, -height / 2, 0),
1441
+ new THREE.Vector3(-width / 2, -height / 2, 0)
1442
+ ].map((corner) => panel.group.localToWorld(corner).project(this.panelCamera));
1443
+ const xs = points.map((point) => (point.x + 1) * window.innerWidth / 2);
1444
+ const ys = points.map((point) => (1 - point.y) * window.innerHeight / 2);
1445
+ const x = Math.min(...xs), y = Math.min(...ys);
1446
+ return { x, y, width: Math.max(...xs) - x, height: Math.max(...ys) - y };
1447
+ }
1409
1448
  /** Returns the live rendered minimap bounds rather than its hidden DOM fallback bounds. */
1410
1449
  getVisualTestMinimapRect() {
1411
1450
  const minimap = this.minimaps.values().next().value;
@@ -1516,6 +1555,8 @@ export class StageExperience {
1516
1555
  });
1517
1556
  return {
1518
1557
  ...inventory,
1558
+ pixelRatio: this.pipeline.getFullPixelRatio(),
1559
+ renderSettings: this.pipeline.getRenderSettings(),
1519
1560
  canvases: this.pipeline.getCanvasOutputs(),
1520
1561
  creations: this.pipeline.renderTargetSetCreations,
1521
1562
  resizes: this.pipeline.renderTargetSetResizes,
@@ -1549,7 +1590,7 @@ export class StageExperience {
1549
1590
  advanceVisualTestFrames(frames = 12) {
1550
1591
  const frameCount = THREE.MathUtils.clamp(Math.floor(frames), 1, 120);
1551
1592
  for (let index = 0; index < frameCount; index += 1) {
1552
- this.lastInteractionTime = performance.now() - 1000 / 60;
1593
+ this.lastFrameTime = performance.now() - 1000 / 60;
1553
1594
  this.renderFrame(true);
1554
1595
  }
1555
1596
  }
@@ -1619,6 +1660,9 @@ export class StageExperience {
1619
1660
  element.style.pointerEvents = 'none';
1620
1661
  }
1621
1662
  async loadEnvironment() {
1663
+ // A content page without any spatial elements has no environment to load.
1664
+ if (!this.hdr)
1665
+ return;
1622
1666
  const token = this.pageBinding.token;
1623
1667
  const lease = this.environments.acquire(this.hdr);
1624
1668
  try {
@@ -1911,11 +1955,17 @@ export class StageExperience {
1911
1955
  options: panel.options,
1912
1956
  pointerLift: 0,
1913
1957
  pointerReactive: target.pointerReactive ?? true,
1958
+ focusReactive: target.focusReactive ?? true,
1914
1959
  projectionRoot,
1915
1960
  surface: target.surface
1916
1961
  });
1917
1962
  this.panelScene.add(projectionRoot ?? panel.group);
1918
- this.attachPanelContent(target.content, index, target.contentInset);
1963
+ if (target.nativeContent) {
1964
+ // Draw floating glass above regular panels; its content stays in the top layer.
1965
+ panel.group.renderOrder = 100;
1966
+ }
1967
+ else
1968
+ this.attachPanelContent(target.content, index, target.contentInset);
1919
1969
  }
1920
1970
  else {
1921
1971
  const options = resolveLiquidGlassPanelOptions(measuredOptions);
@@ -1930,18 +1980,21 @@ export class StageExperience {
1930
1980
  options,
1931
1981
  pointerLift: 0,
1932
1982
  pointerReactive: target.pointerReactive ?? true,
1983
+ focusReactive: target.focusReactive ?? true,
1933
1984
  projectionRoot,
1934
1985
  surface: target.surface
1935
1986
  });
1936
1987
  if (projectionRoot)
1937
1988
  this.panelScene.add(projectionRoot);
1938
- this.attachPanelSurface(target.surfaceElement, index, Boolean(target.minimap));
1989
+ if (!target.nativeContent)
1990
+ this.attachPanelSurface(target.surfaceElement, index, Boolean(target.minimap));
1939
1991
  }
1940
1992
  this.createMinimap(index, target.minimap);
1941
1993
  const panel = this.panelRuntimes[index];
1942
1994
  const group = target.frame.dataset.catalogTransitionGroup;
1943
1995
  panel.transitionGroup = group === 'enter' || group === 'shared' ? group : undefined;
1944
- panel.glass?.setVisibilityAlpha(this.getPanelTransitionOpacity(panel) * (target.getSurfaceOpacity?.() ?? 1));
1996
+ panel.glass?.setVisibilityAlpha(this.getPanelTransitionOpacity(panel) * (target.getSurfaceOpacity?.() ?? 1) *
1997
+ (target.getVisible?.() === false ? 0 : 1));
1945
1998
  const minimap = this.minimaps.get(index);
1946
1999
  if (minimap) {
1947
2000
  this.updateMinimapOverlayVisibility(minimap);
@@ -1967,55 +2020,76 @@ export class StageExperience {
1967
2020
  return;
1968
2021
  this.layoutDirty = false;
1969
2022
  const measurePanels = force || this.panelMeasurementsDirty;
1970
- this.panelTargets.forEach((target, index) => {
1971
- const runtime = this.panelRuntimes[index];
1972
- if (!runtime)
1973
- return;
1974
- const options = this.getMeasuredPanelOptions(target, measurePanels);
1975
- const geometryChanged = hasPanelGeometryChanged(runtime.options, options);
1976
- if (geometryChanged && runtime.glass && target.minimap) {
1977
- this.replacePanel(index, options);
1978
- }
1979
- else {
1980
- if (geometryChanged) {
1981
- const radius = options.radius ?? runtime.options.radius;
1982
- runtime.glass?.setVisualSize(options.width, options.height, radius);
1983
- runtime.options.width = options.width;
1984
- runtime.options.height = options.height;
1985
- runtime.options.radius = radius;
1986
- }
1987
- }
1988
- const currentRuntime = this.panelRuntimes[index];
1989
- if (!currentRuntime)
1990
- return;
1991
- currentRuntime.options.position.x = options.position.x;
1992
- currentRuntime.options.position.y = options.position.y;
1993
- if (currentRuntime.projectionRoot) {
1994
- currentRuntime.group.position.set(0, 0, 0);
1995
- this.setPanelProjectionTransform(currentRuntime.projectionRoot, options.position.x, options.position.y, 0);
1996
- }
1997
- else {
1998
- currentRuntime.group.position.set(options.position.x, options.position.y, 0);
2023
+ this.panelTargets.forEach((target, index) => this.syncPanelLayout(target, index, measurePanels));
2024
+ this.panelMeasurementsDirty = false;
2025
+ }
2026
+ syncPanelLayout(target, index, measurePanels) {
2027
+ const runtime = this.panelRuntimes[index];
2028
+ if (!runtime)
2029
+ return;
2030
+ // Preserve the last popup mesh while closed instead of resizing it to a 1px box.
2031
+ if (target.nativeContent && target.getVisible?.() === false)
2032
+ return;
2033
+ const options = this.getMeasuredPanelOptions(target, measurePanels);
2034
+ const geometryChanged = hasPanelGeometryChanged(runtime.options, options);
2035
+ if (geometryChanged && runtime.glass && target.minimap) {
2036
+ this.replacePanel(index, options);
2037
+ }
2038
+ else {
2039
+ if (geometryChanged) {
2040
+ const radius = options.radius ?? runtime.options.radius;
2041
+ runtime.glass?.setVisualSize(options.width, options.height, radius);
2042
+ runtime.options.width = options.width;
2043
+ runtime.options.height = options.height;
2044
+ runtime.options.radius = radius;
1999
2045
  }
2046
+ }
2047
+ const currentRuntime = this.panelRuntimes[index];
2048
+ if (!currentRuntime)
2049
+ return;
2050
+ currentRuntime.options.position.x = options.position.x;
2051
+ currentRuntime.options.position.y = options.position.y;
2052
+ if (currentRuntime.projectionRoot) {
2053
+ currentRuntime.group.position.set(0, 0, 0);
2054
+ this.setPanelProjectionTransform(currentRuntime.projectionRoot, options.position.x, options.position.y, 0);
2055
+ }
2056
+ else {
2057
+ currentRuntime.group.position.set(options.position.x, options.position.y, 0);
2058
+ }
2059
+ // Intrinsic DOM sizing and native popover layout remain owned by the adapter.
2060
+ if (!target.nativeContent) {
2000
2061
  if (currentRuntime.surface === 'glass') {
2001
2062
  this.updateContentElement(target.content, currentRuntime, target.contentInset);
2002
2063
  }
2003
2064
  else {
2004
2065
  this.updateSurfaceElement(target.surfaceElement, currentRuntime, currentRuntime.options.width, currentRuntime.options.height, Boolean(target.minimap));
2005
2066
  }
2006
- if (currentRuntime.content) {
2007
- if (currentRuntime.contentProjectionRoot) {
2008
- currentRuntime.content.position.set(0, 0, 0);
2009
- this.setPanelProjectionTransform(currentRuntime.contentProjectionRoot, currentRuntime.options.position.x, currentRuntime.options.position.y, PANEL_CONTENT_Z);
2010
- }
2011
- else {
2012
- currentRuntime.content.position.set(currentRuntime.options.position.x, currentRuntime.options.position.y, PANEL_CONTENT_Z);
2013
- }
2067
+ }
2068
+ if (currentRuntime.content) {
2069
+ if (currentRuntime.contentProjectionRoot) {
2070
+ currentRuntime.content.position.set(0, 0, 0);
2071
+ this.setPanelProjectionTransform(currentRuntime.contentProjectionRoot, currentRuntime.options.position.x, currentRuntime.options.position.y, PANEL_CONTENT_Z);
2072
+ }
2073
+ else {
2074
+ currentRuntime.content.position.set(currentRuntime.options.position.x, currentRuntime.options.position.y, PANEL_CONTENT_Z);
2014
2075
  }
2015
- if (geometryChanged && target.minimap)
2016
- this.createMinimap(index, target.minimap);
2076
+ }
2077
+ if (geometryChanged && target.minimap)
2078
+ this.createMinimap(index, target.minimap);
2079
+ }
2080
+ /** Commit anchor DOM positions and dependent native surfaces in one render transaction. */
2081
+ renderPanelContents() {
2082
+ this.cssRenderer.render(this.panelContentScene, this.panelCamera);
2083
+ this.renderFlatPanelSurfaces();
2084
+ this.panelTargets.forEach((target, index) => {
2085
+ if (!target.nativeContent || target.getVisible?.() === false)
2086
+ return;
2087
+ target.updateNativeLayout?.();
2088
+ this.syncPanelLayout(target, index, true);
2089
+ const runtime = this.panelRuntimes[index];
2090
+ if (runtime)
2091
+ runtime.group.visible = this.isPanelTargetVisible(index);
2017
2092
  });
2018
- this.panelMeasurementsDirty = false;
2019
2093
  }
2020
2094
  replacePanel(index, options) {
2021
2095
  if (!this.pipeline.activeRenderTargets)
@@ -2066,6 +2140,8 @@ export class StageExperience {
2066
2140
  const target = this.panelTargets[index];
2067
2141
  if (!target)
2068
2142
  return true;
2143
+ if (target.getVisible?.() === false)
2144
+ return false;
2069
2145
  const cachedRect = this.pageBinding.getPanelRect(target.frame);
2070
2146
  if (!cachedRect)
2071
2147
  return true;
@@ -2320,9 +2396,9 @@ export class StageExperience {
2320
2396
  this.renderer.setCanvasTarget(this.backgroundCanvasTarget);
2321
2397
  this.renderer.setClearColor(0xffffff, 1);
2322
2398
  const now = performance.now();
2323
- const delta = Math.min((now - this.lastInteractionTime) / 1000, 0.05);
2399
+ const delta = Math.min((now - this.lastFrameTime) / 1000, 0.05);
2324
2400
  this.advancePreparedPage(now);
2325
- this.lastInteractionTime = now;
2401
+ this.lastFrameTime = now;
2326
2402
  this.backgroundCanvas.style.visibility = '';
2327
2403
  this.catalogLayerAnimating =
2328
2404
  this.catalogLayer?.update(this.renderer, this.scene.environment, now) ?? false;
@@ -2336,9 +2412,8 @@ export class StageExperience {
2336
2412
  this.syncPanelLayouts();
2337
2413
  const panelsAnimating = this.updatePanelPointerInteraction(delta);
2338
2414
  const domAnimating = this.updatePanelDomRenderModes();
2415
+ this.renderPanelContents();
2339
2416
  this.pipeline.renderFrame(true, false);
2340
- this.cssRenderer.render(this.panelContentScene, this.panelCamera);
2341
- this.renderFlatPanelSurfaces();
2342
2417
  this.animationActive = this.catalogLayerAnimating || panelsAnimating || domAnimating;
2343
2418
  if (!force && (this.animationActive || this.renderInvalidated))
2344
2419
  this.scheduleRender();
@@ -2362,9 +2437,8 @@ export class StageExperience {
2362
2437
  this.syncPanelLayouts();
2363
2438
  const panelsAnimating = this.updatePanelPointerInteraction(delta);
2364
2439
  const panelDomModeAnimating = this.updatePanelDomRenderModes();
2440
+ this.renderPanelContents();
2365
2441
  this.pipeline.renderFrame(false, !this.scrollActive && !this.catalogHandoff);
2366
- this.cssRenderer.render(this.panelContentScene, this.panelCamera);
2367
- this.renderFlatPanelSurfaces();
2368
2442
  this.animationActive =
2369
2443
  this.presentation.readiness.animating ||
2370
2444
  this.catalogLayerAnimating ||