While working on other things, I discovered how performant it was to switch textures on an SCNNode. What if I could switch textures quickly, like at the speed of scroll? And thus, ARPKCarousel was born. spoiler: it’s plenty fast in a scrollview

See it on Github  github

I like working with usdz files so I grabbed one off Apple’s QuickLook Gallery and chucked it into a SCNView. Then underneath, I have a UICollectionView and the gist of it is whatever is at index 0 is the texture of the model. I added a few quality of life tweaks:

  • the SCNView is placed to hide the ‘active’ texture cell but not the label so you can get some context
  • The UICollectionView has a large right contentInset to make sure the last cell can fit underneath slot 0
  • I used a subclass of UICollectionViewFlowLayout to get the cells to snap to position 0 nicely (thanks to this SO post https://stackoverflow.com/a/49617263)

There could be a lot of other cool things to make this more useable but I’d like to move onto experiments on how this works in AR in future posts