aboutsummaryrefslogtreecommitdiff
path: root/js/lib
diff options
context:
space:
mode:
Diffstat (limited to 'js/lib')
-rwxr-xr-xjs/lib/drawing/world.js31
-rwxr-xr-xjs/lib/geom/circle.js18
-rwxr-xr-xjs/lib/geom/geom-obj.js12
-rwxr-xr-xjs/lib/geom/line.js11
-rwxr-xr-xjs/lib/geom/rectangle.js28
-rw-r--r--js/lib/rdge/materials/julia-material.js6
-rw-r--r--js/lib/rdge/materials/mandel-material.js6
-rw-r--r--js/lib/rdge/materials/plasma-material.js19
-rw-r--r--js/lib/rdge/materials/pulse-material.js1
-rw-r--r--js/lib/rdge/materials/radial-blur-material.js29
-rw-r--r--js/lib/rdge/materials/water-material.js25
11 files changed, 111 insertions, 75 deletions
diff --git a/js/lib/drawing/world.js b/js/lib/drawing/world.js
index 0ee66abe..0979cf12 100755
--- a/js/lib/drawing/world.js
+++ b/js/lib/drawing/world.js
@@ -751,6 +751,21 @@ World.prototype.exportJSON = function()
751 var strArray = []; 751 var strArray = [];
752 this.exportObjectsJSON( this._geomRoot, worldObj ); 752 this.exportObjectsJSON( this._geomRoot, worldObj );
753 753
754 // You would think that the RDGE export function
755 // would not be destructive of the data. You would be wrong...
756 // We need to rebuild everything
757 if (this._useWebGL)
758 {
759 var root = this._rootNode;
760 root.children = new Array();
761 if (worldObj.children && (worldObj.children.length === 1))
762 {
763 this.init();
764 this._geomRoot = undefined;
765 this.importObjectsJSON( worldObj.children[0] );
766 }
767 }
768
754 // convert the object to a string 769 // convert the object to a string
755 var jStr = JSON.stringify( worldObj ); 770 var jStr = JSON.stringify( worldObj );
756 771
@@ -759,14 +774,6 @@ World.prototype.exportJSON = function()
759 // and pre-JSON versions of fileIO. 774 // and pre-JSON versions of fileIO.
760 // the ending ';' in the version string is necessary 775 // the ending ';' in the version string is necessary
761 jStr = "v1.0;" + jStr; 776 jStr = "v1.0;" + jStr;
762
763 // You would think that the RDGE export function
764 // would not change the data. You would be wrong...
765 // rebuild the tree
766 var root = this._rootNode;
767 root.children = new Array();
768 if (worldObj.children && (worldObj.children.length === 1))
769 this.importObjectsJSON( worldObj.children[0] );
770 777
771 return jStr; 778 return jStr;
772} 779}
@@ -780,13 +787,14 @@ World.prototype.exportObjectsJSON = function( obj, parentObj )
780 parentObj.children.push( jObj ); 787 parentObj.children.push( jObj );
781 788
782 if (obj.getChild()) { 789 if (obj.getChild()) {
783 this.exportObjects( obj.getChild (), jObj ); 790 this.exportObjectsJSON( obj.getChild (), jObj );
784 } 791 }
785 792
786 if (obj.getNext()) 793 if (obj.getNext())
787 this.exportObjects( obj.getNext(), parentObj ); 794 this.exportObjectsJSON( obj.getNext(), parentObj );
788} 795}
789 796
797/*
790World.prototype.export = function() 798World.prototype.export = function()
791{ 799{
792 var exportStr = "GLWorld 1.0\n"; 800 var exportStr = "GLWorld 1.0\n";
@@ -849,6 +857,7 @@ World.prototype.exportObjects = function( obj ) {
849 857
850 return rtnStr; 858 return rtnStr;
851}; 859};
860*/
852 861
853World.prototype.findTransformNodeByMaterial = function( materialNode, trNode ) { 862World.prototype.findTransformNodeByMaterial = function( materialNode, trNode ) {
854 //if (trNode == null) trNode = this._ctrNode; 863 //if (trNode == null) trNode = this._ctrNode;
@@ -893,6 +902,8 @@ World.prototype.importJSON = function( jObj )
893 // render using canvas 2D 902 // render using canvas 2D
894 this.render(); 903 this.render();
895 } 904 }
905 else
906 this.restartRenderLoop();
896} 907}
897 908
898World.prototype.importObjectsJSON = function( jObj, parentGeomObj ) 909World.prototype.importObjectsJSON = function( jObj, parentGeomObj )
diff --git a/js/lib/geom/circle.js b/js/lib/geom/circle.js
index fec62308..d48bf98b 100755
--- a/js/lib/geom/circle.js
+++ b/js/lib/geom/circle.js
@@ -634,24 +634,6 @@ var Circle = function GLCircle() {
634 var strokeMaterialName = jObj.strokeMat; 634 var strokeMaterialName = jObj.strokeMat;
635 var fillMaterialName = jObj.fillMat; 635 var fillMaterialName = jObj.fillMat;
636 this.importMaterialsJSON( jObj.materials ); 636 this.importMaterialsJSON( jObj.materials );
637
638 var strokeMat = MaterialsModel.getMaterial( strokeMaterialName );
639 if (!strokeMat) {
640 console.log( "object material not found in library: " + strokeMaterialName );
641 strokeMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() );
642 }
643 else
644 strokeMat = strokeMat.dup();
645 this._strokeMaterial = strokeMat;
646
647 var fillMat = MaterialsModel.getMaterial( fillMaterialName );
648 if (!fillMat) {
649 console.log( "object material not found in library: " + fillMaterialName );
650 fillMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() );
651 }
652 else
653 fillMat = fillMat.dup();
654 this._fillMaterial = fillMat;
655 }; 637 };
656 638
657 639
diff --git a/js/lib/geom/geom-obj.js b/js/lib/geom/geom-obj.js
index 63f71955..75b7808b 100755
--- a/js/lib/geom/geom-obj.js
+++ b/js/lib/geom/geom-obj.js
@@ -279,6 +279,11 @@ var GeomObj = function GLGeomObj() {
279 279
280 this.importMaterialsJSON = function( jObj ) 280 this.importMaterialsJSON = function( jObj )
281 { 281 {
282 this._materialArray = [];
283 this._materialTypeArray = [];
284
285 if (!jObj) return;
286
282 var nMaterials = jObj.nMaterials; 287 var nMaterials = jObj.nMaterials;
283 var matArray = jObj.materials; 288 var matArray = jObj.materials;
284 for (var i=0; i<nMaterials; i++) 289 for (var i=0; i<nMaterials; i++)
@@ -318,7 +323,14 @@ var GeomObj = function GLGeomObj() {
318 } 323 }
319 324
320 if (mat) 325 if (mat)
326 {
321 mat.importJSON( matObj ); 327 mat.importJSON( matObj );
328 this._materialArray.push( mat );
329 this._materialTypeArray.push( matObj.type );
330 var type = matArray[i].type;
331 if (type == "fill") this._fillMaterial = mat;
332 else this._strokeMaterial = mat;
333 }
322 } 334 }
323 } 335 }
324 336
diff --git a/js/lib/geom/line.js b/js/lib/geom/line.js
index a706eb93..e839e229 100755
--- a/js/lib/geom/line.js
+++ b/js/lib/geom/line.js
@@ -137,16 +137,7 @@ var Line = function GLLine( world, xOffset, yOffset, width, height, slope, strok
137 this._strokeStyle = jObj.strokeStyle; 137 this._strokeStyle = jObj.strokeStyle;
138 this._strokeColor = jObj.strokeColor; 138 this._strokeColor = jObj.strokeColor;
139 var strokeMaterialName = jObj.strokeMat; 139 var strokeMaterialName = jObj.strokeMat;
140 140 this.importMaterialsJSON( jObj.materials );
141 var strokeMat = MaterialsModel.getMaterial( strokeMaterialName );
142 if (!strokeMat) {
143 console.log( "object material not found in library: " + strokeMaterialName );
144 strokeMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() );
145 }
146 else
147 strokeMat = strokeMat.dup();
148 this._strokeMaterial = strokeMat;
149
150 }; 141 };
151 142
152 this.export = function() { 143 this.export = function() {
diff --git a/js/lib/geom/rectangle.js b/js/lib/geom/rectangle.js
index c6bc2d88..38e428bd 100755
--- a/js/lib/geom/rectangle.js
+++ b/js/lib/geom/rectangle.js
@@ -78,8 +78,6 @@ var Rectangle = function GLRectangle() {
78 } else { 78 } else {
79 this._fillMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ); 79 this._fillMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() );
80 } 80 }
81
82 this.exportMaterials();
83 }; 81 };
84 82
85 /////////////////////////////////////////////////////////////////////// 83 ///////////////////////////////////////////////////////////////////////
@@ -291,24 +289,6 @@ var Rectangle = function GLRectangle() {
291 var strokeMaterialName = jObj.strokeMat; 289 var strokeMaterialName = jObj.strokeMat;
292 var fillMaterialName = jObj.fillMat; 290 var fillMaterialName = jObj.fillMat;
293 this.importMaterialsJSON( jObj.materials ); 291 this.importMaterialsJSON( jObj.materials );
294
295 var strokeMat = MaterialsModel.getMaterial( strokeMaterialName );
296 if (!strokeMat) {
297 console.log( "object material not found in library: " + strokeMaterialName );
298 strokeMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() );
299 }
300 else
301 strokeMat = strokeMat.dup();
302 this._strokeMaterial = strokeMat;
303
304 var fillMat = MaterialsModel.getMaterial( fillMaterialName );
305 if (!fillMat) {
306 console.log( "object material not found in library: " + fillMaterialName );
307 fillMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() );
308 }
309 else
310 fillMat = fillMat.dup();
311 this._fillMaterial = fillMat;
312 }; 292 };
313 293
314 this.import = function( importStr ) { 294 this.import = function( importStr ) {
@@ -430,10 +410,10 @@ var Rectangle = function GLRectangle() {
430 brRadius = -z*(r-l)/(2.0*zn)*brRadiusNDC; 410 brRadius = -z*(r-l)/(2.0*zn)*brRadiusNDC;
431 411
432 // stroke 412 // stroke
433// var strokeMaterial = this.makeStrokeMaterial(); 413 var strokeMaterial = this.makeStrokeMaterial();
434// var strokePrim = this.createStroke([x,y], 2*xFill, 2*yFill, strokeSize, tlRadius, blRadius, brRadius, trRadius, strokeMaterial); 414 var strokePrim = this.createStroke([x,y], 2*xFill, 2*yFill, strokeSize, tlRadius, blRadius, brRadius, trRadius, strokeMater