Using tweenlite to tween 3d coordinates

1.4k views Asked by At

im trying to tween a sprite to new 3D coordinates (x,y,z) using AS3 and i would like to use TweenLite to do it but i don't know how?

Im not a very experienced programmer, i only started to tackle the 3d possibilities of flash 10 and Tweenlite has been really helpful so far for my animations.

I've been trying to use the QuaternionsPlugin like this:

TweenLite.to(myMc, 2, {quaternions:{orientation:new Quaternion(x, y, z, w)}});

There's the x,y,z properties but i couldn't figure out what w stand for. I tried an example with the Sprite class below but when i compile it, it says : 1180: Call to a possibly undefined method Quaternion.

package com{
import flash.display.*;
import flash.events.*;  
import com.greensock.TweenLite; 
import com.greensock.plugins.TweenPlugin; 
import com.greensock.plugins.QuaternionsPlugin;  

TweenPlugin.activate([QuaternionsPlugin]); //activation is permanent in the SWF, so this line only needs to be run once.

public class Carousel extends Sprite {
     public function Carousel():void {      

    }

    public function scrollUp():void{
        TweenLite.to(Mc1, 2, {quaternions:{orientation:new Quaternion(246, 244, 0, 400)}});
        TweenLite.to(Mc2, 2, {quaternions:{orientation:new Quaternion(242, 210, 70, 353)}});
    }

    public function scrollDown():void{
        TweenLite.to(Mc1, 2, {quaternions:{orientation:new Quaternion(242, 290, 60, 360)}});
        TweenLite.to(Mc2, 2, {quaternions:{orientation:new Quaternion(246, 244, 0, 400)}});
    }
}

}

Thanks for any hint/help, really!

1

There are 1 answers

1
Chunky Chunk On BEST ANSWER

the Quanternion object is from PaperVision3D's math class. "w" is for the angle of rotation and a quaternion guarantees the the most efficient path for the rotation.

Vector3D objects have w properties. Matrix3D's interpolate() method uses quaternions, so you could tween using Matrix3D's intropolate() or transformVector() methods, or you could simply tween the x, y, and z properties of your display object - assuming you don't require the absolute most efficient rendering.