@relu-interactives/spatial-ecs 0.3.20 → 0.4.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 (77) hide show
  1. package/dist/{System-BhnLw0fZ.d.cts → System-QjjSc6LZ.d.cts} +14 -0
  2. package/dist/{System-BhnLw0fZ.d.ts → System-QjjSc6LZ.d.ts} +14 -0
  3. package/dist/{XRHandPose-CLl4MiHx.d.cts → XRHandPose-Capx-RTD.d.cts} +47 -2
  4. package/dist/{XRHandPose-CrzI57JA.d.ts → XRHandPose-Csd3QGkj.d.ts} +47 -2
  5. package/dist/{chunk-CDSE7476.js → chunk-24ZMSBR7.js} +540 -5
  6. package/dist/chunk-24ZMSBR7.js.map +1 -0
  7. package/dist/{chunk-D6KXWNYT.js → chunk-2GTFFLGG.js} +3 -3
  8. package/dist/{chunk-D6KXWNYT.js.map → chunk-2GTFFLGG.js.map} +1 -1
  9. package/dist/{chunk-P42OE3RU.js → chunk-OWQPGEBB.js} +4 -4
  10. package/dist/{chunk-P42OE3RU.js.map → chunk-OWQPGEBB.js.map} +1 -1
  11. package/dist/{chunk-H6DQ7JRE.js → chunk-ZWONFM2F.js} +33 -3
  12. package/dist/chunk-ZWONFM2F.js.map +1 -0
  13. package/dist/components/index.cjs +30 -0
  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/accessing-components.md +7 -6
  19. package/dist/docs/guide/behaviour-data-binding/component-input.md +10 -6
  20. package/dist/docs/guide/behaviour-data-binding/entity-input.md +13 -5
  21. package/dist/docs/guide/camera-rigs.md +2 -2
  22. package/dist/docs/guide/components/animation.md +12 -5
  23. package/dist/docs/guide/components/audio.md +13 -6
  24. package/dist/docs/guide/components/camera.md +10 -4
  25. package/dist/docs/guide/components/entity-type.md +13 -6
  26. package/dist/docs/guide/components/image-target-anchor.md +6 -2
  27. package/dist/docs/guide/components/image-target.md +10 -5
  28. package/dist/docs/guide/components/image.md +10 -4
  29. package/dist/docs/guide/components/instance-slot.md +7 -3
  30. package/dist/docs/guide/components/instanced-mesh.md +15 -7
  31. package/dist/docs/guide/components/light.md +10 -4
  32. package/dist/docs/guide/components/material.md +14 -8
  33. package/dist/docs/guide/components/mesh-geometry.md +10 -4
  34. package/dist/docs/guide/components/mesh.md +10 -4
  35. package/dist/docs/guide/components/model.md +4 -2
  36. package/dist/docs/guide/components/name.md +11 -6
  37. package/dist/docs/guide/components/object3d-ref.md +7 -3
  38. package/dist/docs/guide/components/parent-id.md +10 -4
  39. package/dist/docs/guide/components/physics.md +12 -6
  40. package/dist/docs/guide/components/script.md +10 -4
  41. package/dist/docs/guide/components/sprite.md +10 -4
  42. package/dist/docs/guide/components/transform.md +6 -2
  43. package/dist/docs/guide/components/video.md +10 -4
  44. package/dist/docs/guide/prefabs.md +2 -0
  45. package/dist/docs/guide/runtime-entity-management.md +1 -1
  46. package/dist/docs/guide/spawning/instanced-mesh.md +11 -6
  47. package/dist/docs/guide/systems/input-system.md +4 -1
  48. package/dist/docs/guide/systems/script-object-system.md +9 -1
  49. package/dist/docs/guide/vr-and-hand-poses.md +7 -3
  50. package/dist/docs/guide/world-api.md +23 -15
  51. package/dist/factories/index.cjs +6 -0
  52. package/dist/factories/index.cjs.map +1 -1
  53. package/dist/factories/index.d.cts +2 -2
  54. package/dist/factories/index.d.ts +2 -2
  55. package/dist/factories/index.js +3 -3
  56. package/dist/{index-6l4hn2Sh.d.ts → index-BAeeVJ6f.d.ts} +94 -2
  57. package/dist/{index-g777AmFv.d.cts → index-BRATaqTT.d.ts} +78 -4
  58. package/dist/{index-JRcoel9F.d.ts → index-C1rprGz_.d.cts} +78 -4
  59. package/dist/{index-C2I5PxCI.d.cts → index-SC9Mgjht.d.cts} +94 -2
  60. package/dist/index.cjs +586 -0
  61. package/dist/index.cjs.map +1 -1
  62. package/dist/index.d.cts +7 -7
  63. package/dist/index.d.ts +7 -7
  64. package/dist/index.js +26 -8
  65. package/dist/index.js.map +1 -1
  66. package/dist/systems/index.cjs +566 -0
  67. package/dist/systems/index.cjs.map +1 -1
  68. package/dist/systems/index.d.cts +2 -2
  69. package/dist/systems/index.d.ts +2 -2
  70. package/dist/systems/index.js +3 -3
  71. package/dist/types.d.cts +1 -1
  72. package/dist/types.d.ts +1 -1
  73. package/dist/worldSnapshotUtils.d.cts +1 -1
  74. package/dist/worldSnapshotUtils.d.ts +1 -1
  75. package/package.json +4 -2
  76. package/dist/chunk-CDSE7476.js.map +0 -1
  77. package/dist/chunk-H6DQ7JRE.js.map +0 -1
