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

Method local_transform

native/watchos/src/models.rs:56–83  ·  view source on GitHub ↗

Compose TRS into a column-major 4x4 matrix, or return `matrix` if set.

(&self)

Source from the content-addressed store, hash-verified

54
55 /// Compose TRS into a column-major 4x4 matrix, or return `matrix` if set.
56 pub fn local_transform(&self) -> [f32; 16] {
57 if let Some(m) = self.matrix { return m; }
58 let [tx, ty, tz] = self.translation;
59 let [qx, qy, qz, qw] = self.rotation;
60 let [sx, sy, sz] = self.scale;
61 // Rotation matrix from quaternion.
62 let xx = qx * qx; let yy = qy * qy; let zz = qz * qz;
63 let xy = qx * qy; let xz = qx * qz; let yz = qy * qz;
64 let wx = qw * qx; let wy = qw * qy; let wz = qw * qz;
65 [
66 (1.0 - 2.0 * (yy + zz)) * sx,
67 (2.0 * (xy + wz)) * sx,
68 (2.0 * (xz - wy)) * sx,
69 0.0,
70
71 (2.0 * (xy - wz)) * sy,
72 (1.0 - 2.0 * (xx + zz)) * sy,
73 (2.0 * (yz + wx)) * sy,
74 0.0,
75
76 (2.0 * (xz + wy)) * sz,
77 (2.0 * (yz - wx)) * sz,
78 (1.0 - 2.0 * (xx + yy)) * sz,
79 0.0,
80
81 tx, ty, tz, 1.0,
82 ]
83 }
84}
85
86pub struct Mesh {

Callers 1

spawn_node_subtreeFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected