Module: material

Material API. Contains methods to control parameters of materials.

Summary

Methods

Type Definitions

Detailed Description

Methods

check_specular_hardness(obj, mat_name) → {boolean}

Check the specular hardness for the object material.
Parameters:
Name Type Description
obj Object3D Object 3D
mat_name string Material name
Returns:
Specular hardness presence
Type
boolean
Source:
Example
var m_scenes = require("scenes");
var m_mat = require("material");

var cube = m_scenes.get_object_by_name("Cube");
var has_specular_hardness = m_mat.check_specular_hardness(cube, "MyMaterial");

check_specular_intensity(obj, mat_name) → {boolean}

Check the specular intensity for the object material.
Parameters:
Name Type Description
obj Object3D Object 3D
mat_name string Material name
Returns:
Specular intensity presence
Type
boolean
Source:
Example
var m_scenes = require("scenes");
var m_mat = require("material");

var cube = m_scenes.get_object_by_name("Cube");
var has_specular_intensity = m_mat.check_specular_intensity(cube, "MyMaterial");

get_alpha_factor(obj, mat_name) → {number}

Get the diffuse alpha factor for the object material.
Parameters:
Name Type Description
obj Object3D Object 3D
mat_name string Material name
Returns:
Diffuse alpha factor value
Type
number
Source:
Example
var m_scenes = require("scenes");
var m_mat = require("material");

var cube = m_scenes.get_object_by_name("Cube");
var alpha_factor = m_mat.get_alpha_factor(cube, "MyMaterial");

get_ambient_factor(obj, mat_name) → {number}

Get the ambient factor for the object material.
Parameters:
Name Type Description
obj Object3D Object 3D
mat_name string Material name
Returns:
Ambient factor value
Type
number
Source:
Example
var m_scenes = require("scenes");
var m_mat = require("material");

var cube = m_scenes.get_object_by_name("Cube");
var ambient_factor = m_mat.get_ambient_factor(cube, "MyMaterial");

get_diffuse_color(obj, mat_name) → {RGBA}

Get the diffuse color and alpha for the object material.
Parameters:
Name Type Description
obj Object3D Object 3D
mat_name string Material name
Returns:
Material diffuse color+alpha
Type
RGBA
Source:
Example
var m_scenes = require("scenes");
var m_mat = require("material");

var cube = m_scenes.get_object_by_name("Cube");
var diffuse_color = m_mat.get_diffuse_color(cube, "MyMaterial");

get_diffuse_color_factor(obj, mat_name) → {number}

Get the diffuse color factor for the object material.
Parameters:
Name Type Description
obj Object3D Object 3D
mat_name string Material name
Returns:
Diffuse color factor value
Type
number
Source:
Example
var m_scenes = require("scenes");
var m_mat = require("material");

var cube = m_scenes.get_object_by_name("Cube");
var diffuse_color_factor = m_mat.get_diffuse_color_factor(cube, "MyMaterial");

get_diffuse_intensity(obj, mat_name) → {number}

Get the diffuse color intensity for the object material.
Parameters:
Name Type Description
obj Object3D Object 3D
mat_name string Material name
Returns:
Diffuse intensity value
Type
number
Source:
Example
var m_scenes = require("scenes");
var m_mat = require("material");

var cube = m_scenes.get_object_by_name("Cube");
var diffuse_intensity = m_mat.get_diffuse_intensity(cube, "MyMaterial");

get_emit_factor(obj, mat_name) → {number}

Get the emit factor for the object material.
Parameters:
Name Type Description
obj Object3D Object 3D
mat_name string Material name
Returns:
Emit factor value
Type
number
Source:
Example
var m_scenes = require("scenes");
var m_mat = require("material");

var cube = m_scenes.get_object_by_name("Cube");
var emit_factor = m_mat.get_emit_factor(cube, "MyMaterial");

get_line_params(obj) → (nullable) {LineParams}

Get line params or null in case of error.
Parameters:
Name Type Description
obj Object3D Line object
Returns:
Line params
Type
LineParams
Source:
Example
var m_scenes = require("scenes");
var m_mat  = require("material");

