diff --git a/assets/index.html b/assets/index.html
index 6890a46..cc8d579 100644
--- a/assets/index.html
+++ b/assets/index.html
@@ -193,46 +193,47 @@
}
if (h > 0) {
- var shadowFront = hFrontNeighbor - h;
- var shadowLeft = hLeftNeighbor - h;
+ var hFrontNeighbor2 = heightMap[(wx + TILE) + ',' + wy] || 0;
+ var hBackNeighbor2 = heightMap[wx + ',' + (wy - TILE)] || 0;
+
+ var shadowFront = hFrontNeighbor2 - h;
+ var shadowBack = hBackNeighbor2 - h;
if (shadowFront > 0) {
var shadowW = Math.min(shadowFront * 2, TILE);
var tt = shadowW / 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) * tt, wy + TILE - GAP/2, h * HEIGHT_UNIT);
- var topB = project(wx + TILE - GAP/2 - (TILE - GAP) * tt, wy + TILE - GAP/2, h * HEIGHT_UNIT);
+ var top3 = project(wx + TILE - GAP/2, wy + GAP/2, h * HEIGHT_UNIT);
+ var topA = project(wx + TILE - GAP/2, wy + TILE - GAP/2 - (TILE - GAP) * tt, h * HEIGHT_UNIT);
+ var topB = project(wx + TILE - GAP/2, wy + GAP/2 + (TILE - GAP) * tt, h * HEIGHT_UNIT);
shadows.push({
- x: wx, y: wy,
points: [
- { x: top1[0], y: top1[1] },
+ { x: top2[0], y: top2[1] },
{ x: topA[0], y: topA[1] },
{ x: topB[0], y: topB[1] },
- { x: top2[0], y: top2[1] }
+ { x: top3[0], y: top3[1] }
],
- depth: (wx + wy) - 1
+ depth: (wx + wy) + 1
});
}
- if (shadowLeft > 0) {
- var shadowW = Math.min(shadowLeft * 2, TILE);
+ if (shadowBack > 0) {
+ var shadowW = Math.min(shadowBack * 2, TILE);
var tt = shadowW / 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) * tt, h * HEIGHT_UNIT);
- var topB = project(wx + GAP/2, wy + TILE - GAP/2 - (TILE - GAP) * tt, h * HEIGHT_UNIT);
+ var top4 = project(wx + GAP/2, wy + GAP/2, h * HEIGHT_UNIT);
+ var topA = project(wx + GAP/2 + (TILE - GAP) * tt, wy + TILE - GAP/2, h * HEIGHT_UNIT);
+ var topB = project(wx + GAP/2 + (TILE - GAP) * tt, wy + GAP/2, h * HEIGHT_UNIT);
shadows.push({
- x: wx, y: wy,
points: [
{ x: top4[0], y: top4[1] },
{ x: topA[0], y: topA[1] },
{ x: topB[0], y: topB[1] },
{ x: top1[0], y: top1[1] }
],
- depth: (wx + wy) - 1
+ depth: (wx + wy) + 1
});
}
}