3D Procedural generation at runtime

Hey guys,

Seems like simple question, but was not able to find a clear answer. I am building an app (game like) and all 3D geometry is going to be created and modified at run time.

What framework should I use with SwiftUI ? SceneKit or RealityKit

Thanks

Replies

I fully expect any answer you get from Apple would be "They're both fully supported frameworks", and so far that's boiled down to how you want to use the content. For quite a while, only SceneKit had APIs for generating geometry meshes procedurally, but two years ago RealityKit quietly added API (although it's not really documented) - so you can do the same there.

RealityKit comes with a super-easy path to making 3D content overlaying the current world (at least through the lens of an iPhone or iPad currently), but if you're just trying to display 3D content on macOS its quite a bit crankier to deal with (although it's possible). RealityKit also comes with a presumption that you'll be coding the interactions with any 3D content leveraging an ECS pattern, which is rather "built-in" at the core. The best examples & content I've seen for learning how to procedurally assemble geometry with RealityKit is RealityGeometries at (https://swiftpackageindex.com/maxxfrazer/RealityGeometries) - read through the code and you'll see how the MeshDescriptors are used to assemble things.

SceneKit is a slightly older API, but in some ways much easier to get into for procedurally generated (and displayed) geometry. There's also some libraries you can leverage (such as Euclid at (https://github.com/nicklockwood/Euclid) which has been a joy for my experiments and purpose. There's quite a bit more (existing) sample content out there for SceneKit, so while the API can be a bit quirky from swift, it's quite solid.

Hi @heckj

Thank you for such a detailed explanation. It seems I will go with SceneKit and will hope apple will not kill it in a year or two. Building my app for iOS(IPad) and Mac Plus SceneKit has a lot of helpful things like, camera controller, mesh flattening and so on… Does it uses ECS as well or only RealityKit? What you mean by SceneKit being quirky with Swift?

Btw here is what I am building https://www.thebrief.space