Mesh boolean subtraction operation with SceneKit/RealityKit

I ma trying to figure out if there is a Boolean subtraction functionality native in SceneKit or RealityKit. Simple operation like cutting a hole in a box from a sphere.

If not, are there any libraries (free) that I can look into?

Answered by arthurfromberlin in 676672022

I think Model I/O offers this for Voxels: https://developer.apple.com/documentation/modelio/mdlvoxelarray

But you could take a look at this library to generate models which could be used in SceneKit via SCNGeometry(which in turn could be exported to USDZ and then used with RealityKit): https://github.com/nicklockwood/Euclid

Accepted Answer

I think Model I/O offers this for Voxels: https://developer.apple.com/documentation/modelio/mdlvoxelarray

But you could take a look at this library to generate models which could be used in SceneKit via SCNGeometry(which in turn could be exported to USDZ and then used with RealityKit): https://github.com/nicklockwood/Euclid

Model I/O can do it with voxels as mentioned. Using Voxels and BSP trees don't normally produce very clean results. Unfortunately there isn't a good library to use out-of-the-box. Here is a good article/algorithm for producing cleaner meshes: http://sandervanrossen.blogspot.com/2009/12/realtime-csg-part-1.html

Mesh boolean subtraction operation with SceneKit/RealityKit
 
 
Q