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

Side by Side Diff: native_client_sdk/src/examples/api/graphics_3d/example.js

Issue 23838002: [NaCl SDK] Simplify graphics3d example. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nits Created 7 years, 3 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
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 function $(id) {
6 return document.getElementById(id);
7 }
8
9 function postAngleMessage() {
10 var xAngle = parseFloat($('xAngle').value);
11 var yAngle = parseFloat($('yAngle').value);
12 common.naclModule.postMessage([xAngle, yAngle]);
13 }
14
15 // Add event listeners after the NaCl module has loaded. These listeners will
16 // forward messages to the NaCl module via postMessage()
17 function attachListeners() {
18 $('xAngle').addEventListener('change', postAngleMessage);
19 $('yAngle').addEventListener('change', postAngleMessage);
20 $('animateOff').addEventListener('click', function() {
21 $('animateOn').checked = '';
22 common.naclModule.postMessage(false);
23 });
24 $('animateOn').addEventListener('click', function() {
25 $('animateOff').checked = '';
26 common.naclModule.postMessage(true);
27 });
28 }
29
30 // Handle a message coming from the NaCl module.
31 function handleMessage(event) {
32 if (!(event.data instanceof Array))
33 return;
34 if (event.data.length != 2)
35 return;
36
37 var xAngle = event.data[0];
38 var yAngle = event.data[1];
39 $('xAngle').value = xAngle;
40 $('yAngle').value = yAngle;
41 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698