Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. XRInputSourceEvent

XRInputSourceEvent

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.

TheWebXR Device API'sXRInputSourceEvent interface describes an event which has occurred on a WebXR user input device such as a hand controller, gaze tracking system, or motion tracking system. More specifically, they represent a change in the state of anXRInputSource.

To learn more about handling inputs in a WebXR project, see the articleInputs and input sources.

Event XRInputSourceEvent

Constructor

XRInputSourceEvent()

Creates and returns a newXRInputSourceEvent object whose properties match those provided in theeventInitDict dictionary provided.

Instance properties

frameRead only

AnXRFrame object providing the needed information about the event frame during which the event occurred. This frame may have been rendered in the past rather than being a current frame. Because this is anevent frame, not ananimation frame, you cannot call theXRFrame methodgetViewerPose() on it; instead, usegetPose().

inputSourceRead only

AnXRInputSource object indicating which input source generated the input event.

Instance methods

TheXRInputSourceEvent interface doesn't define any methods; however, several methods are inherited from the parent interface,Event.

Event types

select

Sent to anXRSession when the sending input source has fully completed aprimary action.

selectend

Sent to anXRSession when an ongoingprimary action ends, or when an input source with an ongoing primary action has been disconnected from the system.

selectstart

Sent to anXRSession when an input source begins itsprimary action, indicating that the user has begun a command-like input, such as pressing a trigger or button, issuing a spoken command, tapping on a touchpad, or the like.

squeeze

Sent to anXRSession when the sending input source has fully completed aprimary squeeze action.

squeezeend

Sent to anXRSession when an ongoingprimary squeeze action ends or when an input source with an ongoing primary squeeze action is disconnected.

squeezestart

Sent to anXRSession when an input source begins itsprimary squeeze action, indicating that the user has begun to grab, squeeze, or grip the controller.

Examples

The code below sets up handlers for primary action events in order to determine when the user clicks on (shoots at/pokes at/whatever) objects in the scene.

js
xrSession.addEventListener("select", (event) => {  let targetRayPose = event.frame.getPose(    event.inputSource.targetRaySpace,    myRefSpace,  );  if (targetRayPose) {    let hit = myHitTest(targetRayPose.transform);    if (hit) {      /* handle the hit */    }  }});

Specifications

Specification
WebXR Device API
# xrinputsourceevent-interface

Browser compatibility

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp