diff options
-rw-r--r-- | assets/canvas-runtime.js | 73 | ||||
-rw-r--r-- | js/io/system/ninjalibrary.json | 2 | ||||
-rw-r--r-- | js/lib/rdge/materials/taper-material.js | 6 |
3 files changed, 47 insertions, 34 deletions
diff --git a/assets/canvas-runtime.js b/assets/canvas-runtime.js index 2035d2e0..cd673854 100644 --- a/assets/canvas-runtime.js +++ b/assets/canvas-runtime.js | |||
@@ -608,6 +608,7 @@ NinjaCvsRt.RuntimeGeomObj = Object.create(Object.prototype, { | |||
608 | case "uber": mat = Object.create(NinjaCvsRt.RuntimeUberMaterial, {}); break; | 608 | case "uber": mat = Object.create(NinjaCvsRt.RuntimeUberMaterial, {}); break; |
609 | case "plasma": mat = Object.create(NinjaCvsRt.RuntimePlasmaMaterial, {}); break; | 609 | case "plasma": mat = Object.create(NinjaCvsRt.RuntimePlasmaMaterial, {}); break; |
610 | case "water": mat = Object.create(NinjaCvsRt.RuntimeWaterMaterial, {}); break; | 610 | case "water": mat = Object.create(NinjaCvsRt.RuntimeWaterMaterial, {}); break; |
611 | case "taper": mat = Object.create(NinjaCvsRt.RuntimeTaperMaterial, {}); break; | ||
611 | 612 | ||
612 | case "deform": | 613 | case "deform": |
613 | case "paris": | 614 | case "paris": |
@@ -1518,20 +1519,23 @@ NinjaCvsRt.RuntimeTaperMaterial = Object.create(NinjaCvsRt.RuntimeMaterial, { | |||
1518 | 1519 | ||
1519 | 1520 | ||
1520 | isAnimated: { value: function() { return true; }}, | 1521 | isAnimated: { value: function() { return true; }}, |
1521 | 1522 | ||
1522 | importJSON: { | 1523 | importJSON: { |
1523 | value: function(jObj) { | 1524 | value: function(jObj) { |
1524 | this._tex0 = jObj.tex0; | 1525 | for (var prop in jObj) |
1525 | this._tex1 = jObj.tex1; | 1526 | { |
1526 | 1527 | if ((prop != 'material') && (prop != 'name')) | |
1527 | this._speed = jObj.speed; | 1528 | { |
1529 | var value = jObj[prop]; | ||
1530 | this[prop] = value; | ||
1531 | } | ||
1532 | } | ||
1528 | 1533 | ||
1529 | this._limit1 = jObj.limit1; | 1534 | this._dTime = jObj.dTime; |
1530 | this._limit2 = jObj.limit2; | 1535 | } |
1531 | this._twistAmount = jObj.angle; | ||
1532 | } | ||
1533 | }, | 1536 | }, |
1534 | 1537 | ||
1538 | |||
1535 | init: { | 1539 | init: { |
1536 | value: function(world) { | 1540 | value: function(world) { |
1537 | var material = this._materialNode; | 1541 | var material = this._materialNode; |
@@ -1541,15 +1545,18 @@ NinjaCvsRt.RuntimeTaperMaterial = Object.create(NinjaCvsRt.RuntimeMaterial, { | |||
1541 | var renderer = RDGE.globals.engine.getContext().renderer; | 1545 | var renderer = RDGE.globals.engine.getContext().renderer; |
1542 | if (renderer && technique) | 1546 | if (renderer && technique) |
1543 | { | 1547 | { |
1544 | var wrap = 'REPEAT', mips = true; | 1548 | // var wrap = 'REPEAT', mips = true; |
1545 | var tex = renderer.getTextureByName(this._tex0, wrap, mips ); | 1549 | // var tex = renderer.getTextureByName(this._tex0, wrap, mips ); |
1546 | if (tex) technique.u_tex0.set( tex ); | 1550 | // if (tex) technique.u_tex0.set( tex ); |
1547 | tex = renderer.getTextureByName(this._tex1, wrap, mips ); | 1551 | // tex = renderer.getTextureByName(this._tex1, wrap, mips ); |
1548 | if (tex) technique.u_tex1.set( tex ); | 1552 | // if (tex) technique.u_tex1.set( tex ); |
1549 | 1553 | ||
1550 | technique.u_twistAmount.set( [this._angle] ); | 1554 | technique.u_limit1.set( [this.u_limit1] ); |
1551 | technique.u_limit1.set( [this._limit1] ); | ||
1552 | technique.u_limit2.set( [this._limit2] ); | 1555 | technique.u_limit2.set( [this._limit2] ); |
1556 | technique.u_limit3.set( [this._limit3] ); | ||
1557 | technique.u_minVal.set( [this.u_minVal] ); | ||
1558 | technique.u_maxVal.set( [this.u_maxVal] ); | ||
1559 | technique.u_taperAmount.set( [this.u_taperAmount] ); | ||
1553 | } | 1560 | } |
1554 | } | 1561 | } |
1555 | } | 1562 | } |
@@ -1560,21 +1567,25 @@ NinjaCvsRt.RuntimeTaperMaterial = Object.create(NinjaCvsRt.RuntimeMaterial, { | |||
1560 | update: { | 1567 | update: { |
1561 | value: function(time) { | 1568 | value: function(time) { |
1562 | 1569 | ||
1563 | var angle = this._angle; | 1570 | var speed = this.u_speed; |
1564 | angle += this._dTime * this._speed; | 1571 | this._dTime += 0.01 * speed; |
1565 | if (angle > this._twistAmount) | 1572 | |
1566 | { | 1573 | if (this._shader && this._shader.colorMe) { |
1567 | angle = this._twistAmount; | 1574 | var t3 = this.u_limit3 - this._dTime; |
1568 | this._dTime = -this._dTime; | 1575 | if (t3 < 0) { |
1569 | } | 1576 | this._dTime = this.u_limit1 - 1.0; |
1570 | else if (angle < 0.0) | 1577 | t3 = this.u_limit3 - this._dTime; |
1571 | { | 1578 | } |
1572 | angle = 0; | 1579 | |
1573 | this._dTime = -this._dTime; | 1580 | var t1 = this.u_limit1 - this._dTime, |
1574 | } | 1581 | t2 = this.u_limit2 - this._dTime; |
1575 | this._angle = angle; | 1582 | |
1576 | this._shader.twistMe["u_twistAmount"].set([angle]); | 1583 | |
1577 | } | 1584 | this._shader.colorMe["u_limit1"].set([t1]); |
1585 | this._shader.colorMe["u_limit2"].set([t2]); | ||
1586 | this._shader.colorMe["u_limit3"].set([t3]); | ||
1587 | } | ||
1588 | } | ||
1578 | } | 1589 | } |
1579 | }); | 1590 | }); |
1580 | 1591 | ||
diff --git a/js/io/system/ninjalibrary.json b/js/io/system/ninjalibrary.json index fb108937..f8e61ca5 100644 --- a/js/io/system/ninjalibrary.json +++ b/js/io/system/ninjalibrary.json | |||
@@ -1,6 +1,6 @@ | |||
1 | { | 1 | { |
2 | "libraries": [ | 2 | "libraries": [ |
3 | {"name": "Montage", "path": "/node_modules/descriptor.json", "version": "0.10.1.0"}, | 3 | {"name": "Montage", "path": "/node_modules/descriptor.json", "version": "0.10.1.0"}, |
4 | {"name": "RDGE", "path": "/assets/descriptor.json", "version": "0.6.0.0"} | 4 | {"name": "RDGE", "path": "/assets/descriptor.json", "version": "0.6.0.1"} |
5 | ] | 5 | ] |
6 | } \ No newline at end of file | 6 | } \ No newline at end of file |
diff --git a/js/lib/rdge/materials/taper-material.js b/js/lib/rdge/materials/taper-material.js index a44314b6..0ae039f7 100644 --- a/js/lib/rdge/materials/taper-material.js +++ b/js/lib/rdge/materials/taper-material.js | |||
@@ -32,6 +32,7 @@ var TaperMaterial = function TaperMaterial() | |||
32 | 32 | ||
33 | this.isAnimated = function () { return true; }; | 33 | this.isAnimated = function () { return true; }; |
34 | this.getShaderDef = function() { return taperShaderDef; }; | 34 | this.getShaderDef = function() { return taperShaderDef; }; |
35 | this.getTechniqueName = function() { return 'colorMe' }; | ||
35 | 36 | ||
36 | this.hasVertexDeformation = function () { return this._hasVertexDeformation; }; | 37 | this.hasVertexDeformation = function () { return this._hasVertexDeformation; }; |
37 | this._hasVertexDeformation = true; | 38 | this._hasVertexDeformation = true; |
@@ -50,12 +51,12 @@ var TaperMaterial = function TaperMaterial() | |||
50 | 51 | ||
51 | // set up the material node | 52 | // set up the material node |
52 | this._materialNode = RDGE.createMaterialNode("taperMaterial" + "_" + world.generateUniqueNodeID()); | 53 | this._materialNode = RDGE.createMaterialNode("taperMaterial" + "_" + world.generateUniqueNodeID()); |
54 | this._materialNode.setShader(this._shader); | ||
53 | 55 | ||
54 | this._time = 0; | 56 | this._time = 0; |
55 | if (this._shader && this._shader['default']) { | 57 | if (this._shader && this._shader['default']) { |
56 | this._shader['default'].u_time.set([this._time]); | 58 | this._shader['default'].u_time.set([this._time]); |
57 | } | 59 | } |
58 | this._materialNode.setShader(this._shader); | ||
59 | 60 | ||
60 | // initialize the taper properties | 61 | // initialize the taper properties |
61 | this.setShaderValues(); | 62 | this.setShaderValues(); |
@@ -133,7 +134,8 @@ taperShaderDef = { | |||
133 | 'u_minVal': { 'type': 'float' }, | 134 | 'u_minVal': { 'type': 'float' }, |
134 | 'u_maxVal': { 'type': 'float' }, | 135 | 'u_maxVal': { 'type': 'float' }, |
135 | 'u_center': { 'type': 'float' }, | 136 | 'u_center': { 'type': 'float' }, |
136 | 'u_taperAmount': { 'type': 'float' } | 137 | 'u_taperAmount': { 'type': 'float' }, |
138 | 'u_speed': { 'type': 'float' } | ||
137 | } | 139 | } |
138 | } | 140 | } |
139 | ] | 141 | ] |