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

Handle zoom while camera change #492

Merged
merged 2 commits into from
Oct 17, 2024
Merged

Conversation

arjxn-py
Copy link
Member

zoom.mov

Shall fix #483

@arjxn-py arjxn-py added bug and removed bug labels Oct 17, 2024
Copy link
Contributor

github-actions bot commented Oct 17, 2024

Integration tests repot: appsharing.space

Copy link
Contributor

github-actions bot commented Oct 17, 2024

Preview PR at appsharing.space

@@ -1323,12 +1324,17 @@ export class MainView extends React.Component<IProps, IStates> {
const width = this.divRef.current?.clientWidth || 0;
const height = this.divRef.current?.clientHeight || 0;

const distance = position.distanceTo(target);
const zoomFactor = 1000 / distance;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know why we need this magic 1000 number?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is kind of an arbitrary number after some hit and trials, I noticed that more you zoom the object in PerspectiveCamera more further it goes on OrthographicCamera

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it meant that the distance was inversely proportional to the zooming in that i needed to do

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good! I tested on my side and this seems to work well. We have other magic numbers in JupyterCAD

@martinRenou martinRenou merged commit c179bcc into jupytercad:main Oct 17, 2024
9 checks passed
@arjxn-py arjxn-py deleted the camera-zoom branch October 17, 2024 11:22
@martinRenou martinRenou added the enhancement New Feature or improvement label Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New Feature or improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Switching from perspective projection to orthogonal projection zooms out a lot
2 participants