var geometry = new THREE.SphereGeometry( 10, 32, 16 ); var art = [ '' , '' , '' , '' , ''] arr_planet = [] arr_planet.push(image) arr_planet.push(image_1) arr_planet.push(image_2) for (i = 0; i < 3; i++) { var now_it = 'it' + i var now_mat = 'mat' + i now_it = new THREE.Texture( arr_planet[i] ); arr_planet[i].addEventListener( 'load', function ( event ) { now_it.needsUpdate = true; } ); now_mat = new THREE.MeshPhongMaterial( { color: 0xffffff, specular: 0x050505, shininess: 50, map:now_it } ); art[i]= new THREE.Mesh( geometry, now_mat ); art[i].position.x =(dx) scene.add( art[i]); dx = dx + 25 } 

PS: I apologize for the clumsy code

    1 answer 1

    I tried to keep the code in its original form. Replaced use of "THREE.Texture" with "THREE.ImageUtils.loadTexture". Code worker - loaded three balls with three different textures.

      var geometry = new THREE.SphereGeometry(10, 32, 16); var art = ['', '', '', '', '']; arr_planet = []; arr_planet.push("1.jpg"); arr_planet.push("2.jpg"); arr_planet.push("3.jpg"); for (var i = 0; i < 3; i++) { var now_it = 'it' + i; var now_mat = 'mat' + i; //now_it = new THREE.Texture(arr_planet[i]); //arr_planet[i].addEventListener('load', function () { now_it.needsUpdate = true; }); now_it = THREE.ImageUtils.loadTexture(arr_planet[i]); now_mat = new THREE.MeshPhongMaterial({ color: 0xffffff, specular: 0x050505, shininess: 50, map: now_it }); art[i] = new THREE.Mesh(geometry, now_mat); art[i].position.x = dx; scene.add(art[i]); dx += 25; }