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

Color.set()

The Color.set() method sets the current color value based on the provided color.

Syntax

set(color: Color | string | number): Color

Parameters

  • color : Color | String | Number - The color value to set to. Can be a Color instance, a string representing a color in hexadecimal notation, or a number representing a color in decimal notation.

Return Value

  • Color - The Color instance on which the method was called.

Examples

Setting the color using a Color instance

const red = new THREE.Color(0xff0000); // create a new Color instance representing the color red
const mesh = new THREE.Mesh(geometry, material);

mesh.material.color.set(red); // set the mesh's color to red

Setting the color using a hexadecimal string

const mesh = new THREE.Mesh(geometry, material);

mesh.material.color.set('#00ff00'); // set the mesh's color to green

Setting the color using a decimal number

const mesh = new THREE.Mesh(geometry, material);

mesh.material.color.set(16711680); // set the mesh's color to red

Notes

  • If a string color value is provided, it must be in hexadecimal notation.
  • If a number color value is provided, it must be in decimal notation.
  • If any other value is provided, the method will throw an error.