@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,108 @@
|
|
|
1
|
+
# Postprocessing
|
|
2
|
+
|
|
3
|
+
The `Postprocessing` component owns the scene-wide effect chain (bloom, vignette, depth-of-field, tone mapping, SSAO, and more). Each effect has its own `enabled` flag plus per-effect parameters.
|
|
4
|
+
|
|
5
|
+
It is a **singleton** there is exactly one `Postprocessing` entity per scene, owned by the editor.
|
|
6
|
+
|
|
7
|
+
> [!IMPORTANT]
|
|
8
|
+
> The render system only applies effects when the master toggle `postEnabled` is `true`. Enabling an individual effect alone has no visual impact unless the master toggle is also on.
|
|
9
|
+
|
|
10
|
+
> **Managed by:** [`PostprocessingSyncSystem`](../systems/postprocessing-sync-system)
|
|
11
|
+
|
|
12
|
+
## Get the component from the world
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
import { Behaviour, Postprocessing } from "@relu-interactives/spatial-ecs";
|
|
16
|
+
|
|
17
|
+
export default class ReadPostprocessing extends Behaviour {
|
|
18
|
+
init() {
|
|
19
|
+
const [entityId] = this.world.query(Postprocessing);
|
|
20
|
+
if (entityId === undefined) return;
|
|
21
|
+
|
|
22
|
+
const post = this.world.getComponent(entityId, Postprocessing);
|
|
23
|
+
if (!post) return;
|
|
24
|
+
|
|
25
|
+
console.log("post enabled?", post.values.postEnabled);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
`post.values` is the live state object mutate fields on it directly. The `PostprocessingSyncSystem` reads it every frame and rebuilds the composer pipeline as effects are toggled.
|
|
31
|
+
|
|
32
|
+
## Change values at runtime
|
|
33
|
+
|
|
34
|
+
### Enable the master toggle and a few effects
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
post.values.postEnabled = true;
|
|
38
|
+
|
|
39
|
+
post.values.bloom.enabled = true;
|
|
40
|
+
post.values.bloom.intensity = 1.5;
|
|
41
|
+
post.values.bloom.threshold = 0.25;
|
|
42
|
+
post.values.bloom.radius = 0.8;
|
|
43
|
+
|
|
44
|
+
post.values.vignette.enabled = true;
|
|
45
|
+
post.values.vignette.darkness = 1.4;
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Toggle a single effect from a script
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
function setBloom(post, on) {
|
|
52
|
+
post.values.postEnabled = on || somethingElseEnabled(post);
|
|
53
|
+
post.values.bloom.enabled = on;
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Cinematic depth of field
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
post.values.dof.enabled = true;
|
|
61
|
+
post.values.dof.focusDistance = 0.02; // distance from the camera (normalised)
|
|
62
|
+
post.values.dof.focalLength = 0.05;
|
|
63
|
+
post.values.dof.bokehScale = 4;
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Color grading
|
|
67
|
+
|
|
68
|
+
```ts
|
|
69
|
+
post.values.toneMapping.enabled = true;
|
|
70
|
+
post.values.toneMapping.exposure = 1.1;
|
|
71
|
+
|
|
72
|
+
post.values.hueSaturation.enabled = true;
|
|
73
|
+
post.values.hueSaturation.hue = 0.05; // radians
|
|
74
|
+
post.values.hueSaturation.saturation = 0.2; // 0 = unchanged
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Authorable values
|
|
78
|
+
|
|
79
|
+
Top-level master toggle:
|
|
80
|
+
|
|
81
|
+
| Path | Type | Default |
|
|
82
|
+
| --- | --- | --- |
|
|
83
|
+
| `postEnabled` | `boolean` | `false` |
|
|
84
|
+
|
|
85
|
+
Each effect lives under its own key with `enabled` plus parameters:
|
|
86
|
+
|
|
87
|
+
| Effect | Path prefix | Key parameters |
|
|
88
|
+
| --- | --- | --- |
|
|
89
|
+
| Depth of field | `dof` | `focusDistance`, `focalLength`, `bokehScale` |
|
|
90
|
+
| Bloom | `bloom` | `intensity`, `threshold`, `radius` |
|
|
91
|
+
| Vignette | `vignette` | `offset`, `darkness` |
|
|
92
|
+
| Chromatic aberration | `chromAberration` | `offsetX`, `offsetY` |
|
|
93
|
+
| Film noise | `noise` | `opacity` |
|
|
94
|
+
| Pixelation | `pixelation` | `granularity` |
|
|
95
|
+
| Tone mapping | `toneMapping` | `exposure` |
|
|
96
|
+
| Hue / saturation | `hueSaturation` | `hue`, `saturation` |
|
|
97
|
+
| Sepia | `sepia` | `intensity` |
|
|
98
|
+
| SMAA | `smaa` | _(toggle only)_ |
|
|
99
|
+
| SSAO | `ssao` | `intensity`, `radius` |
|
|
100
|
+
| Dot screen | `dotScreen` | `scale`, `angle`, `opacity` |
|
|
101
|
+
| Glitch | `glitch` | `delay`, `duration`, `strength`, `mode`, `active` |
|
|
102
|
+
|
|
103
|
+
For the full type, including every legacy/optional parameter, see [`PostprocessingState`](../../api/components/classes/Postprocessing.md).
|
|
104
|
+
|
|
105
|
+
## API reference
|
|
106
|
+
|
|
107
|
+
- Class: [`Postprocessing`](../../api/components/classes/Postprocessing.md)
|
|
108
|
+
- Source: [`core/components/Postprocessing.ts`](https://github.com/Relu-Interactives/relu-spatial-ecs-engine/blob/main/core/components/Postprocessing.ts)
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Ambient Light
|
|
2
|
+
|
|
3
|
+
A scene-wide light that adds uniform color to every surface. No shadows, no direction.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { Behaviour, ObjectManagementSystem } from "@relu-interactives/spatial-ecs";
|
|
7
|
+
|
|
8
|
+
export default class SpawnAmbient extends Behaviour {
|
|
9
|
+
init() {
|
|
10
|
+
const objects = this.world.getSystem(ObjectManagementSystem);
|
|
11
|
+
objects?.requestCreate("ambientLight", { name: "Fill" });
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Payload
|
|
17
|
+
|
|
18
|
+
| Field | Type | Default | Description |
|
|
19
|
+
| --- | --- | --- | --- |
|
|
20
|
+
| `name` | `string` | `"Ambient Light"` | Display name. |
|
|
21
|
+
| `transform` | `TransformData` | identity | Position has no visual effect (ambient is uniform). |
|
|
22
|
+
| `parentId` | `EntityId \| null` | `null` | Optional parent entity. |
|
|
23
|
+
|
|
24
|
+
Default color is `#ffffff` and intensity is `0.6`. To change them after spawn, update the `Light` component.
|
|
25
|
+
|
|
26
|
+
## Components attached
|
|
27
|
+
|
|
28
|
+
`Transform`, `Object3DRef`, `Name`, `EntityType`, `ParentId`, `Selectable`, `Light`.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Area Light
|
|
2
|
+
|
|
3
|
+
A rectangular area light (`THREE.RectAreaLight`). Great for soft "softbox" lighting. Only `MeshStandardMaterial` and `MeshPhysicalMaterial` are affected.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { Behaviour, ObjectManagementSystem } from "@relu-interactives/spatial-ecs";
|
|
7
|
+
|
|
8
|
+
export default class SpawnSoftbox extends Behaviour {
|
|
9
|
+
init() {
|
|
10
|
+
const objects = this.world.getSystem(ObjectManagementSystem);
|
|
11
|
+
objects?.requestCreate("areaLight", {
|
|
12
|
+
name: "Softbox",
|
|
13
|
+
transform: { position: { x: 0, y: 4, z: 0 } },
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Payload
|
|
20
|
+
|
|
21
|
+
| Field | Type | Default | Description |
|
|
22
|
+
| --- | --- | --- | --- |
|
|
23
|
+
| `name` | `string` | `"Area Light"` | Display name. |
|
|
24
|
+
| `transform.position` | `{ x, y, z }` | `(0, 4, 0)` | Light position. The light initially looks at the world origin. |
|
|
25
|
+
| `transform.rotation` / `scale` | — | identity | Standard transform fields. |
|
|
26
|
+
| `parentId` | `EntityId \| null` | `null` | Optional parent entity. |
|
|
27
|
+
|
|
28
|
+
Default color `#ffffff`, intensity `5`, dimensions `4 × 4`.
|
|
29
|
+
|
|
30
|
+
## Components attached
|
|
31
|
+
|
|
32
|
+
`Transform`, `Object3DRef`, `Name`, `EntityType`, `ParentId`, `Selectable`, `Light`.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Audio
|
|
2
|
+
|
|
3
|
+
A 3D positional audio source attached to the active camera's `AudioListener`.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { Behaviour, ObjectManagementSystem } from "@relu-interactives/spatial-ecs";
|
|
7
|
+
|
|
8
|
+
export default class SpawnSound extends Behaviour {
|
|
9
|
+
init() {
|
|
10
|
+
const objects = this.world.getSystem(ObjectManagementSystem);
|
|
11
|
+
objects?.requestCreate("audio", {
|
|
12
|
+
name: "Ambience",
|
|
13
|
+
path: "/assets/audio/ambience.mp3",
|
|
14
|
+
transform: { position: { x: 0, y: 1, z: 0 } },
|
|
15
|
+
options: { autoplay: true, loop: true, volume: 0.5 },
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Payload
|
|
22
|
+
|
|
23
|
+
| Field | Type | Default | Description |
|
|
24
|
+
| --- | --- | --- | --- |
|
|
25
|
+
| `name` | `string` | `"Audio"` | Display name. |
|
|
26
|
+
| `path` | `string` | `""` | URL or local-asset path to the audio clip (MP3, WAV, OGG). |
|
|
27
|
+
| `transform` | `TransformData` | identity | Position / rotation / scale (position drives spatialization). |
|
|
28
|
+
| `parentId` | `EntityId \| null` | `null` | Optional parent entity. |
|
|
29
|
+
|
|
30
|
+
### `options`
|
|
31
|
+
|
|
32
|
+
| Option | Type | Default | Description |
|
|
33
|
+
| --- | --- | --- | --- |
|
|
34
|
+
| `autoplay` | `boolean` | `false` | Start playback as soon as the clip is loaded. |
|
|
35
|
+
| `loop` | `boolean` | `false` | Loop playback indefinitely. |
|
|
36
|
+
| `volume` | `number` (0–1) | `1` | Linear gain. |
|
|
37
|
+
| `refDistance` | `number` | `1` | Distance at which volume is unattenuated. |
|
|
38
|
+
| `rolloffFactor` | `number` | `1` | How quickly volume falls off past `refDistance`. |
|
|
39
|
+
|
|
40
|
+
## Components attached
|
|
41
|
+
|
|
42
|
+
`Transform`, `Object3DRef`, `Name`, `EntityType`, `ParentId`, `Selectable`, `Audio`.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Camera
|
|
2
|
+
|
|
3
|
+
Spawn an additional camera entity. Useful for cinematics, picture-in-picture, or AR cameras.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { Behaviour, ObjectManagementSystem } from "@relu-interactives/spatial-ecs";
|
|
7
|
+
|
|
8
|
+
export default class SpawnCamera extends Behaviour {
|
|
9
|
+
init() {
|
|
10
|
+
const objects = this.world.getSystem(ObjectManagementSystem);
|
|
11
|
+
objects?.requestCreate("camera", {
|
|
12
|
+
name: "Cinematic",
|
|
13
|
+
transform: { position: { x: 0, y: 2, z: 5 } },
|
|
14
|
+
options: {
|
|
15
|
+
type: "3d",
|
|
16
|
+
projection: "perspective",
|
|
17
|
+
fov: 50,
|
|
18
|
+
near: 0.1,
|
|
19
|
+
far: 1000,
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Payload
|
|
27
|
+
|
|
28
|
+
| Field | Type | Default | Description |
|
|
29
|
+
| --- | --- | --- | --- |
|
|
30
|
+
| `name` | `string` | `"Camera"` | Display name. |
|
|
31
|
+
| `transform` | `TransformData` | identity | Position / rotation / scale. |
|
|
32
|
+
| `useWorldCamera` | `boolean` | `false` | Reuse the existing world camera object instead of creating a new one (only honored at runtime, not in the editor). |
|
|
33
|
+
| `parentId` | `EntityId \| null` | `null` | Optional parent entity. |
|
|
34
|
+
|
|
35
|
+
### `options`
|
|
36
|
+
|
|
37
|
+
| Option | Type | Default | Description |
|
|
38
|
+
| --- | --- | --- | --- |
|
|
39
|
+
| `type` | `"3d" \| "ar"` | `"3d"` | Logical camera type (used by tracking systems). |
|
|
40
|
+
| `isDefault` | `boolean` | `false` | Mark this camera as the default render camera. |
|
|
41
|
+
| `projection` | `"perspective" \| "orthographic"` | `"perspective"` | Projection model. |
|
|
42
|
+
| `fov` | `number` | `60` | Vertical field of view (degrees). Perspective only. |
|
|
43
|
+
| `near` | `number` | `0.1` | Near clip plane. |
|
|
44
|
+
| `far` | `number` | `1000` | Far clip plane. |
|
|
45
|
+
| `left` / `right` / `top` / `bottom` | `number` | ±half-height | Orthographic frustum edges. |
|
|
46
|
+
| `zoom` | `number` | `1` | Orthographic zoom. |
|
|
47
|
+
|
|
48
|
+
## Components attached
|
|
49
|
+
|
|
50
|
+
`Transform`, `Object3DRef`, `Name`, `EntityType`, `ParentId`, `Selectable`, `Camera`.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Capsule
|
|
2
|
+
|
|
3
|
+
A `THREE.CapsuleGeometry` with radius `0.5`, length `1`, 4 cap subdivisions, and 8 radial segments.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { Behaviour, ObjectManagementSystem } from "@relu-interactives/spatial-ecs";
|
|
7
|
+
|
|
8
|
+
export default class SpawnCapsule extends Behaviour {
|
|
9
|
+
init() {
|
|
10
|
+
const objects = this.world.getSystem(ObjectManagementSystem);
|
|
11
|
+
objects?.requestCreate("capsule", {
|
|
12
|
+
name: "Player",
|
|
13
|
+
transform: { position: { x: 0, y: 1, z: 0 } },
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Payload
|
|
20
|
+
|
|
21
|
+
| Field | Type | Default | Description |
|
|
22
|
+
| --- | --- | --- | --- |
|
|
23
|
+
| `name` | `string` | `"Capsule"` | Display name. |
|
|
24
|
+
| `transform` | `TransformData` | identity | Position / rotation (radians) / scale. |
|
|
25
|
+
| `parentId` | `EntityId \| null` | `null` | Optional parent entity. |
|
|
26
|
+
|
|
27
|
+
## Components attached
|
|
28
|
+
|
|
29
|
+
`Transform`, `Object3DRef`, `Name`, `EntityType`, `ParentId`, `Selectable`, `Mesh`, `Material`, `MeshGeometry`.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Cube
|
|
2
|
+
|
|
3
|
+
A unit `1×1×1` `THREE.BoxGeometry` mesh with a default white `MeshStandardMaterial`.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { Behaviour, ObjectManagementSystem } from "@relu-interactives/spatial-ecs";
|
|
7
|
+
|
|
8
|
+
export default class SpawnCube extends Behaviour {
|
|
9
|
+
init() {
|
|
10
|
+
const objects = this.world.getSystem(ObjectManagementSystem);
|
|
11
|
+
objects?.requestCreate("cube", {
|
|
12
|
+
name: "Crate",
|
|
13
|
+
transform: { position: { x: 0, y: 1, z: 0 } },
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Payload
|
|
20
|
+
|
|
21
|
+
| Field | Type | Default | Description |
|
|
22
|
+
| --- | --- | --- | --- |
|
|
23
|
+
| `name` | `string` | `"Cube"` | Display name. |
|
|
24
|
+
| `transform` | `TransformData` | identity | Position / rotation (radians) / scale. |
|
|
25
|
+
| `parentId` | `EntityId \| null` | `null` | Optional parent entity. |
|
|
26
|
+
|
|
27
|
+
Default size is `1` along each axis — adjust by changing `transform.scale` after spawn (e.g. `getComponent(id, TransformComponent).scale.x = 2`).
|
|
28
|
+
|
|
29
|
+
## Components attached
|
|
30
|
+
|
|
31
|
+
`Transform`, `Object3DRef`, `Name`, `EntityType`, `ParentId`, `Selectable`, `Mesh`, `Material`, `MeshGeometry`.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Cylinder
|
|
2
|
+
|
|
3
|
+
A `THREE.CylinderGeometry` with radius `0.5`, height `1`, and 20 radial segments.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { Behaviour, ObjectManagementSystem } from "@relu-interactives/spatial-ecs";
|
|
7
|
+
|
|
8
|
+
export default class SpawnCylinder extends Behaviour {
|
|
9
|
+
init() {
|
|
10
|
+
const objects = this.world.getSystem(ObjectManagementSystem);
|
|
11
|
+
objects?.requestCreate("cylinder", {
|
|
12
|
+
name: "Pillar",
|
|
13
|
+
transform: { position: { x: 0, y: 0.5, z: 0 } },
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Payload
|
|
20
|
+
|
|
21
|
+
| Field | Type | Default | Description |
|
|
22
|
+
| --- | --- | --- | --- |
|
|
23
|
+
| `name` | `string` | `"Cylinder"` | Display name. |
|
|
24
|
+
| `transform` | `TransformData` | identity | Position / rotation (radians) / scale. |
|
|
25
|
+
| `parentId` | `EntityId \| null` | `null` | Optional parent entity. |
|
|
26
|
+
|
|
27
|
+
## Components attached
|
|
28
|
+
|
|
29
|
+
`Transform`, `Object3DRef`, `Name`, `EntityType`, `ParentId`, `Selectable`, `Mesh`, `Material`, `MeshGeometry`.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Directional Light
|
|
2
|
+
|
|
3
|
+
A parallel-ray light source — like the sun. Casts shadows by default.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { Behaviour, ObjectManagementSystem } from "@relu-interactives/spatial-ecs";
|
|
7
|
+
|
|
8
|
+
export default class SpawnSun extends Behaviour {
|
|
9
|
+
init() {
|
|
10
|
+
const objects = this.world.getSystem(ObjectManagementSystem);
|
|
11
|
+
objects?.requestCreate("directionalLight", {
|
|
12
|
+
name: "Sun",
|
|
13
|
+
transform: { position: { x: 5, y: 8, z: 5 } },
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Payload
|
|
20
|
+
|
|
21
|
+
| Field | Type | Default | Description |
|
|
22
|
+
| --- | --- | --- | --- |
|
|
23
|
+
| `name` | `string` | `"Directional Light"` | Display name. |
|
|
24
|
+
| `transform.position` | `{ x, y, z }` | `(3, 6, 4)` | Light position (direction is `target − position`). |
|
|
25
|
+
| `transform.rotation` / `scale` | — | identity | Standard transform fields. |
|
|
26
|
+
| `parentId` | `EntityId \| null` | `null` | Optional parent entity. |
|
|
27
|
+
|
|
28
|
+
Default color `#ffffff`, intensity `1.5`, `castShadow: true`.
|
|
29
|
+
|
|
30
|
+
## Components attached
|
|
31
|
+
|
|
32
|
+
`Transform`, `Object3DRef`, `Name`, `EntityType`, `ParentId`, `Selectable`, `Light`.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Empty
|
|
2
|
+
|
|
3
|
+
An invisible `THREE.Group`. Useful as a parent / pivot / spawn anchor.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { Behaviour, ObjectManagementSystem } from "@relu-interactives/spatial-ecs";
|
|
7
|
+
|
|
8
|
+
export default class SpawnAnchor extends Behaviour {
|
|
9
|
+
init() {
|
|
10
|
+
const objects = this.world.getSystem(ObjectManagementSystem);
|
|
11
|
+
objects?.requestCreate("empty", {
|
|
12
|
+
name: "SpawnPoint",
|
|
13
|
+
transform: { position: { x: 0, y: 0, z: -3 } },
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Payload
|
|
20
|
+
|
|
21
|
+
| Field | Type | Default | Description |
|
|
22
|
+
| --- | --- | --- | --- |
|
|
23
|
+
| `name` | `string` | `"Empty"` | Display name. |
|
|
24
|
+
| `transform` | `TransformData` | identity | Position / rotation (radians) / scale. |
|
|
25
|
+
| `parentId` | `EntityId \| null` | `null` | Optional parent entity. |
|
|
26
|
+
|
|
27
|
+
## Components attached
|
|
28
|
+
|
|
29
|
+
`Transform`, `Object3DRef`, `Name`, `EntityType`, `ParentId`, `Selectable`.
|
|
30
|
+
|
|
31
|
+
(No mesh/material — Empties are pure transform anchors.)
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Image Target
|
|
2
|
+
|
|
3
|
+
An AR image-tracking anchor. Children of an image-target entity are revealed and aligned when the tracker recognizes the printed image at runtime.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { Behaviour, ObjectManagementSystem } from "@relu-interactives/spatial-ecs";
|
|
7
|
+
|
|
8
|
+
export default class SpawnTarget extends Behaviour {
|
|
9
|
+
init() {
|
|
10
|
+
const objects = this.world.getSystem(ObjectManagementSystem);
|
|
11
|
+
objects?.requestCreate("imageTarget", {
|
|
12
|
+
name: "PosterTarget",
|
|
13
|
+
path: "/assets/targets/poster.png",
|
|
14
|
+
options: {
|
|
15
|
+
compiledTargetUrl: "/assets/targets/poster.mind",
|
|
16
|
+
},
|
|
17
|
+
}, (entityId) => {
|
|
18
|
+
// Parent renderable content under the target so it shows when tracked.
|
|
19
|
+
objects?.requestCreate("model", {
|
|
20
|
+
name: "Reveal",
|
|
21
|
+
path: "/assets/models/reveal.glb",
|
|
22
|
+
parentId: entityId,
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Payload
|
|
30
|
+
|
|
31
|
+
| Field | Type | Default | Description |
|
|
32
|
+
| --- | --- | --- | --- |
|
|
33
|
+
| `name` | `string` | `"Image Target"` | Display name. |
|
|
34
|
+
| `path` | `string` | `""` | URL of the source image used as a visual reference in the editor. |
|
|
35
|
+
| `transform` | `TransformData` | identity | Position / rotation / scale (usually left at identity — the tracker drives the transform). |
|
|
36
|
+
| `parentId` | `EntityId \| null` | `null` | Optional parent entity. |
|
|
37
|
+
|
|
38
|
+
### `options`
|
|
39
|
+
|
|
40
|
+
| Option | Type | Description |
|
|
41
|
+
| --- | --- | --- |
|
|
42
|
+
| `targets` | `ImageTargetReference[]` | Optional list of target references when bundling multiple images into one compiled file. |
|
|
43
|
+
| `compiledTargetUrl` | `string` | URL to the compiled `.mind` file used by the tracker. |
|
|
44
|
+
| `compiledTargetDir` | `string` | Optional directory containing compiled target files. |
|
|
45
|
+
|
|
46
|
+
## Components attached
|
|
47
|
+
|
|
48
|
+
`Transform`, `Object3DRef`, `Name`, `EntityType`, `ParentId`, `Selectable`, `ImageTarget`, `ImageTargetAnchor`.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Image
|
|
2
|
+
|
|
3
|
+
A flat textured plane that auto-sizes to the loaded image's aspect ratio. Useful for billboards, UI quads, or photo planes.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { Behaviour, ObjectManagementSystem } from "@relu-interactives/spatial-ecs";
|
|
7
|
+
|
|
8
|
+
export default class SpawnPoster extends Behaviour {
|
|
9
|
+
init() {
|
|
10
|
+
const objects = this.world.getSystem(ObjectManagementSystem);
|
|
11
|
+
objects?.requestCreate("image", {
|
|
12
|
+
name: "Poster",
|
|
13
|
+
path: "/assets/images/poster.png",
|
|
14
|
+
transform: { position: { x: 0, y: 1.5, z: -2 } },
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Payload
|
|
21
|
+
|
|
22
|
+
| Field | Type | Default | Description |
|
|
23
|
+
| --- | --- | --- | --- |
|
|
24
|
+
| `name` | `string` | `"Image"` | Display name. |
|
|
25
|
+
| `path` | `string` | `""` | URL or local-asset path to the image (PNG / JPG). |
|
|
26
|
+
| `transform` | `TransformData` | identity | Position / rotation / scale. |
|
|
27
|
+
| `parentId` | `EntityId \| null` | `null` | Optional parent entity. |
|
|
28
|
+
|
|
29
|
+
The plane is created at `1×1` and rescaled in X by `width / height` once the texture loads.
|
|
30
|
+
|
|
31
|
+
## Components attached
|
|
32
|
+
|
|
33
|
+
`Transform`, `Object3DRef`, `Name`, `EntityType`, `ParentId`, `Selectable`, `Image`.
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# Spawning Objects
|
|
2
|
+
|
|
3
|
+
`ObjectManagementSystem` is the runtime factory the editor uses to create every built-in object kind. From inside a `Behaviour` you can ask it to spawn the same primitives at runtime — pre-wired with all of their default components.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { Behaviour, ObjectManagementSystem } from "@relu-interactives/spatial-ecs";
|
|
7
|
+
|
|
8
|
+
export default class Example extends Behaviour {
|
|
9
|
+
init() {
|
|
10
|
+
const objects = this.world.getSystem(ObjectManagementSystem);
|
|
11
|
+
objects?.requestCreate("cube", { name: "MyCube" }, (entityId) => {
|
|
12
|
+
console.log("spawned", entityId);
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## The `requestCreate` payload
|
|
19
|
+
|
|
20
|
+
Every kind accepts the same envelope:
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
objects.requestCreate(
|
|
24
|
+
kind, // one of the supported kinds below
|
|
25
|
+
payload, // common + kind-specific fields (see each page)
|
|
26
|
+
onCreated?, // optional callback (entityId) => void
|
|
27
|
+
);
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Common payload fields available on every kind:
|
|
31
|
+
|
|
32
|
+
| Field | Type | Description |
|
|
33
|
+
| --- | --- | --- |
|
|
34
|
+
| `name` | `string` | Display name. Defaults to a sensible label per kind (e.g. `"Cube"`). |
|
|
35
|
+
| `transform.position` | `{ x, y, z }` | World-space position. |
|
|
36
|
+
| `transform.rotation` | `{ x, y, z }` | Euler rotation in radians. |
|
|
37
|
+
| `transform.scale` | `{ x, y, z }` | Per-axis scale. Defaults to `1`. |
|
|
38
|
+
| `parentId` | `EntityId \| null` | Attach the new entity under another entity. |
|
|
39
|
+
|
|
40
|
+
Kind-specific fields go on `payload.path` (asset URL) or `payload.options` (typed options bag). Each page below lists exactly what is read.
|
|
41
|
+
|
|
42
|
+
## Use `requestCreate` (queued) vs `createNow` (immediate)
|
|
43
|
+
|
|
44
|
+
| Method | Returns | When to use |
|
|
45
|
+
| --- | --- | --- |
|
|
46
|
+
| `requestCreate(kind, payload, onCreated?)` | `void` (callback fires after creation) | Default. Schedules creation to run between frames so it never collides with other systems. |
|
|
47
|
+
| `createNow(kind, world, payload)` | `EntityId` | When you need the id synchronously (rare). Skips the queue. |
|
|
48
|
+
|
|
49
|
+
## Supported kinds
|
|
50
|
+
|
|
51
|
+
### Primitives
|
|
52
|
+
|
|
53
|
+
- [Cube](./cube)
|
|
54
|
+
- [Sphere](./sphere)
|
|
55
|
+
- [Plane](./plane)
|
|
56
|
+
- [Capsule](./capsule)
|
|
57
|
+
- [Cylinder](./cylinder)
|
|
58
|
+
- [Empty](./empty)
|
|
59
|
+
|
|
60
|
+
### Media
|
|
61
|
+
|
|
62
|
+
- [Model](./model)
|
|
63
|
+
- [Image](./image)
|
|
64
|
+
- [Sprite](./sprite)
|
|
65
|
+
- [Video](./video)
|
|
66
|
+
- [Audio](./audio)
|
|
67
|
+
|
|
68
|
+
### Tracking & Camera
|
|
69
|
+
|
|
70
|
+
- [Image Target](./image-target)
|
|
71
|
+
- [Camera](./camera)
|
|
72
|
+
|
|
73
|
+
### Lights
|
|
74
|
+
|
|
75
|
+
- [Ambient Light](./ambient-light)
|
|
76
|
+
- [Directional Light](./directional-light)
|
|
77
|
+
- [Point Light](./point-light)
|
|
78
|
+
- [Spot Light](./spot-light)
|
|
79
|
+
- [Area Light](./area-light)
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Model
|
|
2
|
+
|
|
3
|
+
Loads a glTF / glb model (with optional Draco compression). The entity is created immediately; the model meshes attach asynchronously once the file is loaded.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { Behaviour, ObjectManagementSystem } from "@relu-interactives/spatial-ecs";
|
|
7
|
+
|
|
8
|
+
export default class SpawnModel extends Behaviour {
|
|
9
|
+
init() {
|
|
10
|
+
const objects = this.world.getSystem(ObjectManagementSystem);
|
|
11
|
+
objects?.requestCreate("model", {
|
|
12
|
+
name: "Robot",
|
|
13
|
+
path: "/assets/models/robot.glb",
|
|
14
|
+
transform: { position: { x: 0, y: 0, z: 0 } },
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Payload
|
|
21
|
+
|
|
22
|
+
| Field | Type | Default | Description |
|
|
23
|
+
| --- | --- | --- | --- |
|
|
24
|
+
| `name` | `string` | `"Model"` | Display name. |
|
|
25
|
+
| `path` | `string` | `""` | URL or local-asset path to a `.glb` / `.gltf`. If empty, an anchor is created with no mesh. |
|
|
26
|
+
| `transform` | `TransformData` | identity | Position / rotation / scale. |
|
|
27
|
+
| `parentId` | `EntityId \| null` | `null` | Optional parent entity. |
|
|
28
|
+
|
|
29
|
+
## Components attached
|
|
30
|
+
|
|
31
|
+
`Transform`, `Object3DRef`, `Name`, `EntityType`, `ParentId`, `Selectable`, `Model`, `MeshGeometry`. If the loaded file contains animation clips, an `Animation` component is also attached automatically.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Plane
|
|
2
|
+
|
|
3
|
+
A `100 × 100` double-sided `THREE.PlaneGeometry`. By default it is rotated `-π/2` on the X-axis so it lies flat (XZ ground plane).
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { Behaviour, ObjectManagementSystem } from "@relu-interactives/spatial-ecs";
|
|
7
|
+
|
|
8
|
+
export default class SpawnFloor extends Behaviour {
|
|
9
|
+
init() {
|
|
10
|
+
const objects = this.world.getSystem(ObjectManagementSystem);
|
|
11
|
+
objects?.requestCreate("plane", { name: "Floor" });
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Payload
|
|
17
|
+
|
|
18
|
+
| Field | Type | Default | Description |
|
|
19
|
+
| --- | --- | --- | --- |
|
|
20
|
+
| `name` | `string` | `"Plane"` | Display name. |
|
|
21
|
+
| `transform.position` | `{ x, y, z }` | `(0, 0, 0)` | Position. |
|
|
22
|
+
| `transform.rotation` | `{ x, y, z }` | `(-π/2, 0, 0)` | Default lies the plane flat. Pass your own to override. |
|
|
23
|
+
| `transform.scale` | `{ x, y, z }` | `(1, 1, 1)` | Per-axis scale. |
|
|
24
|
+
| `parentId` | `EntityId \| null` | `null` | Optional parent entity. |
|
|
25
|
+
|
|
26
|
+
> [!TIP]
|
|
27
|
+
> Pass `transform.rotation` explicitly to make a wall: `{ x: 0, y: 0, z: 0 }` keeps it vertical.
|
|
28
|
+
|
|
29
|
+
## Components attached
|
|
30
|
+
|
|
31
|
+
`Transform`, `Object3DRef`, `Name`, `EntityType`, `ParentId`, `Selectable`, `Mesh`, `Material`, `MeshGeometry`.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Point Light
|
|
2
|
+
|
|
3
|
+
An omnidirectional light that radiates equally in all directions, with falloff over `distance`.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { Behaviour, ObjectManagementSystem } from "@relu-interactives/spatial-ecs";
|
|
7
|
+
|
|
8
|
+
export default class SpawnTorch extends Behaviour {
|
|
9
|
+
init() {
|
|
10
|
+
const objects = this.world.getSystem(ObjectManagementSystem);
|
|
11
|
+
objects?.requestCreate("pointLight", {
|
|
12
|
+
name: "Torch",
|
|
13
|
+
transform: { position: { x: 0, y: 2, z: 0 } },
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Payload
|
|
20
|
+
|
|
21
|
+
| Field | Type | Default | Description |
|
|
22
|
+
| --- | --- | --- | --- |
|
|
23
|
+
| `name` | `string` | `"Point Light"` | Display name. |
|
|
24
|
+
| `transform.position` | `{ x, y, z }` | `(2, 3, 2)` | Light position. |
|
|
25
|
+
| `transform.rotation` / `scale` | — | identity | Standard transform fields. |
|
|
26
|
+
| `parentId` | `EntityId \| null` | `null` | Optional parent entity. |
|
|
27
|
+
|
|
28
|
+
Default color `#ffffff`, intensity `1`, distance `10`.
|
|
29
|
+
|
|
30
|
+
## Components attached
|
|
31
|
+
|
|
32
|
+
`Transform`, `Object3DRef`, `Name`, `EntityType`, `ParentId`, `Selectable`, `Light`.
|