Skip to content

@relu-interactives/spatial-ecs


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

Class: XRAnchorComponent ​

Defined in: components/XRAnchor.ts:33

Pins an entity to a real-world position.

A headset's idea of where the room is keeps being refined while a session runs — it re-recognises the space, corrects drift, and quietly shifts its coordinate system by a few centimetres. Content placed at fixed scene coordinates does not move with those corrections, so a vase carefully set on a real table gradually slides off it.

An anchor is the runtime's own handle on a point in the room. Attaching this component hands the entity's pose over to that handle, so the entity moves exactly as the runtime's understanding of the room moves and stays put relative to the real world.

Because the anchor OWNS the transform once created, moving the entity by script or by physics has no lasting effect — release it first if you want to move it, then re-anchor.

Anchors last only as long as the session. Persisting one across launches needs requestPersistentHandle, which is still a draft extension and not supported here.

Extends ​

Constructors ​

Constructor ​

ts
new XRAnchorComponent(options?): XRAnchorComponent;

Defined in: components/XRAnchor.ts:37

Parameters ​

ParameterType
options?XRAnchorOptions

Returns ​

XRAnchorComponent

Overrides ​

Component.constructor

Properties ​

PropertyTypeDescriptionDefined in
enabledbooleanWhether the entity should anchor. Turning this off releases the anchor.components/XRAnchor.ts:35