aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/RDGE/runtime/CanvasLoader.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/helper-classes/RDGE/runtime/CanvasLoader.js')
-rw-r--r--js/helper-classes/RDGE/runtime/CanvasLoader.js72
1 files changed, 72 insertions, 0 deletions
diff --git a/js/helper-classes/RDGE/runtime/CanvasLoader.js b/js/helper-classes/RDGE/runtime/CanvasLoader.js
new file mode 100644
index 00000000..12a985d3
--- /dev/null
+++ b/js/helper-classes/RDGE/runtime/CanvasLoader.js
@@ -0,0 +1,72 @@
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
8
9///////////////////////////////////////////////////////////////////////
10// Class ShapeRuntime
11// Manages runtime shape display
12///////////////////////////////////////////////////////////////////////
13function CanvasLoader( root, valueArray, loadForAuthoring )
14{
15 var value = valueArray;
16 var nWorlds = value.length;
17 for (var i=0; i<nWorlds; i++)
18 {
19 var importStr = value[i];
20 var startIndex = importStr.indexOf( "id: " );
21 if (startIndex >= 0)
22 {
23 var endIndex = importStr.indexOf( "\n", startIndex );
24 if (endIndex > 0)
25 {
26 var id = importStr.substring( startIndex+4, endIndex );
27 var canvas = this.findCanvasWithID( id, root );
28 if (canvas)
29 {
30 if (loadForAuthoring)
31 {
32 if (!canvas.elementModel)
33 {
34 NJUtils.makeElementModel(canvas, "Canvas", "shape", true);
35 }
36
37 if (canvas.elementModel)
38 {
39 if (canvas.elementModel.shapeModel.GLWorld)
40 canvas.elementModel.shapeModel.GLWorld.clearTree();
41
42 var world = new GLWorld( canvas );
43 canvas.elementModel.shapeModel.GLWorld = world;
44 world.import( importStr );
45 }
46 }
47 else
48 {
49 var rt = new GLRuntime( canvas, importStr );
50 }
51 }
52 }
53 }
54 }
55
56 this.findCanvasWithID = function( id, elt )
57 {
58 var cid = elt.getAttribute( "data-RDGE-id" );
59 if (cid == id) return elt;
60
61 if (elt.children)
62 {
63 var nKids = elt.children.length;
64 for (var i=0; i<nKids; i++)
65 {
66 var child = elt.children[i];
67 this.findCanvasWithID( id, child );
68 }
69 }
70 }
71}
72