@relu-interactives/spatial-ecs 0.3.10 → 0.3.12

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 (38) hide show
  1. package/dist/{XRHandPose-hAtj9wm-.d.cts → XRHandPose-DawOR0uR.d.cts} +56 -14
  2. package/dist/{XRHandPose-CjacJ_16.d.ts → XRHandPose-DhAd9Qi6.d.ts} +56 -14
  3. package/dist/{chunk-NJOO7NO6.js → chunk-7ZIN6TGT.js} +3 -3
  4. package/dist/{chunk-NJOO7NO6.js.map → chunk-7ZIN6TGT.js.map} +1 -1
  5. package/dist/{chunk-5UVBEAGW.js → chunk-ID7U4FER.js} +4 -4
  6. package/dist/{chunk-5UVBEAGW.js.map → chunk-ID7U4FER.js.map} +1 -1
  7. package/dist/{chunk-O2HSIZFC.js → chunk-LCJ6IH2O.js} +324 -47
  8. package/dist/chunk-LCJ6IH2O.js.map +1 -0
  9. package/dist/{chunk-ELSZ5U3F.js → chunk-OMDYLFTN.js} +7 -4
  10. package/dist/chunk-OMDYLFTN.js.map +1 -0
  11. package/dist/components/index.cjs +5 -2
  12. package/dist/components/index.cjs.map +1 -1
  13. package/dist/components/index.d.cts +2 -2
  14. package/dist/components/index.d.ts +2 -2
  15. package/dist/components/index.js +1 -1
  16. package/dist/docs/guide/vr-and-hand-poses.md +7 -3
  17. package/dist/factories/index.cjs +5 -2
  18. package/dist/factories/index.cjs.map +1 -1
  19. package/dist/factories/index.d.cts +1 -1
  20. package/dist/factories/index.d.ts +1 -1
  21. package/dist/factories/index.js +3 -3
  22. package/dist/{index-B7JDsx4a.d.ts → index-B49322Q3.d.ts} +2 -3
  23. package/dist/{index-DU-CF-3m.d.cts → index-DJ9bn9SF.d.cts} +70 -1
  24. package/dist/{index-B-KhN8Ox.d.ts → index-M0I5B3JA.d.ts} +70 -1
  25. package/dist/{index-B9JqYr3Q.d.cts → index-Xm3im4Pt.d.cts} +2 -3
  26. package/dist/index.cjs +326 -44
  27. package/dist/index.cjs.map +1 -1
  28. package/dist/index.d.cts +5 -5
  29. package/dist/index.d.ts +5 -5
  30. package/dist/index.js +8 -8
  31. package/dist/systems/index.cjs +326 -44
  32. package/dist/systems/index.cjs.map +1 -1
  33. package/dist/systems/index.d.cts +1 -1
  34. package/dist/systems/index.d.ts +1 -1
  35. package/dist/systems/index.js +3 -3
  36. package/package.json +1 -1
  37. package/dist/chunk-ELSZ5U3F.js.map +0 -1
  38. package/dist/chunk-O2HSIZFC.js.map +0 -1
