Packageaway3d.graphs.bsp
Classpublic class BSPTree
InheritanceBSPTree Inheritance ObjectContainer3D Inheritance Mesh Inheritance Object3D Inheritance flash.events.EventDispatcher

BSPTree is a scene graph structure that allows static scenes to be rendered without z-sorting or z-conflicts, and performs early culling to remove big parts of the geometry that don't need to be rendered. It also speeds up various tasks such as collision detection.

Public Properties
 PropertyDefined by
  activeLeaf : BSPNode
[read-only] The leaf containing the camera.
BSPTree
 Inheritedalpha : Number
An optional alpha value that can be applied to the 3d object.
Object3D
 InheritedanimationLibrary : AnimationLibrary
Reference container for all animations used in the container.
Object3D
 Inheritedback : Material
Defines a triangle material to be used for the backface of all faces in the 3d object.
Mesh
 InheritedblendMode : String
An optional blend mode that can be applied to the 3d object.
Object3D
 Inheritedbothsides : Boolean
Indicates whether both the front and reverse sides of a face should be rendered.
Mesh
 InheritedboundingRadius : Number
Returns the bounding radius of the 3d object
Object3D
 Inheritedcenter : Array
Object3D
 Inheritedchildren : Array
Returns the children of the container as an array of 3d objects
ObjectContainer3D
  collidedObject : Object3D
[read-only]
BSPTree
 Inheritedcollider : Boolean
Indicates whether this object is used for collision detection.
Object3D
  collisionPlane : Plane3D
[read-only] The plane against which was collided during the last call to traceCollision
BSPTree
  collisionRatio : Number
[read-only] The ratio [0, 1] on the movement line where the previous collision occurred
BSPTree
 Inheritedcommands : Array
Returns an array of the commands contained in the mesh object.
Mesh
 Inheriteddebugbb : Boolean
Indicates whether a debug bounding box should be rendered around the 3d object.
Object3D
 InheriteddebugBoundingBox : WireCube
Object3D
 InheriteddebugBoundingSphere : WireSphere
Object3D
 Inheriteddebugbs : Boolean
Indicates whether a debug bounding sphere should be rendered around the 3d object.
Object3D
 Inheritedelements : Array
Returns an array of all elements contained in the mesh object.
Mesh
 Inheritedeulers : Number3D
Defines the rotation of the 3d object as a Number3D object containing euler angles for rotation around x, y and z axis.
Object3D
 Inheritedextra : Object
An optional untyped object that can contain used-defined properties
Object3D
 Inheritedfaces : Array
Returns an array of the faces contained in the mesh object.
Mesh
 InheritedfaceVOs : Array
Returns an array of the faceVOs contained in the mesh object.
Mesh
 Inheritedfilters : Array
An optional array of filters that can be applied to the 3d object.
Object3D
 Inheritedgeometry : Geometry
Defines the geometry object used for the mesh.
Mesh
 InheritedgeometryLibrary : GeometryLibrary
Reference container for all geometries used in the container.
Object3D
 Inheritedid : int
Object3D
 Inheritedindexes : Array
Placeholder for md2 frame indexes
Mesh
 Inheritedindices : Array
Returns an array of the indices contained in the mesh object.
Mesh
 InheritedinverseSceneTransform : MatrixAway3D
Returns the inverse of sceneTransform.
Object3D
 Inheritedlightarray : ILightConsumer
returns the array of lights contained inside the container.
Object3D
 Inheritedlights : Array
Returns the lights of the container as an array of light objects
ObjectContainer3D
 Inheritedmaterial : Material
Defines the material used to render the faces, segments or 3d sprites in the geometry object.
Mesh
 InheritedmaterialLibrary : MaterialLibrary
Reference container for all materials used in the container.
Object3D
 InheritedmaxX : Number
Returns the maximum x value of the 3d object
Object3D
 InheritedmaxY : Number
Returns the maximum y value of the 3d object
Object3D
 InheritedmaxZ : Number
Returns the maximum z value of the 3d object
Object3D
 InheritedminX : Number
Returns the minimum x value of the 3d object
Object3D
 InheritedminY : Number
