Merge pull request #45445 from dsnopek/webxr-mono

[3.2] Support mono devices in WebXR
This commit is contained in:
Rémi Verschelde 2021-01-27 21:11:56 +01:00 committed by GitHub
commit 9ba95970ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 3 deletions

View File

@ -61,6 +61,7 @@ extern void godot_webxr_initialize(
GodotWebXRSimpleEventCallback p_on_simple_event);
extern void godot_webxr_uninitialize();
extern int godot_webxr_get_view_count();
extern int *godot_webxr_get_render_targetsize();
extern float *godot_webxr_get_transform_for_eye(int p_eye);
extern float *godot_webxr_get_projection_for_eye(int p_eye);

View File

@ -395,6 +395,15 @@ const GodotWebXR = {
GodotWebXR.pauseResumeMainLoop();
},
godot_webxr_get_view_count__proxy: 'sync',
godot_webxr_get_view_count__sig: 'i',
godot_webxr_get_view_count: function () {
if (!GodotWebXR.session || !GodotWebXR.pose) {
return 0;
}
return GodotWebXR.pose.views.length;
},
godot_webxr_get_render_targetsize__proxy: 'sync',
godot_webxr_get_render_targetsize__sig: 'i',
godot_webxr_get_render_targetsize: function () {

View File

@ -199,12 +199,11 @@ StringName WebXRInterfaceJS::get_name() const {
};
int WebXRInterfaceJS::get_capabilities() const {
return ARVRInterface::ARVR_STEREO;
return ARVRInterface::ARVR_STEREO | ARVRInterface::ARVR_MONO;
};
bool WebXRInterfaceJS::is_stereo() {
// @todo WebXR can be mono! So, how do we know? Count the views in the frame?
return true;
return godot_webxr_get_view_count() == 2;
};
bool WebXRInterfaceJS::is_initialized() const {