Hi,
I am trying to calculate faces and vertices. I am asking this question to know that I am in the right way.
If mesh.geometry.index.count/3
is the count of triangles in the geometry, is mesh.geometry.attributes.position.count/3
the number of vertices?
If not how do I calculate vertices?
In the mesh I tried, position.count
was 828 and index.count
was 2196.
I don’t understand how position works with index. I’m a bit confused here. It will be helpful if you can explain that.
Thanks,
Binoy
See simple examples from the Collection of examples from discourse.threejs.org
BufferGeometryNonIndexed
BufferGeometryIndexed
and
NumberingHelperExamples
somewhat more sophisticated
MorphBoxSphere
RoundedBoxFlatUV
No, the number of vertices is defined by mesh.geometry.attributes.position.count
. If you want to read a vertex, do it like so:
const positionAttribute = mesh.geometry.getAttribute( 'position' );
const vertex= new THREE.Vector3();
for ( let i= 0; i< positionAttribute.count; i ++ ) {
vertex.fromBufferAttribute( positionAttribute, i );
// do something with the vertex
}
1 Like