Update objects after add to scene


Now I have a bucle for which add objects to a scene:

for (var i = 0; i < DEMOS.length; i++) {
            var geometry = new THREE.PlaneGeometry(1.5 * SCALE, 1 * SCALE);
            var texture = loader.load('url');
            var material = new THREE.MeshBasicMaterial({map: texture});
            var plane = new THREE.Mesh(geometry, material);
            plane.position.x = positions[i][0]
            plane.position.y = positions[i][1]
            plane.position.z = positions[i][2]


I would like to update this objects when a asyncronous event be fired, for example to change the image of the texture I have to save this obj into an array?


Use the onLoad callback:

var texture = loader.load( 'url', function() {

    scene.add( plane );

} );

BTW: With a little research effort, you can answer this question by yourself :wink:


This response is for this message or for the other question? :wink:

This one I guess :blush:

I think that this answer is to this question, no?

How helps, add the object in the callback to be able to edit the objects after been added?

Thanks :wink:

Oh you’re right, sry. But changing objects afterwards using callbacks or event listener is no big deal. You are using ordinary JavaScript features for this. Have a look at the official examples to see some code samples.

Besides, the following manual page describes three.js specific things you have to care about:


Thanks, needsToUpdate was the key.

Sorry for my noob questions but sometimes I don’t know what search or where is the key to search.

Thanks again