Shaku

Shaku JS

Back To Table of Content

Camera

Camera

Implements a Camera object.

Kind: global class

new Camera(gfx)

Create the camera.

Param Type Description
gfx Gfx The gfx manager instance.

camera.viewport ⇒ Rectangle

Get camera’s viewport (drawing region to set when using this camera).

Kind: instance property of Camera
Returns: Rectangle - Camera’s viewport as rectangle.

camera.viewport

Set camera’s viewport.

Kind: instance property of Camera

Param Type Description
viewport Rectangle New viewport to set or null to not use any viewport when using this camera.

camera.getRegion() ⇒ Rectangle

Get the region this camera covers.

Kind: instance method of Camera
Returns: Rectangle - region this camera covers.

camera.orthographicOffset(offset, ignoreViewportSize, near, far)

Make this camera an orthographic camera with offset.

Kind: instance method of Camera

Param Type Description
offset Vector2 Camera offset (top-left corner).
ignoreViewportSize Boolean If true, will take the entire canvas size for calculation and ignore the viewport size, if set.
near Number Near clipping plane.
far Number Far clipping plane.

camera.orthographic(region, near, far)

Make this camera an orthographic camera.

Kind: instance method of Camera

Param Type Description
region Rectangle Camera left, top, bottom and right. If not set, will take entire canvas.
near Number Near clipping plane.
far Number Far clipping plane.