aboutsummaryrefslogtreecommitdiff
path: root/js/lib/rdge/runtime/CanvasDataManager.js
diff options
context:
space:
mode:
authorJose Antonio Marquez Russo2012-03-08 10:49:06 -0800
committerJose Antonio Marquez Russo2012-03-08 10:49:06 -0800
commit85f21e020ac281e8e545df1cf269034de99a00b1 (patch)
tree441834fa8b02b1cc2a970210020d27e06d2c99be /js/lib/rdge/runtime/CanvasDataManager.js
parentd9813946dc28d8c28033a68b68300b9d9eda115c (diff)
parent11a6f18e274d7232cdbb8f6e9e65e0a5ab756451 (diff)
downloadninja-85f21e020ac281e8e545df1cf269034de99a00b1.tar.gz
Merge pull request #29 from ericmueller/integration
Integration
Diffstat (limited to 'js/lib/rdge/runtime/CanvasDataManager.js')
-rw-r--r--js/lib/rdge/runtime/CanvasDataManager.js83
1 files changed, 83 insertions, 0 deletions
diff --git a/js/lib/rdge/runtime/CanvasDataManager.js b/js/lib/rdge/runtime/CanvasDataManager.js
new file mode 100644
index 00000000..8afc9de0
--- /dev/null
+++ b/js/lib/rdge/runtime/CanvasDataManager.js
@@ -0,0 +1,83 @@
1/* <copyright>
2This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
3No 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
8var GeomObj = require("js/lib/geom/geom-obj").GeomObj;
9var ShapePrimitive = require("js/lib/geom/shape-primitive").ShapePrimitive;
10var MaterialsModel = require("js/models/materials-model").MaterialsModel;
11var GLRuntime = require("js/lib/rdge/runtime/GLRuntime").GLRuntime;
12
13///////////////////////////////////////////////////////////////////////
14// Class ShapeRuntime
15// Manages runtime shape display
16///////////////////////////////////////////////////////////////////////
17var CanvasDataManager = function CanvasDataManager()
18{
19 this.loadGLData = function(root, valueArray )
20 {
21 var value = valueArray;
22 var nWorlds = value.length;
23 for (var i=0; i<nWorlds; i++)
24 {
25 var importStr = value[i];
26 var startIndex = importStr.indexOf( "id: " );
27 if (startIndex >= 0)
28 {
29 var endIndex = importStr.indexOf( "\n", startIndex );
30 if (endIndex > 0)
31 {
32 var id = importStr.substring( startIndex+4, endIndex );
33 var canvas = this.findCanvasWithID( id, root );
34 if (canvas)
35 {
36 var rt = new GLRuntime( canvas, importStr );
37 }
38 }
39 }
40 }
41 }
42
43 this.collectGLData = function( elt, dataArray )
44 {
45 if (elt.elementModel && elt.elementModel.shapeModel && elt.elementModel.shapeModel.GLWorld)
46 {
47 var data = elt.elementModel.shapeModel.GLWorld.export( true );
48 dataArray.push( data );
49 }
50
51 if (elt.children)
52 {
53 var nKids = elt.children.length;
54 for (var i=0; i<nKids; i++)
55 {
56 var child = elt.children[i];
57 this.collectGLData( child, dataArray );
58 }
59 }
60 }
61
62 this.findCanvasWithID = function( id, elt )
63 {
64 var cid = elt.getAttribute( "data-RDGE-id" );
65 if (cid == id) return elt;
66
67 if (elt.children)
68 {
69 var nKids = elt.children.length;
70 for (var i=0; i<nKids; i++)
71 {
72 var child = elt.children[i];
73 var foundElt = this.findCanvasWithID( id, child );
74 if (foundElt) return foundElt;
75 }
76 }
77 }
78}
79
80
81if (typeof exports === "object") {
82 exports.CanvasDataManager = CanvasDataManager;
83}