@shopware-ag/dive 3.0.11 → 4.0.0

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 (200) hide show
  1. package/README.md +31 -5
  2. package/build/chunks/{AssetCache-MtISiPD2.cjs → AssetCache-DdxevusY.cjs} +1 -1
  3. package/build/chunks/{AssetCache-DOB996Vk.mjs → AssetCache-MXFCGzZU.mjs} +1 -1
  4. package/build/chunks/AssetExporter-CD2iuQce.mjs +108 -0
  5. package/build/chunks/AssetExporter-CoL-QXkB.cjs +1 -0
  6. package/build/chunks/{AssetLoader-B1n3KGOu.cjs → AssetLoader-BDDJG9JL.cjs} +2 -2
  7. package/build/chunks/{AssetLoader-BY5D3Cvc.mjs → AssetLoader-kRhuVN4p.mjs} +12 -21
  8. package/build/chunks/FileTypes-DGSsi-AX.mjs +2294 -0
  9. package/build/chunks/FileTypes-gD_1MonW.cjs +29 -0
  10. package/build/chunks/ModelComponent-Cj3ff6nL.cjs +1 -0
  11. package/build/chunks/ModelComponent-DkfAgTL0.mjs +87 -0
  12. package/build/chunks/OrbitController-DFPcXvlO.cjs +1 -0
  13. package/build/chunks/OrbitController-DLEyTvUt.mjs +612 -0
  14. package/build/chunks/SpriteTextComponent-ByefJLeU.cjs +1 -0
  15. package/build/chunks/SpriteTextComponent-CG5vfiFy.mjs +83 -0
  16. package/build/chunks/collectAnimations-BgYCN1le.mjs +35 -0
  17. package/build/chunks/collectAnimations-C3HfZHte.cjs +1 -0
  18. package/build/chunks/contributesToBounds-C1mva__U.cjs +1 -0
  19. package/build/chunks/contributesToBounds-DYmHYES4.mjs +14 -0
  20. package/build/chunks/detachTransformControls-2XQrpLN-.cjs +1 -0
  21. package/build/chunks/detachTransformControls-Dr3TIdVy.mjs +209 -0
  22. package/build/chunks/{isFileTypeSupported-C-hfGk-7.mjs → isFileExtensionSupported-CgcqpgqN.mjs} +1 -1
  23. package/build/chunks/{isFileTypeSupported-xoGjHFuz.cjs → isFileExtensionSupported-RvlnH2dr.cjs} +1 -1
  24. package/build/chunks/isVisibleInHierarchy-D9JcLqR5.cjs +1 -0
  25. package/build/chunks/isVisibleInHierarchy-KzVGvDEw.mjs +21 -0
  26. package/build/components/boundingbox/BoundingBoxComponent.d.ts +100 -0
  27. package/build/components/boundingbox/index.d.ts +1 -0
  28. package/build/components/camera/CameraComponent.d.ts +75 -0
  29. package/build/components/camera/index.d.ts +2 -0
  30. package/build/components/camera/perspective/PerspectiveCameraComponent.d.ts +39 -0
  31. package/build/components/grid/GridComponent.d.ts +50 -0
  32. package/build/components/index.d.ts +6 -9
  33. package/build/components/light/LightComponent.d.ts +65 -0
  34. package/build/components/light/ambient/AmbientLightComponent.d.ts +10 -0
  35. package/build/components/light/directional/DirectionalLightComponent.d.ts +23 -0
  36. package/build/components/light/hemi/HemisphereLightComponent.d.ts +21 -0
  37. package/build/components/light/index.d.ts +5 -3
  38. package/build/components/light/point/PointLightComponent.d.ts +26 -0
  39. package/build/components/line/MultiLineComponent.d.ts +133 -0
  40. package/build/components/line/index.d.ts +1 -0
  41. package/build/components/mesh/MeshComponent.d.ts +74 -0
  42. package/build/components/mesh/floor/FloorComponent.d.ts +36 -0
  43. package/build/components/mesh/index.d.ts +4 -0
  44. package/build/components/mesh/model/ModelComponent.d.ts +67 -0
  45. package/build/components/mesh/primitive/PrimitiveComponent.d.ts +43 -0
  46. package/build/components/spritetext/SpriteTextComponent.d.ts +58 -0
  47. package/build/constants/VisibilityLayerMask.d.ts +23 -0
  48. package/build/dive.cjs +1 -1
  49. package/build/dive.mjs +252 -774
  50. package/build/engine/Dive.d.ts +17 -13
  51. package/build/engine/boundingbox/BoundingBox.d.ts +76 -0
  52. package/build/engine/component/Component.d.ts +236 -0
  53. package/build/engine/environment/Environment.d.ts +8 -18
  54. package/build/engine/index.d.ts +4 -1
  55. package/build/engine/node/Node.d.ts +189 -0
  56. package/build/engine/promise/abortable/AbortablePromise.d.ts +8 -0
  57. package/build/engine/renderer/Renderer.d.ts +43 -7
  58. package/build/engine/scene/Scene.d.ts +88 -4
  59. package/build/engine/scene/root/Root.d.ts +29 -0
  60. package/build/engine/scene/xrroot/XRRoot.d.ts +1 -1
  61. package/build/engine/view/View.d.ts +15 -4
  62. package/build/helpers/collectAnimations/collectAnimations.d.ts +23 -0
  63. package/build/helpers/computeProductBounds/computeProductBounds.d.ts +18 -0
  64. package/build/helpers/contributesToBounds/contributesToBounds.d.ts +17 -0
  65. package/build/helpers/detachTransformControls/detachTransformControls.d.ts +15 -0
  66. package/build/helpers/disposeComponents/disposeComponents.d.ts +20 -0
  67. package/build/helpers/findSceneRecursive/findSceneRecursive.d.ts +7 -3
  68. package/build/helpers/implementsInterface/implementsInterface.d.ts +11 -0
  69. package/build/helpers/index.d.ts +6 -1
  70. package/build/helpers/isVisibleInHierarchy/isVisibleInHierarchy.d.ts +12 -0
  71. package/build/index.d.ts +0 -1
  72. package/build/plugins/animation/index.mjs +3 -2
  73. package/build/plugins/animation/src/system/AnimationSystem.d.ts +3 -2
  74. package/build/plugins/ar/index.cjs +1 -1
  75. package/build/plugins/ar/index.mjs +2 -2
  76. package/build/plugins/ar/src/webxr/WebXR.d.ts +7 -0
  77. package/build/plugins/assetcache/index.cjs +1 -1
  78. package/build/plugins/assetcache/index.mjs +1 -1
  79. package/build/plugins/assetexporter/index.cjs +1 -1
  80. package/build/plugins/assetexporter/index.mjs +1 -1
  81. package/build/plugins/assetexporter/src/AssetExporter.d.ts +12 -0
  82. package/build/plugins/assetloader/index.cjs +1 -1
  83. package/build/plugins/assetloader/index.mjs +2 -2
  84. package/build/plugins/mediacreator/index.cjs +1 -1
  85. package/build/plugins/mediacreator/index.mjs +32 -30
  86. package/build/plugins/mediacreator/src/MediaCreator.d.ts +1 -2
  87. package/build/plugins/orbitcontroller/index.cjs +1 -1
  88. package/build/plugins/orbitcontroller/index.d.ts +1 -0
  89. package/build/plugins/orbitcontroller/index.mjs +1 -1
  90. package/build/plugins/orbitcontroller/src/OrbitController.d.ts +39 -6
  91. package/build/plugins/orientationdisplay/index.cjs +1 -1
  92. package/build/plugins/orientationdisplay/index.mjs +41 -33
  93. package/build/plugins/orientationdisplay/src/OrientationDisplay.d.ts +3 -3
  94. package/build/plugins/quickview/index.cjs +1 -1
  95. package/build/plugins/quickview/index.mjs +71 -19
  96. package/build/plugins/quickview/src/QuickView.d.ts +40 -8
  97. package/build/plugins/quickview/types/QuickViewSettings.d.ts +14 -0
  98. package/build/plugins/state/index.cjs +1 -27
  99. package/build/plugins/state/index.mjs +2031 -4135
  100. package/build/plugins/state/src/EngineGateway.d.ts +98 -0
  101. package/build/plugins/state/src/EntityRegistry.d.ts +51 -0
  102. package/build/plugins/state/src/State.d.ts +20 -9
  103. package/build/plugins/state/src/actions/camera/computeencompassingview.d.ts +1 -1
  104. package/build/plugins/state/src/actions/camera/movecamera.d.ts +2 -2
  105. package/build/plugins/state/src/actions/index.d.ts +1 -0
  106. package/build/plugins/state/src/actions/media/generatemedia.d.ts +1 -1
  107. package/build/plugins/state/src/actions/object/addobject.d.ts +2 -3
  108. package/build/plugins/state/src/actions/object/deleteobject.d.ts +3 -4
  109. package/build/plugins/state/src/actions/object/deselectobject.d.ts +3 -4
  110. package/build/plugins/state/src/actions/object/dropit.d.ts +2 -2
  111. package/build/plugins/state/src/actions/object/getallobjects.d.ts +2 -3
  112. package/build/plugins/state/src/actions/object/getobjects.d.ts +3 -4
  113. package/build/plugins/state/src/actions/object/index.d.ts +0 -1
  114. package/build/plugins/state/src/actions/object/modelloaded.d.ts +2 -2
  115. package/build/plugins/state/src/actions/object/selectobject.d.ts +3 -4
  116. package/build/plugins/state/src/actions/object/setparent.d.ts +3 -4
  117. package/build/plugins/state/src/actions/object/updateobject.d.ts +3 -4
  118. package/build/plugins/state/src/actions/renderer/startrender.d.ts +1 -1
  119. package/build/plugins/state/src/actions/scene/exportscene.d.ts +2 -2
  120. package/build/plugins/state/src/actions/scene/index.d.ts +0 -1
  121. package/build/plugins/state/src/actions/scene/setbackground.d.ts +2 -2
  122. package/build/plugins/state/src/actions/scene/updatescene.d.ts +2 -2
  123. package/build/plugins/state/src/actions/state/getstate.d.ts +8 -0
  124. package/build/plugins/state/src/actions/state/index.d.ts +2 -0
  125. package/build/plugins/state/src/actions/state/setstate.d.ts +8 -0
  126. package/build/plugins/state/src/helpers/copyVectors/copyVectors.d.ts +17 -0
  127. package/build/plugins/state/src/helpers/updateParentLink/updateParentLink.d.ts +29 -0
  128. package/build/plugins/state/src/helpers/watchEntity/watchEntity.d.ts +30 -0
  129. package/build/plugins/state/types/ActionTypes.d.ts +18 -3
  130. package/build/plugins/state/types/RegisteredEntity.d.ts +27 -0
  131. package/build/plugins/state/types/{StateSceneData.d.ts → StateData.d.ts} +7 -8
  132. package/build/plugins/state/types/index.d.ts +3 -1
  133. package/build/plugins/state/types/schema/BaseEntitySchema.d.ts +25 -0
  134. package/build/plugins/state/types/schema/CameraSchema.d.ts +18 -0
  135. package/build/plugins/state/types/schema/EntitySchema.d.ts +21 -0
  136. package/build/plugins/state/types/schema/EntityTypeSchema.d.ts +9 -0
  137. package/build/{types → plugins/state/types}/schema/GroupSchema.d.ts +8 -1
  138. package/build/{types → plugins/state/types}/schema/LightSchema.d.ts +16 -0
  139. package/build/plugins/state/types/schema/ModelSchema.d.ts +33 -0
  140. package/build/{types → plugins/state/types}/schema/PrimitiveSchema.d.ts +8 -4
  141. package/build/{types → plugins/state/types}/schema/index.d.ts +1 -4
  142. package/build/plugins/toolbox/index.cjs +1 -1
  143. package/build/plugins/toolbox/index.mjs +194 -150
  144. package/build/plugins/toolbox/src/PointerContext.d.ts +7 -0
  145. package/build/plugins/toolbox/src/SelectionState.d.ts +21 -0
  146. package/build/plugins/toolbox/src/Toolbox.d.ts +9 -2
  147. package/build/{components → plugins/toolbox/src}/gizmo/Gizmo.d.ts +16 -2
  148. package/build/{components → plugins/toolbox/src}/gizmo/handles/AxisHandle.d.ts +2 -3
  149. package/build/{components → plugins/toolbox/src}/gizmo/handles/RadialHandle.d.ts +2 -3
  150. package/build/{components → plugins/toolbox/src}/gizmo/handles/ScaleHandle.d.ts +2 -3
  151. package/build/{components → plugins/toolbox/src}/gizmo/rotate/RotateGizmo.d.ts +2 -2
  152. package/build/{components → plugins/toolbox/src}/gizmo/scale/ScaleGizmo.d.ts +3 -3
  153. package/build/{components → plugins/toolbox/src}/gizmo/translate/TranslateGizmo.d.ts +2 -2
  154. package/build/types/components/DIVESceneObject.d.ts +13 -6
  155. package/build/types/components/index.d.ts +0 -1
  156. package/build/types/events/DIVEComponentEventMap.d.ts +14 -0
  157. package/build/types/events/DIVEEntityEventMap.d.ts +47 -0
  158. package/build/types/events/index.d.ts +2 -0
  159. package/build/types/geometry/DIVEGeometry.d.ts +16 -0
  160. package/build/types/geometry/DIVEGeometryType.d.ts +7 -0
  161. package/build/types/geometry/index.d.ts +2 -0
  162. package/build/types/index.d.ts +3 -1
  163. package/build/types/material/DIVEMaterial.d.ts +21 -0
  164. package/build/types/material/index.d.ts +1 -0
  165. package/package.json +8 -9
  166. package/build/chunks/AssetExporter-Cdxb04b3.cjs +0 -1
  167. package/build/chunks/AssetExporter-DLL_vJae.mjs +0 -67
  168. package/build/chunks/FileTypes-DMTSUCcK.cjs +0 -29
  169. package/build/chunks/FileTypes-DYtXCJQV.mjs +0 -2141
  170. package/build/chunks/PerspectiveCamera-B5TvUzTa.mjs +0 -39
  171. package/build/chunks/PerspectiveCamera-DwQUmkDv.cjs +0 -1
  172. package/build/chunks/PovSchema-Co9FznEz.cjs +0 -1
  173. package/build/chunks/PovSchema-DWWvr_ED.mjs +0 -10
  174. package/build/chunks/findInterface-C6mrvf_t.cjs +0 -1
  175. package/build/chunks/findInterface-DbJ5qzbc.mjs +0 -11
  176. package/build/components/boundingbox/BoundingBox.d.ts +0 -136
  177. package/build/components/floor/Floor.d.ts +0 -14
  178. package/build/components/grid/Grid.d.ts +0 -23
  179. package/build/components/group/Group.d.ts +0 -28
  180. package/build/components/light/AmbientLight.d.ts +0 -19
  181. package/build/components/light/PointLight.d.ts +0 -29
  182. package/build/components/light/SceneLight.d.ts +0 -20
  183. package/build/components/model/Model.d.ts +0 -26
  184. package/build/components/node/Node.d.ts +0 -24
  185. package/build/components/primitive/Primitive.d.ts +0 -27
  186. package/build/components/root/Root.d.ts +0 -34
  187. package/build/engine/camera/PerspectiveCamera.d.ts +0 -24
  188. package/build/helpers/isFileTypeSupported/isFileTypeSupported.d.ts +0 -9
  189. package/build/plugins/state/src/actions/object/placeonfloor.d.ts +0 -12
  190. package/build/plugins/state/src/actions/scene/getallscenedata.d.ts +0 -9
  191. package/build/types/components/DIVELight.d.ts +0 -4
  192. package/build/types/schema/BaseEntitySchema.d.ts +0 -8
  193. package/build/types/schema/EntitySchema.d.ts +0 -11
  194. package/build/types/schema/EntityTypeSchema.d.ts +0 -1
  195. package/build/types/schema/GeometrySchema.d.ts +0 -7
  196. package/build/types/schema/GeometryTypeSchema.d.ts +0 -1
  197. package/build/types/schema/MaterialSchema.d.ts +0 -11
  198. package/build/types/schema/ModelSchema.d.ts +0 -14
  199. package/build/types/schema/PovSchema.d.ts +0 -10
  200. /package/build/{components → plugins/toolbox/src}/gizmo/plane/GizmoPlane.d.ts +0 -0
