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

Side by Side Diff: samples/GoogleIO-2009/step01.html

Issue 149438: Add Google IO sample. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/o3d/
Patch Set: '' Created 11 years, 5 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 | « samples/GoogleIO-2009/shaders/checker.shader ('k') | samples/GoogleIO-2009/step02.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!--
2 Copyright 2009, Google Inc.
3 All rights reserved.
4
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are
7 met:
8
9 * Redistributions of source code must retain the above copyright
10 notice, this list of conditions and the following disclaimer.
11 * Redistributions in binary form must reproduce the above
12 copyright notice, this list of conditions and the following disclaimer
13 in the documentation and/or other materials provided with the
14 distribution.
15 * Neither the name of Google Inc. nor the names of its
16 contributors may be used to endorse or promote products derived from
17 this software without specific prior written permission.
18
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 -->
31 <!--
32 Google I/O O3D Sample.
33
34 This sample shows the steps to make a simple frame rate independent game.
35 -->
36 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
37 "http://www.w3.org/TR/html4/loose.dtd">
38 <html>
39 <head>
40 <meta http-equiv="content-type" content="text/html; charset=UTF-8">
41 <title>
42 Google I/O O3D Sample
43 </title>
44 <style type="text/css">
45 html, body {
46 height: 100%;
47 margin: 0;
48 padding: 0;
49 border: none;
50 font-family: Arial, sans-serif;
51 }
52 </style>
53 <!-- Include sample javascript library functions-->
54 <script type="text/javascript" src="../o3djs/base.js"></script>
55
56 <!-- Our javascript code -->
57 <script type="text/javascript">
58 o3djs.require('o3djs.util');
59 o3djs.require('o3djs.math');
60 o3djs.require('o3djs.rendergraph');
61
62 // Events
63 // init() once the page has finished loading.
64 // unload() when the page is unloaded.
65 window.onload = init;
66 window.onunload= unload;
67
68 // global variables
69 var g_o3dElement;
70 var g_o3d;
71 var g_math;
72 var g_client;
73 var g_viewInfo;
74 var g_pack;
75 var g_root;
76 var g_globalParams;
77 var g_o3dWidth;
78 var g_o3dHeight;
79 var g_o3dElement;
80 var g_eye = [15, 25, 50];
81 var g_target = [0, 10, 0];
82 var g_up = [0, 1, 0];
83 var g_viewMatrix;
84
85 /**
86 * Updates the projection matrix.
87 */
88 function updateProjection() {
89 g_viewInfo.drawContext.projection = g_math.matrix4.perspective(
90 g_math.degToRad(45), // field of view.
91 g_o3dWidth / g_o3dHeight, // aspect ratio
92 0.1, // Near plane.
93 5000); // Far plane.
94 }
95
96 /*
97 * Updates the camera.
98 */
99 function updateCamera() {
100 g_viewMatrix = g_math.matrix4.lookAt(g_eye, g_target, g_up);
101 g_viewInfo.drawContext.view = g_viewMatrix;
102 };
103
104 /**
105 * Updates global variables of the client's size if they have changed.
106 */
107 function updateClientSize() {
108 var newWidth = g_client.width;
109 var newHeight = g_client.height;
110 if (g_o3dWidth != newWidth || g_o3dHeight != newHeight) {
111 g_o3dWidth = newWidth;
112 g_o3dHeight = newHeight;
113 updateProjection();
114 }
115 }
116
117 /**
118 * Creates the client area.
119 */
120 function init() {
121 o3djs.util.makeClients(initStep2);
122 }
123
124 /**
125 * Initializes O3D and creates one shape.
126 * @param {Array} clientElements Array of o3d object elements.
127 */
128 function initStep2(clientElements) {
129 // Initializes global variables and libraries.
130 g_o3dElement = clientElements[0];
131 g_o3d = g_o3dElement.o3d;
132 g_math = o3djs.math;
133 g_client = g_o3dElement.client;
134
135 // Creates a pack to manage our resources/assets
136 g_pack = g_client.createPack();
137
138 g_root = g_pack.createObject('Transform');
139
140 g_viewInfo = o3djs.rendergraph.createBasicView(
141 g_pack,
142 g_root,
143 g_client.renderGraphRoot);
144
145 updateClientSize();
146 updateCamera();
147
148 window.g_finished = true; // for selenium testing.
149 }
150
151 /**
152 * Remove any callbacks so they don't get called after the page has unloaded.
153 */
154 function unload() {
155 if (g_client) {
156 g_client.cleanup();
157 }
158 }
159 </script>
160 </head>
161 <body>
162 <table style="width: 100%; height:100%;">
163 <tr style="height: 50px;"><td>
164 <div style="width: 100%; height: 50px; font-size: large;">
165 <img src="assets/colorbar.png" width="100%" height="10px"/><br/>
166 Google I/O 2009 O3D Sample
167 </div>
168 </td></tr>
169 <tr style="height: 100%;"><td>
170 <div style="width: 100%; height: 100%;">
171 <div id="o3d" style="width: 100%; height: 100%;"></div>
172 </div>
173 </td></tr>
174 </table>
175 </body>
176 </html>
OLDNEW
« no previous file with comments | « samples/GoogleIO-2009/shaders/checker.shader ('k') | samples/GoogleIO-2009/step02.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698