@relu-interactives/spatial-ecs 0.3.4 → 0.3.5

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.
package/dist/index.d.cts CHANGED
@@ -3,8 +3,8 @@ export { A as AssetInput, t as CheckboxInput, u as ColorInput, v as ComponentFac
3
3
  import * as THREE from 'three';
4
4
  import { O as Object3DRef } from './XRRig-2686IqLQ.cjs';
5
5
  export { ag as AnimationStateCallbacks, ah as AnimationStateMachine, ai as AnimationStateManager, aj as StateMachine } from './XRRig-2686IqLQ.cjs';
6
- import { X as XrCapabilities, a as XrInputState } from './index-Bc0YCz1A.cjs';
7
- export { A as AnimationSystem, b as AudioSystem, C as CameraSyncSystem, E as EnvironmentSyncSystem, I as InstancedMeshSystem, L as LightSyncSystem, M as MaterialSyncSystem, c as MeshGeometrySystem, d as ModuleLoader, N as NO_XR_CAPABILITIES, O as ObjectVisibilitySystem, P as PhysicsSyncSystem, e as PostprocessingSyncSystem, S as SCRIPT_OBJECT_ROOT_FLAG, f as ScriptBehaviourSystem, g as ScriptObjectSystem, h as SelectionContext, V as VRTeleportAreaSystem, i as VideoSystem, j as XRControllerVisualSystem, k as XRInputSystem, l as XRInteractionSystem, m as XRLocomotionSystem, n as XRSessionSystem, o as XrHandedness, p as XrInputKind, r as readXrCapabilities } from './index-Bc0YCz1A.cjs';
6
+ import { X as XrCapabilities, a as XrInputState } from './index-BvCmmuJ0.cjs';
7
+ export { A as AnimationSystem, b as AudioSystem, C as CameraSyncSystem, E as EnvironmentSyncSystem, I as InstancedMeshSystem, L as LightSyncSystem, M as MaterialSyncSystem, c as MeshGeometrySystem, d as ModuleLoader, N as NO_XR_CAPABILITIES, O as ObjectVisibilitySystem, P as PhysicsSyncSystem, e as PostprocessingSyncSystem, S as SCRIPT_OBJECT_ROOT_FLAG, f as ScriptBehaviourSystem, g as ScriptObjectSystem, h as SelectionContext, V as VRTeleportAreaSystem, i as VideoSystem, j as XRControllerVisualSystem, k as XRInputSystem, l as XRInteractionSystem, m as XRLocomotionSystem, n as XRSessionSystem, o as XRTeleportVisualSystem, p as XrHandedness, q as XrInputKind, r as readXrCapabilities } from './index-BvCmmuJ0.cjs';
8
8
  export { i as CoreComponents } from './index-Xu238jLn.cjs';
9
9
  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, createXRInteractableComponent, createXRRigComponent, registerDefaultComponentFactories, registerDefaultFactories } from './factories/index.cjs';
10
10
  import { GLTF } from 'three/examples/jsm/loaders/GLTFLoader.js';
@@ -743,4 +743,45 @@ declare function serializeEntitySubtree(world: World, rootId: EntityId, options?
743
743
  maxDepth?: number;
744
744
  }): SerializeEntitySubtreeResult;
745
745
 
