library logo

Camera

Class: Camera

Provides the Camera object with information about the camera position, target position and projection matrix information.

Properties:

You can access most of the constructor properties from a camera instance:

Camera Method: constructor

The Camera object, used as eye to project the scene into.

Syntax:

var camera = new PhiloGL.Camera(fov, aspect, near, far [, options]);

Arguments:

  1. fov - (number) The angle (in degrees) for the field of view.
  2. aspect - (number) The aspect ratio of the screen.
  3. near - (number) The closest distance that can be captured by the camera.
  4. far - (number) The longest distance that can be captured by the camera.
  5. options - (object, optional) An object containing the following 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 PhiloGL.Camera(45, canvas.width / canvas.height, 0.1, 100, {
        position: {
          x: 0, y: 0, z: 10
        }                             
      });

Camera Method: update

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

Syntax:

camera.update();

Examples:

  var camera = new PhiloGL.Camera(45, canvas.width / canvas.height, 0.1, 100, {
    position: {
      x: 0, y: 0, z: 10
    }                             
  });

  camera.position = {
    x: 10,
    y: 0,
    z: 10
  };
  camera.update(); //update matrices