@spatial-elements/core 1.0.0-beta.7 → 1.0.0-beta.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 (235) hide show
  1. package/dist/catalog/CarouselDeviceCamera.d.ts +8 -0
  2. package/dist/catalog/CarouselDeviceCamera.d.ts.map +1 -1
  3. package/dist/catalog/CarouselDeviceCamera.js +15 -1
  4. package/dist/catalog/CarouselDeviceCamera.js.map +1 -1
  5. package/dist/catalog/CarouselGlassCompositor.d.ts +8 -2
  6. package/dist/catalog/CarouselGlassCompositor.d.ts.map +1 -1
  7. package/dist/catalog/CarouselGlassCompositor.js +69 -12
  8. package/dist/catalog/CarouselGlassCompositor.js.map +1 -1
  9. package/dist/catalog/CarouselGround.d.ts +22 -1
  10. package/dist/catalog/CarouselGround.d.ts.map +1 -1
  11. package/dist/catalog/CarouselGround.js +185 -24
  12. package/dist/catalog/CarouselGround.js.map +1 -1
  13. package/dist/catalog/CatalogDepthBlur.d.ts +20 -1
  14. package/dist/catalog/CatalogDepthBlur.d.ts.map +1 -1
  15. package/dist/catalog/CatalogDepthBlur.js +126 -23
  16. package/dist/catalog/CatalogDepthBlur.js.map +1 -1
  17. package/dist/catalog/CatalogGeometryFade.d.ts +5 -1
  18. package/dist/catalog/CatalogGeometryFade.d.ts.map +1 -1
  19. package/dist/catalog/CatalogGeometryFade.js +39 -7
  20. package/dist/catalog/CatalogGeometryFade.js.map +1 -1
  21. package/dist/catalog/CatalogModelOutline.d.ts +3 -1
  22. package/dist/catalog/CatalogModelOutline.d.ts.map +1 -1
  23. package/dist/catalog/CatalogModelOutline.js +11 -2
  24. package/dist/catalog/CatalogModelOutline.js.map +1 -1
  25. package/dist/catalog/CatalogPreparation.d.ts.map +1 -1
  26. package/dist/catalog/CatalogPreparation.js +8 -6
  27. package/dist/catalog/CatalogPreparation.js.map +1 -1
  28. package/dist/catalog/CatalogSpatialElementLayer.d.ts +129 -3
  29. package/dist/catalog/CatalogSpatialElementLayer.d.ts.map +1 -1
  30. package/dist/catalog/CatalogSpatialElementLayer.js +408 -33
  31. package/dist/catalog/CatalogSpatialElementLayer.js.map +1 -1
  32. package/dist/catalog/CatalogTransition.d.ts +4 -0
  33. package/dist/catalog/CatalogTransition.d.ts.map +1 -1
  34. package/dist/catalog/CatalogTransition.js +91 -22
  35. package/dist/catalog/CatalogTransition.js.map +1 -1
  36. package/dist/catalog/CatalogWarmOutputContext.d.ts +39 -0
  37. package/dist/catalog/CatalogWarmOutputContext.d.ts.map +1 -0
  38. package/dist/catalog/CatalogWarmOutputContext.js +159 -0
  39. package/dist/catalog/CatalogWarmOutputContext.js.map +1 -0
  40. package/dist/catalog/EarlyNavigationCoordinator.d.ts +35 -0
  41. package/dist/catalog/EarlyNavigationCoordinator.d.ts.map +1 -0
  42. package/dist/catalog/EarlyNavigationCoordinator.js +103 -0
  43. package/dist/catalog/EarlyNavigationCoordinator.js.map +1 -0
  44. package/dist/catalog/NavigationFeedback.d.ts +12 -0
  45. package/dist/catalog/NavigationFeedback.d.ts.map +1 -0
  46. package/dist/catalog/NavigationFeedback.js +40 -0
  47. package/dist/catalog/NavigationFeedback.js.map +1 -0
  48. package/dist/catalog/PreparationGate.d.ts +4 -0
  49. package/dist/catalog/PreparationGate.d.ts.map +1 -1
  50. package/dist/catalog/PreparationGate.js +1 -0
  51. package/dist/catalog/PreparationGate.js.map +1 -1
  52. package/dist/catalog/SourceDomClipping.d.ts +8 -0
  53. package/dist/catalog/SourceDomClipping.d.ts.map +1 -0
  54. package/dist/catalog/SourceDomClipping.js +74 -0
  55. package/dist/catalog/SourceDomClipping.js.map +1 -0
  56. package/dist/catalog/SourceDomMotion.d.ts +28 -0
  57. package/dist/catalog/SourceDomMotion.d.ts.map +1 -0
  58. package/dist/catalog/SourceDomMotion.js +111 -0
  59. package/dist/catalog/SourceDomMotion.js.map +1 -0
  60. package/dist/catalog/SpatialPageRegistry.d.ts +1 -0
  61. package/dist/catalog/SpatialPageRegistry.d.ts.map +1 -1
  62. package/dist/catalog/SpatialPageRegistry.js.map +1 -1
  63. package/dist/catalog/StagedCatalogTransition.d.ts +74 -0
  64. package/dist/catalog/StagedCatalogTransition.d.ts.map +1 -0
  65. package/dist/catalog/StagedCatalogTransition.js +270 -0
  66. package/dist/catalog/StagedCatalogTransition.js.map +1 -0
  67. package/dist/catalog/cardProjection.d.ts +31 -0
  68. package/dist/catalog/cardProjection.d.ts.map +1 -1
  69. package/dist/catalog/cardProjection.js +63 -4
  70. package/dist/catalog/cardProjection.js.map +1 -1
  71. package/dist/catalog/carouselPanelProjection.d.ts.map +1 -1
  72. package/dist/catalog/carouselPanelProjection.js +48 -11
  73. package/dist/catalog/carouselPanelProjection.js.map +1 -1
  74. package/dist/catalog/catalogActivationFocus.d.ts +5 -0
  75. package/dist/catalog/catalogActivationFocus.d.ts.map +1 -0
  76. package/dist/catalog/catalogActivationFocus.js +39 -0
  77. package/dist/catalog/catalogActivationFocus.js.map +1 -0
  78. package/dist/catalog/catalogJourney.d.ts +2 -0
  79. package/dist/catalog/catalogJourney.d.ts.map +1 -1
  80. package/dist/catalog/catalogJourney.js.map +1 -1
  81. package/dist/catalog/catalogPose.d.ts +18 -0
  82. package/dist/catalog/catalogPose.d.ts.map +1 -1
  83. package/dist/catalog/catalogPose.js +26 -5
  84. package/dist/catalog/catalogPose.js.map +1 -1
  85. package/dist/catalog/catalogTransitionViewport.d.ts +9 -0
  86. package/dist/catalog/catalogTransitionViewport.d.ts.map +1 -0
  87. package/dist/catalog/catalogTransitionViewport.js +13 -0
  88. package/dist/catalog/catalogTransitionViewport.js.map +1 -0
  89. package/dist/catalog/catalogViewLink.d.ts +2 -0
  90. package/dist/catalog/catalogViewLink.d.ts.map +1 -1
  91. package/dist/catalog/catalogViewLink.js +10 -2
  92. package/dist/catalog/catalogViewLink.js.map +1 -1
  93. package/dist/catalog/listDeviceOrientation.d.ts +2 -0
  94. package/dist/catalog/listDeviceOrientation.d.ts.map +1 -1
  95. package/dist/catalog/listDeviceOrientation.js +18 -1
  96. package/dist/catalog/listDeviceOrientation.js.map +1 -1
  97. package/dist/catalog/stagedDetailGeometry.d.ts +37 -0
  98. package/dist/catalog/stagedDetailGeometry.d.ts.map +1 -0
  99. package/dist/catalog/stagedDetailGeometry.js +55 -0
  100. package/dist/catalog/stagedDetailGeometry.js.map +1 -0
  101. package/dist/catalog/stagedDockGeometry.d.ts +66 -0
  102. package/dist/catalog/stagedDockGeometry.d.ts.map +1 -0
  103. package/dist/catalog/stagedDockGeometry.js +66 -0
  104. package/dist/catalog/stagedDockGeometry.js.map +1 -0
  105. package/dist/index.d.ts +2 -1
  106. package/dist/index.d.ts.map +1 -1
  107. package/dist/index.js +2 -1
  108. package/dist/index.js.map +1 -1
  109. package/dist/spatial-element/ResponsiveViewportMetrics.d.ts +18 -0
  110. package/dist/spatial-element/ResponsiveViewportMetrics.d.ts.map +1 -0
  111. package/dist/spatial-element/ResponsiveViewportMetrics.js +68 -0
  112. package/dist/spatial-element/ResponsiveViewportMetrics.js.map +1 -0
  113. package/dist/spatial-element/SectionSurfaceRegistry.d.ts +24 -0
  114. package/dist/spatial-element/SectionSurfaceRegistry.d.ts.map +1 -0
  115. package/dist/spatial-element/SectionSurfaceRegistry.js +48 -0
  116. package/dist/spatial-element/SectionSurfaceRegistry.js.map +1 -0
  117. package/dist/spatial-element/SpatialElementDockController.d.ts +19 -9
  118. package/dist/spatial-element/SpatialElementDockController.d.ts.map +1 -1
  119. package/dist/spatial-element/SpatialElementDockController.js +189 -93
  120. package/dist/spatial-element/SpatialElementDockController.js.map +1 -1
  121. package/dist/spatial-element/SpatialElementPaneController.d.ts +67 -0
  122. package/dist/spatial-element/SpatialElementPaneController.d.ts.map +1 -0
  123. package/dist/spatial-element/SpatialElementPaneController.js +245 -0
  124. package/dist/spatial-element/SpatialElementPaneController.js.map +1 -0
  125. package/dist/spatial-element/activeDetailSection.d.ts +8 -0
  126. package/dist/spatial-element/activeDetailSection.d.ts.map +1 -0
  127. package/dist/spatial-element/activeDetailSection.js +19 -0
  128. package/dist/spatial-element/activeDetailSection.js.map +1 -0
  129. package/dist/spatial-element/layoutTokens.json +53 -0
  130. package/dist/spatial-element/responsiveLayout.d.ts +1389 -0
  131. package/dist/spatial-element/responsiveLayout.d.ts.map +1 -0
  132. package/dist/spatial-element/responsiveLayout.js +265 -0
  133. package/dist/spatial-element/responsiveLayout.js.map +1 -0
  134. package/dist/spatial-element/sectionBackground.d.ts +29 -0
  135. package/dist/spatial-element/sectionBackground.d.ts.map +1 -0
  136. package/dist/spatial-element/sectionBackground.js +66 -0
  137. package/dist/spatial-element/sectionBackground.js.map +1 -0
  138. package/dist/spatial-element/spatialElement.d.ts +1 -0
  139. package/dist/spatial-element/spatialElement.d.ts.map +1 -1
  140. package/dist/spatial-element/spatialElement.js +1 -0
  141. package/dist/spatial-element/spatialElement.js.map +1 -1
  142. package/dist/spatial-element/spatialElementDock.d.ts +15 -0
  143. package/dist/spatial-element/spatialElementDock.d.ts.map +1 -1
  144. package/dist/spatial-element/spatialElementDock.js +22 -0
  145. package/dist/spatial-element/spatialElementDock.js.map +1 -1
  146. package/dist/spatial-element/spatialElementMedia.d.ts +16 -0
  147. package/dist/spatial-element/spatialElementMedia.d.ts.map +1 -0
  148. package/dist/spatial-element/spatialElementMedia.js +29 -0
  149. package/dist/spatial-element/spatialElementMedia.js.map +1 -0
  150. package/dist/spatial-element/spatialTheme.d.ts +12 -1
  151. package/dist/spatial-element/spatialTheme.d.ts.map +1 -1
  152. package/dist/spatial-element/spatialTheme.js +30 -1
  153. package/dist/spatial-element/spatialTheme.js.map +1 -1
  154. package/dist/spatial-element/types.d.ts +50 -2
  155. package/dist/spatial-element/types.d.ts.map +1 -1
  156. package/dist/spatial-element/types.js.map +1 -1
  157. package/dist/stage/BackgroundLayerOutput.d.ts +76 -0
  158. package/dist/stage/BackgroundLayerOutput.d.ts.map +1 -0
  159. package/dist/stage/BackgroundLayerOutput.js +333 -0
  160. package/dist/stage/BackgroundLayerOutput.js.map +1 -0
  161. package/dist/stage/LiquidGlassPanel.d.ts +3 -0
  162. package/dist/stage/LiquidGlassPanel.d.ts.map +1 -1
  163. package/dist/stage/LiquidGlassPanel.js +27 -2
  164. package/dist/stage/LiquidGlassPanel.js.map +1 -1
  165. package/dist/stage/MinimapController.d.ts.map +1 -1
  166. package/dist/stage/MinimapController.js +28 -47
  167. package/dist/stage/MinimapController.js.map +1 -1
  168. package/dist/stage/PageBindingController.d.ts +4 -0
  169. package/dist/stage/PageBindingController.d.ts.map +1 -1
  170. package/dist/stage/PageBindingController.js +12 -4
  171. package/dist/stage/PageBindingController.js.map +1 -1
  172. package/dist/stage/PanelPresentationController.d.ts +17 -0
  173. package/dist/stage/PanelPresentationController.d.ts.map +1 -1
  174. package/dist/stage/PanelPresentationController.js +69 -13
  175. package/dist/stage/PanelPresentationController.js.map +1 -1
  176. package/dist/stage/SpatialElementInteractionController.d.ts +7 -0
  177. package/dist/stage/SpatialElementInteractionController.d.ts.map +1 -1
  178. package/dist/stage/SpatialElementInteractionController.js +9 -0
  179. package/dist/stage/SpatialElementInteractionController.js.map +1 -1
  180. package/dist/stage/SpatialElementPresentationController.d.ts +14 -2
  181. package/dist/stage/SpatialElementPresentationController.d.ts.map +1 -1
  182. package/dist/stage/SpatialElementPresentationController.js +47 -2
  183. package/dist/stage/SpatialElementPresentationController.js.map +1 -1
  184. package/dist/stage/SpatialElementRefinement.d.ts +34 -1
  185. package/dist/stage/SpatialElementRefinement.d.ts.map +1 -1
  186. package/dist/stage/SpatialElementRefinement.js +175 -37
  187. package/dist/stage/SpatialElementRefinement.js.map +1 -1
  188. package/dist/stage/StageExperience.d.ts +167 -5
  189. package/dist/stage/StageExperience.d.ts.map +1 -1
  190. package/dist/stage/StageExperience.js +384 -58
  191. package/dist/stage/StageExperience.js.map +1 -1
  192. package/dist/stage/StageRenderPipeline.d.ts +76 -1
  193. package/dist/stage/StageRenderPipeline.d.ts.map +1 -1
  194. package/dist/stage/StageRenderPipeline.js +421 -46
  195. package/dist/stage/StageRenderPipeline.js.map +1 -1
  196. package/dist/stage/VirtualScrollController.d.ts +7 -0
  197. package/dist/stage/VirtualScrollController.d.ts.map +1 -1
  198. package/dist/stage/VirtualScrollController.js +57 -4
  199. package/dist/stage/VirtualScrollController.js.map +1 -1
  200. package/dist/stage/minimap/MinimapModel.d.ts +2 -1
  201. package/dist/stage/minimap/MinimapModel.d.ts.map +1 -1
  202. package/dist/stage/minimap/MinimapModel.js +34 -4
  203. package/dist/stage/minimap/MinimapModel.js.map +1 -1
  204. package/dist/stage/minimap/MinimapModelGeometry.d.ts +21 -0
  205. package/dist/stage/minimap/MinimapModelGeometry.d.ts.map +1 -0
  206. package/dist/stage/minimap/MinimapModelGeometry.js +68 -0
  207. package/dist/stage/minimap/MinimapModelGeometry.js.map +1 -0
  208. package/dist/stage/minimap/MinimapState.d.ts +3 -8
  209. package/dist/stage/minimap/MinimapState.d.ts.map +1 -1
  210. package/dist/stage/minimap/MinimapState.js.map +1 -1
  211. package/dist/stage/panelContext.d.ts +7 -0
  212. package/dist/stage/panelContext.d.ts.map +1 -1
  213. package/dist/stage/panelContext.js.map +1 -1
  214. package/dist/stage/rendererState.d.ts +2 -0
  215. package/dist/stage/rendererState.d.ts.map +1 -1
  216. package/dist/stage/rendererState.js +13 -0
  217. package/dist/stage/rendererState.js.map +1 -1
  218. package/dist/stage/sceneEndpointEligibility.d.ts +20 -0
  219. package/dist/stage/sceneEndpointEligibility.d.ts.map +1 -0
  220. package/dist/stage/sceneEndpointEligibility.js +363 -0
  221. package/dist/stage/sceneEndpointEligibility.js.map +1 -0
  222. package/dist/stage/stageDom.d.ts.map +1 -1
  223. package/dist/stage/stageDom.js +6 -1
  224. package/dist/stage/stageDom.js.map +1 -1
  225. package/dist/stage/stageMath.d.ts +3 -3
  226. package/dist/stage/stageMath.d.ts.map +1 -1
  227. package/dist/stage/stageMath.js +11 -10
  228. package/dist/stage/stageMath.js.map +1 -1
  229. package/dist/stage/stageTypes.d.ts +7 -1
  230. package/dist/stage/stageTypes.d.ts.map +1 -1
  231. package/dist/stage/stageTypes.js.map +1 -1
  232. package/dist/stage/stageVisualTest.d.ts +19 -0
  233. package/dist/stage/stageVisualTest.d.ts.map +1 -1
  234. package/dist/stage/stageVisualTest.js.map +1 -1
  235. package/package.json +1 -1
