noa.camera - manages the camera, its position and direction, mouse sensitivity, and so on.

This module uses the following default options (from the options object passed to the Engine):

var defaults = {
inverseX: false,
inverseY: false,
sensitivityX: 10,
sensitivityY: 10,
initialZoom: 0,
zoomSpeed: 0.2,
}

Hierarchy

  • Camera

Properties

cameraTarget: number

Entity ID of a special entity that exists for the camera to point at.

By default this entity follows the player entity, so you can change the player's eye height by changing the follow component's offset:

var followState = noa.ents.getState(noa.camera.cameraTarget, 'followsEntity')
followState.offset[1] = 0.9 * myPlayerHeight

For customized camera controls you can change the follow target to some other entity, or override the behavior entirely:

// make cameraTarget stop following the player
noa.ents.removeComponent(noa.camera.cameraTarget, 'followsEntity')
// control cameraTarget position directly (or whatever..)
noa.ents.setPosition(noa.camera.cameraTarget, [x,y,z])
currentZoom: number

Current actual zoom distance. This differs from zoomDistance when the camera is in the process of moving towards the desired distance, or when it's obstructed by solid terrain behind the player. This value will get overwritten each tick, but you may want to write to it when overriding the camera zoom speed.

heading: number

Camera yaw angle. Returns the camera's rotation angle around the vertical axis. Range: 0..2π
This value is writeable, but it's managed by the engine and will be overwritten each frame.

inverseX: boolean

Mouse look inverse (horizontal)

inverseY: boolean

Mouse look inverse (vertical)

noa: Engine
pitch: number

Camera pitch angle. Returns the camera's up/down rotation angle. The pitch angle is clamped by a small epsilon, such that the camera never quite points perfectly up or down.
Range: -π/2..π/2.
This value is writeable, but it's managed by the engine and will be overwritten each frame.

sensitivityMult: number

Multiplier for temporarily altering mouse sensitivity. Set this to 0 to temporarily disable camera controls.

sensitivityMultOutsidePointerlock: number

Multiplier for altering mouse sensitivity when pointerlock is not active - default of 0 means no camera movement. Note this setting is ignored if pointerLock isn't supported.

sensitivityX: number

Horizontal mouse sensitivity. Same scale as Overwatch (typical values around 5..10)

sensitivityY: number

Vertical mouse sensitivity. Same scale as Overwatch (typical values around 5..10)

zoomDistance: number

How far back the camera should be from the player's eye position

zoomSpeed: number

How quickly the camera moves to its zoomDistance (0..1)

Methods

  • Returns the camera direction vector (read only)

    Returns any

  • Returns the current camera position (read only)

    Returns any

  • Returns the camera's current target position - i.e. the player's eye position. When the camera is zoomed all the way in, this returns the same location as camera.getPosition().

    Returns any

Generated using TypeDoc