安全上下文
此特征只可用于
安全上下文
(HTTPS),在某些或所有
支持浏览器
.
WebXR Device API's
XRInputSource
interface describes a single source of control input which is part of the user's WebXR-compatible virtual or augmented reality system.
The device is specific to the platform being used, but provides the direction in which it is being aimed and optionally may generate events if the user triggers performs actions using the device.
gamepad
只读
A
Gamepad
object describing the state of the buttons and axes on the XR input source, if it is a gamepad or comparable device. If the device isn't a gamepad-like device, this property's value is
NULL
.
XRInputSource
使用
Gamepad
interface from the
手柄 API
, this input device is strictly associated with the WebXR hardware and is not a general-purpose gaming device.
gripSpace
只读
XRSpace
whose origin tracks the pose which is used to render objects which should appear as if they're held in the hand indicated by
handedness
. The orientation of this space indicates the angle at which the hand is gripping the object. Read on in the main article on
gripSpace
for more details on how to use this space.
handedness
只读
DOMString
that indicates which hand the device represented by this
XRInputSource
is being used in, if any. The value will be
left
,
right
,或
none
.
profiles
只读
DOMString
objects, each specifying the name of an input profile describing the preferred visual representation and behavior of this input source.
targetRayMode
只读
A
DOMString
indicating the methodology used to produce the target ray:
gaze
,
tracked-pointer
,或
screen
.
targetRaySpace
只读
XRSpace
object defining the origin of the target ray and the direciton in which it extends. This space is established using the method defined by
targetRayMode
.
XRInputSource
interface defines no methods.
If the device provides an indication of the direction in which it is pointed, this is done using a target ray . This is a ray extending from the position of the device outward in the direction in which it is pointed.
If the device includes a trigger or other squeezable input, such as a hand gesture device that recognizes when the user squeezes their fist, that action is called a
primary squeeze action
. A primary squeeze action should correspond to a gripping act in reality, such as taking hold of an object or pressing a trigger on a tool or weapon. When a squeeze action begins, such as by the user pressing the trigger or tightening their grip, a
squeezestart
event is sent to the
XRSession
. Once the action is completed and the user has released the trigger or the grip, a
squeeze
event is sent. This is followed by a
squeezeend
, which is also sent if the action is aborted rather than completed.
If the device has a button or other pressable input control, it is a
primary input source
, and this button is a
primary action
. A primary action may occur when the user presses a button, clicks on a touchpad or the top button of a thumb stick, or uses a hand gesture or spoken command that invokes the button-like action. When a primary action begins, a
selectstart
event is sent to the
XRSession
. When the action has completed (such as when the user releases the button), a
select
event is sent. Finally, once that is done—or if the user aborts the action—a
selectend
event is sent to the session object.
An action may be aborted either by the user in some device-specific fashion or if the input device is disconnected before the action is completed.
Each input source has its own local coordinate system, which is described by the
gripSpace
property, which is an
XRSpace
used to map the input's coordinate system into the world coordinate system. The grip space's coordinate system can then be used to render objects so they appear to be held in the user's hand.
For more details on the input source's coordinate system, see the article that covers the
gripSpace
property in detail.
| 规范 | 状态 | 注释 |
|---|---|---|
|
WebXR 设备 API
The definition of 'XRInputSource' in that specification. |
工作草案 | 初始定义。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
XRInputSource
|
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 |
gamepad
|
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 |
gripSpace
|
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 |
handedness
|
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 |
profiles
|
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 |
targetRayMode
|
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 |
targetRaySpace
|
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 |
完整支持
不支持
XRInputSourceArray
XRSpace
XRInputSource
Navigator.xr
WebGLRenderingContext.makeXRCompatible()
XR
XRBoundedReferenceSpace
XRFrame
XRInputSourceArray
XRInputSourceEvent
XRInputSourcesChangeEvent
XRPose
XRReferenceSpace
XRReferenceSpaceEvent
XRRenderState
XRRigidTransform
XRSession
XRSessionEvent
XRSpace
XRView
XRViewerPose
XRViewport
XRWebGLLayer