@relu-interactives/spatial-ecs 0.3.5 → 0.3.6
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/{System-vrU46Vuw.d.cts → System-TmC2EijF.d.cts} +2 -2
- package/dist/{System-vrU46Vuw.d.ts → System-TmC2EijF.d.ts} +2 -2
- package/dist/{XRRig-2686IqLQ.d.cts → XRInteractor-CCUzSqg9.d.ts} +96 -2
- package/dist/{XRRig-D2QURXl1.d.ts → XRInteractor-I2q6TKtF.d.cts} +96 -2
- package/dist/{chunk-4BZYK3JP.js → chunk-FQTOC7HK.js} +135 -88
- package/dist/chunk-FQTOC7HK.js.map +1 -0
- package/dist/{chunk-2LVFGVWI.js → chunk-JRJ3CL5H.js} +3 -3
- package/dist/{chunk-2LVFGVWI.js.map → chunk-JRJ3CL5H.js.map} +1 -1
- package/dist/{chunk-6QC2PJLD.js → chunk-N4GKZ7IV.js} +29 -3
- package/dist/chunk-N4GKZ7IV.js.map +1 -0
- package/dist/{chunk-G53MZVKQ.js → chunk-WRJ2K3LZ.js} +285 -39
- package/dist/chunk-WRJ2K3LZ.js.map +1 -0
- package/dist/components/index.cjs +26 -0
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.d.cts +3 -3
- package/dist/components/index.d.ts +3 -3
- package/dist/components/index.js +1 -1
- package/dist/factories/index.cjs +185 -112
- package/dist/factories/index.cjs.map +1 -1
- package/dist/factories/index.d.cts +7 -3
- package/dist/factories/index.d.ts +7 -3
- package/dist/factories/index.js +3 -3
- package/dist/{index-BtKOaHfY.d.ts → index-BltjPEhg.d.cts} +10 -3
- package/dist/{index-B-CViRMx.d.ts → index-BpbmZuOz.d.ts} +43 -14
- package/dist/{index-BvCmmuJ0.d.cts → index-C5FrDt3z.d.cts} +43 -14
- package/dist/{index-Xu238jLn.d.cts → index-W8pUajCW.d.ts} +10 -3
- package/dist/index.cjs +602 -279
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +35 -9
- package/dist/index.d.ts +35 -9
- package/dist/index.js +8 -8
- package/dist/systems/index.cjs +304 -34
- package/dist/systems/index.cjs.map +1 -1
- package/dist/systems/index.d.cts +2 -2
- package/dist/systems/index.d.ts +2 -2
- package/dist/systems/index.js +3 -3
- package/dist/types.d.cts +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/worldSnapshotUtils.d.cts +1 -1
- package/dist/worldSnapshotUtils.d.ts +1 -1
- package/package.json +1 -1
- package/dist/chunk-4BZYK3JP.js.map +0 -1
- package/dist/chunk-6QC2PJLD.js.map +0 -1
- package/dist/chunk-G53MZVKQ.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { resolveDracoDecoderPath, applyTransform, SHARED_MODEL_RESOURCE_FLAG } from './chunk-
|
|
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, InstanceSlotComponent, Name, ImageComponent, SpriteComponent, VideoComponent, AudioComponent, ImageTarget, Selectable, PrefabNode, PrefabInstance } from './chunk-
|
|
1
|
+
import { resolveDracoDecoderPath, applyTransform, SHARED_MODEL_RESOURCE_FLAG } from './chunk-JRJ3CL5H.js';
|
|
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, XRInteractorComponent, XRInteractorSideComponent, InstanceSlotComponent, Name, ImageComponent, SpriteComponent, VideoComponent, AudioComponent, ImageTarget, Selectable, PrefabNode, PrefabInstance } from './chunk-N4GKZ7IV.js';
|
|
3
3
|
import { __name } from './chunk-OY7ZODZP.js';
|
|
4
4
|
import * as THREE7 from 'three';
|
|
5
5
|
import { DRACOLoader } from 'three/examples/jsm/loaders/DRACOLoader.js';
|
|
@@ -2791,6 +2791,14 @@ function buildComponentValueMaps(snapshot) {
|
|
|
2791
2791
|
snapshot.components,
|
|
2792
2792
|
"XRInteractableComponent"
|
|
2793
2793
|
),
|
|
2794
|
+
xrInteractorValues: readByComponent(
|
|
2795
|
+
snapshot.components,
|
|
2796
|
+
"XRInteractorComponent"
|
|
2797
|
+
),
|
|
2798
|
+
xrInteractorSideValues: readByComponent(
|
|
2799
|
+
snapshot.components,
|
|
2800
|
+
"XRInteractorSideComponent"
|
|
2801
|
+
),
|
|
2794
2802
|
instancedMeshValues: readByComponent(snapshot.components, "InstancedMeshComponent"),
|
|
2795
2803
|
instanceSlotValues: readByComponent(snapshot.components, "InstanceSlotComponent"),
|
|
2796
2804
|
prefabNodeValues: readByComponent(snapshot.components, "PrefabNode"),
|
|
@@ -2977,6 +2985,60 @@ function restorePostCreateComponents(world, objectManagementSystem, targetEntity
|
|
|
2977
2985
|
}
|
|
2978
2986
|
}
|
|
2979
2987
|
}
|
|
2988
|
+
{
|
|
2989
|
+
const sourceInteractor = asRecord(
|
|
2990
|
+
values.xrInteractorValues.get(sourceEntityId)
|
|
2991
|
+
);
|
|
2992
|
+
const interactor = world.getComponent(targetEntityId, XRInteractorComponent);
|
|
2993
|
+
if (sourceInteractor && interactor) {
|
|
2994
|
+
if (typeof sourceInteractor.interactorType === "string") {
|
|
2995
|
+
interactor.interactorType = sourceInteractor.interactorType;
|
|
2996
|
+
}
|
|
2997
|
+
if (typeof sourceInteractor.handPreset === "string") {
|
|
2998
|
+
interactor.handPreset = sourceInteractor.handPreset;
|
|
2999
|
+
}
|
|
3000
|
+
if (typeof sourceInteractor.handColor === "string") {
|
|
3001
|
+
interactor.handColor = sourceInteractor.handColor;
|
|
3002
|
+
}
|
|
3003
|
+
if (typeof sourceInteractor.handOpacity === "number") {
|
|
3004
|
+
interactor.handOpacity = sourceInteractor.handOpacity;
|
|
3005
|
+
}
|
|
3006
|
+
if (typeof sourceInteractor.handEmissiveIntensity === "number") {
|
|
3007
|
+
interactor.handEmissiveIntensity = sourceInteractor.handEmissiveIntensity;
|
|
3008
|
+
}
|
|
3009
|
+
if (typeof sourceInteractor.showRay === "boolean") {
|
|
3010
|
+
interactor.showRay = sourceInteractor.showRay;
|
|
3011
|
+
}
|
|
3012
|
+
}
|
|
3013
|
+
}
|
|
3014
|
+
{
|
|
3015
|
+
const sourceSide = asRecord(
|
|
3016
|
+
values.xrInteractorSideValues.get(sourceEntityId)
|
|
3017
|
+
);
|
|
3018
|
+
if (sourceSide && typeof sourceSide.side === "string") {
|
|
3019
|
+
const existing = world.getComponent(
|
|
3020
|
+
targetEntityId,
|
|
3021
|
+
XRInteractorSideComponent
|
|
3022
|
+
);
|
|
3023
|
+
if (existing) {
|
|
3024
|
+
existing.side = sourceSide.side;
|
|
3025
|
+
} else {
|
|
3026
|
+
world.addComponent(
|
|
3027
|
+
targetEntityId,
|
|
3028
|
+
new XRInteractorSideComponent({
|
|
3029
|
+
side: sourceSide.side
|
|
3030
|
+
})
|
|
3031
|
+
);
|
|
3032
|
+
}
|
|
3033
|
+
}
|
|
3034
|
+
}
|
|
3035
|
+
{
|
|
3036
|
+
const sourceRigOrigin = asRecord(values.xrRigValues.get(sourceEntityId));
|
|
3037
|
+
const rigForOrigin = world.getComponent(targetEntityId, XRRigComponent);
|
|
3038
|
+
if (sourceRigOrigin && rigForOrigin && typeof sourceRigOrigin.trackingOrigin === "string") {
|
|
3039
|
+
rigForOrigin.trackingOrigin = sourceRigOrigin.trackingOrigin;
|
|
3040
|
+
}
|
|
3041
|
+
}
|
|
2980
3042
|
{
|
|
2981
3043
|
const imComponent = world.getComponent(targetEntityId, InstancedMeshComponent);
|
|
2982
3044
|
if (imComponent && imComponent.instanceEntityIds.length > 0) {
|
|
@@ -3566,6 +3628,7 @@ var HYDRATABLE_ENTITY_KINDS = /* @__PURE__ */ new Set([
|
|
|
3566
3628
|
"instanceSlot",
|
|
3567
3629
|
"scriptObject",
|
|
3568
3630
|
"xrRig",
|
|
3631
|
+
"xrInteractor",
|
|
3569
3632
|
"teleportArea"
|
|
3570
3633
|
]);
|
|
3571
3634
|
|
|
@@ -6119,6 +6182,9 @@ var _XRInputSystem = class _XRInputSystem {
|
|
|
6119
6182
|
state.hasAxes = false;
|
|
6120
6183
|
state.buttons = [];
|
|
6121
6184
|
}
|
|
6185
|
+
}
|
|
6186
|
+
for (const record of this.records.values()) {
|
|
6187
|
+
const state = record.state;
|
|
6122
6188
|
if (record.pendingSelectStart) {
|
|
6123
6189
|
state.select = true;
|
|
6124
6190
|
state.selectStart = true;
|
|
@@ -6560,6 +6626,8 @@ var _XRSessionSystem = class _XRSessionSystem {
|
|
|
6560
6626
|
constructor(inputSystem) {
|
|
6561
6627
|
this.presenting = false;
|
|
6562
6628
|
this.capabilities = NO_XR_CAPABILITIES;
|
|
6629
|
+
/** Y compensation applied when a floor-relative space was requested but not granted. */
|
|
6630
|
+
this.appliedOriginOffset = 0;
|
|
6563
6631
|
this.inputSystem = inputSystem ?? null;
|
|
6564
6632
|
}
|
|
6565
6633
|
update(world) {
|
|
@@ -6583,11 +6651,59 @@ var _XRSessionSystem = class _XRSessionSystem {
|
|
|
6583
6651
|
if (session && this.inputSystem) {
|
|
6584
6652
|
this.inputSystem.attachSession(session);
|
|
6585
6653
|
}
|
|
6654
|
+
this.applyTrackingOrigin(world, session ?? null);
|
|
6586
6655
|
this.forEachBehaviour(world, (behaviour) => {
|
|
6587
6656
|
behaviour.onXRSessionStart(this.capabilities);
|
|
6588
6657
|
});
|
|
6589
6658
|
}
|
|
6659
|
+
/**
|
|
6660
|
+
* Apply the rig's authored tracking origin, and compensate when the device
|
|
6661
|
+
* cannot honour it.
|
|
6662
|
+
*
|
|
6663
|
+
* `floor` (`local-floor`) puts Y=0 on the user's real floor, which is what a
|
|
6664
|
+
* scene authored standing on the ground expects. `eye` (`local`) puts Y=0 at
|
|
6665
|
+
* the headset, for seated experiences.
|
|
6666
|
+
*
|
|
6667
|
+
* The compensation matters: `local-floor` is only ever REQUESTED as an
|
|
6668
|
+
* optional feature (requiring it would make `requestSession` reject outright
|
|
6669
|
+
* on devices that lack it). When it isn't granted, the runtime silently falls
|
|
6670
|
+
* back to `local` — the origin jumps to head height and a floor-authored
|
|
6671
|
+
* scene swallows the user, which is exactly the "I'm standing under the
|
|
6672
|
+
* building" symptom. Offsetting the rig down by the eye height restores the
|
|
6673
|
+
* intended floor relationship instead of leaving it broken.
|
|
6674
|
+
*/
|
|
6675
|
+
applyTrackingOrigin(world, session) {
|
|
6676
|
+
const rigEntityId = world.query(XRRigComponent, TransformComponent)[0];
|
|
6677
|
+
if (typeof rigEntityId !== "number") return;
|
|
6678
|
+
const rig = world.getComponent(rigEntityId, XRRigComponent);
|
|
6679
|
+
const transform = world.getComponent(rigEntityId, TransformComponent);
|
|
6680
|
+
if (!rig || !transform) return;
|
|
6681
|
+
const renderer = world.getRenderer();
|
|
6682
|
+
const wantsFloor = rig.trackingOrigin === "floor";
|
|
6683
|
+
try {
|
|
6684
|
+
renderer.xr.setReferenceSpaceType(wantsFloor ? "local-floor" : "local");
|
|
6685
|
+
} catch {
|
|
6686
|
+
}
|
|
6687
|
+
const granted = session?.enabledFeatures;
|
|
6688
|
+
const floorGranted = Array.isArray(granted) ? granted.includes("local-floor") : (
|
|
6689
|
+
// No report at all: trust the request, since a wrong offset is worse
|
|
6690
|
+
// than none on devices that did honour it.
|
|
6691
|
+
true
|
|
6692
|
+
);
|
|
6693
|
+
this.appliedOriginOffset = wantsFloor && !floorGranted ? rig.fallbackEyeHeight : 0;
|
|
6694
|
+
if (this.appliedOriginOffset !== 0) {
|
|
6695
|
+
transform.position.y -= this.appliedOriginOffset;
|
|
6696
|
+
}
|
|
6697
|
+
}
|
|
6590
6698
|
handleSessionEnd(world) {
|
|
6699
|
+
if (this.appliedOriginOffset !== 0) {
|
|
6700
|
+
const rigEntityId = world.query(XRRigComponent, TransformComponent)[0];
|
|
6701
|
+
if (typeof rigEntityId === "number") {
|
|
6702
|
+
const transform = world.getComponent(rigEntityId, TransformComponent);
|
|
6703
|
+
if (transform) transform.position.y += this.appliedOriginOffset;
|
|
6704
|
+
}
|
|
6705
|
+
this.appliedOriginOffset = 0;
|
|
6706
|
+
}
|
|
6591
6707
|
this.capabilities = NO_XR_CAPABILITIES;
|
|
6592
6708
|
this.inputSystem?.detachSession();
|
|
6593
6709
|
this.forEachBehaviour(world, (behaviour) => {
|
|
@@ -6681,17 +6797,74 @@ var _VRTeleportAreaSystem = class _VRTeleportAreaSystem {
|
|
|
6681
6797
|
};
|
|
6682
6798
|
__name(_VRTeleportAreaSystem, "VRTeleportAreaSystem");
|
|
6683
6799
|
var VRTeleportAreaSystem = _VRTeleportAreaSystem;
|
|
6800
|
+
function createHandMaterial(preset, options) {
|
|
6801
|
+
const color = new THREE7.Color(options.color);
|
|
6802
|
+
switch (preset) {
|
|
6803
|
+
case "ghost":
|
|
6804
|
+
return new THREE7.MeshBasicMaterial({
|
|
6805
|
+
color,
|
|
6806
|
+
transparent: true,
|
|
6807
|
+
opacity: Math.min(1, Math.max(0.05, options.opacity * 0.45)),
|
|
6808
|
+
depthWrite: false,
|
|
6809
|
+
side: THREE7.DoubleSide
|
|
6810
|
+
});
|
|
6811
|
+
case "neon":
|
|
6812
|
+
return new THREE7.MeshStandardMaterial({
|
|
6813
|
+
color,
|
|
6814
|
+
emissive: color,
|
|
6815
|
+
emissiveIntensity: Math.max(0.5, options.emissiveIntensity || 2),
|
|
6816
|
+
roughness: 0.35,
|
|
6817
|
+
metalness: 0,
|
|
6818
|
+
transparent: options.opacity < 1,
|
|
6819
|
+
opacity: options.opacity
|
|
6820
|
+
});
|
|
6821
|
+
case "skeleton":
|
|
6822
|
+
return new THREE7.MeshBasicMaterial({
|
|
6823
|
+
color,
|
|
6824
|
+
wireframe: true,
|
|
6825
|
+
transparent: true,
|
|
6826
|
+
opacity: options.opacity
|
|
6827
|
+
});
|
|
6828
|
+
case "custom":
|
|
6829
|
+
case "default":
|
|
6830
|
+
return new THREE7.MeshStandardMaterial({
|
|
6831
|
+
color,
|
|
6832
|
+
roughness: 0.85,
|
|
6833
|
+
metalness: 0,
|
|
6834
|
+
emissive: color,
|
|
6835
|
+
emissiveIntensity: Math.max(0, options.emissiveIntensity),
|
|
6836
|
+
transparent: options.opacity < 1,
|
|
6837
|
+
opacity: options.opacity,
|
|
6838
|
+
side: THREE7.DoubleSide
|
|
6839
|
+
});
|
|
6840
|
+
default: {
|
|
6841
|
+
return new THREE7.MeshStandardMaterial({ color });
|
|
6842
|
+
}
|
|
6843
|
+
}
|
|
6844
|
+
}
|
|
6845
|
+
__name(createHandMaterial, "createHandMaterial");
|
|
6846
|
+
function applyHandMaterial(root, material) {
|
|
6847
|
+
root.traverse((child) => {
|
|
6848
|
+
const mesh = child;
|
|
6849
|
+
if (!mesh.isMesh) return;
|
|
6850
|
+
mesh.material = material;
|
|
6851
|
+
});
|
|
6852
|
+
}
|
|
6853
|
+
__name(applyHandMaterial, "applyHandMaterial");
|
|
6854
|
+
var SLOTS = [
|
|
6855
|
+
{ index: 0, side: "left" },
|
|
6856
|
+
{ index: 1, side: "right" }
|
|
6857
|
+
];
|
|
6684
6858
|
var _XRControllerVisualSystem = class _XRControllerVisualSystem {
|
|
6685
6859
|
constructor(options) {
|
|
6686
6860
|
this.controllerModelFactory = new XRControllerModelFactory();
|
|
6687
6861
|
this.handModelFactory = new XRHandModelFactory();
|
|
6688
6862
|
this.group = new THREE7.Group();
|
|
6689
|
-
this.
|
|
6863
|
+
this.slots = /* @__PURE__ */ new Map();
|
|
6690
6864
|
this.attachedTo = null;
|
|
6691
|
-
/**
|
|
6692
|
-
this.
|
|
6693
|
-
this.
|
|
6694
|
-
this.slots = options?.slots ?? 2;
|
|
6865
|
+
/** Last applied preset signature, so materials rebuild only on real change. */
|
|
6866
|
+
this.handStyleSignature = "";
|
|
6867
|
+
this.handMaterial = null;
|
|
6695
6868
|
this.interactionSystem = options?.interactionSystem ?? null;
|
|
6696
6869
|
this.group.name = "XRControllerVisuals";
|
|
6697
6870
|
this.group.userData.ecsPreviewHidden = true;
|
|
@@ -6700,39 +6873,111 @@ var _XRControllerVisualSystem = class _XRControllerVisualSystem {
|
|
|
6700
6873
|
const renderer = world.getRenderer();
|
|
6701
6874
|
if (!renderer.xr?.enabled) return;
|
|
6702
6875
|
this.ensureAttached(world);
|
|
6703
|
-
this.
|
|
6704
|
-
|
|
6705
|
-
|
|
6706
|
-
|
|
6876
|
+
this.ensureSlots(world);
|
|
6877
|
+
const interactor = this.resolveInteractor(world);
|
|
6878
|
+
const type = interactor?.interactorType ?? "both";
|
|
6879
|
+
const showControllers = type === "controllers" || type === "both";
|
|
6880
|
+
const showHands = type === "hands" || type === "both";
|
|
6881
|
+
this.syncHandMaterial(interactor);
|
|
6882
|
+
for (const { index, side } of SLOTS) {
|
|
6883
|
+
const visuals = this.slots.get(index);
|
|
6884
|
+
if (!visuals) continue;
|
|
6885
|
+
visuals.controllerModel.visible = showControllers;
|
|
6886
|
+
visuals.handModel.visible = showHands;
|
|
6887
|
+
visuals.ray.visible = this.shouldShowRay(interactor);
|
|
6888
|
+
if (showHands && this.handMaterial) {
|
|
6889
|
+
applyHandMaterial(visuals.handModel, this.handMaterial);
|
|
6890
|
+
}
|
|
6891
|
+
this.syncCustomContent(world, visuals, side);
|
|
6892
|
+
}
|
|
6893
|
+
}
|
|
6894
|
+
/** The scene's interactor config, if one was authored. */
|
|
6895
|
+
resolveInteractor(world) {
|
|
6896
|
+
const entityId = world.query(XRInteractorComponent)[0];
|
|
6897
|
+
if (typeof entityId !== "number") return null;
|
|
6898
|
+
return world.getComponent(entityId, XRInteractorComponent) ?? null;
|
|
6899
|
+
}
|
|
6900
|
+
/**
|
|
6901
|
+
* Re-parent the author's left/right interactor content onto the tracked grip
|
|
6902
|
+
* space so it follows the hand.
|
|
6903
|
+
*
|
|
6904
|
+
* `ObjectManagementSystem` reconciles ECS objects back under their ParentId
|
|
6905
|
+
* every frame, so this re-attach has to be re-asserted — the same coexistence
|
|
6906
|
+
* dance the AR anchor system performs.
|
|
6907
|
+
*/
|
|
6908
|
+
syncCustomContent(world, visuals, side) {
|
|
6909
|
+
let content = null;
|
|
6910
|
+
for (const entityId of world.query(
|
|
6911
|
+
XRInteractorSideComponent,
|
|
6912
|
+
Object3DRef
|
|
6913
|
+
)) {
|
|
6914
|
+
const slot = world.getComponent(entityId, XRInteractorSideComponent);
|
|
6915
|
+
if (slot?.side !== side) continue;
|
|
6916
|
+
content = world.getComponent(entityId, Object3DRef)?.object ?? null;
|
|
6917
|
+
break;
|
|
6918
|
+
}
|
|
6919
|
+
if (!content) {
|
|
6920
|
+
visuals.attachedCustom = null;
|
|
6921
|
+
return;
|
|
6922
|
+
}
|
|
6923
|
+
if (content.parent !== visuals.grip) {
|
|
6924
|
+
visuals.grip.add(content);
|
|
6925
|
+
}
|
|
6926
|
+
visuals.attachedCustom = content;
|
|
6927
|
+
}
|
|
6928
|
+
/** Rebuild the hand material only when the authored style actually changes. */
|
|
6929
|
+
syncHandMaterial(interactor) {
|
|
6930
|
+
const preset = interactor?.handPreset ?? "default";
|
|
6931
|
+
const color = interactor?.handColor ?? "#e8b48a";
|
|
6932
|
+
const opacity = interactor?.handOpacity ?? 1;
|
|
6933
|
+
const emissive = interactor?.handEmissiveIntensity ?? 0;
|
|
6934
|
+
const signature = `${preset}:${color}:${opacity}:${emissive}`;
|
|
6935
|
+
if (signature === this.handStyleSignature && this.handMaterial) return;
|
|
6936
|
+
this.handStyleSignature = signature;
|
|
6937
|
+
this.handMaterial?.dispose();
|
|
6938
|
+
this.handMaterial = createHandMaterial(preset, {
|
|
6939
|
+
color,
|
|
6940
|
+
opacity,
|
|
6941
|
+
emissiveIntensity: emissive
|
|
6942
|
+
});
|
|
6943
|
+
}
|
|
6944
|
+
/**
|
|
6945
|
+
* The ray is meaningful only when it points at something. Authors can turn it
|
|
6946
|
+
* off entirely; otherwise it appears on hover/grab so it isn't permanent
|
|
6947
|
+
* clutter implying the whole scene is clickable.
|
|
6948
|
+
*/
|
|
6949
|
+
shouldShowRay(interactor) {
|
|
6950
|
+
if (interactor && !interactor.showRay) return false;
|
|
6951
|
+
if (!this.interactionSystem) return true;
|
|
6952
|
+
return this.interactionSystem.getHoveredEntityId() !== null || this.interactionSystem.isGrabbing();
|
|
6953
|
+
}
|
|
6954
|
+
/** Lazily build per-slot visuals; the device reports profiles late. */
|
|
6955
|
+
ensureSlots(world) {
|
|
6956
|
+
const renderer = world.getRenderer();
|
|
6957
|
+
for (const { index } of SLOTS) {
|
|
6958
|
+
if (this.slots.has(index)) continue;
|
|
6707
6959
|
const controller = renderer.xr.getController(index);
|
|
6708
6960
|
const grip = renderer.xr.getControllerGrip(index);
|
|
6709
6961
|
const hand = renderer.xr.getHand(index);
|
|
6710
6962
|
if (!controller || !grip || !hand) continue;
|
|
6711
6963
|
const ray = this.createRay();
|
|
6712
|
-
this.rays.push(ray);
|
|
6713
6964
|
controller.add(ray);
|
|
6714
|
-
this.
|
|
6715
|
-
grip.add(
|
|
6716
|
-
this.
|
|
6717
|
-
hand.add(
|
|
6718
|
-
this.group.add(hand);
|
|
6719
|
-
this.
|
|
6720
|
-
|
|
6721
|
-
|
|
6722
|
-
|
|
6965
|
+
const controllerModel = this.controllerModelFactory.createControllerModel(grip);
|
|
6966
|
+
grip.add(controllerModel);
|
|
6967
|
+
const handModel = this.handModelFactory.createHandModel(hand, "mesh");
|
|
6968
|
+
hand.add(handModel);
|
|
6969
|
+
this.group.add(controller, grip, hand);
|
|
6970
|
+
this.slots.set(index, {
|
|
6971
|
+
controller,
|
|
6972
|
+
grip,
|
|
6973
|
+
hand,
|
|
6974
|
+
ray,
|
|
6975
|
+
controllerModel,
|
|
6976
|
+
handModel,
|
|
6977
|
+
attachedCustom: null
|
|
6978
|
+
});
|
|
6723
6979
|
}
|
|
6724
6980
|
}
|
|
6725
|
-
/**
|
|
6726
|
-
* Show the aim ray only when it is meaningful: hovering something
|
|
6727
|
-
* interactive, or mid-grab. A permanently-drawn ray is visual noise, and it
|
|
6728
|
-
* implies everything is clickable when most of the scene is not. Teleport
|
|
6729
|
-
* aiming has its own arc, so the straight ray stays hidden for that.
|
|
6730
|
-
*/
|
|
6731
|
-
updateRayVisibility() {
|
|
6732
|
-
if (!this.interactionSystem) return;
|
|
6733
|
-
const active = this.interactionSystem.getHoveredEntityId() !== null || this.interactionSystem.isGrabbing();
|
|
6734
|
-
for (const ray of this.rays) ray.visible = active;
|
|
6735
|
-
}
|
|
6736
6981
|
/**
|
|
6737
6982
|
* Parent the visuals to the XR rig when there is one, so locomotion moves the
|
|
6738
6983
|
* hands with the player. Falls back to the scene root.
|
|
@@ -6758,7 +7003,7 @@ var _XRControllerVisualSystem = class _XRControllerVisualSystem {
|
|
|
6758
7003
|
const line = new THREE7.Line(geometry, material);
|
|
6759
7004
|
line.name = "XRPointerRay";
|
|
6760
7005
|
line.renderOrder = 999;
|
|
6761
|
-
line.visible =
|
|
7006
|
+
line.visible = false;
|
|
6762
7007
|
return line;
|
|
6763
7008
|
}
|
|
6764
7009
|
dispose() {
|
|
@@ -6774,9 +7019,10 @@ var _XRControllerVisualSystem = class _XRControllerVisualSystem {
|
|
|
6774
7019
|
}
|
|
6775
7020
|
});
|
|
6776
7021
|
this.group.clear();
|
|
6777
|
-
this.
|
|
6778
|
-
this.
|
|
6779
|
-
this.
|
|
7022
|
+
this.slots.clear();
|
|
7023
|
+
this.handMaterial?.dispose();
|
|
7024
|
+
this.handMaterial = null;
|
|
7025
|
+
this.handStyleSignature = "";
|
|
6780
7026
|
this.attachedTo = null;
|
|
6781
7027
|
}
|
|
6782
7028
|
};
|
|
@@ -6898,6 +7144,6 @@ var _XRTeleportVisualSystem = class _XRTeleportVisualSystem {
|
|
|
6898
7144
|
__name(_XRTeleportVisualSystem, "XRTeleportVisualSystem");
|
|
6899
7145
|
var XRTeleportVisualSystem = _XRTeleportVisualSystem;
|
|
6900
7146
|
|
|
6901
|
-
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 };
|
|
6902
|
-
//# sourceMappingURL=chunk-
|
|
6903
|
-
//# sourceMappingURL=chunk-
|
|
7147
|
+
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, applyHandMaterial, arcGroundCrossing, buildComponentValueMaps, buildNodeKeyMapsFromSnapshot, buildNodeMapsFromSnapshot, canonicalizeComponentValue, clearPrefabCache, collectDiffPaths, collectEntitySubtree, collectSnapshotSubtreeIds, computeInstanceOverrides, createHandMaterial, decanonicalizeComponentValue, despawnPrefab, encodeOverride, findSnapshotRootEntityIds, findTopLevelNestedRegions, groupOverridePaths, hydrateWorldFromSnapshot, hydrateWorldFromSnapshotDetailed, indexSnapshotByEntity, instantiateSubtree, loadPrefab, mergeComponentValue, parseOverride, parsePrefabAsset, prefabFileVersionFor, readXrCapabilities, restoreComponentState, restorePostCreateComponents, sampleTeleportArc, setPrefabAssetUrlResolver, spawnPrefab };
|
|
7148
|
+
//# sourceMappingURL=chunk-WRJ2K3LZ.js.map
|
|
7149
|
+
//# sourceMappingURL=chunk-WRJ2K3LZ.js.map
|