@spatial-elements/core 0.1.0-beta.2 → 1.0.0-beta.3

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 (93) 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.map +1 -1
  10. package/dist/catalog/CatalogSpatialElementLayer.js +33 -17
  11. package/dist/catalog/CatalogSpatialElementLayer.js.map +1 -1
  12. package/dist/catalog/CatalogTransition.d.ts.map +1 -1
  13. package/dist/catalog/CatalogTransition.js +25 -7
  14. package/dist/catalog/CatalogTransition.js.map +1 -1
  15. package/dist/catalog/SpatialPageRegistry.d.ts +17 -0
  16. package/dist/catalog/SpatialPageRegistry.d.ts.map +1 -0
  17. package/dist/catalog/SpatialPageRegistry.js +21 -0
  18. package/dist/catalog/SpatialPageRegistry.js.map +1 -0
  19. package/dist/catalog/catalogPage.d.ts +7 -3
  20. package/dist/catalog/catalogPage.d.ts.map +1 -1
  21. package/dist/catalog/catalogPage.js.map +1 -1
  22. package/dist/catalog/spatialElementAssets.d.ts +5 -5
  23. package/dist/catalog/spatialElementAssets.d.ts.map +1 -1
  24. package/dist/catalog/spatialElementAssets.js.map +1 -1
  25. package/dist/catalog/spatialElementLodPair.d.ts +2 -1
  26. package/dist/catalog/spatialElementLodPair.d.ts.map +1 -1
  27. package/dist/catalog/spatialElementLodPair.js.map +1 -1
  28. package/dist/index.d.ts +4 -2
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js +3 -1
  31. package/dist/index.js.map +1 -1
  32. package/dist/spatial-element/SpatialElementDockController.d.ts.map +1 -1
  33. package/dist/spatial-element/SpatialElementDockController.js +4 -3
  34. package/dist/spatial-element/SpatialElementDockController.js.map +1 -1
  35. package/dist/spatial-element/spatialElement.d.ts +16 -12
  36. package/dist/spatial-element/spatialElement.d.ts.map +1 -1
  37. package/dist/spatial-element/spatialElement.js +32 -6
  38. package/dist/spatial-element/spatialElement.js.map +1 -1
  39. package/dist/spatial-element/spatialElementGeometry.d.ts +22 -0
  40. package/dist/spatial-element/spatialElementGeometry.d.ts.map +1 -0
  41. package/dist/spatial-element/spatialElementGeometry.js +40 -0
  42. package/dist/spatial-element/spatialElementGeometry.js.map +1 -0
  43. package/dist/spatial-element/spatialElementScene.d.ts +16 -0
  44. package/dist/spatial-element/spatialElementScene.d.ts.map +1 -0
  45. package/dist/spatial-element/spatialElementScene.js +22 -0
  46. package/dist/spatial-element/spatialElementScene.js.map +1 -0
  47. package/dist/spatial-element/spatialTheme.d.ts +16 -0
  48. package/dist/spatial-element/spatialTheme.d.ts.map +1 -0
  49. package/dist/spatial-element/spatialTheme.js +53 -0
  50. package/dist/spatial-element/spatialTheme.js.map +1 -0
  51. package/dist/spatial-element/types.d.ts +63 -33
  52. package/dist/spatial-element/types.d.ts.map +1 -1
  53. package/dist/spatial-element/types.js.map +1 -1
  54. package/dist/stage/MinimapController.js +1 -1
  55. package/dist/stage/MinimapController.js.map +1 -1
  56. package/dist/stage/PanelPresentationController.d.ts.map +1 -1
  57. package/dist/stage/PanelPresentationController.js +5 -3
  58. package/dist/stage/PanelPresentationController.js.map +1 -1
  59. package/dist/stage/SpatialElementInteractionController.d.ts +0 -1
  60. package/dist/stage/SpatialElementInteractionController.d.ts.map +1 -1
  61. package/dist/stage/SpatialElementInteractionController.js +0 -2
  62. package/dist/stage/SpatialElementInteractionController.js.map +1 -1
  63. package/dist/stage/StageExperience.d.ts +10 -4
  64. package/dist/stage/StageExperience.d.ts.map +1 -1
  65. package/dist/stage/StageExperience.js +18 -8
  66. package/dist/stage/StageExperience.js.map +1 -1
  67. package/dist/stage/StageRenderPipeline.d.ts +8 -1
  68. package/dist/stage/StageRenderPipeline.d.ts.map +1 -1
  69. package/dist/stage/StageRenderPipeline.js +23 -6
  70. package/dist/stage/StageRenderPipeline.js.map +1 -1
  71. package/dist/stage/VirtualScrollController.d.ts.map +1 -1
  72. package/dist/stage/VirtualScrollController.js +0 -2
  73. package/dist/stage/VirtualScrollController.js.map +1 -1
  74. package/dist/stage/minimap/MinimapGeometry.d.ts.map +1 -1
  75. package/dist/stage/minimap/MinimapGeometry.js +29 -0
  76. package/dist/stage/minimap/MinimapGeometry.js.map +1 -1
  77. package/dist/stage/panelContext.d.ts +1 -1
  78. package/dist/stage/panelContext.d.ts.map +1 -1
  79. package/dist/stage/panelContext.js.map +1 -1
  80. package/dist/stage/renderSettings.d.ts +10 -0
  81. package/dist/stage/renderSettings.d.ts.map +1 -0
  82. package/dist/stage/renderSettings.js +27 -0
  83. package/dist/stage/renderSettings.js.map +1 -0
  84. package/dist/stage/renderTargetInventory.d.ts +1 -1
  85. package/dist/stage/renderTargetInventory.js +1 -1
  86. package/dist/stage/renderTargetInventory.js.map +1 -1
  87. package/dist/stage/spatialElementFrame.d.ts.map +1 -1
  88. package/dist/stage/spatialElementFrame.js +5 -1
  89. package/dist/stage/spatialElementFrame.js.map +1 -1
  90. package/dist/stage/stageTypes.d.ts +9 -0
  91. package/dist/stage/stageTypes.d.ts.map +1 -1
  92. package/dist/stage/stageTypes.js.map +1 -1
  93. package/package.json +3 -3
