Created
May 21, 2018 20:10
-
-
Save azamsharp/91d4bcddc4c56951143028d64a92384b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private func setupObservers() { | |
self.rootRef.child("cloud-anchors").observe(.value) { (snapshot) in | |
if let dictionary = snapshot.value as? [String:Any] { | |
self.cloudIdentifier = dictionary["cloudIdentifier"] as! String | |
let hex = dictionary["hex"] as! String | |
if let cloudAnchor = try? self.gSession.resolveCloudAnchor(withIdentifier: self.cloudIdentifier) { | |
let box = SCNBox(width: 0.3, height: 0.3, length: 0.3, chamferRadius: 0) | |
let material = SCNMaterial() | |
material.diffuse.contents = UIColor(fromHexString: hex) | |
box.materials = [material] | |
let node = SCNNode(geometry: box) | |
node.position = SCNVector3(cloudAnchor.transform.columns.3.x, cloudAnchor.transform.columns.3.y, cloudAnchor.transform.columns.3.z) | |
self.sceneView.scene.rootNode.addChildNode(node) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment