module:extras/camera.Camera

Back to documentation index.

### new module:extras/camera.Camera(fov, nearZ, farZ)

A class for controlling the projection and view of a 3D scene, in the nature of an abstract “camera”. This class uses the concept of a “camera’s position”, or where the camera is located in world space, as well as a “reference point”, or the point in world space that the camera is looking at.

This class is considered a supplementary class to the Public Domain HTML 3D Library and is not considered part of that library.

To use this class, you must include the script “extras/camera.js”; the class is not included in the “h3du_min.js” file which makes up the HTML 3D Library. Example:

<script type="text/javascript" src="extras/camera.js"></script>

Parameters

Methods

### module:extras/camera~Camera#getDistance()

Finds the distance from the camera’s position to the reference point.

Return Value

Return value. (Type: number)

### module:extras/camera~Camera#getPosition()

Gets the position of the camera.

Return Value

An array of three numbers giving the X, Y, and Z coordinates of the camera’s position, respectively. (Type: Array.<number>)

### module:extras/camera~Camera#getVectorFromCenter()

Gets the 3-element vector that points from the reference point to the camera’s position.

Return Value

The return value as a unit vector (a “normalized” vector with a length of 1). Returns (0,0,0) if the reference point is the same as the camera’s position. (Type: Array.<number>)

### module:extras/camera~Camera#moveAngleHorizontal(angleDegrees)

Moves the camera to the left or right so that it faces the same reference point at the same distance.

Parameters

Return Value

This object. (Type: Camera)

### module:extras/camera~Camera#moveAngleVertical(angleDegrees)

Moves the camera upward or downward so that it faces the same reference point at the same distance.

Parameters

Return Value

This object. (Type: Camera)

### module:extras/camera~Camera#moveClose(dist)

Moves the camera the given distance, but not too close to the reference point.

Parameters

Return Value

This object. (Type: Camera)

### module:extras/camera~Camera#moveForward(dist)

Moves the camera forward the given distance.

Parameters

Return Value

This object. (Type: Camera)

### module:extras/camera~Camera#moveHorizontal(dist)

Moves the camera horizontally relative to the camera’s up vector.

Parameters

Return Value

This object. (Type: Camera)

### module:extras/camera~Camera#moveVertical(dist)

Moves the camera toward or away from the camera’s up vector.

Parameters

Return Value

This object. (Type: Camera)

### module:extras/camera~Camera#setDistance(dist)

Moves the camera a given distance from the reference point without changing its orientation.

Parameters

Return Value

This object. (Type: Camera)

### module:extras/camera~Camera#setPosition(cx, [cy], [cz])

Sets the position of the camera.

Parameters

Return Value

This object. (Type: Camera)

### module:extras/camera~Camera#turnAngleHorizontal(angleDegrees)

Turns the camera to the left or right so that it faces the same distance from a reference point.

Parameters

Return Value

This object. (Type: Camera)

### module:extras/camera~Camera#turnAngleVertical(angleDegrees)

Turns the camera upward or downward so that it faces the same distance from a reference point.

Parameters

Return Value

This object. (Type: Camera)

### module:extras/camera~Camera#update([input])

Updates information about this camera based on the state of an input tracker.

Parameters

Return Value

Return value. (Type: Object)

Back to documentation index.