NodeMaterial : can't extend NodeMaterials classes
See original GitHub issueDescribe the bug
Extending any of the NodeMaterial based material classes creates a broken and unusable material since r138. It gives me this error : Uncaught TypeError: Cannot set properties of undefined (setting 'value')
.
Fix the bug
This problem occurs because the constructor.name is used to determine the value of type. This value will equal the name of the top-most class in the inheritance chain.
I believe setting it manually would be better (ex: PointsNodeMaterial.prototype.type = 'PointsNodeMaterial';
).
Or using a boolean (ex: PointsNodeMaterial.prototype.isPointsNodeMaterial = true;
) (like many other things in threejs) !
Live example
- codepen-latest-release (line 50 👀 )
Expected behavior
Extending any ThreeJs material class should work out of the box.
Platform:
- Device: all
- OS: all
- Browser: all
- Three.js version: r138
Issue Analytics
- State:
- Created 2 years ago
- Comments:12 (6 by maintainers)
Top Results From Across the Web
Node Material
The Node Material is a simple, highly customizable material that you can build ... If you are interested in learning how to create...
Read more >Tutorial: Node based Material System in Release 20 in depth
Dive deep into Node-based Material with Maxon Lead Instructor Helge Maus as he analyzes a project by Maxon Certified Instructor Yan Ge (Joe) ......
Read more >Custom Nodes in the Node Material Editor: Part 1 - YouTube
In this video, Jason walks us through solving a common workflow problem in the Node Material Editor, while giving us a look at...
Read more >Promote Node-based Materials to Core and Polish #16440
@sunag Hey, great work on the node materials! Would it be possible to specify outputs on node materials to render additional scene data...
Read more >State of Node-based Shaders in three.js? Any good tutorials?
As far as I understand node materials will be the only way to build ... that make topographic lines that should be easy...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
When I did the new
WebGLNodeBuilder
I must not have synced all the updates, this is one of the “big updates” problems. One of the safest methods of testing Three.js is the examples, and then the unit test that we are yet to implement for the nodes. The reason this has been repeated is the lack of an example that we can test after updates of “high impact” like newWebGLNodeBuilder
, for that reason I added a simple example in this PR to avoid repeating this type of problem.I posted a PR to fix it. I think it would be better not to use types other than what the class represents because that breaks serialization.