aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rwxr-xr-xjs/document/html-document.js73
-rwxr-xr-xjs/lib/drawing/world.js29
-rwxr-xr-xjs/lib/geom/circle.js5
-rwxr-xr-xjs/lib/geom/geom-obj.js42
-rwxr-xr-xjs/lib/geom/rectangle.js5
-rwxr-xr-xjs/lib/rdge/materials/bump-metal-material.js10
-rw-r--r--js/lib/rdge/materials/pulse-material.js8
-rw-r--r--js/lib/rdge/materials/radial-blur-material.js6
-rw-r--r--js/lib/rdge/materials/taper-material.js2
-rwxr-xr-xjs/lib/rdge/materials/uber-material.js46
-rw-r--r--js/lib/rdge/runtime/CanvasDataManager.js83
-rw-r--r--js/lib/rdge/runtime/CanvasRuntime.js1338
-rw-r--r--js/lib/rdge/runtime/GLRuntime.js357
-rw-r--r--js/lib/rdge/runtime/RuntimeGeomObj.js633
-rw-r--r--js/lib/rdge/runtime/RuntimeMaterial.js351
15 files changed, 1519 insertions, 1469 deletions
diff --git a/js/document/html-document.js b/js/document/html-document.js
index 0dc26884..b9944d66 100755
--- a/js/document/html-document.js
+++ b/js/document/html-document.js
@@ -9,7 +9,6 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
9var Montage = require("montage/core/core").Montage, 9var Montage = require("montage/core/core").Montage,
10 TextDocument = require("js/document/text-document").TextDocument, 10 TextDocument = require("js/document/text-document").TextDocument,
11 NJUtils = require("js/lib/NJUtils").NJUtils, 11 NJUtils = require("js/lib/NJUtils").NJUtils,
12 CanvasDataManager = require("js/lib/rdge/runtime/CanvasDataManager").CanvasDataManager,
13 GLWorld = require("js/lib/drawing/world").World; 12 GLWorld = require("js/lib/drawing/world").World;
14//////////////////////////////////////////////////////////////////////// 13////////////////////////////////////////////////////////////////////////
15// 14//
@@ -195,9 +194,9 @@ exports.HTMLDocument = Montage.create(TextDocument, {
195 this._glData = null; 194 this._glData = null;
196 if (elt) 195 if (elt)
197 { 196 {
198 var cdm = new CanvasDataManager();
199 this._glData = []; 197 this._glData = [];
200 cdm.collectGLData( elt, this._glData ); 198 var path = "assets/";
199 this.collectGLData( elt, this._glData, path );
201 } 200 }
202 201
203 return this._glData; 202 return this._glData;
@@ -208,29 +207,47 @@ exports.HTMLDocument = Montage.create(TextDocument, {
208 var elt = this.documentRoot; 207 var elt = this.documentRoot;
209 if (elt) 208 if (elt)
210 { 209 {
211 var nWorlds= value.length; 210// var loadForRuntime = false;
212 for (var i=0; i<nWorlds; i++) { 211// if (loadForRuntime)
213 var importStr = value[i]; 212// {
214 var startIndex = importStr.indexOf("id: "); 213// var cdm = new CanvasDataManager();
215 if (startIndex >= 0) { 214// cdm.loadGLData(elt, value );
216 var endIndex = importStr.indexOf("\n", startIndex); 215// }
217 if (endIndex > 0) { 216// else
218 var id = importStr.substring( startIndex+4, endIndex); 217 {
219 if (id) { 218 var nWorlds= value.length;
220 var canvas = this.findCanvasWithID(id, elt); 219 for (var i=0; i<nWorlds; i++)
221 if (canvas) { 220 {
222 if (!canvas.elementModel) { 221 var importStr = value[i];
223 NJUtils.makeElementModel(canvas, "Canvas", "shape", true); 222 var startIndex = importStr.indexOf( "id: " );
224 } 223 if (startIndex >= 0)
225 if (canvas.elementModel) { 224 {
226 if (canvas.elementModel.shapeModel.GLWorld) { 225 var endIndex = importStr.indexOf( "\n", startIndex );
227 canvas.elementModel.shapeModel.GLWorld.clearTree(); 226 if (endIndex > 0)
227 {
228 var id = importStr.substring( startIndex+4, endIndex );
229 if (id)
230 {
231 var canvas = this.findCanvasWithID( id, elt );
232 if (canvas)
233 {
234 if (!canvas.elementModel)
235 {
236 NJUtils.makeElementModel(canvas, "Canvas", "shape", true);
237 }
238
239 if (canvas.elementModel)
240 {
241 if (canvas.elementModel.shapeModel.GLWorld)
242 canvas.elementModel.shapeModel.GLWorld.clearTree();
243
244 var index = importStr.indexOf( "webGL: " );
245 var useWebGL = (index >= 0)
246 var world = new GLWorld( canvas, useWebGL );
247 world.import( importStr );
248
249 this.buildShapeModel( canvas.elementModel, world );
228 } 250 }
229 var index = importStr.indexOf( "webGL: " );
230 var useWebGL = (index >= 0)
231 var world = new GLWorld(canvas, useWebGL);
232 world.import( importStr );
233 this.buildShapeModel(canvas.elementModel, world);
234 } 251 }
235 } 252 }
236 } 253 }
@@ -368,11 +385,11 @@ exports.HTMLDocument = Montage.create(TextDocument, {
368 385
369 386
370 collectGLData: { 387 collectGLData: {
371 value: function( elt, dataArray ) 388 value: function( elt, dataArray, imagePath )
372 { 389 {
373 if (elt.elementModel && elt.elementModel.shapeModel && elt.elementModel.shapeModel.GLWorld) 390 if (elt.elementModel && elt.elementModel.shapeModel && elt.elementModel.shapeModel.GLWorld)
374 { 391 {
375 var data = elt.elementModel.shapeModel.GLWorld.export(); 392 var data = elt.elementModel.shapeModel.GLWorld.export( imagePath );
376 dataArray.push( data ); 393 dataArray.push( data );
377 } 394 }
378 395
@@ -382,7 +399,7 @@ exports.HTMLDocument = Montage.create(TextDocument, {
382 for (var i=0; i<nKids; i++) 399 for (var i=0; i<nKids; i++)
383 { 400 {
384 var child = elt.children[i]; 401 var child = elt.children[i];
385 this.collectGLData( child, dataArray ); 402 this.collectGLData( child, dataArray, imagePath );
386 } 403 }
387 } 404 }
388 } 405 }
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
730World.prototype.export = function( exportForPublish ) { 730World.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
940World.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
931if (typeof exports === "object") { 954if (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
diff --git a/js/lib/geom/circle.js b/js/lib/geom/circle.js
index ad77383b..f94d4e6b 100755
--- a/js/lib/geom/circle.js
+++ b/js/lib/geom/circle.js
@@ -61,6 +61,8 @@ var Circle = function GLCircle() {
61 } else { 61