Skip to content

Instantly share code, notes, and snippets.

@azamsharp
Created May 21, 2018 20:10
Show Gist options
  • Save azamsharp/91d4bcddc4c56951143028d64a92384b to your computer and use it in GitHub Desktop.
Save azamsharp/91d4bcddc4c56951143028d64a92384b to your computer and use it in GitHub Desktop.
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