Spherical (double) Wedge with CSG2. Reusable class, fast update

Double wedge (horizontal and vertical) with Sliders allowing you to change the cut angles.

Keep min/max angles within 2*PI of each other, otherwise that direction won’t be cut. Using a sphere as the base shape, but can easily be replaced.

The Wedge class is fairly generic, but not yet optimized for repeated calls within the Render loop.

4 Likes

Nice !!!

Here’s an optimized version when doing lots of repeated CSG operations on the same object.

An instance of the Wedge class saves the original CSG2 object as well as intermediate results (in case of successive wedges on the same mesh). There’s probably some unnecessary checking going on of “null” results, but it seems to work well. The extra checks were trying to debug an unrelated bug. I have yet to do any performance analysis/optimization.

There is special handling of valid null results. When non-intersecting meshes are intersected, producing a mesh with no vertices, the mesh is disabled. VertexData with no points is uploaded to GPU and produces a warning because I can’t figure out from the CSG2 object whether the result is null before doing csg.toVertexData().

1 Like

It makes a little more intuitive sense if the sliders are direction and width:

1 Like

Maybe this is final, unless someone sees a need to make this more formal (or in TypeScript).

One bug found/fiixed. Also made the sliders work for all three axes. For each axis, the centerline of the wedge is on that axis with wedge angles specified as Left Hand Rule (aka counter-clockwise/leftward when looking outward from 0,0,0) around that axis. An angle of zero is facing the “previous” axis.

Note that the axes display disappears if the final result is an empty mesh. It will reappear when the wedge itself does.

2 Likes