I'm having an issue when trying to generate copies of a 3D json model that I've animated. Everything works fine with just one model in the scene.
However, as soon as I attempt to create multiple copies, I encounter the following error:
Uncaught TypeError: Cannot read property '0' of undefined.
The error seems to be pointing back to the following function:
for(i = 0; i < enemics_generats; i++ ){
var enemic = dolent.clone(true); //Clone from original model
enemic.name = i.toString();
if (i > 5){
enemic.visible = false;
}
else{
enemic.visible = true;
}
enemic.box = new THREE.Box3().setFromObject(enemic);//Box collider
enemic.box_helper = new THREE.BoxHelper( enemic ); //Display box on scene
//THE ERROR OCCURS HERE
enemic.mixer = new THREE.AnimationMixer( enemic );
enemic.mixer.clipAction( enemic.animations[ 0 ] ).play(); //ERROR AT THIS LINE
enemics.push(enemic);
scene.add(enemic);
scene.add(enemic.box_helper);
}
Thank you for your assistance.