Can’t Load Model

Software: Away3D 4.x

TomByrne, Newbie
Posted: 10 November 2011 01:38 PM   Total Posts: 11

I have a very simple model (one small cylinder) which was modeled in Sketchup. I have attempted to load the OBJ file exported from Sketchup unsuccessfully.

I then ran the model through PreFab (which opened it fine) and attempted to load it in both OBJ and AC3D, as exported by Prefab, but was again unsuccessful.

In all cases the ‘Resource Complete’ event never gets fired.

I am using a URLLoader to load the model file initially and then Loader3D.loadData to parse the loaded ByteArray.

Something like this:

var loader:URLLoader = new URLLoader();
loader.dataFormat URLLoaderDataFormat.BINARY;
loader.load(new URLRequest(fileUrl));
loader.addEventListener(Event.COMPLETEonLoaded);

function 
onLoaded(e:Event):void{
 
var loader3D = new Loader3D();
 
loader3D.addEventListener(LoaderEvent.RESOURCE_COMPLETEonResourceComplete);
 
container.addChild(_loader);
 
loader3D.loadData(_objLoaderModel.data, new AssetLoaderContext(false),null,new OBJParser());
}

protected function onResourceComplete(event:Event):void{
 trace
("This never gets called");


I’ve attached the Prefab exported OBJ files, as I assume they’re the most likely to work.

Any help would be greatly appreciated.

 

File Attachments
CasterWheel.zip  (File Size: 3KB - Downloads: 150)
   

Leo Brennan, Newbie
Posted: 10 November 2011 03:59 PM   Total Posts: 20   [ # 1 ]

It works for me, I am using this code:

private function loadResources() : void
  {
   AssetLibrary
.enableParser(OBJParser);
   
AssetLibrary.addEventListener(LoaderEvent.RESOURCE_COMPLETEonResourceComplete);
   
AssetLibrary.addEventListener(AssetEvent.ASSET_COMPLETEonAssetComplete);
   
AssetLibrary.load(new URLRequest("ObjFiles/CasterWheel.obj"));
  
}
  
  
private function onResourceComplete(event:LoaderEvent):void {
   
///trace("in onResourceComplete: "+event.url+" type: "+event.type);
  
}
  
  
private function onAssetComplete(event:AssetEvent):void
  {
   
//trace("in onAssetComplete, assetType: "+event.asset.assetType+" name: "+event.asset.name+" name space: "+event.asset.assetNamespace);
   
if (event.asset.assetType == AssetType.MESH)
   
{
    
var mesh:Mesh event.asset as Mesh;
    
mesh.scaleX 200.0;
    
mesh.scaleY 200.0;
    
mesh.scaleZ 200.0;
    
mesh.= -1000;
    
_scene.addChild(mesh);
   
}
  } 
   

Avatar
Fabrice Closier, Administrator
Posted: 10 November 2011 04:18 PM   Total Posts: 1265   [ # 2 ]

make sure you run the latest version from github. In a not so far past, indeed the complete event was not triggered with small files (usually the kind of files that were parsed entirely in a single frame). Also, add error events, after all, they are there to give you valuable hints on whats going on…

   

Jack Dracon, Newbie
Posted: 11 November 2011 01:08 PM   Total Posts: 27   [ # 3 ]

Missing the enableParser(OBJParser) in your code, I guess.
(Leo suggested a good code to put the object on the world).
Good Lucky !

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X