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

Rotate to point? #44

Closed
Pandan opened this issue May 22, 2019 · 0 comments
Closed

Rotate to point? #44

Pandan opened this issue May 22, 2019 · 0 comments

Comments

@Pandan
Copy link

Pandan commented May 22, 2019

Hi!
Thanks for a great library and contribution to the Three community.

Previously is was using the Three example OrbitControl, but since this library have more features, especially animations I am trying it out.
For my project I have sphere which the camera is orbiting around. Depending on user inputs I want to move the camera targeting different points(cities) that are displayed on the sphere(globe).
Perviously I was handling this, picking up the position of the point and calculating the new camera position. Whit this code;

targetClicked() {
   const pos = this.target.position;
   const camDistance = this.camera.position.length();
   this.camera.position.copy(point).normalize().multiplyScalar(camDistance);
   this.controls.update();
}

But is there away to calculate the target; azimuthAngle, polarAngle and use your rotateTo()?

[EDIT]
Sorry for disturbing. I found a solution.
It was a bit to simple, just using .setPosition() with my previous code.

targetClicked() {
   const pos = this.target.position.clone();
   const camDistance = this.camera.position.length();
   pos.normalize().multiplyScalar(camDistance);
   this.controls.setPosition(pos.x, pos.y, pos.z, true);
@Pandan Pandan closed this as completed May 22, 2019
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

No branches or pull requests

1 participant