Starling to access Away3d view

Software: Away3D 4.x

Tayyab, Member
Posted: 04 September 2012 06:36 AM   Total Posts: 72

How do i access view3d view, scene, lightpicker and all the other properties of Away3d in Starling.

/**
 * Constructor
 */
public function Away3DTemplate()
{
 addEventListener
(Event.ADDED_TO_STAGEaddedToStage);
}

/**
 * Global initialise function
 */
private function addedToStage(e:Event):void 
{
 stage
.scaleMode StageScaleMode.NO_SCALE;
 
stage.align StageAlign.TOP_LEFT;
 if (
STARLING_ENABLED)
  
initProxies();
 else
  
onContextCreated(null);
}

/**
 * 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_CREATEDonContextCreated);
 
stage3DProxy.antiAlias 8;
 
stage3DProxy.color 0x0;
}

private function onContextCreated(e:Stage3DEvent):void 
{
 initEngine
();
 if (
STARLING_ENABLED)
  
initStarling();
 
initLights();
 
initMaterials();
 
initObjects();
 
initListeners();
 
initGVC();
 
buildTerrain();
 
 
initMain();
}

private function initMain():void 
{
 
/*var stage1Panel:Stage1Panel = new Stage1Panel(scene, view, lightPicker);
 addChild(stage1Panel);
 //stage1Panel.x = stage.stageWidth/2;
 TweenMax.fromTo(stage1Panel, 0.5, { alpha:0, x:-50 }, { alpha:1, x:0 } );*/
 

 
}

private function initStarling():void 
{
 userInterface 
= new Starling(Interface, stagestage3DProxy.viewPortstage3DProxy.stage3D);
 
 
userInterface.start();
 
//this.stage.addEventListener(Event.RESIZE, stage_resizeHandler, false, int.MAX_VALUE, true);

now how can i acces the variables created here by the userInterface class which is a starling class???

at the moment i have got a global variables class which stores the view and respective variables of away3d and then i access it from starling, which i don’t think is the right way to do it?

   

Avatar
Greg Caldwell (Greg209), Administrator
Posted: 04 September 2012 08:53 AM   Total Posts: 45   [ # 1 ]

Hi Tayyab,

There are going to be various ways to do this but my current preference, in your example, to expose a static getInstance() method on your Starling Interface class to the be able access properties on the STarling side.

In the Interface constructor, you then simply assign the static to ‘this’.

private static var _instance:Interface;

public static function getInstance() : void { return _instance; }

Public function Interface() {
  _instance = this;
  .....

Or something along those lines. You can then access Starling UI properties for your 3D rendering.

Hope that helps.

Greg

 Signature 

Home page : http://www.geepers.co.uk
Mobile apps : Sum It All Up

   

Tayyab, Member
Posted: 04 September 2012 09:24 AM   Total Posts: 72   [ # 2 ]

I have got more classes which are called by the interface class, do I then have to get their instances as well ? I was a thinking of some how getting the away3d instance and do all stuff to away3D from the the starling classes

Would that be a good approach?

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X