How to extrude (in or out) selected array-of-vertices/face in PlaneGeometry

== the problem :
I have PlaneGeometry. say my segments of width and height equal 5 each (so the plane made of 25 parts like a grid.).

i want to extrude some part (selected area of face(s) ) of the shape in or out, like this:

== possible solution:
in multiple posts out there, i see there is a simple solution:

  1. duplicate of the vertices of the selected area.
  2. connect the duplicates to both the original vertices and also their adjacent duplicates

(for example ExtrudeGeometry · Issue #323 · mrdoob/three.js · GitHub)

my issue is:

  • how i implement this steps in code? how i duplicate and connect new verteces to selected verteces
    (how to select the wanted verteces? in goemetry.attributes.positions.array there are multiple verteces which are pointing to the same position, need to connect to them all? if that make sense), also i go to goemetry.attributes.positions.array and somehow insert vertices there?

thanks in advance

This may not be what you’re looking for, but I know that in the decal geometry example, it will set the raycast helper in the direction of the current face normal. You could get that direction, then deduce the needed vertices from the face index I believe (Disclaimer: I’m not great with vertex math).

const n = intersects[ 0 ].face.normal.clone();
n.transformDirection( mesh.matrixWorld );
n.multiplyScalar( 10 );
n.add( intersects[ 0 ].point );

intersection.normal.copy( intersects[ 0 ].face.normal );
mouseHelper.lookAt( n );
1 Like

yeah it can be used to get normals, thanks for the suggestion :+1: