t3d. DepthMaterial

A material for drawing geometry by depth. Depth is based off of the camera near and far plane. White is nearest, black is farthest.

Constructor

new DepthMaterial()

Create a DepthMaterial.

Extends

Members

acceptLight :Boolean

Whether the material is affected by lights. If set true, renderer will try to upload light uniforms.
Type:
  • Boolean
Default Value
  • false

alphaMap :t3d.Texture2D

The alpha map.
Default Value
  • null

alphaMapCoord :Number

Define the UV chanel for the alpha map to use starting from 0 and defaulting to 0.
Type:
  • Number
Default Value
  • 0

alphaMapTransform :t3d.Matrix3

The uv-transform matrix of alpha map.
Default Value
  • t3d.Matrix3()

alphaTest :Number

Sets the alpha value to be used when running an alpha test. The material will not be renderered if the opacity is lower than this value.
Type:
  • Number
Default Value
  • 0

alphaToCoverage :Boolean

Enables alpha to coverage. Can only be used when MSAA is enabled.
Type:
  • Boolean
Default Value
  • false

aoMap :t3d.Texture2D

The red channel of this texture is used as the ambient occlusion map.
Default Value
  • null

aoMapCoord :Number

Define the UV chanel for the ao map to use starting from 0 and defaulting to 0.
Type:
  • Number
Default Value
  • 0

aoMapIntensity :Number

Intensity of the ambient occlusion effect.
Type:
  • Number
Default Value
  • 1

aoMapTransform :t3d.Matrix3

The uv-transform matrix of ao map.
Default Value
  • t3d.Matrix3()

blendDst :t3d.BLEND_FACTOR

Blending destination. The t3d.Material#blending must be set to t3d.BLEND_TYPE.CUSTOM for this to have any effect.
Default Value
  • t3d.BLEND_FACTOR.ONE_MINUS_SRC_ALPHA

blendDstAlpha :t3d.BLEND_FACTOR

The transparency of the t3d.Material#blendDst. The t3d.Material#blending must be set to t3d.BLEND_TYPE.CUSTOM for this to have any effect.
Default Value
  • null

blendEquation :t3d.BLEND_EQUATION

Blending equation to use when applying blending. The t3d.Material#blending must be set to t3d.BLEND_TYPE.CUSTOM for this to have any effect.
Default Value
  • t3d.BLEND_EQUATION.ADD

blendEquationAlpha :t3d.BLEND_EQUATION

The tranparency of the t3d.Material#blendEquation. The t3d.Material#blending must be set to t3d.BLEND_TYPE.CUSTOM for this to have any effect.
Default Value
  • null

blendSrc :t3d.BLEND_FACTOR

Blending source. The t3d.Material#blending must be set to t3d.BLEND_TYPE.CUSTOM for this to have any effect.
Default Value
  • t3d.BLEND_FACTOR.SRC_ALPHA

blendSrcAlpha :t3d.BLEND_FACTOR

The transparency of the t3d.Material#blendSrc. The t3d.Material#blending must be set to t3d.BLEND_TYPE.CUSTOM for this to have any effect.
Default Value
  • null

blending :t3d.BLEND_TYPE

Which blending to use when displaying objects with this material. This must be set to t3d.BLEND_TYPE.CUSTOM to use custom blendSrc, blendDst or blendEquation.
Default Value
  • t3d.BLEND_TYPE.NORMAL

bumpMap :t3d.Texture2D

The texture to create a bump map. The black and white values map to the perceived depth in relation to the lights. Bump doesn't actually affect the geometry of the object, only the lighting.
Default Value
  • null

bumpScale :Number

How much the bump map affects the material. Typical ranges are 0-1.
Type:
  • Number
Default Value
  • 1

clippingPlanes :Array.<t3d.Plane>

User-defined clipping planes specified as t3d.Plane objects in world space. These planes apply to the objects this material is attached to. Points in space whose signed distance to the plane is negative are clipped (not rendered).
Type:
Default Value
  • null

colorWrite :Boolean

Whether to render the material's color. This can be used in conjunction with a mesh's renderOrder property to create invisible objects that occlude other objects.
Type:
  • Boolean
Default Value
  • true

defines :Object

Custom defines of the shader. Only valid when the material type is t3d.MATERIAL_TYPE.SHADER.
Type:
  • Object
Default Value
  • {}

depthFunc :t3d.COMPARE_FUNC

Which depth function to use. See the t3d.COMPARE_FUNC constants for all possible values.
Default Value
  • t3d.COMPARE_FUNC.LEQUAL

depthTest :Boolean

Whether to have depth test enabled when rendering this material.
Type:
  • Boolean
Default Value
  • true

depthWrite :Boolean

Whether rendering this material has any effect on the depth buffer. When drawing 2D overlays it can be useful to disable the depth writing in order to layer several things together without creating z-index artifacts.
Type:
  • Boolean
Default Value
  • true

diffuse :t3d.Color3

The diffuse color.
Default Value
  • t3d.Color3(0xffffff)

diffuseMap :t3d.Texture2D

The diffuse map.
Default Value
  • null

diffuseMapCoord :Number

