DisplayObject3D

Kind of class:public class
Package:org.papervision3d.objects
Inherits from:DisplayObjectContainer3D < EventDispatcher
Known subclasses:
Classpath:org.papervision3d.objects.DisplayObject3D
File last modified:Sunday, 02 March 2008, 15:23:46
The DisplayObject class represents instances of 3D objects that are contained in the scene.

That includes all objects in the scene, not only those that can be rendered, but also the camera and its target.

The DisplayObject3D class supports basic functionality like the x, y and z position of an object, as well as rotationX, rotationY, rotationZ, scaleX, scaleY and scaleZ and visible. It also supports more advanced properties of the object such as its transform Matrix3D.

DisplayObject3D is not an abstract base class; therefore, you can call DisplayObject3D directly. Invoking new DisplayObject() creates a new empty object in 3D space, like when you used createEmptyMovieClip().

Summary


Constructor
Constants
  • MESH_SORT_CENTER : uint
    • tells Mesh3D's render() method to sort by measuring from the center of a triangle
  • MESH_SORT_FAR : uint
    • tells Mesh3D's render() method to sort by measuring from the farthest point of a triangle
  • MESH_SORT_CLOSE : uint
    • tells Mesh3D's render() method to sort by measuring from the closest point of a triangle
Class properties
  • ZERO : DisplayObject3D
    • Returns an empty DiplayObject3D object positioned in the center of the 3D coordinate system (0, 0 ,0).
  • faceLevelMode : Boolean
    • This allows objects faces to have their own containers.
  • sortedArray : Array
Instance properties
  • x : Number
    • An Number that sets the X coordinate of a object relative to the origin of its parent.
  • y : Number
    • An Number that sets the Y coordinate of a object relative to the origin of its parent.
  • z : Number
    • An Number that sets the Z coordinate of a object relative to the origin of its parent.
  • rotationX : Number
    • Specifies the rotation around the X axis from its original orientation.
  • rotationY : Number
    • Specifies the rotation around the Y axis from its original orientation.
  • rotationZ : Number
    • Specifies the rotation around the Z axis from its original orientation.
  • scale : Number
    • Sets the 3D scale as applied from the registration point of the object.
  • scaleX : Number
    • Sets the scale along the local X axis as applied from the registration point of the object.
  • scaleY : Number
    • Sets the scale along the local Y axis as applied from the registration point of the object.
  • scaleZ : Number
    • Sets the scale along the local Z axis as applied from the registration point of the object.
  • sceneX : Number
    • The X coordinate of a object relative to the scene coordinate system.
  • sceneY : Number
    • The Y coordinate of a object relative to the scene coordinate system.
  • sceneZ : Number
    • The Z coordinate of a object relative to the scene coordinate system.
  • screen : Number3D
    • [read-only] The coordinate of the object on screen.
  • visible : Boolean
    • Whether or not the display object is visible.
  • name : String
    • An optional object name.
  • id : int
    • [read-only] Unique id of this instance.
  • extra : Object
    • An object that contains user defined properties.
  • material (material:MaterialObject3D) : MaterialObject3D
    • The default material for the object instance.
  • materials : MaterialsList
    • The list of materials for this instance.
  • scene (p_scene:SceneObject3D) : SceneObject3D
  • parent : DisplayObjectContainer3D
    • [read-only] Indicates the DisplayObjectContainer3D object that contains this display object.
  • meshSort : uint
    • tells Mesh3D's render() method to compare the measurement choice of the user for a triangle's sorting
  • transform : Matrix3D
    • A Matrix3D object containing values that affect the scaling, rotation, and translation of the display object.
  • view : Matrix3D
    • [internal-use] A camera transformed Matrix3D object.
  • world : Matrix3D
    • World transformation.
  • faces : Array
    • [internal-use]
  • geometry : GeometryObject3D
    • The GeometryObject3D object that contains the 3D definition of this instance.
  • screenZ : Number
    • [internal-use] The average depth of the object faces center.
  • culled : Boolean
    • [internal use] Is this object culled by camera frustum?
  • useOwnContainer (b:Boolean) : Boolean
  • containerSortMode (sortMode:int) : int
  • containerBlendMode (blendmode:int) : int
  • filters (filters:Array) : Array
  • userData (userData:UserData) : UserData
