0

When I setup the scene, the camera gets its position like here:

    let cameraNode = SCNNode()
    cameraNode.camera = SCNCamera()
    scene?.rootNode.addChildNode(cameraNode)
    cameraNode.position = SCNVector3(x: 0, y: 0, z: 20)

My (obviously wrong) assumption was that these position data will change when a user starts to move or zoom the 3D model. This would mean that actually not the 3D model is changing its position but just the view point (of the camera).

However, I notice that the initial data do never change and I cannot detect programmatically whether the user has zoomed in or out etc.

I would appreciate if someone could explain the logic which sceneKit is using here and whether I can derive the 3D model (or camera?) position change by any other method?

Peter Mattheisen
  • 117
  • 2
  • 13

1 Answers1

0

The documentation for allowsCameraControl mentions that the out of the box camera control mechanism doesn't modify the scene graph:

If you set this property to true, SceneKit creates a camera node and handles mouse or touch events to allow the user to pan, zoom, and rotate their view of the scene. (Enabling user camera control does not modify camera objects already existing in the scene graph or the nodes containing them.)

mnuages
  • 13,049
  • 2
  • 23
  • 40
  • This parameter is set to true already in my project: scnView?.allowsCameraControl = true Without this setting I would not be able to move and zoom the 3D object. The question is how I can retrieve the changed camera position data after a move or zoom. – Peter Mattheisen Jan 20 '22 at 07:55
  • 1
    After SceneKit creates a new camera on your behalf you should be able to retrieve it through `scnView.pointOfView`. – mnuages Jan 21 '22 at 08:33
  • when the user starts moving the view using allowsCameraControl = true, SceneKit add's an additional, internal Camera Object. When you i.Ex double tap your screen, the camera returns to it's initial camera object and position. – ZAY Jan 21 '22 at 14:21