Shaku

Shaku JS

Back To Table of Content

Camera3D

Camera3D

Implements a 3d Camera object.

Kind: global class

new Camera3D(gfx)

Create the camera.

Param Type Description
gfx Gfx The gfx manager instance.

camera3D.projection

Camera projection matrix. You can set it manually, or use ‘orthographicOffset’ / ‘orthographic’ / ‘perspective’ helper functions.

Kind: instance property of Camera3D

camera3D.view

Camera view matrix. You can set it manually, or use ‘setViewLookat’ helper function.

Kind: instance property of Camera3D

camera3D.calcVisibleFrustum() ⇒ Frustum

Calc and return the currently-visible view frustum, based on active camera.

Kind: instance method of Camera3D
Returns: Frustum - Visible frustum.

camera3D.setViewLookat([eyePosition], [lookAt])

Set camera view matrix from source position and lookat.

Kind: instance method of Camera3D

Param Type Description
[eyePosition] Vector3 Camera source position.
[lookAt] Vector3 Camera look-at target.

camera3D.getDirection() ⇒ Vector3

Get 3d direction vector of this camera.

Kind: instance method of Camera3D
Returns: Vector3 - 3D direction vector.

camera3D.getViewProjection() ⇒ Matrix

Get view projection matrix.

Kind: instance method of Camera3D
Returns: Matrix - View-projection matrix.

camera3D.getProjectionView() ⇒ Matrix

Get projection view matrix.

Kind: instance method of Camera3D
Returns: Matrix - Projection-view matrix.

camera3D.perspective(fieldOfView, aspectRatio, near, far)

Make this camera a perspective camera.

Kind: instance method of Camera3D

Param Type Description
fieldOfView \* Field of view angle in radians.
aspectRatio \* Aspect ratio.
near \* Near clipping plane.
far \* Far clipping plane.

camera3D.unproject(point, zDistance) ⇒ Vector3

Unproject a 2d vector into 3D space. You can use this method to get the 3D direction the user points on with the mouse.

Kind: instance method of Camera3D
Returns: Vector3 - Unprojected point in 3D space.

Param Type Default Description
point Vector2   Vector to unproject.
zDistance Number 0 Distance from camera to locate the 3D point at (0 = near plane, 1 = far plane).