aboutsummaryrefslogtreecommitdiff
path: root/js/document
diff options
context:
space:
mode:
authorhwc4872012-02-22 16:28:29 -0800
committerhwc4872012-02-22 16:28:29 -0800
commit64280907f31e6f6e5659acb0893df3e0da5bb044 (patch)
treea7665fecf079d3c9bcdd34a6eedec52ab2a4206f /js/document
parent2bb869eb1c0b71e379f159eb0f95dfa168496d8d (diff)
downloadninja-64280907f31e6f6e5659acb0893df3e0da5bb044.tar.gz
GL save and reload.
Diffstat (limited to 'js/document')
-rwxr-xr-xjs/document/html-document.js41
1 files changed, 8 insertions, 33 deletions
diff --git a/js/document/html-document.js b/js/document/html-document.js
index 9a7755e6..f5816f64 100755
--- a/js/document/html-document.js
+++ b/js/document/html-document.js
@@ -152,13 +152,13 @@ exports.HTMLDocument = Montage.create(TextDocument, {
152 glData: { 152 glData: {
153 get: function() 153 get: function()
154 { 154 {
155 var elt = this.iframe;
156 var elt = this.iframe.contentWindow.document.getElementById("UserContent"); 155 var elt = this.iframe.contentWindow.document.getElementById("UserContent");
157 this._glData = null; 156 this._glData = null;
158 if (elt) 157 if (elt)
159 { 158 {
160 this._glData = new Array(); 159 var cdm = new CanvasDataManager();
161 this.collectGLData( elt, this._glData ); 160 this._glData = [];
161 cdm.collectGLData( elt, this._glData );
162 } 162 }
163 163
164 return this._glData 164 return this._glData
@@ -166,37 +166,12 @@ exports.HTMLDocument = Montage.create(TextDocument, {
166 166
167 set: function(value) 167 set: function(value)
168 { 168 {
169 var nWorlds = value.length; 169 var elt = this.iframe.contentWindow.document.getElementById("UserContent");
170 for (var i=0; i<nWorlds; i++) 170 if (elt)
171 { 171 {
172 var importStr = value[i]; 172 console.log( "load canvas data: " + value );
173 var startIndex = importStr.indexOf( "id: " ); 173 var cdm = new CanvasDataManager();
174 if (startIndex >= 0) 174 cdm.loadGLData(elt, value);
175 {
176 var endIndex = importStr.indexOf( "\n", startIndex );
177 if (endIndex > 0)
178 {
179 var id = importStr.substring( startIndex+4, endIndex );
180 var canvas = this.iframe.contentWindow.document.getElementById( id );
181 if (canvas)
182 {
183 if (!canvas.elementModel)
184 {
185 NJUtils.makeElementModel(canvas, "Canvas", "shape", true);
186 }
187
188 if (canvas.elementModel)
189 {
190 if (canvas.elementModel.shapeModel.GLWorld)
191 canvas.elementModel.shapeModel.GLWorld.clearTree();
192
193 var world = new GLWorld( canvas );
194 canvas.elementModel.shapeModel.GLWorld = world;
195 world.import( importStr );
196 }
197 }
198 }
199 }
200 } 175 }
201 } 176 }
202 }, 177 },