summaryrefslogtreecommitdiff
path: root/modules/webxr/native/library_godot_webxr.js
diff options
context:
space:
mode:
Diffstat (limited to 'modules/webxr/native/library_godot_webxr.js')
-rw-r--r--modules/webxr/native/library_godot_webxr.js14
1 files changed, 13 insertions, 1 deletions
diff --git a/modules/webxr/native/library_godot_webxr.js b/modules/webxr/native/library_godot_webxr.js
index 764656712d..8e9ef8a73c 100644
--- a/modules/webxr/native/library_godot_webxr.js
+++ b/modules/webxr/native/library_godot_webxr.js
@@ -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);