API Documentation

for 0.0.1
Show:

Camera Class

Camera class. Must be created by the user so that the current scene can be seen. If no camera is added to the scene, rendering is not done (nothing is seen, so nothing is rendered).

A Camera contains a transform object to be moved and rotated in space. Viewport can be defined by the user to create multicam rendering.

Constructor

Camera

(
  • params
)

Parameters:

  • params Object

    an object containing all the possible parameters for this class. Use it like in the following example. Possible parameters are lisited below.

    • [context] Context optional

      mobilizing context to use

    • [type="perspective"] String optional

      One of "perspective", "ortho" or "cube"

    • [fov] Number optional

      vertical field of view

    • [cubeResolution=1024] Number optional

      if the type is "cube", defines the size of the cubemap, must be a power of 2

    • [near=1] Number optional

      near plane

    • [far=5000] Number optional

      far plane

    • [viewport=Rect(0,0,1,1)] Rect optional

      the Rect defining the viewport in normalize % (0 ~ 1), that is the portion of the rendering canvas to be used as a rendering surface for this camera

    • [layer] Context optional

      the layer in which to render the camera, that is the scene it is

    • [position] Vector3 optional

      the position where to create the camera in space

    • [verticalshift=0] Number optional

      vertical lens shift in %

    • [horizontalshift=0] Number optional

      horizontal lens shift in %

    • [autorender=true] Boolean optional

      Should the camera automatically renders itself or not

    • [autoClear=true] Boolean optional

      Should the camera automatically clears itself or not

    • [autoupdatematrix=true] Boolean optional

      Should the camera transformation matrix automatically updates itself or not

Example:

//this is how to use a parameters object in order to instanciate a Mobilizing.js object
var mobilizingObject = new Mobilizing.Class({paramName1: value, paramName2: value});

Methods

getAspect

() Number

gets the aspect ratio of the camera view

Returns:

Number:

cam aspect value

getClearColor

() Color

Gets the clear color, which is the color used to paint the backgroud. Note: this is camera independant, each cam on the scene can have a different clear color, or a different background color.

Returns:

Color:

Color object associated to this clearColor

getFarPlane

() Number

Gets cam far plane

Returns:

Number:

far plane value

getFOV returns the value

() Number

get the vertical field of view in degrees

Returns:

Number:

Field Of View value

getNearPlane

() Number

Gets cam near plane

Returns:

Number:

far plane value

getZoom

() Number

Gets current zoom value.

Returns:

Number:

zoom value

lookAt

(
  • Vector3
)

Makes the cam "looks at" the argements coordinates. Handy way to orient the cam or to make it follow an object in space.

Parameters:

  • Vector3 Object

    the coordinates to look at.

setAspect

(
  • the
)

Sets the aspect ratio of the camera view

Parameters:

  • the Number

    ratio (ex. 4/3)

setAutoClear

(
  • val
)

Change the autoClear property of this camera. Needed to had a "trail effect"

Parameters:

  • val Boolean

setAutoClearColor

(
  • val
)

Change the autoClearColor property of this camera. Needed to had a "trail effect"

Parameters:

  • val Boolean

setAutoClearDepth

(
  • val
)

Change the setAutoClearDepth property of this camera.

Parameters:

  • val Boolean

setAutoClearStencil

(
  • val
)

Change the setAutoClearStencil property of this camera.

Parameters:

  • val Boolean

setAutorender

(
  • b
)

Set the autorender flag, which means that the camera will render itself automatically.

Parameters:

  • b Bool

    flag true/false

setClearColor

(
  • Color
  • Alpha
)

Set the clear color, which is the color used to paint the backgroud. Note: this is camera independant, each cam on the scene can have a different clear color, or a different background color.

Parameters:

  • Color Color

    Mobilizing.Color object

  • Alpha Number

    A number >= 0 && <= 1

setFarPlane

(
  • far
)

Sets cam far plane

Parameters:

  • far Number

    plane value

setFOV

(
  • fov
)

set the vertical field of view in degrees

Parameters:

  • fov Number

    default to 35 degree

setNearPlane

(
  • near
)

Sets cam near plane

Parameters:

  • near Number

    plane value

setOrthoPlanes

(
  • left
  • right
  • top
  • bottom
)

Method to recompute the frame of ortho cam. Is used internally for window resizing.

Parameters:

  • left Number
  • right Number
  • top Number
  • bottom Number

setPlanes

(
  • near
  • far
)

Sets cam far and near planes

Parameters:

  • near Number

    near plane value

  • far Number

    far plane value

setRenderTexture

(
  • renderTexture
)

Set the RenderTexture to render on. By default, the camera renders on the Context canvas.

Parameters:

setToPixel

()

Tries to adjust the cam z distance so that 1 world unit == 1 screen pixel. Useful to make object move at the mouse or touch position x and y. For perspective cam only.

setVerticalShift

(
  • the
)

Sets the horizontal shift ratio of the camera view

Parameters:

  • the Number

    ratio (1 -> 100%)

setVerticalShift

(
  • the
)

Sets the vertical shift ratio of the camera view

Parameters:

  • the Number

    ratio (1 -> 100%)

setZoom

(
  • zoom
)

Zoom is for ortho cam and mimics the Z translation of perspective cams. This is expressed like a scale, zoom = 2 will double, .5 make it half.

Parameters:

  • zoom Number

    value

Properties

dirty

Boolean flag to know if something has changed

Default: true