Member-only story
Creating Custom Geometry With Standard Shapes in SceneKit Under SwiftUI
Continuing my investigation into SceneKit

A while back, I wrote a piece about the Swift Algorithms library. A set of code primitives developed by Apple that — well — one day may make it into the core Swift language. Implementations that are probably better pieces of code than you or I would have time to craft. Data structures like stacks and double-ended arrays — code you should use rather than reinvent.
In the same vein, I want to continue an exploration of custom geometric meshes and shapes, that is, reusing code that Apple has already written, although perhaps a little differently from the Swift Algorithms library.
Now, in SceneKit, you have half a dozen predefined shapes you can build, like SCNSphere
, SCNCylinder
and SCNBox
. They’re all good, but sometimes you want/need more.
More, you can get perhaps a little easier by making use of those predefined shapes in your custom geometry — join me to look at how you can use SceneKit to build the bare bones of your model and then add to it later. Be warned, I plan to use the createGeometry routine I published in this paper earlier in the month.
As before, I want to start this piece with some code with an extension to extract a template of vertices…