Want to extrude shape when top and bottom vertices of the 3d shape is given

Am trying to extrude a 3d shape where its top and bottom vertices can be different for example to face can be a bigger triangle whereas the bottom is smaller

A Playground of what you are trying to achieve would help, but have you checked out custom extrusion. You can specify a rotation and scale along the extrusion path using functions.

You can see the spheres right
i can drag and edit the top vertices and I want to do the same for bottom
and it should allow the bottom face to be smaller or bigger than the top face

Are the top and bottom faces always parallel, or do you want to be able to extrude along an arbitrary path?

They are always parallel

In that case you have a custom mesh with 6 vertices (in the case of a triangular prism). I’d just adjust the vert positions. E.g. have your spheres be meshes and on drag end, adjust the position of the corresponding vert to match the sphere position.

1 Like

Am trying to do that but it isn’t working for me
can you provide the code snipet if you dont mind
It will be very useful

I have tried creating 6 vertices custom mesh but it isnt extruding a triangular prism

In that case you have a custom mesh with 6 vertices (in the case of a triangular prism). I’d just adjust the vert positions. E.g. have your spheres be meshes and on drag end, adjust the position of the corresponding vert to match the sphere position.

Can someone help me with this

You should take a look at: Updating Vertices | Babylon.js Documentation (babylonjs.com) it will be helpful :slight_smile:

Am not able to get the bottom vertices as am extruding polygon using just 3 vertices

You’re extruding a prism from the 3 vertices, correct? After the extrusion is done, you can just access and modify the vertex data of any data you want.

yes I am but am not able to access the bottom three vertices and edit them

You need to make sure the mesh is created with updateable:true.
Babylon.js Playground

How do you understand which indices to edit when a vertex is dragged?

I printed out the vertices and looked for ones that had a y coord of -1. What you could probably do is generate your spheres to be at each vertex (avoiding duplicates), record the index of the associated vertex (of which there would be multiples which need to be updated when the sphere moves) and then update the vertices on drag end for the sphere.

This is a helpful reference - Create Custom Meshes From Scratch | Babylon.js Documentation

1 Like

Thank you eric lemme check it out and let you know