Returns the minimum y value of the 3d object
Object3D
 InheritedminZ : Number
Returns the minimum z value of the 3d object
Object3D
 InheritedmouseEnabled : Boolean = true
Defines whether mouse events are received on the 3d object
Object3D
 Inheritedname : String
An optional name string for the 3d object.
Object3D
 InheritedobjectDepth : Number
Boundary depth of the 3d object return The depth of the mesh
Object3D
 InheritedobjectHeight : Number
Boundary height of the 3d object return The height of the mesh
Object3D
 InheritedobjectWidth : Number
Boundary width of the 3d object return The width of the object
Object3D
 Inheritedoutline : Material
Defines a segment material to be used for outlining the 3d object.
Mesh
 InheritedownCanvas : Boolean
Defines whether the contents of the 3d object are rendered using it's own render session
Object3D
 InheritedownLights : Boolean
Defines whether the children of the container are rendered using it's own lights.
Object3D
 InheritedownSession : AbstractRenderSession
Defines a unique render session for the 3d object.
Object3D
  parent : ObjectContainer3D
[write-only]
BSPTree
 InheritedpivotPoint : Number3D
Defines the local point around which the object rotates.
Object3D
 InheritedpivotZero : Boolean
Object3D
 InheritedpolyCount : int
Returns the number of elements in the container, including elements in child nodes.
ObjectContainer3D
 Inheritedposition : Number3D
Defines the position of the 3d object, relative to the local coordinates of the parent ObjectContainer3D.
Object3D
 InheritedprojectorType : String
Object3D
 Inheritedpushback : Boolean
Elements use their furthest point from the camera when z-sorting
Object3D
 Inheritedpushfront : Boolean
Elements use their nearest point to the camera when z-sorting
Object3D
 Inheritedrenderer : IPrimitiveConsumer
An optional renderer object that can be used to render the contents of the object.
Object3D
  rootNode : BSPNode
[read-only]
BSPTree
 InheritedrotationX : Number
Defines the euler angle of rotation of the 3d object around the x-axis, relative to the local coordinates of the parent ObjectContainer3D.
Object3D
 InheritedrotationY : Number
Defines the euler angle of rotation of the 3d object around the y-axis, relative to the local coordinates of the parent ObjectContainer3D.
Object3D
 InheritedrotationZ : Number
Defines the euler angle of rotation of the 3d object around the z-axis, relative to the local coordinates of the parent ObjectContainer3D.
Object3D
 InheritedscaleX : Number
Defines the scale of the 3d object along the x-axis, relative to local coordinates.
Object3D
 InheritedscaleY : Number
Defines the scale of the 3d object along the y-axis, relative to local coordinates.
Object3D
 InheritedscaleZ : Number
Defines the scale of the 3d object along the z-axis, relative to local coordinates.
Object3D
 Inheritedscene : Scene3D
Returns the parent scene of the 3d object
Object3D
 InheritedscenePivotPoint : Number3D
Object3D
 InheritedscenePosition : Number3D
Returns the position of the 3d object, relative to the global coordinates of the Scene3D object.
Object3D
 InheritedsceneTransform : MatrixAway3D
Returns the transformation of the 3d object, relative to the global coordinates of the Scene3D object.
Object3D
 InheritedscreenXOffset : Number
Defines an additional offset to the x coordinate used on mesh elements or objects with ownCanvas set to true
Object3D
 InheritedscreenYOffset : Number
Defines an additional offset to the y coordinate used on mesh elements or objects with ownCanvas set to true
Object3D
 InheritedscreenZOffset : Number
Defines an additional offset to the z-sorting algorithm used on mesh elements or objects with ownCanvas set to true
Object3D
 Inheritedsegments : Array
Returns an array of the segments contained in the mesh object.
Mesh
 InheritedsegmentVOs : Array
Returns an array of the segmentVOs contained in the mesh object.
Mesh
 Inheritedsession : AbstractRenderSession
The render session used by the 3d object
Object3D
 Inheritedsprites : Array
Returns an array of the 3d sprites contained in the mesh object.
Mesh
 InheritedspriteVOs : Array
Returns an array of the spriteVOs contained in the mesh object.
Mesh
 InheritedstartIndices : Array
