@relu-interactives/spatial-ecs 0.3.13 → 0.3.15

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 (39) hide show
  1. package/dist/{System-31wk-A0g.d.cts → System-BhnLw0fZ.d.cts} +7 -0
  2. package/dist/{System-31wk-A0g.d.ts → System-BhnLw0fZ.d.ts} +7 -0
  3. package/dist/{XRHandPose-9mVZVU3K.d.cts → XRHandPose-LR4EhboN.d.cts} +1 -1
  4. package/dist/{XRHandPose-To0260Lc.d.ts → XRHandPose-SZ7ou63b.d.ts} +1 -1
  5. package/dist/{chunk-N2634D4W.js → chunk-GULLCPO6.js} +63 -13
  6. package/dist/chunk-GULLCPO6.js.map +1 -0
  7. package/dist/{chunk-CHZQ4NXP.js → chunk-PNQ7HDQC.js} +2 -2
  8. package/dist/{chunk-CHZQ4NXP.js.map → chunk-PNQ7HDQC.js.map} +1 -1
  9. package/dist/{chunk-JHFBEMXM.js → chunk-UHJ4MDIM.js} +6 -3
  10. package/dist/chunk-UHJ4MDIM.js.map +1 -0
  11. package/dist/components/index.d.cts +3 -3
  12. package/dist/components/index.d.ts +3 -3
  13. package/dist/docs/guide/vr-and-hand-poses.md +12 -1
  14. package/dist/factories/index.cjs +3 -0
  15. package/dist/factories/index.cjs.map +1 -1
  16. package/dist/factories/index.d.cts +2 -2
  17. package/dist/factories/index.d.ts +2 -2
  18. package/dist/factories/index.js +2 -2
  19. package/dist/{index-lqw8BM6E.d.cts → index-BKGV3VvQ.d.cts} +11 -4
  20. package/dist/{index-BPKDsVF7.d.cts → index-BL5EWkwY.d.cts} +2 -2
  21. package/dist/{index-BbXqWyEZ.d.ts → index-Bi7L3QHF.d.ts} +11 -4
  22. package/dist/{index-Wzs-8FYa.d.ts → index-ByiUoIoh.d.ts} +2 -2
  23. package/dist/index.cjs +63 -9
  24. package/dist/index.cjs.map +1 -1
  25. package/dist/index.d.cts +45 -8
  26. package/dist/index.d.ts +45 -8
  27. package/dist/index.js +6 -6
  28. package/dist/systems/index.cjs +59 -9
  29. package/dist/systems/index.cjs.map +1 -1
  30. package/dist/systems/index.d.cts +2 -2
  31. package/dist/systems/index.d.ts +2 -2
  32. package/dist/systems/index.js +2 -2
  33. package/dist/types.d.cts +1 -1
  34. package/dist/types.d.ts +1 -1
  35. package/dist/worldSnapshotUtils.d.cts +1 -1
  36. package/dist/worldSnapshotUtils.d.ts +1 -1
  37. package/package.json +1 -1
  38. package/dist/chunk-JHFBEMXM.js.map +0 -1
  39. package/dist/chunk-N2634D4W.js.map +0 -1
@@ -603,6 +603,13 @@ type CreatePayload = {
603
603
  options?: Record<string, unknown>;
604
604
  camera?: Record<string, unknown>;
605
605
  useWorldCamera?: boolean;
606
+ /**
607
+ * Suppress the default child entities a factory would otherwise create.
608
+ *
609
+ * Set during hydration: the snapshot already contains those children, so
610
+ * letting the factory add its own too duplicates them on every load.
611
+ */
612
+ skipDefaultChildren?: boolean;
606
613
  };
