LittleJS 1.30.0

Render3D

Camera3D

Camera3D - Position, rotation and lens for the 3D view

  • Looks down its -Z axis, rotation is vec3(pitch, yaw, roll)

Constructor

new Camera3D()render3d.js:1698

Create a camera, looking down -Z from z=10 by default

Members

Methods

Members

align2D : booleanrender3d.js:1717

Line the 3D camera up with the 2D camera, so 3D things at z=0 sit on the 2D sprites; it lines up with the 2D view of the main canvas, whatever canvas size a screenToRay is given

align2DZ : numberrender3d.js:1720

The z of the plane align2D lines up with the 2D view, the camera sitting its distance in front of it

far : numberrender3d.js:1712

Far clip distance, Infinity is allowed for a perspective view

fov : numberrender3d.js:1708

Vertical field of view in radians

near : numberrender3d.js:1710

Near clip distance

orthographic : numberrender3d.js:1714

Visible height in world units for an orthographic view, 0 is perspective

World position

Euler rotation, vec3(pitch, yaw, roll) in radians

Methods

follow(target, offset, percent)render3d.js:1776

Chase a target from an offset, easing toward it, and look at it

target Vector3
offset Vector3

Where to sit relative to the target

percent number optional, default 1

How far to move toward the spot each call, 1 snaps

getForward() → Vector3render3d.js:1745

Returns the direction the camera looks

getMatrix() → Matrix4render3d.js:1725

Returns the camera's world transform

getProjectionMatrix(aspect) → Matrix4render3d.js:1734

Returns the projection matrix

aspect number

Width over height

Returns the camera's right axis

Returns the camera's up axis

getViewMatrix() → Matrix4render3d.js:1729

Returns the view matrix, world to camera space

lookAt(target)render3d.js:1757

Point the camera at a target, sets pitch and yaw and clears roll

target Vector3
orbit(target, distance, yaw, pitch)render3d.js:1764

Put the camera on an orbit around a target, looking at it

target Vector3
distance number
yaw number

Radians around Y

pitch number optional, default 0.5

Radians above the horizon

update2D(canvasHeight)render3d.js:1784

Line the 3D camera up with the 2D camera, called automatically when align2D is set

canvasHeight number optional

Defaults to the main canvas height