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

Orbit Controls distance was not included in modifiers #325

Open
jasonsturges opened this issue Dec 13, 2023 · 4 comments
Open

Orbit Controls distance was not included in modifiers #325

jasonsturges opened this issue Dec 13, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@jasonsturges
Copy link

jasonsturges commented Dec 13, 2023

Why was setting distance left out of Orbit Controls?

API provides access via:

  • getAzimuthalAngle
  • getDistance
  • getPolarAngle

But only mutates via:

  • setAzimuthalAngle
  • setPolarAngle

this.setPolarAngle = (value: number): void => {
// use modulo wrapping to safeguard value
let phi = moduloWrapAround(value, 2 * Math.PI)
let currentPhi = spherical.phi
// convert to the equivalent shortest angle
if (currentPhi < 0) currentPhi += 2 * Math.PI
if (phi < 0) phi += 2 * Math.PI
let phiDist = Math.abs(phi - currentPhi)
if (2 * Math.PI - phiDist < phiDist) {
if (phi < currentPhi) {
phi += 2 * Math.PI
} else {
currentPhi += 2 * Math.PI
}
}
sphericalDelta.phi = phi - currentPhi
scope.update()
}
this.setAzimuthalAngle = (value: number): void => {
// use modulo wrapping to safeguard value
let theta = moduloWrapAround(value, 2 * Math.PI)
let currentTheta = spherical.theta
// convert to the equivalent shortest angle
if (currentTheta < 0) currentTheta += 2 * Math.PI
if (theta < 0) theta += 2 * Math.PI
let thetaDist = Math.abs(theta - currentTheta)
if (2 * Math.PI - thetaDist < thetaDist) {
if (theta < currentTheta) {
theta += 2 * Math.PI
} else {
currentTheta += 2 * Math.PI
}
}
sphericalDelta.theta = theta - currentTheta
scope.update()
}

Relates to three.js mrdoob/three.js#22174, mrdoob/three.js#22836

@jasonsturges jasonsturges added the enhancement New feature or request label Dec 13, 2023
@dustinlacewell
Copy link

Bump.

@CodyJasonBennett
Copy link
Member

You're welcome to make a PR while I'm out. Reminder this is open source and not a commercial forum with a dedicated staff. That said, this doesn't look too bad, just make sure that orthographic camera has its zoom modified since z position has no effect on a parallel projection.

@dustinlacewell
Copy link

Sorry, wasn't implying this should've been taken care of, but rather looking to see if there was an answer to OP's question. There may have been a good reason it was left out!

@jasonsturges
Copy link
Author

I believe there was a pull request on this that was never merged. Presumably had some issue.

Just noting there is no setDistance, which would be nice and complete the provided API.

Appreciate the orthographic camera tip - if I get a chance I'll take a stab at it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants