How to init 2 same models in the same scene?

Software: Away3D 4.x

LuoYang, Newbie
Posted: 17 August 2012 05:07 AM   Total Posts: 5

hi , I’ve create a model class, so that I can init the model in another class and then put on the scene, question is I can’t init 2 models, the error is the material cannot be shared with 2 or more models. please help me.

   

Avatar
loth, Sr. Member
Posted: 17 August 2012 08:55 PM   Total Posts: 236   [ # 1 ]

maybe use clone of your object
var newObject:Mesh = Mesh(oldObject.clone());

   

LuoYang, Newbie
Posted: 20 August 2012 07:32 PM   Total Posts: 5   [ # 2 ]

clone() can work, but it’s not what I want in the function…........

   

LuoYang, Newbie
Posted: 20 August 2012 07:35 PM   Total Posts: 5   [ # 3 ]

bcoz clone a object will have the same property of previous one, I want them to work independently

   

Richard Olsson, Administrator
Posted: 27 August 2012 09:35 AM   Total Posts: 1192   [ # 4 ]

What do you mean they have “the same property”? Some properties have reference values instead of POD values, e.g. material, geometry et c. If you want those to be independent, you have to clone those as well. One way would be to do the following:

myNewMesh = new Mesh(null);
myNewMesh.geometry myOldMesh.geometry.clone();
myNewMesh.material myOldMesh.material.clone(); 

Note though that if you can you should always share geometry and materials because that will increase rendering performance.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X