Skip to content

MouseViewController

cjcliffe edited this page Oct 15, 2011 · 4 revisions

CubicVR.MouseViewController

The MouseViewController creates a simple orbital view controller for a canvas and a Camera.

Constructor:

MouseViewController( canvas, camera )

Parameters:

  • canvas : A canvas element.
  • camera : A Camera.

Methods:

setCamera( camera )

Set the camera to be controlled.

Parameters:

Returns:

none

getMousePosition()

Get the mouse's relative position on the canvas.

Returns:

Mouse position, [offsetLeft, offsetTop].

Example usage:

From samples/cube_viewcontrol.html:

// ...

// New scene with our canvas dimensions and default camera with FOV 80
var scene = new CubicVR.Scene(canvas.width, canvas.height, 80);

// set initial camera position and target
scene.camera.position = [1, 1, 1];
scene.camera.target = [0, 0, 0];

// Start our main drawing loop, it provides a timer and the gl context as parameters
CubicVR.MainLoop(function(timer, gl) {
   scene.render();
});

// initialize a mouse view controller
var mvc = new CubicVR.MouseViewController(canvas, scene.camera);
Clone this wiki locally