Packagealternativa.engine3d.core
Classpublic class Object3D
Implementsflash.events.IEventDispatcher
SubclassesCamera3D, Mesh, Sprite3D

Base class for in-scene objects. Class implements scene objects hierarchy and also contains information about transformation of an object as a whole in the parent object's coordinate system. An object can be scaled, rotated and translated. The resulting transformation is a composition of the all three operations in the listed order.

The global transformation of an object in the scene coordinate system is a composition of local transformations of the object and all of its parents in the objects' tree.

The class implements flash.events.IEventDispatcher interface and can receive mouse events which contain an information about point in the 3d-space where an event has occured. The capture and bubbling phases are not implemented yet.



Public Properties
 PropertyDefined by
  children : Set
[read-only] A set of child objects.
Object3D
  coords : Point3D
Object coordinates.
Object3D
  mobility : int
Mobility level.
Object3D
  mouseEnabled : Boolean = true
Specifies whether this object receives mouse messages.
Object3D
  name : String
Object name.
Object3D
  parent : Object3D
[read-only] Parent object.
Object3D
  rotationX : Number
X-axis rotation angle in radians.
Object3D
  rotationY : Number
Y-axis rotation angle in radians.
Object3D
  rotationZ : Number
Z-axis rotation angle in radians.
Object3D
  scaleX : Number
X-axis scale coefficient.
Object3D
  scaleY : Number
Y-axis scale coefficient.
Object3D
  scaleZ : Number
Z-axis scale coefficient.
Object3D
  scene : Scene3D
[read-only] Scene containing given object.
Object3D
  transformation : Matrix3D
[read-only] Full (global) transformation matrix of an object.
Object3D
  x : Number
X coordinate.
Object3D
  y : Number
Y coordinate.
Object3D
  z : Number
Z coordinate.
Object3D
Public Methods
 MethodDefined by
  
Object3D(name:String = null)
Create an instance of class.
Object3D
  
Adds a child object.
Object3D
  
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
Registers an event listener.
Object3D
  
Clones object.
Object3D
  
dispatchEvent(event:Event):Boolean
Dispatches an event.
Object3D
  
forEach(func:Function):void
Calls the specified function for the object an all its children, passing the current object as an argument.
Object3D
  
getChildByName(name:String, deep:Boolean = false):Object3D
Gets a child object with the given name.
Object3D
  
globalToLocal(point:Point3D, result:Point3D = null):Point3D
Transforms a point form global coordinate system to an object's coordinate system
Object3D
  
hasEventListener(type:String):Boolean
Checks if there are registered event listeners for events of the specified type.
Object3D
  
localToGlobal(point:Point3D, result:Point3D = null):Point3D
Transforms a point from local coordinate system of an object to global coordinate system.
Object3D
  
Delete child object.
Object3D
  
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
Removes an event listener.
Object3D
  
toString():String
Get string representation of object.
Object3D
  
willTrigger(type:String):Boolean
Object3D
Protected Methods
 MethodDefined by
  
addToScene(scene:Scene3D):void
Method is being called when adding object to scene.
Object3D
  
Copy source object properties.
Object3D
  
Create empty object without inner structure.
Object3D
  
defaultName():String
Default object name.
Object3D
  
Method is being called whed deleting object from a scene.
Object3D
Events
 EventSummaryDefined by
   Dispatched when a user presses and releases left mouse button over the same object.Object3D
   Dispatched when a user presses left mouse button over an object.Object3D
   Dispatched when a user moves mouse pointer while it is over an object.Object3D
   Dispatched when a user moves mouse pointer away from an object.Object3D
   Dispatched when a user moves mouse pointer over an object.Object3D
   Dispatched when a user releases left mouse button over an object.Object3D
   Dispatched when a user spins mouse wheel over an object.Object3D
Property detail
childrenproperty
children:Set  [read-only]

A set of child objects.

Implementation
    public function get children():Set
coordsproperty 
coords:Point3D  [read-write]

Object coordinates.

Implementation
    public function get coords():Point3D
    public function set coords(value:Point3D):void
mobilityproperty 
mobility:int  [read-write]

Mobility level. Resulting mobility is a sum of the object mobility and it's parent objects in scene hierarchy.

Implementation
    public function get mobility():int
    public function set mobility(value:int):void
mouseEnabledproperty 
public var mouseEnabled:Boolean = true

Specifies whether this object receives mouse messages. If an object has this property set to false, no surface or face of the object can recieve mouse messages regardless of their mouseEnabled property.

