LittleJS 1.30.0

Render3D

CameraControl3D

CameraControl3D - Drag to turn the camera around a point, roll the wheel to zoom

  • An EngineObject3D, so move its pos3D to follow something, or parent it to an object
  • A camera of the camera plugin: the newest made drives the view, after the objects move each update
  • Destroy it to hand the camera back, and it stops driving the camera
  • Set persistent to keep it when engineObjectsDestroy clears out a level
  • Every part of it is a field, so a game can change the buttons, speeds and limits

Extends EngineObject3D

Constructor

new CameraControl3D(target, distance, pitch, idleSpin)render3dExtras.js:1231

Create a camera control, it drives render3D.camera every frame

target Vector3 optional

The point to look at, its pos3D

distance number optional, default 10

How far the camera sits from the target

pitch number optional, default 0.4

Angle above the horizon, PI/2 looks straight down, clamped to pitchRange

idleSpin number optional, default 0

Turned each frame while not dragging, 0 holds still

new CameraControl3D(vec3(0, 1, 0), 15); // look at a point from 15 units away

Members

Methods

Inherited from EngineObject3D

Inherited from EngineObject

Members

distance : numberrender3dExtras.js:1243

How far the camera sits from the target

dragButton : numberrender3dExtras.js:1251

Mouse button that turns the camera, 0 is left and 2 is right

dragSpeed : numberrender3dExtras.js:1253

How far dragging a pixel turns the camera

idleSpin : numberrender3dExtras.js:1247

Turned each frame while not dragging

Angle above the horizon

Lowest and highest pitch, so it cannot tip over the top, widened to hold the pitch given

Angle around the target, dragging changes it

Closest and furthest the wheel can zoom to

zoomSpeed : numberrender3dExtras.js:1255

How much one wheel notch zooms, 0 turns zooming off

Methods

Make this the camera that drives the view

Camera controls draw nothing

Taking over from another camera, it keeps its own orbit

Read the mouse and turn the orbit, called automatically each frame

Put the camera on its orbit, called by the camera plugin after the objects update