diff options
Diffstat (limited to 'js')
-rwxr-xr-x | js/document/html-document.js | 8 | ||||
-rwxr-xr-x | js/lib/drawing/world.js | 400 | ||||
-rwxr-xr-x | js/lib/geom/brush-stroke.js | 12 | ||||
-rwxr-xr-x | js/lib/geom/circle.js | 94 | ||||
-rwxr-xr-x | js/lib/geom/geom-obj.js | 442 | ||||
-rwxr-xr-x | js/lib/geom/line.js | 70 | ||||
-rwxr-xr-x | js/lib/geom/rectangle.js | 110 | ||||
-rwxr-xr-x | js/lib/rdge/materials/bump-metal-material.js | 54 | ||||
-rw-r--r-- | js/lib/rdge/materials/cloud-material.js | 41 | ||||
-rwxr-xr-x | js/lib/rdge/materials/flat-material.js | 28 | ||||
-rwxr-xr-x | js/lib/rdge/materials/linear-gradient-material.js | 63 | ||||
-rwxr-xr-x | js/lib/rdge/materials/material.js | 15 | ||||
-rw-r--r-- | js/lib/rdge/materials/pulse-material.js | 42 | ||||
-rw-r--r-- | js/lib/rdge/materials/radial-blur-material.js | 38 | ||||
-rwxr-xr-x | js/lib/rdge/materials/radial-gradient-material.js | 59 | ||||
-rw-r--r-- | js/lib/rdge/materials/taper-material.js | 38 | ||||
-rw-r--r-- | js/lib/rdge/materials/twist-vert-material.js | 38 | ||||
-rwxr-xr-x | js/lib/rdge/materials/uber-material.js | 187 |
18 files changed, 282 insertions, 1457 deletions
diff --git a/js/document/html-document.js b/js/document/html-document.js index c9887b88..953f909c 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js | |||
@@ -276,13 +276,6 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
276 | var world = new GLWorld( canvas, useWebGL ); | 276 | var world = new GLWorld( canvas, useWebGL ); |
277 | world.importJSON( jObj ); | 277 | world.importJSON( jObj ); |
278 | } | 278 | } |
279 | else | ||
280 | { | ||
281 | var index = importStr.indexOf( "webGL: " ); | ||
282 | var useWebGL = (index >= 0); | ||
283 | var world = new GLWorld( canvas, useWebGL ); | ||
284 | world.import( importStr ); | ||
285 | } | ||
286 | 279 | ||
287 | this.buildShapeModel( canvas.elementModel, world ); | 280 | this.buildShapeModel( canvas.elementModel, world ); |
288 | } | 281 | } |
@@ -432,7 +425,6 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
432 | if (elt.elementModel && elt.elementModel.shapeModel && elt.elementModel.shapeModel.GLWorld) | 425 | if (elt.elementModel && elt.elementModel.shapeModel && elt.elementModel.shapeModel.GLWorld) |
433 | { | 426 | { |
434 | var data = elt.elementModel.shapeModel.GLWorld.exportJSON(); | 427 | var data = elt.elementModel.shapeModel.GLWorld.exportJSON(); |
435 | //var data = elt.elementModel.shapeModel.GLWorld.export(); | ||
436 | dataArray.push( data ); | 428 | dataArray.push( data ); |
437 | } | 429 | } |
438 | 430 | ||
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 | ||
438 | World.prototype.addObject = function( obj ) { | 438 | World.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 | ||
471 | World.prototype.restartRenderLoop = function() { | 471 | World.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 | ||
737 | World.prototype.exportJSON = function() | 737 | World.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 | |||
783 | World.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 | |||
797 | World.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 | /* | 780 | World.prototype.rebuildTree = function (obj) { |
814 | World.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; |