-
Notifications
You must be signed in to change notification settings - Fork 103
MouseViewController
cjcliffe edited this page Oct 15, 2011
·
4 revisions
The MouseViewController creates a simple orbital view controller for a canvas and a Camera.
Parameters:
-
canvas
: A canvas element. -
camera
: A Camera.
Set the camera to be controlled.
Parameters:
-
camera
: A Camera.
Returns:
none
Get the mouse's relative position on the canvas.
Returns:
Mouse position, [offsetLeft, offsetTop]
.
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);