-
-
Notifications
You must be signed in to change notification settings - Fork 36k
ObjectLoader: Fix loading multiple materials with the same uuid #15128
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
Changes from all commits
3b6c7f4
6f47a25
44d9c06
61503c4
38fd96a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -454,6 +454,7 @@ Object.assign( ObjectLoader.prototype, { | |
parseMaterials: function ( json, textures ) { | ||
|
||
var materials = {}; | ||
var cache = {}; | ||
|
||
if ( json !== undefined ) { | ||
|
||
|
@@ -466,21 +467,31 @@ Object.assign( ObjectLoader.prototype, { | |
|
||
if ( data.type === 'MultiMaterial' ) { | ||
|
||
// Deprecated | ||
|
||
// Deprecated | ||
var array = []; | ||
|
||
for ( var j = 0; j < data.materials.length; j ++ ) { | ||
|
||
array.push( loader.parse( data.materials[ j ] ) ); | ||
if ( cache[ data.materials[ j ].uuid ] ) { | ||
|
||
array.push( cache[ data.materials[ j ].uuid ] ); | ||
|
||
} else { | ||
|
||
var mat = loader.parse( data.materials[ j ] ); | ||
cache[ data.materials[ j ].uuid ] = mat; | ||
array.push( mat ); | ||
|
||
} | ||
|
||
} | ||
|
||
materials[ data.uuid ] = array; | ||
cache[ data.uuid ] = array; | ||
|
||
} else { | ||
|
||
materials[ data.uuid ] = loader.parse( data ); | ||
cache[ data.uuid ] = materials[ data.uuid ]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one too. Is it really needed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is most likely needed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see... |
||
|
||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this one needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you like to do another PR removing it? Just to keep the code clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I'll clean it up on my end 👌
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
f8dc0a9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.