diff options
Diffstat (limited to 'js')
69 files changed, 2356 insertions, 530 deletions
diff --git a/js/document/html-document.js b/js/document/html-document.js index 67026407..bc27ea7b 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js | |||
@@ -8,7 +8,9 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot | |||
8 | // | 8 | // |
9 | var Montage = require("montage/core/core").Montage, | 9 | var Montage = require("montage/core/core").Montage, |
10 | TextDocument = require("js/document/text-document").TextDocument, | 10 | TextDocument = require("js/document/text-document").TextDocument, |
11 | NJUtils = require("js/lib/NJUtils").NJUtils; | 11 | NJUtils = require("js/lib/NJUtils").NJUtils, |
12 | CanvasDataManager = require("js/lib/rdge/runtime/CanvasDataManager").CanvasDataManager, | ||
13 | GLWorld = require("js/lib/drawing/world").World; | ||
12 | //////////////////////////////////////////////////////////////////////// | 14 | //////////////////////////////////////////////////////////////////////// |
13 | // | 15 | // |
14 | exports.HTMLDocument = Montage.create(TextDocument, { | 16 | exports.HTMLDocument = Montage.create(TextDocument, { |
@@ -206,13 +208,93 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
206 | var elt = this.documentRoot; | 208 | var elt = this.documentRoot; |
207 | if (elt) | 209 | if (elt) |
208 | { | 210 | { |
209 | console.log( "load canvas data: " , value ); | 211 | var nWorlds= value.length; |
210 | var cdm = new CanvasDataManager(); | 212 | for (var i=0; i<nWorlds; i++) { |
211 | cdm.loadGLData(elt, value); | 213 | var importStr = value[i]; |
214 | var startIndex = importStr.indexOf("id: "); | ||
215 | if (startIndex >= 0) { | ||
216 | var endIndex = importStr.indexOf("\n", startIndex); | ||
217 | if (endIndex > 0) { | ||
218 | var id = importStr.substring( startIndex+4, endIndex); | ||
219 | if (id) { | ||
220 | var canvas = this.findCanvasWithID(id, elt); | ||
221 | if (canvas) { | ||
222 | if (!canvas.elementModel) { | ||
223 | NJUtils.makeElementModel(canvas, "Canvas", "shape", true); | ||
224 | } | ||
225 | if (canvas.elementModel) { | ||
226 | if (canvas.elementModel.shapeModel.GLWorld) { | ||
227 | canvas.elementModel.shapeModel.GLWorld.clearTree(); | ||
228 | } | ||
229 | var index = importStr.indexOf( "webGL: " ); | ||
230 | var useWebGL = (index >= 0) | ||
231 | var world = new GLWorld(canvas, useWebGL); | ||
232 | world.import( importStr ); | ||
233 | this.buildShapeModel(canvas.elementModel, world); | ||
234 | } | ||
235 | } | ||
236 | } | ||
237 | } | ||
238 | } | ||
239 | } | ||
212 | } | 240 | } |
213 | } | 241 | } |
214 | }, | 242 | }, |
215 | 243 | ||
244 | buildShapeModel: | ||
245 | { | ||
246 | value: function( elementModel, world ) | ||
247 | { | ||
248 | var shapeModel = elementModel.shapeModel; | ||
249 | shapeModel.shapeCount = 1; // for now... | ||
250 | shapeModel.useWebGl = world._useWebGL; | ||
251 | shapeModel.GLWorld = world; | ||
252 | var root = world.getGeomRoot(); | ||
253 | if (root) | ||
254 | { | ||
255 | shapeModel.GLGeomObj = root; | ||
256 | shapeModel.strokeSize = root._strokeWidth; | ||
257 | shapeModel.stroke = root._strokeColor.slice(); | ||
258 | shapeModel.strokeMaterial = root._strokeMaterial.dup(); | ||
259 | shapeModel.strokeStyle = "solid"; | ||
260 | //shapeModel.strokeStyleIndex | ||
261 | //shapeModel.border | ||
262 | //shapeModel.background | ||
263 | switch (root.geomType()) | ||
264 | { | ||
265 | case root.GEOM_TYPE_RECTANGLE: | ||
266 | elementModel.selection = "Rectangle"; | ||
267 | elementModel.pi = "RectanglePi"; | ||
268 | shapeModel.fill = root._fillColor.slice(); | ||
269 | shapeModel.fillMaterial = root._fillMaterial.dup(); | ||
270 | shapeModel.tlRadius = root._tlRadius; | ||
271 | shapeModel.trRadius = root._trRadius; | ||
272 | shapeModel.blRadius = root._blRadius; | ||
273 | shapeModel.brRadius = root._brRadius; | ||
274 | break; | ||
275 | |||
276 | case root.GEOM_TYPE_CIRCLE: | ||
277 | elementModel.selection = "Oval"; | ||
278 | elementModel.pi = "OvalPi"; | ||
279 | shapeModel.fill = root._fillColor.slice(); | ||
280 | shapeModel.fillMaterial = root._fillMaterial.dup(); | ||