Sprite2DMaterial
Defined in: packages/three-flatland/src/materials/Sprite2DMaterial.ts:316
TSL-based material for 2D sprites.
UNIFIED API: This material reads from instance attributes, which works for:
- Single sprites (Sprite2D sets attributes on its geometry)
- Batched sprites (SpriteBatch sets instanced attributes)
Core instance attributes (always present):
- instanceUV (vec4): frame UV (x, y, width, height) in atlas
- instanceColor (vec4): tint color and alpha (r, g, b, a)
- instanceFlip (vec2): flip flags (x, y) where 1 = normal, -1 = flipped
Effects are composed via registerEffect(), which packs effect data into
fixed-size vec4 buffers with per-sprite enable flags.
Extends
Section titled “Extends”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Sprite2DMaterial(
options?):Sprite2DMaterial
Defined in: packages/three-flatland/src/materials/Sprite2DMaterial.ts:400
Parameters
Section titled “Parameters”options?
Section titled “options?”Returns
Section titled “Returns”Sprite2DMaterial
Overrides
Section titled “Overrides”Properties
Section titled “Properties”allowOverride
Section titled “allowOverride”allowOverride:
boolean
Defined in: three.js/materials/Material:allowOverride
Whether it’s possible to override the material with Scene#overrideMaterial or not.
Default
Section titled “Default”trueInherited from
Section titled “Inherited from”alphaHash
Section titled “alphaHash”alphaHash:
boolean
Defined in: three.js/materials/Material:alphaHash
Enables alpha hashed transparency, an alternative to Material#transparent or Material#alphaTest. The material will not be rendered if opacity is lower than a random threshold. Randomization introduces some grain or noise, but approximates alpha blending without the associated problems of sorting. Using TAA can reduce the resulting noise.
Default
Section titled “Default”falseInherited from
Section titled “Inherited from”alphaMap
Section titled “alphaMap”alphaMap:
Texture<unknown,TextureEventMap> |null
Defined in: three.js/materials/MeshBasicMaterial:alphaMap
The alpha map is a grayscale texture that controls the opacity across the surface (black: fully transparent; white: fully opaque).
Only the color of the texture is used, ignoring the alpha channel if one exists. For RGB and RGBA textures, the renderer will use the green channel when sampling this texture due to the extra bit of precision provided for green in DXT-compressed and uncompressed RGB 565 formats. Luminance-only and luminance/alpha textures will also still work as expected.
alphaMap represents non-color data. Any texture assigned must have
texture.colorSpace = NoColorSpace (default).
Default
Section titled “Default”nullInherited from
Section titled “Inherited from”alphaTestNode
Section titled “alphaTestNode”alphaTestNode:
Node|null
Defined in: three.js/materials/nodes/NodeMaterial:alphaTestNode
The alpha test of node materials is by default inferred from the alphaTest
property. This node property allows to overwrite the default and define the
alpha test with a node instead.
If you don’t want to overwrite the alpha test but modify the existing value instead, use materialAlphaTest.
Default
Section titled “Default”nullInherited from
Section titled “Inherited from”alphaToCoverage
Section titled “alphaToCoverage”alphaToCoverage:
boolean
Defined in: three.js/materials/Material:alphaToCoverage
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 smooth aliasing on clip plane edges and alphaTest-clipped edges.
Default
Section titled “Default”falseInherited from
Section titled “Inherited from”EffectMaterial.alphaToCoverage
aoMap:
Texture<unknown,TextureEventMap> |null
Defined in: three.js/materials/MeshBasicMaterial:aoMap
The red channel of this texture is used as the ambient occlusion map. Requires a second set of UVs.
aoMap represents non-color data. Any texture assigned must have
texture.colorSpace = NoColorSpace (default).
Default
Section titled “Default”nullInherited from
Section titled “Inherited from”aoMapIntensity
Section titled “aoMapIntensity”aoMapIntensity:
number
Defined in: three.js/materials/MeshBasicMaterial:aoMapIntensity
Intensity of the ambient occlusion effect. Range is [0,1], where 0
disables ambient occlusion. Where intensity is 1 and the AO map’s
red channel is also 1, ambient light is fully occluded on a surface.
Default
Section titled “Default”1Inherited from
Section titled “Inherited from”aoNode
Section titled “aoNode”aoNode:
Node|null
Defined in: three.js/materials/nodes/NodeMaterial:aoNode
The lighting of node materials might be influenced by ambient occlusion.
The default AO is inferred from an ambient occlusion map assigned to aoMap
and the respective aoMapIntensity. This node property allows to overwrite
the default and define the ambient occlusion with a custom node instead.
If you don’t want to overwrite the diffuse color but modify the existing values instead, use materialAO.
Default
Section titled “Default”nullInherited from
Section titled “Inherited from”backdropAlphaNode
Section titled “backdropAlphaNode”backdropAlphaNode:
Node|null
Defined in: three.js/materials/nodes/NodeMaterial:backdropAlphaNode
This node allows to modulate the influence of backdropNode to the outgoing light.
Default
Section titled “Default”nullInherited from
Section titled “Inherited from”EffectMaterial.backdropAlphaNode
backdropNode
Section titled “backdropNode”backdropNode:
Node|null
Defined in: three.js/materials/nodes/NodeMaterial:backdropNode
This node can be used to implement a variety of filter-like effects. The idea is
to store the current rendering into a texture e.g. via viewportSharedTexture(), use it
to create an arbitrary effect and then assign the node composition to this property.
Everything behind the object using this material will now be affected by a filter.
const material = new NodeMaterial()material.transparent = true;
// everything behind the object will be monochromaticmaterial.backdropNode = saturation( viewportSharedTexture().rgb, 0 );Backdrop computations are part of the lighting so only lit materials can use this property.
Default
Section titled “Default”nullInherited from
Section titled “Inherited from”batchId
Section titled “batchId”
readonlybatchId:number
Defined in: packages/three-flatland/src/materials/Sprite2DMaterial.ts:365
Unique batch ID for this material instance (used for batching).
blendAlpha
Section titled “blendAlpha”blendAlpha:
number
Defined in: three.js/materials/Material:blendAlpha
Represents the alpha value of the constant blend color.
This property has only an effect when using custom blending with ConstantAlpha or OneMinusConstantAlpha.
Default
Section titled “Default”0Inherited from
Section titled “Inherited from”blendColor
Section titled “blendColor”blendColor:
Color
Defined in: three.js/materials/Material:blendColor
Represents the RGB values of the constant blend color.
This property has only an effect when using custom blending with ConstantColor or OneMinusConstantColor.
Default
Section titled “Default”(0,0,0)Inherited from
Section titled “Inherited from”blendDst
Section titled “blendDst”blendDst:
BlendingDstFactor
Defined in: three.js/materials/Material:blendDst
Defines the blending destination factor.
Default
Section titled “Default”OneMinusSrcAlphaFactorInherited from
Section titled “Inherited from”blendDstAlpha
Section titled “blendDstAlpha”blendDstAlpha:
BlendingDstFactor|null
Defined in: three.js/materials/Material:blendDstAlpha
Defines the blending destination alpha factor.
Default
Section titled “Default”nullInherited from
Section titled “Inherited from”blendEquation
Section titled “blendEquation”blendEquation:
BlendingEquation
Defined in: three.js/materials/Material:blendEquation
Defines the blending equation.
Default
Section titled “Default”AddEquationInherited from
Section titled “Inherited from”blendEquationAlpha
Section titled “blendEquationAlpha”blendEquationAlpha:
BlendingEquation|null
Defined in: three.js/materials/Material:blendEquationAlpha
Defines the blending equation of the alpha channel.
Default
Section titled “Default”nullInherited from
Section titled “Inherited from”EffectMaterial.blendEquationAlpha
blending
Section titled “blending”blending:
Blending
Defined in: three.js/materials/Material:blending
Defines the blending type of the material.
It must be set to CustomBlending if custom blending properties like
Material#blendSrc, Material#blendDst or Material#blendEquation
should have any effect.
Default
Section titled “Default”NormalBlendingInherited from
Section titled “Inherited from”blendSrc
Section titled “blendSrc”blendSrc:
BlendingSrcFactor
Defined in: three.js/materials/Material:blendSrc
Defines the blending source factor.
Default
Section titled “Default”SrcAlphaFactorInherited from
Section titled “Inherited from”blendSrcAlpha
Section titled “blendSrcAlpha”blendSrcAlpha:
BlendingSrcFactor|null
Defined in: three.js/materials/Material:blendSrcAlpha
Defines the blending source alpha factor.
Default
Section titled “Default”nullInherited from
Section titled “Inherited from”castShadowNode
Section titled “castShadowNode”castShadowNode:
Node|null
Defined in: three.js/materials/nodes/NodeMaterial:castShadowNode
This node can be used to influence how an object using this node material casts shadows. To apply a color to shadows, you can simply do:
material.castShadowNode = vec4( 1, 0, 0, 1 );Which can be nice to fake colored shadows of semi-transparent objects. It
is also common to use the property with Fn function so checks are performed
per fragment.
materialCustomShadow.castShadowNode = Fn( () => { hash( vertexIndex ).greaterThan( 0.5 ).discard(); return materialColor;} )();Default
Section titled “Default”nullInherited from
Section titled “Inherited from”castShadowPositionNode
Section titled “castShadowPositionNode”castShadowPositionNode:
Node|null
Defined in: three.js/materials/nodes/NodeMaterial:castShadowPositionNode
Allows to overwrite the geometry position used for shadow map projection which is by default positionLocal, the vertex position in local space.
Default
Section titled “Default”nullInherited from
Section titled “Inherited from”EffectMaterial.castShadowPositionNode
clipIntersection
Section titled “clipIntersection”clipIntersection:
boolean
Defined in: three.js/materials/Material:clipIntersection
Changes the behavior of clipping planes so that only their intersection is clipped, rather than their union.
Default
Section titled “Default”falseInherited from
Section titled “Inherited from”EffectMaterial.clipIntersection
clippingPlanes
Section titled “clippingPlanes”clippingPlanes:
Plane[] |null
Defined in: three.js/materials/Material:clippingPlanes
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 negative are clipped
(not rendered). This requires WebGLRenderer#localClippingEnabled to
be true.
Default
Section titled “Default”nullInherited from
Section titled “Inherited from”clipShadows
Section titled “clipShadows”clipShadows:
boolean
Defined in: three.js/materials/Material:clipShadows
Defines whether to clip shadows according to the clipping planes specified on this material.
Default
Section titled “Default”falseInherited from
Section titled “Inherited from”color:
Color
Defined in: three.js/materials/MeshBasicMaterial:color
Color of the material.
Default
Section titled “Default”(1,1,1)Inherited from
Section titled “Inherited from”colorNode
Section titled “colorNode”colorNode:
Node<"vec3"> |Node<"float"> |Node<"vec4"> |Node<"vec2"> |Node<"color"> |null
Defined in: three.js/materials/nodes/NodeMaterial:colorNode
The diffuse color of node materials is by default inferred from the
color and map properties. This node property allows to overwrite the default
and define the diffuse color with a node instead.
material.colorNode = color( 0xff0000 ); // define red colorIf you don’t want to overwrite the diffuse color but modify the existing values instead, use materialColor.
material.colorNode = materialColor.mul( color( 0xff0000 ) ); // give diffuse colors a red tintDefault
Section titled “Default”nullInherited from
Section titled “Inherited from”colorWrite
Section titled “colorWrite”colorWrite:
boolean
Defined in: three.js/materials/Material:colorWrite
Whether to render the material’s color.
This can be used in conjunction with Object3D#renderOder to create invisible objects that occlude other objects.
Default
Section titled “Default”trueInherited from
Section titled “Inherited from”combine
Section titled “combine”combine:
Combine
Defined in: three.js/materials/MeshBasicMaterial:combine
How to combine the result of the surface’s color with the environment map, if any.
When set to MixOperation, the MeshBasicMaterial#reflectivity is used to
blend between the two colors.
Default
Section titled “Default”MultiplyOperationInherited from
Section titled “Inherited from”contextNode
Section titled “contextNode”contextNode:
ContextNode<unknown> |null
Defined in: three.js/materials/nodes/NodeMaterial:contextNode
This node can be used as a global context management component for this material.
Default
Section titled “Default”nullInherited from
Section titled “Inherited from”defines?
Section titled “defines?”
optionaldefines?:Record<string,unknown>
Defined in: three.js/materials/Material:defines
Inherited from
Section titled “Inherited from”depthFunc
Section titled “depthFunc”depthFunc:
DepthModes
Defined in: three.js/materials/Material:depthFunc
Defines the depth function.
Default
Section titled “Default”LessEqualDepthInherited from
Section titled “Inherited from”depthNode
Section titled “depthNode”depthNode:
Node|null
Defined in: three.js/materials/nodes/NodeMaterial:depthNode
Allows to overwrite depth values in the fragment shader.
Default
Section titled “Default”nullInherited from
Section titled “Inherited from”depthTest
Section titled “depthTest”depthTest:
boolean
Defined in: three.js/materials/Material:depthTest
Whether to have depth test enabled when rendering this material. When the depth test is disabled, the depth write will also be implicitly disabled.
Default
Section titled “Default”trueInherited from
Section titled “Inherited from”depthWrite
Section titled “depthWrite”depthWrite:
boolean
Defined in: three.js/materials/Material:depthWrite
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.
Default
Section titled “Default”trueInherited from
Section titled “Inherited from”dithering
Section titled “dithering”dithering:
boolean
Defined in: three.js/materials/Material:dithering
Whether to apply dithering to the color to remove the appearance of banding.
Default
Section titled “Default”falseInherited from
Section titled “Inherited from”envMap
Section titled “envMap”envMap:
Texture<unknown,TextureEventMap> |null
Defined in: three.js/materials/MeshBasicMaterial:envMap
The environment map.
envMap represents luminance data, and the texture must be assigned
a Texture#colorSpace . Most envMap textures set
texture.colorSpace = LinearSRGBColorSpace and use float-type formats
such as .exr or .hdr.
Default
Section titled “Default”nullInherited from
Section titled “Inherited from”envMapRotation
Section titled “envMapRotation”envMapRotation:
Euler
Defined in: three.js/materials/MeshBasicMaterial:envMapRotation
The rotation of the environment map in radians.
Default
Section titled “Default”(0,0,0)Inherited from
Section titled “Inherited from”envNode
Section titled “envNode”envNode:
Node|null
Defined in: three.js/materials/nodes/NodeMaterial:envNode
The environment of node materials can be defined by an environment
map assigned to the envMap property or by Scene.environment
if the node material is a PBR material. This node property allows to overwrite
the default behavior and define the environment with a custom node.
material.envNode = pmremTexture( renderTarget.texture );Default
Section titled “Default”nullInherited from
Section titled “Inherited from”fog:
boolean
Defined in: three.js/materials/nodes/NodeMaterial:fog
Whether this material is affected by fog or not.
Default
Section titled “Default”trueInherited from
Section titled “Inherited from”forceSinglePass
Section titled “forceSinglePass”forceSinglePass:
boolean
Defined in: three.js/materials/Material:forceSinglePass
Whether double-sided, transparent objects should be rendered with a single pass or not.
The engine renders double-sided, transparent objects with two draw calls (back faces first,
then front faces) to mitigate transparency artifacts. There are scenarios however where this
approach produces no quality gains but still doubles draw calls e.g. when rendering flat
vegetation like grass sprites. In these cases, set the forceSinglePass flag to true to
disable the two pass rendering to avoid performance issues.
Default
Section titled “Default”falseInherited from
Section titled “Inherited from”EffectMaterial.forceSinglePass
fragmentNode
Section titled “fragmentNode”fragmentNode:
Node|null
Defined in: three.js/materials/nodes/NodeMaterial:fragmentNode
This node property can be used if you need complete freedom in implementing the fragment shader. Assigning a node will replace the built-in material logic used in the fragment stage.
Default
Section titled “Default”nullInherited from
Section titled “Inherited from”geometryNode
Section titled “geometryNode”geometryNode:
Node|null
Defined in: three.js/materials/nodes/NodeMaterial:geometryNode
This node property is intended for logic which modifies geometry data once or per animation step.
Apps usually place such logic randomly in initialization routines or in the animation loop.
geometryNode is intended as a dedicated API so there is an intended spot where geometry modifications
can be implemented.
The idea is to assign a Fn definition that holds the geometry modification logic. A typical example
would be a GPU based particle system that provides a node material for usage on app level. The particle
simulation would be implemented as compute shaders and managed inside a Fn function. This function is
eventually assigned to geometryNode.
Default
Section titled “Default”nullInherited from
Section titled “Inherited from”isMaterial
Section titled “isMaterial”
readonlyisMaterial:boolean
Defined in: three.js/materials/Material:isMaterial
This flag can be used for type testing.
Default
Section titled “Default”trueInherited from
Section titled “Inherited from”isMeshBasicNodeMaterial
Section titled “isMeshBasicNodeMaterial”
readonlyisMeshBasicNodeMaterial:boolean
Defined in: three.js/materials/nodes/MeshBasicNodeMaterial:isMeshBasicNodeMaterial
This flag can be used for type testing.
Default
Section titled “Default”trueInherited from
Section titled “Inherited from”EffectMaterial.isMeshBasicNodeMaterial
isNodeMaterial
Section titled “isNodeMaterial”
readonlyisNodeMaterial:boolean
Defined in: three.js/materials/nodes/NodeMaterial:isNodeMaterial
This flag can be used for type testing.
Default
Section titled “Default”trueInherited from
Section titled “Inherited from”lightMap
Section titled “lightMap”lightMap:
Texture<unknown,TextureEventMap> |null
Defined in: three.js/materials/MeshBasicMaterial:lightMap
The light map. Requires a second set of UVs.
lightMap represents pre-baked illuminance data, and the texture must be assigned
a Texture#colorSpace . Most lightMap textures set
texture.colorSpace = LinearSRGBColorSpace and use float-type formats
such as .exr or .hdr.
Default
Section titled “Default”nullInherited from
Section titled “Inherited from”lightMapIntensity
Section titled “lightMapIntensity”lightMapIntensity:
number
Defined in: three.js/materials/MeshBasicMaterial:lightMapIntensity
Intensity of the baked light.
Default
Section titled “Default”1Inherited from
Section titled “Inherited from”EffectMaterial.lightMapIntensity
lights
Section titled “lights”lights:
boolean
Defined in: three.js/materials/nodes/NodeMaterial:lights
Whether this material is affected by lights or not.
Default
Section titled “Default”falseInherited from
Section titled “Inherited from”lightsNode
Section titled “lightsNode”lightsNode:
LightsNode|null
Defined in: three.js/materials/nodes/NodeMaterial:lightsNode
Node materials which set their lights property to true
are affected by all lights of the scene. Sometimes selective
lighting is wanted which means only some lights in the scene
affect a material. This can be achieved by creating an instance
of LightsNode with a list of selective
lights and assign the node to this property.
const customLightsNode = lights( [ light1, light2 ] );material.lightsNode = customLightsNode;Default
Section titled “Default”nullInherited from
Section titled “Inherited from”map:
Texture<unknown,TextureEventMap> |null
Defined in: three.js/materials/MeshBasicMaterial:map
The color map. May optionally include an alpha channel, typically combined
with Material#transparent or Material#alphaTest. The texture map
color is modulated by the diffuse color.
map represents color data, and the texture must be assigned a
Texture#colorSpace . Most map textures set
texture.colorSpace = SRGBColorSpace.
Default
Section titled “Default”nullInherited from
Section titled “Inherited from”maskNode
Section titled “maskNode”maskNode:
Node|null
Defined in: three.js/materials/nodes/NodeMaterial:maskNode
Discards the fragment if the mask value is false.
Default
Section titled “Default”nullInherited from
Section titled “Inherited from”maskShadowNode
Section titled “maskShadowNode”maskShadowNode:
Node|null
Defined in: three.js/materials/nodes/NodeMaterial:maskShadowNode
This node can be used to implement a shadow mask for the material.
Default
Section titled “Default”nullInherited from
Section titled “Inherited from”mrtNode
Section titled “mrtNode”mrtNode:
MRTNode|null
Defined in: three.js/materials/nodes/NodeMaterial:mrtNode
MRT configuration is done on renderer or pass level. This node allows to overwrite what values are written into MRT targets on material level. This can be useful for implementing selective FX features that should only affect specific objects.
Default
Section titled “Default”nullInherited from
Section titled “Inherited from”name:
string
Defined in: three.js/materials/Material:name
The name of the material.
Inherited from
Section titled “Inherited from”normalNode
Section titled “normalNode”normalNode:
Node|null
Defined in: three.js/materials/nodes/NodeMaterial:normalNode
The normals of node materials are by default inferred from the normalMap/normalScale
or bumpMap/bumpScale properties. This node property allows to overwrite the default
and define the normals with a node instead.
If you don’t want to overwrite the normals but modify the existing values instead, use materialNormal.
Default
Section titled “Default”nullInherited from
Section titled “Inherited from”opacity
Section titled “opacity”opacity:
number
Defined in: three.js/materials/Material:opacity
Defines how transparent the material is.
A value of 0.0 indicates fully transparent, 1.0 is fully opaque.
If the Material#transparent is not set to true,
the material will remain fully opaque and this value will only affect its color.
Default
Section titled “Default”1Inherited from
Section titled “Inherited from”opacityNode
Section titled “opacityNode”opacityNode:
Node|null
Defined in: three.js/materials/nodes/NodeMaterial:opacityNode
The opacity of node materials is by default inferred from the opacity
and alphaMap properties. This node property allows to overwrite the default
and define the opacity with a node instead.
If you don’t want to overwrite the opacity but modify the existing value instead, use materialOpacity.
Default
Section titled “Default”nullInherited from
Section titled “Inherited from”outputNode
Section titled “outputNode”outputNode:
Node|null
Defined in: three.js/materials/nodes/NodeMaterial:outputNode
This node can be used to define the final output of the material.
TODO: Explain the differences to fragmentNode.
Default
Section titled “Default”nullInherited from
Section titled “Inherited from”polygonOffset
Section titled “polygonOffset”polygonOffset:
boolean
Defined in: three.js/materials/Material:polygonOffset
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 the depth test is performed and before the value is written into the depth buffer.
Can be useful for rendering hidden-line images, for applying decals to surfaces, and for rendering solids with highlighted edges.
Default
Section titled “Default”falseInherited from
Section titled “Inherited from”polygonOffsetFactor
Section titled “polygonOffsetFactor”polygonOffsetFactor:
number
Defined in: three.js/materials/Material:polygonOffsetFactor
Specifies a scale factor that is used to create a variable depth offset for each polygon.
Default
Section titled “Default”0Inherited from
Section titled “Inherited from”EffectMaterial.polygonOffsetFactor
polygonOffsetUnits
Section titled “polygonOffsetUnits”polygonOffsetUnits:
number
Defined in: three.js/materials/Material:polygonOffsetUnits
Is multiplied by an implementation-specific value to create a constant depth offset.
Default
Section titled “Default”0Inherited from
Section titled “Inherited from”EffectMaterial.polygonOffsetUnits
positionNode
Section titled “positionNode”positionNode:
Node|null
Defined in: three.js/materials/nodes/NodeMaterial:positionNode
The local vertex positions are computed based on multiple factors like the attribute data, morphing or skinning. This node property allows to overwrite the default and define local vertex positions with nodes instead.
If you don’t want to overwrite the vertex positions but modify the existing values instead, use positionLocal.
material.positionNode = positionLocal.add( displace );Default
Section titled “Default”nullInherited from
Section titled “Inherited from”precision
Section titled “precision”precision:
"highp"|"mediump"|"lowp"|null
Defined in: three.js/materials/Material:precision
Override the renderer’s default precision for this material.
Default
Section titled “Default”nullInherited from
Section titled “Inherited from”premultipliedAlpha
Section titled “premultipliedAlpha”premultipliedAlpha:
boolean
Defined in: three.js/materials/Material:premultipliedAlpha
Whether to premultiply the alpha (transparency) value.
Default
Section titled “Default”falseInherited from
Section titled “Inherited from”EffectMaterial.premultipliedAlpha
receivedShadowNode
Section titled “receivedShadowNode”receivedShadowNode: (() =>
Node) |null
Defined in: three.js/materials/nodes/NodeMaterial:receivedShadowNode
This node can be used to influence how an object using this node material receive shadows.
const totalShadows = float( 1 ).toVar();material.receivedShadowNode = Fn( ( [ shadow ] ) => { totalShadows.mulAssign( shadow ); //return float( 1 ); // bypass received shadows return shadow.mix( color( 0xff0000 ), 1 ); // modify shadow color} );
@default null
#### Inherited from
[`EffectMaterial`](/three-flatland/api/three-flatland/src/classes/effectmaterial/).[`receivedShadowNode`](/three-flatland/api/three-flatland/src/classes/effectmaterial/#receivedshadownode)
***
### receivedShadowPositionNode
> **receivedShadowPositionNode**: [`Node`](https://threejs.org/docs/) \| `null`
Defined in: [three.js/materials/nodes/NodeMaterial:receivedShadowPositionNode](https://threejs.org/docs/#api/en/materials/nodes/NodeMaterial.receivedShadowPositionNode)
Allows to overwrite the position used for shadow map rendering whichis by default positionWorld, the vertex positionin world space.
#### Default
```tsnullInherited from
Section titled “Inherited from”EffectMaterial.receivedShadowPositionNode
reflectivity
Section titled “reflectivity”reflectivity:
number
Defined in: three.js/materials/MeshBasicMaterial:reflectivity
How much the environment map affects the surface.
The valid range is between 0 (no reflections) and 1 (full reflections).
Default
Section titled “Default”1Inherited from
Section titled “Inherited from”refractionRatio
Section titled “refractionRatio”refractionRatio:
number
Defined in: three.js/materials/MeshBasicMaterial:refractionRatio
The index of refraction (IOR) of air (approximately 1) divided by the
index of refraction of the material. It is used with environment mapping
modes CubeRefractionMapping and EquirectangularRefractionMapping.
The refraction ratio should not exceed 1.
Default
Section titled “Default”0.98Inherited from
Section titled “Inherited from”EffectMaterial.refractionRatio
shadowSide
Section titled “shadowSide”shadowSide:
Side|null
Defined in: three.js/materials/Material:shadowSide
Defines which side of faces cast shadows. If null, the side casting shadows
is determined as follows:
- When Material#side is set to
FrontSide, the back side cast shadows. - When Material#side is set to
BackSide, the front side cast shadows. - When Material#side is set to
DoubleSide, both sides cast shadows.
Default
Section titled “Default”nullInherited from
Section titled “Inherited from”side:
Side
Defined in: three.js/materials/Material:side
Defines which side of faces will be rendered - front, back or both.
Default
Section titled “Default”FrontSideInherited from
Section titled “Inherited from”specularMap
Section titled “specularMap”specularMap:
Texture<unknown,TextureEventMap> |null
Defined in: three.js/materials/MeshBasicMaterial:specularMap
Specular map used by the material.
specularMap represents color data, and the texture must be assigned a
Texture#colorSpace . Most specularMap textures set
texture.colorSpace = SRGBColorSpace.
Default
Section titled “Default”nullInherited from
Section titled “Inherited from”stencilFail
Section titled “stencilFail”stencilFail:
StencilOp
Defined in: three.js/materials/Material:stencilFail
Which stencil operation to perform when the comparison function returns false.
Default
Section titled “Default”KeepStencilOpInherited from
Section titled “Inherited from”stencilFunc
Section titled “stencilFunc”stencilFunc:
StencilFunc
Defined in: three.js/materials/Material:stencilFunc
The stencil comparison function to use.
Default
Section titled “Default”AlwaysStencilFuncInherited from
Section titled “Inherited from”stencilFuncMask
Section titled “stencilFuncMask”stencilFuncMask:
number
Defined in: three.js/materials/Material:stencilFuncMask
The bit mask to use when comparing against the stencil buffer.
Default
Section titled “Default”0xffInherited from
Section titled “Inherited from”EffectMaterial.stencilFuncMask
stencilRef
Section titled “stencilRef”stencilRef:
number
Defined in: three.js/materials/Material:stencilRef
The value to use when performing stencil comparisons or stencil operations.
Default
Section titled “Default”0Inherited from
Section titled “Inherited from”stencilWrite
Section titled “stencilWrite”stencilWrite:
boolean
Defined in: three.js/materials/Material:stencilWrite
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.
Default
Section titled “Default”falseInherited from
Section titled “Inherited from”stencilWriteMask
Section titled “stencilWriteMask”stencilWriteMask:
number
Defined in: three.js/materials/Material:stencilWriteMask
The bit mask to use when writing to the stencil buffer.
Default
Section titled “Default”0xffInherited from
Section titled “Inherited from”EffectMaterial.stencilWriteMask
stencilZFail
Section titled “stencilZFail”stencilZFail:
StencilOp
Defined in: three.js/materials/Material:stencilZFail
Which stencil operation to perform when the comparison function returns
true but the depth test fails.
Default
Section titled “Default”KeepStencilOpInherited from
Section titled “Inherited from”stencilZPass
Section titled “stencilZPass”stencilZPass:
StencilOp
Defined in: three.js/materials/Material:stencilZPass
Which stencil operation to perform when the comparison function returns
true and the depth test passes.
Default
Section titled “Default”KeepStencilOpInherited from
Section titled “Inherited from”toneMapped
Section titled “toneMapped”toneMapped:
boolean
Defined in: three.js/materials/Material:toneMapped
Defines whether this material is tone mapped according to the renderer’s tone mapping setting.
It is ignored when rendering to a render target or using post processing or when using
WebGPURenderer. In all these cases, all materials are honored by tone mapping.
Default
Section titled “Default”trueInherited from
Section titled “Inherited from”transparent
Section titled “transparent”transparent:
boolean
Defined in: three.js/materials/Material:transparent
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 Material#opacity.
Default
Section titled “Default”falseInherited from
Section titled “Inherited from”type:
string='Sprite2DMaterial'
Defined in: packages/three-flatland/src/materials/Sprite2DMaterial.ts:337
Canonical three.js class identifier — every built-in material
overrides this (MeshBasicMaterial’s type is 'MeshBasicMaterial',
etc.). Devtools / inspectors that walk the scene graph read .type
to categorise materials without instanceof checks. Subclasses
(e.g. future TileMapMaterial) should override again.
Overrides
Section titled “Overrides”userData
Section titled “userData”userData:
Record<string,any>
Defined in: three.js/materials/Material:userData
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.
Inherited from
Section titled “Inherited from”
readonlyuuid:string
Defined in: three.js/materials/Material:uuid
The UUID of the material.
Inherited from
Section titled “Inherited from”version
Section titled “version”
readonlyversion:number
Defined in: three.js/materials/Material:version
This starts at 0 and counts how many times Material#needsUpdate is set to true.
Default
Section titled “Default”0Inherited from
Section titled “Inherited from”vertexColors
Section titled “vertexColors”vertexColors:
boolean
Defined in: three.js/materials/Material:vertexColors
If set to true, vertex colors should be used.
The engine supports RGB and RGBA vertex colors depending on whether a three (RGB) or four (RGBA) component color buffer attribute is used.
Default
Section titled “Default”falseInherited from
Section titled “Inherited from”vertexNode
Section titled “vertexNode”vertexNode:
Node|null
Defined in: three.js/materials/nodes/NodeMaterial:vertexNode
This node property can be used if you need complete freedom in implementing the vertex shader. Assigning a node will replace the built-in material logic used in the vertex stage.
Default
Section titled “Default”nullInherited from
Section titled “Inherited from”visible
Section titled “visible”visible:
boolean
Defined in: three.js/materials/Material:visible
Defines whether 3D objects using this material are visible.
Default
Section titled “Default”trueInherited from
Section titled “Inherited from”wireframe
Section titled “wireframe”wireframe:
boolean
Defined in: three.js/materials/MeshBasicMaterial:wireframe
Renders the geometry as a wireframe.
Default
Section titled “Default”falseInherited from
Section titled “Inherited from”wireframeLinecap
Section titled “wireframeLinecap”wireframeLinecap:
"round"|"bevel"|"miter"
Defined in: three.js/materials/MeshBasicMaterial:wireframeLinecap
Defines appearance of wireframe ends.
Can only be used with SVGRenderer.
Default
Section titled “Default”'round'Inherited from
Section titled “Inherited from”EffectMaterial.wireframeLinecap
wireframeLinejoin
Section titled “wireframeLinejoin”wireframeLinejoin:
"round"|"bevel"|"miter"
Defined in: three.js/materials/MeshBasicMaterial:wireframeLinejoin
Defines appearance of wireframe joints.
Can only be used with SVGRenderer.
Default
Section titled “Default”'round'Inherited from
Section titled “Inherited from”EffectMaterial.wireframeLinejoin
wireframeLinewidth
Section titled “wireframeLinewidth”wireframeLinewidth:
number
Defined in: three.js/materials/MeshBasicMaterial:wireframeLinewidth
Controls the thickness of the wireframe.
Can only be used with SVGRenderer.
Default
Section titled “Default”1Inherited from
Section titled “Inherited from”EffectMaterial.wireframeLinewidth
MAX_EFFECT_FLOATS
Section titled “MAX_EFFECT_FLOATS”
readonlystaticMAX_EFFECT_FLOATS:24=24
Defined in: packages/three-flatland/src/materials/EffectMaterial.ts:154
Maximum total effect-data floats allowed across all registered
effects on this material. WebGPU allows 8 vertex-buffer bindings
per pipeline; SpriteBatch uses 2 fixed bindings (instanceMatrix +
interleaved core — the synth-quad geometry’s position/uv
attributes exist for user TSL but cost a binding only when a
material’s nodes actually read them), leaving 6 for
effectBuf0..5 × 4 floats = 24 floats. Exceeding this would force
a 7th effectBuf binding which WebGPU rejects at pipeline creation
with a cryptic “vertex buffer count exceeds maximum” error.
registerEffect throws clearly when the cap would be exceeded.
A material whose custom TSL nodes call uv()/positionGeometry()
consumes one or two additional vertex-buffer bindings beyond the 2
above, reducing headroom below 24 floats for that material.
Inherited from
Section titled “Inherited from”EffectMaterial.MAX_EFFECT_FLOATS
Accessors
Section titled “Accessors”alphaTest
Section titled “alphaTest”Get Signature
Section titled “Get Signature”get alphaTest():
number
Defined in: three.js/materials/Material:alphaTest
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.
Default
Section titled “Default”0Returns
Section titled “Returns”number
Set Signature
Section titled “Set Signature”set alphaTest(
value):void
Defined in: three.js/materials/Material:alphaTest
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”colorTransform
Section titled “colorTransform”Get Signature
Section titled “Get Signature”get colorTransform():
ColorTransformFn|null
Defined in: packages/three-flatland/src/materials/EffectMaterial.ts:251
Get the color transform function.
Returns
Section titled “Returns”ColorTransformFn | null
Set Signature
Section titled “Set Signature”set colorTransform(
value):void
Defined in: packages/three-flatland/src/materials/EffectMaterial.ts:259
Set the color transform function. Triggers shader rebuild.
Parameters
Section titled “Parameters”ColorTransformFn | null
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”globalUniforms
Section titled “globalUniforms”Get Signature
Section titled “Get Signature”get globalUniforms():
GlobalUniforms|null
Defined in: packages/three-flatland/src/materials/Sprite2DMaterial.ts:553
Get the global uniforms reference.
Returns
Section titled “Returns”GlobalUniforms | null
Set Signature
Section titled “Set Signature”set globalUniforms(
value):void
Defined in: packages/three-flatland/src/materials/Sprite2DMaterial.ts:561
Set the global uniforms reference. Triggers shader rebuild to include global tint.
Parameters
Section titled “Parameters”GlobalUniforms | null
Returns
Section titled “Returns”void
needsUpdate
Section titled “needsUpdate”Set Signature
Section titled “Set Signature”set needsUpdate(
value):void
Defined in: three.js/materials/Material:needsUpdate
Setting this property to true indicates the engine the material
needs to be recompiled.
Default
Section titled “Default”falseParameters
Section titled “Parameters”boolean
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”requiredChannels
Section titled “requiredChannels”Get Signature
Section titled “Get Signature”get requiredChannels():
ReadonlySet<string>
Defined in: packages/three-flatland/src/materials/EffectMaterial.ts:271
Get the required channels set.
Returns
Section titled “Returns”ReadonlySet<string>
Set Signature
Section titled “Set Signature”set requiredChannels(
value):void
Defined in: packages/three-flatland/src/materials/EffectMaterial.ts:279
Set the required channels. Triggers shader rebuild when channels change.
Parameters
Section titled “Parameters”ReadonlySet<string>
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”EffectMaterial.requiredChannels
Get Signature
Section titled “Get Signature”get
statictype():string
Defined in: three.js/materials/nodes/NodeMaterial:type
Returns
Section titled “Returns”string
Inherited from
Section titled “Inherited from”Methods
Section titled “Methods”addEventListener()
Section titled “addEventListener()”addEventListener<
T>(type,listener):void
Defined in: three.js/core/EventDispatcher:addEventListener
Adds a listener to an event type.
Type Parameters
Section titled “Type Parameters”T extends "dispose"
Parameters
Section titled “Parameters”T
The type of event to listen to.
listener
Section titled “listener”EventListener <MaterialEventMap [T], T, Sprite2DMaterial>
The function that gets called when the event is fired.
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”EffectMaterial.addEventListener
build()
Section titled “build()”build(
builder):void
Defined in: three.js/materials/nodes/NodeMaterial:build
Builds this material with the given node builder.
Parameters
Section titled “Parameters”builder
Section titled “builder”The current node builder.
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”clone()
Section titled “clone()”clone():
this
Defined in: packages/three-flatland/src/materials/Sprite2DMaterial.ts:823
Clone this material.
Returns
Section titled “Returns”this
Overrides
Section titled “Overrides”copy()
Section titled “copy()”copy(
source):this
Defined in: three.js/materials/nodes/NodeMaterial:copy
Copies the common properties of the given material to this instance.
Parameters
Section titled “Parameters”source
Section titled “source”The material to copy.
Returns
Section titled “Returns”this
A reference to this node material.
Inherited from
Section titled “Inherited from”customProgramCacheKey()
Section titled “customProgramCacheKey()”customProgramCacheKey():
string
Defined in: three.js/materials/Material:customProgramCacheKey
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 or recompile the shader for this material as needed.
This method can only be used when rendering with WebGLRenderer .
Returns
Section titled “Returns”string
The custom program cache key.
Inherited from
Section titled “Inherited from”EffectMaterial.customProgramCacheKey
dispatchEvent()
Section titled “dispatchEvent()”dispatchEvent<
T>(event):void
Defined in: three.js/core/EventDispatcher:dispatchEvent
Fire an event type.
Type Parameters
Section titled “Type Parameters”T extends "dispose"
Parameters
Section titled “Parameters”BaseEvent <T> & MaterialEventMap [T]
The event that gets fired.
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”dispose()
Section titled “dispose()”dispose():
void
Defined in: packages/three-flatland/src/materials/Sprite2DMaterial.ts:845
Frees the GPU-related resources allocated by this instance. Call this method whenever this instance is no longer used in your app.
Returns
Section titled “Returns”void
Material#dispose
Overrides
Section titled “Overrides”fromJSON()
Section titled “fromJSON()”fromJSON(
json,textures):this
Defined in: three.js/materials/Material:fromJSON
Deserializes the material from the given JSON.
Parameters
Section titled “Parameters”The JSON holding the serialized material.
textures
Section titled “textures”Record<string, Texture >
A dictionary holding textures referenced by the material.
Returns
Section titled “Returns”this
A reference to this material.
Inherited from
Section titled “Inherited from”getEffectFieldLocation()
Section titled “getEffectFieldLocation()”getEffectFieldLocation(
effectName,fieldName): {bufferName:string;componentIndex:number;size:number; } |undefined
Defined in: packages/three-flatland/src/materials/EffectMaterial.ts:785
Locate an effect’s schema field within the packed instance buffers.
Returns the effectBufN attribute that contains this field, the
float offset within a single instance’s 4-float slice of that
buffer (0-3), and the field’s float width. Returns undefined
if no registered effect declares the given field.
Used by instance-writing code (e.g. TileLayer, SpriteBatch) that needs to poke per-instance effect values directly without going through a MaterialEffect instance’s property setter.
Parameters
Section titled “Parameters”effectName
Section titled “effectName”string
fieldName
Section titled “fieldName”string
Returns
Section titled “Returns”{ bufferName: string; componentIndex: number; size: number; } | undefined
Inherited from
Section titled “Inherited from”EffectMaterial.getEffectFieldLocation
getEffects()
Section titled “getEffects()”getEffects(): readonly typeof
MaterialEffect[]
Defined in: packages/three-flatland/src/materials/EffectMaterial.ts:511
Get the list of registered effect classes.
Returns
Section titled “Returns”readonly typeof MaterialEffect[]
Inherited from
Section titled “Inherited from”getTexture()
Section titled “getTexture()”getTexture():
Texture<unknown,TextureEventMap> |null
Defined in: packages/three-flatland/src/materials/Sprite2DMaterial.ts:670
Get the sprite texture.
Returns
Section titled “Returns”Texture <unknown, TextureEventMap > | null
getUsedEffectFloats()
Section titled “getUsedEffectFloats()”getUsedEffectFloats():
number
Defined in: packages/three-flatland/src/materials/EffectMaterial.ts:213
Current per-instance effect-float usage (sum across all registered effects). Complements getMaxEffectFloats.
Returns
Section titled “Returns”number
Inherited from
Section titled “Inherited from”EffectMaterial.getUsedEffectFloats
hasEffect()
Section titled “hasEffect()”hasEffect(
effectClass):boolean
Defined in: packages/three-flatland/src/materials/EffectMaterial.ts:504
Check if an effect class is registered on this material.
Parameters
Section titled “Parameters”effectClass
Section titled “effectClass”typeof MaterialEffect
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”hasEventListener()
Section titled “hasEventListener()”hasEventListener<
T>(type,listener):boolean
Defined in: three.js/core/EventDispatcher:hasEventListener
Checks if listener is added to an event type.
Type Parameters
Section titled “Type Parameters”T extends "dispose"
Parameters
Section titled “Parameters”T
The type of event to listen to.
listener
Section titled “listener”EventListener <MaterialEventMap [T], T, Sprite2DMaterial>
The function that gets called when the event is fired.
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”EffectMaterial.hasEventListener
onBeforeCompile()
Section titled “onBeforeCompile()”onBeforeCompile(
parameters,renderer):void
Defined in: three.js/materials/Material:onBeforeCompile
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 materials.
This method can only be used when rendering with WebGLRenderer . The
recommended approach when customizing materials is to use WebGPURenderer with the new
Node Material system and TSL .
Parameters
Section titled “Parameters”parameters
Section titled “parameters”WebGLProgramParametersWithUniforms
renderer
Section titled “renderer”A reference to the renderer.
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”EffectMaterial.onBeforeCompile
onBeforeRender()
Section titled “onBeforeRender()”onBeforeRender(
renderer,scene,camera,geometry,object,group):void
Defined in: three.js/materials/Material:onBeforeRender
An optional callback that is executed immediately before the material is used to render a 3D object.
This method can only be used when rendering with WebGLRenderer .
Parameters
Section titled “Parameters”renderer
Section titled “renderer”The renderer.
The scene.
camera
Section titled “camera”The camera that is used to render the scene.
geometry
Section titled “geometry”The 3D object’s geometry.
object
Section titled “object”The 3D object.
The geometry group data.
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”registerEffect()
Section titled “registerEffect()”registerEffect(
effectClass,constants?):boolean
Defined in: packages/three-flatland/src/materials/EffectMaterial.ts:325
Register an effect class on this material. Assigns a bit index and packed buffer slots, then rebuilds the shader. If the effect is already registered, this is a no-op.
Parameters
Section titled “Parameters”effectClass
Section titled “effectClass”typeof MaterialEffect
The MaterialEffect subclass to register
constants?
Section titled “constants?”Record<string, unknown>
Optional constants from the effect instance (for provider effects)
Returns
Section titled “Returns”boolean
Whether the buffer tier changed (requiring batch rebuild).
Inherited from
Section titled “Inherited from”removeEventListener()
Section titled “removeEventListener()”removeEventListener<
T>(type,listener):void
Defined in: three.js/core/EventDispatcher:removeEventListener
Removes a listener from an event type.
Type Parameters
Section titled “Type Parameters”T extends "dispose"
Parameters
Section titled “Parameters”T
The type of the listener that gets removed.
listener
Section titled “listener”EventListener <MaterialEventMap [T], T, Sprite2DMaterial>
The listener function that gets removed.
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”EffectMaterial.removeEventListener
setDefaultValues()
Section titled “setDefaultValues()”setDefaultValues(
material):void
Defined in: three.js/materials/nodes/NodeMaterial:setDefaultValues
Most classic material types have a node pendant e.g. for MeshBasicMaterial
there is MeshBasicNodeMaterial. This utility method is intended for
defining all material properties of the classic type in the node type.
Parameters
Section titled “Parameters”material
Section titled “material”The material to copy properties with their values to this node material.
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”EffectMaterial.setDefaultValues
setTexture()
Section titled “setTexture()”setTexture(
value):void
Defined in: packages/three-flatland/src/materials/Sprite2DMaterial.ts:681
Set the sprite texture. Re-resolves the geometry strategy: an alpha-blend material whose atlas registered polygon meshes flips to the tight-mesh path (geometry position/uv instead of vertexIndex synthesis). A flip bumps the schema version so existing batches rebuild with matching geometry.
Parameters
Section titled “Parameters”Texture <unknown, TextureEventMap > | null
Returns
Section titled “Returns”void
setup()
Section titled “setup()”setup(
builder):void
Defined in: three.js/materials/nodes/NodeMaterial:setup
Setups the vertex and fragment stage of this node material.
Parameters
Section titled “Parameters”builder
Section titled “builder”The current node builder.
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”setupAmbientOcclusion()
Section titled “setupAmbientOcclusion()”setupAmbientOcclusion(
builder):Node
Defined in: three.js/materials/nodes/NodeMaterial:setupAmbientOcclusion
Setups the ambient occlusion node from the material.
Parameters
Section titled “Parameters”builder
Section titled “builder”The current node builder.
Returns
Section titled “Returns”The ambient occlusion node.
Inherited from
Section titled “Inherited from”EffectMaterial.setupAmbientOcclusion
setupClipping()
Section titled “setupClipping()”setupClipping(
builder):ClippingNode
Defined in: three.js/materials/nodes/NodeMaterial:setupClipping
Setups the clipping node.
Parameters
Section titled “Parameters”builder
Section titled “builder”The current node builder.
Returns
Section titled “Returns”The clipping node.
Inherited from
Section titled “Inherited from”setupDepth()
Section titled “setupDepth()”setupDepth(
builder):void
Defined in: three.js/materials/nodes/NodeMaterial:setupDepth
Setups the depth of this material.
Parameters
Section titled “Parameters”builder
Section titled “builder”The current node builder.
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”setupDiffuseColor()
Section titled “setupDiffuseColor()”setupDiffuseColor(
builder):void
Defined in: three.js/materials/nodes/NodeMaterial:setupDiffuseColor
Setups the computation of the material’s diffuse color.
Parameters
Section titled “Parameters”builder
Section titled “builder”The current node builder.
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”EffectMaterial.setupDiffuseColor
setupEnvironment()
Section titled “setupEnvironment()”setupEnvironment(
builder):BasicEnvironmentNode|null
Defined in: three.js/materials/nodes/MeshBasicNodeMaterial:setupEnvironment
Overwritten since this type of material uses BasicEnvironmentNode to implement the default environment mapping.
Parameters
Section titled “Parameters”builder
Section titled “builder”The current node builder.
Returns
Section titled “Returns”BasicEnvironmentNode | null
The environment node.
Inherited from
Section titled “Inherited from”EffectMaterial.setupEnvironment
setupFog()
Section titled “setupFog()”setupFog(
builder,outputNode):Node
Defined in: three.js/materials/nodes/NodeMaterial:setupFog
Setup the fog.
Parameters
Section titled “Parameters”builder
Section titled “builder”The current node builder.
outputNode
Section titled “outputNode”The existing output node.
Returns
Section titled “Returns”The output node.
Inherited from
Section titled “Inherited from”setupLighting()
Section titled “setupLighting()”setupLighting(
builder):Node
Defined in: three.js/materials/nodes/NodeMaterial:setupLighting
Setups the outgoing light node.
Parameters
Section titled “Parameters”builder
Section titled “builder”The current node builder.
Returns
Section titled “Returns”The outgoing light node.
Inherited from
Section titled “Inherited from”setupLightingModel()
Section titled “setupLightingModel()”setupLightingModel():
BasicLightingModel
Defined in: three.js/materials/nodes/MeshBasicNodeMaterial:setupLightingModel
Setups the lighting model.
Returns
Section titled “Returns”The lighting model.
Inherited from
Section titled “Inherited from”EffectMaterial.setupLightingModel
setupLightMap()
Section titled “setupLightMap()”setupLightMap(
builder):Node
Defined in: three.js/materials/nodes/NodeMaterial:setupLightMap
Setups the light map node from the material.
Parameters
Section titled “Parameters”builder
Section titled “builder”The current node builder.
Returns
Section titled “Returns”The light map node.
Inherited from
Section titled “Inherited from”setupMaterialLightings()
Section titled “setupMaterialLightings()”setupMaterialLightings(
builder):LightingNode[]
Defined in: three.js/materials/nodes/NodeMaterial:setupMaterialLightings
Setups the lights node based on the scene, environment and material.
Parameters
Section titled “Parameters”builder
Section titled “builder”The current node builder.
Returns
Section titled “Returns”LightingNode []
The lights node.
Inherited from
Section titled “Inherited from”EffectMaterial.setupMaterialLightings
setupNormal()
Section titled “setupNormal()”setupNormal():
Node
Defined in: three.js/materials/nodes/NodeMaterial:setupNormal
Setups the normal node from the material.
Returns
Section titled “Returns”The normal node.
Inherited from
Section titled “Inherited from”setupObserver()
Section titled “setupObserver()”setupObserver(
builder):NodeMaterialObserver
Defined in: three.js/materials/nodes/NodeMaterial:setupObserver
Setups a node material observer with the given builder.
Parameters
Section titled “Parameters”builder
Section titled “builder”The current node builder.
Returns
Section titled “Returns”The node material observer.
Inherited from
Section titled “Inherited from”setupOutgoingLight()
Section titled “setupOutgoingLight()”setupOutgoingLight():
Node
Defined in: three.js/materials/nodes/NodeMaterial:setupOutgoingLight
Setups the outgoing light node variable
Returns
Section titled “Returns”The outgoing light node.
Inherited from
Section titled “Inherited from”EffectMaterial.setupOutgoingLight
setupOutput()
Section titled “setupOutput()”setupOutput(
builder,outputNode):Node
Defined in: three.js/materials/nodes/NodeMaterial:setupOutput
Setups the output node.
This method can be implemented by derived materials to extend the functionality of the material’s output or replace it altogether.
class ColoredShadowMaterial extends MeshPhongNodeMaterial { constructor( parameters ) { super( parameters ); this._shadeColor = uniform( new Color( parameters.shadeColor ?? 0xff0000 ) ); }
setupOutput( builder, outputNode ) { // Modify the native output of the MeshPhongNodeMaterial fragment shader const brightness = min( outputNode.r, 1.0 ); const mixedColor = mix( this._shadeColor, diffuseColor.rgb, brightness ); // Return new output back into NodeMaterial flow return super.setupOutput( builder, vec4( mixedColor, outputNode.a ) ); }}Parameters
Section titled “Parameters”builder
Section titled “builder”The current node builder.
outputNode
Section titled “outputNode”The existing output node.
Returns
Section titled “Returns”The output node.
Inherited from
Section titled “Inherited from”setupPositionView()
Section titled “setupPositionView()”setupPositionView(
builder):Node
Defined in: three.js/materials/nodes/NodeMaterial:setupPositionView
Setups the position node in view space. This method exists so derived node materials can modify the implementation e.g. sprite materials.
Parameters
Section titled “Parameters”builder
Section titled “builder”The current node builder.
Returns
Section titled “Returns”The position in view space.
Inherited from
Section titled “Inherited from”EffectMaterial.setupPositionView
setupPremultipliedAlpha()
Section titled “setupPremultipliedAlpha()”setupPremultipliedAlpha(
builder,outputNode):Node
Defined in: three.js/materials/nodes/NodeMaterial:setupPremultipliedAlpha
Setups premultiplied alpha.
Parameters
Section titled “Parameters”builder
Section titled “builder”The current node builder.
outputNode
Section titled “outputNode”The existing output node.
Returns
Section titled “Returns”The output node.
Inherited from
Section titled “Inherited from”EffectMaterial.setupPremultipliedAlpha
setupVariants()
Section titled “setupVariants()”
abstractsetupVariants(builder):void
Defined in: three.js/materials/nodes/NodeMaterial:setupVariants
Abstract interface method that can be implemented by derived materials to setup material-specific node variables.
Parameters
Section titled “Parameters”builder
Section titled “builder”The current node builder.
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”setupVertex()
Section titled “setupVertex()”setupVertex(
builder):Node
Defined in: three.js/materials/nodes/NodeMaterial:setupVertex
Setups the logic for the vertex stage.
Parameters
Section titled “Parameters”builder
Section titled “builder”The current node builder.
Returns
Section titled “Returns”The position in clip space.
Inherited from
Section titled “Inherited from”setValues()
Section titled “setValues()”setValues(
values?):void
Defined in: three.js/materials/nodes/MeshBasicNodeMaterial:setValues
Parameters
Section titled “Parameters”values?
Section titled “values?”MeshBasicNodeMaterialParameters
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”toJSON()
Section titled “toJSON()”toJSON(
meta?):MaterialJSON
Defined in: three.js/materials/Material:toJSON
Serializes the material into JSON.
Parameters
Section titled “Parameters”An optional value holding meta information about the serialization.
Returns
Section titled “Returns”A JSON object representing the serialized material.
ObjectLoader#parse
Inherited from
Section titled “Inherited from”getMaxEffectFloats()
Section titled “getMaxEffectFloats()”
staticgetMaxEffectFloats():number
Defined in: packages/three-flatland/src/materials/EffectMaterial.ts:196
Return the maximum number of per-instance effect floats this material type supports. See MAX_EFFECT_FLOATS.
Returns
Section titled “Returns”number
Inherited from
Section titled “Inherited from”EffectMaterial.getMaxEffectFloats
getShared()
Section titled “getShared()”
staticgetShared(options?):Sprite2DMaterial
Defined in: packages/three-flatland/src/materials/Sprite2DMaterial.ts:350
Get a shared material instance for the given options. Materials with identical configuration (texture, transparent, lit, colorTransform) return the same instance, enabling automatic batching.
Parameters
Section titled “Parameters”options?
Section titled “options?”Returns
Section titled “Returns”Sprite2DMaterial