Understanding and subclassing SCNCameraController

Understanding SCNCameraController

TLDR; I'm able to create my own subclassed camera controller, but it only works for rotation, not translation. I made a demo repo here.

Background

I want to use SceneKit's camera controller to drive my scene's camera. The reason I want to subclass it is that my camera is on a rig where I apply rotation to the rig and translation to the camera. I do that because I animate the camera, and applying both translation and rotation to the camera node doesn't create the animation I want.

Setting up

  1. Instantiate my own SCNCameraController
  2. Set its pointofView to my scene's pointOfView (or its parent node I guess)

Using the camera controller

We now want the new camera controller to drive the scene.

  1. When interactions begin (e.g. mouseDown), call beginInteraction(_ location: CGPoint, withViewport viewport: CGSize)
  2. When interactions update and end call the corresponding functions on the camera controller

Actual behavior

It works when I begin/update/end interactions from mouse down events. It ignores any other event types, like magnification, scrollwheel, which work in e.g. the SceneKit Editor in Xcode. See MySCNView.swift in the repo for a demo. By overriding the camera controller's rotate function, I can see that it is called with deltas. This is great.
But when I override translateInCameraSpaceBy my print statements don't appear and the scene doesn't translate.

Expected behavior

I expected SCNCameraController to also apply translations and rolls to the pointOfView by inspecting the currentEvent and figuring out what to do.

I'm inclined to think that I'm supposed to call translateInCameraSpaceBy myself, but that seems inconsistent with how Begin/Continue/End interaction seems to call rotate.

Demo repo: https://github.com/mortenjust/Camera-Control-Demo

Replies

Let me check and apply your settings.