Module: material

Material API. Containts methods to control parameters of standard materials. The node-based materials are not supported yet.

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:

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:

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:

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:

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:

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:

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 intencity value
Type
Number
Source:

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:

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:

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:

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:

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
dest Vec3 <optional>
Destination color
Returns:
Destination color
Type
RGB
Source:

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"]
Returns:
Value.
Type
Number
Source:

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:

get_specular_color_factor(obj, mat_name) → {RGB}

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
RGB
Source:

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:

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:

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, "Material", cube_001, "Material.001");

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, "Material", 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:

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 cube = m_scenes.get_object_by_name("Cube");
m_mat.set_diffuse_color(cube, "Material", [0.5, 0, 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:

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 intencity value
Source:

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, "Material", 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: new Float32Array([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:

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
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, ["Material", "RGB"], 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"]
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, ["Material", "Value"], 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, "Material", [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 RGB Specular color factor
Source:

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, "Material", 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, "Material", 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: