1

我遇到的问题是,当我将项目推送或取消移动到数组中时,它们会被自动分组,非常奇怪:我猜我的循环没有很好地组合在一起,或多或少我正在试验。感谢任何帮助。

   var i;
   var anObject:/*is created dynamically in a loop for instance I load random images
   and push into  ' myArray'. My myaArray should
   look like this:["image1,image3,image2,image3,image2] but instead 
   im getting:["image1,image3,image3,image2,image2] there grouping up for some reason,
   But i dont   want them too*/


  var BookH = []; 

  function create(){ 
  for (var i=0; i<10; i++){
   var object;
    var tempObject;
    var loader = new THREE.OBJMTLLoader();
    loader.load( 'mod/'+mysqlVars[i].Format+'.obj','mod/bookH.mtl') ;
    loader.addEventListener( 'load', function ( event ) {
           object = event.content;
           for(k in object.children){
               object.children[k].castShadow = true;
               object.children[k].receiveShadow = false;

           } 

          tempObject = object.clone();
          BookH.push(tempObject);
          console.log('mod/'+mysqlVars[9].Format);
          if(BookH.length == 10){
               populate();
           }
         });
    }

    /////////counter loop///
}
4

0 回答 0