var line_object = m_scenes.get_object_by_name("MyLine");
var line_params = m_mat.get_line_params(line_object);

get_material_extended_params(obj, mat_name) → {MaterialExtParams|null}

Get the material extended params
Parameters:
Name Type Description
obj Object3D Object
mat_name string Material name
Returns:
Material extended params or null
Type
MaterialExtParams | null
Source:
Example
var m_scenes = require("scenes");
var m_mat = require("material");

var cube = m_scenes.get_object_by_name("Cube");
var extended_parameters = m_mat.get_material_extended_params(cube, "MyMaterial");

get_materials_names(obj) → {Array.<string>}

Get materials' names for the given object
Parameters:
Name Type Description
obj Object3D Object 3D
Returns:
Array of materials' names
Type
Array.<string>
Source:
Example
var m_scenes = require("scenes");
var m_mat = require("material");

var cube = m_scenes.get_object_by_name("Cube");
var material_list = m_mat.get_materials_names(cube);

get_nodemat_rgb(obj, name_list, destopt) → {RGB}

Get color of the RGB node in the object's material.
Parameters:
Name Type Attributes Description
obj Object3D Object 3D
name_list Array.<string> List consisting of the material name, the names of nested node groups (if any) and the name of the RGB node itself. For world material name is missing
dest Vec3 <optional>
Destination color
Returns:
Destination color
Type
RGB
Source:
Example
var m_scenes = require("scenes");
var m_mat  = require("material");

var cube = m_scenes.get_object_by_name("Cube");
var rgb_node_values = m_mat.get_nodemat_rgb(cube, ["MyMaterial", "MyRGB"]);

get_nodemat_value(obj, name_list) → {number}

Get value of the Value node in the object's material.
Parameters:
Name Type Description
obj Object3D Object 3D
name_list Array.<string> List consisting of the material name, the names of nested node groups (if any) and the name of the Value node itself. Should have at least 2 elements ["Mat","Node"]. For world material name is missing
Returns:
Value.
Type
number
Source:
Example
var m_scenes = require("scenes");
var m_mat  = require("material");

var cube = m_scenes.get_object_by_name("Cube");
var node_value = m_mat.get_nodemat_value(cube, ["MyMaterial", "MyValue"]);

get_specular_color(obj, mat_name) → {RGB}

Get the specular color for the object material.
Parameters:
Name Type Description
obj Object3D Object 3D
mat_name string Material name
Returns:
Specular color
Type
RGB
Source:
Example
var m_scenes = require("scenes");
var m_mat = require("material");

var cube = m_scenes.get_object_by_name("Cube");
var specular_color = m_mat.get_specular_color(cube, "MyMaterial");

get_specular_color_factor(obj, mat_name) → {number}

Get the specular color factor for the object material.
Parameters:
Name Type Description
obj Object3D Object 3D
mat_name string Material name
Returns:
Specular color factor
Type
number
Source:
Example
var m_scenes = require("scenes");
var m_mat = require("material");

var cube = m_scenes.get_object_by_name("Cube");
var specular_color_factor = m_mat.get_specular_color_factor(cube, "MyMaterial");

get_specular_hardness(obj, mat_name) → {number}

Get the specular color hardness for the object material.
Parameters:
Name Type Description
obj Object3D Object 3D
mat_name string Material name
Returns:
Specular color hardness
Type
number
Source:
Example
var m_scenes = require("scenes");
var m_mat = require("material");

var cube = m_scenes.get_object_by_name("Cube");
var specular_hardness = m_mat.get_specular_hardness(cube, "MyMaterial");

get_specular_intensity(obj, mat_name) → {number}

Get the specular color intensity for the object material.
Parameters:
Name Type Description
obj Object3D Object 3D
mat_name string Material name
Returns:
Specular color intensity
Type
number
Source:
Example
var m_scenes = require("scenes");
var m_mat = require("material");

var cube = m_scenes.get_object_by_name("Cube");
var specular_intensity = m_mat.get_specular_intensity(cube, "MyMaterial");

