I have Factory class which is supposed to return pre-assembled objects composed of various geometric shapes grouped using Object3d. Code is below, it works, but I notice that using clone() is more of a performance hit than just repeatedly redrawing the geometries. Why is that? What am i doing wrong? Example: Create easily spawn-able chess piece:
this.pawn = new THREE.Object3D(); // CREATE GROUP
//ADD VARIOUS GEOMETRY:
var sphere = new THREE.Mesh(
new THREE.SphereGeometry(4,5,5) ,
new THREE.MeshBasicMaterial({ color:0x33FF44, wireframe: true }) );
sphere.position.y=22;
this.pawn.add( sphere );
var cyl_height=16;
var cylinder = new THREE.Mesh(
new THREE.CylinderGeometry( 3, 4, cyl_height, 10 ),
new THREE.MeshBasicMaterial( {color:0x33FF44, wireframe: true}) );
cylinder.position.y=cyl_height/2;
this.pawn.add( cylinder )
this.pawn.add( circle );
this.avatars['exchange']=this.exchange;
this.avatars['pawn']=this.pawn;
//// USAGE: getClone('pawn') --> should return light weight clone of pre-built ?
this.getClone=function( identifier_in ){
return this.avatars[ identifier_in ].clone();
}