Currently using three.js version r59, encountering difficulties when attempting to duplicate a loaded model. The goal is to create multiple models through looping, with the plan to apply textures at a later stage.
for (var i=0; i<5-1; i++){
var loader = new THREE.OBJLoader( );
loader.load( 'mod/bookH.obj',function ( object ) {
object.traverse( function ( child ) {
if ( child instanceof THREE.Mesh ) {
child.castShadow = true;
console.log(i);
//child.material.map = texture; //not needed at this point
}
} );
//works below
object.position.set( 1 * 0, 0, 5 );
scene.add( object );
//following does not work and no error occurs...
var testMesh = new.THREE.Object3D(object);
scene.add(testMesh);
});
}