Returns an array of the start indices contained in the mesh object.
Mesh
 Inheritedtransform : MatrixAway3D
Defines the transformation of the 3d object, relative to the local coordinates of the parent ObjectContainer3D.
Object3D
 Inheritedtype : String = "mesh"
String defining the type of class used to generate the mesh.
Mesh
 Inheritedurl : String
String defining the source of the mesh.
Mesh
 InheriteduseHandCursor : Boolean = false
Defines whether a hand cursor is displayed when the mouse rolls over the 3d object.
Object3D
  usePVS : Boolean = true
BSPTree
 Inheritedvertices : Array
Returns an array of the vertices contained in the mesh object.
Mesh
 Inheritedvisible : Boolean
Defines whether the 3d object is visible in the scene
Object3D
 Inheritedx : Number
Defines the x coordinate of the 3d object relative to the local coordinates of the parent ObjectContainer3D.
Object3D
 Inheritedy : Number
Defines the y coordinate of the 3d object relative to the local coordinates of the parent ObjectContainer3D.
Object3D
 Inheritedz : Number
Defines the z coordinate of the 3d object relative to the local coordinates of the parent ObjectContainer3D.
Object3D
Protected Properties
 PropertyDefined by
 Inheritedini : Init
Instance of the Init object used to hold and parse default property values specified by the initialiser object in the 3d object constructor.
Object3D
 Inherited_pivotPoint : Number3D
Object3D
Public Methods
 MethodDefined by
  
BSPTree
(buildDynamicCollisionTree:Boolean = true)
Creates a new BSPTree object.
BSPTree
  
addChild(child:Object3D):void
Adds a 3d object to the scene as a child of the container
BSPTree
 Inherited
addChildren(... childarray):void
Adds an array of 3d objects to the scene as children of the container
ObjectContainer3D
 Inherited
addFace(face:Face):void
Adds a face object to the mesh object.
Mesh
 Inherited
addLight(light:AbstractLight):void
Adds a light as a child of the container
ObjectContainer3D
 Inherited
addOnDimensionsChange(listener:Function):void
Default method for adding a dimensionschanged event listener
Object3D
 Inherited
addOnMouseDown(listener:Function):void
Default method for adding a mouseDown3D event listener
Object3D
 Inherited
addOnMouseMove(listener:Function):void
Default method for adding a mouseMove3D event listener
Object3D
 Inherited
addOnMouseOut(listener:Function):void
Default method for adding a mouseOut3D event listener
Object3D
 Inherited
addOnMouseOver(listener:Function):void
Default method for adding a mouseOver3D event listener
Object3D
 Inherited
addOnMouseUp(listener:Function):void
Default method for adding a mouseUp3D event listener
Object3D
 Inherited
addOnParentUpdate(listener:Function):void
Default method for adding a parentupdated event listener
Object3D
 Inherited
addOnRollOut(listener:Function):void
Default method for adding a rollOut3D event listener
Object3D
 Inherited
addOnRollOver(listener:Function):void
Default method for adding a rollOver3D event listener
Object3D
 Inherited
addOnSceneChange(listener:Function):void
Default method for adding a scenechanged event listener
Object3D
 Inherited
addOnSceneTransformChange(listener:Function):void
Default method for adding a scenetransformchanged event listener
Object3D
 Inherited
addOnSessionChange(listener:Function):void
Default method for adding a sessionchanged event listener
Object3D
 Inherited
addOnTransformChange(listener:Function):void
Default method for adding a transformchanged event listener
Object3D
 Inherited
addSegment(segment:Segment):void
Adds a segment object to the mesh object.
Mesh
 Inherited
addSprite(sprite3d:Sprite3D):void
Adds a sprite3d object to the mesh object.
Mesh
 Inherited
applyPosition(dx:Number, dy:Number, dz:Number):void
Apply the given position to child objects without altering the appearance of the object container
ObjectContainer3D
 Inherited
Apply the local rotations to child objects without altering the appearance of the object container
ObjectContainer3D
 Inherited
