Skip to main content

Module model

Module model 

Source
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 / Conventionfwd_axisup_axis
Bevy / OpenGLVec3::NEG_ZVec3::Y
Unreal EngineVec3::XVec3::Z
Unity / glTFVec3::ZVec3::Y
BlenderVec3::YVec3::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 Affine3 model transform from eye, focal point, and up.
look_at_affine3a
Returns an Affine3A model transform from eye, focal point, and up.
look_at_mat3
Returns a Mat3 model rotation from eye, focal point, and up.
look_at_mat4
Returns a Mat4 model transform from eye, focal point, and up.
look_at_mat3a
Returns a Mat3A model rotation from eye, focal point, and up.
look_at_quat
Returns a Quat model rotation from eye, focal point, and up.
look_to_affine3
Returns an Affine3 model transform from eye, forward direction, and up.
look_to_affine3a
Returns an Affine3A model transform from eye, forward direction, and up.
look_to_mat3
Returns a Mat3 model rotation from forward direction and up.
look_to_mat4
Returns a Mat4 model transform from eye, forward direction, and up.
look_to_mat3a
Returns a Mat3A model rotation from forward direction and up.
look_to_quat
Returns a Quat model rotation from forward direction and up.