I'm trying to achieve a spotlight effect whereby the model is illuminated from the camera's point of view.
In other words, the camera should have a light that always points at the model.
However, the model is always illuminated as if from a stationary light source rather than a dynamic one. The same surfaces of the model are illuminated regardless of the camera's position. If I rotate the camera to the back of the model, all I see is black.
I've seen several other SO questions on this topic, but they did not solve my problem.
In viewDidLoad:
let cameraNode = SCNNode()
cameraNode.camera = SCNCamera()
scene.rootNode.addChildNode(cameraNode)
let light = SCNLight()
light.type = .directional //I've tried the other options, here, to no avail.
light.color = UIColor.init(red: 255/255, green: 255/255, blue: 255/255, alpha: 0.7)
light.castsShadow = true
cameraNode.light = light
cameraNode.position = SCNVector3(x: 0, y: 0, z: 15)
let scnView = self.view as! SCNView
scnView.pointOfView = cameraNode
To move the camera, I'm using the default camera controls via allowsCameraControl = true.
Question: How can I achieve the desired behavior, whereby the camera illuminates the model like a flashlight?
Thank you!