@relu-interactives/spatial-ecs 0.2.21 → 0.2.22

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 (50) hide show
  1. package/dist/{System-me3iAcMF.d.cts → System-CYWZ_Zx5.d.cts} +4 -3
  2. package/dist/{System-me3iAcMF.d.ts → System-CYWZ_Zx5.d.ts} +4 -3
  3. package/dist/{Video-DHnxjGhW.d.ts → Video-C1IOat7L.d.ts} +38 -9
  4. package/dist/{Video-U9hAnf9y.d.cts → Video-ppAXaKt0.d.cts} +38 -9
  5. package/dist/{chunk-K6KMKKJ6.js → chunk-52CHDPRQ.js} +118 -92
  6. package/dist/chunk-52CHDPRQ.js.map +1 -0
  7. package/dist/{chunk-5U3YS4JD.js → chunk-GZ2NKSMV.js} +421 -65
  8. package/dist/chunk-GZ2NKSMV.js.map +1 -0
  9. package/dist/{chunk-V7BNVTJW.js → chunk-JHCPRVBC.js} +25 -4
  10. package/dist/chunk-JHCPRVBC.js.map +1 -0
  11. package/dist/{chunk-AXRCGF63.js → chunk-WKGCC7YL.js} +3 -3
  12. package/dist/{chunk-AXRCGF63.js.map → chunk-WKGCC7YL.js.map} +1 -1
  13. package/dist/components/index.cjs +22 -1
  14. package/dist/components/index.cjs.map +1 -1
  15. package/dist/components/index.d.cts +3 -3
  16. package/dist/components/index.d.ts +3 -3
  17. package/dist/components/index.js +1 -1
  18. package/dist/docs/guide/authoring-a-behaviour.md +3 -40
  19. package/dist/docs/guide/authoring-a-script-object.md +102 -0
  20. package/dist/docs/guide/behaviour-lifecycle.md +4 -4
  21. package/dist/docs/guide/spawning/script-object.md +36 -0
  22. package/dist/docs/guide/systems/_sidebar.json +4 -0
  23. package/dist/docs/guide/systems/script-behaviour-system.md +1 -17
  24. package/dist/docs/guide/systems/script-object-system.md +44 -0
  25. package/dist/factories/index.cjs +164 -117
  26. package/dist/factories/index.cjs.map +1 -1
  27. package/dist/factories/index.d.cts +5 -3
  28. package/dist/factories/index.d.ts +5 -3
  29. package/dist/factories/index.js +3 -3
  30. package/dist/{index-D7FSg0Au.d.ts → index-Cu2Pt7wN.d.cts} +6 -3
  31. package/dist/{index-CZo5I5Gs.d.cts → index-DdiWu1b6.d.ts} +6 -3
  32. package/dist/index.cjs +677 -265
  33. package/dist/index.cjs.map +1 -1
  34. package/dist/index.d.cts +117 -28
  35. package/dist/index.d.ts +117 -28
  36. package/dist/index.js +13 -8
  37. package/dist/index.js.map +1 -1
  38. package/dist/systems/index.cjs +403 -36
  39. package/dist/systems/index.cjs.map +1 -1
  40. package/dist/systems/index.d.cts +44 -3
  41. package/dist/systems/index.d.ts +44 -3
  42. package/dist/systems/index.js +3 -3
  43. package/dist/types.d.cts +1 -1
  44. package/dist/types.d.ts +1 -1
  45. package/dist/worldSnapshotUtils.d.cts +1 -1
  46. package/dist/worldSnapshotUtils.d.ts +1 -1
  47. package/package.json +1 -1
  48. package/dist/chunk-5U3YS4JD.js.map +0 -1
  49. package/dist/chunk-K6KMKKJ6.js.map +0 -1
  50. package/dist/chunk-V7BNVTJW.js.map +0 -1
