Replace materials from DAE scene


/ Published in: ActionScript 3
Save to your folder(s)

Replacing materials in a DAE instance can be a real pain in the ass. This function iterates the children of a DAE instance and assigns materials by node name from MaterialsList.


Copy this code and paste it in your HTML
  1. private function rebuildColladaMaterials(d:DisplayObject3D, matList:MaterialsList):void {
  2. for each(var child:DisplayObject3D in d.children ) {
  3. if ( matList.materialsByName[DisplayObject3D(child.parent).name] != undefined ) {
  4. child.material = matList.materialsByName[DisplayObject3D(child.parent).name]
  5. }
  6. rebuildColladaMaterials(child, matList);
  7. }
  8. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.