diff --git a/assets/index.html b/assets/index.html
index c61e922..b6c7cdd 100644
--- a/assets/index.html
+++ b/assets/index.html
@@ -187,17 +187,20 @@
drawTile(wx, wy, level, true, hRight, hBack, false);
}
- if (h > 0) {
- var shadowFront = (heightMap[(wx + TILE) + ',' + wy] || 0) - h;
- var shadowLeft = (heightMap[wx + ',' + (wy - TILE)] || 0) - h;
+ for (var level = 1; level <= h; level++) {
+ var hRightNeighbor = heightMap[(wx + TILE) + ',' + wy] || 0;
+ var hLeftNeighbor = heightMap[wx + ',' + (wy - TILE)] || 0;
+
+ var shadowFront = hRightNeighbor - level;
+ var shadowLeft = hLeftNeighbor - level;
if (shadowFront > 0) {
- var shadowWidth = Math.min(shadowFront * 2, TILE);
- var t = shadowWidth / TILE;
- var top1 = project(wx + GAP/2, wy + TILE - GAP/2, h * HEIGHT_UNIT);
- var top2 = project(wx + TILE - GAP/2, wy + TILE - GAP/2, h * HEIGHT_UNIT);
- var topA = project(wx + GAP/2 + (TILE - GAP) * t, wy + TILE - GAP/2, h * HEIGHT_UNIT);
- var topB = project(wx + TILE - GAP/2 - (TILE - GAP) * t, wy + TILE - GAP/2, h * HEIGHT_UNIT);
+ var shadowW = Math.min(shadowFront * 2, TILE - GAP);
+ var tt = shadowW / TILE;
+ var top1 = project(wx + GAP/2, wy + TILE - GAP/2, level * HEIGHT_UNIT);
+ var top2 = project(wx + TILE - GAP/2, wy + TILE - GAP/2, level * HEIGHT_UNIT);
+ var topA = project(wx + GAP/2 + (TILE - GAP) * tt, wy + TILE - GAP/2, level * HEIGHT_UNIT);
+ var topB = project(wx + TILE - GAP/2 - (TILE - GAP) * tt, wy + TILE - GAP/2, level * HEIGHT_UNIT);
ctx.fillStyle = 'rgba(0, 0, 0, 0.4)';
ctx.beginPath();
@@ -210,12 +213,12 @@
}
if (shadowLeft > 0) {
- var shadowWidth = Math.min(shadowLeft * 2, TILE);
- var t = shadowWidth / TILE;
- var top4 = project(wx + GAP/2, wy + GAP/2, h * HEIGHT_UNIT);
- var top1 = project(wx + GAP/2, wy + TILE - GAP/2, h * HEIGHT_UNIT);
- var topA = project(wx + GAP/2, wy + GAP/2 + (TILE - GAP) * t, h * HEIGHT_UNIT);
- var topB = project(wx + GAP/2, wy + TILE - GAP/2 - (TILE - GAP) * t, h * HEIGHT_UNIT);
+ var shadowW = Math.min(shadowLeft * 2, TILE - GAP);
+ var tt = shadowW / TILE;
+ var top4 = project(wx + GAP/2, wy + GAP/2, level * HEIGHT_UNIT);
+ var top1 = project(wx + GAP/2, wy + TILE - GAP/2, level * HEIGHT_UNIT);
+ var topA = project(wx + GAP/2, wy + GAP/2 + (TILE - GAP) * tt, level * HEIGHT_UNIT);
+ var topB = project(wx + GAP/2, wy + TILE - GAP/2 - (TILE - GAP) * tt, level * HEIGHT_UNIT);
ctx.fillStyle = 'rgba(0, 0, 0, 0.4)';
ctx.beginPath();