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

Matrix4.equals()

The Matrix4.equals() method in Three.js is used to compare two matrix objects for equality.

Syntax

equals(matrix: Matrix4): boolean;

Parameters

  • matrix: The matrix object to compare to.

Returns

  • boolean: True if the matrix objects are equal, else false.

Description

The equals() method compares the matrix with another matrix object to check if they have the exact same elements in the same order. If they match, the method returns true, else false.

Examples

import { Matrix4 } from 'three';

const matrix1 = new Matrix4(1, 0, 0, 0,
                            0, 1, 0, 0,
                            0, 0, 1, 0,
                            0, 0, 0, 1 );
const matrix2 = new Matrix4(1, 0, 0, 0,
                            0, 1, 0, 0,
                            0, 0, 1, 0,
                            0, 0, 0, 1 );

console.log(matrix1.equals(matrix2)); // true

matrix2.elements[0] = 2;
console.log(matrix1.equals(matrix2)); // false

In this example, we create two identical matrix objects and compare them using the equals() method. The method returns true, indicating that they are equal.

We then modify an element of matrix2 and compare again. This time, the method returns false as the two matrices no longer match.

Remarks

Note that the equals() method only compares the elements of the matrices, not their types or other properties.

See also