XRInputSourcesChangeEvent

Secure context
This feature is available only in secure contexts (HTTPS), in some or all supporting browsers .

The WebXR Device API interface XRInputSourcesChangeEvent is used to represent the inputsourceschange event sent to an XRSession when the set of available WebXR input controllers changes.

构造函数

XRInputSourcesChangeEvent()
Creates and returns a new XRInputSourcesChangeEvent object configured as indicated by the given XRInputSourcesChangeEventInit object. The specified type must be inputsourceschange , which is the only event that uses this interface.

特性

added 只读
An array of zero or more XRInputSource objects, each representing an input device which has been newly connected or enabled for use.
removed 只读
An array of zero or more XRInputSource objects representing the input devices newly connected or enabled for use.
session 只读
XRSession to which this input source change event is being directed.

方法

While XRInputSourcesChangeEvent defines no methods of its own, it inherits methods from its parent interface, Event .

Event types

inputsourceschange
Delivered to the XRSession when the set of input devices available to it changes.

范例

The following example shows how to set up an event handler which uses inputsourceschange events to detect newly-available pointing devices and to load their models in preparation to display them in the next animation frame.

xrSession.addEventListener("inputsourceschange", onInputSourcesChange);
function onInputSourcesChange(event) {
  for (let input of event.added) {
    if (input.targetRayMode == "tracked-pointer") {
      loadControllerMesh(input);
    }
  }
}
					

You can also add a handler for inputsourceschange events by setting the oninputsourceschange event handler:

xrSession.oninputsourceschange = onInputSourcesChange;
					

规范

规范 状态 Comment
WebXR 设备 API
The definition of 'XRInputSourcesChangeEvent' in that specification.
工作草案 初始定义。

浏览器兼容性

更新 GitHub 上的兼容性数据
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
XRInputSourcesChangeEvent 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
XRInputSourcesChangeEvent() 构造函数 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
added 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
removed 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
session 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

图例

完整支持
完整支持
不支持
不支持