Closed LorenzWieseke closed 3 years ago
The #model=
parameter is supported in three-gltf-viewer, but doesn't allow ZIP files - you'll need to unpack the hosted file as a .glb or .gltf first. See this example:
Hey Don, thanks for the reply.
I thought I could use your simple dropdown to unzip a file I downloaded and bring it into the viewer.
I had a look at the object that you pass to the _loadZip
So I tried just handing over a file I download
Apperently it doesn't work that easy ;) I need to convert what I get to the an object like the one in the first screenshot (of type "application/x-zip-compressed") and if I understand it right, thats the type of object you get from the drop event (e.dataTransfer.files)
Don't know if this is the right place to ask stuff like this but as you can see I'm not realy a pro ;)
It would be really nice to get this to work because then I could use the viewer to import sketchfab files directly.
Best regards, Lorenz
You've found the source code for _loadZip
here, I assume?
The simple-dropzone
package doesn't handle anything related to downloading files from the web, so you may just want to throw that out and reuse its unzip implementation.
Yes I used the _loadZip from your repo and I know simple-dropzone has nothing to do with downloading files, the name kind of suggests what its used for ;)
I just thought I could use that pipeline to get my downloaded zip unpacked and into the viewer. The problem is to format of the file. You get your file from the event and then pass it to the _loadZip that calls importBlob to read it in and unzip it.
When I try to get my zip using a request I get a string with the binary in it or, using encoding:null, a buffer. So I first tried to use the importText method and pass that string but that gives me an error.
Next I tried to convert it to a blob and don't change your _loadZip method
but that just gives me an error as well :
I was fiddeling the hole day but don't get how to convert what I get from the request to something that matches the file you get from the drop event.
zip.js needs to be given a Blob or a File instance to decompress. The easiest way to get that from a URL would be to use the fetch
API as shown here: https://developer.mozilla.org/en-US/docs/Web/API/Body/blob
If that isn't working I think you may need to share a demo I can reproduce, it is hard to say exactly what is happening from screenshots.
Thanks a lot ! Finally found some time to try your solution and it worked !
Glad to hear! :)
Would it be possible to import a gltf file (zip) like the simple dropzone does but using the url #model=
https://gltf-viewer.donmccurdy.com/#model=https://3dit-model-storage.s3.eu-central-1.amazonaws.com/DamagedHelmet.zip
I am trying to convert the simple dropzone to do this but it's a bit tricky for me to understand all the blob stuff happening
Thanks in advance