i also having problems with mesh and object, but hey, where here to
help each other :D

ok ill make a simple example, u can make whatever change u need later.

first ok u know this call the scene

private var myvar1:Object3D;
private var myvar2:Object3D;//later well see

            model = Collada.parse(untitledC, {materials:
{mat1:mat1M,mat2:mat2M}});
            model.scale(5); //whatever u want

ok then u grab the childs
myvar1=model.getChildByName("nameofchild1");
myvar2=model.getChildByName("nameofchild2");//guess not so late :p

here comes the fun, u can remove parts:

model.removeChildByName("nameofchild1");

assign functions (this example removes add the child to the scene):

                private function onKeyUp(e:KeyboardEvent):void {
                        switch(e.keyCode)
                        {
                                case "1".charCodeAt():
                                        if (sino1==true){
                                                sino1=false;
                                                
model.removeChildByName("nameofchild1");
                                        }
                                        else{
                                                sino1=true;
                                                model.addChild(nameofchild1);
                                        }
                         }
                  }

k but thats just clowing stuff, to make u in the code, so in ur case
were going to destroy a model, how do we do that?, ok
lets say u have a var wich determinates the number of the materials
(case u have an arrya or wathever), ok add the cases to the swithc
something like:

                                case "9".charCodeAt():
                                                matnum=1;
                                                remakemodel();

                private function remakemodel():void
                {
                        if (thefreakingmodel)
                        seekAnddestroy();
                        //ok here u reassign the model but usinbg the
value of the tnum
case matnum:9
                thefreakingmodel = Collada.parse(theClass,{materials:{where
it goes:matnumber9M}});
                scene.addChild(thefreakingmodel);
                }

so what goes in sekkAnddestroy, my funcion got about 50 lines :p cause
it takes a lot of cases, but to make it simple

                        if(thefreakingmodel){
                                thefreakingmodel.materialLibrary = null;
                                scene.removeChild(thefreakingmodel);
                                thefreakingmodel = null;
                        }

this works, i have tested, and of course theres a lot of ways to do
this in better ways, and a lot of applications for thi, but if i were
a monster i would told u complex methods and at the end confuse u, of
course the best way to learn this is making mistakes, im an expert on
that last one XD, so good luck and if u need something else, tell, i
tried to make it the simplest way, but if u got question let me know.






Reply via email to