How to get all the vertices of my scene using the Three.js
There is any way that I can get the total vertex that I have in my scene like MAYA or 3DS MAX ??.
I have some 3d models loaded with obj loader and I want to know how to get the total vertices or edges or triangles that I have inside my scene.
Like scene.get(vertices);
or scene.get(edges);
renderer.info
is a three.js object that tallies the number of draw calls and rendered primitives. It also shows the number of geometries, textures, and shader programs in use.
console.log( renderer.info );
three.js r.84
There isn't really a straightforward answer to this question.
Edges are not present in three.js geometries, and there are a few different ways of presenting them.
Vertices can belong to triangle soups or indexed meshes, meaning different numbers for the same number of triangles.
Triangles on the other hand, are quite different if they are made to exist with Geometry
vs BufferGeometry
. Geometry
has a Face3
class which is quite complex, BufferGeometry
has a typed array where three numbers can represent a triangle.
If you want to debug the app and see if you're accidentally creating more geometries than needed (clones by mistake or something) use renderer.info
as per WestLangley's suggestion.
If you want to adopt someone elses semantics use something like the rstats tool in the other answer.
If you need something specific to your needs than you can ask questions like "Is it the size that matters, because then i should also perhaps count uvs as vertices", "Is it too big to hold in memory as Geometry
", "Am i interested only in the vertex transformation performance" etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With