The set()
method of the Matrix3
class in the Three.js library sets the values of a 3x3 matrix.
.set(n11, n12, n13, n21, n22, n23, n31, n32, n33)
n11
, n12
, n13
, n21
, n22
, n23
, n31
, n32
, n33
: Nine numbers representing the values to set for the 3x3 matrix.The set()
method sets the values of the Matrix3
instance to the provided values. The values are expected to be provided in row-major order, meaning that the first three values (n11
, n12
, n13
) correspond to the first row of the matrix, and so on.
The set()
method does not return a value, but modifies the calling Matrix3
instance.
const matrix = new THREE.Matrix3();
matrix.set(
1, 0, 0,
0, 1, 0,
0, 0, 1
);
console.log(matrix);
Output:
Matrix3 {
elements: [
1, 0, 0,
0, 1, 0,
0, 0, 1
]
}
Matrix3
class is used to represent 3x3 matrices in Three.js. Such matrices are commonly used in computer graphics for affine transformations, such as rotation, scaling, and translation.set()
method is commonly used to initialize a Matrix3
instance with a specific set of values. Another common approach is to use one of the convenience methods, such as makeRotationZ()
or makeScale()
.