@@ -149,12 +149,15 @@ Toggle visibility on Space, fire on left-click.
149
149
 
150
150
  ```ts
151
151
  import { KeyboardKeys, Behaviour } from "@relu-interactives/spatial-ecs";
152
+ import { Object3DRef } from "@relu-interactives/spatial-ecs/components";
152
153
 
153
154
  export default class ActionHandler extends Behaviour {
154
155
  protected onUpdate() {
155
156
  // getKeyDown fires only on the first frame the key is pressed.
156
157
  if (this.world.getKeyDown(KeyboardKeys.Space)) {
157
- this.transform.visible = !this.transform.visible;
158
+ // Visibility lives on Object3DRef, not on the transform.
159
+ const ref = this.getComponent(Object3DRef);
160
+ if (ref) ref.visibility = !ref.visibility;
158
161
  }
159
162
 
160
163
  // Left mouse button
@@ -29,7 +29,15 @@ The `moduleLoader` owns cache-busting: with the default dynamic-import loader th
29
29
  Construct it and pass it to `World.setup`:
30
30
 
31
31
  ```ts
32
- import { ScriptObjectSystem } from "@relu-interactives/spatial-ecs";
32
+ import {
33
+ ScriptObjectSystem,
34
+ World,
35
+ type ModuleLoader,
36
+ } from "@relu-interactives/spatial-ecs";
37
+
38
+ declare const world: World;
39
+ // Resolves a script URL to its ES module — the templates supply this.
40
+ declare const myModuleLoader: ModuleLoader;
33
41
 
