@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
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"text": "Animation",
|
|
4
|
+
"link": "/guide/components/animation"
|
|
5
|
+
},
|
|
6
|
+
{
|
|
7
|
+
"text": "Audio",
|
|
8
|
+
"link": "/guide/components/audio"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"text": "Camera",
|
|
12
|
+
"link": "/guide/components/camera"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"text": "Entity Type",
|
|
16
|
+
"link": "/guide/components/entity-type"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"text": "Image",
|
|
20
|
+
"link": "/guide/components/image"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"text": "Image Target",
|
|
24
|
+
"link": "/guide/components/image-target"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"text": "Image Target Anchor",
|
|
28
|
+
"link": "/guide/components/image-target-anchor"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"text": "Light",
|
|
32
|
+
"link": "/guide/components/light"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"text": "Material",
|
|
36
|
+
"link": "/guide/components/material"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"text": "Mesh",
|
|
40
|
+
"link": "/guide/components/mesh"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"text": "Mesh Geometry",
|
|
44
|
+
"link": "/guide/components/mesh-geometry"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"text": "Model",
|
|
48
|
+
"link": "/guide/components/model"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"text": "Name",
|
|
52
|
+
"link": "/guide/components/name"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"text": "Object3D Reference",
|
|
56
|
+
"link": "/guide/components/object3d-ref"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"text": "Parent",
|
|
60
|
+
"link": "/guide/components/parent-id"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"text": "Script",
|
|
64
|
+
"link": "/guide/components/script"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"text": "Sprite",
|
|
68
|
+
"link": "/guide/components/sprite"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"text": "Transform",
|
|
72
|
+
"link": "/guide/components/transform"
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"text": "Video",
|
|
76
|
+
"link": "/guide/components/video"
|
|
77
|
+
}
|
|
78
|
+
]
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
# Animation
|
|
2
|
+
|
|
3
|
+
Animation catalog and runtime state for an entity. Combines clips imported from a model with externally added clips, exposes a state machine for named transitions, and is queried each frame by the animation system to advance mixer time. Use the `addState` / `switchState` helpers rather than mutating the state machine directly so the animation system observes transitions.
|
|
4
|
+
|
|
5
|
+
> **Managed by:** [`AnimationSystem`](../systems/animation-system)
|
|
6
|
+
|
|
7
|
+
## Editor inspector
|
|
8
|
+
|
|
9
|
+

