Skip to content

Latest commit

 

History

History
56 lines (41 loc) · 1.25 KB

transform.md

File metadata and controls

56 lines (41 loc) · 1.25 KB

Transform

Transform describes the location, rotation, scale and dimensions of object. To access the transform in Haxe trait:

var transform = object.transform;

To access transform properties in object-space:

var m = transform.local; // Matrix
var l = transform.loc;   // Location
var r = transform.rot;   // Rotation
var s = transform.scale; // Scale

To access transform properties in world-space:

var m = transform.world;                     // Matrix
var l = transform.world.getLoc();            // Location
var r = new Quat().fromMat(transform.world); // Rotation
var s = transform.world.getScale();          // Scale

To manipulate the transform:

transform.translate(1, 2, 3); // x, y, z
transform.rotate(Vec4.zAxis(), 1.2); // Axis, angle in radians

Alternatively, modify the transform properties directly. To apply the changes, call buildMatrix():

transform.loc.set(0, 5, 0);
transform.scale.x = 2.0;
transform.buildMatrix();

To set location, rotation and scale using a matrix:

var m = Mat4.identity();
transform.setMatrix(m);

To retrieve world-space look vector:

var look = transform.look();

Example: