繁体   English   中英

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

[英]Three.js: for loop for every mesh in scene?

所以我想做的就是做点什么

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

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

您可以使用以下模式迭代scene图中的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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM