-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
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
MaterialLoader support custom materials #21265
Comments
What is inversion of control? And how would you extend |
My exact use case is that I have a custom material I'm loading from json, and I don't want to duplicate all of the MaterialLoader logic. Easiest way: Ideal way: MaterialLoader is a classic example of polymorphic serialization. (Same with This same polymorphism applies to toJSON as well -- each material has a toJSON, serializes just what's specific to that material, then calls the base Material's toJSON. |
Would an approach like in Yuka solve your issue? The idea is that users can register custom types for deserialization in certain classes via
Sidenote: If #11266 would be implement, it would not be necessary to have a custom loader. You could actually extend the |
@Mugen87 Yes, this is exactly what I was picturing. The Yuka link is a good example of polymorphic unmarshalling. I think this would also have the benefit of separating loading from the unmarshalling. There are three separate steps here, and IHMO I believe they should be decoupled.
|
The MaterialLoader as it is now isn't very extensible. I would like to be able to more easily create loaders for custom materials without duplicating the material loader.
The main problem is that while there's inversion of control for the textures, there isn't for Materials.
three.js/src/loaders/MaterialLoader.js
Line 70 in d5bb724
This is a factory pattern that isn't provided to the loader, nor is there a way to add a new material constructor / material type.
The text was updated successfully, but these errors were encountered: