BufferGeometry
Object3D
Raycaster
Camera
CubeCamera
PerspectiveCamera
OrthographicCamera
StereoCamera
Clock
Curve
CurvePath
Path
Shape
ShapePath
ArrowHelper
AxesHelper
BoxHelper
Box3Helper
CameraHelper
DirectionalLightHelper
GridHelper
PolarGridHelper
HemisphereLightHelper
PlaneHelper
PointLightHelper
SkeletonHelper
SpotLightHelper
Light
PointLight
RectAreaLight
SpotLight
DirectionalLight
HemisphereLight
LightShadow
PointLightShadow
AnimationLoader
AudioLoader
BufferGeometryLoader
CompressedTextureLoader
CubeTextureLoader
DataTextureLoader
FileLoader
ImageBitmapLoader
ImageLoader
Loader
LoaderUtils
MaterialLoader
ObjectLoader
TextureLoader
LoadingManager
Material
Box2
Box3
Color
Cylindrical
Euler
Frustum
Interpolant
Line3
MathUtils
Matrix3
Matrix4
Plane
Quaternion
AnimationAction
AnimationClip
AnimationMixer
AnimationObjectGroup
AnimationUtils
keyframeTrack
PropertyBinding
PropertyMixer
BooleanKeyframeTrack
QuaternionKeyframeTrack
StringKeyframeTrack
Audio
AudioAnalyser
AudioContext
AudioListener
PositionalAudio

Material.setValues()

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.

Syntax

material.setValues( values: object );

Parameters

  • values (required): An object containing key-value pairs representing the material properties to be updated.

Example

// 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.

Properties

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.

Conclusion

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.