diff options
Diffstat (limited to 'js/lib/drawing')
-rwxr-xr-x | js/lib/drawing/world.js | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/js/lib/drawing/world.js b/js/lib/drawing/world.js index b8bceda6..cffd0083 100755 --- a/js/lib/drawing/world.js +++ b/js/lib/drawing/world.js | |||
@@ -349,7 +349,7 @@ var World = function GLWorld( canvas, use3D ) { | |||
349 | 349 | ||
350 | this.generateUniqueNodeID = function() | 350 | this.generateUniqueNodeID = function() |
351 | { | 351 | { |
352 | var str = String( this._nodeCounter ); | 352 | var str = "" + this._nodeCounter; |
353 | this._nodeCounter++; | 353 | this._nodeCounter++; |
354 | return str; | 354 | return str; |
355 | } | 355 | } |
@@ -727,7 +727,8 @@ World.prototype.getShapeFromPoint = function( offsetX, offsetY ) { | |||
727 | } | 727 | } |
728 | }; | 728 | }; |
729 | 729 | ||
730 | World.prototype.export = function( exportForPublish ) { | 730 | World.prototype.export = function( imagePath ) |
731 | { | ||
731 | var exportStr = "GLWorld 1.0\n"; | 732 | var exportStr = "GLWorld 1.0\n"; |
732 | var id = this.getCanvas().getAttribute( "data-RDGE-id" ); | 733 | var id = this.getCanvas().getAttribute( "data-RDGE-id" ); |
733 | exportStr += "id: " + id + "\n"; | 734 | exportStr += "id: " + id + "\n"; |
@@ -742,9 +743,17 @@ World.prototype.export = function( exportForPublish ) { | |||
742 | // we need 2 export modes: One for save/restore, one for publish. | 743 | // we need 2 export modes: One for save/restore, one for publish. |
743 | // hardcoding for now | 744 | // hardcoding for now |
744 | //var exportForPublish = false; | 745 | //var exportForPublish = false; |
745 | if (!exportForPublish) exportForPublish = false; | 746 | //if (!exportForPublish) exportForPublish = false; |
747 | var exportForPublish = true; | ||
746 | exportStr += "publish: " + exportForPublish + "\n"; | 748 | exportStr += "publish: " + exportForPublish + "\n"; |
747 | 749 | ||
750 | // the relative path for local assets needs to be modified to | ||
751 | // the path specified by argument 'imagePath'. Save that path | ||
752 | // so exporting functions can call newPath = world.cleansePath( oldPath ); | ||
753 | this._imagePath = imagePath.slice(); | ||
754 | var endchar = this._imagePath[this._imagePath.length-1] | ||
755 | if (endchar != '/') this._imagePath += '/'; | ||
756 | |||
748 | if (exportForPublish && this._useWebGL) | 757 | if (exportForPublish && this._useWebGL) |
749 | { | 758 | { |
750 | exportStr += "scenedata: " + this.myScene.exportJSON() + "endscene\n"; | 759 | exportStr += "scenedata: " + this.myScene.exportJSON() + "endscene\n"; |
@@ -928,6 +937,20 @@ World.prototype.importSubObject = function( objStr, parentNode ) { | |||
928 | return trNode; | 937 | return trNode; |
929 | }; | 938 | }; |
930 | 939 | ||
940 | World.prototype.cleansePath = function( url ) | ||
941 | { | ||
942 | //this._imagePath | ||
943 | var searchStr = "assets/"; | ||
944 | var index = url.indexOf( searchStr ); | ||
945 | var rtnPath = url; | ||
946 | if (index >= 0) | ||
947 | { | ||
948 | rtnPath = url.substr( index + searchStr.length ); | ||
949 | rtnPath = this._imagePath + rtnPath; | ||
950 | } | ||
951 | return rtnPath; | ||
952 | } | ||
953 | |||
931 | if (typeof exports === "object") { | 954 | if (typeof exports === "object") { |
932 | exports.World = World; | 955 | exports.World = World; |
933 | } \ No newline at end of file | 956 | } \ No newline at end of file |