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 / OpenGLDVec3::NEG_ZDVec3::Y
Unreal EngineDVec3::XDVec3::Z
Unity / glTFDVec3::ZDVec3::Y
BlenderDVec3::YDVec3::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 DMat4, DAffine3, or similar return a full model transform (rotation and translation). Functions returning DQuat, DMat3, or similar return only the model rotation.

§Example

use glam::DVec3;
use glam::dcamera::model;

// Bevy: object faces -Z, up is Y
let q = model::look_to_quat(DVec3::X, DVec3::Y, DVec3::NEG_Z, DVec3::Y);
assert!((q * DVec3::NEG_Z - DVec3::X).length() < 1e-6);

Functions§

look_at_affine3
Returns an DAffine3 model transform from eye, focal point, and up.
look_at_mat3
Returns a DMat3 model rotation from eye, focal point, and up.
look_at_mat4
Returns a DMat4 model transform from eye, focal point, and up.
look_at_quat
Returns a DQuat model rotation from eye, focal point, and up.
look_to_affine3
Returns an DAffine3 model transform from eye, forward direction, and up.
look_to_mat3
Returns a DMat3 model rotation from forward direction and up.
look_to_mat4
Returns a DMat4 model transform from eye, forward direction, and up.
look_to_quat
Returns a DQuat model rotation from forward direction and up.