My goal is to extrude a shape and generate an ExtrudeGeometry
, but I need the ability to control the direction of the extrusion. Specifically, I have a direction specified in a Vector3
.
The shape is initially drawn on the x-y plane, with the default extrusion depth being along the z-axis. For example, a direction vector of (0,0,1)
results in a standard extrusion, while (0,0,-1)
would extrude the shape in the opposite direction.
I attempted to use an extrude path for this purpose, but found that the shape could rotate freely, which was not my desired outcome. I require the shape to maintain its original orientation. More information on this issue can be found in my previous question here.
I considered adjusting the vertices of the resulting ExtrudedGeometry using a matrix transformation, but encountered difficulties achieving the desired geometry. It's possible that the face normals may become inverted after applying this method due to my lack of expertise in handling matrices.
Note The direction vector will never be perpendicular to the z-axis as it would result in invalid shapes.
The main question:
How can I reliably extrude my shape in the specified direction? To illustrate, consider a square shape on the x-y plane with dimensions of 2000 units, extruded by 2000 units using three different direction vectors. Below are 2D and 3D visual representations of the expected outcomes.