Hi. This is my code of 3 proxy view3d. It’s work nice, but how i can change order of this view3d layers? And i need render to bitmap away3dView layer whith alpha channel. Please help me.
package
{
import away3d.containers.*;
import away3d.controllers.*;
import away3d.core.managers.*;
import away3d.debug.*;
import away3d.entities.*;
import away3d.events.*;
import away3d.materials.*;
import away3d.primitives.*;
import away3d.textures.*;
import flash.display.*;
import flash.events.*;
import flash.text.*;
import away3d.filters.BlurFilter3D;
public class proxy3d extends Sprite
{
// Stage manager and proxy instances
private var stage3DManager:Stage3DManager;
private var stage3DProxy:Stage3DProxy;
// Away3D view instances
private var away3dViewbgr:View3D;
private var away3dView:View3D;
private var away3dView2:View3D;
// Camera controllers
private var hoverController:HoverController;
// Materials
private var cubeMaterial:TextureMaterial;
// Objects
private var cube1:Mesh;
private var cube2:Mesh;
private var cube3:Mesh;
private var cube4:Mesh;
private var cube5:Mesh;
private var cube6:Mesh;
private var fil:BlurFilter3D;
/**
* Constructor
*/
public function proxy3d()
{
init();
}
/**
* Global initialise function
*/
private function init():void
{
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
initProxies();
}
/**
* Initialise the Stage3D proxies
*/
private function initProxies():void
{
// Define a new Stage3DManager for the Stage3D objects
stage3DManager = Stage3DManager.getInstance(stage);
// Create a new Stage3D proxy to contain the separate views
stage3DProxy = stage3DManager.getFreeStage3DProxy();
stage3DProxy.addEventListener(Stage3DEvent.CONTEXT3D_CREATED, onContextCreated);
stage3DProxy.antiAlias = 8;
}
private function onContextCreated(event:Stage3DEvent):void
{
initAway3D();
initAway3D2();
initAway3Dbgr();
initMaterials();
initObjects();
initListeners();
}
/**
* Initialise the Away3D views
*
**
*/
private function initAway3Dbgr():void
{
// Create the first Away3D view which holds the cube objects.
away3dViewbgr = new View3D();
away3dViewbgr.stage3DProxy = stage3DProxy;
away3dViewbgr.shareContext = true;
away3dViewbgr.backgroundColor = 0xcccccc; ///bgr color
var fil:BlurFilter3D = new BlurFilter3D(10, 10);
away3dViewbgr.filters3d = [fil];
hoverController = new HoverController(away3dViewbgr.camera, null, 45, 30, 1200, 5, 89.999);
addChild(away3dViewbgr);
}
private function initAway3D():void
{
// Create the first Away3D view which holds the cube objects.
away3dView = new View3D();
away3dView.stage3DProxy = stage3DProxy;
away3dView.shareContext = true;
hoverController = new HoverController(away3dView.camera, null, 45, 30, 1200, 5, 89.999);
addChild(away3dView);
}
private function initAway3D2():void
{
// Create the first Away3D view which holds the cube objects.
away3dView2 = new View3D();
away3dView2.stage3DProxy = stage3DProxy;
away3dView2.shareContext = true;
hoverController = new HoverController(away3dView2.camera, null, 45, 30, 1200, 5, 89.999);
addChild(away3dView2);
}
/**
* Initialise the materials
*/
private function initMaterials():void
{
//Create a material for the cubes
var cubeBmd:BitmapData = new BitmapData(128, 128, false, 0x0);
cubeBmd.perlinNoise(7, 7, 5, 12345, true, true, 7, true);
cubeMaterial = new TextureMaterial(new BitmapTexture(cubeBmd));
cubeMaterial.gloss = 20;
cubeMaterial.ambientColor = 0x808080;
cubeMaterial.ambient = 1;
}
private function initObjects():void
{
// Build the cubes for view 1
var cG:CubeGeometry = new CubeGeometry(300, 300, 300);
cube1 = new Mesh(cG, cubeMaterial);
cube2 = new Mesh(cG, cubeMaterial);
cube3 = new Mesh(cG, cubeMaterial);
cube4 = new Mesh(cG, cubeMaterial);
cube5 = new Mesh(cG, cubeMaterial);
cube6 = new Mesh(cG, cubeMaterial);
// Arrange them in a circle with one on the center
cube1.x = -750;
cube2.z = -750;
cube3.x = 750;
cube4.z = 750;
cube1.y = cube2.y = cube3.y = cube4.y = cube5.y = 150;
// Add the cubes to view 1
away3dView.scene.addChild(cube1);
away3dView.scene.addChild(cube2);
away3dView.scene.addChild(cube3);
away3dView.scene.addChild(cube4);
away3dView.scene.addChild(new WireframePlane(2500, 2500, 20, 20, 0x000000, 1.5, WireframePlane.ORIENTATION_XZ));
cube6.x = 200;
away3dViewbgr.scene.addChild(cube6);
cube5.x = -150;
away3dView2.scene.addChild(cube5);
}
private function initListeners():void
{
stage3DProxy.addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
private function onEnterFrame(event:Event):void
{
//order 0
away3dViewbgr.render(); //blured cube and background color
//order 1 2???
away3dView2.render(); //1 cube
//order 2 1???
away3dView.render(); //4 cubes and WireframePlane
}
}
}