Mesh instances

Software: Away3D 4.x

superCube, Newbie
Posted: 08 December 2015 08:36 AM   Total Posts: 6

Can meshes be cloned? For example could I import one house and then create several instances?  I would assume the answer to be yes, but I just wanted to confirm.

   

Tempy111, Sr. Member
Posted: 08 December 2015 09:15 AM   Total Posts: 133   [ # 1 ]

Yes

Mesh.clone();

I think it’s still the same in 4.X ^_^

   

Avatar
Fabrice Closier, Administrator
Posted: 08 December 2015 11:38 AM   Total Posts: 1265   [ # 2 ]

Using clone is a bad idea. You then duplicate the entire data. Your project will be bloated and will perform poorly.
instead do:
var baseHouse:Mesh = new Mesh(geom, mat) or from loading it or from as3.

for(var xx…
  scene.addChild(  new Mesh( baseHouse.geometry, somemat or baseHouse.material )

Another efficient way to proceed is to build houses per materials, and loop over them. per loop finish with a Merge. Handle next type of house material.

   

Tempy111, Sr. Member
Posted: 08 December 2015 11:41 AM   Total Posts: 133   [ # 3 ]

mmm. I thought Clone was the best way if you needed to reuse the same model a number of times for, say, collectable items in a game?

   

Avatar
Fabrice Closier, Administrator
Posted: 08 December 2015 11:55 AM   Total Posts: 1265   [ # 4 ]

Question is: what do you want to “collect”: A full data copy of a house or a copy of a house? On screen they look the same.
Use clone only if you destroy/alter the geometry of the shared house data.

   

Tempy111, Sr. Member
Posted: 08 December 2015 01:48 PM   Total Posts: 133   [ # 5 ]

point. ^_^

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X