Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. XRInputSourceArray
  4. length

XRInputSourceArray: length property

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Experimental:This is anexperimental technology
Check theBrowser compatibility table carefully before using this in production.

Secure context: This feature is available only insecure contexts (HTTPS), in some or allsupporting browsers.

The read-onlylength property returns an integer valueindicating the number of items in the input source list represented bytheXRInputSourceArray object.

Value

An integer value indicating the number ofXRInputSource objectsrepresenting WebXR input sources are included in the array.

Examples

In this example, a game that requires at least one input sourceuseslength to check this before proceeding to allow the user to play thegame.

js
let sources = xrSession.inputSources;if (sources.length === 0) {  showAlertDialog(    "You need to have at least one controller to play Super Duper Shark Jump Fest 9000.",    [      { label: "Shop Now", url: "https://www.example.com/shop/controllers" },      { label: "Quit", handler: quitGame },    ],  );}

Here, iflength is 0, ahypotheticalshowAlertDialog() function is called with a prompt stringexplaining the need for a controller, and an array of objects, each describing a buttonand what should happen when it's clicked. The first takes the user to an Amazon.comsearch for VR controllers, and the second calls aquitGame() function tostart shutting the game program down.

Specifications

Specification
WebXR Device API
# dom-xrinputsourcearray-length

Browser compatibility

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp