Created
March 4, 2019 14:44
-
-
Save giln/e8f841d2b737f3b3d364a9210e1fa892 to your computer and use it in GitHub Desktop.
PlaneNode
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
import ARKit | |
import SceneKit | |
public class PlaneNode: SCNNode { | |
// MARK: - Public functions | |
public func update(from planeAnchor: ARPlaneAnchor) { | |
// We need to create a new geometry each time because it does not seem to update correctly for physics | |
guard let device = MTLCreateSystemDefaultDevice(), | |
let geom = ARSCNPlaneGeometry(device: device) else { | |
fatalError() | |
} | |
geom.firstMaterial?.diffuse.contents = UIColor.blue.withAlphaComponent(0.3) | |
geom.update(from: planeAnchor.geometry) | |
// We modify our plane geometry each time ARKit updates the shape of an existing plane | |
geometry = geom | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment