How to set defaultCameraController's point of view at SCNView instantiation?

Hello,


I've got a `sceneView` of type SCNView that I create. It has this set like so: "sceneView.allowsCameraControl = true".


Right after that I am trying to set the position like so:


"sceneView.defaultCameraController.pointOfView?.simdPosition = [0.0, 0.0, 90.0]"


However, there is no "pointOfView"!


Where would be the optimal place to set this position? I have it working on a tap gesture recognizer that I use later, but I'd like to set it right after "pointOfView" exists so that when this view is created the proper view position for the user is set.

Accepted Reply

For others wondering. I found you can explicitly set a node with a camera like so with an initial position:


cameraNode = SCNNode()
cameraNode.camera = SCNCamera()
cameraNode.position = SCNVector3Make(0, 0, 25)
someScene.rootNode.addChildNode(cameraNode)


And then later on your sceneView go:


sceneView.allowsCameraControl = true

Replies

For others wondering. I found you can explicitly set a node with a camera like so with an initial position:


cameraNode = SCNNode()
cameraNode.camera = SCNCamera()
cameraNode.position = SCNVector3Make(0, 0, 25)
someScene.rootNode.addChildNode(cameraNode)


And then later on your sceneView go:


sceneView.allowsCameraControl = true