@@ -1,5 +1,5 @@
1
- import { k as EcsSystem, l as World } from '../System-me3iAcMF.cjs';
2
- export { v as ComponentFactory, B as EcsComponentFactoryKind, I as InputSystem, K as KeyboardKey, L as KeyboardKeys, M as MouseButton, O as ObjectManagementSystem, X as RenderSystem, a0 as TransformSyncSystem } from '../System-me3iAcMF.cjs';
1
+ import { k as EcsSystem, l as World } from '../System-CYWZ_Zx5.cjs';
2
+ export { v as ComponentFactory, B as EcsComponentFactoryKind, I as InputSystem, K as KeyboardKey, L as KeyboardKeys, M as MouseButton, O as ObjectManagementSystem, X as RenderSystem, a0 as TransformSyncSystem } from '../System-CYWZ_Zx5.cjs';
3
3
  import * as THREE from 'three';
4
4
  import '@dimforge/rapier3d-compat';
5
5
 
@@ -122,7 +122,15 @@ declare class InstancedMeshSystem implements EcsSystem {
122
122
  update(world: World): void;
123
123
  }
124
124
 
125
+ /**
126
+ * Shared infrastructure for the script-hosting systems (`ScriptBehaviourSystem`
127
+ * and `ScriptObjectSystem`): module loading, class resolution, data-envelope
128
+ * merge/resolve/serialize. Extracted verbatim from `ScriptBehaviourSystem` so
129
+ * both systems stay behaviourally identical for the parts they share.
130
+ */
131
+ /** Resolves a script URL to its ES module namespace. */
125
132
  type ModuleLoader = (scriptUrl: string) => Promise<Record<string, unknown>>;
