The Material.setValues()
function in Three.js is used to update the properties of a material. It takes an object as the parameter, and each key-value pair in the object corresponds to a property in the material.
material.setValues( values: object );
values
(required): An object containing key-value pairs representing the material properties to be updated.// create a new material
var material = new THREE.MeshBasicMaterial({
color: 0xff0000,
wireframe: true,
});
// update the material properties
material.setValues({
color: 0x00ff00,
wireframe: false,
});
In this example, a new MeshBasicMaterial
is created with an initial color of red and wireframe enabled. The setValues()
function is called to update the color to green and disable wireframe.
The setValues()
function can update any of the following properties:
alphaTest
blendDst
blendDstAlpha
blendEquation
blendEquationAlpha
blending
blendSrc
blendSrcAlpha
clipIntersection
clippingPlanes
clipShadows
color
depthFunc
depthTest
depthWrite
dithering
fog
lights
name
opacity
overdraw
polygonOffset
polygonOffsetFactor
polygonOffsetUnits
precision
premultipliedAlpha
reflectivity
refractionRatio
shading
side
skinning
transparent
vertexColors
visible
wireframe
wireframeLinecap
wireframeLinejoin
wireframeLinewidth
Each property has a specific type and range of values that it can be set to. Refer to the Three.js documentation for more information on each property.
The Material.setValues()
function is a convenient way to update multiple properties of a material at once. It takes an object as the parameter, with each key-value pair representing a material property to be updated. Use this function to easily change the appearance of your Three.js objects.