Gltf ziploader, how to add scene using blob


#1

//using jszip.min.js
//using ziploader.js ,
//using babylon.max.js

var url = `"/3dmax/gltf/obj.zip";` //gltf file 180mb after compression 33mb ,i need this

//xhr zip & progress
var manager = new LoadingManager();

new Promise(function (resolve, reject) {
    if (url.match(/\.zip$/)) {
        new ZipLoader().load(url).then(function (zip) {
            manager.setURLModifier(zip.urlResolver);
            resolve(zip.find(/\.(gltf|glb)$/i));
        });
    } else {
        resolve(url);
    }
}).then(function (files) {
    //zip has been downloaded to the client
    //files[0] blob:/3dmax/gltf/demo1.gltf
    // Now this wrong, how to add scene using blob
    BABYLON.SceneLoader.Load(files[0], ....);
    // im trying to using Tools ,but its wrong too.
BABYLON.Tools.LoadFile(file,
                        (data, url) => {

                        }, (data) => {

                        }, false,
                        (XMLHttpRequest, err) => {

                        });
});`

#2

Hello,

Your browser should be able to do it automatically if your webserver supports automatic gzip compression: How To Optimize Your Site With GZIP Compression ā€“ BetterExplained

If this is not the case, then you need to call Url.CreateObjectUrl(data) on your unzipped content before calling SceneLoader.Load:
https://www.babylonjs-playground.com/#7F6S08#3

Also I recommend using glb instead of gltf as gltf needs additional files (.bin) and Iā€™m not sure they will go through your process


#3

thank you reply
just now I tried use .glb , this format is very good.
my obj.glb source file is 110 MB in size,
54.9mb after transmission through iis7 Gzip, but i use 7z.zip ,the pack size 33.98mb. so i still want to choose zip transmission mode. thank you very much.
next ,i began to try. Url.CreateObjectUrl for glb , if i have any questions, hope to get your help again.