Packageaway3d.containers
Classpublic class View3D
InheritanceView3D Inheritance flash.display.Sprite

Sprite container used for storing camera, scene, session, renderer and clip references, and resolving mouse events

Public Properties
 PropertyDefined by
  background : Sprite
A background sprite positioned under the rendered scene.
View3D
  blockerarray : BlockerArray
View3D
  blockers : Dictionary
View3D
  camera : Camera3D
Camera used when rendering.
View3D
  cameraVarsStore : CameraVarsStore
[read-only]
View3D
  clipping : Clipping
Clipping area used when rendering.
View3D
  drawPrimitiveStore : DrawPrimitiveStore
[read-only]
View3D
  forceUpdate : Boolean
Defines whether the view always redraws on a render, or just redraws what 3d objects change.
View3D
  hud : Sprite
A container for 2D overlays positioned over the rendered scene.
View3D
  mouseEvents : Boolean
Enables/Disables mouse interactivity.
View3D
  mouseMaterial : IUVMaterial
Current material under the mouse.
View3D
  mouseObject : Object3D
Current object under the mouse.
View3D
  mouseZeroMove : Boolean
Forces mousemove events to fire even when cursor is static.
View3D
  overlay : Sprite
An overlay sprite positioned on top of the rendered scene.
View3D
  renderer : IRenderer
Renderer object used to traverse the scenegraph and output the drawing primitives required to render the scene to the view.
View3D
  scene : Scene3D
Scene used when rendering.
View3D
  screenClipping : Clipping
[read-only]
View3D
  session : AbstractRenderSession
Session object used to draw all drawing primitives returned from the renderer to the view container.
View3D
  sourceURL : String
Optional string for storing source url.
View3D
  stats : Boolean
Enables/Disables stats panel.
View3D
  statsOpen : Boolean
Keeps track of whether the stats panel is currently open.
View3D
  statsPanel : Stats
Object instance of the stats panel.
View3D
  updated : Boolean
[read-only] Flag used to determine if the camera has updated the view.
View3D
Public Methods
 MethodDefined by
  
View3D
(init:Object = null)
Creates a new View3D object.
View3D
  
addOnMouseDown(listener:Function):void
Default method for adding a mouseDown3d event listener.
View3D
  
addOnMouseMove(listener:Function):void
Default method for adding a mouseMove3d event listener.
View3D
  
addOnMouseOut(listener:Function):void
Default method for adding a 3d mouseOut event listener.
View3D
  
addOnMouseOver(listener:Function):void
Default method for adding a 3d mouseOver event listener.
View3D
  
addOnMouseUp(listener:Function):void
Default method for adding a mouseUp3d event listener.
View3D
  
addOverlay(value:IOverlay):void
Adds an overlay effect on top of the view container.
View3D
  
addSourceURL(url:String):void
Defines a source url string that can be accessed though a View Source option in the right-click menu.
View3D
  
clear():void
Clears previously rendered view from all render sessions.
View3D
  
findHit(session:AbstractRenderSession, x:Number, y:Number):void
Finds the object that is rendered under a certain view coordinate.
View3D
  
fireMouseEvent(type:String, x:Number, y:Number, ctrlKey:Boolean = false, shiftKey:Boolean = false):void
Collects all information from the given type of 3d mouse event into a MouseEvent3D object that can be accessed from the getMouseEvent() method.
View3D
  
fireMouseMoveEvent(force:Boolean = false):void
Manually fires a mouseMove3D event.
View3D
  
getBitmapData():BitmapData
Returns the bitmapData of the rendered scene.
View3D
  
getContainer():DisplayObject
Returns the DisplayObject container of the rendered scene.
View3D
  
Returns a 3d mouse event object populated with the properties from the hit point.
View3D
  
removeOnMouseDown(listener:Function):void
Default method for removing a mouseDown3d event listener.
View3D
  
removeOnMouseMove(listener:Function):void
Default method for removing a mouseMove3D event listener.
View3D
  
removeOnMouseOut(listener:Function):void
Default method for removing a 3d mouseOut event listener.
View3D
  
