aboutsummaryrefslogtreecommitdiff
path: root/assets/canvas-runtime.js
diff options
context:
space:
mode:
authorhwc4872012-05-31 17:07:10 -0700
committerhwc4872012-05-31 17:07:10 -0700
commit335ce503996e3ccbd2909086328d0a31fbd03370 (patch)
treee54d588e0993572f1d794ff5b75a5082aa2035b1 /assets/canvas-runtime.js
parent129b5282ef35f320ea39d1878d2b5f77ae73a3e2 (diff)
downloadninja-335ce503996e3ccbd2909086328d0a31fbd03370.tar.gz
Added the flag shader to the runtime.
Diffstat (limited to 'assets/canvas-runtime.js')
-rw-r--r--assets/canvas-runtime.js82
1 files changed, 79 insertions, 3 deletions
diff --git a/assets/canvas-runtime.js b/assets/canvas-runtime.js
index f4bfa0ae..918dffdc 100644
--- a/assets/canvas-runtime.js
+++ b/assets/canvas-runtime.js
@@ -580,9 +580,17 @@ NinjaCvsRt.RuntimeGeomObj = Object.create(Object.prototype, {
580 case "zinvert": 580 case "zinvert":
581 case "keleidoscope": 581 case "keleidoscope":
582 case "radialBlur": 582 case "radialBlur":
583 case "pulse": mat = Object.create(NinjaCvsRt.RuntimePulseMaterial, {}); break; 583 case "pulse":
584 mat = Object.create(NinjaCvsRt.RuntimePulseMaterial, {});
585 break;
584 586
585 case "twistVert": mat = Object.create(NinjaCvsRt.RuntimeTwistVertMaterial, {}); break; 587 case "twistVert":
588 mat = Object.create(NinjaCvsRt.RuntimeTwistVertMaterial, {});
589 break;
590
591 case "flag":
592 mat = Object.create(NinjaCvsRt.RuntimeFlagMaterial, {});
593 break;
586 594
587 default: 595 default:
588 console.log( "material type: " + shaderName + " is not supported" ); 596 console.log( "material type: " + shaderName + " is not supported" );
@@ -1381,6 +1389,7 @@ NinjaCvsRt.RuntimeFlatMaterial = Object.create(NinjaCvsRt.RuntimeMaterial, {
1381 1389
1382}); 1390});
1383 1391
1392
1384NinjaCvsRt.RuntimeTwistVertMaterial = Object.create(NinjaCvsRt.RuntimeMaterial, { 1393NinjaCvsRt.RuntimeTwistVertMaterial = Object.create(NinjaCvsRt.RuntimeMaterial, {
1385 _name: { value: "TwistVertMaterial", writable: true }, 1394 _name: { value: "TwistVertMaterial", writable: true },
1386 _shaderName: { value: "twistVert", writable: true }, 1395 _shaderName: { value: "twistVert", writable: true },
@@ -1410,7 +1419,7 @@ NinjaCvsRt.RuntimeTwistVertMaterial = Object.create(NinjaCvsRt.RuntimeMaterial,
1410 1419
1411 init: { 1420 init: {
1412 value: function(world) { 1421 value: function(world) {
1413 var material = this._materialNode; 1422 var material = this._materialNode;
1414 if (material) 1423 if (material)
1415 { 1424 {
1416 var technique = material.shaderProgram["twistMe"]; 1425 var technique = material.shaderProgram["twistMe"];
@@ -1488,6 +1497,7 @@ NinjaCvsRt.RuntimePulseMaterial = Object.create(NinjaCvsRt.RuntimeMaterial, {
1488 if (tex) 1497 if (tex)
1489 technique.u_tex0.set( tex ); 1498 technique.u_tex0.set( tex );
1490 1499
1500 this._shader["default"].u_speed.set( [1.0] );
1491 this._shader["default"].u_time.set( [this._time] ); 1501 this._shader["default"].u_time.set( [this._time] );
1492 } 1502 }
1493 } 1503 }
@@ -1516,6 +1526,72 @@ NinjaCvsRt.RuntimePulseMaterial = Object.create(NinjaCvsRt.RuntimeMaterial, {
1516 } 1526 }
1517}); 1527});
1518 1528
1529
1530NinjaCvsRt.RuntimeFlagMaterial = Object.create(NinjaCvsRt.RuntimeMaterial, {
1531 _name: { value: "FlagMaterial", writable: true },
1532 _shaderName: { value: "flag", writable: true },
1533
1534 // default values
1535 _texMap: { value: 'assets/images/cubelight.png', writable: true },
1536 _speed: { value: 1.0, writable: true },
1537 _waveWidth: { value: 1.0, writable: true },
1538 _waveHeight: { value: 1.0, writable: true },
1539 _dTime: { value: 0.1, writable: true },
1540
1541 importJSON: {
1542 value: function(jObj) {
1543 this._texMap = jObj.texMap;
1544 this._waveWidth = jObj.waveWidth;
1545 this._waveHeight = jObj.waveHeight;
1546 this._speed = jObj.speed;
1547 }
1548 },
1549
1550 init: {
1551 value: function(world) {
1552 if (this._shader) {
1553 var material = this._materialNode;
1554 if (material)
1555 {
1556 var technique = material.shaderProgram['default'];
1557 var renderer = RDGE.globals.engine.getContext().renderer;
1558 if (renderer && technique)
1559 {
1560
1561 if (this._shader && this._shader['default']) {
1562 var wrap = 'REPEAT', mips = true;
1563 var tex = renderer.getTextureByName(this._texMap, wrap, mips );
1564 if (tex) technique.u_tex0.set( tex );
1565
1566 technique.u_speed.set( [this._speed] );
1567 technique.u_waveWidth.set( [this._waveWidth] );
1568 technique.u_waveHeight.set( [this._waveHeight] );
1569 }
1570 }
1571 }
1572 }
1573 }
1574 },
1575
1576 update: {
1577 value: function(time) {
1578 var material = this._materialNode;
1579 if (material)
1580 {
1581 var technique = material.shaderProgram['default'];
1582 var renderer = RDGE.globals.engine.getContext().renderer;
1583 if (renderer && technique)
1584 {
1585 if (this._shader && this._shader['default']) {
1586 this._shader['default'].u_time.set( [this._time] );
1587 }
1588 this._time += this._dTime * this._speed;
1589 }
1590 }
1591 }
1592 }
1593});
1594
1519NinjaCvsRt.RuntimeRadialGradientMaterial = Object.create(NinjaCvsRt.RuntimeMaterial, { 1595NinjaCvsRt.RuntimeRadialGradientMaterial = Object.create(NinjaCvsRt.RuntimeMaterial, {
1520 _name: { value: "RadialGradientMaterial", writable: true }, 1596 _name: { value: "RadialGradientMaterial", writable: true },
1521 _shaderName: { value: "radialGradient", writable: true }, 1597 _shaderName: { value: "radialGradient", writable: true },