@relu-interactives/spatial-ecs 0.3.17 → 0.3.19
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-LR4EhboN.d.cts → XRHandPose-CLl4MiHx.d.cts} +24 -2
- package/dist/{XRHandPose-SZ7ou63b.d.ts → XRHandPose-CrzI57JA.d.ts} +24 -2
- package/dist/{chunk-PNQ7HDQC.js → chunk-D6KXWNYT.js} +3 -3
- package/dist/{chunk-PNQ7HDQC.js.map → chunk-D6KXWNYT.js.map} +1 -1
- package/dist/{chunk-3LDQ4GVZ.js → chunk-H6DQ7JRE.js} +51 -18
- package/dist/chunk-H6DQ7JRE.js.map +1 -0
- package/dist/{chunk-CE2CPZSP.js → chunk-JYKFLQB5.js} +155 -36
- package/dist/chunk-JYKFLQB5.js.map +1 -0
- package/dist/{chunk-UHJ4MDIM.js → chunk-P42OE3RU.js} +4 -4
- package/dist/{chunk-UHJ4MDIM.js.map → chunk-P42OE3RU.js.map} +1 -1
- package/dist/components/index.cjs +36 -10
- 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/docs/guide/vr-and-hand-poses.md +68 -1
- package/dist/factories/index.cjs +11 -0
- package/dist/factories/index.cjs.map +1 -1
- package/dist/factories/index.d.cts +2 -2
- package/dist/factories/index.d.ts +2 -2
- package/dist/factories/index.js +3 -3
- package/dist/{handPose-dFxqbFFY.d.cts → handPose-DlcTtqgx.d.cts} +26 -1
- package/dist/{handPose-dFxqbFFY.d.ts → handPose-DlcTtqgx.d.ts} +26 -1
- package/dist/{index-ekS4iypo.d.cts → index-3pNbH0iP.d.cts} +23 -2
- package/dist/{index-uKFxVCmr.d.ts → index-C_589fc4.d.ts} +23 -2
- package/dist/{index-ByiUoIoh.d.ts → index-JRcoel9F.d.ts} +3 -2
- package/dist/{index-BL5EWkwY.d.cts → index-g777AmFv.d.cts} +3 -2
- package/dist/index.cjs +199 -46
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -8
- package/dist/index.d.ts +11 -8
- package/dist/index.js +8 -8
- package/dist/systems/index.cjs +190 -46
- 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/package.json +1 -1
- package/dist/chunk-3LDQ4GVZ.js.map +0 -1
- package/dist/chunk-CE2CPZSP.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
2
|
import { C as Component, p as EcsEntityKind, F as EcsEntityEditorKind, r as EntityId } from './System-BhnLw0fZ.cjs';
|
|
3
3
|
import * as RAPIER from '@dimforge/rapier3d-compat';
|
|
4
|
-
import { a as XrFinger, b as XrHandPoseOrientation, X as XrHandPoseDefinition } from './handPose-
|
|
4
|
+
import { a as XrFinger, c as XrHandPoseDirection, b as XrHandPoseOrientation, X as XrHandPoseDefinition } from './handPose-DlcTtqgx.cjs';
|
|
5
5
|
|
|
6
6
|
interface StateMachine {
|
|
7
7
|
name: string;
|
|
@@ -1450,6 +1450,12 @@ type XRRigOptions = {
|
|
|
1450
1450
|
snapTurnDegrees?: number;
|
|
1451
1451
|
/** Height in metres used when the device reports no floor-relative space. */
|
|
1452
1452
|
fallbackEyeHeight?: number;
|
|
1453
|
+
/** Teleport arc colour when it lands somewhere valid. */
|
|
1454
|
+
teleportArcColor?: string;
|
|
1455
|
+
/** Teleport arc colour when it lands nowhere teleportable. */
|
|
1456
|
+
teleportArcInvalidColor?: string;
|
|
1457
|
+
/** Teleport arc thickness (diameter), metres. */
|
|
1458
|
+
teleportArcThickness?: number;
|
|
1453
1459
|
};
|
|
1454
1460
|
/**
|
|
1455
1461
|
* Marks an entity as the XR rig — the player's movable origin.
|
|
@@ -1478,6 +1484,12 @@ declare class XRRigComponent extends Component {
|
|
|
1478
1484
|
snapTurnDegrees: number;
|
|
1479
1485
|
/** Eye height fallback for devices without a floor-relative reference space. */
|
|
1480
1486
|
fallbackEyeHeight: number;
|
|
1487
|
+
/** Teleport arc colour when it lands somewhere valid. */
|
|
1488
|
+
teleportArcColor: string;
|
|
1489
|
+
/** Teleport arc colour when it lands nowhere teleportable. */
|
|
1490
|
+
teleportArcInvalidColor: string;
|
|
1491
|
+
/** Teleport arc thickness (diameter), metres. */
|
|
1492
|
+
teleportArcThickness: number;
|
|
1481
1493
|
constructor(options?: XRRigOptions);
|
|
1482
1494
|
}
|
|
1483
1495
|
|
|
@@ -1595,6 +1607,15 @@ type XrHandPoseEntry = {
|
|
|
1595
1607
|
curls: Record<XrFinger, number>;
|
|
1596
1608
|
/** Slack around each curl target. Larger is easier to perform. */
|
|
1597
1609
|
tolerance: number;
|
|
1610
|
+
/**
|
|
1611
|
+
* Directions each finger may point. Empty means the finger may point anywhere.
|
|
1612
|
+
*
|
|
1613
|
+
* Any ONE listed direction satisfies the finger, mirroring fingerpose's
|
|
1614
|
+
* `addDirection` — "thumb up OR diagonally up" is one pose, not two.
|
|
1615
|
+
*/
|
|
1616
|
+
directions: Record<XrFinger, XrHandPoseDirection[]>;
|
|
1617
|
+
/** How far a finger may point from an accepted direction, in degrees. */
|
|
1618
|
+
directionTolerance: number;
|
|
1598
1619
|
/** Which hand may trigger it; null for either. */
|
|
1599
1620
|
hand: "left" | "right" | null;
|
|
1600
1621
|
/** Optional direction requirement. */
|
|
@@ -1608,6 +1629,7 @@ type XRHandPoseOptions = {
|
|
|
1608
1629
|
poses?: XrHandPoseEntry[];
|
|
1609
1630
|
};
|
|
1610
1631
|
declare const DEFAULT_POSE_CURLS: Record<XrFinger, number>;
|
|
1632
|
+
declare const DEFAULT_POSE_DIRECTIONS: Record<XrFinger, XrHandPoseDirection[]>;
|
|
1611
1633
|
/** A pose entry with every field populated, for the editor and AI tools. */
|
|
1612
1634
|
declare function createHandPoseEntry(partial: Partial<XrHandPoseEntry> & {
|
|
1613
1635
|
id: string;
|
|
@@ -1635,4 +1657,4 @@ declare class XRHandPoseComponent extends Component {
|
|
|
1635
1657
|
constructor(options?: XRHandPoseOptions);
|
|
1636
1658
|
}
|
|
1637
1659
|
|
|
1638
|
-
export {
|
|
1660
|
+
export { Selectable as $, AnimationComponent as A, type MaterialValueState as B, CameraComponent as C, DEFAULT_COLLIDER_STATE as D, type EditableMeshObjectKind as E, MeshComponent as F, MeshGeometryComponent as G, type MeshGeometryParameters as H, ImageComponent as I, type MeshGeometryParametersByKind as J, ModelComponent as K, LightComponent as L, MaterialComponent as M, Name as N, Object3DRef as O, PhysicsComponent as P, type PhysicsState as Q, type PlaneMeshParameters as R, type RadiusHeightMeshParameters as S, type RadiusMeshParameters as T, type RigidbodyState as U, type RigidbodyType as V, ScriptComponent as W, type ScriptEntry as X, ScriptObjectComponent as Y, type ScriptObjectComponentInput as Z, type ScriptObjectRuntimeState as _, type AnimationComponentOptions as a, SelectionTransformState as a0, SpriteComponent as a1, type TextureFilteringValue as a2, type TransformModeValue as a3, type TransformSpaceValue as a4, VRTeleportAreaComponent as a5, type VRTeleportAreaOptions as a6, VideoComponent as a7, type VrTeleportShape as a8, XRHandPoseComponent as a9, type AnimationStateCallbacks as aA, AnimationStateMachine as aB, AnimationStateManager as aC, type StateMachine as aD, type XRHandPoseOptions as aa, XRInteractableComponent as ab, type XRInteractableOptions as ac, XRInteractorComponent as ad, type XRInteractorOptions as ae, XRInteractorSideComponent as af, XRRigComponent as ag, type XRRigOptions as ah, type XrAttachPoint as ai, type XrDistanceGrabBehavior as aj, type XrGrabGesture as ak, type XrGrabHands as al, type XrGrabReach as am, type XrHandPoseEntry as an, type XrHandPreset as ao, type XrInteractorSide as ap, type XrInteractorType as aq, type XrLocomotionMode as ar, type XrTrackingOrigin as as, type XrTwoHandRotation as at, createAttachPoint as au, createHandPoseEntry as av, defaultMaterialValue as aw, handPoseDefinitionFor as ax, normalizePhysicsState as ay, setPhysicsLiveRef as az, AudioComponent as b, type CameraComponentOptions as c, type CameraProjection as d, type CameraRuntimeType as e, type ColliderShape as f, type ColliderState as g, type CubeMeshParameters as h, DEFAULT_INSTANCED_MESH_PARAMETERS as i, DEFAULT_INSTANCE_TRANSFORM as j, DEFAULT_MESH_GEOMETRY_PARAMETERS as k, DEFAULT_PHYSICS_STATE as l, DEFAULT_POSE_CURLS as m, DEFAULT_POSE_DIRECTIONS as n, DEFAULT_RIGIDBODY_STATE as o, EntityType as p, ImageTarget as q, ImageTargetAnchor as r, type ImageTargetAnchorOptions as s, type ImageTargetReference as t, InstanceSlotComponent as u, type InstanceTransform as v, InstancedMeshComponent as w, type InstancedMeshKind as x, type LightValueState as y, type MaterialTypeValue as z };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
2
|
import { C as Component, p as EcsEntityKind, F as EcsEntityEditorKind, r as EntityId } from './System-BhnLw0fZ.js';
|
|
3
3
|
import * as RAPIER from '@dimforge/rapier3d-compat';
|
|
4
|
-
import { a as XrFinger, b as XrHandPoseOrientation, X as XrHandPoseDefinition } from './handPose-
|
|
4
|
+
import { a as XrFinger, c as XrHandPoseDirection, b as XrHandPoseOrientation, X as XrHandPoseDefinition } from './handPose-DlcTtqgx.js';
|
|
5
5
|
|
|
6
6
|
interface StateMachine {
|
|
7
7
|
name: string;
|
|
@@ -1450,6 +1450,12 @@ type XRRigOptions = {
|
|
|
1450
1450
|
snapTurnDegrees?: number;
|
|
1451
1451
|
/** Height in metres used when the device reports no floor-relative space. */
|
|
1452
1452
|
fallbackEyeHeight?: number;
|
|
1453
|
+
/** Teleport arc colour when it lands somewhere valid. */
|
|
1454
|
+
teleportArcColor?: string;
|
|
1455
|
+
/** Teleport arc colour when it lands nowhere teleportable. */
|
|
1456
|
+
teleportArcInvalidColor?: string;
|
|
1457
|
+
/** Teleport arc thickness (diameter), metres. */
|
|
1458
|
+
teleportArcThickness?: number;
|
|
1453
1459
|
};
|
|
1454
1460
|
/**
|
|
1455
1461
|
* Marks an entity as the XR rig — the player's movable origin.
|
|
@@ -1478,6 +1484,12 @@ declare class XRRigComponent extends Component {
|
|
|
1478
1484
|
snapTurnDegrees: number;
|
|
1479
1485
|
/** Eye height fallback for devices without a floor-relative reference space. */
|
|
1480
1486
|
fallbackEyeHeight: number;
|
|
1487
|
+
/** Teleport arc colour when it lands somewhere valid. */
|
|
1488
|
+
teleportArcColor: string;
|
|
1489
|
+
/** Teleport arc colour when it lands nowhere teleportable. */
|
|
1490
|
+
teleportArcInvalidColor: string;
|
|
1491
|
+
/** Teleport arc thickness (diameter), metres. */
|
|
1492
|
+
teleportArcThickness: number;
|
|
1481
1493
|
constructor(options?: XRRigOptions);
|
|
1482
1494
|
}
|
|
1483
1495
|
|
|
@@ -1595,6 +1607,15 @@ type XrHandPoseEntry = {
|
|
|
1595
1607
|
curls: Record<XrFinger, number>;
|
|
1596
1608
|
/** Slack around each curl target. Larger is easier to perform. */
|
|
1597
1609
|
tolerance: number;
|
|
1610
|
+
/**
|
|
1611
|
+
* Directions each finger may point. Empty means the finger may point anywhere.
|
|
1612
|
+
*
|
|
1613
|
+
* Any ONE listed direction satisfies the finger, mirroring fingerpose's
|
|
1614
|
+
* `addDirection` — "thumb up OR diagonally up" is one pose, not two.
|
|
1615
|
+
*/
|
|
1616
|
+
directions: Record<XrFinger, XrHandPoseDirection[]>;
|
|
1617
|
+
/** How far a finger may point from an accepted direction, in degrees. */
|
|
1618
|
+
directionTolerance: number;
|
|
1598
1619
|
/** Which hand may trigger it; null for either. */
|
|
1599
1620
|
hand: "left" | "right" | null;
|
|
1600
1621
|
/** Optional direction requirement. */
|
|
@@ -1608,6 +1629,7 @@ type XRHandPoseOptions = {
|
|
|
1608
1629
|
poses?: XrHandPoseEntry[];
|
|
1609
1630
|
};
|
|
1610
1631
|
declare const DEFAULT_POSE_CURLS: Record<XrFinger, number>;
|
|
1632
|
+
declare const DEFAULT_POSE_DIRECTIONS: Record<XrFinger, XrHandPoseDirection[]>;
|
|
1611
1633
|
/** A pose entry with every field populated, for the editor and AI tools. */
|
|
1612
1634
|
declare function createHandPoseEntry(partial: Partial<XrHandPoseEntry> & {
|
|
1613
1635
|
id: string;
|
|
@@ -1635,4 +1657,4 @@ declare class XRHandPoseComponent extends Component {
|
|
|
1635
1657
|
constructor(options?: XRHandPoseOptions);
|
|
1636
1658
|
}
|
|
1637
1659
|
|
|
1638
|
-
export {
|
|
1660
|
+
export { Selectable as $, AnimationComponent as A, type MaterialValueState as B, CameraComponent as C, DEFAULT_COLLIDER_STATE as D, type EditableMeshObjectKind as E, MeshComponent as F, MeshGeometryComponent as G, type MeshGeometryParameters as H, ImageComponent as I, type MeshGeometryParametersByKind as J, ModelComponent as K, LightComponent as L, MaterialComponent as M, Name as N, Object3DRef as O, PhysicsComponent as P, type PhysicsState as Q, type PlaneMeshParameters as R, type RadiusHeightMeshParameters as S, type RadiusMeshParameters as T, type RigidbodyState as U, type RigidbodyType as V, ScriptComponent as W, type ScriptEntry as X, ScriptObjectComponent as Y, type ScriptObjectComponentInput as Z, type ScriptObjectRuntimeState as _, type AnimationComponentOptions as a, SelectionTransformState as a0, SpriteComponent as a1, type TextureFilteringValue as a2, type TransformModeValue as a3, type TransformSpaceValue as a4, VRTeleportAreaComponent as a5, type VRTeleportAreaOptions as a6, VideoComponent as a7, type VrTeleportShape as a8, XRHandPoseComponent as a9, type AnimationStateCallbacks as aA, AnimationStateMachine as aB, AnimationStateManager as aC, type StateMachine as aD, type XRHandPoseOptions as aa, XRInteractableComponent as ab, type XRInteractableOptions as ac, XRInteractorComponent as ad, type XRInteractorOptions as ae, XRInteractorSideComponent as af, XRRigComponent as ag, type XRRigOptions as ah, type XrAttachPoint as ai, type XrDistanceGrabBehavior as aj, type XrGrabGesture as ak, type XrGrabHands as al, type XrGrabReach as am, type XrHandPoseEntry as an, type XrHandPreset as ao, type XrInteractorSide as ap, type XrInteractorType as aq, type XrLocomotionMode as ar, type XrTrackingOrigin as as, type XrTwoHandRotation as at, createAttachPoint as au, createHandPoseEntry as av, defaultMaterialValue as aw, handPoseDefinitionFor as ax, normalizePhysicsState as ay, setPhysicsLiveRef as az, AudioComponent as b, type CameraComponentOptions as c, type CameraProjection as d, type CameraRuntimeType as e, type ColliderShape as f, type ColliderState as g, type CubeMeshParameters as h, DEFAULT_INSTANCED_MESH_PARAMETERS as i, DEFAULT_INSTANCE_TRANSFORM as j, DEFAULT_MESH_GEOMETRY_PARAMETERS as k, DEFAULT_PHYSICS_STATE as l, DEFAULT_POSE_CURLS as m, DEFAULT_POSE_DIRECTIONS as n, DEFAULT_RIGIDBODY_STATE as o, EntityType as p, ImageTarget as q, ImageTargetAnchor as r, type ImageTargetAnchorOptions as s, type ImageTargetReference as t, InstanceSlotComponent as u, type InstanceTransform as v, InstancedMeshComponent as w, type InstancedMeshKind as x, type LightValueState as y, type MaterialTypeValue as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TransformComponent, Object3DRef, ParentId } from './chunk-
|
|
1
|
+
import { TransformComponent, Object3DRef, ParentId } from './chunk-H6DQ7JRE.js';
|
|
2
2
|
import { __name } from './chunk-OY7ZODZP.js';
|
|
3
3
|
import * as THREE2 from 'three';
|
|
4
4
|
import { clone } from 'three/examples/jsm/utils/SkeletonUtils.js';
|
|
@@ -311,5 +311,5 @@ function resolveDracoDecoderPath() {
|
|
|
311
311
|
__name(resolveDracoDecoderPath, "resolveDracoDecoderPath");
|
|
312
312
|
|
|
313
313
|
export { ObjectManagementSystem, SHARED_MODEL_RESOURCE_FLAG, applyTransform, clearModelCache, cloneModelScene, createTransform, loadSharedGltf, resolveDracoDecoderPath, setDracoDecoderPath };
|
|
314
|
-
//# sourceMappingURL=chunk-
|
|
315
|
-
//# sourceMappingURL=chunk-
|
|
314
|
+
//# sourceMappingURL=chunk-D6KXWNYT.js.map
|
|
315
|
+
//# sourceMappingURL=chunk-D6KXWNYT.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../core/utils/modelCache.ts","../core/systems/ObjectMan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,CAAA,uBAAA,EAAA,yBAAA,CAAA;AAIF,SAAS,uBAAA,GAAkC;AAChD,EAAA,IAAI,wBAAA,EAA0B;AAC5B,IAAA,OAAO,wBAAA;AAAA,EACT;AAEA,EAAA,IAAI;AAEF,IAAA,MAAM,eAAe,IAAI,GAAA;AAAA,MACvB,iCAAA;AAAA,MACA,MAAA,CAAA,IAAA,CAAY;AAAA,MACZ,QAAA,EAAS;AAIX,IAAA,IAAI,uBAAA,CAAwB,YAAY,CAAA,EAAG;AACzC,MAAA,OAAO,sBAAA;AAAA,IACT;AAEA,IAAA,OAAO,YAAA;AAAA,EACT,CAAA,CAAA,MAAQ;AAEN,IAAA,OAAO,sBAAA;AAAA,EACT;AACF;AAvBgB,MAAA,CAAA,uBAAA,EAAA,yBAAA,CAAA","file":"chunk-PNQ7HDQC.js","sourcesContent":["import * as THREE from \"three\";\nimport type { GLTF } from \"three/examples/jsm/loaders/GLTFLoader.js\";\nimport { clone as cloneWithSkeleton } from \"three/examples/jsm/utils/SkeletonUtils.js\";\n\n/**\n * userData flag set on geometries/materials that back shared (cached) model\n * scenes. Entity disposal must skip these — other live clones and future\n * spawns reference the same GPU resources.\n */\nexport const SHARED_MODEL_RESOURCE_FLAG = \"spatialEcsSharedModelResource\";\n\nconst modelCache = new Map<string, Promise<GLTF>>();\n\nfunction markSharedResources(root: THREE.Object3D): void {\n root.traverse((child) => {\n if (!(child instanceof THREE.Mesh)) {\n return;\n }\n if (child.geometry) {\n child.geometry.userData[SHARED_MODEL_RESOURCE_FLAG] = true;\n }\n const materials = Array.isArray(child.material)\n ? child.material\n : [child.material];\n for (const material of materials) {\n if (material) {\n material.userData[SHARED_MODEL_RESOURCE_FLAG] = true;\n }\n }\n });\n}\n\n/**\n * Load a GLTF once per URL and share the parsed result, so repeated spawns of\n * the same model skip both the fetch and the parse. The cached scene must\n * never be mounted directly (an Object3D has a single parent) — mount a\n * cloneModelScene() of it. Failed loads are evicted so a retry re-fetches.\n */\nexport function loadSharedGltf(\n url: string,\n load: () => Promise<GLTF>,\n): Promise<GLTF> {\n let pending = modelCache.get(url);\n if (!pending) {\n pending = load().then((gltf) => {\n markSharedResources(gltf.scene);\n return gltf;\n });\n pending.catch(() => {\n modelCache.delete(url);\n });\n modelCache.set(url, pending);\n }\n return pending;\n}\n\n/**\n * Skeleton-aware clone of a cached model scene for mounting. Geometries and\n * materials are shared with the cached original (marked via\n * SHARED_MODEL_RESOURCE_FLAG); the object hierarchy — including rebound\n * skeletons for skinned meshes — is fresh per call.\n */\nexport function cloneModelScene(scene: THREE.Object3D): THREE.Object3D {\n return cloneWithSkeleton(scene);\n}\n\n/**\n * Forget cached models (one URL, or everything). Subsequent loads fetch and\n * parse anew. Does not dispose GPU resources — live clones may still use them.\n */\nexport function clearModelCache(url?: string): void {\n if (typeof url === \"string\") {\n modelCache.delete(url);\n return;\n }\n modelCache.clear();\n}\n","import * as THREE from \"three\";\n\nimport { Object3DRef } from \"../components/Object3DRef\";\nimport { ParentId } from \"../components/ParentId\";\nimport type { TransformData } from \"../components/Transform\";\nimport { TransformComponent } from \"../components/Transform\";\nimport type { EcsSystem } from \"../System\";\nimport { SHARED_MODEL_RESOURCE_FLAG } from \"../utils/modelCache\";\nimport type { World } from \"../World\";\nimport type { EntityId, EcsEntityKind } from \"../types\";\n\nexport type CreatePayload = {\n name?: string;\n transform?: TransformData;\n parentId?: EntityId | null;\n path?: string;\n options?: Record<string, unknown>;\n camera?: Record<string, unknown>;\n useWorldCamera?: boolean;\n /**\n * Suppress the default child entities a factory would otherwise create.\n *\n * Set during hydration: the snapshot already contains those children, so\n * letting the factory add its own too duplicates them on every load.\n */\n skipDefaultChildren?: boolean;\n};\n\nexport type CreateContext = {\n world: World;\n scene: THREE.Scene;\n camera: THREE.PerspectiveCamera;\n payload: CreatePayload;\n isEditor?: boolean;\n};\n\nexport type EntityFactory = (context: CreateContext) => EntityId;\n\nexport type EcsComponentFactoryKind =\n | \"animation\"\n | \"audio\"\n | \"camera\"\n | \"environment\"\n | \"entityType\"\n | \"image\"\n | \"imageTargetAnchor\"\n | \"imageTarget\"\n | \"light\"\n | \"material\"\n | \"mesh\"\n | \"meshGeometry\"\n | \"model\"\n | \"name\"\n | \"object3DRef\"\n | \"parentId\"\n | \"physics\"\n | \"postprocessing\"\n | \"script\"\n | \"scriptObject\"\n | \"selectable\"\n | \"selectionTransformState\"\n | \"sprite\"\n | \"transform\"\n | \"video\"\n | \"instancedMesh\"\n | \"xrRig\"\n | \"vrTeleportArea\"\n | \"xrHandPose\"\n | \"xrInteractable\"\n | \"xrInteractor\"\n | \"xrInteractorSide\";\n\nexport type ComponentFactory = (\n world: World,\n entityId: EntityId,\n ...args: any[]\n) => unknown;\n\ntype CreateRequest = {\n kind: EcsEntityKind;\n payload: CreatePayload;\n onCreated?: (entityId: EntityId) => void;\n};\n\nexport function createTransform(input?: TransformData): TransformComponent {\n return new TransformComponent(input);\n}\n\nexport function applyTransform(\n object: THREE.Object3D,\n transform: TransformComponent,\n): void {\n object.position.set(\n transform.position.x,\n transform.position.y,\n transform.position.z,\n );\n object.rotation.set(\n transform.rotation.x,\n transform.rotation.y,\n transform.rotation.z,\n );\n object.scale.set(transform.scale.x, transform.scale.y, transform.scale.z);\n}\n\nexport class ObjectManagementSystem implements EcsSystem {\n private readonly scene: THREE.Scene;\n private readonly camera: THREE.PerspectiveCamera;\n private readonly isEditor: boolean;\n private readonly registry = new Map<EcsEntityKind, EntityFactory>();\n private readonly componentRegistry = new Map<\n EcsComponentFactoryKind,\n ComponentFactory\n >();\n private readonly createQueue: CreateRequest[] = [];\n\n constructor(\n scene: THREE.Scene,\n camera: THREE.PerspectiveCamera,\n isEditor = false,\n ) {\n this.scene = scene;\n this.camera = camera;\n this.isEditor = isEditor;\n }\n\n register(kind: EcsEntityKind, factory: EntityFactory): void {\n this.registry.set(kind, factory);\n }\n\n registerComponentFactory(\n kind: EcsComponentFactoryKind,\n factory: ComponentFactory,\n ): void {\n this.componentRegistry.set(kind, factory);\n }\n\n getOrCreateAudioListener(): THREE.AudioListener {\n const existing = this.camera.userData.ecsAudioListener;\n if (existing instanceof THREE.AudioListener) {\n return existing;\n }\n\n const listener = new THREE.AudioListener();\n this.camera.add(listener);\n this.camera.userData.ecsAudioListener = listener;\n return listener;\n }\n\n isEditorMode(): boolean {\n return this.isEditor;\n }\n\n getComponentFactory(kind: EcsComponentFactoryKind): ComponentFactory | null {\n return this.componentRegistry.get(kind) ?? null;\n }\n\n createComponentNow(\n kind: EcsComponentFactoryKind,\n world: World,\n entityId: EntityId,\n ...args: any[]\n ): unknown {\n const factory = this.componentRegistry.get(kind);\n if (!factory) {\n throw new Error(`Unknown component kind: ${kind}`);\n }\n\n return factory(world, entityId, ...args);\n }\n\n requestCreate(\n kind: EcsEntityKind,\n payload: CreatePayload = {},\n onCreated?: (entityId: EntityId) => void,\n ): void {\n this.createQueue.push({ kind, payload, onCreated });\n }\n\n createNow(\n kind: EcsEntityKind,\n world: World,\n payload: CreatePayload = {},\n ): EntityId {\n const factory = this.registry.get(kind);\n if (!factory) {\n throw new Error(`Unknown object kind: ${kind}`);\n }\n\n const entityId = factory({\n world,\n scene: this.scene,\n camera: this.camera,\n payload,\n isEditor: this.isEditor,\n });\n\n const object = world.getComponent(entityId, Object3DRef)?.object;\n if (object) {\n object.userData.ecsKind = kind;\n }\n\n if (payload.parentId !== undefined) {\n world.addComponent(entityId, new ParentId(payload.parentId));\n }\n\n return entityId;\n }\n\n /**\n * Removes an entity from the ECS world and its associated `Object3D` from the\n * THREE.js scene graph.\n *\n * @param world - The world the entity belongs to.\n * @param entityId - The entity to remove.\n * @param dispose - When `true`, traverses the entity's `Object3D` subtree and\n * calls `.dispose()` on every `BufferGeometry` and `Material` found. Pass\n * `true` when the entity will not be reused and you want to free GPU memory\n * immediately (e.g. dynamically spawned objects). Defaults to `false`.\n * @returns `true` if the entity existed and was removed; `false` if the entity\n * was not found.\n *\n * @example\n * ```ts\n * // Remove from scene, keep GPU resources (safe if geometry is shared)\n * objects.deleteEntity(world, entityId);\n *\n * // Remove from scene and free GPU memory (use for one-off spawned objects)\n * objects.deleteEntity(world, entityId, true);\n * ```\n */\n deleteEntity(world: World, entityId: EntityId, dispose = false): boolean {\n if (!world.hasEntity(entityId)) {\n return false;\n }\n\n const object3d = world.getComponent(entityId, Object3DRef)?.object;\n if (object3d?.parent) {\n object3d.parent.remove(object3d);\n }\n\n if (dispose && object3d) {\n object3d.traverse((child) => {\n if (child instanceof THREE.Mesh) {\n // Resources backing shared (cached) model scenes are skipped —\n // other live clones and future spawns reference the same objects.\n if (!child.geometry?.userData?.[SHARED_MODEL_RESOURCE_FLAG]) {\n child.geometry?.dispose();\n }\n const materials = Array.isArray(child.material)\n ? child.material\n : [child.material];\n for (const mat of materials) {\n if (mat && !mat.userData?.[SHARED_MODEL_RESOURCE_FLAG]) {\n mat.dispose();\n }\n }\n }\n });\n }\n\n world.destroyEntity(entityId);\n return true;\n }\n\n setParent(\n world: World,\n entityId: EntityId,\n parentId: EntityId | null,\n options?: {\n preserveWorldTransform?: boolean;\n },\n ): boolean {\n if (!world.hasEntity(entityId)) {\n return false;\n }\n\n if (parentId !== null && !world.hasEntity(parentId)) {\n return false;\n }\n\n if (parentId === entityId) {\n return false;\n }\n\n let ancestor = parentId;\n while (ancestor !== null) {\n if (ancestor === entityId) {\n return false;\n }\n\n ancestor = world.getComponent(ancestor, ParentId)?.value ?? null;\n }\n\n const parentComponent = world.getComponent(entityId, ParentId);\n if (parentComponent) {\n if (parentComponent.value === parentId) {\n return false;\n }\n\n parentComponent.value = parentId;\n } else {\n world.addComponent(entityId, new ParentId(parentId));\n }\n\n const preserveWorldTransform = options?.preserveWorldTransform ?? true;\n if (preserveWorldTransform) {\n const object = world.getComponent(entityId, Object3DRef)?.object;\n const parentObject =\n parentId !== null\n ? world.getComponent(parentId, Object3DRef)?.object ?? null\n : null;\n\n if (object) {\n // Refresh matrixWorld before attach so world-space preservation is accurate.\n this.scene.updateMatrixWorld(true);\n\n if (parentObject && parentObject !== object) {\n parentObject.attach(object);\n } else {\n this.scene.attach(object);\n }\n\n object.updateMatrixWorld(true);\n this.syncTransformComponentFromObject(world, entityId, object);\n }\n }\n\n this.reconcileSceneFromWorld(world);\n return true;\n }\n\n private syncTransformComponentFromObject(\n world: World,\n entityId: EntityId,\n object: THREE.Object3D,\n ): void {\n const transform = world.getComponent(entityId, TransformComponent);\n if (!transform) {\n return;\n }\n\n transform.position.x = object.position.x;\n transform.position.y = object.position.y;\n transform.position.z = object.position.z;\n\n transform.rotation.x = object.rotation.x;\n transform.rotation.y = object.rotation.y;\n transform.rotation.z = object.rotation.z;\n\n transform.scale.x = object.scale.x;\n transform.scale.y = object.scale.y;\n transform.scale.z = object.scale.z;\n }\n\n reconcileSceneFromWorld(world: World): void {\n const worldObjects = new Map<EntityId, THREE.Object3D>();\n const entityIds = world.query(Object3DRef);\n\n for (const entityId of entityIds) {\n const object = world.getComponent(entityId, Object3DRef)?.object;\n if (!object) {\n continue;\n }\n\n worldObjects.set(entityId, object);\n }\n\n for (const child of [...this.scene.children]) {\n const entityId = child.userData?.entityId;\n if (typeof entityId === \"number\" && !world.hasEntity(entityId)) {\n this.scene.remove(child);\n }\n }\n\n for (const [entityId, object] of worldObjects.entries()) {\n const parentEntityId = world.getComponent(entityId, ParentId)?.value;\n const parentObject =\n typeof parentEntityId === \"number\"\n ? worldObjects.get(parentEntityId)\n : undefined;\n\n if (parentObject && parentObject !== object) {\n if (object.parent !== parentObject) {\n // Reconcile hierarchy from ParentId while keeping Transform as local source of truth.\n parentObject.add(object);\n object.updateMatrixWorld(true);\n }\n continue;\n }\n\n if (object.parent !== this.scene) {\n // Reconcile hierarchy from ParentId while keeping Transform as local source of truth.\n this.scene.add(object);\n object.updateMatrixWorld(true);\n }\n }\n }\n\n update(world: World): void {\n for (const request of this.createQueue.splice(0)) {\n const entityId = this.createNow(request.kind, world, request.payload);\n request.onCreated?.(entityId);\n }\n\n this.reconcileSceneFromWorld(world);\n }\n}\n","const LOCAL_DRACO_DECODER_RELATIVE_PATH = \"./assets/draco/\";\nexport const DRACO_DECODER_CDN_PATH =\n \"https://www.gstatic.com/draco/versioned/decoders/1.5.7/\";\n\nlet dracoDecoderPathOverride: string | null = null;\n\n/**\n * Override where the DRACO decoder files (draco_wasm_wrapper.js,\n * draco_decoder.wasm, draco_decoder.js) are fetched from. Embedding apps\n * whose bundlers relocate this package's chunks — making the default\n * import.meta.url resolution point at a location that is never populated —\n * should call this before any model loads. The path must end with \"/\".\n * Pass null to restore the default resolution.\n */\nexport function setDracoDecoderPath(path: string | null): void {\n dracoDecoderPathOverride = path;\n}\n\nfunction isBlockedBrowserFileUrl(url: string): boolean {\n return url.startsWith(\"file://\");\n}\n\nexport function resolveDracoDecoderPath(): string {\n if (dracoDecoderPathOverride) {\n return dracoDecoderPathOverride;\n }\n\n try {\n // Prefer vendored decoder assets shipped with this package.\n const resolvedPath = new URL(\n LOCAL_DRACO_DECODER_RELATIVE_PATH,\n import.meta.url,\n ).toString();\n\n // Browser loaders cannot fetch file:// resources from package install paths.\n // Fall back to CDN decoders when bundlers emit file URLs for node_modules assets.\n if (isBlockedBrowserFileUrl(resolvedPath)) {\n return DRACO_DECODER_CDN_PATH;\n }\n\n return resolvedPath;\n } catch {\n // Fallback keeps compatibility in runtimes that cannot resolve package-relative URLs.\n return DRACO_DECODER_CDN_PATH;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../core/utils/modelCache.ts","../core/systems/ObjectManagementSystem.ts","../core/utils/dracoDecoderPath.ts"],"names":["THREE","cloneWithSkeleton"],"mappings":";;;;;AASO,IAAM,0BAAA,GAA6B;AAE1C,IAAM,UAAA,uBAAiB,GAAA,EAA2B;AAElD,SAAS,oBAAoB,IAAA,EAA4B;AACvD,EAAA,IAAA,CAAK,QAAA,CAAS,CAAC,KAAA,KAAU;AACvB,IAAA,IAAI,EAAE,iBAAuBA,MAAA,CAAA,IAAA,CAAA,EAAO;AAClC,MAAA;AAAA,IACF;AACA,IAAA,IAAI,MAAM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AAA;AAAA,IACT;AAEA,IAAA,OAAO,YAAA;AAAA,EACT,CAAA,CAAA,MAAQ;AAEN,IAAA,OAAO,sBAAA;AAAA,EACT;AACF;AAvBgB,MAAA,CAAA,uBAAA,EAAA,yBAAA,CAAA","file":"chunk-D6KXWNYT.js","sourcesContent":["import * as THREE from \"three\";\nimport type { GLTF } from \"three/examples/jsm/loaders/GLTFLoader.js\";\nimport { clone as cloneWithSkeleton } from \"three/examples/jsm/utils/SkeletonUtils.js\";\n\n/**\n * userData flag set on geometries/materials that back shared (cached) model\n * scenes. Entity disposal must skip these — other live clones and future\n * spawns reference the same GPU resources.\n */\nexport const SHARED_MODEL_RESOURCE_FLAG = \"spatialEcsSharedModelResource\";\n\nconst modelCache = new Map<string, Promise<GLTF>>();\n\nfunction markSharedResources(root: THREE.Object3D): void {\n root.traverse((child) => {\n if (!(child instanceof THREE.Mesh)) {\n return;\n }\n if (child.geometry) {\n child.geometry.userData[SHARED_MODEL_RESOURCE_FLAG] = true;\n }\n const materials = Array.isArray(child.material)\n ? child.material\n : [child.material];\n for (const material of materials) {\n if (material) {\n material.userData[SHARED_MODEL_RESOURCE_FLAG] = true;\n }\n }\n });\n}\n\n/**\n * Load a GLTF once per URL and share the parsed result, so repeated spawns of\n * the same model skip both the fetch and the parse. The cached scene must\n * never be mounted directly (an Object3D has a single parent) — mount a\n * cloneModelScene() of it. Failed loads are evicted so a retry re-fetches.\n */\nexport function loadSharedGltf(\n url: string,\n load: () => Promise<GLTF>,\n): Promise<GLTF> {\n let pending = modelCache.get(url);\n if (!pending) {\n pending = load().then((gltf) => {\n markSharedResources(gltf.scene);\n return gltf;\n });\n pending.catch(() => {\n modelCache.delete(url);\n });\n modelCache.set(url, pending);\n }\n return pending;\n}\n\n/**\n * Skeleton-aware clone of a cached model scene for mounting. Geometries and\n * materials are shared with the cached original (marked via\n * SHARED_MODEL_RESOURCE_FLAG); the object hierarchy — including rebound\n * skeletons for skinned meshes — is fresh per call.\n */\nexport function cloneModelScene(scene: THREE.Object3D): THREE.Object3D {\n return cloneWithSkeleton(scene);\n}\n\n/**\n * Forget cached models (one URL, or everything). Subsequent loads fetch and\n * parse anew. Does not dispose GPU resources — live clones may still use them.\n */\nexport function clearModelCache(url?: string): void {\n if (typeof url === \"string\") {\n modelCache.delete(url);\n return;\n }\n modelCache.clear();\n}\n","import * as THREE from \"three\";\n\nimport { Object3DRef } from \"../components/Object3DRef\";\nimport { ParentId } from \"../components/ParentId\";\nimport type { TransformData } from \"../components/Transform\";\nimport { TransformComponent } from \"../components/Transform\";\nimport type { EcsSystem } from \"../System\";\nimport { SHARED_MODEL_RESOURCE_FLAG } from \"../utils/modelCache\";\nimport type { World } from \"../World\";\nimport type { EntityId, EcsEntityKind } from \"../types\";\n\nexport type CreatePayload = {\n name?: string;\n transform?: TransformData;\n parentId?: EntityId | null;\n path?: string;\n options?: Record<string, unknown>;\n camera?: Record<string, unknown>;\n useWorldCamera?: boolean;\n /**\n * Suppress the default child entities a factory would otherwise create.\n *\n * Set during hydration: the snapshot already contains those children, so\n * letting the factory add its own too duplicates them on every load.\n */\n skipDefaultChildren?: boolean;\n};\n\nexport type CreateContext = {\n world: World;\n scene: THREE.Scene;\n camera: THREE.PerspectiveCamera;\n payload: CreatePayload;\n isEditor?: boolean;\n};\n\nexport type EntityFactory = (context: CreateContext) => EntityId;\n\nexport type EcsComponentFactoryKind =\n | \"animation\"\n | \"audio\"\n | \"camera\"\n | \"environment\"\n | \"entityType\"\n | \"image\"\n | \"imageTargetAnchor\"\n | \"imageTarget\"\n | \"light\"\n | \"material\"\n | \"mesh\"\n | \"meshGeometry\"\n | \"model\"\n | \"name\"\n | \"object3DRef\"\n | \"parentId\"\n | \"physics\"\n | \"postprocessing\"\n | \"script\"\n | \"scriptObject\"\n | \"selectable\"\n | \"selectionTransformState\"\n | \"sprite\"\n | \"transform\"\n | \"video\"\n | \"instancedMesh\"\n | \"xrRig\"\n | \"vrTeleportArea\"\n | \"xrHandPose\"\n | \"xrInteractable\"\n | \"xrInteractor\"\n | \"xrInteractorSide\";\n\nexport type ComponentFactory = (\n world: World,\n entityId: EntityId,\n ...args: any[]\n) => unknown;\n\ntype CreateRequest = {\n kind: EcsEntityKind;\n payload: CreatePayload;\n onCreated?: (entityId: EntityId) => void;\n};\n\nexport function createTransform(input?: TransformData): TransformComponent {\n return new TransformComponent(input);\n}\n\nexport function applyTransform(\n object: THREE.Object3D,\n transform: TransformComponent,\n): void {\n object.position.set(\n transform.position.x,\n transform.position.y,\n transform.position.z,\n );\n object.rotation.set(\n transform.rotation.x,\n transform.rotation.y,\n transform.rotation.z,\n );\n object.scale.set(transform.scale.x, transform.scale.y, transform.scale.z);\n}\n\nexport class ObjectManagementSystem implements EcsSystem {\n private readonly scene: THREE.Scene;\n private readonly camera: THREE.PerspectiveCamera;\n private readonly isEditor: boolean;\n private readonly registry = new Map<EcsEntityKind, EntityFactory>();\n private readonly componentRegistry = new Map<\n EcsComponentFactoryKind,\n ComponentFactory\n >();\n private readonly createQueue: CreateRequest[] = [];\n\n constructor(\n scene: THREE.Scene,\n camera: THREE.PerspectiveCamera,\n isEditor = false,\n ) {\n this.scene = scene;\n this.camera = camera;\n this.isEditor = isEditor;\n }\n\n register(kind: EcsEntityKind, factory: EntityFactory): void {\n this.registry.set(kind, factory);\n }\n\n registerComponentFactory(\n kind: EcsComponentFactoryKind,\n factory: ComponentFactory,\n ): void {\n this.componentRegistry.set(kind, factory);\n }\n\n getOrCreateAudioListener(): THREE.AudioListener {\n const existing = this.camera.userData.ecsAudioListener;\n if (existing instanceof THREE.AudioListener) {\n return existing;\n }\n\n const listener = new THREE.AudioListener();\n this.camera.add(listener);\n this.camera.userData.ecsAudioListener = listener;\n return listener;\n }\n\n isEditorMode(): boolean {\n return this.isEditor;\n }\n\n getComponentFactory(kind: EcsComponentFactoryKind): ComponentFactory | null {\n return this.componentRegistry.get(kind) ?? null;\n }\n\n createComponentNow(\n kind: EcsComponentFactoryKind,\n world: World,\n entityId: EntityId,\n ...args: any[]\n ): unknown {\n const factory = this.componentRegistry.get(kind);\n if (!factory) {\n throw new Error(`Unknown component kind: ${kind}`);\n }\n\n return factory(world, entityId, ...args);\n }\n\n requestCreate(\n kind: EcsEntityKind,\n payload: CreatePayload = {},\n onCreated?: (entityId: EntityId) => void,\n ): void {\n this.createQueue.push({ kind, payload, onCreated });\n }\n\n createNow(\n kind: EcsEntityKind,\n world: World,\n payload: CreatePayload = {},\n ): EntityId {\n const factory = this.registry.get(kind);\n if (!factory) {\n throw new Error(`Unknown object kind: ${kind}`);\n }\n\n const entityId = factory({\n world,\n scene: this.scene,\n camera: this.camera,\n payload,\n isEditor: this.isEditor,\n });\n\n const object = world.getComponent(entityId, Object3DRef)?.object;\n if (object) {\n object.userData.ecsKind = kind;\n }\n\n if (payload.parentId !== undefined) {\n world.addComponent(entityId, new ParentId(payload.parentId));\n }\n\n return entityId;\n }\n\n /**\n * Removes an entity from the ECS world and its associated `Object3D` from the\n * THREE.js scene graph.\n *\n * @param world - The world the entity belongs to.\n * @param entityId - The entity to remove.\n * @param dispose - When `true`, traverses the entity's `Object3D` subtree and\n * calls `.dispose()` on every `BufferGeometry` and `Material` found. Pass\n * `true` when the entity will not be reused and you want to free GPU memory\n * immediately (e.g. dynamically spawned objects). Defaults to `false`.\n * @returns `true` if the entity existed and was removed; `false` if the entity\n * was not found.\n *\n * @example\n * ```ts\n * // Remove from scene, keep GPU resources (safe if geometry is shared)\n * objects.deleteEntity(world, entityId);\n *\n * // Remove from scene and free GPU memory (use for one-off spawned objects)\n * objects.deleteEntity(world, entityId, true);\n * ```\n */\n deleteEntity(world: World, entityId: EntityId, dispose = false): boolean {\n if (!world.hasEntity(entityId)) {\n return false;\n }\n\n const object3d = world.getComponent(entityId, Object3DRef)?.object;\n if (object3d?.parent) {\n object3d.parent.remove(object3d);\n }\n\n if (dispose && object3d) {\n object3d.traverse((child) => {\n if (child instanceof THREE.Mesh) {\n // Resources backing shared (cached) model scenes are skipped —\n // other live clones and future spawns reference the same objects.\n if (!child.geometry?.userData?.[SHARED_MODEL_RESOURCE_FLAG]) {\n child.geometry?.dispose();\n }\n const materials = Array.isArray(child.material)\n ? child.material\n : [child.material];\n for (const mat of materials) {\n if (mat && !mat.userData?.[SHARED_MODEL_RESOURCE_FLAG]) {\n mat.dispose();\n }\n }\n }\n });\n }\n\n world.destroyEntity(entityId);\n return true;\n }\n\n setParent(\n world: World,\n entityId: EntityId,\n parentId: EntityId | null,\n options?: {\n preserveWorldTransform?: boolean;\n },\n ): boolean {\n if (!world.hasEntity(entityId)) {\n return false;\n }\n\n if (parentId !== null && !world.hasEntity(parentId)) {\n return false;\n }\n\n if (parentId === entityId) {\n return false;\n }\n\n let ancestor = parentId;\n while (ancestor !== null) {\n if (ancestor === entityId) {\n return false;\n }\n\n ancestor = world.getComponent(ancestor, ParentId)?.value ?? null;\n }\n\n const parentComponent = world.getComponent(entityId, ParentId);\n if (parentComponent) {\n if (parentComponent.value === parentId) {\n return false;\n }\n\n parentComponent.value = parentId;\n } else {\n world.addComponent(entityId, new ParentId(parentId));\n }\n\n const preserveWorldTransform = options?.preserveWorldTransform ?? true;\n if (preserveWorldTransform) {\n const object = world.getComponent(entityId, Object3DRef)?.object;\n const parentObject =\n parentId !== null\n ? world.getComponent(parentId, Object3DRef)?.object ?? null\n : null;\n\n if (object) {\n // Refresh matrixWorld before attach so world-space preservation is accurate.\n this.scene.updateMatrixWorld(true);\n\n if (parentObject && parentObject !== object) {\n parentObject.attach(object);\n } else {\n this.scene.attach(object);\n }\n\n object.updateMatrixWorld(true);\n this.syncTransformComponentFromObject(world, entityId, object);\n }\n }\n\n this.reconcileSceneFromWorld(world);\n return true;\n }\n\n private syncTransformComponentFromObject(\n world: World,\n entityId: EntityId,\n object: THREE.Object3D,\n ): void {\n const transform = world.getComponent(entityId, TransformComponent);\n if (!transform) {\n return;\n }\n\n transform.position.x = object.position.x;\n transform.position.y = object.position.y;\n transform.position.z = object.position.z;\n\n transform.rotation.x = object.rotation.x;\n transform.rotation.y = object.rotation.y;\n transform.rotation.z = object.rotation.z;\n\n transform.scale.x = object.scale.x;\n transform.scale.y = object.scale.y;\n transform.scale.z = object.scale.z;\n }\n\n reconcileSceneFromWorld(world: World): void {\n const worldObjects = new Map<EntityId, THREE.Object3D>();\n const entityIds = world.query(Object3DRef);\n\n for (const entityId of entityIds) {\n const object = world.getComponent(entityId, Object3DRef)?.object;\n if (!object) {\n continue;\n }\n\n worldObjects.set(entityId, object);\n }\n\n for (const child of [...this.scene.children]) {\n const entityId = child.userData?.entityId;\n if (typeof entityId === \"number\" && !world.hasEntity(entityId)) {\n this.scene.remove(child);\n }\n }\n\n for (const [entityId, object] of worldObjects.entries()) {\n const parentEntityId = world.getComponent(entityId, ParentId)?.value;\n const parentObject =\n typeof parentEntityId === \"number\"\n ? worldObjects.get(parentEntityId)\n : undefined;\n\n if (parentObject && parentObject !== object) {\n if (object.parent !== parentObject) {\n // Reconcile hierarchy from ParentId while keeping Transform as local source of truth.\n parentObject.add(object);\n object.updateMatrixWorld(true);\n }\n continue;\n }\n\n if (object.parent !== this.scene) {\n // Reconcile hierarchy from ParentId while keeping Transform as local source of truth.\n this.scene.add(object);\n object.updateMatrixWorld(true);\n }\n }\n }\n\n update(world: World): void {\n for (const request of this.createQueue.splice(0)) {\n const entityId = this.createNow(request.kind, world, request.payload);\n request.onCreated?.(entityId);\n }\n\n this.reconcileSceneFromWorld(world);\n }\n}\n","const LOCAL_DRACO_DECODER_RELATIVE_PATH = \"./assets/draco/\";\nexport const DRACO_DECODER_CDN_PATH =\n \"https://www.gstatic.com/draco/versioned/decoders/1.5.7/\";\n\nlet dracoDecoderPathOverride: string | null = null;\n\n/**\n * Override where the DRACO decoder files (draco_wasm_wrapper.js,\n * draco_decoder.wasm, draco_decoder.js) are fetched from. Embedding apps\n * whose bundlers relocate this package's chunks — making the default\n * import.meta.url resolution point at a location that is never populated —\n * should call this before any model loads. The path must end with \"/\".\n * Pass null to restore the default resolution.\n */\nexport function setDracoDecoderPath(path: string | null): void {\n dracoDecoderPathOverride = path;\n}\n\nfunction isBlockedBrowserFileUrl(url: string): boolean {\n return url.startsWith(\"file://\");\n}\n\nexport function resolveDracoDecoderPath(): string {\n if (dracoDecoderPathOverride) {\n return dracoDecoderPathOverride;\n }\n\n try {\n // Prefer vendored decoder assets shipped with this package.\n const resolvedPath = new URL(\n LOCAL_DRACO_DECODER_RELATIVE_PATH,\n import.meta.url,\n ).toString();\n\n // Browser loaders cannot fetch file:// resources from package install paths.\n // Fall back to CDN decoders when bundlers emit file URLs for node_modules assets.\n if (isBlockedBrowserFileUrl(resolvedPath)) {\n return DRACO_DECODER_CDN_PATH;\n }\n\n return resolvedPath;\n } catch {\n // Fallback keeps compatibility in runtimes that cannot resolve package-relative URLs.\n return DRACO_DECODER_CDN_PATH;\n }\n}\n"]}
|
|
@@ -15,6 +15,7 @@ __export(components_exports, {
|
|
|
15
15
|
DEFAULT_MESH_GEOMETRY_PARAMETERS: () => DEFAULT_MESH_GEOMETRY_PARAMETERS,
|
|
16
16
|
DEFAULT_PHYSICS_STATE: () => DEFAULT_PHYSICS_STATE,
|
|
17
17
|
DEFAULT_POSE_CURLS: () => DEFAULT_POSE_CURLS,
|
|
18
|
+
DEFAULT_POSE_DIRECTIONS: () => DEFAULT_POSE_DIRECTIONS,
|
|
18
19
|
DEFAULT_POSTPROCESSING_STATE: () => DEFAULT_POSTPROCESSING_STATE,
|
|
19
20
|
DEFAULT_RIGIDBODY_STATE: () => DEFAULT_RIGIDBODY_STATE,
|
|
20
21
|
EntityType: () => EntityType,
|
|
@@ -1995,6 +1996,9 @@ var _XRRigComponent = class _XRRigComponent extends Component {
|
|
|
1995
1996
|
this.snapTurn = options?.snapTurn ?? true;
|
|
1996
1997
|
this.snapTurnDegrees = options?.snapTurnDegrees ?? 30;
|
|
1997
1998
|
this.fallbackEyeHeight = options?.fallbackEyeHeight ?? 1.6;
|
|
1999
|
+
this.teleportArcColor = options?.teleportArcColor ?? "#4da3ff";
|
|
2000
|
+
this.teleportArcInvalidColor = options?.teleportArcInvalidColor ?? "#ff5a5a";
|
|
2001
|
+
this.teleportArcThickness = options?.teleportArcThickness ?? 0.012;
|
|
1998
2002
|
}
|
|
1999
2003
|
};
|
|
2000
2004
|
__name(_XRRigComponent, "XRRigComponent");
|
|
@@ -2140,15 +2144,22 @@ function getHandPosePreset(id) {
|
|
|
2140
2144
|
return cloneHandPose(preset);
|
|
2141
2145
|
}
|
|
2142
2146
|
__name(getHandPosePreset, "getHandPosePreset");
|
|
2147
|
+
function cloneTarget(target) {
|
|
2148
|
+
return {
|
|
2149
|
+
...target,
|
|
2150
|
+
...target.directions ? { directions: [...target.directions] } : {}
|
|
2151
|
+
};
|
|
2152
|
+
}
|
|
2153
|
+
__name(cloneTarget, "cloneTarget");
|
|
2143
2154
|
function cloneHandPose(definition) {
|
|
2144
2155
|
return {
|
|
2145
2156
|
...definition,
|
|
2146
2157
|
fingers: {
|
|
2147
|
-
thumb:
|
|
2148
|
-
index:
|
|
2149
|
-
middle:
|
|
2150
|
-
ring:
|
|
2151
|
-
pinky:
|
|
2158
|
+
thumb: cloneTarget(definition.fingers.thumb),
|
|
2159
|
+
index: cloneTarget(definition.fingers.index),
|
|
2160
|
+
middle: cloneTarget(definition.fingers.middle),
|
|
2161
|
+
ring: cloneTarget(definition.fingers.ring),
|
|
2162
|
+
pinky: cloneTarget(definition.fingers.pinky)
|
|
2152
2163
|
},
|
|
2153
2164
|
pinch: definition.pinch ? { ...definition.pinch } : void 0,
|
|
2154
2165
|
orientation: definition.orientation ? { ...definition.orientation } : void 0
|
|
@@ -2157,22 +2168,27 @@ function cloneHandPose(definition) {
|
|
|
2157
2168
|
__name(cloneHandPose, "cloneHandPose");
|
|
2158
2169
|
function handPoseFromCurls(id, name, curls, options) {
|
|
2159
2170
|
const tolerance = options?.tolerance ?? NARROW;
|
|
2160
|
-
const target = /* @__PURE__ */ __name((curl) =>
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2171
|
+
const target = /* @__PURE__ */ __name((finger, curl) => {
|
|
2172
|
+
const directions = options?.directions?.[finger];
|
|
2173
|
+
return {
|
|
2174
|
+
curl: Math.min(1, Math.max(0, curl)),
|
|
2175
|
+
tolerance,
|
|
2176
|
+
...directions && directions.length > 0 ? { directions } : {}
|
|
2177
|
+
};
|
|
2178
|
+
}, "target");
|
|
2164
2179
|
return {
|
|
2165
2180
|
id,
|
|
2166
2181
|
name,
|
|
2167
2182
|
fingers: {
|
|
2168
|
-
thumb: target(curls.thumb),
|
|
2169
|
-
index: target(curls.index),
|
|
2170
|
-
middle: target(curls.middle),
|
|
2171
|
-
ring: target(curls.ring),
|
|
2172
|
-
pinky: target(curls.pinky)
|
|
2183
|
+
thumb: target("thumb", curls.thumb),
|
|
2184
|
+
index: target("index", curls.index),
|
|
2185
|
+
middle: target("middle", curls.middle),
|
|
2186
|
+
ring: target("ring", curls.ring),
|
|
2187
|
+
pinky: target("pinky", curls.pinky)
|
|
2173
2188
|
},
|
|
2174
2189
|
pinch: options?.pinch,
|
|
2175
2190
|
orientation: options?.orientation,
|
|
2191
|
+
directionToleranceDegrees: options?.directionToleranceDegrees,
|
|
2176
2192
|
hand: options?.hand
|
|
2177
2193
|
};
|
|
2178
2194
|
}
|
|
@@ -2186,6 +2202,13 @@ var DEFAULT_POSE_CURLS = {
|
|
|
2186
2202
|
ring: 0,
|
|
2187
2203
|
pinky: 0
|
|
2188
2204
|
};
|
|
2205
|
+
var DEFAULT_POSE_DIRECTIONS = {
|
|
2206
|
+
thumb: [],
|
|
2207
|
+
index: [],
|
|
2208
|
+
middle: [],
|
|
2209
|
+
ring: [],
|
|
2210
|
+
pinky: []
|
|
2211
|
+
};
|
|
2189
2212
|
function createHandPoseEntry(partial) {
|
|
2190
2213
|
return {
|
|
2191
2214
|
id: partial.id,
|
|
@@ -2193,6 +2216,14 @@ function createHandPoseEntry(partial) {
|
|
|
2193
2216
|
preset: partial.preset ?? null,
|
|
2194
2217
|
curls: { ...DEFAULT_POSE_CURLS, ...partial.curls },
|
|
2195
2218
|
tolerance: partial.tolerance ?? 0.25,
|
|
2219
|
+
directions: {
|
|
2220
|
+
thumb: [...partial.directions?.thumb ?? []],
|
|
2221
|
+
index: [...partial.directions?.index ?? []],
|
|
2222
|
+
middle: [...partial.directions?.middle ?? []],
|
|
2223
|
+
ring: [...partial.directions?.ring ?? []],
|
|
2224
|
+
pinky: [...partial.directions?.pinky ?? []]
|
|
2225
|
+
},
|
|
2226
|
+
directionTolerance: partial.directionTolerance ?? 45,
|
|
2196
2227
|
hand: partial.hand ?? null,
|
|
2197
2228
|
orientation: partial.orientation ?? null,
|
|
2198
2229
|
minHoldSeconds: partial.minHoldSeconds ?? 0.15,
|
|
@@ -2215,7 +2246,9 @@ function handPoseDefinitionFor(entry, resolvePreset) {
|
|
|
2215
2246
|
return handPoseFromCurls(entry.id, entry.name, entry.curls, {
|
|
2216
2247
|
tolerance: entry.tolerance,
|
|
2217
2248
|
orientation: entry.orientation ?? void 0,
|
|
2218
|
-
hand: entry.hand ?? void 0
|
|
2249
|
+
hand: entry.hand ?? void 0,
|
|
2250
|
+
directions: entry.directions,
|
|
2251
|
+
directionToleranceDegrees: entry.directionTolerance
|
|
2219
2252
|
});
|
|
2220
2253
|
}
|
|
2221
2254
|
__name(handPoseDefinitionFor, "handPoseDefinitionFor");
|
|
@@ -2229,6 +2262,6 @@ var _XRHandPoseComponent = class _XRHandPoseComponent extends Component {
|
|
|
2229
2262
|
__name(_XRHandPoseComponent, "XRHandPoseComponent");
|
|
2230
2263
|
var XRHandPoseComponent = _XRHandPoseComponent;
|
|
2231
2264
|
|
|
2232
|
-
export { AnimationComponent, AnimationStateMachine, AnimationStateManager, AudioComponent, CameraComponent, DEFAULT_COLLIDER_STATE, DEFAULT_ENVIRONMENT_STATE, DEFAULT_INSTANCED_MESH_PARAMETERS, DEFAULT_INSTANCE_TRANSFORM, DEFAULT_MESH_GEOMETRY_PARAMETERS, DEFAULT_PHYSICS_STATE, DEFAULT_POSE_CURLS, DEFAULT_POSTPROCESSING_STATE, DEFAULT_RIGIDBODY_STATE, EntityType, Environment, HAND_POSE_PRESETS, HAND_POSE_PRESET_IDS, ImageComponent, ImageTarget, ImageTargetAnchor, InstanceSlotComponent, InstancedMeshComponent, LightComponent, MaterialComponent, MeshComponent, MeshGeometryComponent, ModelComponent, Name, Object3DRef, ParentId, PhysicsComponent, Postprocessing, PrefabInstance, PrefabNode, ScriptComponent, ScriptObjectComponent, Selectable, SelectionTransformState, SpriteComponent, TransformComponent, VRTeleportAreaComponent, VideoComponent, XRHandPoseComponent, XRInteractableComponent, XRInteractorComponent, XRInteractorSideComponent, XRRigComponent, cloneHandPose, components_exports, createAttachPoint, createHandPoseEntry, defaultMaterialValue, getHandPosePreset, handPoseDefinitionFor, handPoseFromCurls, normalizePhysicsState, setPhysicsLiveRef };
|
|
2233
|
-
//# sourceMappingURL=chunk-
|
|
2234
|
-
//# sourceMappingURL=chunk-
|
|
2265
|
+
export { AnimationComponent, AnimationStateMachine, AnimationStateManager, AudioComponent, CameraComponent, DEFAULT_COLLIDER_STATE, DEFAULT_ENVIRONMENT_STATE, DEFAULT_INSTANCED_MESH_PARAMETERS, DEFAULT_INSTANCE_TRANSFORM, DEFAULT_MESH_GEOMETRY_PARAMETERS, DEFAULT_PHYSICS_STATE, DEFAULT_POSE_CURLS, DEFAULT_POSE_DIRECTIONS, DEFAULT_POSTPROCESSING_STATE, DEFAULT_RIGIDBODY_STATE, EntityType, Environment, HAND_POSE_PRESETS, HAND_POSE_PRESET_IDS, ImageComponent, ImageTarget, ImageTargetAnchor, InstanceSlotComponent, InstancedMeshComponent, LightComponent, MaterialComponent, MeshComponent, MeshGeometryComponent, ModelComponent, Name, Object3DRef, ParentId, PhysicsComponent, Postprocessing, PrefabInstance, PrefabNode, ScriptComponent, ScriptObjectComponent, Selectable, SelectionTransformState, SpriteComponent, TransformComponent, VRTeleportAreaComponent, VideoComponent, XRHandPoseComponent, XRInteractableComponent, XRInteractorComponent, XRInteractorSideComponent, XRRigComponent, cloneHandPose, components_exports, createAttachPoint, createHandPoseEntry, defaultMaterialValue, getHandPosePreset, handPoseDefinitionFor, handPoseFromCurls, normalizePhysicsState, setPhysicsLiveRef };
|
|
2266
|
+
//# sourceMappingURL=chunk-H6DQ7JRE.js.map
|
|
2267
|
+
//# sourceMappingURL=chunk-H6DQ7JRE.js.map
|