removeOnMouseOver(listener:Function):void
Default method for removing a 3d mouseOver event listener.
View3D
  
removeOnMouseUp(listener:Function):void
Default method for removing a 3d mouseUp event listener.
View3D
  
removeOverlay(value:IOverlay):void
Removes an overlay effect on top of the view container.
View3D
  
render():void
Renders a snapshot of the view to the render session's view container.
View3D
  
View3D
Events
 EventSummaryDefined by
   Dispatched when a user presses the let hand mouse button while the cursor is over a 3d object View3D
   Dispatched when a user moves the cursor while it is over a 3d object View3D
   Dispatched when a user moves the cursor away from a 3d object View3D
   Dispatched when a user moves the cursor over a 3d object View3D
   Dispatched when a user releases the let hand mouse button while the cursor is over a 3d object View3D
Property detail
backgroundproperty
public var background:Sprite

A background sprite positioned under the rendered scene.

blockerarrayproperty 
public var blockerarray:BlockerArray
blockersproperty 
public var blockers:Dictionary
cameraproperty 
camera:Camera3D  [read-write]

Camera used when rendering.

Implementation
    public function get camera():Camera3D
    public function set camera(value:Camera3D):void

See also

cameraVarsStoreproperty 
cameraVarsStore:CameraVarsStore  [read-only]
Implementation
    public function get cameraVarsStore():CameraVarsStore
clippingproperty 
clipping:Clipping  [read-write]

Clipping area used when rendering. If null, the visible edges of the screen are located with the Clipping.screen() method.

Implementation
    public function get clipping():Clipping
    public function set clipping(value:Clipping):void

See also

render()
away3d.core.render.Clipping.scene()
drawPrimitiveStoreproperty 
drawPrimitiveStore:DrawPrimitiveStore  [read-only]
Implementation
    public function get drawPrimitiveStore():DrawPrimitiveStore
forceUpdateproperty 
public var forceUpdate:Boolean

Defines whether the view always redraws on a render, or just redraws what 3d objects change. Defaults to false.

See also

hudproperty 
public var hud:Sprite

A container for 2D overlays positioned over the rendered scene.

mouseEventsproperty 
public var mouseEvents:Boolean

Enables/Disables mouse interactivity.

mouseMaterialproperty 
public var mouseMaterial:IUVMaterial

Current material under the mouse.

mouseObjectproperty 
public var mouseObject:Object3D

Current object under the mouse.

mouseZeroMoveproperty 
public var mouseZeroMove:Boolean

Forces mousemove events to fire even when cursor is static.

overlayproperty 
public var overlay:Sprite

An overlay sprite positioned on top of the rendered scene.

rendererproperty 
renderer:IRenderer  [read-write]

Renderer object used to traverse the scenegraph and output the drawing primitives required to render the scene to the view.

Implementation
    public function get renderer():IRenderer
    public function set renderer(value:IRenderer):void
sceneproperty 
scene:Scene3D  [read-write]

Scene used when rendering.

Implementation
    public function get scene():Scene3D
    public function set scene(value:Scene3D):void

See also

render()
screenClippingproperty 
screenClipping:Clipping  [read-only]
Implementation
    public function get screenClipping():Clipping
sessionproperty 
session:AbstractRenderSession  [read-write]

Session object used to draw all drawing primitives returned from the renderer to the view container.

Implementation
    public function get session():AbstractRenderSession
    public function set session(value:AbstractRenderSession):void

See also

sourceURLproperty 
public var sourceURL:String

Optional string for storing source url.

statsproperty 
public var stats:Boolean

Enables/Disables stats panel.

See also

statsOpenproperty 
public var statsOpen:Boolean

Keeps track of whether the stats panel is currently open.

See also

statsPanelproperty 
public var statsPanel:Stats

Object instance of the stats panel.

See also

updatedproperty 
updated:Boolean  [read-only]

Flag used to determine if the camera has updated the view.

Implementation
    public function get updated():Boolean

See also

