Atlaslog
Atlaslog / three.js / API reference / Matrix4
three.js · API reference

Matrix4

Quick answer

Matrix4 is a 4x4 column-major transform matrix holding translation, rotation, scale, and projection. Object3D uses it for matrix and matrixWorld, and you can compose transforms with compose(), invert() them, or build camera projections with makePerspective() and makeOrthographic(). elements stores 16 floats in column-major order, matching GPU upload layout.

Last verified 2026-11-03 · three.js 0.160.0 · Cite this page
new THREE.Matrix4 () → Matrix4(单位矩阵)
Key points
Example
const m = new THREE.Matrix4();

const T = new THREE.Matrix4().makeTranslation(10, 0, 5);
const R = new THREE.Matrix4().makeRotationY(Math.PI / 6);
const S = new THREE.Matrix4().makeScale(2, 2, 2);

m.multiplyMatrices(T, R).multiply(S);   // T · R · S
const position = new THREE.Vector3(10, 0, 5);
const quaternion = new THREE.Quaternion().setFromAxisAngle(
  new THREE.Vector3(0, 1, 0), Math.PI / 6
);
m.compose(position, quaternion, new THREE.Vector3(2, 2, 2));
mesh.updateMatrix();
const world = new THREE.Matrix4().multiplyMatrices(
  mesh.parent ? mesh.parent.matrixWorld : new THREE.Matrix4(),
  mesh.matrix
);
const clip = new THREE.Vector4(x, y, z, 1).applyMatrix4(camera.projectionMatrix);
const ndcX = clip.x / clip.w;
Notes
Runnable examplesChinese originalAll API references
English edition written for Atlaslog. Code is taken from the original Chinese page and runs unchanged.
Cite this page

Atlaslog (2026). Matrix4. https://www.jingweizhi.com/en/three/api/matrix4.html (accessed 2026-11-03).