Packageorg.papervision3d.objects.primitives
Classpublic class Cube
InheritanceCube Inheritance TriangleMesh3D Inheritance Vertices3D Inheritance DisplayObject3D Inheritance DisplayObjectContainer3D Inheritance flash.events.EventDispatcher

The Cube class lets you create and display flat rectangle objects.

The rectangle can be divided in smaller segments. This is usually done to reduce linear mapping artifacts.

Dividing the Cube in the direction of the perspective or vanishing point, helps to reduce this problem. Perspective distortion dissapears when the Cube is facing straignt to the camera, i.e. it is perpendicular with the vanishing point of the scene.



Public Properties
 PropertyDefined by
  ALL : int
[static] All faces selected.
Cube
  BACK : int = 0x02
[static] Back face selection
Cube
  BOTTOM : int = 0x20
[static] Bottom face selection
Cube
 Inheritedchildren : Object
Returns the children object.
DisplayObjectContainer3D
 InheritedcontainerBlendMode : int
DisplayObject3D
 InheritedcontainerSortMode : int
DisplayObject3D
 Inheritedculled : Boolean
[internal use] Is this object culled by camera frustum?
DisplayObject3D
 Inheritedextra : Object
An object that contains user defined properties.
DisplayObject3D
 InheritedfaceLevelMode : Boolean
[static] This allows objects faces to have their own containers.
DisplayObject3D
 Inheritedfaces : Array
[internal-use]
DisplayObject3D
 Inheritedfilters : Array
DisplayObject3D
  FRONT : int = 0x01
[static] Front face selection
Cube
 Inheritedgeometry : GeometryObject3D
The GeometryObject3D object that contains the 3D definition of this instance.
DisplayObject3D
 Inheritedid : int
[read-only] Unique id of this instance.
DisplayObject3D
  LEFT : int = 0x08
[static] Left face selection
Cube
 Inheritedmaterial : MaterialObject3D
DisplayObject3D
 Inheritedmaterials : MaterialsList
The list of materials for this instance.
DisplayObject3D
 InheritedmeshSort : uint = 1
tells Mesh3D's render() method to compare the measurement choice of the user for a triangle's sorting
DisplayObject3D
 Inheritedname : String
An optional object name.
DisplayObject3D
  NONE : int = 0x00
[static] No faces selected.
Cube
 InheritednumChildren : int
Returns the number of children of this object.
DisplayObjectContainer3D
 Inheritedparent : DisplayObjectContainer3D
[read-only] Indicates the DisplayObjectContainer3D object that contains this display object.
DisplayObject3D
  RIGHT : int = 0x04
[static] Right face selection
Cube
 Inheritedroot : DisplayObjectContainer3D
[read-only] [read-only] The scene, which is the top-most displayObjectContainer3D in the tree structure.
DisplayObjectContainer3D
 InheritedrotationX : Number
Specifies the rotation around the X axis from its original orientation.
DisplayObject3D
 InheritedrotationY : Number
Specifies the rotation around the Y axis from its original orientation.
DisplayObject3D
 InheritedrotationZ : Number
Specifies the rotation around the Z axis from its original orientation.
DisplayObject3D
 Inheritedscale : Number
Sets the 3D scale as applied from the registration point of the object.
DisplayObject3D
 InheritedscaleX : Number
Sets the scale along the local X axis as applied from the registration point of the object.
DisplayObject3D
 InheritedscaleY : Number
Sets the scale along the local Y axis as applied from the registration point of the object.
DisplayObject3D
 InheritedscaleZ : Number
Sets the scale along the local Z axis as applied from the registration point of the object.
DisplayObject3D
 Inheritedscene : SceneObject3D
DisplayObject3D
 InheritedsceneX : Number
The X coordinate of a object relative to the scene coordinate system.
DisplayObject3D
 InheritedsceneY : Number
The Y coordinate of a object relative to the scene coordinate system.
DisplayObject3D
 InheritedsceneZ : Number
The Z coordinate of a object relative to the scene coordinate system.
DisplayObject3D
 Inheritedscreen : Number3D
[read-only] The coordinate of the object on screen.
DisplayObject3D
 InheritedscreenZ : Number
[internal-use] The average depth of the object faces center.
DisplayObject3D
  segments : Number3D
Number of segments per axis.
Cube
 InheritedsortedArray : Array
[static]
DisplayObject3D
  TOP : int = 0x10
[static] Top face selection
Cube
 Inheritedtransform : Matrix3D
A Matrix3D object containing values that affect the scaling, rotation, and translation of the display object.
DisplayObject3D
 InheriteduseOwnContainer : Boolean
DisplayObject3D
 Inheritedview : Matrix3D
[internal-use] A camera transformed Matrix3D object.
DisplayObject3D
 Inheritedvisible : Boolean
Whether or not the display object is visible.
DisplayObject3D
 Inheritedworld : Matrix3D
World transformation.
DisplayObject3D
 Inheritedx : Number
