ARKitのサンプル集「ARKit-Sampler」をオープンソースで公開しました。

ソースコードは GitHub に置いてあるので、ご自由にご活用ください。
使用言語はSwiftです。
ARKitのサンプルは公式のを含めいろいろ出てますが、ARKit-Samplerでは「余計な実装を混ぜずに、できるだけシンプルな実装で伝える」というところに気をつけています。もともとは書籍執筆のために用意したものなので、とくに序盤のサンプルはシンプルで意図が汲みやすいと思います。
ビルド方法
- ここから Inceptionv3.mlmodel をダウンロードして mlmodels フォルダ配下に置く
- Xcode 9 でビルドしてiOS 11端末にインストール
基本的にビルドするだけですが、Core MLのモデルファイルをダウンロードしてくる必要があります。
サンプル一覧
今のところ12個のサンプルが入っています。随時追加していきます。
3-lines AR
「実質3行」のシンプルなAR。ARKitが簡単に扱えるということがわかります。

Plane Detection
ARKitの基本機能、水平面の検出方法を示したシンプルなサンプル。

Virtual Object
水平面に仮想オブジェクトを設置するサンプル。

AR Interaction
仮想オブジェクトや、検出した水平面に対するインタラクションの実装方法を示したサンプル。
AR Measure
もはやARKitの定番実装例となっている、ARKitをメジャー(巻尺)代わりに使うサンプル。

AR Drawing
空中に絵や文字を書くサンプル。

Core ML + ARKit",
Core ML + Visionで認識したオブジェクトに対してARKitで「ARタグ付け」するサンプル。

Metal + ARKit
ARKitの描画にMetalを利用するサンプル。

Metal + ARKit (SCNProgram)
ARKitで追加した仮想オブジェクトのマテリアルをSCNProgram
を用いてMetalで描画するサンプル。

Simple Face Tracking
Face-basedなARのサンプル。

Vertical Plane Detection
ARKit 1.5から入った、垂直平面を検出するサンプル。
Irregularly-Shaped Plane Detection
ARKit 1.5から入った、ARSCNPlaneGeometry
とARPlaneGeometry
を使用して「非」矩形な形状の表面を検出するサンプル。

「つくりながら学ぶ」ARKitの入門書
ARKitの本を書いて個人で出版しました。
はじめの一歩として3行で書ける最小実装のARから始めて、平面を検出する方法、その平面に仮想オブジェクトを設置する方法、そしてその仮想オブジェクトとインタラクションできるようにする方法・・・と、読み進めるにつれて「作りながら」引き出しが増えていき、最終的にはARKitを用いたメジャーや、空間に絵や文字を描くといった、ARKitならではのアプリケーションの実装ができるよう構成しています。
全142ページ。サンプルコードはGitHubよりダウンロード可能です。BOOTHにて販売中。