MCPcopy Create free account
hub / github.com/esengine/esengine / createTransformMatrix

Function createTransformMatrix

scripts/test-fbxloader-bindpose.mjs:14–27  ·  view source on GitHub ↗
(position, rotation, scale)

Source from the content-addressed store, hash-verified

12
13// Matrix math utilities
14function createTransformMatrix(position, rotation, scale) {
15 const [qx, qy, qz, qw] = rotation;
16 const [sx, sy, sz] = scale;
17 const xx = qx * qx, xy = qx * qy, xz = qx * qz, xw = qx * qw;
18 const yy = qy * qy, yz = qy * qz, yw = qy * qw;
19 const zz = qz * qz, zw = qz * qw;
20
21 return new Float32Array([
22 (1 - 2 * (yy + zz)) * sx, 2 * (xy + zw) * sx, 2 * (xz - yw) * sx, 0,
23 2 * (xy - zw) * sy, (1 - 2 * (xx + zz)) * sy, 2 * (yz + xw) * sy, 0,
24 2 * (xz + yw) * sz, 2 * (yz - xw) * sz, (1 - 2 * (xx + yy)) * sz, 0,
25 position[0], position[1], position[2], 1
26 ]);
27}
28
29function multiplyMatrices(a, b) {
30 const result = new Float32Array(16);

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected