Skip to content

An ARViewController with embedded features. I am will be integrating further components along the way.

Notifications You must be signed in to change notification settings

pierre-wehbe/ARSuite

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ARSuite

Travis Swift 4.0

intro image

An ARViewController with embedded features. I am will be integrating further components along the way.

Current components:

  • ARCursor

TODOs:

  • ARMenu
  • ARNodes
  • ARScreenRecording
  • ARScreenSharing

Requirements

  • iOS 12.0+
  • Xcode 10.0+

Installation

CocoaPods

Add the following to your Podfile:

use_frameworks!
pod 'ARSuite', :git => 'https://github.com/pierre-wehbe/ARSuite.git', :tag => '1.0.0'

Build the framwork yourself

  1. Open ARSuite.xcproject
  2. Build
  3. You will get "ARSuite.framework" under product
  4. Go to your project and drag the the framework of 3 anywhere in the project
  5. Go to Project -> General -> Linked Frameworks and Binaries, the framework should be present there
  6. Select it and click on the "-" sign to remove it
  7. Select "+" in the "Embedded Binaries" section and select the framework, it should now be present in both "Embedded Binarie" and "Linked Frameworks and Binaries"
  8. You're done :)

Quick Start

1. Setup

import ARSuite

Step 1 - Inherit from ARSuiteViewController

class ViewController: ARSuiteViewController {
  ...
}

This view controller has already an ARSCNView sceneView embedded that is by default clipped to the view's bounds. Its frame can be modified using:

sceneView.frame = CGRect(...)

Step 2 - Initialize Delegate

override func viewDidLoad() {
  super.viewDidLoad()
  
    // Initialize Delegates
    sceneView.session.delegate = self
    sceneView.delegate = self
    sceneView.scene.physicsWorld.contactDelegate = self
}

Step 3 - Add Delegate Functions

// MARK - ARSessionDelegate
extension ViewController {
    override func session(_ session: ARSession, didUpdate frame: ARFrame) {
        super.session(session, didUpdate: frame)
    }
}

// MARK - SCNPhysicsContactDelegate
extension ViewController {
    override func physicsWorld(_ world: SCNPhysicsWorld, didBegin contact: SCNPhysicsContact) {
        super.physicsWorld(world, didBegin: contact)
    }

    override func physicsWorld(_ world: SCNPhysicsWorld, didUpdate contact: SCNPhysicsContact) {
        super.physicsWorld(world, didUpdate: contact)
    }

    override func physicsWorld(_ world: SCNPhysicsWorld, didEnd contact: SCNPhysicsContact) {
        super.physicsWorld(world, didEnd: contact)
    }
}

These need to be declared ti call its super delegate methods necessary for proper functionning of the framework.

2. Components

Table of Contents Description
ARCursor Cursor that enables you to interract with AR Objects present in the scene

ARCursor

Currently ARCursor can interract with SCNNode objects In order to make a node a target to the cursor, use the function convertNodeToTarget(node: SCNNode)

Example:

// MARK - ARSCNViewDelegate
extension ViewController: ARSCNViewDelegate {
    func renderer(_ renderer: SCNSceneRenderer, didAdd node: SCNNode, for anchor: ARAnchor) {
        guard !(anchor is ARPlaneAnchor) else { return }
        let sphereNode: SCNNode = generateSphereNode()
        convertNodeToTarget(node: sphereNode)
        DispatchQueue.main.async {
            node.addChildNode(sphereNode)
        }
    }
}

ARCursorDemo

3. Example Projects

To try out the different components, example projects have been created. You can clone this repository and open the Examples subfolder.

Contribute

Contributions are highly appreciated! To submit one:

  1. Fork
  2. Commit changes to a branch in your fork
  3. Push your code and make a pull request

Created By:

Pierre WEHBE

License

MIT

About

An ARViewController with embedded features. I am will be integrating further components along the way.

Resources

Stars

Watchers

Forks

Packages

No packages published