Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
Tommaso Mastroberardino

Rotating camera around an object

Recommended Posts

Hi everyone

 

I've started yesterday playing around with GSAP for work and so far i'm having a lot of fun :D.

My objective is to have a simple 3d object at the center of my scene and a camera to rotate around it. So far so good.

 

But i'm having trouble implementing a reset function for the camera, when a button is clicked the camera should go back to the starting position with an animation.

 

https://jsfiddle.net/tomthebearded/dkug68to/

 

As you can see when you run the jsfiddle what i've tried until now is changing the position of the camera with gsap.to but it's not right effect for my project. Changing the position in this way makes the camera basically move close to the center before moving out to reach the final position.

What i need is more a rotation around the object to reach a defined position. 

 

Is there a way to achieve this?

 

Link to comment
Share on other sites

Thank you @Cassie

 

But it's my understanding that the autoRotate it's only for infinite rotation and it's linear. Instead i need to rotate to a specific position and stop.

Link to comment
Share on other sites

Since you're tweening x/y/z values the camera will move in a straight line from point a to b, you'll need to math the arc, and setup an onUpdate, or perhaps motionPath would be an easier solution to accommodate this.

Link to comment
Share on other sites

5 minutes ago, elegantseagulls said:

Thank you 

 

The first link seems to be about rotating a camera on itself to look at another object. Not my case.

The second is about rotation on user input (dragging the camera) but i had no problem implementing this part.

 

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×