diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml index ec380ddc54d..a82cf9a2a91 100644 --- a/doc/classes/ProjectSettings.xml +++ b/doc/classes/ProjectSettings.xml @@ -1058,6 +1058,8 @@ [Environment] that will be used as a fallback environment in case a scene does not specify its own environment. The default environment is loaded in at scene load time regardless of whether you have set an environment or not. If you do not rely on the fallback environment, it is best to delete [code]default_env.tres[/code], or to specify a different default environment here. + + @@ -1287,6 +1289,8 @@ + + diff --git a/modules/webxr/doc_classes/WebXRInterface.xml b/modules/webxr/doc_classes/WebXRInterface.xml index f178dc1bd58..bddffd910ee 100644 --- a/modules/webxr/doc_classes/WebXRInterface.xml +++ b/modules/webxr/doc_classes/WebXRInterface.xml @@ -1,5 +1,5 @@ - + AR/VR interface using WebXR. @@ -66,7 +66,7 @@ func _webxr_session_started(): # This tells Godot to start rendering to the headset. - get_viewport().arvr = true + get_viewport().xr = true # This will be the reference space type you ultimately got, out of the # types that you requested above. This is useful if you want the game to # work a little differently in 'bounded-floor' versus 'local-floor'. @@ -75,7 +75,7 @@ func _webxr_session_ended(): # If the user exits immersive mode, then we tell Godot to render to the web # page again. - get_viewport().arvr = false + get_viewport().xr = false func _webxr_session_failed(message): OS.alert("Failed to initialize: " + message) @@ -90,18 +90,7 @@ https://www.snopekgames.com/blog/2020/how-make-vr-game-webxr-godot - - - - - - - Checks if the given [code]session_mode[/code] is supported by the user's browser. - Possible values come from [url=https://developer.mozilla.org/en-US/docs/Web/API/XRSessionMode]WebXR's XRSessionMode[/url], including: [code]"immersive-vr"[/code], [code]"immersive-ar"[/code], and [code]"inline"[/code]. - This method returns nothing, instead it emits the [signal session_supported] signal with the result. - - - + @@ -118,18 +107,23 @@ - [signal squeezestart] + + + + + + + Checks if the given [code]session_mode[/code] is supported by the user's browser. + Possible values come from [url=https://developer.mozilla.org/en-US/docs/Web/API/XRSessionMode]WebXR's XRSessionMode[/url], including: [code]"immersive-vr"[/code], [code]"immersive-ar"[/code], and [code]"inline"[/code]. + This method returns nothing, instead it emits the [signal session_supported] signal with the result. + + - - The session mode used by [method XRInterface.initialize] when setting up the WebXR session. - This doesn't have any effect on the interface when already initialized. - Possible values come from [url=https://developer.mozilla.org/en-US/docs/Web/API/XRSessionMode]WebXR's XRSessionMode[/url], including: [code]"immersive-vr"[/code], [code]"immersive-ar"[/code], and [code]"inline"[/code]. - - - A comma-seperated list of required features used by [method XRInterface.initialize] when setting up the WebXR session. - If a user's browser or device doesn't support one of the given features, initialization will fail and [signal session_failed] will be emitted. - This doesn't have any effect on the interface when already initialized. - Possible values come from [url=https://developer.mozilla.org/en-US/docs/Web/API/XRReferenceSpaceType]WebXR's XRReferenceSpaceType[/url]. If you want to use a particular reference space type, it must be listed in either [member required_features] or [member optional_features]. + + The vertices of a polygon which defines the boundaries of the user's play area. + This will only be available if [member reference_space_type] is [code]"bounded-floor"[/code] and only on certain browsers and devices that support it. + The [signal reference_space_reset] signal may indicate when this changes. A comma-seperated list of optional features used by [method XRInterface.initialize] when setting up the WebXR session. @@ -137,62 +131,38 @@ This doesn't have any effect on the interface when already initialized. Possible values come from [url=https://developer.mozilla.org/en-US/docs/Web/API/XRReferenceSpaceType]WebXR's XRReferenceSpaceType[/url]. If you want to use a particular reference space type, it must be listed in either [member required_features] or [member optional_features]. + + The reference space type (from the list of requested types set in the [member requested_reference_space_types] property), that was ultimately used by [method XRInterface.initialize] when setting up the WebXR session. + Possible values come from [url=https://developer.mozilla.org/en-US/docs/Web/API/XRReferenceSpaceType]WebXR's XRReferenceSpaceType[/url]. If you want to use a particular reference space type, it must be listed in either [member required_features] or [member optional_features]. + A comma-seperated list of reference space types used by [method XRInterface.initialize] when setting up the WebXR session. The reference space types are requested in order, and the first on supported by the users device or browser will be used. The [member reference_space_type] property contains the reference space type that was ultimately used. This doesn't have any effect on the interface when already initialized. Possible values come from [url=https://developer.mozilla.org/en-US/docs/Web/API/XRReferenceSpaceType]WebXR's XRReferenceSpaceType[/url]. If you want to use a particular reference space type, it must be listed in either [member required_features] or [member optional_features]. - - The reference space type (from the list of requested types set in the [member requested_reference_space_types] property), that was ultimately used by [method XRInterface.initialize] when setting up the WebXR session. + + A comma-seperated list of required features used by [method XRInterface.initialize] when setting up the WebXR session. + If a user's browser or device doesn't support one of the given features, initialization will fail and [signal session_failed] will be emitted. + This doesn't have any effect on the interface when already initialized. Possible values come from [url=https://developer.mozilla.org/en-US/docs/Web/API/XRReferenceSpaceType]WebXR's XRReferenceSpaceType[/url]. If you want to use a particular reference space type, it must be listed in either [member required_features] or [member optional_features]. + + The session mode used by [method XRInterface.initialize] when setting up the WebXR session. + This doesn't have any effect on the interface when already initialized. + Possible values come from [url=https://developer.mozilla.org/en-US/docs/Web/API/XRSessionMode]WebXR's XRSessionMode[/url], including: [code]"immersive-vr"[/code], [code]"immersive-ar"[/code], and [code]"inline"[/code]. + Indicates if the WebXR session's imagery is visible to the user. Possible values come from [url=https://developer.mozilla.org/en-US/docs/Web/API/XRVisibilityState]WebXR's XRVisibilityState[/url], including [code]"hidden"[/code], [code]"visible"[/code], and [code]"visible-blurred"[/code]. - - The vertices of a polygon which defines the boundaries of the user's play area. - This will only be available if [member reference_space_type] is [code]"bounded-floor"[/code] and only on certain browsers and devices that support it. - The [signal reference_space_reset] signal may indicate when this changes. - - - - - - + - Emitted by [method is_session_supported] to indicate if the given [code]session_mode[/code] is supported or not. - - - - - Emitted by [method XRInterface.initialize] if the session is successfully started. - At this point, it's safe to do [code]get_viewport().arvr = true[/code] to instruct Godot to start rendering to the AR/VR device. - - - - - - - Emitted by [method XRInterface.initialize] if the session fails to start. - [code]message[/code] may optionally contain an error message from WebXR, or an empty string if no message is available. - - - - - Emitted when the user ends the WebXR session (which can be done using UI from the browser or device). - At this point, you should do [code]get_viewport().arvr = false[/code] to instruct Godot to resume rendering to the screen. - - - - - - - Emitted when one of the "controllers" has started its "primary action". - Use [method get_controller] to get more information about the controller. + Emitted to indicate that the reference space has been reset or reconfigured. + 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 [member bounds_geometry]) or pressed/held a button to recenter their position. + See [url=https://developer.mozilla.org/en-US/docs/Web/API/XRReferenceSpace/reset_event]WebXR's XRReferenceSpace reset event[/url] for more information. @@ -211,14 +181,43 @@ Use [method get_controller] to get more information about the controller. - + - Emitted when one of the "controllers" has started its "primary squeeze action". + Emitted when one of the "controllers" has started its "primary action". Use [method get_controller] to get more information about the controller. + + + Emitted when the user ends the WebXR session (which can be done using UI from the browser or device). + At this point, you should do [code]get_viewport().xr = false[/code] to instruct Godot to resume rendering to the screen. + + + + + + + Emitted by [method XRInterface.initialize] if the session fails to start. + [code]message[/code] may optionally contain an error message from WebXR, or an empty string if no message is available. + + + + + Emitted by [method XRInterface.initialize] if the session is successfully started. + At this point, it's safe to do [code]get_viewport().xr = true[/code] to instruct Godot to start rendering to the AR/VR device. + + + + + + + + + Emitted by [method is_session_supported] to indicate if the given [code]session_mode[/code] is supported or not. + + @@ -235,18 +234,19 @@ Use [method get_controller] to get more information about the controller. + + + + + Emitted when one of the "controllers" has started its "primary squeeze action". + Use [method get_controller] to get more information about the controller. + + Emitted when [member visibility_state] has changed. - - - Emitted to indicate that the reference space has been reset or reconfigured. - 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 [member bounds_geometry]) or pressed/held a button to recenter their position. - See [url=https://developer.mozilla.org/en-US/docs/Web/API/XRReferenceSpace/reset_event]WebXR's XRReferenceSpace reset event[/url] for more information. - - diff --git a/modules/webxr/webxr_interface.cpp b/modules/webxr/webxr_interface.cpp index 2c28ce070f4..3e8e75bf0e3 100644 --- a/modules/webxr/webxr_interface.cpp +++ b/modules/webxr/webxr_interface.cpp @@ -42,7 +42,7 @@ void WebXRInterface::_bind_methods() { ClassDB::bind_method(D_METHOD("get_reference_space_type"), &WebXRInterface::get_reference_space_type); ClassDB::bind_method(D_METHOD("set_requested_reference_space_types", "requested_reference_space_types"), &WebXRInterface::set_requested_reference_space_types); ClassDB::bind_method(D_METHOD("get_requested_reference_space_types"), &WebXRInterface::get_requested_reference_space_types); - ClassDB::bind_method(D_METHOD("get_controller"), &WebXRInterface::get_controller); + ClassDB::bind_method(D_METHOD("get_controller", "controller_id"), &WebXRInterface::get_controller); ClassDB::bind_method(D_METHOD("get_visibility_state"), &WebXRInterface::get_visibility_state); ClassDB::bind_method(D_METHOD("get_bounds_geometry"), &WebXRInterface::get_bounds_geometry);