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

Focus not on the ground? #6

Closed
tad-lispy opened this issue Apr 16, 2024 · 2 comments
Closed

Focus not on the ground? #6

tad-lispy opened this issue Apr 16, 2024 · 2 comments

Comments

@tad-lispy
Copy link
Contributor

tad-lispy commented Apr 16, 2024

Hi again! I'm trying to implement custom controls for my camera and for that I need to know where the camera is pointing at on the ground. My understanding was that the focus or target_focus contain this information, but when reading those properties I'm getting a point high above the ground (large y coordinate), even if I manually set the target focus to be at y = 0.0. It also changes when zoom is changed. I think it basically contains the current camera height. Is this intentional? Could you please advise how to get the coordinates on the ground?

My naive way of doing that is as follows, but it doesn't account for any ground topology.

let ground_focus = camera.focus.translation.xz().extend(0.0).xzy();
@Plonq
Copy link
Owner

Plonq commented Apr 16, 2024

Hi! You're correct that the target_focus is automatically adjusted and reflect the camera's height. I'll need to think about this a bit more but a hacky way to get the actual focal point is to reverse engineer it by subtracting cam.height_max.lerp(cam.height_min, cam.target_zoom) from the Y coordinate of focus or target_focus. (That's the value added to the ground surface in order to follow the ground.)

EDIT: use zoom in that lerp if using focus

@Plonq
Copy link
Owner

Plonq commented Apr 19, 2024

I have pushed 0.4.2 which contains #8. focus now isn't moved up to the camera's height and you can use it directly instead of subtracting the height from it.

@Plonq Plonq closed this as completed Apr 19, 2024
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

2 participants