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

OrbitControls: add getDistance() #22126

Merged
merged 3 commits into from
Jul 25, 2021
Merged

OrbitControls: add getDistance() #22126

merged 3 commits into from
Jul 25, 2021

Conversation

marcofugaro
Copy link
Contributor

Related issue: remake of #21162

Description

Add OrbitControls.getDistance() which exposes spherical.radius.

This is useful for example if you want to enable zooming in but disable zooming out from the start position:

const controls = new OrbitControls(camera, renderer.domElement);
const currentDistance = controls.getDistance();
controls.maxDistance = currentDistance;

@WestLangley
Copy link
Collaborator

I do not think these internals should be exposed, but at a minimum, methods must return the correct answer. In this case, that includes orthographic camera.

@WestLangley
Copy link
Collaborator

This PR does not produce the correct answer for orthographic camera.

Why not compute the distance to the target and return the result?

@marcofugaro
Copy link
Contributor Author

@WestLangley I treated getDistance exactly like minDistance and maxDistance. They are not available for orthographic camera as well. Should those be changed as well in your opinion?

@WestLangley
Copy link
Collaborator

@marcofugaro No, I would just focus on this PR. If you compute the actual distance, the returned value will be correct.

I personally prefer no method to one that can return the incorrect answer.

@marcofugaro
Copy link
Contributor Author

@WestLangley done, how does it look now?

@marcofugaro
Copy link
Contributor Author

All done!

@WestLangley WestLangley added this to the r131 milestone Jul 22, 2021
@mrdoob mrdoob merged commit ae4a7c4 into mrdoob:dev Jul 25, 2021
@mrdoob
Copy link
Owner

mrdoob commented Jul 25, 2021

Thanks!

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

Successfully merging this pull request may close these issues.

4 participants