746
- export { ADDED_NODE_MARKER_COMPONENT, type ApplyPrefabToSnapshotResult, Behaviour, Component, type ComponentValueMaps, EcsEntityKind, EcsSystem, type EcsWorldComponentSnapshot, type EcsWorldStateSnapshotLike, EntityId, ExternalRefWarning, HYDRATABLE_ENTITY_KINDS, type HydrateOptions, type HydrateWorldFromSnapshotResult, type InstantiateSubtreeResult, NODE_KEY_SEPARATOR, type NestedRegion, type NodeKeyMaps, type NodeMaps, OVERRIDE_DIFF_EXCLUDED_COMPONENTS, OVERRIDE_ROOT_EXCLUDED_COMPONENTS, ObjectManagementSystem, ParentLookup, SHARED_MODEL_RESOURCE_FLAG, ScriptObject, type SerializeEntitySubtreeResult, SpawnPrefabOptions, SpawnPrefabSource, SubtreeSnapshot, World, WorldEntityView, XrCapabilities, XrInputState, applyPrefabToSnapshotInstances, buildComponentValueMaps, buildNodeKeyMapsFromSnapshot, buildNodeMapsFromSnapshot, canonicalizeComponentValue, clearModelCache, collectDiffPaths, collectDirectPrefabDependencies, collectEntitySubtree, collectSnapshotSubtreeIds, computeInstanceOverrides, decanonicalizeComponentValue, encodeOverride, findSnapshotRootEntityIds, findTopLevelNestedRegions, groupOverridePaths, hydrateWorldFromSnapshot, hydrateWorldFromSnapshotDetailed, indexSnapshotByEntity, instantiateSubtree, loadSharedGltf, mergeComponentValue, parseOverride, resolveDracoDecoderPath, restoreComponentState, restorePostCreateComponents, serializeEntitySubtree, setDracoDecoderPath };
746
+ /**
747
+ * Projectile-arc sampling for teleport aiming.
748
+ *
749
+ * A straight ray makes distance impossible to judge in VR — it gives the eye no
750
+ * cue about where it meets the floor, so users consistently over- or
751
+ * under-shoot. A ballistic arc reads as a thrown object: the apex and the
752
+ * downward approach tell you exactly where it lands. Every mature VR locomotion
753
+ * implementation uses one.
754
+ *
755
+ * Pure and side-effect free so the curve can be unit-tested without a headset.
756
+ */
757
+ /** Downward acceleration applied to the aim curve, m/s². */
758
+ declare const ARC_GRAVITY = 9.8;
759
+ /** Launch speed of the virtual projectile, m/s. Tuned for ~5-8m reach. */
760
+ declare const ARC_SPEED = 7;
761
+ /** Samples along the curve. Enough to look smooth without wasting raycasts. */
762
+ declare const ARC_STEPS = 24;
763
+ /** Seconds of flight to simulate before giving up on finding ground. */
764
+ declare const ARC_MAX_TIME = 2;
765
+ /**
766
+ * Sample a ballistic curve starting at `origin` heading along `direction`.
767
+ *
768
+ * Returns points in world space, oldest first. The caller raycasts consecutive
769
+ * pairs to find where the arc meets a teleport surface — sampling and
770
+ * intersection are kept separate so this stays testable.
771
+ */
772
+ declare function sampleTeleportArc(origin: THREE.Vector3, direction: THREE.Vector3, out?: THREE.Vector3[], options?: {
773
+ speed?: number;
774
+ gravity?: number;
775
+ steps?: number;
776
+ maxTime?: number;
777
+ }): THREE.Vector3[];
778
+ /**
779
+ * Where a sampled arc first crosses `groundY` going downward, or null.
780
+ *
781
+ * Used as a cheap pre-check before raycasting: if the curve never descends to
782
+ * the floor plane there is nothing to hit, so we can skip the per-segment
783
+ * intersection work entirely.
784
+ */
785
+ declare function arcGroundCrossing(points: THREE.Vector3[], groundY: number): THREE.Vector3 | null;
786
+
787
+ export { ADDED_NODE_MARKER_COMPONENT, ARC_GRAVITY, ARC_MAX_TIME, ARC_SPEED, ARC_STEPS, type ApplyPrefabToSnapshotResult, Behaviour, Component, type ComponentValueMaps, EcsEntityKind, EcsSystem, type EcsWorldComponentSnapshot, type EcsWorldStateSnapshotLike, EntityId, ExternalRefWarning, HYDRATABLE_ENTITY_KINDS, type HydrateOptions, type HydrateWorldFromSnapshotResult, type InstantiateSubtreeResult, NODE_KEY_SEPARATOR, type NestedRegion, type NodeKeyMaps, type NodeMaps, OVERRIDE_DIFF_EXCLUDED_COMPONENTS, OVERRIDE_ROOT_EXCLUDED_COMPONENTS, ObjectManagementSystem, ParentLookup, SHARED_MODEL_RESOURCE_FLAG, ScriptObject, type SerializeEntitySubtreeResult, SpawnPrefabOptions, SpawnPrefabSource, SubtreeSnapshot, World, WorldEntityView, XrCapabilities, XrInputState, applyPrefabToSnapshotInstances, arcGroundCrossing, buildComponentValueMaps, buildNodeKeyMapsFromSnapshot, buildNodeMapsFromSnapshot, canonicalizeComponentValue, clearModelCache, collectDiffPaths, collectDirectPrefabDependencies, collectEntitySubtree, collectSnapshotSubtreeIds, computeInstanceOverrides, decanonicalizeComponentValue, encodeOverride, findSnapshotRootEntityIds, findTopLevelNestedRegions, groupOverridePaths, hydrateWorldFromSnapshot, hydrateWorldFromSnapshotDetailed, indexSnapshotByEntity, instantiateSubtree, loadSharedGltf, mergeComponentValue, parseOverride, resolveDracoDecoderPath, restoreComponentState, restorePostCreateComponents, sampleTeleportArc, serializeEntitySubtree, setDracoDecoderPath };
package/dist/index.d.ts CHANGED
@@ -3,8 +3,8 @@ export { A as AssetInput, t as CheckboxInput, u as ColorInput, v as ComponentFac
3
3
  import * as THREE from 'three';
4
4
  import { O as Object3DRef } from './XRRig-D2QURXl1.js';
5
5
  export { ag as AnimationStateCallbacks, ah as AnimationStateMachine, ai as AnimationStateManager, aj as StateMachine } from './XRRig-D2QURXl1.js';
6
- import { X as XrCapabilities, a as XrInputState } from './index-CRmfSYdj.js';
7
- export { A as AnimationSystem, b as AudioSystem, C as CameraSyncSystem, E as EnvironmentSyncSystem, I as InstancedMeshSystem, L as LightSyncSystem, M as MaterialSyncSystem, c as MeshGeometrySystem, d as ModuleLoader, N as NO_XR_CAPABILITIES, O as ObjectVisibilitySystem, P as PhysicsSyncSystem, e as PostprocessingSyncSystem, S as SCRIPT_OBJECT_ROOT_FLAG, f as ScriptBehaviourSystem, g as ScriptObjectSystem, h as SelectionContext, V as VRTeleportAreaSystem, i as VideoSystem, j as XRControllerVisualSystem, k as XRInputSystem, l as XRInteractionSystem, m as XRLocomotionSystem, n as XRSessionSystem, o as XrHandedness, p as XrInputKind, r as readXrCapabilities } from './index-CRmfSYdj.js';
6
+ import { X as XrCapabilities, a as XrInputState } from './index-B-CViRMx.js';
7
+ export { A as AnimationSystem, b as AudioSystem, C as CameraSyncSystem, E as EnvironmentSyncSystem, I as InstancedMeshSystem, L as LightSyncSystem, M as MaterialSyncSystem, c as MeshGeometrySystem, d as ModuleLoader, N as NO_XR_CAPABILITIES, O as ObjectVisibilitySystem, P as PhysicsSyncSystem, e as PostprocessingSyncSystem, S as SCRIPT_OBJECT_ROOT_FLAG, f as ScriptBehaviourSystem, g as ScriptObjectSystem, h as SelectionContext, V as VRTeleportAreaSystem, i as VideoSystem, j as XRControllerVisualSystem, k as XRInputSystem, l as XRInteractionSystem, m as XRLocomotionSystem, n as XRSessionSystem, o as XRTeleportVisualSystem, p as XrHandedness, q as XrInputKind, r as readXrCapabilities } from './index-B-CViRMx.js';
8
8
  export { i as CoreComponents } from './index-BtKOaHfY.js';
9
9
  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, createXRInteractableComponent, createXRRigComponent, registerDefaultComponentFactories, registerDefaultFactories } from './factories/index.js';
