To understand the positional relationship between objects in Away3D, first create a coordinate system and three planes. The coordinate system has been encapsulated as a Trident class in Away3D and can be called directly:
var tri:Trident = new Trident(400, true);scene.addChild(tri);
The first parameter is the length of the coordinate axis, and the second parameter is the letter of the coordinate axis.
There are three Coordinate Planes. Here, the GridPlane class is better.
var p1:GridPlane = new GridPlane();p1.width = 800;p1.height = 800;p1.segmentsH = 2;p1.segmentsW = 2;p1.material = new WireframeMaterial(0xff0000);scene.addChild(p1);
Create two other planes by rotating them.
The center point of the ry created by Away3D is in its ry center. To change this point, you need to use the movePivot method. The movePivot method requires the coordinate parameter, which is relative to the center point of the ry, that is, local coordinates. Put a cube of 100*100*100 in the First quadrant, you can write:
cube.movePivot( -50, -50, -50);
Then the rotating axis of the object is changed to the three coordinate axes corresponding to the center.
In practical applications, moveForward and moveBackward are commonly used to control object positions. Their corresponding moving directions are:
MoveForward: Forward to the Z axis
MoveBackward: negative to the Z axis
MoveLeft: negative to the X axis
MoveRight: Forward to the X axis
MoveUp: forward to Y axis
MoveDown: Negative to Y axis
Three rotation functions are required:
Pitch: clockwise around the X axis
Yaw: clockwise around the Y axis
Roll: clockwise around the Z axis
Clockwise refers to looking at the direction of the specified axis. Since the nine functions can also contain negative parameters, there are actually only six functions that control the Six Degrees of Freedom of an object.
The advantage of using these functions is that they will adapt to the new local coordinate system with the object location.