I have just started to play with Three.js and JS and I really love this tool. It is amazing how much you can do by just tinkering with the examples from the web. ^^
Now I want to do something which I have not found in the examples.
This is a broad question and I am looking just for pointers/links/suggestions on which functions/types to use or documentation to read. Sorry if it is too vague (if that is the case, I will try to work on it and provide some code/visualizations on what I would like to achieve).
Currently, I have a non-convex polygon with
N vertices drawn in the X-Y plane. I can easily extrude it with
THREE.ExtrudeBufferGeometry. The “poblem” is that this function only allows me to extrude the polygon a certain height (i.e.:
depth: 10) for all vertices. But I am looking for something different.
I would like to extrude the polygon up (in the positive Z-direction), but limit the extrusion with an inclined plane (not necessarily parallel to the X-Y plane). Assumptions:
- The plane is above (Z-direction) all vertices in the polygon that is to be extruded; that means the shape of the polygon in the base is conserved after extrusion (and matches the shape of the top when looked from the Z-direction with an orthographic projection)
- The plane is not parallel to Z-direction, so the polygon, when extruded, always ends up crossing the plane for all its vertices (volume of the final 3D object is finite)
So, basically, the final geometry is a 3D geometry with
2 x N vertices, half of them sitting in the X-Y plane (Z = 0) and the other half above them (sharing the same X-Y coordinates). The total number of faces is 2 (one top, one bottom) plus
N (one 4-sided polygon joining each pair of segments between the top and bottom faces through 2 vertical segments).
I would like to be able to select/access and interact with all those vertices and all those faces (i.e.: through an attribute or method). No need pointers/links for that, just to make clear I would like the final 3D object to maintain that information.
- What would you recommend me to use?
- Should I just extrude with
THREE.ExtrudeBufferGeometryand then cut? (GitHub - tdhooper/threejs-slice-geometry: Slice three.js geometry with a plane.), although I would prefer not to add a dependency
- Should I create a shape/polygon in the inclined plane first and then extrude downwards to the X-Y plane? (don’t know if that would make things easier)
- Is there a better method/type?