Instance methods
  • addChild (child:DisplayObject3D, name:String = null) : DisplayObject3D
    • Adds a child DisplayObject3D instance to this DisplayObjectContainer instance.
  • addGeometry (geometry:GeometryObject3D = null) : void
    • Adds a geometry definition to the instance.
  • distanceTo (obj:DisplayObject3D) : Number
    • Gets the distance to the position of the given object.
  • 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.
  • hitTestObject (obj:DisplayObject3D, multiplier:Number = 1) : Boolean
    • Evaluates the display object to see if it overlaps or intersects with the obj display object.
  • getMaterialByName (name:String) : MaterialObject3D
    • Returns the material that exists with the specified name in the materials list.
  • materialsList : String
    • Returns a string value with the list of material names of the materials list.
  • project (parent:DisplayObject3D) : Number
    • [internal-use] Projects three dimensional coordinates onto a two dimensional plane to simulate the relationship of the camera to subject.
  • moveForward (distance:Number) : void
    • Translate the display object in the direction it is facing, i.e.
  • moveBackward (distance:Number) : void
    • Translate the display object in the opposite direction it is facing, i.e.
  • moveLeft (distance:Number) : void
    • Translate the display object lateraly, to the left of the direction it is facing, i.e.
  • moveRight (distance:Number) : void
    • Translate the display object lateraly, to the right of the direction it is facing, i.e.
  • moveUp (distance:Number) : void
    • Translate the display object upwards, with respect to the direction it is facing, i.e.
  • moveDown (distance:Number) : void
    • Translate the display object downwards, with respect to the direction it is facing, i.e.
  • translate (distance:Number, axis:Number3D) : void
    • Move the object along a given direction.
  • 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.
  • yaw (angle:Number) : void
    • Rotate the display object around about the vertical axis —an axis drawn from top to bottom.
  • 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.
  • lookAt (targetObject:DisplayObject3D = null) : void
    • Make the object look at a specific position.
  • copyPosition (reference:*) : void
    • Copies the position information (x, y and z coordinates) from another object or Matrix3D.
  • copyTransform (reference:*) : void
    • Copies the transformation information (position, rotation and scale) from another object or Matrix3D.
  • toString : String
    • Returns a string value representing the three-dimensional position values of the display object instance.
  • setLayerForViewport (layer:ViewportLayer) : void

Constructor

DisplayObject3D

public function DisplayObject3D (
name:String = null, geometry:GeometryObject3D = null, initObject:Object = null) : void

Creates a new DisplayObject3D instance. After creating the instance, call the addChild() method of a DisplayObjectContainer3D.
Parameters:
name :
[optional] - The name of the newly created object.
geometry :
[optional] - The geometry of the newly created object.
initObject:
[optional] - An object that contains user defined properties with which to populate the newly created DisplayObject3D.
  • x: An Number that sets the X coordinate of a object relative to the scene coordinate system.
  • y: An Number that sets the Y coordinate of a object relative to the scene coordinate system.
  • z: An Number that sets the Z coordinate of a object relative to the scene coordinate system.
  • rotationX: Specifies the rotation around the X axis from its original orientation.
  • rotationY: Specifies the rotation around the Y axis from its original orientation.
  • rotationZ: Specifies the rotation around the Z axis from its original orientation.
  • scaleX: Sets the scale along the local X axis as applied from the registration point of the object.
  • scaleY: Sets the scale along the local Y axis as applied from the registration point of the object.
  • scaleZ: Sets the scale along the local Z axis as applied from the registration point of the object.
  • visible: Whether or not the display object is visible.

    A Boolean value that indicates whether the object is projected, transformed and rendered. A value of false will effectively ignore the object. The default value is true.

  • container: The MovieClip that you draw into when rendering. Use only when the object is rendered in its own unique MovieClip.

    It's Boolean value determines whether the container MovieClip should be cleared before rendering.

  • extra: An object that contains user defined properties.

    All properties of the extra field are copied into the new instance. The properties specified with extra are publicly available.

Constants

MESH_SORT_CENTER

public static const MESH_SORT_CENTER:uint = 1
(read)

tells Mesh3D's render() method to sort by measuring from the center of a triangle

MESH_SORT_CLOSE

public static const MESH_SORT_CLOSE:uint = 3
(read)

tells Mesh3D's render() method to sort by measuring from the closest point of a triangle

MESH_SORT_FAR

public static const MESH_SORT_FAR:uint = 2
(read)

tells Mesh3D's render() method to sort by measuring from the farthest point of a triangle

Class properties

faceLevelMode

public static faceLevelMode:Boolean
(read,write)

This allows objects faces to have their own containers.

sortedArray

public static sortedArray:Array = new Array()
(read,write)

ZERO

public static ZERO:DisplayObject3D
(read)

