安全上下文
此特征只可用于
安全上下文
(HTTPS),在某些或所有
支持浏览器
.
XRInputSourceArray
接口的
entries()
method returns a JavaScript
iterator
which can then be used to iterate over the key/value pairs in the input source array.
Each item in the array is an
XRInputSource
对象。
Most frequently, you will use this in tandem with statements such as
for...of
.
let inputSourceIterator = xrInputSourceArray.entries();
for (let entry of xrInputSourceArray.entries()) {
/* ... */
}
None.
An
iterator
which can be used to walk through the list of
XRInputSource
objects included in the input source array.
This example snippet gets the list of inputs for a session and tries to handle each type of input device it supports using.
let sources = xrSession.inputSources;
for (let input of sources.entries()) {
if (input.gamepad) {
checkGamepad(input.gamepad);
} else {
if (input.targetRayMode === "tracked-pointer" &&
input.handedness === player.handedness) {
/* Handle main hand controller */
handleMainHandInput(input);
} else {
/* Handle other inputs */
}
}
}
For each input in the llist, gamepad inputs are dispatched to a
checkGamepad()
with the input's
Gamepad
object, taken from its
gamepad
property, as an input
For other devices, we look for
tracked-pointer
devices in the player's main hand, dispatching those to a
handleMainHandInput()
方法。
| 规范 | 状态 | 注释 |
|---|---|---|
|
WebXR 设备 API
The definition of 'XRInputSourceArray' in that specification. 1 |
工作草案 |
XRInputSourceArray
interface
|
[1]
见
Iterator-like methods
in
Information contained in a WebIDL file
for information on how an
iterable
declaration in an interface definition causes
entries()
,
forEach()
,
keys()
,和
values()
methods to be exposed from objects that implement the interface.
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
entries()
|
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
Navigator.xr
WebGLRenderingContext.makeXRCompatible()
XR
XRBoundedReferenceSpace
XRFrame
XRInputSource
XRInputSourceEvent
XRInputSourcesChangeEvent
XRPose
XRReferenceSpace
XRReferenceSpaceEvent
XRRenderState
XRRigidTransform
XRSession
XRSessionEvent
XRSpace
XRView
XRViewerPose
XRViewport
XRWebGLLayer