ExtrudeGeometry on arbitrary planes

I want to create a ExtrudeGeometry on an arbitrary plane with a particular shape on the plane along the plane’s normal direction. Referring to the screenshot as the example, the green triangle is the plane and the yellow geometry is the ExtrudeGeometry I wish to create. What I have is the vertical projection of their boundary vertices on the ground (the red triangle for the plane and the blue rectangle for the shape). I also know the vertex positions of the actual plane (the green triangle). So to create the ExtrudeGeometry , I am taking these steps:

  1. Project the shape’s vertices vertically upward onto the plane
  2. Make the rotation matrix using green triangle’s edge as the rotation axis and apply on the projected shape’s vertices so they become horizontal
  • This is necessary because I cannot just make Vector2 with the x & z of the shape’s vertices (that would be the ground projected shape instead of the actual shape on the plane). Maybe there’s a better way to to this?
  1. Calculate the center of the rotated shape’s vertices and sub each vertex with the center. Now the shape is centered at origin.
  2. Create extrude shape with x & z coords of the shape’s vertices and the extrude geometry.

→ 5. Rotate the extrude mesh (negative or positive 90deg?). Translate the mesh with distance of shape on plane’s center subtract origin. Make quaternion with up vector and plane’s normal and apply to the mesh. As you can see in the first screenshot, I kind of get it working. But once the plane’s facing direction changes, things do not work properly (screenshot 2).



Just tried to play with the following idea:

  • there is some black shape on the ground (with curves and holes)
  • it is extruded vertically as an orange beam
  • at some point the beam hits an invisible slanted plane, defined by a normal vector
  • the extrusion continues as red, in the direction of the normal vector, using the hit zone as a new shape

The code is far from optimal, the 5 transformations (lines 116-120) could be packed in a single matrix, the geometry is not needed to be generated every time (this is just to experiment with different slopes).

Maybe this is not exactly what you ask for, but it looks relevant. Sort of.

https://codepen.io/boytchev/full/GRPNEbK

image

3 Likes

It reminds me of those slightly older construction designs.

ProfiledContourGeometry
ProfiledContourGeometry MultiMaterial