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.equals()

The Color.equals() method is used to compare two THREE.Color objects and returns true if they are equal and false otherwise.

Syntax

color.equals(otherColor);

Parameters

  • otherColor: The THREE.Color object to compare with.

Return value

The method returns a Boolean value: true if the two colors are equal, false otherwise.

Example

const color1 = new THREE.Color(0xff0000);
const color2 = new THREE.Color("red");
const color3 = new THREE.Color(0x00ff00);

console.log(color1.equals(color2)); // returns true
console.log(color1.equals(color3)); // returns false

Notes

The Color.equals() method compares the red, green, and blue components of the two colors, as well as the alpha component if it is present. If all components are equal, the method returns true, otherwise, it returns false.

When comparing THREE.Color objects, it is recommended to use the equals() method instead of the == operator, as the objects may have different reference values even if their RGB values are the same.

Browser compatibility

The Color.equals() method is supported in all modern browsers.

See also