diff options
-rwxr-xr-x | js/document/html-document.js | 15 | ||||
-rwxr-xr-x | js/lib/drawing/world.js | 29 | ||||
-rwxr-xr-x | js/lib/geom/circle.js | 5 | ||||
-rwxr-xr-x | js/lib/geom/geom-obj.js | 42 | ||||
-rwxr-xr-x | js/lib/geom/rectangle.js | 5 | ||||
-rwxr-xr-x | js/lib/rdge/materials/bump-metal-material.js | 10 | ||||
-rw-r--r-- | js/lib/rdge/materials/pulse-material.js | 8 | ||||
-rw-r--r-- | js/lib/rdge/materials/radial-blur-material.js | 6 | ||||
-rw-r--r-- | js/lib/rdge/materials/taper-material.js | 2 | ||||
-rwxr-xr-x | js/lib/rdge/materials/uber-material.js | 46 | ||||
-rw-r--r-- | js/lib/rdge/runtime/CanvasDataManager.js | 83 | ||||
-rw-r--r-- | js/lib/rdge/runtime/CanvasRuntime.js | 1338 | ||||
-rw-r--r-- | js/lib/rdge/runtime/GLRuntime.js | 357 | ||||
-rw-r--r-- | js/lib/rdge/runtime/RuntimeGeomObj.js | 633 | ||||
-rw-r--r-- | js/lib/rdge/runtime/RuntimeMaterial.js | 351 |
15 files changed, 1480 insertions, 1450 deletions
diff --git a/js/document/html-document.js b/js/document/html-document.js index 078a73b5..b2113623 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 | |||
9 | var Montage = require("montage/core/core").Montage, | 9 | var 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 | // |
@@ -174,9 +173,9 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
174 | this._glData = null; | 173 | this._glData = null; |
175 | if (elt) | 174 | if (elt) |
176 | { | 175 | { |
177 | var cdm = new CanvasDataManager(); | ||
178 | this._glData = []; | 176 | this._glData = []; |
179 | cdm.collectGLData( elt, this._glData ); | 177 | var path = "assets/"; |
178 | this.collectGLData( elt, this._glData, path ); | ||
180 | } | 179 | } |
181 | 180 | ||
182 | return this._glData; | 181 | return this._glData; |
@@ -187,9 +186,7 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
187 | var elt = this.documentRoot; | 186 | var elt = this.documentRoot; |
188 | if (elt) | 187 | if (elt) |
189 | { | 188 | { |
190 | // FOR JOSE: The following commented out lines are what the runtime | 189 | // var loadForRuntime = false; |
191 | // version should execute. | ||
192 | // var loadForRuntime = true; | ||
193 | // if (loadForRuntime) | 190 | // if (loadForRuntime) |
194 | // { | 191 | // { |
195 | // var cdm = new CanvasDataManager(); | 192 | // var cdm = new CanvasDataManager(); |
@@ -367,11 +364,11 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
367 | 364 | ||
368 | 365 | ||
369 | collectGLData: { | 366 | collectGLData: { |
370 | value: function( elt, dataArray ) | 367 | value: function( elt, dataArray, imagePath ) |
371 | { | 368 | { |
372 | if (elt.elementModel && elt.elementModel.shapeModel && elt.elementModel.shapeModel.GLWorld) | 369 | if (elt.elementModel && elt.elementModel.shapeModel && elt.elementModel.shapeModel.GLWorld) |
373 | { | 370 | { |
374 | var data = elt.elementModel.shapeModel.GLWorld.export(); | 371 | var data = elt.elementModel.shapeModel.GLWorld.export( imagePath ); |
375 | dataArray.push( data ); | 372 | dataArray.push( data ); |
376 | } | 373 | } |
377 | 374 | ||
@@ -381,7 +378,7 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
381 | for (var i=0; i<nKids; i++) | 378 | for (var i=0; i<nKids; i++) |
382 | { | 379 | { |
383 | var child = elt.children[i]; | 380 | var child = elt.children[i]; |
384 | this.collectGLData( child, dataArray ); | 381 | this.collectGLData( child, dataArray, imagePath ); |
385 | } | 382 | } |
386 | } | 383 | } |
387 | } | 384 | } |
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 |
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 | } else { |
62 | this._fillMaterial = MaterialsModel.exportFlatMaterial(); | 62 | this._fillMaterial = MaterialsModel.exportFlatMaterial(); |
63 | } | 63 | } |
64 | |||
65 | this.exportMaterials(); | ||
64 | }; | 66 | }; |
65 | 67 | ||
66 | /////////////////////////////////////////////////////////////////////// | 68 | /////////////////////////////////////////////////////////////////////// |
@@ -610,8 +612,9 @@ var Circle = function GLCircle() { | |||
610 | console.log( "object material not found in library: " + fillMaterialName ); | 612 | console.log( "object material not found in library: " + fillMaterialName ); |
611 | fillMat = MaterialsModel.exportFlatMaterial(); | 613 | fillMat = MaterialsModel.exportFlatMaterial(); |
612 | } | 614 | } |
613 | |||
614 | this._fillMaterial = fillMat; | 615 | this._fillMaterial = fillMat; |
616 | |||
617 | this.importMaterials( importStr ); | ||
615 | }; | 618 | }; |
616 | 619 | ||
617 | this.collidesWithPoint = function( x, y ) { | 620 | this.collidesWithPoint = function( x, y ) { |
diff --git a/js/lib/geom/geom-obj.js b/js/lib/geom/geom-obj.js index 852aab89..1a197832 100755 --- a/js/lib/geom/geom-obj.js +++ b/js/lib/geom/geom-obj.js | |||
@@ -5,6 +5,27 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot | |||
5 | </copyright> */ | 5 | </copyright> */ |
6 | 6 | ||
7 | var MaterialsModel = require("js/models/materials-model").MaterialsModel; | 7 | var MaterialsModel = require("js/models/materials-model").MaterialsModel; |
8 | var FlatMaterial = require("js/lib/rdge/materials/flat-material").FlatMaterial; | ||
9 | var LinearGradientMaterial = require("js/lib/rdge/materials/linear-gradient-material").LinearGradientMaterial; | ||
10 | var RadialGradientMaterial = require("js/lib/rdge/materials/radial-gradient-material").RadialGradientMaterial; | ||
11 | var BumpMetalMaterial = require("js/lib/rdge/materials/bump-metal-material").BumpMetalMaterial; | ||
12 | var UberMaterial = require("js/lib/rdge/materials/uber-material").UberMaterial; | ||
13 | var RadialBlurMaterial = require("js/lib/rdge/materials/radial-blur-material").RadialBlurMaterial; | ||
14 | var PlasmaMaterial = require("js/lib/rdge/materials/plasma-material").PlasmaMaterial; | ||
15 | var PulseMaterial = require("js/lib/rdge/materials/pulse-material").PulseMaterial; | ||
16 | var TunnelMaterial = require("js/lib/rdge/materials/tunnel-material").TunnelMaterial; | ||
17 | var ReliefTunnelMaterial = require("js/lib/rdge/materials/relief-tunnel-material").ReliefTunnelMaterial; | ||
18 | var SquareTunnelMaterial = require("js/lib/rdge/materials/square-tunnel-material").SquareTunnelMaterial; | ||
19 | var FlyMaterial = require("js/lib/rdge/materials/fly-material").FlyMaterial; | ||
20 | var WaterMaterial = require("js/lib/rdge/materials/water-material").WaterMaterial; | ||
21 | var ZInvertMaterial = require("js/lib/rdge/materials/z-invert-material").ZInvertMaterial; | ||
22 | var DeformMaterial = require("js/lib/rdge/materials/deform-material").DeformMaterial; | ||
23 | var StarMaterial = require("js/lib/rdge/materials/star-material").StarMaterial; | ||
24 | var TwistMaterial = require("js/lib/rdge/materials/twist-material").TwistMaterial; | ||
25 | var JuliaMaterial = require("js/lib/rdge/materials/julia-material").JuliaMaterial; | ||
26 | var KeleidoscopeMaterial = require("js/lib/rdge/materials/keleidoscope-material").KeleidoscopeMaterial; | ||
27 | var MandelMaterial = require("js/lib/rdge/materials/mandel-material").MandelMaterial; | ||
28 | |||
8 | /////////////////////////////////////////////////////////////////////// | 29 | /////////////////////////////////////////////////////////////////////// |
9 | // Class GLGeomObj | 30 | // Class GLGeomObj |
10 | // Super class for all geometry classes | 31 | // Super class for all geometry classes |
@@ -235,7 +256,26 @@ var GeomObj = function GLGeomObj() { | |||
235 | var materialType = this.getPropertyFromString( "material: ", importStr ); | 256 | var materialType = this.getPropertyFromString( "material: ", importStr ); |
236 | switch (materialType) | 257 | switch (materialType) |
237 | { | 258 | { |
238 | case "flat": mat = new FlatMaterial(); break; | 259 | case "flat": mat = new FlatMaterial(); break; |