Place a chair on the real floor
Updated
Your 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.
Place a chair on the real floor
#pragma lifecycle(startup, update)
let reticle;let hand;
function startup() { reticle = findEntity('Reticle'); hand = Input.xr.controller(0);}
function update() { const hit = XRRaycaster.fromViewer().hit(); reticle.visible = Boolean(hit); if (!hit) return;
reticle.position.copy(hit.point); reticle.quaternion.copy(hit.orientation);
if (hand.isReleased(XRButton.Trigger)) { const chair = spawn('Chair', { position: hit.point, enabled: true }); chair.getComponent(XRAnchorComponent).anchorAt(hit); }}How it works
Section titled “How it works”The script is explained step by step in Place a chair on the real floor.
Open it in XR Creator
Section titled “Open it in XR Creator”Download the project file below, then import it in XR Hub with Projects › New › Import, as described in Projects and templates. It opens in XR Creator with the same scene you see running above, each script already attached to its Behavior entity. From there you can edit the scripts, adjust components and their props, preview your changes, and deploy the result as a world of your own.
FirstArPlacement.xrproj