diff --git a/src/components/gltf-model-plus.js b/src/components/gltf-model-plus.js index b5904f0fc36c9695908f56017772449ee99dd7e3..8b1d02b7d3d334ddbf84c18f5f8c89f4920b504b 100644 --- a/src/components/gltf-model-plus.js +++ b/src/components/gltf-model-plus.js @@ -200,7 +200,7 @@ function cachedLoadGLTF(src, basePath, contentType, preferredTechnique, onProgre try { let gltfUrl = src; let onLoad = resolve; - if (contentType === "model/gltf+zip") { + if (contentType === "model/gltf+zip" || contentType === "application/x-zip-compressed") { const fileMap = await getFilesFromSketchfabZip(src); gltfUrl = fileMap["scene.gtlf"]; onLoad = model => { diff --git a/src/components/media-loader.js b/src/components/media-loader.js index 1ae37f321a5374919e9dc5fedd51ab722b245ffa..b97074439ddddab0e020b6973ec286a0a1570176 100644 --- a/src/components/media-loader.js +++ b/src/components/media-loader.js @@ -84,7 +84,12 @@ AFRAME.registerComponent("media-loader", { } this.el.setAttribute("image-plus", { src: blobUrl || raw, contentType }); this.el.setAttribute("position-at-box-shape-border", { target: ".delete-button", dirs: ["forward", "back"] }); - } else if (contentType.startsWith("model/gltf") || url.endsWith(".gltf") || url.endsWith(".glb")) { + } else if ( + contentType.indexOf("x-zip-compressed") !== -1 || + contentType.startsWith("model/gltf") || + url.endsWith(".gltf") || + url.endsWith(".glb") + ) { this.el.addEventListener( "model-loaded", () => { @@ -94,8 +99,17 @@ AFRAME.registerComponent("media-loader", { { once: true } ); this.el.addEventListener("model-error", this.onError, { once: true }); + let blobUrl; + if (token) { + const modelResponse = await fetch(raw, { + method: "GET", + headers: { Authorization: `Token ${token}` } + }); + const blob = await modelResponse.blob(); + blobUrl = window.URL.createObjectURL(blob); + } this.el.setAttribute("gltf-model-plus", { - src: raw, + src: blobUrl || raw, contentType, basePath: THREE.LoaderUtils.extractUrlBase(origin), inflate: true