get_water_material_params(obj, water_mat_name) → {WaterMaterialParams|null}

Get params for the water material
Parameters:
Name Type Description
obj Object3D Object
water_mat_name string Water material name
Returns:
Water material params or null
Type
WaterMaterialParams | null
Source:

inherit_material(obj_from, mat_from_name, obj_to, mat_to_name)

Inherit the batch material from another object.
Parameters:
Name Type Description
obj_from Object3D Source Object 3D
mat_from_name string Source material name
obj_to Object3D Destination Object 3D
mat_to_name string Destination material name
Source:
Example
var m_mat = require("material");
var m_scenes = require("scenes");

var cube = m_scenes.get_object_by_name("Cube");
var cube_001 = m_scenes.get_object_by_name("Cube.001");
m_mat.inherit_material(cube, "MyMaterial_1", cube_001, "MyMaterial_2");

set_alpha_factor(obj, mat_name, alpha_factor)

Set the alpha factor for the object material.
Parameters:
Name Type Description
obj Object3D Object 3D
mat_name string Material name
alpha_factor number Alpha factor value
Source:
Example
var m_mat = require("material");
var m_scenes = require("scenes");

var cube = m_scenes.get_object_by_name("Cube");
m_mat.set_alpha_factor(cube, "MyMaterial", 0.2);

set_ambient_factor(obj, mat_name, ambient_factor)

Set the ambient factor for the object material.
Parameters:
Name Type Description
obj Object3D Object 3D
mat_name string Material name
ambient_factor number Ambient factor value
Source:
Example
var m_scenes = require("scenes");
var m_mat = require("material");

var cube = m_scenes.get_object_by_name("Cube");
m_mat.set_ambient_factor(cube, "MyMaterial", 0.6);

set_diffuse_color(obj, mat_name, color)

Set the diffuse color and alpha for the object material.
Parameters:
Name Type Description
obj Object3D Object 3D
mat_name string Material name
color RGBA Color+alpha vector
Source:
Example
var m_mat = require("material");
var m_scenes = require("scenes");
var m_rgba = require("rgba");

var cube = m_scenes.get_object_by_name("Cube");
m_mat.set_diffuse_color(cube, "MyMaterial", m_rgba.from_values(1.0, 0.0, 0.0, 1.0));

set_diffuse_color_factor(obj, mat_name, diffuse_color_factor)

Set the diffuse color factor for the object material.
Parameters:
Name Type Description
obj Object3D Object 3D
mat_name string Material name
diffuse_color_factor number Diffuse color factor value
Source:
Example
var m_scenes = require("scenes");
var m_mat = require("material");

var cube = m_scenes.get_object_by_name("Cube");
m_mat.set_diffuse_color_factor(cube, "MyMaterial", 0.05);

set_diffuse_intensity(obj, mat_name, intensity)

Set the diffuse color intensity for the object material.
Parameters:
Name Type Description
obj Object3D Object 3D
mat_name string Material name
intensity number Diffuse intensity value
Source:
Example
var m_scenes = require("scenes");
var m_mat = require("material");

var cube = m_scenes.get_object_by_name("Cube");
m_mat.set_diffuse_intensity(cube, "MyMaterial", 0.5);

set_emit_factor(obj, mat_name, emit_factor)

Set the emit factor for the object material.
Parameters:
Name Type Description
obj Object3D Object 3D
mat_name string Material name
emit_factor number Emit factor value
Source:
Example
var m_mat = require("material");
var m_scenes = require("scenes");

var cube = m_scenes.get_object_by_name("Cube");
m_mat.set_emit_factor(cube, "MyMaterial", 1);

set_line_params(obj, line_params)

Set line params.
Parameters:
Name Type Description
obj Object3D Line object
line_params LineParams Line params
Source:
Example
var m_mat = require("material");
var m_scenes = require("scenes");

var empty = m_scenes.get_object_by_name("Empty");
m_mat.set_line_params(empty, {
    color: [1.0, 0.0, 0.0, 1.0],
    width: 5
});

