XRFrame: createAnchor() method
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Experimental:This is anexperimental technology
Check theBrowser compatibility table carefully before using this in production.
Secure context: This feature is available only insecure contexts (HTTPS), in some or allsupporting browsers.
ThecreateAnchor() method of theXRFrame interface creates a free-floatingXRAnchor which will be fixed relative to the real world.
SeeXRHitTestResult.createAnchor() for creating an anchor from a hit test result that is attached to a real-world object.
In this article
Syntax
createAnchor(pose, space)Parameters
poseAn
XRRigidTransformobject with the initial pose where the anchor should be created. The system will make sure that the relationship with the physical world made at this moment in time is maintained as the tracking system's understanding of the world evolves.spaceAn
XRSpaceobject the pose is relative to.
Return value
Examples
>Creating an anchor
frame.createAnchor(anchorPose, referenceSpace).then( (anchor) => { // Do stuff with the anchor (assign objects that will be relative to this anchor) }, (error) => { console.error(`Could not create anchor: ${error}`); },);Specifications
| Specification |
|---|
| WebXR Anchors Module> # dom-xrframe-createanchor> |