An ARViewController with embedded features. I am will be integrating further components along the way.
- ARCursor
- ARMenu
- ARNodes
- ARScreenRecording
- ARScreenSharing
- iOS 12.0+
- Xcode 10.0+
Add the following to your Podfile:
use_frameworks!
pod 'ARSuite', :git => 'https://github.com/pierre-wehbe/ARSuite.git', :tag => '1.0.0'
- Open ARSuite.xcproject
- Build
- You will get "ARSuite.framework" under product
- Go to your project and drag the the framework of 3 anywhere in the project
- Go to Project -> General -> Linked Frameworks and Binaries, the framework should be present there
- Select it and click on the "-" sign to remove it
- Select "+" in the "Embedded Binaries" section and select the framework, it should now be present in both "Embedded Binarie" and "Linked Frameworks and Binaries"
- You're done :)
import ARSuite
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(...)
override func viewDidLoad() {
super.viewDidLoad()
// Initialize Delegates
sceneView.session.delegate = self
sceneView.delegate = self
sceneView.scene.physicsWorld.contactDelegate = self
}
// 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.
Table of Contents | Description |
---|---|
ARCursor | Cursor that enables you to interract with AR Objects present in the scene |
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)
}
}
}
To try out the different components, example projects have been created.
You can clone this repository and open the Examples
subfolder.
Contributions are highly appreciated! To submit one:
- Fork
- Commit changes to a branch in your fork
- Push your code and make a pull request
Pierre WEHBE