aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rwxr-xr-xjs/document/html-document.js6
-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
-rwxr-xr-xjs/models/materials-model.js4
13 files changed, 116 insertions, 80 deletions
diff --git a/js/document/html-document.js b/js/document/html-document.js
index bb54874c..8b765501 100755
--- a/js/document/html-document.js
+++ b/js/document/html-document.js
@@ -291,7 +291,7 @@ exports.HTMLDocument = Montage.create(TextDocument, {
291 shapeModel.GLGeomObj = root; 291 shapeModel.GLGeomObj = root;
292 shapeModel.strokeSize = root._strokeWidth; 292 shapeModel.strokeSize = root._strokeWidth;
293 shapeModel.stroke = root._strokeColor.slice(); 293 shapeModel.stroke = root._strokeColor.slice();
294 shapeModel.strokeMaterial = root._strokeMaterial.dup(); 294 shapeModel.strokeMaterial = root._strikeMaterial ? root._strokeMaterial.dup() : null;
295 shapeModel.strokeStyle = "solid"; 295 shapeModel.strokeStyle = "solid";
296 //shapeModel.strokeStyleIndex 296 //shapeModel.strokeStyleIndex
297 //shapeModel.border 297 //shapeModel.border
@@ -302,7 +302,7 @@ exports.HTMLDocument = Montage.create(TextDocument, {
302 elementModel.selection = "Rectangle"; 302 elementModel.selection = "Rectangle";
303 elementModel.pi = "RectanglePi"; 303 elementModel.pi = "RectanglePi";
304 shapeModel.fill = root._fillColor.slice(); 304 shapeModel.fill = root._fillColor.slice();
305 shapeModel.fillMaterial = root._fillMaterial.dup(); 305 shapeModel.fillMaterial = root._fillMaterial ? root._fillMaterial.dup() : null;
306 shapeModel.tlRadius = root._tlRadius; 306 shapeModel.tlRadius = root._tlRadius;
307 shapeModel.trRadius = root._trRadius; 307 shapeModel.trRadius = root._trRadius;
308 shapeModel.blRadius = root._blRadius; 308 shapeModel.blRadius = root._blRadius;
@@ -313,7 +313,7 @@ exports.HTMLDocument = Montage.create(TextDocument, {
313 elementModel.selection = "Oval"; 313 elementModel.selection = "Oval";
314 elementModel.pi = "OvalPi"; 314 elementModel.pi = "OvalPi";
315 shapeModel.fill = root._fillColor.slice(); 315 shapeModel.fill = root._fillColor.slice();
316 shapeModel.fillMaterial = root._fillMaterial.dup(); 316 shapeModel.fillMaterial = root._fillMaterial ? root._fillMaterial.dup() : null;
317 shapeModel.innerRadius = root._innerRadius; 317 shapeModel.innerRadius = root._innerRadius;
318 break; 318 break;
319 319
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 {