|
|
10
|
+
|
|
11
|
+
## Properties
|
|
12
|
+
|
|
13
|
+
| Property | Type | Description |
|
|
14
|
+
| --- | --- | --- |
|
|
15
|
+
| `clips` | `THREE.AnimationClip[]` | Combined ordered list of clips (model + external) currently loaded. |
|
|
16
|
+
| `clipCatalog` | `AnimationClipCatalogEntry[]` | Per-clip metadata used by the inspector. |
|
|
17
|
+
| `availableClips` | `string[]` | Display names of clips available for state-machine bindings. |
|
|
18
|
+
| `externalClipSources` | `string[]` | URLs/paths of external clip sources (saved with the project). |
|
|
19
|
+
| `paused` | `boolean` | Whether playback is currently paused. |
|
|
20
|
+
| `reverse` | `boolean` | Play the active clip in reverse. |
|
|
21
|
+
| `timeScale` | `number` | Playback speed multiplier (`1` = real-time). |
|
|
22
|
+
| `crossFadeDuration` | `number` | Default cross-fade duration in seconds when switching states. |
|
|
23
|
+
| `states` | `AnimationStateMachine[]` | All state-machine entries authored on this entity. |
|
|
24
|
+
| `active` | `AnimationStateMachine \| null` | State currently being played, or `null` if none. |
|
|
25
|
+
| `activeStateName` | `string \| null` | Name of the `active` state, or `null` if none. |
|
|
26
|
+
| `stateManager` | `AnimationStateManager` | Manager that drives state transitions; mutate via `addState`/`switchState`. |
|
|
27
|
+
|
|
28
|
+
## API reference
|
|
29
|
+
|
|
30
|
+
- Class: [`AnimationComponent`](../../api/components/classes/AnimationComponent.md)
|
|
31
|
+
- Source: [`core/components/Animation.ts`](https://github.com/Relu-Interactives/relu-spatial-ecs-engine/blob/main/core/components/Animation.ts)
|
|
32
|
+
|
|
33
|
+
## Scripting examples
|
|
34
|
+
|
|
35
|
+
::: tip Component access patterns
|
|
36
|
+
Use `this.getComponent(X)` to access a component on the **entity this script is attached to**. Use `this.world.getEntityByName` to find another entity by name, then `this.world.getComponent` to read its component:
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
// Component on the entity this script is on
|
|
40
|
+
const anim = this.getComponent(AnimationComponent);
|
|
41
|
+
|
|
42
|
+
// Component on another entity, found by its scene name
|
|
43
|
+
const other = this.world.getEntityByName("Character");
|
|
44
|
+
if (other) {
|
|
45
|
+
const anim = this.world.getComponent(other.entityId, AnimationComponent);
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
:::
|
|
49
|
+
|
|
50
|
+
### Switch states on keyboard input
|
|
51
|
+
|
|
52
|
+
Transition between an idle and a walk state based on arrow-key input. The cross-fade duration is set from the inspector.
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
import { Behaviour, AnimationComponent, KeyboardKeys } from "@relu-interactives/spatial-ecs";
|
|
56
|
+
import type { StringInput, FloatInput } from "@relu-interactives/spatial-ecs";
|
|
57
|
+
|
|
58
|
+
export default class AnimationController extends Behaviour {
|
|
59
|
+
data = {
|
|
60
|
+
idleState: "Idle" as StringInput,
|
|
61
|
+
walkState: "Walk" as StringInput,
|
|
62
|
+
crossFadeDuration: 0.3 as FloatInput,
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
protected init() {
|
|
66
|
+
const anim = this.getComponent(AnimationComponent);
|
|
67
|
+
if (anim) {
|
|
68
|
+
anim.crossFadeDuration = this.data.crossFadeDuration;
|
|
69
|
+
anim.switchState(this.data.idleState);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
protected onUpdate() {
|
|
74
|
+
const anim = this.getComponent(AnimationComponent);
|
|
75
|
+
if (!anim) return;
|
|
76
|
+
|
|
77
|
+
const moving =
|
|
78
|
+
this.world.getKey(KeyboardKeys.ArrowUp) || this.world.getKey(KeyboardKeys.ArrowDown);
|
|
79
|
+
const target = moving ? this.data.walkState : this.data.idleState;
|
|
80
|
+
|
|
81
|
+
if (anim.activeStateName !== target) {
|
|
82
|
+
anim.switchState(target);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Control playback speed and pause
|
|
89
|
+
|
|
90
|
+
Drive `timeScale` and `paused` live from inspector fields, useful for slow-motion or freeze effects.
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
import { Behaviour, AnimationComponent } from "@relu-interactives/spatial-ecs";
|
|
94
|
+
import type { FloatInput, BooleanInput } from "@relu-interactives/spatial-ecs";
|
|
95
|
+
|
|
96
|
+
export default class AnimationSpeedDriver extends Behaviour {
|
|
97
|
+
data = {
|
|
98
|
+
timeScale: 1 as FloatInput,
|
|
99
|
+
paused: false as BooleanInput,
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
protected onUpdate() {
|
|
103
|
+
const anim = this.getComponent(AnimationComponent);
|
|
104
|
+
if (!anim) return;
|
|
105
|
+
anim.timeScale = this.data.timeScale;
|
|
106
|
+
anim.paused = this.data.paused;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
::: tip State machine
|
|
112
|
+
Always use anim.switchState(name)` to change the active clip — do not assign to `active` directly. This ensures the animation system observes the transition and applies the configured cross-fade.
|
|
113
|
+
:::
|
|
114
|
+
|
|
115
|
+
### Via `ComponentInput` in the inspector
|
|
116
|
+
|
|
117
|
+
You can also pick this component from the inspector using a `ComponentInput` field. Assign any entity in the inspector and the field resolves to the live `AnimationComponent` instance at runtime.
|
|
118
|
+
|
|
119
|
+
```typescript
|
|
120
|
+
import {
|
|
121
|
+
Behaviour,
|
|
122
|
+
AnimationComponent,
|
|
123
|
+
type ComponentInput,
|
|
124
|
+
} from "@relu-interactives/spatial-ecs";
|
|
125
|
+
|
|
126
|
+
export default class Example extends Behaviour {
|
|
127
|
+
data = {
|
|
128
|
+
targetAnimation: {
|
|
129
|
+
type: "component",
|
|
130
|
+
value: null,
|
|
131
|
+
} as unknown as ComponentInput,
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
protected onUpdate() {
|
|
135
|
+
const anim = this.data.targetAnimation.value as AnimationComponent | null;
|
|
136
|
+
if (!anim) return;
|
|
137
|
+
// Use the live component instance.
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Via `EntityInput` in the inspector
|
|
143
|
+
|
|
144
|
+
Alternatively, pick an entity from the inspector using an `EntityInput` field and then read the component off that entity via `world.getComponent`:
|
|
145
|
+
|
|
146
|
+
```typescript
|
|
147
|
+
import {
|
|
148
|
+
Behaviour,
|
|
149
|
+
AnimationComponent,
|
|
150
|
+
type EntityInput,
|
|
151
|
+
type WorldEntityView,
|
|
152
|
+
} from "@relu-interactives/spatial-ecs";
|
|
153
|
+
|
|
154
|
+
export default class Example extends Behaviour {
|
|
155
|
+
data = {
|
|
156
|
+
targetEntity: { type: "entity", value: null } as unknown as EntityInput,
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
protected onUpdate() {
|
|
160
|
+
const entity = this.data.targetEntity.value as WorldEntityView | null;
|
|
161
|
+
if (!entity) return;
|
|
162
|
+
|
|
163
|
+
const anim = this.world.getComponent(
|
|
164
|
+
entity.entityId,
|
|
165
|
+
AnimationComponent,
|
|
166
|
+
) as AnimationComponent | null;
|
|
167
|
+
if (!anim) return;
|
|
168
|
+
// Use the component on the picked entity.
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
```
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
# Audio
|
|
2
|
+
|
|
3
|
+
Plays an audio clip from `path`. Supports both global stereo (`positional: false`) and 3D positional audio with the configured distance model. Runtime fields (`object`, `audio`, `isPlaying`, `isPaused`) are recreated when the project loads and are never persisted to saved snapshots.
|
|
4
|
+
|
|
5
|
+
> **Managed by:** [`AudioSystem`](../systems/audio-system)
|
|
6
|
+
|
|
7
|
+
## Editor inspector
|
|
8
|
+
|
|
9
|
+

|
|
10
|
+
|
|
11
|
+
## Properties
|
|
12
|
+
|
|
13
|
+
| Property | Type | Description |
|
|
14
|
+
| --- | --- | --- |
|
|
15
|
+
| `path` | `string` | Source URL or `localasset://` path of the audio file. |
|
|
16
|
+
| `options` | `typeof DEFAULT_AUDIO_OPTIONS` | Playback options. | Field | Default | Description | |---|---|---| | `autoplay` | `false` | Start playback as soon as the clip is loaded. | | `loop` | `false` | Loop playback indefinitely. | | `pitch` | `1` | Playback rate multiplier (`1` = normal speed/pitch). | | `volume` | `1` | Linear gain in `[0, 1]`. | | `positional` | `false` | When `true`, audio is spatialized using the entity's transform. | | `refDistance` | `1` | Distance at which volume is unattenuated (positional only). | | `distanceModel` | `"inverse"` | WebAudio distance model (`linear`, `inverse`, `exponential`). | | `rolloffFactor` | `1` | How quickly volume falls off past `refDistance`. | |
|
|
17
|
+
| `object` | `THREE.Object3D \| null` | Live three.js object hosting the audio (a parented `Audio`/`PositionalAudio`). `null` until built. |
|
|
18
|
+
| `audio` | `THREE.Audio<GainNode> \| THREE.PositionalAudio \| null` | Live three.js audio source. `null` until built. Recreated when the project loads. |
|
|
19
|
+
| `isPlaying` | `boolean` | Whether the audio should be playing. Managed by `AudioSystem` in preview. Non-enumerable — not persisted to snapshots or save data. Set via `play` / `stop`. |
|
|
20
|
+
| `isPaused` | `boolean` | Whether the audio is paused mid-playback (position is preserved). Non-enumerable — not persisted to snapshots or save data. Set via `pause` / `play` / `stop`. |
|
|
21
|
+
|
|
22
|
+
## API reference
|
|
23
|
+
|
|
24
|
+
- Class: [`AudioComponent`](../../api/components/classes/AudioComponent.md)
|
|
25
|
+
- Source: [`core/components/Audio.ts`](https://github.com/Relu-Interactives/relu-spatial-ecs-engine/blob/main/core/components/Audio.ts)
|
|
26
|
+
|
|
27
|
+
## Scripting examples
|
|
28
|
+
|
|
29
|
+
::: tip Component access patterns
|
|
30
|
+
Use `this.getComponent(X)` to access a component on the **entity this script is attached to**. Use `this.world.getEntityByName` to find another entity by name, then `this.world.getComponent` to read its component:
|
|
31
|
+
|
|
32
|
+
```typescript
|
|
33
|
+
// Component on the entity this script is on
|
|
34
|
+
const audio = this.getComponent(AudioComponent);
|
|
35
|
+
|
|
36
|
+
// Component on another entity, found by its scene name
|
|
37
|
+
const other = this.world.getEntityByName("AmbientSpeaker");
|
|
38
|
+
if (other) {
|
|
39
|
+
const audio = this.world.getComponent(other.entityId, AudioComponent);
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
:::
|
|
43
|
+
|
|
44
|
+
### Play / stop on key press
|
|
45
|
+
|
|
46
|
+
Toggle audio playback when the player presses Space. Volume is exposed as an inspector field.
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
import { Behaviour, AudioComponent, KeyboardKeys } from "@relu-interactives/spatial-ecs";
|
|
50
|
+
import type { FloatInput } from "@relu-interactives/spatial-ecs";
|
|
51
|
+
|
|
52
|
+
export default class AudioController extends Behaviour {
|
|
53
|
+
data = {
|
|
54
|
+
volume: 1 as FloatInput,
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
protected init() {
|
|
58
|
+
const audio = this.getComponent(AudioComponent);
|
|
59
|
+
if (audio) audio.options.volume = this.data.volume;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
protected onUpdate() {
|
|
63
|
+
const audio = this.getComponent(AudioComponent);
|
|
64
|
+
if (!audio) return;
|
|
65
|
+
|
|
66
|
+
// Keep volume in sync with the inspector slider
|
|
67
|
+
audio.options.volume = this.data.volume;
|
|
68
|
+
|
|
69
|
+
if (this.world.getKeyDown(KeyboardKeys.Space)) {
|
|
70
|
+
if (audio.isPlaying) {
|
|
71
|
+
audio.stop();
|
|
72
|
+
} else {
|
|
73
|
+
audio.play();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Proximity-triggered audio
|
|
81
|
+
|
|
82
|
+
Start playing when the camera comes within a configurable range, and stop when it moves away.
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
import { Behaviour, AudioComponent, TransformComponent, CameraComponent } from "@relu-interactives/spatial-ecs";
|
|
86
|
+
import type { FloatInput } from "@relu-interactives/spatial-ecs";
|
|
87
|
+
|
|
88
|
+
export default class ProximityAudio extends Behaviour {
|
|
89
|
+
data = {
|
|
90
|
+
triggerDistance: 3 as FloatInput,
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
protected onUpdate() {
|
|
94
|
+
const audio = this.getComponent(AudioComponent);
|
|
95
|
+
if (!audio) return;
|
|
96
|
+
|
|
97
|
+
// Find the default camera entity
|
|
98
|
+
let cameraPos = { x: 0, y: 0, z: 0 };
|
|
99
|
+
for (const [id, cam] of this.world.query([CameraComponent])) {
|
|
100
|
+
if (cam.isDefault) {
|
|
101
|
+
const ct = this.world.getComponent(id, TransformComponent);
|
|
102
|
+
if (ct) cameraPos = ct.position;
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const dx = this.transform.position.x - cameraPos.x;
|
|
108
|
+
const dy = this.transform.position.y - cameraPos.y;
|
|
109
|
+
const dz = this.transform.position.z - cameraPos.z;
|
|
110
|
+
const dist = Math.sqrt(dx * dx + dy * dy + dz * dz);
|
|
111
|
+
|
|
112
|
+
if (dist < this.data.triggerDistance && !audio.isPlaying) {
|
|
113
|
+
audio.play();
|
|
114
|
+
} else if (dist >= this.data.triggerDistance && audio.isPlaying) {
|
|
115
|
+
audio.stop();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
::: tip Playback methods
|
|
122
|
+
Use `audio.play()`, `audio.pause()`, and `audio.stop()` rather than calling methods on `audio.audio` directly. These helpers update `isPlaying` / `isPaused` so the `AudioSystem` applies the correct THREE.js call in preview.
|
|
123
|
+
:::
|
|
124
|
+
|
|
125
|
+
### Via `ComponentInput` in the inspector
|
|
126
|
+
|
|
127
|
+
You can also pick this component from the inspector using a `ComponentInput` field. Assign any entity in the inspector and the field resolves to the live `AudioComponent` instance at runtime.
|
|
128
|
+
|
|
129
|
+
```typescript
|
|
130
|
+
import {
|
|
131
|
+
Behaviour,
|
|
132
|
+
AudioComponent,
|
|
133
|
+
type ComponentInput,
|
|
134
|
+
} from "@relu-interactives/spatial-ecs";
|
|
135
|
+
|
|
136
|
+
export default class Example extends Behaviour {
|
|
137
|
+
data = {
|
|
138
|
+
targetAudio: {
|
|
139
|
+
type: "component",
|
|
140
|
+
value: null,
|
|
141
|
+
} as unknown as ComponentInput,
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
protected onUpdate() {
|
|
145
|
+
const audio = this.data.targetAudio.value as AudioComponent | null;
|
|
146
|
+
if (!audio) return;
|
|
147
|
+
// Use the live component instance.
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Via `EntityInput` in the inspector
|
|
153
|
+
|
|
154
|
+
Alternatively, pick an entity from the inspector using an `EntityInput` field and then read the component off that entity via `world.getComponent`:
|
|
155
|
+
|
|
156
|
+
```typescript
|
|
157
|
+
import {
|
|
158
|
+
Behaviour,
|
|
159
|
+
AudioComponent,
|
|
160
|
+
type EntityInput,
|
|
161
|
+
type WorldEntityView,
|
|
162
|
+
} from "@relu-interactives/spatial-ecs";
|
|
163
|
+
|
|
164
|
+
export default class Example extends Behaviour {
|
|
165
|
+
data = {
|
|
166
|
+
targetEntity: { type: "entity", value: null } as unknown as EntityInput,
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
protected onUpdate() {
|
|
170
|
+
const entity = this.data.targetEntity.value as WorldEntityView | null;
|
|
171
|
+
if (!entity) return;
|
|
172
|
+
|
|
173
|
+
const audio = this.world.getComponent(
|
|
174
|
+
entity.entityId,
|
|
175
|
+
AudioComponent,
|
|
176
|
+
) as AudioComponent | null;
|
|
177
|
+
if (!audio) return;
|
|
178
|
+
// Use the component on the picked entity.
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
```
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
# Camera
|
|
2
|
+
|
|
3
|
+
Camera entity state. Supports perspective and orthographic projections, a `3d` or `ar` runtime type, and an `isDefault` flag for the camera that the preview/editor renders through. Field-of-view, near/far, ortho frustum, and zoom are persisted; the live `THREE.Camera` is recreated when the project loads.
|
|
4
|
+
|
|
5
|
+
> **Managed by:** [`CameraSyncSystem`](../systems/camera-sync-system)
|
|
6
|
+
|
|
7
|
+
## Editor inspector
|
|
8
|
+
|
|
9
|
+

|
|
10
|
+
|
|
11
|
+
## Properties
|
|
12
|
+
|
|
13
|
+
| Property | Type | Description |
|
|
14
|
+
| --- | --- | --- |
|
|
15
|
+
| `camera` | `THREE.Camera` | Live three.js camera. Recreated when the project loads to match `projection`. |
|
|
16
|
+
| `type` | `CameraRuntimeType` | Runtime camera mode (`3d` or `ar`). |
|
|
17
|
+
| `isDefault` | `boolean` | When `true`, this is the active rendering camera. Only one camera per scene should be the default. |
|
|
18
|
+
| `projection` | `CameraProjection` | Active projection model (`perspective` or `orthographic`). |
|
|
19
|
+
| `fov` | `number` | Vertical field of view in **degrees**. Used when `projection` is `perspective`. |
|
|
20
|
+
| `near` | `number` | Near clip plane in world units. |
|
|
21
|
+
| `far` | `number` | Far clip plane in world units. |
|
|
22
|
+
| `left` | `number` | Left edge of the orthographic frustum (orthographic only). |
|
|
23
|
+
| `right` | `number` | Right edge of the orthographic frustum (orthographic only). |
|
|
24
|
+
| `top` | `number` | Top edge of the orthographic frustum (orthographic only). |
|
|
25
|
+
| `bottom` | `number` | Bottom edge of the orthographic frustum (orthographic only). |
|
|
26
|
+
| `zoom` | `number` | Zoom multiplier applied to the projection. |
|
|
27
|
+
|
|
28
|
+
## API reference
|
|
29
|
+
|
|
30
|
+
- Class: [`CameraComponent`](../../api/components/classes/CameraComponent.md)
|
|
31
|
+
- Source: [`core/components/Camera.ts`](https://github.com/Relu-Interactives/relu-spatial-ecs-engine/blob/main/core/components/Camera.ts)
|
|
32
|
+
|
|
33
|
+
## Scripting examples
|
|
34
|
+
|
|
35
|
+
::: tip Component access patterns
|
|
36
|
+
Use `this.getComponent(X)` to access a component on the **entity this script is attached to**. Use `this.world.getEntityByName` to find another entity by name, then `this.world.getComponent` to read its component:
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
// Component on the entity this script is on
|
|
40
|
+
const cam = this.getComponent(CameraComponent);
|
|
41
|
+
|
|
42
|
+
// Component on another entity, found by its scene name
|
|
43
|
+
const other = this.world.getEntityByName("CinematicCam");
|
|
44
|
+
if (other) {
|
|
45
|
+
const cam = this.world.getComponent(other.entityId, CameraComponent);
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
:::
|
|
49
|
+
|
|
50
|
+
### Zoom with a hold key
|
|
51
|
+
|
|
52
|
+
Smoothly lerp the field-of-view toward a zoomed-in value while Shift is held, then lerp back out.
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
import { Behaviour, CameraComponent, KeyboardKeys } from "@relu-interactives/spatial-ecs";
|
|
56
|
+
import type { FloatInput } from "@relu-interactives/spatial-ecs";
|
|
57
|
+
|
|
58
|
+
export default class CameraZoom extends Behaviour {
|
|
59
|
+
data = {
|
|
60
|
+
normalFov: 60 as FloatInput,
|
|
61
|
+
zoomedFov: 30 as FloatInput,
|
|
62
|
+
zoomSpeed: 5 as FloatInput,
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
protected onUpdate() {
|
|
66
|
+
const cam = this.getComponent(CameraComponent);
|
|
67
|
+
if (!cam) return;
|
|
68
|
+
|
|
69
|
+
const targetFov = this.world.getKey(KeyboardKeys.ShiftLeft)
|
|
70
|
+
? this.data.zoomedFov
|
|
71
|
+
: this.data.normalFov;
|
|
72
|
+
|
|
73
|
+
cam.fov += (targetFov - cam.fov) * this.data.zoomSpeed * this.deltaTime;
|
|
74
|
+
|
|
75
|
+
// Propagate the change to the live THREE.PerspectiveCamera
|
|
76
|
+
const live = cam.camera as {
|
|
77
|
+
isPerspectiveCamera?: boolean;
|
|
78
|
+
fov?: number;
|
|
79
|
+
updateProjectionMatrix?(): void;
|
|
80
|
+
};
|
|
81
|
+
if (live.isPerspectiveCamera && live.updateProjectionMatrix) {
|
|
82
|
+
live.fov = cam.fov;
|
|
83
|
+
live.updateProjectionMatrix();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Orbit the camera around a point
|
|
90
|
+
|
|
91
|
+
Rotate the camera entity's position around the scene origin at a configurable radius and height.
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
import { Behaviour, CameraComponent } from "@relu-interactives/spatial-ecs";
|
|
95
|
+
import type { FloatInput } from "@relu-interactives/spatial-ecs";
|
|
96
|
+
|
|
97
|
+
export default class OrbitCamera extends Behaviour {
|
|
98
|
+
data = {
|
|
99
|
+
radius: 5 as FloatInput,
|
|
100
|
+
height: 2 as FloatInput,
|
|
101
|
+
speed: 0.5 as FloatInput,
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
private elapsed = 0;
|
|
105
|
+
|
|
106
|
+
protected onUpdate() {
|
|
107
|
+
const cam = this.getComponent(CameraComponent);
|
|
108
|
+
if (!cam?.isDefault) return;
|
|
109
|
+
|
|
110
|
+
this.elapsed += this.deltaTime;
|
|
111
|
+
const angle = this.elapsed * this.data.speed;
|
|
112
|
+
|
|
113
|
+
this.transform.position.x = Math.sin(angle) * this.data.radius;
|
|
114
|
+
this.transform.position.y = this.data.height;
|
|
115
|
+
this.transform.position.z = Math.cos(angle) * this.data.radius;
|
|
116
|
+
|
|
117
|
+
// Always look toward the origin
|
|
118
|
+
this.transform.rotation.y = -angle;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Via `ComponentInput` in the inspector
|
|
124
|
+
|
|
125
|
+
You can also pick this component from the inspector using a `ComponentInput` field. Assign any entity in the inspector and the field resolves to the live `CameraComponent` instance at runtime.
|
|
126
|
+
|
|
127
|
+
```typescript
|
|
128
|
+
import {
|
|
129
|
+
Behaviour,
|
|
130
|
+
CameraComponent,
|
|
131
|
+
type ComponentInput,
|
|
132
|
+
} from "@relu-interactives/spatial-ecs";
|
|
133
|
+
|
|
134
|
+
export default class Example extends Behaviour {
|
|
135
|
+
data = {
|
|
136
|
+
targetCamera: {
|
|
137
|
+
type: "component",
|
|
138
|
+
value: null,
|
|
139
|
+
} as unknown as ComponentInput,
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
protected onUpdate() {
|
|
143
|
+
const cam = this.data.targetCamera.value as CameraComponent | null;
|
|
144
|
+
if (!cam) return;
|
|
145
|
+
// Use the live component instance.
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### Via `EntityInput` in the inspector
|
|
151
|
+
|
|
152
|
+
Alternatively, pick an entity from the inspector using an `EntityInput` field and then read the component off that entity via `world.getComponent`:
|
|
153
|
+
|
|
154
|
+
```typescript
|
|
155
|
+
import {
|
|
156
|
+
Behaviour,
|
|
157
|
+
CameraComponent,
|
|
158
|
+
type EntityInput,
|
|
159
|
+
type WorldEntityView,
|
|
160
|
+
} from "@relu-interactives/spatial-ecs";
|
|
161
|
+
|
|
162
|
+
export default class Example extends Behaviour {
|
|
163
|
+
data = {
|
|
164
|
+
targetEntity: { type: "entity", value: null } as unknown as EntityInput,
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
protected onUpdate() {
|
|
168
|
+
const entity = this.data.targetEntity.value as WorldEntityView | null;
|
|
169
|
+
if (!entity) return;
|
|
170
|
+
|
|
171
|
+
const cam = this.world.getComponent(
|
|
172
|
+
entity.entityId,
|
|
173
|
+
CameraComponent,
|
|
174
|
+
) as CameraComponent | null;
|
|
175
|
+
if (!cam) return;
|
|
176
|
+
// Use the component on the picked entity.
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
```
|