materialLibrary dynamic change materials

Software: Away3D 4.x

Black Moon, Newbie
Posted: 26 August 2011 05:40 PM   Total Posts: 1

I’m loading 3ds object in my scene.

On buttonClick I need to switch the model material between wireframe and loaded one.

Switch to wireframe materials goes normal, but switching back - here’s trouble

//saving default materials
d:Object = new Object();
for 
each(var _md:MaterialData in model.materialLibrary
   
{    
    d[_md
.name] _md.material;
   



// switching
_wire = !_wire
   var 
_md:MaterialData;
      
   var 
m:Material = new WireFrameMaterial(0x0000FF{thickness:1});
  
   if (
_wire)
   

    
for each (_md in model.materialLibrary)
    

       
    
    
    _md
.material m// here's ok
    
    
}
   }
   
else
   
{   
       
    
    
for each (_md in model.materialLibrary)
    
{      
     m 
d[_md.name];
     
_md.material m//here's error
     
    

But it works if materialLibrary.length=1 (only one material loaded).

There’s mistake? Thanks

   

Black Moon, Newbie
Posted: 06 September 2011 10:15 AM   Total Posts: 1   [ # 1 ]

The decision in my case is to change and store each face material..

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X