Skip to content

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