Problem loading large 3MF files in Three JS

I have a 3mf file that is 200MB and when I load it using the 3MFloaders.js, I get the following error:

THREE.3MFLoader: Error loading 3MF - no 3MF document found: 3D/3dmodel.model

I looked at the source code and it seems to have something to do with the xmlData variable not finding a value called ‘model.’ So I added console.log(xmlData) in the 3mfloader.js and it gives out a html document with a div tag stating that error on line 1 at column 1: Extra content at the end of the document. I do not know what document it is referring to as an error on line 1 at column 1.

I am trying to figure out why this large 3mf file does not load in three js because 3D builder on Windows and CURA can both open the file. I have been successful at opening 40MB 3mf files in three js so I am trying to figure out how to resolve this issue for a 200MB 3mf file.

The issue is probably not related to the file size. 3MF files are actually zip files containing different XML files. 3MFLoader searches for a specific model definition which obviously can’t be found in your case.

If you could manage to reproduce the issue with a smaller file, it would be great to share it so I can investigate the issue more closely.

So I kept cutting down <object> tags which contain the meshes one by one in my 3mf file and tested to see if I still had the error and hopefully provide a small file size with the replicated error. But at a certain point, the error went away after I removed many meshes. I thought the issue might have been with a particular mesh but that does not seem to be the case as no particular <object> was causing an issue when I removed it and kept the rest.

It seems that the error disappears when the file size is less than ~80MB.

In addition, I looked closer at the 3MFLoader.js file where the error originated and included some console.log to output what is happening:

for ( let i = 0; i < modelPartNames.length; i ++ ) {
      const modelPart = modelPartNames[ i ];
      const view = zip[ modelPart ];
      const fileText = LoaderUtils.decodeText( view );
      const xmlData = new DOMParser().parseFromString( fileText, 'application/xml' );
                
      console.log(modelPart);       // Prints 3D/3dmodel.model
      console.log(view);            // Prints out Uint8Array(747332240) with many numbers
      console.log(fileText);        // Prints nothing
      console.log(xmlData);         // Prints the html error saying error on line 1 at column 1
      if ( xmlData.documentElement.nodeName.toLowerCase() !== 'model' ) {
           console.error( 'THREE.3MFLoader: Error loading 3MF - no 3MF document found: ', modelPart ); 
}

Since fileText is not outputing anything, I believe LoaderUtils.decodeText is unable to work with large files.