How to mimic faces/edges/vertex extruding from CAD software? (Such as blender, maya, 3dsmax)

I am trying to understand what code is needed so that a user is able to extrude the face/ vertices (or a singular vertex) of a SUBDIVIDED primitive, like a 3D cube.

This should be similar to how blender or any other CAD software extrudes faces/edges/vertices

Example of my goal:

Could someone give me a clear explanation of the logic behind this, with some code examples?

1 Like

Take a look at the landing page animation of vectary.

You may get some better idea. Logics are not too complex to understand.

An extrusion is basically the extension of a geometric structure into an additional dimension. A point is expanded to a line, a line is expanded to a surface, and a surface is expanded to a 3D body. In many cases, an extrusion proceeds as follows:

  • Select the origin of the extrusion, mostly done by the user via interaction.
  • According to your selection, extrude the geometry by creating additional vertices and lines/faces along a certain direction with a specific depth. The normal of a selected face is usually a good default value for the direction but it can be an arbitrary vector. Even a spline or a curve can define the shape of the extrusion.
  • The extruded part can consist of one or more segments (or subdivisions). The more segments, the smoother is the extrusion.

You might want to study ExtrudeGeometry to see how the second and third step are implemented. Be aware, the code contains a lot of bevel-related sections that might be irrelevant to you.