Latest 0.1.7
Homepage https://github.com/scottfinkelstein/MixedRealityKit
License MIT
Platforms ios 11.0
Frameworks Foundation, UIKit, SceneKit, ARKit
Authors

An easy way to add a stereoscopic ARKit SceneView to your project.

The MixedRealityKit class extends ARSCNView and splits camera in two stereoscopic SceneViews. Works with Google Cardboard or any VR Viewer that supports non-barrel distorted VR.

Virtual Reality Demo (enclosed room scene)
Virtual Reality Example

Mixed Reality Demo (viewing virtual objects in the real world)
Virtual Reality Example

Setting up a new Project to use MixedRealityKit

  1. Add to your podfile:

pod 'MixedRealityKit'

  1. In Terminal, navigate to your project folder, then:

pod update

pod install

  1. Make sure the Camera Usage Description key is set in your info.plist.
  2. For best results, uncheck Portrait under Device Orientation. Due to some weirdness with the scene flipping upside down, you need both Landscape Left and Landscape Right checked.

Change your ViewController class to look like the following

import UIKit
import SceneKit
import ARKit
import MixedRealityKit

class ViewController: UIViewController, MixedRealityDelegate {

    var sceneView:MixedRealityKit?

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        sceneView=MixedRealityKit(frame: view.frame)
        sceneView?.mixedRealityDelegate = self

        let scene=SCNScene()
        sceneView?.scene=scene

        view.addSubview(sceneView!)
    }

    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        sceneView?.runSession()
    }

    override func viewWillDisappear(_ animated: Bool) {
        super.viewWillDisappear(animated)
        sceneView?.pauseSession()
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    // MixedRealityDelegate Methods - These are passed from ARSCNViewDelegate and ARSCNSessionDelegate by way of the MixedRealityDelegate, allowing you to subscribe only to MixedRealityDelegate

    func renderer(_ renderer: SCNSceneRenderer, updateAtTime time: TimeInterval) {

    }

    func renderer(_ renderer: SCNSceneRenderer, didAdd node: SCNNode, for anchor: ARAnchor) {

    }

    func renderer(_ renderer: SCNSceneRenderer, willUpdate node: SCNNode, for anchor: ARAnchor) {

    }

    func renderer(_ renderer: SCNSceneRenderer, didRemove node: SCNNode, for anchor: ARAnchor) {

    }

    func session(_ session: ARSession, didUpdate frame: ARFrame) {

    }

    func session(_ session: ARSession, didFailWithError error: Error) {

    }

    func sessionWasInterrupted(_ session: ARSession) {

    }

    func sessionInterruptionEnded(_ session: ARSession) {

    }

}

You can use the Room.scn file provided in this repo, or create an empty SCNScene(), adding your own nodes to it. If you are adding a floor to your scene, you will need to play with the y-axis positioning so it matches the relative eye level. I found that -1.7 worked well.

Delegates

I added a new delegate to the MixedRealityKit class called mixedRealityDelegate which allows you to optionally override the ARSCNViewDelegate methods in your ViewController as you normally would, passing them to the MixedRealityKit class. While you don’t need to override these delegates, you will need to implement them in your ViewController. The Error Message "Fix" button will do this for you if you are lazy :) I’m hoping to fix this requirement in a future release.

Options

disableSleepMode – (default: true): When set to true your device will not go turn off when idle. This can be overridden, but since your device will likely be in a Google Cardboard, you will not want it to go to sleep.

The runSession() method takes the optional parameter detectPlanes (default: false). As of now, only horizontal plane detection is available out of the box.

Author

Scott Finkelstein Twitter

Available as open source under the terms of the MIT License.

Latest podspec

{
    "name": "MixedRealityKit",
    "version": "0.1.7",
    "summary": "Easily add a stereoscopic ARKit SceneView to your project.",
    "description": "The MixedRealityKit class extends ARSCNView and splits camera in two stereoscopic SceneViews. Works with Google Cardboard or any VR Viewer that supports non-barrel distorted VR.",
    "homepage": "https://github.com/scottfinkelstein/MixedRealityKit",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Scott Finkelstein": "[email protected]"
    },
    "source": {
        "git": "https://github.com/scottfinkelstein/MixedRealityKit.git",
        "tag": "0.1.7"
    },
    "platforms": {
        "ios": "11.0"
    },
    "source_files": "MixedRealityKit/Source/MixedRealityKit.swift",
    "frameworks": [
        "Foundation",
        "UIKit",
        "SceneKit",
        "ARKit"
    ],
    "pushed_with_swift_version": ""4.0""
}

Pin It on Pinterest

Share This