title: SceneKit - positioning SCNCamera and permitting object rotation
body: <p>I am close to completing my first project in SceneKit but I'm struggling with the last few steps. It is probably easiest to explain my progress by sharing a <a href="https://drive.google.com/open?id=1uJbzM93mEwsAruX62CTbPBZmUyiWwDfI" rel="nofollow noreferrer">short screen capture video</a> of the Xcode Simulator displaying my current scene.</p>
  
  <p>As you can see by the screen capture my project is composed of three elements (this is all done in code, I do not import any external assets):</p>
  
  <ol>
  <li>outside box (defined via six SCNBox objects per corner)</li>
  <li>inside sun (defined via a SCNTube object for the circle and UIBezierPath objects per "ray")</li>
  <li>position of camera</li>
  </ol>
  
  <p>Based on feedback I have <a href="https://github.com/LedenMcLeden/logo" rel="nofollow noreferrer">committed the code to GitHub</a>.</p>
  
  <p>Right now the camera is allowed to rotate as seen in the screen capture but the centre of rotation of the camera and of the objects doesn't align so it appears to spin off-axis.</p>
  
  <p>Here's where I want to get to:</p>
  
  <ol>
  <li>correct camera position so that the combined box &amp; sun is positioned directly in front of the camera, filling the screen</li>
  <li>maintain the sun's position as being fixed (already done I guess)</li>
  <li>allow the box to rotate freely in x, y &amp; z around the sun based on touch input - so the user can "flick" the box and watch it flip and spin around the sun</li>
  </ol>
  
  <p>The code structure is straight forward:</p>
  
  <pre><code>class GameViewController: UIViewController {
  
  var gameView: SCNView!
  var gameScene: SCNScene!
  var cameraNode: SCNNode!
  var targetCreationTime: TimeInterval = 0
  
  override func viewDidLoad() {
      super.viewDidLoad()
      initView()
      initScene()   // createSun() and createCube() called here
      initCamera()
  }
  </code></pre>
  
  <p>And with respect to the camera position:</p>
  
  <pre><code>   func initCamera() {
          let camera = SCNCamera()
          cameraNode = SCNNode()
          cameraNode.camera = camera
          cameraNode.position = SCNVector3(x: 0, y: 0, z: 0)
          cameraNode.rotation = SCNVector4Make(1, 0, 0, .pi/2)
      }
  </code></pre>
  
  <p>But what I've found is that despite playing around with the random cameraNode.position and cameraNode.rotation values the camera view doesn't seem to change.</p>
  
  <p><strong>My questions</strong> - any help will be greatly appreciated:</p>
  
  <ol>
  <li>advice on repositioning the camera (what am I doing wrong?!) - once it's in the right place I can easily set "gameView.allowsCameraControl = false"</li>
  <li>advice on how to enable the box to spin about its axis around the sun (while the sun remains fixed)</li>
  <li>stretch goal! Any kind of general "check out this tutorial" type info on materials and lighting, and embedding this view into a SwiftUI view</li>
  </ol>
  
  <p>Thanks!</p>