Prevent fatal error in WebXR when 'immersize-ar' loses and regains tracking
This commit is contained in:
parent
1ea133b6b5
commit
a23fc126eb
3 changed files with 32 additions and 10 deletions
|
|
@ -380,6 +380,11 @@ const GodotWebXR = {
|
|||
gl.deleteTexture(texture);
|
||||
}
|
||||
GodotWebXR.textures[i] = null;
|
||||
|
||||
const texture_id = GodotWebXR.texture_ids[i];
|
||||
if (texture_id !== null) {
|
||||
GL.textures[texture_id] = null;
|
||||
}
|
||||
GodotWebXR.texture_ids[i] = null;
|
||||
}
|
||||
|
||||
|
|
@ -460,7 +465,7 @@ const GodotWebXR = {
|
|||
godot_webxr_get_external_texture_for_eye__proxy: 'sync',
|
||||
godot_webxr_get_external_texture_for_eye__sig: 'ii',
|
||||
godot_webxr_get_external_texture_for_eye: function (p_eye) {
|
||||
if (!GodotWebXR.session || !GodotWebXR.pose) {
|
||||
if (!GodotWebXR.session) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -469,6 +474,13 @@ const GodotWebXR = {
|
|||
return GodotWebXR.texture_ids[view_index];
|
||||
}
|
||||
|
||||
// Check pose separately and after returning the cached texture id,
|
||||
// because we won't get a pose in some cases if we lose tracking, and
|
||||
// we don't want to return 0 just because tracking was lost.
|
||||
if (!GodotWebXR.pose) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const glLayer = GodotWebXR.session.renderState.baseLayer;
|
||||
const view = GodotWebXR.pose.views[view_index];
|
||||
const viewport = glLayer.getViewport(view);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue