-
-
Notifications
You must be signed in to change notification settings - Fork 35.2k
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
Fix TransformControl zoom for OrthographicCamera #19116
Conversation
Can you make the code like this? var eyeDistance;
if ( camera.isOrthographicCamera ) {
eyeDistance = 1000 / this.camera.zoom;
} else {
eyeDistance = this.worldPosition.distanceTo( this.cameraPosition );
} |
/cc @WestLangley @arodic |
This is a comment about the formatting only -- not the patch itself. var eyeDistance = camera.isOrthographicCamera ? 1000 / this.camera.zoom : this.worldPosition.distanceTo( this.cameraPosition ); |
Yes. I thought about both suggested options. Which is more preferable? |
Lets go with @WestLangley's. |
Done and verified in my project. |
Looks good to me |
Thanks! |
This is a red flag that the implementation is not correct. For example, try the fiddle in #19158 using the dev branch (not master) and an orthographic camera. It is unusable. /ping @arodic |
Yeah, it looks like magic number wont work. I'll fix. Please re-open this issue. |
Submitted a fix for this issue #19163 |
When OrthographcCamera is used together with OrbitControls TransformControls graphical representation is not scaled correctly. This is because TransformControls was originally written for the PerspectiveCamera, where scaling is done by positioning camera further or closer to the object.
For the orthographic projection this doesn't work, because camera position is always infinitely far away from the object, so zoom factor should be used instead.
The fix contains "magical number" 1000. This was selected by experiment, but it can be changed, if there is a good reason.
Current shape of the control with control size = 1: