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

Fix issue where loader could overwrite mesh after it had been set

parent f7c85552
No related branches found
No related tags found
No related merge requests found
......@@ -266,10 +266,10 @@ AFRAME.registerComponent("gltf-model-plus", {
this.model = model.scene || model.scenes[0];
this.model.animations = model.animations;
this.el.setObject3D("mesh", this.model);
let object3DToSet = this.model;
if (this.data.inflate && (this.inflatedEl = inflateEntities(this.model, this.templates, gltfPath))) {
this.el.appendChild(this.inflatedEl);
this.el.setObject3D("mesh", this.inflatedEl.object3D);
object3DToSet = this.inflatedEl.object3D;
// TODO: Still don't fully understand the lifecycle here and how it differs between browsers, we should dig in more
// Wait one tick for the appended custom elements to be connected before attaching templates
await nextTick();
......@@ -278,6 +278,7 @@ AFRAME.registerComponent("gltf-model-plus", {
attachTemplate(this.el, name, this.templates[name]);
}
}
this.el.setObject3D("mesh", object3DToSet);
this.el.emit("model-loaded", { format: "gltf", model: this.model });
} catch (e) {
console.error("Failed to load glTF model", e, this);
......
......@@ -63,6 +63,14 @@ AFRAME.registerComponent("media-loader", {
const contentType = (meta && meta.expected_content_type) || (await fetchContentType(raw));
if (contentType.startsWith("image/") || contentType.startsWith("video/")) {
this.el.addEventListener(
"image-loaded",
() => {
console.log("clearing timeout");
clearTimeout(this.showLoaderTimeout);
},
{ once: true }
);
this.el.setAttribute("image-plus", { src: raw, contentType });
} else if (contentType.startsWith("model/gltf") || url.endsWith(".gltf") || url.endsWith(".glb")) {
this.el.addEventListener(
......
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