Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. XRTransientInputHitTestSource

XRTransientInputHitTestSource

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Secure context: This feature is available only insecure contexts (HTTPS), in some or allsupporting browsers.

Experimental:This is anexperimental technology
Check theBrowser compatibility table carefully before using this in production.

TheXRTransientInputHitTestSource interface of theWebXR Device API handles transient input hit test subscriptions. You can get anXRTransientInputHitTestSource object by calling theXRSession.requestHitTestSourceForTransientInput().

This object doesn't itself contain transient input hit test results, but it is used to compute hit tests for eachXRFrame by callingXRFrame.getHitTestResultsForTransientInput(), which returnsXRTransientInputHitTestResult objects.

Instance properties

None.

Instance methods

XRTransientInputHitTestSource.cancel()Experimental

Unsubscribes from the transient input hit test.

Examples

Getting anXRTransientInputHitTestSource object for a session

Use theXRSession.requestHitTestSourceForTransientInput() method to get a transient input hit test source.

js
const xrSession = navigator.xr.requestSession("immersive-ar", {  requiredFeatures: ["local", "hit-test"],});let transientHitTestSource = null;xrSession  .requestHitTestSourceForTransientInput({    profile: "generic-touchscreen",    offsetRay: new XRRay(),  })  .then((touchScreenHitTestSource) => {    transientHitTestSource = touchScreenHitTestSource;  });// frame loopfunction onXRFrame(time, xrFrame) {  let hitTestResults = xrFrame.getHitTestResultsForTransientInput(    transientHitTestSource,  );  // do things with the transient hit test results}

Unsubscribe from a transient input hit test

To unsubscribe from a transient input hit test source, use theXRTransientInputHitTestSource.cancel() method. Since the object will no longer be usable, you can clean up and set theXRTransientInputHitTestSource object tonull.

js
transientHitTestSource.cancel();transientHitTestSource = null;

Specifications

Specification
WebXR Hit Test Module
# transient-input-hit-test-source-interface

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp