From cf8b7aacdab79bdeac7004428b10b366a0d7b651 Mon Sep 17 00:00:00 2001 From: Robert Long <robert@robertlong.me> Date: Mon, 6 Aug 2018 19:34:44 -0700 Subject: [PATCH] Fix resolveGLTFUri to work with blob urls. --- src/components/gltf-model-plus.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/components/gltf-model-plus.js b/src/components/gltf-model-plus.js index c31aefea5..b90e23687 100644 --- a/src/components/gltf-model-plus.js +++ b/src/components/gltf-model-plus.js @@ -209,8 +209,15 @@ async function loadEnvMap() { return texture; } -function resolveGLTFUri(gltfProperty, basePath) { - return resolveMedia(new URL(gltfProperty.uri, basePath).href).then(({ raw }) => (gltfProperty.uri = raw)); +async function resolveGLTFUri(gltfProperty, basePath) { + const url = new URL(gltfProperty.uri, basePath); + + if (url.protocol === "blob:") { + gltfProperty.uri = url.href; + } else { + const { raw } = await resolveMedia(url.href); + gltfProperty.uri = raw; + } } async function loadGLTF(src, preferredTechnique, onProgress) { @@ -271,6 +278,8 @@ async function loadGLTF(src, preferredTechnique, onProgress) { await Promise.all(pendingFarsparkPromises); + console.log(parser.json); + const gltf = await new Promise((resolve, reject) => parser.parse( (scene, scenes, cameras, animations, json) => { -- GitLab