Class: Camera

Grape2D. Camera

new Camera(options)

Camera is used to select the objects to display in a scene. A camera doesn't rotate or scale objects in the x and y axis, only the coordinates are changed to the transformation defined.
Parameters:
Name Type Argument Description
options Object <optional>
Setup options.
Properties
Name Type Argument Description
scale Grape2D.Vector <optional>
The scale to be applied. There are two ways to define the scale. This method is one, the other is defined it directly in the transformation. If the two are set, then the two are applied.
lookAt Grape2D.Vector <optional>
Defines the (center) position, to where the camera is looking at.
transformation Grape2D.Matrix <optional>
Transformation matrix to be applied to the object coordinates.
Source:

Members

<private> cM :Grape2D.Matrix

Computed matrix
Type:
Source:

<private> icM :Grape2D.Matrix

Inverse of the computed matrix
Type:
Source:

<private> lookAt :Grape2D.Vector

The position to where the camera is looking at.
Type:
Source:

<private> scale :Grape2D.Vector

Scale set by the user, should be defined in the matrix.
Type:
Source:

<private> transformation :Grape2D.Matrix

The transformation matrix to aply to the object coordinates.
Type:
Source:

Methods

<protected> computeMatrix()

Computes the matrix for better performances.
Source:

computeShape(renderer) → {Grape2D.Shape}

Creates a shape, based on the camera transformation and renderer properties.
Parameters:
Name Type Description
renderer Grape2D.Renderer The renderer.
Source:
Returns:
A bounding volume representing the camera view region.
Type
Grape2D.Shape

getLookAt() → {Grape2D.Vector}

Gets the look at property.
Source:
Returns:
The look at.
Type
Grape2D.Vector

getScale() → {Grape2D.Vector}

Gets the current scale. Scale defined in the transformation is not taken into account.
Source:
Returns:
Scale
Type
Grape2D.Vector

rescale(scale)

Sets a new scale.
Parameters:
Name Type Description
scale Grape2D.Vector The new scale.
Source:

setLookAt(position)

Sets the center position to where the camera is looking at.
Parameters:
Name Type Description
position Grape2D.Vector The new look at.
Source:

viewportToWcs(renderer, vector) → {Grape2D.Vector}

Applies the transformation, on a vector in the Viewport Coordinate System (VCS), to get a vector in the World Coordinate System (WSC).
Parameters:
Name Type Description
renderer Grape2D.Renderer The viewport.
vector Grape2D.Vector Vector in the VCS.
Source:
Returns:
A vector in the WCS
Type
Grape2D.Vector

wcsToViewport(renderer, vector) → {Grape2D.Vector}

Applies the transformation, on a vector in the World Coordinate System (WCS), to get a vector in the Viewport (Renderer) Coordinate System (VSC).
Parameters:
Name Type Description
renderer Grape2D.Renderer The viewport.
vector Grape2D.Vector Vector in the WCS.
Source:
Returns:
A vector in the VCS
Type
Grape2D.Vector