【问题标题】:Three.js: for loop for every mesh in scene?Three.js:场景中每个网格的for循环?
【发布时间】:2014-12-04 01:13:05
【问题描述】:

所以我想做的是像

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

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

【问题讨论】:

    标签: javascript three.js


    【解决方案1】:

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

    【讨论】:

    • 谢谢!正是我想要的!
    猜你喜欢
    • 1970-01-01
    • 2012-06-21
    • 2014-08-18
    • 2019-03-27
    • 2016-07-20
    • 1970-01-01
    • 2012-08-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多