Skip to content
Stian Jensen edited this page Mar 27, 2017 · 8 revisions

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

A node in nin may choose to use the Camera Controller, the easiest way is to subclass NIN.THREENode, and specify a json file in options as follows:

"options": {
  "camera": "res/node.camera.json"
}

Also remember to call super.update(frame) in the node's update loop.

...update(frame) {
    super.update(frame);
...
}

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

{
  "position": [
    {
      "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]
      ]   
    },
    {
      "startFrame": 2000,
      "endFrame": 3000,
      "points": [
        [0, 500, 100],
        [0, 400, 200],
        [0, 400, 500],
        [1000, 100, 1000]
      ]
    }
  ], 
  "lookAt": [
    {
      "startFrame": 0,
      "endFrame": 500,
      "point": [164.98,7.58,-769.71]
    },
    {
      "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, click 'start fly-around mode' on the node you want to fly around in. Now you can fly freely. Fly-around mode is available for all nodes subclassing NIN.THREENode currently.

There are many shortcuts to learn for navigating – all of them are listed below:

Shortcuts in fly around mode

key function
c toggle fly around mode on/off
x reset camera rotation
a/w/s/d camera horizontal position
arrows camera pitch/yaw
q/e camera roll
r/f camera vertical position
Z/z camera zoom in/out
mouse click on demo lookat click target
Clone this wiki locally