@relu-interactives/spatial-ecs 0.3.11 → 0.3.12
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/{XRHandPose-C-KJeYcJ.d.cts → XRHandPose-DawOR0uR.d.cts} +8 -0
- package/dist/{XRHandPose-B6I4y1lj.d.ts → XRHandPose-DhAd9Qi6.d.ts} +8 -0
- package/dist/{chunk-Y3AC3VZ2.js → chunk-7ZIN6TGT.js} +3 -3
- package/dist/{chunk-Y3AC3VZ2.js.map → chunk-7ZIN6TGT.js.map} +1 -1
- package/dist/{chunk-FSHRPY65.js → chunk-ID7U4FER.js} +4 -4
- package/dist/{chunk-FSHRPY65.js.map → chunk-ID7U4FER.js.map} +1 -1
- package/dist/{chunk-KLU2M43M.js → chunk-LCJ6IH2O.js} +60 -20
- package/dist/chunk-LCJ6IH2O.js.map +1 -0
- package/dist/{chunk-TXEGYR76.js → chunk-OMDYLFTN.js} +4 -2
- package/dist/chunk-OMDYLFTN.js.map +1 -0
- package/dist/components/index.cjs +2 -0
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.d.cts +2 -2
- package/dist/components/index.d.ts +2 -2
- package/dist/components/index.js +1 -1
- package/dist/docs/guide/vr-and-hand-poses.md +1 -1
- package/dist/factories/index.cjs +2 -0
- package/dist/factories/index.cjs.map +1 -1
- package/dist/factories/index.d.cts +1 -1
- package/dist/factories/index.d.ts +1 -1
- package/dist/factories/index.js +3 -3
- package/dist/{index-CEZp7qLL.d.ts → index-B49322Q3.d.ts} +1 -1
- package/dist/{index-jlgDou9W.d.cts → index-DJ9bn9SF.d.cts} +14 -0
- package/dist/{index-Bi_wIo1o.d.ts → index-M0I5B3JA.d.ts} +14 -0
- package/dist/{index-DPRnnSI-.d.cts → index-Xm3im4Pt.d.cts} +1 -1
- package/dist/index.cjs +58 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +8 -8
- package/dist/systems/index.cjs +58 -16
- 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 +3 -3
- package/package.json +1 -1
- package/dist/chunk-KLU2M43M.js.map +0 -1
- package/dist/chunk-TXEGYR76.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, createAttachPoint, XRHandPoseComponent, createHandPoseEntry, XRInteractorComponent, XRInteractorSideComponent, InstanceSlotComponent, Name, ImageComponent, SpriteComponent, VideoComponent, AudioComponent, ImageTarget, Selectable, PrefabNode, PrefabInstance, handPoseDefinitionFor, getHandPosePreset } from './chunk-
|
|
1
|
+
import { resolveDracoDecoderPath, applyTransform, SHARED_MODEL_RESOURCE_FLAG } from './chunk-7ZIN6TGT.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, createAttachPoint, XRHandPoseComponent, createHandPoseEntry, XRInteractorComponent, XRInteractorSideComponent, InstanceSlotComponent, Name, ImageComponent, SpriteComponent, VideoComponent, AudioComponent, ImageTarget, Selectable, PrefabNode, PrefabInstance, handPoseDefinitionFor, getHandPosePreset } from './chunk-OMDYLFTN.js';
|
|
3
3
|
import { __name } from './chunk-OY7ZODZP.js';
|
|
4
4
|
import * as THREE19 from 'three';
|
|
5
5
|
import { DRACOLoader } from 'three/examples/jsm/loaders/DRACOLoader.js';
|
|
@@ -3134,6 +3134,12 @@ function restorePostCreateComponents(world, objectManagementSystem, targetEntity
|
|
|
3134
3134
|
if (typeof sourceInteractor.showRay === "boolean") {
|
|
3135
3135
|
interactor.showRay = sourceInteractor.showRay;
|
|
3136
3136
|
}
|
|
3137
|
+
if (typeof sourceInteractor.rayColor === "string") {
|
|
3138
|
+
interactor.rayColor = sourceInteractor.rayColor;
|
|
3139
|
+
}
|
|
3140
|
+
if (typeof sourceInteractor.rayThickness === "number") {
|
|
3141
|
+
interactor.rayThickness = sourceInteractor.rayThickness;
|
|
3142
|
+
}
|
|
3137
3143
|
}
|
|
3138
3144
|
}
|
|
3139
3145
|
{
|
|
@@ -7191,6 +7197,13 @@ var _XRInteractionSystem = class _XRInteractionSystem {
|
|
|
7191
7197
|
isGrabbing() {
|
|
7192
7198
|
return this.grabs.size > 0;
|
|
7193
7199
|
}
|
|
7200
|
+
/** True when THIS hand is holding something. */
|
|
7201
|
+
isGrabbingWith(handedness) {
|
|
7202
|
+
for (const input of this.grabs.keys()) {
|
|
7203
|
+
if (input.handedness === handedness) return true;
|
|
7204
|
+
}
|
|
7205
|
+
return false;
|
|
7206
|
+
}
|
|
7194
7207
|
/**
|
|
7195
7208
|
* How an entity is currently held.
|
|
7196
7209
|
*
|
|
@@ -7750,6 +7763,7 @@ __name(applyHandMaterial, "applyHandMaterial");
|
|
|
7750
7763
|
|
|
7751
7764
|
// core/systems/XRControllerVisualSystem.ts
|
|
7752
7765
|
var RAY_LENGTH = 5;
|
|
7766
|
+
var RAY_RADIUS = 3e-3;
|
|
7753
7767
|
var SLOTS = [
|
|
7754
7768
|
{ index: 0, side: "left" },
|
|
7755
7769
|
{ index: 1, side: "right" }
|
|
@@ -7759,6 +7773,8 @@ var _XRControllerVisualSystem = class _XRControllerVisualSystem {
|
|
|
7759
7773
|
this.controllerModelFactory = new XRControllerModelFactory();
|
|
7760
7774
|
this.handModelFactory = new XRHandModelFactory();
|
|
7761
7775
|
this.group = new THREE19.Group();
|
|
7776
|
+
/** Reused so a per-frame colour compare allocates nothing. */
|
|
7777
|
+
this.rayColorScratch = new THREE19.Color();
|
|
7762
7778
|
this.slots = /* @__PURE__ */ new Map();
|
|
7763
7779
|
this.attachedTo = null;
|
|
7764
7780
|
/** Last applied preset signature, so materials rebuild only on real change. */
|
|
@@ -7787,8 +7803,9 @@ var _XRControllerVisualSystem = class _XRControllerVisualSystem {
|
|
|
7787
7803
|
const hasHand = liveKind === null || liveKind === "hand";
|
|
7788
7804
|
visuals.controllerModel.visible = showControllers && hasController;
|
|
7789
7805
|
visuals.handModel.visible = showHands && hasHand;
|
|
7790
|
-
visuals.ray.visible = this.shouldShowRay(interactor);
|
|
7806
|
+
visuals.ray.visible = this.shouldShowRay(interactor, side);
|
|
7791
7807
|
this.fitRayToHover(visuals.ray, side);
|
|
7808
|
+
this.applyRayStyle(visuals.ray, interactor);
|
|
7792
7809
|
if (showHands && this.handMaterial) {
|
|
7793
7810
|
applyHandMaterial(visuals.handModel, this.handMaterial);
|
|
7794
7811
|
}
|
|
@@ -7864,10 +7881,23 @@ var _XRControllerVisualSystem = class _XRControllerVisualSystem {
|
|
|
7864
7881
|
* off entirely; otherwise it appears on hover/grab so it isn't permanent
|
|
7865
7882
|
* clutter implying the whole scene is clickable.
|
|
7866
7883
|
*/
|
|
7867
|
-
shouldShowRay(interactor) {
|
|
7884
|
+
shouldShowRay(interactor, side) {
|
|
7868
7885
|
if (interactor && !interactor.showRay) return false;
|
|
7869
7886
|
if (!this.interactionSystem) return true;
|
|
7870
|
-
return this.interactionSystem.
|
|
7887
|
+
return this.interactionSystem.getHoverFor(side) !== null || this.interactionSystem.isGrabbingWith(side);
|
|
7888
|
+
}
|
|
7889
|
+
/** Push the author's ray colour and thickness onto the mesh. */
|
|
7890
|
+
applyRayStyle(ray, interactor) {
|
|
7891
|
+
if (!interactor) return;
|
|
7892
|
+
const material = ray.material;
|
|
7893
|
+
if (material?.color && !material.color.equals(this.rayColorScratch.set(interactor.rayColor))) {
|
|
7894
|
+
material.color.copy(this.rayColorScratch);
|
|
7895
|
+
}
|
|
7896
|
+
const radius = Math.max(5e-4, interactor.rayThickness / 2) / RAY_RADIUS;
|
|
7897
|
+
if (ray.scale.x !== radius) {
|
|
7898
|
+
ray.scale.x = radius;
|
|
7899
|
+
ray.scale.y = radius;
|
|
7900
|
+
}
|
|
7871
7901
|
}
|
|
7872
7902
|
/**
|
|
7873
7903
|
* Stop the ray at whatever it is pointing at.
|
|
@@ -7879,7 +7909,7 @@ var _XRControllerVisualSystem = class _XRControllerVisualSystem {
|
|
|
7879
7909
|
fitRayToHover(ray, side) {
|
|
7880
7910
|
const hover = this.interactionSystem?.getHoverFor(side) ?? null;
|
|
7881
7911
|
const length = hover && Number.isFinite(hover.distance) && hover.distance > 0 ? Math.min(hover.distance, RAY_LENGTH) : RAY_LENGTH;
|
|
7882
|
-
ray.scale.z = length
|
|
7912
|
+
ray.scale.z = length;
|
|
7883
7913
|
}
|
|
7884
7914
|
/** Lazily build per-slot visuals; the device reports profiles late. */
|
|
7885
7915
|
ensureSlots(world) {
|
|
@@ -7919,22 +7949,32 @@ var _XRControllerVisualSystem = class _XRControllerVisualSystem {
|
|
|
7919
7949
|
target.add(this.group);
|
|
7920
7950
|
this.attachedTo = target;
|
|
7921
7951
|
}
|
|
7952
|
+
/**
|
|
7953
|
+
* The pointer ray.
|
|
7954
|
+
*
|
|
7955
|
+
* A cylinder rather than a `THREE.Line`, because WebGL ignores `linewidth` —
|
|
7956
|
+
* every line renders one pixel wide regardless, which is nearly invisible on a
|
|
7957
|
+
* headset. A thin mesh is the only way to get a ray with real thickness
|
|
7958
|
+
* without pulling in a line-rendering extension.
|
|
7959
|
+
*/
|
|
7922
7960
|
createRay() {
|
|
7923
|
-
const geometry = new THREE19.
|
|
7924
|
-
|
|
7925
|
-
|
|
7926
|
-
|
|
7927
|
-
const material = new THREE19.LineBasicMaterial({
|
|
7961
|
+
const geometry = new THREE19.CylinderGeometry(RAY_RADIUS, RAY_RADIUS, 1, 8, 1);
|
|
7962
|
+
geometry.rotateX(-Math.PI / 2);
|
|
7963
|
+
geometry.translate(0, 0, -0.5);
|
|
7964
|
+
const material = new THREE19.MeshBasicMaterial({
|
|
7928
7965
|
color: "#4da3ff",
|
|
7929
7966
|
transparent: true,
|
|
7930
|
-
opacity: 0.
|
|
7931
|
-
depthTest: false
|
|
7967
|
+
opacity: 0.75,
|
|
7968
|
+
depthTest: false,
|
|
7969
|
+
depthWrite: false
|
|
7932
7970
|
});
|
|
7933
|
-
const
|
|
7934
|
-
|
|
7935
|
-
|
|
7936
|
-
|
|
7937
|
-
|
|
7971
|
+
const mesh = new THREE19.Mesh(geometry, material);
|
|
7972
|
+
mesh.name = "XRPointerRay";
|
|
7973
|
+
mesh.renderOrder = 999;
|
|
7974
|
+
mesh.visible = false;
|
|
7975
|
+
mesh.raycast = () => {
|
|
7976
|
+
};
|
|
7977
|
+
return mesh;
|
|
7938
7978
|
}
|
|
7939
7979
|
dispose() {
|
|
7940
7980
|
this.group.removeFromParent();
|
|
@@ -8733,5 +8773,5 @@ __name(_XRHoverVisualSystem, "XRHoverVisualSystem");
|
|
|
8733
8773
|
var XRHoverVisualSystem = _XRHoverVisualSystem;
|
|
8734
8774
|
|
|
8735
8775
|
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, 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 };
|
|
8736
|
-
//# sourceMappingURL=chunk-
|
|
8737
|
-
//# sourceMappingURL=chunk-
|
|
8776
|
+
//# sourceMappingURL=chunk-LCJ6IH2O.js.map
|
|
8777
|
+
//# sourceMappingURL=chunk-LCJ6IH2O.js.map
|