question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NodeMaterial : can't extend NodeMaterials classes

See original GitHub issue

Describe 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

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:closed
  • Created 2 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
sunagcommented, Oct 7, 2022

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 new WebGLNodeBuilder, for that reason I added a simple example in this PR to avoid repeating this type of problem.

1reaction
sunagcommented, Mar 15, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found