Constructor detail
View3D()constructor
public function View3D(init:Object = null)
Parameters
init:Object (default = null) — [optional] An initialisation object for specifying default instance properties.
Init Parameters
 stats:Boolean (default = true)
 session:Object
 scene:ObjectOrInit (default = Scene3D)
 camera:ObjectOrInit (default = Camera3D)
 renderer:Object
 clipping:Object (default = Clipping)
 x:Number (default = 0)
 y:Number (default = 0)
 forceUpdate:Boolean (default = false)
 mouseZeroMove:Boolean (default = false)
 mouseEvents:Boolean (default = true)
Method detail
addOnMouseDown()method
public function addOnMouseDown(listener:Function):void

Default method for adding a mouseDown3d event listener.

Parameters
listener:Function — The listener function.
addOnMouseMove()method 
public function addOnMouseMove(listener:Function):void

Default method for adding a mouseMove3d event listener.

Parameters
listener:Function — The listener function.
addOnMouseOut()method 
public function addOnMouseOut(listener:Function):void

Default method for adding a 3d mouseOut event listener.

Parameters
listener:Function — The listener function.
addOnMouseOver()method 
public function addOnMouseOver(listener:Function):void

Default method for adding a 3d mouseOver event listener.

Parameters
listener:Function — The listener function.
addOnMouseUp()method 
public function addOnMouseUp(listener:Function):void

Default method for adding a mouseUp3d event listener.

Parameters
listener:Function — The listener function.
addOverlay()method 
public function addOverlay(value:IOverlay):void

Adds an overlay effect on top of the view container.

Parameters
value:IOverlay
addSourceURL()method 
public function addSourceURL(url:String):void

Defines a source url string that can be accessed though a View Source option in the right-click menu. Requires the stats panel to be enabled.

Parameters
url:String — The url to the source files.
clear()method 
public function clear():void

Clears previously rendered view from all render sessions.

See also

findHit()method 
public function findHit(session:AbstractRenderSession, x:Number, y:Number):void

Finds the object that is rendered under a certain view coordinate. Used for mouse click events.

Parameters
session:AbstractRenderSession
 
x:Number
 
y:Number
fireMouseEvent()method 
public function fireMouseEvent(type:String, x:Number, y:Number, ctrlKey:Boolean = false, shiftKey:Boolean = false):void

Collects all information from the given type of 3d mouse event into a MouseEvent3D object that can be accessed from the getMouseEvent() method.

Parameters
type:String — The type of 3d mouse event being triggered - can be MOUSE_UP, MOUSE_DOWN, MOUSE_OVER, MOUSE_OUT, and MOUSE_MOVE.
 
x:Number — The x coordinate being used for the 3d mouse event.
 
y:Number — The y coordinate being used for the 3d mouse event.
 
ctrlKey:Boolean (default = false) — [optional] The ctrl key value being used for the 3d mouse event.
 
shiftKey:Boolean (default = false) — [optional] The shift key value being used for the 3d mouse event.

See also

fireMouseMoveEvent()method 
public function fireMouseMoveEvent(force:Boolean = false):void

Manually fires a mouseMove3D event.

Parameters
force:Boolean (default = false)
getBitmapData()method 
public function getBitmapData():BitmapData

Returns the bitmapData of the rendered scene. session is required to be an instance of BitmapRenderSession, otherwise an error is thrown.

Returns
BitmapData — The rendered view image.

Throws
— incorrect session object - require BitmapRenderSession.

See also

getContainer()method 
public function getContainer():DisplayObject

Returns the DisplayObject container of the rendered scene.

Returns
DisplayObject — The DisplayObject containing the output from the render session of the view.

See also

getMouseEvent()method 
public function getMouseEvent(type:String):MouseEvent3D

Returns a 3d mouse event object populated with the properties from the hit point.

Parameters
type:String

Returns
MouseEvent3D
removeOnMouseDown()method 
public function removeOnMouseDown(listener:Function):void

Default method for removing a mouseDown3d event listener.

Parameters
listener:Function — The listener function.
removeOnMouseMove()method 
public function removeOnMouseMove(listener:Function):void

