Material

MeshNodeMaterial

A custom node-based material.

This material used to describe custom material setups exported from Blender or 3ds Max. I can be physically based or non-physical depending on the specified node graph.

Examples

Change material color specified in the "RGB.001" node:

var object = app.scene.getObjectByName("MyObj"); var mat = object.material; var index = mat.nodeRGBMap['RGB.001']; // 'RGB.001' is the name of an RGB node mat.nodeRGB[index] = new v3d.Vector4(1, 0, 0, 1); // new color in RGBA format mat.needsUpdate = true;

Change value specified in the "Value.001" node:

var object = app.scene.getObjectByName("Circle"); var mat = object.material; var index = mat.nodeValueMap['Value.001']; mat.nodeValue[index] = 0.5; // new value mat.needsUpdate = true;

Constructor

MeshNodeMaterial(parameters : Object)

parameters - (optional) an object with one or more properties defining the material's appearance. Any property of the material (including any property inherited from Material) can be passed in here.

The exception is the property color, which can be passed in as a hexadecimal string and is 0xffffff (white) by default. Color.set(color) is called internally.

Properties

See the base Material class for common properties.

.nodeGraph : DiGraph

Directed graph which contains material nodes.

.additionalNodeGraphs : Object

Additional graphs representing node groups of the main node graph.

.profile : String

Node material profile, it can be "blender" or "max".

.nodeTextures : Object

Object with material textures. It maps texture names to textures. You can use it to dynamically assign new textures to a material.

.nodeRGB : Array

Array of Vector4 values which contains color values of a material's "RGB" nodes. Please note that these colors are represented by 4-dimentional vector, not the Color class.

.nodeRGBMap : Array

Maps "RGB" node name to index in .nodeRGB array. Used to define which color value is to be updated, see the example listing above.

.nodeValue : Array

Array of float values which contain values of the material's "Value" nodes.

.nodeValueMap : Array

Maps "Value" node name to index in .nodeValue array. Used to define which value is to be updated, see the example listing above.

.isMeshNodeMaterial : Boolean

Used to check whether this class represent node material.
You should not change this, as it is used internally for optimization.

Methods

See the base Material class for common methods.

.updateNodeGraph () : null

Generate shaders and update other material parameters based on the specified .nodeGraph.

Static Methods

.nodeGraphFromGLTF (gltfNodeGraph : Object) : DiGraph

Convert GLTF node graph to the format used by the material's .nodeGraph property.

Puzzles

Use the following puzzles to manage your materials:
assign material - assign the material to an object.
replace texture - replace the material's texture.

Source

For more info on how to obtain the source code of this module see this page.