How to use THREE.triangle .setFromPointsAndIndices()

Hello,

Does anyone have an example of how to use .setFromPointsAndIndices() correctly?

I have a BufferGeometry and want to use it’s index vertices to make a triangle.

var pos = threeMesh1.geometry.index;
var tri = new THREE.Triangle(); 
tri.setFromPointsAndIndices(pos, i * 3 + 0, i * 3 + 1, i * 3 + 2);

/cc

Using of this method assumes that you have an array of THREE.Vector3(), that you pass in the first parameter.
If you have .index property in your geometry, it means that your geometry is a buffer geometry, whose positions stored in a typed array in a buffer attribute. Which is a set of float numbers, not of THREE.Vector3().

Thus, from my point of view, trying to use that method, you just make things complicated for no reason.

1 Like