Skip to content
Snippets Groups Projects
Commit e994b7b2 authored by netpro2k's avatar netpro2k
Browse files

Cleanup based on PR feedback

parent dd531045
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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") {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment