diff options
Diffstat (limited to 'js/lib')
-rwxr-xr-x | js/lib/drawing/world.js | 8 | ||||
-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 | 6 | ||||
-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/GLRuntime.js | 357 | ||||
-rw-r--r-- | js/lib/rdge/runtime/RuntimeGeomObj.js | 633 | ||||
-rw-r--r-- | js/lib/rdge/runtime/RuntimeMaterial.js | 351 |
13 files changed, 113 insertions, 1439 deletions
diff --git a/js/lib/drawing/world.js b/js/lib/drawing/world.js index b8bceda6..44c9e37d 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() |
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,7 +743,8 @@ 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 | ||
748 | if (exportForPublish && this._useWebGL) | 750 | if (exportForPublish && this._useWebGL) |
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; |
260 | case "radialGradient": mat = new RadialGradientMaterial(); break; | ||
261 | case "linearGradient": mat = new LinearGradientMaterial(); break; | ||
262 | case "bumpMetal": mat = new BumpMetalMaterial(); break; | ||
263 | case "uber": mat = new UberMaterial(); break; | ||
264 | case "plasma": mat = new PlasmaMaterial(); break; | ||
265 | case "deform": mat = new DeformMaterial(); break; | ||
266 | case "water": mat = new WaterMaterial(); break; | ||
267 | case "tunnel": mat = new TunnelMaterial(); break; | ||
268 | case "reliefTunnel": mat = new ReliefTunnelMaterial(); break; | ||
269 | case "squareTunnel": mat = new SquareTunnelMaterial(); break; | ||
270 | case "twist": mat = new TwiseMaterial(); break; | ||
271 | case "fly": mat = new FlyMaterial(); break; | ||
272 | case "julia": mat = new JuliaMaterial(); break; | ||
273 | case "mandel": mat = new MandelMaterial(); break; | ||
274 | case "star": mat = new StarMaterial(); break; | ||
275 | case "zinvert": mat = new ZInvertMaterial(); break; | ||
276 | case "keleidoscope": mat = new KeleidoscopeMaterial(); break; | ||
277 | case "radialBlur": mat = new RadialBlurMaterial(); break; | ||
278 | case "pulse": mat = new PulseMaterial(); break; | ||
239 | 279 | ||
240 | default: | 280 | default: |
241 | console.log( "material type: " + materialType + " is not supported" ); | 281 | console.log( "material type: " + materialType + " is not supported" ); |
diff --git a/js/lib/geom/rectangle.js b/js/lib/geom/rectangle.js index f91e830c..370bb257 100755 --- a/js/lib/geom/rectangle.js +++ b/js/lib/geom/rectangle.js | |||
@@ -79,6 +79,8 @@ var Rectangle = function GLRectangle() { | |||
79 | } else { | 79 | } else { |
80 | this._fillMaterial = MaterialsModel.exportFlatMaterial(); | 80 | this._fillMaterial = MaterialsModel.exportFlatMaterial(); |
81 | } | 81 | } |
82 | |||
83 | this.exportMaterials(); | ||
82 | }; | 84 | }; |
83 | 85 | ||
84 | /////////////////////////////////////////////////////////////////////// | 86 | /////////////////////////////////////////////////////////////////////// |
@@ -264,8 +266,9 @@ var Rectangle = function GLRectangle() { | |||
264 | console.log( "object material not found in library: " + fillMaterialName ); | 266 | console.log( "object material not found in library: " + fillMaterialName ); |
265 | fillMat = MaterialsModel.exportFlatMaterial(); | 267 | fillMat = MaterialsModel.exportFlatMaterial(); |
266 | } | 268 | } |
267 | |||
268 | this._fillMaterial = fillMat; | 269 | this._fillMaterial = fillMat; |
270 | |||
271 | this.importMaterials( importStr ); | ||
269 | }; | 272 | }; |
270 | 273 | ||
271 | this.buildBuffers = function() { | 274 | this.buildBuffers = function() { |
diff --git a/js/lib/rdge/materials/bump-metal-material.js b/js/lib/rdge/materials/bump-metal-material.js index 67b16371..fa6f5300 100755 --- a/js/lib/rdge/materials/bump-metal-material.js +++ b/js/lib/rdge/materials/bump-metal-material.js | |||
@@ -158,10 +158,14 @@ var BumpMetalMaterial = function BumpMetalMaterial() { | |||
158 | var exportStr = "material: " + this.getShaderName() + "\n"; | 158 | var exportStr = "material: " + this.getShaderName() + "\n"; |
159 | exportStr += "name: " + this.getName() + "\n"; | 159 | exportStr += "name: " + this.getName() + "\n"; |
160 | 160 | ||
161 | var world = this.getWorld(); | ||
162 | if (!world) | ||
163 | throw new Error( "no world in material.export, " + this.getName() ); | ||
164 | |||
161 | exportStr += "lightDiff: " + this.getLightDiff() + "\n"; | 165 | exportStr += "lightDiff: " + this.getLightDiff() + "\n"; |
162 | exportStr += "diffuseTexture: " + this.getDiffuseTexture() + "\n"; | 166 | exportStr += "diffuseTexture: " + this.getDiffuseTexture() + "\n"; |
163 | exportStr += "specularTexture: " + this.getSpecularTexture() + "\n"; | 167 | exportStr += "specularTexture: " + this.getSpecularTexture() + "\n"; |
164 | exportStr += "normalMap: " + this.getNormalTexture() + "\n"; | 168 | exportStr += "normalMap: " + this.getNormalTexture() + "\n"; |
165 | 169 | ||
166 | // every material needs to terminate like this | 170 | // every material needs to terminate like this |
167 | exportStr += "endMaterial\n"; | 171 | exportStr += "endMaterial\n"; |
diff --git a/js/lib/rdge/materials/pulse-material.js b/js/lib/rdge/materials/pulse-material.js index 1e3137eb..81db36c6 100644 --- a/js/lib/rdge/materials/pulse-material.js +++ b/js/lib/rdge/materials/pulse-material.js | |||
@@ -179,8 +179,12 @@ var PulseMaterial = function PulseMaterial() { | |||
179 | var exportStr = "material: " + this.getShaderName() + "\n"; | 179 | var exportStr = "material: " + this.getShaderName() + "\n"; |
180 | exportStr += "name: " + this.getName() + "\n"; | 180 | exportStr += "name: " + this.getName() + "\n"; |
181 | 181 | ||
182 | var texMapName = this._propValues[this._propNames[0]]; | 182 | var world = this.getWorld(); |
183 | exportStr += "texture: " + texMapName + "\n"; | 183 | if (!world) |
184 | throw new Error( "no world in material.export, " + this.getName() ); | ||
185 | |||
186 | var texMapName = this._propValues[this._propNames[0]]; | ||
187 | exportStr += "texture: " +texMapName + "\n"; | ||
184 | 188 | ||
185 | // every material needs to terminate like this | 189 | // every material needs to terminate like this |
186 | exportStr += "endMaterial\n"; | 190 | exportStr += "endMaterial\n"; |
diff --git a/js/lib/rdge/materials/radial-blur-material.js b/js/lib/rdge/materials/radial-blur-material.js index d0d05e8d..46cdda74 100644 --- a/js/lib/rdge/materials/radial-blur-material.js +++ b/js/lib/rdge/materials/radial-blur-material.js | |||
@@ -162,7 +162,11 @@ var RadialBlurMaterial = function RadialBlurMaterial() { | |||
162 | var exportStr = "material: " + this.getShaderName() + "\n"; | 162 | var exportStr = "material: " + this.getShaderName() + "\n"; |
163 | exportStr += "name: " + this.getName() + "\n"; | 163 | exportStr += "name: " + this.getName() + "\n"; |
164 | 164 | ||
165 | var texMapName = this._propValues[this._propNames[0]]; | 165 | var world = this.getWorld(); |