From 7b6e8194b91168abdeb94702eb350d14f147858b Mon Sep 17 00:00:00 2001 From: hwc487 Date: Thu, 8 Mar 2012 17:29:18 -0800 Subject: Canvas IO --- js/lib/drawing/world.js | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'js/lib/drawing') 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 ) { this.generateUniqueNodeID = function() { - var str = String( this._nodeCounter ); + var str = "" + this._nodeCounter; this._nodeCounter++; return str; } @@ -727,7 +727,8 @@ World.prototype.getShapeFromPoint = function( offsetX, offsetY ) { } }; -World.prototype.export = function( exportForPublish ) { +World.prototype.export = function( imagePath ) +{ var exportStr = "GLWorld 1.0\n"; var id = this.getCanvas().getAttribute( "data-RDGE-id" ); exportStr += "id: " + id + "\n"; @@ -742,9 +743,17 @@ World.prototype.export = function( exportForPublish ) { // we need 2 export modes: One for save/restore, one for publish. // hardcoding for now //var exportForPublish = false; - if (!exportForPublish) exportForPublish = false; + //if (!exportForPublish) exportForPublish = false; + var exportForPublish = true; exportStr += "publish: " + exportForPublish + "\n"; + // the relative path for local assets needs to be modified to + // the path specified by argument 'imagePath'. Save that path + // so exporting functions can call newPath = world.cleansePath( oldPath ); + this._imagePath = imagePath.slice(); + var endchar = this._imagePath[this._imagePath.length-1] + if (endchar != '/') this._imagePath += '/'; + if (exportForPublish && this._useWebGL) { exportStr += "scenedata: " + this.myScene.exportJSON() + "endscene\n"; @@ -928,6 +937,20 @@ World.prototype.importSubObject = function( objStr, parentNode ) { return trNode; }; +World.prototype.cleansePath = function( url ) +{ + //this._imagePath + var searchStr = "assets/"; + var index = url.indexOf( searchStr ); + var rtnPath = url; + if (index >= 0) + { + rtnPath = url.substr( index + searchStr.length ); + rtnPath = this._imagePath + rtnPath; + } + return rtnPath; +} + if (typeof exports === "object") { exports.World = World; } \ No newline at end of file -- cgit v1.2.3