package/README.md CHANGED
@@ -6,17 +6,23 @@ See the [authoring guide](https://github.com/LauridBergjohann/spatial-elements/b
6
6
 
7
7
  Beta API; MPL-2.0; see LICENSE.
8
8
 
9
+ Read the [getting-started tutorial](https://github.com/LauridBergjohann/spatial-elements/blob/main/docs/getting-started.md), [API reference](https://github.com/LauridBergjohann/spatial-elements/blob/main/docs/api.md) and [configuration migration](https://github.com/LauridBergjohann/spatial-elements/blob/main/docs/configuration-migration.md).
10
+
11
+ Element content and required `geometry: { low, high }` belong in `SpatialElementData`; shared appearance belongs in `SpatialTheme`. Use `createSpatialTheme({ id, name })` for defaults. The SvelteKit shell needs only the theme; pages register their own data. These docs target version `1.0.0-beta.3` and newer.
12
+
9
13
  Installation:
10
14
 
11
15
  ~~~sh
12
- npm install @spatial-elements/core@beta
16
+ npm install @spatial-elements/core@latest
13
17
  ~~~
14
18
 
15
19
  Requires Node.js 22.12+ tooling.
16
20
 
17
21
  A visible “Built with Spatial Elements” link is appreciated, but not required. This does not replace your obligations under the MPL-2.0 license.
18
22
 
19
- Three.js is a required peer dependency (^0.185.1), shared with the application and other adapters.
23
+ Three.js is a required peer dependency (^0.186.1), shared with the application and other adapters.
20
24
  Modern npm installs it automatically. If the application imports Three.js directly, declare it
21
- explicitly with `npm install three@^0.185.1`. Do not bypass incompatible peer ranges with
25
+ explicitly with `npm install three@^0.186.1`. Do not bypass incompatible peer ranges with
22
26
  `--legacy-peer-deps`. Other package managers may require explicit peer installation.
27
+
28
+ Category lighting is explicit: pass `hdr="/assets/category.hdr"` to `ContentPage` (also `SpatialListPage`). It is never inferred from an element. Identical geometry URLs share one cached fetch/decode.
@@ -1 +1 @@
1
- {"version":3,"file":"CatalogGeometryFade.d.ts","sourceRoot":"","sources":["../../src/catalog/CatalogGeometryFade.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAGtC,kFAAkF;AAClF,qBAAa,mBAAmB;IAC/B,gBAAgB;IAGhB,OAAO,CAAC,OAAO,CAAC,CAAqB;IACrC,OAAO,CAAC,QAAQ,CAAC,CAAqB;IACtC,OAAO,CAAC,IAAI,CAAC,CAAiB;IAC9B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAc;IAEpC,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,cAAc,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,IAAI;IA6CxE,OAAO;CAOP"}
1
+ {"version":3,"file":"CatalogGeometryFade.d.ts","sourceRoot":"","sources":["../../src/catalog/CatalogGeometryFade.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAItC,kFAAkF;AAClF,qBAAa,mBAAmB;IAC/B,gBAAgB;IAGhB,OAAO,CAAC,OAAO,CAAC,CAAqB;IACrC,OAAO,CAAC,QAAQ,CAAC,CAAqB;IACtC,OAAO,CAAC,IAAI,CAAC,CAAiB;IAC9B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAc;IAEpC,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,cAAc,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,IAAI;IAgDxE,OAAO;CAOP"}
@@ -1,5 +1,6 @@
1
1
  import * as THREE from 'three/webgpu';
2
2
  import { texture, uniform } from 'three/tsl';
3
+ import { getRefinementSize } from '../stage/SpatialElementRefinement.js';
3
4
  /** Fade the resolved image, never the individual opaque surfaces of a element. */
4
5
  export class CatalogGeometryFade {
5
6
  getRenderTargets() {
@@ -18,8 +19,11 @@ export class CatalogGeometryFade {
18
19
  return;
19
20
  const destination = renderer.getRenderTarget();
20
21
  const size = destination ?? renderer.getDrawingBufferSize(new THREE.Vector2());
22
+ // Use the same budget as the preparation target. Otherwise the first moving
23
+ // frame reallocates a full-resolution MSAA capture after the bounded warm-up.
24
+ const { width, height } = getRefinementSize(size.width, size.height);
21
25
  if (!this.capture) {
22
- this.capture = new THREE.RenderTarget(size.width, size.height, {
26
+ this.capture = new THREE.RenderTarget(width, height, {
23
27
  type: THREE.HalfFloatType,
24
28
  samples: 4
25
29
  });
@@ -32,7 +36,7 @@ export class CatalogGeometryFade {
32
36
  this.material.toneMapped = false;
33
37
  this.quad = new THREE.QuadMesh(this.material);
34
38
  }
35
- this.capture.setSize(size.width, size.height);
39
+ this.capture.setSize(width, height);
36
40
  const color = renderer.getClearColor(new THREE.Color());
37
41
  const clearAlpha = renderer.getClearAlpha();
38
42
  const scissor = renderer.getScissor(new THREE.Vector4());
@@ -1 +1 @@
1
- {"version":3,"file":"CatalogGeometryFade.js","sourceRoot":"","sources":["../../src/catalog/CatalogGeometryFade.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE7C,kFAAkF;AAClF,MAAM,OAAO,mBAAmB;IAC/B,gBAAgB;QACf,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC3C,CAAC;IACO,OAAO,CAAsB;IAC7B,QAAQ,CAAsB;IAC9B,IAAI,CAAkB;IACb,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAEpC,MAAM,CAAC,QAA8B,EAAE,OAAe,EAAE,IAAgB;QACvE,IAAI,OAAO,IAAI,CAAC,EAAE,CAAC;YAClB,IAAI,EAAE,CAAC;YACP,OAAO;QACR,CAAC;QACD,IAAI,OAAO,IAAI,CAAC;YAAE,OAAO;QACzB,MAAM,WAAW,GAAG,QAAQ,CAAC,eAAe,EAAE,CAAC;QAC/C,MAAM,IAAI,GAAG,WAAW,IAAI,QAAQ,CAAC,oBAAoB,CAAC,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAC/E,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;YACnB,IAAI,CAAC,OAAO,GAAG,IAAI,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE;gBAC9D,IAAI,EAAE,KAAK,CAAC,aAAa;gBACzB,OAAO,EAAE,CAAC;aACV,CAAC,CAAC;YACH,IAAI,CAAC,QAAQ,GAAG,IAAI,KAAK,CAAC,YAAY,EAAE,CAAC;YACzC,IAAI,CAAC,QAAQ,CAAC,YAAY,GAAG,OAAO,CAAC,IAAI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Ac,CAAC,WAAW,CAAC,CAAC;YACrC,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,OAAO,CAAC;YAC3B,IAAI,CAAC,IAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC7B,CAAC;gBAAS,CAAC;YACV,QAAQ,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC;YACtC,QAAQ,CAAC,aAAa,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;YAC1C,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;YAC7B,QAAQ,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;QACtC,CAAC;IACF,CAAC;IACD,OAAO;QACN,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC;QACxB,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC;IACvB,CAAC;CACD","sourcesContent":["import * as THREE from 'three/webgpu';\nimport { texture, uniform } from 'three/tsl';\n\n/** Fade the resolved image, never the individual opaque surfaces of a element. */\nexport class CatalogGeometryFade {\n\tgetRenderTargets() {\n\t\treturn this.capture ? [this.capture] : [];\n\t}\n\tprivate capture?: THREE.RenderTarget;\n\tprivate material?: THREE.NodeMaterial;\n\tprivate quad?: THREE.QuadMesh;\n\tprivate readonly alpha = uniform(1);\n\n\trender(renderer: THREE.WebGPURenderer, opacity: number, draw: () => void) {\n\t\tif (opacity >= 1) {\n\t\t\tdraw();\n\t\t\treturn;\n\t\t}\n\t\tif (opacity <= 0) return;\n\t\tconst destination = renderer.getRenderTarget();\n\t\tconst size = destination ?? renderer.getDrawingBufferSize(new THREE.Vector2());\n\t\tif (!this.capture) {\n\t\t\tthis.capture = new THREE.RenderTarget(size.width, size.height, {\n\t\t\t\ttype: THREE.HalfFloatType,\n\t\t\t\tsamples: 4\n\t\t\t});\n\t\t\tthis.material = new THREE.NodeMaterial();\n\t\t\tthis.material.fragmentNode = texture(this.capture.texture).mul(this.alpha);\n\t\t\tthis.material.transparent = true;\n\t\t\tthis.material.premultipliedAlpha = true;\n\t\t\tthis.material.depthTest = false;\n\t\t\tthis.material.depthWrite = false;\n\t\t\tthis.material.toneMapped = false;\n\t\t\tthis.quad = new THREE.QuadMesh(this.material);\n\t\t}\n\t\tthis.capture.setSize(size.width, size.height);\n\t\tconst color = renderer.getClearColor(new THREE.Color());\n\t\tconst clearAlpha = renderer.getClearAlpha();\n\t\tconst scissor = renderer.getScissor(new THREE.Vector4());\n\t\tconst scissorTest = renderer.getScissorTest();\n\t\ttry {\n\t\t\trenderer.setRenderTarget(this.capture);\n\t\t\trenderer.setScissorTest(false);\n\t\t\trenderer.setClearColor(0x000000, 0);\n\t\t\trenderer.clear();\n\t\t\tdraw();\n\t\t\trenderer.setRenderTarget(destination);\n\t\t\trenderer.setScissor(scissor);\n\t\t\trenderer.setScissorTest(scissorTest);\n\t\t\tthis.alpha.value = opacity;\n\t\t\tthis.quad!.render(renderer);\n\t\t} finally {\n\t\t\trenderer.setRenderTarget(destination);\n\t\t\trenderer.setClearColor(color, clearAlpha);\n\t\t\trenderer.setScissor(scissor);\n\t\t\trenderer.setScissorTest(scissorTest);\n\t\t}\n\t}\n\tdispose() {\n\t\tthis.capture?.dispose();\n\t\tthis.material?.dispose();\n\t\tthis.capture = undefined;\n\t\tthis.material = undefined;\n\t\tthis.quad = undefined;\n\t}\n}\n"]}
1
+ {"version":3,"file":"CatalogGeometryFade.js","sourceRoot":"","sources":["../../src/catalog/CatalogGeometryFade.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AAEzE,kFAAkF;AAClF,MAAM,OAAO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,QAAQ,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC;YACtC,QAAQ,CAAC,aAAa,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;YAC1C,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;YAC7B,QAAQ,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;QACtC,CAAC;IACF,CAAC;IACD,OAAO;QACN,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC;QACxB,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC;IACvB,CAAC;CACD","sourcesContent":["import * as THREE from 'three/webgpu';\nimport { texture, uniform } from 'three/tsl';\nimport { getRefinementSize } from '../stage/SpatialElementRefinement.js';\n\n/** Fade the resolved image, never the individual opaque surfaces of a element. */\nexport class CatalogGeometryFade {\n\tgetRenderTargets() {\n\t\treturn this.capture ? [this.capture] : [];\n\t}\n\tprivate capture?: THREE.RenderTarget;\n\tprivate material?: THREE.NodeMaterial;\n\tprivate quad?: THREE.QuadMesh;\n\tprivate readonly alpha = uniform(1);\n\n\trender(renderer: THREE.WebGPURenderer, opacity: number, draw: () => void) {\n\t\tif (opacity >= 1) {\n\t\t\tdraw();\n\t\t\treturn;\n\t\t}\n\t\tif (opacity <= 0) return;\n\t\tconst destination = renderer.getRenderTarget();\n\t\tconst size = destination ?? renderer.getDrawingBufferSize(new THREE.Vector2());\n\t\t// Use the same budget as the preparation target. Otherwise the first moving\n\t\t// frame reallocates a full-resolution MSAA capture after the bounded warm-up.\n\t\tconst { width, height } = getRefinementSize(size.width, size.height);\n\t\tif (!this.capture) {\n\t\t\tthis.capture = new THREE.RenderTarget(width, height, {\n\t\t\t\ttype: THREE.HalfFloatType,\n\t\t\t\tsamples: 4\n\t\t\t});\n\t\t\tthis.material = new THREE.NodeMaterial();\n\t\t\tthis.material.fragmentNode = texture(this.capture.texture).mul(this.alpha);\n\t\t\tthis.material.transparent = true;\n\t\t\tthis.material.premultipliedAlpha = true;\n\t\t\tthis.material.depthTest = false;\n\t\t\tthis.material.depthWrite = false;\n\t\t\tthis.material.toneMapped = false;\n\t\t\tthis.quad = new THREE.QuadMesh(this.material);\n\t\t}\n\t\tthis.capture.setSize(width, height);\n\t\tconst color = renderer.getClearColor(new THREE.Color());\n\t\tconst clearAlpha = renderer.getClearAlpha();\n\t\tconst scissor = renderer.getScissor(new THREE.Vector4());\n\t\tconst scissorTest = renderer.getScissorTest();\n\t\ttry {\n\t\t\trenderer.setRenderTarget(this.capture);\n\t\t\trenderer.setScissorTest(false);\n\t\t\trenderer.setClearColor(0x000000, 0);\n\t\t\trenderer.clear();\n\t\t\tdraw();\n\t\t\trenderer.setRenderTarget(destination);\n\t\t\trenderer.setScissor(scissor);\n\t\t\trenderer.setScissorTest(scissorTest);\n\t\t\tthis.alpha.value = opacity;\n\t\t\tthis.quad!.render(renderer);\n\t\t} finally {\n\t\t\trenderer.setRenderTarget(destination);\n\t\t\trenderer.setClearColor(color, clearAlpha);\n\t\t\trenderer.setScissor(scissor);\n\t\t\trenderer.setScissorTest(scissorTest);\n\t\t}\n\t}\n\tdispose() {\n\t\tthis.capture?.dispose();\n\t\tthis.material?.dispose();\n\t\tthis.capture = undefined;\n\t\tthis.material = undefined;\n\t\tthis.quad = undefined;\n\t}\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import * as THREE from 'three/webgpu';
2
- import type { SpatialStageConfig } from '../spatial-element/types.js';
2
+ import type { SpatialElementScene } from '../spatial-element/spatialElementScene.js';
3
3
  import { SpatialElementRefinement } from '../stage/SpatialElementRefinement.js';
4
4
  import type { SpatialElementAssetInstance, SpatialElementAssetManager } from './assets/SpatialElementAssetManager.js';
5
5
  import type { EnvironmentCache, PreparedEnvironment } from './EnvironmentCache.js';
@@ -22,7 +22,7 @@ export interface SpatialElementPreparation {
22
22
  gpuWarmMs: number;
23
23
  };
24
24
  }
25
- export declare const preparationKey: (stage: Pick<SpatialStageConfig, "hdr" | "glb" | "lodPair" | "model" | "background">) => string;
25
+ export declare const preparationKey: (stage: Pick<SpatialElementScene, "hdr" | "glb" | "lodPair" | "model" | "background">) => string;
26
26
  /** At most one speculative presentation is retained; active instances are adopted by the stage. */
27
27
  export declare class CatalogPreparation {
28
28
  private assets;
@@ -32,7 +32,7 @@ export declare class CatalogPreparation {
32
32
  private changed;
33
33
  current?: SpatialElementPreparation;
34
34
  constructor(assets: SpatialElementAssetManager, environments: EnvironmentCache, gate: PreparationGate, warm: (high: PreparedHigh, environment: PreparedEnvironment, signal: AbortSignal) => Promise<void>, changed: () => void);
35
- prepare(stage: SpatialStageConfig): SpatialElementPreparation;
35
+ prepare(stage: SpatialElementScene): SpatialElementPreparation;
36
36
  takeHigh(entry: SpatialElementPreparation): PreparedHigh | undefined;
37
37
  dispose(): void;
38
38
  }
@@ -1 +1 @@
1
- {"version":3,"file":"CatalogPreparation.d.ts","sourceRoot":"","sources":["../../src/catalog/CatalogPreparation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAQtE,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,KAAK,EAAE,2BAA2B,EAAE,0BAA0B,EAAE,MAAM,wCAAwC,CAAC;AACtH,OAAO,KAAK,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACnF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAG5D,MAAM,WAAW,YAAY;IAC5B,QAAQ,EAAE,2BAA2B,CAAC;IACtC,IAAI,EAAE,KAAK,CAAC,QAAQ,CAAC;IACrB,SAAS,EAAE,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC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;IACd,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,IAAI;IACZ,OAAO,CAAC,IAAI;IAKZ,OAAO,CAAC,OAAO;IAVhB,OAAO,CAAC,EAAE,yBAAyB,CAAC;gBAE3B,MAAM,EAAE,0BAA0B,EAClC,YAAY,EAAE,gBAAgB,EAC9B,IAAI,EAAE,eAAe,EACrB,IAAI,EAAE,CACb,IAAI,EAAE,YAAY,EAClB,WAAW,EAAE,mBAAmB,EAChC,MAAM,EAAE,WAAW,KACf,OAAO,CAAC,IAAI,CAAC,EACV,OAAO,EAAE,MAAM,IAAI;IAE5B,OAAO,CAAC,KAAK,EAAE,mBAAmB;IA0FlC,QAAQ,CAAC,KAAK,EAAE,yBAAyB;IAQzC,OAAO;CAQP;AACD,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,YAAY,QAKrD"}
@@ -1,9 +1,10 @@
1
1
  import * as THREE from 'three/webgpu';
2
+ import { DEFAULT_BACKGROUND } from '../stage/stageConstants.js';
2
3
  import { prepareSpatialElementFrame } from '../stage/spatialElementFrame.js';
3
4
  import { applyModelMaterialOverrides, getMeshBounds, getMeshMaterials, isMesh } from '../stage/stageSceneUtils.js';
4
5
  import { SpatialElementRefinement } from '../stage/SpatialElementRefinement.js';
5
6
  import { resolveSpatialElementLodPair } from './spatialElementLodPair.js';
6
- export const preparationKey = (stage) => JSON.stringify([stage.hdr, stage.glb, stage.lodPair, stage.model ?? {}, stage.background]);
7
+ export const preparationKey = (stage) => JSON.stringify([stage.hdr, stage.glb, stage.lodPair, stage.model ?? {}, { ...DEFAULT_BACKGROUND, ...stage.background }]);
7
8
  /** At most one speculative presentation is retained; active instances are adopted by the stage. */
8
9
  export class CatalogPreparation {
9
10
  assets;
@@ -1 +1 @@
1
- {"version":3,"file":"CatalogPreparation.js","sourceRoot":"","sources":["../../src/catalog/CatalogPreparation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAE,0BAA0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ACpB,IAAI,IAAI;wBAAE,mBAAmB,CAAC,IAAI,CAAC,CAAC;oBACpC,KAAK,CAAC,OAAO,EAAE,CAAC;gBACjB,CAAC;YACF,CAAC,CAAC,EAAE,CAAC;QACN,CAAC;QACD,OAAO,KAAK,CAAC;IACd,CAAC;IACD,QAAQ,CAAC,KAAgC;QACxC,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;QACxB,IAAI,IAAI,EAAE,CAAC;YACV,KAAK,CAAC,IAAI,GAAG,SAAS,CAAC;YACvB,KAAK,CAAC,SAAS,GAAG,SAAS,CAAC;QAC7B,CAAC;QACD,OAAO,IAAI,CAAC;IACb,CAAC;IACD,OAAO;QACN,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC;QACzB,IAAI,CAAC,KAAK;YAAE,OAAO;QACnB,KAAK,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;QACzB,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;QAC5B,IAAI,KAAK,CAAC,IAAI;YAAE,mBAAmB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACjD,CAAC;CACD;AACD,MAAM,UAAU,mBAAmB,CAAC,IAAkB;IACrD,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,CAAC;IAC7B,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;IACrB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;IACzD,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;AACzB,CAAC","sourcesContent":["import * as THREE from 'three/webgpu';\nimport type { SpatialStageConfig } from '../spatial-element/types.js';\nimport { prepareSpatialElementFrame } from '../stage/spatialElementFrame.js';\nimport {\n\tapplyModelMaterialOverrides,\n\tgetMeshBounds,\n\tgetMeshMaterials,\n\tisMesh\n} from '../stage/stageSceneUtils.js';\nimport { SpatialElementRefinement } from '../stage/SpatialElementRefinement.js';\nimport type { SpatialElementAssetInstance, SpatialElementAssetManager } from './assets/SpatialElementAssetManager.js';\nimport type { EnvironmentCache, PreparedEnvironment } from './EnvironmentCache.js';\nimport type { PreparationGate } from './PreparationGate.js';\nimport { resolveSpatialElementLodPair } from './spatialElementLodPair.js';\n\nexport interface PreparedHigh {\n\tinstance: SpatialElementAssetInstance;\n\tpose: THREE.Object3D;\n\toverrides: Set<THREE.Material>;\n\tblend: SpatialElementRefinement;\n}\nexport interface SpatialElementPreparation {\n\tkey: string;\n\tcontroller: AbortController;\n\tenvironment: ReturnType<EnvironmentCache['acquire']>;\n\tbackgroundState: 'loading' | 'ready' | 'failed';\n\thighState: 'loading' | 'ready' | 'failed' | 'unavailable' | 'adopted';\n\thigh?: PreparedHigh;\n\ttimings?: { buildMs: number; gpuWarmMs: number };\n}\nexport const preparationKey = (\n\tstage: Pick<SpatialStageConfig, 'hdr' | 'glb' | 'lodPair' | 'model' | 'background'>\n) => JSON.stringify([stage.hdr, stage.glb, stage.lodPair, stage.model ?? {}, stage.background]);\n\n/** At most one speculative presentation is retained; active instances are adopted by the stage. */\nexport class CatalogPreparation {\n\tcurrent?: SpatialElementPreparation;\n\tconstructor(\n\t\tprivate assets: SpatialElementAssetManager,\n\t\tprivate environments: EnvironmentCache,\n\t\tprivate gate: PreparationGate,\n\t\tprivate warm: (\n\t\t\thigh: PreparedHigh,\n\t\t\tenvironment: PreparedEnvironment,\n\t\t\tsignal: AbortSignal\n\t\t) => Promise<void>,\n\t\tprivate changed: () => void\n\t) {}\n\tprepare(stage: SpatialStageConfig) {\n\t\tconst key = preparationKey(stage);\n\t\tif (this.current?.key === key && this.current.highState !== 'adopted') return this.current;\n\t\tthis.dispose();\n\t\tconst pair = resolveSpatialElementLodPair(stage.glb, stage.lodPair);\n\t\tconst entry: SpatialElementPreparation = {\n\t\t\tkey,\n\t\t\tcontroller: new AbortController(),\n\t\t\tenvironment: this.environments.acquire(stage.hdr),\n\t\t\tbackgroundState: 'loading',\n\t\t\thighState: pair ? 'loading' : 'unavailable'\n\t\t};\n\t\tthis.current = entry;\n\t\tvoid entry.environment.ready\n\t\t\t.then(\n\t\t\t\tasync () => {\n\t\t\t\t\tawait this.gate.wait(entry.controller.signal);\n\t\t\t\t\tentry.backgroundState = 'ready';\n\t\t\t\t\tthis.changed();\n\t\t\t\t},\n\t\t\t\t() => {\n\t\t\t\t\tentry.backgroundState = 'failed';\n\t\t\t\t\tthis.changed();\n\t\t\t\t}\n\t\t\t)\n\t\t\t.catch(() => {});\n\t\tif (entry.environment.value) entry.backgroundState = 'ready';\n\t\tif (pair) {\n\t\t\tconst signal = entry.controller.signal;\n\t\t\tconst lease = this.assets.acquire(pair.high, { signal });\n\t\t\tvoid (async () => {\n\t\t\t\tlet high: PreparedHigh | undefined;\n\t\t\t\tlet instance: SpatialElementAssetInstance | undefined;\n\t\t\t\ttry {\n\t\t\t\t\tconst [, environment] = await Promise.all([lease.ready, entry.environment.ready]);\n\t\t\t\t\tawait this.gate.wait(signal);\n\t\t\t\t\tinstance = await lease.createInstance();\n\t\t\t\t\tlet buildStarted = 0;\n\t\t\t\t\tawait this.gate.run(() => {\n\t\t\t\t\t\tbuildStarted = performance.now();\n\t\t\t\t\t\tsignal.throwIfAborted();\n\t\t\t\t\t\tconst settings = stage.model ?? {};\n\t\t\t\t\t\tapplyModelMaterialOverrides(instance!.scene, settings.materialOverrides);\n\t\t\t\t\t\tconst overrides = new Set<THREE.Material>();\n\t\t\t\t\t\tconst excluded = new Set(settings.excludeMeshes ?? []);\n\t\t\t\t\t\tinstance!.scene.traverse((object) => {\n\t\t\t\t\t\t\tif (!isMesh(object)) return;\n\t\t\t\t\t\t\tif (excluded.has(object.name)) object.visible = false;\n\t\t\t\t\t\t\tif (settings.materialOverrides?.[object.name])\n\t\t\t\t\t\t\t\tgetMeshMaterials(object).forEach((material) => overrides.add(material));\n\t\t\t\t\t\t});\n\t\t\t\t\t\tconst container = new THREE.Group();\n\t\t\t\t\t\tprepareSpatialElementFrame(container, instance!.scene, pair, settings);\n\t\t\t\t\t\thigh = {\n\t\t\t\t\t\t\tinstance: instance!,\n\t\t\t\t\t\t\toverrides,\n\t\t\t\t\t\t\tpose: container.children[0],\n\t\t\t\t\t\t\tblend: new SpatialElementRefinement(true)\n\t\t\t\t\t\t};\n\t\t\t\t\t\tinstance = undefined;\n\t\t\t\t\t\tif (getMeshBounds(container, (mesh) => !excluded.has(mesh.name)).isEmpty())\n\t\t\t\t\t\t\tthrow new Error('High contains no spatialElement meshes');\n\t\t\t\t\t}, signal);\n\t\t\t\t\tconst warmStarted = performance.now();\n\t\t\t\t\tawait this.warm(high!, environment, signal);\n\t\t\t\t\tentry.timings = {\n\t\t\t\t\t\tbuildMs: warmStarted - buildStarted,\n\t\t\t\t\t\tgpuWarmMs: performance.now() - warmStarted\n\t\t\t\t\t};\n\t\t\t\t\tawait this.gate.wait(signal);\n\t\t\t\t\tsignal.throwIfAborted();\n\t\t\t\t\tentry.high = high;\n\t\t\t\t\thigh = undefined;\n\t\t\t\t\tentry.highState = 'ready';\n\t\t\t\t\tthis.changed();\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (!signal.aborted) {\n\t\t\t\t\t\tentry.highState = 'failed';\n\t\t\t\t\t\tconsole.warn('Optional spatialElement preparation failed; retaining Low', error);\n\t\t\t\t\t\tthis.changed();\n\t\t\t\t\t}\n\t\t\t\t} finally {\n\t\t\t\t\tinstance?.dispose();\n\t\t\t\t\tif (high) disposePreparedHigh(high);\n\t\t\t\t\tlease.release();\n\t\t\t\t}\n\t\t\t})();\n\t\t}\n\t\treturn entry;\n\t}\n\ttakeHigh(entry: SpatialElementPreparation) {\n\t\tconst high = entry.high;\n\t\tif (high) {\n\t\t\tentry.high = undefined;\n\t\t\tentry.highState = 'adopted';\n\t\t}\n\t\treturn high;\n\t}\n\tdispose() {\n\t\tconst entry = this.current;\n\t\tthis.current = undefined;\n\t\tif (!entry) return;\n\t\tentry.controller.abort();\n\t\tentry.environment.release();\n\t\tif (entry.high) disposePreparedHigh(entry.high);\n\t}\n}\nexport function disposePreparedHigh(high: PreparedHigh) {\n\thigh.pose.removeFromParent();\n\thigh.blend.dispose();\n\thigh.overrides.forEach((material) => material.dispose());\n\thigh.instance.dispose();\n}\n"]}
1
+ {"version":3,"file":"CatalogPreparation.js","sourceRoot":"","sources":["../../src/catalog/CatalogPreparation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEhE,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EACN,2BAA2B,EAC3B,aAAa,EACb,gBAAgB,EAChB,MAAM,EACN,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAIhF,OAAO,EAAE,4BAA4B,EAAE,MAAM,4BAA4B,CAAC;AAiB1E,MAAM,CAAC,MAAM,cAAc,GAAG,CAC7B,KAAoF,EACnF,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,KAAK,IAAI,EAAE,EAAE,EAAE,GAAG,kBAAkB,EAAE,GAAG,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;AAE9H,mGAAmG;AACnG,MAAM,OAAO,kBAAkB;IAGrB;IACA;IACA;IACA;IAKA;IAVT,OAAO,CAA6B;IACpC,YACS,MAAkC,EAClC,YAA8B,EAC9B,IAAqB,EACrB,IAIU,EACV,OAAmB;QARnB,WAAM,GAAN,MAAM,CAA4B;QAClC,iBAAY,GAAZ,YAAY,CAAkB;QAC9B,SAAI,GAAJ,IAAI,CAAiB;QACrB,SAAI,GAAJ,IAAI,CAIM;QACV,Y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AmB,CAAC,IAAkB;IACrD,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,CAAC;IAC7B,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;IACrB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;IACzD,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;AACzB,CAAC","sourcesContent":["import * as THREE from 'three/webgpu';\nimport { DEFAULT_BACKGROUND } from '../stage/stageConstants.js';\nimport type { SpatialElementScene } from '../spatial-element/spatialElementScene.js';\nimport { prepareSpatialElementFrame } from '../stage/spatialElementFrame.js';\nimport {\n\tapplyModelMaterialOverrides,\n\tgetMeshBounds,\n\tgetMeshMaterials,\n\tisMesh\n} from '../stage/stageSceneUtils.js';\nimport { SpatialElementRefinement } from '../stage/SpatialElementRefinement.js';\nimport type { SpatialElementAssetInstance, SpatialElementAssetManager } from './assets/SpatialElementAssetManager.js';\nimport type { EnvironmentCache, PreparedEnvironment } from './EnvironmentCache.js';\nimport type { PreparationGate } from './PreparationGate.js';\nimport { resolveSpatialElementLodPair } from './spatialElementLodPair.js';\n\nexport interface PreparedHigh {\n\tinstance: SpatialElementAssetInstance;\n\tpose: THREE.Object3D;\n\toverrides: Set<THREE.Material>;\n\tblend: SpatialElementRefinement;\n}\nexport interface SpatialElementPreparation {\n\tkey: string;\n\tcontroller: AbortController;\n\tenvironment: ReturnType<EnvironmentCache['acquire']>;\n\tbackgroundState: 'loading' | 'ready' | 'failed';\n\thighState: 'loading' | 'ready' | 'failed' | 'unavailable' | 'adopted';\n\thigh?: PreparedHigh;\n\ttimings?: { buildMs: number; gpuWarmMs: number };\n}\nexport const preparationKey = (\n\tstage: Pick<SpatialElementScene, 'hdr' | 'glb' | 'lodPair' | 'model' | 'background'>\n) => JSON.stringify([stage.hdr, stage.glb, stage.lodPair, stage.model ?? {}, { ...DEFAULT_BACKGROUND, ...stage.background }]);\n\n/** At most one speculative presentation is retained; active instances are adopted by the stage. */\nexport class CatalogPreparation {\n\tcurrent?: SpatialElementPreparation;\n\tconstructor(\n\t\tprivate assets: SpatialElementAssetManager,\n\t\tprivate environments: EnvironmentCache,\n\t\tprivate gate: PreparationGate,\n\t\tprivate warm: (\n\t\t\thigh: PreparedHigh,\n\t\t\tenvironment: PreparedEnvironment,\n\t\t\tsignal: AbortSignal\n\t\t) => Promise<void>,\n\t\tprivate changed: () => void\n\t) {}\n\tprepare(stage: SpatialElementScene) {\n\t\tconst key = preparationKey(stage);\n\t\tif (this.current?.key === key && this.current.highState !== 'adopted') return this.current;\n\t\tthis.dispose();\n\t\tconst pair = resolveSpatialElementLodPair(stage.glb, stage.lodPair);\n\t\tconst entry: SpatialElementPreparation = {\n\t\t\tkey,\n\t\t\tcontroller: new AbortController(),\n\t\t\tenvironment: this.environments.acquire(stage.hdr),\n\t\t\tbackgroundState: 'loading',\n\t\t\thighState: pair ? 'loading' : 'unavailable'\n\t\t};\n\t\tthis.current = entry;\n\t\tvoid entry.environment.ready\n\t\t\t.then(\n\t\t\t\tasync () => {\n\t\t\t\t\tawait this.gate.wait(entry.controller.signal);\n\t\t\t\t\tentry.backgroundState = 'ready';\n\t\t\t\t\tthis.changed();\n\t\t\t\t},\n\t\t\t\t() => {\n\t\t\t\t\tentry.backgroundState = 'failed';\n\t\t\t\t\tthis.changed();\n\t\t\t\t}\n\t\t\t)\n\t\t\t.catch(() => {});\n\t\tif (entry.environment.value) entry.backgroundState = 'ready';\n\t\tif (pair) {\n\t\t\tconst signal = entry.controller.signal;\n\t\t\tconst lease = this.assets.acquire(pair.high, { signal });\n\t\t\tvoid (async () => {\n\t\t\t\tlet high: PreparedHigh | undefined;\n\t\t\t\tlet instance: SpatialElementAssetInstance | undefined;\n\t\t\t\ttry {\n\t\t\t\t\tconst [, environment] = await Promise.all([lease.ready, entry.environment.ready]);\n\t\t\t\t\tawait this.gate.wait(signal);\n\t\t\t\t\tinstance = await lease.createInstance();\n\t\t\t\t\tlet buildStarted = 0;\n\t\t\t\t\tawait this.gate.run(() => {\n\t\t\t\t\t\tbuildStarted = performance.now();\n\t\t\t\t\t\tsignal.throwIfAborted();\n\t\t\t\t\t\tconst settings = stage.model ?? {};\n\t\t\t\t\t\tapplyModelMaterialOverrides(instance!.scene, settings.materialOverrides);\n\t\t\t\t\t\tconst overrides = new Set<THREE.Material>();\n\t\t\t\t\t\tconst excluded = new Set(settings.excludeMeshes ?? []);\n\t\t\t\t\t\tinstance!.scene.traverse((object) => {\n\t\t\t\t\t\t\tif (!isMesh(object)) return;\n\t\t\t\t\t\t\tif (excluded.has(object.name)) object.visible = false;\n\t\t\t\t\t\t\tif (settings.materialOverrides?.[object.name])\n\t\t\t\t\t\t\t\tgetMeshMaterials(object).forEach((material) => overrides.add(material));\n\t\t\t\t\t\t});\n\t\t\t\t\t\tconst container = new THREE.Group();\n\t\t\t\t\t\tprepareSpatialElementFrame(container, instance!.scene, pair, settings);\n\t\t\t\t\t\thigh = {\n\t\t\t\t\t\t\tinstance: instance!,\n\t\t\t\t\t\t\toverrides,\n\t\t\t\t\t\t\tpose: container.children[0],\n\t\t\t\t\t\t\tblend: new SpatialElementRefinement(true)\n\t\t\t\t\t\t};\n\t\t\t\t\t\tinstance = undefined;\n\t\t\t\t\t\tif (getMeshBounds(container, (mesh) => !excluded.has(mesh.name)).isEmpty())\n\t\t\t\t\t\t\tthrow new Error('High contains no spatialElement meshes');\n\t\t\t\t\t}, signal);\n\t\t\t\t\tconst warmStarted = performance.now();\n\t\t\t\t\tawait this.warm(high!, environment, signal);\n\t\t\t\t\tentry.timings = {\n\t\t\t\t\t\tbuildMs: warmStarted - buildStarted,\n\t\t\t\t\t\tgpuWarmMs: performance.now() - warmStarted\n\t\t\t\t\t};\n\t\t\t\t\tawait this.gate.wait(signal);\n\t\t\t\t\tsignal.throwIfAborted();\n\t\t\t\t\tentry.high = high;\n\t\t\t\t\thigh = undefined;\n\t\t\t\t\tentry.highState = 'ready';\n\t\t\t\t\tthis.changed();\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (!signal.aborted) {\n\t\t\t\t\t\tentry.highState = 'failed';\n\t\t\t\t\t\tconsole.warn('Optional spatialElement preparation failed; retaining Low', error);\n\t\t\t\t\t\tthis.changed();\n\t\t\t\t\t}\n\t\t\t\t} finally {\n\t\t\t\t\tinstance?.dispose();\n\t\t\t\t\tif (high) disposePreparedHigh(high);\n\t\t\t\t\tlease.release();\n\t\t\t\t}\n\t\t\t})();\n\t\t}\n\t\treturn entry;\n\t}\n\ttakeHigh(entry: SpatialElementPreparation) {\n\t\tconst high = entry.high;\n\t\tif (high) {\n\t\t\tentry.high = undefined;\n\t\t\tentry.highState = 'adopted';\n\t\t}\n\t\treturn high;\n\t}\n\tdispose() {\n\t\tconst entry = this.current;\n\t\tthis.current = undefined;\n\t\tif (!entry) return;\n\t\tentry.controller.abort();\n\t\tentry.environment.release();\n\t\tif (entry.high) disposePreparedHigh(entry.high);\n\t}\n}\nexport function disposePreparedHigh(high: PreparedHigh) {\n\thigh.pose.removeFromParent();\n\thigh.blend.dispose();\n\thigh.overrides.forEach((material) => material.dispose());\n\thigh.instance.dispose();\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"CatalogSpatialElementLayer.d.ts","sourceRoot":"","sources":["../../src/catalog/CatalogSpatialElementLayer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AAE5E,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAErF,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,EAAE,eAAe,EAAsB,MAAM,6BAA6B,CAAC;AAevF,OAAO,EAAE,0BAA0B,EAAoC,MAAM,wCAAwC,CAAC;AAgEtH,oGAAoG;AACpG,wBAAgB,iCAAiC,CAAC,MAAM,EAAE,KAAK,CAAC,OAAO,EAAE,KAAK,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QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE;IAOxF,OAAO,CAAC,kBAAkB;IAQ1B,wBAAwB,CAAC,gBAAgB,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,wBAAwB,GAAG,SAAS;IAmC7G,eAAe;WAlkBa,MAAM;WAAK,MAAM;;IAskB7C,2FAA2F;IAC3F,aAAa;;;;;sBAxuBP,MAAM;qBACP,MAAM;uBACJ,MAAM;wBACL,MAAM;;;;;;;;;;;;IAoxBd,gBAAgB,CAAC,MAAM,EAAE;QACxB,MAAM,EAAE,KAAK,CAAC,iBAAiB,CAAC;QAChC,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC;QACtB,QAAQ,EAAE,MAAM,CAAC;QACjB,oBAAoB,CAAC,EAAE,MAAM,CAAC;KAC9B;IAMD,cAAc,CACb,IAAI,EAAE,KAAK,CAAC,QAAQ,GAAG,SAAS,EAChC,KAAK,EAAE,wBAAwB,GAAG,SAAS,EAC3C,QAAQ,EAAE,MAAM,EAChB,WAAW,CAAC,EAAE,KAAK,CAAC,OAAO;IAW5B,aAAa;IAoBb,iFAAiF;IACjF,iBAAiB,CAAC,OAAO,EAAE,MAAM;IAIjC,OAAO;IAmBP,OAAO,CAAC,WAAW;IAqFnB,OAAO,CAAC,aAAa;IAwCrB,OAAO,CAAC,aAAa;IA8FrB,OAAO,CAAC,YAAY;CAYpB;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAgB7F"}
@@ -3,6 +3,7 @@ import { recordCarouselPanel } from './carouselPanelProjection.js';
3
3
  import { prepareSpatialElementFrame } from '../stage/spatialElementFrame.js';
4
4
  import { resolveSpatialElementLodPair } from './spatialElementLodPair.js';
5
5
  import * as THREE from 'three/webgpu';
6
+ import { getSpatialElementScene, hasSpatialElementScene } from '../spatial-element/spatialElementScene.js';
6
7
  import { getStageVisualScrollPosition } from '../stage/scrollFrame.js';
7
8
  import { getCameraOrbitQuaternion, getPanelPointerInfluence, getPanelPointerRotation, setPanelLocalPerspectiveMatrix } from '../stage/stageMath.js';
8
9
  import { applyModelMaterialOverrides, centerAndScale, getMeshBounds, getMeshMaterials, isMesh } from '../stage/stageSceneUtils.js';
@@ -172,7 +173,7 @@ export class CatalogSpatialElementLayer {
172
173
  this.desired.clear();
173
174
  this.spatialElements.clear();
174
175
  for (const spatialElement of spatialElements) {
175
- if (!spatialElement.stage)
176
+ if (!hasSpatialElementScene(spatialElement))
176
177
  continue;
177
178
  const key = JSON.stringify([
178
179
  getSpatialElementEntityKey(brandId, spatialElement.id),
@@ -182,13 +183,14 @@ export class CatalogSpatialElementLayer {
182
183
  this.spatialElements.set(key, { brandId, spatialElement });
183
184
  }
184
185
  for (const actor of this.actors.values()) {
185
- actor.pose = this.spatialElements.get(actor.key)?.spatialElement.pose ?? actor.pose;
186
+ const nextElement = this.spatialElements.get(actor.key)?.spatialElement;
187
+ actor.pose = nextElement?.pose ?? actor.pose;
186
188
  if (this.handoff && actor.rendered)
187
189
  continue;
188
190
  if (this.handoff?.actor !== actor &&
189
191
  (!this.desired.has(actor.key) ||
190
192
  JSON.stringify(actor.stage) !==
191
- JSON.stringify(this.spatialElements.get(actor.key)?.spatialElement.stage)))
193
+ JSON.stringify(nextElement && hasSpatialElementScene(nextElement) ? getSpatialElementScene(nextElement) : undefined)))
192
194
  this.disposeActor(actor);
193
195
  }
194
196
  this.layoutDirty = true;
@@ -219,17 +221,12 @@ export class CatalogSpatialElementLayer {
219
221
  if (!candidates.length)
220
222
  return;
221
223
  await Promise.all(candidates.map(async ([key, { brandId, spatialElement }]) => {
222
- if (!spatialElement.stage)
224
+ if (!hasSpatialElementScene(spatialElement))
223
225
  return;
224
226
  const request = new AbortController();
225
227
  this.requests.add(request);
226
228
  this.loadingKeys.add(key);
227
- const lease = this.assets.acquire(resolveSpatialElementLodPair(spatialElement.stage.glb, spatialElement.stage.lodPair)?.low ?? {
228
- url: spatialElement.stage.glb,
229
- format: 'glb',
230
- revision: 'legacy-unversioned',
231
- requirements: { decoders: ['draco'], extensions: [] }
232
- }, { signal: request.signal });
229
+ const lease = this.assets.acquire(getSpatialElementScene(spatialElement).lodPair.low, { signal: request.signal });
233
230
  let instance;
234
231
  try {
235
232
  instance = await lease.createInstance();
@@ -237,7 +234,7 @@ export class CatalogSpatialElementLayer {
237
234
  instance.dispose();
238
235
  return;
239
236
  }
240
- const actor = this.createActor(key, brandId, spatialElement.id, spatialElement.stage, instance);
237
+ const actor = this.createActor(key, brandId, spatialElement.id, getSpatialElementScene(spatialElement), instance);
241
238
  actor.occurrence = spatialElement.occurrence;
242
239
  actor.pose = spatialElement.pose;
243
240
  this.actors.set(key, actor);
@@ -340,7 +337,7 @@ export class CatalogSpatialElementLayer {
340
337
  actor.view.position.set(0, compact ? slot.height / 2 - 180 : 0, 0);
341
338
  actor.view.scale.setScalar((Math.min(slot.width, compact ? 360 : slot.height) * 0.82) / (actor.radius * 2));
342
339
  actor.root.updateMatrixWorld(true);
343
- const hitTarget = actor.card.querySelector('.spatial-element-target');
340
+ const hitTarget = actor.hitTarget;
344
341
  if (hitTarget) {
345
342
  // Project cached model bounds, not the framing sphere: empty foreground
346
343
  // margins must not intercept clicks on visible neighbouring spatialElements.
@@ -361,9 +358,9 @@ export class CatalogSpatialElementLayer {
361
358
  hitTarget.style.height = `${bottom - top}px`;
362
359
  hitTarget.style.maxWidth = 'none';
363
360
  }
364
- const panel = actor.card.querySelector('.summary');
365
- if (panel) {
366
- const pw = panel.offsetWidth, ph = panel.offsetHeight;
361
+ const panel = actor.summaryPanel;
362
+ if (panel && actor.summarySize) {
363
+ const { width: pw, height: ph } = actor.summarySize;
367
364
  const matrix = actor.tilt.matrixWorld
368
365
  .clone()
369
366
  .multiply(new THREE.Matrix4().makeTranslation(compact ? 0 : slot.width * 0.39, compact ? slot.height / 2 - 360 - ph / 2 : 0, 0));
@@ -444,9 +441,14 @@ export class CatalogSpatialElementLayer {
444
441
  return animating;
445
442
  }
446
443
  draw(renderer, band) {
447
- this.passes++;
448
444
  const width = window.innerWidth, height = window.innerHeight;
449
445
  const all = [...this.actors.values()].filter((actor) => actor.root.visible && this.handoff?.actor !== actor);
446
+ if (!all.some((actor) => (actor.band ?? 'front') === band)) {
447
+ if (band === 'front' && this.handoff)
448
+ this.renderHandoff(renderer);
449
+ return;
450
+ }
451
+ this.passes++;
450
452
  for (const actor of all)
451
453
  actor.root.visible = (actor.band ?? 'front') === band;
452
454
  this.geometryFade.render(renderer, this.exitOpacity, () => {
@@ -455,7 +457,8 @@ export class CatalogSpatialElementLayer {
455
457
  const clipped = shown.filter((actor) => actor.clip);
456
458
  for (const actor of clipped)
457
459
  actor.root.visible = false;
458
- renderer.render(this.scene, this.camera);
460
+ if (shown.length > clipped.length)
461
+ renderer.render(this.scene, this.camera);
459
462
  if (clipped.length) {
460
463
  const oldScissor = renderer.getScissor(new THREE.Vector4());
461
464
  const oldTest = renderer.getScissorTest();
@@ -805,6 +808,17 @@ export class CatalogSpatialElementLayer {
805
808
  for (const { actor } of measured) {
806
809
  actor.cardRect = actor.card.getBoundingClientRect();
807
810
  actor.slotRect = actor.slot.getBoundingClientRect();
811
+ if (actor.pose) {
812
+ actor.hitTarget = actor.card.querySelector('.spatial-element-target') ?? undefined;
813
+ const panel = actor.card.querySelector('.summary') ?? undefined;
814
+ if (actor.summaryPanel && actor.summaryPanel !== panel)
815
+ this.layoutObserver.unobserve(actor.summaryPanel);
816
+ actor.summaryPanel = panel;
817
+ actor.summarySize = panel ? { width: panel.offsetWidth, height: panel.offsetHeight } : undefined;
818
+ // Summary content can resize without changing its section's fixed height.
819
+ if (panel)
820
+ this.layoutObserver.observe(panel);
821
+ }
808
822
  actor.scrollX = scrollX;
809
823
  actor.scrollY = scrollY;
810
824
  }
@@ -889,6 +903,8 @@ export class CatalogSpatialElementLayer {
889
903
  };
890
904
  }
891
905
  disposeActor(actor) {
906
+ if (actor.summaryPanel)
907
+ this.layoutObserver.unobserve(actor.summaryPanel);
892
908
  actor.root.removeFromParent();
893
909
  actor.model.removeFromParent();
894
910
  actor.card?.removeAttribute('data-catalog-model-ready');