Reputation: 623
Is it possible to remove or cut away sections of shapes in Three.js?
For example, if I made a CylinderGeometry and wanted to "shave" the front of it away, so that the front was flat and the back was curved, like a half cylinder. Is this possible?
I need to be able to do it to the front and back of a cylinder, so just the sides are curved.
Upvotes: 20
Views: 21634
Reputation: 51837
It is possible. You can deal with triangles yourself, or use Boolean operations with a library like constructive solid geometry to do mesh subtraction.
Have a look here and here for some suggestions related to manipulating geometry.
There are other algorithms to slice a mesh that could be ported over, but it depends on how simple or complex you need this thing to be.
Upvotes: 31