aboutsummaryrefslogtreecommitdiff
path: root/js/lib
diff options
context:
space:
mode:
Diffstat (limited to 'js/lib')
-rwxr-xr-xjs/lib/drawing/world.js400
-rwxr-xr-xjs/lib/geom/brush-stroke.js12
-rwxr-xr-xjs/lib/geom/circle.js94
-rwxr-xr-xjs/lib/geom/geom-obj.js442
-rwxr-xr-xjs/lib/geom/line.js70
-rwxr-xr-xjs/lib/geom/rectangle.js110
-rwxr-xr-xjs/lib/rdge/materials/bump-metal-material.js54
-rw-r--r--js/lib/rdge/materials/cloud-material.js41
-rwxr-xr-xjs/lib/rdge/materials/flat-material.js28
-rwxr-xr-xjs/lib/rdge/materials/linear-gradient-material.js63
-rwxr-xr-xjs/lib/rdge/materials/material.js15
-rw-r--r--js/lib/rdge/materials/pulse-material.js42
-rw-r--r--js/lib/rdge/materials/radial-blur-material.js38
-rwxr-xr-xjs/lib/rdge/materials/radial-gradient-material.js59
-rw-r--r--js/lib/rdge/materials/taper-material.js38
-rw-r--r--js/lib/rdge/materials/twist-vert-material.js38
-rwxr-xr-xjs/lib/rdge/materials/uber-material.js187
17 files changed, 282 insertions, 1449 deletions
diff --git a/js/lib/drawing/world.js b/js/lib/drawing/world.js
index 801c199a..ae8c2cce 100755
--- a/js/lib/drawing/world.js
+++ b/js/lib/drawing/world.js
@@ -435,38 +435,38 @@ World.prototype.updateObject = function (obj) {
435 } 435 }
436}; 436};
437 437
438World.prototype.addObject = function( obj ) { 438World.prototype.addObject = function (obj) {
439 if (!obj) return; 439 if (!obj) return;
440 440
441 try { 441 try {
442 // undefine all the links of the object 442 // undefine all the links of the object
443 obj.setChild( undefined ); 443 obj.setChild(undefined);
444 obj.setNext( undefined ); 444 obj.setNext(undefined);
445 obj.setPrev( undefined ); 445 obj.setPrev(undefined);
446 obj.setParent( undefined ); 446 obj.setParent(undefined);
447 447
448 obj.setWorld( this ); 448 obj.setWorld(this);
449 449
450 if (this._geomRoot == null) { 450 if (this._geomRoot == null) {
451 this._geomRoot = obj; 451 this._geomRoot = obj;
452 } else { 452 } else {
453 var go = this._geomRoot; 453 var go = this._geomRoot;
454 while (go.getNext()) go = go.getNext(); 454 while (go.getNext()) go = go.getNext();
455 go.setNext( obj ); 455 go.setNext(obj);
456 obj.setPrev( go ); 456 obj.setPrev(go);
457 } 457 }
458 458
459 // build the WebGL buffers 459 // build the WebGL buffers
460 if (this._useWebGL) { 460 if (this._useWebGL) {
461 obj.buildBuffers(); 461 obj.buildBuffers();
462 this.restartRenderLoop(); 462 this.restartRenderLoop();
463 } 463 }
464 } 464 }
465 465
466 catch(e) { 466 catch (e) {
467 alert( "Exception in GLWorld.addObject " + e ); 467 alert("Exception in GLWorld.addObject " + e);
468 } 468 }
469} 469};
470 470
471World.prototype.restartRenderLoop = function() { 471World.prototype.restartRenderLoop = function() {
472 //console.log( "restartRenderLoop" ); 472 //console.log( "restartRenderLoop" );
@@ -734,146 +734,76 @@ World.prototype.getShapeFromPoint = function( offsetX, offsetY ) {
734 734
735 735
736 736
737World.prototype.exportJSON = function() 737World.prototype.exportJSON = function () {
738{ 738 // world properties
739 // world properties 739 var worldObj =
740 var worldObj =
741 { 740 {
742 'version' : 1.1, 741 'version': 1.1,
743 'id' : this.getCanvas().getAttribute( "data-RDGE-id" ), 742 'id': this.getCanvas().getAttribute("data-RDGE-id"),
744 'fov' : this._fov, 743 'fov': this._fov,
745 'zNear' : this._zNear, 744 'zNear': this._zNear,
746 'zFar' : this._zFar, 745 'zFar': this._zFar,
747 'viewDist' : this._viewDist, 746 'viewDist': this._viewDist,
748 'webGL' : this._useWebGL 747 'webGL': this._useWebGL
749 }; 748 };
750 749
751 // RDGE scenegraph 750 // RDGE scenegraph
752 if (this._useWebGL) 751 if (this._useWebGL)
753 worldObj.scenedata = this.myScene.exportJSON(); 752 worldObj.scenedata = this.myScene.exportJSON();
754 753
755 // object data 754 // object data
756 var strArray = []; 755 var strArray = [];
757 this.exportObjectsJSON( this._geomRoot, worldObj ); 756 this.exportObjectsJSON(this._geomRoot, worldObj);
758 757
759 // You would think that the RDGE export function 758 // You would think that the RDGE export function
760 // would not be destructive of the data. You would be wrong... 759 // would not be destructive of the data. You would be wrong...
761 // We need to rebuild everything 760 // We need to rebuild everything
762 if (this._useWebGL) 761 if (this._useWebGL) {
763 { 762 if (worldObj.children && (worldObj.children.length === 1)) {
764 if (worldObj.children && (worldObj.children.length === 1))
765 {
766 this.rebuildTree(this._geomRoot); 763 this.rebuildTree(this._geomRoot);
767 this.restartRenderLoop(); 764 this.restartRenderLoop();
768 } 765 }
769 }
770
771 // convert the object to a string
772 var jStr = JSON.stringify( worldObj );
773
774 // prepend some version information to the string.
775 // this string is also used to differentiate between JSON
776 // and pre-JSON versions of fileIO.
777 // the ending ';' in the version string is necessary
778 jStr = "v1.0;" + jStr;
779
780 return jStr;
781}
782
783World.prototype.rebuildTree = function( obj )
784{
785 if (!obj) return;
786
787 obj.buildBuffers();
788
789 if (obj.getChild()) {
790 this.rebuildTree( obj.getChild () );
791 } 766 }
792 767
793 if (obj.getNext()) 768 // convert the object to a string
794 this.rebuildTree( obj.getNext() ); 769 var jStr = JSON.stringify(worldObj);
795}
796
797World.prototype.exportObjectsJSON = function( obj, parentObj )
798{
799 if (!obj) return;
800
801 var jObj = obj.exportJSON();
802 if (!parentObj.children) parentObj.children = [];
803 parentObj.children.push( jObj );
804 770
805 if (obj.getChild()) { 771 // prepend some version information to the string.
806 this.exportObjectsJSON( obj.getChild (), jObj ); 772 // this string is also used to differentiate between JSON
807 } 773 // and pre-JSON versions of fileIO.
774 // the ending ';' in the version string is necessary
775 jStr = "v1.0;" + jStr;
808 776
809 if (obj.getNext()) 777 return jStr;
810 this.exportObjectsJSON( obj.getNext(), parentObj ); 778};
811}
812 779
813/* 780World.prototype.rebuildTree = function (obj) {
814World.prototype.export = function() 781 if (!obj) return;
815{
816 var exportStr = "GLWorld 1.0\n";
817 var id = this.getCanvas().getAttribute( "data-RDGE-id" );
818 exportStr += "id: " + id + "\n";
819 //exportStr += "id: " + this._canvas.rdgeid + "\n";
820 exportStr += "fov: " + this._fov + "\n";
821 exportStr += "zNear: " + this._zNear + "\n";
822 exportStr += "zFar: " + this._zFar + "\n";
823 exportStr += "viewDist: " + this._viewDist + "\n";
824 if (this._useWebGL)
825 exportStr += "webGL: true\n";
826
827 // we need 2 export modes: One for save/restore, one for publish.
828 // hardcoding for now
829 //var exportForPublish = false;
830 //if (!exportForPublish) exportForPublish = false;
831 var exportForPublish = true;
832 exportStr += "publish: " + exportForPublish + "\n";
833
834 if (exportForPublish && this._useWebGL)
835 {
836 exportStr += "scenedata: " + this.myScene.exportJSON() + "endscene\n";
837 782
838 // write out all of the objects 783 obj.buildBuffers();
839 exportStr += "tree\n";
840 exportStr += this.exportObjects( this._geomRoot );
841 exportStr += "endtree\n";
842 }
843 else
844 {
845 // output the material library
846 //exportStr += MaterialsLibrary.export(); // THIS NEEDS TO BE DONE AT THE DOC LEVEL
847 784
848 // write out all of the objects 785 if (obj.getChild()) {
849 exportStr += "tree\n"; 786 this.rebuildTree(obj.getChild());
850 exportStr += this.exportObjects( this._geomRoot ); 787 }
851 exportStr += "endtree\n";
852 }
853 788
854 return exportStr; 789 if (obj.getNext())
790 this.rebuildTree(obj.getNext());