@relu-interactives/spatial-ecs 0.3.8 → 0.3.9

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.
@@ -2912,13 +2912,9 @@ function restorePostCreateComponents(world, objectManagementSystem, targetEntity
2912
2912
  runtimeMessage: typeof entry.runtimeMessage === "string" ? entry.runtimeMessage : void 0
2913
2913
  };
2914
2914
  }).filter((entry) => entry.className || entry.scriptUrl) : [];
2915
- if (!entries.length) {
2916
- return;
2915
+ if (entries.length) {
2916
+ world.addComponent(targetEntityId, new ScriptComponent(entries));
2917
2917
  }
2918
- world.addComponent(
2919
- targetEntityId,
2920
- new ScriptComponent(entries)
2921
- );
2922
2918
  }
2923
2919
  const sourceScriptObject = asRecord(values.scriptObjectValues.get(sourceEntityId));
2924
2920
  if (sourceScriptObject) {
@@ -2967,10 +2963,14 @@ function restorePostCreateComponents(world, objectManagementSystem, targetEntity
2967
2963
  const sourceInteractable = asRecord(
2968
2964
  values.xrInteractableValues.get(sourceEntityId)
2969
2965
  );
2970
- const interactable = world.getComponent(
2966
+ let interactable = world.getComponent(
2971
2967
  targetEntityId,
2972
2968
  XRInteractableComponent
2973
2969
  );
2970
+ if (sourceInteractable && !interactable) {
2971
+ interactable = new XRInteractableComponent();
2972
+ world.addComponent(targetEntityId, interactable);
2973
+ }
2974
2974
  if (sourceInteractable && interactable) {
2975
2975
  if (typeof sourceInteractable.enabled === "boolean") {
2976
2976
  interactable.enabled = sourceInteractable.enabled;
@@ -3027,7 +3027,11 @@ function restorePostCreateComponents(world, objectManagementSystem, targetEntity
3027
3027
  const sourceHandPose = asRecord(
3028
3028
  values.xrHandPoseValues.get(sourceEntityId)
3029
3029
  );
3030
- const handPose = world.getComponent(targetEntityId, XRHandPoseComponent);
3030
+ let handPose = world.getComponent(targetEntityId, XRHandPoseComponent);
3031
+ if (sourceHandPose && !handPose) {
3032
+ handPose = new XRHandPoseComponent();
3033
+ world.addComponent(targetEntityId, handPose);
3034
+ }
3031
3035
  if (sourceHandPose && handPose) {
3032
3036
  if (typeof sourceHandPose.enabled === "boolean") {
3033
3037
  handPose.enabled = sourceHandPose.enabled;
@@ -6378,6 +6382,7 @@ __name(_XRInputSystem, "XRInputSystem");
6378
6382
  var XRInputSystem = _XRInputSystem;
6379
6383
  var VELOCITY_SAMPLES = 5;
6380
6384
  var MAX_SAMPLE_AGE_SECONDS = 0.2;
6385
+ var MAX_PLAUSIBLE_SPEED = 20;
6381
6386
  var _ThrowVelocityTracker = class _ThrowVelocityTracker {
6382
6387
  constructor() {
6383
6388
  this.samples = [];
@@ -6411,6 +6416,7 @@ var _ThrowVelocityTracker = class _ThrowVelocityTracker {
6411
6416
  if (dt <= 1e-5) continue;
6412
6417
  const velocity = new THREE7.Vector3().subVectors(current.position, previous.position).divideScalar(dt);
6413
6418
  const speed = velocity.length();
6419
+ if (speed > MAX_PLAUSIBLE_SPEED) continue;
6414
6420
  if (speed > bestSpeed) {
6415
6421
  bestSpeed = speed;
6416
6422
  best = velocity;
@@ -6560,7 +6566,9 @@ var _XRInteractionSystem = class _XRInteractionSystem {
6560
6566
  if (!interactable?.enabled) continue;
6561
6567
  if (!world.isEntityVisible(entityId)) continue;
6562
6568
  const object = world.getComponent(entityId, Object3DRef)?.object;
6563
- if (object) out.push({ entityId, object });
6569
+ if (object) {
6570
+ out.push({ entityId, object, pointable: interactable.pointable });
6571
+ }
6564
6572
  }
6565
6573
  return out;
6566
6574
  }
@@ -6572,6 +6580,7 @@ var _XRInteractionSystem = class _XRInteractionSystem {
6572
6580
  let nearestId = null;
6573
6581
  let nearestDistance = Number.POSITIVE_INFINITY;
6574
6582
  for (const entry of interactables) {
6583
+ if (!entry.pointable) continue;
6575
6584
  const hit = this.raycaster.intersectObject(entry.object, true)[0];
6576
6585
  if (!hit) continue;
6577
6586
  if (hit.distance < nearestDistance) {
@@ -8099,6 +8108,6 @@ var _XRHandPoseSystem = class _XRHandPoseSystem {
8099
8108
  __name(_XRHandPoseSystem, "XRHandPoseSystem");
8100
8109
  var XRHandPoseSystem = _XRHandPoseSystem;
8101
8110
 
8102
- 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_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, XRInputSystem, XRInteractionSystem, XRLocomotionSystem, XRSessionSystem, XRTeleportVisualSystem, XR_FINGERS, 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 };
8103
- //# sourceMappingURL=chunk-LMTB4KQ4.js.map
8104
- //# sourceMappingURL=chunk-LMTB4KQ4.js.map
8111
+ 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, XRInputSystem, XRInteractionSystem, XRLocomotionSystem, XRSessionSystem, XRTeleportVisualSystem, XR_FINGERS, 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 };
8112
+ //# sourceMappingURL=chunk-W5TSYV6Q.js.map
8113
+ //# sourceMappingURL=chunk-W5TSYV6Q.js.map