class_webxrinterface.rst 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675
  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. By including 'hand-tracking'
  58. # as an optional feature, it will be enabled if supported.
  59. webxr_interface.required_features = 'local-floor'
  60. webxr_interface.optional_features = 'bounded-floor, hand-tracking'
  61. # This will return false if we're unable to even request the session,
  62. # however, it can still fail asynchronously later in the process, so we
  63. # only know if it's really succeeded or failed when our
  64. # _webxr_session_started() or _webxr_session_failed() methods are called.
  65. if not webxr_interface.initialize():
  66. OS.alert("Failed to initialize")
  67. return
  68. func _webxr_session_started():
  69. $Button.visible = false
  70. # This tells Godot to start rendering to the headset.
  71. get_viewport().use_xr = true
  72. # This will be the reference space type you ultimately got, out of the
  73. # types that you requested above. This is useful if you want the game to
  74. # work a little differently in 'bounded-floor' versus 'local-floor'.
  75. print("Reference space type: ", webxr_interface.reference_space_type)
  76. # This will be the list of features that were successfully enabled
  77. # (except on browsers that don't support this property).
  78. print("Enabled features: ", webxr_interface.enabled_features)
  79. func _webxr_session_ended():
  80. $Button.visible = true
  81. # If the user exits immersive mode, then we tell Godot to render to the web
  82. # page again.
  83. get_viewport().use_xr = false
  84. func _webxr_session_failed(message):
  85. OS.alert("Failed to initialize: " + message)
  86. There are a couple ways to handle "controller" input:
  87. - 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.
  88. - 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.
  89. 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.
  90. .. rst-class:: classref-introduction-group
  91. Tutorials
  92. ---------
  93. - `How to make a VR game for WebXR with Godot 4 <https://www.snopekgames.com/tutorial/2023/how-make-vr-game-webxr-godot-4>`__
  94. .. rst-class:: classref-reftable-group
  95. Properties
  96. ----------
  97. .. table::
  98. :widths: auto
  99. +-----------------------------+-------------------------------------------------------------------------------------------------------+
  100. | :ref:`String<class_String>` | :ref:`enabled_features<class_WebXRInterface_property_enabled_features>` |
  101. +-----------------------------+-------------------------------------------------------------------------------------------------------+
  102. | :ref:`String<class_String>` | :ref:`optional_features<class_WebXRInterface_property_optional_features>` |
  103. +-----------------------------+-------------------------------------------------------------------------------------------------------+
  104. | :ref:`String<class_String>` | :ref:`reference_space_type<class_WebXRInterface_property_reference_space_type>` |
  105. +-----------------------------+-------------------------------------------------------------------------------------------------------+
  106. | :ref:`String<class_String>` | :ref:`requested_reference_space_types<class_WebXRInterface_property_requested_reference_space_types>` |
  107. +-----------------------------+-------------------------------------------------------------------------------------------------------+
  108. | :ref:`String<class_String>` | :ref:`required_features<class_WebXRInterface_property_required_features>` |
  109. +-----------------------------+-------------------------------------------------------------------------------------------------------+
  110. | :ref:`String<class_String>` | :ref:`session_mode<class_WebXRInterface_property_session_mode>` |
  111. +-----------------------------+-------------------------------------------------------------------------------------------------------+
  112. | :ref:`String<class_String>` | :ref:`visibility_state<class_WebXRInterface_property_visibility_state>` |
  113. +-----------------------------+-------------------------------------------------------------------------------------------------------+
  114. .. rst-class:: classref-reftable-group
  115. Methods
  116. -------
  117. .. table::
  118. :widths: auto
  119. +---------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
  120. | :ref:`Array<class_Array>` | :ref:`get_available_display_refresh_rates<class_WebXRInterface_method_get_available_display_refresh_rates>`\ (\ ) |const| |
  121. +---------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
  122. | :ref:`float<class_float>` | :ref:`get_display_refresh_rate<class_WebXRInterface_method_get_display_refresh_rate>`\ (\ ) |const| |
  123. +---------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
  124. | :ref:`TargetRayMode<enum_WebXRInterface_TargetRayMode>` | :ref:`get_input_source_target_ray_mode<class_WebXRInterface_method_get_input_source_target_ray_mode>`\ (\ input_source_id\: :ref:`int<class_int>`\ ) |const| |
  125. +---------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
  126. | :ref:`XRControllerTracker<class_XRControllerTracker>` | :ref:`get_input_source_tracker<class_WebXRInterface_method_get_input_source_tracker>`\ (\ input_source_id\: :ref:`int<class_int>`\ ) |const| |
  127. +---------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
  128. | :ref:`bool<class_bool>` | :ref:`is_input_source_active<class_WebXRInterface_method_is_input_source_active>`\ (\ input_source_id\: :ref:`int<class_int>`\ ) |const| |
  129. +---------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
  130. | |void| | :ref:`is_session_supported<class_WebXRInterface_method_is_session_supported>`\ (\ session_mode\: :ref:`String<class_String>`\ ) |
  131. +---------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
  132. | |void| | :ref:`set_display_refresh_rate<class_WebXRInterface_method_set_display_refresh_rate>`\ (\ refresh_rate\: :ref:`float<class_float>`\ ) |
  133. +---------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
  134. .. rst-class:: classref-section-separator
  135. ----
  136. .. rst-class:: classref-descriptions-group
  137. Signals
  138. -------
  139. .. _class_WebXRInterface_signal_display_refresh_rate_changed:
  140. .. rst-class:: classref-signal
  141. **display_refresh_rate_changed**\ (\ ) :ref:`🔗<class_WebXRInterface_signal_display_refresh_rate_changed>`
  142. Emitted after the display's refresh rate has changed.
  143. .. rst-class:: classref-item-separator
  144. ----
  145. .. _class_WebXRInterface_signal_reference_space_reset:
  146. .. rst-class:: classref-signal
  147. **reference_space_reset**\ (\ ) :ref:`🔗<class_WebXRInterface_signal_reference_space_reset>`
  148. Emitted to indicate that the reference space has been reset or reconfigured.
  149. 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.
  150. See `WebXR's XRReferenceSpace reset event <https://developer.mozilla.org/en-US/docs/Web/API/XRReferenceSpace/reset_event>`__ for more information.
  151. .. rst-class:: classref-item-separator
  152. ----
  153. .. _class_WebXRInterface_signal_select:
  154. .. rst-class:: classref-signal
  155. **select**\ (\ input_source_id\: :ref:`int<class_int>`\ ) :ref:`🔗<class_WebXRInterface_signal_select>`
  156. Emitted after one of the input sources has finished its "primary action".
  157. 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.
  158. .. rst-class:: classref-item-separator
  159. ----
  160. .. _class_WebXRInterface_signal_selectend:
  161. .. rst-class:: classref-signal
  162. **selectend**\ (\ input_source_id\: :ref:`int<class_int>`\ ) :ref:`🔗<class_WebXRInterface_signal_selectend>`
  163. Emitted when one of the input sources has finished its "primary action".
  164. 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.
  165. .. rst-class:: classref-item-separator
  166. ----
  167. .. _class_WebXRInterface_signal_selectstart:
  168. .. rst-class:: classref-signal
  169. **selectstart**\ (\ input_source_id\: :ref:`int<class_int>`\ ) :ref:`🔗<class_WebXRInterface_signal_selectstart>`
  170. Emitted when one of the input source has started its "primary action".
  171. 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.
  172. .. rst-class:: classref-item-separator
  173. ----
  174. .. _class_WebXRInterface_signal_session_ended:
  175. .. rst-class:: classref-signal
  176. **session_ended**\ (\ ) :ref:`🔗<class_WebXRInterface_signal_session_ended>`
  177. Emitted when the user ends the WebXR session (which can be done using UI from the browser or device).
  178. At this point, you should do ``get_viewport().use_xr = false`` to instruct Godot to resume rendering to the screen.
  179. .. rst-class:: classref-item-separator
  180. ----
  181. .. _class_WebXRInterface_signal_session_failed:
  182. .. rst-class:: classref-signal
  183. **session_failed**\ (\ message\: :ref:`String<class_String>`\ ) :ref:`🔗<class_WebXRInterface_signal_session_failed>`
  184. Emitted by :ref:`XRInterface.initialize()<class_XRInterface_method_initialize>` if the session fails to start.
  185. \ ``message`` may optionally contain an error message from WebXR, or an empty string if no message is available.
  186. .. rst-class:: classref-item-separator
  187. ----
  188. .. _class_WebXRInterface_signal_session_started:
  189. .. rst-class:: classref-signal
  190. **session_started**\ (\ ) :ref:`🔗<class_WebXRInterface_signal_session_started>`
  191. Emitted by :ref:`XRInterface.initialize()<class_XRInterface_method_initialize>` if the session is successfully started.
  192. At this point, it's safe to do ``get_viewport().use_xr = true`` to instruct Godot to start rendering to the XR device.
  193. .. rst-class:: classref-item-separator
  194. ----
  195. .. _class_WebXRInterface_signal_session_supported:
  196. .. rst-class:: classref-signal
  197. **session_supported**\ (\ session_mode\: :ref:`String<class_String>`, supported\: :ref:`bool<class_bool>`\ ) :ref:`🔗<class_WebXRInterface_signal_session_supported>`
  198. Emitted by :ref:`is_session_supported()<class_WebXRInterface_method_is_session_supported>` to indicate if the given ``session_mode`` is supported or not.
  199. .. rst-class:: classref-item-separator
  200. ----
  201. .. _class_WebXRInterface_signal_squeeze:
  202. .. rst-class:: classref-signal
  203. **squeeze**\ (\ input_source_id\: :ref:`int<class_int>`\ ) :ref:`🔗<class_WebXRInterface_signal_squeeze>`
  204. Emitted after one of the input sources has finished its "primary squeeze action".
  205. 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.
  206. .. rst-class:: classref-item-separator
  207. ----
  208. .. _class_WebXRInterface_signal_squeezeend:
  209. .. rst-class:: classref-signal
  210. **squeezeend**\ (\ input_source_id\: :ref:`int<class_int>`\ ) :ref:`🔗<class_WebXRInterface_signal_squeezeend>`
  211. Emitted when one of the input sources has finished its "primary squeeze action".
  212. 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.
  213. .. rst-class:: classref-item-separator
  214. ----
  215. .. _class_WebXRInterface_signal_squeezestart:
  216. .. rst-class:: classref-signal
  217. **squeezestart**\ (\ input_source_id\: :ref:`int<class_int>`\ ) :ref:`🔗<class_WebXRInterface_signal_squeezestart>`
  218. Emitted when one of the input sources has started its "primary squeeze action".
  219. 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.
  220. .. rst-class:: classref-item-separator
  221. ----
  222. .. _class_WebXRInterface_signal_visibility_state_changed:
  223. .. rst-class:: classref-signal
  224. **visibility_state_changed**\ (\ ) :ref:`🔗<class_WebXRInterface_signal_visibility_state_changed>`
  225. Emitted when :ref:`visibility_state<class_WebXRInterface_property_visibility_state>` has changed.
  226. .. rst-class:: classref-section-separator
  227. ----
  228. .. rst-class:: classref-descriptions-group
  229. Enumerations
  230. ------------
  231. .. _enum_WebXRInterface_TargetRayMode:
  232. .. rst-class:: classref-enumeration
  233. enum **TargetRayMode**: :ref:`🔗<enum_WebXRInterface_TargetRayMode>`
  234. .. _class_WebXRInterface_constant_TARGET_RAY_MODE_UNKNOWN:
  235. .. rst-class:: classref-enumeration-constant
  236. :ref:`TargetRayMode<enum_WebXRInterface_TargetRayMode>` **TARGET_RAY_MODE_UNKNOWN** = ``0``
  237. We don't know the target ray mode.
  238. .. _class_WebXRInterface_constant_TARGET_RAY_MODE_GAZE:
  239. .. rst-class:: classref-enumeration-constant
  240. :ref:`TargetRayMode<enum_WebXRInterface_TargetRayMode>` **TARGET_RAY_MODE_GAZE** = ``1``
  241. Target ray originates at the viewer's eyes and points in the direction they are looking.
  242. .. _class_WebXRInterface_constant_TARGET_RAY_MODE_TRACKED_POINTER:
  243. .. rst-class:: classref-enumeration-constant
  244. :ref:`TargetRayMode<enum_WebXRInterface_TargetRayMode>` **TARGET_RAY_MODE_TRACKED_POINTER** = ``2``
  245. Target ray from a handheld pointer, most likely a VR touch controller.
  246. .. _class_WebXRInterface_constant_TARGET_RAY_MODE_SCREEN:
  247. .. rst-class:: classref-enumeration-constant
  248. :ref:`TargetRayMode<enum_WebXRInterface_TargetRayMode>` **TARGET_RAY_MODE_SCREEN** = ``3``
  249. Target ray from touch screen, mouse or other tactile input device.
  250. .. rst-class:: classref-section-separator
  251. ----
  252. .. rst-class:: classref-descriptions-group
  253. Property Descriptions
  254. ---------------------
  255. .. _class_WebXRInterface_property_enabled_features:
  256. .. rst-class:: classref-property
  257. :ref:`String<class_String>` **enabled_features** :ref:`🔗<class_WebXRInterface_property_enabled_features>`
  258. .. rst-class:: classref-property-setget
  259. - :ref:`String<class_String>` **get_enabled_features**\ (\ )
  260. A comma-separated list of features that were successfully enabled by :ref:`XRInterface.initialize()<class_XRInterface_method_initialize>` when setting up the WebXR session.
  261. This may include features requested by setting :ref:`required_features<class_WebXRInterface_property_required_features>` and :ref:`optional_features<class_WebXRInterface_property_optional_features>`, and will only be available after :ref:`session_started<class_WebXRInterface_signal_session_started>` has been emitted.
  262. \ **Note:** This may not be support by all web browsers, in which case it will be an empty string.
  263. .. rst-class:: classref-item-separator
  264. ----
  265. .. _class_WebXRInterface_property_optional_features:
  266. .. rst-class:: classref-property
  267. :ref:`String<class_String>` **optional_features** :ref:`🔗<class_WebXRInterface_property_optional_features>`
  268. .. rst-class:: classref-property-setget
  269. - |void| **set_optional_features**\ (\ value\: :ref:`String<class_String>`\ )
  270. - :ref:`String<class_String>` **get_optional_features**\ (\ )
  271. A comma-seperated list of optional features used by :ref:`XRInterface.initialize()<class_XRInterface_method_initialize>` when setting up the WebXR session.
  272. 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.
  273. This doesn't have any effect on the interface when already initialized.
  274. Possible values come from `WebXR's XRReferenceSpaceType <https://developer.mozilla.org/en-US/docs/Web/API/XRReferenceSpaceType>`__, or include other features like ``"hand-tracking"`` to enable hand tracking.
  275. .. rst-class:: classref-item-separator
  276. ----
  277. .. _class_WebXRInterface_property_reference_space_type:
  278. .. rst-class:: classref-property
  279. :ref:`String<class_String>` **reference_space_type** :ref:`🔗<class_WebXRInterface_property_reference_space_type>`
  280. .. rst-class:: classref-property-setget
  281. - :ref:`String<class_String>` **get_reference_space_type**\ (\ )
  282. 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.
  283. 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>`.
  284. .. rst-class:: classref-item-separator
  285. ----
  286. .. _class_WebXRInterface_property_requested_reference_space_types:
  287. .. rst-class:: classref-property
  288. :ref:`String<class_String>` **requested_reference_space_types** :ref:`🔗<class_WebXRInterface_property_requested_reference_space_types>`
  289. .. rst-class:: classref-property-setget
  290. - |void| **set_requested_reference_space_types**\ (\ value\: :ref:`String<class_String>`\ )
  291. - :ref:`String<class_String>` **get_requested_reference_space_types**\ (\ )
  292. A comma-seperated list of reference space types used by :ref:`XRInterface.initialize()<class_XRInterface_method_initialize>` when setting up the WebXR session.
  293. 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.
  294. This doesn't have any effect on the interface when already initialized.
  295. 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>`.
  296. .. rst-class:: classref-item-separator
  297. ----
  298. .. _class_WebXRInterface_property_required_features:
  299. .. rst-class:: classref-property
  300. :ref:`String<class_String>` **required_features** :ref:`🔗<class_WebXRInterface_property_required_features>`
  301. .. rst-class:: classref-property-setget
  302. - |void| **set_required_features**\ (\ value\: :ref:`String<class_String>`\ )
  303. - :ref:`String<class_String>` **get_required_features**\ (\ )
  304. A comma-seperated list of required features used by :ref:`XRInterface.initialize()<class_XRInterface_method_initialize>` when setting up the WebXR session.
  305. 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.
  306. This doesn't have any effect on the interface when already initialized.
  307. Possible values come from `WebXR's XRReferenceSpaceType <https://developer.mozilla.org/en-US/docs/Web/API/XRReferenceSpaceType>`__, or include other features like ``"hand-tracking"`` to enable hand tracking.
  308. .. rst-class:: classref-item-separator
  309. ----
  310. .. _class_WebXRInterface_property_session_mode:
  311. .. rst-class:: classref-property
  312. :ref:`String<class_String>` **session_mode** :ref:`🔗<class_WebXRInterface_property_session_mode>`
  313. .. rst-class:: classref-property-setget
  314. - |void| **set_session_mode**\ (\ value\: :ref:`String<class_String>`\ )
  315. - :ref:`String<class_String>` **get_session_mode**\ (\ )
  316. The session mode used by :ref:`XRInterface.initialize()<class_XRInterface_method_initialize>` when setting up the WebXR session.
  317. This doesn't have any effect on the interface when already initialized.
  318. Possible values come from `WebXR's XRSessionMode <https://developer.mozilla.org/en-US/docs/Web/API/XRSessionMode>`__, including: ``"immersive-vr"``, ``"immersive-ar"``, and ``"inline"``.
  319. .. rst-class:: classref-item-separator
  320. ----
  321. .. _class_WebXRInterface_property_visibility_state:
  322. .. rst-class:: classref-property
  323. :ref:`String<class_String>` **visibility_state** :ref:`🔗<class_WebXRInterface_property_visibility_state>`
  324. .. rst-class:: classref-property-setget
  325. - :ref:`String<class_String>` **get_visibility_state**\ (\ )
  326. Indicates if the WebXR session's imagery is visible to the user.
  327. Possible values come from `WebXR's XRVisibilityState <https://developer.mozilla.org/en-US/docs/Web/API/XRVisibilityState>`__, including ``"hidden"``, ``"visible"``, and ``"visible-blurred"``.
  328. .. rst-class:: classref-section-separator
  329. ----
  330. .. rst-class:: classref-descriptions-group
  331. Method Descriptions
  332. -------------------
  333. .. _class_WebXRInterface_method_get_available_display_refresh_rates:
  334. .. rst-class:: classref-method
  335. :ref:`Array<class_Array>` **get_available_display_refresh_rates**\ (\ ) |const| :ref:`🔗<class_WebXRInterface_method_get_available_display_refresh_rates>`
  336. 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.
  337. .. rst-class:: classref-item-separator
  338. ----
  339. .. _class_WebXRInterface_method_get_display_refresh_rate:
  340. .. rst-class:: classref-method
  341. :ref:`float<class_float>` **get_display_refresh_rate**\ (\ ) |const| :ref:`🔗<class_WebXRInterface_method_get_display_refresh_rate>`
  342. 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>`.
  343. .. rst-class:: classref-item-separator
  344. ----
  345. .. _class_WebXRInterface_method_get_input_source_target_ray_mode:
  346. .. rst-class:: classref-method
  347. :ref:`TargetRayMode<enum_WebXRInterface_TargetRayMode>` **get_input_source_target_ray_mode**\ (\ input_source_id\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_WebXRInterface_method_get_input_source_target_ray_mode>`
  348. Returns the target ray mode for the given ``input_source_id``.
  349. 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.
  350. .. rst-class:: classref-item-separator
  351. ----
  352. .. _class_WebXRInterface_method_get_input_source_tracker:
  353. .. rst-class:: classref-method
  354. :ref:`XRControllerTracker<class_XRControllerTracker>` **get_input_source_tracker**\ (\ input_source_id\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_WebXRInterface_method_get_input_source_tracker>`
  355. Gets an :ref:`XRControllerTracker<class_XRControllerTracker>` for the given ``input_source_id``.
  356. 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.
  357. Use this method to get information about the input source that triggered one of these signals:
  358. - :ref:`selectstart<class_WebXRInterface_signal_selectstart>`\
  359. - :ref:`select<class_WebXRInterface_signal_select>`\
  360. - :ref:`selectend<class_WebXRInterface_signal_selectend>`\
  361. - :ref:`squeezestart<class_WebXRInterface_signal_squeezestart>`\
  362. - :ref:`squeeze<class_WebXRInterface_signal_squeeze>`\
  363. - :ref:`squeezestart<class_WebXRInterface_signal_squeezestart>`
  364. .. rst-class:: classref-item-separator
  365. ----
  366. .. _class_WebXRInterface_method_is_input_source_active:
  367. .. rst-class:: classref-method
  368. :ref:`bool<class_bool>` **is_input_source_active**\ (\ input_source_id\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_WebXRInterface_method_is_input_source_active>`
  369. Returns ``true`` if there is an active input source with the given ``input_source_id``.
  370. .. rst-class:: classref-item-separator
  371. ----
  372. .. _class_WebXRInterface_method_is_session_supported:
  373. .. rst-class:: classref-method
  374. |void| **is_session_supported**\ (\ session_mode\: :ref:`String<class_String>`\ ) :ref:`🔗<class_WebXRInterface_method_is_session_supported>`
  375. Checks if the given ``session_mode`` is supported by the user's browser.
  376. Possible values come from `WebXR's XRSessionMode <https://developer.mozilla.org/en-US/docs/Web/API/XRSessionMode>`__, including: ``"immersive-vr"``, ``"immersive-ar"``, and ``"inline"``.
  377. This method returns nothing, instead it emits the :ref:`session_supported<class_WebXRInterface_signal_session_supported>` signal with the result.
  378. .. rst-class:: classref-item-separator
  379. ----
  380. .. _class_WebXRInterface_method_set_display_refresh_rate:
  381. .. rst-class:: classref-method
  382. |void| **set_display_refresh_rate**\ (\ refresh_rate\: :ref:`float<class_float>`\ ) :ref:`🔗<class_WebXRInterface_method_set_display_refresh_rate>`
  383. 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.
  384. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  385. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  386. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  387. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  388. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  389. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  390. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  391. .. |void| replace:: :abbr:`void (No return value.)`