@shopware-ag/dive 3.1.0 → 4.0.1
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.
- package/README.md +31 -5
- package/build/chunks/{AssetCache-xpY_N7Yp.cjs → AssetCache-CUVFS7wk.cjs} +1 -1
- package/build/chunks/{AssetCache-C3YXhbaX.mjs → AssetCache-DnAAa719.mjs} +1 -1
- package/build/chunks/AssetExporter-CD2iuQce.mjs +108 -0
- package/build/chunks/AssetExporter-CoL-QXkB.cjs +1 -0
- package/build/chunks/{AssetLoader-MfH5d_Rr.mjs → AssetLoader-Bkp3fWZz.mjs} +9 -9
- package/build/chunks/{AssetLoader-CRxLq0AL.cjs → AssetLoader-DnVvCd41.cjs} +2 -2
- package/build/chunks/FileTypes-B-MjfMGd.cjs +29 -0
- package/build/chunks/FileTypes-D3Dxr2dj.mjs +2294 -0
- package/build/chunks/ModelComponent-Cmu0EX0r.cjs +1 -0
- package/build/chunks/ModelComponent-WA0kLOEY.mjs +87 -0
- package/build/chunks/OrbitController-CAJIiZeE.cjs +1 -0
- package/build/chunks/OrbitController-DxCbrQVB.mjs +612 -0
- package/build/chunks/SpriteTextComponent-BpoKLOjA.cjs +1 -0
- package/build/chunks/SpriteTextComponent-DIZFqao0.mjs +83 -0
- package/build/chunks/collectAnimations-BgYCN1le.mjs +35 -0
- package/build/chunks/collectAnimations-C3HfZHte.cjs +1 -0
- package/build/chunks/contributesToBounds-C1mva__U.cjs +1 -0
- package/build/chunks/contributesToBounds-DYmHYES4.mjs +14 -0
- package/build/chunks/detachTransformControls-B4iRF1bw.mjs +209 -0
- package/build/chunks/detachTransformControls-CZ2cd5hx.cjs +1 -0
- package/build/chunks/{isFileTypeSupported-BBU39V4u.cjs → isFileExtensionSupported-B1q2eWs7.cjs} +1 -1
- package/build/chunks/{isFileTypeSupported-9h8lrIuG.mjs → isFileExtensionSupported-BqOqU3-h.mjs} +1 -1
- package/build/chunks/isVisibleInHierarchy-D9JcLqR5.cjs +1 -0
- package/build/chunks/isVisibleInHierarchy-KzVGvDEw.mjs +21 -0
- package/build/components/boundingbox/BoundingBoxComponent.d.ts +100 -0
- package/build/components/boundingbox/index.d.ts +1 -0
- package/build/components/camera/CameraComponent.d.ts +75 -0
- package/build/components/camera/index.d.ts +2 -0
- package/build/components/camera/perspective/PerspectiveCameraComponent.d.ts +39 -0
- package/build/components/grid/GridComponent.d.ts +50 -0
- package/build/components/index.d.ts +6 -10
- package/build/components/light/LightComponent.d.ts +65 -0
- package/build/components/light/ambient/AmbientLightComponent.d.ts +10 -0
- package/build/components/light/directional/DirectionalLightComponent.d.ts +23 -0
- package/build/components/light/hemi/HemisphereLightComponent.d.ts +21 -0
- package/build/components/light/index.d.ts +5 -3
- package/build/components/light/point/PointLightComponent.d.ts +26 -0
- package/build/components/line/MultiLineComponent.d.ts +133 -0
- package/build/components/line/index.d.ts +1 -0
- package/build/components/mesh/MeshComponent.d.ts +74 -0
- package/build/components/mesh/floor/FloorComponent.d.ts +36 -0
- package/build/components/mesh/index.d.ts +4 -0
- package/build/components/mesh/model/ModelComponent.d.ts +67 -0
- package/build/components/mesh/primitive/PrimitiveComponent.d.ts +43 -0
- package/build/components/spritetext/SpriteTextComponent.d.ts +58 -0
- package/build/constants/VisibilityLayerMask.d.ts +23 -0
- package/build/dive.cjs +1 -1
- package/build/dive.mjs +252 -773
- package/build/engine/Dive.d.ts +11 -13
- package/build/engine/boundingbox/BoundingBox.d.ts +76 -0
- package/build/engine/component/Component.d.ts +236 -0
- package/build/engine/environment/Environment.d.ts +0 -18
- package/build/engine/index.d.ts +4 -1
- package/build/engine/node/Node.d.ts +189 -0
- package/build/engine/promise/abortable/AbortablePromise.d.ts +8 -0
- package/build/engine/renderer/Renderer.d.ts +43 -7
- package/build/engine/scene/Scene.d.ts +88 -4
- package/build/engine/scene/root/Root.d.ts +29 -0
- package/build/engine/scene/xrroot/XRRoot.d.ts +1 -1
- package/build/engine/view/View.d.ts +15 -4
- package/build/helpers/collectAnimations/collectAnimations.d.ts +23 -0
- package/build/helpers/computeProductBounds/computeProductBounds.d.ts +18 -0
- package/build/helpers/contributesToBounds/contributesToBounds.d.ts +17 -0
- package/build/helpers/detachTransformControls/detachTransformControls.d.ts +15 -0
- package/build/helpers/disposeComponents/disposeComponents.d.ts +20 -0
- package/build/helpers/findSceneRecursive/findSceneRecursive.d.ts +7 -3
- package/build/helpers/implementsInterface/implementsInterface.d.ts +11 -0
- package/build/helpers/index.d.ts +6 -1
- package/build/helpers/isVisibleInHierarchy/isVisibleInHierarchy.d.ts +12 -0
- package/build/index.d.ts +0 -1
- package/build/plugins/animation/index.mjs +3 -2
- package/build/plugins/animation/src/system/AnimationSystem.d.ts +3 -2
- package/build/plugins/ar/index.cjs +1 -1
- package/build/plugins/ar/index.mjs +2 -2
- package/build/plugins/ar/src/webxr/WebXR.d.ts +7 -0
- package/build/plugins/assetcache/index.cjs +1 -1
- package/build/plugins/assetcache/index.mjs +1 -1
- package/build/plugins/assetexporter/index.cjs +1 -1
- package/build/plugins/assetexporter/index.mjs +1 -1
- package/build/plugins/assetexporter/src/AssetExporter.d.ts +12 -0
- package/build/plugins/assetloader/index.cjs +1 -1
- package/build/plugins/assetloader/index.mjs +2 -2
- package/build/plugins/mediacreator/index.cjs +1 -1
- package/build/plugins/mediacreator/index.mjs +32 -30
- package/build/plugins/mediacreator/src/MediaCreator.d.ts +1 -2
- package/build/plugins/orbitcontroller/index.cjs +1 -1
- package/build/plugins/orbitcontroller/index.d.ts +1 -0
- package/build/plugins/orbitcontroller/index.mjs +1 -1
- package/build/plugins/orbitcontroller/src/OrbitController.d.ts +39 -6
- package/build/plugins/orientationdisplay/index.cjs +1 -1
- package/build/plugins/orientationdisplay/index.mjs +39 -31
- package/build/plugins/orientationdisplay/src/OrientationDisplay.d.ts +3 -3
- package/build/plugins/quickview/index.cjs +1 -1
- package/build/plugins/quickview/index.mjs +68 -45
- package/build/plugins/quickview/src/QuickView.d.ts +40 -13
- package/build/plugins/quickview/types/index.d.ts +0 -18
- package/build/plugins/state/index.cjs +1 -27
- package/build/plugins/state/index.mjs +1983 -4262
- package/build/plugins/state/src/EngineGateway.d.ts +98 -0
- package/build/plugins/state/src/EntityRegistry.d.ts +51 -0
- package/build/plugins/state/src/State.d.ts +20 -9
- package/build/plugins/state/src/actions/camera/computeencompassingview.d.ts +1 -1
- package/build/plugins/state/src/actions/camera/movecamera.d.ts +2 -2
- package/build/plugins/state/src/actions/media/generatemedia.d.ts +1 -1
- package/build/plugins/state/src/actions/object/addobject.d.ts +2 -3
- package/build/plugins/state/src/actions/object/deleteobject.d.ts +3 -4
- package/build/plugins/state/src/actions/object/deselectobject.d.ts +3 -4
- package/build/plugins/state/src/actions/object/dropit.d.ts +2 -2
- package/build/plugins/state/src/actions/object/getallobjects.d.ts +2 -3
- package/build/plugins/state/src/actions/object/getobjects.d.ts +3 -4
- package/build/plugins/state/src/actions/object/index.d.ts +0 -1
- package/build/plugins/state/src/actions/object/modelloaded.d.ts +2 -2
- package/build/plugins/state/src/actions/object/selectobject.d.ts +3 -4
- package/build/plugins/state/src/actions/object/setparent.d.ts +3 -4
- package/build/plugins/state/src/actions/object/updateobject.d.ts +3 -4
- package/build/plugins/state/src/actions/renderer/startrender.d.ts +1 -1
- package/build/plugins/state/src/actions/scene/exportscene.d.ts +2 -2
- package/build/plugins/state/src/actions/scene/index.d.ts +0 -1
- package/build/plugins/state/src/actions/scene/setbackground.d.ts +2 -2
- package/build/plugins/state/src/actions/scene/updatescene.d.ts +2 -2
- package/build/plugins/state/src/actions/state/getstate.d.ts +1 -1
- package/build/plugins/state/src/actions/state/setstate.d.ts +1 -1
- package/build/plugins/state/src/helpers/copyVectors/copyVectors.d.ts +17 -0
- package/build/plugins/state/src/helpers/updateParentLink/updateParentLink.d.ts +29 -0
- package/build/plugins/state/src/helpers/watchEntity/watchEntity.d.ts +30 -0
- package/build/plugins/state/types/ActionTypes.d.ts +18 -3
- package/build/plugins/state/types/RegisteredEntity.d.ts +27 -0
- package/build/plugins/state/types/StateData.d.ts +1 -1
- package/build/plugins/state/types/index.d.ts +2 -1
- package/build/{types → plugins/state/types}/schema/GroupSchema.d.ts +1 -1
- package/build/{types → plugins/state/types}/schema/ModelSchema.d.ts +7 -4
- package/build/{types → plugins/state/types}/schema/PrimitiveSchema.d.ts +4 -5
- package/build/{types → plugins/state/types}/schema/index.d.ts +0 -3
- package/build/plugins/toolbox/index.cjs +1 -1
- package/build/plugins/toolbox/index.mjs +193 -140
- package/build/plugins/toolbox/src/PointerContext.d.ts +7 -0
- package/build/plugins/toolbox/src/SelectionState.d.ts +21 -0
- package/build/plugins/toolbox/src/Toolbox.d.ts +9 -2
- package/build/{components → plugins/toolbox/src}/gizmo/Gizmo.d.ts +16 -2
- package/build/{components → plugins/toolbox/src}/gizmo/handles/AxisHandle.d.ts +2 -3
- package/build/{components → plugins/toolbox/src}/gizmo/handles/RadialHandle.d.ts +2 -3
- package/build/{components → plugins/toolbox/src}/gizmo/handles/ScaleHandle.d.ts +2 -3
- package/build/{components → plugins/toolbox/src}/gizmo/rotate/RotateGizmo.d.ts +2 -2
- package/build/{components → plugins/toolbox/src}/gizmo/scale/ScaleGizmo.d.ts +3 -3
- package/build/{components → plugins/toolbox/src}/gizmo/translate/TranslateGizmo.d.ts +2 -2
- package/build/types/components/DIVESceneObject.d.ts +13 -6
- package/build/types/components/index.d.ts +0 -1
- package/build/types/events/DIVEComponentEventMap.d.ts +14 -0
- package/build/types/events/DIVEEntityEventMap.d.ts +47 -0
- package/build/types/events/index.d.ts +2 -0
- package/build/types/{schema/GeometrySchema.d.ts → geometry/DIVEGeometry.d.ts} +4 -4
- package/build/types/{schema/GeometryTypeSchema.d.ts → geometry/DIVEGeometryType.d.ts} +1 -1
- package/build/types/geometry/index.d.ts +2 -0
- package/build/types/index.d.ts +3 -1
- package/build/types/{schema/MaterialSchema.d.ts → material/DIVEMaterial.d.ts} +1 -1
- package/build/types/material/index.d.ts +1 -0
- package/package.json +6 -5
- package/build/chunks/AssetExporter-C5MScs9S.mjs +0 -70
- package/build/chunks/AssetExporter-Cdxb04b3.cjs +0 -1
- package/build/chunks/CameraSchema-cgY5WBGW.mjs +0 -10
- package/build/chunks/CameraSchema-twxH-72N.cjs +0 -1
- package/build/chunks/FileTypes-Cgyf8ocm.cjs +0 -29
- package/build/chunks/FileTypes-DiYB3WBp.mjs +0 -2166
- package/build/chunks/PerspectiveCamera-B5TvUzTa.mjs +0 -39
- package/build/chunks/PerspectiveCamera-DwQUmkDv.cjs +0 -1
- package/build/chunks/SpriteText-2lCRglsw.cjs +0 -1
- package/build/chunks/SpriteText-C_CQPvUn.mjs +0 -50
- package/build/chunks/findInterface-C6mrvf_t.cjs +0 -1
- package/build/chunks/findInterface-DbJ5qzbc.mjs +0 -11
- package/build/components/boundingbox/BoundingBox.d.ts +0 -140
- package/build/components/floor/Floor.d.ts +0 -14
- package/build/components/grid/Grid.d.ts +0 -23
- package/build/components/group/Group.d.ts +0 -28
- package/build/components/light/AmbientLight.d.ts +0 -19
- package/build/components/light/PointLight.d.ts +0 -29
- package/build/components/light/SceneLight.d.ts +0 -20
- package/build/components/model/Model.d.ts +0 -26
- package/build/components/node/Node.d.ts +0 -24
- package/build/components/primitive/Primitive.d.ts +0 -27
- package/build/components/root/Root.d.ts +0 -34
- package/build/components/spritetext/SpriteText.d.ts +0 -27
- package/build/engine/camera/PerspectiveCamera.d.ts +0 -24
- package/build/helpers/isFileTypeSupported/isFileTypeSupported.d.ts +0 -9
- package/build/plugins/quickview/src/state/QuickViewState.d.ts +0 -4
- package/build/plugins/quickview/src/uri/QuickViewUri.d.ts +0 -3
- package/build/plugins/state/src/actions/object/placeonfloor.d.ts +0 -12
- package/build/plugins/state/src/actions/scene/getallscenedata.d.ts +0 -12
- package/build/plugins/state/types/StateSceneData.d.ts +0 -5
- package/build/types/components/DIVELight.d.ts +0 -4
- /package/build/{types → plugins/state/types}/schema/BaseEntitySchema.d.ts +0 -0
- /package/build/{types → plugins/state/types}/schema/CameraSchema.d.ts +0 -0
- /package/build/{types → plugins/state/types}/schema/EntitySchema.d.ts +0 -0
- /package/build/{types → plugins/state/types}/schema/EntityTypeSchema.d.ts +0 -0
- /package/build/{types → plugins/state/types}/schema/LightSchema.d.ts +0 -0
- /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
|
-
|
|
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
|
-
|
|
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, "
|
|
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, "
|
|
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, "
|
|
22
|
+
}, Pick<ActionDependencies, "registry" | "gateway" | "controller" | "getAnimationSystem">, Promise<{
|
|
23
23
|
stop: () => void;
|
|
24
24
|
}>>;
|
|
25
25
|
declare global {
|
|
@@ -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, "
|
|
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
|
-
|
|
4
|
-
export declare const AddObjectAction: new (payload: EntitySchema, dependencies: Pick<ActionDependencies, "registered" | "engine">) => Action<EntitySchema, Pick<ActionDependencies, "registered" | "engine">, Promise<import('../../../../../index.ts').DIVEModel | import('../../../../../index.ts').DIVEGroup | import('../../../../../index.ts').DIVEPrimitive | import('../../../../../index.ts').DIVELight | undefined>>;
|
|
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, "
|
|
5
|
+
}, dependencies: Pick<ActionDependencies, "registry" | "gateway">) => Action<Partial<EntitySchema> & {
|
|
7
6
|
id: string;
|
|
8
|
-
}, Pick<ActionDependencies, "
|
|
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, "
|
|
5
|
+
}, dependencies: Pick<ActionDependencies, "registry" | "getToolbox">) => Action<Partial<EntitySchema> & {
|
|
7
6
|
id: string;
|
|
8
|
-
}, Pick<ActionDependencies, "
|
|
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, "
|
|
5
|
+
}, dependencies: Pick<ActionDependencies, "registry">) => Action<{
|
|
6
6
|
id: string;
|
|
7
|
-
}, Pick<ActionDependencies, "
|
|
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
|
-
|
|
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, "
|
|
5
|
+
}, dependencies: Pick<ActionDependencies, "registry" | "gateway">) => Action<{
|
|
7
6
|
ids: string[];
|
|
8
|
-
}, Pick<ActionDependencies, "
|
|
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, "
|
|
5
|
+
}, dependencies: Pick<ActionDependencies, "registry">) => Action<{
|
|
6
6
|
id: string;
|
|
7
|
-
}, Pick<ActionDependencies, "
|
|
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, "
|
|
5
|
+
}, dependencies: Pick<ActionDependencies, "registry" | "getToolbox">) => Action<Partial<EntitySchema> & {
|
|
7
6
|
id: string;
|
|
8
|
-
}, Pick<ActionDependencies, "
|
|
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, "
|
|
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, "
|
|
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, "
|
|
5
|
+
}, dependencies: Pick<ActionDependencies, "registry" | "gateway">) => Action<Partial<EntitySchema> & {
|
|
7
6
|
id: string;
|
|
8
|
-
}, Pick<ActionDependencies, "
|
|
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, "
|
|
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, "
|
|
6
|
+
}, dependencies: Pick<ActionDependencies, "gateway" | "getAssetExporter">) => Action<{
|
|
7
7
|
type: keyof StateExportFileType;
|
|
8
|
-
}, Pick<ActionDependencies, "
|
|
8
|
+
}, Pick<ActionDependencies, "gateway" | "getAssetExporter">, Promise<ArrayBuffer | null>>;
|
|
9
9
|
declare global {
|
|
10
10
|
interface ActionTypes {
|
|
11
11
|
EXPORT_SCENE: typeof ExportSceneAction;
|
|
@@ -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, "
|
|
5
|
+
}, dependencies: Pick<ActionDependencies, "gateway">) => Action<{
|
|
6
6
|
color: string | number;
|
|
7
|
-
}, Pick<ActionDependencies, "
|
|
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, "
|
|
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, "
|
|
15
|
+
}>, Pick<ActionDependencies, "gateway">, void>;
|
|
16
16
|
declare global {
|
|
17
17
|
interface ActionTypes {
|
|
18
18
|
UPDATE_SCENE: typeof UpdateSceneAction;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Action } from '../action.ts';
|
|
2
2
|
import { ActionDependencies, StateData } from '../../../types/index.ts';
|
|
3
|
-
export declare const GetStateAction: new (payload: void, dependencies: Pick<ActionDependencies, "
|
|
3
|
+
export declare const GetStateAction: new (payload: void, dependencies: Pick<ActionDependencies, "registry" | "gateway" | "controller">) => Action<void, Pick<ActionDependencies, "registry" | "gateway" | "controller">, StateData>;
|
|
4
4
|
declare global {
|
|
5
5
|
interface ActionTypes {
|
|
6
6
|
GET_STATE: typeof GetStateAction;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Action } from '../action.ts';
|
|
2
2
|
import { ActionDependencies, StateData } from '../../../types/index.ts';
|
|
3
|
-
export declare const SetStateAction: new (payload: StateData, dependencies: Pick<ActionDependencies, "
|
|
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
4
|
declare global {
|
|
5
5
|
interface ActionTypes {
|
|
6
6
|
SET_STATE: typeof SetStateAction;
|
|
@@ -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
|
-
|
|
10
|
-
|
|
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>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { DIVESceneObject } from '../../../index.ts';
|
|
2
|
+
import { EntitySchema } from './schema/index.ts';
|
|
3
|
+
/**
|
|
4
|
+
* One entity, as the state holds it: its data, the node representing it, and the
|
|
5
|
+
* teardown for the listeners attached to that node.
|
|
6
|
+
*
|
|
7
|
+
* Kept together on purpose. All three share an id, a lifetime and every state
|
|
8
|
+
* change, so splitting them across separate maps only created the chance for
|
|
9
|
+
* them to drift apart — and made every caller that needed two of them do two
|
|
10
|
+
* lookups.
|
|
11
|
+
*
|
|
12
|
+
* This shape is a state-internal detail. Actions reach it through
|
|
13
|
+
* {@link EntityRegistry}, never through the map, so it can change without
|
|
14
|
+
* touching them.
|
|
15
|
+
*
|
|
16
|
+
* @module
|
|
17
|
+
*/
|
|
18
|
+
export type RegisteredEntity = {
|
|
19
|
+
schema: EntitySchema;
|
|
20
|
+
/**
|
|
21
|
+
* Absent for a state-only entity. A camera has a position and a target, but
|
|
22
|
+
* nothing in the scene tree.
|
|
23
|
+
*/
|
|
24
|
+
node?: DIVESceneObject;
|
|
25
|
+
/** Drops the listeners on {@link node}. Called by `EntityRegistry.unregister`. */
|
|
26
|
+
unwatch?: () => void;
|
|
27
|
+
};
|