Placing Virtual Objects in Augmented Reality

Overview

Placing Virtual Objects in Augmented Reality

Learn best practices for visual feedback, gesture interactions, and realistic rendering in AR experiences, as well as tips for building SceneKit-based AR apps.

Overview

Augmented reality offers new ways for users to interact with real and virtual 3D content in your app. However, many of the fundamental principles of human interface design are still valid. Convincing AR illusions also require careful attention to 3D asset design and rendering. By following this article's guidelines for AR human interface principles and experimenting with this example code, you can create immersive, intuitive augmented reality experiences.

Getting Started

ARKit is available on any iOS 11 device, but the world tracking features that enable high-quality AR experiences require a device with the A9 or later processor.

Feedback

Help users recognize when your app is ready for real-world interactions. Tracking the real-world environment involves complex algorithms whose timeliness and accuracy are affected by real-world conditions.

The FocusSquare class in this example project draws a square outline in the AR view, giving the user hints about the status of ARKit world tracking. The square changes size to reflect estimated scene depth, and switches between open and closed states with a "lock" animation to indicate whether ARKit has detected a plane suitable for placing an object.

Use the session(_:cameraDidChangeTrackingState:) delegate method to detect changes in tracking quality, and present feedback to the user when low-quality conditions are correctable (for example, by telling the user to move to an environment with better lighting).

Use specific terms a user is likely to recognize. For example, if you give textual feedback for plane detection, a user not familiar with technical definitions might mistake the word "plane" as referring to aircraft.

Fall back gracefully if tracking fails, and allow the user to reset tracking if their experience isn't working as expected. See the restartExperience button and method in this example's ViewController class. The use3DOFTrackingFallback variable controls whether to switch to a lower-fidelity session configuration when tracking quality is poor.

Help users understand the relationship of your app's virtual content to the real world. Use visual cues in your UI that react to changes in camera position relative to virtual content.

The focus square disappears after the user places an object in the scene, and reappears when the user points the camera away from the object.

The Plane class in this example handles visualization of real-world planes detected by ARKit. Its createOcclusionNode and updateOcclusionNode methods create invisible geometry that realistically obscures virtual content.

Direct Manipulation

Provide common gestures, familiar to users of other iOS apps, for interacting with real-world objects. See the Gesture class in this example for implementations of the gestures available in this example app, such as one-finger dragging to move a virtual object and two-finger rotation to spin the object.

