Packageflash.geom
Classpublic class Utils3D
InheritanceUtils3D Inheritance Object

Language version: ActionScript 3.0
Runtime version: AIR 1.5

The Utils3D class contains static methods that simplify the implementation of certain three-dimensional matrix operations.

See also

flash.geom.Matrix3D
flash.geom.Vector3D
flash.geom.Transform
flash.geom.PerspectiveProjection
flash.display.Graphics
flash.display.GraphicsTrianglePath
Vector


Public Properties
 PropertyDefined by
 Inheritedconstructor : Object
A reference to the class object or constructor function for a given object instance.
Object
 Inheritedprototype : Object
[static] A reference to the prototype object of a class or function object.
Object
Public Methods
 MethodDefined by
 Inherited
Indicates whether an object has a specified property defined.
Object
 Inherited
Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter.
Object
  
pointTowards(percent:Number, mat:Matrix3D, pos:Vector3D, at:Vector3D = null, up:Vector3D = null):Matrix3D
[static] Interpolates the orientation of an object toward a position.
Utils3D
  
pointTowardsToOutput(percent:Number, mat:Matrix3D, pos:Vector3D, at:Vector3D = null, up:Vector3D = null, output:Matrix3D = null):Matrix3D
[static] Interpolates the orientation of an object toward a position.
Utils3D
  
[static] Using a projection Matrix3D object, projects a Vector3D object from one space coordinate to another.
Utils3D
  
projectVectors(m:Matrix3D, verts:Vector.<Number>, projectedVerts:Vector.<Number>, uvts:Vector.<Number>):void
[static] Using a projection Matrix3D object, projects a Vector of three-dimensional space coordinates (verts) to a Vector of two-dimensional space coordinates (projectedVerts).
Utils3D
  
[static] Using a projection Matrix3D object, projects a Vector3D object from one space coordinate to another.
Utils3D
 Inherited
Indicates whether the specified property exists and is enumerable.
Object
 Inherited
Sets the availability of a dynamic property for loop operations.
Object
 Inherited
Returns the string representation of this object, formatted according to locale-specific conventions.
Object
 Inherited
Returns the string representation of the specified object.
Object
 Inherited
Returns the primitive value of the specified object.
Object
Method detail
pointTowards()method
public static function pointTowards(percent:Number, mat:Matrix3D, pos:Vector3D, at:Vector3D = null, up:Vector3D = null):Matrix3D

Language version: ActionScript 3.0
Runtime version: AIR 1.5

Interpolates the orientation of an object toward a position. The pointTowards() method combines the functionality of the Matrix3D.pointAt() and Matrix3D.interpolateTo() methods.

The pointTowards() method allows for in-place modification to the orientation. It decomposes the Matrix3D of the display object and replaces the rotation elements by ones that make a percent turn toward the position of the target. The object can make an incremental turn toward the target while still moving in its own direction. The consecutive calls to the pointTowards() followed by a translation method can produce the animation of an object chasing or following a moving target. First point the object a percent point toward the target, then incrementally move the object along an axis.

Parameters
percent:Number — A Number between 0 and 1 that incrementally turns the object toward the target.
 
mat:Matrix3D — The Matrix3D property of the object that is transformed.
 
pos:Vector3D — The world-relative position of the target object. World-relative defines the transformation of the object relative to the world space and coordinates, where all objects are positioned.
 
at:Vector3D (default = null) — The object-relative vector that defines where the display object is pointing. Object-relative defines the transformation of the object relative to the object space, the object's own frame of reference and coordinate system. Default value is (0,0,-1).
 
up:Vector3D (default = null) — The object-relative vector that defines "up" for the display object. If the object is drawn looking down from the above, the +z axis is its "up" vector. Object-relative defines the transformation of the object relative to the object space, the object's own frame of reference and coordinate system. Default value is (0,-1,0).

Returns
Matrix3D — A modified version of the Matrix3D object specified in the second parameter. To transform the display object using the pointTowards() method, set the Matrix3D property of the display object to the returned Matrix3D object.

See also

pointTowardsToOutput()method 
public static function pointTowardsToOutput(percent:Number, mat:Matrix3D, pos:Vector3D, at:Vector3D = null, up:Vector3D = null, output:Matrix3D = null):Matrix3D

Language version: ActionScript 3.0
Runtime version: AIR 33.1

Interpolates the orientation of an object toward a position. The pointTowards() method combines the functionality of the Matrix3D.pointAt() and Matrix3D.interpolateTo() methods.

The pointTowards() method allows for in-place modification to the orientation. It decomposes the Matrix3D of the display object and replaces the rotation elements by ones that make a percent turn toward the position of the target. The object can make an incremental turn toward the target while still moving in its own direction. The consecutive calls to the pointTowards() followed by a translation method can produce the animation of an object chasing or following a moving target. First point the object a percent point toward the target, then incrementally move the object along an axis.

Parameters
percent:Number — A Number between 0 and 1 that incrementally turns the object toward the target.
 
mat:Matrix3D — The Matrix3D property of the object that is transformed.
 
