diff options
Diffstat (limited to 'assets/canvas-runtime.js')
-rw-r--r-- | assets/canvas-runtime.js | 79 |
1 files changed, 78 insertions, 1 deletions
diff --git a/assets/canvas-runtime.js b/assets/canvas-runtime.js index ef1d01a9..2f728c06 100644 --- a/assets/canvas-runtime.js +++ b/assets/canvas-runtime.js | |||
@@ -87,6 +87,10 @@ NinjaCvsRt.CanvasDataManager = Object.create(Object.prototype, { | |||
87 | var glRt = Object.create(NinjaCvsRt.GLRuntime, {}); | 87 | var glRt = Object.create(NinjaCvsRt.GLRuntime, {}); |
88 | glRt.renderWorld(canvas, jObj, this._assetPath); | 88 | glRt.renderWorld(canvas, jObj, this._assetPath); |
89 | } | 89 | } |
90 | else | ||
91 | { | ||
92 | console.log( "***** COULD NOT FIND CANVAS WITH ID " + id + " *****" ); | ||
93 | } | ||
90 | } | 94 | } |
91 | } | 95 | } |
92 | } | 96 | } |
@@ -1491,6 +1495,79 @@ NinjaCvsRt.RuntimeTwistVertMaterial = Object.create(NinjaCvsRt.RuntimeMaterial, | |||
1491 | } | 1495 | } |
1492 | }); | 1496 | }); |
1493 | 1497 | ||
1498 | ////////////////////////////////////////////////////// | ||
1499 | |||
1500 | NinjaCvsRt.RuntimeTaperMaterial = Object.create(NinjaCvsRt.RuntimeMaterial, { | ||
1501 | _name: { value: "TaperMaterial", writable: true }, | ||
1502 | _shaderName: { value: "taper", writable: true }, | ||
1503 | |||
1504 | _dTime: { value: 0.01, writable: true }, | ||
1505 | _twistAmount: { value: 0.0, writable: true }, | ||
1506 | _angle: { value: 0.0, writable: true }, | ||
1507 | |||
1508 | |||
1509 | isAnimated: { value: function() { return true; }}, | ||
1510 | |||
1511 | importJSON: { | ||
1512 | value: function(jObj) { | ||
1513 | this._tex0 = jObj.tex0; | ||
1514 | this._tex1 = jObj.tex1; | ||
1515 | |||
1516 | this._speed = jObj.speed; | ||
1517 | |||
1518 | this._limit1 = jObj.limit1; | ||
1519 | this._limit2 = jObj.limit2; | ||
1520 | this._twistAmount = jObj.angle; | ||
1521 | } | ||
1522 | }, | ||
1523 | |||
1524 | init: { | ||
1525 | value: function(world) { | ||
1526 | var material = this._materialNode; | ||
1527 | if (material) | ||
1528 | { | ||
1529 | var technique = material.shaderProgram["colorMe"]; | ||
1530 | var renderer = RDGE.globals.engine.getContext().renderer; | ||
1531 | if (renderer && technique) | ||
1532 | { | ||
1533 | var wrap = 'REPEAT', mips = true; | ||
1534 | var tex = renderer.getTextureByName(this._tex0, wrap, mips ); | ||
1535 | if (tex) technique.u_tex0.set( tex ); | ||
1536 | tex = renderer.getTextureByName(this._tex1, wrap, mips ); | ||
1537 | if (tex) technique.u_tex1.set( tex ); | ||
1538 | |||
1539 | technique.u_twistAmount.set( [this._angle] ); | ||
1540 | technique.u_limit1.set( [this._limit1] ); | ||
1541 | technique.u_limit2.set( [this._limit2] ); | ||
1542 | } | ||
1543 | } | ||
1544 | } | ||
1545 | }, | ||
1546 | |||
1547 | // several materials inherit from pulse. | ||
1548 | // they may share this update method | ||
1549 | update: { | ||
1550 | value: function(time) { | ||
1551 | |||
1552 | var angle = this._angle; | ||
1553 | angle += this._dTime * this._speed; | ||
1554 | if (angle > this._twistAmount) | ||
1555 | { | ||
1556 | angle = this._twistAmount; | ||
1557 | this._dTime = -this._dTime; | ||
1558 | } | ||
1559 | else if (angle < 0.0) | ||
1560 | { | ||
1561 | angle = 0; | ||
1562 | this._dTime = -this._dTime; | ||
1563 | } | ||
1564 | this._angle = angle; | ||
1565 | this._shader.twistMe["u_twistAmount"].set([angle]); | ||
1566 | } | ||
1567 | } | ||
1568 | }); | ||
1569 | |||
1570 | |||
1494 | NinjaCvsRt.RuntimePulseMaterial = Object.create(NinjaCvsRt.RuntimeMaterial, { | 1571 | NinjaCvsRt.RuntimePulseMaterial = Object.create(NinjaCvsRt.RuntimeMaterial, { |
1495 | _name: { value: "PulseMaterial", writable: true }, | 1572 | _name: { value: "PulseMaterial", writable: true }, |
1496 | _shaderName: { value: "pulse", writable: true }, | 1573 | _shaderName: { value: "pulse", writable: true }, |
@@ -1501,7 +1578,7 @@ NinjaCvsRt.RuntimePulseMaterial = Object.create(NinjaCvsRt.RuntimeMaterial, { | |||
1501 | 1578 | ||
1502 | importJSON: { | 1579 | importJSON: { |
1503 | value: function(jObj) { | 1580 | value: function(jObj) { |
1504 | this._texMap = jObj.texture; | 1581 | this._texMap = jObj.u_tex0; |
1505 | if (jObj.dTime) this._dTime = jObj.dTime; | 1582 | if (jObj.dTime) this._dTime = jObj.dTime; |
1506 | } | 1583 | } |
1507 | }, | 1584 | }, |