@@ -1,6 +1,6 @@
1
1
  import { WebGPURenderer } from 'three/webgpu';
2
2
  import { DIVEScene } from '../scene/Scene.ts';
3
- import { DIVEPerspectiveCamera } from '../camera/PerspectiveCamera.ts';
3
+ import { DIVECameraComponent } from '../../components/camera/CameraComponent.ts';
4
4
  import { DIVEEnvironment } from '../environment/Environment.ts';
5
5
  export type DIVERendererSettings = {
6
6
  /**
@@ -70,25 +70,61 @@ export declare const DIVERendererDefaultSettings: Required<DIVERendererSettings>
70
70
  */
71
71
  export declare class DIVERenderer {
72
72
  private _scene;
73
- private _camera;
74
73
  readonly isDIVERenderer: true;
75
74
  private _webgpurenderer;
76
75
  private _environment;
77
76
  private _initPromise;
78
77
  private _settings;
79
- constructor(_scene: DIVEScene, _camera: DIVEPerspectiveCamera, settings?: Partial<DIVERendererSettings>);
78
+ /**
79
+ * Whose eyes the next frame is drawn through.
80
+ *
81
+ * The component, not the bare camera: a camera is reached through the
82
+ * component that owns it everywhere else, and taking the camera here would
83
+ * make the renderer the one place holding a handle that cannot be asked for
84
+ * its layers or resized. `tick` reads `.camera` off it per frame, so a
85
+ * component that swaps its camera is followed rather than remembered wrongly.
86
+ *
87
+ * Settable rather than fixed at construction: cameras are nodes now, so a
88
+ * caller may want to render through a camera entity or a preview and back
89
+ * again. Welding one in meant rebuilding the renderer -- and with it the WebGPU
90
+ * context -- to look somewhere else.
91
+ */
92
+ activeCamera: DIVECameraComponent;
93
+ constructor(_scene: DIVEScene, camera: DIVECameraComponent, settings?: Partial<DIVERendererSettings>);
80
94
  get webgpurenderer(): WebGPURenderer;
81
95
  get environment(): DIVEEnvironment;
82
96
  get canvas(): HTMLCanvasElement;
83
97
  get initialized(): boolean;
84
98
  initAsync(): Promise<void>;
85
- /**
86
- * @deprecated Use {@link DIVERenderer.tick} instead.
87
- */
88
- render(): void;
89
99
  tick(): void;
90
100
  onResize(width: number, height: number): void;
91
101
  dispose(): void;
92
102
  setCanvas(canvas: HTMLCanvasElement): void;
103
+ /**
104
+ * Stops a `dispose` from ending the canvas's WebGL context.
105
+ *
106
+ * `WebGLBackend.dispose()` finishes with `WEBGL_lose_context.loseContext()`,
107
+ * which kills the context of the *canvas*, not of the renderer. A canvas is
108
+ * only ever given one context per type, so once it is lost
109
+ * `getContext('webgl2')` keeps handing back the dead one -- and the next
110
+ * renderer on it reads `getParameter(VIEWPORT)`, gets `null`, and throws. That
111
+ * made a canvas unusable after the first teardown, which is not something DIVE
112
+ * may do to an element a caller passed in and still has in their document.
113
+ *
114
+ * Skipping it is only safe because {@link DIVEScene.dispose} releases the GPU
115
+ * resources itself, through the `dispose` listeners three puts on every
116
+ * geometry, material and texture -- and `DIVE.disposeAsync` runs it before the
117
+ * views, while this renderer is still there to hear it.
118
+ *
119
+ * `WebGLExtensions.get` returns whatever its cache holds unless that is
120
+ * `undefined`, so seeding the entry with `null` makes the lookup in `dispose`
121
+ * come up empty. Everything else `dispose` does still runs.
122
+ *
123
+ * Warns rather than throws if three's internals have moved: the canvas is then
124
+ * lost again, which is bad, but not worth failing a teardown over.
125
+ *
126
+ * @param renderer - The renderer about to be disposed.
127
+ */
128
+ private _keepCanvasUsable;
93
129
  private _createWebGPURenderer;
94
130
  }
@@ -1,6 +1,8 @@
1
1
  import { Scene, Box3, ColorRepresentation } from 'three/webgpu';
2
- import { DIVERoot } from '../../components/root/Root.ts';
3
- import { DIVEGrid } from '../../components/grid/Grid.ts';
2
+ import { DIVERoot } from './root/Root.ts';
3
+ import { GridComponent } from '../../components/grid/GridComponent.ts';
4
+ import { DIVEComponent } from '../component/Component.ts';
5
+ import { DIVETicker } from '../clock/Clock.ts';
4
6
  export type DIVESceneSettings = {
5
7
  /**
6
8
  * Whether to add a floor to the scene.
@@ -41,15 +43,97 @@ export declare const DIVESceneDefaultSettings: Required<DIVESceneSettings>;
41
43
  *
42
44
  * @module
43
45
  */
44
- export declare class DIVEScene extends Scene {
46
+ /**
47
+ * A basic scene class.
48
+ *
49
+ * Comes with a root object that contains all the scene objects, and drives the
50
+ * per-frame tick of every component attached anywhere below it.
51
+ */
52
+ export declare class DIVEScene extends Scene implements DIVETicker {
45
53
  readonly isDIVEScene: true;
46
54
  private _settings;
47
55
  private _root;
48
56
  private _grid;
57
+ /**
58
+ * Components that asked for a per-frame callback.
59
+ *
60
+ * Flat and enrolment-based: nothing walks the scene tree per frame, and
61
+ * components without a `tick` never appear here at all. Nodes enrol and
62
+ * withdraw their components as they enter and leave the tree, so the only
63
+ * per-frame cost is iterating this array.
64
+ */
65
+ private _tickingComponents;
66
+ /** Set while `tick` is iterating, so mutations are deferred. */
67
+ private _isTicking;
68
+ /**
69
+ * What was withdrawn while `tick` was iterating.
70
+ *
71
+ * Splicing under the loop would shift the indices, so a withdrawal that
72
+ * arrives mid-frame is recorded and applied afterwards. Recorded by identity,
73
+ * not derived from `tick`/`tickEnabled` state: a component that is removed
74
+ * from its node still has both, so a state-based compaction kept it enrolled
75
+ * and it went on ticking with no owner -- and, after a move, in two scenes.
76
+ */
77
+ private _withdrawn;
49
78
  constructor(settings?: Partial<DIVESceneSettings>);
50
79
  get root(): DIVERoot;
51
- get grid(): DIVEGrid;
80
+ /**
81
+ * The grid, built on first use.
82
+ *
83
+ * Lazy because a scene without one should not pay for the plane, the shader
84
+ * material and its uniforms.
85
+ */
86
+ get grid(): GridComponent;
87
+ /**
88
+ * Puts the grid on its own node in the scene.
89
+ *
90
+ * Its own node, and not the root: the grid is furniture the viewer sees, not
91
+ * scene content, so it must stay out of everything that walks the root --
92
+ * bounds, exports, the entity tree.
93
+ */
94
+ private _buildGrid;
52
95
  setBackground(value: ColorRepresentation): void;
53
96
  computeSceneBB(): Box3;
97
+ /**
98
+ * Drives every enrolled component once per frame.
99
+ *
100
+ * @param deltaTime - Seconds since the previous frame.
101
+ */
102
+ tick(deltaTime: number): void;
103
+ /**
104
+ * Registers a component for the per-frame tick.
105
+ *
106
+ * Called by {@link DIVENode} when a component becomes live; not part of the
107
+ * component-authoring surface.
108
+ *
109
+ * @param component - The component to enrol.
110
+ * @internal
111
+ */
112
+ enlistComponent(component: DIVEComponent): void;
113
+ /**
114
+ * Removes a component from the per-frame tick.
115
+ *
116
+ * @param component - The component to withdraw.
117
+ * @internal
118
+ */
119
+ withdrawComponent(component: DIVEComponent): void;
120
+ /**
121
+ * Gives up everything in the scene, GPU resources included.
122
+ *
123
+ * Every component gets its `dispose` called, which is what actually frees
124
+ * geometries, materials and textures: three hangs a `dispose` listener on each
125
+ * of those and destroys the GPU object when it fires. Its own
126
+ * `Renderer.dispose` does not do this -- it only drops its bookkeeping -- so
127
+ * without this pass the only thing that ever released GPU memory was ending
128
+ * the canvas's WebGL context, which is not something DIVE may do to a canvas
129
+ * it was handed.
130
+ *
131
+ * Found through the nodes rather than by looking for components in the graph:
132
+ * a component is not in the graph -- only what it contributed is -- so
133
+ * `node.components` is the only place they can be reached.
134
+ *
135
+ * Collects first and disposes afterwards, because a component is free to
136
+ * change the tree it sits in while being disposed.
137
+ */
54
138
  dispose(): void;
55
139
  }
@@ -0,0 +1,29 @@
1
+ import { Box3 } from 'three/webgpu';
2
+ import { FloorComponent } from '../../../components/mesh/floor/FloorComponent.ts';
3
+ import { DIVENode } from '../../node/Node.ts';
4
+ /**
5
+ * The scene node every entity hangs off, and the owner of the ground plane.
6
+ *
7
+ * It holds objects, it does not interpret them: turning entity data into
8
+ * scene objects is the state plugin's job and lives in its `EngineGateway`.
9
+ *
10
+ * @module
11
+ */
12
+ export declare class DIVERoot extends DIVENode {
13
+ readonly isDIVERoot: true;
14
+ /**
15
+ * The ground plane component.
16
+ *
17
+ * Kept as a named accessor because scene settings address the floor
18
+ * directly, rather than as an entity.
19
+ */
20
+ get floor(): FloorComponent;
21
+ constructor();
22
+ /**
23
+ * The world bounding box of everything the scene actually contains.
24
+ *
25
+ * Helpers, gizmo handles and the floor are excluded by their layer, so no
26
+ * per-class exceptions are needed here.
27
+ */
28
+ computeSceneBB(): Box3;
29
+ }
@@ -1,5 +1,5 @@
1
1
  import { Object3D } from 'three/webgpu';
2
- import { DIVERoot } from '../../../components/root/Root.ts';
2
+ import { DIVERoot } from '../root/Root.ts';
3
3
  import { DIVEXRLightRoot } from './xrlightroot/XRLightRoot.ts';
4
4
  import { DIVEScene } from '../Scene.ts';
5
5
  export declare class DIVEXRRoot extends Object3D {
@@ -1,10 +1,9 @@
1
1
  import { DIVETicker } from '../clock/Clock.ts';
2
- import { DIVEPerspectiveCamera } from '../camera/PerspectiveCamera.ts';
2
+ import { DIVECameraComponent } from '../../components/camera/CameraComponent.ts';
3
3
  import { DIVERenderer, DIVERendererSettings } from '../renderer/Renderer.ts';
4
4
  import { DIVEScene } from '../scene/Scene.ts';
5
5
  export declare class DIVEView implements DIVETicker {
6
6
  private _scene;
7
- private _camera;
8
7
  private _settings;
9
8
  readonly isDIVEView: true;
10
9
  readonly uuid: string;
@@ -12,9 +11,21 @@ export declare class DIVEView implements DIVETicker {
12
11
  private _renderer;
13
12
  private _canvasLifecycleManager;
14
13
  private _initPromise;
15
- constructor(_scene: DIVEScene, _camera: DIVEPerspectiveCamera, _settings: Partial<DIVERendererSettings>);
14
+ constructor(_scene: DIVEScene, cameraComponent: DIVECameraComponent, _settings: Partial<DIVERendererSettings>);
16
15
  get renderer(): DIVERenderer;
17
- get camera(): DIVEPerspectiveCamera;
16
+ /**
17
+ * What the view looks through.
18
+ *
19
+ * The component and not the camera or its node: everything a consumer needs
20
+ * hangs off it -- `camera` for three, `owner` for the transform, `onResize` and
21
+ * `setCameraLayer` for itself -- so there is one way in rather than three.
22
+ *
23
+ * Read off the renderer rather than kept here. `DIVERenderer.activeCamera` is
24
+ * settable, so a second copy would keep reporting the camera the renderer has
25
+ * already stopped drawing through -- and `onResize` below would resize that
26
+ * stale one.
27
+ */
28
+ get cameraComponent(): DIVECameraComponent;
18
29
  get canvas(): HTMLCanvasElement;
19
30
  tick(): void;
20
31
  initAsync(): Promise<void>;
@@ -0,0 +1,23 @@
1
+ import { AnimationClip, Object3D } from 'three/webgpu';
2
+ /**
3
+ * Gathers every animation clip below a root, bound to the objects it animates.
4
+ *
5
+ * Both exporters take a root and its clips separately, and resolve each track
6
+ * against the subtree they are handed. Clips therefore reach a file only when
7
+ * they are passed at the top level -- ones sitting on a descendant's
8
+ * `Object3D.animations`, or held by a component, are invisible to the export.
9
+ *
10
+ * Two places are read, because that is where clips end up: `Object3D.animations`,
11
+ * which the asset loader fills for a plain load, and the `animations` field of a
12
+ * component, which is where {@link ModelComponent} keeps them. Components are not
13
+ * part of the graph, so a traversal alone never reaches them. Matched
14
+ * structurally, so a component added later that carries clips needs no change
15
+ * here.
16
+ *
17
+ * Each clip is bound to the objects of the asset that holds it, which is why this
18
+ * cannot live in the exporter: only the holder knows which objects its clips
19
+ * belong to, and by the time a whole scene is handed over, that pairing is gone.
20
+ *
21
+ * @param root - The object to collect below.
22
+ */
23
+ export declare function collectAnimations(root: Object3D): AnimationClip[];
@@ -0,0 +1,18 @@
1
+ import { Box3, Matrix4, Object3D } from 'three/webgpu';
2
+ /**
3
+ * Computes the bounding box of everything in a subtree that counts as real
4
+ * geometry, as decided by {@link contributesToBounds}.
5
+ *
6
+ * Prefer this over `Box3.expandByObject`: that method recurses through the whole
7
+ * subtree itself and knows nothing about layers, so combining it with a
8
+ * `traverse` (as the previous call sites did) walks every node once per ancestor
9
+ * and pulls helper geometry into the result.
10
+ *
11
+ * @param object - Root of the subtree to measure.
12
+ * @param target - Optional box to write into, so callers can avoid allocating.
13
+ * @param intoFrame - Inverse of the frame to measure in. Omit for world space.
14
+ * A box is always axis-aligned in the frame it was measured in, so measuring in
15
+ * an object's own frame is what makes an oriented box possible.
16
+ * @returns The bounding box; empty when the subtree holds no real geometry.
17
+ */
18
+ export declare function computeProductBounds(object: Object3D, target?: Box3, intoFrame?: Matrix4): Box3;
@@ -0,0 +1,17 @@
1
+ import { Object3D } from 'three/webgpu';
2
+ /**
3
+ * Decides whether an object's geometry counts as real content.
4
+ *
5
+ * This is the single answer to "should this be measured, snapped against or
6
+ * exported?". It is a plain layer test on purpose: the visibility layers already
7
+ * encode exactly this distinction -- `PRODUCT` is real geometry, while `UI`
8
+ * handles, `HELPER` visualisations and the `FLOOR` ground plane are not. Adding
9
+ * a component or helper therefore never requires touching the call sites, only
10
+ * picking the right layer.
11
+ *
12
+ * Note this deliberately ignores `visible`, matching the previous behaviour:
13
+ * hiding an object does not shrink the scene bounds.
14
+ *
15
+ * @param object - The object to test.
16
+ */
17
+ export declare function contributesToBounds(object: Object3D): boolean;
@@ -0,0 +1,15 @@
1
+ import { Object3D } from 'three/webgpu';
2
+ /**
3
+ * Release the gizmo if it is currently holding this object.
4
+ *
5
+ * Only necessary because the old `TransformControls` are still in use instead
6
+ * of `DIVEGizmo`: they keep a reference to their target, so removing the
7
+ * object from the scene without detaching first leaves the gizmo pointing at
8
+ * something that is no longer there.
9
+ *
10
+ * Both shapes are checked because the controls sit under a helper root in
11
+ * newer three versions and directly in the scene in older ones.
12
+ *
13
+ * @param object - The object about to leave the scene.
14
+ */
15
+ export declare const detachTransformControls: (object: Object3D) => void;
@@ -0,0 +1,20 @@
1
+ import { Object3D } from 'three/webgpu';
2
+ /**
3
+ * Frees the GPU resources held by every component in a subtree.
4
+ *
5
+ * A component's geometries, materials and textures are only released by its own
6
+ * `dispose`, and nothing else in a teardown does that -- `Renderer.dispose` drops
7
+ * bookkeeping, and unparenting an object frees nothing at all. So whoever takes
8
+ * something out of the scene for good has to come through here, or it leaks until
9
+ * the page goes away.
10
+ *
11
+ * Walks the graph rather than a node's `components`, because components are not
12
+ * in the graph: what the traversal finds is nodes, and each of them is asked for
13
+ * its components.
14
+ *
15
+ * Unparents nothing. Removing an object and freeing what it holds are separate
16
+ * questions, and a caller that is only moving something must not free it.
17
+ *
18
+ * @param object - Root of the subtree to free. Included itself.
19
+ */
20
+ export declare function disposeComponents(object: Object3D): void;
@@ -1,9 +1,13 @@
1
1
  import { Object3D } from 'three/webgpu';
2
2
  import { DIVEScene } from '../../engine/scene/Scene.ts';
3
3
  /**
4
- * Find the scene object of an object.
4
+ * Find the scene an object belongs to.
5
+ *
6
+ * Returns `null` for a detached subtree. Objects are routinely built before
7
+ * they are added to the scene -- entity prefabs are assembled and only then
8
+ * handed to the root -- so "no scene yet" is an ordinary state, not an error.
5
9
  *
6
10
  * @param object - The object to find the scene of.
7
- * @returns The scene object.
11
+ * @returns The scene, or `null` when the object is not (yet) in one.
8
12
  */
9
- export declare const findSceneRecursive: (object: Object3D) => DIVEScene;
13
+ export declare const findSceneRecursive: (object: Object3D | null | undefined) => DIVEScene | null;
@@ -1,2 +1,13 @@
1
1
  import { Object3D } from 'three/webgpu';
2
+ /**
3
+ * Checks whether an object carries a capability brand.
4
+ *
5
+ * Tests for the value being `true`, not merely for the key being present: a
6
+ * `readonly isSelectable: false` would otherwise count as implementing the
7
+ * interface, and `findInterface` would stop its walk at that object and hand it
8
+ * back as the owner.
9
+ *
10
+ * @param object - The object to check.
11
+ * @param discriminator - The brand property, e.g. `isSelectable`.
12
+ */
2
13
  export declare function implementsInterface<T>(object: Object3D | null | undefined, discriminator: string): object is Object3D & T;
@@ -1,11 +1,16 @@
1
1
  export * from './applyMixins/applyMixins.ts';
2
+ export * from './computeProductBounds/computeProductBounds.ts';
3
+ export * from './disposeComponents/disposeComponents.ts';
4
+ export * from './contributesToBounds/contributesToBounds.ts';
5
+ export * from './collectAnimations/collectAnimations.ts';
2
6
  export * from './deepClone/deepClone.ts';
7
+ export * from './detachTransformControls/detachTransformControls.ts';
3
8
  export * from './findInterface/findInterface.ts';
4
9
  export * from './findSceneRecursive/findSceneRecursive.ts';
5
10
  export * from './getFileTypeFromUri/getFileTypeFromUri.ts';
6
11
  export * from './getObjectDelta/getObjectDelta.ts';
7
12
  export * from './implementsInterface/implementsInterface.ts';
8
- export * from './isFileTypeSupported/isFileTypeSupported.ts';
13
+ export * from './isVisibleInHierarchy/isVisibleInHierarchy.ts';
9
14
  export * from './isMimeTypeSupported/isMimeTypeSupported.ts';
10
15
  export * from './isFileExtensionSupported/isFileExtensionSupported.ts';
11
16
  export * from './isURIFileExtensionSupported/isURIFileExtensionSupported.ts';
@@ -0,0 +1,12 @@
1
+ import { Object3D } from 'three/webgpu';
2
+ /**
3
+ * Checks whether an object is visible, taking its ancestors into account.
4
+ *
5
+ * `Raycaster` deliberately ignores `visible` — it only tests `layers`. So a ray
6
+ * still reports a hit on a visible mesh whose parent node was hidden, and any
7
+ * picking code has to apply the hierarchy rule itself.
8
+ *
9
+ * @param object - The object to check.
10
+ * @returns True when the object and every one of its ancestors are visible.
11
+ */
12
+ export declare function isVisibleInHierarchy(object: Object3D | null | undefined): boolean;
package/build/index.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  export * from './engine/index.ts';
2
2
  export * from './constants/index.ts';
3
3
  export * from './components/index.ts';
4
- export * from './engine/index.ts';
5
4
  export * from './interfaces/index.ts';
6
5
  export * from './helpers/index.ts';
7
6
  export * from './error/index.ts';
@@ -56,9 +56,10 @@ class l {
56
56
  *
57
57
  * @example
58
58
  * // Animate a single clip (e.g. a single animation) at once.
59
+ * // The clips belong to the ModelComponent that loaded them, not to the node.
59
60
  * const animator = await animationSystem.fromClips(
60
- * model,
61
- * model.animations,
61
+ * node,
62
+ * node.requireComponent(ModelComponent).animations,
62
63
  * );
63
64
  * // plays first clip by default
64
65
  * animator.play();
@@ -116,9 +116,10 @@ export declare class AnimationSystem implements DIVETicker {
116
116
  *
117
117
  * @example
118
118
  * // Animate a single clip (e.g. a single animation) at once.
119
+ * // The clips belong to the ModelComponent that loaded them, not to the node.
119
120
  * const animator = await animationSystem.fromClips(
120
- * model,
121
- * model.animations,
121
+ * node,
122
+ * node.requireComponent(ModelComponent).animations,
122
123
  * );
123
124
  * // plays first clip by default
124
125
  * animator.play();
@@ -1 +1 @@
1
- "use strict";var f=Object.defineProperty;var h=(o,e,r)=>e in o?f(o,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[e]=r;var l=(o,e,r)=>h(o,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../systeminfo/index.cjs"),A=require("../assetconverter/index.cjs"),O=require("../../chunks/AssetLoader-B1n3KGOu.cjs");require("three/examples/jsm/loaders/DRACOLoader.js");const w=require("../../chunks/AssetExporter-Cdxb04b3.cjs");var m=(o=>(o.AR_DESKTOP_PLATFORM_ERROR="ar-desktop-platform-error",o.AR_QUICK_LOOK_NOT_SAFARI_ERROR="ar-quicklook-not-safari-error",o.AR_QUICK_LOOK_VERSION_MISMATCH_ERROR="ar-quicklook-version-mismatch-error",o.AR_QUICK_LOOK_UNKNOWN_ERROR="ar-quicklook-unknown-error",o))(m||{});class a extends Error{constructor(r,t){super(r);l(this,"type");this.name=this.constructor.name,this.type=t,Object.setPrototypeOf(this,new.target.prototype)}}class R extends a{constructor(){super("AR features are not supported on desktop platforms.","ar-desktop-platform-error")}}class p extends a{constructor(){super("ARQuickLook on iOS is only available in Safari.","ar-quicklook-not-safari-error")}}class d extends a{constructor(e,r){super(`ARQuickLook requires iOS version ${r} or later. Current version: ${e}.`,"ar-quicklook-version-mismatch-error"),this.currentVersion=e,this.requiredVersion=r}}class u extends a{constructor(){super("An unknown ARQuickLook compatibility error occurred.","ar-quicklook-unknown-error")}}const k=12;class S{constructor(){l(this,"converter",new A.AssetConverter(new O.AssetLoader,new w.AssetExporter))}async launch(e,r){if(c.SystemInfo.getBrowser()!==c.EBrowser.SAFARI)return Promise.reject(new p);const t=c.SystemInfo.getIOSVersion();if(t&&t.major<k)return Promise.reject(new d(t.full,k));if(!t)return Promise.reject(new u);if(!c.SystemInfo.getSupportsARQuickLook())return Promise.reject(new u);const n=await this.convertToUSDZ(e,r);return this.launchARQuickLook(n,r)}async convertToUSDZ(e,r){const t=await this.converter.convert(e).to("usdz",{quickLookCompatible:!0,ar:{anchoring:{type:"plane"},planeAnchoring:{alignment:"horizontal"}}}),n=new Blob([t],{type:"model/vnd.usdz+zip"});return URL.createObjectURL(n)}launchARQuickLook(e,r){return new Promise(t=>{(r==null?void 0:r.arScale)==="fixed"&&(e=e.concat("#allowsContentScaling=0"));const n=document.createElement("a");n.innerHTML="<picture></picture>",n.rel="ar",n.href=e,n.download="scene.usdz",t(),n.click()})}}class _{launch(e,r){const t=self.location.toString(),n=document.createElement("a"),s=this._createParams(t,e,r),i=this._createIntent(t,e,s);n.setAttribute("href",i),n.click()}_createParams(e,r,t){const n=new URL(r,e),s=new URLSearchParams(n.search);return s.set("mode","ar_preferred"),this._applyScaleOption(s,t),this._applyPlacementOption(s,t),this._applySoundOption(s,e),this._applyLinkOption(s,e),s}_applyScaleOption(e,r){(r==null?void 0:r.arScale)==="fixed"&&e.set("resizable","false")}_applyPlacementOption(e,r){(r==null?void 0:r.arPlacement)==="vertical"&&e.set("enable_vertical_placement","true")}_applySoundOption(e,r){if(e.has("sound")){const t=new URL(e.get("sound"),r);e.set("sound",t.toString())}}_applyLinkOption(e,r){if(e.has("link")){const t=new URL(e.get("link"),r);e.set("link",t.toString())}}_createIntent(e,r,t){const n=new URL(e),s=new URL(r,e),i="#model-viewer-no-ar-fallback";return n.hash=i,`intent://arvr.google.com/scene-viewer/1.2?${t.toString()+"&file="+s.toString()}#Intent;scheme=https;package=com.google.android.googlequicksearchbox;action=android.intent.action.VIEW;S.browser_fallback_url=${encodeURIComponent(n.toString())};end;`}}class L{async launch(e,r){const t=c.SystemInfo.getSystem();return t===c.ESystem.IOS?new S().launch(e,r):t===c.ESystem.ANDROID?new _().launch(e,r):Promise.reject(new R)}}exports.ARDesktopPlatformError=R;exports.ARError=a;exports.ARQuickLook=S;exports.ARQuickLookNotSafariError=p;exports.ARQuickLookUnknownError=u;exports.ARQuickLookVersionMismatchError=d;exports.ARSystem=L;exports.EARErrorType=m;exports.SceneViewer=_;
1
+ "use strict";var f=Object.defineProperty;var h=(o,e,r)=>e in o?f(o,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[e]=r;var l=(o,e,r)=>h(o,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../systeminfo/index.cjs"),A=require("../assetconverter/index.cjs"),O=require("../../chunks/AssetLoader-BDDJG9JL.cjs");require("three/examples/jsm/loaders/DRACOLoader.js");const w=require("../../chunks/AssetExporter-CoL-QXkB.cjs");var m=(o=>(o.AR_DESKTOP_PLATFORM_ERROR="ar-desktop-platform-error",o.AR_QUICK_LOOK_NOT_SAFARI_ERROR="ar-quicklook-not-safari-error",o.AR_QUICK_LOOK_VERSION_MISMATCH_ERROR="ar-quicklook-version-mismatch-error",o.AR_QUICK_LOOK_UNKNOWN_ERROR="ar-quicklook-unknown-error",o))(m||{});class a extends Error{constructor(r,t){super(r);l(this,"type");this.name=this.constructor.name,this.type=t,Object.setPrototypeOf(this,new.target.prototype)}}class R extends a{constructor(){super("AR features are not supported on desktop platforms.","ar-desktop-platform-error")}}class p extends a{constructor(){super("ARQuickLook on iOS is only available in Safari.","ar-quicklook-not-safari-error")}}class d extends a{constructor(e,r){super(`ARQuickLook requires iOS version ${r} or later. Current version: ${e}.`,"ar-quicklook-version-mismatch-error"),this.currentVersion=e,this.requiredVersion=r}}class u extends a{constructor(){super("An unknown ARQuickLook compatibility error occurred.","ar-quicklook-unknown-error")}}const k=12;class S{constructor(){l(this,"converter",new A.AssetConverter(new O.AssetLoader,new w.AssetExporter))}async launch(e,r){if(c.SystemInfo.getBrowser()!==c.EBrowser.SAFARI)return Promise.reject(new p);const t=c.SystemInfo.getIOSVersion();if(t&&t.major<k)return Promise.reject(new d(t.full,k));if(!t)return Promise.reject(new u);if(!c.SystemInfo.getSupportsARQuickLook())return Promise.reject(new u);const n=await this.convertToUSDZ(e,r);return this.launchARQuickLook(n,r)}async convertToUSDZ(e,r){const t=await this.converter.convert(e).to("usdz",{quickLookCompatible:!0,ar:{anchoring:{type:"plane"},planeAnchoring:{alignment:"horizontal"}}}),n=new Blob([t],{type:"model/vnd.usdz+zip"});return URL.createObjectURL(n)}launchARQuickLook(e,r){return new Promise(t=>{(r==null?void 0:r.arScale)==="fixed"&&(e=e.concat("#allowsContentScaling=0"));const n=document.createElement("a");n.innerHTML="<picture></picture>",n.rel="ar",n.href=e,n.download="scene.usdz",t(),n.click()})}}class _{launch(e,r){const t=self.location.toString(),n=document.createElement("a"),s=this._createParams(t,e,r),i=this._createIntent(t,e,s);n.setAttribute("href",i),n.click()}_createParams(e,r,t){const n=new URL(r,e),s=new URLSearchParams(n.search);return s.set("mode","ar_preferred"),this._applyScaleOption(s,t),this._applyPlacementOption(s,t),this._applySoundOption(s,e),this._applyLinkOption(s,e),s}_applyScaleOption(e,r){(r==null?void 0:r.arScale)==="fixed"&&e.set("resizable","false")}_applyPlacementOption(e,r){(r==null?void 0:r.arPlacement)==="vertical"&&e.set("enable_vertical_placement","true")}_applySoundOption(e,r){if(e.has("sound")){const t=new URL(e.get("sound"),r);e.set("sound",t.toString())}}_applyLinkOption(e,r){if(e.has("link")){const t=new URL(e.get("link"),r);e.set("link",t.toString())}}_createIntent(e,r,t){const n=new URL(e),s=new URL(r,e),i="#model-viewer-no-ar-fallback";return n.hash=i,`intent://arvr.google.com/scene-viewer/1.2?${t.toString()+"&file="+s.toString()}#Intent;scheme=https;package=com.google.android.googlequicksearchbox;action=android.intent.action.VIEW;S.browser_fallback_url=${encodeURIComponent(n.toString())};end;`}}class L{async launch(e,r){const t=c.SystemInfo.getSystem();return t===c.ESystem.IOS?new S().launch(e,r):t===c.ESystem.ANDROID?new _().launch(e,r):Promise.reject(new R)}}exports.ARDesktopPlatformError=R;exports.ARError=a;exports.ARQuickLook=S;exports.ARQuickLookNotSafariError=p;exports.ARQuickLookUnknownError=u;exports.ARQuickLookVersionMismatchError=d;exports.ARSystem=L;exports.EARErrorType=m;exports.SceneViewer=_;
@@ -3,9 +3,9 @@ var R = (o, e, r) => e in o ? p(o, e, { enumerable: !0, configurable: !0, writab
3
3
  var l = (o, e, r) => R(o, typeof e != "symbol" ? e + "" : e, r);
4
4
  import { SystemInfo as c, EBrowser as d, ESystem as u } from "../systeminfo/index.mjs";
5
5
  import { AssetConverter as h } from "../assetconverter/index.mjs";
6
- import { A as _ } from "../../chunks/AssetLoader-BY5D3Cvc.mjs";
6
+ import { A as _ } from "../../chunks/AssetLoader-kRhuVN4p.mjs";
7
7
  import "three/examples/jsm/loaders/DRACOLoader.js";
8
- import { A as f } from "../../chunks/AssetExporter-DLL_vJae.mjs";
8
+ import { A as f } from "../../chunks/AssetExporter-CD2iuQce.mjs";
9
9
  var S = /* @__PURE__ */ ((o) => (o.AR_DESKTOP_PLATFORM_ERROR = "ar-desktop-platform-error", o.AR_QUICK_LOOK_NOT_SAFARI_ERROR = "ar-quicklook-not-safari-error", o.AR_QUICK_LOOK_VERSION_MISMATCH_ERROR = "ar-quicklook-version-mismatch-error", o.AR_QUICK_LOOK_UNKNOWN_ERROR = "ar-quicklook-unknown-error", o))(S || {});
10
10
  class a extends Error {
11
11
  constructor(r, t) {
@@ -4,6 +4,13 @@ export declare class DIVEWebXR {
4
4
  private static _renderer;
5
5
  private static _scene;
6
6
  private static _controller;
7
+ /**
8
+ * Where the camera stood before the session, to be put back afterwards.
9
+ *
10
+ * Position and target are the whole transform -- the controller rebuilds the
11
+ * orientation from them -- and the position belongs to the node the camera
12
+ * component is attached to, not to the camera.
13
+ */
7
14
  private static _cameraPosition;
8
15
  private static _cameraTarget;
9
16
  private static _renderCallbackId;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../chunks/AssetCache-MtISiPD2.cjs");exports.AssetCache=e.AssetCache;exports.Chunk=e.Chunk;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../chunks/AssetCache-DdxevusY.cjs");exports.AssetCache=e.AssetCache;exports.Chunk=e.Chunk;
@@ -1,4 +1,4 @@
1
- import { A as e, C } from "../../chunks/AssetCache-DOB996Vk.mjs";
1
+ import { A as e, C } from "../../chunks/AssetCache-MXFCGzZU.mjs";
2
2
  export {
3
3
  e as AssetCache,
4
4
  C as Chunk
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../chunks/AssetExporter-Cdxb04b3.cjs");exports.AssetExporter=e.AssetExporter;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../chunks/AssetExporter-CoL-QXkB.cjs");exports.AssetExporter=e.AssetExporter;
@@ -1,4 +1,4 @@
1
- import { A as o } from "../../chunks/AssetExporter-DLL_vJae.mjs";
1
+ import { A as o } from "../../chunks/AssetExporter-CD2iuQce.mjs";
2
2
  export {
3
3
  o as AssetExporter
4
4
  };
@@ -27,8 +27,20 @@ export declare class AssetExporter {
27
27
  private _usdzExporter;
28
28
  constructor();
29
29
  export<T extends FileType>(object: Object3D, type: T, options?: FileTypeToExporterOptions[T]): Promise<ArrayBuffer>;
30
+ private _exportByType;
30
31
  private _exportGlb;
31
32
  private _exportGltf;
32
33
  private _exportUsdz;
34
+ /**
35
+ * Temporarily hides everything drawable that does not count as real geometry.
36
+ *
37
+ * Anything carrying a geometry, not just a `Mesh`: a group's link lines and a
38
+ * bounding box helper are `LineSegments`, and a class-based test left them in
39
+ * the file. The layer decides, so product lines and points are exported and
40
+ * helper meshes are not.
41
+ *
42
+ * @returns A function that restores the previous visibility.
43
+ */
44
+ private _hideNonProductGeometry;
33
45
  private _computeNormals;
34
46
  }
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../chunks/AssetLoader-B1n3KGOu.cjs");exports.AssetLoader=e.AssetLoader;exports.DRACOWorker=e.DRACOWorker;exports.DracoLoader=e.DracoLoader;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../chunks/AssetLoader-BDDJG9JL.cjs");exports.AssetLoader=e.AssetLoader;exports.DRACOWorker=e.DRACOWorker;exports.DracoLoader=e.DracoLoader;
@@ -1,5 +1,5 @@
1
- import { A as o } from "../../chunks/AssetLoader-BY5D3Cvc.mjs";
2
- import { D as s, a as t } from "../../chunks/AssetLoader-BY5D3Cvc.mjs";
1
+ import { A as o } from "../../chunks/AssetLoader-kRhuVN4p.mjs";
2
+ import { D as s, a as t } from "../../chunks/AssetLoader-kRhuVN4p.mjs";
3
3
  export {
4
4
  o as AssetLoader,
5
5
  s as DRACOWorker,
@@ -1 +1 @@
1
- "use strict";var p=Object.defineProperty;var y=(c,t,e)=>t in c?p(c,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):c[t]=e;var a=(c,t,e)=>y(c,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=require("three/webgpu"),w=require("../../chunks/PerspectiveCamera-DwQUmkDv.cjs");class b{constructor(t,e,r){a(this,"_renderer");a(this,"_scene");a(this,"_controller");this._renderer=t,this._scene=e,this._controller=r}async generateMedia(t){const{position:e,target:r,resolution:i}=t,{width:o,height:s}=i,h=this._controller.object.position.clone(),d=this._controller.object.quaternion.clone(),l=this._controller.target.clone(),n=this._renderer.canvas.clientWidth||o,g=this._renderer.canvas.clientHeight||s;try{return"onResize"in this._controller.object&&this._controller.object.onResize(o,s),this._controller.object.position.copy(e),this._controller.target.copy(r),this._controller.update(),(await this.drawCanvas(void 0,i)).toDataURL()}finally{this._controller.object.position.copy(h),this._controller.object.quaternion.copy(d),this._controller.target.copy(l),this._controller.update(),"onResize"in this._controller.object&&this._controller.object.onResize(n,g)}}async drawCanvas(t,e){await this._renderer.initAsync();const r=this._renderer.webgpurenderer,i=Math.max(1,(e==null?void 0:e.width)??(t==null?void 0:t.width)??(t==null?void 0:t.clientWidth)??this._renderer.canvas.clientWidth),o=Math.max(1,(e==null?void 0:e.height)??(t==null?void 0:t.height)??(t==null?void 0:t.clientHeight)??this._renderer.canvas.clientHeight),s=new _.RenderTarget(i,o,{colorSpace:_.SRGBColorSpace}),h=r.getRenderTarget(),d=this._controller.object.layers.mask;try{r.setRenderTarget(s),this._controller.object.layers.mask=w.DIVEPerspectiveCamera.LIVE_VIEW_LAYER_MASK,r.render(this._scene,this._controller.object);const l=await r.readRenderTargetPixelsAsync(s,0,0,i,o),n=t??document.createElement("canvas");return n.width=i,n.height=o,this._writePixelsToCanvas(n,l,i,o),n}finally{this._controller.object.layers.mask=d,r.setRenderTarget(h),s.dispose()}}_writePixelsToCanvas(t,e,r,i){const o=t.getContext("2d");if(!o)throw new Error("MediaCreator.drawCanvas: 2D canvas context is not available.");const s=o.createImageData(r,i);s.data.set(new Uint8ClampedArray(Array.from(e))),o.putImageData(s,0,0)}}exports.MediaCreator=b;
1
+ "use strict";var p=Object.defineProperty;var w=(a,e,t)=>e in a?p(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t;var h=(a,e,t)=>w(a,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("three/webgpu"),y=require("../../chunks/FileTypes-gD_1MonW.cjs");require("three/examples/jsm/loaders/HDRLoader.js");require("three/tsl");class C{constructor(e,t,r){h(this,"_renderer");h(this,"_scene");h(this,"_controller");this._renderer=e,this._scene=t,this._controller=r}async generateMedia(e){const{position:t,target:r,resolution:i}=e,{width:o,height:s}=i,d=this._controller.object.owner.position.clone(),n=this._controller.target.clone(),g=this._renderer.canvas.clientWidth||o,_=this._renderer.canvas.clientHeight||s;try{return this._controller.object.onResize(o,s),this._controller.object.owner.position.copy(t),this._controller.target.copy(r),this._controller.update(),(await this.drawCanvas(void 0,i)).toDataURL()}finally{this._controller.object.owner.position.copy(d),this._controller.target.copy(n),this._controller.update(),this._controller.object.onResize(g,_)}}async drawCanvas(e,t){await this._renderer.initAsync();const r=this._renderer.webgpurenderer,i=Math.max(1,(t==null?void 0:t.width)??(e==null?void 0:e.width)??(e==null?void 0:e.clientWidth)??this._renderer.canvas.clientWidth),o=Math.max(1,(t==null?void 0:t.height)??(e==null?void 0:e.height)??(e==null?void 0:e.clientHeight)??this._renderer.canvas.clientHeight),s=new l.RenderTarget(i,o,{colorSpace:l.SRGBColorSpace}),d=r.getRenderTarget(),n=this._controller.object.camera,g=n.layers.mask;try{r.setRenderTarget(s),n.layers.mask=y.DIVECameraComponent.LIVE_VIEW_LAYER_MASK,r.render(this._scene,n);const _=await r.readRenderTargetPixelsAsync(s,0,0,i,o),c=e??document.createElement("canvas");return c.width=i,c.height=o,this._writePixelsToCanvas(c,_,i,o),c}finally{n.layers.mask=g,r.setRenderTarget(d),s.dispose()}}_writePixelsToCanvas(e,t,r,i){const o=e.getContext("2d");if(!o)throw new Error("MediaCreator.drawCanvas: 2D canvas context is not available.");const s=o.createImageData(r,i);s.data.set(new Uint8ClampedArray(Array.from(t))),o.putImageData(s,0,0)}}exports.MediaCreator=C;