@@ -1,7 +1,13 @@
1
1
  import { CatalogGeometryFade } from './CatalogGeometryFade.js';
2
2
  import { CarouselDeviceCamera } from './CarouselDeviceCamera.js';
3
+ import { isCatalogActivationFocus } from './catalogActivationFocus.js';
3
4
  import { isDeviceOrientationPaused, getListDeviceYaw, getListDevicePitch, getListDeviceRoll, subscribeListDeviceYaw } from './listDeviceOrientation.js';
4
5
  import { cardModelFit } from './cardModelFit.js';
6
+ import { createStagedDetailGeometry } from './stagedDetailGeometry.js';
7
+ import { createStagedDockGeometry } from './stagedDockGeometry.js';
8
+ import { sourceDomProjectiveMatrix } from './SourceDomMotion.js';
9
+ import { withRendererState } from '../stage/rendererState.js';
10
+ import { resolveDetailLayout } from '../spatial-element/responsiveLayout.js';
5
11
  import { CatalogDepthBlur } from './CatalogDepthBlur.js';
6
12
  import { CatalogModelOutline } from './CatalogModelOutline.js';
7
13
  import { DEFAULT_INTERACTION_THEME } from '../stage/stageConstants.js';
@@ -12,7 +18,7 @@ import * as THREE from 'three/webgpu';
12
18
  import { getSpatialElementScene, hasSpatialElementScene } from '../spatial-element/spatialElementScene.js';
