Better Programming

Advice for programmers.

Follow publication

Member-only story

Creating Custom Geometry With Standard Shapes in SceneKit Under SwiftUI

Continuing my investigation into SceneKit

Mark Lucking
Better Programming
Published in
4 min readMay 13, 2022
An imaginary planet — a custom shape, drawn using SCNSphere as a base

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…

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Mark Lucking
Mark Lucking

Written by Mark Lucking

Coding for 35+ years, enjoying using and learning Swift/iOS development. Writer @ Better Programming, @The StartUp, @Mac O’Clock, Level Up Coding & More

No responses yet

Write a response