Three.js:为场景中的每个网格循环?

时间:2014-12-04 01:13:06

标签: javascript three.js

所以我想做的就是做

之类的事情
scene.forEachMeshInScene(function(mesh){
      //And here I can do stuff
});

但遗憾的是,这并不存在。我怎么能这样做?

1 个答案:

答案 0 :(得分:11)

您可以使用以下模式迭代Mesh图表中的scene个对象:

scene.traverse( function( node ) {

    if ( node instanceof THREE.Mesh ) {

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

    }

} );

three.js r.69

相关问题