安全上下文
此特征只可用于
安全上下文
(HTTPS),在某些或所有
支持浏览器
.
XRInputSourceEvent()
constructor creates and returns a new
XRInputSourceEvent
object describing an event (state change) which has occurred on a WebXR user input device represented by an
XRInputSource
.
newInputSourceEvent = new XRInputSourceEvent(type, eventInitDict);
type
A
DOMString
indicating which of the input source events the new object will represent. Permitted values are listed under
事件类型
下文。
eventInitDict
XRInputSourceEventInit
dictionary which contains the values to assign to the new event's properties.
新的
XRInputSourceEvent
object representing the event described by the given
type
and
eventInitDict
.
select
XRSession
when the sending input source has fully completed a
primary action
.
selectend
XRSession
when an ongoing
primary action
ends, or when an input source with an ongoing primary action has been disconnected from the system.
selectstart
XRSession
when an input source begins its
primary 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
XRSession
when the sending input source has fully completed a
primary squeeze action
.
squeezeend
XRSession
when an ongoing
primary squeeze action
ends or when an input source with an ongoing primary squeeze action is disconnected.
squeezestart
XRSession
when an input source begins its
primary squeeze action
, indicating that the user has begun to grab, squeeze, or grip the controller.
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.
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 */
}
}
});
| 规范 | 状态 | 注释 |
|---|---|---|
|
WebXR 设备 API
The definition of 'XRInputSourceEvent' in that specification. |
工作草案 | 初始定义。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
XRInputSourceEvent
|
Chrome 79 | Edge 79 | Firefox 不支持 No | IE 不支持 No | Opera 不支持 No | Safari 不支持 No | WebView Android 不支持 No | Chrome Android 79 | Firefox Android 不支持 No | Opera Android 不支持 No | Safari iOS 不支持 No | Samsung Internet Android 11.2 |
XRInputSourceEvent()
构造函数
|
Chrome 79 | Edge 79 | Firefox 不支持 No | IE 不支持 No | Opera 不支持 No | Safari 不支持 No | WebView Android 不支持 No | Chrome Android 79 | Firefox Android 不支持 No | Opera Android 不支持 No | Safari iOS 不支持 No | Samsung Internet Android 11.2 |
frame
|
Chrome 79 | Edge 79 | Firefox 不支持 No | IE 不支持 No | Opera 不支持 No | Safari 不支持 No | WebView Android 不支持 No | Chrome Android 79 | Firefox Android 不支持 No | Opera Android 不支持 No | Safari iOS 不支持 No | Samsung Internet Android 11.2 |
inputSource
|
Chrome 79 | Edge 79 | Firefox 不支持 No | IE 不支持 No | Opera 不支持 No | Safari 不支持 No | WebView Android 不支持 No | Chrome Android 79 | Firefox Android 不支持 No | Opera Android 不支持 No | Safari iOS 不支持 No | Samsung Internet Android 11.2 |
完整支持
不支持
XRInputSourceEvent
XRInputSourceEvent()
Navigator.xr
WebGLRenderingContext.makeXRCompatible()
XR
XRBoundedReferenceSpace
XRFrame
XRInputSource
XRInputSourceArray
XRInputSourcesChangeEvent
XRPose
XRReferenceSpace
XRReferenceSpaceEvent
XRRenderState
XRRigidTransform
XRSession
XRSessionEvent
XRSpace
XRView
XRViewerPose
XRViewport
XRWebGLLayer