Define the UV chanel for the diffuse map to use starting from 0 and defaulting to 0.
Type:
  • Number
Default Value
  • 0

diffuseMapTransform :t3d.Matrix3

The uv-transform matrix of diffuse map. This will also affect other maps that cannot be individually specified uv transform, such as normalMap, bumpMap, etc.
Default Value
  • t3d.Matrix3()

dithering :Boolean

Whether to apply dithering to the color to remove the appearance of banding.
Type:
  • Boolean
Default Value
  • false

drawMode :t3d.DRAW_MODE

Determines how the mesh triangles are constructed from the vertices.
Default Value
  • t3d.DRAW_MODE.TRIANGLES

emissive :t3d.Color3

Emissive (light) color of the material, essentially a solid color unaffected by other lighting.
Default Value
  • t3d.Color3(0x000000)

emissiveMap :t3d.Texture2D

Set emissive (glow) map. The emissive map color is modulated by the emissive color. If you have an emissive map, be sure to set the emissive color to something other than black.
Default Value
  • null

emissiveMapCoord :Number

Define the UV chanel for the emissive map to use starting from 0 and defaulting to 0.
Type:
  • Number
Default Value
  • 0

emissiveMapTransform :t3d.Matrix3

The uv-transform matrix of emissive map.
Default Value
  • t3d.Matrix3()

envMap :t3d.TextureCube|null|undefined

The environment map. If set to undefined, then the material will not inherit envMap from scene.environment.
Type:
Default Value
  • null

envMapCombine :t3d.ENVMAP_COMBINE_TYPE

How to combine the result of the surface's color with the environment map, if any. This has no effect in a t3d.PBRMaterial.
Default Value
  • t3d.ENVMAP_COMBINE_TYPE.MULTIPLY

envMapIntensity :Number

Scales the effect of the environment map by multiplying its color. This can effect both the diffuse and specular components of environment map.
Type:
  • Number
Default Value
  • 1

fog :Boolean

Whether the material is affected by fog.
Type:
  • Boolean
Default Value
  • true

forceUpdateUniforms :Boolean

Whether the material uniforms need to be updated every draw call. If set false, the material uniforms are only updated once per frame , this can help optimize performance.
Type:
  • Boolean
Default Value
  • true

fragmentShader :String

Custom GLSL code for fragment shader. Only valid when the material type is t3d.MATERIAL_TYPE.SHADER.
Type:
  • String
Default Value
  • ""

(readonly) id :Number

Unique number for this material instance.
Type:
  • Number

needsUpdate :Boolean

Specifies that the material needs to be recompiled. This property is automatically set to true when instancing a new material.
Type:
  • Boolean
Default Value
  • true

normalMap :t3d.Texture2D

The normal map.
Default Value
  • null

normalScale :t3d.Vector2

How much the normal map affects the material. Typical ranges are 0-1.
Default Value
  • t3d.Vector2(1,1)

opacity :Number

Float in the range of 0.0 - 1.0 indicating how transparent the material is. A value of 0.0 indicates fully transparent, 1.0 is fully opaque.
Type:
  • Number
Default Value
  • 1

packToRGBA :Boolean

Encoding for depth packing.
Type:
  • Boolean
Default Value
  • false

polygonOffset :Boolean

Whether to use polygon offset. This corresponds to the GL_POLYGON_OFFSET_FILL WebGL feature.
Type:
  • Boolean
Default Value
  • false

polygonOffsetFactor :Number

Sets the polygon offset factor.
Type:
  • Number
Default Value
  • 0

polygonOffsetUnits :Number

Sets the polygon offset units.
Type:
  • Number
Default Value
  • 0

precision :String

Override the renderer's default precision for this material. Can be "highp", "mediump" or "lowp".
Type:
  • String
Default Value
  • null

premultipliedAlpha :Boolean

Whether to premultiply the alpha (transparency) value.
Type:
  • Boolean
Default Value
  • false

shaderName :String

Custom shader name. This naming can help ShaderMaterial to optimize the length of the index hash string. It is valid only when the material type is t3d.MATERIAL_TYPE.SHADER. Otherwise, if the material is a built-in type, the name of the shader will always be equal to the material type.
Type:
  • String
Default Value
  • ""

shading :t3d.SHADING_TYPE

Define whether the material is rendered with flat shading or smooth shading.
Default Value
  • t3d.SHADING_TYPE.SMOOTH_SHADING

side :t3d.DRAW_SIDE

Defines which side of faces will be rendered - front, back or double.
Default Value
  • t3d.DRAW_SIDE.FRONT

stencilFail :t3d.OPERATION

Which stencil operation to perform when the comparison function returns false. See the t3d.OPERATION constants for all possible values.
Default Value
  • t3d.OPERATION.KEEP

stencilFailBack :t3d.OPERATION|null

Which stencil operation to perform when the comparison function returns false. See the t3d.OPERATION constants for all possible values. You can explicitly specify the two-sided stencil op state by defining stencilFailBack, stencilZFailBack and stencilZPassBack.
Type:
Default Value
  • null

stencilFunc :t3d.COMPARE_FUNC

