class_webxrinterface.rst 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648
  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/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/modules/webxr/doc_classes/WebXRInterface.xml.
  6. .. _class_WebXRInterface:
  7. WebXRInterface
  8. ==============
  9. **Inherits:** :ref:`XRInterface<class_XRInterface>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
  10. XR 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 Web exports.
  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 XR interfaces would instead use functions that return a result immediately. This makes **WebXRInterface** quite a bit more complicated to initialize than other XR interfaces.
  18. Here's the minimum code required to start an immersive VR session:
  19. ::
  20. extends Node3D
  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.pressed.connect(self._on_button_pressed)
  27. webxr_interface = XRServer.find_interface("WebXR")
  28. if webxr_interface:
  29. # WebXR uses a lot of asynchronous callbacks, so we connect to various
  30. # signals in order to receive them.
  31. webxr_interface.session_supported.connect(self._webxr_session_supported)
  32. webxr_interface.session_started.connect(self._webxr_session_started)
  33. webxr_interface.session_ended.connect(self._webxr_session_ended)
  34. webxr_interface.session_failed.connect(self._webxr_session_failed)
  35. # This returns immediately - our _webxr_session_supported() method
  36. # (which we connected to the "session_supported" signal above) will
  37. # be called sometime later to let us know if it's supported or not.
  38. webxr_interface.is_session_supported("immersive-vr")
  39. func _webxr_session_supported(session_mode, supported):
  40. if session_mode == 'immersive-vr':
  41. vr_supported = supported
  42. func _on_button_pressed():
  43. if not vr_supported:
  44. OS.alert("Your browser doesn't support VR")
  45. return
  46. # We want an immersive VR session, as opposed to AR ('immersive-ar') or a
  47. # simple 3DoF viewer ('viewer').
  48. webxr_interface.session_mode = 'immersive-vr'
  49. # 'bounded-floor' is room scale, 'local-floor' is a standing or sitting
  50. # experience (it puts you 1.6m above the ground if you have 3DoF headset),
  51. # whereas as 'local' puts you down at the XROrigin.
  52. # This list means it'll first try to request 'bounded-floor', then
  53. # fallback on 'local-floor' and ultimately 'local', if nothing else is
  54. # supported.
  55. webxr_interface.requested_reference_space_types = 'bounded-floor, local-floor, local'
  56. # In order to use 'local-floor' or 'bounded-floor' we must also
  57. # mark the features as required or optional.
  58. webxr_interface.required_features = 'local-floor'
  59. webxr_interface.optional_features = 'bounded-floor'
  60. # This will return false if we're unable to even request the session,
  61. # however, it can still fail asynchronously later in the process, so we
  62. # only know if it's really succeeded or failed when our
  63. # _webxr_session_started() or _webxr_session_failed() methods are called.
  64. if not webxr_interface.initialize():
  65. OS.alert("Failed to initialize")
  66. return
  67. func _webxr_session_started():
  68. $Button.visible = false
  69. # This tells Godot to start rendering to the headset.
  70. get_viewport().use_xr = true
  71. # This will be the reference space type you ultimately got, out of the
  72. # types that you requested above. This is useful if you want the game to
  73. # work a little differently in 'bounded-floor' versus 'local-floor'.
  74. print ("Reference space type: " + webxr_interface.reference_space_type)
  75. func _webxr_session_ended():
  76. $Button.visible = true
  77. # If the user exits immersive mode, then we tell Godot to render to the web
  78. # page again.
  79. get_viewport().use_xr = false
  80. func _webxr_session_failed(message):
  81. OS.alert("Failed to initialize: " + message)
  82. There are a couple ways to handle "controller" input:
  83. - Using :ref:`XRController3D<class_XRController3D>` nodes and their :ref:`XRController3D.button_pressed<class_XRController3D_signal_button_pressed>` and :ref:`XRController3D.button_released<class_XRController3D_signal_button_released>` signals. This is how controllers are typically handled in XR apps in Godot, however, this will only work with advanced VR controllers like the Oculus Touch or Index controllers, for example.
  84. - 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 input sources like a tap on the screen, a spoken voice command or a button press on the device itself.
  85. You can use both 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.
  86. .. rst-class:: classref-introduction-group
  87. Tutorials
  88. ---------
  89. - `How to make a VR game for WebXR with Godot 4 <https://www.snopekgames.com/tutorial/2023/how-make-vr-game-webxr-godot-4>`__
  90. .. rst-class:: classref-reftable-group
  91. Properties
  92. ----------
  93. .. table::
  94. :widths: auto
  95. +-----------------------------+-------------------------------------------------------------------------------------------------------+
  96. | :ref:`String<class_String>` | :ref:`optional_features<class_WebXRInterface_property_optional_features>` |
  97. +-----------------------------+-------------------------------------------------------------------------------------------------------+
  98. | :ref:`String<class_String>` | :ref:`reference_space_type<class_WebXRInterface_property_reference_space_type>` |
  99. +-----------------------------+-------------------------------------------------------------------------------------------------------+
  100. | :ref:`String<class_String>` | :ref:`requested_reference_space_types<class_WebXRInterface_property_requested_reference_space_types>` |
  101. +-----------------------------+-------------------------------------------------------------------------------------------------------+
  102. | :ref:`String<class_String>` | :ref:`required_features<class_WebXRInterface_property_required_features>` |
  103. +-----------------------------+-------------------------------------------------------------------------------------------------------+
  104. | :ref:`String<class_String>` | :ref:`session_mode<class_WebXRInterface_property_session_mode>` |
  105. +-----------------------------+-------------------------------------------------------------------------------------------------------+
  106. | :ref:`String<class_String>` | :ref:`visibility_state<class_WebXRInterface_property_visibility_state>` |
  107. +-----------------------------+-------------------------------------------------------------------------------------------------------+
  108. .. rst-class:: classref-reftable-group
  109. Methods
  110. -------
  111. .. table::
  112. :widths: auto
  113. +---------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
  114. | :ref:`Array<class_Array>` | :ref:`get_available_display_refresh_rates<class_WebXRInterface_method_get_available_display_refresh_rates>` **(** **)** |const| |
  115. +---------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
  116. | :ref:`float<class_float>` | :ref:`get_display_refresh_rate<class_WebXRInterface_method_get_display_refresh_rate>` **(** **)** |const| |
  117. +---------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
  118. | :ref:`TargetRayMode<enum_WebXRInterface_TargetRayMode>` | :ref:`get_input_source_target_ray_mode<class_WebXRInterface_method_get_input_source_target_ray_mode>` **(** :ref:`int<class_int>` input_source_id **)** |const| |
  119. +---------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
  120. | :ref:`XRPositionalTracker<class_XRPositionalTracker>` | :ref:`get_input_source_tracker<class_WebXRInterface_method_get_input_source_tracker>` **(** :ref:`int<class_int>` input_source_id **)** |const| |
  121. +---------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
  122. | :ref:`bool<class_bool>` | :ref:`is_input_source_active<class_WebXRInterface_method_is_input_source_active>` **(** :ref:`int<class_int>` input_source_id **)** |const| |
  123. +---------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
  124. | void | :ref:`is_session_supported<class_WebXRInterface_method_is_session_supported>` **(** :ref:`String<class_String>` session_mode **)** |
  125. +---------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
  126. | void | :ref:`set_display_refresh_rate<class_WebXRInterface_method_set_display_refresh_rate>` **(** :ref:`float<class_float>` refresh_rate **)** |
  127. +---------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
  128. .. rst-class:: classref-section-separator
  129. ----
  130. .. rst-class:: classref-descriptions-group
  131. Signals
  132. -------
  133. .. _class_WebXRInterface_signal_display_refresh_rate_changed:
  134. .. rst-class:: classref-signal
  135. **display_refresh_rate_changed** **(** **)**
  136. Emitted after the display's refresh rate has changed.
  137. .. rst-class:: classref-item-separator
  138. ----
  139. .. _class_WebXRInterface_signal_reference_space_reset:
  140. .. rst-class:: classref-signal
  141. **reference_space_reset** **(** **)**
  142. Emitted to indicate that the reference space has been reset or reconfigured.
  143. 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:`XRInterface.get_play_area<class_XRInterface_method_get_play_area>`) or pressed/held a button to recenter their position.
  144. See `WebXR's XRReferenceSpace reset event <https://developer.mozilla.org/en-US/docs/Web/API/XRReferenceSpace/reset_event>`__ for more information.
  145. .. rst-class:: classref-item-separator
  146. ----
  147. .. _class_WebXRInterface_signal_select:
  148. .. rst-class:: classref-signal
  149. **select** **(** :ref:`int<class_int>` input_source_id **)**
  150. Emitted after one of the input sources has finished its "primary action".
  151. Use :ref:`get_input_source_tracker<class_WebXRInterface_method_get_input_source_tracker>` and :ref:`get_input_source_target_ray_mode<class_WebXRInterface_method_get_input_source_target_ray_mode>` to get more information about the input source.
  152. .. rst-class:: classref-item-separator
  153. ----
  154. .. _class_WebXRInterface_signal_selectend:
  155. .. rst-class:: classref-signal
  156. **selectend** **(** :ref:`int<class_int>` input_source_id **)**
  157. Emitted when one of the input sources has finished its "primary action".
  158. Use :ref:`get_input_source_tracker<class_WebXRInterface_method_get_input_source_tracker>` and :ref:`get_input_source_target_ray_mode<class_WebXRInterface_method_get_input_source_target_ray_mode>` to get more information about the input source.
  159. .. rst-class:: classref-item-separator
  160. ----
  161. .. _class_WebXRInterface_signal_selectstart:
  162. .. rst-class:: classref-signal
  163. **selectstart** **(** :ref:`int<class_int>` input_source_id **)**
  164. Emitted when one of the input source has started its "primary action".
  165. Use :ref:`get_input_source_tracker<class_WebXRInterface_method_get_input_source_tracker>` and :ref:`get_input_source_target_ray_mode<class_WebXRInterface_method_get_input_source_target_ray_mode>` to get more information about the input source.
  166. .. rst-class:: classref-item-separator
  167. ----
  168. .. _class_WebXRInterface_signal_session_ended:
  169. .. rst-class:: classref-signal
  170. **session_ended** **(** **)**
  171. Emitted when the user ends the WebXR session (which can be done using UI from the browser or device).
  172. At this point, you should do ``get_viewport().use_xr = false`` to instruct Godot to resume rendering to the screen.
  173. .. rst-class:: classref-item-separator
  174. ----
  175. .. _class_WebXRInterface_signal_session_failed:
  176. .. rst-class:: classref-signal
  177. **session_failed** **(** :ref:`String<class_String>` message **)**
  178. Emitted by :ref:`XRInterface.initialize<class_XRInterface_method_initialize>` if the session fails to start.
  179. \ ``message`` may optionally contain an error message from WebXR, or an empty string if no message is available.
  180. .. rst-class:: classref-item-separator
  181. ----
  182. .. _class_WebXRInterface_signal_session_started:
  183. .. rst-class:: classref-signal
  184. **session_started** **(** **)**
  185. Emitted by :ref:`XRInterface.initialize<class_XRInterface_method_initialize>` if the session is successfully started.
  186. At this point, it's safe to do ``get_viewport().use_xr = true`` to instruct Godot to start rendering to the XR device.
  187. .. rst-class:: classref-item-separator
  188. ----
  189. .. _class_WebXRInterface_signal_session_supported:
  190. .. rst-class:: classref-signal
  191. **session_supported** **(** :ref:`String<class_String>` session_mode, :ref:`bool<class_bool>` supported **)**
  192. Emitted by :ref:`is_session_supported<class_WebXRInterface_method_is_session_supported>` to indicate if the given ``session_mode`` is supported or not.
  193. .. rst-class:: classref-item-separator
  194. ----
  195. .. _class_WebXRInterface_signal_squeeze:
  196. .. rst-class:: classref-signal
  197. **squeeze** **(** :ref:`int<class_int>` input_source_id **)**
  198. Emitted after one of the input sources has finished its "primary squeeze action".
  199. Use :ref:`get_input_source_tracker<class_WebXRInterface_method_get_input_source_tracker>` and :ref:`get_input_source_target_ray_mode<class_WebXRInterface_method_get_input_source_target_ray_mode>` to get more information about the input source.
  200. .. rst-class:: classref-item-separator
  201. ----
  202. .. _class_WebXRInterface_signal_squeezeend:
  203. .. rst-class:: classref-signal
  204. **squeezeend** **(** :ref:`int<class_int>` input_source_id **)**
  205. Emitted when one of the input sources has finished its "primary squeeze action".
  206. Use :ref:`get_input_source_tracker<class_WebXRInterface_method_get_input_source_tracker>` and :ref:`get_input_source_target_ray_mode<class_WebXRInterface_method_get_input_source_target_ray_mode>` to get more information about the input source.
  207. .. rst-class:: classref-item-separator
  208. ----
  209. .. _class_WebXRInterface_signal_squeezestart:
  210. .. rst-class:: classref-signal
  211. **squeezestart** **(** :ref:`int<class_int>` input_source_id **)**
  212. Emitted when one of the input sources has started its "primary squeeze action".
  213. Use :ref:`get_input_source_tracker<class_WebXRInterface_method_get_input_source_tracker>` and :ref:`get_input_source_target_ray_mode<class_WebXRInterface_method_get_input_source_target_ray_mode>` to get more information about the input source.
  214. .. rst-class:: classref-item-separator
  215. ----
  216. .. _class_WebXRInterface_signal_visibility_state_changed:
  217. .. rst-class:: classref-signal
  218. **visibility_state_changed** **(** **)**
  219. Emitted when :ref:`visibility_state<class_WebXRInterface_property_visibility_state>` has changed.
  220. .. rst-class:: classref-section-separator
  221. ----
  222. .. rst-class:: classref-descriptions-group
  223. Enumerations
  224. ------------
  225. .. _enum_WebXRInterface_TargetRayMode:
  226. .. rst-class:: classref-enumeration
  227. enum **TargetRayMode**:
  228. .. _class_WebXRInterface_constant_TARGET_RAY_MODE_UNKNOWN:
  229. .. rst-class:: classref-enumeration-constant
  230. :ref:`TargetRayMode<enum_WebXRInterface_TargetRayMode>` **TARGET_RAY_MODE_UNKNOWN** = ``0``
  231. We don't know the the target ray mode.
  232. .. _class_WebXRInterface_constant_TARGET_RAY_MODE_GAZE:
  233. .. rst-class:: classref-enumeration-constant
  234. :ref:`TargetRayMode<enum_WebXRInterface_TargetRayMode>` **TARGET_RAY_MODE_GAZE** = ``1``
  235. Target ray originates at the viewer's eyes and points in the direction they are looking.
  236. .. _class_WebXRInterface_constant_TARGET_RAY_MODE_TRACKED_POINTER:
  237. .. rst-class:: classref-enumeration-constant
  238. :ref:`TargetRayMode<enum_WebXRInterface_TargetRayMode>` **TARGET_RAY_MODE_TRACKED_POINTER** = ``2``
  239. Target ray from a handheld pointer, most likely a VR touch controller.
  240. .. _class_WebXRInterface_constant_TARGET_RAY_MODE_SCREEN:
  241. .. rst-class:: classref-enumeration-constant
  242. :ref:`TargetRayMode<enum_WebXRInterface_TargetRayMode>` **TARGET_RAY_MODE_SCREEN** = ``3``
  243. Target ray from touch screen, mouse or other tactile input device.
  244. .. rst-class:: classref-section-separator
  245. ----
  246. .. rst-class:: classref-descriptions-group
  247. Property Descriptions
  248. ---------------------
  249. .. _class_WebXRInterface_property_optional_features:
  250. .. rst-class:: classref-property
  251. :ref:`String<class_String>` **optional_features**
  252. .. rst-class:: classref-property-setget
  253. - void **set_optional_features** **(** :ref:`String<class_String>` value **)**
  254. - :ref:`String<class_String>` **get_optional_features** **(** **)**
  255. A comma-seperated list of optional features used by :ref:`XRInterface.initialize<class_XRInterface_method_initialize>` when setting up the WebXR session.
  256. 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.
  257. This doesn't have any effect on the interface when already initialized.
  258. 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>`.
  259. .. rst-class:: classref-item-separator
  260. ----
  261. .. _class_WebXRInterface_property_reference_space_type:
  262. .. rst-class:: classref-property
  263. :ref:`String<class_String>` **reference_space_type**
  264. .. rst-class:: classref-property-setget
  265. - :ref:`String<class_String>` **get_reference_space_type** **(** **)**
  266. 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:`XRInterface.initialize<class_XRInterface_method_initialize>` when setting up the WebXR session.
  267. 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>`.
  268. .. rst-class:: classref-item-separator
  269. ----
  270. .. _class_WebXRInterface_property_requested_reference_space_types:
  271. .. rst-class:: classref-property
  272. :ref:`String<class_String>` **requested_reference_space_types**
  273. .. rst-class:: classref-property-setget
  274. - void **set_requested_reference_space_types** **(** :ref:`String<class_String>` value **)**
  275. - :ref:`String<class_String>` **get_requested_reference_space_types** **(** **)**
  276. A comma-seperated list of reference space types used by :ref:`XRInterface.initialize<class_XRInterface_method_initialize>` when setting up the WebXR session.
  277. The reference space types are requested in order, and the first one 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 selected.
  278. This doesn't have any effect on the interface when already initialized.
  279. 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>`.
  280. .. rst-class:: classref-item-separator
  281. ----
  282. .. _class_WebXRInterface_property_required_features:
  283. .. rst-class:: classref-property
  284. :ref:`String<class_String>` **required_features**
  285. .. rst-class:: classref-property-setget
  286. - void **set_required_features** **(** :ref:`String<class_String>` value **)**
  287. - :ref:`String<class_String>` **get_required_features** **(** **)**
  288. A comma-seperated list of required features used by :ref:`XRInterface.initialize<class_XRInterface_method_initialize>` when setting up the WebXR session.
  289. 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.
  290. This doesn't have any effect on the interface when already initialized.
  291. 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>`.
  292. .. rst-class:: classref-item-separator
  293. ----
  294. .. _class_WebXRInterface_property_session_mode:
  295. .. rst-class:: classref-property
  296. :ref:`String<class_String>` **session_mode**
  297. .. rst-class:: classref-property-setget
  298. - void **set_session_mode** **(** :ref:`String<class_String>` value **)**
  299. - :ref:`String<class_String>` **get_session_mode** **(** **)**
  300. The session mode used by :ref:`XRInterface.initialize<class_XRInterface_method_initialize>` when setting up the WebXR session.
  301. This doesn't have any effect on the interface when already initialized.
  302. Possible values come from `WebXR's XRSessionMode <https://developer.mozilla.org/en-US/docs/Web/API/XRSessionMode>`__, including: ``"immersive-vr"``, ``"immersive-ar"``, and ``"inline"``.
  303. .. rst-class:: classref-item-separator
  304. ----
  305. .. _class_WebXRInterface_property_visibility_state:
  306. .. rst-class:: classref-property
  307. :ref:`String<class_String>` **visibility_state**
  308. .. rst-class:: classref-property-setget
  309. - :ref:`String<class_String>` **get_visibility_state** **(** **)**
  310. Indicates if the WebXR session's imagery is visible to the user.
  311. Possible values come from `WebXR's XRVisibilityState <https://developer.mozilla.org/en-US/docs/Web/API/XRVisibilityState>`__, including ``"hidden"``, ``"visible"``, and ``"visible-blurred"``.
  312. .. rst-class:: classref-section-separator
  313. ----
  314. .. rst-class:: classref-descriptions-group
  315. Method Descriptions
  316. -------------------
  317. .. _class_WebXRInterface_method_get_available_display_refresh_rates:
  318. .. rst-class:: classref-method
  319. :ref:`Array<class_Array>` **get_available_display_refresh_rates** **(** **)** |const|
  320. Returns display refresh rates supported by the current HMD. Only returned if this feature is supported by the web browser and after the interface has been initialized.
  321. .. rst-class:: classref-item-separator
  322. ----
  323. .. _class_WebXRInterface_method_get_display_refresh_rate:
  324. .. rst-class:: classref-method
  325. :ref:`float<class_float>` **get_display_refresh_rate** **(** **)** |const|
  326. Returns the display refresh rate for the current HMD. Not supported on all HMDs and browsers. It may not report an accurate value until after using :ref:`set_display_refresh_rate<class_WebXRInterface_method_set_display_refresh_rate>`.
  327. .. rst-class:: classref-item-separator
  328. ----
  329. .. _class_WebXRInterface_method_get_input_source_target_ray_mode:
  330. .. rst-class:: classref-method
  331. :ref:`TargetRayMode<enum_WebXRInterface_TargetRayMode>` **get_input_source_target_ray_mode** **(** :ref:`int<class_int>` input_source_id **)** |const|
  332. Returns the target ray mode for the given ``input_source_id``.
  333. This can help interpret the input coming from that input source. See `XRInputSource.targetRayMode <https://developer.mozilla.org/en-US/docs/Web/API/XRInputSource/targetRayMode>`__ for more information.
  334. .. rst-class:: classref-item-separator
  335. ----
  336. .. _class_WebXRInterface_method_get_input_source_tracker:
  337. .. rst-class:: classref-method
  338. :ref:`XRPositionalTracker<class_XRPositionalTracker>` **get_input_source_tracker** **(** :ref:`int<class_int>` input_source_id **)** |const|
  339. Gets an :ref:`XRPositionalTracker<class_XRPositionalTracker>` for the given ``input_source_id``.
  340. In the context of WebXR, an input source 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 input source is used, interpret the position and orientation of the :ref:`XRPositionalTracker<class_XRPositionalTracker>` as a ray pointing at the object the user wishes to interact with.
  341. Use this method to get information about the input source that triggered one of these signals:
  342. - :ref:`selectstart<class_WebXRInterface_signal_selectstart>`\
  343. - :ref:`select<class_WebXRInterface_signal_select>`\
  344. - :ref:`selectend<class_WebXRInterface_signal_selectend>`\
  345. - :ref:`squeezestart<class_WebXRInterface_signal_squeezestart>`\
  346. - :ref:`squeeze<class_WebXRInterface_signal_squeeze>`\
  347. - :ref:`squeezestart<class_WebXRInterface_signal_squeezestart>`
  348. .. rst-class:: classref-item-separator
  349. ----
  350. .. _class_WebXRInterface_method_is_input_source_active:
  351. .. rst-class:: classref-method
  352. :ref:`bool<class_bool>` **is_input_source_active** **(** :ref:`int<class_int>` input_source_id **)** |const|
  353. Returns ``true`` if there is an active input source with the given ``input_source_id``.
  354. .. rst-class:: classref-item-separator
  355. ----
  356. .. _class_WebXRInterface_method_is_session_supported:
  357. .. rst-class:: classref-method
  358. void **is_session_supported** **(** :ref:`String<class_String>` session_mode **)**
  359. Checks if the given ``session_mode`` is supported by the user's browser.
  360. Possible values come from `WebXR's XRSessionMode <https://developer.mozilla.org/en-US/docs/Web/API/XRSessionMode>`__, including: ``"immersive-vr"``, ``"immersive-ar"``, and ``"inline"``.
  361. This method returns nothing, instead it emits the :ref:`session_supported<class_WebXRInterface_signal_session_supported>` signal with the result.
  362. .. rst-class:: classref-item-separator
  363. ----
  364. .. _class_WebXRInterface_method_set_display_refresh_rate:
  365. .. rst-class:: classref-method
  366. void **set_display_refresh_rate** **(** :ref:`float<class_float>` refresh_rate **)**
  367. Sets the display refresh rate for the current HMD. Not supported on all HMDs and browsers. It won't take effect right away until after :ref:`display_refresh_rate_changed<class_WebXRInterface_signal_display_refresh_rate_changed>` is emitted.
  368. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  369. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  370. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  371. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  372. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  373. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  374. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`