An Number that sets the X coordinate of a object relative to the origin of its parent.
DisplayObject3D
 Inheritedy : Number
An Number that sets the Y coordinate of a object relative to the origin of its parent.
DisplayObject3D
 Inheritedz : Number
An Number that sets the Z coordinate of a object relative to the origin of its parent.
DisplayObject3D
 InheritedZERO : DisplayObject3D
[static] Returns an empty DiplayObject3D object positioned in the center of the 3D coordinate system (0, 0 ,0).
DisplayObject3D
Protected Properties
 PropertyDefined by
 Inherited_children : Dictionary
[internal-use] Names indexed by children.
DisplayObjectContainer3D
 Inherited_childrenByName : Object
[internal-use] Children indexed by name.
DisplayObjectContainer3D
 Inherited_containerBlendMode : int
DisplayObject3D
 Inherited_containerSortMode : int
DisplayObject3D
 Inherited_filters : Array
DisplayObject3D
 Inherited_scene : SceneObject3D = null
The scene where the object belongs.
DisplayObject3D
 Inherited_sorted : Array
DisplayObject3D
 Inherited_transformDirty : Boolean = false
[internal-use]
DisplayObject3D
 Inherited_useOwnContainer : Boolean
DisplayObject3D
Public Methods
 MethodDefined by
  
Cube(materials:MaterialsList, width:Number = 500, depth:Number = 500, height:Number = 500, segmentsS:int = 1, segmentsT:int = 1, segmentsH:int = 1, insideFaces:int = 0, excludeFaces:int = 0, initObject:Object = null)
Create a new Cube object.
Cube
 Inherited
addChild(child:DisplayObject3D, name:String = null):DisplayObject3D
Adds a child DisplayObject3D instance to this DisplayObjectContainer instance.
DisplayObject3D
 Inherited
Adds all the children of a DisplayObject3D instance to this DisplayObjectContainer instance.
DisplayObjectContainer3D
 Inherited
addCollada(filename:String, materials:MaterialsList = null, scale:Number = 1):void
This method has been deprecated.
DisplayObjectContainer3D
 Inherited
addGeometry(geometry:GeometryObject3D = null):void
Adds a geometry definition to the instance.
DisplayObject3D
 Inherited
boundingBox():Object
Calculates 3D bounding box.
Vertices3D
 Inherited
childrenList():String
Returns a string value with the list of objects.
DisplayObjectContainer3D
 Inherited
copyPosition(reference:*):void
Copies the position information (x, y and z coordinates) from another object or Matrix3D.
DisplayObject3D
 Inherited
copyTransform(reference:*):void
Copies the transformation information (position, rotation and scale) from another object or Matrix3D.
DisplayObject3D
 Inherited
Gets the distance to the position of the given object.
DisplayObject3D
 Inherited
Returns the child display object that exists with the specified name.
DisplayObjectContainer3D
 Inherited
Returns the material that exists with the specified name in the materials list.
DisplayObject3D
 Inherited
hitTestObject(obj:DisplayObject3D, multiplier:Number = 1):Boolean
Evaluates the display object to see if it overlaps or intersects with the obj display object.
DisplayObject3D
 Inherited
hitTestPoint(x:Number, y:Number, z:Number):Boolean
Evaluates the display object to see if it overlaps or intersects with the point specified by the x, y and z parameters.
DisplayObject3D
 Inherited
lookAt(targetObject:DisplayObject3D, upAxis:Number3D = null):void
Make the object look at a specific position.
DisplayObject3D
 Inherited
materialsList():String
Returns a string value with the list of material names of the materials list.
DisplayObject3D
 Inherited
Merges duplicated vertices.
TriangleMesh3D
 Inherited
moveBackward(distance:Number):void
Translate the display object in the opposite direction it is facing, i.e.
DisplayObject3D
 Inherited
moveDown(distance:Number):void
Translate the display object downwards, with respect to the direction it is facing, i.e.
DisplayObject3D
 Inherited
moveForward(distance:Number):void
Translate the display object in the direction it is facing, i.e.
DisplayObject3D
 Inherited
moveLeft(distance:Number):void
Translate the display object lateraly, to the left of the direction it is facing, i.e.
DisplayObject3D
 Inherited
moveRight(distance:Number):void
Translate the display object lateraly, to the right of the direction it is facing, i.e.
DisplayObject3D
 Inherited
moveUp(distance:Number):void
Translate the display object upwards, with respect to the direction it is facing, i.e.
DisplayObject3D
 Inherited
pitch(angle:Number):void
Rotate the display object around its lateral or transverse axis —an axis running from the pilot's left to right in piloted aircraft, and parallel to the wings of a winged aircraft; thus the nose pitches up and the tail down, or vice-versa.
DisplayObject3D
 Inherited
project(parent:DisplayObject3D, renderSessionData:RenderSessionData):Number
Projects three dimensional coordinates onto a two dimensional plane to simulate the relationship of the camera to subject.
TriangleMesh3D
 Inherited
