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

Quaternion.equals()

The Quaternion.equals() method is used to compare two quaternions and check whether they are equal or not. It returns true if both the quaternions have the same values for the x, y, z and w components, false otherwise.

Syntax

quaternion.equals( other )

Parameters

  • other: The quaternion to compare.

Return Value

  • Returns true if the two quaternions are equal, false otherwise.

Example

const quat1 = new THREE.Quaternion(0.707, 0, 0, 0.707);
const quat2 = new THREE.Quaternion(0.707, 0, 0, 0.707);

const result = quat1.equals(quat2);

console.log(result); // true

Notes

  • In three.js, Quaternion is a class that represents a 4D vector used to encode rotations in 3D space. It is implemented using the Vector4 class in three.js.
  • Quaternions are often used instead of Euler angles to avoid the problem of gimbal lock, which can occur when using Euler angles in certain situations.
  • Quaternions are not commutative, meaning that q1 * q2 is not equal to q2 * q1 in general.

See Also