Converting buffergeometry to geometry need a lot of memory

converting loaded stl mesh from buffergeometry to geometry need a lot of memory.
how i can reduce memory usage or get the mesh of intersection between an stl buffergeometry and a plane?

What do you mean with this?

i have created a algorithm that slice a geometry to slice.
but it need a lot of RAM for big imported mesh.

how i can reduce ram consumption?

or is possible to slice a buffergeometry?

Do you mean something like that:

yes but for bufferedgeometry

So, you’re free to modify the code from those SO answers to work with THREE.BufferGeometry(). The difference is just in the method of how to get vertices of a face in such type of geometry (indexed or non-indexed).

any idea, how to get vertices of bufferedgeometry

Well, yes.
Work with geometry.attributes.position for non-indexed.
Work with geometry.index + geometry.attributes.position for indexed.

1 Like

non_indexed have edges between vertices or edges is represented by vertices

Non-indexed is just a set of triangles.
So, amount of faces in such geometry is geometry.attributes.position.count / (3 * 3)
But I may be wrong :slight_smile: Give it a try :wink:

Little correction :innocent: It is just geometry.attributes.position.count / 3.

1 Like

importing a 100MB stl file and using
geometry = new THREE.Geometry().fromBufferGeometry( geometry );
take 1GB of RAM
any way exist to avoid huge ram consumption and avoid developping new algorithm to work with buffergeometry.

Why do you perform the geometry conversion in the first place? I don’t think there is an easy way to avoid the respective overhead.

i use
geometry = new THREE.Geometry().fromBufferGeometry( geometry );
to can intersect a mesh with plane in easy way

Oops, yeah, my fault :slight_smile: Thanks for correction, Michael

Doubtful statement.
I used THREE.Geometry() because it was just more acceptable/applicable for an example on SO.

Is it possible to show (the source code of) the algorithm?

i try to split it in a standalone algorithm to post it.