最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Three.js: for loop for every mesh in scene? - Stack Overflow

programmeradmin2浏览0评论

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?

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?

Share Improve this question asked Dec 4, 2014 at 1:13 ByteDuckByteDuck 1,8613 gold badges15 silver badges28 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 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

发布评论

评论列表(0)

  1. 暂无评论