607
614
  type CreateContext = {
608
615
  world: World;
@@ -603,6 +603,13 @@ type CreatePayload = {
603
603
  options?: Record<string, unknown>;
604
604
  camera?: Record<string, unknown>;
605
605
  useWorldCamera?: boolean;
606
+ /**
607
+ * Suppress the default child entities a factory would otherwise create.
608
+ *
609
+ * Set during hydration: the snapshot already contains those children, so
610
+ * letting the factory add its own too duplicates them on every load.
611
+ */
612
+ skipDefaultChildren?: boolean;
606
613
  };
607
614
  type CreateContext = {
608
615
  world: World;
@@ -1,5 +1,5 @@
1
1
  import * as THREE from 'three';
2
- import { C as Component, p as EcsEntityKind, F as EcsEntityEditorKind, r as EntityId } from './System-31wk-A0g.cjs';
2
+ import { C as Component, p as EcsEntityKind, F as EcsEntityEditorKind, r as EntityId } from './System-BhnLw0fZ.cjs';
3
3
  import * as RAPIER from '@dimforge/rapier3d-compat';
4
4
  import { a as XrFinger, b as XrHandPoseOrientation, X as XrHandPoseDefinition } from './handPose-dFxqbFFY.cjs';
5
5
 
@@ -1,5 +1,5 @@
1
1
  import * as THREE from 'three';
2
- import { C as Component, p as EcsEntityKind, F as EcsEntityEditorKind, r as EntityId } from './System-31wk-A0g.js';
2
+ import { C as Component, p as EcsEntityKind, F as EcsEntityEditorKind, r as EntityId } from './System-BhnLw0fZ.js';
3
3
  import * as RAPIER from '@dimforge/rapier3d-compat';
4
4
  import { a as XrFinger, b as XrHandPoseOrientation, X as XrHandPoseDefinition } from './handPose-dFxqbFFY.js';
5
5
 
@@ -1,4 +1,4 @@
1
- import { resolveDracoDecoderPath, applyTransform, SHARED_MODEL_RESOURCE_FLAG } from './chunk-CHZQ4NXP.js';
1
+ import { resolveDracoDecoderPath, applyTransform, SHARED_MODEL_RESOURCE_FLAG } from './chunk-PNQ7HDQC.js';
2
2
  import { AnimationComponent, ModelComponent, CameraComponent, Object3DRef, Environment, Postprocessing, TransformComponent, PhysicsComponent, setPhysicsLiveRef, LightComponent, MaterialComponent, DEFAULT_MESH_GEOMETRY_PARAMETERS, MeshGeometryComponent, InstancedMeshComponent, ParentId, ScriptComponent, ScriptObjectComponent, XRRigComponent, VRTeleportAreaComponent, XRInteractableComponent, createAttachPoint, XRHandPoseComponent, createHandPoseEntry, XRInteractorComponent, XRInteractorSideComponent, InstanceSlotComponent, Name, ImageComponent, SpriteComponent, VideoComponent, AudioComponent, ImageTarget, Selectable, PrefabNode, PrefabInstance, handPoseDefinitionFor, getHandPosePreset } from './chunk-3LDQ4GVZ.js';
3
3
  import { __name } from './chunk-OY7ZODZP.js';
4
4
  import * as THREE19 from 'three';
@@ -3945,6 +3945,7 @@ function hydrateWorldFromSnapshotDetailed(snapshot, world, objectManagementSyste
3945
3945
  isDefault: true
3946
3946
  };
3947
3947
  }
3948
+ payload.skipDefaultChildren = true;
3948
3949
  const createdEntityId = objectManagementSystem.createNow(kind, world, payload);
3949
3950
  idMap.set(sourceEntityId, createdEntityId);
3950
3951
  }
@@ -7204,17 +7205,22 @@ var _XRInteractionSystem = class _XRInteractionSystem {
7204
7205
  return this.grabs.size > 0;
7205
7206
  }
