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 · 0 comments
Open

Orbit Controls distance was not included in modifiers #325

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

Comments

@jasonsturges
Copy link

Why was setting distance left out of Orbit Controls?

API provides access via:

  • getAzimuthalAngle
  • getDistance
  • setPolarAngle

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
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

1 participant