Jump to content
Search Community

How to make a square rotate in 3D around its own axis, respecting perspective with GSAP?

ramonbjj
Moderator Tag

Go to solution Solved by Rodrigo,

Recommended Posts

Posted

Hi everyone,

 

I’m trying to create a 3D animation with GSAP where a square rotates like a disk, respecting the perspective. The square is tilted with rotationX and rotationY, but I want it to rotate around its own Z-axis in 3D, like spinning on its edges.

 

The rotation currently feels flat and clockwise, and I want it to rotate in the direction of the square itself, taking the 3D perspective into account.

 

Any tips on how to achieve this?

 

Thanks in advance!

 

Codepen: 

See the Pen pvoEKaX by ramonv (@ramonv) on CodePen.

  • Solution
Posted

Hi @ramonbjj and welcome to the GSAP Forums!

 

The simplest and easiest way is to wrap the element with another, tilt that parent element and rotate the one inside. Something like this:

See the Pen gbOwdRM by GreenSock (@GreenSock) on CodePen.

 

Hopefully this helps

Happy Tweening!

Posted
38 minutes ago, Rodrigo said:

Hi @ramonbjj and welcome to the GSAP Forums!

 

The simplest and easiest way is to wrap the element with another, tilt that parent element and rotate the one inside. Something like this:

 

 

 

Hopefully this helps

Happy Tweening!

Nailed it, thank you! I've updated my code using your solution, that's exactly what I needed.


See the Pen pvoEKaX by ramonv (@ramonv) on CodePen.

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.
×
×
  • Create New...