Modify cube shape with the raycaster

Hi,

I am looking in the best way to edit the shape of a mesh/geometry via the raycaster.

For instance if I display a cube in my rendered, I’d like to “cut it” with my mouse cursor, ideally using the raycaster.

Is there already a good way to do so?

Should I use another library to manage the geometry editing? Should I do it myself or has somebody already implemented it?

Thanks

Could you clarify your question with some pictures for illustration?

Draw region of interest (ROI), possibly with Raycaster: (The ROIs to be drawn could have arbitrary shapes)
draw_roi

Remove ROI from the geometry/mesh:
croped_roi

Then the “Cropped” geometry/mesh would be a new 100% valid geometry itself.

Does it clarify things @prisoner849 ?

Real world application in volume rendering: https://www.youtube.com/watch?v=qr11lNGnTxo
14 AM

Thanks!

Yeah, now it’s clearer :slight_smile: So just an idea: use raycaster + CSG.

Using mouse and raycaster, you create kind of an irregular pyramid, whose “top” is at the position of the camera and “bottom” is far enough (further than position of the object + a half of the depth of the object).
You can get points of the “bottom” by finding intersection with THREE.Plane() or using raycaster.ray.at(). It’s up to you, but I’d prefer the first method with THREE.Plane().
Now, you have a set of vertices and you can build the pyramid. How you will do it, it’s up to you again.
When all is ready, use ThreeCSG to subtract the “pyramid” from the object.
That’s all :slight_smile: Maybe the other users here have another ideas and will to share them.

1 Like

Yes that is pretty much the approach I was considering - Was not aware of THREECSG that should be all I need!

Thanks!