10
10
  import { GLTF } from 'three/examples/jsm/loaders/GLTFLoader.js';
@@ -743,4 +743,45 @@ declare function serializeEntitySubtree(world: World, rootId: EntityId, options?
743
743
  maxDepth?: number;
744
744
  }): SerializeEntitySubtreeResult;
745
745
 
746
- export { ADDED_NODE_MARKER_COMPONENT, type ApplyPrefabToSnapshotResult, Behaviour, Component, type ComponentValueMaps, EcsEntityKind, EcsSystem, type EcsWorldComponentSnapshot, type EcsWorldStateSnapshotLike, EntityId, ExternalRefWarning, HYDRATABLE_ENTITY_KINDS, type HydrateOptions, type HydrateWorldFromSnapshotResult, type InstantiateSubtreeResult, NODE_KEY_SEPARATOR, type NestedRegion, type NodeKeyMaps, type NodeMaps, OVERRIDE_DIFF_EXCLUDED_COMPONENTS, OVERRIDE_ROOT_EXCLUDED_COMPONENTS, ObjectManagementSystem, ParentLookup, SHARED_MODEL_RESOURCE_FLAG, ScriptObject, type SerializeEntitySubtreeResult, SpawnPrefabOptions, SpawnPrefabSource, SubtreeSnapshot, World, WorldEntityView, XrCapabilities, XrInputState, applyPrefabToSnapshotInstances, buildComponentValueMaps, buildNodeKeyMapsFromSnapshot, buildNodeMapsFromSnapshot, canonicalizeComponentValue, clearModelCache, collectDiffPaths, collectDirectPrefabDependencies, collectEntitySubtree, collectSnapshotSubtreeIds, computeInstanceOverrides, decanonicalizeComponentValue, encodeOverride, findSnapshotRootEntityIds, findTopLevelNestedRegions, groupOverridePaths, hydrateWorldFromSnapshot, hydrateWorldFromSnapshotDetailed, indexSnapshotByEntity, instantiateSubtree, loadSharedGltf, mergeComponentValue, parseOverride, resolveDracoDecoderPath, restoreComponentState, restorePostCreateComponents, serializeEntitySubtree, setDracoDecoderPath };
746
+ /**
747
+ * Projectile-arc sampling for teleport aiming.
748
+ *
749
+ * A straight ray makes distance impossible to judge in VR — it gives the eye no
750
+ * cue about where it meets the floor, so users consistently over- or
751
+ * under-shoot. A ballistic arc reads as a thrown object: the apex and the
752
+ * downward approach tell you exactly where it lands. Every mature VR locomotion
753
+ * implementation uses one.
754
+ *
755
+ * Pure and side-effect free so the curve can be unit-tested without a headset.
756
+ */
757
+ /** Downward acceleration applied to the aim curve, m/s². */
758
+ declare const ARC_GRAVITY = 9.8;
759
+ /** Launch speed of the virtual projectile, m/s. Tuned for ~5-8m reach. */
760
+ declare const ARC_SPEED = 7;
761
+ /** Samples along the curve. Enough to look smooth without wasting raycasts. */
762
+ declare const ARC_STEPS = 24;
763
+ /** Seconds of flight to simulate before giving up on finding ground. */
764
+ declare const ARC_MAX_TIME = 2;
765
+ /**
766
+ * Sample a ballistic curve starting at `origin` heading along `direction`.
767
+ *
768
+ * Returns points in world space, oldest first. The caller raycasts consecutive
769
+ * pairs to find where the arc meets a teleport surface — sampling and
770
+ * intersection are kept separate so this stays testable.
771
+ */
772
+ declare function sampleTeleportArc(origin: THREE.Vector3, direction: THREE.Vector3, out?: THREE.Vector3[], options?: {
773
+ speed?: number;
774
+ gravity?: number;
775
+ steps?: number;
776
+ maxTime?: number;
777
+ }): THREE.Vector3[];
778
+ /**
779
+ * Where a sampled arc first crosses `groundY` going downward, or null.
780
+ *
781
+ * Used as a cheap pre-check before raycasting: if the curve never descends to
782
+ * the floor plane there is nothing to hit, so we can skip the per-segment
783
+ * intersection work entirely.
784
+ */
785
+ declare function arcGroundCrossing(points: THREE.Vector3[], groundY: number): THREE.Vector3 | null;
786
+
787
+ export { ADDED_NODE_MARKER_COMPONENT, ARC_GRAVITY, ARC_MAX_TIME, ARC_SPEED, ARC_STEPS, type ApplyPrefabToSnapshotResult, Behaviour, Component, type ComponentValueMaps, EcsEntityKind, EcsSystem, type EcsWorldComponentSnapshot, type EcsWorldStateSnapshotLike, EntityId, ExternalRefWarning, HYDRATABLE_ENTITY_KINDS, type HydrateOptions, type HydrateWorldFromSnapshotResult, type InstantiateSubtreeResult, NODE_KEY_SEPARATOR, type NestedRegion, type NodeKeyMaps, type NodeMaps, OVERRIDE_DIFF_EXCLUDED_COMPONENTS, OVERRIDE_ROOT_EXCLUDED_COMPONENTS, ObjectManagementSystem, ParentLookup, SHARED_MODEL_RESOURCE_FLAG, ScriptObject, type SerializeEntitySubtreeResult, SpawnPrefabOptions, SpawnPrefabSource, SubtreeSnapshot, World, WorldEntityView, XrCapabilities, XrInputState, applyPrefabToSnapshotInstances, arcGroundCrossing, buildComponentValueMaps, buildNodeKeyMapsFromSnapshot, buildNodeMapsFromSnapshot, canonicalizeComponentValue, clearModelCache, collectDiffPaths, collectDirectPrefabDependencies, collectEntitySubtree, collectSnapshotSubtreeIds, computeInstanceOverrides, decanonicalizeComponentValue, encodeOverride, findSnapshotRootEntityIds, findTopLevelNestedRegions, groupOverridePaths, hydrateWorldFromSnapshot, hydrateWorldFromSnapshotDetailed, indexSnapshotByEntity, instantiateSubtree, loadSharedGltf, mergeComponentValue, parseOverride, resolveDracoDecoderPath, restoreComponentState, restorePostCreateComponents, sampleTeleportArc, serializeEntitySubtree, setDracoDecoderPath };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { MeshGeometrySystem, InstancedMeshSystem, EnvironmentSyncSystem, PostprocessingSyncSystem, LightSyncSystem, MaterialSyncSystem, VRTeleportAreaSystem, PhysicsSyncSystem, AnimationSystem, AudioSystem, VideoSystem, CameraSyncSystem, TransformSyncSystem, ObjectVisibilitySystem, RenderSystem, spawnPrefab, despawnPrefab, buildNodeKeyMapsFromSnapshot, indexSnapshotByEntity, findTopLevelNestedRegions, collectSnapshotSubtreeIds, groupOverridePaths, OVERRIDE_DIFF_EXCLUDED_COMPONENTS, OVERRIDE_ROOT_EXCLUDED_COMPONENTS, canonicalizeComponentValue, mergeComponentValue, decanonicalizeComponentValue, computeInstanceOverrides, collectEntitySubtree, ADDED_NODE_MARKER_COMPONENT } from './chunk-ID266ZUA.js';
2
- export { ADDED_NODE_MARKER_COMPONENT, AnimationSystem, AudioSystem, Behaviour, CameraSyncSystem, EnvironmentSyncSystem, HYDRATABLE_ENTITY_KINDS, InputSystem, InstancedMeshSystem, KeyboardKeys, LightSyncSystem, MaterialSyncSystem, MeshGeometrySystem, NODE_KEY_SEPARATOR, NO_XR_CAPABILITIES, OVERRIDE_DIFF_EXCLUDED_COMPONENTS, OVERRIDE_ROOT_EXCLUDED_COMPONENTS, ObjectVisibilitySystem, PREFAB_FILE_VERSION, PREFAB_FILE_VERSION_NESTED, PhysicsSyncSystem, PostprocessingSyncSystem, RenderSystem, SCRIPT_OBJECT_ROOT_FLAG, ScriptBehaviourSystem, ScriptObject, ScriptObjectSystem, TransformSyncSystem, VRTeleportAreaSystem, VideoSystem, XRControllerVisualSystem, XRInputSystem, XRInteractionSystem, XRLocomotionSystem, XRSessionSystem, buildComponentValueMaps, buildNodeKeyMapsFromSnapshot, buildNodeMapsFromSnapshot, canonicalizeComponentValue, clearPrefabCache, collectDiffPaths, collectEntitySubtree, collectSnapshotSubtreeIds, computeInstanceOverrides, decanonicalizeComponentValue, despawnPrefab, encodeOverride, findSnapshotRootEntityIds, findTopLevelNestedRegions, groupOverridePaths, hydrateWorldFromSnapshot, hydrateWorldFromSnapshotDetailed, indexSnapshotByEntity, instantiateSubtree, loadPrefab, mergeComponentValue, parseOverride, parsePrefabAsset, prefabFileVersionFor, readXrCapabilities, restoreComponentState, restorePostCreateComponents, setPrefabAssetUrlResolver, spawnPrefab } from './chunk-ID266ZUA.js';
1
+ import { MeshGeometrySystem, InstancedMeshSystem, EnvironmentSyncSystem, PostprocessingSyncSystem, LightSyncSystem, MaterialSyncSystem, VRTeleportAreaSystem, PhysicsSyncSystem, AnimationSystem, AudioSystem, VideoSystem, CameraSyncSystem, TransformSyncSystem, ObjectVisibilitySystem, RenderSystem, spawnPrefab, despawnPrefab, buildNodeKeyMapsFromSnapshot, indexSnapshotByEntity, findTopLevelNestedRegions, collectSnapshotSubtreeIds, groupOverridePaths, OVERRIDE_DIFF_EXCLUDED_COMPONENTS, OVERRIDE_ROOT_EXCLUDED_COMPONENTS, canonicalizeComponentValue, mergeComponentValue, decanonicalizeComponentValue, computeInstanceOverrides, collectEntitySubtree, ADDED_NODE_MARKER_COMPONENT } from './chunk-G53MZVKQ.js';
2
+ export { ADDED_NODE_MARKER_COMPONENT, ARC_GRAVITY, ARC_MAX_TIME, ARC_SPEED, ARC_STEPS, AnimationSystem, AudioSystem, Behaviour, CameraSyncSystem, EnvironmentSyncSystem, HYDRATABLE_ENTITY_KINDS, InputSystem, InstancedMeshSystem, KeyboardKeys, LightSyncSystem, MaterialSyncSystem, MeshGeometrySystem, NODE_KEY_SEPARATOR, NO_XR_CAPABILITIES, OVERRIDE_DIFF_EXCLUDED_COMPONENTS, OVERRIDE_ROOT_EXCLUDED_COMPONENTS, ObjectVisibilitySystem, PREFAB_FILE_VERSION, PREFAB_FILE_VERSION_NESTED, PhysicsSyncSystem, PostprocessingSyncSystem, RenderSystem, SCRIPT_OBJECT_ROOT_FLAG, ScriptBehaviourSystem, ScriptObject, ScriptObjectSystem, TransformSyncSystem, VRTeleportAreaSystem, VideoSystem, XRControllerVisualSystem, XRInputSystem, XRInteractionSystem, XRLocomotionSystem, XRSessionSystem, XRTeleportVisualSystem, arcGroundCrossing, buildComponentValueMaps, buildNodeKeyMapsFromSnapshot, buildNodeMapsFromSnapshot, canonicalizeComponentValue, clearPrefabCache, collectDiffPaths, collectEntitySubtree, collectSnapshotSubtreeIds, computeInstanceOverrides, decanonicalizeComponentValue, despawnPrefab, encodeOverride, findSnapshotRootEntityIds, findTopLevelNestedRegions, groupOverridePaths, hydrateWorldFromSnapshot, hydrateWorldFromSnapshotDetailed, indexSnapshotByEntity, instantiateSubtree, loadPrefab, mergeComponentValue, parseOverride, parsePrefabAsset, prefabFileVersionFor, readXrCapabilities, restoreComponentState, restorePostCreateComponents, sampleTeleportArc, setPrefabAssetUrlResolver, spawnPrefab } from './chunk-G53MZVKQ.js';
3
3
  import { registerDefaultFactories } from './chunk-4BZYK3JP.js';
