diff options
Diffstat (limited to 'js/document')
-rwxr-xr-x | js/document/html-document.js | 195 | ||||
-rwxr-xr-x | js/document/templates/montage-html/default_html.css | 9 | ||||
-rwxr-xr-x | js/document/templates/montage-html/index.html | 2 | ||||
-rw-r--r-- | js/document/templates/montage-html/main.reel/main.js | 42 | ||||
-rwxr-xr-x | js/document/text-document.js | 4 |
5 files changed, 117 insertions, 135 deletions
diff --git a/js/document/html-document.js b/js/document/html-document.js index 051490f5..2531465d 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js | |||
@@ -9,7 +9,8 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot | |||
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 | GLWorld = require("js/lib/drawing/world").World; | 12 | GLWorld = require("js/lib/drawing/world").World, |
13 | MaterialsModel = require("js/models/materials-model").MaterialsModel; | ||
13 | //////////////////////////////////////////////////////////////////////// | 14 | //////////////////////////////////////////////////////////////////////// |
14 | // | 15 | // |
15 | exports.HTMLDocument = Montage.create(TextDocument, { | 16 | exports.HTMLDocument = Montage.create(TextDocument, { |
@@ -193,12 +194,9 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
193 | var elt = this.iframe.contentWindow.document.getElementById("UserContent"); | 194 | var elt = this.iframe.contentWindow.document.getElementById("UserContent"); |
194 | // | 195 | // |
195 | if (elt) { | 196 | if (elt) { |
196 | this._glData = []; | 197 | var matLib = MaterialsModel.exportMaterials(); |
197 | //if (path) { | 198 | this._glData = [matLib]; |
198 | //this.collectGLData(elt, this._glData, path); | 199 | this.collectGLData(elt, this._glData ); |
199 | //} else { | ||
200 | this.collectGLData(elt, this._glData ); | ||
201 | //} | ||
202 | } else { | 200 | } else { |
203 | this._glData = null | 201 | this._glData = null |
204 | } | 202 | } |
@@ -207,35 +205,83 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
207 | }, | 205 | }, |
208 | set: function(value) { | 206 | set: function(value) { |
209 | var elt = this.documentRoot; | 207 | var elt = this.documentRoot; |
210 | if (elt) { | 208 | if (elt) |
209 | { | ||
211 | var nWorlds= value.length; | 210 | var nWorlds= value.length; |
212 | for (var i=0; i<nWorlds; i++) { | 211 | for (var i=0; i<nWorlds; i++) |
212 | { | ||
213 | /* | ||
214 | // Use this code to test the runtime version of WebGL | ||
215 | var cdm = new NinjaCvsRt.CanvasDataManager(); | ||
216 | cdm.loadGLData(elt, value, null ); | ||
217 | */ | ||
218 | |||
219 | // /* | ||
220 | // get the data for the next canvas | ||
213 | var importStr = value[i]; | 221 | var importStr = value[i]; |
214 | var startIndex = importStr.indexOf( "id: " ); | 222 | |
215 | if (startIndex >= 0) { | 223 | // determine if it is the new (JSON) or old style format |
216 | var endIndex = importStr.indexOf( "\n", startIndex ); | 224 | var id = null; |
217 | if (endIndex > 0) { | 225 | var jObj = null; |
218 | var id = importStr.substring( startIndex+4, endIndex ); | 226 | var index = importStr.indexOf( ';' ); |
219 | if (id) { | 227 | if ((importStr[0] === 'v') && (index < 24)) |
220 | var canvas = this.findCanvasWithID( id, elt ); | 228 | { |
221 | if (canvas) { | 229 | // JSON format. pull off the |
222 | if (!canvas.elementModel) { | 230 | importStr = importStr.substr( index+1 ); |
223 | NJUtils.makeElementModel(canvas, "Canvas", "shape", true); | 231 | jObj = jObj = JSON.parse( importStr ); |
224 | } | 232 | id = jObj.id; |
225 | if (canvas.elementModel) { | 233 | } |
226 | if (canvas.elementModel.shapeModel.GLWorld) { | 234 | else |
227 | canvas.elementModel.shapeModel.GLWorld.clearTree(); | 235 | { |
228 | } | 236 | // at this point the data could be either the materials library or |
229 | var index = importStr.indexOf( "webGL: " ); | 237 | // an old style world. We can determine which by converting the string |
230 | var useWebGL = (index >= 0) | 238 | // to an object via JSON.parse. That operation will fail if the string |
231 | var world = new GLWorld( canvas, useWebGL ); | 239 | // is an old style world. |
232 | world.import( importStr ); | 240 | var matLibStr = 'materialLibrary;'; |
233 | this.buildShapeModel( canvas.elementModel, world ); | 241 | index = importStr.indexOf( matLibStr ); |
234 | } | 242 | if (index == 0) |
243 | { | ||
244 | importStr = importStr.substr( matLibStr.length ); | ||
245 | var matLibObj = JSON.parse( importStr ); | ||
246 | MaterialsModel.importMaterials( matLibObj ); | ||
247 | } | ||
248 | else | ||
249 | { | ||
250 | var startIndex = importStr.indexOf( "id: " ); | ||
251 | if (startIndex >= 0) { | ||
252 | var endIndex = importStr.indexOf( "\n", startIndex ); | ||
253 | if (endIndex > 0) | ||
254 | id = importStr.substring( startIndex+4, endIndex ); | ||
255 | } | ||
256 | } | ||
257 | } | ||
258 | |||
259 | if (id != null) | ||
260 | { | ||
261 | var canvas = this.findCanvasWithID( id, elt ); | ||
262 | if (canvas) | ||
263 | { | ||
264 | if (!canvas.elementModel) | ||
265 | { | ||
266 | NJUtils.makeElementModel(canvas, "Canvas", "shape", true); | ||
267 | } | ||
268 | if (canvas.elementModel) | ||
269 | { | ||
270 | if (canvas.elementModel.shapeModel.GLWorld) | ||
271 | canvas.elementModel.shapeModel.GLWorld.clearTree(); | ||
272 | |||
273 | if (jObj) | ||
274 | { | ||
275 | var useWebGL = jObj.webGL; | ||
276 | var world = new GLWorld( canvas, useWebGL ); | ||
277 | world.importJSON( jObj ); | ||
235 | } | 278 | } |
279 | |||
280 | this.buildShapeModel( canvas.elementModel, world ); | ||
236 | } | 281 | } |
237 | } | 282 | } |
238 | } | 283 | } |
284 | // */ | ||
239 | } | 285 | } |
240 | } | 286 | } |
241 | } | 287 | } |
@@ -254,19 +300,13 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
254 | { | 300 | { |
255 | shapeModel.GLGeomObj = root; | 301 | shapeModel.GLGeomObj = root; |
256 | shapeModel.strokeSize = root._strokeWidth; | 302 | shapeModel.strokeSize = root._strokeWidth; |
257 | shapeModel.stroke = root._strokeColor.slice(); | ||
258 | shapeModel.strokeMaterial = root._strokeMaterial.dup(); | ||
259 | shapeModel.strokeStyle = "solid"; | 303 | shapeModel.strokeStyle = "solid"; |
260 | //shapeModel.strokeStyleIndex | 304 | //shapeModel.strokeStyleIndex |
261 | //shapeModel.border | ||
262 | //shapeModel.background | ||
263 | switch (root.geomType()) | 305 | switch (root.geomType()) |
264 | { | 306 | { |
265 | case root.GEOM_TYPE_RECTANGLE: | 307 | case root.GEOM_TYPE_RECTANGLE: |
266 | elementModel.selection = "Rectangle"; | 308 | elementModel.selection = "Rectangle"; |
267 | elementModel.pi = "RectanglePi"; | 309 | elementModel.pi = "RectanglePi"; |
268 | shapeModel.fill = root._fillColor.slice(); | ||
269 | shapeModel.fillMaterial = root._fillMaterial.dup(); | ||
270 | shapeModel.tlRadius = root._tlRadius; | 310 | shapeModel.tlRadius = root._tlRadius; |
271 | shapeModel.trRadius = root._trRadius; | 311 | shapeModel.trRadius = root._trRadius; |
272 | shapeModel.blRadius = root._blRadius; | 312 | shapeModel.blRadius = root._blRadius; |
@@ -276,8 +316,6 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
276 | case root.GEOM_TYPE_CIRCLE: | 316 | case root.GEOM_TYPE_CIRCLE: |
277 | elementModel.selection = "Oval"; | 317 | elementModel.selection = "Oval"; |
278 | elementModel.pi = "OvalPi"; | 318 | elementModel.pi = "OvalPi"; |
279 | shapeModel.fill = root._fillColor.slice(); | ||
280 | shapeModel.fillMaterial = root._fillMaterial.dup(); | ||
281 | shapeModel.innerRadius = root._innerRadius; | 319 | shapeModel.innerRadius = root._innerRadius; |
282 | break; | 320 | break; |
283 | 321 | ||
@@ -287,6 +325,12 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
287 | shapeModel.slope = root._slope; | 325 | shapeModel.slope = root._slope; |
288 | break; | 326 | break; |
289 | 327 | ||
328 | case root.GEOM_TYPE_BRUSH_STROKE: | ||
329 | elementModel.selection = "BrushStroke"; | ||
330 | elementModel.pi = "BrushStrokePi"; | ||
331 | break; | ||
332 | |||
333 | |||
290 | default: | 334 | default: |
291 | console.log( "geometry type not supported for file I/O, " + root.geomType()); | 335 | console.log( "geometry type not supported for file I/O, " + root.geomType()); |
292 | break; | 336 | break; |
@@ -372,7 +416,7 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
372 | { | 416 | { |
373 | if (elt.elementModel && elt.elementModel.shapeModel && elt.elementModel.shapeModel.GLWorld) | 417 | if (elt.elementModel && elt.elementModel.shapeModel && elt.elementModel.shapeModel.GLWorld) |
374 | { | 418 | { |
375 | var data = elt.elementModel.shapeModel.GLWorld.export(); | 419 | var data = elt.elementModel.shapeModel.GLWorld.exportJSON(); |
376 | dataArray.push( data ); | 420 | dataArray.push( data ); |
377 | } | 421 | } |
378 | 422 | ||
@@ -510,67 +554,13 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
510 | } | 554 | } |
511 | // | 555 | // |
512 | if(!this.documentRoot.Ninja) this.documentRoot.Ninja = {}; | 556 | if(!this.documentRoot.Ninja) this.documentRoot.Ninja = {}; |
513 | //Inserting user's document into template | ||
514 |