diff options
100 files changed, 2481 insertions, 682 deletions
diff --git a/assets/canvas-runtime.js b/assets/canvas-runtime.js new file mode 100644 index 00000000..655e52fa --- /dev/null +++ b/assets/canvas-runtime.js | |||
@@ -0,0 +1,1376 @@ | |||
1 | /* <copyright> | ||
2 | This file contains proprietary software owned by Motorola Mobility, Inc.<br/> | ||
3 | No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> | ||
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | ||
5 | </copyright> */ | ||
6 | |||
7 | /////////////////////////////////////////////////////////////////////// | ||
8 | //Loading webGL/canvas data | ||
9 | function initWebGl (rootElement, directory) { | ||
10 | var cvsDataMngr, ninjaWebGlData = JSON.parse((document.querySelectorAll(['script[data-ninja-webgl]'])[0].innerHTML.replace('(', '')).replace(')', '')); | ||
11 | if (ninjaWebGlData && ninjaWebGlData.data) { | ||
12 | for (var n=0; ninjaWebGlData.data[n]; n++) { | ||
13 | ninjaWebGlData.data[n] = unescape(ninjaWebGlData.data[n]); | ||
14 | } | ||
15 | } | ||
16 | //Creating data manager | ||
17 | cvsDataMngr = new CanvasDataManager(); | ||
18 | //Loading data to canvas(es) | ||
19 | cvsDataMngr.loadGLData(rootElement, ninjaWebGlData.data, directory); | ||
20 | } | ||
21 | |||
22 | /////////////////////////////////////////////////////////////////////// | ||
23 | // Class ShapeRuntime | ||
24 | // Manages runtime shape display | ||
25 | /////////////////////////////////////////////////////////////////////// | ||
26 | function CanvasDataManager() | ||
27 | { | ||
28 | this.loadGLData = function(root, valueArray, assetPath ) | ||
29 | { | ||
30 | this._assetPath = assetPath.slice(); | ||
31 | |||
32 | var value = valueArray; | ||
33 | var nWorlds = value.length; | ||
34 | for (var i=0; i<nWorlds; i++) | ||
35 | { | ||
36 | var importStr = value[i]; | ||
37 | var startIndex = importStr.indexOf( "id: " ); | ||
38 | if (startIndex >= 0) | ||
39 | { | ||
40 | var endIndex = importStr.indexOf( "\n", startIndex ); | ||
41 | if (endIndex > 0) | ||
42 | { | ||
43 | var id = importStr.substring( startIndex+4, endIndex ); | ||
44 | var canvas = this.findCanvasWithID( id, root ); | ||
45 | if (canvas) | ||
46 | { | ||
47 | var rt = new GLRuntime( canvas, importStr, assetPath ); | ||
48 | } | ||
49 | } | ||
50 | } | ||
51 | } | ||
52 | } | ||
53 | |||
54 | this.collectGLData = function( elt, dataArray ) | ||
55 | { | ||
56 | if (elt.elementModel && elt.elementModel.shapeModel && elt.elementModel.shapeModel.GLWorld) | ||
57 | { | ||
58 | var data = elt.elementModel.shapeModel.GLWorld.export( true ); | ||
59 | dataArray.push( data ); | ||
60 | } | ||
61 | |||
62 | if (elt.children) | ||
63 | { | ||
64 | var nKids = elt.children.length; | ||
65 | for (var i=0; i<nKids; i++) | ||
66 | { | ||
67 | var child = elt.children[i]; | ||
68 | this.collectGLData( child, dataArray ); | ||
69 | } | ||
70 | <