diff options
author | Jonathan Duran | 2012-02-27 11:22:51 -0800 |
---|---|---|
committer | Jonathan Duran | 2012-02-27 11:22:51 -0800 |
commit | ab10898c78f2bd5d765d9c915848ed8c8e08c5a3 (patch) | |
tree | b1ebb87e9c101c558108e1cec043d64a03cc50a1 /js/helper-classes/RDGE/runtime/CanvasDataManager.js | |
parent | fb8aacbadba8dffb9619eb16e4626c197dc9264d (diff) | |
parent | da60be29baab67440535b6b2b71fe7de989dfed0 (diff) | |
download | ninja-ab10898c78f2bd5d765d9c915848ed8c8e08c5a3.tar.gz |
Merge branch 'refs/heads/integration-candidate' into Timeline
Diffstat (limited to 'js/helper-classes/RDGE/runtime/CanvasDataManager.js')
-rw-r--r-- | js/helper-classes/RDGE/runtime/CanvasDataManager.js | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/js/helper-classes/RDGE/runtime/CanvasDataManager.js b/js/helper-classes/RDGE/runtime/CanvasDataManager.js new file mode 100644 index 00000000..4985fc9a --- /dev/null +++ b/js/helper-classes/RDGE/runtime/CanvasDataManager.js | |||
@@ -0,0 +1,98 @@ | |||
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 | |||
9 | /////////////////////////////////////////////////////////////////////// | ||
10 | // Class ShapeRuntime | ||
11 | // Manages runtime shape display | ||
12 | /////////////////////////////////////////////////////////////////////// | ||
13 | function CanvasDataManager() | ||
14 | { | ||
15 | this.loadGLData = function(root, valueArray) | ||
16 | { | ||
17 | var value = valueArray; | ||
18 | var nWorlds = value.length; | ||
19 | for (var i=0; i<nWorlds; i++) | ||
20 | { | ||
21 | var importStr = value[i]; | ||
22 | var startIndex = importStr.indexOf( "id: " ); | ||
23 | if (startIndex >= 0) | ||
24 | { | ||
25 | var endIndex = importStr.indexOf( "\n", startIndex ); | ||
26 | if (endIndex > 0) | ||
27 | { | ||
28 | var id = importStr.substring( startIndex+4, endIndex ); | ||
29 | var canvas = this.findCanvasWithID( id, root ); | ||
30 | if (canvas) | ||
31 | { | ||
32 | var loadForAuthoring = true; | ||
33 | var index = importStr.indexOf( "scenedata: " ); | ||
34 | if (index >= 0) loadForAuthoring = false; | ||
35 | |||
36 | if (loadForAuthoring) | ||
37 | { | ||
38 | if (!canvas.elementModel) | ||
39 | { | ||
40 | NJUtils.makeElementModel(canvas, "Canvas", "shape", true); | ||
41 | } | ||
42 | |||
43 | if (canvas.elementModel) | ||
44 | { | ||
45 | if (canvas.elementModel.shapeModel.GLWorld) | ||
46 | canvas.elementModel.shapeModel.GLWorld.clearTree(); | ||
47 | |||
48 | var world = new GLWorld( canvas ); | ||
49 | canvas.elementModel.shapeModel.GLWorld = world; | ||
50 | world.import( importStr ); | ||
51 | } | ||
52 | } | ||
53 | else | ||
54 | { | ||
55 | var rt = new GLRuntime( canvas, importStr ); | ||
56 | } | ||
57 | } | ||
58 | } | ||
59 | } | ||
60 | } | ||
61 | } | ||
62 | |||
63 | this.collectGLData = function( elt, dataArray ) | ||
64 | { | ||
65 | if (elt.elementModel && elt.elementModel.shapeModel && elt.elementModel.shapeModel.GLWorld) | ||
66 | { | ||
67 | var data = elt.elementModel.shapeModel.GLWorld.export(); | ||
68 | dataArray.push( data ); | ||
69 | } | ||
70 | |||
71 | if (elt.children) | ||
72 | { | ||
73 | var nKids = elt.children.length; | ||
74 | for (var i=0; i<nKids; i++) | ||
75 | { | ||
76 | var child = elt.children[i]; | ||
77 | this.collectGLData( child, dataArray ); | ||
78 | } | ||
79 | } | ||
80 | } | ||
81 | |||
82 | this.findCanvasWithID = function( id, elt ) | ||
83 | { | ||
84 | var cid = elt.getAttribute( "data-RDGE-id" ); | ||
85 | if (cid == id) return elt; | ||
86 | |||
87 | if (elt.children) | ||
88 | { | ||
89 | var nKids = elt.children.length; | ||
90 | for (var i=0; i<nKids; i++) | ||
91 | { | ||
92 | var child = elt.children[i]; | ||
93 | this.findCanvasWithID( id, child ); | ||
94 | } | ||
95 | } | ||
96 | } | ||
97 | } | ||
98 | |||