package geometry._theory { import away3d.primitives.Sphere; import flash.geom.Vector3D; import triga.shapes.Axis; import triga.shapes.Label; import triga.shapes.Tick; import triga.shapes.XYZ; /** * @author Nicolas Barradeau * http://en.nicoptere.net */ public class A_VectorProperties extends BaseScene { private var point3d:Tick; public function A_VectorProperties() { cameraDistance = -250; setup(); addChild( GlobalTextField.instance ); var vector3D:Vector3D = new Vector3D( 50, 50, 50 ); //the classic X/Y/Z _trace( 'vector.x', vector3D.x ); _trace( 'vector.y', vector3D.y ); _trace( 'vector.z', vector3D.z ); //and an extra param: W... WTF! _trace( 'vector.w', vector3D.w ); /** * The fourth element of a Vector3D object (in addition to the x, y, * and z properties) can hold data such as the angle of rotation. The default value is 0. * * Quaternion notation employs an angle as the fourth element in its calculation of * three-dimensional rotation. The w property can be used to define the angle of rotation * about the Vector3D object. The combination of the rotation angle and the coordinates (x,y,z) * determines the display object's orientation. In addition, the w property can be used as a perspective * warp factor for a projected three-dimensional position or as a projection transform value in * representing a three-dimensional coordinate projected into the two-dimensional space. For example, * you can create a projection matrix using the Matrix3D.rawData property, that, when * applied to a Vector3D object, produces a transform value in the Vector3D object's fourth element (the * w property). Dividing the Vector3D object's other elements by the transform value * then produces a projected Vector3D object. You can use the Vector3D.project() method * to divide the first three elements of a Vector3D object by its fourth element. */ //addMesh( new XYZ(100) ); // Adobe's implementation is quite misleading: a Vector3D is both a point in 3D and a vector or a 'direction' point3d = new Tick( vector3D, 50, WHITE ) addMesh( point3d ); var sphere:Sphere = new Sphere( BLUE, Vector3D.distance( new Vector3D(), vector3D ), 64, 32 ); BLUE.alpha = .35; addMesh( sphere ); var axis:Axis = new Axis( new Vector3D(), vector3D, 1, WHITE ); addMesh( axis ); addMesh( new Label( vector3D, 'vector as\na point in 3D' ) ); addMesh( new Label( new Vector3D(), 'vector as\na direction\nfrom origin' ) ); } } }