aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rwxr-xr-xjs/document/html-document.js68
-rwxr-xr-xjs/lib/drawing/world.js9
-rwxr-xr-xjs/lib/geom/geom-obj.js67
3 files changed, 81 insertions, 63 deletions
diff --git a/js/document/html-document.js b/js/document/html-document.js
index bf03e38b..bb54874c 100755
--- a/js/document/html-document.js
+++ b/js/document/html-document.js
@@ -215,30 +215,59 @@ exports.HTMLDocument = Montage.create(TextDocument, {
215 */ 215 */
216 216
217 // /* 217 // /*
218 // get the data for the next canvas
218 var importStr = value[i]; 219 var importStr = value[i];
219 var jObj = JSON.parse( importStr ); 220
220 if (jObj) 221 // determine if it is the new (JSON) or old style format
222 var id = null;
223 var jObj = null;
224 var index = importStr.indexOf( ';' );
225 if ((importStr[0] === 'v') && (index < 24))
226 {
227 // JSON format. pull off the
228 importStr = importStr.substr( index+1 );
229 jObj = jObj = JSON.parse( importStr );
230 id = jObj.id;
231 }
232 else
221 { 233 {
222 var id = jObj.id; 234 var startIndex = importStr.indexOf( "id: " );
223 if (id) 235 if (startIndex >= 0) {
236 var endIndex = importStr.indexOf( "\n", startIndex );
237 if (endIndex > 0)
238 id = importStr.substring( startIndex+4, endIndex );
239 }
240 }
241
242 if (id != null)
243 {
244 var canvas = this.findCanvasWithID( id, elt );
245 if (canvas)
224 { 246 {
225 var canvas = this.findCanvasWithID( id, elt ); 247 if (!canvas.elementModel)
226 if (canvas) { 248 {
227 if (!canvas.elementModel) { 249 NJUtils.makeElementModel(canvas, "Canvas", "shape", true);
228 NJUtils.makeElementModel(canvas, "Canvas", "shape", true); 250 }
251 if (canvas.elementModel)
252 {
253 if (canvas.elementModel.shapeModel.GLWorld)
254 canvas.elementModel.shapeModel.GLWorld.clearTree();
255
256 if (jObj)
257 {
258 var useWebGL = jObj.webGL;
259 var world = new GLWorld( canvas, useWebGL );
260 world.importJSON( jObj );
229 } 261 }
230 if (canvas.elementModel) { 262 else
231 if (canvas.elementModel.shapeModel.GLWorld) { 263 {
232 canvas.elementModel.shapeModel.GLWorld.clearTree(); 264 var index = importStr.indexOf( "webGL: " );
233 } 265 var useWebGL = (index >= 0);
234 if (jObj) 266 var world = new GLWorld( canvas, useWebGL );
235 { 267 world.import( importStr );
236 var useWebGL = jObj.webGL;
237 var world = new GLWorld( canvas, useWebGL );
238 world.importJSON( jObj );
239 this.buildShapeModel( canvas.elementModel, world );
240 }
241 } 268 }
269
270 this.buildShapeModel( canvas.elementModel, world );
242 } 271 }
243 } 272 }
244 } 273 }
@@ -380,6 +409,7 @@ exports.HTMLDocument = Montage.create(TextDocument, {
380 if (elt.elementModel && elt.elementModel.shapeModel && elt.elementModel.shapeModel.GLWorld) 409 if (elt.elementModel && elt.elementModel.shapeModel && elt.elementModel.shapeModel.GLWorld)
381 { 410 {
382 var data = elt.elementModel.shapeModel.GLWorld.exportJSON(); 411 var data = elt.elementModel.shapeModel.GLWorld.exportJSON();
412 //var data = elt.elementModel.shapeModel.GLWorld.export();
383 dataArray.push( data ); 413 dataArray.push( data );
384 } 414 }
385 415
diff --git a/js/lib/drawing/world.js b/js/lib/drawing/world.js
index 4b117242..0ee66abe 100755
--- a/js/lib/drawing/world.js
+++ b/js/lib/drawing/world.js
@@ -754,7 +754,14 @@ World.prototype.exportJSON = function()
754 // convert the object to a string 754 // convert the object to a string
755 var jStr = JSON.stringify( worldObj ); 755 var jStr = JSON.stringify( worldObj );
756 756
757 // the RDGE export function corrupts the data. 757 // prepend some version information to the string.
758 // this string is also used to differentiate between JSON
759 // and pre-JSON versions of fileIO.
760 // the ending ';' in the version string is necessary
761 jStr = "v1.0;" + jStr;
762
763 // You would think that the RDGE export function
764 // would not change the data. You would be wrong...
758 // rebuild the tree 765 // rebuild the tree
759 var root = this._rootNode; 766 var root = this._rootNode;
760 root.children = new Array(); 767 root.children = new Array();
diff --git a/js/lib/geom/geom-obj.js b/js/lib/geom/geom-obj.js
index a4813326..63f71955 100755
--- a/js/lib/geom/geom-obj.js
+++ b/js/lib/geom/geom-obj.js
@@ -5,28 +5,6 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
5</copyright> */ 5</copyright> */
6 6
7var MaterialsModel = require("js/models/materials-model").MaterialsModel; 7var MaterialsModel = require("js/models/materials-model").MaterialsModel;
8/*
9var FlatMaterial = require("js/lib/rdge/materials/flat-material").FlatMaterial;
10var LinearGradientMaterial = require("js/lib/rdge/materials/linear-gradient-material").LinearGradientMaterial;
11var RadialGradientMaterial = require("js/lib/rdge/materials/radial-gradient-material").RadialGradientMaterial;
12var BumpMetalMaterial = require("js/lib/rdge/materials/bump-metal-material").BumpMetalMaterial;
13var UberMaterial = require("js/lib/rdge/materials/uber-material").UberMaterial;
14var RadialBlurMaterial = require("js/lib/rdge/materials/radial-blur-material").RadialBlurMaterial;
15var PlasmaMaterial = require("js/lib/rdge/materials/plasma-material").PlasmaMaterial;
16var PulseMaterial = require("js/lib/rdge/materials/pulse-material").PulseMaterial;
17var TunnelMaterial = require("js/lib/rdge/materials/tunnel-material").TunnelMaterial;
18var ReliefTunnelMaterial = require("js/lib/rdge/materials/relief-tunnel-material").ReliefTunnelMaterial;
19var SquareTunnelMaterial = require("js/lib/rdge/materials/square-tunnel-material").SquareTunnelMaterial;
20var FlyMaterial = require("js/lib/rdge/materials/fly-material").FlyMaterial;
21var WaterMaterial = require("js/lib/rdge/materials/water-material").WaterMaterial;
22var ZInvertMaterial = require("js/lib/rdge/materials/z-invert-material").ZInvertMaterial;
23var DeformMaterial = require("js/lib/rdge/materials/deform-material").DeformMaterial;
24var StarMaterial = require("js/lib/rdge/materials/star-material").StarMaterial;
25var TwistMaterial = require("js/lib/rdge/materials/twist-material").TwistMaterial;
26var JuliaMaterial = require("js/lib/rdge/materials/julia-material").JuliaMaterial;
27var KeleidoscopeMaterial = require("js/lib/rdge/materials/keleidoscope-material").KeleidoscopeMaterial;
28var MandelMaterial = require("js/lib/rdge/materials/mandel-material").MandelMaterial;
29*/
30 8
31/////////////////////////////////////////////////////////////////////// 9///////////////////////////////////////////////////////////////////////
32// Class GLGeomObj 10// Class GLGeomObj
@@ -335,7 +313,7 @@ var GeomObj = function GLGeomObj() {
335 break; 313 break;
336 314
337 default: 315 default:
338 console.log( "material type: " + materialType + " is not supported" ); 316 console.log( "material type: " + shaderName + " is not supported" );
339 break; 317 break;
340 } 318 }
341 319
@@ -375,26 +353,29 @@ var GeomObj = function GLGeomObj() {
375 var materialType = this.getPropertyFromString( "material: ", importStr ); 353 var materialType = this.getPropertyFromString( "material: ", importStr );
376 switch (materialType) 354 switch (materialType)
377 { 355 {
378 case "flat": mat = new FlatMaterial(); break; 356 case "flat":
379 case "radialGradient": mat = new RadialGradientMaterial(); break; 357 case "radialGradient":
380 case "linearGradient": mat = new LinearGradientMaterial(); break; 358 case "linearGradient":
381 case "bumpMetal": mat = new BumpMetalMaterial(); break; 359 case "bumpMetal":
382 case "uber": mat = new UberMaterial(); break; 360 case "uber":
383 case "plasma": mat = new PlasmaMaterial(); break; 361 case "plasma":
384 case "deform": mat = new DeformMaterial(); break; 362 case "deform":
385 case "water": mat = new WaterMaterial(); break; 363 case "water":
386 case "tunnel": mat = new TunnelMaterial(); break; 364 case "tunnel":
387 case "reliefTunnel": mat = new ReliefTunnelMaterial(); break; 365 case "reliefTunnel":
388 case "squareTunnel": mat = new SquareTunnelMaterial(); break; 366 case "squareTunnel":
389 case "twist": mat = new TwiseMaterial(); break; 367 case "twist":
390 case "fly": mat = new FlyMaterial(); break; 368 case "fly":
391 case "julia": mat = new JuliaMaterial(); break; 369 case "julia":
392 case "mandel": mat = new MandelMaterial(); break; 370 case "mandel":
393 case "star": mat = new StarMaterial(); break; 371 case "star":
394 case "zinvert": mat = new ZInvertMaterial(); break; 372 case "zinvert":
395 case "keleidoscope": mat = new KeleidoscopeMaterial(); break; 373 case "keleidoscope":
396 case "radialBlur": mat = new RadialBlurMaterial(); break; 374 case "radialBlur":
397 case "pulse": mat = new PulseMaterial(); break; 375 case "pulse":
376 mat = MaterialsModel.getMaterialByShader( materialType );
377 if (mat) mat = mat.dup();
378 break;
398 379
399 default: 380 default:
400 console.log( "material type: " + materialType + " is not supported" ); 381 console.log( "material type: " + materialType + " is not supported" );