class_webxrinterface.rst 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/3.6/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/3.6/modules/webxr/doc_classes/WebXRInterface.xml.
  6. .. _class_WebXRInterface:
  7. WebXRInterface
  8. ==============
  9. **Inherits:** :ref:`ARVRInterface<class_ARVRInterface>` **<** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
  10. AR/VR interface using WebXR.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. WebXR is an open standard that allows creating VR and AR applications that run in the web browser.
  15. As such, this interface is only available when running in an HTML5 export.
  16. WebXR supports a wide range of devices, from the very capable (like Valve Index, HTC Vive, Oculus Rift and Quest) down to the much less capable (like Google Cardboard, Oculus Go, GearVR, or plain smartphones).
  17. Since WebXR is based on Javascript, it makes extensive use of callbacks, which means that **WebXRInterface** is forced to use signals, where other AR/VR interfaces would instead use functions that return a result immediately. This makes **WebXRInterface** quite a bit more complicated to initialize than other AR/VR interfaces.
  18. Here's the minimum code required to start an immersive VR session:
  19. ::
  20. extends Spatial
  21. var webxr_interface
  22. var vr_supported = false
  23. func _ready():
  24. # We assume this node has a button as a child.
  25. # This button is for the user to consent to entering immersive VR mode.
  26. $Button.connect("pressed", self, "_on_Button_pressed")
  27. webxr_interface = ARVRServer.find_interface("WebXR")
  28. if webxr_interface:
  29. # Map to the standard button/axis ids when possible.
  30. webxr_interface.xr_standard_mapping = true
  31. # WebXR uses a lot of asynchronous callbacks, so we connect to various
  32. # signals in order to receive them.
  33. webxr_interface.connect("session_supported", self, "_webxr_session_supported")
  34. webxr_interface.connect("session_started", self, "_webxr_session_started")
  35. webxr_interface.connect("session_ended", self, "_webxr_session_ended")
  36. webxr_interface.connect("session_failed", self, "_webxr_session_failed")
  37. # This returns immediately - our _webxr_session_supported() method
  38. # (which we connected to the "session_supported" signal above) will
  39. # be called sometime later to let us know if it's supported or not.
  40. webxr_interface.is_session_supported("immersive-vr")
  41. func _webxr_session_supported(session_mode, supported):
  42. if session_mode == 'immersive-vr':
  43. vr_supported = supported
  44. func _on_Button_pressed():
  45. if not vr_supported:
  46. OS.alert("Your browser doesn't support VR")
  47. return
  48. # We want an immersive VR session, as opposed to AR ('immersive-ar') or a
  49. # simple 3DoF viewer ('viewer').
  50. webxr_interface.session_mode = 'immersive-vr'
  51. # 'bounded-floor' is room scale, 'local-floor' is a standing or sitting
  52. # experience (it puts you 1.6m above the ground if you have 3DoF headset),
  53. # whereas as 'local' puts you down at the ARVROrigin.
  54. # This list means it'll first try to request 'bounded-floor', then
  55. # fallback on 'local-floor' and ultimately 'local', if nothing else is
  56. # supported.
  57. webxr_interface.requested_reference_space_types = 'bounded-floor, local-floor, local'
  58. # In order to use 'local-floor' or 'bounded-floor' we must also
  59. # mark the features as required or optional.
  60. webxr_interface.required_features = 'local-floor'
  61. webxr_interface.optional_features = 'bounded-floor'
  62. # This will return false if we're unable to even request the session,
  63. # however, it can still fail asynchronously later in the process, so we
  64. # only know if it's really succeeded or failed when our
  65. # _webxr_session_started() or _webxr_session_failed() methods are called.
  66. if not webxr_interface.initialize():
  67. OS.alert("Failed to initialize")
  68. return
  69. func _webxr_session_started():
  70. $Button.visible = false
  71. # This tells Godot to start rendering to the headset.
  72. get_viewport().arvr = true
  73. # This will be the reference space type you ultimately got, out of the
  74. # types that you requested above. This is useful if you want the game to
  75. # work a little differently in 'bounded-floor' versus 'local-floor'.
  76. print ("Reference space type: " + webxr_interface.reference_space_type)
  77. func _webxr_session_ended():
  78. $Button.visible = true
  79. # If the user exits immersive mode, then we tell Godot to render to the web
  80. # page again.
  81. get_viewport().arvr = false
  82. func _webxr_session_failed(message):
  83. OS.alert("Failed to initialize: " + message)
  84. There are several ways to handle "controller" input:
  85. - Using :ref:`ARVRController<class_ARVRController>` nodes and their :ref:`ARVRController.button_pressed<class_ARVRController_signal_button_pressed>` and :ref:`ARVRController.button_release<class_ARVRController_signal_button_release>` signals. This is how controllers are typically handled in AR/VR apps in Godot, however, this will only work with advanced VR controllers like the Oculus Touch or Index controllers, for example. The buttons codes are defined by `Section 3.3 of the WebXR Gamepads Module <https://immersive-web.github.io/webxr-gamepads-module/#xr-standard-gamepad-mapping>`__.
  86. - Using :ref:`Node._unhandled_input<class_Node_method__unhandled_input>` and :ref:`InputEventJoypadButton<class_InputEventJoypadButton>` or :ref:`InputEventJoypadMotion<class_InputEventJoypadMotion>`. This works the same as normal joypads, except the :ref:`InputEvent.device<class_InputEvent_property_device>` starts at 100, so the left controller is 100 and the right controller is 101, and the button codes are also defined by `Section 3.3 of the WebXR Gamepads Module <https://immersive-web.github.io/webxr-gamepads-module/#xr-standard-gamepad-mapping>`__.
  87. - Using the :ref:`select<class_WebXRInterface_signal_select>`, :ref:`squeeze<class_WebXRInterface_signal_squeeze>` and related signals. This method will work for both advanced VR controllers, and non-traditional "controllers" like a tap on the screen, a spoken voice command or a button press on the device itself. The ``controller_id`` passed to these signals is the same id as used in :ref:`ARVRController.controller_id<class_ARVRController_property_controller_id>`.
  88. You can use one or all of these methods to allow your game or app to support a wider or narrower set of devices and input methods, or to allow more advanced interactions with more advanced devices.
  89. .. rst-class:: classref-introduction-group
  90. Tutorials
  91. ---------
  92. - `How to make a VR game for WebXR with Godot <https://www.snopekgames.com/blog/2020/how-make-vr-game-webxr-godot>`__
  93. .. rst-class:: classref-reftable-group
  94. Properties
  95. ----------
  96. .. table::
  97. :widths: auto
  98. +-------------------------------------------------+-------------------------------------------------------------------------------------------------------+
  99. | :ref:`PoolVector3Array<class_PoolVector3Array>` | :ref:`bounds_geometry<class_WebXRInterface_property_bounds_geometry>` |
  100. +-------------------------------------------------+-------------------------------------------------------------------------------------------------------+
  101. | :ref:`String<class_String>` | :ref:`optional_features<class_WebXRInterface_property_optional_features>` |
  102. +-------------------------------------------------+-------------------------------------------------------------------------------------------------------+
  103. | :ref:`String<class_String>` | :ref:`reference_space_type<class_WebXRInterface_property_reference_space_type>` |
  104. +-------------------------------------------------+-------------------------------------------------------------------------------------------------------+
  105. | :ref:`String<class_String>` | :ref:`requested_reference_space_types<class_WebXRInterface_property_requested_reference_space_types>` |
  106. +-------------------------------------------------+-------------------------------------------------------------------------------------------------------+
  107. | :ref:`String<class_String>` | :ref:`required_features<class_WebXRInterface_property_required_features>` |
  108. +-------------------------------------------------+-------------------------------------------------------------------------------------------------------+
  109. | :ref:`String<class_String>` | :ref:`session_mode<class_WebXRInterface_property_session_mode>` |
  110. +-------------------------------------------------+-------------------------------------------------------------------------------------------------------+
  111. | :ref:`String<class_String>` | :ref:`visibility_state<class_WebXRInterface_property_visibility_state>` |
  112. +-------------------------------------------------+-------------------------------------------------------------------------------------------------------+
  113. | :ref:`bool<class_bool>` | :ref:`xr_standard_mapping<class_WebXRInterface_property_xr_standard_mapping>` |
  114. +-------------------------------------------------+-------------------------------------------------------------------------------------------------------+
  115. .. rst-class:: classref-reftable-group
  116. Methods
  117. -------
  118. .. table::
  119. :widths: auto
  120. +-----------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+
  121. | :ref:`ARVRPositionalTracker<class_ARVRPositionalTracker>` | :ref:`get_controller<class_WebXRInterface_method_get_controller>` **(** :ref:`int<class_int>` controller_id **)** |const| |
  122. +-----------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+
  123. | :ref:`TargetRayMode<enum_WebXRInterface_TargetRayMode>` | :ref:`get_controller_target_ray_mode<class_WebXRInterface_method_get_controller_target_ray_mode>` **(** :ref:`int<class_int>` controller_id **)** |const| |
  124. +-----------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+
  125. | void | :ref:`is_session_supported<class_WebXRInterface_method_is_session_supported>` **(** :ref:`String<class_String>` session_mode **)** |
  126. +-----------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+
  127. .. rst-class:: classref-section-separator
  128. ----
  129. .. rst-class:: classref-descriptions-group
  130. Signals
  131. -------
  132. .. _class_WebXRInterface_signal_reference_space_reset:
  133. .. rst-class:: classref-signal
  134. **reference_space_reset** **(** **)**
  135. Emitted to indicate that the reference space has been reset or reconfigured.
  136. When (or whether) this is emitted depends on the user's browser or device, but may include when the user has changed the dimensions of their play space (which you may be able to access via :ref:`bounds_geometry<class_WebXRInterface_property_bounds_geometry>`) or pressed/held a button to recenter their position.
  137. See `WebXR's XRReferenceSpace reset event <https://developer.mozilla.org/en-US/docs/Web/API/XRReferenceSpace/reset_event>`__ for more information.
  138. .. rst-class:: classref-item-separator
  139. ----
  140. .. _class_WebXRInterface_signal_select:
  141. .. rst-class:: classref-signal
  142. **select** **(** :ref:`int<class_int>` controller_id **)**
  143. Emitted after one of the "controllers" has finished its "primary action".
  144. Use :ref:`get_controller<class_WebXRInterface_method_get_controller>` to get more information about the controller.
  145. .. rst-class:: classref-item-separator
  146. ----
  147. .. _class_WebXRInterface_signal_selectend:
  148. .. rst-class:: classref-signal
  149. **selectend** **(** :ref:`int<class_int>` controller_id **)**
  150. Emitted when one of the "controllers" has finished its "primary action".
  151. Use :ref:`get_controller<class_WebXRInterface_method_get_controller>` to get more information about the controller.
  152. .. rst-class:: classref-item-separator
  153. ----
  154. .. _class_WebXRInterface_signal_selectstart:
  155. .. rst-class:: classref-signal
  156. **selectstart** **(** :ref:`int<class_int>` controller_id **)**
  157. Emitted when one of the "controllers" has started its "primary action".
  158. Use :ref:`get_controller<class_WebXRInterface_method_get_controller>` to get more information about the controller.
  159. .. rst-class:: classref-item-separator
  160. ----
  161. .. _class_WebXRInterface_signal_session_ended:
  162. .. rst-class:: classref-signal
  163. **session_ended** **(** **)**
  164. Emitted when the user ends the WebXR session (which can be done using UI from the browser or device).
  165. At this point, you should do ``get_viewport().arvr = false`` to instruct Godot to resume rendering to the screen.
  166. .. rst-class:: classref-item-separator
  167. ----
  168. .. _class_WebXRInterface_signal_session_failed:
  169. .. rst-class:: classref-signal
  170. **session_failed** **(** :ref:`String<class_String>` message **)**
  171. Emitted by :ref:`ARVRInterface.initialize<class_ARVRInterface_method_initialize>` if the session fails to start.
  172. \ ``message`` may optionally contain an error message from WebXR, or an empty string if no message is available.
  173. .. rst-class:: classref-item-separator
  174. ----
  175. .. _class_WebXRInterface_signal_session_started:
  176. .. rst-class:: classref-signal
  177. **session_started** **(** **)**
  178. Emitted by :ref:`ARVRInterface.initialize<class_ARVRInterface_method_initialize>` if the session is successfully started.
  179. At this point, it's safe to do ``get_viewport().arvr = true`` to instruct Godot to start rendering to the AR/VR device.
  180. .. rst-class:: classref-item-separator
  181. ----
  182. .. _class_WebXRInterface_signal_session_supported:
  183. .. rst-class:: classref-signal
  184. **session_supported** **(** :ref:`String<class_String>` session_mode, :ref:`bool<class_bool>` supported **)**
  185. Emitted by :ref:`is_session_supported<class_WebXRInterface_method_is_session_supported>` to indicate if the given ``session_mode`` is supported or not.
  186. .. rst-class:: classref-item-separator
  187. ----
  188. .. _class_WebXRInterface_signal_squeeze:
  189. .. rst-class:: classref-signal
  190. **squeeze** **(** :ref:`int<class_int>` controller_id **)**
  191. Emitted after one of the "controllers" has finished its "primary squeeze action".
  192. Use :ref:`get_controller<class_WebXRInterface_method_get_controller>` to get more information about the controller.
  193. .. rst-class:: classref-item-separator
  194. ----
  195. .. _class_WebXRInterface_signal_squeezeend:
  196. .. rst-class:: classref-signal
  197. **squeezeend** **(** :ref:`int<class_int>` controller_id **)**
  198. Emitted when one of the "controllers" has finished its "primary squeeze action".
  199. Use :ref:`get_controller<class_WebXRInterface_method_get_controller>` to get more information about the controller.
  200. .. rst-class:: classref-item-separator
  201. ----
  202. .. _class_WebXRInterface_signal_squeezestart:
  203. .. rst-class:: classref-signal
  204. **squeezestart** **(** :ref:`int<class_int>` controller_id **)**
  205. Emitted when one of the "controllers" has started its "primary squeeze action".
  206. Use :ref:`get_controller<class_WebXRInterface_method_get_controller>` to get more information about the controller.
  207. .. rst-class:: classref-item-separator
  208. ----
  209. .. _class_WebXRInterface_signal_visibility_state_changed:
  210. .. rst-class:: classref-signal
  211. **visibility_state_changed** **(** **)**
  212. Emitted when :ref:`visibility_state<class_WebXRInterface_property_visibility_state>` has changed.
  213. .. rst-class:: classref-section-separator
  214. ----
  215. .. rst-class:: classref-descriptions-group
  216. Enumerations
  217. ------------
  218. .. _enum_WebXRInterface_TargetRayMode:
  219. .. rst-class:: classref-enumeration
  220. enum **TargetRayMode**:
  221. .. _class_WebXRInterface_constant_TARGET_RAY_MODE_UNKNOWN:
  222. .. rst-class:: classref-enumeration-constant
  223. :ref:`TargetRayMode<enum_WebXRInterface_TargetRayMode>` **TARGET_RAY_MODE_UNKNOWN** = ``0``
  224. We don't know the target ray mode.
  225. .. _class_WebXRInterface_constant_TARGET_RAY_MODE_GAZE:
  226. .. rst-class:: classref-enumeration-constant
  227. :ref:`TargetRayMode<enum_WebXRInterface_TargetRayMode>` **TARGET_RAY_MODE_GAZE** = ``1``
  228. Target ray originates at the viewer's eyes and points in the direction they are looking.
  229. .. _class_WebXRInterface_constant_TARGET_RAY_MODE_TRACKED_POINTER:
  230. .. rst-class:: classref-enumeration-constant
  231. :ref:`TargetRayMode<enum_WebXRInterface_TargetRayMode>` **TARGET_RAY_MODE_TRACKED_POINTER** = ``2``
  232. Target ray from a handheld pointer, most likely a VR touch controller.
  233. .. _class_WebXRInterface_constant_TARGET_RAY_MODE_SCREEN:
  234. .. rst-class:: classref-enumeration-constant
  235. :ref:`TargetRayMode<enum_WebXRInterface_TargetRayMode>` **TARGET_RAY_MODE_SCREEN** = ``3``
  236. Target ray from touch screen, mouse or other tactile input device.
  237. .. rst-class:: classref-section-separator
  238. ----
  239. .. rst-class:: classref-descriptions-group
  240. Property Descriptions
  241. ---------------------
  242. .. _class_WebXRInterface_property_bounds_geometry:
  243. .. rst-class:: classref-property
  244. :ref:`PoolVector3Array<class_PoolVector3Array>` **bounds_geometry**
  245. .. rst-class:: classref-property-setget
  246. - :ref:`PoolVector3Array<class_PoolVector3Array>` **get_bounds_geometry** **(** **)**
  247. The vertices of a polygon which defines the boundaries of the user's play area.
  248. This will only be available if :ref:`reference_space_type<class_WebXRInterface_property_reference_space_type>` is ``"bounded-floor"`` and only on certain browsers and devices that support it.
  249. The :ref:`reference_space_reset<class_WebXRInterface_signal_reference_space_reset>` signal may indicate when this changes.
  250. .. rst-class:: classref-item-separator
  251. ----
  252. .. _class_WebXRInterface_property_optional_features:
  253. .. rst-class:: classref-property
  254. :ref:`String<class_String>` **optional_features**
  255. .. rst-class:: classref-property-setget
  256. - void **set_optional_features** **(** :ref:`String<class_String>` value **)**
  257. - :ref:`String<class_String>` **get_optional_features** **(** **)**
  258. A comma-seperated list of optional features used by :ref:`ARVRInterface.initialize<class_ARVRInterface_method_initialize>` when setting up the WebXR session.
  259. If a user's browser or device doesn't support one of the given features, initialization will continue, but you won't be able to use the requested feature.
  260. This doesn't have any effect on the interface when already initialized.
  261. Possible values come from `WebXR's XRReferenceSpaceType <https://developer.mozilla.org/en-US/docs/Web/API/XRReferenceSpaceType>`__. If you want to use a particular reference space type, it must be listed in either :ref:`required_features<class_WebXRInterface_property_required_features>` or :ref:`optional_features<class_WebXRInterface_property_optional_features>`.
  262. .. rst-class:: classref-item-separator
  263. ----
  264. .. _class_WebXRInterface_property_reference_space_type:
  265. .. rst-class:: classref-property
  266. :ref:`String<class_String>` **reference_space_type**
  267. .. rst-class:: classref-property-setget
  268. - :ref:`String<class_String>` **get_reference_space_type** **(** **)**
  269. The reference space type (from the list of requested types set in the :ref:`requested_reference_space_types<class_WebXRInterface_property_requested_reference_space_types>` property), that was ultimately used by :ref:`ARVRInterface.initialize<class_ARVRInterface_method_initialize>` when setting up the WebXR session.
  270. Possible values come from `WebXR's XRReferenceSpaceType <https://developer.mozilla.org/en-US/docs/Web/API/XRReferenceSpaceType>`__. If you want to use a particular reference space type, it must be listed in either :ref:`required_features<class_WebXRInterface_property_required_features>` or :ref:`optional_features<class_WebXRInterface_property_optional_features>`.
  271. .. rst-class:: classref-item-separator
  272. ----
  273. .. _class_WebXRInterface_property_requested_reference_space_types:
  274. .. rst-class:: classref-property
  275. :ref:`String<class_String>` **requested_reference_space_types**
  276. .. rst-class:: classref-property-setget
  277. - void **set_requested_reference_space_types** **(** :ref:`String<class_String>` value **)**
  278. - :ref:`String<class_String>` **get_requested_reference_space_types** **(** **)**
  279. A comma-seperated list of reference space types used by :ref:`ARVRInterface.initialize<class_ARVRInterface_method_initialize>` when setting up the WebXR session.
  280. The reference space types are requested in order, and the first on supported by the users device or browser will be used. The :ref:`reference_space_type<class_WebXRInterface_property_reference_space_type>` property contains the reference space type that was ultimately used.
  281. This doesn't have any effect on the interface when already initialized.
  282. Possible values come from `WebXR's XRReferenceSpaceType <https://developer.mozilla.org/en-US/docs/Web/API/XRReferenceSpaceType>`__. If you want to use a particular reference space type, it must be listed in either :ref:`required_features<class_WebXRInterface_property_required_features>` or :ref:`optional_features<class_WebXRInterface_property_optional_features>`.
  283. .. rst-class:: classref-item-separator
  284. ----
  285. .. _class_WebXRInterface_property_required_features:
  286. .. rst-class:: classref-property
  287. :ref:`String<class_String>` **required_features**
  288. .. rst-class:: classref-property-setget
  289. - void **set_required_features** **(** :ref:`String<class_String>` value **)**
  290. - :ref:`String<class_String>` **get_required_features** **(** **)**
  291. A comma-seperated list of required features used by :ref:`ARVRInterface.initialize<class_ARVRInterface_method_initialize>` when setting up the WebXR session.
  292. If a user's browser or device doesn't support one of the given features, initialization will fail and :ref:`session_failed<class_WebXRInterface_signal_session_failed>` will be emitted.
  293. This doesn't have any effect on the interface when already initialized.
  294. Possible values come from `WebXR's XRReferenceSpaceType <https://developer.mozilla.org/en-US/docs/Web/API/XRReferenceSpaceType>`__. If you want to use a particular reference space type, it must be listed in either :ref:`required_features<class_WebXRInterface_property_required_features>` or :ref:`optional_features<class_WebXRInterface_property_optional_features>`.
  295. .. rst-class:: classref-item-separator
  296. ----
  297. .. _class_WebXRInterface_property_session_mode:
  298. .. rst-class:: classref-property
  299. :ref:`String<class_String>` **session_mode**
  300. .. rst-class:: classref-property-setget
  301. - void **set_session_mode** **(** :ref:`String<class_String>` value **)**
  302. - :ref:`String<class_String>` **get_session_mode** **(** **)**
  303. The session mode used by :ref:`ARVRInterface.initialize<class_ARVRInterface_method_initialize>` when setting up the WebXR session.
  304. This doesn't have any effect on the interface when already initialized.
  305. Possible values come from `WebXR's XRSessionMode <https://developer.mozilla.org/en-US/docs/Web/API/XRSessionMode>`__, including: ``"immersive-vr"``, ``"immersive-ar"``, and ``"inline"``.
  306. .. rst-class:: classref-item-separator
  307. ----
  308. .. _class_WebXRInterface_property_visibility_state:
  309. .. rst-class:: classref-property
  310. :ref:`String<class_String>` **visibility_state**
  311. .. rst-class:: classref-property-setget
  312. - :ref:`String<class_String>` **get_visibility_state** **(** **)**
  313. Indicates if the WebXR session's imagery is visible to the user.
  314. Possible values come from `WebXR's XRVisibilityState <https://developer.mozilla.org/en-US/docs/Web/API/XRVisibilityState>`__, including ``"hidden"``, ``"visible"``, and ``"visible-blurred"``.
  315. .. rst-class:: classref-item-separator
  316. ----
  317. .. _class_WebXRInterface_property_xr_standard_mapping:
  318. .. rst-class:: classref-property
  319. :ref:`bool<class_bool>` **xr_standard_mapping**
  320. .. rst-class:: classref-property-setget
  321. - void **set_xr_standard_mapping** **(** :ref:`bool<class_bool>` value **)**
  322. - :ref:`bool<class_bool>` **get_xr_standard_mapping** **(** **)**
  323. If set to true, the button and axes ids will be converted to match the standard ids used by other AR/VR interfaces, when possible.
  324. Otherwise, the ids will be passed through unaltered from WebXR.
  325. .. rst-class:: classref-section-separator
  326. ----
  327. .. rst-class:: classref-descriptions-group
  328. Method Descriptions
  329. -------------------
  330. .. _class_WebXRInterface_method_get_controller:
  331. .. rst-class:: classref-method
  332. :ref:`ARVRPositionalTracker<class_ARVRPositionalTracker>` **get_controller** **(** :ref:`int<class_int>` controller_id **)** |const|
  333. Gets an :ref:`ARVRPositionalTracker<class_ARVRPositionalTracker>` for the given ``controller_id``.
  334. In the context of WebXR, a "controller" can be an advanced VR controller like the Oculus Touch or Index controllers, or even a tap on the screen, a spoken voice command or a button press on the device itself. When a non-traditional controller is used, interpret the position and orientation of the :ref:`ARVRPositionalTracker<class_ARVRPositionalTracker>` as a ray pointing at the object the user wishes to interact with.
  335. Use this method to get information about the controller that triggered one of these signals:
  336. - :ref:`selectstart<class_WebXRInterface_signal_selectstart>`\
  337. - :ref:`select<class_WebXRInterface_signal_select>`\
  338. - :ref:`selectend<class_WebXRInterface_signal_selectend>`\
  339. - :ref:`squeezestart<class_WebXRInterface_signal_squeezestart>`\
  340. - :ref:`squeeze<class_WebXRInterface_signal_squeeze>`\
  341. - :ref:`squeezestart<class_WebXRInterface_signal_squeezestart>`
  342. .. rst-class:: classref-item-separator
  343. ----
  344. .. _class_WebXRInterface_method_get_controller_target_ray_mode:
  345. .. rst-class:: classref-method
  346. :ref:`TargetRayMode<enum_WebXRInterface_TargetRayMode>` **get_controller_target_ray_mode** **(** :ref:`int<class_int>` controller_id **)** |const|
  347. Returns the target ray mode for the given ``controller_id``.
  348. This can help interpret the input coming from that controller. See `XRInputSource.targetRayMode <https://developer.mozilla.org/en-US/docs/Web/API/XRInputSource/targetRayMode>`__ for more information.
  349. .. rst-class:: classref-item-separator
  350. ----
  351. .. _class_WebXRInterface_method_is_session_supported:
  352. .. rst-class:: classref-method
  353. void **is_session_supported** **(** :ref:`String<class_String>` session_mode **)**
  354. Checks if the given ``session_mode`` is supported by the user's browser.
  355. Possible values come from `WebXR's XRSessionMode <https://developer.mozilla.org/en-US/docs/Web/API/XRSessionMode>`__, including: ``"immersive-vr"``, ``"immersive-ar"``, and ``"inline"``.
  356. This method returns nothing, instead it emits the :ref:`session_supported<class_WebXRInterface_signal_session_supported>` signal with the result.
  357. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  358. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  359. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  360. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`