Capítulo 66 de 859
Abstract base class for materials.
Materials define the appearance of renderable 3D objects.
Constructor
| Signature |
|---|
new Material() (abstract) |
Properties
| Property | Description |
|---|---|
.allowOverride : boolean | Whether it's possible to override the material with Scene#overrideMaterial or not. |
.alphaHash : boolean | Enables alpha hashed transparency, an alternative to Material#transparent or Material#alphaTest. The material will not be rendered if opacity i… |
.alphaTest : number (readonly) | Sets the alpha value to be used when running an alpha test. The material will not be rendered if the opacity is lower than this value. |
.alphaToCoverage : boolean | Whether alpha to coverage should be enabled or not. Can only be used with MSAA-enabled contexts (meaning when the renderer was created with antialias parameter set to true). Enabling this will sm… |
.blendAlpha : number | Represents the alpha value of the constant blend color. |
.blendColor : Color | Represents the RGB values of the constant blend color. |
| `.blendDst : ZeroFactor | OneFactor |
| `.blendDstAlpha : ZeroFactor | OneFactor |
| `.blendEquation : AddEquation | SubtractEquation |
| `.blendEquationAlpha : AddEquation | SubtractEquation |
| `.blendSrc : ZeroFactor | OneFactor |
| `.blendSrcAlpha : ZeroFactor | OneFactor |
| `.blending : NoBlending | NormalBlending |
.clipIntersection : boolean | Changes the behavior of clipping planes so that only their intersection is clipped, rather than their union. |
.clipShadows : boolean | Defines whether to clip shadows according to the clipping planes specified on this material. |
.clippingPlanes : Array.<Plane> | User-defined clipping planes specified as THREE.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 neg… |
.colorWrite : boolean | Whether to render the material's color. |
| `.depthFunc : NeverDepth | AlwaysDepth |
.depthTest : boolean | Whether to have depth test enabled when rendering this material. When the depth test is disabled, the depth write will also be implicitly disabled. |
.depthWrite : boolean | Whether rendering this material has any effect on the depth buffer. |
.dithering : boolean | Whether to apply dithering to the color to remove the appearance of banding. |
.forceSinglePass : boolean | Whether double-sided, transparent objects should be rendered with a single pass or not. |
.id : number (readonly) | The ID of the material. |
.isMaterial : boolean (readonly) | This flag can be used for type testing. |
.name : string | The name of the material. |
.needsUpdate : boolean | Setting this property to true indicates the engine the material needs to be recompiled. |
.opacity : number | Defines how transparent the material is. A value of 0.0 indicates fully transparent, 1.0 is fully opaque. |
.polygonOffset : boolean | Whether to use polygon offset or not. When enabled, each fragment's depth value will be offset after it is interpolated from the depth values of the appropriate vertices. The offset is added before t… |
.polygonOffsetFactor : number | Specifies a scale factor that is used to create a variable depth offset for each polygon. |
.polygonOffsetUnits : number | Is multiplied by an implementation-specific value to create a constant depth offset. |
| `.precision : 'highp' | 'mediump' |
.premultipliedAlpha : boolean | Whether to premultiply the alpha (transparency) value. |
| `.shadowSide : FrontSide | BackSide |
| `.side : FrontSide | BackSide |
| `.stencilFail : ZeroStencilOp | KeepStencilOp |
| `.stencilFunc : NeverStencilFunc | LessStencilFunc |
.stencilFuncMask : number | The bit mask to use when comparing against the stencil buffer. |
.stencilRef : number | The value to use when performing stencil comparisons or stencil operations. |
.stencilWrite : 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. |
.stencilWriteMask : number | The bit mask to use when writing to the stencil buffer. |
| `.stencilZFail : ZeroStencilOp | KeepStencilOp |
| `.stencilZPass : ZeroStencilOp | KeepStencilOp |
.toneMapped : boolean | Defines whether this material is tone mapped according to the renderer's tone mapping setting. |
.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. |
.type : string (readonly) | The type property is used for detecting the object type in context of serialization/deserialization. |
.userData : Object | An object that can be used to store custom data about the Material. It should not hold references to functions as these will not be cloned. |
.uuid : string (readonly) | The UUID of the material. |
.version : number (readonly) | This starts at 0 and counts how many times Material#needsUpdate is set to true. |
.vertexColors : boolean | If set to true, vertex colors should be used. |
.visible : boolean | Defines whether 3D objects using this material are visible. |
Methods
| Method | Description |
|---|---|
.clone() : Material | Returns a new material with copied values from this instance. |
.copy( source : Material ) : Material | Copies the values of the given material to this instance. |
.customProgramCacheKey() : string | In case Material#onBeforeCompile is used, this callback can be used to identify values of settings used in onBeforeCompile(), so three.js can reuse a cached shader … |
.dispose() | Frees the GPU-related resources allocated by this instance. Call this method whenever this instance is no longer used in your app. |
.fromJSON( json : Object, textures : Object.<string, Texture> ) : Material | Deserializes the material from the given JSON. |
.onBeforeCompile( shaderobject : Object, renderer : WebGLRenderer ) | An optional callback that is executed immediately before the shader program is compiled. This function is called with the shader source code as a parameter. Useful for the modification of built-in ma… |
.onBeforeRender( renderer : WebGLRenderer, scene : Scene, camera : Camera, geometry : BufferGeometry, object : Object3D, group : Object ) | An optional callback that is executed immediately before the material is used to render a 3D object. |
.setValues( values : Object ) | This method can be used to set default values from parameter objects. It is a generic implementation so it can be used with different types of materials. |
| `.toJSON( meta : Object | string ) : Object` |