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

Matrix3.equals()

The equals() method in the Matrix3 class in three.js library is used to check if this matrix and another matrix passed as a parameter are equal, with a tolerance of epsilon for each component.

Syntax

.equals(matrix: Matrix3, epsilon?: number): boolean

Parameters

The method takes the following parameters:

  • matrix: An instance of Matrix3. Matrix to compare to the current matrix.
  • epsilon (optional): A floating-point value representing the tolerance level for the comparison.

Return Value

The method returns a boolean value true if the two matrices are equal within the given tolerance or false otherwise.

Example

let matrix1 = new THREE.Matrix3().set(1, 2, 3, 4, 5, 6, 7, 8, 9);
let matrix2 = new THREE.Matrix3().set(1.001, 2.002, 3.002, 4, 5, 6, 7, 8, 9);

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

matrix2 = new THREE.Matrix3().set(1.1, 2.2, 3.3, 4, 5, 6, 7, 8, 9);

console.log(matrix1.equals(matrix2, 0.01)); // false

In this example, we create two Matrix3 objects, matrix1 and matrix2, with slightly different values. We then compare these two matrices using the equals() method with a tolerance level of 0.01. Since the differences between the two matrices are within this tolerance level, the method returns true. Then, we update the values of matrix2 to be significantly different from matrix1. Again, we use the equals() method with a tolerance level of 0.01. This time, the differences between the two matrices are greater than the tolerance level, so the method returns false.