133
+
126
134
  /**
127
135
  * Optional context that enables raycast-based onSelect / onDeselect dispatch.
128
136
  * When provided, pointer/touch taps on the canvas fire a raycast against the
@@ -166,6 +174,39 @@ declare class ScriptBehaviourSystem implements EcsSystem {
166
174
  private loadBehaviour;
167
175
  }
168
176
 
177
+ /** Tags the Object3D a script's `build()` returned, so reloads can find/remove it. */
178
+ declare const SCRIPT_OBJECT_ROOT_FLAG = "__scriptObjectRoot";
179
+ /**
180
+ * Builds, ticks, and disposes {@link ScriptObject} scripts. Unlike
181
+ * `ScriptBehaviourSystem`, this runs in the editor AND at runtime — there is NO
182
+ * `isEditorMode` gating anywhere here. A script's `build()` output is attached
183
+ * under the entity's `Object3DRef.object` (so it inherits transform, selection
184
+ * and visibility). `runtimeState` is written on transitions only (never every
185
+ * frame).
186
+ *
187
+ * Construct it and pass it to `World.setup({ systems })`.
188
+ *
189
+ * @category Systems
190
+ */
191
+ declare class ScriptObjectSystem implements EcsSystem {
192
+ private readonly moduleLoader;
193
+ private instances;
194
+ private loading;
195
+ /** Bumped by invalidate*() so in-flight loads that predate it are discarded. */
196
+ private epoch;
197
+ constructor(moduleLoader?: ModuleLoader);
198
+ update(world: World, deltaTime: number): void;
199
+ private loadScriptObject;
200
+ /** Dispose a record's instance + built subtree. `keepTombstone` leaves an error marker. */
201
+ private teardownRecord;
202
+ private markError;
203
+ /** Dispose all live instances so the next update() reloads with fresh modules. */
204
+ invalidateAll(): void;
205
+ /** Invalidate only the entities whose script matches `scriptUrl`. */
206
+ invalidate(scriptUrl: string): void;
207
+ dispose(world: World): void;
208
+ }
209
+
169
210
  /**
170
211
  * Reconciles `AudioComponent` state with the underlying THREE.js audio objects
171
212
  * each frame.
@@ -235,4 +276,4 @@ declare class VideoSystem implements EcsSystem {
235
276
  dispose(_world: World): void;
236
277
  }
237
278
 
238
- export { AnimationSystem, AudioSystem, CameraSyncSystem, EnvironmentSyncSystem, InstancedMeshSystem, LightSyncSystem, MaterialSyncSystem, MeshGeometrySystem, ObjectVisibilitySystem, PhysicsSyncSystem, PostprocessingSyncSystem, ScriptBehaviourSystem, type SelectionContext, VideoSystem };
279
+ export { AnimationSystem, AudioSystem, CameraSyncSystem, EnvironmentSyncSystem, InstancedMeshSystem, LightSyncSystem, MaterialSyncSystem, MeshGeometrySystem, type ModuleLoader, ObjectVisibilitySystem, PhysicsSyncSystem, PostprocessingSyncSystem, SCRIPT_OBJECT_ROOT_FLAG, ScriptBehaviourSystem, ScriptObjectSystem, type SelectionContext, VideoSystem };
@@ -1,5 +1,5 @@
1
- import { k as EcsSystem, l as World } from '../System-me3iAcMF.js';
2
- export { v as ComponentFactory, B as EcsComponentFactoryKind, I as InputSystem, K as KeyboardKey, L as KeyboardKeys, M as MouseButton, O as ObjectManagementSystem, X as RenderSystem, a0 as TransformSyncSystem } from '../System-me3iAcMF.js';
1
+ import { k as EcsSystem, l as World } from '../System-CYWZ_Zx5.js';
2
+ export { v as ComponentFactory, B as EcsComponentFactoryKind, I as InputSystem, K as KeyboardKey, L as KeyboardKeys, M as MouseButton, O as ObjectManagementSystem, X as RenderSystem, a0 as TransformSyncSystem } from '../System-CYWZ_Zx5.js';
3
3
  import * as THREE from 'three';
4
4
  import '@dimforge/rapier3d-compat';
5
5
 
@@ -122,7 +122,15 @@ declare class InstancedMeshSystem implements EcsSystem {
122
122
  update(world: World): void;
123
123
  }
124
124
 
125
+ /**
126
+ * Shared infrastructure for the script-hosting systems (`ScriptBehaviourSystem`
127
+ * and `ScriptObjectSystem`): module loading, class resolution, data-envelope
128
+ * merge/resolve/serialize. Extracted verbatim from `ScriptBehaviourSystem` so
129
+ * both systems stay behaviourally identical for the parts they share.
130
+ */
131
+ /** Resolves a script URL to its ES module namespace. */
125
132
  type ModuleLoader = (scriptUrl: string) => Promise<Record<string, unknown>>;
