Host typegenerated
Transform
Where an object is, how it is turned and how big it is. For an object attached to another, these are measured from that parent.
15 members · engine 0.1.0
Transform.forward: Vec3Read-only unit world-space facing direction: -Z at identity. Parent rotation is included and scale is ignored. Copy it to move withworld_position += forward * speed * dt.Transform.look_at(target: Vec3) -> unitFaces a world-space Vec3 target with Y up and zero world roll; preserves position and scale, including under a parent. Vertical targets use yaw zero. Coincident/non-finite targets are errors with no mutation.Transform.pitch: numberHow far a 3D object is tipped up (positive) or down from level, in radians, after its yaw. Changing it keeps its yaw and roll.Transform.position: Vec3Where the object is. Change it to move the object:this.transform.position.x += speed * dt. Measured from the parent if it has one.Transform.right: Vec3Read-only unit world-space +X direction, with parent rotation included and scale ignored.Transform.roll: numberHow far a 3D object is turned about the way it faces, in radians, after its yaw and pitch. Changing it keeps its yaw and pitch.Transform.rotate_around(pivot: Vec3, axis: Vec3, radians: number) -> unitRotates position and orientation around a world-space Vec3 pivot and nonzero Vec3 axis by radians. Normalizes the axis and preserves scale. Invalid input/output, a singular parent scale, or movement off a Z-locked layer is an error with no mutation.Transform.rotation: QuatParent-relative Quat in x/y/z/w order. Reads copy the stored rotation; whole writes normalize finite nonzero values atomically and preserve position, scale and Z lock. Stored components are readable; change components on a local var and assign it back. Zero/non-finite writes fail without mutation.Transform.rotation_z: numberHow far the object is turned, in radians. A full turn isTAU. This is the turn of a flat object in a 2D game; it replaces any 3D turn.Transform.scale: Vec3How big the object is on each axis; 1 is its normal size.Transform.to_local(point: Vec3) -> Vec3A world-space Vec3 point measured in this object's own space: its position subtracted, its world rotation undone and its world scale divided out. What a point on a moving, turning ship is in the ship's own blocks. Reads only; zero scale is an error.Transform.to_world(point: Vec3) -> Vec3A Vec3 point in this object's own space placed in the world: scaled, turned and moved by the object's world transform, parents included. The inverse ofto_local. Reads only.Transform.up: Vec3Read-only unit world-space +Y direction, with parent rotation included and scale ignored.Transform.world_position: Vec3Where the object is in the world, even when it is attached to a parent. Use it to compare positions of objects in different places.Transform.yaw: numberWhich way a 3D object faces on the ground, in radians: a turn about the up (Y) axis. At zero it faces -Z, and positive turns it left. It moves alongVec3(-sin(yaw), 0.0, -cos(yaw)), and faces a pointdaway withatan2(-d.x, -d.z). Changing it keeps its pitch and roll.
- Source
- docs/generated/decay-api.json
- Schema
- v1
- Engine version
- 0.1.0
- Source commit
909aca81368b