WebXR: Better errors when WebXR Layers or multiview are unavailable
This commit is contained in:
parent
26df04377e
commit
9fc8dd686b
@ -94,7 +94,7 @@ const GodotWebXR = {
|
|||||||
return layer;
|
return layer;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!GodotWebXR.session || !GodotWebXR.gl_binding) {
|
if (!GodotWebXR.session || !GodotWebXR.gl_binding || !GodotWebXR.gl_binding.createProjectionLayer) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -293,10 +293,29 @@ const GodotWebXR = {
|
|||||||
GodotWebXR.gl = gl;
|
GodotWebXR.gl = gl;
|
||||||
|
|
||||||
gl.makeXRCompatible().then(function () {
|
gl.makeXRCompatible().then(function () {
|
||||||
GodotWebXR.gl_binding = new XRWebGLBinding(session, gl);
|
const throwNoWebXRLayersError = () => {
|
||||||
|
throw new Error('This browser doesn\'t support WebXR Layers (which Godot requires) nor is the polyfill in use. If you are the developer of this application, please consider including the polyfill.');
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
GodotWebXR.gl_binding = new XRWebGLBinding(session, gl);
|
||||||
|
} catch (error) {
|
||||||
|
// We'll end up here for browsers that don't have XRWebGLBinding at all, or if the browser does support WebXR Layers,
|
||||||
|
// but is using the WebXR polyfill, so calling native XRWebGLBinding with the polyfilled XRSession won't work.
|
||||||
|
throwNoWebXRLayersError();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!GodotWebXR.gl_binding.createProjectionLayer) {
|
||||||
|
// On other browsers, XRWebGLBinding exists and works, but it doesn't support creating projection layers (which is
|
||||||
|
// contrary to the spec, which says this MUST be supported) and so the polyfill is required.
|
||||||
|
throwNoWebXRLayersError();
|
||||||
|
}
|
||||||
|
|
||||||
// This will trigger the layer to get created.
|
// This will trigger the layer to get created.
|
||||||
GodotWebXR.getLayer();
|
const layer = GodotWebXR.getLayer();
|
||||||
|
if (!layer) {
|
||||||
|
throw new Error('Unable to create WebXR Layer.');
|
||||||
|
}
|
||||||
|
|
||||||
function onReferenceSpaceSuccess(reference_space, reference_space_type) {
|
function onReferenceSpaceSuccess(reference_space, reference_space_type) {
|
||||||
GodotWebXR.space = reference_space;
|
GodotWebXR.space = reference_space;
|
||||||
|
@ -291,10 +291,17 @@ bool WebXRInterfaceJS::initialize() {
|
|||||||
|
|
||||||
if (!initialized) {
|
if (!initialized) {
|
||||||
if (!godot_webxr_is_supported()) {
|
if (!godot_webxr_is_supported()) {
|
||||||
|
emit_signal("session_failed", "WebXR is unsupported by this web browser.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (session_mode == "immersive-vr" && !GLES3::Config::get_singleton()->multiview_supported) {
|
||||||
|
emit_signal("session_failed", "Stereo rendering in Godot requires multiview, but this web browser doesn't support it.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (requested_reference_space_types.is_empty()) {
|
if (requested_reference_space_types.is_empty()) {
|
||||||
|
emit_signal("session_failed", "No reference spaces were requested.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user