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

The premultipy method of the Matrix4 class in three.js is used to multiply a matrix with another matrix in the left-multiplication form.

Syntax

premultiply(matrix: Matrix4): this

Parameters

  • matrix: The matrix to be multiplied with.

Return Value

The this keyword, which refers to the Matrix4 object that is being modified.

Description

The premultipy method is used to multiply a matrix with another matrix in the left multiplication form. The matrix passed as an argument is multiplied in the order matrix * this, where matrix is the argument and this refers to the current Matrix4 object.

This method updates the current object, and returns a reference to the same object. Therefore, this method can be chained with other methods on the Matrix4 object.

Examples

const matrix1 = new THREE.Matrix4().makeScale(2, 2, 2);
const matrix2 = new THREE.Matrix4().makeRotationY(Math.PI / 2);

matrix1.premultiply(matrix2);

console.log(matrix1.toArray());
// [ 0, 0, -2, 0, 0, 2, 0, 0, 2, 0, 0, 0, 0, 0, 0, 1 ]
const matrix1 = new THREE.Matrix4().makeScale(2, 2, 2);
const matrix2 = new THREE.Matrix4().makeRotationY(Math.PI / 2);
const matrix3 = new THREE.Matrix4().makeTranslation(1, 2, 3);

matrix1.premultiply(matrix2).premultiply(matrix3);

console.log(matrix1.toArray());
// [ 0, 0, -2, 3, 0, 2, 0, 4, 2, 0, 0, 0, 0, 0, 0, 1 ]

See Also

  • Matrix4.multiply()
  • Matrix4.makeRotationY()
  • Matrix4.makeScale()