package {
import away3d.animators.PathAnimator;
import away3d.animators.data.Path;
import away3d.cameras.Camera3D;
import away3d.containers.View3D;
import away3d.core.math.Number3D;
import away3d.extrusions.PathExtrude;
import away3d.primitives.Cube;
import flash.display.Sprite;
import flash.events.Event;
public class PathAnimatorTest extends Sprite
{
private var view:View3D;
private var cam:Camera3D;
private var cube:Cube;
private var animator:PathAnimator;
private var _path:Path
private var ext:PathExtrude;
private var inc:Number = 0;
public function PathAnimatorTest()
{
init();
}
private function init():void
{
cam = new Camera3D;
cam.z = -2000;
cam.moveUp(2000);
cam.lookAt(new Number3D(0,0,700));
cube = new Cube();
cube.x = 100;
view = new View3D();
view.x = 200;
view.y = 200;
view.camera = cam;
this.view.scene.addChild(cube);
this.addChild(view);
_path = new Path([new Number3D(0,0,0), new
Number3D(0,0,0),new
Number3D(0,0,0),null,new Number3D(0,0,0),new Number3D(0,0,5000)]);
ext = new PathExtrude(_path,[new Number3D(100,0,0),new
Number3D
(-100,0,0)],null,null,null);
this.view.scene.addChild(ext);
this.animator = new PathAnimator(this._path, this.cube,
{lookat:false, aligntopath:false});
this.addEventListener(Event.ENTER_FRAME, enterFrame);
}
private function enterFrame(e:Event):void
{
//inc += 0.1;
this.animator.update(0);
view.render();
cube.rotationX++;
}
}
}
On Jan 20, 5:19 am, Patrick <[email protected]> wrote:
> Hi All,
>
> I am having a problem to animate an object along a path. I followed
> Fabrice's tutorial.
>
> When I call the update method in the render loop and pass a value 0
> the object, in my case a cube, is positioned at the beginning of the
> path. If I change the value passed to anything other than 0 but still
> below 1, the code breaks.
>
> Why is pathAnimator.update(0); working,
>
> but pathAnimator.update(0.5); not?
>
> Any answers will be appreciated. :)
>
> Thanks, Patrick