Downloading models in JavaScript - Developers - Sketchfab


(Rozakos George) #1

Hi,

3D Modeller and Animator. I am utilising Sketchfabs API for an app service idea to upload and download models of my own and others that are available on Sketchfab.

I am still very fresh and a beginner in javascript. I am utilising ThreeJS as the main test app to stream all models through to edit and view.

I have provided a link below of the instructions I am following to download and open the gltf models in three js.

Instructions:

I am struggling with the entry.getData. It doesn’t seem clear on how to Generate URLs for every Entry. This is how it is laid out at the moment:

zip.workerScriptsPath = ‘/lib/’;
var reader = new zip.HttpReader(‘models/untitled.zip’);
var entry;
zip.createReader(
reader,
function(zipReader) {
zipReader.getEntries(function(entries){
console.log(entries);

// entry = entries

// return entry
});

},

entry.getData(
new zip.BlobWriter(‘text/plain’),
function onEnd(data) {
var url = window.URL.createObjectURL(data);

}),

function(error) {
console.error(error);
}
);

At this point, I managed to read the entry data of the zip. However is there any clear instruction in Generating the URLs for every entry loaded.

I am sorry if this might be an obvious silly question!

Thank you,
George