aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorValerio Virgillito2012-02-10 16:19:54 -0800
committerValerio Virgillito2012-02-10 16:19:54 -0800
commit344933fd505afb9f5dfa3be8cc959112df04da0a (patch)
treee0fd4bbc44b96909d7619593b29d9b063209a7ce /js
parent48977780443d97b9e97b047066639c9056788041 (diff)
parentde65f73c0f129a26aa9007b69e8fce31d0e92d00 (diff)
downloadninja-344933fd505afb9f5dfa3be8cc959112df04da0a.tar.gz
Merge pull request #31 from mqg734/WebGLFixes
Merging WebGL fixes
Diffstat (limited to 'js')
-rw-r--r--js/controllers/elements/shapes-controller.js29
-rw-r--r--js/data/pi/pi-data.js6
-rw-r--r--js/helper-classes/RDGE/GLCircle.js3
-rw-r--r--js/helper-classes/RDGE/GLLine.js70
-rw-r--r--js/helper-classes/RDGE/GLMaterial.js11
-rw-r--r--js/helper-classes/RDGE/GLRectangle.js162
-rw-r--r--js/helper-classes/RDGE/GLWorld.js75
-rw-r--r--js/helper-classes/RDGE/Materials/BrickMaterial.js231
-rw-r--r--js/helper-classes/RDGE/Materials/BumpMetalMaterial.js48
-rw-r--r--js/helper-classes/RDGE/Materials/FlatMaterial.js60
-rw-r--r--js/helper-classes/RDGE/Materials/IridescentScalesMaterial.js215
-rw-r--r--js/helper-classes/RDGE/Materials/JuliaMaterial.js150
-rw-r--r--js/helper-classes/RDGE/Materials/KeleidoscopeMaterial.js149
-rw-r--r--js/helper-classes/RDGE/Materials/LinearGradientMaterial.js148
-rw-r--r--js/helper-classes/RDGE/Materials/MandelMaterial.js151
-rw-r--r--js/helper-classes/RDGE/Materials/PlasmaMaterial.js134
-rw-r--r--js/helper-classes/RDGE/Materials/PulseMaterial.js237
-rw-r--r--js/helper-classes/RDGE/Materials/QuiltMaterial.js168
-rw-r--r--js/helper-classes/RDGE/Materials/RadialBlurMaterial.js244
-rw-r--r--js/helper-classes/RDGE/Materials/RadialGradientMaterial.js87
-rw-r--r--js/helper-classes/RDGE/Materials/StitchMaterial.js119
-rw-r--r--js/helper-classes/RDGE/Materials/TunnelMaterial.js133
-rw-r--r--js/helper-classes/RDGE/Materials/TwistMaterial.js149
-rw-r--r--js/helper-classes/RDGE/Materials/UberMaterial.js56
-rw-r--r--js/helper-classes/RDGE/MaterialsLibrary.js38
-rw-r--r--js/helper-classes/RDGE/rdge-compiled.js57
-rw-r--r--js/helper-classes/RDGE/src/core/script/renderer.js22
-rw-r--r--js/panels/Materials/Materials.xml13
-rw-r--r--js/panels/Materials/materials-popup.reel/materials-popup.js14
-rwxr-xr-xjs/preloader/Preloader.js16
30 files changed, 579 insertions, 2416 deletions
diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js
index b9c033aa..640119c4 100644
--- a/js/controllers/elements/shapes-controller.js
+++ b/js/controllers/elements/shapes-controller.js
@@ -346,19 +346,24 @@ exports.ShapesController = Montage.create(CanvasController, {
346 { 346 {
347 world = new GLWorld(el, true); 347 world = new GLWorld(el, true);
348 el.elementModel.shapeModel.GLWorld = world; 348 el.elementModel.shapeModel.GLWorld = world;
349 el.elementModel.shapeModel.GLGeomObj.setWorld(world);
350 el.elementModel.shapeModel.useWebGl = true; 349 el.elementModel.shapeModel.useWebGl = true;
350 world.import(worldData);
351 el.elementModel.shapeModel.GLGeomObj = world.getGeomRoot();
352
351 sm = Object.create(MaterialsLibrary.getMaterial("FlatMaterial")); 353 sm = Object.create(MaterialsLibrary.getMaterial("FlatMaterial"));
352 fm = Object.create(MaterialsLibrary.getMaterial("FlatMaterial")); 354 if(sm)
353 if(sm && fm)
354 { 355 {
355 el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(sm); 356 el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(sm);
356 el.elementModel.shapeModel.GLGeomObj.setFillMaterial(fm);
357 el.elementModel.shapeModel.strokeMaterial = sm; 357 el.elementModel.shapeModel.strokeMaterial = sm;
358 }
359 fm = Object.create(MaterialsLibrary.getMaterial("FlatMaterial"));
360 // TODO - Use consts after GL code is converted to object literal notation
361// if( fm && (el.elementModel.shapeModel.GLGeomObj.geomType() !== GLGeomObj.GEOM_TYPE_LINE) )
362 if( fm && (el.elementModel.shapeModel.GLGeomObj.geomType() !== 3) )
363 {
364 el.elementModel.shapeModel.GLGeomObj.setFillMaterial(fm);
358 el.elementModel.shapeModel.fillMaterial = fm; 365 el.elementModel.shapeModel.fillMaterial = fm;
359 el.elementModel.shapeModel.GLGeomObj.buildBuffers();
360 } 366 }
361 world.import(worldData);
362 } 367 }
363 368
364 } 369 }
@@ -378,13 +383,17 @@ exports.ShapesController = Montage.create(CanvasController, {
378 world = new GLWorld(el, false); 383 world = new GLWorld(el, false);
379 el.elementModel.shapeModel.GLWorld = world; 384 el.elementModel.shapeModel.GLWorld = world;
380 el.elementModel.shapeModel.useWebGl = false; 385 el.elementModel.shapeModel.useWebGl = false;
386 world.import(worldData);
387 el.elementModel.shapeModel.GLGeomObj = world.getGeomRoot();
381 el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(null); 388 el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(null);
382 el.elementModel.shapeModel.GLGeomObj.setFillMaterial(null);
383 el.elementModel.shapeModel.strokeMaterial = null; 389 el.elementModel.shapeModel.strokeMaterial = null;
384 el.elementModel.shapeModel.fillMaterial = null; 390 // TODO - Use consts after GL code is converted to object literal notation
385 world.import(worldData); 391 if(el.elementModel.shapeModel.GLGeomObj.geomType() !== 3)
392 {
393 el.elementModel.shapeModel.GLGeomObj.setFillMaterial(null);
394 el.elementModel.shapeModel.fillMaterial = null;
395 }
386 } 396 }
387
388 } 397 }
389 } 398 }
390 399
diff --git a/js/data/pi/pi-data.js b/js/data/pi/pi-data.js
index 10b33a0e..8ffd0ec7 100644
--- a/js/data/pi/pi-data.js
+++ b/js/data/pi/pi-data.js
@@ -459,12 +459,14 @@ exports.PiData = Montage.create( Montage, {
459 [ 459 [
460 { 460 {
461 type: "dropdown", 461 type: "dropdown",
462 id: "stroke", 462 id: "strokeMaterial",
463 prop: "strokeMaterial",
463 label: "Stroke", 464 label: "Stroke",
464 labelField: "_name", 465 labelField: "_name",
465 dataField: "_name", 466 dataField: "_name",
466 items : { boundObject: "this.application.ninja.appModel", boundProperty: "materials" }, 467 items : { boundObject: "this.application.ninja.appModel", boundProperty: "materials" },
467 enabled: { boundObject: "this.controls", boundProperty: "useWebGl" } 468 enabled: { boundObject: "this.controls", boundProperty: "useWebGl" },
469 divider : true
468 } 470 }
469 ] 471 ]
470 ] 472 ]
diff --git a/js/helper-classes/RDGE/GLCircle.js b/js/helper-classes/RDGE/GLCircle.js
index 942eb528..08057778 100644
--- a/js/helper-classes/RDGE/GLCircle.js
+++ b/js/helper-classes/RDGE/GLCircle.js
@@ -133,6 +133,9 @@ function GLCircle()
133 if (!world) throw( "null world in buildBuffers" ); 133 if (!world) throw( "null world in buildBuffers" );
134 134
135 if (!world._useWebGL) return; 135 if (!world._useWebGL) return;
136
137 // make sure RDGE has the correct context
138 g_Engine.setContext( world.getCanvas().uuid );
136 139
137 // create the gl buffer 140 // create the gl buffer
138 var gl = world.getGLContext(); 141 var gl = world.getGLContext();
diff --git a/js/helper-classes/RDGE/GLLine.js b/js/helper-classes/RDGE/GLLine.js
index 67379b52..5ec51230 100644
--- a/js/helper-classes/RDGE/GLLine.js
+++ b/js/helper-classes/RDGE/GLLine.js
@@ -28,6 +28,8 @@ function GLLine( world, xOffset, yOffset, width, height, slope, strokeSize, stro
28 this._strokeWidth = 0.25; 28 this._strokeWidth = 0.25;
29 29
30 this._strokeStyle = "Solid"; 30 this._strokeStyle = "Solid";
31 this._scaleX = 1.0;
32 this._scaleY = 1.0;
31 33
32 if (arguments.length > 0) 34 if (arguments.length > 0)
33 { 35 {
@@ -44,13 +46,9 @@ function GLLine( world, xOffset, yOffset, width, height, slope, strokeSize, stro
44 this._strokeColor = strokeColor; 46 this._strokeColor = strokeColor;
45 47
46 this._strokeStyle = strokeStyle; 48 this._strokeStyle = strokeStyle;
49 this._scaleX = (world.getViewportWidth())/(world.getViewportHeight());
47 } 50 }
48 51
49 this._scaleX = 1.0;
50 this._scaleY = 1.0;
51
52 this._scaleX = (world._viewportWidth)/(world._viewportHeight);
53
54 this._strokeVerticesLen = 0; 52 this._strokeVerticesLen = 0;
55 53
56 this.m_world = world; 54 this.m_world = world;
@@ -104,7 +102,64 @@ function GLLine( world, xOffset, yOffset, width, height, slope, strokeSize, stro
104 this.setSlope = function(m) { this._slope = m; } 102 this.setSlope = function(m) { this._slope = m; }
105 103
106 this.geomType = function() { return this.GEOM_TYPE_LINE; } 104 this.geomType = function() { return this.GEOM_TYPE_LINE; }
107 105
106 ///////////////////////////////////////////////////////////////////////
107 // Methods
108 ///////////////////////////////////////////////////////////////////////
109 this.export = function()
110 {
111 var rtnStr = "type: " + this.geomType() + "\n";
112
113 rtnStr += "xoff: " + this._xOffset + "\n";
114 rtnStr += "yoff: " + this._yOffset + "\n";
115 rtnStr += "width: " + this._width + "\n";
116 rtnStr += "height: " + this._height + "\n";
117 rtnStr += "xAdj: " + this._xAdj + "\n";
118 rtnStr += "yAdj: " + this._yAdj + "\n";
119 rtnStr += "strokeWidth: " + this._strokeWidth + "\n";
120 rtnStr += "strokeColor: " + String(this._strokeColor) + "\n";
121 rtnStr += "strokeStyle: " + this._strokeStyle + "\n";
122 rtnStr += "slope: " + String(this._slope) + "\n";
123
124 rtnStr += "strokeMat: ";
125 if (this._strokeMaterial)
126 rtnStr += this._strokeMaterial.getName();
127 else
128 rtnStr += "flatMaterial";
129 rtnStr += "\n";
130
131 return rtnStr;
132 }
133
134 this.import = function( importStr )
135 {
136 this._xOffset = Number( this.getPropertyFromString( "xoff: ", importStr ) );