-
Notifications
You must be signed in to change notification settings - Fork 0
Camera
The Camera class represents a camera, typically used in a Scene. By default Scene includes a camera of Scene.camera
.
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.
Set the targeting state of the camera.
Parameters:
-
targeted
: If true then camera will followCamera.target
point, otherwise camera followsCamera.position
andCamera.rotation
Returns:
none
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 aobj.tMatrix
transform.
Returns:
none
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
Set the camera's Field of View.
Parameters:
-
fov
: Field of View in Degrees.
Returns:
none
Set the camera Field of View via the Lens focal length.
Parameters:
-
lens
: Lens value in focal length.
Returns:
none
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
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.