three.js icon indicating copy to clipboard operation
three.js copied to clipboard

MaterialX: TextureNode does not have nodeType set

Open beersandrew opened this issue 1 year ago • 2 comments

Description

When using the MaterialXLoader with TiledImage MaterialX nodes, three creates TextureNodes, however I do not see the output type of the TiledImage as the nodeType of the TextureNode as I'd expect. Typically there is a ConvertNode parenting the TextureNode with the correct type, however I've encountered a situation where the TextureNode is parented by a MathNode in which in1 has type color3 but the TextureNode should export a float type, here it's impossible to know which type should be used. This is an issue when exporting three nodes

Solution

When reading the tiledImage node from the MaterialX file, put the output type as the nodeType on the TextureNode

Alternatives

If there is some reason for this, or if I'm totally missing where this type can be found, please let me know!

Additional context

StackBlitz : https://stackblitz.com/edit/three-mtlx-ptdcen?file=main.js,mtlx%2Fbrick.mtlx&terminal=dev

Screenshot 2024-10-14 at 11 57 32

No response

beersandrew avatar Oct 14 '24 14:10 beersandrew

The node system uses Node.getNodeType() to check the type of node, .nodeType is used only for static types, would not be the case with TextureNode.

sunag avatar Oct 15 '24 00:10 sunag

The node system uses Node.getNodeType() to check the type of node, .nodeType is used only for static types, would not be the case with TextureNode.

Thanks @sunag, I'm not sure this is exactly what i'm looking for. In MaterialX, I can have a tiledimage node that outputs a float, color3, float3 (maybe others), however this block of code https://github.com/mrdoob/three.js/blob/dev/src/nodes/accessors/TextureNode.js#L72, seems to only output float, uvec4, ivec4, or vec4. Do you know if there's some other field or way to get the float / vector3|float3 / color output from the tiledimage / texture node?

beersandrew avatar Oct 15 '24 00:10 beersandrew