Hi, I’m trying to load *.obj + *.mtl files from zip archive.
var unzippedData = new JSZip( zippedData );
var materials = new THREE.MTLLoader().parse( unzippedData.file( 'materials.mtl' ).asText() );
var object = new THREE.OBJLoader().setMaterials( materials ).parse( unzippedData.file( 'model.obj' ).asText() );
It’s kind of working, but having a problem with resolving img textures from MTLLoader, it’s trying to load them as there are files in file system (so, i’'m getting 404).
It’s been a while since I used this on a zip file, but essentially you’ll need to do something like this:
// given image data extracted from zip file
const extractedImage = XXXX;
// create a blob URL of the image
const buffer = new Uint8Array( extractedImage );
const blob = new Blob( [ buffer.buffer ] );
const url = URL.createObjectURL( blob );
// then create a library of extracted images
images[ extractedImageFilename ] = url;
// finally use LoadingManager.setURLModifier#
LoadingManager.setURLModifier = ( url ) => {
// check if the URL is an image, then check if the image is in your library
/// and return the extracted image if it is
}