Mesh from AWD only loaded partially

Software: Away3D 4.x

3d d, Newbie
Posted: 18 February 2014 03:38 PM   Total Posts: 1

Hello,

I’m trying to load a mesh of a track segment. However sometimes only a random part is being displayed ( sometimes it’s shown fully)

I’m using the following code to load 1 straight and 1 curve segment from 2 embedded AWDs:

public class Prefabs {
private static var _tracksMeshes:Vector.<Mesh> = new Vector.<Mesh>(6);
[Embed(source="/../embed/track_curve.awd"mimeType="application/octet-stream")]
  
private static var TrackCurve:Class;
  
  
[Embed(source="/../embed/track_straight.awd"mimeType="application/octet-stream")]
  
private static var TrackStraight:Class;

                private static var 
_isCurveTrackLoaded:Boolean false;
  private static var 
_isStraightTrackLoaded:Boolean false;
  
  
  
{
   Parsers
.enableAllBundled();
   
   
AssetLibrary.getBundle("2").addEventListener(AssetEvent.ASSET_COMPLETE_onAssetCompleteCurve);
   
AssetLibrary.getBundle("2").loadData(new TrackCurve());
   
   
AssetLibrary.getBundle("1").addEventListener(AssetEvent.ASSET_COMPLETE_onAssetCompleteStraight);
   
AssetLibrary.getBundle("1").loadData(new TrackStraight());
  
}
  
  
private static var _onAssetCompleteCurve:Function = function(e:AssetEvent):void {
   
if (e.asset is Mesh{
    
var baseMesh:Mesh e.asset as Mesh;
    
    
_tracksMeshes[2+0] baseMesh.clone() as Mesh;
    
_tracksMeshes[2+0].rotationY =90;
    
_tracksMeshes[2+1] baseMesh.clone() as Mesh;
    
_tracksMeshes[2+1].rotationY =270;
    
_tracksMeshes[2+1].+= 40;
    
_tracksMeshes[2+1].-= 40;
    
    
_tracksMeshes[4+0] baseMesh.clone() as Mesh;
    
_tracksMeshes[4+1] baseMesh.clone() as Mesh;
    
_tracksMeshes[4+1].moveRight(40);
    
_tracksMeshes[4+1].moveForward(40);
    
_tracksMeshes[4+1].rotationY =180;
    
    
    
    
_isCurveTrackLoaded true;
   
}
  }
  
  
private static var _onAssetCompleteStraight:Function = function(e:AssetEvent):void {
   
if (e.asset is Mesh{
    
var baseMesh:Mesh e.asset as Mesh;
    
_tracksMeshes[0+0] baseMesh.clone() as Mesh;
    
_tracksMeshes[0+1] baseMesh.clone() as Mesh;
    
_tracksMeshes[0+1].rotationY 90;
    
_isStraightTrackLoaded true;
   
}
  }
  
  
public static function isReady():Boolean {
   
return (_isCurveTrackLoaded && _isStraightTrackLoaded);
  
}

I’m loading from another class:

_waitStart();

private function 
_waitStart():void {
 
if (!Prefabs.isReady())
  
setTimeout(function():void { _waitStart() }100);
 else
 
_showSample();
}

private function _showSample():void {
_view
.scene.addChild(_tracksMeshes[0].clone());
_view.scene.addChild(_tracksMeshes[1].clone());
_view.scene.addChild(_tracksMeshes[2].clone());
_view.scene.addChild(_tracksMeshes[3].clone());
_view.scene.addChild(_tracksMeshes[4].clone());
_view.scene.addChild(_tracksMeshes[5].clone());

addEventListener(Event.ENTER_FRAME_onEnterFrame);
}

private function _onEnterFrame(e:Event):void {
 _view
.render();

How can I make sure that the mesh is loaded completely??

 

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X