Loading Custom Mesh fail in one case but not in another case

Software: Other

Ludovic, Jr. Member
Posted: 21 November 2015 08:52 AM   Total Posts: 31

I have two programs that load the same .obj file in an identical way yet in one program the assetType returned is Geometry with a name set to null and no further processing (so no mesh). In the other program the assetType is [asset Geometry] at first but then a second event (not triggered by me) occurs and the assetType on that second event is [asset Mesh]. Network traffic in the browser shows that the .obj file itself has been properly loaded in both case.

Any idea why would that be? I am attaching some snippets of code here:

Both programs initiate the .obj asset loading in that way:

this.token AssetLibrary.load(new URLRequest('_assets/tile.obj'));
this.token.addEventListener(LoaderEvent.RESOURCE_COMPLETE, (event:LoaderEvent) => this.onResourceComplete(event)); 

onResourceComplete() function of broken program:

private onResourceComplete(event:LoaderEvent)
    
{
        
var loader:AssetLoader = <AssetLoaderevent.target;
        var 
l:number loader.baseDependency.assets.length;
        
console.log'away.events.LoaderEvent.RESOURCE_COMPLETE' event lloader );
        for (var 
i:number 0li++) {
            
var asset:IAsset loader.baseDependency.assets[i];
            
console.log("assetType:"asset.assetType"name:"asset.name"url:"event.url);
            
console.log("Mesh.assetType is "Mesh.assetType);
            switch (
asset.assetType{
                
case  Mesh.assetType:
                    
//That case never gets triggered? but it does in the other program that works?
                    
if (event.url =='_assets/tile.obj'{
                        this
._tileMesh =  <Meshasset;
                        
//some code removed for brievety sake here
                    
}
                    
break;
                case 
TextureBase.assetType :
                    
//unrelated and properly working code here has been removed for brievety sake
                    
break;
            
}
        }
    } 

onResourceComplete() function of working program:

public onResourceComplete(event:LoaderEvent//that is taken from one the example program that I simplified a bit
        
var loader:AssetLoader = <AssetLoaderevent.target;
        var 
l:number loader.baseDependency.assets.length;
        
console.log('away.events.LoaderEvent.RESOURCE_COMPLETE'eventlloader);
        for (var 
c:number 0lc++) {
            
var asset:IAsset loader.baseDependency.assets[c];
            
console.log("assetType:"asset.assetType"name:"asset.name"url:"event.url);
            switch (
asset.assetType{
                
case  Mesh.assetType:
                    
//That case gets triggered in that program
                    
if (event.url == '_assets/tile.obj'{
                        
var mesh:Mesh = <Meshasset;
                        
//some code removed for brievety sake here
                    
}
                    
break;
                case 
TextureBase.assetType :
                    
//unrelated and properly working code here has been removed for brievety sake
                    
break;
            
}
        }
        
if (this.mat && this.spartanFlag)
            for (var 
c:number 0this.meshes.lengthc++)
                
this.meshes[c].material this.mat;
        
this.view.scene.addChild(this.doc);
    
   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X