Jump to content
GreenSock

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

rotate the shortest way

Recommended Posts

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 post
Share on other sites

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

Link to post
Share on other sites

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 post
Share on other sites
Guest
This topic is now closed to further replies.

  • Recently Browsing   0 members

    No registered users viewing this page.

×