Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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 group). Before release r72 I was use this code

1st geometry:

bufCompaniesGeomNotActive.addDrawCall(0, geomCompaniesNotActive.faces.length * 3, 0);
bufCompaniesGeomNotActive.addDrawCall(0, 0, 0);

2nd geometry

bufCompaniesGeomActive.addDrawCall(0, 0, 0);

In r72 release addDrawCall just renamed to addGroup. But main problem is 2 group's in 1st geometry. I was trying make visible part's like before

 floor.companiesGeomNotActive.groups[0].start = 0;
 floor.companiesGeomNotActive.groups[0].count = obj.startFaceIndexNotActive * 3;

 floor.companiesGeomNotActive.groups[1].start = obj.endFaceIndexNotActive * 3;
 floor.companiesGeomNotActive.groups[1].count = lengthNotActive - obj.endFaceIndexNotActive * 3;

but no success. I've found method companiesGeomActive.setDrawRange(obj.startFaceIndexActive * 3, 3 * (obj.endFaceIndexActive - obj.startFaceIndexActive)); and it works but how can I set ranges for many groups?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
388 views
Welcome To Ask or Share your Answers For Others

1 Answer

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...