34
42
  world.setup({
35
43
  systems: [new ScriptObjectSystem(myModuleLoader)],
@@ -192,9 +192,11 @@ Add an **XR Hand Pose** component and list the poses to watch for. Each is eithe
192
192
  ```ts
193
193
  import {
194
194
  Behaviour,
195
- Object3DRef,
196
195
  type XrHandPoseEventDetail,
197
196
  } from "@relu-interactives/spatial-ecs";
197
+ import {
198
+ Object3DRef,
199
+ } from "@relu-interactives/spatial-ecs/components";
198
200
 
199
201
  export default class Portal extends Behaviour {
200
202
  onHandPoseStart(event: XrHandPoseEventDetail) {
@@ -214,16 +216,18 @@ export default class Portal extends Behaviour {
214
216
 
215
217
  `XrHandPoseEventDetail` is `{ poseId, poseName, handedness, confidence }`. Match on `poseId` — it is the id set in the inspector, not the preset name.
216
218
 
217
- **Changing another object's colour from a pose.** `MaterialComponent.updateValue` takes an index and a PATCH OBJECT — `updateValue(0, { color })`, not `updateValue(0, "color", value)`.
219
+ **Changing another object's colour from a pose.** `MaterialComponent.updateValue` takes an index and a PATCH OBJECT — `updateValue(0, { color })`, not `updateValue(0, { color: value })`.
218
220
 
219
221
  ```ts
220
222
  import {
221
223
  Behaviour,
222
- MaterialComponent,
223
224
  type EntityInput,
224
225
  type WorldEntityView,
225
226
  type XrHandPoseEventDetail,
226
227
  } from "@relu-interactives/spatial-ecs";
228
+ import {
229
+ MaterialComponent,
230
+ } from "@relu-interactives/spatial-ecs/components";
227
231
 
228
232
  export default class PoseColor extends Behaviour {
229
233
  data = { target: { type: "entity", value: null } as unknown as EntityInput };
@@ -10,7 +10,8 @@ This page summarises the methods most useful from a `Behaviour` and shows how to
10
10
  ## Inside a Behaviour
11
11
 
12
12
  ```ts
13
- import { Behaviour, TransformComponent } from "@relu-interactives/spatial-ecs";
13
+ import { Behaviour } from "@relu-interactives/spatial-ecs";
14
+ import { TransformComponent } from "@relu-interactives/spatial-ecs/components";
14
15
 
15
16
  export default class Spinner extends Behaviour {
16
17
  onUpdate() {
@@ -120,7 +121,8 @@ Both methods accept `Vec3` (`THREE.Vector3` or `{ x, y, z }`) and return `Inters
120
121
  ### Find an entity by name and move it
121
122
 
122
123
  ```ts
123
- import { Behaviour, TransformComponent } from "@relu-interactives/spatial-ecs";
124
+ import { Behaviour } from "@relu-interactives/spatial-ecs";
125
+ import { TransformComponent } from "@relu-interactives/spatial-ecs/components";
124
126
 
125
127
  export default class TargetMover extends Behaviour {
126
128
  onUpdate() {
@@ -138,7 +140,8 @@ export default class TargetMover extends Behaviour {
138
140
  ### Iterate every entity that owns a component
139
141
 
140
142
  ```ts
141
- import { Behaviour, LightComponent } from "@relu-interactives/spatial-ecs";
143
+ import { Behaviour } from "@relu-interactives/spatial-ecs";
144
+ import { LightComponent } from "@relu-interactives/spatial-ecs/components";
142
145
 
143
146
  export default class FlickerAllLights extends Behaviour {
144
147
  onUpdate() {
@@ -188,7 +191,10 @@ export default class HierarchyWalker extends Behaviour {
188
191
 
189
192
  ```ts
190
193
  import { Behaviour } from "@relu-interactives/spatial-ecs";
191
- import type Health from "./Health";
194
+ // Your own Behaviour, in a sibling file.
195
+ declare class Health extends Behaviour {
196
+ takeDamage(amount: number): void;
197
+ }
192
198
 
193
199
  export default class DamageDealer extends Behaviour {
194
200
  fire() {
@@ -229,12 +235,12 @@ export default class Spawner extends Behaviour {
229
235
  );
230
236
  this.world.getScene().add(mesh);
231
237
 
232
- this.world.addComponents(id, [
233
- createNameComponent({ value: "RuntimeCube" }),
234
- createEntityTypeComponent({ value: "cube" }),
235
- createTransformComponent({ position: { x: 0, y: 1, z: 0 } }),
236
- createObject3DRefComponent({ object: mesh }),
237
- ]);
238
+ // Each factory takes (world, entityId, ...constructorArgs) and attaches
239
+ // the component itself — there is nothing to pass to addComponents.
240
+ createNameComponent(this.world, id, "RuntimeCube");
241
+ createEntityTypeComponent(this.world, id, "cube");
242
+ createTransformComponent(this.world, id, { position: { x: 0, y: 1, z: 0 } });
243
+ createObject3DRefComponent(this.world, id, mesh);
238
244
  }
239
245
  }
240
246
  ```
@@ -343,7 +349,8 @@ export default class LookDetector extends Behaviour {
343
349
  ### Read keyboard and mouse input
344
350
 
345
351
  ```ts
346
- import { Behaviour, TransformComponent, KeyboardKeys } from "@relu-interactives/spatial-ecs";
352
+ import { Behaviour, KeyboardKeys } from "@relu-interactives/spatial-ecs";
353
+ import { TransformComponent } from "@relu-interactives/spatial-ecs/components";
347
354
 
348
355
  export default class WASDMove extends Behaviour {
349
356
  speed = 3;
@@ -392,11 +399,12 @@ export default class FpsLook extends Behaviour {
392
399
  ### Reach into the physics world
393
400
 
394
401
  ```ts
395
- import { Behaviour, PhysicsComponent } from "@relu-interactives/spatial-ecs";
402
+ import { Behaviour, KeyboardKeys } from "@relu-interactives/spatial-ecs";
403
+ import { PhysicsComponent } from "@relu-interactives/spatial-ecs/components";
396
404
 
397
405
  export default class Jump extends Behaviour {
398
406
  onUpdate() {
399
- if (!this.world.getKeyDown("space")) return;
407
+ if (!this.world.getKeyDown(KeyboardKeys.Space)) return;
400
408
 
401
409
  const physics = this.world.getComponent(this.entity.entityId, PhysicsComponent);
402
410
  physics?.rigidBody?.applyImpulse({ x: 0, y: 5, z: 0 }, true);
@@ -411,12 +419,12 @@ ticks stop when paused — physics, animation, scripts, and the render pass.
411
419
  The last rendered frame stays frozen on the canvas.
412
420
 
413
421
  ```ts
414
- import { Behaviour } from "@relu-interactives/spatial-ecs";
422
+ import { Behaviour, KeyboardKeys } from "@relu-interactives/spatial-ecs";
415
423
 
416
424
  export default class PauseOnHit extends Behaviour {
417
425
  onUpdate() {
418
426
  // Pause when the spacebar is pressed, resume when pressed again.
419
- if (!this.world.getKeyDown("Space")) return;
427
+ if (!this.world.getKeyDown(KeyboardKeys.Space)) return;
420
428
 
421
429
  if (this.world.isPaused()) {
422
430
  this.world.resume();
@@ -2254,6 +2254,12 @@ var _XRRigComponent = class _XRRigComponent extends Component {
2254
2254
  this.teleportArcColor = options?.teleportArcColor ?? "#4da3ff";
2255
2255
  this.teleportArcInvalidColor = options?.teleportArcInvalidColor ?? "#ff5a5a";
2256
2256
  this.teleportArcThickness = options?.teleportArcThickness ?? 0.012;
2257
+ this.passthrough = options?.passthrough ?? false;
2258
+ this.depthOcclusion = options?.depthOcclusion ?? false;
2259
+ this.environmentPhysics = options?.environmentPhysics ?? "none";
2260
+ this.environmentDebug = options?.environmentDebug ?? false;
2261
+ this.hitTest = options?.hitTest ?? false;
2262
+ this.anchors = options?.anchors ?? false;
2257
2263
  }
2258
2264
  };
2259
2265
  __name(_XRRigComponent, "XRRigComponent");