@relu-interactives/spatial-ecs 0.4.3 → 0.4.4
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/{chunk-6UZC6M7V.js → chunk-OY2OONRR.js} +52 -12
- package/dist/chunk-OY2OONRR.js.map +1 -0
- package/dist/docs/guide/mixed-reality.md +23 -0
- package/dist/{index-CBdnIyI8.d.cts → index-7YCk4cmQ.d.cts} +23 -1
- package/dist/{index-n7SeH119.d.ts → index-B2oHfqkj.d.ts} +23 -1
- package/dist/index.cjs +50 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/systems/index.cjs +50 -10
- package/dist/systems/index.cjs.map +1 -1
- package/dist/systems/index.d.cts +1 -1
- package/dist/systems/index.d.ts +1 -1
- package/dist/systems/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-6UZC6M7V.js.map +0 -1
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, ar as XrHandPreset } from './XRHandPose-CxPv-LBo.cjs';
|
|
5
5
|
export { aD as AnimationStateCallbacks, aE as AnimationStateMachine, aF as AnimationStateManager, aG as StateMachine } from './XRHandPose-CxPv-LBo.cjs';
|
|
6
|
-
import { X as XrCapabilities, a as XrInputState, b as XrHandPoseEventDetail } from './index-
|
|
7
|
-
export { A as AnimationSystem, c as AudioSystem, C as CameraSyncSystem, E as EnvironmentSyncSystem, I as InstancedMeshSystem, L as LightSyncSystem, M as MaterialSyncSystem, d as MeshGeometrySystem, e as ModuleLoader, N as NO_XR_CAPABILITIES, O as ObjectVisibilitySystem, P as PhysicsSyncSystem, f as PostprocessingSyncSystem, S as SCRIPT_OBJECT_ROOT_FLAG, g as ScriptBehaviourSystem, h as ScriptObjectSystem, i as SelectionContext, V as VRTeleportAreaSystem, j as VideoSystem, k as XRAnchorSystem, l as XRControllerVisualSystem, m as XREnvironmentSystem, n as XRHandPoseSystem, o as XRHitTestSystem, p as XRHoverVisualSystem, q as XRInputSystem, r as XRInteractionSystem, s as XRLocomotionSystem, t as XRSessionSystem, u as XRTeleportVisualSystem, v as XR_HOVER_SHELL_FLAG, w as XrHandedness, x as XrHitResult, y as XrInputKind, z as readXrCapabilities } from './index-
|
|
6
|
+
import { X as XrCapabilities, a as XrInputState, b as XrHandPoseEventDetail } from './index-7YCk4cmQ.cjs';
|
|
7
|
+
export { A as AnimationSystem, c as AudioSystem, C as CameraSyncSystem, E as EnvironmentSyncSystem, I as InstancedMeshSystem, L as LightSyncSystem, M as MaterialSyncSystem, d as MeshGeometrySystem, e as ModuleLoader, N as NO_XR_CAPABILITIES, O as ObjectVisibilitySystem, P as PhysicsSyncSystem, f as PostprocessingSyncSystem, S as SCRIPT_OBJECT_ROOT_FLAG, g as ScriptBehaviourSystem, h as ScriptObjectSystem, i as SelectionContext, V as VRTeleportAreaSystem, j as VideoSystem, k as XRAnchorSystem, l as XRControllerVisualSystem, m as XREnvironmentSystem, n as XRHandPoseSystem, o as XRHitTestSystem, p as XRHoverVisualSystem, q as XRInputSystem, r as XRInteractionSystem, s as XRLocomotionSystem, t as XRSessionSystem, u as XRTeleportVisualSystem, v as XR_HOVER_SHELL_FLAG, w as XrHandedness, x as XrHitResult, y as XrInputKind, z as readXrCapabilities } from './index-7YCk4cmQ.cjs';
|
|
8
8
|
export { i as CoreComponents } from './index-CQsHUez3.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, createXRAnchorComponent, createXRHandPoseComponent, createXRInteractableComponent, createXRInteractorComponent, createXRInteractorSideComponent, createXRRigComponent, registerDefaultComponentFactories, registerDefaultFactories } from './factories/index.cjs';
|
|
10
10
|
import { GLTF } from 'three/examples/jsm/loaders/GLTFLoader.js';
|
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, ar as XrHandPreset } from './XRHandPose-BImIa4ZS.js';
|
|
5
5
|
export { aD as AnimationStateCallbacks, aE as AnimationStateMachine, aF as AnimationStateManager, aG as StateMachine } from './XRHandPose-BImIa4ZS.js';
|
|
6
|
-
import { X as XrCapabilities, a as XrInputState, b as XrHandPoseEventDetail } from './index-
|
|
7
|
-
export { A as AnimationSystem, c as AudioSystem, C as CameraSyncSystem, E as EnvironmentSyncSystem, I as InstancedMeshSystem, L as LightSyncSystem, M as MaterialSyncSystem, d as MeshGeometrySystem, e as ModuleLoader, N as NO_XR_CAPABILITIES, O as ObjectVisibilitySystem, P as PhysicsSyncSystem, f as PostprocessingSyncSystem, S as SCRIPT_OBJECT_ROOT_FLAG, g as ScriptBehaviourSystem, h as ScriptObjectSystem, i as SelectionContext, V as VRTeleportAreaSystem, j as VideoSystem, k as XRAnchorSystem, l as XRControllerVisualSystem, m as XREnvironmentSystem, n as XRHandPoseSystem, o as XRHitTestSystem, p as XRHoverVisualSystem, q as XRInputSystem, r as XRInteractionSystem, s as XRLocomotionSystem, t as XRSessionSystem, u as XRTeleportVisualSystem, v as XR_HOVER_SHELL_FLAG, w as XrHandedness, x as XrHitResult, y as XrInputKind, z as readXrCapabilities } from './index-
|
|
6
|
+
import { X as XrCapabilities, a as XrInputState, b as XrHandPoseEventDetail } from './index-B2oHfqkj.js';
|
|
7
|
+
export { A as AnimationSystem, c as AudioSystem, C as CameraSyncSystem, E as EnvironmentSyncSystem, I as InstancedMeshSystem, L as LightSyncSystem, M as MaterialSyncSystem, d as MeshGeometrySystem, e as ModuleLoader, N as NO_XR_CAPABILITIES, O as ObjectVisibilitySystem, P as PhysicsSyncSystem, f as PostprocessingSyncSystem, S as SCRIPT_OBJECT_ROOT_FLAG, g as ScriptBehaviourSystem, h as ScriptObjectSystem, i as SelectionContext, V as VRTeleportAreaSystem, j as VideoSystem, k as XRAnchorSystem, l as XRControllerVisualSystem, m as XREnvironmentSystem, n as XRHandPoseSystem, o as XRHitTestSystem, p as XRHoverVisualSystem, q as XRInputSystem, r as XRInteractionSystem, s as XRLocomotionSystem, t as XRSessionSystem, u as XRTeleportVisualSystem, v as XR_HOVER_SHELL_FLAG, w as XrHandedness, x as XrHitResult, y as XrInputKind, z as readXrCapabilities } from './index-B2oHfqkj.js';
|
|
8
8
|
export { i as CoreComponents } from './index-CuGqxuk-.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, createXRAnchorComponent, createXRHandPoseComponent, createXRInteractableComponent, createXRInteractorComponent, createXRInteractorSideComponent, createXRRigComponent, registerDefaultComponentFactories, registerDefaultFactories } from './factories/index.js';
|
|
10
10
|
import { GLTF } from 'three/examples/jsm/loaders/GLTFLoader.js';
|
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-
|
|
2
|
-
export { ADDED_NODE_MARKER_COMPONENT, ARC_GRAVITY, ARC_MAX_TIME, ARC_SPEED, ARC_STEPS, AnimationSystem, AudioSystem, Behaviour, CURLED_COS, CameraSyncSystem, DEFAULT_DIRECTION_TOLERANCE, 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, XRAnchorSystem, XRControllerVisualSystem, XREnvironmentSystem, XRHandPoseSystem, XRHitTestSystem, 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 } from './chunk-
|
|
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-OY2OONRR.js';
|
|
2
|
+
export { ADDED_NODE_MARKER_COMPONENT, ARC_GRAVITY, ARC_MAX_TIME, ARC_SPEED, ARC_STEPS, AnimationSystem, AudioSystem, Behaviour, CURLED_COS, CameraSyncSystem, DEFAULT_DIRECTION_TOLERANCE, 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, XRAnchorSystem, XRControllerVisualSystem, XREnvironmentSystem, XRHandPoseSystem, XRHitTestSystem, 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 } from './chunk-OY2OONRR.js';
|
|
3
3
|
import { registerDefaultFactories } from './chunk-SGADE55G.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, createXRAnchorComponent, createXRHandPoseComponent, createXRInteractableComponent, createXRInteractorComponent, createXRInteractorSideComponent, createXRRigComponent, registerDefaultComponentFactories, registerDefaultFactories } from './chunk-SGADE55G.js';
|
|
5
5
|
import { ObjectManagementSystem } from './chunk-4DWZK4X4.js';
|
package/dist/systems/index.cjs
CHANGED
|
@@ -9594,6 +9594,8 @@ var _XRSessionSystem = class _XRSessionSystem {
|
|
|
9594
9594
|
this.capabilities = NO_XR_CAPABILITIES;
|
|
9595
9595
|
/** Y compensation applied when a floor-relative space was requested but not granted. */
|
|
9596
9596
|
this.appliedOriginOffset = 0;
|
|
9597
|
+
/** The live session, so an async floor probe can tell if it has been replaced. */
|
|
9598
|
+
this.session = null;
|
|
9597
9599
|
this.inputSystem = inputSystem ?? null;
|
|
9598
9600
|
}
|
|
9599
9601
|
update(world) {
|
|
@@ -9612,6 +9614,7 @@ var _XRSessionSystem = class _XRSessionSystem {
|
|
|
9612
9614
|
}
|
|
9613
9615
|
handleSessionStart(world) {
|
|
9614
9616
|
const session = world.getRenderer().xr.getSession();
|
|
9617
|
+
this.session = session ?? null;
|
|
9615
9618
|
const mode = session && session.environmentBlendMode !== "opaque" ? "immersive-ar" : "immersive-vr";
|
|
9616
9619
|
this.capabilities = readXrCapabilities(session ?? null, mode);
|
|
9617
9620
|
if (session && this.inputSystem) {
|
|
@@ -9650,16 +9653,16 @@ var _XRSessionSystem = class _XRSessionSystem {
|
|
|
9650
9653
|
renderer.xr.setReferenceSpaceType(wantsFloor ? "local-floor" : "local");
|
|
9651
9654
|
} catch {
|
|
9652
9655
|
}
|
|
9653
|
-
|
|
9654
|
-
|
|
9655
|
-
|
|
9656
|
-
|
|
9657
|
-
|
|
9658
|
-
|
|
9659
|
-
|
|
9660
|
-
|
|
9656
|
+
this.appliedOriginOffset = 0;
|
|
9657
|
+
if (!wantsFloor || !session) return;
|
|
9658
|
+
const sessionAtRequest = session;
|
|
9659
|
+
session.requestReferenceSpace("local-floor").then(() => {
|
|
9660
|
+
}).catch(() => {
|
|
9661
|
+
if (this.session !== sessionAtRequest) return;
|
|
9662
|
+
if (this.appliedOriginOffset !== 0) return;
|
|
9663
|
+
this.appliedOriginOffset = rig.fallbackEyeHeight;
|
|
9661
9664
|
transform.position.y -= this.appliedOriginOffset;
|
|
9662
|
-
}
|
|
9665
|
+
});
|
|
9663
9666
|
}
|
|
9664
9667
|
handleSessionEnd(world) {
|
|
9665
9668
|
if (this.appliedOriginOffset !== 0) {
|
|
@@ -9670,6 +9673,7 @@ var _XRSessionSystem = class _XRSessionSystem {
|
|
|
9670
9673
|
}
|
|
9671
9674
|
this.appliedOriginOffset = 0;
|
|
9672
9675
|
}
|
|
9676
|
+
this.session = null;
|
|
9673
9677
|
this.capabilities = NO_XR_CAPABILITIES;
|
|
9674
9678
|
this.inputSystem?.detachSession();
|
|
9675
9679
|
this.forEachBehaviour(world, (behaviour) => {
|
|
@@ -9786,6 +9790,7 @@ __name(decomposeXrPose, "decomposeXrPose");
|
|
|
9786
9790
|
|
|
9787
9791
|
// core/systems/XREnvironmentSystem.ts
|
|
9788
9792
|
var DEBUG_COLOR = 5088255;
|
|
9793
|
+
var ROOM_CAPTURE_DELAY_SECONDS = 3;
|
|
9789
9794
|
var _XREnvironmentSystem = class _XREnvironmentSystem {
|
|
9790
9795
|
constructor() {
|
|
9791
9796
|
/** Keyed by the XRPlane/XRMesh object itself — the runtime's own identity. */
|
|
@@ -9793,17 +9798,24 @@ var _XREnvironmentSystem = class _XREnvironmentSystem {
|
|
|
9793
9798
|
this.meshes = /* @__PURE__ */ new Map();
|
|
9794
9799
|
this.presenting = false;
|
|
9795
9800
|
this.debugVisible = false;
|
|
9801
|
+
/** Seconds presenting, used to decide the room has genuinely nothing in it. */
|
|
9802
|
+
this.elapsed = 0;
|
|
9803
|
+
/** `initiateRoomCapture` may be called only ONCE per session. */
|
|
9804
|
+
this.roomCaptureRequested = false;
|
|
9796
9805
|
}
|
|
9797
|
-
update(world) {
|
|
9806
|
+
update(world, deltaTime = 0) {
|
|
9798
9807
|
const presenting = world.isXrPresenting();
|
|
9799
9808
|
if (!presenting) {
|
|
9800
9809
|
if (this.presenting) {
|
|
9801
9810
|
this.presenting = false;
|
|
9811
|
+
this.elapsed = 0;
|
|
9812
|
+
this.roomCaptureRequested = false;
|
|
9802
9813
|
this.clearAll(world);
|
|
9803
9814
|
}
|
|
9804
9815
|
return;
|
|
9805
9816
|
}
|
|
9806
9817
|
this.presenting = true;
|
|
9818
|
+
this.elapsed += deltaTime;
|
|
9807
9819
|
const rig = this.findRig(world);
|
|
9808
9820
|
const mode = rig?.environmentPhysics ?? "none";
|
|
9809
9821
|
if (mode === "none") {
|
|
@@ -9832,6 +9844,34 @@ var _XREnvironmentSystem = class _XREnvironmentSystem {
|
|
|
9832
9844
|
} else if (this.meshes.size > 0) {
|
|
9833
9845
|
this.clearMap(world, this.meshes);
|
|
9834
9846
|
}
|
|
9847
|
+
this.maybeCaptureRoom(world, frame);
|
|
9848
|
+
}
|
|
9849
|
+
/**
|
|
9850
|
+
* Ask the runtime to scan the room when it turns out we have no room.
|
|
9851
|
+
*
|
|
9852
|
+
* Plane and mesh detection do NOT scan anything — they replay a scan the user
|
|
9853
|
+
* captured earlier through the system's own room setup. Most people have
|
|
9854
|
+
* never run it, and those who have may have run it in a DIFFERENT room, so a
|
|
9855
|
+
* mixed-reality experience opens against either nothing at all or someone
|
|
9856
|
+
* else's furniture, with no prompt and no error.
|
|
9857
|
+
*
|
|
9858
|
+
* `XRSession.initiateRoomCapture()` (Meta's extension) launches that setup
|
|
9859
|
+
* from inside the session, and exists precisely for this case. Contract, from
|
|
9860
|
+
* Meta's docs: callable ONCE per session, and only worth calling once we are
|
|
9861
|
+
* confident the room really is empty — the arrays populate a beat after the
|
|
9862
|
+
* session starts, so a check on frame one would fire for everyone.
|
|
9863
|
+
*/
|
|
9864
|
+
maybeCaptureRoom(world, frame) {
|
|
9865
|
+
if (this.roomCaptureRequested) return;
|
|
9866
|
+
if (this.elapsed < ROOM_CAPTURE_DELAY_SECONDS) return;
|
|
9867
|
+
if (this.planes.size > 0 || this.meshes.size > 0) return;
|
|
9868
|
+
if ((frame.detectedPlanes?.size ?? 0) > 0) return;
|
|
9869
|
+
if ((frame.detectedMeshes?.size ?? 0) > 0) return;
|
|
9870
|
+
const session = world.getRenderer().xr.getSession?.();
|
|
9871
|
+
if (typeof session?.initiateRoomCapture !== "function") return;
|
|
9872
|
+
this.roomCaptureRequested = true;
|
|
9873
|
+
session.initiateRoomCapture()?.catch(() => {
|
|
9874
|
+
});
|
|
9835
9875
|
}
|
|
9836
9876
|
/** How many pieces of real geometry are currently colliding. Script-facing. */
|
|
9837
9877
|
getDetectedCount() {
|