@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
@@ -0,0 +1,98 @@
1
+ import { DIVE, DIVERoot, DIVESceneObject } from '../../../index.ts';
2
+ import { EntitySchema, MinimalSchema, PartialSchema } from '../types/index.ts';
3
+ /**
4
+ * The scene properties that are not entities.
5
+ *
6
+ * They live on three different engine objects — scene, grid and floor — and
7
+ * used to be read and written in three places that had already drifted apart.
8
+ */
9
+ export type SceneSettings = {
10
+ name: string;
11
+ backgroundColor: string;
12
+ gridEnabled: boolean;
13
+ floorEnabled: boolean;
14
+ floorColor: string;
15
+ };
16
+ /**
17
+ * What may be written back.
18
+ *
19
+ * Colours come out as hex strings but go in either way, because three accepts
20
+ * both and callers pass whatever they happen to hold.
21
+ */
22
+ export type SceneSettingsPatch = Partial<Omit<SceneSettings, 'backgroundColor' | 'floorColor'> & {
23
+ backgroundColor: string | number;
24
+ floorColor: string | number;
25
+ }>;
26
+ /**
27
+ * #### EngineGateway
28
+ * is the single seam between the state plugin and the engine.
29
+ *
30
+ * The engine holds objects; it does not know what an entity, an action or a
31
+ * state is. Everything that turns entity data into scene objects passes through
32
+ * here.
33
+ *
34
+ * One direction only. Reports coming back the other way are `watchEntity`'s
35
+ * business — which is why this class holds no reference to the state and has no
36
+ * way to command it.
37
+ *
38
+ * It is not a facade over the engine API. It offers what the state layer
39
+ * needs, in the state layer's vocabulary: entities, scene settings, rendering.
40
+ *
41
+ * @module
42
+ */
43
+ export declare class EngineGateway {
44
+ private readonly _engine;
45
+ /** id -> scene object, so lookups do not walk the tree. */
46
+ private readonly _entities;
47
+ constructor(engine: DIVE);
48
+ /** The scene root, for everything that needs the subtree as a whole. */
49
+ get root(): DIVERoot;
50
+ /**
51
+ * Resolves an entity id to its scene object.
52
+ *
53
+ * Backed by a map rather than a tree walk: this runs on every frame a gizmo
54
+ * is dragged, via `object-transform` -> `UPDATE_OBJECT` -> `updateEntity`,
55
+ * and a `traverse` visits every mesh of every loaded asset on the way.
56
+ */
57
+ findEntity(entity: MinimalSchema<EntitySchema>): DIVESceneObject | undefined;
58
+ /**
59
+ * Puts an empty scene object for this entity into the scene.
60
+ *
61
+ * Separate from {@link applyEntity} because of what happens in between:
62
+ * applying a model schema awaits the asset load, and `object-load` fires
63
+ * inside that await. Whoever wants to hear it has to be listening — and
64
+ * registered, or the report writes to an id the state does not know yet.
65
+ * One combined call left no moment for that.
66
+ *
67
+ * Synchronous, so nothing can slip in front of the caller either.
68
+ *
69
+ * @returns The scene object, or `undefined` for a state-only entity.
70
+ */
71
+ createEntity(entity: EntitySchema): DIVESceneObject | undefined;
72
+ /** Writes an entity's data onto the scene object created for it. */
73
+ applyEntity(sceneObject: DIVESceneObject, entity: PartialSchema): Promise<void>;
74
+ updateEntity(patch: PartialSchema): Promise<void>;
75
+ removeEntity(entity: MinimalSchema<EntitySchema>): void;
76
+ /** Forgets every scene object. Listener teardown belongs to the registry. */
77
+ dispose(): void;
78
+ readSceneSettings(): SceneSettings;
79
+ applySceneSettings(patch: SceneSettingsPatch): void;
80
+ startRendering(): Promise<void>;
81
+ registerTicker(ticker: Parameters<DIVE['clock']['addTicker']>[0]): void;
82
+ /**
83
+ * Builds the node for an entity by composing the components its type needs.
84
+ *
85
+ * This is the whole "which entity type means which capabilities" mapping.
86
+ * Note a `scene` light is not one component but two: a hemisphere and a
87
+ * directional one, each carrying its own intensity factor, which is what
88
+ * lets {@link _applyLight} stay free of per-type branching.
89
+ */
90
+ private _instantiate;
91
+ private _instantiateLight;
92
+ private _apply;
93
+ private _applyLight;
94
+ private _applyModel;
95
+ private _applyPrimitive;
96
+ private _applyGroup;
97
+ private _setParent;
98
+ }
@@ -0,0 +1,51 @@
1
+ import { DIVESceneObject } from '../../../index.ts';
2
+ import { EntitySchema, PartialSchema, RegisteredEntity } from '../types/index.ts';
3
+ /**
4
+ * Holds every entity the state knows: its data, its scene object, and the
5
+ * teardown for the listeners on that object.
6
+ *
7
+ * The map itself never leaves this class. Actions get the registry and use
8
+ * `read` / `write` / `register` / `unregister`, so how an entity is stored stays
9
+ * a detail here — and `write` being the only way in means the vector-copy rule
10
+ * is enforced rather than remembered at each call site.
11
+ *
12
+ * @module
13
+ */
14
+ export declare class EntityRegistry {
15
+ private readonly _entities;
16
+ /** How many entities are registered. */
17
+ get size(): number;
18
+ /** Every entity. */
19
+ read(): RegisteredEntity[];
20
+ /** One entity, or `undefined` if it is not registered. */
21
+ read(id: string): RegisteredEntity | undefined;
22
+ /**
23
+ * Patches an entity's data.
24
+ *
25
+ * Copies vectors on the way in. The engine reports them as live references
26
+ * into a buffer it reuses next frame, and `merge` assigns by reference when
27
+ * the target key is absent — so a moving object would otherwise keep
28
+ * rewriting its own stored transform.
29
+ *
30
+ * @param id - The entity to patch.
31
+ * @param patch - The fields to apply; anything absent stays as it is.
32
+ */
33
+ write(id: string, patch: PartialSchema): void;
34
+ /**
35
+ * Takes an entity in.
36
+ *
37
+ * @param schema - The entity data.
38
+ * @param node - Its scene object, absent for a state-only entity.
39
+ * @param unwatch - Drops the listeners on the node again.
40
+ */
41
+ register(schema: EntitySchema, node?: DIVESceneObject, unwatch?: () => void): void;
42
+ /**
43
+ * Drops an entity and the listeners on its node.
44
+ *
45
+ * @param id - The entity to drop.
46
+ * @returns Whether it was registered.
47
+ */
48
+ unregister(id: string): boolean;
49
+ /** Drops everything, listeners included. */
50
+ clear(): void;
51
+ }
@@ -5,24 +5,34 @@ export type ActionSubscriber<ActionType extends keyof ActionTypes> = (payload: A
5
5
  export type ActionUnsubscribe = () => void;
6
6
  export declare class State {
7
7
  private static __instances;
8
- static get(id: string): State | undefined;
9
- private _id;
10
- get id(): string;
11
8
  private engine;
12
9
  private controller;
13
- private _mediaCreator;
10
+ /** The only way from here into the engine, see {@link EngineGateway}. */
11
+ private gateway;
12
+ /**
13
+ * modules, each loaded on first use
14
+ * the promise is cached, not the instance, and stored before anything is
15
+ * awaited, or two callers in the same tick each build their own
16
+ */
17
+ private _mediaCreator?;
14
18
  private getMediaCreator;
15
- private _arSystem;
19
+ private _arSystem?;
16
20
  private getARSystem;
17
- private _assetExplorer;
21
+ private _assetExplorer?;
18
22
  private getAssetExporter;
19
- private _animationSystem;
23
+ private _animationSystem?;
20
24
  private getAnimationSystem;
21
- private _toolbox;
25
+ private _toolbox?;
22
26
  private getToolbox;
23
- private registered;
27
+ /** Every entity this state holds. See {@link EntityRegistry}. */
28
+ private registry;
24
29
  private listeners;
25
30
  constructor(dive: DIVE, controller: OrbitController);
31
+ /**
32
+ * Tears this state down and forgets it.
33
+ *
34
+ * @returns Whether it was still registered.
35
+ */
26
36
  destroyInstance(): boolean;
27
37
  performAction<ActionType extends keyof ActionTypes>(action: ActionType, ...args: ActionPayload<ActionTypes[ActionType]> extends void ? [] : [ActionPayload<ActionTypes[ActionType]>]): ActionReturn<ActionTypes[ActionType]>;
28
38
  subscribe<ActionType extends keyof ActionTypes>(type: ActionType, listener: ActionSubscriber<ActionType>): ActionUnsubscribe;
@@ -30,6 +40,7 @@ export declare class State {
30
40
  private getDependencies;
31
41
  }
32
42
  export * from './ActionRegistry.ts';
43
+ export * from './EngineGateway.ts';
33
44
  export * from './actions/index.ts';
34
45
  export * from '../types/index.ts';
35
46
  export type { ActionTypes };
@@ -1,7 +1,7 @@
1
1
  import { Action } from '../action.ts';
2
2
  import { Vector3Like } from 'three/webgpu';
3
3
  import { ActionDependencies } from '../../../types/index.ts';
4
- export declare const ComputeEncompassingViewAction: new (payload: void, dependencies: Pick<ActionDependencies, "engine" | "controller">) => Action<void, Pick<ActionDependencies, "engine" | "controller">, {
4
+ export declare const ComputeEncompassingViewAction: new (payload: void, dependencies: Pick<ActionDependencies, "gateway" | "controller">) => Action<void, Pick<ActionDependencies, "gateway" | "controller">, {
5
5
  position: Vector3Like;
6
6
  target: Vector3Like;
7
7
  }>;
@@ -10,7 +10,7 @@ export declare const MoveCameraAction: new (payload: {
10
10
  id: string;
11
11
  locked: boolean;
12
12
  duration: number;
13
- }, dependencies: Pick<ActionDependencies, "registered" | "engine" | "controller" | "getAnimationSystem">) => Action<{
13
+ }, dependencies: Pick<ActionDependencies, "registry" | "gateway" | "controller" | "getAnimationSystem">) => Action<{
14
14
  position: Vector3Like;
15
15
  target: Vector3Like;
16
16
  locked: boolean;
@@ -19,7 +19,7 @@ export declare const MoveCameraAction: new (payload: {
19
19
  id: string;
20
20
  locked: boolean;
21
21
  duration: number;
22
- }, Pick<ActionDependencies, "registered" | "engine" | "controller" | "getAnimationSystem">, Promise<{
22
+ }, Pick<ActionDependencies, "registry" | "gateway" | "controller" | "getAnimationSystem">, Promise<{
23
23
  stop: () => void;
24
24
  }>>;
25
25
  declare global {
@@ -4,4 +4,5 @@ export * from './media/index.ts';
4
4
  export * from './object/index.ts';
5
5
  export * from './renderer/index.ts';
6
6
  export * from './scene/index.ts';
7
+ export * from './state/index.ts';
7
8
  export * from './toolbox/index.ts';
@@ -1,7 +1,7 @@
1
1
  import { Action } from '../action.ts';
2
2
  import { ActionDependencies } from '../../../types/index.ts';
3
3
  import { MediaGenerationByPosition, MediaGenerationById } from '../../../../mediacreator/index.ts';
4
- export declare const GenerateMediaAction: new (payload: MediaGenerationById | MediaGenerationByPosition, dependencies: Pick<ActionDependencies, "registered" | "getMediaCreator">) => Action<MediaGenerationById | MediaGenerationByPosition, Pick<ActionDependencies, "registered" | "getMediaCreator">, Promise<string>>;
4
+ export declare const GenerateMediaAction: new (payload: MediaGenerationById | MediaGenerationByPosition, dependencies: Pick<ActionDependencies, "registry" | "getMediaCreator">) => Action<MediaGenerationById | MediaGenerationByPosition, Pick<ActionDependencies, "registry" | "getMediaCreator">, Promise<string>>;
5
5
  declare global {
6
6
  interface ActionTypes {
7
7
  GENERATE_MEDIA: typeof GenerateMediaAction;
@@ -1,7 +1,6 @@
1
1
  import { Action } from '../action.ts';
2
- import { ActionDependencies } from '../../../types/index.ts';
3
- import { EntitySchema } from '../../../../../index.ts';
4
- export declare const AddObjectAction: new (payload: EntitySchema, dependencies: Pick<ActionDependencies, "registered" | "engine">) => Action<EntitySchema, Pick<ActionDependencies, "registered" | "engine">, void>;
2
+ import { ActionDependencies, EntitySchema } from '../../../types/index.ts';
3
+ export declare const AddObjectAction: new (payload: EntitySchema, dependencies: Pick<ActionDependencies, "registry" | "dispatch" | "gateway">) => Action<EntitySchema, Pick<ActionDependencies, "registry" | "dispatch" | "gateway">, Promise<import('../../../../../index.ts').DIVENode | undefined>>;
5
4
  declare global {
6
5
  interface ActionTypes {
7
6
  ADD_OBJECT: typeof AddObjectAction;
@@ -1,11 +1,10 @@
1
1
  import { Action } from '../action.ts';
2
- import { ActionDependencies } from '../../../types/index.ts';
3
- import { EntitySchema } from '../../../../../index.ts';
2
+ import { ActionDependencies, EntitySchema } from '../../../types/index.ts';
4
3
  export declare const DeleteObjectAction: new (payload: Partial<EntitySchema> & {
5
4
  id: string;
6
- }, dependencies: Pick<ActionDependencies, "registered" | "engine">) => Action<Partial<EntitySchema> & {
5
+ }, dependencies: Pick<ActionDependencies, "registry" | "gateway">) => Action<Partial<EntitySchema> & {
7
6
  id: string;
8
- }, Pick<ActionDependencies, "registered" | "engine">, void>;
7
+ }, Pick<ActionDependencies, "registry" | "gateway">, void>;
9
8
  declare global {
10
9
  interface ActionTypes {
11
10
  DELETE_OBJECT: typeof DeleteObjectAction;
@@ -1,11 +1,10 @@
1
1
  import { Action } from '../action.ts';
2
- import { ActionDependencies } from '../../../types/index.ts';
3
- import { EntitySchema } from '../../../../../index.ts';
2
+ import { ActionDependencies, EntitySchema } from '../../../types/index.ts';
4
3
  export declare const DeselectObjectAction: new (payload: Partial<EntitySchema> & {
5
4
  id: string;
6
- }, dependencies: Pick<ActionDependencies, "registered" | "engine" | "getToolbox">) => Action<Partial<EntitySchema> & {
5
+ }, dependencies: Pick<ActionDependencies, "registry" | "getToolbox">) => Action<Partial<EntitySchema> & {
7
6
  id: string;
8
- }, Pick<ActionDependencies, "registered" | "engine" | "getToolbox">, Promise<void>>;
7
+ }, Pick<ActionDependencies, "registry" | "getToolbox">, Promise<void>>;
9
8
  declare global {
10
9
  interface ActionTypes {
11
10
  DESELECT_OBJECT: typeof DeselectObjectAction;
@@ -2,9 +2,9 @@ import { Action } from '../action.ts';
2
2
  import { ActionDependencies } from '../../../types/index.ts';
3
3
  export declare const DropItAction: new (payload: {
4
4
  id: string;
5
- }, dependencies: Pick<ActionDependencies, "registered" | "engine">) => Action<{
5
+ }, dependencies: Pick<ActionDependencies, "registry">) => Action<{
6
6
  id: string;
7
- }, Pick<ActionDependencies, "registered" | "engine">, void>;
7
+ }, Pick<ActionDependencies, "registry">, void>;
8
8
  declare global {
9
9
  interface ActionTypes {
10
10
  DROP_IT: typeof DropItAction;
@@ -1,7 +1,6 @@
1
1
  import { Action } from '../action.ts';
2
- import { ActionDependencies } from '../../../types/index.ts';
3
- import { EntitySchema } from '../../../../../index.ts';
4
- export declare const GetAllObjectsAction: new (payload: void, dependencies: Pick<ActionDependencies, "registered">) => Action<void, Pick<ActionDependencies, "registered">, Map<string, EntitySchema>>;
2
+ import { ActionDependencies, EntitySchema } from '../../../types/index.ts';
3
+ export declare const GetAllObjectsAction: new (payload: void, dependencies: Pick<ActionDependencies, "registry">) => Action<void, Pick<ActionDependencies, "registry">, Map<string, EntitySchema>>;
5
4
  declare global {
6
5
  interface ActionTypes {
7
6
  GET_ALL_OBJECTS: typeof GetAllObjectsAction;
@@ -1,11 +1,10 @@
1
1
  import { Action } from '../action.ts';
2
- import { ActionDependencies } from '../../../types/index.ts';
3
- import { EntitySchema } from '../../../../../index.ts';
2
+ import { ActionDependencies, EntitySchema } from '../../../types/index.ts';
4
3
  export declare const GetObjectsAction: new (payload: {
5
4
  ids: string[];
6
- }, dependencies: Pick<ActionDependencies, "registered" | "engine">) => Action<{
5
+ }, dependencies: Pick<ActionDependencies, "registry" | "gateway">) => Action<{
7
6
  ids: string[];
8
- }, Pick<ActionDependencies, "registered" | "engine">, EntitySchema[]>;
7
+ }, Pick<ActionDependencies, "registry" | "gateway">, EntitySchema[]>;
9
8
  declare global {
10
9
  interface ActionTypes {
11
10
  GET_OBJECTS: typeof GetObjectsAction;
@@ -5,7 +5,6 @@ export * from './dropit.ts';
5
5
  export * from './getallobjects.ts';
6
6
  export * from './getobjects.ts';
7
7
  export * from './modelloaded.ts';
8
- export * from './placeonfloor.ts';
9
8
  export * from './selectobject.ts';
10
9
  export * from './setparent.ts';
11
10
  export * from './updateobject.ts';
@@ -2,9 +2,9 @@ import { Action } from '../action.ts';
2
2
  import { ActionDependencies } from '../../../types/index.ts';
3
3
  export declare const ModelLoadedAction: new (payload: {
4
4
  id: string;
5
- }, dependencies: Pick<ActionDependencies, "registered">) => Action<{
5
+ }, dependencies: Pick<ActionDependencies, "registry">) => Action<{
6
6
  id: string;
7
- }, Pick<ActionDependencies, "registered">, void>;
7
+ }, Pick<ActionDependencies, "registry">, void>;
8
8
  declare global {
9
9
  interface ActionTypes {
10
10
  MODEL_LOADED: typeof ModelLoadedAction;
@@ -1,11 +1,10 @@
1
1
  import { Action } from '../action.ts';
2
- import { ActionDependencies } from '../../../types/index.ts';
3
- import { EntitySchema } from '../../../../../index.ts';
2
+ import { ActionDependencies, EntitySchema } from '../../../types/index.ts';
4
3
  export declare const SelectObjectAction: new (payload: Partial<EntitySchema> & {
5
4
  id: string;
6
- }, dependencies: Pick<ActionDependencies, "registered" | "engine" | "getToolbox">) => Action<Partial<EntitySchema> & {
5
+ }, dependencies: Pick<ActionDependencies, "registry" | "getToolbox">) => Action<Partial<EntitySchema> & {
7
6
  id: string;
8
- }, Pick<ActionDependencies, "registered" | "engine" | "getToolbox">, Promise<void>>;
7
+ }, Pick<ActionDependencies, "registry" | "getToolbox">, Promise<void>>;
9
8
  declare global {
10
9
  interface ActionTypes {
11
10
  SELECT_OBJECT: typeof SelectObjectAction;
@@ -1,6 +1,5 @@
1
1
  import { Action } from '../action.ts';
2
- import { ActionDependencies } from '../../../types/index.ts';
3
- import { EntitySchema } from '../../../../../index.ts';
2
+ import { ActionDependencies, EntitySchema } from '../../../types/index.ts';
4
3
  export declare const SetParentAction: new (payload: {
5
4
  object: Partial<EntitySchema> & {
6
5
  id: string;
@@ -8,14 +7,14 @@ export declare const SetParentAction: new (payload: {
8
7
  parent: (Partial<EntitySchema> & {
9
8
  id: string;
10
9
  }) | null;
11
- }, dependencies: Pick<ActionDependencies, "registered" | "engine">) => Action<{
10
+ }, dependencies: Pick<ActionDependencies, "registry" | "gateway">) => Action<{
12
11
  object: Partial<EntitySchema> & {
13
12
  id: string;
14
13
  };
15
14
  parent: (Partial<EntitySchema> & {
16
15
  id: string;
17
16
  }) | null;
18
- }, Pick<ActionDependencies, "registered" | "engine">, void>;
17
+ }, Pick<ActionDependencies, "registry" | "gateway">, void>;
19
18
  declare global {
20
19
  interface ActionTypes {
21
20
  SET_PARENT: typeof SetParentAction;
@@ -1,11 +1,10 @@
1
1
  import { Action } from '../action.ts';
2
- import { ActionDependencies } from '../../../types/index.ts';
3
- import { EntitySchema } from '../../../../../index.ts';
2
+ import { ActionDependencies, EntitySchema } from '../../../types/index.ts';
4
3
  export declare const UpdateObjectAction: new (payload: Partial<EntitySchema> & {
5
4
  id: string;
6
- }, dependencies: Pick<ActionDependencies, "registered" | "engine">) => Action<Partial<EntitySchema> & {
5
+ }, dependencies: Pick<ActionDependencies, "registry" | "gateway">) => Action<Partial<EntitySchema> & {
7
6
  id: string;
8
- }, Pick<ActionDependencies, "registered" | "engine">, void>;
7
+ }, Pick<ActionDependencies, "registry" | "gateway">, Promise<void>>;
9
8
  declare global {
10
9
  interface ActionTypes {
11
10
  UPDATE_OBJECT: typeof UpdateObjectAction;
@@ -1,6 +1,6 @@
1
1
  import { Action } from '../action.ts';
2
2
  import { ActionDependencies } from '../../../types/index.ts';
3
- export declare const StartRenderAction: new (payload: void, dependencies: Pick<ActionDependencies, "engine">) => Action<void, Pick<ActionDependencies, "engine">, void>;
3
+ export declare const StartRenderAction: new (payload: void, dependencies: Pick<ActionDependencies, "gateway">) => Action<void, Pick<ActionDependencies, "gateway">, Promise<void>>;
4
4
  declare global {
5
5
  interface ActionTypes {
6
6
  START_RENDER: typeof StartRenderAction;
@@ -3,9 +3,9 @@ import { ActionDependencies } from '../../../types/index.ts';
3
3
  import { StateExportFileType } from '../../../types/StateExportFileType.ts';
4
4
  export declare const ExportSceneAction: new (payload: {
5
5
  type: keyof StateExportFileType;
6
- }, dependencies: Pick<ActionDependencies, "engine" | "getAssetExporter">) => Action<{
6
+ }, dependencies: Pick<ActionDependencies, "gateway" | "getAssetExporter">) => Action<{
7
7
  type: keyof StateExportFileType;
8
- }, Pick<ActionDependencies, "engine" | "getAssetExporter">, Promise<ArrayBuffer | null>>;
8
+ }, Pick<ActionDependencies, "gateway" | "getAssetExporter">, Promise<ArrayBuffer | null>>;
9
9
  declare global {
10
10
  interface ActionTypes {
11
11
  EXPORT_SCENE: typeof ExportSceneAction;
@@ -1,4 +1,3 @@
1
1
  export * from './exportscene.ts';
2
- export * from './getallscenedata.ts';
3
2
  export * from './setbackground.ts';
4
3
  export * from './updatescene.ts';
@@ -2,9 +2,9 @@ import { Action } from '../action.ts';
2
2
  import { ActionDependencies } from '../../../types/index.ts';
3
3
  export declare const SetBackgroundAction: new (payload: {
4
4
  color: string | number;
5
- }, dependencies: Pick<ActionDependencies, "engine">) => Action<{
5
+ }, dependencies: Pick<ActionDependencies, "gateway">) => Action<{
6
6
  color: string | number;
7
- }, Pick<ActionDependencies, "engine">, void>;
7
+ }, Pick<ActionDependencies, "gateway">, void>;
8
8
  declare global {
9
9
  interface ActionTypes {
10
10
  SET_BACKGROUND: typeof SetBackgroundAction;
@@ -6,13 +6,13 @@ export declare const UpdateSceneAction: new (payload: Partial<{
6
6
  gridEnabled: boolean;
7
7
  floorEnabled: boolean;
8
8
  floorColor: string | number;
9
- }>, dependencies: Pick<ActionDependencies, "engine">) => Action<Partial<{
9
+ }>, dependencies: Pick<ActionDependencies, "gateway">) => Action<Partial<{
10
10
  name: string;
11
11
  backgroundColor: string | number;
12
12
  gridEnabled: boolean;
13
13
  floorEnabled: boolean;
14
14
  floorColor: string | number;
15
- }>, Pick<ActionDependencies, "engine">, void>;
15
+ }>, Pick<ActionDependencies, "gateway">, void>;
16
16
  declare global {
17
17
  interface ActionTypes {
18
18
  UPDATE_SCENE: typeof UpdateSceneAction;
@@ -0,0 +1,8 @@
1
+ import { Action } from '../action.ts';
2
+ import { ActionDependencies, StateData } from '../../../types/index.ts';
3
+ export declare const GetStateAction: new (payload: void, dependencies: Pick<ActionDependencies, "registry" | "gateway" | "controller">) => Action<void, Pick<ActionDependencies, "registry" | "gateway" | "controller">, StateData>;
4
+ declare global {
5
+ interface ActionTypes {
6
+ GET_STATE: typeof GetStateAction;
7
+ }
8
+ }
@@ -0,0 +1,2 @@
1
+ export * from './getstate.ts';
2
+ export * from './setstate.ts';
@@ -0,0 +1,8 @@
1
+ import { Action } from '../action.ts';
2
+ import { ActionDependencies, StateData } from '../../../types/index.ts';
3
+ export declare const SetStateAction: new (payload: StateData, dependencies: Pick<ActionDependencies, "registry" | "dispatch" | "gateway" | "controller">) => Action<StateData, Pick<ActionDependencies, "registry" | "dispatch" | "gateway" | "controller">, Promise<import('../../../../../index.ts').DIVENode[]>>;
4
+ declare global {
5
+ interface ActionTypes {
6
+ SET_STATE: typeof SetStateAction;
7
+ }
8
+ }
@@ -0,0 +1,17 @@
1
+ import { PartialSchema } from '../../../types/index.ts';
2
+ /**
3
+ * Returns a patch whose vectors are plain copies.
4
+ *
5
+ * The engine reports transforms as live references into objects it keeps reusing
6
+ * — `DIVENode.onMove` hands out a scratch `Vector3` that the next frame
7
+ * overwrites. Storing such a reference means the stored schema silently changes
8
+ * underneath its owner, and `lodash.merge` assigns by reference whenever the
9
+ * target key is absent.
10
+ *
11
+ * This used to be `copyVec` at each call site in the gateway. It lives here
12
+ * because `EntityRegistry.write` is now the only way into a schema, so copying
13
+ * can happen once instead of being remembered every time.
14
+ *
15
+ * @param patch - The patch to sanitise.
16
+ */
17
+ export declare const copyVectors: <T extends PartialSchema>(patch: T) => T;
@@ -0,0 +1,29 @@
1
+ import { DIVESceneObject } from '../../../../../index.ts';
2
+ /**
3
+ * Draws the link from a group to one of its members, wherever the member is now.
4
+ *
5
+ * Grouping is a state-level idea: the engine only knows that some node holds a
6
+ * `MultiLineComponent`. So the knowledge that "a member gets a line from its
7
+ * parent's origin" lives here, and the line component stays a plain drawing
8
+ * primitive that watches nothing.
9
+ *
10
+ * Takes the **member**, not the group: it walks up to whatever the parent happens
11
+ * to be, so no caller has to know which group an object is in, or notice when
12
+ * that changes. Does nothing when the parent draws no lines, which is the normal
13
+ * case.
14
+ *
15
+ * Adding and moving are the same call, keyed by the member itself. The gateway
16
+ * used to keep a handle per member and had one method to add, one to remove and
17
+ * one to redraw — and the redraw had to be remembered at four call sites, where
18
+ * it was duly forgotten at one of them. There is nothing left to forget: a move
19
+ * arrives as `object-transform`, and this is idempotent.
20
+ *
21
+ * Only the drawing side lives here. Dropping a link is nobody's decision: the
22
+ * group hears `childremoved` and does it, which is set up where the line
23
+ * component is attached.
24
+ *
25
+ * @param sceneObject - The member whose link should be drawn.
26
+ *
27
+ * @module
28
+ */
29
+ export declare const updateParentLink: (sceneObject: DIVESceneObject) => void;
@@ -0,0 +1,30 @@
1
+ import { DIVESceneObject } from '../../../../../index.ts';
2
+ import { ActionDependencies, EntitySchema } from '../../../types/index.ts';
3
+ /**
4
+ * Listens to what a scene object reports about itself and records it.
5
+ *
6
+ * ### Why this reports instead of commanding
7
+ *
8
+ * An object's own report travels engine -> state. The state is the destination,
9
+ * not the source, so the report writes the schema and announces the change —
10
+ * it does not run an action. Running `UPDATE_OBJECT` here, as this code used to,
11
+ * meant sending a command back to the very object that had just moved: the
12
+ * position went out through `updateEntity` -> `setPosition` -> `worldToLocal`
13
+ * onto the node it came from, once per frame of a gizmo drag.
14
+ *
15
+ * Subscribers see no difference. `dispatch` is the same call `performAction`
16
+ * makes at the end, with the same payload under the same name, so
17
+ * `state.subscribe('UPDATE_OBJECT', …)` keeps receiving gizmo positions.
18
+ *
19
+ * The closure is the routing: the id comes from the entity that was just
20
+ * created, so nothing has to search for it later, and the engine never learns
21
+ * that any of this happens.
22
+ *
23
+ * @param node - The scene object to listen to.
24
+ * @param entity - The entity it stands for.
25
+ * @param deps - EntityRegistry to write, dispatch to announce.
26
+ * @returns Drops every listener again. Belongs in the registry entry.
27
+ *
28
+ * @module
29
+ */
30
+ export declare const watchEntity: (node: DIVESceneObject, entity: EntitySchema, { registry, dispatch }: Pick<ActionDependencies, "registry" | "dispatch">) => (() => void);
@@ -1,13 +1,28 @@
1
- import { DIVE, EntitySchema } from '../../../index.ts';
2
1
  import { OrbitController } from '../../orbitcontroller/index.ts';
2
+ import { EngineGateway } from '../src/EngineGateway.ts';
3
+ import { EntityRegistry } from '../src/EntityRegistry.ts';
3
4
  export type ActionPayload<T> = T extends new (payload: infer P, dependencies: infer D) => unknown ? P : never;
4
5
  export type ActionReturn<T> = T extends new (payload: infer P, dependencies: infer D) => infer ClassInstance ? ClassInstance extends {
5
6
  execute(): infer E;
6
7
  } ? E : never : never;
7
8
  export type ActionDeps<T> = T extends new (payload: unknown, dependencies: infer D) => unknown ? D extends Partial<ActionDependencies> ? D : never : never;
8
9
  export interface ActionDependencies {
9
- registered: Map<string, EntitySchema>;
10
- engine: DIVE;
10
+ /**
11
+ * Every entity the state holds: data, scene object, listener teardown.
12
+ *
13
+ * Handed out as an object rather than as a map, so that how an entity is
14
+ * stored stays the registry's business — and so `write` stays the only way
15
+ * into a schema, which is what makes the vector-copy rule enforceable.
16
+ */
17
+ registry: EntityRegistry;
18
+ /**
19
+ * Notifies subscribers without performing an action.
20
+ *
21
+ * This is what an engine-to-state report uses: the state already changed, so
22
+ * running a command would write it back into the engine it came from.
23
+ */
24
+ dispatch: <ActionType extends keyof ActionTypes>(type: ActionType, payload: ActionPayload<ActionTypes[ActionType]>) => void;
25
+ gateway: EngineGateway;
11
26
  controller: OrbitController;
12
27
  getAnimationSystem: () => Promise<import('../../animation/index.ts').AnimationSystem>;
13
28
  getARSystem: () => Promise<import('../../ar/index.ts').ARSystem>;