pos:Vector3D — The world-relative position of the target object. World-relative defines the transformation of the object relative to the world space and coordinates, where all objects are positioned.
 
at:Vector3D (default = null) — The object-relative vector that defines where the display object is pointing. Object-relative defines the transformation of the object relative to the object space, the object's own frame of reference and coordinate system. Default value is (0,0,-1).
 
up:Vector3D (default = null) — The object-relative vector that defines "up" for the display object. If the object is drawn looking down from the above, the +z axis is its "up" vector. Object-relative defines the transformation of the object relative to the object space, the object's own frame of reference and coordinate system. Default value is (0,-1,0).
 
output:Matrix3D (default = null) — An optional Matrix3D object that will be used for the output rather than creating a new Matrix3D object

Returns
Matrix3D — A modified version of the Matrix3D object specified in the second parameter. To transform the display object using the pointTowards() method, set the Matrix3D property of the display object to the returned Matrix3D object.

See also

projectVector()method 
public static function projectVector(m:Matrix3D, v:Vector3D):Vector3D

Language version: ActionScript 3.0
Runtime version: AIR 1.5

Using a projection Matrix3D object, projects a Vector3D object from one space coordinate to another. The projectVector() method is like the Matrix3D.transformVector() method except that the projectVector() method divides the x, y, and z elements of the original Vector3D object by the projection depth value. The depth value is the distance from the eye to the Vector3D object in view or eye space. The default value for this distance is the value of the z element.

Parameters
m:Matrix3D — A projection Matrix3D object that implements the projection transformation. If a display object has a PerspectiveProjection object, you can use the perspectiveProjection.toMatrix() method to produce a projection Matrix3D object that applies to the children of the display object. For more advance projections, use the matrix3D.rawData property to create a custom projection matrix. There is no built-in Matrix3D method for creating a projection Matrix3D object.
 
v:Vector3D — The Vector3D object that is projected to a new space coordinate.

Returns
Vector3D — A new Vector3D with a transformed space coordinate.

See also

projectVectors()method 
public static function projectVectors(m:Matrix3D, verts:Vector.<Number>, projectedVerts:Vector.<Number>, uvts:Vector.<Number>):void

Language version: ActionScript 3.0
Runtime version: AIR 1.5

Using a projection Matrix3D object, projects a Vector of three-dimensional space coordinates (verts) to a Vector of two-dimensional space coordinates (projectedVerts). The projected Vector object should be pre-allocated before it is used as a parameter.

The projectVectors() method also sets the t value of the uvt data. You should pre-allocate a Vector that can hold the uvts data for each projected Vector set of coordinates. Also specify the u and v values of the uvt data. The uvt data is a Vector of normalized coordinates used for texture mapping. In UV coordinates, (0,0) is the upper left of the bitmap, and (1,1) is the lower right of the bitmap.

This method can be used in conjunction with the Graphics.drawTriangles() method and the GraphicsTrianglePath class.

Parameters
m:Matrix3D — A projection Matrix3D object that implements the projection transformation. You can produce a projection Matrix3D object using the Matrix3D.rawData property.
 
verts:Vector.<Number> — A Vector of Numbers, where every three Numbers represent the x, y, and z coordinates of a three-dimensional space, like Vector3D(x,y,z).
 
projectedVerts:Vector.<Number> — A vector of Numbers, where every two Numbers represent a projected two-dimensional coordinate, like Point(x,y). You should pre-allocate the Vector. The projectVectors() method fills the values for each projected point.
 
uvts:Vector.<Number> — A vector of Numbers, where every three Numbers represent the u, v, and t elements of the uvt data. The u and v are the texture coordinate for each projected point. The t value is the projection depth value, the distance from the eye to the Vector3D object in the view or eye space. You should pre-allocate the Vector and specify the u and v values. The projectVectors method fills the t value for each projected point.

See also

projectVectorToOutput()method 
public static function projectVectorToOutput(m:Matrix3D, v:Vector3D, output:Vector3D):Vector3D

Language version: ActionScript 3.0
Runtime version: AIR 33.1

Using a projection Matrix3D object, projects a Vector3D object from one space coordinate to another. The projectVector() method is like the Matrix3D.transformVector() method except that the projectVector() method divides the x, y, and z elements of the original Vector3D object by the projection depth value. The depth value is the distance from the eye to the Vector3D object in view or eye space. The default value for this distance is the value of the z element.

Parameters
m:Matrix3D — A projection Matrix3D object that implements the projection transformation. If a display object has a PerspectiveProjection object, you can use the perspectiveProjection.toMatrix() method to produce a projection Matrix3D object that applies to the children of the display object. For more advance projections, use the matrix3D.rawData property to create a custom projection matrix. There is no built-in Matrix3D method for creating a projection Matrix3D object.
 
v:Vector3D — The Vector3D object that is projected to a new space coordinate.
 
output:Vector3D — An optional Vector3D object that will be used for the output rather than creating a new Vector3D object

Returns
Vector3D — A new Vector3D with a transformed space coordinate.

See also