asAS3Class(classname:String = null, packagename:String = "", round:Boolean = false, animated:Boolean = false):String
Returns a formatted string containing a self contained AS3 class definition that can be used to re-create the mesh.
Mesh
 Inherited
asXML():XML
Returns an xml representation of the mesh
Mesh
 Inherited
centerMeshes():void
Adjusts each pivot point of the container object's children so that they lies at the center of each childs geoemtry.
ObjectContainer3D
 Inherited
centerPivot():void
Adjusts the pivot point of the object so that it lies at the center of it's geoemtry.
ObjectContainer3D
 Inherited
clone(object:Object3D = null):Object3D
Duplicates the 3d object's properties to another ObjectContainer3D object
ObjectContainer3D
 Inherited
cloneAll(object:Object3D = null):Object3D
Duplicates the 3d object's properties to another ObjectContainer3D object, including bones and geometry
ObjectContainer3D
 Inherited
distanceTo(obj:Object3D):Number
Calulates the absolute distance between the local 3d object position and the position of the given 3d object
Object3D
 Inherited
getBoneByName(boneName:String):Bone
Returns a bone object specified by name from the child array of the container
ObjectContainer3D
 Inherited
getChildByName(childName:String):Object3D
Returns a 3d object specified by name from the child array of the container
ObjectContainer3D
  
getLeafContaining(point:Number3D, quitOnCulled:Boolean = false):BSPNode
Finds the leaf that contains a given point
BSPTree
 Inherited
invertFaces():void
Inverts the geometry of all face objects.
Mesh
 Inherited
lookAt(target:Number3D, upAxis:Number3D = null):void
Rotates the 3d object around to face a point defined relative to the local coordinates of the parent ObjectContainer3D.
Object3D
 Inherited
moveBackward(distance:Number):void
Moves the 3d object backwards along it's local z axis
Object3D
 Inherited
moveDown(distance:Number):void
Moves the 3d object backwards along it's local y axis
Object3D
 Inherited
moveForward(distance:Number):void
Moves the 3d object forwards along it's local z axis
Object3D
 Inherited
moveLeft(distance:Number):void
Moves the 3d object backwards along it's local x axis
Object3D
 Inherited
movePivot(dx:Number, dy:Number, dz:Number):void
Moves the local point around which the object rotates.
Object3D
 Inherited
moveRight(distance:Number):void
Moves the 3d object forwards along it's local x axis
Object3D
 Inherited
moveTo(dx:Number, dy:Number, dz:Number):void
Moves the 3d object directly to a point in space
Object3D
 Inherited
moveUp(distance:Number):void
Moves the 3d object forwards along it's local y axis
Object3D
 Inherited
pitch(angle:Number):void
Rotates the 3d object around it's local x-axis
Object3D
 Inherited
quarterFace(face:Face):void
Divides a face object into 4 equal sized face objects.
Mesh
 Inherited
quarterFaces():void
Divides all faces objects of a Mesh into 4 equal sized face objects.
Mesh
  
removeChild(child:Object3D):void
Removes a 3d object from the child array of the container
BSPTree
 Inherited
removeChildByName(name:String):void
Removes a 3d object from the child array of the container
ObjectContainer3D
 Inherited
removeFace(face:Face):void
Removes a face object from the mesh object.
Mesh
 Inherited
Removes a light from the container
ObjectContainer3D
 Inherited
removeOnDimensionsChange(listener:Function):void
Default method for removing a dimensionschanged event listener
Object3D
 Inherited
removeOnMouseDown(listener:Function):void
Default method for removing a mouseDown3D event listener
Object3D
 Inherited
removeOnMouseMove(listener:Function):void
Default method for removing a mouseMove3D event listener
Object3D
 Inherited
removeOnMouseOut(listener:Function):void
Default method for removing a mouseOut3D event listener
Object3D
 Inherited
removeOnMouseOver(listener:Function):void
Default method for removing a mouseOver3D event listener
Object3D
 Inherited
removeOnMouseUp(listener:Function):void
Default method for removing a mouseUp3D event listener
Object3D
 Inherited
removeOnParentUpdate(listener:Function):void
Default method for removing a parentupdated event listener
Object3D
 Inherited
