Skip to content

Variable: XRAnchor

const XRAnchor: Component<{ attached: { default: false; type: Boolean; }; }>

Defined in: packages/core/src/scene-understanding/anchor.ts:39

Component for anchoring entities to stable real‑world positions in AR/VR.

Remarks

  • Anchors provide persistent, stable positioning relative to the real world.
  • Entities with this component are automatically managed by SceneUnderstandingSystem.
  • The entity's object3D will be attached to a world‑anchored group for stable tracking.
  • Requires WebXR session with 'anchor' feature enabled.
  • Anchors persist across tracking loss and help maintain consistent positioning.
  • Once attached, the entity's transform is managed relative to the anchor's reference frame.
  • Internal attached property tracks whether the entity has been processed by the system.

Examples

ts
const marker = world.createEntity()
marker.addComponent(XRAnchor) // Will be anchored to current world position
ts
const hologram = world.createTransformEntity(hologramMesh)
hologram.addComponent(XRAnchor)
// The SceneUnderstandingSystem will anchor this at the current reference position

See

SceneUnderstandingSystem