aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rwxr-xr-xjs/document/html-document.js1
-rw-r--r--js/lib/rdge/materials/plasma-material.js30
-rw-r--r--js/lib/rdge/runtime/RuntimeGeomObj.js4
-rw-r--r--js/lib/rdge/runtime/RuntimeMaterial.js34
4 files changed, 44 insertions, 25 deletions
diff --git a/js/document/html-document.js b/js/document/html-document.js
index 44f90d41..0a3497f1 100755
--- a/js/document/html-document.js
+++ b/js/document/html-document.js
@@ -190,7 +190,6 @@ exports.HTMLDocument = Montage.create(TextDocument, {
190 var loadForRuntime = true; 190 var loadForRuntime = true;
191 if (loadForRuntime) 191 if (loadForRuntime)
192 { 192 {
193 //console.log( "load canvas data: " , value );
194 var cdm = new CanvasDataManager(); 193 var cdm = new CanvasDataManager();
195 cdm.loadGLData(elt, value, NJUtils); 194 cdm.loadGLData(elt, value, NJUtils);
196 } 195 }
diff --git a/js/lib/rdge/materials/plasma-material.js b/js/lib/rdge/materials/plasma-material.js
index 62d0db70..86b1a93c 100644
--- a/js/lib/rdge/materials/plasma-material.js
+++ b/js/lib/rdge/materials/plasma-material.js
@@ -17,8 +17,6 @@ var PlasmaMaterial = function PlasmaMaterial() {
17 this._dTime = 0.01; 17 this._dTime = 0.01;
18 this._speed = 1.0; 18 this._speed = 1.0;
19 19
20 this._color = [1,0,0,1];
21
22 20
23 /////////////////////////////////////////////////////////////////////// 21 ///////////////////////////////////////////////////////////////////////
24 // Property Accessors 22 // Property Accessors
@@ -30,20 +28,12 @@ var PlasmaMaterial = function PlasmaMaterial() {
30 /////////////////////////////////////////////////////////////////////// 28 ///////////////////////////////////////////////////////////////////////
31 // Material Property Accessors 29 // Material Property Accessors
32 /////////////////////////////////////////////////////////////////////// 30 ///////////////////////////////////////////////////////////////////////
33 this._propNames = ["color"]; 31
34 this._propLabels = ["Color"]; 32 this.setProperty = function( prop, value )
35 this._propTypes = ["color"]; 33 {
36 this._propValues = []; 34 // plasma has no properties
37
38 this._propValues[ this._propNames[0] ] = this._color;
39
40 this.setProperty = function( prop, value ) {
41 // make sure we have legitimate imput
42 if (this.validateProperty( prop, value )) {
43 this._color = value.slice(0);
44 this._shader['default'][prop].set(value);
45 }
46 }; 35 };
36
47 /////////////////////////////////////////////////////////////////////// 37 ///////////////////////////////////////////////////////////////////////
48 38
49 /////////////////////////////////////////////////////////////////////// 39 ///////////////////////////////////////////////////////////////////////
@@ -65,8 +55,7 @@ var PlasmaMaterial = function PlasmaMaterial() {
65 55
66 // set the default value 56 // set the default value
67 this._time = 0; 57 this._time = 0;
68 this._shader['default'].u_time = this._time; 58 this._shader['default'].u_time.set( [this._time] );
69 this.setProperty( "color", [this._time, 0, 0, 1] );
70 59
71 // set up the material node 60 // set up the material node
72 this._materialNode = createMaterialNode("plasmaMaterial" + "_" + world.generateUniqueNodeID()); 61 this._materialNode = createMaterialNode("plasmaMaterial" + "_" + world.generateUniqueNodeID());
@@ -74,11 +63,7 @@ var PlasmaMaterial = function PlasmaMaterial() {
74 }; 63 };
75 64
76 this.update = function( time ) { 65 this.update = function( time ) {
77 this._shader['default'].u_time = this._time; 66 this._shader['default'].u_time.set( [this._time] );
78 var color = this.getProperty( "color" );
79 color[0] = this._time;
80 this.setProperty( "color", color );
81 //console.log( "update color to: " + color );
82 this._time += this._dTime; 67 this._time += this._dTime;
83 } 68 }
84 69
@@ -112,7 +97,6 @@ var plasmaShaderDef =
112 'params' : 97 'params' :
113 { 98 {
114 'u_time' : { 'type' : 'float' }, 99 'u_time' : { 'type' : 'float' },
115 'color' : { 'type' : 'vec4' }
116 }, 100 },
117 101
118 // render states 102 // render states
diff --git a/js/lib/rdge/runtime/RuntimeGeomObj.js b/js/lib/rdge/runtime/RuntimeGeomObj.js
index 5b212dce..93d4d9a1 100644
--- a/js/lib/rdge/runtime/RuntimeGeomObj.js
+++ b/js/lib/rdge/runtime/RuntimeGeomObj.js
@@ -11,7 +11,8 @@ var RuntimeFlatMaterial = RuntimeMaterial.RuntimeFlatMaterial,
11 RuntimeLinearGradientMaterial = RuntimeMaterial.RuntimeLinearGradientMaterial, 11 RuntimeLinearGradientMaterial = RuntimeMaterial.RuntimeLinearGradientMaterial,
12 RuntimeBumpMetalMaterial = RuntimeMaterial.RuntimeBumpMetalMaterial, 12 RuntimeBumpMetalMaterial = RuntimeMaterial.RuntimeBumpMetalMaterial,
13 RuntimeUberMaterial = RuntimeMaterial.RuntimeUberMaterial, 13 RuntimeUberMaterial = RuntimeMaterial.RuntimeUberMaterial,
14 RuntimePulseMaterial = RuntimeMaterial.RuntimePulseMaterial; 14 RuntimePulseMaterial = RuntimeMaterial.RuntimePulseMaterial,
15 RuntimePlasmaMaterial = RuntimeMaterial.RuntimePlasmaMaterial;
15 16
16 17
17 18
@@ -94,6 +95,7 @@ var RuntimeGeomObj = function RuntimeGeomObj()
94 case "linearGradient": mat = new RuntimeLinearGradientMaterial(); break; 95 case "linearGradient": mat = new RuntimeLinearGradientMaterial(); break;
95 case "bumpMetal": mat = new RuntimeBumpMetalMaterial(); break; 96 case "bumpMetal": mat = new RuntimeBumpMetalMaterial(); break;
96 case "uber": mat = new RuntimeUberMaterial(); break; 97 case "uber": mat = new RuntimeUberMaterial(); break;
98 case "plasma": mat = new RuntimePlasmaMaterial(); break;
97 99
98 case "deform": 100 case "deform":
99 case "water": 101 case "water":
diff --git a/js/lib/rdge/runtime/RuntimeMaterial.js b/js/lib/rdge/runtime/RuntimeMaterial.js
index 294c4787..1bbbc3b1 100644
--- a/js/lib/rdge/runtime/RuntimeMaterial.js
+++ b/js/lib/rdge/runtime/RuntimeMaterial.js
@@ -54,6 +54,10 @@ var RuntimeMaterial = function RuntimeMaterial( world )
54 { 54 {
55 } 55 }
56 56
57 this.import = function( importStr )
58 {
59 }
60
57 this.getPropertyFromString = function( prop, str ) 61 this.getPropertyFromString = function( prop, str )
58 { 62 {
59 var index = str.indexOf( prop ); 63 var index = str.indexOf( prop );
@@ -304,6 +308,35 @@ function RuntimeUberMaterial()
304{ 308{
305} 309}
306 310
311function RuntimePlasmaMaterial()
312{
313 // inherit the members of RuntimeMaterial
314 this.inheritedFrom = RuntimeMaterial;
315 this.inheritedFrom();
316
317 this.init = function( )
318 {
319 this.update();
320 }
321
322 this.update = function( time )
323 {
324 var material = this._materialNode;
325 if (material)
326 {
327 var technique = material.shaderProgram.default;
328 var renderer = g_Engine.getContext().renderer;
329 if (renderer && technique)
330 {
331 if (this._shader && this._shader.default)
332 this._shader.default.u_time.set( [this._time] );
333 this._time += this._dTime;
334 if (this._time > 200.0) this._time = 0.0;
335 }
336 }
337 }
338}
339
307 340
308if (typeof exports === "object") 341if (typeof exports === "object")
309{ 342{
@@ -314,4 +347,5 @@ if (typeof exports === "object")
314 exports.RuntimeLinearGradientMaterial = RuntimeLinearGradientMaterial; 347 exports.RuntimeLinearGradientMaterial = RuntimeLinearGradientMaterial;
315 exports.RuntimeBumpMetalMaterial = RuntimeBumpMetalMaterial; 348 exports.RuntimeBumpMetalMaterial = RuntimeBumpMetalMaterial;
316 exports.RuntimeUberMaterial = RuntimeUberMaterial; 349 exports.RuntimeUberMaterial = RuntimeUberMaterial;
350 exports.RuntimePlasmaMaterial = RuntimePlasmaMaterial;
317} 351}