Tetrahedral Mesh Generation with points

Hello,
How can I generate a tetrahedral mesh surface like this for these points? Could you please point me to some example or tutorial?
Thank you very much

You could give ConvexBufferGeometry a try. It computes the convex hull for a given set of points and then generates the corresponding geometry data. The following example demonstrates this approach:

https://threejs.org/examples/#webgl_geometry_convex

1 Like

Also, have a look at this forum topic:
https://discourse.threejs.org/t/grid-collection/1893?u=prisoner849

1 Like

Thanks for reply. In the example the vertices are declared as below, and then passed to the THREE.ConvexBufferGeometry.
var vertices = new THREE.DodecahedronGeometry( 10 ).vertices;
var meshGeometry = new THREE.ConvexBufferGeometry( vertices );

But when I try to pass the points to THREE.ConvexBufferGeometry, like below, it wont work.
var meshGeometry = new THREE.ConvexBufferGeometry( points );

Could you please tell me how to do this right?
Thank you very much

What do you mean with “won’t work”? Please be more specific.

Console output is :
Uncaught TypeError: THREE.ConvexBufferGeometry is not a constructor.
I think the problem is the points cannot be directly passed on to the ConvexBufferGeometry?

You have to include ConvexBufferGeometry and QuickHull into your app. It’s no part of the core lib.

1 Like

Oh… Sorry about that noob mistake…
Now the console output is,

THREE.QuickHull: Points parameter is not an array.
setFromPoints @ QuickHull.js:43
QuickHull.js:47 Uncaught TypeError: Cannot read property 'length' of undefined

When I type
var meshGeometry = new THREE.ConvexBufferGeometry( positions );

Console output is,
Uncaught TypeError: point.getComponent is not a function

Do you actually pass in an array of points? What is the type of positions?

positions is an array.
You can see it here.

See the Pen Tetrahedral Mesh Generation by brabbit640 (@brabbit640) on CodePen.

Your codepen produces the following error:

Uncaught TypeError: THREE.OrbitControls is not a constructor

Have you actually tested the codepen before sharing?

Yes I’m testing them on local machine. I put them on Codepen to show you :slight_smile:
But I can’t see any console output on Codepen. Don’t know why.

Try it with the browser console :wink:

1 Like

Oh sorry. OrbitController fixed now. I tested all locally so didn’t test again with codepen. Just copied code there to show you the whole code.
Thanks

Use this:

positions.push( new THREE.Vector3(x, y, z) );

instead of this:

positions.push( x, y, z );

if you want to work with THREE.ConvexBufferGeometry().

1 Like

Thank you. It works :slight_smile:
However there’s some faces which shouldn’t be there. :frowning:
Is there a way to get rid of them?

See the Pen Tetrahedral Mesh Generation by brabbit640 (@brabbit640) on CodePen.

Again, you have to be more specific! How should the community know which faces you mean???

1 Like

Oh sorry. I only needed the curved surface. It’s something like this.
Thank you

1

Unfortunately, this does not work with ConvexBufferGeometry. I think you have to triangulate the surface by yourself.

1 Like