Skip to content

@relu-interactives/spatial-ecs


@relu-interactives/spatial-ecs / components / XREnvironmentComponent

Class: XREnvironmentComponent ​

Defined in: components/XREnvironment.ts:26

Marks an entity as a piece of the user's REAL room, detected at runtime.

These entities are spawned by XREnvironmentSystem from WebXR plane and mesh detection — they are never authored, never saved, and vanish with the session. They exist as ordinary entities (rather than colliders hidden inside a system) so the normal physics pipeline builds their colliders, and so scripts can find them with a plain world.query(XREnvironmentComponent).

semanticLabel is what makes them useful to a game rather than just solid: it is how a script says "spawn the target on a WALL" or "only drop coins on the FLOOR". It is whatever the runtime reported — commonly floor, wall, ceiling, table, desk, couch, door, window — and is null on runtimes that classify nothing, so always handle the null case.

Extends ​

Constructors ​

Constructor ​

ts
new XREnvironmentComponent(
   kind, 
   semanticLabel?, 
   orientation?): XREnvironmentComponent;

Defined in: components/XREnvironment.ts:34

Parameters ​

ParameterTypeDefault value
kindXrEnvironmentKindundefined
semanticLabelstring | nullnull
orientation| XrEnvironmentOrientation | nullnull

Returns ​

XREnvironmentComponent

Overrides ​

Component.constructor

Properties ​

PropertyTypeDescriptionDefined in
kindXrEnvironmentKindWhether this came from plane detection or the room mesh.components/XREnvironment.ts:28
semanticLabelstring | nullThe runtime's classification, or null when it did not provide one.components/XREnvironment.ts:30
orientation| XrEnvironmentOrientation | nullPlane orientation, or null for mesh geometry and unclassified planes.components/XREnvironment.ts:32