6

So what I want is to do something like

scene.forEachMeshInScene(function(mesh){
      //And here I can do stuff
});

But sadly, that doesn't exist. How can I do something like this?

1 Answer 1

14

You can use the following pattern to iterate over the Mesh objects in the scene graph:

scene.traverse( function( node ) {

    if ( node instanceof THREE.Mesh ) {

        // insert your code here, for example:
        node.material = new THREE.MeshNormalMaterial()

    }

} );

three.js r.69

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.