Skip to content

Commit

Permalink
Merge pull request #2 from matthewbadeau/fix/Jack-J-Young-3mf-prod-fix
Browse files Browse the repository at this point in the history
3MFLoader: Fix parsing of assets with sub models
  • Loading branch information
Floppy authored Feb 11, 2025
2 parents 025aebc + 9553006 commit 41c06dc
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ class ThreeMFLoader extends Loader {

}

let rootModelFile = null;

for (file in zip) {

if (file.match(/\_rels\/.rels$/)) {
Expand All @@ -148,9 +150,13 @@ class ThreeMFLoader extends Loader {

modelRelsName = file;

} else if (file.match(/^3D\/.*\.model$/)) {
} else if ( file.match( /^3D\/[^\/]*\.model$/ ) ) {

rootModelFile = file;

modelPartNames.push(file);
} else if ( file.match( /^3D\/.*\/.*\.model$/ ) ) {

modelPartNames.push( file ); // sub models

} else if (file.match(/^3D\/Textures?\/.*/)) {

Expand All @@ -160,6 +166,8 @@ class ThreeMFLoader extends Loader {

}

modelPartNames.push( rootModelFile ); // push root model at the end so it is processed after the sub models

if (relsName === undefined) throw new Error('THREE.ThreeMFLoader: Cannot find relationship file `rels` in 3MF archive.');

//
Expand Down

0 comments on commit 41c06dc

Please sign in to comment.