Spawn an Object as Instanced Children with haxe

question
#1

How can I spawn an object as instanced children? I took the instancing example and add a new Trait to the scene with following code:

package arm;
class MyTraitduplicate extends iron.Trait {
	var suzanne:iron.object.Object;
	public function new() {
		super();

		notifyOnInit(function() {
		suzanne = iron.Scene.active.getChild("Suzanne");
		iron.Scene.active.spawnObject("Suzanne", suzanne, function(go) {
				go.transform.loc.x = 0;
				go.transform.loc.x = 0;
				go.transform.loc.z = 8;
				go.transform.buildMatrix();
			});
		});
	}
}

I expected the result like the left picture, such as I do it manually (only one more linked object / no copied mesh):


But with my code I get the result from the right picture (Instead of one more linked object, the whole mesh is copied).

For a simulation project i need the ability to spawn many objects, that share the same very big mesh. So for a better performance and less memory consumption I don’t want to have multiple copies of the same mesh.

1 Like

#2

Why do you have already two meshes on the left side?

0 Likes

#3

The ground plane is a separate mesh.

0 Likes