4
4
  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, createXRInteractableComponent, createXRRigComponent, registerDefaultComponentFactories, registerDefaultFactories } from './chunk-4BZYK3JP.js';
5
5
  import { ObjectManagementSystem } from './chunk-2LVFGVWI.js';
@@ -7895,6 +7895,32 @@ var _XRInteractionSystem = class _XRInteractionSystem {
7895
7895
  };
7896
7896
  __name(_XRInteractionSystem, "XRInteractionSystem");
7897
7897
  var XRInteractionSystem = _XRInteractionSystem;
7898
+ var ARC_GRAVITY = 9.8;
7899
+ var ARC_SPEED = 7;
7900
+ var ARC_STEPS = 24;
7901
+ var ARC_MAX_TIME = 2;
7902
+ function sampleTeleportArc(origin, direction, out = [], options) {
7903
+ const speed = options?.speed ?? ARC_SPEED;
7904
+ const gravity = options?.gravity ?? ARC_GRAVITY;
7905
+ const steps = Math.max(2, options?.steps ?? ARC_STEPS);
7906
+ const maxTime = options?.maxTime ?? ARC_MAX_TIME;
7907
+ out.length = 0;
7908
+ const velocity = direction.clone().normalize().multiplyScalar(speed);
7909
+ for (let i = 0; i < steps; i += 1) {
7910
+ const t = i / (steps - 1) * maxTime;
7911
+ out.push(
7912
+ new THREE14__namespace.Vector3(
7913
+ origin.x + velocity.x * t,
7914
+ origin.y + velocity.y * t - 0.5 * gravity * t * t,
7915
+ origin.z + velocity.z * t
7916
+ )
7917
+ );
7918
+ }
7919
+ return out;
7920
+ }
7921
+ __name(sampleTeleportArc, "sampleTeleportArc");
7922
+
7923
+ // core/systems/XRLocomotionSystem.ts
7898
7924
  var UP = new THREE14__namespace.Vector3(0, 1, 0);
