Handle multiple zip files.

This commit is contained in:
kovacsv 2021-09-16 07:45:11 +02:00
parent 87a7fffc4f
commit 30830e8431
3 changed files with 22 additions and 2 deletions

View File

@ -225,7 +225,8 @@ OV.Importer = class
}
OV.LoadExternalLibrary ('loaders/fflate.min.js').then (() => {
for (let i = 0; i < archives.length; i++) {
const archiveBuffer = new Uint8Array (archives[0].content);
const archiveFile = archives[i];
const archiveBuffer = new Uint8Array (archiveFile.content);
const decompressed = fflate.unzipSync (archiveBuffer);
for (const fileName in decompressed) {
if (Object.prototype.hasOwnProperty.call (decompressed, fileName)) {

Binary file not shown.

View File

@ -302,5 +302,24 @@ describe ('Importer Test', function () {
assert.fail ();
}
});
});
});
it ('Multiple Zip Files', function (done) {
let files = [
new FileObject ('zip', 'cube_with_materials_notexture.zip'),
new FileObject ('zip', 'textures.zip')
];
ImportFiles (files, {
success : function (importer, importResult) {
assert (!OV.IsModelEmpty (importResult.model));
console.log (importResult.usedFiles);
assert.deepStrictEqual (importResult.usedFiles, ['cube_with_materials.obj', 'cube_with_materials.mtl', 'cube_texture.png']);
assert.deepStrictEqual (importResult.missingFiles, []);
done ();
},
error : function (importer, importError) {
assert.fail ();
}
});
});
});