Giter Club home page Giter Club logo

arkit's Introduction

🎈 AR Post Malone 🎈

Platform Language

Augmented reality (AR) describes user experiences that add 2D or 3D elements to the live view from a device’s camera in a way that makes those elements appear to inhabit the real world.

I am going to show how neat is to write an AR iOS application with ARKit, a framework that provides you high-level classes for tracking, scene understanding and rendering. More specifically, ARKit is a session based framework. This means that everything will happen in a concrete session. The session relates the virtual objects with the real world by means of the Tracking.

This app runs an ARKit world tracking session with content displayed in a SpriteKit 2D view. Every session has a scene that will render the virtual objects in the real world, accessed by means of the iOS device sensors.

This app is based on the code ARBalloons.

Running

  • This app has been successfully tested on Xcode 9.4 + iOS 11.4.
  • When running it in your device, simply click on where you want to see Post Malone. Then click again to explode it out! 😎

Understanding the Source Code

Info.plist

An information property list file is a XML file that contains essential configuration information for a bundled executable. Example of the information you want to add is:

  • The name of your app (<string>PostMaloneBalloon</string>).
  • Camera usage (<key>NSCameraUsageDescription</key>).
  • Frameworks you need (<key>UIRequiredDeviceCapabilities</key> with <string>armv7</string> and <string>arkit</string>).

Assets.xcassets directory

This is where you place assets such as the images used in your App (Post Malone head) and icons. A file Content.json is placed inside every directory to describe the assets.

Base.lproj directory

Contains two story board files, that were borrowed from this example.:

  • LaunchScreen.storyboard.
  • Main.storyboard.

Scene.swift

Anchors are 3D points that correspond to real-world features that ARKit detects. Anchors are created in this class, together with the Sprite scene (Scene.sks). The class Scene controls how the App is operating within the scenes. Rendering brings tracking and scene understanding together with your content.

For our App, we are:

  • Defining the method touchesBegan, where we define what happens when we click the scene.
  • The sequence of movements is defined by let sequence = SKAction.sequence([popSound, moveDown, moveDownFloating, moveToBottom]).
  • When you touch the scene, a Post Malone Balloon head appears and starts to behave as a balloon (moveDownFloating = ((arc4random() % 2)==0) ? moveLeftDown : moveRightDown).
  • The balloon either pops (let popSound = SKAction.playSoundFileNamed("pop", waitForCompletion: false)) or fades after a second (fadeOut = SKAction.fadeOut(withDuration: 1.0)).
  • An ARAnchor uses a 4×4 matrix represents the combined position, rotation or orientation, and scale of an object in three-dimensional space (as in var translation = matrix_identity_float4x4).

ViewController.swift

This view is managed by the class ViewController, which inherits from ARSKViewDelegate so that we can create a sceneView variable. This class has methods for:

  • Views

    • Scaling and placing the view.
    • View when it loads (and load the pre-defined scene from SKScene).
    • View to appear and disappear.
    • Run.
  • Sessions

    • Session interrupted.
    • Session ended.

AppDelegate.swift

This is where we call the class AppDelegate, which answers for UIApplicationMain. In this class, we create a variable that will work as the window UI and we have UI methods for:

  • See if the application is about to move from active to inactive state (for example, pause ongoing tasks).
  • Release shared resources and save user data.
  • Change from the background to the active state.
  • Restart any tasks that were paused while the application was inactive.
  • Termination actions for when the application is about to terminate (for example, to save data if appropriate).

Some Learning References

Augmented Reality

AR Platforms

Quintessential Readings

Courses

Code Samples


Virtual Reality

Devices

Devices supporting three degrees of freedom:

Devices supporting six degrees of freedom:

Game Engines

  • Unity: uses C# as its primary programming language.
  • Unreal: uses C++ and a node-based language called Blueprints Visual Scripting.

Development

  • React 260.
  • WebVR: open standard with a JavaScript API that makes it possible to experience VR in your browser.
  • A-frame: framework for building virtual reality experiences with HTML.
  • React VR: library developed by Facebook based on React and React Native.
  • treejs.

Assets

Making

Buying

UI/UX

Quintessential VR News & Blogs

VR Channels

VR Courses

VR Podcasts

VR Forums

Some Terminology

  • Field of view: measured in degrees, is the extent of the observable world that is seen at any given moment (humans have a FOV of around 180°, but most HMDs offer between 50 and 110°).

  • Latency: In VR, a 20 millisecond latency is considered low and acceptable for a comfortable experience.

  • Haptics: recreate the sense of touch by applying forces, vibrations, or motions to the user, through feedback devices (example, vibrating game controllers).

  • Stitching: the process of combining multiple video sources with overlapping fields of view to produce a fully immersive 360°. 

  • Visual Inertial Odometry: ARKit analyzes the phone camera and motion data in order to keep track of the world around i ARSession object that manages the motion tracking and image processing.


License

Creative Commons License

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

arkit's People

Contributors

mia-stein avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.