nameproperty 
name:String  [read-write]

Object name.

Implementation
    public function get name():String
    public function set name(value:String):void
parentproperty 
parent:Object3D  [read-only]

Parent object.

Implementation
    public function get parent():Object3D
rotationXproperty 
rotationX:Number  [read-write]

X-axis rotation angle in radians.

Implementation
    public function get rotationX():Number
    public function set rotationX(value:Number):void
rotationYproperty 
rotationY:Number  [read-write]

Y-axis rotation angle in radians.

Implementation
    public function get rotationY():Number
    public function set rotationY(value:Number):void
rotationZproperty 
rotationZ:Number  [read-write]

Z-axis rotation angle in radians.

Implementation
    public function get rotationZ():Number
    public function set rotationZ(value:Number):void
scaleXproperty 
scaleX:Number  [read-write]

X-axis scale coefficient.

Implementation
    public function get scaleX():Number
    public function set scaleX(value:Number):void
scaleYproperty 
scaleY:Number  [read-write]

Y-axis scale coefficient.

Implementation
    public function get scaleY():Number
    public function set scaleY(value:Number):void
scaleZproperty 
scaleZ:Number  [read-write]

Z-axis scale coefficient.

Implementation
    public function get scaleZ():Number
    public function set scaleZ(value:Number):void
sceneproperty 
scene:Scene3D  [read-only]

Scene containing given object.

Implementation
    public function get scene():Scene3D
transformationproperty 
transformation:Matrix3D  [read-only]

Full (global) transformation matrix of an object.

Implementation
    public function get transformation():Matrix3D
xproperty 
x:Number  [read-write]

X coordinate.

Implementation
    public function get x():Number
    public function set x(value:Number):void
yproperty 
y:Number  [read-write]

Y coordinate.

Implementation
    public function get y():Number
    public function set y(value:Number):void
zproperty 
z:Number  [read-write]

Z coordinate.

Implementation
    public function get z():Number
    public function set z(value:Number):void
Constructor detail
Object3D()constructor
public function Object3D(name:String = null)

Create an instance of class.

Parameters
name:String (default = null)object name
Method detail
addChild()method
public function addChild(child:Object3D):Object3D

Adds a child object. Adding object is being deleted from previous parent's list. Parent scene becomes object's new scene.

Parameters
child:Object3Dan object to be added as a child

Returns
Object3Dadded object

Throws
Object3DHierarchyError an attempt to add child object, which cannot be linked with this parent
addEventListener()method 
public function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void

Registers an event listener.

Parameters
type:Stringthe type of an event
 
listener:Functionthe listener function
 
useCapture:Boolean (default = false)not used
 
priority:int (default = 0)the priority level of the event listener. All listeners with priority n are processed before listeners of priority n-1. If two or more listeners share the same priority, they are processed in the order in which they were added.
 
useWeakReference:Boolean (default = false)Determines whether the reference to the listener is strong or weak. A strong reference prevents your listener from being garbage-collected. A weak reference does not.
addToScene()method 
protected function addToScene(scene:Scene3D):void

Method is being called when adding object to scene. Descendants may redefine method for making specific actions.

Parameters
scene:Scene3Dscene, which object is being added to
clone()method 
public function clone():Object3D

Clones object. Descendants have to override methods createEmptyObject() и clonePropertiesFrom() for proper cloning.

Returns
Object3Da clone of the object

See also

clonePropertiesFrom()method 
protected function clonePropertiesFrom(source:Object3D):void

Copy source object properties. This method is being used in clone() method and must be redefined in it's descendants to get a right object. Every descendant must copy only properties that were added to base class in this exact method. Inherited properties copying is made by calling super.clonePropertiesFrom(source).

Parameters
source:Object3Dobject, which properties are being copied
createEmptyObject()method 
protected function createEmptyObject():Object3D

Create empty object without inner structure. For example, if geometrical primitive, when added, forms a bunch of vertices, faces and surfaces, this method don't create them. This method is being used in clone() and has to be redefined in descendants in order to get the right object.

Returns
Object3Da new empty object
defaultName()method 
protected function defaultName():String

Default object name.

Returns
Stringdefault object name
dispatchEvent()method 
public function dispatchEvent(event:Event):Boolean

Dispatches an event.

Parameters
event:Eventthe event to dispatch

Returns
Booleanfalse
forEach()method 
public function forEach(func:Function):void

