Skip to content
Stian Jensen edited this page Jul 10, 2014 · 8 revisions

The camera controller in nin lets you describe camera movements declaratively, in everyone's favorite notation – JSON.

A layer in nin may choose to use the Camera Controller, by instantiating the CameraController with its position:

this.cameraController = new CameraController(layer.position);
this.camera = this.cameraController.camera;

Also remember to call the updateCamera method of the cameraController, in the layers update loop.

...update(frame, relativeFrame) {
    this.cameraController.updateCamera(relativeFrame);
...
}

Now in res/camerapaths.json, define your camera path. An example looks like this:

[                                                                                                        
  {
    "position": [
      {   
        "type": "spline",
        "startFrame": 0,
        "endFrame": 500,
        "points": [
          [-989.31,4985.34,1790.19],
          [-1482.62,2452,2973.01],
          [-546.02,521.76,970.01],
          [-27.2,112.65,-291.66]
        ]   
      },  
      {   
        "type": "spline",
        "startFrame": 2000,
        "endFrame": 3000,
        "points": [
          [0, 500, 100],
          [0, 400, 200],
          [0, 400, 500],
          [1000, 100, 1000]
        ]   
      }   
    ],  
    "lookAt": [
      {   
        "type": "point",
        "startFrame": 0,
        "endFrame": 500,
        "point": [164.98,7.58,-769.71]
      },  
      {   
        "type": "spline",
        "startFrame": 1000,
        "endFrame": 2000,
        "points": [
          [3742.5, 4.41, 1368.1],
          [901.38,6.05,133.29],
          [827.42,24.83,2788.35]
        ]   
      }   
    ]  
  }
]

Fly around mode

Now, this is maybe the most exciting feature of the camera controller! It lets you fly – can you believe it?

To use it, select the layer you want to fly around in, and press 'c' on your keyboard. Now you can fly freely.

There are many shortcuts to learn for navigating, and some more for dumping the data you obtain. When you have found the position you want to store, you can press 'p' to print and select the current position. Simply copy this, and paste it where you want it inside your camerapaths.json.

Shortcuts in fly around mode

Clone this wiki locally