Default method for removing a mouseMove3D event listener.

Parameters
listener:Function — The listener function.
removeOnMouseOut()method 
public function removeOnMouseOut(listener:Function):void

Default method for removing a 3d mouseOut event listener.

Parameters
listener:Function — The listener function.
removeOnMouseOver()method 
public function removeOnMouseOver(listener:Function):void

Default method for removing a 3d mouseOver event listener.

Parameters
listener:Function — The listener function.
removeOnMouseUp()method 
public function removeOnMouseUp(listener:Function):void

Default method for removing a 3d mouseUp event listener.

Parameters
listener:Function — The listener function.
removeOverlay()method 
public function removeOverlay(value:IOverlay):void

Removes an overlay effect on top of the view container.

Parameters
value:IOverlay
render()method 
public function render():void

Renders a snapshot of the view to the render session's view container.

See also

updateScreenClipping()method 
public function updateScreenClipping():void
Event detail
mouseDownevent 
Event object type: away3d.events.MouseEvent3D

Dispatched when a user presses the let hand mouse button while the cursor is over a 3d object

mouseMoveevent  
Event object type: away3d.events.MouseEvent3D

Dispatched when a user moves the cursor while it is over a 3d object

mouseOutevent  
Event object type: away3d.events.MouseEvent3D

Dispatched when a user moves the cursor away from a 3d object

mouseOverevent  
Event object type: away3d.events.MouseEvent3D

Dispatched when a user moves the cursor over a 3d object

mouseUpevent  
Event object type: away3d.events.MouseEvent3D

Dispatched when a user releases the let hand mouse button while the cursor is over a 3d object

Wiki link
Click to go to the wiki page for 'away3d.containers.View3D'

Code examples

Embedding Away3D in Flex  based on V2.2 

Custom MXML component (viewport.mxml) that makes it really easy to add Away3D support to any Flex app. Just save the component to your projects folder, drag the component on stage, position / scale the viewport, name the instance and you are ready to go.

The ID of the component is what you'll use to target the Viewport, so if you name the component "Away3D", you can now set the zoom with this command:
Away3D.view.camera.zoom = 3;

Source Files : http://www.flashgamer.com/2008/08/using_away3d_inside_a_flex_app.html

Finding an object\'s 2D bounds.  based on V2.2 

Here's a way to use the Session object within your View3D to find the bounds of an object you've drawn to the screen with view.render(). This example is built for a single object, in my case an imported OBJ file. The coordinates returned are relative to (this), the movie within which the view object is contained.

Here's a way to get the 2D bounds of an object you've drawn to your view.

	// view has been defined previously, it's our View3D object.
	var sessionContainer:DisplayObjectContainer = view.session.getContainer(view) as DisplayObjectContainer;
	var drawnObject = sessionContainer.getChildAt(0);
	var viewBounds = drawnObject.getRect(this);
	trace("vb: " + viewBounds.left + "," + viewBounds.top + "/" + viewBounds.right + "," +viewBounds.bottom);

Complete View3D example  based on V2.0 

package
{
    import away3d.containers.View3D;
    import away3d.primitives.Sphere;
    import flash.display.Sprite;
    
    public class Basic01 extends Sprite
    {
        public function Basic01()
        {
            // create a viewport
            var view:View3D = new View3D({x:275,y:200});
            addChild(view);
            
            // create a sphere and put it on the 3D stage
            var sphere:Sphere = new Sphere();
            view.scene.addChild(sphere);
            
            // render the view
            view.render();
        }
    }
}

This code will create a new viewport (View3D), set it up and render a sphere. The x/y parameters passed to View3D should be exactly half the width/height of your SWF, so {x:275,y:200} is correct for the standard 550x400 pixel Flash Movie.

Place View3D in the middle of your SWF  based on V1.9.2 

var swd:Number=640;
var swh:Number=480;
var view:View3D=new View3D({x:swd / 2,y:swh / 2});

Comments
No comments found
Please leave a comment

Please leave a comment

security image