From 63456982ab7376b92b0a0b5769f7d1ab4f47d8fd Mon Sep 17 00:00:00 2001 From: netpro2k <netpro2k@gmail.com> Date: Thu, 15 Mar 2018 19:15:00 -0700 Subject: [PATCH] Allow creating an a-gltf-entity with no src set initially --- src/elements/a-gltf-entity.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/elements/a-gltf-entity.js b/src/elements/a-gltf-entity.js index c660dcbcf..d8318246d 100644 --- a/src/elements/a-gltf-entity.js +++ b/src/elements/a-gltf-entity.js @@ -227,7 +227,7 @@ AFRAME.registerElement("a-gltf-entity", { async value(src) { try { // If the src attribute is a selector, get the url from the asset item. - if (src.charAt(0) === "#") { + if (src && src.charAt(0) === "#") { const assetEl = document.getElementById(src.substring(1)); const fallbackSrc = assetEl.getAttribute("src"); @@ -246,6 +246,8 @@ AFRAME.registerElement("a-gltf-entity", { if (src === this.lastSrc) return; this.lastSrc = src; + if (!src) return; + const model = await cachedLoadGLTF(src); // If we started loading something else already -- GitLab