diff options
author | simonrad@chromium.org <simonrad@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-03 23:15:18 +0000 |
---|---|---|
committer | simonrad@chromium.org <simonrad@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-03 23:15:18 +0000 |
commit | df2c7403503b45467d3d76ddc2f42296fa53ac50 (patch) | |
tree | a2d84c70b3cd37fb645fb8d5c5bcfab638c9d392 /o3d/samples/manipulators/rotate1.html | |
parent | 89d6e6e3456280a12b4b806de8cbe3d049476df6 (diff) | |
download | chromium_src-df2c7403503b45467d3d76ddc2f42296fa53ac50.zip chromium_src-df2c7403503b45467d3d76ddc2f42296fa53ac50.tar.gz chromium_src-df2c7403503b45467d3d76ddc2f42296fa53ac50.tar.bz2 |
Creates a CameraController class, and makes the Rotate1 manipulator use line geometry.
- Creates a basic CameraController class. It allows the user to rotate the camera around a center position using the mouse, and outputs a view matrix.
- Changes the Rotate1 manipulator to display as line geometry. Adds a line ring primitive and a special shader.
- Merges changes to Rotate1 sample into Translate1+2 samples as well. We probably should refactor the samples so we don't have duplicate code.
R=gman,kbr
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/465023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@33747 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d/samples/manipulators/rotate1.html')
-rw-r--r-- | o3d/samples/manipulators/rotate1.html | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/o3d/samples/manipulators/rotate1.html b/o3d/samples/manipulators/rotate1.html index 49f56f3..0b418db 100644 --- a/o3d/samples/manipulators/rotate1.html +++ b/o3d/samples/manipulators/rotate1.html @@ -52,6 +52,7 @@ o3djs.require('o3djs.rendergraph'); o3djs.require('o3djs.primitives'); o3djs.require('o3djs.manipulators'); o3djs.require('o3djs.effect'); +o3djs.require('o3djs.cameracontroller'); // global variables var g_o3dElement; @@ -62,10 +63,10 @@ var g_mainPack; var g_mainViewInfo; var g_mainRoot; var g_lightPosition = [5, 5, 7]; -var g_eyePosition = [1, 5, 23]; var g_lastCubeTransform; var g_primitives = []; var g_manager; +var g_cameraController; /** * Creates the client area. @@ -110,14 +111,20 @@ function main(clientElements) { } function onMouseDown(e) { - g_manager.mousedown(e.x, e.y, - g_mainViewInfo.drawContext.view, - g_mainViewInfo.drawContext.projection, - g_client.width, - g_client.height); + if(e.button == 2) { + g_cameraController.mousedown(e); + } else { + g_manager.mousedown(e.x, e.y, + g_mainViewInfo.drawContext.view, + g_mainViewInfo.drawContext.projection, + g_client.width, + g_client.height); + } } function onMouseMove(e) { + g_cameraController.mousemove(e); + g_mainViewInfo.drawContext.view = g_cameraController.calculateViewMatrix(); g_manager.mousemove(e.x, e.y, g_mainViewInfo.drawContext.view, g_mainViewInfo.drawContext.projection, @@ -127,8 +134,12 @@ function onMouseMove(e) { } function onMouseUp(e) { - g_manager.mouseup(); - g_manager.updateInactiveManipulators(); + if(e.button == 2) { + g_cameraController.mouseup(e); + } else { + g_manager.mouseup(); + g_manager.updateInactiveManipulators(); + } } /** @@ -164,12 +175,13 @@ function initContext() { 1, // Near plane. 5000); // Far plane. - // Set up our view transformation to look towards the world origin where the - // primitives are located. - g_mainViewInfo.drawContext.view = g_math.matrix4.lookAt( - g_eyePosition, // eye - [0, 2, 0], // target - [0, 1, 0]); // up + // Set up our view transformation using our CameraController. + g_cameraController = o3djs.cameracontroller.createCameraController( + [0, 2, 0], // centerPos + 23, // backpedal + 0, // heightAngle + 0); // rotationAngle + g_mainViewInfo.drawContext.view = g_cameraController.calculateViewMatrix(); } /** |