diff --git a/src/components/gltf-model-plus.js b/src/components/gltf-model-plus.js index 7128e506a138f56b4f4d177e7af2a8c895a9c174..c12a0cad6cac31825aed17ddde7659e0aab0b75e 100644 --- a/src/components/gltf-model-plus.js +++ b/src/components/gltf-model-plus.js @@ -209,6 +209,10 @@ async function loadEnvMap() { return texture; } +function resolveGLTFUri(gltfProperty, basePath) { + return resolveMedia(new URL(gltfProperty.uri, basePath).href).then(({ raw }) => (gltfProperty.uri = raw)); +} + async function loadGLTF(src, preferredTechnique, onProgress) { const { raw, origin, contentType } = await resolveMedia(src); const basePath = THREE.LoaderUtils.extractUrlBase(origin); @@ -236,21 +240,13 @@ async function loadGLTF(src, preferredTechnique, onProgress) { if (images) { for (const image of images) { - const imagePromise = resolveMedia(new URL(image.uri, parser.options.path).href).then(({ raw }) => { - image.uri = raw; - }); - - pendingFarsparkPromises.push(imagePromise); + pendingFarsparkPromises.push(resolveGLTFUri(image, parser.options.path)); } } if (buffers) { for (const buffer of buffers) { - const bufferPromise = resolveMedia(new URL(buffer.uri, parser.options.path).href).then(({ raw }) => { - buffer.uri = raw; - }); - - pendingFarsparkPromises.push(bufferPromise); + pendingFarsparkPromises.push(resolveGLTFUri(buffer, parser.options.path)); } }