# JSDoc: Class: Viewport

# Class: Viewport

## Viewport(canvas)

#### new Viewport(canvas)

Used to indicate how the user views the content inside of the canvas.

##### Parameters:

Name | Type | Description
--- | --- | ---
`canvas` | DOM | Canvas DOM element where the viewport is being rendered.

Source:
  - Viewport.js, line 14

### Members

#### canvas

Canvas DOM element where the viewport is being rendered.

Source:
  - Viewport.js, line 24

#### inverseMatrix

Inverse of the local transformation matrix.

Source:
  - Viewport.js, line 49

#### matrix

Local transformation matrix applied to the object.

Source:
  - Viewport.js, line 44

#### matrixNeedsUpdate

If true the matrix is updated before rendering the object.

Source:
  - Viewport.js, line 54

#### moveOnScale

Flag to indicate if the viewport should move when scalling. For some application its easier to focus the target if the viewport moves to the pointer location while scalling.

Source:
  - Viewport.js, line 61

#### position

Position of the object.

Source:
  - Viewport.js, line 29

#### rotation

Rotation of the object relative to its center.

Source:
  - Viewport.js, line 39

#### rotationPoint

Value of the initial point of rotation if the viewport is being rotated. Is set to null when the viewport is not being rotated.

Source:
  - Viewport.js, line 68

#### scale

Scale of the object.

Source:
  - Viewport.js, line 34

#### uuid

UUID of the object.

Source:
  - Viewport.js, line 19

### Methods

#### centerObject(object, canvas)

Center the viewport relative to a object. The position of the object is used a central point, this method does not consider "box" attributes or other strucures in the object.

##### Parameters:

Name | Type | Description
--- | --- | ---
`object` | Object2D | Object to be centered on the viewport.
`canvas` | DOM | Canvas element where the image is drawn.

Source:
  - Viewport.js, line 107

#### updateMatrix()

Calculate and update the viewport transformation matrix. Also updates the inverse matrix of the viewport.

Source:
  - Viewport.js, line 76