Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. XRFrame
  4. createAnchor()

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.

Syntax

js
createAnchor(pose, space)

Parameters

pose

AnXRRigidTransform object 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.

space

AnXRSpace object the pose is relative to.

Return value

APromise resolving to anXRAnchor object.

Examples

Creating an anchor

js
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

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp