Constructor
new Camera3D()
Create a camera, looking down -Z from z=10 by default
- Source
Members
align2D
Properties| Type | Description |
|---|---|
| boolean | Line the 3D camera up with the 2D camera, so 3D things at z=0 sit on the 2D sprites |
- Source
far
Properties| Type | Description |
|---|---|
| number | Far clip distance, Infinity is allowed for a perspective view |
- Source
fov
Properties| Type | Description |
|---|---|
| number | Vertical field of view in radians |
- Source
near
Properties| Type | Description |
|---|---|
| number | Near clip distance |
- Source
orthographic
Properties| Type | Description |
|---|---|
| number | Visible height in world units for an orthographic view, 0 is perspective |
- Source
pos
Properties| Type | Description |
|---|---|
| Vector3 | World position |
- Source
rotation
Properties| Type | Description |
|---|---|
| Vector3 | Euler rotation, vec3(pitch, yaw, roll) in radians |
- Source
Methods
follow(target, offset, percentopt)
Chase a target from an offset, easing toward it, and look at it
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
target | Vector3 | |||
offset | Vector3 | Where to sit relative to the target | ||
percent | number | <optional> | 1 | How far to move toward the spot each call, 1 snaps |
- Source
forward() → {Vector3}
Returns the direction the camera looks
- Source
- Type:
- Vector3
getMatrix() → {Matrix4}
Returns the camera's world transform
- Source
- Type:
- Matrix4
getProjectionMatrix(aspect) → {Matrix4}
Returns the projection matrix
| Name | Type | Description |
|---|---|---|
aspect | number | Width over height |
- Source
- Type:
- Matrix4
getViewMatrix() → {Matrix4}
Returns the view matrix, world to camera space
- Source
- Type:
- Matrix4
lookAt(target)
Point the camera at a target, sets pitch and yaw and clears roll
| Name | Type | Description |
|---|---|---|
target | Vector3 |
- Source
orbit(target, distance, yaw, pitchopt)
Put the camera on an orbit around a target, looking at it
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
target | Vector3 | |||
distance | number | |||
yaw | number | Radians around Y | ||
pitch | number | <optional> | 0.5 | Radians above the horizon |
- Source
right() → {Vector3}
Returns the camera's right axis
- Source
- Type:
- Vector3
up() → {Vector3}
Returns the camera's up axis
- Source
- Type:
- Vector3
update2D(canvasHeightopt)
Line the 3D camera up with the 2D camera, called automatically when align2D is set
| Name | Type | Attributes | Description |
|---|---|---|---|
canvasHeight | number | <optional> | Defaults to the main canvas height |
- Source