removeOnRollOut(listener:Function):void
Default method for removing a rollOut3D event listener
Object3D
 Inherited
removeOnRollOver(listener:Function):void
Default method for removing a rollOver3D event listener
Object3D
 Inherited
removeOnSceneChange(listener:Function):void
Default method for removing a scenechanged event listener
Object3D
 Inherited
removeOnSceneTransformChange(listener:Function):void
Default method for removing a scenetransformchanged event listener
Object3D
 Inherited
removeOnSessionChange(listener:Function):void
Default method for removing a sessionchanged event listener
Object3D
 Inherited
removeOnTransformChange(listener:Function):void
Default method for removing a transformchanged event listener
Object3D
 Inherited
removeSegment(segment:Segment):void
Removes a segment object from the mesh object.
Mesh
 Inherited
removeSprite(sprite3d:Sprite3D):void
Removes a 3d sprite object from the mesh object.
Mesh
 Inherited
roll(angle:Number):void
Rotates the 3d object around it's local z-axis
Object3D
 Inherited
rotate(axis:Number3D, angle:Number):void
Rotates the 3d object around an axis by a defined angle
Object3D
 Inherited
rotateTo(ax:Number, ay:Number, az:Number):void
Rotates the 3d object directly to a euler angle
Object3D
 Inherited
scale(scale:Number):void
Scales the contents of the 3d object.
Object3D
 Inherited
splitFace(face:Face, side:int = 0):void
Divides a face object into 2 face objects.
Mesh
 Inherited
splitFaces(side:int = 0):void
Divides all faces objects of a Mesh into 2 face objects.
Mesh
 Inherited
tick(time:int):void
Called by the TickTraverser.
Object3D
 Inherited
toString():String
Used to trace the values of a 3d object.
Object3D
  
traceCollision(start:Number3D, end:Number3D, testMethod:int, halfExtents:Number3D = null):Boolean
Finds the closest colliding Face between start and end position
BSPTree
 Inherited
translate(axis:Number3D, distance:Number):void
Moves the 3d object along a vector by a defined length
Object3D
  
traverse(traverser:Traverser):void
Used when traversing the scenegraph
BSPTree
 Inherited
triFace(face:Face):void
Divides a face object into 3 face objects.
Mesh
 Inherited
triFaces():void
Divides all faces objects of a Mesh into 3 face objects.
Mesh
 Inherited
updateMaterials(source:Object3D, view:View3D):void
Updates the materials in the mesh object
Mesh
 Inherited
updateObject():void
Object3D
 Inherited
updateSession():void
Object3D
 Inherited
updateVertex(v:Vertex, x:Number, y:Number, z:Number, refreshNormals:Boolean = false):void
update vertex information.
Mesh
 Inherited
yaw(angle:Number):void
Rotates the 3d object around it's local y-axis
Object3D
Protected Methods
 MethodDefined by
 Inherited
ObjectContainer3D
 Inherited
Object3D
Events
 EventSummaryDefined by
 Inherited Dispatched when the bounding dimensions of the 3d object changes.Object3D
 Inherited Dispatched when a user presses the left hand mouse button while the cursor is over the 3d object.Object3D
 Inherited Dispatched when a user moves the cursor while it is over the 3d object.Object3D
 Inherited Dispatched when a user moves the cursor away from the 3d object.Object3D
 Inherited Dispatched when a user moves the cursor over the 3d object.Object3D
 Inherited Dispatched when a user releases the left hand mouse button while the cursor is over the 3d object.Object3D
 Inherited Dispatched when a user rolls out of the 3d object.Object3D
 Inherited Dispatched when a user rolls over the 3d object.Object3D
 Inherited Dispatched when the parent scene of the 3d object changes.Object3D
 Inherited Dispatched when the scene transform matrix of the 3d object changes.Object3D
 Inherited Dispatched when the render session property of the 3d object changes.Object3D
 Inherited Dispatched when the render session property of the 3d object updates its contents.Object3D
 Inherited Dispatched when the local transform matrix of the 3d object changes.Object3D
Public Constants
 ConstantDefined by
  COLLISION_EPSILON : Number = 0.1
[static]
BSPTree
  EPSILON : Number = 0.07
