Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1354)

Unified Diff: samples/o3d-webgl-samples/pool.html

Issue 2456004: Adding zoom on scrollwheel event to Pool demo. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/o3d/
Patch Set: '' Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | samples/o3d-webgl-samples/texturesamplers.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samples/o3d-webgl-samples/pool.html
===================================================================
--- samples/o3d-webgl-samples/pool.html (revision 49133)
+++ samples/o3d-webgl-samples/pool.html (working copy)
@@ -894,6 +894,8 @@
o3djs.event.addEventListener(g_o3dElement, 'keypress', keyPressed);
o3djs.event.addEventListener(g_o3dElement, 'keyup', keyUp);
o3djs.event.addEventListener(g_o3dElement, 'keydown', keyDown);
+
+ o3djs.event.addEventListener(g_o3dElement, 'wheel', scrollWheel);
}
@@ -1884,6 +1886,22 @@
}
}
+function zoomIn() {
+ g_cameraInfo.targetPosition.radius *= 0.9;
+}
+
+function zoomOut() {
+ g_cameraInfo.targetPosition.radius /= 0.9;
+}
+
+function scrollWheel(event) {
+ if (event.deltaY > 0) {
+ zoomIn();
+ } else {
+ zoomOut();
+ }
+}
+
function keyPressed(event) {
var keyChar = String.fromCharCode(o3djs.event.getEventKeyChar(event));
keyChar = keyChar.toLowerCase();
@@ -1943,12 +1961,12 @@
case '=':
case '+':
- g_cameraInfo.targetPosition.radius *= 0.9;
+ zoomIn();
break;
case '-':
case '_':
- g_cameraInfo.targetPosition.radius /= 0.9;
+ zoomOut();
break;
case ' ':
« no previous file with comments | « no previous file | samples/o3d-webgl-samples/texturesamplers.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698