Skip to content
cjcliffe edited this page Oct 25, 2011 · 7 revisions

CubicVR.Camera

The Camera class represents a camera, typically used in a Scene. By default Scene includes a camera of Scene.camera.

Camera( obj_init )

Note Camera( width, height, fov, nearclip, farclip ) will be deprecated.

Parameters:

var myCamera = new CubicVR.Camera({
    width: 512,     // Width of the viewport, typically canvas.width.
    height: 512,    // Height of the viewport, typically canvas.height.
    fov: 60.0,      // Field of View, specified in degrees.
    nearclip: 0.1,  // Near clipping plane, pixels closer than this will be discarded.
    farclip: 400,   // Far clipping plane, pixels further than this will be discarded.
    parent: null,   // SceneObject to parent to, all positions become relative to the SceneObject.
    position: [0.0, 0.0, 0.0],  // Starting position of the camera.
    rotation: [0.0, 0.0, 0.0],  // Starting rotation for the camera (un-targeted only).
    target: [0.0, 0.0, 0.0],    // Starting position for the camera target.
    targeted: true              // Whether or not this camera is targeted.
});

You can set most parameters directly on the camera if they do not have an available function yet (position, rotation, etc).

Note the camera can also be specified via CubicVR.get functionality.

Methods:

setTargeted( targeted )

Set the targeting state of the camera.

Parameters:

  • targeted : If true then camera will follow Camera.target point, otherwise camera follows Camera.position and Camera.rotation

Returns:

none

setParent( parent )

Set the parent object of the camera, position and rotation will become relative to the parent. use SceneObject.setParent(null) to remove the parent.

Parameters:

  • parent : A parent object such as a SceneObject that contains a obj.tMatrix transform.

Returns:

none

setClip( nearclip, farclip )

Set the camera clipping planes for near and far.

Parameters:

  • nearclip : Near clipping plane, pixels closer than this will be discarded.
  • farclip : Far clipping plane, pixels further than this will be discarded.

Returns:

none

setFOV( fov )

Set the camera's Field of View.

Parameters:

  • fov : Field of View in Degrees.

Returns:

none

setLENS( lens )

Set the camera Field of View via the Lens focal length.

Parameters:

  • lens : Lens value in focal length.

Returns:

none

lookat( eyeX, eyeY, eyeZ, lookAtX, lookAtY, lookAtZ, upX, upY, upZ )

Emulates gluLookAt() for directly manipulating the camera frustum.

Parameters:

  • eyeX : Eye X coordinate position.
  • eyeY : Eye Y coordinate position.
  • eyeZ : Eye Z coordinate position.
  • lookAtX : Target X coordinate position.
  • lookAtY : Target Y coordinate position.
  • lookAtZ : Target Z coordinate position.
  • upX : Camera up-axis vector, X component.
  • upY : Camera up-axis vector, Y component.
  • upZ : Camera up-axis vector, Z component.

Returns:

none

getRayTo( x, y )

Calculate a ray from the camera viewport X,Y position.

Parameters:

  • x : X position in the viewport
  • y : Y position in the viewport

Returns:

A vector in format [1.0, 0.0, 0.0] representing a ray in the world from the camera near to far plane at the specified X,Y in the volume.

Clone this wiki locally