Created
October 5, 2017 17:32
-
-
Save azamsharp/d9db1d937e8e4b87e7acd219cf1d1ffb to your computer and use it in GitHub Desktop.
AR CoreLocation
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
ViewController.swift: | |
for item in response.mapItems { | |
let placeLocation = (item.placemark.location)! | |
let placeAnnotationNode = PlaceAnnotation(location: placeLocation) | |
placeAnnotationNode.scale = SCNVector3(0.1, 0.1, 0.1) | |
DispatchQueue.main.async { | |
self.sceneLocationView.addLocationNodeWithConfirmedLocation(locationNode: placeAnnotationNode) | |
} | |
} | |
PlaceLocation.swift: | |
import Foundation | |
import ARCL | |
import CoreLocation | |
import SceneKit | |
class PlaceAnnotation : LocationNode { | |
public var annotationNode: SCNNode | |
override init(location: CLLocation?) { | |
self.annotationNode = SCNNode() | |
super.init(location: location) | |
initializeUI() | |
} | |
private func initializeUI() { | |
let boxGeometry = SCNBox(width: 0.2, height: 0.2, length: 0.2, chamferRadius: 0) | |
let material = SCNMaterial() | |
material.diffuse.contents = UIColor.red | |
boxGeometry.materials = [material] | |
self.annotationNode.geometry = boxGeometry | |
let billboardConstraint = SCNBillboardConstraint() | |
billboardConstraint.freeAxes = SCNBillboardAxis.Y | |
constraints = [billboardConstraint] | |
self.addChildNode(self.annotationNode) | |
} | |
required init?(coder aDecoder: NSCoder) { | |
fatalError("init(coder:) has not been implemented") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment