Skip to main content

TRANSFORM

Constant TRANSFORM 

Source
pub const TRANSFORM: &str = "type Transform {\n  position: Vec3 = Vec3 {};\n  rotation: Vec3 = Vec3 {};\n  scale: Vec3 = Vec3 { x: 1, y: 1, z: 1 };\n}";
Expand description

Local pose and scale for an entity.

Position is meters, rotation is XYZ Euler radians, and scale defaults to one on every axis. Physics owns the position and rotation of dynamic bodies.

§Declaration

type Transform {
  position: Vec3 = Vec3 {};
  rotation: Vec3 = Vec3 {};
  scale: Vec3 = Vec3 { x: 1, y: 1, z: 1 };
}

§Fields and methods

  • position: Translation in meters; defaults to the local origin.

  • rotation: XYZ Euler rotation in radians; defaults to zero rotation.

  • scale: Per-axis multiplier; defaults to (1, 1, 1). Physical spheres require uniform positive scale.

§Set a pose

Create a transform value in meters.

let value = Transform { position: Vec3 { x: 2 } };
print(value.position.x);

§Attach a renderable pose

A scene adapter reads Transform from an entity with geometry.

let entity = spawn(Sphere {});
add(entity, Transform { position: Vec3 { y: 1 } });
print(get[Transform](entity).position.y);