The Camera class contains properties and methods to interact with the positioning and orientation of cameras. It does not allow control over other properties of the engine camera (such as clipping planes).

Camera Methods

Camera (Constructor)

  • Overview:
    • Instantiates a Camera object
  • Syntax:
    • new Camera();
    • new Camera( position );
    • new Camera( position, orientation );
    • new Camera( position, orientation, up );
  • Parameters:
    • position: A vector specifying the position (in world-space coordinates) of the camera. If unspecified, defaults to the initial position of the main camera.
    • orientation: A vector aligned parallel to the direction the camera faces. If unspecified, defaults to the initial orientation of the main camera.
    • up: A vector aligned parallel to the direction considered 'upwards' by the camera. If unspecified, defaults to vertically upwards.
  • Returns:

A new Camera object with the given configuration.

  • Notes:

The main camera is initially positioned near the map origin, with zero tilt and oriented to give a 30 degree 'isometric' view.

getFocus

  • Overview:
    • Determines the position on the map the camera is focused at.
  • Syntax:
    • getFocus();
  • Parameters:
  • None.
  • Returns:
    • A Vector object representing the point of intersection of a ray projected from the camera along its forward-axis with the terrain.
  • Notes:
  • If the camera ray does not intersect with the terrain, this function returns the point of intersection of the ray with a virtual terrain plane of average elevation that extends infinitely in all directions.

lookAt

  • Overview:
    • Sets the configuration of this camera such that it is located at a given position and looks towards a given point.
  • Syntax:
    • lookAt( position, focusPoint );
    • lookAt( position, focusPoint, up );
  • Parameters:
    • position: The desired position of the camera.
    • focusPoint: The point that the camera should be oriented to point towards.
    • up: A vector aligned parallel to the direction to be considered 'upwards' by the camera. If unspecified, defaults to vertically upwards.
  • Returns:
    • True if the camera settings were changed sucessfully, otherwise false if there was some error in the parameters.
  • Notes:
    • The position and focus of the camera should not be the same point. (If they are, the results are undefined.)

Camera Properties

position

  • Overview:
    • Gets or sets the position in world-space of this camera.
  • Type:
    • Vector3D

orientation

  • Overview:
    • Gets or sets the vector that points in front of the camera. This vector must not be the zero vector.
  • Type:
    • Vector3D

up

  • Overview:
    • Gets or sets the vector that points in upwards from the camera. This vector must not be the zero vector.
  • Type:
    • Vector3D

Camera Global Objects

camera

  • Overview:
    • Gets or sets a JavaScript object representing the current camera position and orientation.
  • Type:
    • Camera

Camera Global Functions

setCameraTarget

  • Overview:
    • Focus the game camera on a given position.
  • Syntax:
    • setCameraTarget (Vector3D);
    • Example: setCameraTarget(selection[0].position); Focus the camera on the first unit in the selection.
  • Parameters:
    • target position vector [CVector3D]
  • Returns:
    • success [bool]
  • Notes:
Last modified 16 years ago Last modified on Feb 23, 2008, 4:19:01 AM
Note: See TracWiki for help on using the wiki.