[static]
BSPTree
  TEST_METHOD_AABB : int = 1
[static]
BSPTree
  TEST_METHOD_ELLIPSOID : int = 2
[static]
BSPTree
  TEST_METHOD_POINT : int = 0
[static]
BSPTree
Property detail
activeLeafproperty
activeLeaf:BSPNode  [read-only]

The leaf containing the camera. Returns null if the camera is in "solid" space.

Implementation
    public function get activeLeaf():BSPNode
_collidedObjectproperty 
arcane var _collidedObject:Object3D
collidedObjectproperty 
collidedObject:Object3D  [read-only]

Implementation
    public function get collidedObject():Object3D
_collisionPlaneproperty 
arcane var _collisionPlane:Plane3D
collisionPlaneproperty 
collisionPlane:Plane3D  [read-only]

The plane against which was collided during the last call to traceCollision

Implementation
    public function get collisionPlane():Plane3D
_collisionRatioproperty 
arcane var _collisionRatio:Number
collisionRatioproperty 
collisionRatio:Number  [read-only]

The ratio [0, 1] on the movement line where the previous collision occurred

Implementation
    public function get collisionRatio():Number
_leavesproperty 
arcane var _leaves:Vector
leavesproperty 
leaves:Vector  [read-only]

All the leaves in the current tree

Implementation
    arcane function get leaves():Vector
parentproperty 
parent:ObjectContainer3D  [write-only]

Implementation
    public function set parent(value:ObjectContainer3D):void
_rootNodeproperty 
arcane var _rootNode:BSPNode
rootNodeproperty 
rootNode:BSPNode  [read-only]Implementation
    public function get rootNode():BSPNode
usePVSproperty 
public var usePVS:Boolean = true
Constructor detail
BSPTree()constructor
public function BSPTree(buildDynamicCollisionTree:Boolean = true)Parameters
buildDynamicCollisionTree:Boolean (default = true)
Init Parameters
Method detail
addChild()method
public override function addChild(child:Object3D):void

Adds a 3d object to the scene as a child of the container

Parameters
child:Object3D — The 3d object to be added
addTemporaryChild()method 
arcane function addTemporaryChild(mesh:Mesh):void Parameters
mesh:Mesh
getLeafContaining()method 
public function getLeafContaining(point:Number3D, quitOnCulled:Boolean = false):BSPNode

Finds the leaf that contains a given point

Parameters
point:Number3D — The point to be traced. The point is expressed in local space.
 
quitOnCulled:Boolean (default = false) — Indicates whether leaf finding should stop when a culled node is encountered.

Returns
BSPNode — The leaf containing the point
removeChild()method 
public override function removeChild(child:Object3D):void

Removes a 3d object from the child array of the container

Parameters
child:Object3D — The 3d object to be removed
removeTemporaryChild()method 
arcane function removeTemporaryChild(mesh:Mesh):void Parameters
mesh:Mesh
traceCollision()method 
public function traceCollision(start:Number3D, end:Number3D, testMethod:int, halfExtents:Number3D = null):Boolean

Finds the closest colliding Face between start and end position

Parameters
start:Number3D — The starting position of the object (ie the object's current position)
 
end:Number3D — The position the object is trying to reach
 
testMethod:int — The radii of the object's bounding eclipse
 
halfExtents:Number3D (default = null)

Returns
Boolean — The closest Face colliding with the object. Null if no collision was found.
traverse()method 
public override function traverse(traverser:Traverser):void

Used when traversing the scenegraph

Parameters
traverser:Traverser — The traverser object
Constant detail
COLLISION_EPSILONconstant
public static const COLLISION_EPSILON:Number = 0.1
EPSILONconstant 
public static const EPSILON:Number = 0.07
TEST_METHOD_AABBconstant 
public static const TEST_METHOD_AABB:int = 1
TEST_METHOD_ELLIPSOIDconstant 
public static const TEST_METHOD_ELLIPSOID:int = 2
TEST_METHOD_POINTconstant 
public static const TEST_METHOD_POINT:int = 0
Wiki link
Click to go to the wiki page for 'away3d.graphs.bsp.BSPTree'

Code examples

Comments