7899
7925
  var AXIS_DEADZONE = 0.5;
7900
7926
  var _XRLocomotionSystem = class _XRLocomotionSystem {
@@ -7902,13 +7928,26 @@ var _XRLocomotionSystem = class _XRLocomotionSystem {
7902
7928
  this.raycaster = new THREE14__namespace.Raycaster();
7903
7929
  /** Per-source latch so one stick push yields exactly one snap turn. */
7904
7930
  this.turnLatched = /* @__PURE__ */ new WeakSet();
7905
- /** Where the pointer currently lands, for the consumer to draw a marker. */
7906
- this.teleportPoint = null;
7931
+ /** Reused arc buffer — aiming runs every frame. */
7932
+ this.arcPoints = [];
7933
+ /** Curve up to the landing point, for the visual system. Empty when not aiming. */
7934
+ this.aimCurve = [];
7935
+ this.landingPoint = null;
7936
+ /** True once we've tried to self-heal camera parenting for this session. */
7937
+ this.parentingChecked = false;
7907
7938
  this.inputSystem = inputSystem;
7908
7939
  }
7909
7940
  update(world, deltaTime) {
7910
- this.teleportPoint = null;
7911
- if (!world.isXrPresenting()) return;
7941
+ this.aimCurve = [];
7942
+ this.landingPoint = null;
7943
+ if (!world.isXrPresenting()) {
7944
+ this.parentingChecked = false;
7945
+ return;
7946
+ }
7947
+ if (!this.parentingChecked) {
7948
+ this.parentingChecked = true;
7949
+ this.ensureCameraUnderRig(world);
7950
+ }
7912
7951
  const rigEntityId = world.query(XRRigComponent, TransformComponent)[0];
7913
7952
  if (typeof rigEntityId !== "number") return;
7914
7953
  const rig = world.getComponent(rigEntityId, XRRigComponent);
@@ -7925,9 +7964,37 @@ var _XRLocomotionSystem = class _XRLocomotionSystem {
7925
7964
  this.applySmoothMove(world, rig, rigTransform, inputs, deltaTime);
7926
7965
  }
7927
7966
  }
7967
+ /**
7968
+ * Guarantee the render camera is a CHILD of the rig.
7969
+ *
7970
+ * Locomotion moves the rig, and three composes the head pose against
7971
+ * `camera.parent` — so if the camera sits at the scene root instead, moving
7972
+ * the rig does nothing at all and the player is frozen in place. Scenes
7973
+ * authored before the rig existed (or with the camera re-parented by hand)
7974
+ * would otherwise silently fail to move, which is exactly the symptom that is
7975
+ * hardest to diagnose from inside a headset. Repairing it via `ParentId` lets
7976
+ * `ObjectManagementSystem` reconcile the scene graph normally.
7977
+ */
7978
+ ensureCameraUnderRig(world) {
7979
+ const rigEntityId = world.query(XRRigComponent)[0];
7980
+ if (typeof rigEntityId !== "number") return;
7981
+ const activeCamera = world.getCamera();
7982
+ for (const entityId of world.query(CameraComponent, Object3DRef)) {
7983
+ if (world.getComponent(entityId, Object3DRef)?.object !== activeCamera) {
7984
+ continue;
7985
+ }
7986
+ const parent = world.getComponent(entityId, ParentId);
7987
+ if (parent) {
7988
+ if (parent.value !== rigEntityId) parent.value = rigEntityId;
7989
+ } else {
7990
+ world.addComponent(entityId, new ParentId(rigEntityId));
7991
+ }
7992
+ return;
7993
+ }
7994
+ }
7928
7995
  /**
7929
7996
  * Snap turning, not smooth turning — rotating the view continuously is the
7930
- * single biggest cause of VR nausea, so the comfort-safe option is the one
7997
+ * single biggest cause of VR nausea, so the comfort-safe option is what's
7931
7998
  * wired to the stick.
7932
7999
  */
7933
8000
  applySnapTurn(rig, transform, inputs) {
@@ -7941,8 +8008,7 @@ var _XRLocomotionSystem = class _XRLocomotionSystem {
7941
8008
  }
7942
8009
  if (this.turnLatched.has(source)) continue;
7943
8010
  this.turnLatched.add(source);
7944
- const step = THREE14__namespace.MathUtils.degToRad(rig.snapTurnDegrees);
7945
- transform.rotation.y -= Math.sign(x) * step;
8011
+ transform.rotation.y -= Math.sign(x) * THREE14__namespace.MathUtils.degToRad(rig.snapTurnDegrees);
7946
8012
  }
7947
8013
  }
