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

6

我希望你能翻译以下内容:我想要做的是类似于

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

但很遗憾,这并不存在。我该怎么做才能实现这样的功能?
1个回答

14

您可以使用以下模式来迭代场景图中的Mesh对象:

scene.traverse( function( node ) {

    if ( node instanceof THREE.Mesh ) {

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

    }

} );

three.js r.69


谢谢!正是我想要的! - ByteDuck

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接