@relu-interactives/spatial-ecs 0.3.0 → 0.3.2
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-CYWZ_Zx5.d.cts → System-vrU46Vuw.d.cts} +16 -2
- package/dist/{System-CYWZ_Zx5.d.ts → System-vrU46Vuw.d.ts} +16 -2
- package/dist/{Video-AIQYTAAr.d.cts → XRRig-CAmf04NX.d.ts} +131 -4
- package/dist/{Video-DlZ4G9ig.d.ts → XRRig-Cu-EyliG.d.cts} +131 -4
- package/dist/{chunk-PZ4CAALA.js → chunk-67WGASUJ.js} +3 -3
- package/dist/{chunk-PZ4CAALA.js.map → chunk-67WGASUJ.js.map} +1 -1
- package/dist/{chunk-AT5SPSPM.js → chunk-JWTRFJBL.js} +168 -83
- package/dist/chunk-JWTRFJBL.js.map +1 -0
- package/dist/{chunk-7JFSEV7A.js → chunk-SALBG747.js} +757 -6
- package/dist/chunk-SALBG747.js.map +1 -0
- package/dist/{chunk-7BPHZWQ6.js → chunk-U3MDYKPV.js} +47 -3
- package/dist/chunk-U3MDYKPV.js.map +1 -0
- package/dist/components/index.cjs +44 -0
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.d.cts +3 -3
- package/dist/components/index.d.ts +3 -3
- package/dist/components/index.js +1 -1
- package/dist/factories/index.cjs +236 -107
- package/dist/factories/index.cjs.map +1 -1
- package/dist/factories/index.d.cts +9 -3
- package/dist/factories/index.d.ts +9 -3
- package/dist/factories/index.js +3 -3
- package/dist/index-Bc0YCz1A.d.cts +514 -0
- package/dist/index-CRmfSYdj.d.ts +514 -0
- package/dist/{index-Gr8aCPRM.d.cts → index-CUFd71ri.d.cts} +12 -3
- package/dist/{index-BwiRJNIT.d.ts → index-w1oqWl_M.d.ts} +12 -3
- package/dist/index.cjs +1107 -198
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +42 -8
- package/dist/index.d.ts +42 -8
- package/dist/index.js +26 -8
- package/dist/index.js.map +1 -1
- package/dist/systems/index.cjs +799 -1
- package/dist/systems/index.cjs.map +1 -1
- package/dist/systems/index.d.cts +3 -278
- package/dist/systems/index.d.ts +3 -278
- 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-7BPHZWQ6.js.map +0 -1
- package/dist/chunk-7JFSEV7A.js.map +0 -1
- package/dist/chunk-AT5SPSPM.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as AnimationComponent, b as AudioComponent, c as CameraComponentOptions, C as CameraComponent, S as RigidbodyState, g as ColliderState, P as PhysicsComponent, n as EntityType, I as ImageComponent, p as ImageTargetAnchor, o as ImageTarget, L as LightComponent, M as MaterialComponent, z as MeshComponent, B as MeshGeometryComponent, H as ModelComponent, N as Name, O as Object3DRef, V as ScriptEntry, U as ScriptComponent, X as ScriptObjectComponentInput, W as ScriptObjectComponent, Z as Selectable, _ as SelectionTransformState, $ as SpriteComponent, v as InstancedMeshKind, F as MeshGeometryParameters, u as InstancedMeshComponent, s as InstanceSlotComponent,
|
|
2
|
-
import { l as World, g as EnvironmentState, E as Environment, P as ParentId, i as PostprocessingState, h as Postprocessing, T as TransformComponent, O as ObjectManagementSystem } from '../System-
|
|
1
|
+
import { A as AnimationComponent, b as AudioComponent, c as CameraComponentOptions, C as CameraComponent, S as RigidbodyState, g as ColliderState, P as PhysicsComponent, n as EntityType, I as ImageComponent, p as ImageTargetAnchor, o as ImageTarget, L as LightComponent, M as MaterialComponent, z as MeshComponent, B as MeshGeometryComponent, H as ModelComponent, N as Name, O as Object3DRef, V as ScriptEntry, U as ScriptComponent, X as ScriptObjectComponentInput, W as ScriptObjectComponent, Z as Selectable, _ as SelectionTransformState, $ as SpriteComponent, v as InstancedMeshKind, F as MeshGeometryParameters, u as InstancedMeshComponent, s as InstanceSlotComponent, a5 as VideoComponent, a9 as XRRigComponent, a3 as VRTeleportAreaComponent, a7 as XRInteractableComponent } from '../XRRig-Cu-EyliG.cjs';
|
|
2
|
+
import { l as World, g as EnvironmentState, E as Environment, P as ParentId, i as PostprocessingState, h as Postprocessing, T as TransformComponent, O as ObjectManagementSystem } from '../System-vrU46Vuw.cjs';
|
|
3
3
|
import * as THREE from 'three';
|
|
4
4
|
import '@dimforge/rapier3d-compat';
|
|
5
5
|
|
|
@@ -74,8 +74,14 @@ declare function createInstanceSlotComponent(world: World, entityId: number, gro
|
|
|
74
74
|
|
|
75
75
|
declare function createVideoComponent(world: World, entityId: number, ...args: ConstructorParameters<typeof VideoComponent>): VideoComponent;
|
|
76
76
|
|
|
77
|
+
declare function createXRRigComponent(world: World, entityId: number, ...args: ConstructorParameters<typeof XRRigComponent>): XRRigComponent;
|
|
78
|
+
|
|
79
|
+
declare function createVRTeleportAreaComponent(world: World, entityId: number, ...args: ConstructorParameters<typeof VRTeleportAreaComponent>): VRTeleportAreaComponent;
|
|
80
|
+
|
|
81
|
+
declare function createXRInteractableComponent(world: World, entityId: number, ...args: ConstructorParameters<typeof XRInteractableComponent>): XRInteractableComponent;
|
|
82
|
+
|
|
77
83
|
declare function registerDefaultComponentFactories(objectManagementSystem: ObjectManagementSystem): void;
|
|
78
84
|
|
|
79
85
|
declare function registerDefaultFactories(objectManagementSystem: ObjectManagementSystem): void;
|
|
80
86
|
|
|
81
|
-
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, createVideoComponent, registerDefaultComponentFactories, registerDefaultFactories };
|
|
87
|
+
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, createXRRigComponent, registerDefaultComponentFactories, registerDefaultFactories };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as AnimationComponent, b as AudioComponent, c as CameraComponentOptions, C as CameraComponent, S as RigidbodyState, g as ColliderState, P as PhysicsComponent, n as EntityType, I as ImageComponent, p as ImageTargetAnchor, o as ImageTarget, L as LightComponent, M as MaterialComponent, z as MeshComponent, B as MeshGeometryComponent, H as ModelComponent, N as Name, O as Object3DRef, V as ScriptEntry, U as ScriptComponent, X as ScriptObjectComponentInput, W as ScriptObjectComponent, Z as Selectable, _ as SelectionTransformState, $ as SpriteComponent, v as InstancedMeshKind, F as MeshGeometryParameters, u as InstancedMeshComponent, s as InstanceSlotComponent,
|
|
2
|
-
import { l as World, g as EnvironmentState, E as Environment, P as ParentId, i as PostprocessingState, h as Postprocessing, T as TransformComponent, O as ObjectManagementSystem } from '../System-
|
|
1
|
+
import { A as AnimationComponent, b as AudioComponent, c as CameraComponentOptions, C as CameraComponent, S as RigidbodyState, g as ColliderState, P as PhysicsComponent, n as EntityType, I as ImageComponent, p as ImageTargetAnchor, o as ImageTarget, L as LightComponent, M as MaterialComponent, z as MeshComponent, B as MeshGeometryComponent, H as ModelComponent, N as Name, O as Object3DRef, V as ScriptEntry, U as ScriptComponent, X as ScriptObjectComponentInput, W as ScriptObjectComponent, Z as Selectable, _ as SelectionTransformState, $ as SpriteComponent, v as InstancedMeshKind, F as MeshGeometryParameters, u as InstancedMeshComponent, s as InstanceSlotComponent, a5 as VideoComponent, a9 as XRRigComponent, a3 as VRTeleportAreaComponent, a7 as XRInteractableComponent } from '../XRRig-CAmf04NX.js';
|
|
2
|
+
import { l as World, g as EnvironmentState, E as Environment, P as ParentId, i as PostprocessingState, h as Postprocessing, T as TransformComponent, O as ObjectManagementSystem } from '../System-vrU46Vuw.js';
|
|
3
3
|
import * as THREE from 'three';
|
|
4
4
|
import '@dimforge/rapier3d-compat';
|
|
5
5
|
|
|
@@ -74,8 +74,14 @@ declare function createInstanceSlotComponent(world: World, entityId: number, gro
|
|
|
74
74
|
|
|
75
75
|
declare function createVideoComponent(world: World, entityId: number, ...args: ConstructorParameters<typeof VideoComponent>): VideoComponent;
|
|
76
76
|
|
|
77
|
+
declare function createXRRigComponent(world: World, entityId: number, ...args: ConstructorParameters<typeof XRRigComponent>): XRRigComponent;
|
|
78
|
+
|
|
79
|
+
declare function createVRTeleportAreaComponent(world: World, entityId: number, ...args: ConstructorParameters<typeof VRTeleportAreaComponent>): VRTeleportAreaComponent;
|
|
80
|
+
|
|
81
|
+
declare function createXRInteractableComponent(world: World, entityId: number, ...args: ConstructorParameters<typeof XRInteractableComponent>): XRInteractableComponent;
|
|
82
|
+
|
|
77
83
|
declare function registerDefaultComponentFactories(objectManagementSystem: ObjectManagementSystem): void;
|
|
78
84
|
|
|
79
85
|
declare function registerDefaultFactories(objectManagementSystem: ObjectManagementSystem): void;
|
|
80
86
|
|
|
81
|
-
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, createVideoComponent, registerDefaultComponentFactories, registerDefaultFactories };
|
|
87
|
+
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, createXRRigComponent, registerDefaultComponentFactories, registerDefaultFactories };
|
package/dist/factories/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
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, createVideoComponent, registerDefaultComponentFactories, registerDefaultFactories } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
3
|
-
import '../chunk-
|
|
1
|
+
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, createXRRigComponent, registerDefaultComponentFactories, registerDefaultFactories } from '../chunk-JWTRFJBL.js';
|
|
2
|
+
import '../chunk-67WGASUJ.js';
|
|
3
|
+
import '../chunk-U3MDYKPV.js';
|
|
4
4
|
import '../chunk-OY7ZODZP.js';
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
|
6
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,514 @@
|
|
|
1
|
+
import { k as EcsSystem, l as World } from './System-vrU46Vuw.cjs';
|
|
2
|
+
import * as THREE from 'three';
|
|
3
|
+
|
|
4
|
+
declare class AnimationSystem implements EcsSystem {
|
|
5
|
+
private readonly runtimeByEntity;
|
|
6
|
+
private readonly gltfLoader;
|
|
7
|
+
private readonly fbxLoader;
|
|
8
|
+
private loadClipsFromSource;
|
|
9
|
+
private refreshExternalClipSources;
|
|
10
|
+
private release;
|
|
11
|
+
update(world: World, deltaTime: number): void;
|
|
12
|
+
dispose(): void;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
declare class CameraSyncSystem implements EcsSystem {
|
|
16
|
+
private readonly signatures;
|
|
17
|
+
update(world: World): void;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
declare class ObjectVisibilitySystem implements EcsSystem {
|
|
21
|
+
update(world: World): void;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
declare class EnvironmentSyncSystem implements EcsSystem {
|
|
25
|
+
private readonly scene;
|
|
26
|
+
private readonly textureLoader;
|
|
27
|
+
private signature;
|
|
28
|
+
private activeTexture;
|
|
29
|
+
private pendingImageUrl;
|
|
30
|
+
constructor(scene: THREE.Scene);
|
|
31
|
+
private disposeActiveTexture;
|
|
32
|
+
private applySkybox;
|
|
33
|
+
private applyFog;
|
|
34
|
+
update(world: World): void;
|
|
35
|
+
dispose(): void;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
declare class PostprocessingSyncSystem implements EcsSystem {
|
|
39
|
+
private readonly renderer;
|
|
40
|
+
private readonly scene;
|
|
41
|
+
private readonly camera;
|
|
42
|
+
private signature;
|
|
43
|
+
private composer;
|
|
44
|
+
private composerEnabled;
|
|
45
|
+
constructor(renderer: THREE.WebGLRenderer, scene: THREE.Scene, camera: THREE.PerspectiveCamera);
|
|
46
|
+
private setComposerEnabled;
|
|
47
|
+
private disposeComposer;
|
|
48
|
+
private buildComposer;
|
|
49
|
+
update(world: World): void;
|
|
50
|
+
dispose(): void;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
declare class PhysicsSyncSystem implements EcsSystem {
|
|
54
|
+
private readonly rigidBodyHandles;
|
|
55
|
+
private readonly colliderHandles;
|
|
56
|
+
private readonly rigidBodySignatures;
|
|
57
|
+
private readonly colliderSignatures;
|
|
58
|
+
private readonly isEditorMode;
|
|
59
|
+
private rapier;
|
|
60
|
+
private isBootstrappingWorld;
|
|
61
|
+
private accumulator;
|
|
62
|
+
constructor(options?: {
|
|
63
|
+
isEditor?: boolean;
|
|
64
|
+
});
|
|
65
|
+
private ensurePhysicsWorld;
|
|
66
|
+
private removeEntityPhysics;
|
|
67
|
+
update(world: World, deltaTime: number): void;
|
|
68
|
+
dispose(world: World): void;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
declare class LightSyncSystem implements EcsSystem {
|
|
72
|
+
private readonly signatures;
|
|
73
|
+
update(world: World): void;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
declare class MaterialSyncSystem implements EcsSystem {
|
|
77
|
+
private readonly signatures;
|
|
78
|
+
private readonly textureCache;
|
|
79
|
+
update(world: World): void;
|
|
80
|
+
dispose(): void;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
declare class MeshGeometrySystem implements EcsSystem {
|
|
84
|
+
private readonly geometrySignatures;
|
|
85
|
+
private readonly shadowSignatures;
|
|
86
|
+
update(world: World): void;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Maintains the runtime geometry for entities with an {@link InstancedMeshComponent}.
|
|
91
|
+
*
|
|
92
|
+
* - **Primitive kinds** (`cube`, `sphere`, `plane`, `cylinder`, `capsule`): creates a single
|
|
93
|
+
* `THREE.InstancedMesh` on the anchor and writes per-instance matrices every frame.
|
|
94
|
+
* - **Model kind** (`model`): asynchronously loads the GLTF/GLB at `comp.modelPath`, traverses
|
|
95
|
+
* the scene to collect all `THREE.Mesh` nodes, and creates one `THREE.InstancedMesh` per mesh
|
|
96
|
+
* (preserving the mesh's local transform and original materials). All sub-meshes are grouped
|
|
97
|
+
* under a `THREE.Group` stored in `comp.instancedMesh`. Per-instance matrices are composed as
|
|
98
|
+
* `instanceTransform × meshLocalMatrix` every frame.
|
|
99
|
+
*
|
|
100
|
+
* Geometry is rebuilt whenever the signature (`meshKind:parameters:instanceCount` for primitives,
|
|
101
|
+
* `model:path:instanceCount` for model kind) changes.
|
|
102
|
+
*/
|
|
103
|
+
declare class InstancedMeshSystem implements EcsSystem {
|
|
104
|
+
/** Signature tracking for geometry + instance count changes. */
|
|
105
|
+
private readonly geometrySignatures;
|
|
106
|
+
/** Signature being loaded per entity. Maps entityId → geometrySignature in-flight.
|
|
107
|
+
* Prevents re-dispatching a load every frame while comp.instancedMesh is still null. */
|
|
108
|
+
private readonly loadingSignatures;
|
|
109
|
+
/** Per-mesh data for model kind, populated after GLTF load. */
|
|
110
|
+
private readonly modelMeshEntries;
|
|
111
|
+
/**
|
|
112
|
+
* System-internal ref to the Three.js mesh/group most recently placed on
|
|
113
|
+
* the anchor by this system. Used for cleanup on rebuild instead of
|
|
114
|
+
* `comp.instancedMesh`, which can be stale (pointing to a disposed mesh)
|
|
115
|
+
* after an undo/redo restores a history snapshot captured at an earlier
|
|
116
|
+
* geometry configuration. Relying on the stale comp ref would skip removal
|
|
117
|
+
* of the current live mesh → ghost mesh in the scene.
|
|
118
|
+
*/
|
|
119
|
+
private readonly trackedMeshes;
|
|
120
|
+
update(world: World): void;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Shared infrastructure for the script-hosting systems (`ScriptBehaviourSystem`
|
|
125
|
+
* and `ScriptObjectSystem`): module loading, class resolution, data-envelope
|
|
126
|
+
* merge/resolve/serialize. Extracted verbatim from `ScriptBehaviourSystem` so
|
|
127
|
+
* both systems stay behaviourally identical for the parts they share.
|
|
128
|
+
*/
|
|
129
|
+
/** Resolves a script URL to its ES module namespace. */
|
|
130
|
+
type ModuleLoader = (scriptUrl: string) => Promise<Record<string, unknown>>;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Optional context that enables raycast-based onSelect / onDeselect dispatch.
|
|
134
|
+
* When provided, pointer/touch taps on the canvas fire a raycast against the
|
|
135
|
+
* scene. If the hit object (or any ancestor) carries userData.entityId, every
|
|
136
|
+
* Behaviour instance for that entity receives onSelect(); the previously
|
|
137
|
+
* selected entity's instances receive onDeselect().
|
|
138
|
+
*/
|
|
139
|
+
type SelectionContext = {
|
|
140
|
+
camera: THREE.Camera;
|
|
141
|
+
scene: THREE.Scene;
|
|
142
|
+
domElement: HTMLElement;
|
|
143
|
+
};
|
|
144
|
+
declare class ScriptBehaviourSystem implements EcsSystem {
|
|
145
|
+
private instances;
|
|
146
|
+
private loading;
|
|
147
|
+
private readonly moduleLoader;
|
|
148
|
+
private readonly selectionCtx;
|
|
149
|
+
private readonly raycaster;
|
|
150
|
+
private readonly ndcPointer;
|
|
151
|
+
private selectedEntityId;
|
|
152
|
+
private pendingEntityId;
|
|
153
|
+
private pointerDownPos;
|
|
154
|
+
private static readonly CLICK_THRESHOLD;
|
|
155
|
+
constructor(moduleLoader?: ModuleLoader, selectionContext?: SelectionContext);
|
|
156
|
+
/** Walk up the object hierarchy to find the nearest userData.entityId. */
|
|
157
|
+
private resolveEntityId;
|
|
158
|
+
/** Convert client (screen) coordinates to normalised device coordinates. */
|
|
159
|
+
private toNdc;
|
|
160
|
+
/** Fire raycast and queue the result to be dispatched in the next update(). */
|
|
161
|
+
private queueRaycast;
|
|
162
|
+
private onPointerDown;
|
|
163
|
+
private onPointerUp;
|
|
164
|
+
/**
|
|
165
|
+
* Apply a queued selection change.
|
|
166
|
+
* Calls onDeselect() on all behaviours of the previous entity and
|
|
167
|
+
* onSelect() on all behaviours of the newly selected entity.
|
|
168
|
+
*/
|
|
169
|
+
private applySelection;
|
|
170
|
+
update(world: World, deltaTime: number): void;
|
|
171
|
+
dispose(world: World): void;
|
|
172
|
+
private loadBehaviour;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/** Tags the Object3D a script's `build()` returned, so reloads can find/remove it. */
|
|
176
|
+
declare const SCRIPT_OBJECT_ROOT_FLAG = "__scriptObjectRoot";
|
|
177
|
+
/**
|
|
178
|
+
* Builds, ticks, and disposes {@link ScriptObject} scripts. Unlike
|
|
179
|
+
* `ScriptBehaviourSystem`, this runs in the editor AND at runtime — there is NO
|
|
180
|
+
* `isEditorMode` gating anywhere here. A script's `build()` output is attached
|
|
181
|
+
* under the entity's `Object3DRef.object` (so it inherits transform, selection
|
|
182
|
+
* and visibility). `runtimeState` is written on transitions only (never every
|
|
183
|
+
* frame).
|
|
184
|
+
*
|
|
185
|
+
* Construct it and pass it to `World.setup({ systems })`.
|
|
186
|
+
*
|
|
187
|
+
* @category Systems
|
|
188
|
+
*/
|
|
189
|
+
declare class ScriptObjectSystem implements EcsSystem {
|
|
190
|
+
private readonly moduleLoader;
|
|
191
|
+
private instances;
|
|
192
|
+
private loading;
|
|
193
|
+
/** Bumped by invalidate*() so in-flight loads that predate it are discarded. */
|
|
194
|
+
private epoch;
|
|
195
|
+
constructor(moduleLoader?: ModuleLoader);
|
|
196
|
+
update(world: World, deltaTime: number): void;
|
|
197
|
+
private loadScriptObject;
|
|
198
|
+
/** Dispose a record's instance + built subtree. `keepTombstone` leaves an error marker. */
|
|
199
|
+
private teardownRecord;
|
|
200
|
+
private markError;
|
|
201
|
+
/** Dispose all live instances so the next update() reloads with fresh modules. */
|
|
202
|
+
invalidateAll(): void;
|
|
203
|
+
/** Invalidate only the entities whose script matches `scriptUrl`. */
|
|
204
|
+
invalidate(scriptUrl: string): void;
|
|
205
|
+
dispose(world: World): void;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Reconciles `AudioComponent` state with the underlying THREE.js audio objects
|
|
210
|
+
* each frame.
|
|
211
|
+
*
|
|
212
|
+
* **Playback** — drives `play()`, `pause()`, and `stop()` on the THREE.js
|
|
213
|
+
* audio node based on the `isPlaying` / `isPaused` flags set by
|
|
214
|
+
* `AudioComponent.play()`, `.pause()`, and `.stop()`.
|
|
215
|
+
*
|
|
216
|
+
* **Option sync** — detects changes to `loop`, `pitch`, `volume`,
|
|
217
|
+
* `refDistance`, `distanceModel`, and `rolloffFactor` and applies them live.
|
|
218
|
+
* Changes take effect on the next frame, so scripts and inspector edits during
|
|
219
|
+
* runtime are reflected without reloading the scene.
|
|
220
|
+
*
|
|
221
|
+
* Only active in **preview** mode (`isEditor: true` makes every update a
|
|
222
|
+
* no-op so the editor is unaffected).
|
|
223
|
+
*
|
|
224
|
+
* @category Systems
|
|
225
|
+
*/
|
|
226
|
+
declare class AudioSystem implements EcsSystem {
|
|
227
|
+
private readonly isEditor;
|
|
228
|
+
/** THREE.js `isPlaying` state captured at the end of the previous frame. */
|
|
229
|
+
private readonly prevPlayingState;
|
|
230
|
+
/** Snapshot of options applied in the previous frame, for change detection. */
|
|
231
|
+
private readonly prevOptions;
|
|
232
|
+
/** Tracks entities that were stopped due to invisibility. */
|
|
233
|
+
private readonly stoppedDueToInvisibility;
|
|
234
|
+
constructor({ isEditor }?: {
|
|
235
|
+
isEditor?: boolean;
|
|
236
|
+
});
|
|
237
|
+
update(world: World, _deltaTime: number): void;
|
|
238
|
+
/** Apply any changed options from the component to the THREE.js audio node. */
|
|
239
|
+
private _syncOptions;
|
|
240
|
+
dispose(_world: World): void;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Reconciles `VideoComponent` state with the underlying HTML video element
|
|
245
|
+
* and THREE.js mesh/material each frame.
|
|
246
|
+
*
|
|
247
|
+
* **Playback** — drives `play()`, `pause()`, and stop (pause + seek to 0) on
|
|
248
|
+
* the HTML `<video>` element based on the `isPlaying` / `isPaused` flags set
|
|
249
|
+
* by `VideoComponent.play()`, `.pause()`, and `.stop()`.
|
|
250
|
+
*
|
|
251
|
+
* **Option sync** — detects changes to `loop`, `volume`, `width`, `height`,
|
|
252
|
+
* and green-screen shader uniforms (`backgroundColor`, `similarity`,
|
|
253
|
+
* `smoothness`, `spill`) and applies them live without a scene reload.
|
|
254
|
+
*
|
|
255
|
+
* Only active in **preview** mode (`isEditor: true` makes every update a
|
|
256
|
+
* no-op so the editor is unaffected).
|
|
257
|
+
*
|
|
258
|
+
* @category Systems
|
|
259
|
+
*/
|
|
260
|
+
declare class VideoSystem implements EcsSystem {
|
|
261
|
+
private readonly isEditor;
|
|
262
|
+
/** Playback intent captured at the end of the previous frame. */
|
|
263
|
+
private readonly prevIntent;
|
|
264
|
+
/** Snapshot of options applied in the previous frame, for change detection. */
|
|
265
|
+
private readonly prevOptions;
|
|
266
|
+
/** Tracks entities that were manually paused due to invisibility. */
|
|
267
|
+
private readonly pausedDueToInvisibility;
|
|
268
|
+
constructor({ isEditor }?: {
|
|
269
|
+
isEditor?: boolean;
|
|
270
|
+
});
|
|
271
|
+
update(world: World, _deltaTime: number): void;
|
|
272
|
+
/** Apply any changed options from the component to the video element and mesh. */
|
|
273
|
+
private _syncOptions;
|
|
274
|
+
dispose(_world: World): void;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Shared vocabulary for the WebXR layer.
|
|
279
|
+
*
|
|
280
|
+
* The single most important design constraint here: **the three target
|
|
281
|
+
* platforms expose fundamentally different input models**, and a runtime that
|
|
282
|
+
* hard-codes one of them silently excludes the others.
|
|
283
|
+
*
|
|
284
|
+
* - Meta Quest / Pico → motion controllers (trigger, grip, thumbstick) and,
|
|
285
|
+
* optionally, tracked hands.
|
|
286
|
+
* - Android XR → tracked hands are the PRIMARY input.
|
|
287
|
+
* - Apple Vision Pro → no controllers at all. Input arrives as
|
|
288
|
+
* `transient-pointer` sources that exist ONLY for the duration of a
|
|
289
|
+
* gaze-and-pinch, appearing on pinch-start and disappearing on release.
|
|
290
|
+
*
|
|
291
|
+
* {@link XrInputState} normalizes all three into one shape so gameplay code and
|
|
292
|
+
* Behaviours are written once. Anything platform-specific is expressed as a
|
|
293
|
+
* capability (`kind`, `hasAxes`) rather than a branch on device name — we never
|
|
294
|
+
* sniff the user agent, per the WebXR guidance from every vendor.
|
|
295
|
+
*/
|
|
296
|
+
/** Which hand an input source belongs to (`none` for gaze / single-source devices). */
|
|
297
|
+
type XrHandedness = "left" | "right" | "none";
|
|
298
|
+
/**
|
|
299
|
+
* How an input source is physically driven.
|
|
300
|
+
*
|
|
301
|
+
* `transient-pointer` is the Vision Pro case: the source is EPHEMERAL — it is
|
|
302
|
+
* created when the user pinches and destroyed when they release, so it must
|
|
303
|
+
* never be cached across frames by identity.
|
|
304
|
+
*/
|
|
305
|
+
type XrInputKind = "controller" | "hand" | "transient-pointer" | "gaze";
|
|
306
|
+
/**
|
|
307
|
+
* One frame of normalized input for a single source.
|
|
308
|
+
*
|
|
309
|
+
* Boolean actions follow the same pending→latched contract as the desktop
|
|
310
|
+
* `InputSystem`: `select` is the held state, while `selectStart` / `selectEnd`
|
|
311
|
+
* are true for exactly one frame. This lets Behaviours poll (`if (select)`) or
|
|
312
|
+
* edge-detect (`if (selectStart)`) without subscribing to events.
|
|
313
|
+
*/
|
|
314
|
+
type XrInputState = {
|
|
315
|
+
handedness: XrHandedness;
|
|
316
|
+
kind: XrInputKind;
|
|
317
|
+
/** False once the source disconnects (a released pinch on Vision Pro). */
|
|
318
|
+
connected: boolean;
|
|
319
|
+
/** Pointing ray in WORLD space, from the source's `targetRaySpace`. */
|
|
320
|
+
rayOrigin: THREE.Vector3;
|
|
321
|
+
rayDirection: THREE.Vector3;
|
|
322
|
+
/** Physical grip pose. Null for gaze and transient-pointer, which have no grip. */
|
|
323
|
+
gripPosition: THREE.Vector3 | null;
|
|
324
|
+
gripQuaternion: THREE.Quaternion | null;
|
|
325
|
+
/** Primary action: controller trigger, hand pinch, or Vision Pro gaze-pinch. */
|
|
326
|
+
select: boolean;
|
|
327
|
+
selectStart: boolean;
|
|
328
|
+
selectEnd: boolean;
|
|
329
|
+
/** Secondary action: controller grip squeeze. Never fires for hands/gaze. */
|
|
330
|
+
squeeze: boolean;
|
|
331
|
+
squeezeStart: boolean;
|
|
332
|
+
squeezeEnd: boolean;
|
|
333
|
+
/** Thumbstick / trackpad axes in [-1, 1]. Empty when {@link hasAxes} is false. */
|
|
334
|
+
axes: number[];
|
|
335
|
+
/** True only for sources with a physical stick — gates stick-driven locomotion. */
|
|
336
|
+
hasAxes: boolean;
|
|
337
|
+
/** Raw gamepad button pressed-states, when the source exposes a gamepad. */
|
|
338
|
+
buttons: boolean[];
|
|
339
|
+
};
|
|
340
|
+
/**
|
|
341
|
+
* What the ACTIVE session actually granted us.
|
|
342
|
+
*
|
|
343
|
+
* Always derived from `XRSession.enabledFeatures` — never from the device name.
|
|
344
|
+
* A feature being requested is not a promise it was granted, and support varies
|
|
345
|
+
* sharply per platform (e.g. Vision Pro grants no `immersive-ar` at all today).
|
|
346
|
+
*/
|
|
347
|
+
type XrCapabilities = {
|
|
348
|
+
/** The session's mode. `immersive-ar` implies passthrough / mixed reality. */
|
|
349
|
+
mode: "immersive-vr" | "immersive-ar" | "inline";
|
|
350
|
+
/** Tracked-hand joint data is available. */
|
|
351
|
+
handTracking: boolean;
|
|
352
|
+
/** Real-world plane detection (incubating; effectively Quest-only today). */
|
|
353
|
+
planeDetection: boolean;
|
|
354
|
+
/** Real-world mesh detection (draft spec; Quest-only today). */
|
|
355
|
+
meshDetection: boolean;
|
|
356
|
+
/** Per-frame depth buffer (Android XR stereo, Quest experimental). */
|
|
357
|
+
depthSensing: boolean;
|
|
358
|
+
/** Spatial anchors. */
|
|
359
|
+
anchors: boolean;
|
|
360
|
+
/** Ray-against-real-world hit testing. */
|
|
361
|
+
hitTest: boolean;
|
|
362
|
+
/** Everything the UA reported, verbatim, for diagnostics. */
|
|
363
|
+
enabledFeatures: string[];
|
|
364
|
+
};
|
|
365
|
+
/** Capabilities for "no session running" — every feature off. */
|
|
366
|
+
declare const NO_XR_CAPABILITIES: XrCapabilities;
|
|
367
|
+
/**
|
|
368
|
+
* Read granted features off a live session.
|
|
369
|
+
*
|
|
370
|
+
* `enabledFeatures` is optional in the spec and missing on some UAs; when it is
|
|
371
|
+
* absent we report nothing as granted rather than optimistically assuming
|
|
372
|
+
* support, so callers degrade instead of calling an API that will throw.
|
|
373
|
+
*/
|
|
374
|
+
declare function readXrCapabilities(session: XRSession | null, mode?: XrCapabilities["mode"]): XrCapabilities;
|
|
375
|
+
|
|
376
|
+
declare class XRInputSystem implements EcsSystem {
|
|
377
|
+
private readonly records;
|
|
378
|
+
private session;
|
|
379
|
+
private readonly onSelectStart;
|
|
380
|
+
private readonly onSelectEnd;
|
|
381
|
+
private readonly onSqueezeStart;
|
|
382
|
+
private readonly onSqueezeEnd;
|
|
383
|
+
private mark;
|
|
384
|
+
private ensureRecord;
|
|
385
|
+
/** Bind to a session. Called by {@link XRSessionSystem} on session start. */
|
|
386
|
+
attachSession(session: XRSession): void;
|
|
387
|
+
/** Unbind and drop all per-source state. */
|
|
388
|
+
detachSession(): void;
|
|
389
|
+
update(world: World): void;
|
|
390
|
+
/** Every input source active this frame. */
|
|
391
|
+
getInputs(): XrInputState[];
|
|
392
|
+
/** The first source for a hand, or null. Prefer this for hand-specific logic. */
|
|
393
|
+
getInput(handedness: XrHandedness): XrInputState | null;
|
|
394
|
+
/** True while ANY source is selecting — the portable "is the user acting" check. */
|
|
395
|
+
isSelecting(): boolean;
|
|
396
|
+
dispose(): void;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
declare class XRInteractionSystem implements EcsSystem {
|
|
400
|
+
private readonly inputSystem;
|
|
401
|
+
private readonly raycaster;
|
|
402
|
+
/** Which entity each source is holding. Keyed by source state identity. */
|
|
403
|
+
private readonly grabs;
|
|
404
|
+
private hoveredEntityId;
|
|
405
|
+
constructor(inputSystem: XRInputSystem);
|
|
406
|
+
update(world: World): void;
|
|
407
|
+
private collectInteractables;
|
|
408
|
+
/** Entity id of the nearest pointable hit along this source's ray, or null. */
|
|
409
|
+
private raycast;
|
|
410
|
+
private grab;
|
|
411
|
+
private moveHeld;
|
|
412
|
+
private release;
|
|
413
|
+
private releaseAll;
|
|
414
|
+
/**
|
|
415
|
+
* Where the "hand" is for this source. Controllers and tracked hands report a
|
|
416
|
+
* grip pose; gaze and transient-pointer sources have none, so we hold the
|
|
417
|
+
* object a fixed distance along the ray instead.
|
|
418
|
+
*/
|
|
419
|
+
private handPosition;
|
|
420
|
+
private dispatch;
|
|
421
|
+
/** Entity currently under a pointer this frame, or null. */
|
|
422
|
+
getHoveredEntityId(): number | null;
|
|
423
|
+
/** True when any source is holding something. */
|
|
424
|
+
isGrabbing(): boolean;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
declare class XRLocomotionSystem implements EcsSystem {
|
|
428
|
+
private readonly inputSystem;
|
|
429
|
+
private readonly raycaster;
|
|
430
|
+
/** Per-source latch so one stick push yields exactly one snap turn. */
|
|
431
|
+
private readonly turnLatched;
|
|
432
|
+
/** Where the pointer currently lands, for the consumer to draw a marker. */
|
|
433
|
+
private teleportPoint;
|
|
434
|
+
constructor(inputSystem: XRInputSystem);
|
|
435
|
+
update(world: World, deltaTime: number): void;
|
|
436
|
+
/**
|
|
437
|
+
* Snap turning, not smooth turning — rotating the view continuously is the
|
|
438
|
+
* single biggest cause of VR nausea, so the comfort-safe option is the one
|
|
439
|
+
* wired to the stick.
|
|
440
|
+
*/
|
|
441
|
+
private applySnapTurn;
|
|
442
|
+
private applySmoothMove;
|
|
443
|
+
private applyTeleport;
|
|
444
|
+
private collectTeleportTargets;
|
|
445
|
+
/**
|
|
446
|
+
* Where the teleport pointer currently lands this frame, or null.
|
|
447
|
+
* Consumers use this to render an aim marker.
|
|
448
|
+
*/
|
|
449
|
+
getTeleportPoint(): THREE.Vector3 | null;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* Owns the immersive-session lifecycle and fans XR events out to Behaviours.
|
|
454
|
+
*
|
|
455
|
+
* Detects session start/end by polling `renderer.xr.isPresenting` rather than
|
|
456
|
+
* binding to `sessionstart`/`sessionend`: the session may already be running
|
|
457
|
+
* before this system is registered (the consumer owns the entry button), and
|
|
458
|
+
* polling a boolean makes the system correct regardless of construction order.
|
|
459
|
+
*
|
|
460
|
+
* Hook dispatch mirrors `ImageTargetAnchorSystem`'s AR precedent — walk live
|
|
461
|
+
* `ScriptComponent.scriptInstances` and call the public no-op hook — so XR and
|
|
462
|
+
* AR extend `Behaviour` the same way.
|
|
463
|
+
*/
|
|
464
|
+
declare class XRSessionSystem implements EcsSystem {
|
|
465
|
+
private presenting;
|
|
466
|
+
private capabilities;
|
|
467
|
+
private readonly inputSystem;
|
|
468
|
+
constructor(inputSystem?: XRInputSystem);
|
|
469
|
+
update(world: World): void;
|
|
470
|
+
private handleSessionStart;
|
|
471
|
+
private handleSessionEnd;
|
|
472
|
+
/**
|
|
473
|
+
* Relay this frame's one-frame select edges. Polling the latched state (rather
|
|
474
|
+
* than dispatching from the DOM event) keeps hook delivery on the ECS tick, so
|
|
475
|
+
* a Behaviour's `onSelectStart` always observes the same world state its
|
|
476
|
+
* `onUpdate` would.
|
|
477
|
+
*/
|
|
478
|
+
private dispatchInputEdges;
|
|
479
|
+
private forEachBehaviour;
|
|
480
|
+
/** What the active session granted. `NO_XR_CAPABILITIES` when not presenting. */
|
|
481
|
+
getCapabilities(): XrCapabilities;
|
|
482
|
+
/** True while an immersive session is presenting. */
|
|
483
|
+
isPresenting(): boolean;
|
|
484
|
+
/** Convenience passthrough so consumers need only hold this system. */
|
|
485
|
+
getInputs(): XrInputState[];
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
declare class VRTeleportAreaSystem implements EcsSystem {
|
|
489
|
+
private readonly signatures;
|
|
490
|
+
update(world: World): void;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
declare class XRControllerVisualSystem implements EcsSystem {
|
|
494
|
+
private readonly controllerModelFactory;
|
|
495
|
+
private readonly handModelFactory;
|
|
496
|
+
private readonly group;
|
|
497
|
+
private built;
|
|
498
|
+
private attachedTo;
|
|
499
|
+
/** Index → whether we've already attached visuals for that slot. */
|
|
500
|
+
private readonly ready;
|
|
501
|
+
/** How many controller slots to wire. Two covers every current headset. */
|
|
502
|
+
private readonly slots;
|
|
503
|
+
constructor(slots?: number);
|
|
504
|
+
update(world: World): void;
|
|
505
|
+
/**
|
|
506
|
+
* Parent the visuals to the XR rig when there is one, so locomotion moves the
|
|
507
|
+
* hands with the player. Falls back to the scene root.
|
|
508
|
+
*/
|
|
509
|
+
private ensureAttached;
|
|
510
|
+
private createRay;
|
|
511
|
+
dispose(): void;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
export { AnimationSystem as A, CameraSyncSystem as C, EnvironmentSyncSystem as E, InstancedMeshSystem as I, LightSyncSystem as L, MaterialSyncSystem as M, NO_XR_CAPABILITIES as N, ObjectVisibilitySystem as O, PhysicsSyncSystem as P, SCRIPT_OBJECT_ROOT_FLAG as S, VRTeleportAreaSystem as V, type XrCapabilities as X, type XrInputState as a, AudioSystem as b, MeshGeometrySystem as c, type ModuleLoader as d, PostprocessingSyncSystem as e, ScriptBehaviourSystem as f, ScriptObjectSystem as g, type SelectionContext as h, VideoSystem as i, XRControllerVisualSystem as j, XRInputSystem as k, XRInteractionSystem as l, XRLocomotionSystem as m, XRSessionSystem as n, type XrHandedness as o, type XrInputKind as p, readXrCapabilities as r };
|