This is preliminary documentation and is subject to change.

WebGL 3D Material


3d material.



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



Method invalidates material and removes all shaders from material.


Method removes all material channels and shaders.


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.


  • For opacity channel will be amount of opacity.
  • For rest channels number will be set to color.


Each element in array is item for shader.


 Where each item is:

  • Array of 3 numbers - channel color.
  • Definition of channel item.


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:

 "lightmap":{"texture":"test triangles.jpg","uvset":1,"format":"rgb"},


In this article