@relu-interactives/spatial-ecs 0.3.20 → 0.3.21

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 (34) hide show
  1. package/dist/docs/guide/accessing-components.md +7 -6
  2. package/dist/docs/guide/behaviour-data-binding/component-input.md +10 -6
  3. package/dist/docs/guide/behaviour-data-binding/entity-input.md +13 -5
  4. package/dist/docs/guide/camera-rigs.md +2 -2
  5. package/dist/docs/guide/components/animation.md +12 -5
  6. package/dist/docs/guide/components/audio.md +13 -6
  7. package/dist/docs/guide/components/camera.md +10 -4
  8. package/dist/docs/guide/components/entity-type.md +13 -6
  9. package/dist/docs/guide/components/image-target-anchor.md +6 -2
  10. package/dist/docs/guide/components/image-target.md +10 -5
  11. package/dist/docs/guide/components/image.md +10 -4
  12. package/dist/docs/guide/components/instance-slot.md +7 -3
  13. package/dist/docs/guide/components/instanced-mesh.md +15 -7
  14. package/dist/docs/guide/components/light.md +10 -4
  15. package/dist/docs/guide/components/material.md +14 -8
  16. package/dist/docs/guide/components/mesh-geometry.md +10 -4
  17. package/dist/docs/guide/components/mesh.md +10 -4
  18. package/dist/docs/guide/components/model.md +4 -2
  19. package/dist/docs/guide/components/name.md +11 -6
  20. package/dist/docs/guide/components/object3d-ref.md +7 -3
  21. package/dist/docs/guide/components/parent-id.md +10 -4
  22. package/dist/docs/guide/components/physics.md +12 -6
  23. package/dist/docs/guide/components/script.md +10 -4
  24. package/dist/docs/guide/components/sprite.md +10 -4
  25. package/dist/docs/guide/components/transform.md +6 -2
  26. package/dist/docs/guide/components/video.md +10 -4
  27. package/dist/docs/guide/prefabs.md +2 -0
  28. package/dist/docs/guide/runtime-entity-management.md +1 -1
  29. package/dist/docs/guide/spawning/instanced-mesh.md +11 -6
  30. package/dist/docs/guide/systems/input-system.md +4 -1
  31. package/dist/docs/guide/systems/script-object-system.md +9 -1
  32. package/dist/docs/guide/vr-and-hand-poses.md +7 -3
  33. package/dist/docs/guide/world-api.md +23 -15
  34. package/package.json +4 -2
@@ -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();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@relu-interactives/spatial-ecs",
3
- "version": "0.3.20",
3
+ "version": "0.3.21",
4
4
  "description": "Reusable ECS core engine for Relu Spatial editor and runtime experiences.",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -60,7 +60,9 @@
60
60
  "docs:preview": "vitepress preview docs",
61
61
  "release:patch": "npm version patch",
62
62
  "release:minor": "npm version minor",
63
- "release:major": "npm version major"
63
+ "release:major": "npm version major",
64
+ "docs:check": "node scripts/check-doc-examples.mjs --verbose",
65
+ "docs:fix-imports": "node scripts/fix-doc-imports.mjs"
64
66
  },
65
67
  "peerDependencies": {
66
68
  "three": ">=0.184.0 <0.185.0"