Hi.
I’m trying to set a DisplayObject3D as a parent to a Camera3D.
the addChild(Camera) won’t work…
So I tried to make a new class: cCameraPivot that is inherited from DisplayObject3D, but there seems to be a problem with the overriding of the properties (x, y, z, rotationX, etc. etc…)
In the overiding setter I have no access to the defined camera of the pivot.
Here is the code:
package
{
import org.papervision3d.cameras.Camera3D;
import org.papervision3d.objects.DisplayObject3D;
import org.papervision3d.core.proto.GeometryObject3D;
public class cCameraPivot extends DisplayObject3D
{
public var Cam :Camera3D;
private var camPos :DisplayObject3D;
public function cCameraPivot(camera:Camera3D, name:String = "pivot", geometry: GeometryObject3D = null)
{
super(name, geometry);
Cam = camera;
camPos = new DisplayObject3D();
camPos.copyTransform(Cam);
this.addChild(camPos);
}
public override function set x(value:Number):void {
camPos.copyTransform(Camera);
super.x = value;
Camera.copyTransform(camPos);
}
}
}
I get this message on running:
[COLOR=red]TypeError: Error #1009: Cannot access a property or method of a null object reference.[/COLOR]
[COLOR=red]at cCameraPivot/set x()[C:\Data\Projects\Treepodia\PV Test 3\src\cCameraPivot.as:27][/COLOR]
whice is the first line in the setter of X.
What can be done???
TNX