diff options
author | Eric Guzman | 2012-03-29 16:29:04 -0700 |
---|---|---|
committer | Eric Guzman | 2012-03-29 16:29:04 -0700 |
commit | ccd57d8610a7839cf14b2c9e354b64acf53093a7 (patch) | |
tree | f11b4418483fd21831b72ca6dc0451422a25bfe2 /js/lib/drawing | |
parent | 7aefa059c79c9bef5c7a8a93cdfbd1ce55f69118 (diff) | |
parent | f4949cab544886702e7ad6eeaa6215125c7b067a (diff) | |
download | ninja-ccd57d8610a7839cf14b2c9e354b64acf53093a7.tar.gz |
Merge branch 'refs/heads/master' into PresetsPI
Diffstat (limited to 'js/lib/drawing')
-rwxr-xr-x | js/lib/drawing/world.js | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/js/lib/drawing/world.js b/js/lib/drawing/world.js index 781695b6..5a054224 100755 --- a/js/lib/drawing/world.js +++ b/js/lib/drawing/world.js | |||
@@ -761,13 +761,10 @@ World.prototype.exportJSON = function() | |||
761 | // We need to rebuild everything | 761 | // We need to rebuild everything |
762 | if (this._useWebGL) | 762 | if (this._useWebGL) |
763 | { | 763 | { |
764 | var root = this._rootNode; | ||
765 | root.children = new Array(); | ||
766 | if (worldObj.children && (worldObj.children.length === 1)) | 764 | if (worldObj.children && (worldObj.children.length === 1)) |
767 | { | 765 | { |
768 | this.init(); | 766 | this.rebuildTree(this._geomRoot); |
769 | this._geomRoot = undefined; | 767 | this.restartRenderLoop(); |
770 | this.importObjectsJSON( worldObj.children[0] ); | ||
771 | } | 768 | } |
772 | } | 769 | } |
773 | 770 | ||
@@ -783,6 +780,20 @@ World.prototype.exportJSON = function() | |||
783 | return jStr; | 780 | return jStr; |
784 | } | 781 | } |
785 | 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 | } | ||
792 | |||
793 | if (obj.getNext()) | ||
794 | this.rebuildTree( obj.getNext() ); | ||
795 | } | ||
796 | |||
786 | World.prototype.exportObjectsJSON = function( obj, parentObj ) | 797 | World.prototype.exportObjectsJSON = function( obj, parentObj ) |
787 | { | 798 | { |
788 | if (!obj) return; | 799 | if (!obj) return; |
@@ -931,6 +942,7 @@ World.prototype.importObjectsJSON = function( jObj, parentGeomObj ) | |||
931 | World.prototype.importObjectJSON = function( jObj, parentGeomObj ) | 942 | World.prototype.importObjectJSON = function( jObj, parentGeomObj ) |
932 | { | 943 | { |
933 | var type = jObj.type; | 944 | var type = jObj.type; |
945 | var BrushStroke = require("js/lib/geom/brush-stroke").BrushStroke; | ||
934 | 946 | ||
935 | var obj; | 947 | var obj; |
936 | switch (type) | 948 | switch (type) |
@@ -950,6 +962,11 @@ World.prototype.importObjectJSON = function( jObj, parentGeomObj ) | |||
950 | obj.importJSON( jObj ); | 962 | obj.importJSON( jObj ); |
951 | break; | 963 | break; |
952 | 964 | ||
965 | case 6: //brush stroke | ||
966 | obj = new BrushStroke(); | ||
967 | obj.importJSON(jObj); | ||
968 | break; | ||
969 | |||
953 | default: | 970 | default: |
954 | throw new Error( "Unrecognized object type: " + type ); | 971 | throw new Error( "Unrecognized object type: " + type ); |
955 | break; | 972 | break; |