Map touch gestures into a restricted space so the user can more easily control results. Touch gestures are inherently two-dimensional, but an AR experience involves the three dimensions of the real world. For example:

  • Limit object dragging to the two-dimensional plane the object rests on. (Especially if a plane represents the ground or floor, it often makes sense to ignore the plane's extent while dragging.)

  • Limit object rotation to a single axis at a time. (In this example, each object rests on a plane, so the object can rotate around a vertical axis.)

  • Don't allow the user to resize virtual objects, or offer this ability only sparingly. A virtual object inhabits the real world more convincingly when it has an intuitive intrinsic size. Additionally, a user may become confused as to whether they're resizing an object or changing its depth relative to the camera. (If you do provide object resizing, use pinch gestures.)

While the user is dragging a virtual object, smooth the changes in its position so that it doesn't appear to jump while moving. See the updateVirtualObjectPosition method in this example's ViewController class for an example of smoothing based on perceived distance from the camera.

Set thresholds for gestures so that the user doesn't trigger a gesture accidentally, but moderate your thresholds so that gestures aren't too hard to discover or intentionally trigger. See the TwoFingerGesture class for examples of using thresholds to dynamically choose gesture effects.

Provide a large enough area where the user can tap (or begin a drag) on a virtual object, so that they can still see the object while moving it. See how the firstTouchWasOnObject boolean is computed in the TwoFingerGesture class for examples.

Design interactions for situations where AR illusions can be most convincing. For example, place virtual content near the centers of detected planes, where it's safer to assume that the detected plane is a good match to the real-world surface. It may be tempting to design experiences that use the full surface of a table top, where virtual scene elements can react to or fall off the table's edges. However, world tracking and plane detection may not precisely estimate the edges of the table.

User Control

Strive for a balance between accurately placing virtual content and respecting the user's input. For example, consider a situation where the user attempts to place content that should appear on top of a flat surface.

  • First, try to place content by using the hitTest(_:types:) method to search for an intersection with a plane anchor. If you don't find a plane anchor, there might still be a plane at the target location that has not yet been identified by plane detection.
  • Lacking a plane anchor, you can hit-test against scene features to get a rough estimate for where to place content right away, and refine that estimate over time as ARKit detects planes.
  • When plane detection provides a better estimate for where to place content, use animation to subtly move that content to its new position. Having user-placed content suddenly jump to a new position can break the AR illusion and confuse the user.
  • Filter out hit test results which are too close or too far away. In most scenarios there exists a reasonable limit for how far away virtual content can be placed. To prevent users from accidentally placing virtual content too far away you can make use of the distance property of ARHitTestResult to filter out hit tests which exeed the limit.

Avoid interrupting the AR experience. If the user transitions to another fullscreen UI in your app, the AR view might not be an expected state when coming back.

Use the popover presentation (even on iPhone) for auxiliary view controllers to keep the user in the AR experience while adjusting settings or making a modal selection. In this example, the SettingsViewController and VirtualObjectSelectionViewController classes use popover presentation.

Testing

For testing and debugging AR experiences, it helps to have a live visualization of the scene processing that ARKit performs. See the showDebugVisuals method in this project's ViewController class for world tracking visualization, and the HitTestVisualization class for a demonstration of ARKit's feature detection methods.

You might also like...
A minimal iOS AR app that displays virtual objects at specific geographical locations, in an AR scene.
A minimal iOS AR app that displays virtual objects at specific geographical locations, in an AR scene.

AR Simple GeoLocation A minimal iOS AR, Augmented Reality, app that displays virtual objects at specific geographical location, in an AR scene. With t

Reality-iOS - NFT Augmented Reality(AR) app that demonstrate application of ARImageTracking in iOS powered by ARKit 2

Reality-iOS NFT Augmented Reality(AR) app that demonstrate application of ARImag

Browse the streets of Los Angeles on an Augmented Reality historical walking tour.

Ruscha AR 0.3 Browse the streets of Los Angeles on an Augmented Reality historical walking tour. Explore Hollywood through the photos of Ed Ruscha. Th

A collaborative Augmented Reality iOS experience using Real-time Messaging

Collaborative AR Experience This project creates an augmented reality experience where you can build a scene together with anyone around the world, se

 It is a music and podcast creation system that enables users to create multiple tracks using AR(Augmented Reality).
It is a music and podcast creation system that enables users to create multiple tracks using AR(Augmented Reality).

AR-Studio It is a music creation system enables users to create multiple tracks using AR(Augmented Reality). Introduction AR Studio turns your iPad, a

👻 Augmented reality game in a pixel/billboard style
👻 Augmented reality game in a pixel/billboard style

ARbusters What's ARbusters? ARbusters is an augmented reality game in a pixel/billboard style. The gameplay is pretty simple, look around you and kill

Augmented Reality image tracking with SwiftUI, RealityKit and ARKit 4.

ARImageTracking This is an Augmented Reality Xcode project that uses Apple's newest RealityKit framework and ARKit 4 features, to dynamically track a

An augmented reality (AR) ghost hunting simulation for iPhone

ARanormal An augmented reality (AR) ghost hunting simulation for iPhone About ARanormal was the first game by Jesdo Software, released for iPhone in O

Furniture E-Commerce Augmented Reality(AR) app in iOS powered by ARKit
Furniture E-Commerce Augmented Reality(AR) app in iOS powered by ARKit

HomeMax-iOS Furniture E-Commerce Augmented Reality(AR) app in iOS powered by ARKit and SceneKit. Inspired by IKEA place app. Description Experience on

ARID - Augmented Reality app using Apple’s ARKit framework which can recognise faces of famous scientists
ARID - Augmented Reality app using Apple’s ARKit framework which can recognise faces of famous scientists

ARID Augmented Reality app using Apple’s ARKit framework which can recognise fac

ARDicee - Simple augmented reality app using SceneKit and ARKit
ARDicee - Simple augmented reality app using SceneKit and ARKit

ARDicee Simple augmented reality app using SceneKit and ARKit Requirements Xcode

Develop simple and fun Augmented Reality (AR) iOS apps
Develop simple and fun Augmented Reality (AR) iOS apps

AR-Dice Simple and fun to use iOS app made to make Augmented reality (AR) be in

Smart Online Shopping iOS App with Augmented Reality (AR) and simple Social Media features using SwiftUI and Google Firebase Cloud Services
Smart Online Shopping iOS App with Augmented Reality (AR) and simple Social Media features using SwiftUI and Google Firebase Cloud Services

Table of contents App Demo How to Run Context Content How it's written Inspiration App Demo AR.online.shopping.iOS.demo.mp4 How to Run First make sure

ARKit Base Project. Place virtual objects based on WWDC example project
ARKit Base Project. Place virtual objects based on WWDC example project

ARKit - Placing Virtual Objects in Augmented Reality Learn best practices for visual feedback, gesture interactions, and realistic rendering in AR exp

A minimal iOS AR app that displays virtual objects at specific geographical locations, in an AR scene.
A minimal iOS AR app that displays virtual objects at specific geographical locations, in an AR scene.

AR Simple GeoLocation A minimal iOS AR, Augmented Reality, app that displays virtual objects at specific geographical location, in an AR scene. With t

A ARM macOS Virtual Machine, using macOS 12's new Virtualization framework.
A ARM macOS Virtual Machine, using macOS 12's new Virtualization framework.

macOS Virtual Machine A ARM macOS Virtual Machine, using macOS 12's new Virtualization framework. I copied KhaosT's code from here, all I did is chang

A note source and a rhythm source to create a new virtual MIDI instrument

MidiCombiner for Mac Combines inputs from 2 different MIDI sources: A note source and a rhythm source to create a new virtual MIDI instrument. The not

ZX Spectrum emulator for macOs. Retro Virtual Machine

Retro Virtual Machine 1.1.x This is the code for version 1.1.x of my emulator for the ZX Spectrum, Retro Virtual Machine. The current version (v2.0.7)

Comments
  • type '[vector_float3]' (aka 'Array<float3>') has no member 'advanced' Error

    type '[vector_float3]' (aka 'Array') has no member 'advanced' Error

    Value of type '[vector_float3]' (aka 'Array') has no member 'advanced'

    I am getting above error in Xcode 9 GM seed in Utilities.swift It was working fine in Xcode beta 3 but it is not working in latest version Please help me to solve this error.

    opened by arpitjain03 2
  • Persistent storing objects

    Persistent storing objects

    How to store the locations of objects in userdefaults and obtain it on restarting the application. Because objects are being rendered as an vector of Virtual Object class, so on load how to render it again where it was.

    opened by jitinarora22 0
  • add multiple objects at once

    add multiple objects at once

    Hey,

    i'm trying to add one model for multiple times. I changed the delegate code to add a scene every time the plus button is tapped. I think that the problem is in ViewController.swift: `// MARK: - Virtual Object Loading

    var virtualObject: VirtualObject? func loadVirtualObject(at index: Int) {...}`

    Is there only place for one object in SceneView?

    For now every time i add a new model the old one disappears.

    opened by oneeypi 1
  • This doesn't work anymore...?

    This doesn't work anymore...?

    Does this app work anymore?

    When I try to run it I get like 15 errors involving all sorts of stuff: "Use of undeclared type AESessionConfiguration" and so on...

    skaermbillede 2017-12-04 kl 10 13 33
    opened by ghost 0
Owner
Yuchao
Yuchao
Browse the streets of Los Angeles on an Augmented Reality historical walking tour.

Ruscha AR 0.3 Browse the streets of Los Angeles on an Augmented Reality historical walking tour. Explore Hollywood through the photos of Ed Ruscha. Th

Rick van Voorden 2 Jul 9, 2022
It is a music and podcast creation system that enables users to create multiple tracks using AR(Augmented Reality).

AR-Studio It is a music creation system enables users to create multiple tracks using AR(Augmented Reality). Introduction AR Studio turns your iPad, a

Ayush Singh 5 Dec 3, 2022
Augmented Reality image tracking with SwiftUI, RealityKit and ARKit 4.

ARImageTracking This is an Augmented Reality Xcode project that uses Apple's newest RealityKit framework and ARKit 4 features, to dynamically track a

Richard Qi 198 Dec 7, 2022
An augmented reality (AR) ghost hunting simulation for iPhone

ARanormal An augmented reality (AR) ghost hunting simulation for iPhone About ARanormal was the first game by Jesdo Software, released for iPhone in O

Jesse Douglas 1 Nov 2, 2021
Furniture E-Commerce Augmented Reality(AR) app in iOS powered by ARKit

HomeMax-iOS Furniture E-Commerce Augmented Reality(AR) app in iOS powered by ARKit and SceneKit. Inspired by IKEA place app. Description Experience on

Ikmal Azman 5 Oct 14, 2022
ARID - Augmented Reality app using Apple’s ARKit framework which can recognise faces of famous scientists

ARID Augmented Reality app using Apple’s ARKit framework which can recognise fac

Hemanth 0 Jan 12, 2022
ARDicee - Simple augmented reality app using SceneKit and ARKit

ARDicee Simple augmented reality app using SceneKit and ARKit Requirements Xcode

donggyu 3 Feb 4, 2022
Develop simple and fun Augmented Reality (AR) iOS apps

AR-Dice Simple and fun to use iOS app made to make Augmented reality (AR) be in

Dishant Nagpal 1 Feb 23, 2022
Smart Online Shopping iOS App with Augmented Reality (AR) and simple Social Media features using SwiftUI and Google Firebase Cloud Services

Table of contents App Demo How to Run Context Content How it's written Inspiration App Demo AR.online.shopping.iOS.demo.mp4 How to Run First make sure

Ashkan Goharfar 13 Nov 1, 2022
ARKit Base Project. Place virtual objects based on WWDC example project

ARKit - Placing Virtual Objects in Augmented Reality Learn best practices for visual feedback, gesture interactions, and realistic rendering in AR exp

Ignacio Chiazzo Cardarello 338 Jan 5, 2023