7948
8014
  applySmoothMove(world, rig, transform, inputs, deltaTime) {
@@ -7967,16 +8033,41 @@ var _XRLocomotionSystem = class _XRLocomotionSystem {
7967
8033
  const targets = this.collectTeleportTargets(world);
7968
8034
  if (targets.length === 0) return;
7969
8035
  for (const input of inputs) {
7970
- this.raycaster.set(input.rayOrigin, input.rayDirection);
7971
- const hit = this.raycaster.intersectObjects(targets, true)[0];
8036
+ if (!input.select && !input.selectEnd) continue;
8037
+ const points = sampleTeleportArc(
8038
+ input.rayOrigin,
8039
+ input.rayDirection,
8040
+ this.arcPoints
8041
+ );
8042
+ const hit = this.raycastArc(points, targets);
7972
8043
  if (!hit) continue;
7973
- this.teleportPoint = hit.point.clone();
8044
+ this.landingPoint = hit.point;
8045
+ this.aimCurve = points.slice(0, hit.segmentIndex + 1).concat(hit.point);
7974
8046
  if (input.selectEnd) {
7975
8047
  transform.position.x = hit.point.x;
7976
8048
  transform.position.y = hit.point.y;
7977
8049
  transform.position.z = hit.point.z;
8050
+ this.aimCurve = [];
8051
+ this.landingPoint = null;
8052
+ }
8053
+ }
8054
+ }
8055
+ /** Walk the arc segment-by-segment, returning the first surface hit. */
8056
+ raycastArc(points, targets) {
8057
+ for (let i = 1; i < points.length; i += 1) {
8058
+ const from = points[i - 1];
8059
+ const to = points[i];
8060
+ const delta = new THREE14__namespace.Vector3().subVectors(to, from);
8061
+ const distance = delta.length();
8062
+ if (distance < 1e-6) continue;
8063
+ this.raycaster.set(from, delta.divideScalar(distance));
8064
+ this.raycaster.far = distance;
8065
+ const hit = this.raycaster.intersectObjects(targets, true)[0];
8066
+ if (hit) {
8067
+ return { point: hit.point.clone(), segmentIndex: i - 1 };
7978
8068
  }
7979
8069
  }
8070
+ return null;
7980
8071
  }
7981
8072
  collectTeleportTargets(world) {
7982
8073
  const objects = [];
@@ -7989,12 +8080,13 @@ var _XRLocomotionSystem = class _XRLocomotionSystem {
7989
8080
  }
7990
8081
  return objects;
7991
8082
  }
7992
- /**
7993
- * Where the teleport pointer currently lands this frame, or null.
7994
- * Consumers use this to render an aim marker.
7995
- */
7996
- getTeleportPoint() {
7997
- return this.teleportPoint;
8083
+ /** Arc points up to the landing spot this frame; empty when not aiming. */
8084
+ getAimCurve() {
8085
+ return this.aimCurve;
8086
+ }
8087
+ /** Where the arc currently lands, or null when not aiming at a valid area. */
8088
+ getLandingPoint() {
8089
+ return this.landingPoint;
7998
8090
  }
7999
8091
  };
8000
8092
  __name(_XRLocomotionSystem, "XRLocomotionSystem");
@@ -8156,7 +8248,7 @@ var _VRTeleportAreaSystem = class _VRTeleportAreaSystem {
8156
8248
  __name(_VRTeleportAreaSystem, "VRTeleportAreaSystem");
8157
8249
  var VRTeleportAreaSystem = _VRTeleportAreaSystem;
8158
8250
  var _XRControllerVisualSystem = class _XRControllerVisualSystem {
8159
- constructor(slots = 2) {
8251
+ constructor(options) {
8160
8252
  this.controllerModelFactory = new XRControllerModelFactory_js.XRControllerModelFactory();
8161
8253
  this.handModelFactory = new XRHandModelFactory_js.XRHandModelFactory();
8162
8254
  this.group = new THREE14__namespace.Group();
@@ -8164,7 +8256,9 @@ var _XRControllerVisualSystem = class _XRControllerVisualSystem {
8164
8256
  this.attachedTo = null;
8165
8257
  /** Index → whether we've already attached visuals for that slot. */
8166
8258
  this.ready = /* @__PURE__ */ new Set();
8167
- this.slots = slots;
8259
+ this.rays = [];
8260
+ this.slots = options?.slots ?? 2;
8261
+ this.interactionSystem = options?.interactionSystem ?? null;
8168
8262
  this.group.name = "XRControllerVisuals";
8169
8263
  this.group.userData.ecsPreviewHidden = true;
8170
8264
  }
@@ -8172,6 +8266,7 @@ var _XRControllerVisualSystem = class _XRControllerVisualSystem {
8172
8266
  const renderer = world.getRenderer();
8173
8267
  if (!renderer.xr?.enabled) return;
8174
8268
  this.ensureAttached(world);
8269
+ this.updateRayVisibility();
8175
8270
  if (this.built) return;
8176
8271
  for (let index = 0; index < this.slots; index += 1) {
8177
8272
  if (this.ready.has(index)) continue;
@@ -8179,7 +8274,9 @@ var _XRControllerVisualSystem = class _XRControllerVisualSystem {
8179
8274
  const grip = renderer.xr.getControllerGrip(index);
8180
8275
  const hand = renderer.xr.getHand(index);
8181
8276
  if (!controller || !grip || !hand) continue;
8182
- controller.add(this.createRay());
8277
+ const ray = this.createRay();
8278
+ this.rays.push(ray);
8279
+ controller.add(ray);
8183
8280
  this.group.add(controller);
8184
8281
  grip.add(this.controllerModelFactory.createControllerModel(grip));
8185
8282
  this.group.add(grip);
@@ -8191,6 +8288,17 @@ var _XRControllerVisualSystem = class _XRControllerVisualSystem {
8191
8288
  this.built = true;
8192
8289
  }
8193
8290
  }
8291
+ /**
8292
+ * Show the aim ray only when it is meaningful: hovering something
8293
+ * interactive, or mid-grab. A permanently-drawn ray is visual noise, and it
8294
+ * implies everything is clickable when most of the scene is not. Teleport
8295
+ * aiming has its own arc, so the straight ray stays hidden for that.
8296
+ */
8297
+ updateRayVisibility() {
8298
+ if (!this.interactionSystem) return;
8299
+ const active = this.interactionSystem.getHoveredEntityId() !== null || this.interactionSystem.isGrabbing();
8300
+ for (const ray of this.rays) ray.visible = active;
8301
+ }
8194
8302
  /**
8195
8303
  * Parent the visuals to the XR rig when there is one, so locomotion moves the
8196
8304
  * hands with the player. Falls back to the scene root.
@@ -8216,6 +8324,7 @@ var _XRControllerVisualSystem = class _XRControllerVisualSystem {
8216
8324
  const line = new THREE14__namespace.Line(geometry, material);
8217
8325
  line.name = "XRPointerRay";
8218
8326
  line.renderOrder = 999;
8327
+ line.visible = this.interactionSystem === null;
8219
8328
  return line;
8220
8329
  }
8221
8330
  dispose() {
@@ -8231,6 +8340,7 @@ var _XRControllerVisualSystem = class _XRControllerVisualSystem {
8231
8340
  }
8232
8341
  });
8233
8342
  this.group.clear();
8343
+ this.rays.length = 0;
8234
8344
  this.ready.clear();
8235
8345
  this.built = false;
8236
8346
  this.attachedTo = null;
@@ -8238,6 +8348,121 @@ var _XRControllerVisualSystem = class _XRControllerVisualSystem {
8238
8348
  };
8239
8349
  __name(_XRControllerVisualSystem, "XRControllerVisualSystem");
8240
8350
  var XRControllerVisualSystem = _XRControllerVisualSystem;
8351
+ var MARKER_RADIUS = 0.28;
8352
+ var ACCENT = new THREE14__namespace.Color("#4da3ff");
8353
+ var _XRTeleportVisualSystem = class _XRTeleportVisualSystem {
8354
+ constructor(locomotionSystem) {
8355
+ this.group = new THREE14__namespace.Group();
8356
+ this.arcGeometry = new THREE14__namespace.BufferGeometry();
8357
+ this.marker = new THREE14__namespace.Group();
8358
+ this.attached = false;
8359
+ this.locomotionSystem = locomotionSystem;
8360
+ this.group.name = "XRTeleportVisuals";
8361
+ this.group.userData.ecsPreviewHidden = true;
8362
+ const arcMaterial = new THREE14__namespace.LineBasicMaterial({
8363
+ vertexColors: true,
8364
+ transparent: true,
8365
+ depthTest: false
8366
+ });
8367
+ this.arc = new THREE14__namespace.Line(this.arcGeometry, arcMaterial);
8368
+ this.arc.frustumCulled = false;
8369
+ this.arc.renderOrder = 998;
8370
+ this.group.add(this.arc);
8371
+ this.marker.add(this.createRing(), this.createDot());
8372
+ this.marker.renderOrder = 999;
8373
+ this.group.add(this.marker);
8374
+ this.setVisible(false);
8375
+ }
8376
+ update(world) {
8377
+ if (!this.attached) {
8378
+ world.getScene().add(this.group);
8379
+ this.attached = true;
8380
+ }
8381
+ const curve = this.locomotionSystem.getAimCurve();
8382
+ const landing = this.locomotionSystem.getLandingPoint();
8383
+ if (!landing || curve.length < 2) {
8384
+ this.setVisible(false);
8385
+ return;
8386
+ }
8387
+ this.updateArcGeometry(curve);
8388
+ this.marker.position.copy(landing);
8389
+ this.marker.position.y += 0.01;
8390
+ this.setVisible(true);
8391
+ }
8392
+ updateArcGeometry(curve) {
8393
+ const count = curve.length;
8394
+ const positions = new Float32Array(count * 3);
8395
+ const colors = new Float32Array(count * 3);
8396
+ for (let i = 0; i < count; i += 1) {
8397
+ const point = curve[i];
8398
+ positions[i * 3] = point.x;
8399
+ positions[i * 3 + 1] = point.y;
8400
+ positions[i * 3 + 2] = point.z;
8401
+ const t = count > 1 ? i / (count - 1) : 0;
8402
+ const fade = 1 - t * 0.75;
8403
+ colors[i * 3] = ACCENT.r * fade;
8404
+ colors[i * 3 + 1] = ACCENT.g * fade;
8405
+ colors[i * 3 + 2] = ACCENT.b * fade;
8406
+ }
8407
+ this.arcGeometry.setAttribute(
8408
+ "position",
8409
+ new THREE14__namespace.BufferAttribute(positions, 3)
8410
+ );
8411
+ this.arcGeometry.setAttribute("color", new THREE14__namespace.BufferAttribute(colors, 3));
8412
+ this.arcGeometry.computeBoundingSphere();
8413
+ }
8414
+ createRing() {
8415
+ const geometry = new THREE14__namespace.RingGeometry(
8416
+ MARKER_RADIUS * 0.72,
8417
+ MARKER_RADIUS,
8418
+ 48
8419
+ );
8420
+ geometry.rotateX(-Math.PI / 2);
8421
+ return new THREE14__namespace.Mesh(
8422
+ geometry,
8423
+ new THREE14__namespace.MeshBasicMaterial({
8424
+ color: ACCENT,
8425
+ transparent: true,
8426
+ opacity: 0.9,
8427
+ side: THREE14__namespace.DoubleSide,
8428
+ depthTest: false
8429
+ })
8430
+ );
8431
+ }
8432
+ createDot() {
8433
+ const geometry = new THREE14__namespace.CircleGeometry(MARKER_RADIUS * 0.16, 24);
8434
+ geometry.rotateX(-Math.PI / 2);
8435
+ return new THREE14__namespace.Mesh(
8436
+ geometry,
8437
+ new THREE14__namespace.MeshBasicMaterial({
8438
+ color: ACCENT,
8439
+ transparent: true,
8440
+ opacity: 0.55,
8441
+ side: THREE14__namespace.DoubleSide,
8442
+ depthTest: false
8443
+ })
8444
+ );
8445
+ }
8446
+ setVisible(visible) {
8447
+ this.group.visible = visible;
8448
+ }
8449
+ dispose() {
8450
+ this.group.removeFromParent();
8451
+ this.group.traverse((child) => {
8452
+ const mesh = child;
8453
+ mesh.geometry?.dispose?.();
8454
+ const material = mesh.material;
8455
+ if (Array.isArray(material)) {
8456
+ for (const entry of material) entry.dispose?.();
8457
+ } else {
8458
+ material?.dispose?.();
8459
+ }
8460
+ });
8461
+ this.attached = false;
8462
+ }
8463
+ };
8464
+ __name(_XRTeleportVisualSystem, "XRTeleportVisualSystem");
8465
+ var XRTeleportVisualSystem = _XRTeleportVisualSystem;
8241
8466
 
8242
8467
  exports.AnimationSystem = AnimationSystem;
8243
8468
  exports.AudioSystem = AudioSystem;
@@ -8265,5 +8490,6 @@ exports.XRInputSystem = XRInputSystem;
8265
8490
  exports.XRInteractionSystem = XRInteractionSystem;
8266
8491
  exports.XRLocomotionSystem = XRLocomotionSystem;
8267
8492
  exports.XRSessionSystem = XRSessionSystem;
8493
+ exports.XRTeleportVisualSystem = XRTeleportVisualSystem;
8268
8494
  //# sourceMappingURL=index.cjs.map
8269
8495
  //# sourceMappingURL=index.cjs.map