BufferGeometry: how to render groups of faces

前端 未结 1 1691
再見小時候
再見小時候 2020-12-22 05:57

I have 2 geometries and 2 meshes. Main goal is sometimes exclude part of first geometry (so I need 2 groups for that) and show in this time part of 2nd geometry (always 1 g

相关标签:
1条回答
  • 2020-12-22 06:39

    BufferGeometry.groups is now used to support MultiMaterial ( formerly MeshFaceMaterial ).

    geometry.clearGroups();
    geometry.addGroup( start1, count1, 0 ); // materialIndex 0
    geometry.addGroup( start2, count2, 1 ); // materialIndex 1
    
    var material = new THREE.MultiMaterial( materialsArray );
    var mesh = new THREE.Mesh( geometry, material );
    

    If you have a single material and want to render sub-groups of faces, you can use a pattern like so:

    geometry.clearGroups();
    geometry.addGroup( start1, count1, 0 ); // zero
    geometry.addGroup( start2, count2, 0 ); // zero
    
    var materialsArray = [ material ];
    var material = new THREE.MultiMaterial( materialsArray );
    var mesh = new THREE.Mesh( geometry, material );
    

    geometry.drawRange is ignored when the material is MultiMaterial.

    three.js r.72

    0 讨论(0)
提交回复
热议问题