Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow configure the UP direction for LookAt driver #22

Open
wentao opened this issue Mar 7, 2024 · 0 comments
Open

Allow configure the UP direction for LookAt driver #22

wentao opened this issue Mar 7, 2024 · 0 comments

Comments

@wentao
Copy link

wentao commented Mar 7, 2024

The current implementation in

pub fn look_at<H: Handedness, V, Q>(forward: V) -> Q
where
    V: Into<mint::Vector3<f32>>,
    Q: From<mint::Quaternion<f32>>,
{
    let forward: Vec3 = forward.into().into();

    let result = forward
        .try_normalize()
        .and_then(|forward| {
            let right =
                H::right_from_up_and_forward::<Vec3, Vec3>(Vec3::Z, forward).try_normalize()?;
            let up = H::up_from_right_and_forward(right, forward);
            Some(Quat::from_mat3(&Mat3::from_cols(
                right,
                up,
                forward * H::FORWARD_Z_SIGN,
            )))
        })
        .unwrap_or_default();

    From::from(result.into())
}

hard code Vec3::Y as the look at up direction. It would be great to have that configurable, so this package can be used in different camera setup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant