MCPcopy Create free account
hub / github.com/Bloom-Engine/engine / trsToMat4

Function trsToMat4

src/world/loader.ts:310–321  ·  view source on GitHub ↗
(t: TransformData)

Source from the content-addressed store, hash-verified

308// The rotation order matches glTF / Blender / most game engines (XYZ Euler,
309// applied right-to-left so X spin happens first in object space).
310export function trsToMat4(t: TransformData): Mat4 {
311 const pos: Vec3 = { x: t.position[0], y: t.position[1], z: t.position[2] };
312 const scl: Vec3 = { x: t.scale[0], y: t.scale[1], z: t.scale[2] };
313
314 let m = mat4Identity();
315 m = mat4Translate(m, pos);
316 m = mat4RotateZ(m, t.rotation[2]);
317 m = mat4RotateY(m, t.rotation[1]);
318 m = mat4RotateX(m, t.rotation[0]);
319 m = mat4Scale(m, scl);
320 return m;
321}
322
323// Apply an RGBA tint to a scene node. Pulled into a helper so it can be reused
324// by prefab expansion (where children inherit the parent entity's tint unless

Callers 2

spawnModelEntityFunction · 0.70
spawnPrefabEntityFunction · 0.70

Calls 6

mat4IdentityFunction · 0.90
mat4TranslateFunction · 0.90
mat4RotateZFunction · 0.90
mat4RotateYFunction · 0.90
mat4RotateXFunction · 0.90
mat4ScaleFunction · 0.90

Tested by

no test coverage detected