Constructor
new Camera(typeopt)
Constructor
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
type |
Camera.Type |
<optional> |
Type of camera |
Members
Methods
getPosition() → (non-null) {Array.<number>}
Get camera's position
A vector with three values: x, y and z
Array.<number>
getProjectionMatrix() → (non-null) {glMatrix.mat4}
Get camera's projection matrix
A matrix
glMatrix.mat4
getViewMatrix() → (non-null) {glMatrix.mat4}
Get camera's matrix
A matrix
glMatrix.mat4
getViewport() → (non-null) {glMatrix.vec3}
Get camera's viewport
A vector with four values: x, y, w and h
glMatrix.vec3
getViewProjectionMatrix() → (non-null) {glMatrix.mat4}
Get camera's matrix
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 |
A reference to the instance
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 |
A reference to the instance
rotate(yaw, pitch) → {Camera}
Set camera's rotation
Parameters:
Name | Type | Description |
---|---|---|
yaw |
number | A floating value |
pitch |
number | A floating value |
A reference to the instance
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 |
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) |
A reference to the instance
setRatio(ratio) → {Camera}
Set screen's ratio
Parameters:
Name | Type | Description |
---|---|---|
ratio |
number | Ratio to assign (4/3, 16/9, …) |
A reference to the instance
setType(type) → {Camera}
Set camera's distances
Parameters:
Name | Type | Description |
---|---|---|
type |
Camera.Type | Type asked, for 2D you should use "Orthographic" |
A reference to the instance
setViewDistances(min, max) → {Camera}
Set camera's distances
Parameters:
Name | Type | Description |
---|---|---|
min |
number | Minimum distance to show |
max |
number | Maximum distance to show |
A reference to the instance
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 |
A reference to the instance
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 |
An array with position in 2D
glMatrix.vec2
zoom(zoomValue) → {Camera}
Zoom
Parameters:
Name | Type | Description |
---|---|---|
zoomValue |
number | Zoom scale to apply |
A reference to the instance