Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
ppdc

rotate the shortest way

Recommended Posts

i set up a rotating masked wheel like this:

http://pedaci.de/geheimlabor/anim_dev/rotateWheel.html

 

now when you click the yellow and then green segments (and back) the mask spins all the way around instead of just taking the (obvious) short way.

is there a quick and easy way to correct this behaviour?

thanks.

Link to comment
Share on other sites

Sure, you can specify rotation to be clockwise, counter-clockwise or shortest distance thanks to our DirectionalRotation plugin (which happens to be baked into CSSPlugin).

TweenLite.to(element, 1, {rotation:"180_short"})  // shortest distance
TweenLite.to(element, 1, {rotation:"180_cw"}) //force clockwise rotation
TweenLite.to(element, 1, {rotation:"180_ccw"}) //force counter-clockwise rotation  

See it in action here:

http://codepen.io/GreenSock/full/jiEyG

  • Like 1
Link to comment
Share on other sites

Ahhh, thanks! I hoped you had a solution built in. Great!

Link to comment
Share on other sites

  • 4 years later...

Hello there!

 

What if I would like to to that with a variable?

 

Something like:

 

 let cameraLookatTransition = {
        x: cameraLookat.x,
        y: cameraLookat.y
      };

      let cameraActualLookat = {
        x: this.controls.getPolarAngle(),
        y: this.controls.getAzimuthalAngle()
      };



let actualTween = new TWEEN.Tween(cameraActualLookat)
      .to(cameraLookatTransition, this.easingDuration)
      .onUpdate(function(actualLookAt) {

        controls.setRotation(this.x, this.y)
      })
      .easing(TWEEN.Easing.Sinusoidal.Out)
      .start();

 

Now, this is bringing the absolute way so to say, that is, in many cases, the longest way and then it is causing my orbitCamera (threeJS) spinning really fast on a weird way.

 

is there any way to provide the Tween a kind of threshold? So, in my case, it would be 3.14 and -3.14 and then it would add or substract to go the shortest way.

 

Thanks a lot...

 

Ricardo

Link to comment
Share on other sites

  • Carl locked this topic
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×