Skip to main content

Math

Matrix4​

one 4x4 matrix.Matrix4Any parameter of a method can be pureJavaScriptarray.

usage​

let Matrix4 =window.mapmost.Matrix4;

Copy the matrix toMatrix4so that it can be usedMatrix4Methods to operate on it (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 emptyMatrix4

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. used forMatrix4When transforming a vector, 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)​

around X Axis adds a given angle of rotation. Equivalent to right multiplying the new transformation into the matrix, but with higher performance.

matrix4.rotateX(radians)

rotateY(radians: number)​

around Y Axis adds a given angle of rotation.

rotateY(radians)

rotateZ(radians: number)​

around Z Axis adds a given angle of rotation.

matrix4.rotateZ(radians)

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

around X、Y and Z The axis adds continuous rotation by a given angle.

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) - Scale factor to apply to each axis.

matrix4.scale([x, y, z])
x(number) - to be multiplied by x scale factor of components
y(number) - to be multiplied by y scale factor of components
z(number) - to be multiplied by z scale factor of components

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 The coordinate system on this axis will be flipped.
scale -0 The component will be removed.

translate(scale: number[3])​

Adds a translation to the matrix.

matrix4.translate([x, y, z])
x(number) - to add to x Translation of components
y(number) - to add to y translation of components
z(number) - to add to z translation of components

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。