@@ -610,10 +610,36 @@ declare function normalizePhysicsState(value: {
610
610
  * ENUMERABLE property from plain assignment, leaking Rapier objects — and for
611
611
  * trimesh their huge vertex buffers — into snapshot/history/debug walks.
612
612
  */
613
- declare function setPhysicsLiveRef(component: PhysicsComponent, key: "rigidBody" | "collider", value: RapierRigidBody | RapierCollider | null): void;
613
+ /**
614
+ * A velocity waiting to be applied to the body, in world space.
615
+ *
616
+ * Needed because a throw is decided while the body is still kinematic (the hand
617
+ * was holding it), and Rapier ignores velocity on kinematic bodies. Queueing it
618
+ * lets `PhysicsSyncSystem` apply it in the same tick it turns the body dynamic
619
+ * again, which is the only moment the velocity actually takes.
620
+ */
621
+ type PendingBodyVelocity = {
622
+ linear: {
623
+ x: number;
624
+ y: number;
625
+ z: number;
626
+ };
627
+ angular: {
628
+ x: number;
629
+ y: number;
630
+ z: number;
631
+ };
632
+ };
633
+ declare function setPhysicsLiveRef(component: PhysicsComponent, key: "rigidBody" | "collider" | "pendingVelocity", value: RapierRigidBody | RapierCollider | PendingBodyVelocity | null): void;
614
634
  declare class PhysicsComponent extends Component {
615
635
  /** Authoring state. Saved with the project. */
616
636
  values: PhysicsState;
637
+ /**
638
+ * Velocity to apply the moment this body becomes dynamic again.
639
+ *
640
+ * Non-enumerable, like the Rapier refs — never serialized.
641
+ */
642
+ pendingVelocity?: PendingBodyVelocity | null;
617
643
  /**
618
644
  * Live Rapier rigid body. `null` until physics is initialized.
619
645
  * NON-ENUMERABLE — Rapier wrappers (and, for trimesh, their vertex buffers)
@@ -1208,14 +1234,6 @@ declare class VRTeleportAreaComponent extends Component {
1208
1234
  constructor(options?: VRTeleportAreaOptions);
1209
1235
  }
1210
1236
 
1211
- /**
1212
- * How an entity behaves while held.
1213
- *
1214
- * `kinematic` snaps it to the hand and ignores physics — predictable, and right
1215
- * for tools and UI. `physics` keeps the body simulated so it can collide while
1216
- * held and, crucially, carry momentum when released (see {@link throwOnRelease}).
1217
- */
1218
- type XrGrabMode = "kinematic" | "physics";
1219
1237
  /**
1220
1238
  * How close the user must be to grab.
1221
1239
  *
@@ -1282,12 +1300,19 @@ type XrAttachPoint = {
1282
1300
  type XrGrabHands = "single" | "handOff" | "two";
1283
1301
  /** How the second hand affects orientation. See `solveTwoHandTransform`. */
1284
1302
  type XrTwoHandRotation = "align" | "primary";
1303
+ /**
1304
+ * What an object does when a pointer lands on it.
1305
+ *
1306
+ * Hover feedback is what tells the user the ray has actually caught something —
1307
+ * without it, aiming at a grabbable object and aiming at empty space look
1308
+ * identical.
1309
+ */
1310
+ type XrHoverBehavior = "none" | "color" | "scale" | "both";
1285
1311
  /** Optional initializer for {@link XRInteractableComponent}. */
1286
1312
  type XRInteractableOptions = {
1287
1313
  enabled?: boolean;
1288
1314
  grabbable?: boolean;
1289
1315
  pointable?: boolean;
1290
- grabMode?: XrGrabMode;
1291
1316
  grabReach?: XrGrabReach;
1292
1317
  distanceBehavior?: XrDistanceGrabBehavior;
1293
1318
  grabGesture?: XrGrabGesture;
@@ -1321,7 +1346,12 @@ type XRInteractableOptions = {
1321
1346
  throwOnRelease?: boolean;
1322
1347
  /** Scales released velocity; >1 makes throws feel stronger than real life. */
1323
1348
  throwStrength?: number;
1324
- highlightOnHover?: boolean;
1349
+ /** Feedback shown while a pointer is on the object. */
1350
+ hoverBehavior?: XrHoverBehavior;
1351
+ /** Outline colour used by the `color` and `both` behaviours. */
1352
+ hoverColor?: string;
1353
+ /** Size multiplier used by the `scale` and `both` behaviours. */
1354
+ hoverScale?: number;
1325
1355
  };
1326
1356
  /**
1327
1357
  * Makes an entity respond to XR pointers and hands.
@@ -1336,7 +1366,6 @@ declare class XRInteractableComponent extends Component {
1336
1366
  enabled: boolean;
1337
1367
  grabbable: boolean;
1338
1368
  pointable: boolean;
1339
- grabMode: XrGrabMode;
1340
1369
  /** Whether the object can be grabbed up close, at range, or either. */
1341
1370
  grabReach: XrGrabReach;
1342
1371
  /** What a distance grab does — bring it here, or manipulate it in place. */
@@ -1373,7 +1402,12 @@ declare class XRInteractableComponent extends Component {
1373
1402
  throwOnRelease: boolean;
1374
1403
  /** Multiplier on released velocity. */
1375
1404
  throwStrength: number;
1376
- highlightOnHover: boolean;
1405
+ /** Feedback shown while a pointer is on the object. */
1406
+ hoverBehavior: XrHoverBehavior;
1407
+ /** Outline colour for the `color` and `both` behaviours. */
1408
+ hoverColor: string;
1409
+ /** Size multiplier for the `scale` and `both` behaviours. */
1410
+ hoverScale: number;
1377
1411
  constructor(options?: XRInteractableOptions);
1378
1412
  }
1379
1413
  /** An attach point with every field populated, for the editor and AI tools. */
@@ -1475,6 +1509,10 @@ type XRInteractorOptions = {
1475
1509
  handEmissiveIntensity?: number;
1476
1510
  /** Draw the aim ray from each hand. */
1477
1511
  showRay?: boolean;
1512
+ /** Pointer ray colour. */
1513
+ rayColor?: string;
1514
+ /** Pointer ray thickness (diameter), metres. */
1515
+ rayThickness?: number;
1478
1516
  };
1479
1517
  /**
1480
1518
  * Configures what the user sees as their hands, and hosts custom hand content.
@@ -1499,6 +1537,10 @@ declare class XRInteractorComponent extends Component {
1499
1537
  handEmissiveIntensity: number;
1500
1538
  /** Draw the aim ray from each hand. */
1501
1539
  showRay: boolean;
1540
+ /** Pointer ray colour. */
1541
+ rayColor: string;
1542
+ /** Pointer ray thickness (diameter), metres. */
1543
+ rayThickness: number;
1502
1544
  constructor(options?: XRInteractorOptions);
1503
1545
  }
1504
1546
  /**
@@ -1577,4 +1619,4 @@ declare class XRHandPoseComponent extends Component {
1577
1619
  constructor(options?: XRHandPoseOptions);
1578
1620
  }
1579
1621
 
1580
- export { SelectionTransformState as $, AnimationComponent as A, MeshComponent as B, CameraComponent as C, DEFAULT_COLLIDER_STATE as D, type EditableMeshObjectKind as E, MeshGeometryComponent as F, type MeshGeometryParameters as G, type MeshGeometryParametersByKind as H, ImageComponent as I, ModelComponent as J, type PhysicsState as K, LightComponent as L, MaterialComponent as M, Name as N, Object3DRef as O, PhysicsComponent as P, type PlaneMeshParameters as Q, type RadiusHeightMeshParameters as R, type RadiusMeshParameters as S, type RigidbodyState as T, type RigidbodyType as U, ScriptComponent as V, type ScriptEntry as W, ScriptObjectComponent as X, type ScriptObjectComponentInput as Y, type ScriptObjectRuntimeState as Z, Selectable as _, type AnimationComponentOptions as a, SpriteComponent as a0, type TextureFilteringValue as a1, type TransformModeValue as a2, type TransformSpaceValue as a3, VRTeleportAreaComponent as a4, type VRTeleportAreaOptions as a5, VideoComponent as a6, type VrTeleportShape as a7, XRHandPoseComponent as a8, type XRHandPoseOptions as a9, type AnimationStateCallbacks as aA, AnimationStateMachine as aB, AnimationStateManager as aC, type StateMachine as aD, XRInteractableComponent as aa, type XRInteractableOptions as ab, XRInteractorComponent as ac, type XRInteractorOptions as ad, XRInteractorSideComponent as ae, XRRigComponent as af, type XRRigOptions as ag, type XrAttachPoint as ah, type XrDistanceGrabBehavior as ai, type XrGrabGesture as aj, type XrGrabHands as ak, type XrGrabMode as al, type XrGrabReach as am, type XrHandPoseEntry as an, type XrHandPreset as ao, type XrInteractorSide as ap, type XrInteractorType as aq, type XrLocomotionMode as ar, type XrTrackingOrigin as as, type XrTwoHandRotation as at, createAttachPoint as au, createHandPoseEntry as av, defaultMaterialValue as aw, handPoseDefinitionFor as ax, normalizePhysicsState as ay, setPhysicsLiveRef as az, AudioComponent as b, type CameraComponentOptions as c, type CameraProjection as d, type CameraRuntimeType as e, type ColliderShape as f, type ColliderState as g, type CubeMeshParameters as h, DEFAULT_INSTANCED_MESH_PARAMETERS as i, DEFAULT_INSTANCE_TRANSFORM as j, DEFAULT_MESH_GEOMETRY_PARAMETERS as k, DEFAULT_PHYSICS_STATE as l, DEFAULT_POSE_CURLS as m, DEFAULT_RIGIDBODY_STATE as n, EntityType as o, ImageTarget as p, ImageTargetAnchor as q, type ImageTargetAnchorOptions as r, type ImageTargetReference as s, InstanceSlotComponent as t, type InstanceTransform as u, InstancedMeshComponent as v, type InstancedMeshKind as w, type LightValueState as x, type MaterialTypeValue as y, type MaterialValueState as z };
1622
+ export { SelectionTransformState as $, AnimationComponent as A, MeshComponent as B, CameraComponent as C, DEFAULT_COLLIDER_STATE as D, type EditableMeshObjectKind as E, MeshGeometryComponent as F, type MeshGeometryParameters as G, type MeshGeometryParametersByKind as H, ImageComponent as I, ModelComponent as J, type PhysicsState as K, LightComponent as L, MaterialComponent as M, Name as N, Object3DRef as O, PhysicsComponent as P, type PlaneMeshParameters as Q, type RadiusHeightMeshParameters as R, type RadiusMeshParameters as S, type RigidbodyState as T, type RigidbodyType as U, ScriptComponent as V, type ScriptEntry as W, ScriptObjectComponent as X, type ScriptObjectComponentInput as Y, type ScriptObjectRuntimeState as Z, Selectable as _, type AnimationComponentOptions as a, SpriteComponent as a0, type TextureFilteringValue as a1, type TransformModeValue as a2, type TransformSpaceValue as a3, VRTeleportAreaComponent as a4, type VRTeleportAreaOptions as a5, VideoComponent as a6, type VrTeleportShape as a7, XRHandPoseComponent as a8, type XRHandPoseOptions as a9, AnimationStateMachine as aA, AnimationStateManager as aB, type StateMachine as aC, XRInteractableComponent as aa, type XRInteractableOptions as ab, XRInteractorComponent as ac, type XRInteractorOptions as ad, XRInteractorSideComponent as ae, XRRigComponent as af, type XRRigOptions as ag, type XrAttachPoint as ah, type XrDistanceGrabBehavior as ai, type XrGrabGesture as aj, type XrGrabHands as ak, type XrGrabReach as al, type XrHandPoseEntry as am, type XrHandPreset as an, type XrInteractorSide as ao, type XrInteractorType as ap, type XrLocomotionMode as aq, type XrTrackingOrigin as ar, type XrTwoHandRotation as as, createAttachPoint as at, createHandPoseEntry as au, defaultMaterialValue as av, handPoseDefinitionFor as aw, normalizePhysicsState as ax, setPhysicsLiveRef as ay, type AnimationStateCallbacks as az, AudioComponent as b, type CameraComponentOptions as c, type CameraProjection as d, type CameraRuntimeType as e, type ColliderShape as f, type ColliderState as g, type CubeMeshParameters as h, DEFAULT_INSTANCED_MESH_PARAMETERS as i, DEFAULT_INSTANCE_TRANSFORM as j, DEFAULT_MESH_GEOMETRY_PARAMETERS as k, DEFAULT_PHYSICS_STATE as l, DEFAULT_POSE_CURLS as m, DEFAULT_RIGIDBODY_STATE as n, EntityType as o, ImageTarget as p, ImageTargetAnchor as q, type ImageTargetAnchorOptions as r, type ImageTargetReference as s, InstanceSlotComponent as t, type InstanceTransform as u, InstancedMeshComponent as v, type InstancedMeshKind as w, type LightValueState as x, type MaterialTypeValue as y, type MaterialValueState as z };
@@ -610,10 +610,36 @@ declare function normalizePhysicsState(value: {
610
610
  * ENUMERABLE property from plain assignment, leaking Rapier objects — and for
611
611
  * trimesh their huge vertex buffers — into snapshot/history/debug walks.
612
612
  */
613
- declare function setPhysicsLiveRef(component: PhysicsComponent, key: "rigidBody" | "collider", value: RapierRigidBody | RapierCollider | null): void;
613
+ /**
614
+ * A velocity waiting to be applied to the body, in world space.
615
+ *
616
+ * Needed because a throw is decided while the body is still kinematic (the hand
617
+ * was holding it), and Rapier ignores velocity on kinematic bodies. Queueing it
618
+ * lets `PhysicsSyncSystem` apply it in the same tick it turns the body dynamic
619
+ * again, which is the only moment the velocity actually takes.
620
+ */
621
+ type PendingBodyVelocity = {
622
+ linear: {
623
+ x: number;
624
+ y: number;
625
+ z: number;
626
+ };
627
+ angular: {
628
+ x: number;
629
+ y: number;
630
+ z: number;
631
+ };
632
+ };
633
+ declare function setPhysicsLiveRef(component: PhysicsComponent, key: "rigidBody" | "collider" | "pendingVelocity", value: RapierRigidBody | RapierCollider | PendingBodyVelocity | null): void;
614
634
  declare class PhysicsComponent extends Component {
615
635
  /** Authoring state. Saved with the project. */
616
636
  values: PhysicsState;
637
+ /**
638
+ * Velocity to apply the moment this body becomes dynamic again.
639
+ *
640
+ * Non-enumerable, like the Rapier refs — never serialized.
641
+ */
642
+ pendingVelocity?: PendingBodyVelocity | null;
617
643
  /**
618
644
  * Live Rapier rigid body. `null` until physics is initialized.
619
645
  * NON-ENUMERABLE — Rapier wrappers (and, for trimesh, their vertex buffers)
@@ -1208,14 +1234,6 @@ declare class VRTeleportAreaComponent extends Component {
1208
1234
  constructor(options?: VRTeleportAreaOptions);
1209
1235
  }
1210
1236
 
1211
- /**
1212
- * How an entity behaves while held.
1213
- *
1214
- * `kinematic` snaps it to the hand and ignores physics — predictable, and right
1215
- * for tools and UI. `physics` keeps the body simulated so it can collide while
1216
- * held and, crucially, carry momentum when released (see {@link throwOnRelease}).
1217
- */
1218
- type XrGrabMode = "kinematic" | "physics";
1219
1237
  /**
1220
1238
  * How close the user must be to grab.
1221
1239
  *
@@ -1282,12 +1300,19 @@ type XrAttachPoint = {
1282
1300
  type XrGrabHands = "single" | "handOff" | "two";
1283
1301
  /** How the second hand affects orientation. See `solveTwoHandTransform`. */
1284
1302
  type XrTwoHandRotation = "align" | "primary";
1303
+ /**
1304
+ * What an object does when a pointer lands on it.
1305
+ *
1306
+ * Hover feedback is what tells the user the ray has actually caught something —
1307
+ * without it, aiming at a grabbable object and aiming at empty space look
1308
+ * identical.
1309
+ */
1310
+ type XrHoverBehavior = "none" | "color" | "scale" | "both";
1285
1311
  /** Optional initializer for {@link XRInteractableComponent}. */
1286
1312
  type XRInteractableOptions = {
1287
1313
  enabled?: boolean;
1288
1314
  grabbable?: boolean;
1289
1315
  pointable?: boolean;
1290
- grabMode?: XrGrabMode;
1291
1316
  grabReach?: XrGrabReach;
1292
1317
  distanceBehavior?: XrDistanceGrabBehavior;
1293
1318
  grabGesture?: XrGrabGesture;
@@ -1321,7 +1346,12 @@ type XRInteractableOptions = {
1321
1346
  throwOnRelease?: boolean;
1322
1347
  /** Scales released velocity; >1 makes throws feel stronger than real life. */
1323
1348
  throwStrength?: number;
1324
- highlightOnHover?: boolean;
1349
+ /** Feedback shown while a pointer is on the object. */
1350
+ hoverBehavior?: XrHoverBehavior;
1351
+ /** Outline colour used by the `color` and `both` behaviours. */
1352
+ hoverColor?: string;
1353
+ /** Size multiplier used by the `scale` and `both` behaviours. */
1354
+ hoverScale?: number;
1325
1355
  };
1326
1356
  /**
1327
1357
  * Makes an entity respond to XR pointers and hands.
@@ -1336,7 +1366,6 @@ declare class XRInteractableComponent extends Component {
1336
1366
  enabled: boolean;
1337
1367
  grabbable: boolean;
1338
1368
  pointable: boolean;
1339
- grabMode: XrGrabMode;
1340
1369
  /** Whether the object can be grabbed up close, at range, or either. */
1341
1370
  grabReach: XrGrabReach;
1342
1371
  /** What a distance grab does — bring it here, or manipulate it in place. */
@@ -1373,7 +1402,12 @@ declare class XRInteractableComponent extends Component {
1373
1402
  throwOnRelease: boolean;
1374
1403
  /** Multiplier on released velocity. */
1375
1404
  throwStrength: number;
1376
- highlightOnHover: boolean;
1405
+ /** Feedback shown while a pointer is on the object. */
1406
+ hoverBehavior: XrHoverBehavior;
1407
+ /** Outline colour for the `color` and `both` behaviours. */
1408
+ hoverColor: string;
1409
+ /** Size multiplier for the `scale` and `both` behaviours. */
1410
+ hoverScale: number;
1377
1411
  constructor(options?: XRInteractableOptions);
1378
1412
  }
1379
1413
  /** An attach point with every field populated, for the editor and AI tools. */
@@ -1475,6 +1509,10 @@ type XRInteractorOptions = {
1475
1509
  handEmissiveIntensity?: number;
1476
1510
  /** Draw the aim ray from each hand. */
1477
1511
  showRay?: boolean;
1512
+ /** Pointer ray colour. */
1513
+ rayColor?: string;
1514
+ /** Pointer ray thickness (diameter), metres. */
1515
+ rayThickness?: number;
1478
1516
  };
1479
1517
  /**
1480
1518
  * Configures what the user sees as their hands, and hosts custom hand content.
@@ -1499,6 +1537,10 @@ declare class XRInteractorComponent extends Component {
1499
1537
  handEmissiveIntensity: number;
1500
1538
  /** Draw the aim ray from each hand. */
1501
1539
  showRay: boolean;
1540
+ /** Pointer ray colour. */
1541
+ rayColor: string;
1542
+ /** Pointer ray thickness (diameter), metres. */
1543
+ rayThickness: number;
1502
1544
  constructor(options?: XRInteractorOptions);
1503
1545
  }
1504
1546
  /**
@@ -1577,4 +1619,4 @@ declare class XRHandPoseComponent extends Component {
1577
1619
  constructor(options?: XRHandPoseOptions);
1578
1620
  }
1579
1621
 
1580
- export { SelectionTransformState as $, AnimationComponent as A, MeshComponent as B, CameraComponent as C, DEFAULT_COLLIDER_STATE as D, type EditableMeshObjectKind as E, MeshGeometryComponent as F, type MeshGeometryParameters as G, type MeshGeometryParametersByKind as H, ImageComponent as I, ModelComponent as J, type PhysicsState as K, LightComponent as L, MaterialComponent as M, Name as N, Object3DRef as O, PhysicsComponent as P, type PlaneMeshParameters as Q, type RadiusHeightMeshParameters as R, type RadiusMeshParameters as S, type RigidbodyState as T, type RigidbodyType as U, ScriptComponent as V, type ScriptEntry as W, ScriptObjectComponent as X, type ScriptObjectComponentInput as Y, type ScriptObjectRuntimeState as Z, Selectable as _, type AnimationComponentOptions as a, SpriteComponent as a0, type TextureFilteringValue as a1, type TransformModeValue as a2, type TransformSpaceValue as a3, VRTeleportAreaComponent as a4, type VRTeleportAreaOptions as a5, VideoComponent as a6, type VrTeleportShape as a7, XRHandPoseComponent as a8, type XRHandPoseOptions as a9, type AnimationStateCallbacks as aA, AnimationStateMachine as aB, AnimationStateManager as aC, type StateMachine as aD, XRInteractableComponent as aa, type XRInteractableOptions as ab, XRInteractorComponent as ac, type XRInteractorOptions as ad, XRInteractorSideComponent as ae, XRRigComponent as af, type XRRigOptions as ag, type XrAttachPoint as ah, type XrDistanceGrabBehavior as ai, type XrGrabGesture as aj, type XrGrabHands as ak, type XrGrabMode as al, type XrGrabReach as am, type XrHandPoseEntry as an, type XrHandPreset as ao, type XrInteractorSide as ap, type XrInteractorType as aq, type XrLocomotionMode as ar, type XrTrackingOrigin as as, type XrTwoHandRotation as at, createAttachPoint as au, createHandPoseEntry as av, defaultMaterialValue as aw, handPoseDefinitionFor as ax, normalizePhysicsState as ay, setPhysicsLiveRef as az, AudioComponent as b, type CameraComponentOptions as c, type CameraProjection as d, type CameraRuntimeType as e, type ColliderShape as f, type ColliderState as g, type CubeMeshParameters as h, DEFAULT_INSTANCED_MESH_PARAMETERS as i, DEFAULT_INSTANCE_TRANSFORM as j, DEFAULT_MESH_GEOMETRY_PARAMETERS as k, DEFAULT_PHYSICS_STATE as l, DEFAULT_POSE_CURLS as m, DEFAULT_RIGIDBODY_STATE as n, EntityType as o, ImageTarget as p, ImageTargetAnchor as q, type ImageTargetAnchorOptions as r, type ImageTargetReference as s, InstanceSlotComponent as t, type InstanceTransform as u, InstancedMeshComponent as v, type InstancedMeshKind as w, type LightValueState as x, type MaterialTypeValue as y, type MaterialValueState as z };
1622
+ export { SelectionTransformState as $, AnimationComponent as A, MeshComponent as B, CameraComponent as C, DEFAULT_COLLIDER_STATE as D, type EditableMeshObjectKind as E, MeshGeometryComponent as F, type MeshGeometryParameters as G, type MeshGeometryParametersByKind as H, ImageComponent as I, ModelComponent as J, type PhysicsState as K, LightComponent as L, MaterialComponent as M, Name as N, Object3DRef as O, PhysicsComponent as P, type PlaneMeshParameters as Q, type RadiusHeightMeshParameters as R, type RadiusMeshParameters as S, type RigidbodyState as T, type RigidbodyType as U, ScriptComponent as V, type ScriptEntry as W, ScriptObjectComponent as X, type ScriptObjectComponentInput as Y, type ScriptObjectRuntimeState as Z, Selectable as _, type AnimationComponentOptions as a, SpriteComponent as a0, type TextureFilteringValue as a1, type TransformModeValue as a2, type TransformSpaceValue as a3, VRTeleportAreaComponent as a4, type VRTeleportAreaOptions as a5, VideoComponent as a6, type VrTeleportShape as a7, XRHandPoseComponent as a8, type XRHandPoseOptions as a9, AnimationStateMachine as aA, AnimationStateManager as aB, type StateMachine as aC, XRInteractableComponent as aa, type XRInteractableOptions as ab, XRInteractorComponent as ac, type XRInteractorOptions as ad, XRInteractorSideComponent as ae, XRRigComponent as af, type XRRigOptions as ag, type XrAttachPoint as ah, type XrDistanceGrabBehavior as ai, type XrGrabGesture as aj, type XrGrabHands as ak, type XrGrabReach as al, type XrHandPoseEntry as am, type XrHandPreset as an, type XrInteractorSide as ao, type XrInteractorType as ap, type XrLocomotionMode as aq, type XrTrackingOrigin as ar, type XrTwoHandRotation as as, createAttachPoint as at, createHandPoseEntry as au, defaultMaterialValue as av, handPoseDefinitionFor as aw, normalizePhysicsState as ax, setPhysicsLiveRef as ay, type AnimationStateCallbacks as az, AudioComponent as b, type CameraComponentOptions as c, type CameraProjection as d, type CameraRuntimeType as e, type ColliderShape as f, type ColliderState as g, type CubeMeshParameters as h, DEFAULT_INSTANCED_MESH_PARAMETERS as i, DEFAULT_INSTANCE_TRANSFORM as j, DEFAULT_MESH_GEOMETRY_PARAMETERS as k, DEFAULT_PHYSICS_STATE as l, DEFAULT_POSE_CURLS as m, DEFAULT_RIGIDBODY_STATE as n, EntityType as o, ImageTarget as p, ImageTargetAnchor as q, type ImageTargetAnchorOptions as r, type ImageTargetReference as s, InstanceSlotComponent as t, type InstanceTransform as u, InstancedMeshComponent as v, type InstancedMeshKind as w, type LightValueState as x, type MaterialTypeValue as y, type MaterialValueState as z };
@@ -1,4 +1,4 @@
1
- import { TransformComponent, Object3DRef, ParentId } from './chunk-ELSZ5U3F.js';
1
+ import { TransformComponent, Object3DRef, ParentId } from './chunk-OMDYLFTN.js';
2
2
  import { __name } from './chunk-OY7ZODZP.js';
3
3
  import * as THREE2 from 'three';
4
4
  import { clone } from 'three/examples/jsm/utils/SkeletonUtils.js';
@@ -311,5 +311,5 @@ function resolveDracoDecoderPath() {
311
311
  __name(resolveDracoDecoderPath, "resolveDracoDecoderPath");
312
312
 
313
313
  export { ObjectManagementSystem, SHARED_MODEL_RESOURCE_FLAG, applyTransform, clearModelCache, cloneModelScene, createTransform, loadSharedGltf, resolveDracoDecoderPath, setDracoDecoderPath };
314
- //# sourceMappingURL=chunk-NJOO7NO6.js.map
315
- //# sourceMappingURL=chunk-NJOO7NO6.js.map
314
+ //# sourceMappingURL=chunk-7ZIN6TGT.js.map
315
+ //# sourceMappingURL=chunk-7ZIN6TGT.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../core/utils/modelCache.ts","../core/systems/ObjectManagementSystem.ts","../core/utils/dracoDecoderPath.ts"],"names":["THREE","cloneWithSkeleton"],"mappings":";;;;;AASO,IAAM,0BAAA,GAA6B;AAE1C,IAAM,UAAA,uBAAiB,GAAA,EAA2B;AAElD,SAAS,oBAAoB,IAAA,EAA4B;AACvD,EAAA,IAAA,CAAK,QAAA,CAAS,CAAC,KAAA,KAAU;AACvB,IAAA,IAAI,EAAE,iBAAuBA,MAAA,CAAA,IAAA,CAAA,EAAO;AAClC,MAAA;AAAA,IACF;AACA,IAAA,IAAI,MAAM,QAAA,EAAU;AAClB,MAAA,KAAA,CAAM,QAAA,CAAS,QAAA,CAAS,0BAA0B,CAAA,GAAI,IAAA;AAAA,IACxD;AACA,IAAA,MAAM,SAAA,GAAY,KAAA,CAAM,OAAA,CAAQ,KAAA,CAAM,QAAQ,IAC1C,KAAA,CAAM,QAAA,GACN,CAAC,KAAA,CAAM,QAAQ,CAAA;AACnB,IAAA,KAAA,MAAW,YAAY,SAAA,EAAW;AAChC,MAAA,IAAI,QAAA,EAAU;AACZ,QAAA,QAAA,CAAS,QAAA,CAAS,0BAA0B,CAAA,GAAI,IAAA;AAAA,MAClD;AAAA,IACF;AAAA,EACF,CAAC,CAAA;AACH;AAjBS,MAAA,CAAA,mBAAA,EAAA,qBAAA,CAAA;AAyBF,SAAS,cAAA,CACd,KACA,IAAA,EACe;AACf,EAAA,IAAI,OAAA,GAAU,UAAA,CAAW,GAAA,CAAI,GAAG,CAAA;AAChC,EAAA,IAAI,CAAC,OAAA,EAAS;AACZ,IAAA,OAAA,GAAU,IAAA,EAAK,CAAE,IAAA,CAAK,CAAC,IAAA,KAAS;AAC9B,MAAA,mBAA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,IAAA,EAA2B;AAC7D,EAAA,wBAAA,GAA2B,IAAA;AAC7B;AAFgB,MAAA,CAAA,mBAAA,EAAA,qBAAA,CAAA;AAIhB,SAAS,wBAAwB,GAAA,EAAsB;AACrD,EAAA,OAAO,GAAA,CAAI,WAAW,SAAS,CAAA;AACjC;AAFS,MAAA,CAAA,uBAAA,EAAA,yBAAA,CAAA;AAIF,SAAS,uBAAA,GAAkC;AAChD,EAAA,IAAI,wBAAA,EAA0B;AAC5B,IAAA,OAAO,wBAAA;AAAA,EACT;AAEA,EAAA,IAAI;AAEF,IAAA,MAAM,eAAe,IAAI,GAAA;AAAA,MACvB,iCAAA;AAAA,MACA,MAAA,CAAA,IAAA,CAAY;AAAA,MACZ,QAAA,EAAS;AAIX,IAAA,IAAI,uBAAA,CAAwB,YAAY,CAAA,EAAG;AACzC,MAAA,OAAO,sBAAA;AAAA,IACT;AAEA,IAAA,OAAO,YAAA;AAAA,EACT,CAAA,CAAA,MAAQ;AAEN,IAAA,OAAO,sBAAA;AAAA,EACT;AACF;AAvBgB,MAAA,CAAA,uBAAA,EAAA,yBAAA,CAAA","file":"chunk-NJOO7NO6.js","sourcesContent":["import * as THREE from \"three\";\nimport type { GLTF } from \"three/examples/jsm/loaders/GLTFLoader.js\";\nimport { clone as cloneWithSkeleton } from \"three/examples/jsm/utils/SkeletonUtils.js\";\n\n/**\n * userData flag set on geometries/materials that back shared (cached) model\n * scenes. Entity disposal must skip these — other live clones and future\n * spawns reference the same GPU resources.\n */\nexport const SHARED_MODEL_RESOURCE_FLAG = \"spatialEcsSharedModelResource\";\n\nconst modelCache = new Map<string, Promise<GLTF>>();\n\nfunction markSharedResources(root: THREE.Object3D): void {\n root.traverse((child) => {\n if (!(child instanceof THREE.Mesh)) {\n return;\n }\n if (child.geometry) {\n child.geometry.userData[SHARED_MODEL_RESOURCE_FLAG] = true;\n }\n const materials = Array.isArray(child.material)\n ? child.material\n : [child.material];\n for (const material of materials) {\n if (material) {\n material.userData[SHARED_MODEL_RESOURCE_FLAG] = true;\n }\n }\n });\n}\n\n/**\n * Load a GLTF once per URL and share the parsed result, so repeated spawns of\n * the same model skip both the fetch and the parse. The cached scene must\n * never be mounted directly (an Object3D has a single parent) — mount a\n * cloneModelScene() of it. Failed loads are evicted so a retry re-fetches.\n */\nexport function loadSharedGltf(\n url: string,\n load: () => Promise<GLTF>,\n): Promise<GLTF> {\n let pending = modelCache.get(url);\n if (!pending) {\n pending = load().then((gltf) => {\n markSharedResources(gltf.scene);\n return gltf;\n });\n pending.catch(() => {\n modelCache.delete(url);\n });\n modelCache.set(url, pending);\n }\n return pending;\n}\n\n/**\n * Skeleton-aware clone of a cached model scene for mounting. Geometries and\n * materials are shared with the cached original (marked via\n * SHARED_MODEL_RESOURCE_FLAG); the object hierarchy — including rebound\n * skeletons for skinned meshes — is fresh per call.\n */\nexport function cloneModelScene(scene: THREE.Object3D): THREE.Object3D {\n return cloneWithSkeleton(scene);\n}\n\n/**\n * Forget cached models (one URL, or everything). Subsequent loads fetch and\n * parse anew. Does not dispose GPU resources — live clones may still use them.\n */\nexport function clearModelCache(url?: string): void {\n if (typeof url === \"string\") {\n modelCache.delete(url);\n return;\n }\n modelCache.clear();\n}\n","import * as THREE from \"three\";\n\nimport { Object3DRef } from \"../components/Object3DRef\";\nimport { ParentId } from \"../components/ParentId\";\nimport type { TransformData } from \"../components/Transform\";\nimport { TransformComponent } from \"../components/Transform\";\nimport type { EcsSystem } from \"../System\";\nimport { SHARED_MODEL_RESOURCE_FLAG } from \"../utils/modelCache\";\nimport type { World } from \"../World\";\nimport type { EntityId, EcsEntityKind } from \"../types\";\n\nexport type CreatePayload = {\n name?: string;\n transform?: TransformData;\n parentId?: EntityId | null;\n path?: string;\n options?: Record<string, unknown>;\n camera?: Record<string, unknown>;\n useWorldCamera?: boolean;\n};\n\nexport type CreateContext = {\n world: World;\n scene: THREE.Scene;\n camera: THREE.PerspectiveCamera;\n payload: CreatePayload;\n isEditor?: boolean;\n};\n\nexport type EntityFactory = (context: CreateContext) => EntityId;\n\nexport type EcsComponentFactoryKind =\n | \"animation\"\n | \"audio\"\n | \"camera\"\n | \"environment\"\n | \"entityType\"\n | \"image\"\n | \"imageTargetAnchor\"\n | \"imageTarget\"\n | \"light\"\n | \"material\"\n | \"mesh\"\n | \"meshGeometry\"\n | \"model\"\n | \"name\"\n | \"object3DRef\"\n | \"parentId\"\n | \"physics\"\n | \"postprocessing\"\n | \"script\"\n | \"scriptObject\"\n | \"selectable\"\n | \"selectionTransformState\"\n | \"sprite\"\n | \"transform\"\n | \"video\"\n | \"instancedMesh\"\n | \"xrRig\"\n | \"vrTeleportArea\"\n | \"xrHandPose\"\n | \"xrInteractable\"\n | \"xrInteractor\"\n | \"xrInteractorSide\";\n\nexport type ComponentFactory = (\n world: World,\n entityId: EntityId,\n ...args: any[]\n) => unknown;\n\ntype CreateRequest = {\n kind: EcsEntityKind;\n payload: CreatePayload;\n onCreated?: (entityId: EntityId) => void;\n};\n\nexport function createTransform(input?: TransformData): TransformComponent {\n return new TransformComponent(input);\n}\n\nexport function applyTransform(\n object: THREE.Object3D,\n transform: TransformComponent,\n): void {\n object.position.set(\n transform.position.x,\n transform.position.y,\n transform.position.z,\n );\n object.rotation.set(\n transform.rotation.x,\n transform.rotation.y,\n transform.rotation.z,\n );\n object.scale.set(transform.scale.x, transform.scale.y, transform.scale.z);\n}\n\nexport class ObjectManagementSystem implements EcsSystem {\n private readonly scene: THREE.Scene;\n private readonly camera: THREE.PerspectiveCamera;\n private readonly isEditor: boolean;\n private readonly registry = new Map<EcsEntityKind, EntityFactory>();\n private readonly componentRegistry = new Map<\n EcsComponentFactoryKind,\n ComponentFactory\n >();\n private readonly createQueue: CreateRequest[] = [];\n\n constructor(\n scene: THREE.Scene,\n camera: THREE.PerspectiveCamera,\n isEditor = false,\n ) {\n this.scene = scene;\n this.camera = camera;\n this.isEditor = isEditor;\n }\n\n register(kind: EcsEntityKind, factory: EntityFactory): void {\n this.registry.set(kind, factory);\n }\n\n registerComponentFactory(\n kind: EcsComponentFactoryKind,\n factory: ComponentFactory,\n ): void {\n this.componentRegistry.set(kind, factory);\n }\n\n getOrCreateAudioListener(): THREE.AudioListener {\n const existing = this.camera.userData.ecsAudioListener;\n if (existing instanceof THREE.AudioListener) {\n return existing;\n }\n\n const listener = new THREE.AudioListener();\n this.camera.add(listener);\n this.camera.userData.ecsAudioListener = listener;\n return listener;\n }\n\n isEditorMode(): boolean {\n return this.isEditor;\n }\n\n getComponentFactory(kind: EcsComponentFactoryKind): ComponentFactory | null {\n return this.componentRegistry.get(kind) ?? null;\n }\n\n createComponentNow(\n kind: EcsComponentFactoryKind,\n world: World,\n entityId: EntityId,\n ...args: any[]\n ): unknown {\n const factory = this.componentRegistry.get(kind);\n if (!factory) {\n throw new Error(`Unknown component kind: ${kind}`);\n }\n\n return factory(world, entityId, ...args);\n }\n\n requestCreate(\n kind: EcsEntityKind,\n payload: CreatePayload = {},\n onCreated?: (entityId: EntityId) => void,\n ): void {\n this.createQueue.push({ kind, payload, onCreated });\n }\n\n createNow(\n kind: EcsEntityKind,\n world: World,\n payload: CreatePayload = {},\n ): EntityId {\n const factory = this.registry.get(kind);\n if (!factory) {\n throw new Error(`Unknown object kind: ${kind}`);\n }\n\n const entityId = factory({\n world,\n scene: this.scene,\n camera: this.camera,\n payload,\n isEditor: this.isEditor,\n });\n\n const object = world.getComponent(entityId, Object3DRef)?.object;\n if (object) {\n object.userData.ecsKind = kind;\n }\n\n if (payload.parentId !== undefined) {\n world.addComponent(entityId, new ParentId(payload.parentId));\n }\n\n return entityId;\n }\n\n /**\n * Removes an entity from the ECS world and its associated `Object3D` from the\n * THREE.js scene graph.\n *\n * @param world - The world the entity belongs to.\n * @param entityId - The entity to remove.\n * @param dispose - When `true`, traverses the entity's `Object3D` subtree and\n * calls `.dispose()` on every `BufferGeometry` and `Material` found. Pass\n * `true` when the entity will not be reused and you want to free GPU memory\n * immediately (e.g. dynamically spawned objects). Defaults to `false`.\n * @returns `true` if the entity existed and was removed; `false` if the entity\n * was not found.\n *\n * @example\n * ```ts\n * // Remove from scene, keep GPU resources (safe if geometry is shared)\n * objects.deleteEntity(world, entityId);\n *\n * // Remove from scene and free GPU memory (use for one-off spawned objects)\n * objects.deleteEntity(world, entityId, true);\n * ```\n */\n deleteEntity(world: World, entityId: EntityId, dispose = false): boolean {\n if (!world.hasEntity(entityId)) {\n return false;\n }\n\n const object3d = world.getComponent(entityId, Object3DRef)?.object;\n if (object3d?.parent) {\n object3d.parent.remove(object3d);\n }\n\n if (dispose && object3d) {\n object3d.traverse((child) => {\n if (child instanceof THREE.Mesh) {\n // Resources backing shared (cached) model scenes are skipped —\n // other live clones and future spawns reference the same objects.\n if (!child.geometry?.userData?.[SHARED_MODEL_RESOURCE_FLAG]) {\n child.geometry?.dispose();\n }\n const materials = Array.isArray(child.material)\n ? child.material\n : [child.material];\n for (const mat of materials) {\n if (mat && !mat.userData?.[SHARED_MODEL_RESOURCE_FLAG]) {\n mat.dispose();\n }\n }\n }\n });\n }\n\n world.destroyEntity(entityId);\n return true;\n }\n\n setParent(\n world: World,\n entityId: EntityId,\n parentId: EntityId | null,\n options?: {\n preserveWorldTransform?: boolean;\n },\n ): boolean {\n if (!world.hasEntity(entityId)) {\n return false;\n }\n\n if (parentId !== null && !world.hasEntity(parentId)) {\n return false;\n }\n\n if (parentId === entityId) {\n return false;\n }\n\n let ancestor = parentId;\n while (ancestor !== null) {\n if (ancestor === entityId) {\n return false;\n }\n\n ancestor = world.getComponent(ancestor, ParentId)?.value ?? null;\n }\n\n const parentComponent = world.getComponent(entityId, ParentId);\n if (parentComponent) {\n if (parentComponent.value === parentId) {\n return false;\n }\n\n parentComponent.value = parentId;\n } else {\n world.addComponent(entityId, new ParentId(parentId));\n }\n\n const preserveWorldTransform = options?.preserveWorldTransform ?? true;\n if (preserveWorldTransform) {\n const object = world.getComponent(entityId, Object3DRef)?.object;\n const parentObject =\n parentId !== null\n ? world.getComponent(parentId, Object3DRef)?.object ?? null\n : null;\n\n if (object) {\n // Refresh matrixWorld before attach so world-space preservation is accurate.\n this.scene.updateMatrixWorld(true);\n\n if (parentObject && parentObject !== object) {\n parentObject.attach(object);\n } else {\n this.scene.attach(object);\n }\n\n object.updateMatrixWorld(true);\n this.syncTransformComponentFromObject(world, entityId, object);\n }\n }\n\n this.reconcileSceneFromWorld(world);\n return true;\n }\n\n private syncTransformComponentFromObject(\n world: World,\n entityId: EntityId,\n object: THREE.Object3D,\n ): void {\n const transform = world.getComponent(entityId, TransformComponent);\n if (!transform) {\n return;\n }\n\n transform.position.x = object.position.x;\n transform.position.y = object.position.y;\n transform.position.z = object.position.z;\n\n transform.rotation.x = object.rotation.x;\n transform.rotation.y = object.rotation.y;\n transform.rotation.z = object.rotation.z;\n\n transform.scale.x = object.scale.x;\n transform.scale.y = object.scale.y;\n transform.scale.z = object.scale.z;\n }\n\n reconcileSceneFromWorld(world: World): void {\n const worldObjects = new Map<EntityId, THREE.Object3D>();\n const entityIds = world.query(Object3DRef);\n\n for (const entityId of entityIds) {\n const object = world.getComponent(entityId, Object3DRef)?.object;\n if (!object) {\n continue;\n }\n\n worldObjects.set(entityId, object);\n }\n\n for (const child of [...this.scene.children]) {\n const entityId = child.userData?.entityId;\n if (typeof entityId === \"number\" && !world.hasEntity(entityId)) {\n this.scene.remove(child);\n }\n }\n\n for (const [entityId, object] of worldObjects.entries()) {\n const parentEntityId = world.getComponent(entityId, ParentId)?.value;\n const parentObject =\n typeof parentEntityId === \"number\"\n ? worldObjects.get(parentEntityId)\n : undefined;\n\n if (parentObject && parentObject !== object) {\n if (object.parent !== parentObject) {\n // Reconcile hierarchy from ParentId while keeping Transform as local source of truth.\n parentObject.add(object);\n object.updateMatrixWorld(true);\n }\n continue;\n }\n\n if (object.parent !== this.scene) {\n // Reconcile hierarchy from ParentId while keeping Transform as local source of truth.\n this.scene.add(object);\n object.updateMatrixWorld(true);\n }\n }\n }\n\n update(world: World): void {\n for (const request of this.createQueue.splice(0)) {\n const entityId = this.createNow(request.kind, world, request.payload);\n request.onCreated?.(entityId);\n }\n\n this.reconcileSceneFromWorld(world);\n }\n}\n","const LOCAL_DRACO_DECODER_RELATIVE_PATH = \"./assets/draco/\";\nexport const DRACO_DECODER_CDN_PATH =\n \"https://www.gstatic.com/draco/versioned/decoders/1.5.7/\";\n\nlet dracoDecoderPathOverride: string | null = null;\n\n/**\n * Override where the DRACO decoder files (draco_wasm_wrapper.js,\n * draco_decoder.wasm, draco_decoder.js) are fetched from. Embedding apps\n * whose bundlers relocate this package's chunks — making the default\n * import.meta.url resolution point at a location that is never populated —\n * should call this before any model loads. The path must end with \"/\".\n * Pass null to restore the default resolution.\n */\nexport function setDracoDecoderPath(path: string | null): void {\n dracoDecoderPathOverride = path;\n}\n\nfunction isBlockedBrowserFileUrl(url: string): boolean {\n return url.startsWith(\"file://\");\n}\n\nexport function resolveDracoDecoderPath(): string {\n if (dracoDecoderPathOverride) {\n return dracoDecoderPathOverride;\n }\n\n try {\n // Prefer vendored decoder assets shipped with this package.\n const resolvedPath = new URL(\n LOCAL_DRACO_DECODER_RELATIVE_PATH,\n import.meta.url,\n ).toString();\n\n // Browser loaders cannot fetch file:// resources from package install paths.\n // Fall back to CDN decoders when bundlers emit file URLs for node_modules assets.\n if (isBlockedBrowserFileUrl(resolvedPath)) {\n return DRACO_DECODER_CDN_PATH;\n }\n\n return resolvedPath;\n } catch {\n // Fallback keeps compatibility in runtimes that cannot resolve package-relative URLs.\n return DRACO_DECODER_CDN_PATH;\n }\n}\n"]}
1
+ {"version":3,"sources":["../core/utils/modelCache.ts","../core/systems/ObjectManagementSystem.ts","../core/utils/dracoDecoderPath.ts"],"names":["THREE","cloneWithSkeleton"],"mappings":";;;;;AASO,IAAM,0BAAA,GAA6B;AAE1C,IAAM,UAAA,uBAAiB,GAAA,EAA2B;AAElD,SAAS,oBAAoB,IAAA,EAA4B;AACvD,EAAA,IAAA,CAAK,QAAA,CAAS,CAAC,KAAA,KAAU;AACvB,IAAA,IAAI,EAAE,iB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AA,EAAS;AAIX,IAAA,IAAI,uBAAA,CAAwB,YAAY,CAAA,EAAG;AACzC,MAAA,OAAO,sBAAA;AAAA,IACT;AAEA,IAAA,OAAO,YAAA;AAAA,EACT,CAAA,CAAA,MAAQ;AAEN,IAAA,OAAO,sBAAA;AAAA,EACT;AACF;AAvBgB,MAAA,CAAA,uBAAA,EAAA,yBAAA,CAAA","file":"chunk-7ZIN6TGT.js","sourcesContent":["import * as THREE from \"three\";\nimport type { GLTF } from \"three/examples/jsm/loaders/GLTFLoader.js\";\nimport { clone as cloneWithSkeleton } from \"three/examples/jsm/utils/SkeletonUtils.js\";\n\n/**\n * userData flag set on geometries/materials that back shared (cached) model\n * scenes. Entity disposal must skip these — other live clones and future\n * spawns reference the same GPU resources.\n */\nexport const SHARED_MODEL_RESOURCE_FLAG = \"spatialEcsSharedModelResource\";\n\nconst modelCache = new Map<string, Promise<GLTF>>();\n\nfunction markSharedResources(root: THREE.Object3D): void {\n root.traverse((child) => {\n if (!(child instanceof THREE.Mesh)) {\n return;\n }\n if (child.geometry) {\n child.geometry.userData[SHARED_MODEL_RESOURCE_FLAG] = true;\n }\n const materials = Array.isArray(child.material)\n ? child.material\n : [child.material];\n for (const material of materials) {\n if (material) {\n material.userData[SHARED_MODEL_RESOURCE_FLAG] = true;\n }\n }\n });\n}\n\n/**\n * Load a GLTF once per URL and share the parsed result, so repeated spawns of\n * the same model skip both the fetch and the parse. The cached scene must\n * never be mounted directly (an Object3D has a single parent) — mount a\n * cloneModelScene() of it. Failed loads are evicted so a retry re-fetches.\n */\nexport function loadSharedGltf(\n url: string,\n load: () => Promise<GLTF>,\n): Promise<GLTF> {\n let pending = modelCache.get(url);\n if (!pending) {\n pending = load().then((gltf) => {\n markSharedResources(gltf.scene);\n return gltf;\n });\n pending.catch(() => {\n modelCache.delete(url);\n });\n modelCache.set(url, pending);\n }\n return pending;\n}\n\n/**\n * Skeleton-aware clone of a cached model scene for mounting. Geometries and\n * materials are shared with the cached original (marked via\n * SHARED_MODEL_RESOURCE_FLAG); the object hierarchy — including rebound\n * skeletons for skinned meshes — is fresh per call.\n */\nexport function cloneModelScene(scene: THREE.Object3D): THREE.Object3D {\n return cloneWithSkeleton(scene);\n}\n\n/**\n * Forget cached models (one URL, or everything). Subsequent loads fetch and\n * parse anew. Does not dispose GPU resources — live clones may still use them.\n */\nexport function clearModelCache(url?: string): void {\n if (typeof url === \"string\") {\n modelCache.delete(url);\n return;\n }\n modelCache.clear();\n}\n","import * as THREE from \"three\";\n\nimport { Object3DRef } from \"../components/Object3DRef\";\nimport { ParentId } from \"../components/ParentId\";\nimport type { TransformData } from \"../components/Transform\";\nimport { TransformComponent } from \"../components/Transform\";\nimport type { EcsSystem } from \"../System\";\nimport { SHARED_MODEL_RESOURCE_FLAG } from \"../utils/modelCache\";\nimport type { World } from \"../World\";\nimport type { EntityId, EcsEntityKind } from \"../types\";\n\nexport type CreatePayload = {\n name?: string;\n transform?: TransformData;\n parentId?: EntityId | null;\n path?: string;\n options?: Record<string, unknown>;\n camera?: Record<string, unknown>;\n useWorldCamera?: boolean;\n};\n\nexport type CreateContext = {\n world: World;\n scene: THREE.Scene;\n camera: THREE.PerspectiveCamera;\n payload: CreatePayload;\n isEditor?: boolean;\n};\n\nexport type EntityFactory = (context: CreateContext) => EntityId;\n\nexport type EcsComponentFactoryKind =\n | \"animation\"\n | \"audio\"\n | \"camera\"\n | \"environment\"\n | \"entityType\"\n | \"image\"\n | \"imageTargetAnchor\"\n | \"imageTarget\"\n | \"light\"\n | \"material\"\n | \"mesh\"\n | \"meshGeometry\"\n | \"model\"\n | \"name\"\n | \"object3DRef\"\n | \"parentId\"\n | \"physics\"\n | \"postprocessing\"\n | \"script\"\n | \"scriptObject\"\n | \"selectable\"\n | \"selectionTransformState\"\n | \"sprite\"\n | \"transform\"\n | \"video\"\n | \"instancedMesh\"\n | \"xrRig\"\n | \"vrTeleportArea\"\n | \"xrHandPose\"\n | \"xrInteractable\"\n | \"xrInteractor\"\n | \"xrInteractorSide\";\n\nexport type ComponentFactory = (\n world: World,\n entityId: EntityId,\n ...args: any[]\n) => unknown;\n\ntype CreateRequest = {\n kind: EcsEntityKind;\n payload: CreatePayload;\n onCreated?: (entityId: EntityId) => void;\n};\n\nexport function createTransform(input?: TransformData): TransformComponent {\n return new TransformComponent(input);\n}\n\nexport function applyTransform(\n object: THREE.Object3D,\n transform: TransformComponent,\n): void {\n object.position.set(\n transform.position.x,\n transform.position.y,\n transform.position.z,\n );\n object.rotation.set(\n transform.rotation.x,\n transform.rotation.y,\n transform.rotation.z,\n );\n object.scale.set(transform.scale.x, transform.scale.y, transform.scale.z);\n}\n\nexport class ObjectManagementSystem implements EcsSystem {\n private readonly scene: THREE.Scene;\n private readonly camera: THREE.PerspectiveCamera;\n private readonly isEditor: boolean;\n private readonly registry = new Map<EcsEntityKind, EntityFactory>();\n private readonly componentRegistry = new Map<\n EcsComponentFactoryKind,\n ComponentFactory\n >();\n private readonly createQueue: CreateRequest[] = [];\n\n constructor(\n scene: THREE.Scene,\n camera: THREE.PerspectiveCamera,\n isEditor = false,\n ) {\n this.scene = scene;\n this.camera = camera;\n this.isEditor = isEditor;\n }\n\n register(kind: EcsEntityKind, factory: EntityFactory): void {\n this.registry.set(kind, factory);\n }\n\n registerComponentFactory(\n kind: EcsComponentFactoryKind,\n factory: ComponentFactory,\n ): void {\n this.componentRegistry.set(kind, factory);\n }\n\n getOrCreateAudioListener(): THREE.AudioListener {\n const existing = this.camera.userData.ecsAudioListener;\n if (existing instanceof THREE.AudioListener) {\n return existing;\n }\n\n const listener = new THREE.AudioListener();\n this.camera.add(listener);\n this.camera.userData.ecsAudioListener = listener;\n return listener;\n }\n\n isEditorMode(): boolean {\n return this.isEditor;\n }\n\n getComponentFactory(kind: EcsComponentFactoryKind): ComponentFactory | null {\n return this.componentRegistry.get(kind) ?? null;\n }\n\n createComponentNow(\n kind: EcsComponentFactoryKind,\n world: World,\n entityId: EntityId,\n ...args: any[]\n ): unknown {\n const factory = this.componentRegistry.get(kind);\n if (!factory) {\n throw new Error(`Unknown component kind: ${kind}`);\n }\n\n return factory(world, entityId, ...args);\n }\n\n requestCreate(\n kind: EcsEntityKind,\n payload: CreatePayload = {},\n onCreated?: (entityId: EntityId) => void,\n ): void {\n this.createQueue.push({ kind, payload, onCreated });\n }\n\n createNow(\n kind: EcsEntityKind,\n world: World,\n payload: CreatePayload = {},\n ): EntityId {\n const factory = this.registry.get(kind);\n if (!factory) {\n throw new Error(`Unknown object kind: ${kind}`);\n }\n\n const entityId = factory({\n world,\n scene: this.scene,\n camera: this.camera,\n payload,\n isEditor: this.isEditor,\n });\n\n const object = world.getComponent(entityId, Object3DRef)?.object;\n if (object) {\n object.userData.ecsKind = kind;\n }\n\n if (payload.parentId !== undefined) {\n world.addComponent(entityId, new ParentId(payload.parentId));\n }\n\n return entityId;\n }\n\n /**\n * Removes an entity from the ECS world and its associated `Object3D` from the\n * THREE.js scene graph.\n *\n * @param world - The world the entity belongs to.\n * @param entityId - The entity to remove.\n * @param dispose - When `true`, traverses the entity's `Object3D` subtree and\n * calls `.dispose()` on every `BufferGeometry` and `Material` found. Pass\n * `true` when the entity will not be reused and you want to free GPU memory\n * immediately (e.g. dynamically spawned objects). Defaults to `false`.\n * @returns `true` if the entity existed and was removed; `false` if the entity\n * was not found.\n *\n * @example\n * ```ts\n * // Remove from scene, keep GPU resources (safe if geometry is shared)\n * objects.deleteEntity(world, entityId);\n *\n * // Remove from scene and free GPU memory (use for one-off spawned objects)\n * objects.deleteEntity(world, entityId, true);\n * ```\n */\n deleteEntity(world: World, entityId: EntityId, dispose = false): boolean {\n if (!world.hasEntity(entityId)) {\n return false;\n }\n\n const object3d = world.getComponent(entityId, Object3DRef)?.object;\n if (object3d?.parent) {\n object3d.parent.remove(object3d);\n }\n\n if (dispose && object3d) {\n object3d.traverse((child) => {\n if (child instanceof THREE.Mesh) {\n // Resources backing shared (cached) model scenes are skipped —\n // other live clones and future spawns reference the same objects.\n if (!child.geometry?.userData?.[SHARED_MODEL_RESOURCE_FLAG]) {\n child.geometry?.dispose();\n }\n const materials = Array.isArray(child.material)\n ? child.material\n : [child.material];\n for (const mat of materials) {\n if (mat && !mat.userData?.[SHARED_MODEL_RESOURCE_FLAG]) {\n mat.dispose();\n }\n }\n }\n });\n }\n\n world.destroyEntity(entityId);\n return true;\n }\n\n setParent(\n world: World,\n entityId: EntityId,\n parentId: EntityId | null,\n options?: {\n preserveWorldTransform?: boolean;\n },\n ): boolean {\n if (!world.hasEntity(entityId)) {\n return false;\n }\n\n if (parentId !== null && !world.hasEntity(parentId)) {\n return false;\n }\n\n if (parentId === entityId) {\n return false;\n }\n\n let ancestor = parentId;\n while (ancestor !== null) {\n if (ancestor === entityId) {\n return false;\n }\n\n ancestor = world.getComponent(ancestor, ParentId)?.value ?? null;\n }\n\n const parentComponent = world.getComponent(entityId, ParentId);\n if (parentComponent) {\n if (parentComponent.value === parentId) {\n return false;\n }\n\n parentComponent.value = parentId;\n } else {\n world.addComponent(entityId, new ParentId(parentId));\n }\n\n const preserveWorldTransform = options?.preserveWorldTransform ?? true;\n if (preserveWorldTransform) {\n const object = world.getComponent(entityId, Object3DRef)?.object;\n const parentObject =\n parentId !== null\n ? world.getComponent(parentId, Object3DRef)?.object ?? null\n : null;\n\n if (object) {\n // Refresh matrixWorld before attach so world-space preservation is accurate.\n this.scene.updateMatrixWorld(true);\n\n if (parentObject && parentObject !== object) {\n parentObject.attach(object);\n } else {\n this.scene.attach(object);\n }\n\n object.updateMatrixWorld(true);\n this.syncTransformComponentFromObject(world, entityId, object);\n }\n }\n\n this.reconcileSceneFromWorld(world);\n return true;\n }\n\n private syncTransformComponentFromObject(\n world: World,\n entityId: EntityId,\n object: THREE.Object3D,\n ): void {\n const transform = world.getComponent(entityId, TransformComponent);\n if (!transform) {\n return;\n }\n\n transform.position.x = object.position.x;\n transform.position.y = object.position.y;\n transform.position.z = object.position.z;\n\n transform.rotation.x = object.rotation.x;\n transform.rotation.y = object.rotation.y;\n transform.rotation.z = object.rotation.z;\n\n transform.scale.x = object.scale.x;\n transform.scale.y = object.scale.y;\n transform.scale.z = object.scale.z;\n }\n\n reconcileSceneFromWorld(world: World): void {\n const worldObjects = new Map<EntityId, THREE.Object3D>();\n const entityIds = world.query(Object3DRef);\n\n for (const entityId of entityIds) {\n const object = world.getComponent(entityId, Object3DRef)?.object;\n if (!object) {\n continue;\n }\n\n worldObjects.set(entityId, object);\n }\n\n for (const child of [...this.scene.children]) {\n const entityId = child.userData?.entityId;\n if (typeof entityId === \"number\" && !world.hasEntity(entityId)) {\n this.scene.remove(child);\n }\n }\n\n for (const [entityId, object] of worldObjects.entries()) {\n const parentEntityId = world.getComponent(entityId, ParentId)?.value;\n const parentObject =\n typeof parentEntityId === \"number\"\n ? worldObjects.get(parentEntityId)\n : undefined;\n\n if (parentObject && parentObject !== object) {\n if (object.parent !== parentObject) {\n // Reconcile hierarchy from ParentId while keeping Transform as local source of truth.\n parentObject.add(object);\n object.updateMatrixWorld(true);\n }\n continue;\n }\n\n if (object.parent !== this.scene) {\n // Reconcile hierarchy from ParentId while keeping Transform as local source of truth.\n this.scene.add(object);\n object.updateMatrixWorld(true);\n }\n }\n }\n\n update(world: World): void {\n for (const request of this.createQueue.splice(0)) {\n const entityId = this.createNow(request.kind, world, request.payload);\n request.onCreated?.(entityId);\n }\n\n this.reconcileSceneFromWorld(world);\n }\n}\n","const LOCAL_DRACO_DECODER_RELATIVE_PATH = \"./assets/draco/\";\nexport const DRACO_DECODER_CDN_PATH =\n \"https://www.gstatic.com/draco/versioned/decoders/1.5.7/\";\n\nlet dracoDecoderPathOverride: string | null = null;\n\n/**\n * Override where the DRACO decoder files (draco_wasm_wrapper.js,\n * draco_decoder.wasm, draco_decoder.js) are fetched from. Embedding apps\n * whose bundlers relocate this package's chunks — making the default\n * import.meta.url resolution point at a location that is never populated —\n * should call this before any model loads. The path must end with \"/\".\n * Pass null to restore the default resolution.\n */\nexport function setDracoDecoderPath(path: string | null): void {\n dracoDecoderPathOverride = path;\n}\n\nfunction isBlockedBrowserFileUrl(url: string): boolean {\n return url.startsWith(\"file://\");\n}\n\nexport function resolveDracoDecoderPath(): string {\n if (dracoDecoderPathOverride) {\n return dracoDecoderPathOverride;\n }\n\n try {\n // Prefer vendored decoder assets shipped with this package.\n const resolvedPath = new URL(\n LOCAL_DRACO_DECODER_RELATIVE_PATH,\n import.meta.url,\n ).toString();\n\n // Browser loaders cannot fetch file:// resources from package install paths.\n // Fall back to CDN decoders when bundlers emit file URLs for node_modules assets.\n if (isBlockedBrowserFileUrl(resolvedPath)) {\n return DRACO_DECODER_CDN_PATH;\n }\n\n return resolvedPath;\n } catch {\n // Fallback keeps compatibility in runtimes that cannot resolve package-relative URLs.\n return DRACO_DECODER_CDN_PATH;\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
- import { createTransform, applyTransform, resolveDracoDecoderPath, loadSharedGltf, cloneModelScene } from './chunk-NJOO7NO6.js';
2
- import { AnimationComponent, AudioComponent, Object3DRef, CameraComponent, MeshGeometryComponent, PhysicsComponent, Environment, EntityType, ImageComponent, ImageTargetAnchor, ImageTarget, LightComponent, MaterialComponent, MeshComponent, ModelComponent, Name, ParentId, Postprocessing, ScriptComponent, ScriptObjectComponent, Selectable, SelectionTransformState, SpriteComponent, TransformComponent, InstancedMeshComponent, InstanceSlotComponent, VideoComponent, XRRigComponent, VRTeleportAreaComponent, XRHandPoseComponent, XRInteractableComponent, XRInteractorComponent, XRInteractorSideComponent, DEFAULT_INSTANCE_TRANSFORM } from './chunk-ELSZ5U3F.js';
1
+ import { createTransform, applyTransform, resolveDracoDecoderPath, loadSharedGltf, cloneModelScene } from './chunk-7ZIN6TGT.js';
2
+ import { AnimationComponent, AudioComponent, Object3DRef, CameraComponent, MeshGeometryComponent, PhysicsComponent, Environment, EntityType, ImageComponent, ImageTargetAnchor, ImageTarget, LightComponent, MaterialComponent, MeshComponent, ModelComponent, Name, ParentId, Postprocessing, ScriptComponent, ScriptObjectComponent, Selectable, SelectionTransformState, SpriteComponent, TransformComponent, InstancedMeshComponent, InstanceSlotComponent, VideoComponent, XRRigComponent, VRTeleportAreaComponent, XRHandPoseComponent, XRInteractableComponent, XRInteractorComponent, XRInteractorSideComponent, DEFAULT_INSTANCE_TRANSFORM } from './chunk-OMDYLFTN.js';
3
3
  import { __name } from './chunk-OY7ZODZP.js';
4
4
  import * as THREE25 from 'three';
5
5
  import { RectAreaLightHelper } from 'three/examples/jsm/helpers/RectAreaLightHelper.js';
@@ -1665,5 +1665,5 @@ function registerDefaultFactories(objectManagementSystem) {
1665
1665
  __name(registerDefaultFactories, "registerDefaultFactories");
1666
1666
 
1667
1667
  export { createAnimationComponent, createAudioComponent, createCameraComponent, createEntityTypeComponent, createEnvironmentComponent, createImageComponent, createImageTargetAnchorComponent, createImageTargetComponent, createInstanceSlotComponent, createInstancedMeshComponent, createLightComponent, createMaterialComponent, createMeshComponent, createMeshGeometryComponent, createModelComponent, createNameComponent, createObject3DRefComponent, createParentIdComponent, createPhysicsComponent, createPostprocessingComponent, createScriptComponent, createScriptObjectComponent, createSelectableComponent, createSelectionTransformStateComponent, createSpriteComponent, createTransformComponent, createVRTeleportAreaComponent, createVideoComponent, createXRHandPoseComponent, createXRInteractableComponent, createXRInteractorComponent, createXRInteractorSideComponent, createXRRigComponent, registerDefaultComponentFactories, registerDefaultFactories };
1668
- //# sourceMappingURL=chunk-5UVBEAGW.js.map
1669
- //# sourceMappingURL=chunk-5UVBEAGW.js.map
1668
+ //# sourceMappingURL=chunk-ID7U4FER.js.map
1669
+ //# sourceMappingURL=chunk-ID7U4FER.js.map