diff --git a/src/components/player-info.js b/src/components/player-info.js index 717b1d2a96336f38ced2ce511b68b12f8acdcddf..8cb265a67b9c67ac26510d6b8a03efb59703c931 100644 --- a/src/components/player-info.js +++ b/src/components/player-info.js @@ -17,7 +17,6 @@ AFRAME.registerComponent("player-info", { }, applyProperties() { const nametagEl = this.el.querySelector(".nametag"); - console.log("updating properties", this.data, nametagEl); if (this.data.displayName && nametagEl) { nametagEl.setAttribute("text", { value: this.data.displayName diff --git a/src/elements/a-gltf-entity.js b/src/elements/a-gltf-entity.js index d8318246dd2aa91d28dbe084d0a3233c1d1d2684..b6923b12375c00cec14299275421f2ac2d8d2d30 100644 --- a/src/elements/a-gltf-entity.js +++ b/src/elements/a-gltf-entity.js @@ -218,6 +218,8 @@ AFRAME.registerElement("a-gltf-entity", { templateRoot: document.importNode(templateEl.content.firstElementChild, true) }) ); + // Imported custom nodes don't immediatly set up their callbacks in Firefox, wait a tick before considering them "loaded" + // We do this all up front so that we don't have to wait every time we load a new GLTF model. setTimeout(resolve, 0); }); } @@ -246,7 +248,11 @@ AFRAME.registerElement("a-gltf-entity", { if (src === this.lastSrc) return; this.lastSrc = src; - if (!src) return; + if (!src) { + console.warn("gltf-entity set to an empty source, unloading inflated model."); + this.removeInflatedEl(); + return; + } const model = await cachedLoadGLTF(src); @@ -255,10 +261,7 @@ AFRAME.registerElement("a-gltf-entity", { if (src != this.lastSrc) return; // If we had inflated something already before, clean that up - if (this.inflatedEl) { - this.inflatedEl.parentNode.removeChild(this.inflatedEl); - delete this.inflatedEl; - } + this.removeInflatedEl(); this.model = model.scene || model.scenes[0]; this.model.animations = model.animations; @@ -279,6 +282,15 @@ AFRAME.registerElement("a-gltf-entity", { } }, + removeInflatedEl: { + value() { + if (this.inflatedEl) { + this.inflatedEl.parentNode.removeChild(this.inflatedEl); + delete this.inflatedEl; + } + } + }, + attributeChangedCallback: { value(attr, oldVal, newVal) { if (attr === "src") {