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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | samples/o3d-webgl-samples/texturesamplers.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!-- 1 <!--
2 Copyright 2009, Google Inc. 2 Copyright 2009, Google Inc.
3 All rights reserved. 3 All rights reserved.
4 4
5 Redistribution and use in source and binary forms, with or without 5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are 6 modification, are permitted provided that the following conditions are
7 met: 7 met:
8 8
9 * Redistributions of source code must retain the above copyright 9 * Redistributions of source code must retain the above copyright
10 notice, this list of conditions and the following disclaimer. 10 notice, this list of conditions and the following disclaimer.
(...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after
887 * Registers event handlers. 887 * Registers event handlers.
888 */ 888 */
889 function registerEventCallbacks() { 889 function registerEventCallbacks() {
890 o3djs.event.addEventListener(g_o3dElement, 'mousedown', startDragging); 890 o3djs.event.addEventListener(g_o3dElement, 'mousedown', startDragging);
891 o3djs.event.addEventListener(g_o3dElement, 'mousemove', drag); 891 o3djs.event.addEventListener(g_o3dElement, 'mousemove', drag);
892 o3djs.event.addEventListener(g_o3dElement, 'mouseup', stopDragging); 892 o3djs.event.addEventListener(g_o3dElement, 'mouseup', stopDragging);
893 893
894 o3djs.event.addEventListener(g_o3dElement, 'keypress', keyPressed); 894 o3djs.event.addEventListener(g_o3dElement, 'keypress', keyPressed);
895 o3djs.event.addEventListener(g_o3dElement, 'keyup', keyUp); 895 o3djs.event.addEventListener(g_o3dElement, 'keyup', keyUp);
896 o3djs.event.addEventListener(g_o3dElement, 'keydown', keyDown); 896 o3djs.event.addEventListener(g_o3dElement, 'keydown', keyDown);
897
898 o3djs.event.addEventListener(g_o3dElement, 'wheel', scrollWheel);
897 } 899 }
898 900
899 901
900 /** 902 /**
901 * Creates the client area. 903 * Creates the client area.
902 */ 904 */
903 function initClient() { 905 function initClient() {
904 o3djs.webgl.makeClients(main); 906 o3djs.webgl.makeClients(main);
905 } 907 }
906 908
(...skipping 970 matching lines...) Expand 10 before | Expand all | Expand 10 after
1877 finishShooting(); 1879 finishShooting();
1878 break; 1880 break;
1879 } 1881 }
1880 } 1882 }
1881 1883
1882 function keyDown(event) { 1884 function keyDown(event) {
1883 switch (event.keyCode) { 1885 switch (event.keyCode) {
1884 } 1886 }
1885 } 1887 }
1886 1888
1889 function zoomIn() {
1890 g_cameraInfo.targetPosition.radius *= 0.9;
1891 }
1892
1893 function zoomOut() {
1894 g_cameraInfo.targetPosition.radius /= 0.9;
1895 }
1896
1897 function scrollWheel(event) {
1898 if (event.deltaY > 0) {
1899 zoomIn();
1900 } else {
1901 zoomOut();
1902 }
1903 }
1904
1887 function keyPressed(event) { 1905 function keyPressed(event) {
1888 var keyChar = String.fromCharCode(o3djs.event.getEventKeyChar(event)); 1906 var keyChar = String.fromCharCode(o3djs.event.getEventKeyChar(event));
1889 keyChar = keyChar.toLowerCase(); 1907 keyChar = keyChar.toLowerCase();
1890 var identifier = o3djs.event.getKeyIdentifier(event.charCode, event.keyCode); 1908 var identifier = o3djs.event.getKeyIdentifier(event.charCode, event.keyCode);
1891 1909
1892 var spotDelta = 1; 1910 var spotDelta = 1;
1893 var cueBall = g_physics.balls[0]; 1911 var cueBall = g_physics.balls[0];
1894 var x = cueBall.center[0]; 1912 var x = cueBall.center[0];
1895 var y = cueBall.center[1]; 1913 var y = cueBall.center[1];
1896 1914
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1936 if (!g_rolling) 1954 if (!g_rolling)
1937 g_barRoot.visible = true; 1955 g_barRoot.visible = true;
1938 break; 1956 break;
1939 1957
1940 case 't': 1958 case 't':
1941 g_cameraInfo.goTo([0, 0, 0], null, null, 100); 1959 g_cameraInfo.goTo([0, 0, 0], null, null, 100);
1942 break; 1960 break;
1943 1961
1944 case '=': 1962 case '=':
1945 case '+': 1963 case '+':
1946 g_cameraInfo.targetPosition.radius *= 0.9; 1964 zoomIn();
1947 break; 1965 break;
1948 1966
1949 case '-': 1967 case '-':
1950 case '_': 1968 case '_':
1951 g_cameraInfo.targetPosition.radius /= 0.9; 1969 zoomOut();
1952 break; 1970 break;
1953 1971
1954 case ' ': 1972 case ' ':
1955 if (!g_cameraInfo.lookingAt(g_physics.balls[0].center)) { 1973 if (!g_cameraInfo.lookingAt(g_physics.balls[0].center)) {
1956 g_cameraInfo.zoomToPoint(g_physics.balls[0].center); 1974 g_cameraInfo.zoomToPoint(g_physics.balls[0].center);
1957 if (!g_rolling) 1975 if (!g_rolling)
1958 g_barRoot.visible = true; 1976 g_barRoot.visible = true;
1959 } else { 1977 } else {
1960 if (g_seriousness > 1) { 1978 if (g_seriousness > 1) {
1961 if (!(g_rolling || g_shooting)) { 1979 if (!(g_rolling || g_shooting)) {
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
2155 } 2173 }
2156 2174
2157 </textarea> 2175 </textarea>
2158 <!-- End of effect --> 2176 <!-- End of effect -->
2159 </div> 2177 </div>
2160 2178
2161 </body> 2179 </body>
2162 </html> 2180 </html>
2163 2181
2164 2182
OLDNEW
« 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