Recorded – watch the full episode on YouTube.
How did you learn SceneKit and ARKit, and what tips do you have for others doing the same?
James Thomson: So everything I do in my apps generally is “how can I learn something new.” And I think that is a great thing to try and do if you can: adopting these APIs because they're new and you might get features out of it. That is one sort of axis of this.
Learning a new thing is always good. And I'd done some 3D graphics back at university a long time ago on SGI work stations. And I hadn't really done anything since that point. And there were a lot of rumblings that Apple was looking at AR in a big way. And possibly looking at AR in a big way because of future products. So whether you're going to be wearing AR glasses in a few years time, who knows? But it seems like Apple's investing more heavily in AR than is justified by what they're currently doing with AR. And we've seen leaks of products in the works. And whether these things actually make it to a product, an actual product, is still an open question. But they're clearly working on something.
"PCalc currently has something like 48 alternative app icons that you can pick."
So I started with that as a, I would like to learn about doing AR. How does one start with that? And it's like, well, best way if you're going to be on Apple platforms to do that is to use SceneKit as your 3D engine. Because Apple's done a lot with SceneKit. It's a very high level object-oriented thing. It's kind of like, make a box, put it here. That box has this weight, these physics properties. Now run everything. And a physics engine will run it and things like that.
And I was like, okay, this seems fun. And people who have seen the talk that I did on Easter eggs will know that part of my attraction to all this stuff was some of the 3D things that were in Apple's little Easter eggs in the OS going back into the nineties. And I my goal was, can I make a 3D version of the icon for my app, which is just sitting in the about screen, which you can move around? And I had been doing some stuff that summer with making alternative app icons. I got into this thing of like I did a few alternative app icons and people liked them. So I did more of them. And then I did more of them. PCalc currently has something like 48 alternative app icons that you can pick.
“So everything I do in my apps generally is how can I learn something new?”
And part of that, I started, well, how can I do different ones? Because I'm not an artist, I'm not very good at it. But I can mess around with stuff in their 3D software package until it looks nice. Make it look chrome, shine a nice light on it, that kind of thing. So what I did was, as part of that, I had a 3D model of the icon which I had built. Well, let's take this, let's import this, we'll put it in the SceneKit scene file.
I now have a thing, I can move a light, I can shine a light on it and have a light that's sort of circling this icon. And then I was like, well, let's play with it. Oh, there's a physics engine. What happens if I assign physics to these objects? What if I had other objects? And it's like, ah, what's an interesting object? Bananas are an interesting shape. What happens if you threw a banana at this icon? Oh, it bounces off. This is quite good. What happens if you drop 500 bananas on it? The performance is terrible. Why is the performance terrible? It was an exploration, because I didn't have any real background in 3D graphics or performance optimization of 3D.
I basically worked my way through the SceneKit APIs. And I was working through them. Oh there's a vehicle API! You can take a model, you can say these are four wheels, and you can spin the wheels, and you can turn the wheels. And it's basically you have a little car. What if I put a little car in this? And then I put a little car in it. And you could drive it around.
"And the SceneKit APIs are really nice, I enjoy them a lot, in the kind of stuff that you can do. And it was just a process of go through the APIs, look at each section of it."
What happens if I put a ramp? I could build a ramp in a 3D graphics package – it’s just a triangle extruded out. So I built a ramp and I drove the car at it. The car jumped into the air, did this sort of real magnificent jump. And I thought this is amazing. That's where it led to, well, let's make a little assault course that this car can drive around and jump through hoops.
Then if you've delved deeper into the about screen, there's a whole city that you can drive around in. And there's a castle. I wonder if I could make my own thing. So I said, well, let's try and make a helicopter. How do you make the physics engines for a helicopter? Well, let's think of it not like a helicopter. Let's think of it like a quadcopter. Let's take this thing and mount four virtual thrusters underneath it. Could I do something like that, that auto-balanced itself? And that's an interesting problem to try and solve.
I mean, this is not a physically accurate simulation of a helicopter by any means. But it was a fun thing to try and do this. And the SceneKit APIs are really nice, I enjoy them a lot, the kind of stuff that you can do. And it was just a process of go through the APIs, look at each section of it.
The Ray Wenderlich site has a ton of really good tutorials on SceneKit. And I worked through a lot of those. And it was like, how do I do this? How does this work? And so for each thing it was learn how to do this thing. And then that worked into, let's try and do a bit of it in AR.
This transcript was recorded as part of Swiftly Speaking. You can watch the full original episode on YouTube, or subscribe to the audio version on Apple Podcasts.
SPONSORED ViRE offers discoverable way of working with regex. It provides really readable regex experience, code complete & cheat sheet, unit tests, powerful replace system, step-by-step search & replace, regex visual scheme, regex history & playground. ViRE is available on Mac & iPad.
Link copied to your pasteboard.