diff options
author | Valerio Virgillito | 2012-03-13 11:15:34 -0700 |
---|---|---|
committer | Valerio Virgillito | 2012-03-13 11:15:34 -0700 |
commit | f6b958360d82854bdaf51848e7fd715d1f633179 (patch) | |
tree | 80f6c08bb730089bdd3f26310df8d2363f9ba863 | |
parent | c24f58c10231c30d3a8a4c9fb9a4f395dd746180 (diff) | |
parent | 4d7b86f55c504ee4e8c2460cf6b60cb9a2cf18f0 (diff) | |
download | ninja-f6b958360d82854bdaf51848e7fd715d1f633179.tar.gz |
Merge pull request #105 from joseeight/FileIO-Build-Candidate
File I/O adding webGL/canvas data functionality
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 |