Class

Camera

Camera(typeopt)

A camera

Constructor

new Camera(typeopt)

Constructor
Parameters:
Name Type Attributes Description
type Camera.Type <optional>
Type of camera

View Source Camera.js, line 14

Members

Object

static Type

Types

View Source Camera.js, line 396

Methods

getPosition() → (non-null) {Array.<number>}

Get camera's position

View Source Camera.js, line 309

A vector with three values: x, y and z
Array.<number>

getProjectionMatrix() → (non-null) {glMatrix.mat4}

Get camera's projection matrix

View Source Camera.js, line 318

A matrix
glMatrix.mat4

getViewMatrix() → (non-null) {glMatrix.mat4}

Get camera's matrix

View Source Camera.js, line 327

A matrix
glMatrix.mat4

getViewport() → (non-null) {glMatrix.vec3}

Get camera's viewport

View Source Camera.js, line 342

A vector with four values: x, y, w and h
glMatrix.vec3

getViewProjectionMatrix() → (non-null) {glMatrix.mat4}

Get camera's matrix

View Source Camera.js, line 351

A matrix
glMatrix.mat4

lookAt(x, y, z) → {Camera}

Set camera's direction: Point to look at
Parameters:
Name Type Description
x number Direction on X
y number Direction on Y
z number Direction on Z

View Source Camera.js, line 146

A reference to the instance
Camera

move(x, y, z) → {Camera}

Set camera's position
Parameters:
Name Type Description
x number Position on X
y number Position on Y
z number Position on Z

View Source Camera.js, line 161

A reference to the instance
Camera

rotate(yaw, pitch) → {Camera}

Set camera's rotation
Parameters:
Name Type Description
yaw number A floating value
pitch number A floating value

View Source Camera.js, line 175

A reference to the instance
Camera

screenToWorldPoint(position) → (non-null) {glMatrix.vec3}

Convert a point in 2D space to the 3D space Z value must have one of this two values: - 0 for near plane - 1 for far plane
Parameters:
Name Type Description
position Array.<number> Position in 2D space/a vec3

View Source Camera.js, line 370

An array with position in 3D
glMatrix.vec3

setFieldOfView(value) → {Camera}

Set field of view
Parameters:
Name Type Description
value number Value in degrees (default: 45)

View Source Camera.js, line 213

A reference to the instance
Camera

setRatio(ratio) → {Camera}

Set screen's ratio
Parameters:
Name Type Description
ratio number Ratio to assign (4/3, 16/9, …)

View Source Camera.js, line 226

A reference to the instance
Camera

setType(type) → {Camera}

Set camera's distances
Parameters:
Name Type Description
type Camera.Type Type asked, for 2D you should use "Orthographic"

View Source Camera.js, line 239

A reference to the instance
Camera

setViewDistances(min, max) → {Camera}

Set camera's distances
Parameters:
Name Type Description
min number Minimum distance to show
max number Maximum distance to show

View Source Camera.js, line 268

A reference to the instance
Camera

setViewport(x, y, w, h) → {Camera}

Set camera's viewport
Parameters:
Name Type Description
x number View start position on X
y number View start position on Y
w number View size on X
h number View size on Y

View Source Camera.js, line 284

A reference to the instance
Camera

worldToScreenPoint(position) → (non-null) {glMatrix.vec2}

Convert a point in 3D space to the 2D space
Parameters:
Name Type Description
position Array.<number> Position in 3D space/a vec3

View Source Camera.js, line 383

An array with position in 2D
glMatrix.vec2

zoom(zoomValue) → {Camera}

Zoom
Parameters:
Name Type Description
zoomValue number Zoom scale to apply

View Source Camera.js, line 297

A reference to the instance
Camera