Constructor
new Material(nameopt, shaderDefinitionopt)
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
name |
string |
<optional> |
'Default Material' |
Material name |
shaderDefinition |
Object |
<optional> |
Optional shader to associate with the material |
Members
blendState :Object
Specification of blending for this Material
Properties:
Name | Type | Description |
---|---|---|
blending |
string |
possible values: 'NoBlending', 'TransparencyBlending', |
blendEquation |
string |
possible values: 'AddEquation', 'SubtractEquation', |
blendSrc |
string |
possible values: 'SrcAlphaFactor', 'ZeroFactor', 'OneFactor', |
blendDst |
string |
possible values: 'SrcAlphaFactor', 'ZeroFactor', 'OneFactor', 'SrcColorFactor', |
cullState :Object
Specification of culling for this Material
Properties:
Name | Type | Description |
---|---|---|
enabled |
boolean | |
cullFace |
string |
possible values: 'Front', 'Back', 'FrontAndBack', default 'Back' |
frontFace |
string |
possible values: 'CW' (clockwise) and 'CCW' (counterclockwise - default) |
depthState :Object
Specification of depth handling for this Material
Properties:
Name | Type | Description |
---|---|---|
enabled |
boolean |
default: true |
write |
boolean |
default: true |
depthFunc |
string |
possible values: 'Never', 'Always', 'Less', 'LessEqual', 'Equal', 'GreaterEqual', |
dualTransparency :boolean
Render the mesh twice with front/back-facing for double transparency rendering. Default is false.
- Default Value:
-
- false
flat :boolean
Use flat rendering mode for this material. Default is false.
- Default Value:
-
- false
lineWidth :number
Width of lines, if line rendering / wireframe is enabled. Default is 1.
- Default Value:
-
- 1
name :string
Material name
offsetState :Object
Specification of the polygon offset for this Material
Properties:
Name | Type | Description |
---|---|---|
enabled |
boolean | |
factor |
number |
default: 1 |
units |
number |
default: 1 |
renderQueue :number
Determines the order in which an object is drawn. There are four pre-defined render queues:
- RenderQueue.BACKGROUND = Rendered before any other objects. Commonly used for skyboxes and the likes
(0-999)
- RenderQueue.OPAQUE = Used for most objects, typically opaque geometry. Rendered front to back
(1000-1999)
- RenderQueue.TRANSPARENT = For all alpha-blended objects. Rendered back to front (2000-2999)
- RenderQueue.OVERLAY = For overlay effects like lens-flares etc (3000+)
By default materials use the render queue of the shader. See Shader or RenderQueue for more info
shader :Shader
Shader to use when rendering
uniforms :Object
Possible overrides for shader uniforms
- Default Value:
-
-
{}
-
wireframe :boolean
Show wireframe on this material. Default is false.
- Default Value:
-
- false
Methods
(static) createShader(shaderDefinition, nameopt) → {Shader}
Creates a new or finds an existing, cached Shader object
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
shaderDefinition |
ShaderDefinition |
see Shader |
||
name |
string |
<optional> |
DefaultShader |
- Deprecated:
-
- Yes
clone(optionsopt) → {Material}
Returns a clone of this material
Parameters:
Name | Type | Attributes | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
<optional> |
Properties
|
getRenderQueue() → {number}
Returns the render queue of this material
getSampler(name) → {Sampler}
Gets a texture sampler
Parameters:
Name | Type | Description |
---|---|---|
name |
string |
Name of texture slot to retrieve sampler from |
getSamplerEntries() → {Object}
Get the map of [slot_name]: [sampler]
getSamplers() → {Array.<SamplerObject>}
Get all samplers as an array
getTexture(name) → {Texture}
Gets a texture in a specific slot
Parameters:
Name | Type | Description |
---|---|---|
name |
string |
Name of texture slot to retrieve texture from |
getTextureCoord(name) → {number}
Gets a texCoord in a specific slot
Parameters:
Name | Type | Description |
---|---|---|
name |
string |
Name of texture slot to retrieve texture from |
getTextureEntries() → {Object}
Get the map of [slot_name]: [Texture]
getTextures() → {Array.<Texture>}
Get all textures as an array
makeInstanced(instanceCount)
Sets the shader define for instance count as well as 'instanceCount' in Material info.
Parameters:
Name | Type | Description |
---|---|---|
instanceCount |
number |
number of instances to draw per instanced draw call |
removeTexture(name)
Removes a texture in a specific slot
Parameters:
Name | Type | Description |
---|---|---|
name |
string |
Name of texture slot to remove |
setEnvironmentMap(ibl)
Set pbr Environment map for this material. If the material is not pbr material, it will return immediately
Parameters:
Name | Type | Description |
---|---|---|
ibl |
ImageBasedLight |
setRenderQueue(queue)
Sets the render queue of this material
Parameters:
Name | Type | Description |
---|---|---|
queue |
number |
See RenderQueue for options |
setSampler(name, sampler)
Sets a texture sampler
Parameters:
Name | Type | Description |
---|---|---|
name |
string |
Name of texture slot to retrieve sampler from |
sampler |
Array.<Sampler> |
if found, or undefined if not in slot. Should return the same amount as the |
setTexture(name, texture, samplers, texCoord)
Sets a texture in a specific slot
Parameters:
Name | Type | Description |
---|---|---|
name |
string |
Name of texture slot |
texture |
Texture |
Texture to set |
samplers |
SamplerObject |
Texture sampler to set (optional) |
texCoord |
number |
TexCoord for the texture |