luma.gl

Camera

LumaGL provides two camera classes - PerspectiveCamera and OrthoCamera. They are used to prepare perspective and orthographic projection matrices when rendering your scene.

Class: PerspectiveCamera

Used to calculate view and perspective projection matrices when rendering your scene.

Properties:

PerspectiveCamera Method: constructor

Syntax:

var camera = new PerspectiveCamera([options]);

Options:

Examples:

Creates a camera with position (0, 0, 10) pointing to a target in (0, 0, 0).

  var canvas = document.getElementById('canvas');
  var camera = new PerspectiveCamera({
        fov: 45,
        aspect: canvas.width / canvas.height,
        near: 0.1,
        far: 100,
        position: new Vec3(0, 0, 10)
      });

PerspectiveCamera Method: update

Updates the PerspectiveCamera view matrix with the information provided on position and target.

Syntax:

camera.update();

Examples:

  var camera = new PerspectiveCamera({
    fov: 45,
    aspect: canvas.width / canvas.height,
    near: 0.1,
    far: 100,
    position: new Vec3(0, 0, 10)
  });

  camera.position = new Vec3(10, 0, 10);
  camera.update(); //update matrices

Class: OrthoCamera

Used to calculate view and orthographic projection matrices when rendering your scene.

Properties:

OrthoCamera Method: constructor

Syntax:

var camera = new OrthoCamera([options]);

Options:

Examples:

Creates a camera with position (0, 0, 10) pointing to a target in (0, 0, 0).

  var canvas = document.getElementById('canvas');
  var camera = new OrthoCamera({
        fov: 45,
        aspect: canvas.width / canvas.height,
        near: 0.1,
        far: 100,
        position: new Vec3(0, 0, 10)
      });

OrthoCamera Method: update

Updates the OrthoCamera view matrix with the information provided on position and target.

Syntax:

camera.update();

Examples:

  var camera = new OrthoCamera({
    fov: 45,
    aspect: canvas.width / canvas.height,
    near: 0.1,
    far: 100,
    position: new Vec3(0, 0, 10)
  });

  camera.position = new Vec3(10, 0, 10);
  camera.update(); //update matrices