Movatterモバイル変換


[0]ホーム

URL:


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

XRHitTestResult: 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 theXRHitTestResult interface creates anXRAnchor from a hit test result that is attached to a real-world object.

Syntax

js
createAnchor()

Parameters

None.

Return value

APromise resolving with anXRAnchor object.

Examples

Creating an anchor from a hit test result

The following example starts with anXRHitTestResult retrieved by callingXRFrame.getHitTestResults(). After callingcreateAnchor(), the Promise resolves with anXRAnchor to attach a virtual object to that location.

js
hitTestResult.createAnchor().then(  (anchor) => {    // add anchored objects to the scene  },  (error) => {    console.error(`Could not create anchor: ${error}`);  },);

Specifications

Specification
WebXR Anchors Module
# dom-xrhittestresult-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