-
Notifications
You must be signed in to change notification settings - Fork 103
Material
cjcliffe edited this page Oct 15, 2011
·
8 revisions
The Material class is used to apply color, texture and other surface properties to a Mesh's Face.
Parameters:
-
init
: This can be undefined, a single string representing the name of the Material or an object constructor. The object constructor parameters are equivalent to the object structure with the exception ofMaterial.textures[]
being in the formatMaterial.textures[enums.texture.map.COLOR] = [[Texture]];
Object Constructor:
- init object
-
diffuse
: Diffuse Material color, default:[1.0,1.0,1.0]
-
specular
: Specular Material color, default:[0.5, 0.5, 0.5]
-
color
: Material color, default:[1.0,1.0,1.0]
-
ambient
: Ambient emission color, default:[0.0,0.0,0.0]
-
opacity
: Opacity, default:1.0
-
shininess
: Shininess, default:1.0
-
max_smooth
: Maximum smoothing angle for this material during[[Mesh]].calculateNormals()
for automatic edge splitting. default:60.0
-
name
: Name of this material, used for retrieving materials by name. -
textures
: texture configuration object-
color
: Texture to use for this material'senums.texture.map.COLOR
binding. -
envsphere
: Texture to use for this material'senums.texture.map.ENVSPHERE
binding. -
normal
: Texture to use for this material'senums.texture.map.NORMAL
binding. -
bump
: Texture to use for this material'senums.texture.map.BUMP
binding. -
reflect
: Texture to use for this material'senums.texture.map.REFLECT
binding. -
specular
: Texture to use for this material'senums.texture.map.SPECULAR
binding. -
ambient
: Texture to use for this material'senums.texture.map.AMBIENT
binding. -
alpha
: Texture to use for this material'senums.texture.map.ALPHA
binding.
-
-
Apply Texture texture to the given texture_type of this material.
Parameters:
-
texture
: A Texture based class that will be used as the image source. -
texture_type
: (optional) The destination texture type in this material. It can be one of several CubicVR.enums:-
enums.texture.map.COLOR
: apply to COLOR channel (default) -
enums.texture.map.SPECULAR
: apply to SPECULAR channel -
enums.texture.map.NORMAL
: apply to NORMAL channel, affects surface lighting -
enums.texture.map.BUMP
: apply to BUMP (or parallax) channel providing heights for a holographic depth effect -
enums.texture.map.REFLECT
- apply to REFLECT to determine areas reflections such as ENVSPHERE will be applied -
enums.texture.map.ENVSPHERE
: apply to ENVSPHERE to provide a spherical map reflection -
enums.texture.map.AMBIENT
: apply to AMBIENT to provide an ambient emission (brightness regardless of lighting) -
enums.texture.map.ALPHA
: apply as ALPHA clipping or ALPHA transparency depending on material opacity
-
Returns:
none
From samples/basic/materials.html:
var material1 = new CubicVR.Material({
color: [80/255, 200/255, 120/255],
specular: [1,1,1],
shininess: 0.9,
env_amount: 1.0,
textures: {
color: new CubicVR.Texture("../images/2576-diffuse.jpg"),
normal: new CubicVR.Texture("../images/2576-normal.jpg"),
bump: new CubicVR.Texture("../images/2576-bump.jpg"),
envsphere: new CubicVR.Texture("../images/fract_reflections.jpg")
}
});