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

feat(OrbitControls): expose zoom methods for programmatical controls #383

Merged
merged 4 commits into from
Oct 30, 2024

Conversation

NotYoojun
Copy link
Contributor

@NotYoojun NotYoojun commented Oct 24, 2024

Why

It's really necessary to programmatically control the zoom scale in OrbitControls. Not only do my projects need this but many others may want this, too.

https://stackoverflow.com/questions/43167656/programmatically-zoom-orbitcontrols
https://stackoverflow.com/questions/39856907/three-js-orbitcontrols-js-invoking-zoom-in-out-with-button-controls-dollyout
https://stackoverflow.com/questions/41198618/orbitcontrols-js-how-to-zoom-in-zoom-out

What

I added a few methods to perform the dolly operations, and programmatically control the actual zoom scale. These are not used in most scenarios, however they can be useful for specific use cases

// Not used in most scenarios, however they can be useful for specific use cases
getZoomScale: () => number

// Dolly in programmatically
dollyIn: (dollyScale?: number) => void
// Dolly out programmatically
dollyOut: (dollyScale?: number) => void
// Get the current scale
getScale: () => number
// Set the current scale (these are not used in most scenarios, however they can be useful for specific use cases)
setScale: (newScale: number) => void

Checklist

  • [?] Documentation updated
  • Ready to be merged

By the way, where should I update the document and storybook?

I really hope this can be merged and released into the latest package, please. It's really meaningful and significant to my projects. Thanks!

Copy link

codesandbox-ci bot commented Oct 24, 2024

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@NotYoojun
Copy link
Contributor Author

Anyone could take a look?

@CodyJasonBennett CodyJasonBennett changed the title feat (OrbitControls): Expose zoom methods for programmatical controls feat(OrbitControls): expose zoom methods for programmatical controls Oct 30, 2024
@CodyJasonBennett
Copy link
Member

Had my eye on this. I need to upgrade our CI, then I'll get this in.

@CodyJasonBennett CodyJasonBennett merged commit 98aaa0b into pmndrs:main Oct 30, 2024
3 checks passed
@NotYoojun
Copy link
Contributor Author

@CodyJasonBennett Thanks buddy! 😁

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.

2 participants