Calls the specified function for the object an all its children, passing the current object as an argument.

Parameters
func:Functionfunction of type Function(object:Object3D):void
getChildByName()method 
public function getChildByName(name:String, deep:Boolean = false):Object3D

Gets a child object with the given name.

Parameters
name:Stringchild object name
 
deep:Boolean (default = false)deep search mode flag. When value false is specified, the method performs a search only among the direct children of an object, otherwise full subtree of children objects is processed.

Returns
Object3Dany child object which has the specified name or null if there is no such objects
globalToLocal()method 
public function globalToLocal(point:Point3D, result:Point3D = null):Point3D

Transforms a point form global coordinate system to an object's coordinate system

Parameters
point:Point3Da point in global coordinate system
 
result:Point3D (default = null)the result will be written into this parameter. If value of null is specified, then a new instance of Point3D will be created.

Returns
Point3Dthe transformed point
hasEventListener()method 
public function hasEventListener(type:String):Boolean

Checks if there are registered event listeners for events of the specified type.

Parameters
type:Stringthe type of an event

Returns
Booleantrue if there are listeners of events of the specified type, otherwise false
localToGlobal()method 
public function localToGlobal(point:Point3D, result:Point3D = null):Point3D

Transforms a point from local coordinate system of an object to global coordinate system.

Parameters
point:Point3Da point in local coordinate system
 
result:Point3D (default = null)the result will be written in this parameter. If value of null is specified, then a new instance of Point3D will be created.

Returns
Point3Dthe transformed point or null if the object is not in a scene
removeChild()method 
public function removeChild(child:Object3D):Object3D

Delete child object.

Parameters
child:Object3Dchild object

Returns
Object3Dremoved object

Throws
Object3DNotFoundError an attempt to delete non-existing object
removeEventListener()method 
public function removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void

Removes an event listener.

Parameters
type:Stringthe type of an event
 
listener:Functionthe listener function
 
useCapture:Boolean (default = false)not used
removeFromScene()method 
protected function removeFromScene(scene:Scene3D):void

Method is being called whed deleting object from a scene.Descendants may redefine method for making specific actions.

Parameters
scene:Scene3Dscena, from which the object is being deleted from
toString()method 
public function toString():String

Get string representation of object.

Returns
Stringa string representation of the object
willTrigger()method 
public function willTrigger(type:String):Boolean

Parameters
type:String

Returns
Boolean
Event detail
clickevent 
Event object type: alternativa.engine3d.events.MouseEvent3D
MouseEvent3D.type property = alternativa.engine3d.events.MouseEvent3D.CLICK

Dispatched when a user presses and releases left mouse button over the same object.

The value of the type property of a click event object.
mouseDownevent  
Event object type: alternativa.engine3d.events.MouseEvent3D
MouseEvent3D.type property = alternativa.engine3d.events.MouseEvent3D.MOUSE_DOWN

Dispatched when a user presses left mouse button over an object.

The value of the type property of a mouseDown event object.
mouseMoveevent  
Event object type: alternativa.engine3d.events.MouseEvent3D
MouseEvent3D.type property = alternativa.engine3d.events.MouseEvent3D.MOUSE_MOVE

Dispatched when a user moves mouse pointer while it is over an object.

The value of the type property of a mouseMove event object.
mouseOutevent  
Event object type: alternativa.engine3d.events.MouseEvent3D
MouseEvent3D.type property = alternativa.engine3d.events.MouseEvent3D.MOUSE_OUT

Dispatched when a user moves mouse pointer away from an object.

The value of the type property of a mouseOut event object.
mouseOverevent  
Event object type: alternativa.engine3d.events.MouseEvent3D
MouseEvent3D.type property = alternativa.engine3d.events.MouseEvent3D.MOUSE_OVER

Dispatched when a user moves mouse pointer over an object.

The value of the type property of a mouseOver event object.
mouseUpevent  
Event object type: alternativa.engine3d.events.MouseEvent3D
MouseEvent3D.type property = alternativa.engine3d.events.MouseEvent3D.MOUSE_UP

Dispatched when a user releases left mouse button over an object.

The value of the type property of a mouseUp event object.
mouseWheelevent  
Event object type: alternativa.engine3d.events.MouseEvent3D
MouseEvent3D.type property = alternativa.engine3d.events.MouseEvent3D.MOUSE_WHEEL

Dispatched when a user spins mouse wheel over an object.

The value of the type property of a mouseWheel event object.