WebGL FinalMesh API | 3D Material

iv.material

3d material.

Constructor

iv.material(data)

Constructor creates new camera object and initialized it using optional data parameter.

Methods

.invalidate()

Method invalidates material and removes all shaders from material.

.clear()

Method removes all material channels and shaders.

.load(data)

Method initialised material from material description object.

data Object with material definition.

Shaders will be created on first material usage. Shader will depend on scene lights and mesh properties. All parameters in object are optional.

Supported fields are:

path Path to material resources - textures. String.
name Name of material. String.
phong  Phong exponent. Number.
backSide Material for back side. Boolean.
diffuse Diffuse channel
specular Specular channel
emissive Emissive channel
reflection Reflection channel
opacity Opacity channel
bump Bump channel
ambient Same as emissive channel
lightmap Light map channel

 

Format of each channel is array of items or item or number.

Number

Array

Each element in array is item for shader.

Item

 Where each item is:

 

Object for material channel definition

color Channel color. Number or array of 3 items. For instance red color may be: 0xff0000 or [1,0,0]
amount Amount. number from 0 to 1
blend Blend mode. String: "mul", "add", "sub".
texture Texture definition. Object

 

Texture defintion:

type string, optional. "cube" - for reflection texture
tm 3x2 UV matrix.
cmp Components. 'a' or 'rgb'.
filter Filter.
uvset UV set. 0 or 1.
wrapT Wrap in T direction.
wrapS Wrap in S direction.
   

Sample material:

{"diffuse":{"texture":"ash_uvgrid03.jpg","format":"rgb"},
 "specular":{"color":[0.7,0.7,0.7]},
 "lightmap":{"texture":"test triangles.jpg","uvset":1,"format":"rgb"},
 "phong":16
}