diff options
author | Jose Antonio Marquez Russo | 2012-03-08 10:49:06 -0800 |
---|---|---|
committer | Jose Antonio Marquez Russo | 2012-03-08 10:49:06 -0800 |
commit | 85f21e020ac281e8e545df1cf269034de99a00b1 (patch) | |
tree | 441834fa8b02b1cc2a970210020d27e06d2c99be /js | |
parent | d9813946dc28d8c28033a68b68300b9d9eda115c (diff) | |
parent | 11a6f18e274d7232cdbb8f6e9e65e0a5ab756451 (diff) | |
download | ninja-85f21e020ac281e8e545df1cf269034de99a00b1.tar.gz |
Merge pull request #29 from ericmueller/integration
Integration
Diffstat (limited to 'js')
67 files changed, 2316 insertions, 509 deletions
diff --git a/js/document/html-document.js b/js/document/html-document.js index b9b68972..05c7d6c0 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,113 @@ 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 | // FOR JOSE: The following commented out lines are what the runtime |
210 | var cdm = new CanvasDataManager(); | 212 | // version should execute. |
211 | cdm.loadGLData(elt, value); | 213 | // var loadForRuntime = true; |
214 | // if (loadForRuntime) | ||
215 | // { | ||
216 | // var cdm = new CanvasDataManager(); | ||
217 | // cdm.loadGLData(elt, value ); | ||
218 | // } | ||
219 | // else | ||
220 | { | ||
221 | var nWorlds= value.length; | ||
222 | for (var i=0; i<nWorlds; i++) | ||
223 | { | ||
224 | var importStr = value[i]; | ||
225 | var startIndex = importStr.indexOf( "id: " ); | ||
226 | if (startIndex >= 0) | ||
227 | { | ||
228 | var endIndex = importStr.indexOf( "\n", startIndex ); | ||
229 | if (endIndex > 0) | ||
230 | { | ||
231 | var id = importStr.substring( startIndex+4, endIndex ); | ||
232 | if (id) | ||
233 | { | ||
234 | var canvas = this.findCanvasWithID( id, elt ); | ||
235 | if (canvas) | ||
236 | { | ||
237 | if (!canvas.elementModel) | ||
238 | { | ||
239 | NJUtils.makeElementModel(canvas, "Canvas", "shape", true); | ||
240 | } | ||
241 | |||
242 | if (canvas.elementModel) | ||
243 | { | ||
244 | if (canvas.elementModel.shapeModel.GLWorld) | ||
245 | canvas.elementModel.shapeModel.GLWorld.clearTree(); | ||
246 | |||
247 | var index = importStr.indexOf( "webGL: " ); | ||
248 | var useWebGL = (index >= 0) | ||
249 | var world = new GLWorld( canvas, useWebGL ); | ||
250 | world.import( importStr ); | ||
251 | |||
252 | this.buildShapeModel( canvas.elementModel, world ); | ||
253 | } | ||
254 | } | ||
255 | } | ||
256 | } | ||
257 | } | ||
258 | } | ||
259 | } | ||
212 | } | 260 | } |
213 | } | 261 | } |
214 | }, | 262 | }, |
215 | 263 | ||
264 | buildShapeModel: | ||
265 | { | ||
266 | value: function( elementModel, world ) | ||
267 | { | ||
268 | var shapeModel = elementModel.shapeModel; | ||
269 | shapeModel.shapeCount = 1; // for now... | ||
270 | shapeModel.useWebGl = world._useWebGL; | ||
271 | shapeModel.GLWorld = world; | ||
272 | var root = world.getGeomRoot(); | ||
273 | if (root) | ||
274 | { | ||
275 | shapeModel.GLGeomObj = root; | ||
276 | shapeModel.strokeSize = root._strokeWidth; | ||
277 | shapeModel.stroke = root._strokeColor.slice(); | ||
278 | shapeModel.strokeMaterial = root._strokeMaterial.dup(); | ||
279 | shapeModel.strokeStyle = "solid"; | ||
280 | //shapeModel.strokeStyleIndex | ||
281 | //shapeModel.border | ||
282 | //shapeModel.background | ||
283 | switch (root.geomType()) | ||
284 | { | ||
285 | case root.GEOM_TYPE_RECTANGLE: | ||
286 | elementModel.selection = "Rectangle"; | ||
287 | elementModel.pi = "RectanglePi"; | ||
288 | shapeModel.fill = root._fillColor.slice(); | ||
289 | shapeModel.fillMaterial = root._fillMaterial.dup(); | ||
290 | shapeModel.tlRadius = root._tlRadius; | ||
291 |