Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3MFLoader: Fix parsing of assets with sub models. #30491

Merged
merged 3 commits into from
Feb 10, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions examples/jsm/loaders/3MFLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ class ThreeMFLoader extends Loader {

}

let rootModelFile = null;

for ( file in zip ) {

if ( file.match( /\_rels\/.rels$/ ) ) {
Expand All @@ -132,9 +134,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 @@ -144,6 +150,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