@relu-interactives/spatial-ecs 0.2.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/README.md +125 -0
- package/dist/System-rXAmagXA.d.cts +659 -0
- package/dist/System-rXAmagXA.d.ts +659 -0
- package/dist/Video-CDemv74U.d.cts +1261 -0
- package/dist/Video-ChKV1UI7.d.ts +1261 -0
- package/dist/assets/draco/draco_decoder.js +34 -0
- package/dist/assets/draco/draco_decoder.wasm +0 -0
- package/dist/assets/draco/draco_wasm_wrapper.js +117 -0
- package/dist/chunk-AYEF3X2P.js +223 -0
- package/dist/chunk-AYEF3X2P.js.map +1 -0
- package/dist/chunk-MAWBTMCG.js +1722 -0
- package/dist/chunk-MAWBTMCG.js.map +1 -0
- package/dist/chunk-NFDTIYR4.js +248 -0
- package/dist/chunk-NFDTIYR4.js.map +1 -0
- package/dist/chunk-OY7ZODZP.js +16 -0
- package/dist/chunk-OY7ZODZP.js.map +1 -0
- package/dist/chunk-P2YDX5DB.js +3304 -0
- package/dist/chunk-P2YDX5DB.js.map +1 -0
- package/dist/chunk-QHILSPT4.js +3 -0
- package/dist/chunk-QHILSPT4.js.map +1 -0
- package/dist/chunk-XWIEEJ7Z.js +1315 -0
- package/dist/chunk-XWIEEJ7Z.js.map +1 -0
- package/dist/components/index.cjs +1745 -0
- package/dist/components/index.cjs.map +1 -0
- package/dist/components/index.d.cts +4 -0
- package/dist/components/index.d.ts +4 -0
- package/dist/components/index.js +4 -0
- package/dist/components/index.js.map +1 -0
- package/dist/docs/api/Behaviour/classes/Behaviour.md +554 -0
- package/dist/docs/api/Behaviour/index.md +15 -0
- package/dist/docs/api/Component/classes/Component.md +57 -0
- package/dist/docs/api/Component/index.md +15 -0
- package/dist/docs/api/components/classes/AnimationComponent.md +318 -0
- package/dist/docs/api/components/classes/AudioComponent.md +114 -0
- package/dist/docs/api/components/classes/CameraComponent.md +59 -0
- package/dist/docs/api/components/classes/EntityType.md +48 -0
- package/dist/docs/api/components/classes/Environment.md +47 -0
- package/dist/docs/api/components/classes/ImageComponent.md +57 -0
- package/dist/docs/api/components/classes/ImageTarget.md +60 -0
- package/dist/docs/api/components/classes/ImageTargetAnchor.md +48 -0
- package/dist/docs/api/components/classes/LightComponent.md +70 -0
- package/dist/docs/api/components/classes/MaterialComponent.md +181 -0
- package/dist/docs/api/components/classes/MeshComponent.md +48 -0
- package/dist/docs/api/components/classes/MeshGeometryComponent.md +64 -0
- package/dist/docs/api/components/classes/ModelComponent.md +49 -0
- package/dist/docs/api/components/classes/Name.md +46 -0
- package/dist/docs/api/components/classes/Object3DRef.md +54 -0
- package/dist/docs/api/components/classes/ParentId.md +47 -0
- package/dist/docs/api/components/classes/PhysicsComponent.md +82 -0
- package/dist/docs/api/components/classes/Postprocessing.md +49 -0
- package/dist/docs/api/components/classes/ScriptComponent.md +54 -0
- package/dist/docs/api/components/classes/Selectable.md +46 -0
- package/dist/docs/api/components/classes/SelectionTransformState.md +54 -0
- package/dist/docs/api/components/classes/SpriteComponent.md +55 -0
- package/dist/docs/api/components/classes/TransformComponent.md +197 -0
- package/dist/docs/api/components/classes/VideoComponent.md +123 -0
- package/dist/docs/api/components/functions/normalizePhysicsState.md +23 -0
- package/dist/docs/api/components/index.md +94 -0
- package/dist/docs/api/components/type-aliases/AnimationComponentOptions.md +42 -0
- package/dist/docs/api/components/type-aliases/CameraComponentOptions.md +45 -0
- package/dist/docs/api/components/type-aliases/CameraProjection.md +15 -0
- package/dist/docs/api/components/type-aliases/CameraRuntimeType.md +15 -0
- package/dist/docs/api/components/type-aliases/ColliderShape.md +15 -0
- package/dist/docs/api/components/type-aliases/ColliderState.md +62 -0
- package/dist/docs/api/components/type-aliases/CubeMeshParameters.md +27 -0
- package/dist/docs/api/components/type-aliases/EditableMeshObjectKind.md +15 -0
- package/dist/docs/api/components/type-aliases/EnvironmentFogState.md +37 -0
- package/dist/docs/api/components/type-aliases/EnvironmentFogType.md +15 -0
- package/dist/docs/api/components/type-aliases/EnvironmentGradientEffect.md +15 -0
- package/dist/docs/api/components/type-aliases/EnvironmentSkyboxState.md +34 -0
- package/dist/docs/api/components/type-aliases/EnvironmentSkyboxType.md +15 -0
- package/dist/docs/api/components/type-aliases/EnvironmentState.md +29 -0
- package/dist/docs/api/components/type-aliases/ImageTargetAnchorOptions.md +25 -0
- package/dist/docs/api/components/type-aliases/ImageTargetReference.md +33 -0
- package/dist/docs/api/components/type-aliases/LightValueState.md +41 -0
- package/dist/docs/api/components/type-aliases/MaterialTypeValue.md +15 -0
- package/dist/docs/api/components/type-aliases/MaterialValueState.md +75 -0
- package/dist/docs/api/components/type-aliases/MeshGeometryParameters.md +13 -0
- package/dist/docs/api/components/type-aliases/MeshGeometryParametersByKind.md +33 -0
- package/dist/docs/api/components/type-aliases/PhysicsState.md +25 -0
- package/dist/docs/api/components/type-aliases/PlaneMeshParameters.md +25 -0
- package/dist/docs/api/components/type-aliases/PostprocessingState.md +164 -0
- package/dist/docs/api/components/type-aliases/RadiusHeightMeshParameters.md +25 -0
- package/dist/docs/api/components/type-aliases/RadiusMeshParameters.md +23 -0
- package/dist/docs/api/components/type-aliases/RigidbodyState.md +53 -0
- package/dist/docs/api/components/type-aliases/RigidbodyType.md +19 -0
- package/dist/docs/api/components/type-aliases/ScriptEntry.md +38 -0
- package/dist/docs/api/components/type-aliases/TextureFilteringValue.md +15 -0
- package/dist/docs/api/components/type-aliases/TransformData.md +27 -0
- package/dist/docs/api/components/type-aliases/TransformModeValue.md +15 -0
- package/dist/docs/api/components/type-aliases/TransformSpaceValue.md +15 -0
- package/dist/docs/api/components/type-aliases/Vec3.md +27 -0
- package/dist/docs/api/components/variables/DEFAULT_COLLIDER_STATE.md +13 -0
- package/dist/docs/api/components/variables/DEFAULT_ENVIRONMENT_STATE.md +13 -0
- package/dist/docs/api/components/variables/DEFAULT_MESH_GEOMETRY_PARAMETERS.md +13 -0
- package/dist/docs/api/components/variables/DEFAULT_PHYSICS_STATE.md +13 -0
- package/dist/docs/api/components/variables/DEFAULT_POSTPROCESSING_STATE.md +13 -0
- package/dist/docs/api/components/variables/DEFAULT_RIGIDBODY_STATE.md +13 -0
- package/dist/docs/api/index/classes/AnimationStateMachine.md +201 -0
- package/dist/docs/api/index/classes/AnimationStateManager.md +253 -0
- package/dist/docs/api/index/classes/AnimationSystem.md +68 -0
- package/dist/docs/api/index/classes/AudioSystem.md +98 -0
- package/dist/docs/api/index/classes/CameraSyncSystem.md +49 -0
- package/dist/docs/api/index/classes/EnvironmentSyncSystem.md +75 -0
- package/dist/docs/api/index/classes/InputSystem.md +449 -0
- package/dist/docs/api/index/classes/LightSyncSystem.md +49 -0
- package/dist/docs/api/index/classes/MaterialSyncSystem.md +67 -0
- package/dist/docs/api/index/classes/MeshGeometrySystem.md +49 -0
- package/dist/docs/api/index/classes/ObjectManagementSystem.md +298 -0
- package/dist/docs/api/index/classes/ObjectVisibilitySystem.md +49 -0
- package/dist/docs/api/index/classes/PhysicsSyncSystem.md +83 -0
- package/dist/docs/api/index/classes/PostprocessingSyncSystem.md +80 -0
- package/dist/docs/api/index/classes/RenderSystem.md +64 -0
- package/dist/docs/api/index/classes/ScriptBehaviourSystem.md +83 -0
- package/dist/docs/api/index/classes/TransformSyncSystem.md +49 -0
- package/dist/docs/api/index/classes/VideoSystem.md +97 -0
- package/dist/docs/api/index/classes/World.md +1405 -0
- package/dist/docs/api/index/functions/createAnimationComponent.md +28 -0
- package/dist/docs/api/index/functions/createAudioComponent.md +32 -0
- package/dist/docs/api/index/functions/createCameraComponent.md +28 -0
- package/dist/docs/api/index/functions/createEntityTypeComponent.md +28 -0
- package/dist/docs/api/index/functions/createEnvironmentComponent.md +28 -0
- package/dist/docs/api/index/functions/createImageComponent.md +28 -0
- package/dist/docs/api/index/functions/createImageTargetAnchorComponent.md +28 -0
- package/dist/docs/api/index/functions/createImageTargetComponent.md +28 -0
- package/dist/docs/api/index/functions/createLightComponent.md +28 -0
- package/dist/docs/api/index/functions/createMaterialComponent.md +28 -0
- package/dist/docs/api/index/functions/createMeshComponent.md +28 -0
- package/dist/docs/api/index/functions/createMeshGeometryComponent.md +28 -0
- package/dist/docs/api/index/functions/createModelComponent.md +28 -0
- package/dist/docs/api/index/functions/createNameComponent.md +28 -0
- package/dist/docs/api/index/functions/createObject3DRefComponent.md +28 -0
- package/dist/docs/api/index/functions/createParentIdComponent.md +28 -0
- package/dist/docs/api/index/functions/createPhysicsComponent.md +30 -0
- package/dist/docs/api/index/functions/createPostprocessingComponent.md +28 -0
- package/dist/docs/api/index/functions/createScriptComponent.md +28 -0
- package/dist/docs/api/index/functions/createSelectableComponent.md +28 -0
- package/dist/docs/api/index/functions/createSelectionTransformStateComponent.md +28 -0
- package/dist/docs/api/index/functions/createSpriteComponent.md +28 -0
- package/dist/docs/api/index/functions/createTransformComponent.md +28 -0
- package/dist/docs/api/index/functions/createVideoComponent.md +28 -0
- package/dist/docs/api/index/functions/hydrateWorldFromSnapshot.md +28 -0
- package/dist/docs/api/index/functions/hydrateWorldFromSnapshotDetailed.md +28 -0
- package/dist/docs/api/index/functions/registerDefaultComponentFactories.md +23 -0
- package/dist/docs/api/index/functions/registerDefaultFactories.md +23 -0
- package/dist/docs/api/index/index.md +249 -0
- package/dist/docs/api/index/interfaces/EcsSystem.md +50 -0
- package/dist/docs/api/index/interfaces/StateMachine.md +26 -0
- package/dist/docs/api/index/type-aliases/AnimationStateCallbacks.md +25 -0
- package/dist/docs/api/index/type-aliases/ComponentFactory.md +25 -0
- package/dist/docs/api/index/type-aliases/EcsComponentFactoryKind.md +37 -0
- package/dist/docs/api/index/type-aliases/EcsWorldComponentSnapshot.md +26 -0
- package/dist/docs/api/index/type-aliases/EcsWorldStateSnapshotLike.md +25 -0
- package/dist/docs/api/index/type-aliases/HydrateWorldFromSnapshotResult.md +23 -0
- package/dist/docs/api/index/type-aliases/KeyboardKey.md +13 -0
- package/dist/docs/api/index/type-aliases/MouseButton.md +13 -0
- package/dist/docs/api/index/type-aliases/SelectionContext.md +31 -0
- package/dist/docs/api/index/variables/HYDRATABLE_ENTITY_KINDS.md +13 -0
- package/dist/docs/api/index/variables/KeyboardKeys.md +195 -0
- package/dist/docs/api/index.md +15 -0
- package/dist/docs/api/typedoc-sidebar.json +1 -0
- package/dist/docs/api/types/index.md +34 -0
- package/dist/docs/api/types/type-aliases/AssetInput.md +23 -0
- package/dist/docs/api/types/type-aliases/CheckboxInput.md +13 -0
- package/dist/docs/api/types/type-aliases/ColorInput.md +13 -0
- package/dist/docs/api/types/type-aliases/ComponentInput.md +52 -0
- package/dist/docs/api/types/type-aliases/ComponentKind.md +37 -0
- package/dist/docs/api/types/type-aliases/DropdownInput.md +23 -0
- package/dist/docs/api/types/type-aliases/DropdownOption.md +23 -0
- package/dist/docs/api/types/type-aliases/EcsEntityEditorKind.md +15 -0
- package/dist/docs/api/types/type-aliases/EcsEntityKind.md +35 -0
- package/dist/docs/api/types/type-aliases/EntityId.md +16 -0
- package/dist/docs/api/types/type-aliases/EntityInput.md +23 -0
- package/dist/docs/api/types/type-aliases/FloatInput.md +13 -0
- package/dist/docs/api/types/type-aliases/IntersectionResult.md +29 -0
- package/dist/docs/api/types/type-aliases/ParentLookup.md +26 -0
- package/dist/docs/api/types/type-aliases/SelectionListener.md +25 -0
- package/dist/docs/api/types/type-aliases/SliderInput.md +27 -0
- package/dist/docs/api/types/type-aliases/TextInput.md +13 -0
- package/dist/docs/api/types/type-aliases/ToggleInput.md +13 -0
- package/dist/docs/api/types/type-aliases/Vec3.md +23 -0
- package/dist/docs/api/types/type-aliases/Vector2Input.md +23 -0
- package/dist/docs/api/types/type-aliases/Vector3Input.md +25 -0
- package/dist/docs/api/types/type-aliases/WorldEntityView.md +17 -0
- package/dist/docs/guide/accessing-components.md +399 -0
- package/dist/docs/guide/authoring-a-behaviour.md +166 -0
- package/dist/docs/guide/behaviour-lifecycle.md +43 -0
- package/dist/docs/guide/component-catalog.md +59 -0
- package/dist/docs/guide/components/_sidebar.json +78 -0
- package/dist/docs/guide/components/animation.md +171 -0
- package/dist/docs/guide/components/audio.md +181 -0
- package/dist/docs/guide/components/camera.md +179 -0
- package/dist/docs/guide/components/entity-type.md +141 -0
- package/dist/docs/guide/components/image-target-anchor.md +103 -0
- package/dist/docs/guide/components/image-target.md +122 -0
- package/dist/docs/guide/components/image.md +146 -0
- package/dist/docs/guide/components/light.md +157 -0
- package/dist/docs/guide/components/material.md +161 -0
- package/dist/docs/guide/components/mesh-geometry.md +153 -0
- package/dist/docs/guide/components/mesh.md +151 -0
- package/dist/docs/guide/components/model.md +96 -0
- package/dist/docs/guide/components/name.md +121 -0
- package/dist/docs/guide/components/object3d-ref.md +115 -0
- package/dist/docs/guide/components/parent-id.md +108 -0
- package/dist/docs/guide/components/physics.md +163 -0
- package/dist/docs/guide/components/script.md +142 -0
- package/dist/docs/guide/components/sprite.md +155 -0
- package/dist/docs/guide/components/transform.md +155 -0
- package/dist/docs/guide/components/video.md +153 -0
- package/dist/docs/guide/concepts.md +34 -0
- package/dist/docs/guide/getting-started/creating-objects.md +50 -0
- package/dist/docs/guide/getting-started/editing-objects.md +62 -0
- package/dist/docs/guide/getting-started/editor/assets-browser.md +55 -0
- package/dist/docs/guide/getting-started/editor/hierarchy.md +47 -0
- package/dist/docs/guide/getting-started/editor/index.md +16 -0
- package/dist/docs/guide/getting-started/editor/inspector.md +36 -0
- package/dist/docs/guide/getting-started/editor/modules.md +35 -0
- package/dist/docs/guide/getting-started/editor/scene-inspector.md +64 -0
- package/dist/docs/guide/getting-started/editor/toolbar.md +39 -0
- package/dist/docs/guide/getting-started/editor/viewport.md +43 -0
- package/dist/docs/guide/getting-started/first-launch.md +17 -0
- package/dist/docs/guide/getting-started/index.md +37 -0
- package/dist/docs/guide/getting-started/installation.md +59 -0
- package/dist/docs/guide/getting-started/preview-and-test.md +55 -0
- package/dist/docs/guide/getting-started/project-types/3d.md +30 -0
- package/dist/docs/guide/getting-started/project-types/ar.md +6 -0
- package/dist/docs/guide/getting-started/project-types/face-tracking.md +6 -0
- package/dist/docs/guide/getting-started/project-types/image-tracking.md +42 -0
- package/dist/docs/guide/getting-started/project-types/index.md +25 -0
- package/dist/docs/guide/getting-started/project-types/vr.md +6 -0
- package/dist/docs/guide/getting-started/projects.md +53 -0
- package/dist/docs/guide/getting-started/shortcuts.md +43 -0
- package/dist/docs/guide/inspector-data-binding.md +367 -0
- package/dist/docs/guide/reading-input.md +202 -0
- package/dist/docs/guide/scene/environment.md +101 -0
- package/dist/docs/guide/scene/index.md +36 -0
- package/dist/docs/guide/scene/postprocessing.md +108 -0
- package/dist/docs/guide/spawning/ambient-light.md +28 -0
- package/dist/docs/guide/spawning/area-light.md +32 -0
- package/dist/docs/guide/spawning/audio.md +42 -0
- package/dist/docs/guide/spawning/camera.md +50 -0
- package/dist/docs/guide/spawning/capsule.md +29 -0
- package/dist/docs/guide/spawning/cube.md +31 -0
- package/dist/docs/guide/spawning/cylinder.md +29 -0
- package/dist/docs/guide/spawning/directional-light.md +32 -0
- package/dist/docs/guide/spawning/empty.md +31 -0
- package/dist/docs/guide/spawning/image-target.md +48 -0
- package/dist/docs/guide/spawning/image.md +33 -0
- package/dist/docs/guide/spawning/index.md +79 -0
- package/dist/docs/guide/spawning/model.md +31 -0
- package/dist/docs/guide/spawning/plane.md +31 -0
- package/dist/docs/guide/spawning/point-light.md +32 -0
- package/dist/docs/guide/spawning/sphere.md +29 -0
- package/dist/docs/guide/spawning/spot-light.md +32 -0
- package/dist/docs/guide/spawning/sprite.md +31 -0
- package/dist/docs/guide/spawning/video.md +53 -0
- package/dist/docs/guide/system-overview.md +73 -0
- package/dist/docs/guide/systems/_sidebar.json +66 -0
- package/dist/docs/guide/systems/animation-system.md +32 -0
- package/dist/docs/guide/systems/audio-system.md +28 -0
- package/dist/docs/guide/systems/camera-sync-system.md +31 -0
- package/dist/docs/guide/systems/environment-sync-system.md +31 -0
- package/dist/docs/guide/systems/input-system.md +217 -0
- package/dist/docs/guide/systems/light-sync-system.md +29 -0
- package/dist/docs/guide/systems/material-sync-system.md +32 -0
- package/dist/docs/guide/systems/mesh-geometry-system.md +40 -0
- package/dist/docs/guide/systems/object-management-system.md +38 -0
- package/dist/docs/guide/systems/object-visibility-system.md +26 -0
- package/dist/docs/guide/systems/physics-sync-system.md +56 -0
- package/dist/docs/guide/systems/postprocessing-sync-system.md +43 -0
- package/dist/docs/guide/systems/render-system.md +22 -0
- package/dist/docs/guide/systems/script-behaviour-system.md +59 -0
- package/dist/docs/guide/systems/transform-sync-system.md +29 -0
- package/dist/docs/guide/systems/video-system.md +30 -0
- package/dist/docs/guide/world-api.md +405 -0
- package/dist/factories/index.cjs +3077 -0
- package/dist/factories/index.cjs.map +1 -0
- package/dist/factories/index.d.cts +69 -0
- package/dist/factories/index.d.ts +69 -0
- package/dist/factories/index.js +6 -0
- package/dist/factories/index.js.map +1 -0
- package/dist/index-B4-YyUNR.d.cts +73 -0
- package/dist/index-BZUOKeTO.d.ts +73 -0
- package/dist/index.cjs +8584 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +283 -0
- package/dist/index.d.ts +283 -0
- package/dist/index.js +1729 -0
- package/dist/index.js.map +1 -0
- package/dist/systems/index.cjs +5119 -0
- package/dist/systems/index.cjs.map +1 -0
- package/dist/systems/index.d.cts +200 -0
- package/dist/systems/index.d.ts +200 -0
- package/dist/systems/index.js +6 -0
- package/dist/systems/index.js.map +1 -0
- package/dist/types.cjs +4 -0
- package/dist/types.cjs.map +1 -0
- package/dist/types.d.cts +3 -0
- package/dist/types.d.ts +3 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/worldSnapshotUtils.cjs +259 -0
- package/dist/worldSnapshotUtils.cjs.map +1 -0
- package/dist/worldSnapshotUtils.d.cts +3 -0
- package/dist/worldSnapshotUtils.d.ts +3 -0
- package/dist/worldSnapshotUtils.js +4 -0
- package/dist/worldSnapshotUtils.js.map +1 -0
- package/package.json +80 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
import { E as EcsSystem, C as Component, W as WorldEntityView, T as TransformComponent, b as World, c as ComponentClass, d as ParentLookup, e as EcsEntityKind, O as ObjectManagementSystem } from './System-rXAmagXA.cjs';
|
|
2
|
+
export { A as AssetInput, f as CheckboxInput, g as ColorInput, h as ComponentFactory, i as ComponentInput, j as ComponentKind, D as DropdownInput, k as DropdownOption, l as EcsComponentFactoryKind, m as EcsEntityEditorKind, n as EntityId, o as EntityInput, F as FloatInput, I as InputSystem, p as IntersectionResult, K as KeyboardKey, q as KeyboardKeys, M as MouseButton, R as RenderSystem, S as SelectionListener, r as SliderInput, s as TextInput, t as ToggleInput, u as TransformSyncSystem, v as Vec3, w as Vector2Input, x as Vector3Input } from './System-rXAmagXA.cjs';
|
|
3
|
+
import * as THREE from 'three';
|
|
4
|
+
import { P as Object3DRef } from './Video-CDemv74U.cjs';
|
|
5
|
+
export { a7 as AnimationStateCallbacks, a8 as AnimationStateMachine, a9 as AnimationStateManager, aa as StateMachine } from './Video-CDemv74U.cjs';
|
|
6
|
+
export { i as CoreComponents } from './index-B4-YyUNR.cjs';
|
|
7
|
+
export { AnimationSystem, AudioSystem, CameraSyncSystem, EnvironmentSyncSystem, LightSyncSystem, MaterialSyncSystem, MeshGeometrySystem, ObjectVisibilitySystem, PhysicsSyncSystem, PostprocessingSyncSystem, ScriptBehaviourSystem, SelectionContext, VideoSystem } from './systems/index.cjs';
|
|
8
|
+
export { createAnimationComponent, createAudioComponent, createCameraComponent, createEntityTypeComponent, createEnvironmentComponent, createImageComponent, createImageTargetAnchorComponent, createImageTargetComponent, createLightComponent, createMaterialComponent, createMeshComponent, createMeshGeometryComponent, createModelComponent, createNameComponent, createObject3DRefComponent, createParentIdComponent, createPhysicsComponent, createPostprocessingComponent, createScriptComponent, createSelectableComponent, createSelectionTransformStateComponent, createSpriteComponent, createTransformComponent, createVideoComponent, registerDefaultComponentFactories, registerDefaultFactories } from './factories/index.cjs';
|
|
9
|
+
import '@dimforge/rapier3d-compat';
|
|
10
|
+
|
|
11
|
+
interface CustomEcsSystem extends EcsSystem {
|
|
12
|
+
data: Component | Record<string, unknown>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Base class for all user-authored scripts attached to an entity through a
|
|
17
|
+
* `ScriptComponent`. Subclass `Behaviour` to drive per-frame logic on a single
|
|
18
|
+
* entity with full access to the {@link World}, the entity's
|
|
19
|
+
* {@link TransformComponent}, and its three.js {@link Object3DRef}.
|
|
20
|
+
*
|
|
21
|
+
* @remarks
|
|
22
|
+
* Scripts are dispatched by `ScriptBehaviourSystem` once per frame in this
|
|
23
|
+
* order: {@link Behaviour.init} (first frame only) → {@link Behaviour.onUpdate}.
|
|
24
|
+
* Override {@link Behaviour.onUpdate} for per-frame logic — never override
|
|
25
|
+
* {@link Behaviour.update}, which is the engine-managed entry point.
|
|
26
|
+
*
|
|
27
|
+
* **Editor scripts**: By default, `Behaviour` subclasses do not run inside the
|
|
28
|
+
* editor. Set `executeInEditor: true` on the script entry in the inspector to
|
|
29
|
+
* enable the full lifecycle (`init` → `onUpdate` → `dispose`) while the editor
|
|
30
|
+
* is open. This gives direct access to the Three.js scene, camera, and renderer
|
|
31
|
+
* via {@link World.getScene}, {@link World.getCamera}, and
|
|
32
|
+
* {@link World.getRenderer} — useful for custom shaders, procedural geometry,
|
|
33
|
+
* grass, and any Three.js feature the editor's object palette does not expose.
|
|
34
|
+
* Avoid mutating ECS component state every frame in editor mode, as it creates
|
|
35
|
+
* undo history entries on every tick.
|
|
36
|
+
*
|
|
37
|
+
* The runtime recognizes a script by its **default export** plus the
|
|
38
|
+
* inherited static marker `__reluBehaviourClass`. Do not override the marker.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* import { Behaviour, type Component } from "@relu-interactives/spatial-ecs";
|
|
43
|
+
*
|
|
44
|
+
*
|
|
45
|
+
* export default class Spinner extends Behaviour {
|
|
46
|
+
* data: {
|
|
47
|
+
* speed: number;
|
|
48
|
+
* axis: "x" | "y" | "z";
|
|
49
|
+
* };
|
|
50
|
+
*
|
|
51
|
+
* init() {
|
|
52
|
+
* this.data.speed ??= 1;
|
|
53
|
+
* this.data.axis ??= "y";
|
|
54
|
+
* }
|
|
55
|
+
*
|
|
56
|
+
* onUpdate() {
|
|
57
|
+
* this.transform.rotation[this.data.axis] += this.data.speed * this.deltaTime;
|
|
58
|
+
* }
|
|
59
|
+
* }
|
|
60
|
+
* ```
|
|
61
|
+
*
|
|
62
|
+
* @see {@link World}
|
|
63
|
+
* @see {@link TransformComponent}
|
|
64
|
+
* @see {@link Object3DRef}
|
|
65
|
+
*
|
|
66
|
+
* @category Scripting
|
|
67
|
+
*/
|
|
68
|
+
declare class Behaviour implements CustomEcsSystem {
|
|
69
|
+
/**
|
|
70
|
+
* Static marker used by `ScriptBehaviourSystem` to detect `Behaviour`
|
|
71
|
+
* subclasses across bundle-identity splits (esbuild may produce a second
|
|
72
|
+
* copy of the package when scripts are bundled, breaking `instanceof`).
|
|
73
|
+
* Inherited by every subclass via the prototype chain.
|
|
74
|
+
*
|
|
75
|
+
* @internal
|
|
76
|
+
*/
|
|
77
|
+
static readonly __reluBehaviourClass: true;
|
|
78
|
+
/**
|
|
79
|
+
* Inspector-bound payload from the entity's `ScriptComponent`. Override the
|
|
80
|
+
* type on subclasses with `declare data: MyDataShape` to get type safety
|
|
81
|
+
* inside hooks. Saved with the project so values persist across reloads.
|
|
82
|
+
*/
|
|
83
|
+
data: Component | Record<string, unknown>;
|
|
84
|
+
/** Numeric id of the entity this script is attached to. */
|
|
85
|
+
entityId: number;
|
|
86
|
+
/** View of the owning entity (id + components) at construction time. */
|
|
87
|
+
entity: WorldEntityView;
|
|
88
|
+
/**
|
|
89
|
+
* Live three.js object wrapper for the entity. May be `null` for entities
|
|
90
|
+
* with no scene presence; helpers on this class return `null` in that case.
|
|
91
|
+
*/
|
|
92
|
+
threeRef: Object3DRef;
|
|
93
|
+
/**
|
|
94
|
+
* The entity's {@link TransformComponent}. Mutating `position`, `rotation`,
|
|
95
|
+
* or `scale` here is picked up the same frame by `TransformSyncSystem`.
|
|
96
|
+
*/
|
|
97
|
+
transform: TransformComponent;
|
|
98
|
+
/**
|
|
99
|
+
* The owning {@link World}. Refreshed each frame in {@link Behaviour.update}.
|
|
100
|
+
* Use it to query other entities or components.
|
|
101
|
+
*/
|
|
102
|
+
world: World;
|
|
103
|
+
/**
|
|
104
|
+
* Seconds elapsed since the last frame. Set by the engine before each
|
|
105
|
+
* {@link Behaviour.onUpdate}.
|
|
106
|
+
*/
|
|
107
|
+
deltaTime: number;
|
|
108
|
+
/**
|
|
109
|
+
* Engine-managed constructor. Hosts (`ScriptBehaviourSystem`) instantiate
|
|
110
|
+
* subclasses with the owning world, the entity id, and the script's `data`
|
|
111
|
+
* payload. User code should not call this directly.
|
|
112
|
+
*
|
|
113
|
+
* @param world - The owning ECS world.
|
|
114
|
+
* @param entityId - The entity this script is bound to.
|
|
115
|
+
* @param component - The `ScriptComponent.data` payload, or any object that
|
|
116
|
+
* should be exposed to the script as `this.data`.
|
|
117
|
+
*/
|
|
118
|
+
constructor(world: World, entityId: number, component: Component | Record<string, unknown>);
|
|
119
|
+
/**
|
|
120
|
+
* Engine-managed per-frame entry point. Refreshes {@link Behaviour.deltaTime}
|
|
121
|
+
* and delegates to {@link Behaviour.onUpdate}.
|
|
122
|
+
*
|
|
123
|
+
* @remarks Do **not** override this method — override
|
|
124
|
+
* {@link Behaviour.onUpdate} instead.
|
|
125
|
+
*
|
|
126
|
+
* @param world - The owning world (may differ from the constructor world
|
|
127
|
+
* after hot reload).
|
|
128
|
+
* @param deltaTime - Seconds since the last frame.
|
|
129
|
+
*/
|
|
130
|
+
update(world: World, deltaTime: number): void;
|
|
131
|
+
/**
|
|
132
|
+
* Optional cleanup hook invoked when the script is detached or the entity
|
|
133
|
+
* is destroyed. Override to release timers, listeners, or other resources.
|
|
134
|
+
*
|
|
135
|
+
* @param world - The owning world at disposal time.
|
|
136
|
+
*/
|
|
137
|
+
dispose?(world: World): void;
|
|
138
|
+
/**
|
|
139
|
+
* Returns the entity's world-space position as a new `THREE.Vector3`, or
|
|
140
|
+
* `null` if the entity has no scene presence.
|
|
141
|
+
*/
|
|
142
|
+
getWorldPosition(): THREE.Vector3 | null;
|
|
143
|
+
/**
|
|
144
|
+
* Returns the entity's forward direction in world space (the +Z axis of its
|
|
145
|
+
* world matrix), or `null` if the entity has no scene presence.
|
|
146
|
+
*/
|
|
147
|
+
getWorldDirection(): THREE.Vector3 | null;
|
|
148
|
+
/**
|
|
149
|
+
* Returns a unit vector pointing from this entity toward the given world
|
|
150
|
+
* position, or `null` if the entity has no scene presence.
|
|
151
|
+
*
|
|
152
|
+
* @param targetPosition - Destination point in world space.
|
|
153
|
+
*/
|
|
154
|
+
directionTo(targetPosition: THREE.Vector3): THREE.Vector3 | null;
|
|
155
|
+
/**
|
|
156
|
+
* Returns the world-space distance from this entity to the given position,
|
|
157
|
+
* or `null` if the entity has no scene presence.
|
|
158
|
+
*
|
|
159
|
+
* @param targetPosition - Destination point in world space.
|
|
160
|
+
*/
|
|
161
|
+
distanceTo(targetPosition: THREE.Vector3): number | null;
|
|
162
|
+
/**
|
|
163
|
+
* Linearly interpolates the entity's position toward `targetPosition` and
|
|
164
|
+
* writes the result back through {@link TransformComponent}. No-op if the
|
|
165
|
+
* entity has no scene presence.
|
|
166
|
+
*
|
|
167
|
+
* @param targetPosition - Destination point in world space.
|
|
168
|
+
* @param alpha - Interpolation factor in [0, 1]. Multiply by `deltaTime`
|
|
169
|
+
* for frame-rate-independent smoothing.
|
|
170
|
+
*/
|
|
171
|
+
lerpTo(targetPosition: THREE.Vector3, alpha: number): void;
|
|
172
|
+
/**
|
|
173
|
+
* Spherically interpolates the entity's rotation toward `targetRotation`
|
|
174
|
+
* and writes the result back through {@link TransformComponent}. No-op if
|
|
175
|
+
* the entity has no scene presence.
|
|
176
|
+
*
|
|
177
|
+
* @param targetRotation - Destination orientation as a quaternion.
|
|
178
|
+
* @param alpha - Interpolation factor in [0, 1].
|
|
179
|
+
*/
|
|
180
|
+
slerpTo(targetRotation: THREE.Quaternion, alpha: number): void;
|
|
181
|
+
/**
|
|
182
|
+
* Rotates the entity to face `targetPosition` in world space and writes the
|
|
183
|
+
* resulting orientation back through {@link TransformComponent}. No-op if
|
|
184
|
+
* the entity has no scene presence.
|
|
185
|
+
*
|
|
186
|
+
* @param targetPosition - Point in world space to face.
|
|
187
|
+
*/
|
|
188
|
+
lookAt(targetPosition: THREE.Vector3): void;
|
|
189
|
+
/** Returns every component currently attached to this entity. */
|
|
190
|
+
getComponents(): Component[];
|
|
191
|
+
/**
|
|
192
|
+
* Returns the entity's component of the given class, or `null` if it has
|
|
193
|
+
* no such component.
|
|
194
|
+
*
|
|
195
|
+
* @typeParam T - Concrete component type.
|
|
196
|
+
* @param componentClass - Component class constructor to look up.
|
|
197
|
+
*
|
|
198
|
+
* @example
|
|
199
|
+
* ```ts
|
|
200
|
+
* const mesh = this.getComponent(MeshComponent);
|
|
201
|
+
* if (mesh) console.log(mesh.geometryRef);
|
|
202
|
+
* ```
|
|
203
|
+
*/
|
|
204
|
+
getComponent<T extends Component>(componentClass: ComponentClass<T>): T | null;
|
|
205
|
+
/**
|
|
206
|
+
* Returns the latest {@link WorldEntityView} snapshot for this entity, or
|
|
207
|
+
* `null` if it was destroyed.
|
|
208
|
+
*/
|
|
209
|
+
getEntity(): WorldEntityView | null;
|
|
210
|
+
/**
|
|
211
|
+
* Resolves the entity's parent from the {@link ParentId} component, if any.
|
|
212
|
+
*
|
|
213
|
+
* @returns A {@link ParentLookup} with the parent component reference and
|
|
214
|
+
* the parent entity view (or `null` if the entity is at the root).
|
|
215
|
+
*/
|
|
216
|
+
getParent(): ParentLookup;
|
|
217
|
+
/**
|
|
218
|
+
* Returns every direct child entity of this one (entities whose
|
|
219
|
+
* {@link ParentId} matches `entityId`).
|
|
220
|
+
*/
|
|
221
|
+
getChildren(): WorldEntityView[];
|
|
222
|
+
/**
|
|
223
|
+
* Called once before the first {@link Behaviour.onUpdate}. Override to
|
|
224
|
+
* default and validate {@link Behaviour.data}, cache references, or set
|
|
225
|
+
* initial state.
|
|
226
|
+
*
|
|
227
|
+
* @remarks
|
|
228
|
+
* Also called in editor mode when `executeInEditor` is `true` on the script
|
|
229
|
+
* entry.
|
|
230
|
+
*/
|
|
231
|
+
protected init(): void;
|
|
232
|
+
/**
|
|
233
|
+
* Called every frame while the script is enabled. Override with the
|
|
234
|
+
* script's main per-frame logic.
|
|
235
|
+
*
|
|
236
|
+
* @remarks
|
|
237
|
+
* Also called every frame in editor mode when `executeInEditor` is `true`.
|
|
238
|
+
* Access the Three.js scene with `this.world.getScene()` for editor-only
|
|
239
|
+
* rendering work such as custom shaders or procedural geometry.
|
|
240
|
+
*/
|
|
241
|
+
protected onUpdate(): void;
|
|
242
|
+
/** Called when the editor selects this entity. Optional UX hook. */
|
|
243
|
+
onSelect(): void;
|
|
244
|
+
/** Called when the editor deselects this entity. Optional UX hook. */
|
|
245
|
+
onDeselect(): void;
|
|
246
|
+
/**
|
|
247
|
+
* Called when an image-tracking target this entity depends on becomes
|
|
248
|
+
* visible. Optional AR hook.
|
|
249
|
+
*
|
|
250
|
+
* @param target - The newly-visible target entity view.
|
|
251
|
+
*/
|
|
252
|
+
onTargetFound(target: WorldEntityView): void;
|
|
253
|
+
/**
|
|
254
|
+
* Called when an image-tracking target this entity depends on is lost.
|
|
255
|
+
* Optional AR hook.
|
|
256
|
+
*
|
|
257
|
+
* @param target - The target entity view that became invisible.
|
|
258
|
+
*/
|
|
259
|
+
onTargetLost(target: WorldEntityView): void;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
type EcsWorldComponentSnapshot = {
|
|
263
|
+
component: string;
|
|
264
|
+
entries: Array<{
|
|
265
|
+
entityId: number;
|
|
266
|
+
value: unknown;
|
|
267
|
+
}>;
|
|
268
|
+
};
|
|
269
|
+
type EcsWorldStateSnapshotLike = {
|
|
270
|
+
selectedEntityId?: number | null;
|
|
271
|
+
entities: number[];
|
|
272
|
+
components: EcsWorldComponentSnapshot[];
|
|
273
|
+
};
|
|
274
|
+
type HydrateWorldFromSnapshotResult = {
|
|
275
|
+
restoredCount: number;
|
|
276
|
+
selectedEntityId: number | null;
|
|
277
|
+
};
|
|
278
|
+
declare const HYDRATABLE_ENTITY_KINDS: Set<EcsEntityKind>;
|
|
279
|
+
|
|
280
|
+
declare function hydrateWorldFromSnapshotDetailed(snapshot: EcsWorldStateSnapshotLike | null | undefined, world: World, objectManagementSystem: ObjectManagementSystem): HydrateWorldFromSnapshotResult;
|
|
281
|
+
declare function hydrateWorldFromSnapshot(snapshot: EcsWorldStateSnapshotLike | null | undefined, world: World, objectManagementSystem: ObjectManagementSystem): number;
|
|
282
|
+
|
|
283
|
+
export { Behaviour, Component, EcsEntityKind, EcsSystem, type EcsWorldComponentSnapshot, type EcsWorldStateSnapshotLike, HYDRATABLE_ENTITY_KINDS, type HydrateWorldFromSnapshotResult, ObjectManagementSystem, ParentLookup, World, WorldEntityView, hydrateWorldFromSnapshot, hydrateWorldFromSnapshotDetailed };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
import { E as EcsSystem, C as Component, W as WorldEntityView, T as TransformComponent, b as World, c as ComponentClass, d as ParentLookup, e as EcsEntityKind, O as ObjectManagementSystem } from './System-rXAmagXA.js';
|
|
2
|
+
export { A as AssetInput, f as CheckboxInput, g as ColorInput, h as ComponentFactory, i as ComponentInput, j as ComponentKind, D as DropdownInput, k as DropdownOption, l as EcsComponentFactoryKind, m as EcsEntityEditorKind, n as EntityId, o as EntityInput, F as FloatInput, I as InputSystem, p as IntersectionResult, K as KeyboardKey, q as KeyboardKeys, M as MouseButton, R as RenderSystem, S as SelectionListener, r as SliderInput, s as TextInput, t as ToggleInput, u as TransformSyncSystem, v as Vec3, w as Vector2Input, x as Vector3Input } from './System-rXAmagXA.js';
|
|
3
|
+
import * as THREE from 'three';
|
|
4
|
+
import { P as Object3DRef } from './Video-ChKV1UI7.js';
|
|
5
|
+
export { a7 as AnimationStateCallbacks, a8 as AnimationStateMachine, a9 as AnimationStateManager, aa as StateMachine } from './Video-ChKV1UI7.js';
|
|
6
|
+
export { i as CoreComponents } from './index-BZUOKeTO.js';
|
|
7
|
+
export { AnimationSystem, AudioSystem, CameraSyncSystem, EnvironmentSyncSystem, LightSyncSystem, MaterialSyncSystem, MeshGeometrySystem, ObjectVisibilitySystem, PhysicsSyncSystem, PostprocessingSyncSystem, ScriptBehaviourSystem, SelectionContext, VideoSystem } from './systems/index.js';
|
|
8
|
+
export { createAnimationComponent, createAudioComponent, createCameraComponent, createEntityTypeComponent, createEnvironmentComponent, createImageComponent, createImageTargetAnchorComponent, createImageTargetComponent, createLightComponent, createMaterialComponent, createMeshComponent, createMeshGeometryComponent, createModelComponent, createNameComponent, createObject3DRefComponent, createParentIdComponent, createPhysicsComponent, createPostprocessingComponent, createScriptComponent, createSelectableComponent, createSelectionTransformStateComponent, createSpriteComponent, createTransformComponent, createVideoComponent, registerDefaultComponentFactories, registerDefaultFactories } from './factories/index.js';
|
|
9
|
+
import '@dimforge/rapier3d-compat';
|
|
10
|
+
|
|
11
|
+
interface CustomEcsSystem extends EcsSystem {
|
|
12
|
+
data: Component | Record<string, unknown>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Base class for all user-authored scripts attached to an entity through a
|
|
17
|
+
* `ScriptComponent`. Subclass `Behaviour` to drive per-frame logic on a single
|
|
18
|
+
* entity with full access to the {@link World}, the entity's
|
|
19
|
+
* {@link TransformComponent}, and its three.js {@link Object3DRef}.
|
|
20
|
+
*
|
|
21
|
+
* @remarks
|
|
22
|
+
* Scripts are dispatched by `ScriptBehaviourSystem` once per frame in this
|
|
23
|
+
* order: {@link Behaviour.init} (first frame only) → {@link Behaviour.onUpdate}.
|
|
24
|
+
* Override {@link Behaviour.onUpdate} for per-frame logic — never override
|
|
25
|
+
* {@link Behaviour.update}, which is the engine-managed entry point.
|
|
26
|
+
*
|
|
27
|
+
* **Editor scripts**: By default, `Behaviour` subclasses do not run inside the
|
|
28
|
+
* editor. Set `executeInEditor: true` on the script entry in the inspector to
|
|
29
|
+
* enable the full lifecycle (`init` → `onUpdate` → `dispose`) while the editor
|
|
30
|
+
* is open. This gives direct access to the Three.js scene, camera, and renderer
|
|
31
|
+
* via {@link World.getScene}, {@link World.getCamera}, and
|
|
32
|
+
* {@link World.getRenderer} — useful for custom shaders, procedural geometry,
|
|
33
|
+
* grass, and any Three.js feature the editor's object palette does not expose.
|
|
34
|
+
* Avoid mutating ECS component state every frame in editor mode, as it creates
|
|
35
|
+
* undo history entries on every tick.
|
|
36
|
+
*
|
|
37
|
+
* The runtime recognizes a script by its **default export** plus the
|
|
38
|
+
* inherited static marker `__reluBehaviourClass`. Do not override the marker.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* import { Behaviour, type Component } from "@relu-interactives/spatial-ecs";
|
|
43
|
+
*
|
|
44
|
+
*
|
|
45
|
+
* export default class Spinner extends Behaviour {
|
|
46
|
+
* data: {
|
|
47
|
+
* speed: number;
|
|
48
|
+
* axis: "x" | "y" | "z";
|
|
49
|
+
* };
|
|
50
|
+
*
|
|
51
|
+
* init() {
|
|
52
|
+
* this.data.speed ??= 1;
|
|
53
|
+
* this.data.axis ??= "y";
|
|
54
|
+
* }
|
|
55
|
+
*
|
|
56
|
+
* onUpdate() {
|
|
57
|
+
* this.transform.rotation[this.data.axis] += this.data.speed * this.deltaTime;
|
|
58
|
+
* }
|
|
59
|
+
* }
|
|
60
|
+
* ```
|
|
61
|
+
*
|
|
62
|
+
* @see {@link World}
|
|
63
|
+
* @see {@link TransformComponent}
|
|
64
|
+
* @see {@link Object3DRef}
|
|
65
|
+
*
|
|
66
|
+
* @category Scripting
|
|
67
|
+
*/
|
|
68
|
+
declare class Behaviour implements CustomEcsSystem {
|
|
69
|
+
/**
|
|
70
|
+
* Static marker used by `ScriptBehaviourSystem` to detect `Behaviour`
|
|
71
|
+
* subclasses across bundle-identity splits (esbuild may produce a second
|
|
72
|
+
* copy of the package when scripts are bundled, breaking `instanceof`).
|
|
73
|
+
* Inherited by every subclass via the prototype chain.
|
|
74
|
+
*
|
|
75
|
+
* @internal
|
|
76
|
+
*/
|
|
77
|
+
static readonly __reluBehaviourClass: true;
|
|
78
|
+
/**
|
|
79
|
+
* Inspector-bound payload from the entity's `ScriptComponent`. Override the
|
|
80
|
+
* type on subclasses with `declare data: MyDataShape` to get type safety
|
|
81
|
+
* inside hooks. Saved with the project so values persist across reloads.
|
|
82
|
+
*/
|
|
83
|
+
data: Component | Record<string, unknown>;
|
|
84
|
+
/** Numeric id of the entity this script is attached to. */
|
|
85
|
+
entityId: number;
|
|
86
|
+
/** View of the owning entity (id + components) at construction time. */
|
|
87
|
+
entity: WorldEntityView;
|
|
88
|
+
/**
|
|
89
|
+
* Live three.js object wrapper for the entity. May be `null` for entities
|
|
90
|
+
* with no scene presence; helpers on this class return `null` in that case.
|
|
91
|
+
*/
|
|
92
|
+
threeRef: Object3DRef;
|
|
93
|
+
/**
|
|
94
|
+
* The entity's {@link TransformComponent}. Mutating `position`, `rotation`,
|
|
95
|
+
* or `scale` here is picked up the same frame by `TransformSyncSystem`.
|
|
96
|
+
*/
|
|
97
|
+
transform: TransformComponent;
|
|
98
|
+
/**
|
|
99
|
+
* The owning {@link World}. Refreshed each frame in {@link Behaviour.update}.
|
|
100
|
+
* Use it to query other entities or components.
|
|
101
|
+
*/
|
|
102
|
+
world: World;
|
|
103
|
+
/**
|
|
104
|
+
* Seconds elapsed since the last frame. Set by the engine before each
|
|
105
|
+
* {@link Behaviour.onUpdate}.
|
|
106
|
+
*/
|
|
107
|
+
deltaTime: number;
|
|
108
|
+
/**
|
|
109
|
+
* Engine-managed constructor. Hosts (`ScriptBehaviourSystem`) instantiate
|
|
110
|
+
* subclasses with the owning world, the entity id, and the script's `data`
|
|
111
|
+
* payload. User code should not call this directly.
|
|
112
|
+
*
|
|
113
|
+
* @param world - The owning ECS world.
|
|
114
|
+
* @param entityId - The entity this script is bound to.
|
|
115
|
+
* @param component - The `ScriptComponent.data` payload, or any object that
|
|
116
|
+
* should be exposed to the script as `this.data`.
|
|
117
|
+
*/
|
|
118
|
+
constructor(world: World, entityId: number, component: Component | Record<string, unknown>);
|
|
119
|
+
/**
|
|
120
|
+
* Engine-managed per-frame entry point. Refreshes {@link Behaviour.deltaTime}
|
|
121
|
+
* and delegates to {@link Behaviour.onUpdate}.
|
|
122
|
+
*
|
|
123
|
+
* @remarks Do **not** override this method — override
|
|
124
|
+
* {@link Behaviour.onUpdate} instead.
|
|
125
|
+
*
|
|
126
|
+
* @param world - The owning world (may differ from the constructor world
|
|
127
|
+
* after hot reload).
|
|
128
|
+
* @param deltaTime - Seconds since the last frame.
|
|
129
|
+
*/
|
|
130
|
+
update(world: World, deltaTime: number): void;
|
|
131
|
+
/**
|
|
132
|
+
* Optional cleanup hook invoked when the script is detached or the entity
|
|
133
|
+
* is destroyed. Override to release timers, listeners, or other resources.
|
|
134
|
+
*
|
|
135
|
+
* @param world - The owning world at disposal time.
|
|
136
|
+
*/
|
|
137
|
+
dispose?(world: World): void;
|
|
138
|
+
/**
|
|
139
|
+
* Returns the entity's world-space position as a new `THREE.Vector3`, or
|
|
140
|
+
* `null` if the entity has no scene presence.
|
|
141
|
+
*/
|
|
142
|
+
getWorldPosition(): THREE.Vector3 | null;
|
|
143
|
+
/**
|
|
144
|
+
* Returns the entity's forward direction in world space (the +Z axis of its
|
|
145
|
+
* world matrix), or `null` if the entity has no scene presence.
|
|
146
|
+
*/
|
|
147
|
+
getWorldDirection(): THREE.Vector3 | null;
|
|
148
|
+
/**
|
|
149
|
+
* Returns a unit vector pointing from this entity toward the given world
|
|
150
|
+
* position, or `null` if the entity has no scene presence.
|
|
151
|
+
*
|
|
152
|
+
* @param targetPosition - Destination point in world space.
|
|
153
|
+
*/
|
|
154
|
+
directionTo(targetPosition: THREE.Vector3): THREE.Vector3 | null;
|
|
155
|
+
/**
|
|
156
|
+
* Returns the world-space distance from this entity to the given position,
|
|
157
|
+
* or `null` if the entity has no scene presence.
|
|
158
|
+
*
|
|
159
|
+
* @param targetPosition - Destination point in world space.
|
|
160
|
+
*/
|
|
161
|
+
distanceTo(targetPosition: THREE.Vector3): number | null;
|
|
162
|
+
/**
|
|
163
|
+
* Linearly interpolates the entity's position toward `targetPosition` and
|
|
164
|
+
* writes the result back through {@link TransformComponent}. No-op if the
|
|
165
|
+
* entity has no scene presence.
|
|
166
|
+
*
|
|
167
|
+
* @param targetPosition - Destination point in world space.
|
|
168
|
+
* @param alpha - Interpolation factor in [0, 1]. Multiply by `deltaTime`
|
|
169
|
+
* for frame-rate-independent smoothing.
|
|
170
|
+
*/
|
|
171
|
+
lerpTo(targetPosition: THREE.Vector3, alpha: number): void;
|
|
172
|
+
/**
|
|
173
|
+
* Spherically interpolates the entity's rotation toward `targetRotation`
|
|
174
|
+
* and writes the result back through {@link TransformComponent}. No-op if
|
|
175
|
+
* the entity has no scene presence.
|
|
176
|
+
*
|
|
177
|
+
* @param targetRotation - Destination orientation as a quaternion.
|
|
178
|
+
* @param alpha - Interpolation factor in [0, 1].
|
|
179
|
+
*/
|
|
180
|
+
slerpTo(targetRotation: THREE.Quaternion, alpha: number): void;
|
|
181
|
+
/**
|
|
182
|
+
* Rotates the entity to face `targetPosition` in world space and writes the
|
|
183
|
+
* resulting orientation back through {@link TransformComponent}. No-op if
|
|
184
|
+
* the entity has no scene presence.
|
|
185
|
+
*
|
|
186
|
+
* @param targetPosition - Point in world space to face.
|
|
187
|
+
*/
|
|
188
|
+
lookAt(targetPosition: THREE.Vector3): void;
|
|
189
|
+
/** Returns every component currently attached to this entity. */
|
|
190
|
+
getComponents(): Component[];
|
|
191
|
+
/**
|
|
192
|
+
* Returns the entity's component of the given class, or `null` if it has
|
|
193
|
+
* no such component.
|
|
194
|
+
*
|
|
195
|
+
* @typeParam T - Concrete component type.
|
|
196
|
+
* @param componentClass - Component class constructor to look up.
|
|
197
|
+
*
|
|
198
|
+
* @example
|
|
199
|
+
* ```ts
|
|
200
|
+
* const mesh = this.getComponent(MeshComponent);
|
|
201
|
+
* if (mesh) console.log(mesh.geometryRef);
|
|
202
|
+
* ```
|
|
203
|
+
*/
|
|
204
|
+
getComponent<T extends Component>(componentClass: ComponentClass<T>): T | null;
|
|
205
|
+
/**
|
|
206
|
+
* Returns the latest {@link WorldEntityView} snapshot for this entity, or
|
|
207
|
+
* `null` if it was destroyed.
|
|
208
|
+
*/
|
|
209
|
+
getEntity(): WorldEntityView | null;
|
|
210
|
+
/**
|
|
211
|
+
* Resolves the entity's parent from the {@link ParentId} component, if any.
|
|
212
|
+
*
|
|
213
|
+
* @returns A {@link ParentLookup} with the parent component reference and
|
|
214
|
+
* the parent entity view (or `null` if the entity is at the root).
|
|
215
|
+
*/
|
|
216
|
+
getParent(): ParentLookup;
|
|
217
|
+
/**
|
|
218
|
+
* Returns every direct child entity of this one (entities whose
|
|
219
|
+
* {@link ParentId} matches `entityId`).
|
|
220
|
+
*/
|
|
221
|
+
getChildren(): WorldEntityView[];
|
|
222
|
+
/**
|
|
223
|
+
* Called once before the first {@link Behaviour.onUpdate}. Override to
|
|
224
|
+
* default and validate {@link Behaviour.data}, cache references, or set
|
|
225
|
+
* initial state.
|
|
226
|
+
*
|
|
227
|
+
* @remarks
|
|
228
|
+
* Also called in editor mode when `executeInEditor` is `true` on the script
|
|
229
|
+
* entry.
|
|
230
|
+
*/
|
|
231
|
+
protected init(): void;
|
|
232
|
+
/**
|
|
233
|
+
* Called every frame while the script is enabled. Override with the
|
|
234
|
+
* script's main per-frame logic.
|
|
235
|
+
*
|
|
236
|
+
* @remarks
|
|
237
|
+
* Also called every frame in editor mode when `executeInEditor` is `true`.
|
|
238
|
+
* Access the Three.js scene with `this.world.getScene()` for editor-only
|
|
239
|
+
* rendering work such as custom shaders or procedural geometry.
|
|
240
|
+
*/
|
|
241
|
+
protected onUpdate(): void;
|
|
242
|
+
/** Called when the editor selects this entity. Optional UX hook. */
|
|
243
|
+
onSelect(): void;
|
|
244
|
+
/** Called when the editor deselects this entity. Optional UX hook. */
|
|
245
|
+
onDeselect(): void;
|
|
246
|
+
/**
|
|
247
|
+
* Called when an image-tracking target this entity depends on becomes
|
|
248
|
+
* visible. Optional AR hook.
|
|
249
|
+
*
|
|
250
|
+
* @param target - The newly-visible target entity view.
|
|
251
|
+
*/
|
|
252
|
+
onTargetFound(target: WorldEntityView): void;
|
|
253
|
+
/**
|
|
254
|
+
* Called when an image-tracking target this entity depends on is lost.
|
|
255
|
+
* Optional AR hook.
|
|
256
|
+
*
|
|
257
|
+
* @param target - The target entity view that became invisible.
|
|
258
|
+
*/
|
|
259
|
+
onTargetLost(target: WorldEntityView): void;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
type EcsWorldComponentSnapshot = {
|
|
263
|
+
component: string;
|
|
264
|
+
entries: Array<{
|
|
265
|
+
entityId: number;
|
|
266
|
+
value: unknown;
|
|
267
|
+
}>;
|
|
268
|
+
};
|
|
269
|
+
type EcsWorldStateSnapshotLike = {
|
|
270
|
+
selectedEntityId?: number | null;
|
|
271
|
+
entities: number[];
|
|
272
|
+
components: EcsWorldComponentSnapshot[];
|
|
273
|
+
};
|
|
274
|
+
type HydrateWorldFromSnapshotResult = {
|
|
275
|
+
restoredCount: number;
|
|
276
|
+
selectedEntityId: number | null;
|
|
277
|
+
};
|
|
278
|
+
declare const HYDRATABLE_ENTITY_KINDS: Set<EcsEntityKind>;
|
|
279
|
+
|
|
280
|
+
declare function hydrateWorldFromSnapshotDetailed(snapshot: EcsWorldStateSnapshotLike | null | undefined, world: World, objectManagementSystem: ObjectManagementSystem): HydrateWorldFromSnapshotResult;
|
|
281
|
+
declare function hydrateWorldFromSnapshot(snapshot: EcsWorldStateSnapshotLike | null | undefined, world: World, objectManagementSystem: ObjectManagementSystem): number;
|
|
282
|
+
|
|
283
|
+
export { Behaviour, Component, EcsEntityKind, EcsSystem, type EcsWorldComponentSnapshot, type EcsWorldStateSnapshotLike, HYDRATABLE_ENTITY_KINDS, type HydrateWorldFromSnapshotResult, ObjectManagementSystem, ParentLookup, World, WorldEntityView, hydrateWorldFromSnapshot, hydrateWorldFromSnapshotDetailed };
|