diff --git a/lib/torque/renderer/iso.js b/lib/torque/renderer/iso.js index aeeabb2..d8b7fb7 100644 --- a/lib/torque/renderer/iso.js +++ b/lib/torque/renderer/iso.js @@ -135,7 +135,7 @@ torque.extend(IsoRenderer.prototype, torque.Event, { else if (type === 1 || type === 14){ next = [S,W]; interpolation = { - x: this._lerp(cornerValues[2], cornerValues[3], contourValue), + x: 1-this._lerp(cornerValues[2], cornerValues[3], contourValue), y: this._lerp(cornerValues[0], cornerValues[3], contourValue) }; } @@ -157,7 +157,7 @@ torque.extend(IsoRenderer.prototype, torque.Event, { next = [N,E]; interpolation = { x: this._lerp(cornerValues[0], cornerValues[1], contourValue), - y: this._lerp(cornerValues[2], cornerValues[1], contourValue) + y: 1 - this._lerp(cornerValues[2], cornerValues[1], contourValue) }; } else if (type === 6 || type === 9) { @@ -170,21 +170,48 @@ torque.extend(IsoRenderer.prototype, torque.Event, { else if (type === 7 || type === 8) { next = [N,W]; interpolation = { - x: this._lerp(cornerValues[1], cornerValues[0], contourValue), - y: this._lerp(cornerValues[3], cornerValues[0], contourValue) + x: 1-this._lerp(cornerValues[1], cornerValues[0], contourValue), + y: 1-this._lerp(cornerValues[3], cornerValues[0], contourValue) }; } else if (type === 5 || type === 10) { - if (!previousPos) return; var diff = [previousPos.x - currentPos.x, previousPos.y - currentPos.y]; if (diff[0] === -1){ - return {x: currentPos.x, y: currentPos.y - 1}; + return { + x: currentPos.x, + y: currentPos.y - 1, + interpolation: { + x: 1 - this._lerp(cornerValues[1], cornerValues[0], contourValue), + y: 1 - this._lerp(cornerValues[3], cornerValues[0], contourValue) + } + }; } else if (diff[0] === 1){ - return {x: currentPos.x, y: currentPos.y + 1}; + return { + x: currentPos.x, + y: currentPos.y + 1, + interpolation: { + x: this._lerp(cornerValues[3], cornerValues[2], contourValue), + y: this._lerp(cornerValues[1], cornerValues[2], contourValue) + } + }; } else if (diff[1] === -1){ - return {x: currentPos.x + 1, y: currentPos.y}; + return { + x: currentPos.x + 1, + y: currentPos.y, + interpolation: { + x: this._lerp(cornerValues[0], cornerValues[1], contourValue), + y: 1 - this._lerp(cornerValues[2], cornerValues[1], contourValue) + } + }; } else if (diff[1] === 1){ - return {x: currentPos.x - 1, y: currentPos.y}; + return { + x: currentPos.x - 1, + y: currentPos.y, + interpolation: { + x: this._lerp(cornerValues[3], cornerValues[2], contourValue), + y: this._lerp(cornerValues[1], cornerValues[2], contourValue) + } + }; } } @@ -205,7 +232,7 @@ torque.extend(IsoRenderer.prototype, torque.Event, { if (grid.length > 0) { var style = this._shader.getLayers()[1].getStyle({}, {zoom: 2}); var cellsY = this.globalGrid.length-1; - var contourValues = [1]; + var contourValues = [2 , 16]; var ctx = this._ctx; var res = this.options.resolution; var startPos = this.firstTileCoords.pos;