asset always displayed in wrong viewport

Software: Away3D 4.x

seti3d, Newbie
Posted: 13 March 2013 09:21 AM   Total Posts: 19

Hi Guys!
I work with two cameras. The first one uses the top 95% of the display and the second camera the 5% at the bottom for displaying menus and so.
My object has been embedded in the code and is displayed in the top part of the display (called topView). At the bottom part of the display (called bottomView) I created a simple CubeGeometry for testing purposes. Everything works perfect, e.g. when clicking the cube the cubes alpha value changes to make it transparent.
But now my problem:
When importing a second AWD it will always be displayed in my topView next to the first AWD file although I add it with the same syntax I added the cube:
bottomView.scene.addChild(slider);

Then I thought it could be the sliders position - so I changed it. What happened? Both imported objects moved to the bottomView.

I coded my problem in this way:

[Embed(source=..., mymeType=...]  --> my first AWD
private var importObject : Class;
[Embed(source=..., mymeType=...]   --> second AWD
private var regler : Class;
private var 
topView:View3D;
private var 
bottomView:View3D;
private var 
schieber:Mesh;
private var 
object:Mesh;
.....
private function 
setupMultiView():void
{
    
...
    var 
camera1:Camera3D = new Camera3D(lens);
    ...
    var 
camera2:Camera3D = new Camera3D();
    ...
    
topView = new View3D(scene,camera1);
    
topView.height stage.stageHeight*.95;
    
addChild(topView);
    
bottomView = new View3D(scene,camera2);
    
bottomView.height=stage.stageHeight*.05;
    ...
}
private function objectLoad() : void
{
    Parsers
.enableAllBundled();
    
AssetLibrary.addEventListener(AssetEvent.ASSET_COMPLETEonAssetComplete);
    
AssetLibrary.loadData(new importObject() ); --> first AWD
}
private function objectLoad2():void
{
    Parsers
.enableAllBundled();
    
AssetLibrary.addEventListener(AssetEvent.ASSET_COMPLETEonAssetComplete2);
    
AssetLibrary.loadData(new regler() ); --> second AWD
}
private function onAssetComplete(ev:AssetEvent) : void
{
    removeEventListener
(AssetEvent.ASSET_COMPLETEonAssetComplete); 
    
object ev.asset as Mesh;
    
object.scale(1);    
    
topView.scene.addChild(object); -->first AWD in topView
}
private function onAssetComplete2(ev2:AssetEvent) : void
{
    removeEventListener
(AssetEvent.ASSET_COMPLETEonAssetComplete2); 
    
schieber ev2.asset as Mesh;
    
schieber.scale(0.1);
    
bottomView.scene.addChild(schieber);-->second AWD in topView

If I call objectLoad() the AWD will be shown in topView. If I call objectLoad2() the AWD will also be shown in topView.

But when I change the function onAssetComplete2 and change the position of the second imported AWD the position of the first loaded AWD changes too.

Does anyone know where I do the mistake?

   

seti3d, Newbie
Posted: 13 March 2013 10:12 AM   Total Posts: 19   [ # 1 ]

Hi again!
I changed my code to try using namespaces. I just use one loading function:

... 
private function 
objectLoad():void
{
    Parsers
.enableAllBundled();
    
AssetLibrary.addEventListener(AssetEvent.ASSET_COMPLETEonAssetComplete);
    
AssetLibrary.loadData(new importObject(), null"Tank");
    
AssetLibrary.loadData(new regler(), null"Slider");
}
private function onAssetComplete(ev:AssetEvent):void
{
    removeEventListener
(...);
    if (
ev.asset.assetNamespace == "Tank")
    
{
        object 
ev.asset as Mesh;
        
object.scale(1);
        
topView.scene.addChild(object);
    
}
    
if (ev.asset.assetNamespace == "Slider")
    
{
        schieber 
ev.asset as Mesh;
        
bottomView.scene.addChild(schieber);
    
}

But it is the same like before. Both objects will be displayed in the topView.

   

seti3d, Newbie
Posted: 13 March 2013 11:08 AM   Total Posts: 19   [ # 2 ]

I got it. The second example works with position change of the AWD to display it in the second viewport:

private function onAssetComplete(ev:AssetEvent):void
{
    removeEventListener
(...);
    if (
ev.asset.assetNamespace == "Tank")
    
{
        object 
ev.asset as Mesh;
        
object.scale(1);
        
topView.scene.addChild(object);
    
}
    
if (ev.asset.assetNamespace == "Slider")
    
{
        schieber 
ev.asset as Mesh;

        
schieber.position = new Vector3d(-3000,3000,0);

        
bottomView.scene.addChild(schieber);
    
}

 

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X