I have a problem accessing an object outside the bounds of events. If I put an object in an array and checked this array, it is also empty, but in scope it is full. I need to know how I can access an object outside the event scope.
for (var i = 0; i < 19; i++){ var loader = new THREE.OBJMTLLoader(); loader.addEventListener( 'load', function ( event ) { var tree = event.content; myWorld.setWorldTreePosition(multiplier); tree.position.y = 0; tree.position.x = myWorld.myTreePosition.position.x; tree.position.z = myWorld.myTreePosition.position.z; tree.rotation.x = -(Math.PI / 2); tree.scale.set(10,5,5); scene.add( tree ); collidableMeshList2.push(tree); tree.castShadow = true;
source share