Can’t instanciate loaded models with Away3D v4

Software: Away3D 4.x

Aloex666, Newbie
Posted: 28 January 2012 11:44 AM   Total Posts: 9

Hey guys,

I’m searching in forums many many hours but can’t find an answer.
I’m programming a test application to check out the performance of Stage3D. During the performancetest, Flash automatically adds Cubes on the Stage and rotate them.
With the cube Primitive it works very well. In a function (attachModel), called every second, I create, position and scale a Cube by saying

_cube = new Cube();
_view.scene.addChild(_cube); 

Now I want to load a model in my constructor function and create an instance of it in the same function, like I did it with the cubes. This is what I have written:

//constructor Function....
Loader3D.enableParser(Max3DSParser);
_loader = new Loader3D();
var 
_request:URLRequest = new URLRequest("../assets/utah_teapot/utah_teapot_992.3ds");
_loader.addEventListener(LoaderEvent.RESOURCE_COMPLETEonResourceComplete);   _loader.load(_request);

//attachModel Function...
var _model:Mesh _loader.getChildAt(0) as Mesh;
_model.0;
_model.0;
_model.0;
_model.scale(1); 

When i first call attachModel it works very well. I see my teapot.
At the second call, the Flash Debugger says:

" RangeError: Error #1125: The index 0 is out of range 0." 

I found out, that when I trace _loader.numChildren Flash says that at the first call the number is 1. At the second call it’s 0. And I don’t know why the model is out of the loader.

So finally, my question is:
can I load a 3ds-model once and use it many times, without loading it again for each function-call?!

P.S. the Away3D-Exporter Classes don’t work for Away3D 4, am I right?

 

   

_kihu, Jr. Member
Posted: 01 February 2012 11:45 AM   Total Posts: 43   [ # 1 ]

 
Try sth like this:

var assetLoaderContext:AssetLoaderContext = new AssetLoaderContext();
Loader3D.enableParser(Max3DSParser);
loader3D = new Loader3D();
loader3D.addEventListener(AssetEvent.ASSET_COMPLETEonSuccess);
loader3D.load(new URLRequest(modelUrl),assetLoaderContext);

private function 
onSuccess(e:AssetEvent):void{

if (e.asset.assetType == AssetType.MESH{
 
var mesh:Mesh e.asset as Mesh;
 
mesh.castsShadows true;
 var 
obj:Object3D mesh.clone();
}
   

Aloex666, Newbie
Posted: 01 February 2012 11:50 AM   Total Posts: 9   [ # 2 ]

thank you I will try it smile smile

   

Aloex666, Newbie
Posted: 01 February 2012 12:50 PM   Total Posts: 9   [ # 3 ]

Ok, it works really nice with .clone()!
Now I just wondered why I don’t see anything, but there wasn’t a texture on my mesh. :D

Thank you smile

   

Aloex666, Newbie
Posted: 01 February 2012 05:04 PM   Total Posts: 9   [ # 4 ]

One question remains:

Is _view.antiAlias = 2 comparable to 2x AntiAlaising like you find it at Game MenĂ¼s?!

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X