H3DU.Camera

Back to documentation index.

### H3DU.Camera(batch, fov, nearZ, farZ, [canvas])

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

### H3DU.Camera#getDistance()

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

Return Value

Return value. (Type: number)

### H3DU.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>)

### H3DU.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>)

### H3DU.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: H3DU.Camera)

### H3DU.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: H3DU.Camera)

### H3DU.Camera#moveClose(dist)

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

Parameters

Return Value

This object. (Type: H3DU.Camera)

### H3DU.Camera#moveForward(dist)

Moves the camera forward the given distance.

Parameters

Return Value

This object. (Type: H3DU.Camera)

### H3DU.Camera#moveHorizontal(dist)

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

Parameters

Return Value

This object. (Type: H3DU.Camera)

### H3DU.Camera#moveVertical(dist)

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

Parameters

Return Value

This object. (Type: H3DU.Camera)

### H3DU.Camera#setDistance(dist)

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

Parameters

Return Value

This object. (Type: H3DU.Camera)

### H3DU.Camera#setPosition(cx, [cy], [cz])

Sets the position of the camera.

Parameters

Return Value

This object. (Type: H3DU.Camera)

### H3DU.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: H3DU.Camera)

### H3DU.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: H3DU.Camera)

### H3DU.Camera#turnHorizontal(angleDegrees)

Deprecated: Renamed to “moveAngleHorizontal”.

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: H3DU.Camera)

### H3DU.Camera#turnVertical(angleDegrees)

Deprecated: Renamed to “moveAngleVertical”.

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

Parameters

Return Value

This object. (Type: H3DU.Camera)

### H3DU.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.