title: How can I load multiple stl files with array variable
body: <pre><code>    var stlpath = '../assets/models/stl/part';
      var stlformat = '.stl';
      var part = new Array();
  
      for( var i = 1; i&lt;28; i++){
  
          var url = stlpath + i + stlformat;
  
          stlloader.load(url, function (geometry) {
              console.log(geometry);
  
              var mat = new THREE.MeshLambertMaterial( {color: 0xffffff} );
  
              part = new THREE.Mesh(geometry, mat);
              part.rotation.x = -0.5 * Math.PI; part.rotation.z = -0.5 * Math.PI;
              part.position.set(0, -15, 0);
              part.scale.set(0.3, 0.3, 0.3);
              part.castShadow = true;
              part.receiveShadow = true;
  
              scene.add(part);
          });
      }
  </code></pre>
  
  <p>I have loaded multiple stl files successfully with this code. But this code hold stl files with just one variable, "part", so I am not able to handle each of stl files. I want adjust each stl with separated variables.</p>
  
  <p>I tried to use an array as a variable.</p>
  
  <pre><code>    var stlpath = '../assets/models/stl/part';
      var stlformat = '.stl';
      var part = new Array();
  
      for( var i = 1; i&lt;28; i++){
  
          var url = stlpath + i + stlformat;
  
          stlloader.load(url, function (geometry) {
              console.log(geometry);
  
              var mat = new THREE.MeshLambertMaterial( {color: 0xffffff} );
  
              part[i] = new THREE.Mesh(geometry, mat);
              part[i].rotation.x = -0.5 * Math.PI; part.rotation.z = -0.5 * Math.PI;
              part[i].position.set(0, -15, 0);
              part[i].scale.set(0.3, 0.3, 0.3);
              part[i].castShadow = true;
              part[i].receiveShadow = true;
  
              scene.add(part[i]);
          });
      }
  </code></pre>
  
  <p>But this code doesn't work without any error message. I have no idea that why it doesn't work. Can you give any advice, solution, or example? </p>
  
  <p>Thank you</p>