7206
7207
  /**
7207
- * Whether this hand's primary action is committed to interaction.
7208
+ * Whether this input's primary action is committed to interaction.
7208
7209
  *
7209
- * True while the hand holds something, and also while it merely HOVERS a
7210
+ * True while the source holds something, and also while it merely HOVERS a
7210
7211
  * grabbable — because the pinch that is about to grab must not be read as a
7211
7212
  * teleport by the locomotion system. Without the hover half, the first pinch
7212
7213
  * of a grab teleports the player, and so does the pinch that takes an object
7213
7214
  * from the other hand.
7215
+ *
7216
+ * Keyed on the INPUT SOURCE rather than handedness. Vision Pro reports
7217
+ * `handedness: "none"` for every gaze-pinch (it is hard-coded in WebKit), so a
7218
+ * handedness-keyed check silently never matched there and each pinch both
7219
+ * grabbed and teleported.
7214
7220
  */
7215
- isHandBusy(world, handedness) {
7216
- if (this.isGrabbingWith(handedness)) return true;
7217
- const hover = this.getHoverFor(handedness);
7221
+ isSourceBusy(world, input) {
7222
+ if (this.grabs.has(input)) return true;
7223
+ const hover = this.hovers.get(input);
7218
7224
  if (!hover) return false;
7219
7225
  const interactable = world.getComponent(
7220
7226
  hover.entityId,
@@ -7293,6 +7299,42 @@ function arcGroundCrossing(points, groundY) {
7293
7299
  }
7294
7300
  __name(arcGroundCrossing, "arcGroundCrossing");
7295
7301
 
7302
+ // core/xr/teleportAimGate.ts
7303
+ var _TeleportAimGate = class _TeleportAimGate {
7304
+ constructor() {
7305
+ this.aiming = /* @__PURE__ */ new WeakSet();
7306
+ }
7307
+ /**
7308
+ * Feed one frame for one source.
7309
+ *
7310
+ * @returns whether the teleport should commit this frame.
7311
+ */
7312
+ update(source, aiming, releasing) {
7313
+ const hadAim = this.aiming.has(source);
7314
+ if (aiming) this.aiming.add(source);
7315
+ if (!releasing) return false;
7316
+ this.aiming.delete(source);
7317
+ return hadAim || aiming;
7318
+ }
7319
+ /** True if this source currently has an aim engaged. */
7320
+ isAiming(source) {
7321
+ return this.aiming.has(source);
7322
+ }
7323
+ /**
7324
+ * Drop a source's aim without committing.
7325
+ *
7326
+ * Called when a hand starts interacting, so the release that ends the grab
7327
+ * cannot cash in an aim engaged before it.
7328
+ *
7329
+ * @returns whether an aim was actually discarded.
7330
+ */
7331
+ cancel(source) {
7332
+ return this.aiming.delete(source);
7333
+ }
7334
+ };
7335
+ __name(_TeleportAimGate, "TeleportAimGate");
7336
+ var TeleportAimGate = _TeleportAimGate;
7337
+
7296
7338
  // core/systems/XRLocomotionSystem.ts
7297
7339
  var UP = new THREE19.Vector3(0, 1, 0);
7298
7340
  var AXIS_DEADZONE = 0.5;
@@ -7310,6 +7352,8 @@ var _XRLocomotionSystem = class _XRLocomotionSystem {
7310
7352
  this.aimValid = false;
7311
7353
  /** Sources currently aiming via thumbstick (hysteresis, so it doesn't chatter). */
7312
7354
  this.stickAiming = /* @__PURE__ */ new WeakSet();
7355
+ /** Gates teleport commits on a prior aim. See {@link TeleportAimGate}. */
7356
+ this.teleportAim = new TeleportAimGate();
7313
7357
  /** True once we've tried to self-heal camera parenting for this session. */
7314
7358
  this.parentingChecked = false;
7315
7359
  /**
@@ -7443,13 +7487,19 @@ var _XRLocomotionSystem = class _XRLocomotionSystem {
7443
7487
  applyTeleport(world, transform, inputs) {
7444
7488
  const targets = this.collectTeleportTargets(world);
7445
7489
  for (const input of inputs) {
7446
- if (input.handedness !== "none" && this.interactionSystem?.isHandBusy(world, input.handedness)) {
7490
+ const source = input;
7491
+ if (this.interactionSystem?.isSourceBusy(world, input)) {
7492
+ if (this.teleportAim.cancel(source)) {
7493
+ this.aimCurve = [];
7494
+ this.landingPoint = null;
7495
+ this.aimValid = false;
7496
+ }
7447
7497
  continue;
7448
7498
  }
7449
- const source = input;
7450
7499
  const stick = this.readStickAim(input, source);
7451
- const aiming = input.select || stick.aiming;
7452
- const commit = input.selectEnd || stick.released;
7500
+ const aiming = input.select || input.selectStart || stick.aiming;
7501
+ const releasing = input.selectEnd || stick.released;
7502
+ const commit = this.teleportAim.update(source, aiming, releasing);
7453
7503
  if (!aiming && !commit) continue;
7454
7504
  const points = sampleTeleportArc(
7455
7505
  input.rayOrigin,
@@ -8815,6 +8865,6 @@ var _XRHoverVisualSystem = class _XRHoverVisualSystem {
8815
8865
  __name(_XRHoverVisualSystem, "XRHoverVisualSystem");
8816
8866
  var XRHoverVisualSystem = _XRHoverVisualSystem;
8817
8867
 
8818
- export { ADDED_NODE_MARKER_COMPONENT, ARC_GRAVITY, ARC_MAX_TIME, ARC_SPEED, ARC_STEPS, AnimationSystem, AudioSystem, Behaviour, CURLED_COS, CameraSyncSystem, DEFAULT_ENTER_CONFIDENCE, DEFAULT_EXIT_CONFIDENCE, DEFAULT_LOST_GRACE_SECONDS, DEFAULT_MIN_HOLD_SECONDS, EnvironmentSyncSystem, FALLBACK_HAND_SCALE, HYDRATABLE_ENTITY_KINDS, HandPoseTracker, InputSystem, InstancedMeshSystem, KeyboardKeys, LightSyncSystem, MATCH_FALLOFF, MAX_PLAUSIBLE_SPEED, MAX_SAMPLE_AGE_SECONDS, MaterialSyncSystem, MeshGeometrySystem, NODE_KEY_SEPARATOR, NO_XR_CAPABILITIES, OVERRIDE_DIFF_EXCLUDED_COMPONENTS, OVERRIDE_ROOT_EXCLUDED_COMPONENTS, ObjectVisibilitySystem, PINCH_FINGERS, PREFAB_FILE_VERSION, PREFAB_FILE_VERSION_NESTED, PhysicsSyncSystem, PostprocessingSyncSystem, RenderSystem, SCRIPT_OBJECT_ROOT_FLAG, STRAIGHT_COS, ScriptBehaviourSystem, ScriptObject, ScriptObjectSystem, ThrowVelocityTracker, TransformSyncSystem, VELOCITY_SAMPLES, VRTeleportAreaSystem, VideoSystem, XRControllerVisualSystem, XRHandPoseSystem, XRHoverVisualSystem, XRInputSystem, XRInteractionSystem, XRLocomotionSystem, XRSessionSystem, XRTeleportVisualSystem, XR_FINGERS, XR_HOVER_SHELL_FLAG, angularVelocityFrom, applyHandMaterial, arcGroundCrossing, buildComponentValueMaps, buildNodeKeyMapsFromSnapshot, buildNodeMapsFromSnapshot, canonicalizeComponentValue, clearPrefabCache, collectDiffPaths, collectEntitySubtree, collectSnapshotSubtreeIds, computeFingerCurl, computeHandShape, computeInstanceOverrides, computePalmPose, computePalmWidth, computePinch, computeSpread, createHandMaterial, decanonicalizeComponentValue, despawnPrefab, encodeOverride, estimateHandScale, findSnapshotRootEntityIds, findTopLevelNestedRegions, groupOverridePaths, hydrateWorldFromSnapshot, hydrateWorldFromSnapshotDetailed, indexSnapshotByEntity, instantiateSubtree, loadPrefab, matchHandPose, mergeComponentValue, parseOverride, parsePrefabAsset, prefabFileVersionFor, readXrCapabilities, restoreComponentState, restorePostCreateComponents, sampleTeleportArc, setPrefabAssetUrlResolver, spawnPrefab };
8819
- //# sourceMappingURL=chunk-N2634D4W.js.map
8820
- //# sourceMappingURL=chunk-N2634D4W.js.map
8868
+ export { ADDED_NODE_MARKER_COMPONENT, ARC_GRAVITY, ARC_MAX_TIME, ARC_SPEED, ARC_STEPS, AnimationSystem, AudioSystem, Behaviour, CURLED_COS, CameraSyncSystem, DEFAULT_ENTER_CONFIDENCE, DEFAULT_EXIT_CONFIDENCE, DEFAULT_LOST_GRACE_SECONDS, DEFAULT_MIN_HOLD_SECONDS, EnvironmentSyncSystem, FALLBACK_HAND_SCALE, HYDRATABLE_ENTITY_KINDS, HandPoseTracker, InputSystem, InstancedMeshSystem, KeyboardKeys, LightSyncSystem, MATCH_FALLOFF, MAX_PLAUSIBLE_SPEED, MAX_SAMPLE_AGE_SECONDS, MaterialSyncSystem, MeshGeometrySystem, NODE_KEY_SEPARATOR, NO_XR_CAPABILITIES, OVERRIDE_DIFF_EXCLUDED_COMPONENTS, OVERRIDE_ROOT_EXCLUDED_COMPONENTS, ObjectVisibilitySystem, PINCH_FINGERS, PREFAB_FILE_VERSION, PREFAB_FILE_VERSION_NESTED, PhysicsSyncSystem, PostprocessingSyncSystem, RenderSystem, SCRIPT_OBJECT_ROOT_FLAG, STRAIGHT_COS, ScriptBehaviourSystem, ScriptObject, ScriptObjectSystem, TeleportAimGate, ThrowVelocityTracker, TransformSyncSystem, VELOCITY_SAMPLES, VRTeleportAreaSystem, VideoSystem, XRControllerVisualSystem, XRHandPoseSystem, XRHoverVisualSystem, XRInputSystem, XRInteractionSystem, XRLocomotionSystem, XRSessionSystem, XRTeleportVisualSystem, XR_FINGERS, XR_HOVER_SHELL_FLAG, angularVelocityFrom, applyHandMaterial, arcGroundCrossing, buildComponentValueMaps, buildNodeKeyMapsFromSnapshot, buildNodeMapsFromSnapshot, canonicalizeComponentValue, clearPrefabCache, collectDiffPaths, collectEntitySubtree, collectSnapshotSubtreeIds, computeFingerCurl, computeHandShape, computeInstanceOverrides, computePalmPose, computePalmWidth, computePinch, computeSpread, createHandMaterial, decanonicalizeComponentValue, despawnPrefab, encodeOverride, estimateHandScale, findSnapshotRootEntityIds, findTopLevelNestedRegions, groupOverridePaths, hydrateWorldFromSnapshot, hydrateWorldFromSnapshotDetailed, indexSnapshotByEntity, instantiateSubtree, loadPrefab, matchHandPose, mergeComponentValue, parseOverride, parsePrefabAsset, prefabFileVersionFor, readXrCapabilities, restoreComponentState, restorePostCreateComponents, sampleTeleportArc, setPrefabAssetUrlResolver, spawnPrefab };
8869
+ //# sourceMappingURL=chunk-GULLCPO6.js.map
8870
+ //# sourceMappingURL=chunk-GULLCPO6.js.map