@relu-interactives/spatial-ecs 0.5.0 → 0.5.1
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-Z6ZMR3CS.js → chunk-Q52ADLF7.js} +69 -3
- package/dist/chunk-Q52ADLF7.js.map +1 -0
- package/dist/{index-CppKDxbu.d.ts → index-D2Jt_JzH.d.ts} +11 -0
- package/dist/{index-I2IsocYW.d.cts → index-DaG03vyN.d.cts} +11 -0
- package/dist/index.cjs +67 -1
- 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 +67 -1
- 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-Z6ZMR3CS.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, aE as XrHandPreset } from './XRHandPose-CQTLGxFC.cjs';
|
|
5
5
|
export { aQ as AnimationStateCallbacks, aR as AnimationStateMachine, aS as AnimationStateManager, aT as StateMachine } from './XRHandPose-CQTLGxFC.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, U as UIInteractionSystem, j as UIPanelSystem, k as UiCanvasLike, V as VRTeleportAreaSystem, l as VideoSystem, m as XRAnchorSystem, n as XRControllerVisualSystem, o as XREnvironmentSystem, p as XRHandPoseSystem, q as XRHitTestSystem, r as XRHoverVisualSystem, s as XRInputSystem, t as XRInteractionSystem, u as XRLocomotionSystem, v as XRSessionSystem, w as XRTeleportVisualSystem, x as XR_HOVER_SHELL_FLAG, y as XrHandedness, z as XrHitResult, B as XrInputKind, D as readXrCapabilities } from './index-
|
|
6
|
+
import { X as XrCapabilities, a as XrInputState, b as XrHandPoseEventDetail } from './index-DaG03vyN.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, U as UIInteractionSystem, j as UIPanelSystem, k as UiCanvasLike, V as VRTeleportAreaSystem, l as VideoSystem, m as XRAnchorSystem, n as XRControllerVisualSystem, o as XREnvironmentSystem, p as XRHandPoseSystem, q as XRHitTestSystem, r as XRHoverVisualSystem, s as XRInputSystem, t as XRInteractionSystem, u as XRLocomotionSystem, v as XRSessionSystem, w as XRTeleportVisualSystem, x as XR_HOVER_SHELL_FLAG, y as XrHandedness, z as XrHitResult, B as XrInputKind, D as readXrCapabilities } from './index-DaG03vyN.cjs';
|
|
8
8
|
export { i as CoreComponents } from './index-Dlr-7-4m.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, createUIButtonComponent, createUIPanelComponent, createUISliderComponent, createUITextComponent, createUIToggleComponent, 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, aE as XrHandPreset } from './XRHandPose-CU3vNFuS.js';
|
|
5
5
|
export { aQ as AnimationStateCallbacks, aR as AnimationStateMachine, aS as AnimationStateManager, aT as StateMachine } from './XRHandPose-CU3vNFuS.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, U as UIInteractionSystem, j as UIPanelSystem, k as UiCanvasLike, V as VRTeleportAreaSystem, l as VideoSystem, m as XRAnchorSystem, n as XRControllerVisualSystem, o as XREnvironmentSystem, p as XRHandPoseSystem, q as XRHitTestSystem, r as XRHoverVisualSystem, s as XRInputSystem, t as XRInteractionSystem, u as XRLocomotionSystem, v as XRSessionSystem, w as XRTeleportVisualSystem, x as XR_HOVER_SHELL_FLAG, y as XrHandedness, z as XrHitResult, B as XrInputKind, D as readXrCapabilities } from './index-
|
|
6
|
+
import { X as XrCapabilities, a as XrInputState, b as XrHandPoseEventDetail } from './index-D2Jt_JzH.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, U as UIInteractionSystem, j as UIPanelSystem, k as UiCanvasLike, V as VRTeleportAreaSystem, l as VideoSystem, m as XRAnchorSystem, n as XRControllerVisualSystem, o as XREnvironmentSystem, p as XRHandPoseSystem, q as XRHitTestSystem, r as XRHoverVisualSystem, s as XRInputSystem, t as XRInteractionSystem, u as XRLocomotionSystem, v as XRSessionSystem, w as XRTeleportVisualSystem, x as XR_HOVER_SHELL_FLAG, y as XrHandedness, z as XrHitResult, B as XrInputKind, D as readXrCapabilities } from './index-D2Jt_JzH.js';
|
|
8
8
|
export { i as CoreComponents } from './index-C3ik3sA1.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, createUIButtonComponent, createUIPanelComponent, createUISliderComponent, createUITextComponent, createUIToggleComponent, 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, UIPanelSystem, 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, UIInteractionSystem, UIPanelSystem, 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, UIPanelSystem, 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-Q52ADLF7.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, UIInteractionSystem, UIPanelSystem, 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-Q52ADLF7.js';
|
|
3
3
|
import { registerDefaultFactories } from './chunk-RXBLOO5B.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, createUIButtonComponent, createUIPanelComponent, createUISliderComponent, createUITextComponent, createUIToggleComponent, createVRTeleportAreaComponent, createVideoComponent, createXRAnchorComponent, createXRHandPoseComponent, createXRInteractableComponent, createXRInteractorComponent, createXRInteractorSideComponent, createXRRigComponent, registerDefaultComponentFactories, registerDefaultFactories } from './chunk-RXBLOO5B.js';
|
|
5
5
|
import { ObjectManagementSystem } from './chunk-WJD2VKEH.js';
|
package/dist/systems/index.cjs
CHANGED
|
@@ -10103,6 +10103,11 @@ function debugColorFor(kind, semanticLabel) {
|
|
|
10103
10103
|
}
|
|
10104
10104
|
__name(debugColorFor, "debugColorFor");
|
|
10105
10105
|
var GLOBAL_MESH_DEBUG_OPACITY = 0.35;
|
|
10106
|
+
var GLOBAL_MESH_SWITCH_MARGIN = 1.5;
|
|
10107
|
+
function isGlobalMeshSurface(mesh) {
|
|
10108
|
+
return (mesh.semanticLabel ?? null) === "global mesh";
|
|
10109
|
+
}
|
|
10110
|
+
__name(isGlobalMeshSurface, "isGlobalMeshSurface");
|
|
10106
10111
|
var DEBUG_RENDER_ORDER = 900;
|
|
10107
10112
|
var ROOM_CAPTURE_DELAY_SECONDS = 3;
|
|
10108
10113
|
var SYNTHETIC_FLOOR_EXTENT = 50;
|
|
@@ -10141,6 +10146,10 @@ var _XREnvironmentSystem = class _XREnvironmentSystem {
|
|
|
10141
10146
|
this.roomCaptureRequested = false;
|
|
10142
10147
|
/** This frame's inverse viewer matrix, or null when unavailable. */
|
|
10143
10148
|
this.viewerInverse = null;
|
|
10149
|
+
/** This frame's viewer position in reference space, for room election. */
|
|
10150
|
+
this.viewerPos = null;
|
|
10151
|
+
/** The ONE global room mesh currently allowed to spawn. */
|
|
10152
|
+
this.electedGlobalMesh = null;
|
|
10144
10153
|
this.tmpViewerMatrix = new THREE26__namespace.Matrix4();
|
|
10145
10154
|
this.tmpViewPos = new THREE26__namespace.Vector3();
|
|
10146
10155
|
}
|
|
@@ -10181,7 +10190,14 @@ var _XREnvironmentSystem = class _XREnvironmentSystem {
|
|
|
10181
10190
|
const useMesh = (mode === "mesh" || mode === "auto") && meshesAvailable;
|
|
10182
10191
|
const usePlanes = mode === "planes" || mode === "auto" && !useMesh;
|
|
10183
10192
|
const viewer = frame.getViewerPose?.(referenceSpace);
|
|
10184
|
-
|
|
10193
|
+
if (viewer) {
|
|
10194
|
+
const vm = viewer.transform.matrix;
|
|
10195
|
+
this.viewerPos = { x: vm[12], y: vm[13], z: vm[14] };
|
|
10196
|
+
this.viewerInverse = this.tmpViewerMatrix.fromArray(vm).invert();
|
|
10197
|
+
} else {
|
|
10198
|
+
this.viewerPos = null;
|
|
10199
|
+
this.viewerInverse = null;
|
|
10200
|
+
}
|
|
10185
10201
|
if (usePlanes) {
|
|
10186
10202
|
this.syncPlanes(world, frame, referenceSpace, deltaTime);
|
|
10187
10203
|
} else if (this.planes.size > 0) {
|
|
@@ -10336,7 +10352,17 @@ var _XREnvironmentSystem = class _XREnvironmentSystem {
|
|
|
10336
10352
|
for (const mesh of this.pendingMeshes.keys()) {
|
|
10337
10353
|
if (!detected.has(mesh)) this.pendingMeshes.delete(mesh);
|
|
10338
10354
|
}
|
|
10355
|
+
const electedGlobal = this.electGlobalMesh(frame, detected, referenceSpace);
|
|
10339
10356
|
for (const mesh of detected) {
|
|
10357
|
+
if (isGlobalMeshSurface(mesh) && mesh !== electedGlobal) {
|
|
10358
|
+
const stale = this.meshes.get(mesh);
|
|
10359
|
+
if (stale) {
|
|
10360
|
+
this.destroyEntry(world, stale);
|
|
10361
|
+
this.meshes.delete(mesh);
|
|
10362
|
+
}
|
|
10363
|
+
this.pendingMeshes.delete(mesh);
|
|
10364
|
+
continue;
|
|
10365
|
+
}
|
|
10340
10366
|
const pose = frame.getPose(mesh.meshSpace, referenceSpace);
|
|
10341
10367
|
if (!pose) continue;
|
|
10342
10368
|
const emulated = pose.emulatedPosition === true;
|
|
@@ -10360,6 +10386,45 @@ var _XREnvironmentSystem = class _XREnvironmentSystem {
|
|
|
10360
10386
|
if (allowed) this.applyPose(world, entry.entityId, pose);
|
|
10361
10387
|
}
|
|
10362
10388
|
}
|
|
10389
|
+
/**
|
|
10390
|
+
* Pick THE room's global mesh: the one whose scan origin is nearest the
|
|
10391
|
+
* viewer, sticky to the current choice within a margin so origin jitter
|
|
10392
|
+
* can't flap the room. Without a viewer pose (or with a single candidate)
|
|
10393
|
+
* the first candidate stands; ties are impossible to break anyway.
|
|
10394
|
+
*/
|
|
10395
|
+
electGlobalMesh(frame, detected, referenceSpace) {
|
|
10396
|
+
let nearest = null;
|
|
10397
|
+
let nearestDist = Number.POSITIVE_INFINITY;
|
|
10398
|
+
let currentDist = Number.POSITIVE_INFINITY;
|
|
10399
|
+
let currentStillDetected = false;
|
|
10400
|
+
for (const mesh of detected) {
|
|
10401
|
+
if (!isGlobalMeshSurface(mesh)) continue;
|
|
10402
|
+
if (!this.viewerPos) {
|
|
10403
|
+
return this.electedGlobalMesh && detected.has(this.electedGlobalMesh) ? this.electedGlobalMesh : mesh;
|
|
10404
|
+
}
|
|
10405
|
+
const pose = frame.getPose(mesh.meshSpace, referenceSpace);
|
|
10406
|
+
if (!pose) continue;
|
|
10407
|
+
const m = pose.transform.matrix;
|
|
10408
|
+
const d = Math.hypot(
|
|
10409
|
+
m[12] - this.viewerPos.x,
|
|
10410
|
+
m[13] - this.viewerPos.y,
|
|
10411
|
+
m[14] - this.viewerPos.z
|
|
10412
|
+
);
|
|
10413
|
+
if (mesh === this.electedGlobalMesh) {
|
|
10414
|
+
currentDist = d;
|
|
10415
|
+
currentStillDetected = true;
|
|
10416
|
+
}
|
|
10417
|
+
if (d < nearestDist) {
|
|
10418
|
+
nearestDist = d;
|
|
10419
|
+
nearest = mesh;
|
|
10420
|
+
}
|
|
10421
|
+
}
|
|
10422
|
+
if (currentStillDetected && currentDist < nearestDist + GLOBAL_MESH_SWITCH_MARGIN) {
|
|
10423
|
+
return this.electedGlobalMesh;
|
|
10424
|
+
}
|
|
10425
|
+
this.electedGlobalMesh = nearest;
|
|
10426
|
+
return nearest;
|
|
10427
|
+
}
|
|
10363
10428
|
/**
|
|
10364
10429
|
* Admission control for a NOT-yet-spawned surface. With a viewer pose
|
|
10365
10430
|
* available, the surface must behave world-anchored for a few frames before
|
|
@@ -10571,6 +10636,7 @@ var _XREnvironmentSystem = class _XREnvironmentSystem {
|
|
|
10571
10636
|
this.clearMap(world, this.meshes);
|
|
10572
10637
|
this.pendingPlanes.clear();
|
|
10573
10638
|
this.pendingMeshes.clear();
|
|
10639
|
+
this.electedGlobalMesh = null;
|
|
10574
10640
|
}
|
|
10575
10641
|
dispose(world) {
|
|
10576
10642
|
this.clearAll(world);
|