Returns an empty DiplayObject3D object positioned in the center of the 3D coordinate system (0, 0 ,0).

Instance properties

containerBlendMode

public containerBlendMode:int
(read,write)

containerSortMode

public containerSortMode:int
(read,write)

culled

public culled:Boolean
(read,write)

[internal use] Is this object culled by camera frustum?

extra

public extra:Object
(read,write)

An object that contains user defined properties.

All properties of the extra field are copied into the new instance. The properties specified with extra are publicly available.

faces

public faces:Array = new Array()
(read,write)

[internal-use]

filters

public filters:Array
(read,write)

geometry

public geometry:GeometryObject3D
(read,write)

The GeometryObject3D object that contains the 3D definition of this instance.

When different objects share the same geometry, they become instances. They are the same object, displayed multiple times. Changing the shape of this object changes the shape of all of its instances.

Instancing an object saves system memory, and is useful to display an object multiple times while maintaining its shape.

For example, you could create armies and forests full of duplicate objects without needing the memory to handle that much actual geometry. Each instance has its own transform node so it can have its own position, rotation, and scaling.

id

public id:int
(read,write)

[read-only] Unique id of this instance.

material

public material:MaterialObject3D
(read,write)

The default material for the object instance. Materials collect data about how objects appear when rendered.

materials

public materials:MaterialsList
(read,write)

The list of materials for this instance.

meshSort

public meshSort:uint = MESH_SORT_CENTER
(read,write)

tells Mesh3D's render() method to compare the measurement choice of the user for a triangle's sorting

name

public name:String
(read,write)

An optional object name.

parent

(read,write)

[read-only] Indicates the DisplayObjectContainer3D object that contains this display object.

rotationX

public rotationX:Number
(read,write)

Specifies the rotation around the X axis from its original orientation.

rotationY

public rotationY:Number
(read,write)

Specifies the rotation around the Y axis from its original orientation.

rotationZ

public rotationZ:Number
(read,write)

Specifies the rotation around the Z axis from its original orientation.

scale

public scale:Number
(read,write)

Sets the 3D scale as applied from the registration point of the object.

scaleX

public scaleX:Number
(read,write)

Sets the scale along the local X axis as applied from the registration point of the object.

scaleY

public scaleY:Number
(read,write)

Sets the scale along the local Y axis as applied from the registration point of the object.

scaleZ

public scaleZ:Number
(read,write)

Sets the scale along the local Z axis as applied from the registration point of the object.

scene

public scene:SceneObject3D
(read,write)

sceneX

public sceneX:Number
(read)

The X coordinate of a object relative to the scene coordinate system.

sceneY

public sceneY:Number
(read)

The Y coordinate of a object relative to the scene coordinate system.

sceneZ

public sceneZ:Number
(read)

The Z coordinate of a object relative to the scene coordinate system.

screen

public screen:Number3D = new Number3D()
(read,write)

[read-only] The coordinate of the object on screen.

screenZ

public screenZ:Number
(read,write)

[internal-use] The average depth of the object faces center. Used internally for z-sorting.

transform

public transform:Matrix3D
(read,write)

A Matrix3D object containing values that affect the scaling, rotation, and translation of the display object.

useOwnContainer

public useOwnContainer:Boolean
(read,write)

Author:
  • Ralph Hauwert

    Some stuff for the viewports.

userData

public userData:UserData
(read,write)

view

public view:Matrix3D
(read,write)

[internal-use] A camera transformed Matrix3D object.

visible

public visible:Boolean
(read,write)

Whether or not the display object is visible.

A Boolean value that indicates whether the object is projected, transformed and rendered. A value of false will effectively ignore the object. The default value is true.

world

public world:Matrix3D
(read,write)

World transformation.

x

public x:Number
(read,write)

An Number that sets the X coordinate of a object relative to the origin of its parent.

y

public y:Number
(read,write)

An Number that sets the Y coordinate of a object relative to the origin of its parent.

z

public z:Number
(read,write)

An Number that sets the Z coordinate of a object relative to the origin of its parent.

Instance methods

addChild

override public function addChild (
child:DisplayObject3D, name:String = null) : DisplayObject3D

Adds a child DisplayObject3D instance to this DisplayObjectContainer instance.

[TODO: If you add a child object that already has a different display object container as a parent, the object is removed from the child list of the other display object container.]
Parameters:
child:
The DisplayObject3D instance to add as a child of this DisplayObjectContainer3D instance.
name :
An optional name of the child to add or create. If no name is provided, the child name will be used.
Returns:
  • The DisplayObject3D instance that you have added or created.

