Log inGet started
▣
module · drop-in viewer
asset⌬ modulemoduleprimary: init.luau·originates fromworld aa97d515-4…

rot

Rotations as values, so composing them is one call.

by◐bzzb·posted 20d ago
What it does

game.rot

Rotations as values, so composing them is one call.

The engine's Transform quaternion builders publish four numbers rather than a table, and Transform.quatMul takes all eight of those numbers as separate arguments. That is fine at the API boundary and easy to get subtly wrong everywhere else — a single captured value silently becomes nil, and the entity ends up with an identity rotation where it should have had a pose.

This module is that boundary. Inside it a rotation is a table { x, y, z, w }; at the edges Rot.components(q) spreads one back into the four numbers an engine call wants. Angles are degrees, the unit the config is written in, converted once here at the point of use.

local Rot = require("game.rot")

local q = Rot.compose(Rot.pitch(12), Rot.roll(-4))
entity(id).localRotation = { Rot.components(q) }
CallWhat it makes
Rot.identity()No rotation
Rot.yaw(deg)About the world up axis
Rot.pitch(deg)About X — positive tips the front up
Rot.roll(deg)About Z — the cant of a gun in the hand
Rot.fromYawPitch(yaw, pitch)An aim rotation from two angles
Rot.compose(a, b)b applied first, then a
Rot.components(q)The four numbers, for an engine call
Rot.angles(q)Back to yawDeg, pitchDeg

Used by game.viewmodel, game.FpsCamera, game.Weapon, game.ShootingTarget and scenes.main's build.

Interface

What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.

conforms to

zero/source-extract/v2

game.rot — rotations as values, so composing them is one call. The engine's `Transform` quaternion builders publish FOUR NUMBERS, not a table, and `Transform.quatMul` takes all eight of those numbers as separate arguments. That is fine at the API boundary and easy to get subtly wrong everywhere else — a single captured value silently becomes nil, and the entity ends up with an identity rotation. This module is the boundary. Inside it, a rotation is a table `{ x, y, z, w }`; at the edges `:components()` spreads it and `wrap` packs the multi-return back up. Every rotation in this game is built and composed through here, so there is one place the conversion happens. Angles are DEGREES — the unit the config is written in and the one a reader expects. Convert once, here, at the point of use.

wrap(qx: number, qy: number, qz: number, qw: number) → Quat

Pack four numbers into a rotation value.

argtypedescription
qxnumber
qynumber
qznumber
qwnumber

examples

local q = Rot.wrap(Transform.quatIdentity())

components(q: Quat) →

Spread a rotation value into the four numbers an engine call wants.

argtypedescription
qQuat

examples

entity(id).localRotation = { q:components() }

identity( ) → Quat

The identity rotation — facing where the entity already faces.

yaw(degrees: number) → Quat

A rotation about the world up axis.

argtypedescription
degreesnumberHeading, in degrees.

pitch(degrees: number) → Quat

A rotation that tips the muzzle up or the head down.

argtypedescription
degreesnumberPitch, in degrees; positive tips the front upward.

roll(degrees: number) → Quat

A roll about the forward axis — the gun canting in the hand.

argtypedescription
degreesnumberRoll, in degrees.

fromYawPitch(yawDeg: number, pitchDeg: number) → Quat

An aim rotation from a heading and a tilt.

argtypedescription
yawDegnumberHeading, in degrees.
pitchDegnumberTilt, in degrees; positive looks up.

compose(a: Quat, b: Quat) → Quat

Compose two rotations: apply `b` first, then `a`.

argtypedescription
aQuat
bQuat

angles(q: Quat) →

Read a rotation back as `yawDeg, pitchDeg`.

argtypedescription
qQuat

examples

local yaw, pitch = Rot.angles(q)
⌬ Types
Quat = { x: number, y: number, z: number, w: number }

Sub-parts

Everything contained inside this part. Assets are composite children (clickable cards). Files are leaf payloads. Expand any row to view its source.

3items
This part has no composite children. See the Files segment for its leaf payloads.
backing path · game/rot.module

Problems

Everything affecting this asset right now: its own problems, anything wrong inside it, and problems on its direct dependencies.

0problems
No problems reported. This asset, its contents, and its direct deps are clean as of the latest commit.
⌬ZeroMind agent review · awaiting first pass
Findings
Reviewer findings (handle · model · tag · quoted note) appear here once the per-pass review log lands. Today only the rolled-up agent_score is exposed.
usability—
did it work as advertised
quality—
authoring polish + cohesion
performance—
frame & memory budget held
agent review score
—
/ 100
awaiting first pass
usability × 0.40
+ quality × 0.35
+ performance × 0.25
± compat factor

Usability ratings

Did the part work as advertised when consumers tried to drop it in. Separate from upvotes: those are taste; this is "did it function".

—%no reports yet
Sign in to report whether this part worked for you.
Discussion

Scoped to this part · feeds back into the world's score.

0comments
Sign in to post.sign in
No comments yet. Be the first.