set_material_extended_params(obj, mat_name, mat_params)

Set the material params
Parameters:
Name Type Description
obj Object3D Object
mat_name string Material name
mat_params MaterialExtParams Material params
Source:
Example
var m_scenes = require("scenes");
var m_mat = require("material");

var cube = m_scenes.get_object_by_name("Cube");
m_mat.set_material_extended_params(cube, "MyMaterial", {fresnel: 0,
                                                        fresnel_factor: 1.25,
                                                        parallax_scale: 0,
                                                        parallax_steps: "5.0",
                                                        reflect_factor: 0});

set_nodemat_rgb(obj, name_list, r, g, b)

Set color of the RGB node in the object's material.
Parameters:
Name Type Description
obj Object3D Object 3D
name_list Array.<string> List consisting of the material name, the names of nested node groups (if any) and the name of the RGB node itself. For world material name is missing
r number The value to set the red channel of the RGB node to [0..1]
g number The value to set the green channel of the RGB node to [0..1]
b number The value to set the blue channel of the RGB node to [0..1]
Source:
Example
var m_mat = require("material");
var m_scenes = require("scenes");

var cube = m_scenes.get_object_by_name("Cube");
m_mat.set_nodemat_rgb(cube, ["MyMaterial", "RGB.001"], 1, 0, 1);

set_nodemat_value(obj, name_list, value)

Set value of the Value node in the object's material.
Parameters:
Name Type Description
obj Object3D Object 3D
name_list Array.<string> List consisting of the material name, the names of nested node groups (if any) and the name of the Value node itself. Should have at least 2 elements ["Mat","Node"]. For world material name is missing
value number The value to set the Value node to
Source:
Example
var m_mat = require("material");
var m_scenes = require("scenes");

var cube = m_scenes.get_object_by_name("Cube");
m_mat.set_nodemat_value(cube, ["MyMaterial", "Value.001"], 20);

set_specular_color(obj, mat_name, color)

Set the specular color for the object material.
Parameters:
Name Type Description
obj Object3D Object 3D
mat_name string Material name
color RGB Color vector
Source:
Example
var m_mat = require("material");
var m_scenes = require("scenes");

var cube = m_scenes.get_object_by_name("Cube");
m_mat.set_specular_color(cube, "MyMaterial", [0, 0.8, 0]);

set_specular_color_factor(obj, mat_name, factor)

Set the specular color factor for the object material.
Parameters:
Name Type Description
obj Object3D Object 3D
mat_name string Material name
factor number Specular color factor
Source:
Example
var m_scenes = require("scenes");
var m_mat = require("material");

var cube = m_scenes.get_object_by_name("Cube");
m_mat.set_specular_color_factor(cube, "MyMaterial", 0.8);

set_specular_hardness(obj, mat_name, hardness)

Set the specular color hardness for the object material.
Parameters:
Name Type Description
obj Object3D Object 3D
mat_name string Material name
hardness number Specular hardness value
Source:
Example
var m_mat = require("material");
var m_scenes = require("scenes");

var cube = m_scenes.get_object_by_name("Cube");
m_mat.set_specular_hardness(cube, "MyMaterial", 0.8);

set_specular_intensity(obj, mat_name, intensity)

Set the specular color intensity for the object material.
Parameters:
Name Type Description
obj Object3D Object 3D
mat_name string Material name
intensity number Specular intensity value
Source:
Example
var m_mat = require("material");
var m_scenes = require("scenes");

var cube = m_scenes.get_object_by_name("Cube");
m_mat.set_specular_intensity(cube, "MyMaterial", 0.7);

set_water_material_params(obj, water_mat_name, water_mat_params)

Set params for the water material
Parameters:
Name Type Description
obj Object3D Object
water_mat_name string Water material name
water_mat_params WaterMaterialParams Water material params
Source:

Type Definitions

LineParams

Line params.
Type:
  • Object
Properties:
Name Type Description
color RGBA Line diffuse color
width number Line width in pixels
Source: