@relu-interactives/spatial-ecs 0.3.6 → 0.3.8
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-TmC2EijF.d.cts → System-31wk-A0g.d.cts} +1 -1
- package/dist/{System-TmC2EijF.d.ts → System-31wk-A0g.d.ts} +1 -1
- package/dist/{XRInteractor-CCUzSqg9.d.ts → XRHandPose-CxPz8VBp.d.ts} +139 -20
- package/dist/{XRInteractor-I2q6TKtF.d.cts → XRHandPose-VuSbe4iz.d.cts} +139 -20
- package/dist/{chunk-FQTOC7HK.js → chunk-KIKIWCEB.js} +14 -5
- package/dist/chunk-KIKIWCEB.js.map +1 -0
- package/dist/{chunk-N4GKZ7IV.js → chunk-KVGGAL5V.js} +227 -3
- package/dist/chunk-KVGGAL5V.js.map +1 -0
- package/dist/{chunk-JRJ3CL5H.js → chunk-L5BP727H.js} +3 -3
- package/dist/{chunk-JRJ3CL5H.js.map → chunk-L5BP727H.js.map} +1 -1
- package/dist/{chunk-WRJ2K3LZ.js → chunk-LMTB4KQ4.js} +1011 -56
- package/dist/chunk-LMTB4KQ4.js.map +1 -0
- package/dist/components/index.cjs +98 -0
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.d.cts +4 -3
- package/dist/components/index.d.ts +4 -3
- package/dist/components/index.js +1 -1
- package/dist/docs/guide/vr-and-hand-poses.md +111 -0
- package/dist/factories/index.cjs +58 -0
- package/dist/factories/index.cjs.map +1 -1
- package/dist/factories/index.d.cts +6 -3
- package/dist/factories/index.d.ts +6 -3
- package/dist/factories/index.js +3 -3
- package/dist/handPose-dFxqbFFY.d.cts +240 -0
- package/dist/handPose-dFxqbFFY.d.ts +240 -0
- package/dist/{index-W8pUajCW.d.ts → index-BIQoaKAA.d.cts} +9 -3
- package/dist/{index-BltjPEhg.d.cts → index-BxdXgqiI.d.ts} +9 -3
- package/dist/{index-BpbmZuOz.d.ts → index-C7XQyrgE.d.ts} +101 -7
- package/dist/{index-C5FrDt3z.d.cts → index-DyN50JZo.d.cts} +101 -7
- package/dist/index.cjs +1269 -51
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +104 -9
- package/dist/index.d.ts +104 -9
- package/dist/index.js +8 -8
- package/dist/systems/index.cjs +1226 -51
- package/dist/systems/index.cjs.map +1 -1
- package/dist/systems/index.d.cts +3 -2
- package/dist/systems/index.d.ts +3 -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-FQTOC7HK.js.map +0 -1
- package/dist/chunk-N4GKZ7IV.js.map +0 -1
- package/dist/chunk-WRJ2K3LZ.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import { k as EcsSystem, C as Component, W as WorldEntityView, T as TransformComponent, l as World, S as SpawnPrefabSource, m as SpawnPrefabOptions, n as ComponentClass, o as ParentLookup, p as EcsEntityKind, O as ObjectManagementSystem, q as SubtreeSnapshot, r as EntityId, s as ExternalRefWarning } from './System-
|
|
2
|
-
export { A as AssetInput, t as CheckboxInput, u as ColorInput, v as ComponentFactory, w as ComponentInput, x as ComponentKind, y as DropdownInput, z as DropdownOption, B as EcsComponentFactoryKind, F as EcsEntityEditorKind, G as EntityInput, H as FloatInput, I as InputSystem, J as IntersectionResult, K as KeyboardKey, L as KeyboardKeys, M as MouseButton, N as PREFAB_FILE_VERSION, Q as PREFAB_FILE_VERSION_NESTED, R as PrefabAsset, U as RemapSnapshotOptions, X as RenderSystem, Y as SelectionListener, Z as SliderInput, _ as TextInput, $ as ToggleInput, a0 as TransformSyncSystem, a1 as Vec3, a2 as Vector2Input, a3 as Vector3Input, a4 as clearPrefabCache, a5 as despawnPrefab, a6 as loadPrefab, a7 as parsePrefabAsset, a8 as prefabFileVersionFor, a9 as remapSnapshotEntityIds, aa as setPrefabAssetUrlResolver, ab as spawnPrefab } from './System-
|
|
1
|
+
import { k as EcsSystem, C as Component, W as WorldEntityView, T as TransformComponent, l as World, S as SpawnPrefabSource, m as SpawnPrefabOptions, n as ComponentClass, o as ParentLookup, p as EcsEntityKind, O as ObjectManagementSystem, q as SubtreeSnapshot, r as EntityId, s as ExternalRefWarning } from './System-31wk-A0g.cjs';
|
|
2
|
+
export { A as AssetInput, t as CheckboxInput, u as ColorInput, v as ComponentFactory, w as ComponentInput, x as ComponentKind, y as DropdownInput, z as DropdownOption, B as EcsComponentFactoryKind, F as EcsEntityEditorKind, G as EntityInput, H as FloatInput, I as InputSystem, J as IntersectionResult, K as KeyboardKey, L as KeyboardKeys, M as MouseButton, N as PREFAB_FILE_VERSION, Q as PREFAB_FILE_VERSION_NESTED, R as PrefabAsset, U as RemapSnapshotOptions, X as RenderSystem, Y as SelectionListener, Z as SliderInput, _ as TextInput, $ as ToggleInput, a0 as TransformSyncSystem, a1 as Vec3, a2 as Vector2Input, a3 as Vector3Input, a4 as clearPrefabCache, a5 as despawnPrefab, a6 as loadPrefab, a7 as parsePrefabAsset, a8 as prefabFileVersionFor, a9 as remapSnapshotEntityIds, aa as setPrefabAssetUrlResolver, ab as spawnPrefab } from './System-31wk-A0g.cjs';
|
|
3
3
|
import * as THREE from 'three';
|
|
4
|
-
import { O as Object3DRef,
|
|
5
|
-
export {
|
|
6
|
-
import { X as XrCapabilities, a as XrInputState } from './index-
|
|
7
|
-
export { A as AnimationSystem,
|
|
8
|
-
export { i as CoreComponents } from './index-
|
|
9
|
-
export { createAnimationComponent, createAudioComponent, createCameraComponent, createEntityTypeComponent, createEnvironmentComponent, createImageComponent, createImageTargetAnchorComponent, createImageTargetComponent, createInstanceSlotComponent, createInstancedMeshComponent, createLightComponent, createMaterialComponent, createMeshComponent, createMeshGeometryComponent, createModelComponent, createNameComponent, createObject3DRefComponent, createParentIdComponent, createPhysicsComponent, createPostprocessingComponent, createScriptComponent, createScriptObjectComponent, createSelectableComponent, createSelectionTransformStateComponent, createSpriteComponent, createTransformComponent, createVRTeleportAreaComponent, createVideoComponent, createXRInteractableComponent, createXRInteractorComponent, createXRInteractorSideComponent, createXRRigComponent, registerDefaultComponentFactories, registerDefaultFactories } from './factories/index.cjs';
|
|
4
|
+
import { O as Object3DRef, aj as XrHandPreset } from './XRHandPose-VuSbe4iz.cjs';
|
|
5
|
+
export { at as AnimationStateCallbacks, au as AnimationStateMachine, av as AnimationStateManager, aw as StateMachine } from './XRHandPose-VuSbe4iz.cjs';
|
|
6
|
+
import { X as XrCapabilities, a as XrInputState, b as XrHandPoseEventDetail } from './index-DyN50JZo.cjs';
|
|
7
|
+
export { A as AnimationSystem, c as AudioSystem, C as CameraSyncSystem, E as EnvironmentSyncSystem, I as InstancedMeshSystem, L as LightSyncSystem, M as MaterialSyncSystem, d as MeshGeometrySystem, e as ModuleLoader, N as NO_XR_CAPABILITIES, O as ObjectVisibilitySystem, P as PhysicsSyncSystem, f as PostprocessingSyncSystem, S as SCRIPT_OBJECT_ROOT_FLAG, g as ScriptBehaviourSystem, h as ScriptObjectSystem, i as SelectionContext, V as VRTeleportAreaSystem, j as VideoSystem, k as XRControllerVisualSystem, l as XRHandPoseSystem, m as XRInputSystem, n as XRInteractionSystem, o as XRLocomotionSystem, p as XRSessionSystem, q as XRTeleportVisualSystem, r as XrHandedness, s as XrInputKind, t as readXrCapabilities } from './index-DyN50JZo.cjs';
|
|
8
|
+
export { i as CoreComponents } from './index-BIQoaKAA.cjs';
|
|
9
|
+
export { createAnimationComponent, createAudioComponent, createCameraComponent, createEntityTypeComponent, createEnvironmentComponent, createImageComponent, createImageTargetAnchorComponent, createImageTargetComponent, createInstanceSlotComponent, createInstancedMeshComponent, createLightComponent, createMaterialComponent, createMeshComponent, createMeshGeometryComponent, createModelComponent, createNameComponent, createObject3DRefComponent, createParentIdComponent, createPhysicsComponent, createPostprocessingComponent, createScriptComponent, createScriptObjectComponent, createSelectableComponent, createSelectionTransformStateComponent, createSpriteComponent, createTransformComponent, createVRTeleportAreaComponent, createVideoComponent, createXRHandPoseComponent, createXRInteractableComponent, createXRInteractorComponent, createXRInteractorSideComponent, createXRRigComponent, registerDefaultComponentFactories, registerDefaultFactories } from './factories/index.cjs';
|
|
10
10
|
import { GLTF } from 'three/examples/jsm/loaders/GLTFLoader.js';
|
|
11
|
+
import { X as XrHandPoseDefinition, a as XrFinger, b as XrHandPoseOrientation } from './handPose-dFxqbFFY.cjs';
|
|
12
|
+
export { C as CURLED_COS, D as DEFAULT_ENTER_CONFIDENCE, c as DEFAULT_EXIT_CONFIDENCE, d as DEFAULT_LOST_GRACE_SECONDS, e as DEFAULT_MIN_HOLD_SECONDS, F as FALLBACK_HAND_SCALE, H as HandPoseTracker, f as HandPoseTrackerOptions, M as MATCH_FALLOFF, P as PINCH_FINGERS, S as STRAIGHT_COS, g as XR_FINGERS, h as XrFingerCurl, i as XrFingerTarget, j as XrHandJointName, k as XrHandJoints, l as XrHandPoseAxis, m as XrHandPoseContext, n as XrHandPoseDirection, o as XrHandPoseEvent, p as XrHandPoseMatch, q as XrHandShape, r as XrPalmPose, s as computeFingerCurl, t as computeHandShape, u as computePalmPose, v as computePalmWidth, w as computePinch, x as computeSpread, y as estimateHandScale, z as matchHandPose } from './handPose-dFxqbFFY.cjs';
|
|
11
13
|
import '@dimforge/rapier3d-compat';
|
|
12
14
|
|
|
13
15
|
interface CustomEcsSystem extends EcsSystem {
|
|
@@ -301,6 +303,15 @@ declare class Behaviour implements CustomEcsSystem {
|
|
|
301
303
|
*
|
|
302
304
|
* @param input - The source doing the grabbing.
|
|
303
305
|
*/
|
|
306
|
+
/**
|
|
307
|
+
* A hand pose declared on this entity started being held.
|
|
308
|
+
*
|
|
309
|
+
* Fires once the pose has been sustained for its hold time, not the instant
|
|
310
|
+
* the fingers pass through it.
|
|
311
|
+
*/
|
|
312
|
+
onHandPoseStart(_event: XrHandPoseEventDetail): void;
|
|
313
|
+
/** A held hand pose ended, or its hand stopped being tracked. */
|
|
314
|
+
onHandPoseEnd(_event: XrHandPoseEventDetail): void;
|
|
304
315
|
onGrab(input: XrInputState): void;
|
|
305
316
|
/** Called when this entity is released. Optional XR hook. */
|
|
306
317
|
onRelease(input: XrInputState): void;
|
|
@@ -431,6 +442,7 @@ type ComponentValueMaps = {
|
|
|
431
442
|
vrTeleportAreaValues: Map<number, unknown>;
|
|
432
443
|
xrInteractableValues: Map<number, unknown>;
|
|
433
444
|
xrInteractorValues: Map<number, unknown>;
|
|
445
|
+
xrHandPoseValues: Map<number, unknown>;
|
|
434
446
|
xrInteractorSideValues: Map<number, unknown>;
|
|
435
447
|
instancedMeshValues: Map<number, unknown>;
|
|
436
448
|
instanceSlotValues: Map<number, unknown>;
|
|
@@ -810,4 +822,87 @@ declare function createHandMaterial(preset: XrHandPreset, options: HandMaterialO
|
|
|
810
822
|
/** Apply a preset material to every mesh under a hand model. */
|
|
811
823
|
declare function applyHandMaterial(root: THREE.Object3D, material: THREE.Material): void;
|
|
812
824
|
|
|
813
|
-
|
|
825
|
+
/**
|
|
826
|
+
* Built-in poses, keyed by id.
|
|
827
|
+
*
|
|
828
|
+
* The set covers the industry consensus (fist, open palm, point, thumbs up,
|
|
829
|
+
* pinch) plus the widely-requested ones the major toolkits omit — OK sign and
|
|
830
|
+
* gun — and the expressive extras that read well in social VR.
|
|
831
|
+
*/
|
|
832
|
+
declare const HAND_POSE_PRESETS: Record<string, XrHandPoseDefinition>;
|
|
833
|
+
/** Preset ids, in the order the editor lists them. */
|
|
834
|
+
declare const HAND_POSE_PRESET_IDS: readonly string[];
|
|
835
|
+
/**
|
|
836
|
+
* A deep copy of a preset.
|
|
837
|
+
*
|
|
838
|
+
* Returned by value because scenes edit their poses: handing out the shared
|
|
839
|
+
* object would let one scene's tweak leak into every other pose in the app.
|
|
840
|
+
*/
|
|
841
|
+
declare function getHandPosePreset(id: string): XrHandPoseDefinition | null;
|
|
842
|
+
declare function cloneHandPose(definition: XrHandPoseDefinition): XrHandPoseDefinition;
|
|
843
|
+
/**
|
|
844
|
+
* Build a pose from five curl values — the shape the editor's sliders and the
|
|
845
|
+
* AI tools produce.
|
|
846
|
+
*/
|
|
847
|
+
declare function handPoseFromCurls(id: string, name: string, curls: Record<XrFinger, number>, options?: {
|
|
848
|
+
tolerance?: number;
|
|
849
|
+
pinch?: XrHandPoseDefinition["pinch"];
|
|
850
|
+
orientation?: XrHandPoseOrientation;
|
|
851
|
+
hand?: "left" | "right";
|
|
852
|
+
}): XrHandPoseDefinition;
|
|
853
|
+
|
|
854
|
+
/**
|
|
855
|
+
* Estimates release velocity for thrown objects.
|
|
856
|
+
*
|
|
857
|
+
* Naively differencing the last two frames produces terrible throws: a single
|
|
858
|
+
* noisy sample (or the tiny decelerating motion as the user opens their hand)
|
|
859
|
+
* lands right on the release frame and the object dribbles out. Real throws are
|
|
860
|
+
* recovered by looking back over a short WINDOW and taking the best of it — the
|
|
861
|
+
* approach every mature VR toolkit converges on.
|
|
862
|
+
*
|
|
863
|
+
* Pure and frame-rate independent so throw feel can be unit-tested without a
|
|
864
|
+
* headset.
|
|
865
|
+
*/
|
|
866
|
+
/** Samples retained. ~5 frames ≈ 55ms at 90Hz — long enough to smooth noise. */
|
|
867
|
+
declare const VELOCITY_SAMPLES = 5;
|
|
868
|
+
/**
|
|
869
|
+
* Samples older than this are ignored on release.
|
|
870
|
+
*
|
|
871
|
+
* Without it, pausing mid-grab then opening your hand would throw using motion
|
|
872
|
+
* from before the pause.
|
|
873
|
+
*/
|
|
874
|
+
declare const MAX_SAMPLE_AGE_SECONDS = 0.2;
|
|
875
|
+
type VelocitySample = {
|
|
876
|
+
position: THREE.Vector3;
|
|
877
|
+
/** Seconds, monotonically increasing. */
|
|
878
|
+
time: number;
|
|
879
|
+
};
|
|
880
|
+
/**
|
|
881
|
+
* Rolling buffer of hand positions used to recover throw velocity.
|
|
882
|
+
*
|
|
883
|
+
* One per active grab; cleared on release.
|
|
884
|
+
*/
|
|
885
|
+
declare class ThrowVelocityTracker {
|
|
886
|
+
private readonly samples;
|
|
887
|
+
/** Record where the hand is now. Call once per frame while held. */
|
|
888
|
+
record(position: THREE.Vector3, time: number): void;
|
|
889
|
+
/**
|
|
890
|
+
* Velocity to release with, in metres/second.
|
|
891
|
+
*
|
|
892
|
+
* Uses the FASTEST segment inside the window rather than the most recent or
|
|
893
|
+
* the window average. Users decelerate as they open their hand, so the last
|
|
894
|
+
* segment understates the throw and the average washes it out; peak speed is
|
|
895
|
+
* what matches the motion the user actually felt they made.
|
|
896
|
+
*/
|
|
897
|
+
computeVelocity(now: number): THREE.Vector3;
|
|
898
|
+
clear(): void;
|
|
899
|
+
}
|
|
900
|
+
/**
|
|
901
|
+
* Angular velocity from a rotation delta, as an axis-angle vector (rad/s).
|
|
902
|
+
*
|
|
903
|
+
* Spin makes a thrown ball read as thrown rather than launched, and it is what
|
|
904
|
+
* lets a scene do curve shots or spinning props.
|
|
905
|
+
*/
|
|
906
|
+
declare function angularVelocityFrom(previous: THREE.Quaternion, current: THREE.Quaternion, deltaTime: number): THREE.Vector3;
|
|
907
|
+
|
|
908
|
+
export { ADDED_NODE_MARKER_COMPONENT, ARC_GRAVITY, ARC_MAX_TIME, ARC_SPEED, ARC_STEPS, type ApplyPrefabToSnapshotResult, Behaviour, Component, type ComponentValueMaps, EcsEntityKind, EcsSystem, type EcsWorldComponentSnapshot, type EcsWorldStateSnapshotLike, EntityId, ExternalRefWarning, HAND_POSE_PRESETS, HAND_POSE_PRESET_IDS, HYDRATABLE_ENTITY_KINDS, type HandMaterialOptions, type HydrateOptions, type HydrateWorldFromSnapshotResult, type InstantiateSubtreeResult, MAX_SAMPLE_AGE_SECONDS, NODE_KEY_SEPARATOR, type NestedRegion, type NodeKeyMaps, type NodeMaps, OVERRIDE_DIFF_EXCLUDED_COMPONENTS, OVERRIDE_ROOT_EXCLUDED_COMPONENTS, ObjectManagementSystem, ParentLookup, SHARED_MODEL_RESOURCE_FLAG, ScriptObject, type SerializeEntitySubtreeResult, SpawnPrefabOptions, SpawnPrefabSource, SubtreeSnapshot, ThrowVelocityTracker, VELOCITY_SAMPLES, type VelocitySample, World, WorldEntityView, XrCapabilities, XrFinger, XrHandPoseDefinition, XrHandPoseEventDetail, XrHandPoseOrientation, XrInputState, angularVelocityFrom, applyHandMaterial, applyPrefabToSnapshotInstances, arcGroundCrossing, buildComponentValueMaps, buildNodeKeyMapsFromSnapshot, buildNodeMapsFromSnapshot, canonicalizeComponentValue, clearModelCache, cloneHandPose, collectDiffPaths, collectDirectPrefabDependencies, collectEntitySubtree, collectSnapshotSubtreeIds, computeInstanceOverrides, createHandMaterial, decanonicalizeComponentValue, encodeOverride, findSnapshotRootEntityIds, findTopLevelNestedRegions, getHandPosePreset, groupOverridePaths, handPoseFromCurls, hydrateWorldFromSnapshot, hydrateWorldFromSnapshotDetailed, indexSnapshotByEntity, instantiateSubtree, loadSharedGltf, mergeComponentValue, parseOverride, resolveDracoDecoderPath, restoreComponentState, restorePostCreateComponents, sampleTeleportArc, serializeEntitySubtree, setDracoDecoderPath };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import { k as EcsSystem, C as Component, W as WorldEntityView, T as TransformComponent, l as World, S as SpawnPrefabSource, m as SpawnPrefabOptions, n as ComponentClass, o as ParentLookup, p as EcsEntityKind, O as ObjectManagementSystem, q as SubtreeSnapshot, r as EntityId, s as ExternalRefWarning } from './System-
|
|
2
|
-
export { A as AssetInput, t as CheckboxInput, u as ColorInput, v as ComponentFactory, w as ComponentInput, x as ComponentKind, y as DropdownInput, z as DropdownOption, B as EcsComponentFactoryKind, F as EcsEntityEditorKind, G as EntityInput, H as FloatInput, I as InputSystem, J as IntersectionResult, K as KeyboardKey, L as KeyboardKeys, M as MouseButton, N as PREFAB_FILE_VERSION, Q as PREFAB_FILE_VERSION_NESTED, R as PrefabAsset, U as RemapSnapshotOptions, X as RenderSystem, Y as SelectionListener, Z as SliderInput, _ as TextInput, $ as ToggleInput, a0 as TransformSyncSystem, a1 as Vec3, a2 as Vector2Input, a3 as Vector3Input, a4 as clearPrefabCache, a5 as despawnPrefab, a6 as loadPrefab, a7 as parsePrefabAsset, a8 as prefabFileVersionFor, a9 as remapSnapshotEntityIds, aa as setPrefabAssetUrlResolver, ab as spawnPrefab } from './System-
|
|
1
|
+
import { k as EcsSystem, C as Component, W as WorldEntityView, T as TransformComponent, l as World, S as SpawnPrefabSource, m as SpawnPrefabOptions, n as ComponentClass, o as ParentLookup, p as EcsEntityKind, O as ObjectManagementSystem, q as SubtreeSnapshot, r as EntityId, s as ExternalRefWarning } from './System-31wk-A0g.js';
|
|
2
|
+
export { A as AssetInput, t as CheckboxInput, u as ColorInput, v as ComponentFactory, w as ComponentInput, x as ComponentKind, y as DropdownInput, z as DropdownOption, B as EcsComponentFactoryKind, F as EcsEntityEditorKind, G as EntityInput, H as FloatInput, I as InputSystem, J as IntersectionResult, K as KeyboardKey, L as KeyboardKeys, M as MouseButton, N as PREFAB_FILE_VERSION, Q as PREFAB_FILE_VERSION_NESTED, R as PrefabAsset, U as RemapSnapshotOptions, X as RenderSystem, Y as SelectionListener, Z as SliderInput, _ as TextInput, $ as ToggleInput, a0 as TransformSyncSystem, a1 as Vec3, a2 as Vector2Input, a3 as Vector3Input, a4 as clearPrefabCache, a5 as despawnPrefab, a6 as loadPrefab, a7 as parsePrefabAsset, a8 as prefabFileVersionFor, a9 as remapSnapshotEntityIds, aa as setPrefabAssetUrlResolver, ab as spawnPrefab } from './System-31wk-A0g.js';
|
|
3
3
|
import * as THREE from 'three';
|
|
4
|
-
import { O as Object3DRef,
|
|
5
|
-
export {
|
|
6
|
-
import { X as XrCapabilities, a as XrInputState } from './index-
|
|
7
|
-
export { A as AnimationSystem,
|
|
8
|
-
export { i as CoreComponents } from './index-
|
|
9
|
-
export { createAnimationComponent, createAudioComponent, createCameraComponent, createEntityTypeComponent, createEnvironmentComponent, createImageComponent, createImageTargetAnchorComponent, createImageTargetComponent, createInstanceSlotComponent, createInstancedMeshComponent, createLightComponent, createMaterialComponent, createMeshComponent, createMeshGeometryComponent, createModelComponent, createNameComponent, createObject3DRefComponent, createParentIdComponent, createPhysicsComponent, createPostprocessingComponent, createScriptComponent, createScriptObjectComponent, createSelectableComponent, createSelectionTransformStateComponent, createSpriteComponent, createTransformComponent, createVRTeleportAreaComponent, createVideoComponent, createXRInteractableComponent, createXRInteractorComponent, createXRInteractorSideComponent, createXRRigComponent, registerDefaultComponentFactories, registerDefaultFactories } from './factories/index.js';
|
|
4
|
+
import { O as Object3DRef, aj as XrHandPreset } from './XRHandPose-CxPz8VBp.js';
|
|
5
|
+
export { at as AnimationStateCallbacks, au as AnimationStateMachine, av as AnimationStateManager, aw as StateMachine } from './XRHandPose-CxPz8VBp.js';
|
|
6
|
+
import { X as XrCapabilities, a as XrInputState, b as XrHandPoseEventDetail } from './index-C7XQyrgE.js';
|
|
7
|
+
export { A as AnimationSystem, c as AudioSystem, C as CameraSyncSystem, E as EnvironmentSyncSystem, I as InstancedMeshSystem, L as LightSyncSystem, M as MaterialSyncSystem, d as MeshGeometrySystem, e as ModuleLoader, N as NO_XR_CAPABILITIES, O as ObjectVisibilitySystem, P as PhysicsSyncSystem, f as PostprocessingSyncSystem, S as SCRIPT_OBJECT_ROOT_FLAG, g as ScriptBehaviourSystem, h as ScriptObjectSystem, i as SelectionContext, V as VRTeleportAreaSystem, j as VideoSystem, k as XRControllerVisualSystem, l as XRHandPoseSystem, m as XRInputSystem, n as XRInteractionSystem, o as XRLocomotionSystem, p as XRSessionSystem, q as XRTeleportVisualSystem, r as XrHandedness, s as XrInputKind, t as readXrCapabilities } from './index-C7XQyrgE.js';
|
|
8
|
+
export { i as CoreComponents } from './index-BxdXgqiI.js';
|
|
9
|
+
export { createAnimationComponent, createAudioComponent, createCameraComponent, createEntityTypeComponent, createEnvironmentComponent, createImageComponent, createImageTargetAnchorComponent, createImageTargetComponent, createInstanceSlotComponent, createInstancedMeshComponent, createLightComponent, createMaterialComponent, createMeshComponent, createMeshGeometryComponent, createModelComponent, createNameComponent, createObject3DRefComponent, createParentIdComponent, createPhysicsComponent, createPostprocessingComponent, createScriptComponent, createScriptObjectComponent, createSelectableComponent, createSelectionTransformStateComponent, createSpriteComponent, createTransformComponent, createVRTeleportAreaComponent, createVideoComponent, createXRHandPoseComponent, createXRInteractableComponent, createXRInteractorComponent, createXRInteractorSideComponent, createXRRigComponent, registerDefaultComponentFactories, registerDefaultFactories } from './factories/index.js';
|
|
10
10
|
import { GLTF } from 'three/examples/jsm/loaders/GLTFLoader.js';
|
|
11
|
+
import { X as XrHandPoseDefinition, a as XrFinger, b as XrHandPoseOrientation } from './handPose-dFxqbFFY.js';
|
|
12
|
+
export { C as CURLED_COS, D as DEFAULT_ENTER_CONFIDENCE, c as DEFAULT_EXIT_CONFIDENCE, d as DEFAULT_LOST_GRACE_SECONDS, e as DEFAULT_MIN_HOLD_SECONDS, F as FALLBACK_HAND_SCALE, H as HandPoseTracker, f as HandPoseTrackerOptions, M as MATCH_FALLOFF, P as PINCH_FINGERS, S as STRAIGHT_COS, g as XR_FINGERS, h as XrFingerCurl, i as XrFingerTarget, j as XrHandJointName, k as XrHandJoints, l as XrHandPoseAxis, m as XrHandPoseContext, n as XrHandPoseDirection, o as XrHandPoseEvent, p as XrHandPoseMatch, q as XrHandShape, r as XrPalmPose, s as computeFingerCurl, t as computeHandShape, u as computePalmPose, v as computePalmWidth, w as computePinch, x as computeSpread, y as estimateHandScale, z as matchHandPose } from './handPose-dFxqbFFY.js';
|
|
11
13
|
import '@dimforge/rapier3d-compat';
|
|
12
14
|
|
|
13
15
|
interface CustomEcsSystem extends EcsSystem {
|
|
@@ -301,6 +303,15 @@ declare class Behaviour implements CustomEcsSystem {
|
|
|
301
303
|
*
|
|
302
304
|
* @param input - The source doing the grabbing.
|
|
303
305
|
*/
|
|
306
|
+
/**
|
|
307
|
+
* A hand pose declared on this entity started being held.
|
|
308
|
+
*
|
|
309
|
+
* Fires once the pose has been sustained for its hold time, not the instant
|
|
310
|
+
* the fingers pass through it.
|
|
311
|
+
*/
|
|
312
|
+
onHandPoseStart(_event: XrHandPoseEventDetail): void;
|
|
313
|
+
/** A held hand pose ended, or its hand stopped being tracked. */
|
|
314
|
+
onHandPoseEnd(_event: XrHandPoseEventDetail): void;
|
|
304
315
|
onGrab(input: XrInputState): void;
|
|
305
316
|
/** Called when this entity is released. Optional XR hook. */
|
|
306
317
|
onRelease(input: XrInputState): void;
|
|
@@ -431,6 +442,7 @@ type ComponentValueMaps = {
|
|
|
431
442
|
vrTeleportAreaValues: Map<number, unknown>;
|
|
432
443
|
xrInteractableValues: Map<number, unknown>;
|
|
433
444
|
xrInteractorValues: Map<number, unknown>;
|
|
445
|
+
xrHandPoseValues: Map<number, unknown>;
|
|
434
446
|
xrInteractorSideValues: Map<number, unknown>;
|
|
435
447
|
instancedMeshValues: Map<number, unknown>;
|
|
436
448
|
instanceSlotValues: Map<number, unknown>;
|
|
@@ -810,4 +822,87 @@ declare function createHandMaterial(preset: XrHandPreset, options: HandMaterialO
|
|
|
810
822
|
/** Apply a preset material to every mesh under a hand model. */
|
|
811
823
|
declare function applyHandMaterial(root: THREE.Object3D, material: THREE.Material): void;
|
|
812
824
|
|
|
813
|
-
|
|
825
|
+
/**
|
|
826
|
+
* Built-in poses, keyed by id.
|
|
827
|
+
*
|
|
828
|
+
* The set covers the industry consensus (fist, open palm, point, thumbs up,
|
|
829
|
+
* pinch) plus the widely-requested ones the major toolkits omit — OK sign and
|
|
830
|
+
* gun — and the expressive extras that read well in social VR.
|
|
831
|
+
*/
|
|
832
|
+
declare const HAND_POSE_PRESETS: Record<string, XrHandPoseDefinition>;
|
|
833
|
+
/** Preset ids, in the order the editor lists them. */
|
|
834
|
+
declare const HAND_POSE_PRESET_IDS: readonly string[];
|
|
835
|
+
/**
|
|
836
|
+
* A deep copy of a preset.
|
|
837
|
+
*
|
|
838
|
+
* Returned by value because scenes edit their poses: handing out the shared
|
|
839
|
+
* object would let one scene's tweak leak into every other pose in the app.
|
|
840
|
+
*/
|
|
841
|
+
declare function getHandPosePreset(id: string): XrHandPoseDefinition | null;
|
|
842
|
+
declare function cloneHandPose(definition: XrHandPoseDefinition): XrHandPoseDefinition;
|
|
843
|
+
/**
|
|
844
|
+
* Build a pose from five curl values — the shape the editor's sliders and the
|
|
845
|
+
* AI tools produce.
|
|
846
|
+
*/
|
|
847
|
+
declare function handPoseFromCurls(id: string, name: string, curls: Record<XrFinger, number>, options?: {
|
|
848
|
+
tolerance?: number;
|
|
849
|
+
pinch?: XrHandPoseDefinition["pinch"];
|
|
850
|
+
orientation?: XrHandPoseOrientation;
|
|
851
|
+
hand?: "left" | "right";
|
|
852
|
+
}): XrHandPoseDefinition;
|
|
853
|
+
|
|
854
|
+
/**
|
|
855
|
+
* Estimates release velocity for thrown objects.
|
|
856
|
+
*
|
|
857
|
+
* Naively differencing the last two frames produces terrible throws: a single
|
|
858
|
+
* noisy sample (or the tiny decelerating motion as the user opens their hand)
|
|
859
|
+
* lands right on the release frame and the object dribbles out. Real throws are
|
|
860
|
+
* recovered by looking back over a short WINDOW and taking the best of it — the
|
|
861
|
+
* approach every mature VR toolkit converges on.
|
|
862
|
+
*
|
|
863
|
+
* Pure and frame-rate independent so throw feel can be unit-tested without a
|
|
864
|
+
* headset.
|
|
865
|
+
*/
|
|
866
|
+
/** Samples retained. ~5 frames ≈ 55ms at 90Hz — long enough to smooth noise. */
|
|
867
|
+
declare const VELOCITY_SAMPLES = 5;
|
|
868
|
+
/**
|
|
869
|
+
* Samples older than this are ignored on release.
|
|
870
|
+
*
|
|
871
|
+
* Without it, pausing mid-grab then opening your hand would throw using motion
|
|
872
|
+
* from before the pause.
|
|
873
|
+
*/
|
|
874
|
+
declare const MAX_SAMPLE_AGE_SECONDS = 0.2;
|
|
875
|
+
type VelocitySample = {
|
|
876
|
+
position: THREE.Vector3;
|
|
877
|
+
/** Seconds, monotonically increasing. */
|
|
878
|
+
time: number;
|
|
879
|
+
};
|
|
880
|
+
/**
|
|
881
|
+
* Rolling buffer of hand positions used to recover throw velocity.
|
|
882
|
+
*
|
|
883
|
+
* One per active grab; cleared on release.
|
|
884
|
+
*/
|
|
885
|
+
declare class ThrowVelocityTracker {
|
|
886
|
+
private readonly samples;
|
|
887
|
+
/** Record where the hand is now. Call once per frame while held. */
|
|
888
|
+
record(position: THREE.Vector3, time: number): void;
|
|
889
|
+
/**
|
|
890
|
+
* Velocity to release with, in metres/second.
|
|
891
|
+
*
|
|
892
|
+
* Uses the FASTEST segment inside the window rather than the most recent or
|
|
893
|
+
* the window average. Users decelerate as they open their hand, so the last
|
|
894
|
+
* segment understates the throw and the average washes it out; peak speed is
|
|
895
|
+
* what matches the motion the user actually felt they made.
|
|
896
|
+
*/
|
|
897
|
+
computeVelocity(now: number): THREE.Vector3;
|
|
898
|
+
clear(): void;
|
|
899
|
+
}
|
|
900
|
+
/**
|
|
901
|
+
* Angular velocity from a rotation delta, as an axis-angle vector (rad/s).
|
|
902
|
+
*
|
|
903
|
+
* Spin makes a thrown ball read as thrown rather than launched, and it is what
|
|
904
|
+
* lets a scene do curve shots or spinning props.
|
|
905
|
+
*/
|
|
906
|
+
declare function angularVelocityFrom(previous: THREE.Quaternion, current: THREE.Quaternion, deltaTime: number): THREE.Vector3;
|
|
907
|
+
|
|
908
|
+
export { ADDED_NODE_MARKER_COMPONENT, ARC_GRAVITY, ARC_MAX_TIME, ARC_SPEED, ARC_STEPS, type ApplyPrefabToSnapshotResult, Behaviour, Component, type ComponentValueMaps, EcsEntityKind, EcsSystem, type EcsWorldComponentSnapshot, type EcsWorldStateSnapshotLike, EntityId, ExternalRefWarning, HAND_POSE_PRESETS, HAND_POSE_PRESET_IDS, HYDRATABLE_ENTITY_KINDS, type HandMaterialOptions, type HydrateOptions, type HydrateWorldFromSnapshotResult, type InstantiateSubtreeResult, MAX_SAMPLE_AGE_SECONDS, NODE_KEY_SEPARATOR, type NestedRegion, type NodeKeyMaps, type NodeMaps, OVERRIDE_DIFF_EXCLUDED_COMPONENTS, OVERRIDE_ROOT_EXCLUDED_COMPONENTS, ObjectManagementSystem, ParentLookup, SHARED_MODEL_RESOURCE_FLAG, ScriptObject, type SerializeEntitySubtreeResult, SpawnPrefabOptions, SpawnPrefabSource, SubtreeSnapshot, ThrowVelocityTracker, VELOCITY_SAMPLES, type VelocitySample, World, WorldEntityView, XrCapabilities, XrFinger, XrHandPoseDefinition, XrHandPoseEventDetail, XrHandPoseOrientation, XrInputState, angularVelocityFrom, applyHandMaterial, applyPrefabToSnapshotInstances, arcGroundCrossing, buildComponentValueMaps, buildNodeKeyMapsFromSnapshot, buildNodeMapsFromSnapshot, canonicalizeComponentValue, clearModelCache, cloneHandPose, collectDiffPaths, collectDirectPrefabDependencies, collectEntitySubtree, collectSnapshotSubtreeIds, computeInstanceOverrides, createHandMaterial, decanonicalizeComponentValue, encodeOverride, findSnapshotRootEntityIds, findTopLevelNestedRegions, getHandPosePreset, groupOverridePaths, handPoseFromCurls, hydrateWorldFromSnapshot, hydrateWorldFromSnapshotDetailed, indexSnapshotByEntity, instantiateSubtree, loadSharedGltf, mergeComponentValue, parseOverride, resolveDracoDecoderPath, restoreComponentState, restorePostCreateComponents, sampleTeleportArc, serializeEntitySubtree, setDracoDecoderPath };
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { MeshGeometrySystem, InstancedMeshSystem, EnvironmentSyncSystem, PostprocessingSyncSystem, LightSyncSystem, MaterialSyncSystem, VRTeleportAreaSystem, PhysicsSyncSystem, AnimationSystem, AudioSystem, VideoSystem, CameraSyncSystem, TransformSyncSystem, ObjectVisibilitySystem, RenderSystem, spawnPrefab, despawnPrefab, buildNodeKeyMapsFromSnapshot, indexSnapshotByEntity, findTopLevelNestedRegions, collectSnapshotSubtreeIds, groupOverridePaths, OVERRIDE_DIFF_EXCLUDED_COMPONENTS, OVERRIDE_ROOT_EXCLUDED_COMPONENTS, canonicalizeComponentValue, mergeComponentValue, decanonicalizeComponentValue, computeInstanceOverrides, collectEntitySubtree, ADDED_NODE_MARKER_COMPONENT } from './chunk-
|
|
2
|
-
export { ADDED_NODE_MARKER_COMPONENT, ARC_GRAVITY, ARC_MAX_TIME, ARC_SPEED, ARC_STEPS, AnimationSystem, AudioSystem, Behaviour, 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 } from './chunk-
|
|
3
|
-
import { registerDefaultFactories } from './chunk-
|
|
4
|
-
export { createAnimationComponent, createAudioComponent, createCameraComponent, createEntityTypeComponent, createEnvironmentComponent, createImageComponent, createImageTargetAnchorComponent, createImageTargetComponent, createInstanceSlotComponent, createInstancedMeshComponent, createLightComponent, createMaterialComponent, createMeshComponent, createMeshGeometryComponent, createModelComponent, createNameComponent, createObject3DRefComponent, createParentIdComponent, createPhysicsComponent, createPostprocessingComponent, createScriptComponent, createScriptObjectComponent, createSelectableComponent, createSelectionTransformStateComponent, createSpriteComponent, createTransformComponent, createVRTeleportAreaComponent, createVideoComponent, createXRInteractableComponent, createXRInteractorComponent, createXRInteractorSideComponent, createXRRigComponent, registerDefaultComponentFactories, registerDefaultFactories } from './chunk-
|
|
5
|
-
import { ObjectManagementSystem } from './chunk-
|
|
6
|
-
export { ObjectManagementSystem, SHARED_MODEL_RESOURCE_FLAG, clearModelCache, loadSharedGltf, resolveDracoDecoderPath, setDracoDecoderPath } from './chunk-
|
|
7
|
-
import { SelectionTransformState, Object3DRef, Name, EntityType, ParentId, Environment, Postprocessing, ScriptComponent } from './chunk-
|
|
8
|
-
export { AnimationStateMachine, AnimationStateManager, components_exports as CoreComponents } from './chunk-
|
|
1
|
+
import { MeshGeometrySystem, InstancedMeshSystem, EnvironmentSyncSystem, PostprocessingSyncSystem, LightSyncSystem, MaterialSyncSystem, VRTeleportAreaSystem, PhysicsSyncSystem, AnimationSystem, AudioSystem, VideoSystem, CameraSyncSystem, TransformSyncSystem, ObjectVisibilitySystem, RenderSystem, spawnPrefab, despawnPrefab, buildNodeKeyMapsFromSnapshot, indexSnapshotByEntity, findTopLevelNestedRegions, collectSnapshotSubtreeIds, groupOverridePaths, OVERRIDE_DIFF_EXCLUDED_COMPONENTS, OVERRIDE_ROOT_EXCLUDED_COMPONENTS, canonicalizeComponentValue, mergeComponentValue, decanonicalizeComponentValue, computeInstanceOverrides, collectEntitySubtree, ADDED_NODE_MARKER_COMPONENT } from './chunk-LMTB4KQ4.js';
|
|
2
|
+
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_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, XRInputSystem, XRInteractionSystem, XRLocomotionSystem, XRSessionSystem, XRTeleportVisualSystem, XR_FINGERS, angularVelocityFrom, applyHandMaterial, arcGroundCrossing, buildComponentValueMaps, buildNodeKeyMapsFromSnapshot, buildNodeMapsFromSnapshot, canonicalizeComponentValue, clearPrefabCache, collectDiffPaths, collectEntitySubtree, collectSnapshotSubtreeIds, computeFingerCurl, computeHandShape, computeInstanceOverrides, computePalmPose, computePalmWidth, computePinch, computeSpread, createHandMaterial, decanonicalizeComponentValue, despawnPrefab, encodeOverride, estimateHandScale, findSnapshotRootEntityIds, findTopLevelNestedRegions, groupOverridePaths, hydrateWorldFromSnapshot, hydrateWorldFromSnapshotDetailed, indexSnapshotByEntity, instantiateSubtree, loadPrefab, matchHandPose, mergeComponentValue, parseOverride, parsePrefabAsset, prefabFileVersionFor, readXrCapabilities, restoreComponentState, restorePostCreateComponents, sampleTeleportArc, setPrefabAssetUrlResolver, spawnPrefab } from './chunk-LMTB4KQ4.js';
|
|
3
|
+
import { registerDefaultFactories } from './chunk-KIKIWCEB.js';
|
|
4
|
+
export { createAnimationComponent, createAudioComponent, createCameraComponent, createEntityTypeComponent, createEnvironmentComponent, createImageComponent, createImageTargetAnchorComponent, createImageTargetComponent, createInstanceSlotComponent, createInstancedMeshComponent, createLightComponent, createMaterialComponent, createMeshComponent, createMeshGeometryComponent, createModelComponent, createNameComponent, createObject3DRefComponent, createParentIdComponent, createPhysicsComponent, createPostprocessingComponent, createScriptComponent, createScriptObjectComponent, createSelectableComponent, createSelectionTransformStateComponent, createSpriteComponent, createTransformComponent, createVRTeleportAreaComponent, createVideoComponent, createXRHandPoseComponent, createXRInteractableComponent, createXRInteractorComponent, createXRInteractorSideComponent, createXRRigComponent, registerDefaultComponentFactories, registerDefaultFactories } from './chunk-KIKIWCEB.js';
|
|
5
|
+
import { ObjectManagementSystem } from './chunk-L5BP727H.js';
|
|
6
|
+
export { ObjectManagementSystem, SHARED_MODEL_RESOURCE_FLAG, clearModelCache, loadSharedGltf, resolveDracoDecoderPath, setDracoDecoderPath } from './chunk-L5BP727H.js';
|
|
7
|
+
import { SelectionTransformState, Object3DRef, Name, EntityType, ParentId, Environment, Postprocessing, ScriptComponent } from './chunk-KVGGAL5V.js';
|
|
8
|
+
export { AnimationStateMachine, AnimationStateManager, components_exports as CoreComponents, HAND_POSE_PRESETS, HAND_POSE_PRESET_IDS, cloneHandPose, getHandPosePreset, handPoseFromCurls } from './chunk-KVGGAL5V.js';
|
|
9
9
|
import './chunk-QHILSPT4.js';
|
|
10
10
|
import { normalizeDebugValue, DEBUG_CHANGE_IGNORED_SYSTEMS, cloneHistoryValue } from './chunk-OWQSESTO.js';
|
|
11
11
|
import { __name } from './chunk-OY7ZODZP.js';
|