import UIKit
import SceneKit
class Scene: SCNScene {
var cameraPosition = SCNVector3Make(0, 0, 10)
var lightPosition = SCNVector3Make(0, 0, 0)
var ship = SCNNode()
func setup() {
createCameraNode()
createShipNode()
createAmbientLight()
createLight()
}
func createCameraNode () {
let cameraNode = SCNNode()
cameraNode.camera = SCNCamera()
cameraNode.position = cameraPosition
self.rootNode.addChildNode(cameraNode)
}
func createShipNode() {
ship = self.rootNode.childNodeWithName("ship", recursively: true)!
}
func createAmbientLight() {
let ambientLightNode = SCNNode()
ambientLightNode.light = SCNLight()
ambientLightNode.light!.type = SCNLightTypeAmbient
ambientLightNode.light!.color = UIColor.darkGrayColor()
self.rootNode.addChildNode(ambientLightNode)
}
func createLight() {
let lightNode = SCNNode()
lightNode.light = SCNLight()
lightNode.light!.type = SCNLightTypeOmni
lightNode.position = lightPosition
self.rootNode.addChildNode(lightNode)
}
}
This is how my code looks like. I have the following problem. When I add camera node in Scene, my object disappear. When I remove function createCameraNode, everything is ok, my spaceship appears on screen. I have tried to change camera position with negative and positive values on z axis, but still no result. Can someone explain me why?