Loader3D and changing mesh material

Software: Away3D 4.x

fmax, Newbie
Posted: 20 October 2013 09:30 AM   Total Posts: 10

Hi!
I can’t change the material in a model.
var loader:Loader3D = new Loader3D();
loader.addEventListener(LoaderEvent.RESOURCE_COMPLETE, onResourceComplete);
loader.load(new URLRequest(‘flat_test.dae’));
...
onResourceComplete(e:LoaderEvent):void {
// not works :(
loader.getChild(0).getChild(0).material = new ColorMaterial();
}
Here is the model and texture (2.7 Mb):
https://dl.dropboxusercontent.com/u/8126219/flat_test.dae.zip

   

Avatar
GoroMatsumoto, Sr. Member
Posted: 20 October 2013 11:18 AM   Total Posts: 166   [ # 1 ]

You can get informations of your assets by “AssetEvent”.

loader.addEventListener(AssetEvent.ASSET_COMPLETEonAssetComplete);
loader.load(new URLRequest("*****.xxx"),nullnull, new AWD2Parser());

private function 
onAssetComplete(event:AssetEvent):void
{
   
if(event.asset.assetType == "material")
   
{
       trace
(event.asset.name); //you can get asset names.
  
       //you can grab materials.
       
TextureMaterial(event.asset).texture texA;
   
}
   
if(event.asset.assetType == "mesh")
   
{
       trace
(event.asset.name); //you can get asset names.
  
       //you can grab meshes.
       
Mesh(event.asset).material materialA;
   
}
   

fmax, Newbie
Posted: 20 October 2013 11:37 AM   Total Posts: 10   [ # 2 ]
GoroMatsumoto - 20 October 2013 11:18 AM

You can get informations of your assets by “AssetEvent”.

I don’t need information about my assets, I’d like to change some submeshes in runtime.

Unfortunately, not works for me ( I used AssetEvent.ASSET_COMPLETE)

if (assetType == 'mesh'{
Mesh
(e.asset).material = new ColorMaterial();

 

   

Avatar
GoroMatsumoto, Sr. Member
Posted: 20 October 2013 01:58 PM   Total Posts: 166   [ # 3 ]

Good luck.

   

fmax, Newbie
Posted: 20 October 2013 03:28 PM   Total Posts: 10   [ # 4 ]

Here is my solution:

var mesh:Mesh [the mesh for changing]
for each (var item:SubMesh in mesh.subMeshes{
item
.material null;
}
mesh
.material = new ColorMaterial(0xFF00FF); 
   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X