addGeometry

public function addGeometry (
geometry:GeometryObject3D = null) : void

Adds a geometry definition to the instance.

A geometry describes the visual shape and appearance of an object in a scene.
Parameters:
geometry:
A geometry definition.

copyPosition

public function copyPosition (
reference:*) : void

Copies the position information (x, y and z coordinates) from another object or Matrix3D.
Parameters:
reference:
A DisplayObject3D or Matrix3D object to copy the position from.

copyTransform

public function copyTransform (
reference:*) : void

Copies the transformation information (position, rotation and scale) from another object or Matrix3D.
Parameters:
reference:
A DisplayObject3D or Matrix3D object to copy the position from.

distanceTo

public function distanceTo (
obj:DisplayObject3D) : Number

Gets the distance to the position of the given object.
Parameters:
obj:
The display object to measure the distance to.
Returns:
  • The distance to the registration point of the given object.

getMaterialByName

public function getMaterialByName (
name:String) : MaterialObject3D

Returns the material that exists with the specified name in the materials list.

If more that one material object has the specified name, the method returns the first material object in the materials list.

Parameters:
name:
The name of the material to return.
Returns:
  • The material object with the specified name.

hitTestObject

public function hitTestObject (
obj:DisplayObject3D, multiplier:Number = 1) : Boolean

Evaluates the display object to see if it overlaps or intersects with the obj display object.
Parameters:
obj:
The display object to test against.
Returns:
  • true if the display objects intersect; false if not.

hitTestPoint

public function 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.

The x, y and z parameters specify a point in the coordinate space of the instance parent object, not the scene (unless that parent object is the scene).

Parameters:
x:
The x coordinate to test against this object.
y:
The y coordinate to test against this object.
z:
The z coordinate to test against this object.
Returns:
  • true if the display object overlaps or intersects with the specified point; false otherwise.

lookAt

public function lookAt (
targetObject:DisplayObject3D, upAxis:Number3D = null) : void

Make the object look at a specific position.
Parameters:
targetObject:
Object to look at.
upAxis :
The vertical axis of the universe. Normally the positive Y axis.

materialsList

public function materialsList (
) : String

Returns a string value with the list of material names of the materials list.
Returns:
  • A string.

moveBackward

public function moveBackward (
distance:Number) : void

Translate the display object in the opposite direction it is facing, i.e. it's negative Z axis.
Parameters:
distance:
The distance that the object should move backward.

moveDown

public function moveDown (
distance:Number) : void

Translate the display object downwards, with respect to the direction it is facing, i.e. it's negative Y axis.
Parameters:
distance:
The distance that the object should move down.

moveForward

public function moveForward (
distance:Number) : void

Translate the display object in the direction it is facing, i.e. it's positive Z axis.
Parameters:
distance:
The distance that the object should move forward.

moveLeft

public function moveLeft (
distance:Number) : void

Translate the display object lateraly, to the left of the direction it is facing, i.e. it's negative X axis.
Parameters:
distance:
The distance that the object should move left.

moveRight

public function moveRight (
distance:Number) : void

Translate the display object lateraly, to the right of the direction it is facing, i.e. it's positive X axis.
Parameters:
distance:
The distance that the object should move right.

moveUp

public function moveUp (
distance:Number) : void

Translate the display object upwards, with respect to the direction it is facing, i.e. it's positive Y axis.
Parameters:
distance:
The distance that the object should move up.

pitch

public function 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.
Parameters:
angle:
The angle to rotate.

project

public function project (
parent:DisplayObject3D, renderSessionData:RenderSessionData) : Number

[internal-use] Projects three dimensional coordinates onto a two dimensional plane to simulate the relationship of the camera to subject.

This is the first step in the process of representing three dimensional shapes two dimensionally.

Parameters:
parent :
The DisplayObject3D object that contains this display object.
renderSessionData:
Data for the current render.

roll

public function 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.
Parameters:
angle:
 

setLayerForViewport

pv3dview public function setLayerForViewport (
layer:ViewportLayer) : void

toString

override public function toString (
) : String

Returns a string value representing the three-dimensional position values of the display object instance.
Returns:
  • A string.

translate

public function translate (
distance:Number, axis:Number3D) : void

Move the object along a given direction.
Parameters:
distance:
The distance that the object should travel.
axis :
The direction that the object should move towards.

yaw

public function yaw (
angle:Number) : void

Rotate the display object around about the vertical axis —an axis drawn from top to bottom.
Parameters:
angle:
The angle to rotate.