# Stretch a triangles height in a mesh

Hi there, I want to create a function that will increase the height of a triangle in a mesh or in other words stretch a certain part of a geometry.

The effect I want to achieve would look something like this:

I want this function to have an intensity variable that increases the height accordingly.

I can link the source code to have a better look at what I am working on

You are asking the same question as in this thread, but now with an illustration of what you want. Again, there is no such thing as the â€śheightâ€ť of a triangle. What you are asking for is called â€śextrusionâ€ť. You will get more (and possibly better) answers if you use the proper terminology.

For a sphere mesh you can place the sphere at (0,0,0), then scale the x,y,z components of each of the triangleâ€™s vertices by the same factor > 1.0.

For a generic (non-spherical) mesh, youâ€™d need to apply some additional logic to derive the direction of the extrude.

If you also want the side faces to show, you will have to insert those by yourself by connecting the original triangle vertices with the scaled vertices in a suitable manner.

1 Like

Sorry about that @vielzutun.ch, in the previous thread I was unable to describe my issue in detail or correctly. Thatâ€™s the reason why I had to create a new thread.

Is there any library or example that I can get which can help me save some time, cause I know the logic to change the position of the triangles but I donâ€™t know how to derive the direction of the extrude as well as create new triangles which will act as a connecting bridge.

This is exactly what I require:

Not that Iâ€™m aware of.

The best advice from my side ist, to take a close look at the Three.js ExtrudeGeometry function and its source code.

The source code will probably be overly complex for your problem, in that it supports extrusion subdivisions, bevels and such. But at its core, you may be able to extract from there at least the face generation stuff.

To find the extrusion direction for a triangular face of a generic mesh, its face normal may be a good starting point. Have look at the Three.js Triangle.getNormal() function and its source code for reference.

1 Like