133
+
126
134
  /**
127
135
  * Optional context that enables raycast-based onSelect / onDeselect dispatch.
128
136
  * When provided, pointer/touch taps on the canvas fire a raycast against the
@@ -166,6 +174,39 @@ declare class ScriptBehaviourSystem implements EcsSystem {
166
174
  private loadBehaviour;
167
175
  }
168
176
 
177
+ /** Tags the Object3D a script's `build()` returned, so reloads can find/remove it. */
178
+ declare const SCRIPT_OBJECT_ROOT_FLAG = "__scriptObjectRoot";
179
+ /**
180
+ * Builds, ticks, and disposes {@link ScriptObject} scripts. Unlike
181
+ * `ScriptBehaviourSystem`, this runs in the editor AND at runtime — there is NO
182
+ * `isEditorMode` gating anywhere here. A script's `build()` output is attached
183
+ * under the entity's `Object3DRef.object` (so it inherits transform, selection
184
+ * and visibility). `runtimeState` is written on transitions only (never every
185
+ * frame).
186
+ *
187
+ * Construct it and pass it to `World.setup({ systems })`.
188
+ *
189
+ * @category Systems
190
+ */
191
+ declare class ScriptObjectSystem implements EcsSystem {
192
+ private readonly moduleLoader;
193
+ private instances;
194
+ private loading;
195
+ /** Bumped by invalidate*() so in-flight loads that predate it are discarded. */
196
+ private epoch;
197
+ constructor(moduleLoader?: ModuleLoader);
198
+ update(world: World, deltaTime: number): void;
199
+ private loadScriptObject;
200
+ /** Dispose a record's instance + built subtree. `keepTombstone` leaves an error marker. */
201
+ private teardownRecord;
202
+ private markError;
203
+ /** Dispose all live instances so the next update() reloads with fresh modules. */
204
+ invalidateAll(): void;
205
+ /** Invalidate only the entities whose script matches `scriptUrl`. */
206
+ invalidate(scriptUrl: string): void;
207
+ dispose(world: World): void;
208
+ }
209
+
169
210
  /**
170
211
  * Reconciles `AudioComponent` state with the underlying THREE.js audio objects
171
212
  * each frame.
@@ -235,4 +276,4 @@ declare class VideoSystem implements EcsSystem {
235
276
  dispose(_world: World): void;
236
277
  }
237
278
 
238
- export { AnimationSystem, AudioSystem, CameraSyncSystem, EnvironmentSyncSystem, InstancedMeshSystem, LightSyncSystem, MaterialSyncSystem, MeshGeometrySystem, ObjectVisibilitySystem, PhysicsSyncSystem, PostprocessingSyncSystem, ScriptBehaviourSystem, type SelectionContext, VideoSystem };
279
+ export { AnimationSystem, AudioSystem, CameraSyncSystem, EnvironmentSyncSystem, InstancedMeshSystem, LightSyncSystem, MaterialSyncSystem, MeshGeometrySystem, type ModuleLoader, ObjectVisibilitySystem, PhysicsSyncSystem, PostprocessingSyncSystem, SCRIPT_OBJECT_ROOT_FLAG, ScriptBehaviourSystem, ScriptObjectSystem, type SelectionContext, VideoSystem };
@@ -1,6 +1,6 @@
1
- export { AnimationSystem, AudioSystem, CameraSyncSystem, EnvironmentSyncSystem, InputSystem, InstancedMeshSystem, KeyboardKeys, LightSyncSystem, MaterialSyncSystem, MeshGeometrySystem, ObjectVisibilitySystem, PhysicsSyncSystem, PostprocessingSyncSystem, RenderSystem, ScriptBehaviourSystem, TransformSyncSystem, VideoSystem } from '../chunk-5U3YS4JD.js';
2
- export { ObjectManagementSystem } from '../chunk-AXRCGF63.js';
3
- import '../chunk-V7BNVTJW.js';
1
+ export { AnimationSystem, AudioSystem, CameraSyncSystem, EnvironmentSyncSystem, InputSystem, InstancedMeshSystem, KeyboardKeys, LightSyncSystem, MaterialSyncSystem, MeshGeometrySystem, ObjectVisibilitySystem, PhysicsSyncSystem, PostprocessingSyncSystem, RenderSystem, SCRIPT_OBJECT_ROOT_FLAG, ScriptBehaviourSystem, ScriptObjectSystem, TransformSyncSystem, VideoSystem } from '../chunk-GZ2NKSMV.js';
2
+ export { ObjectManagementSystem } from '../chunk-WKGCC7YL.js';
3
+ import '../chunk-JHCPRVBC.js';
4
4
  import '../chunk-OY7ZODZP.js';
5
5
  //# sourceMappingURL=index.js.map
6
6
  //# sourceMappingURL=index.js.map
package/dist/types.d.cts CHANGED
@@ -1,3 +1,3 @@
1
1
  import 'three';
2
- export { A as AssetInput, t as CheckboxInput, u as ColorInput, w as ComponentInput, x as ComponentKind, y as DropdownInput, z as DropdownOption, F as EcsEntityEditorKind, p as EcsEntityKind, r as EntityId, G as EntityInput, H as FloatInput, J as IntersectionResult, o as ParentLookup, Y as SelectionListener, Z as SliderInput, _ as TextInput, $ as ToggleInput, a1 as Vec3, a2 as Vector2Input, a3 as Vector3Input, W as WorldEntityView } from './System-me3iAcMF.cjs';
2
+ export { A as AssetInput, t as CheckboxInput, u as ColorInput, w as ComponentInput, x as ComponentKind, y as DropdownInput, z as DropdownOption, F as EcsEntityEditorKind, p as EcsEntityKind, r as EntityId, G as EntityInput, H as FloatInput, J as IntersectionResult, o as ParentLookup, Y as SelectionListener, Z as SliderInput, _ as TextInput, $ as ToggleInput, a1 as Vec3, a2 as Vector2Input, a3 as Vector3Input, W as WorldEntityView } from './System-CYWZ_Zx5.cjs';
3
3
  import '@dimforge/rapier3d-compat';
package/dist/types.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  import 'three';
2
- export { A as AssetInput, t as CheckboxInput, u as ColorInput, w as ComponentInput, x as ComponentKind, y as DropdownInput, z as DropdownOption, F as EcsEntityEditorKind, p as EcsEntityKind, r as EntityId, G as EntityInput, H as FloatInput, J as IntersectionResult, o as ParentLookup, Y as SelectionListener, Z as SliderInput, _ as TextInput, $ as ToggleInput, a1 as Vec3, a2 as Vector2Input, a3 as Vector3Input, W as WorldEntityView } from './System-me3iAcMF.js';
2
+ export { A as AssetInput, t as CheckboxInput, u as ColorInput, w as ComponentInput, x as ComponentKind, y as DropdownInput, z as DropdownOption, F as EcsEntityEditorKind, p as EcsEntityKind, r as EntityId, G as EntityInput, H as FloatInput, J as IntersectionResult, o as ParentLookup, Y as SelectionListener, Z as SliderInput, _ as TextInput, $ as ToggleInput, a1 as Vec3, a2 as Vector2Input, a3 as Vector3Input, W as WorldEntityView } from './System-CYWZ_Zx5.js';
3
3
  import '@dimforge/rapier3d-compat';
@@ -1,3 +1,3 @@
1
- export { ac as AnyComponent, n as ComponentClass, ad as DEBUG_CHANGE_IGNORED_SYSTEMS, ae as WorldHistorySnapshot, af as cloneHistoryValue, ag as normalizeDebugValue } from './System-me3iAcMF.cjs';
1
+ export { ac as AnyComponent, n as ComponentClass, ad as DEBUG_CHANGE_IGNORED_SYSTEMS, ae as WorldHistorySnapshot, af as cloneHistoryValue, ag as normalizeDebugValue } from './System-CYWZ_Zx5.cjs';
2
2
  import 'three';
3
3
  import '@dimforge/rapier3d-compat';
@@ -1,3 +1,3 @@
1
- export { ac as AnyComponent, n as ComponentClass, ad as DEBUG_CHANGE_IGNORED_SYSTEMS, ae as WorldHistorySnapshot, af as cloneHistoryValue, ag as normalizeDebugValue } from './System-me3iAcMF.js';
1
+ export { ac as AnyComponent, n as ComponentClass, ad as DEBUG_CHANGE_IGNORED_SYSTEMS, ae as WorldHistorySnapshot, af as cloneHistoryValue, ag as normalizeDebugValue } from './System-CYWZ_Zx5.js';
2
2
  import 'three';
3
3
  import '@dimforge/rapier3d-compat';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@relu-interactives/spatial-ecs",
3
- "version": "0.2.21",
3
+ "version": "0.2.22",
4
4
  "description": "Reusable ECS core engine for Relu Spatial editor and runtime experiences.",
5
5
  "license": "MIT",
6
6
  "private": false,