Hide chapters

Apple Augmented Reality by Tutorials

Second Edition · iOS 15 · Swift 5.4 · Xcode 13

Section I: Reality Composer

Section 1: 5 chapters
Show chapters Hide chapters

8. Object Anchors
Written by Chris Language

Heads up... You're reading this book for free, with parts of this chapter shown beyond this point as scrambled text.

In this chapter, you’ll learn about object anchors. Object anchors are like 2D image anchors with an added third dimension. To understand how to use object anchors, you’ll augment a physical toy truck with interactive buttons that will reveal some fun facts about its real-world counterpart.

Crafting a Toy Truck

For this project, you’ll need a physical object that you can use to create an object model. Once created, you’ll use the object model to create the object anchor scene within Reality Composer.

As it turns out, physically attaching a toy truck to this book wasn’t possible. But don’t worry, we found a solution.

FoldUpToys offers a massive collection of foldable paper toys, and you’ll use one of them for this tutorial. Follow this link and see for yourself: Tesla Cybertruck

Download the Tesla Cybertruck project and print the blueprint.

With your printout in hand, grab your scissors and glue — it’s time to build yourself a paper truck!

Depending on the level of your crafting skills, your paper truck will look something like this:

What a beauty! Ready for a test drive, so to speak?

What Are Object Anchors?

Reality Composer offers another anchor type known as an object anchor. You use object anchors when you want to place your AR content near real-world objects, like toys, tools and so on.

Installing the 3D Object Scanner

Before you can do anything, you need to install ARKit Scanner on your iPhone. You’ll use this app to create 3D scans of physical objects.

Preparing for 3D Object Scanning

For the data to represent the target object well, you need a good scan. To get the best scan possible, follow these guidelines for preparing your physical environment:

Scanning 3D Objects

At this point, you’ve installed the ARKit Scanner app on your iPhone, the environment is set, and the toy truck is ready for you to scan.

Getting Started

Start ARKit Scanner on your iPhone and follow the step-by-step instructions provided on-screen.

Refining the Bounding Box

You’re ready to place the approximated bounding box. Tap Next to continue.

Scanning All the Sides

Once you’re sure that the bounding box fully covers the toy truck, tap Scan to continue.

Adjusting the Origin Point

Once you’ve scanned 100% of the object, the scanner will automatically finish and place an estimated origin point on the object.

Testing and Improving 3D Scans

Now that the scanning process is complete, the only thing left to do is to test the object model.

Exporting AR Objects

At last, you’ve scanned your object, tested the scan and even improved the model by merging multiple scans. Your next step is to save the scanned data as an ARObject.

Creating Object Anchors

You should be familiar with this part by now, so instead of boring you with the details, we’ve supplied a ready-made AR experience. All you need to do is add your freshly-created ARObject file.

Key Points

Congratulations, you’ve finished this chapter, and you’ve successfully created an Object Anchor AR Experience.

Have a technical question? Want to report a bug? You can ask questions and report bugs to the book authors in our official book forum here.
© 2024 Kodeco Inc.

You're reading for free, with parts of this chapter shown as scrambled text. Unlock this book, and our entire catalogue of books and videos, with a Kodeco Personal Plan.

Unlock now