XR Anchor
Updated
Pins the entity to a real-world spot.
- Type
comp-xr-anchor- Script class
XRAnchorComponent- Per entity
- One
- Version
- 1.0.0
Read about it in XR anchors: what it does, how to use it from a script, and examples.
Events
Section titled “Events”Sent to the entity’s Signal Emitter as { entityId, eventType, data }. Compare eventType with the EventType constants.
XRAnchor::trackedXRAnchor::lostXRAnchor::restored
Live example
Section titled “Live example”Run it in the browser, read its scripts, and download it as an XR Creator project.
Live example
Place a chair on the real floorYour first AR placement: a ring follows the real surface under the viewer’s gaze, and the trigger or a tap places an anchored copy of a hidden chair there.
This one needs AR: open the page on an AR phone or a mixed-reality headset. On a desktop the ray meets no real surface, so the ring stays hidden and no chair is placed.
From a script
Section titled “From a script”#pragma lifecycle(startup)
function startup() { const component = self.parent.getComponent(XRAnchorComponent); if (component) log(component.props);}