feat: bees and frogs
This commit is contained in:
parent
46e7070b6b
commit
16f205babe
13 changed files with 540 additions and 31 deletions
|
|
@ -20,6 +20,26 @@ export namespace Mat4 {
|
|||
return out
|
||||
}
|
||||
|
||||
/** Model transform T * Ry * S: uniform `scale`, then a yaw rotation about Y,
|
||||
* then a translation. Built directly in column-major storage (no intermediate
|
||||
* matmuls) since it runs per mob per frame. A vertex at local +Z ends up
|
||||
* pointing along world (sin yaw, 0, cos yaw), i.e. the object faces `yaw`. */
|
||||
export function compose(tx: number, ty: number, tz: number, yaw: number, scale: number): Mat4 {
|
||||
const c = Math.cos(yaw)
|
||||
const s = Math.sin(yaw)
|
||||
const out = new Float32Array(16)
|
||||
out[0] = scale * c
|
||||
out[2] = scale * -s
|
||||
out[5] = scale
|
||||
out[8] = scale * s
|
||||
out[10] = scale * c
|
||||
out[12] = tx
|
||||
out[13] = ty
|
||||
out[14] = tz
|
||||
out[15] = 1
|
||||
return out
|
||||
}
|
||||
|
||||
/** Right-handed perspective projection (camera looks down -Z). Maps the view
|
||||
* frustum to clip space; the -1 in row 3 copies -z into w, so the later
|
||||
* divide by w is what produces foreshortening. */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue