Skip to main content

Function (Math)

Matrix4​

A 4x4 matrix. Any argument to a Matrix4 method can be a pure JavaScript array.

Usage​

let Matrix4 =window.mapmost.Matrix4;

Copy the matrix to Matrix4 so that it can be manipulated using Matrix4 methods (such as translation):

const IDENTITY = [1, 0, ..., 1];
const m = new Matrix4(IDENTITY).translate([1, 0, 0]);

Invert matrix

const inverse = matrix.invert();

method​

Constructor​

Create an empty Matrix4

new Matrix4()

identity()​

Set the matrix to a multiplicative identity matrix.

matrix4.identity()

set(...number)​

Set the elements of the matrix.

matrix4.set(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33)

invert()​

Set this matrix to its inverse. The inverse matrix reflects the original matrix elements in the diagonal.

matrix4.invert()

multiplyLeft(matrix: number[16])​

Multiply another matrix from the left. When used with Matrix4 to transform vectors, the vectors are multiplied from the right side. This means that multiplying a matrix from the left will cause it to be applied last during the transformation (unless of course other matrices are multiplied from the left).

matrix4.multiplyLeft(matrix4)

multiplyRight(matrix: number [16] )​

Multiply another matrix from the right.

matrix4.multiplyRight(matrix4)

rotateX(radians: number)​

Adds a given angle of rotation about the X-axis. Equivalent to right multiplying the new transformation into the matrix, but with higher performance.

matrix4.rotateX(radians)

rotateY(radians: number)​

Adds a given angle of rotation about the Y-axis.

rotateY(radians)

rotateZ(radians: number)​

Adds a given angle of rotation about the Z axis.

matrix4.rotateZ(radians)

rotateXYZ(angles: [rx: number, ry: number, rz: number])​

Adds a continuous rotation at a given angle about the X, Y, and Z axes.

rotateXYZ([rx, ry, rz])

scale(factor: number | number[3])​

Add a scaling transform so each axis can be scaled independently.

matrix4.scale(factor) 
factor(number) - The scaling factor to apply to each axis.
matrix4.scale([x, y, z])
x(number) – the scale factor by which the x component is to be multiplied
y(number) - the scale factor by which the y component is to be multiplied
z(number) – the scale factor by which the z component is to be multiplied

Equivalent to right multiplying the new transformation into the matrix, but with higher performance.

matrix4.scale([x, y, z])
During vector transformation, all coordinates will be multiplied by the given factor.
scale -1 will flip the coordinate system on that axis.
scale -0 will remove the component.

translate(scale: number[3])​

Adds a translation to the matrix.

matrix4.translate([x, y, z])
x(number) - the translation to add to the x component
y(number) – the translation to add to the y component
z(number) – the translation to add to the z component

Equivalent to right multiplying the new transformation into the matrix, but with higher performance. During a vector transformation, the given translation value is added to each component of the vector being transformed.

Case​

    const TILESET_URL = "<your url>";
//Create an initialized identity matrix
let matrix = new window.mapmost.Matrix4();
//Add translation rotation transformation
let matrix4 = matrix.translate([0, 0, 200]).rotateX(Math.PI / 2);
map.add3dTilesLayer(
{
id: 'tile-3d-layer',
data: TILESET_URL,
transform: matrix4
}
)

Refer to Example.