Skip to content

@relu-interactives/spatial-ecs


@relu-interactives/spatial-ecs / components

components ​

Classes ​

Components ​

ClassDescription
AnimationComponentAnimation 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.
AudioComponentPlays 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.
BoneAttachmentComponentFixes an entity to a bone of its PARENT's model — a sword in a hand, a hat on a head, a backpack on the chest — so it moves with every animation.
CameraComponentCamera 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.
EntityTypeTags an entity with the kind it was created from (cube, sphere, model, directionalLight, etc.). Factories use this to drive kind-specific behavior; the editor inspector uses it to select component editors.
EnvironmentScene environment settings: skybox (gradient/color/image), fog (linear/exponential), gravity vector for the physics world, and optional image-based lighting / tone mapping (values.lighting). Singleton-style — attached to one environment entity per scene.
FaceHeadComponentThe head in a face-tracking project. There is one, and it stands in for the person: in the editor it's a head you can see and place things on, and at runtime it follows the face the camera finds.
FaceAttachmentComponentFixes an entity to a place on its parent FaceHeadComponent: glasses to the bridge of the nose, a hat to the top of the head.
FaceMeshComponentA surface that follows the face and wears a picture: face paint, a mask, make-up, a glow. It sits on the skin and moves with expression, so a painted cheek stays on the cheek through a smile.
GrassComponentStylised grass on the terrain on the same entity: thousands of blades drawn as instances, swaying in the wind, thinning out with distance and gone past viewDistance. Blades are made around the camera as it moves and dropped behind it, in square chunks, so a huge terrain costs what's near.
ScatterComponentTrees, rocks and bushes scattered over the terrain on the same entity: drawn as instances in square chunks (each culled on its own), as flat pictures of themselves (impostors) past each item's impostor distance, and not at all past its cull distance. The same settings always place the same instances, so nothing about them is saved but the settings.
IKComponentInverse kinematics for a humanoid model: after the animation plays, each chain bends an arm or leg so its hand/foot reaches a target entity — the second hand on a rifle's grip, a hand on a door handle, a foot on a step. The elbow/knee keeps the animation's bend unless a pole entity says otherwise. Bones are found by humanoid name, so any rig the editor recognises works (Mixamo, auto-rigs, Unreal, VRM).
ImageComponentRenders a 2D image as a textured quad in the scene. Width/height are in world units. Texture loading is handled by the image system, which populates ImageComponent.texture and ImageComponent.object asynchronously.
ImageTargetImage-tracking target metadata used by AR projects. Holds the source images users uploaded plus the URL of the compiled .mind target file produced by the image-target compiler. Pair with ImageTargetAnchor on child entities that should appear when the target is detected.
ImageTargetAnchorMarks an entity as an anchor for an image-tracking target. The image tracking system reveals the entity when the referenced target is found and hides it when the target is lost.
InstanceSlotComponentMarks an entity as an instance slot owned by an InstancedMeshComponent group entity.
InstancedMeshComponentHolds authored instanced-mesh data for an entity that renders as a THREE.InstancedMesh. Supports primitive geometry kinds (cube, sphere, plane, capsule, cylinder).
LODComponentLevels of detail: simpler copies of a model drawn when it's small on screen, and an optional size or distance past which it isn't drawn at all.
LightComponentLight source attached to an entity. type selects the underlying three.js light class (directional, point, spot, ambient, hemisphere, rect-area). values carries authoring state including color, intensity, and type-specific fields (distance, decay, angle, penumbra, width, height).
MaterialComponentMaterial catalog for an entity. Tracks the live three.js materials (materials, material) plus serialized authoring state (values[]) mirrored from the inspector. Supports standard, basic, phong, and physical PBR types with optional texture map slots.
MeshComponentHolds the live three.js Object3D for an entity that renders as a primitive mesh (cube, sphere, plane, capsule, cylinder). For loaded GLTF/GLB models see ModelComponent; for the editable geometry parameters see MeshGeometryComponent.
MeshGeometryComponentEditable geometry parameters for primitive meshes (cube, sphere, plane, capsule, cylinder) and for model entities, whose only parameter is their pivot (see ModelMeshParameters). Holds the authoring values plus shadow casting/receiving flags. The mesh-geometry system rebuilds the underlying BufferGeometry when parameters change.
ModelComponentReferences a GLTF/GLB asset loaded from path. The model loading system resolves the asset asynchronously and populates ModelComponent.object once available; loading is deferred-tolerant so the entity exists before the model finishes loading. ModelComponent.loadState reports progress ("loading" → "loaded" or "error").
NameHuman-readable name for an entity. Shown in the editor hierarchy panel and preserved across save/reload.
NetworkIdentityComponentMarks an entity as shared between players. A scene object is simulated by the host (the first player in the room, then the longest connected); a spawned object belongs to the player who spawned it and leaves with them.
NetworkTransformComponentShares an entity's position and rotation. The owner moves it at once and sends updates; everyone else plays them back a little in the past, so movement is smooth however the packets arrive.
NetworkedPropsComponentNamed values shared with everyone: a health bar, a score. Only the entity's owner can change them, with this.network.setProp(). values holds the starting values, and a Behaviour hears changes in onNetworkProp.
NetworkSpawnerComponentGives each player an avatar: when a client connects it spawns playerPrefab as its own, placed around this entity.
XRMultiplayerComponentMultiplayer in VR and mixed reality. Each player's head and hands are shared and drawn for the others, and with colocation on, players in the same room line up their headsets by touching the same two real points. Put it on the XR Rig. Without it, an XR project with multiplayer still shares heads and hands with these defaults.
Object3DRefWraps the live THREE.Object3D for an entity. Almost every entity that renders to the scene carries an Object3DRef so transform sync, selection, and parenting systems can manipulate the underlying object.
OccluderComponentMarks a solid, roughly box-shaped object (a wall, a building, a rock face) as something that hides what's behind it. Each frame the engine draws every occluder's bounding box, shrunk by inset, into a small depth buffer and skips drawing objects that are completely behind them.
ParentIdRecords the parent entity id for hierarchical scene graphs. null means the entity is at the world root. The ObjectManagementSystem reconciles scene-graph parenting from this component each frame.
PhysicsComponentMarker base class for every ECS component. Subclass Component to declare a typed data container that systems can query.
PostprocessingPostprocessing stack settings (depth-of-field, bloom, vignette, chromatic aberration, noise, pixelation, tone mapping, hue/saturation, sepia, SMAA,
PrefabInstanceMarks the ROOT entity of a prefab instance and records its link to the source .prefab asset plus the instance's per-property overrides.
PrefabNodeStable identity for an entity that originated from a prefab asset.
ScriptComponentComponent holding the list of scripts attached to an entity. Loaded from the saved project; the runtime-side fields (scriptInstance, scriptInstances) are non-enumerable so they never leak into save data or undo history.
ScriptObjectComponentComponent for a script object — a single ScriptObject whose THREE.js visual is built by user code and runs in the editor AND at runtime. Unlike ScriptComponent this holds ONE script (not an entries array). The live instance ref is non-enumerable so it never leaks into save data or undo history.
SelectableToggles whether the editor selection system can pick this entity. When enabled is false, the entity is excluded from raycast hit tests.
SelectionTransformStateSingleton-style component (attached once to a system entity) that mirrors the editor's current transform-gizmo state into the ECS world. Persisted in snapshots so undo/redo restores the exact gizmo configuration.
SpriteComponentCamera-facing 2D sprite. Unlike ImageComponent, sprites use THREE.Sprite and always render as billboards.
StreamingComponentStreams an entity and everything under it: its models load when the player comes within loadDistance and are freed from memory (geometry, textures, GPU) once they're further than unloadDistance. Put it on a model, or on a group to stream a whole region (a "cell") at once.
TerrainComponentGround you can sculpt and paint: a heightmap drawn in chunks that get simpler with distance, painted in up to four colour layers, with a physics collider and an optional occluder role (hills hide what's behind them).
TransformComponentPosition, rotation, and scale of an entity in its parent's local space.
UIButtonComponentA pressable control.
UIPanelComponentA flat UI surface in the world — the backdrop menus and HUDs are built on.
UISliderComponentA draggable value control.
UITextComponentA block of text drawn onto a transparent canvas quad.
UIToggleComponentAn on/off switch.
VRTeleportAreaComponentMarks an entity's surface as a valid teleport destination.
VideoComponentPlays a video file as a texture on a quad. Supports green-screen keying (isGreenScreen, backgroundColor, similarity, smoothness, spill). The video element, texture, and material are runtime-only and re-created when the project loads.
XRAnchorComponentPins an entity to a real-world position.
XREnvironmentComponentMarks an entity as a piece of the user's REAL room, detected at runtime.
XRHandPoseComponentListens for hand poses and reports them to the entity's Behaviours.
XRInteractableComponentMakes an entity respond to XR pointers and hands.
XRInteractorComponentConfigures what the user sees as their hands, and hosts custom hand content.
XRInteractorSideComponentMarks an entity as the left or right hand slot of an XRInteractorComponent.
XRRigComponentMarks an entity as the XR rig — the player's movable origin.

Other ​

ClassDescription
CameraRigComponentMakes the camera it's on follow an entity. Add it to the camera entity and pick a target; there's nothing to script. Fields left null take the usual value for the mode.

Type Aliases ​

Type AliasDescription
AnimationComponentOptionsInitializer for AnimationComponent.
BoneHoldWhere an attached entity goes while certain clips play: a rifle slung on the back in Idle, a sword hidden in Swim.
BoneAttachmentOptionsOptional initializer for BoneAttachmentComponent.
CameraRuntimeTypeRuntime camera mode. 3d is a free camera; ar is composited over a tracked image/face feed; xr is driven by an immersive WebXR session (the headset owns the pose and projection — locomotion moves the camera's XR rig parent).
CameraProjectionProjection model.
CameraComponentOptionsOptional initializer for CameraComponent. Any field omitted falls back to the defaults documented on the component.
CameraRigModeHow the camera frames what it follows.
CameraRigLookHow the player turns the camera. auto is the usual one for the mode.
CameraRigOptionsOptional initializer for CameraRigComponent.
EnvironmentSkyboxTypeSkybox rendering modes. none disables skybox rendering entirely.
EnvironmentGradientEffectGradient distribution applied when EnvironmentSkyboxState.type is "gradient".
EnvironmentFogTypeFog distance models. none disables fog.
EnvironmentSkyboxImageProjectionHow an "image" skybox is projected.
EnvironmentToneMappingTone-mapping operator applied by the renderer. "none" leaves colours linear-clamped (three's NoToneMapping).
EnvironmentSkyboxStateSkybox configuration. Only the fields relevant to type are read at render time.
EnvironmentFogStateFog configuration. Mirrors three.js Fog / FogExp2.
EnvironmentLightingStateImage-based lighting and renderer colour settings. Every field is optional; the defaults below apply when a field is missing. When the whole block is absent the scene's environment map and the renderer's tone mapping are left untouched.
EnvironmentStateAggregated authoring state owned by Environment.
FaceHeadOptionsOptional initializer for FaceHeadComponent.
FaceAttachmentOptionsOptional initializer for FaceAttachmentComponent.
FaceMeshBlendHow a face mesh mixes with what's under it.
FaceMeshOptionsOptional initializer for FaceMeshComponent.
FoliageMaskWhere foliage may grow: by paint layer, height and slope.
GrassOptionsOptional initializer for GrassComponent.
ScatterItemOne kind of thing to scatter: a model, how many and how they vary.
ScatterOptionsOptional initializer for ScatterComponent.
IKLimbThe limb a chain moves: its end bone, by humanoid name.
IKChainOne limb reaching for an entity.
IKOptionsOptional initializer for IKComponent.
ImageTargetReferenceSingle uploaded image used as input to the image-target compiler.
ImageTargetAnchorOptionsOptional initializer for ImageTargetAnchor.
InstanceTransformPer-instance transform stored inside InstancedMeshComponent. All rotations are in radians.
InstancedMeshKindPrimitive geometry kinds and custom 3D model kind supported by instanced mesh rendering.
LodLevelOne extra level of detail: a simpler copy of the entity's model.
LODOptionsOptional initializer for LODComponent.
LightShadowStateOptional shadow tuning for a shadow-casting light (directional, spot, point). Only the fields present are applied; a missing field keeps three's default, and a light without a shadow block is never touched.
LightValueStateAuthoring state for LightComponent. Common fields apply to every light kind; the optional fields are only meaningful for specific kinds.
MaterialTypeValueSupported material classes. Each maps to a three.js Mesh*Material type.
TextureFilteringValueTexture sampling mode. smooth uses linear filtering; sharp uses nearest filtering for pixel-art look.
MaterialValueStateAuthoring state for a single slot in MaterialComponent.values. Mirrors the live three.js material so it can be re-applied when the project loads.
EditableMeshObjectKindEditable primitive kinds the mesh-geometry system can rebuild on the fly. model is a passthrough placeholder for entities that own a loaded GLTF/GLB instead.
CubeMeshParametersBox geometry parameters in world units.
PlaneMeshParametersPlane geometry parameters in world units.
RadiusMeshParametersRadius-only primitive parameters (sphere).
RadiusHeightMeshParametersRadius + height primitive parameters (capsule, cylinder).
ModelMeshParametersParameters of a model entity. Its only one is the pivot (0.17.0): a point in the file's space, in the entity's local units, that becomes the entity's origin. The loaded model sits inside the entity moved by -pivot, so the Transform positions, rotates and scales the model about that point. Absent (or the origin) means the file's own origin.
MeshGeometryParametersByKindMap from EditableMeshObjectKind to its parameter shape.
MeshGeometryParameters-
ModelLoadStateLoad progress of a ModelComponent's asset. "unloaded": streamed out of memory because the player is far away (see StreamingComponent); it loads again when they come back.
NetValueA value a networked prop can hold: anything that survives JSON.
NetworkTransformOptions-
XRAvatarStyle-
XRMultiplayerOptions-
OccluderOptionsOptional initializer for OccluderComponent.
RigidbodyTypeRigidbody body type: - dynamic: simulated by physics; affected by forces and gravity. - fixed: immovable static body. - kinematicPosition: moved by setting next position; ignores forces. - kinematicVelocity: moved by setting velocity; ignores forces.
RigidbodyStateAuthoring state for the rigidbody half of PhysicsComponent. Saved with the project.
ColliderShapeCollider primitive shape. trimesh derives geometry from the entity's mesh.
ColliderStateAuthoring state for the collider half of PhysicsComponent. Only the size fields relevant to ColliderState.shape are read at simulation time.
PhysicsStateCombined authoring state for PhysicsComponent. Saved with the project.
PostprocessingStateAggregated post-processing effect chain authored on the scene environment. Each sub-effect has its own enabled flag plus per-effect parameters.
ScriptEntryOne script attached to an entity. Multiple entries may target a single entity (different classes from the same or different files).
ScriptObjectRuntimeState-
ScriptObjectComponentInput-
TransformModeValueActive gizmo mode in the editor.
TransformSpaceValueReference frame for the active gizmo.
StreamingStateWhere a streamed entity is: its models freed, on their way, or shown.
StreamingOptionsOptional initializer for StreamingComponent.
TerrainLayerA paint layer: what a part of the terrain looks like.
TerrainOptionsOptional initializer for TerrainComponent.
Vec3Plain XYZ vector. All ECS transform fields use this shape rather than THREE.Vector3 so they save cleanly with the project.
TransformDataOptional initial values passed to TransformComponent. Missing axes default to 0 for position/rotation and 1 for scale.
UiIconPositionBeside the label, or above it (top, for tiles).
UIButtonOptionsOptional initializer for UIButtonComponent.
UiFollowModeHow a panel orients itself while the experience runs.
UiRendererModeWhat draws a widget tree: uikit (instanced, a few draw calls a menu), canvas (one texture per widget, every style feature), or auto.
UIPanelOptionsOptional initializer for UIPanelComponent.
UiSliderVariant-
UISliderOptionsOptional initializer for UISliderComponent.
UiTextAlign-
UiTextVAlign-
UITextOptionsOptional initializer for UITextComponent.
UiToggleVariant-
UIToggleOptionsOptional initializer for UIToggleComponent.
VrTeleportShapeFootprint of a teleport destination.
VRTeleportAreaOptionsOptional initializer for VRTeleportAreaComponent.
XRAnchorOptionsOptional initializer for XRAnchorComponent.
XrEnvironmentKindWhich WebXR module reported this piece of the room.
XrEnvironmentOrientationHow a detected plane sits in the world, when the runtime says.
XrHandPoseEntryOne pose an entity listens for.
XRHandPoseOptions-
XrGrabReachHow close the user must be to grab.
XrDistanceGrabBehaviorWhat a distance grab does to the object.
XrGrabGestureWhich gesture grabs the object.
XrAttachPointA hand-hold authored on the object.
XrGrabHandsHow many hands may hold the object at once, and what a second grab does.
XrTwoHandRotationHow the second hand affects orientation. See solveTwoHandTransform.
XRInteractableOptionsOptional initializer for XRInteractableComponent.
XrInteractorType-
XrHandPresetLook applied to tracked-hand meshes.
XrInteractorSideWhich hand a child interactor entity follows.
XRInteractorOptionsOptional initializer for XRInteractorComponent.
XrTrackingOriginWhere the headset's origin sits in the scene.
XrLocomotionModeHow the player moves through the scene in an immersive session.
XrEnvironmentPhysicsWhich real-world geometry becomes physics colliders in a passthrough session.
XrViewWhat the player sees in a mixed reality session: their room through passthrough, or a fully virtual world drawn over it (VR). Switched live with world.setXrView, with no new session and no tap.
XRRigOptionsOptional initializer for XRRigComponent.

Variables ​

VariableDescription
DEFAULT_ENVIRONMENT_LIGHTINGDefaults for every EnvironmentLightingState field.
DEFAULT_ENVIRONMENT_STATE-
DEFAULT_SCATTER_ITEM-
DEFAULT_INSTANCE_TRANSFORMDefault identity instance transform.
DEFAULT_INSTANCED_MESH_PARAMETERSDefault geometry parameters per instanced mesh kind. For "model" kind, cube params are stored as a placeholder (unused).
DEFAULT_MESH_GEOMETRY_PARAMETERS-
MODEL_NO_PATH_MESSAGEMessage used when a model entity has no asset path to load.
DEFAULT_RIGIDBODY_STATE-
DEFAULT_COLLIDER_STATE-
DEFAULT_PHYSICS_STATE-
DEFAULT_POSTPROCESSING_STATE-
DEFAULT_TERRAIN_LAYERSThe default layers: grass, dirt, rock, snow.
DEFAULT_TERRAIN_PAINT_RULESRock on steep slopes, snow up high: the default automatic paint.
DEFAULT_POSE_CURLS-
DEFAULT_POSE_DIRECTIONS-

Functions ​

FunctionDescription
normalizeBoneHoldA hold with every field filled in.
normalizeEnvironmentLightingNormalize a lighting block to a complete EnvironmentLightingState. Returns undefined when value is not an object, so a scene without the block stays without it.
normalizeScatterItem-
normalizeIKChainA chain with every field filled in.
setLodActiveLevel-
chooseLodLevelThe level to draw for an object covering screenSize of the screen height, given the level drawn now: -1 for culled. Pure, so it's tested on its own.
defaultMaterialValue-
setModelLoadStateWrite a model's load state as NON-ENUMERABLE own properties, so it never enters snapshots, undo history or saved projects. Always via defineProperty (the pattern setPhysicsLiveRef uses): plain assignment on a history-restored clone would create an ENUMERABLE property instead.
normalizePhysicsState-
setPhysicsLiveRef-
setStreamingStateWrite the runtime state non-enumerably, so it never reaches a save.
unloadDistanceOfThe distance a streamed entity is freed beyond.
createHandPoseEntryA pose entry with every field populated, for the editor and AI tools.
handPoseDefinitionForResolve an entry to the definition the matcher consumes.
createAttachPointAn attach point with every field populated, for the editor and AI tools.