I haven't tested your code, but i see in path definition an error that
might be teh triiger of the error
the Path needs CurveSegments objects, this is at least how its stores
the path data internally.
the CurveSegemt objects do require 3 Numbers3D's
compare the system to the curveTo native of flash, its also requires 3
params
k, so back to your code.
//path definition
var aPath:Array = [
new Number3D(-1000, -1000, -2000),
new Number3D(-1000, 0, 0),
new Number3D(1000, 0, 0),
new Number3D(1000, 1000, -2000)];
var p:Path = new Path(aPath);
should be
//path definition
var aPath:Array = [
new Number3D(-1000, -1000, -2000), --> start poit first segment
new Number3D(-1000, 0, 0), --> directional point first segment
new Number3D(1000, 0, 0), --> end point first segment
3 params: ok
and now things go wrong
new Number3D(1000, 1000, -2000)];
you miss 2 points!
the second segment must first start with last point of previous one
new Number3D(1000, 0, 0),
a directional point
new Number3D(1000, 500, -1000);
and the last point
new Number3D(1000, 1000, -2000)];
I have no idea what the curve must look like, but i'm sure that if you
respect the rule
of 3 params, you will get no errors, and the animation will follow
your curve
if you write a loop, the repeats of the third params for the next one,
is just a matter of saving the Number3D instance, instead
of making new ones, for your curve its not a big problem, but if your
curve are complex, you better reuse instead of creating new ones.
I hope this is the fix to your problem.
Fabrice
On Jun 27, 2009, at 4:27 PM, fran wrote:
Hello, I'm trying to use the PathAnimator (http://away3d.com/
tutorials/
tutorial-how-to-use-the-pathanimator-class). Flash (cs4, v10 player,
away 3.3.3), is complaining about referencing to a null object,
here's the code i'm using:
import away3d.animators.PathAnimator;
import away3d.animators.data.Path;
import away3d.containers.*;
import away3d.core.base.*;
import away3d.primitives.*;
import away3d.core.math.*;
import away3d.materials.*;
//setup
var view:View3D = new View3D({x:300, y:200});
addChild(view);
//path definition
var aPath:Array = [
new Number3D(-1000, -1000, -2000),
new Number3D(-1000, 0, 0),
new Number3D(1000, 0, 0),
new Number3D(1000, 1000, -2000)];
var p:Path = new Path(aPath);
//object to travel path
var mat:IMaterial = new BitmapMaterial(new BitmapData(64,64, false,
0xFF0000));
this.cube = new Cube({material:mat, width:200, height:80, depth:100});
view.scene.addChild(this.cube);
//animator definition
var init:Object = { duration:5000,
lookat:false,
aligntopath:true,
targetobject:null,
offset:new Number3D(0,100,0),
rotations:null,
fps:24,
easein:false ,
easeout:false};
//var pathanimator = new PathAnimator
var pathanimator = new PathAnimator(p, this.cube, init);
//cube @ 50% of path
this.pathanimator.update(0.5);
view.camera.lookAt(this.cube.position);
view.render();
According to debugger, offending line is:
this.pathanimator.update(0.5);
What am I doing wrong?
Thanks in advance.
Fran.