32 fflate.unzip(zipData, (err, files) => {
34 console.error(
"Error unzipping file:", err);
39 for (let fileName in files) {
40 const fileType = fileName.split(
'.').pop().toLowerCase();
42 if ([
'mtlx'].includes(fileType)) {
45 const fileContent =
new TextDecoder(
"utf-8").decode(files[fileName]);
47 documents.push({ name: fileName, content: fileContent });
51 const standardMimeTypes = {
57 'svg':
'image/svg+xml',
60 'hdr':
'image/vnd.radiance'
63 let mimeType =
'image/' + fileType;
64 if (fileType in standardMimeTypes) {
65 mimeType = standardMimeTypes[fileType];
67 const blob =
new Blob([files[fileName]], { type: mimeType });
68 const url = URL.createObjectURL(blob);
70 textures.push({ name: fileName, url: url });
76 if (files[fileName].length === 0) {
77 console.log(`Folder: ${fileName}`);
79 console.log(`Unsupported file type: ${fileName}`);
86 return [documents, textures];