projectFrustum(parent:DisplayObject3D, renderSessionData:RenderSessionData):Number
Vertices3D
 Inherited
projectTexture(u:String = "x", v:String = "y"):void
Planar projection from the specified plane.
TriangleMesh3D
 Inherited
quarterFaces():void
Divides all faces into 4.
TriangleMesh3D
 Inherited
Removes the specified child DisplayObject3D instance from the child list of the DisplayObjectContainer3D instance.
DisplayObjectContainer3D
 Inherited
Removes the child DisplayObject3D instance that exists with the specified name, from the child list of the DisplayObjectContainer3D instance.
DisplayObjectContainer3D
 Inherited
roll(angle:Number):void
Rotate the display object around the longitudinal axis —an axis drawn through the body of the vehicle from tail to nose in the normal direction of flight, or the direction the object is facing.
DisplayObject3D
 Inherited
toString():String
Returns a string value representing the three-dimensional position values of the display object instance.
DisplayObject3D
 Inherited
transformVertices(transformation:Matrix3D):void
Vertices3D
 Inherited
translate(distance:Number, axis:Number3D):void
Move the object along a given direction.
DisplayObject3D
 Inherited
yaw(angle:Number):void
Rotate the display object around about the vertical axis —an axis drawn from top to bottom.
DisplayObject3D
Protected Methods
 MethodDefined by
 Inherited
[internal-use] Updates the transform Matrix3D with the current rotation and scale values.
DisplayObject3D
Public Constants
 ConstantDefined by
 InheritedMESH_SORT_CENTER : uint = 1
[static] tells Mesh3D's render() method to sort by measuring from the center of a triangle
DisplayObject3D
 InheritedMESH_SORT_CLOSE : uint = 3
[static] tells Mesh3D's render() method to sort by measuring from the closest point of a triangle
DisplayObject3D
 InheritedMESH_SORT_FAR : uint = 2
[static] tells Mesh3D's render() method to sort by measuring from the farthest point of a triangle
DisplayObject3D
Property detail
ALLproperty
public static var ALL:int

All faces selected.

BACKproperty 
public static var BACK:int = 0x02

Back face selection

BOTTOMproperty 
public static var BOTTOM:int = 0x20

Bottom face selection

FRONTproperty 
public static var FRONT:int = 0x01

Front face selection

LEFTproperty 
public static var LEFT:int = 0x08

Left face selection

NONEproperty 
public static var NONE:int = 0x00

No faces selected.

RIGHTproperty 
public static var RIGHT:int = 0x04

Right face selection

segmentsproperty 
public var segments:Number3D

Number of segments per axis. Defaults to 1.

TOPproperty 
public static var TOP:int = 0x10

Top face selection

Constructor detail
Cube()constructor
public function Cube(materials:MaterialsList, width:Number = 500, depth:Number = 500, height:Number = 500, segmentsS:int = 1, segmentsT:int = 1, segmentsH:int = 1, insideFaces:int = 0, excludeFaces:int = 0, initObject:Object = null)

Create a new Cube object.

Parameters
materials:MaterialsList — A MaterialObject3D object that contains the material properties of the object. Supported materials are: front, back, right, left, top, bottom & all, for example: var materials:MaterialsList = new MaterialsList( { all: new MovieAssetMaterial( "Front", true ), // This is the default material front: new MovieAssetMaterial( "Front", true ), back: new MovieAssetMaterial( "Back", true ), right: new MovieAssetMaterial( "Right", true ), left: new MovieAssetMaterial( "Left", true ), top: new MovieAssetMaterial( "Top", true ), bottom: new MovieAssetMaterial( "Bottom", true ) } );

 
width:Number (default = 500) — [optional] - Desired width.

 
depth:Number (default = 500) — [optional] - Desired depth.

 
height:Number (default = 500) — [optional] - Desired height.

 
segmentsS:int (default = 1) — [optional] - Number of segments sagitally (plane perpendicular to width). Defaults to 1.

 
segmentsT:int (default = 1) — [optional] - Number of segments transversally (plane perpendicular to depth). Defaults to segmentsS.

 
segmentsH:int (default = 1) — [optional] - Number of segments horizontally (plane perpendicular to height). Defaults to segmentsS.

 
insideFaces:int (default = 0) — [optional] - Faces that are visible from the inside. Defaults to Cube.NONE. You can add or sustract faces to your selection. For examples: Cube.FRONT+Cube.BACK or Cube.ALL-Cube.Top.

 
excludeFaces:int (default = 0) — [optional] - Faces that will not be created. Defaults to Cube.NONE. You can add or sustract faces to your selection. For examples: Cube.FRONT+Cube.BACK or Cube.ALL-Cube.Top.

 
initObject:Object (default = null) — [optional] - An object that contains user defined properties with which to populate the newly created GeometryObject3D.

It includes x, y, z, rotationX, rotationY, rotationZ, scaleX, scaleY scaleZ and a user defined extra object.

If extra is not an object, it is ignored. All properties of the extra field are copied into the new instance. The properties specified with extra are publicly available.