The original sample code runs well on my system. However, after adding few code for light as the following:
override func viewDidLoad() {
...
let light = SCNLight()
light.type = SCNLight.LightType.ambient
light.color = UIColor(white: 0.67, alpha: 1.0)
let ambientLightNode = SCNNode()
ambientLightNode.light = light
sceneView.scene.rootNode.addChildNode(ambientLightNode)
}
the app crashes in function renderer(didAdd:for:) for the line
previewNode?.removeFromParentNode()
Any idea? Thanks