Expand description
Model transform constructors: orient objects in world space.
These functions produce local -> world transforms (object rotation and translation).
Unlike view transforms, model transforms take explicit local axis parameters
(fwd_axis and up_axis) because object conventions vary:
| Engine / Convention | fwd_axis | up_axis |
|---|---|---|
| Bevy / OpenGL | Vec3::NEG_Z | Vec3::Y |
| Unreal Engine | Vec3::X | Vec3::Z |
| Unity / glTF | Vec3::Z | Vec3::Y |
| Blender | Vec3::Y | Vec3::Z |
fwd_axis and up_axis must be perpendicular.
look_to_* functions target a forward direction (dir), look_at_* functions
target a focal point (center). Functions returning Mat4, Affine3, Affine3A,
or similar return a full model transform (rotation and translation). Functions returning
Quat, Mat3, Mat3A, or similar return only the model rotation.
§Example
use glam::Vec3;
use glam::camera::model;
// Bevy: object faces -Z, up is Y
let q = model::look_to_quat(Vec3::X, Vec3::Y, Vec3::NEG_Z, Vec3::Y);
assert!((q * Vec3::NEG_Z - Vec3::X).length() < 1e-6);Functions§
- look_
at_ affine3 - Returns an
Affine3model transform from eye, focal point, and up. - look_
at_ affine3a - Returns an
Affine3Amodel transform from eye, focal point, and up. - look_
at_ mat3 - Returns a
Mat3model rotation from eye, focal point, and up. - look_
at_ mat4 - Returns a
Mat4model transform from eye, focal point, and up. - look_
at_ mat3a - Returns a
Mat3Amodel rotation from eye, focal point, and up. - look_
at_ quat - Returns a
Quatmodel rotation from eye, focal point, and up. - look_
to_ affine3 - Returns an
Affine3model transform from eye, forward direction, and up. - look_
to_ affine3a - Returns an
Affine3Amodel transform from eye, forward direction, and up. - look_
to_ mat3 - Returns a
Mat3model rotation from forward direction and up. - look_
to_ mat4 - Returns a
Mat4model transform from eye, forward direction, and up. - look_
to_ mat3a - Returns a
Mat3Amodel rotation from forward direction and up. - look_
to_ quat - Returns a
Quatmodel rotation from forward direction and up.