13
19
  import { getStageVisualScrollPosition } from '../stage/scrollFrame.js';
14
20
  import { getCameraOrbitQuaternion, getPanelPointerInfluence, getPanelPointerRotation, setPanelLocalPerspectiveMatrix } from '../stage/stageMath.js';
15
- import { applyModelMaterialOverrides, centerAndScale, getMeshBounds, getMeshMaterials, isMesh } from '../stage/stageSceneUtils.js';
21
+ import { applyModelMaterialOverrides, centerAndScale, getMeshBounds, getMeshBoundsPoints, getMeshMaterials, isMesh } from '../stage/stageSceneUtils.js';
16
22
  import { SpatialElementAssetManager } from './assets/SpatialElementAssetManager.js';
17
23
  import { getSpatialElementEntityKey } from './spatialElementAssets.js';
18
24
  import { applyCatalogMaterialOpacity, captureCatalogMaterialOpacity } from './catalogPresentation.js';
@@ -77,19 +83,38 @@ export class CatalogSpatialElementLayer {
77
83
  }
78
84
  scene = new THREE.Scene();
79
85
  passes = 0;
80
- getStats() {
86
+ getRenderActivity() {
87
+ return { camera: this.carouselDeviceCamera.getRenderActivity(), pointer: { ...this.pointer },
88
+ layoutDirty: this.layoutDirty, queueDirty: this.queueDirty, loadingActors: this.loadingKeys.size,
89
+ preparing: this.stagedPreparing, warmups: this.stagedWarmups,
90
+ selected: this.carouselSelection?.spatialElementId ?? null,
91
+ actors: [...this.actors.values()].map(actor => ({ spatialElementId: actor.spatialElementId,
92
+ visible: actor.root.visible, hover: actor.hover, rotationX: actor.rotationX, rotationY: actor.rotationY,
93
+ lift: actor.lift, deviceYaw: actor.deviceYaw, devicePitch: actor.devicePitch, deviceRoll: actor.deviceRoll,
94
+ materialReady: this.stagedMaterialReady(actor) })) };
95
+ }
96
+ getStats(renderer, warmOutput) {
97
+ const signature = renderer && (!warmOutput || warmOutput.isCurrent(renderer)) ? this.stagedSignature(renderer, warmOutput) : undefined;
98
+ const stagedReady = (actor) => Boolean(!this.stagedReadinessBlocked && signature &&
99
+ actor.rendered && actor.root.visible && this.desired.has(actor.key) && this.stagedMaterialReady(actor) &&
100
+ this.stagedPrepared.get(actor) === signature);
81
101
  return {
82
102
  instances: this.actors.size,
83
103
  deviceCamera: { pitch: this.carouselDeviceCamera.angles.x, yaw: this.carouselDeviceCamera.angles.y, roll: this.carouselDeviceCamera.angles.z },
84
104
  detachedInstances: this.detachedInstances,
85
105
  visible: [...this.actors.values()].filter((actor) => actor.root.visible).length,
86
106
  passes: this.passes,
107
+ stagedPreparation: { preparing: this.stagedPreparing,
108
+ readyActors: [...this.actors.values()].filter(stagedReady).length,
109
+ revision: this.stagedWarmRevision, warmups: this.stagedWarmups, failures: this.stagedWarmFailures,
110
+ sourceFrozen: this.stagedSourceFrozen },
87
111
  glass: this.glass.getStats(),
88
112
  ground: this.ground.getStats(),
89
113
  depthBlur: this.depthBlur.getStats(),
90
114
  outline: this.outline.getStats(),
91
115
  actors: [...this.actors.values()].map((actor) => ({
92
116
  spatialElementId: actor.spatialElementId,
117
+ stagedReady: stagedReady(actor),
93
118
  projectedCenter: actor.view.getWorldPosition(new THREE.Vector3()).project(actor.pose ? this.carouselCamera : this.camera).toArray(),
94
119
  band: actor.band,
95
120
  clip: actor.clip ? { ...actor.clip } : undefined,
@@ -127,7 +152,22 @@ export class CatalogSpatialElementLayer {
127
152
  motion = window.matchMedia('(prefers-reduced-motion: reduce)');
128
153
  unsubscribeDeviceYaw;
129
154
  pointer = { x: 0, y: 0, active: false, pressed: false };
155
+ focusVisible = new WeakMap();
156
+ activationFocusFrame = 0;
157
+ activationFocusRequest;
130
158
  handoff;
159
+ stagedPanel;
160
+ stagedPanelOpacity = 1;
161
+ stagedSourceFrozen = false;
162
+ stagedSourceCapture;
163
+ groundPoseSettled = false;
164
+ stagedPreparing = false;
165
+ stagedReadinessBlocked = false;
166
+ stagedWarmRevision = 0;
167
+ stagedWarmups = 0;
168
+ stagedWarmFailures = 0;
169
+ stagedPrepared = new WeakMap();
170
+ stagedWarmFailed = new WeakMap();
131
171
  handoffPoint;
132
172
  generation = 0;
133
173
  disposed = false;
@@ -157,10 +197,14 @@ export class CatalogSpatialElementLayer {
157
197
  pointerDown = (event) => {
158
198
  if (event.pointerType !== 'mouse')
159
199
  this.pointerLeave();
200
+ if (this.pointer.pressed)
201
+ return;
160
202
  this.pointer.pressed = true;
161
203
  this.invalidate();
162
204
  };
163
205
  pointerUp = () => {
206
+ if (!this.pointer.pressed)
207
+ return;
164
208
  this.pointer.pressed = false;
165
209
  this.invalidate();
166
210
  };
@@ -172,12 +216,67 @@ export class CatalogSpatialElementLayer {
172
216
  this.invalidate();
173
217
  };
174
218
  resize = () => {
219
+ this.stagedSourceCapture = undefined;
220
+ this.stagedWarmRevision++;
175
221
  this.layoutDirty = true;
176
222
  this.queueDirty = true;
177
223
  this.invalidate();
178
224
  };
225
+ readFocusVisible(target) {
226
+ if (!target)
227
+ return false;
228
+ const visible = target.matches?.(':focus-visible') ?? false;
229
+ this.focusVisible.set(target, visible);
230
+ return visible;
231
+ }
232
+ cancelActivationFocusRequest() {
233
+ if (this.activationFocusFrame)
234
+ cancelAnimationFrame(this.activationFocusFrame);
235
+ this.activationFocusFrame = 0;
236
+ this.activationFocusRequest = undefined;
237
+ }
238
+ deferActivationFocusRequest() {
239
+ if (this.activationFocusRequest)
240
+ return;
241
+ const request = this.activationFocusRequest = {};
242
+ this.activationFocusFrame = requestAnimationFrame(() => {
243
+ if (this.activationFocusRequest !== request)
244
+ return;
245
+ this.activationFocusRequest = undefined;
246
+ this.activationFocusFrame = 0;
247
+ if (!this.disposed && !this.transitionActive)
248
+ this.invalidate();
249
+ });
250
+ }
251
+ focusChange = (event) => {
252
+ const actor = [...this.actors.values()].find(actor => (actor.pose ? actor.hitTarget : actor.card) === event.target);
253
+ const target = actor && (actor.pose ? actor.hitTarget : actor.card);
254
+ if (!actor || !target)
255
+ return;
256
+ // focusout has already lost :focus-visible. Remember the state actually
257
+ // consumed by the last frame (or preceding focusin), including autofocus.
258
+ const before = this.focusVisible.get(target) ?? false;
259
+ const after = event.type === 'focusin' && (target.matches?.(':focus-visible') ?? false);
260
+ this.focusVisible.set(target, after);
261
+ if (before === after || this.transitionActive || (actor.pose && this.pointer.pressed))
262
+ return;
263
+ // A carousel pointer outline already has the same target value of one.
264
+ // Keep keyboard and genuine hover changes synchronous, without a timer.
265
+ if (actor.pose && this.pointer.active && target.hasAttribute('data-mouse-hover'))
266
+ return;
267
+ // This is only our own programmatic link focus, never Tab/hover/press work.
268
+ // Let Kit's first repaint opportunity stay light; an accepted transition can
269
+ // consume the focus in its first frame. Otherwise request the ordinary next
270
+ // Stage frame, even when the click was vetoed or no router is installed.
271
+ if (isCatalogActivationFocus(event) && actor.pose?.read().front) {
272
+ this.deferActivationFocusRequest();
273
+ return;
274
+ }
275
+ this.invalidate();
276
+ };
179
277
  motionChange = () => this.invalidate();
180
278
  setPageBackground(value) {
279
+ this.stagedSourceCapture = undefined;
181
280
  this.scene.fog.color.set(value);
182
281
  this.invalidate();
183
282
  }
@@ -201,8 +300,8 @@ export class CatalogSpatialElementLayer {
201
300
  window.addEventListener('pointerdown', this.pointerDown, { capture: true, passive: true });
202
301
  window.addEventListener('pointerup', this.pointerUp, { passive: true });
203
302
  window.addEventListener('pointercancel', this.pointerUp, { passive: true });
204
- window.addEventListener('focusin', this.motionChange);
205
- window.addEventListener('focusout', this.motionChange);
303
+ window.addEventListener('focusin', this.focusChange);
304
+ window.addEventListener('focusout', this.focusChange);
206
305
  window.addEventListener('pointerleave', this.pointerLeave);
207
306
  window.addEventListener('blur', this.pointerLeave);
208
307
  window.addEventListener('resize', this.resize);
@@ -212,6 +311,8 @@ export class CatalogSpatialElementLayer {
212
311
  async setSpatialElements(brandId, spatialElements) {
213
312
  if (this.disposed)
214
313
  return;
314
+ this.stagedSourceCapture = undefined;
315
+ this.cancelActivationFocusRequest();
215
316
  const generation = ++this.generation;
216
317
  this.layoutObserver.disconnect();
217
318
  const page = document.querySelector('[data-catalog-list]');
@@ -293,6 +394,7 @@ export class CatalogSpatialElementLayer {
293
394
  const actor = this.createActor(key, brandId, spatialElement.id, getSpatialElementScene(spatialElement), instance);
294
395
  actor.occurrence = spatialElement.occurrence;
295
396
  actor.pose = spatialElement.pose;
397
+ this.stagedSourceCapture = undefined;
296
398
  this.actors.set(key, actor);
297
399
  this.scene.add(actor.root);
298
400
  this.layoutDirty = true;
@@ -347,13 +449,16 @@ export class CatalogSpatialElementLayer {
347
449
  let animating = false;
348
450
  const projectCarousels = [];
349
451
  let selected;
350
- this.glass.beginFrame();
452
+ if (this.stagedPanel)
453
+ this.glass.retainFrame(this.stagedPanel.card, this.stagedPanel.matrix, this.exitOpacity, this.stagedPanelOpacity);
454
+ else
455
+ this.glass.beginFrame();
351
456
  if (!this.handoff)
352
457
  this.ground.beginFrame();
353
458
  for (const actor of this.actors.values()) {
354
459
  if (this.handoff?.actor === actor)
355
460
  continue;
356
- if (this.handoff) {
461
+ if (this.handoff || this.stagedSourceFrozen) {
357
462
  // The outgoing DOM has been snapshotted. Keep these already-rendered
358
463
  // spatialElements at their captured screen pose until the shared fade completes.
359
464
  actor.root.visible = actor.rendered && actor.root.visible && this.exitOpacity > 0.001;
@@ -414,7 +519,7 @@ export class CatalogSpatialElementLayer {
414
519
  }
415
520
  const hoverTarget = !this.transitionActive && !this.pointer.pressed &&
416
521
  ((this.pointer.active && actor.hitTarget?.hasAttribute('data-mouse-hover')) ||
417
- actor.hitTarget?.matches(':focus-visible')) ? 1 : 0;
522
+ this.readFocusVisible(actor.hitTarget)) ? 1 : 0;
418
523
  actor.hover = this.motion.matches ? hoverTarget : THREE.MathUtils.damp(actor.hover, hoverTarget, 18, delta);
419
524
  if (Math.abs(actor.hover - hoverTarget) < 0.01)
420
525
  actor.hover = hoverTarget;
@@ -425,11 +530,15 @@ export class CatalogSpatialElementLayer {
425
530
  actor.band = pose.front ? 'front' : 'rear';
426
531
  actor.root.visible &&= pose.visible;
427
532
  applyCatalogMaterialOpacity(actor.materials, pose.opacity);
428
- const compact = slot.width < 700;
533
+ const framing = pose.framing;
534
+ const compact = framing?.compact ?? width < 840;
535
+ const frame = framing ? Math.min(framing.fit.width, framing.fit.height) : Math.min(slot.width, compact ? 360 : slot.height);
429
536
  // Every seat shares one scene origin. Depth now determines projected size
430
537
  // and spacing naturally, including scroll parallax and the foreground advance.
431
- const x = slot.left + dx + slot.width * (pose.orbit ? (compact ? 0.5 : 0.31) : pose.x - (compact ? 0 : 0.19));
432
- const y = slot.top + dy + (pose.orbit ? (compact ? 180 : slot.height * 0.54) : slot.height * pose.y);
538
+ const anchorX = framing ? framing.fit.x + framing.fit.width / 2 : slot.width * (compact ? 0.5 : 0.31);
539
+ const anchorY = framing ? framing.fit.y + framing.fit.height / 2 : compact ? 180 : slot.height * 0.54;
540
+ const x = slot.left + dx + (pose.orbit ? anchorX : slot.width * (pose.x - (framing || compact ? 0 : 0.19)));
541
+ const y = slot.top + dy + (pose.orbit ? anchorY : slot.height * pose.y);
433
542
  const perspective = pose.orbit ? 1 : 1 - pose.depth / 2500;
434
543
  actor.root.matrix.makeTranslation((x - width / 2) * perspective + (pose.orbit?.x ?? 0), (height / 2 - y) * perspective + (pose.orbit?.y ?? 0), pose.depth);
435
544
  actor.root.matrixWorldNeedsUpdate = true;
@@ -442,10 +551,9 @@ export class CatalogSpatialElementLayer {
442
551
  actor.view.position.set(0, compact && !pose.orbit
443
552
  ? (slot.height - 360) * pose.y / (pose.size / 0.82)
444
553
  : 0, 0);
445
- actor.view.scale.setScalar((Math.min(slot.width, compact ? 360 : slot.height) * 0.82) / (actor.radius * 2));
554
+ actor.view.scale.setScalar((frame * 0.82) / (actor.radius * 2));
446
555
  let groundMatrix;
447
556
  if (pose.orbit && actor.root.visible) {
448
- const frame = Math.min(slot.width, compact ? 360 : slot.height);
449
557
  const floor = frame * 0.32;
450
558
  const pitch = pose.orbit.pitch;
451
559
  // Stand every model on the same plane, including wide or short assets.
@@ -500,7 +608,7 @@ export class CatalogSpatialElementLayer {
500
608
  ? actor.root.matrixWorld.clone().multiply(new THREE.Matrix4().makeRotationY(pose.yaw))
501
609
  : actor.tilt.matrixWorld.clone();
502
610
  const matrix = panelFrame
503
- .multiply(new THREE.Matrix4().makeTranslation(compact ? 0 : slot.width * 0.39, compact ? (pose.orbit ? 180 : slot.height / 2) - 360 - ph / 2 : 0, 0));
611
+ .multiply(new THREE.Matrix4().makeTranslation(framing ? framing.summary.x + pw / 2 - anchorX : compact ? 0 : slot.width * 0.39, framing ? anchorY - (framing.summary.anchorY - (framing.summary.alignment === 'end' ? ph / 2 : 0)) : compact ? (pose.orbit ? 180 : slot.height / 2) - 360 - ph / 2 : 0, 0));
504
612
  const corners = [
505
613
  [-pw / 2, ph / 2],
506
614
  [pw / 2, ph / 2],
@@ -556,7 +664,7 @@ export class CatalogSpatialElementLayer {
556
664
  THREE.MathUtils.radToDeg(rotation.y),
557
665
  -influence * 8,
558
666
  !this.motion.matches && !this.transitionActive &&
559
- ((this.pointer.active && distance === 0) || actor.card.matches?.(':focus-visible')) ? 1 : 0
667
+ ((this.pointer.active && distance === 0) || this.readFocusVisible(actor.card)) ? 1 : 0
560
668
  ];
561
669
  const previous = [actor.rotationX, actor.rotationY, actor.lift, actor.hover];
562
670
  const values = previous.map((value, index) => {
@@ -597,7 +705,7 @@ export class CatalogSpatialElementLayer {
597
705
  if (this.isDestinationActor(actor))
598
706
  actor.root.visible = false;
599
707
  }
600
- if (!this.transitionActive && !this.handoff) {
708
+ if (!this.transitionActive && !this.handoff && !this.stagedSourceFrozen) {
601
709
  const pivot = selected?.view.getWorldPosition(new THREE.Vector3()) ?? new THREE.Vector3();
602
710
  const enabled = selected?.card?.closest('[data-device-orientation]');
603
711
  if (this.motion.matches || !isDeviceOrientationPaused())
@@ -607,16 +715,17 @@ export class CatalogSpatialElementLayer {
607
715
  }
608
716
  for (const project of projectCarousels)
609
717
  project();
610
- if (this.queueDirty) {
718
+ if (this.queueDirty && !this.handoff && !this.stagedSourceFrozen) {
611
719
  this.queueDirty = false;
612
720
  void this.loadVisibleSpatialElements(this.generation);
613
721
  }
614
- this.glass.endFrame();
722
+ this.glass.endFrame(this.stagedPanel?.card);
615
723
  if (!this.handoff)
616
724
  this.ground.endFrame();
725
+ this.groundPoseSettled = !animating;
617
726
  return animating;
618
727
  }
619
- draw(renderer, band) {
728
+ draw(renderer, band, warmOutput) {
620
729
  const width = window.innerWidth, height = window.innerHeight;
621
730
  const all = [...this.actors.values()].filter((actor) => actor.root.visible && this.handoff?.actor !== actor);
622
731
  if (!all.some((actor) => (actor.band ?? 'front') === band)) {
@@ -664,7 +773,7 @@ export class CatalogSpatialElementLayer {
664
773
  actor.root.visible = true;
665
774
  this.depthBlur.render(renderer, this.carouselCamera, actor.renderRect ?? rect, actor.blur ?? 0, (camera) => renderer.render(this.scene, camera), rect);
666
775
  if (actor.hover > 0 && actor.renderRect)
667
- this.outline.render(renderer, this.carouselCamera, actor.model, actor.renderRect, rect, actor.hover * (actor.materials[0]?.material.opacity ?? 1), this.interactionTheme());
776
+ this.outline.render(renderer, this.carouselCamera, actor.model, actor.renderRect, rect, actor.hover * (actor.materials[0]?.material.opacity ?? 1), this.interactionTheme(), warmOutput);
668
777
  actor.root.visible = false;
669
778
  }
670
779
  }
@@ -691,7 +800,7 @@ export class CatalogSpatialElementLayer {
691
800
  actor.card?.setAttribute('data-catalog-model-ready', '');
692
801
  }
693
802
  }
694
- });
803
+ }, warmOutput, this.frozenSourceForBand(band, warmOutput));
695
804
  for (const actor of all)
696
805
  actor.root.visible = true;
697
806
  if (band === 'front' && this.handoff)
@@ -701,20 +810,50 @@ export class CatalogSpatialElementLayer {
701
810
  hasCarousel() {
702
811
  return [...this.actors.values()].some((actor) => Boolean(actor.pose));
703
812
  }
704
- renderRear(renderer) {
813
+ /** A retained glass panel outlives its source actors during staged reveal. */
814
+ hasRearOutput() {
815
+ return this.glass.hasActivePanels() || (this.exitOpacity > 0 && this.hasCarousel());
816
+ }
817
+ renderRear(renderer, warmOutput) {
705
818
  this.glass.render(renderer, this.carouselUiCamera, () => {
706
- this.ground.draw(renderer, this.carouselCamera, this.exitOpacity);
707
- this.draw(renderer, 'rear');
708
- });
819
+ // The full per-shadow signature is valid during normal focus/hover frames too;
820
+ // any changed source/camera pose falls back to live rendering immediately.
821
+ this.ground.draw(renderer, this.carouselCamera, this.exitOpacity, true, this.stagedSignature(renderer), this.stagedPreparing, warmOutput);
822
+ this.draw(renderer, 'rear', warmOutput);
823
+ }, this.exitOpacity === 0);
709
824
  }
710
825
  /** Warm the existing Low material passes in an offscreen preparation target. */
711
826
  renderForPreparation(renderer) {
712
- this.geometryFade.render(renderer, 0.5, () => renderer.render(this.scene, this.camera));
827
+ const visible = [...this.actors.values()].filter(actor => actor.root.visible);
828
+ this.geometryFade.render(renderer, 0.5, () => {
829
+ const fog = this.scene.fog;
830
+ try {
831
+ // Three shares a mesh/material/context owner across cameras. Rendering a
832
+ // Carousel mesh with List fog replaces its live no-fog owner and bindings.
833
+ for (const actor of visible)
834
+ actor.root.visible = !actor.pose;
835
+ if (visible.some(actor => !actor.pose))
836
+ renderer.render(this.scene, this.camera);
837
+ for (const actor of visible)
838
+ actor.root.visible = Boolean(actor.pose);
839
+ if (visible.some(actor => actor.pose)) {
840
+ this.scene.fog = null;
841
+ renderer.render(this.scene, this.carouselCamera);
842
+ }
843
+ }
844
+ finally {
845
+ this.scene.fog = fog;
846
+ for (const actor of visible)
847
+ actor.root.visible = true;
848
+ }
849
+ });
713
850
  }
714
851
  /** Applies only to outgoing list actors; the shared handoff geometry keeps its authored alpha. */
715
852
  setExitOpacity(opacity, active = false) {
716
853
  this.exitOpacity = Number.isFinite(opacity) ? Math.min(1, Math.max(0, opacity)) : 0;
717
854
  this.transitionActive = active;
855
+ if (active)
856
+ this.cancelActivationFocusRequest();
718
857
  this.invalidate();
719
858
  }
720
859
  capture(spatialElementId, occurrence) {
@@ -725,6 +864,7 @@ export class CatalogSpatialElementLayer {
725
864
  : !item.occurrence || item.card?.hasAttribute('data-catalog-selected')));
726
865
  if (!actor?.rendered || !actor.root.visible)
727
866
  return false;
867
+ this.stagedSourceCapture = undefined;
728
868
  this.finishHandoff();
729
869
  this.handoffPoint = undefined;
730
870
  actor.model.updateWorldMatrix(true, true);
@@ -751,6 +891,209 @@ export class CatalogSpatialElementLayer {
751
891
  this.invalidate();
752
892
  return true;
753
893
  }
894
+ /** Computes the known detail endpoint from an already prepared Low actor, before any route mounts. */
895
+ getStagedDetailTarget(spatialElementId, occurrence, fit, viewport, target, coordinateSystem = THREE.WebGPUCoordinateSystem) {
896
+ const actor = [...this.actors.values()].find(item => item.spatialElementId === spatialElementId &&
897
+ this.desired.has(item.key) && (occurrence ? item.occurrence === occurrence :
898
+ !item.occurrence || item.card?.hasAttribute('data-catalog-selected')));
899
+ if (!actor?.rendered || !actor.root.visible)
900
+ return;
901
+ if (target && resolveDetailLayout(target.layout).dock) {
902
+ return createStagedDockGeometry({ layout: target.layout, viewport,
903
+ lowBounds: actor.detailLowBounds, lowBoundsPoints: actor.detailLowBoundsPoints, modelMatrix: actor.detailFrame,
904
+ center: actor.detailBounds.getCenter(new THREE.Vector3()),
905
+ camera: actor.stage.camera ?? {}, minimap: target.minimap, coordinateSystem });
906
+ }
907
+ return createStagedDetailGeometry(actor.detailBounds, actor.detailFrame, actor.stage.camera ?? {}, viewport, fit, coordinateSystem);
908
+ }
909
+ stagedSignature(renderer, warmOutput) {
910
+ const size = renderer.getDrawingBufferSize(new THREE.Vector2());
911
+ return `${this.stagedWarmRevision}:${innerWidth}:${innerHeight}:${size.x}:${size.y}:${renderer.coordinateSystem}:${this.scene.environment?.uuid ?? ''}${warmOutput ? `:${warmOutput.profileKey}` : ''}`;
912
+ }
913
+ stagedCandidates(renderer, warmOutput) {
914
+ const signature = this.stagedSignature(renderer, warmOutput);
915
+ return [...this.actors.values()].filter(actor => actor.rendered && actor.root.visible &&
916
+ this.stagedMaterialReady(actor) &&
917
+ this.stagedPrepared.get(actor) !== signature && this.stagedWarmFailed.get(actor) !== signature);
918
+ }
919
+ stagedMaterialReady(actor) {
920
+ // Capture restores authored opacity. A still-fading carousel seat would
921
+ // otherwise change transparent/depth-write pipeline variants at the click.
922
+ return actor.materials.every(({ material, transparent, depthWrite }) => material.transparent === transparent && material.depthWrite === depthWrite);
923
+ }
924
+ needsStagedPreparation(renderer, warmOutput) {
925
+ return (!warmOutput || warmOutput.isCurrent(renderer)) && !this.disposed && !this.stagedPreparing && !this.handoff && !this.stagedSourceFrozen &&
926
+ (this.stagedCandidates(renderer, warmOutput).length > 0 || (this.groundPoseSettled &&
927
+ this.ground.needsCachePreparation(this.carouselCamera, this.stagedSignature(renderer))));
928
+ }
929
+ isStagedDetailReady(spatialElementId, occurrence, renderer, warmOutput) {
930
+ const actor = [...this.actors.values()].find(item => item.spatialElementId === spatialElementId &&
931
+ this.desired.has(item.key) && (occurrence ? item.occurrence === occurrence :
932
+ !item.occurrence || item.card?.hasAttribute('data-catalog-selected')));
933
+ return Boolean((!warmOutput || warmOutput.isCurrent(renderer)) && !this.stagedReadinessBlocked && actor?.rendered && actor.root.visible && this.stagedMaterialReady(actor) &&
934
+ this.stagedPrepared.get(actor) === this.stagedSignature(renderer, warmOutput));
935
+ }
936
+ /** Idle-only: warm the exact existing Low fade and handoff passes before a click can claim them. */
937
+ async prepareStagedNavigation(renderer, warmOutput) {
938
+ if (!this.needsStagedPreparation(renderer, warmOutput))
939
+ return;
940
+ const actors = this.stagedCandidates(renderer, warmOutput), signature = this.stagedSignature(renderer, warmOutput);
941
+ // Ground pixels are independent of the outer composite profile. Preserve their live-draw key.
942
+ const groundSignature = this.stagedSignature(renderer);
943
+ const warmRear = actors.some(actor => Boolean(actor.pose)) || (this.groundPoseSettled &&
944
+ this.ground.needsCachePreparation(this.carouselCamera, groundSignature));
945
+ this.stagedPreparing = true;
946
+ this.stagedReadinessBlocked = true;
947
+ const fog = this.scene.fog, environment = this.handoffScene.environment, handoffFog = this.handoffScene.fog;
948
+ const exitOpacity = this.exitOpacity;
949
+ const outlines = actors.filter(actor => actor.pose && actor.clip && actor.renderRect);
950
+ const hover = outlines.map(actor => actor.hover);
951
+ const handoffCamera = this.handoffCamera.clone();
952
+ try {
953
+ try {
954
+ const draw = () => withRendererState(renderer, () => {
955
+ // The default keeps the real Canvas output variant. An opt-in scratch
956
+ // context retains Canvas-semantic owners without drawing to a Canvas.
957
+ renderer.setRenderTarget(warmOutput?.target ?? null);
958
+ renderer.setScissor(0, 0, 0, 0);
959
+ renderer.setScissorTest(true);
960
+ // Exercise the actual output bands. A glass carousel renders its rear
961
+ // actors into an RGBA8 backdrop before compositing, and defocused seats
962
+ // use additional resolve passes. A direct scene render misses those
963
+ // target/pipeline variants despite compiling the same model shaders.
964
+ this.exitOpacity = 0.5;
965
+ // Focus fires before Kit's beforeNavigate callback. Prepare its first
966
+ // outline while idle so that pre-navigation frame cannot compile it.
967
+ for (const actor of outlines)
968
+ actor.hover = Math.max(actor.hover, 0.5);
969
+ if (warmRear) {
970
+ if (this.groundPoseSettled)
971
+ this.ground.prepareCaches(renderer, this.carouselCamera, groundSignature);
972
+ this.renderRear(renderer, warmOutput);
973
+ this.ground.prepareWindingVariants(renderer, this.carouselCamera);
974
+ }
975
+ this.draw(renderer, 'front', warmOutput);
976
+ // The fade pass warms offscreen output. The ordinary focused source
977
+ // needs the Canvas variant too, without submitting visible pixels.
978
+ for (const actor of outlines) {
979
+ renderer.setRenderTarget(warmOutput?.target ?? null);
980
+ renderer.setScissor(0, 0, 0, 0);
981
+ renderer.setScissorTest(true);
982
+ this.outline.render(renderer, this.carouselCamera, actor.model, actor.renderRect, actor.clip, 0.5, this.interactionTheme(), warmOutput);
983
+ }
984
+ this.handoffScene.environment = this.scene.environment;
985
+ for (const actor of actors) {
986
+ const model = actor.model, parent = model.parent;
987
+ const matrix = model.matrix.clone(), auto = model.matrixAutoUpdate;
988
+ model.updateWorldMatrix(true, true);
989
+ const world = model.matrixWorld.clone();
990
+ try {
991
+ this.handoffScene.fog = actor.pose ? null : fog;
992
+ this.handoffCamera.copy(actor.pose ? this.carouselCamera : this.camera);
993
+ this.handoffCamera.coordinateSystem = renderer.coordinateSystem;
994
+ this.handoffCamera.updateProjectionMatrix();
995
+ this.handoffScene.add(model);
996
+ model.matrixAutoUpdate = false;
997
+ model.matrix.copy(world);
998
+ model.matrixWorldNeedsUpdate = true;
999
+ renderer.render(this.handoffScene, this.handoffCamera);
1000
+ }
1001
+ finally {
1002
+ if (parent)
1003
+ parent.add(model);
1004
+ else
1005
+ model.removeFromParent();
1006
+ model.matrixAutoUpdate = auto;
1007
+ model.matrix.copy(matrix);
1008
+ model.matrixWorldNeedsUpdate = true;
1009
+ }
1010
+ }
1011
+ });
1012
+ if (warmOutput)
1013
+ warmOutput.borrow(renderer, draw);
1014
+ else
1015
+ draw();
1016
+ }
1017
+ finally {
1018
+ // Restore borrowed scene state before yielding to GPU completion; a
1019
+ // normal render or fallback navigation can run while that wait is pending.
1020
+ this.exitOpacity = exitOpacity;
1021
+ outlines.forEach((actor, index) => { actor.hover = hover[index]; });
1022
+ this.scene.fog = fog;
1023
+ this.handoffScene.environment = environment;
1024
+ this.handoffScene.fog = handoffFog;
1025
+ this.handoffCamera.copy(handoffCamera);
1026
+ // Optional shadow pixels must not revoke already fenced actor readiness.
1027
+ // Keep preparation serialized, but unblock only after every borrowed
1028
+ // render/scene value is restored. New actor passes still await the fence.
1029
+ if (!actors.length)
1030
+ this.stagedReadinessBlocked = false;
1031
+ }
1032
+ const device = renderer.backend.device;
1033
+ await device?.queue.onSubmittedWorkDone();
1034
+ if ((!warmOutput || warmOutput.isCurrent(renderer)) && !this.disposed && !this.handoff && !this.stagedSourceFrozen && signature === this.stagedSignature(renderer, warmOutput)) {
1035
+ this.stagedWarmups++;
1036
+ for (const actor of actors)
1037
+ if (this.actors.get(actor.key) === actor)
1038
+ this.stagedPrepared.set(actor, signature);
1039
+ }
1040
+ }
1041
+ catch (error) {
1042
+ this.stagedWarmFailures++;
1043
+ for (const actor of actors)
1044
+ this.stagedWarmFailed.set(actor, signature);
1045
+ throw error;
1046
+ }
1047
+ finally {
1048
+ this.stagedPreparing = false;
1049
+ this.stagedReadinessBlocked = false;
1050
+ }
1051
+ }
1052
+ freezeStagedSource() {
1053
+ this.stagedSourceFrozen = true;
1054
+ this.stagedSourceCapture = { front: {}, rear: {} };
1055
+ }
1056
+ frozenSourceForBand(band, warmOutput) {
1057
+ const capture = this.stagedSourceCapture;
1058
+ if (!this.stagedSourceFrozen || !capture || this.stagedPreparing || warmOutput)
1059
+ return;
1060
+ // Frozen actors keep their pose, but projection, HDR or outline settings can
1061
+ // still change through the stage. Any such change ends reuse for this freeze.
1062
+ const fog = this.scene.fog;
1063
+ const signature = JSON.stringify([window.innerWidth, window.innerHeight,
1064
+ this.scene.environment?.uuid, this.scene.environment?.version, this.scene.environmentIntensity,
1065
+ fog?.color.getHex(), fog?.near, fog?.far, this.interactionTheme()]);
1066
+ if (capture.signature !== undefined && capture.signature !== signature) {
1067
+ this.stagedSourceCapture = undefined;
1068
+ return;
1069
+ }
1070
+ capture.signature = signature;
1071
+ return capture[band];
1072
+ }
1073
+ /** Move the existing glass mesh with the actual DOM quad, without resizing its resources. */
1074
+ setStagedPanel(card, corners, width, height) {
1075
+ if (card.dataset.carouselSurface !== 'glass')
1076
+ return true;
1077
+ if (!this.glass.hasPanel(card))
1078
+ return false;
1079
+ const matrix = sourceDomProjectiveMatrix(corners, width, height);
1080
+ if (!matrix)
1081
+ return false;
1082
+ const screenToWorld = new THREE.Matrix4().makeTranslation(-innerWidth / 2, innerHeight / 2, 0)
1083
+ .multiply(new THREE.Matrix4().makeScale(1, -1, 1));
1084
+ const planeToLocal = new THREE.Matrix4().makeTranslation(width / 2, height / 2, 0)
1085
+ .multiply(new THREE.Matrix4().makeScale(1, -1, 1));
1086
+ this.stagedPanel = { card, matrix: screenToWorld.multiply(new THREE.Matrix4().fromArray(matrix)).multiply(planeToLocal) };
1087
+ return true;
1088
+ }
1089
+ setStagedPanelOpacity(opacity) { this.stagedPanelOpacity = THREE.MathUtils.clamp(opacity, 0, 1); this.invalidate(); }
1090
+ finishStagedPanel() {
1091
+ this.stagedPanel = undefined;
1092
+ this.stagedSourceFrozen = false;
1093
+ this.stagedSourceCapture = undefined;
1094
+ this.stagedPanelOpacity = 1;
1095
+ this.invalidate();
1096
+ }
754
1097
  /** Last submitted geometry position; diagnostics never advance animation or read DOM layout. */
755
1098
  setDestinationSpatialElement(spatialElementId) {
756
1099
  this.destinationSpatialElement = spatialElementId;
@@ -804,6 +1147,7 @@ export class CatalogSpatialElementLayer {
804
1147
  const handoff = this.handoff;
805
1148
  if (!handoff)
806
1149
  return;
1150
+ this.stagedSourceCapture = undefined;
807
1151
  const actor = handoff.actor;
808
1152
  const model = actor.model;
809
1153
  model.updateWorldMatrix(true, true);
@@ -830,18 +1174,39 @@ export class CatalogSpatialElementLayer {
830
1174
  this.actors.delete(actor.key);
831
1175
  this.detachedInstances++;
832
1176
  let released = false;
1177
+ const release = () => {
1178
+ if (released)
1179
+ return;
1180
+ released = true;
1181
+ this.detachedInstances--;
1182
+ this.disposeActor(actor);
1183
+ };
833
1184
  return {
834
1185
  model,
835
1186
  projection,
836
1187
  referencePoint: actor.referencePoint.clone(),
837
1188
  environment: handoff.sourceEnvironment,
838
1189
  highEnvironment: handoff.highEnvironment,
839
- release: () => {
840
- if (!released) {
841
- released = true;
842
- this.detachedInstances--;
843
- this.disposeActor(actor);
1190
+ release,
1191
+ /** A pre-commit cancellation returns the same prepared instance to its live source. */
1192
+ restore: () => {
1193
+ if (released)
1194
+ return false;
1195
+ if (this.disposed || !this.desired.has(actor.key) || !actor.slot?.isConnected) {
1196
+ release();
1197
+ return false;
844
1198
  }
1199
+ released = true;
1200
+ this.detachedInstances--;
1201
+ this.stagedSourceCapture = undefined;
1202
+ actor.model.matrixAutoUpdate = true;
1203
+ actor.model.updateMatrix();
1204
+ actor.view.add(actor.model);
1205
+ this.scene.add(actor.root);
1206
+ this.actors.set(actor.key, actor);
1207
+ this.layoutDirty = true;
1208
+ this.invalidate();
1209
+ return true;
845
1210
  }
846
1211
  };
847
1212
  }
@@ -864,6 +1229,7 @@ export class CatalogSpatialElementLayer {
864
1229
  const handoff = this.handoff;
865
1230
  if (!handoff)
866
1231
  return;
1232
+ this.stagedSourceCapture = undefined;
867
1233
  this.handoff = undefined;
868
1234
  const actor = handoff.actor;
869
1235
  applyCatalogMaterialOpacity(actor.materials, 1);
@@ -889,6 +1255,8 @@ export class CatalogSpatialElementLayer {
889
1255
  applyCatalogMaterialOpacity(this.handoff.actor.materials, opacity);
890
1256
  }
891
1257
  dispose() {
1258
+ this.stagedSourceCapture = undefined;
1259
+ this.cancelActivationFocusRequest();
892
1260
  this.ground.dispose();
893
1261
  this.glass.dispose();
894
1262
  this.depthBlur.dispose();
@@ -909,8 +1277,8 @@ export class CatalogSpatialElementLayer {
909
1277
  window.removeEventListener('pointerdown', this.pointerDown, true);
910
1278
  window.removeEventListener('pointerup', this.pointerUp);
911
1279
  window.removeEventListener('pointercancel', this.pointerUp);
912
- window.removeEventListener('focusin', this.motionChange);
913
- window.removeEventListener('focusout', this.motionChange);
1280
+ window.removeEventListener('focusin', this.focusChange);
1281
+ window.removeEventListener('focusout', this.focusChange);
914
1282
  window.removeEventListener('pointerleave', this.pointerLeave);
915
1283
  window.removeEventListener('blur', this.pointerLeave);
916
1284
  window.removeEventListener('resize', this.resize);
@@ -957,6 +1325,8 @@ export class CatalogSpatialElementLayer {
957
1325
  material.dispose();
958
1326
  throw new Error('Catalog asset contains no spatialElement geometry');
959
1327
  }
1328
+ const detailLowBounds = getMeshBounds(model, (mesh) => !excluded.has(mesh.name));
1329
+ const detailLowBoundsPoints = getMeshBoundsPoints(model, (mesh) => !excluded.has(mesh.name));
960
1330
  const radius = Math.max(bounds.getBoundingSphere(new THREE.Sphere()).radius, 0.001);
961
1331
  const root = new THREE.Group();
962
1332
  root.matrixAutoUpdate = false;
@@ -977,6 +1347,10 @@ export class CatalogSpatialElementLayer {
977
1347
  stage,
978
1348
  instance,
979
1349
  model,
1350
+ detailFrame: model.matrix.clone(),
1351
+ detailBounds: bounds.clone(),
1352
+ detailLowBounds,
1353
+ detailLowBoundsPoints,
980
1354
  root,
981
1355
  tilt,
982
1356
  view,
@@ -1002,7 +1376,7 @@ export class CatalogSpatialElementLayer {
1002
1376
  };
1003
1377
  }
1004
1378
  measureActors(scrollX, scrollY) {
1005
- if (this.handoff)
1379
+ if (this.handoff || this.stagedSourceFrozen)
1006
1380
  return;
1007
1381
  const measured = [];
1008
1382
  for (const actor of this.actors.values()) {
@@ -1119,6 +1493,7 @@ export class CatalogSpatialElementLayer {
1119
1493
  };
1120
1494
  }
1121
1495
  disposeActor(actor) {
1496
+ this.stagedSourceCapture = undefined;
1122
1497
  this.outline.release(actor.model);
1123
1498
  if (actor.summaryPanel)
1124
1499
  this.layoutObserver.unobserve(actor.summaryPanel);