interpolation corrections

This commit is contained in:
Francisco Dans 2015-08-27 11:32:31 +02:00
parent 7299fdca9a
commit 510580b51b

View File

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