The stencil comparison function to use. See the t3d.COMPARE_FUNC constants for all possible values.
Default Value
  • t3d.COMPARE_FUNC.ALWAYS

stencilFuncBack :t3d.COMPARE_FUNC|null

The stencil comparison function to use. See the t3d.COMPARE_FUNC constants for all possible values. You can explicitly specify the two-sided stencil function state by defining stencilFuncBack, stencilRefBack and stencilFuncMaskBack.
Type:
Default Value
  • null

stencilFuncMask :Number

The bit mask to use when comparing against the stencil buffer.
Type:
  • Number
Default Value
  • 0xFF

stencilFuncMaskBack :Number|null

The bit mask to use when comparing against the stencil buffer. You can explicitly specify the two-sided stencil function state by defining stencilFuncBack, stencilRefBack and stencilFuncMaskBack.
Type:
  • Number | null
Default Value
  • null

stencilRef :Number

The value to use when performing stencil comparisons or stencil operations.
Type:
  • Number
Default Value
  • 0

stencilRefBack :Number|null

The value to use when performing stencil comparisons or stencil operations. You can explicitly specify the two-sided stencil function state by defining stencilFuncBack, stencilRefBack and stencilFuncMaskBack.
Type:
  • Number | null
Default Value
  • null

stencilTest :Boolean

Whether stencil operations are performed against the stencil buffer. In order to perform writes or comparisons against the stencil buffer this value must be true.
Type:
  • Boolean
Default Value
  • false

stencilWriteMask :Number

The bit mask to use when writing to the stencil buffer.
Type:
  • Number
Default Value
  • 0xFF

stencilZFail :t3d.OPERATION

Which stencil operation to perform when the comparison function returns true but the depth test fails. See the t3d.OPERATION constants for all possible values.
Default Value
  • t3d.OPERATION.KEEP

stencilZFailBack :t3d.OPERATION|null

Which stencil operation to perform when the comparison function returns true but the depth test fails. See the t3d.OPERATION constants for all possible values. You can explicitly specify the two-sided stencil op state by defining stencilFailBack, stencilZFailBack and stencilZPassBack.
Type:
Default Value
  • null

stencilZPass :t3d.OPERATION

Which stencil operation to perform when the comparison function returns true and the depth test passes. See the t3d.OPERATION constants for all possible values.
Default Value
  • t3d.OPERATION.KEEP

stencilZPassBack :t3d.OPERATION|null

Which stencil operation to perform when the comparison function returns true and the depth test passes. See the t3d.OPERATION constants for all possible values. You can explicitly specify the two-sided stencil op state by defining stencilFailBack, stencilZFailBack and stencilZPassBack.
Type:
Default Value
  • null

transparent :Boolean

Defines whether this material is transparent. This has an effect on rendering as transparent objects need special treatment and are rendered after non-transparent objects. When set to true, the extent to which the material is transparent is controlled by setting it's blending property.
Type:
  • Boolean
Default Value
  • false

type :t3d.MATERIAL_TYPE

Type of the material.
Default Value
  • t3d.MATERIAL_TYPE.SHADER

uniforms :Object

Custom uniforms of the shader. Only valid when the material type is t3d.MATERIAL_TYPE.SHADER.
Type:
  • Object
Default Value
  • {}

uuid :String

UUID of this material instance. This gets automatically assigned, so this shouldn't be edited.
Type:
  • String

vertexColors :t3d.VERTEX_COLOR

Defines whether vertex coloring is used.
Default Value
  • t3d.VERTEX_COLOR.NONE

vertexShader :String

Custom GLSL code for vertex shader. Only valid when the material type is t3d.MATERIAL_TYPE.SHADER.
Type:
  • String
Default Value
  • ""

vertexTangents :Boolean

Defines whether precomputed vertex tangents, which must be provided in a vec4 "tangent" attribute, are used. When disabled, tangents are derived automatically. Using precomputed tangents will give more accurate normal map details in some cases, such as with mirrored UVs.
Type:
  • Boolean
Default Value
  • false

Methods

addEventListener(type, listener, thisObjectopt)

Adds a listener to an event type.
Parameters:
NameTypeAttributesDefaultDescription
typeStringThe type of event to listen to.
listenerfunctionThe function that gets called when the event is fired.
thisObjectObject<optional>
thisThe Object of calling listener method.

clone() → {t3d.Material}

Return a new material with the same parameters as this material.
Returns:
Type: 
t3d.Material

copy(source) → {t3d.Material}

Copy the parameters from the passed material into this material.
Parameters:
NameTypeDescription
sourcet3d.MaterialThe material to be copied.
Returns:
Type: 
t3d.Material

dispatchEvent(event)

Fire an event.
Parameters:
NameTypeDescription
eventObjectThe event that gets fired.

dispose()

This disposes the material. Textures of a material don't get disposed. These needs to be disposed by Texture.

removeEventListener(type, listener, thisObjectopt)

Removes a listener from an event type.
Parameters:
NameTypeAttributesDefaultDescription
typeStringThe type of the listener that gets removed.
listenerfunctionThe listener function that gets removed.
thisObjectObject<optional>
thisthisObject - The Object of calling listener method.