Upload index.html
Browse files- index.html +17 -6
index.html
CHANGED
|
@@ -1680,12 +1680,23 @@ function drawFishShadows(t) {
|
|
| 1680 |
|
| 1681 |
// Calculate sun position based on raw day phase (linear progression)
|
| 1682 |
const p = ((t / CYCLE) % 1 + 1) % 1; // 0 to 1, linear throughout the day
|
| 1683 |
-
//
|
| 1684 |
-
//
|
| 1685 |
-
|
| 1686 |
-
|
| 1687 |
-
|
| 1688 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1689 |
|
| 1690 |
for (const f of fishes) {
|
| 1691 |
// Fish blocks light, casting a shadow that extends down to the sand at an angle
|
|
|
|
| 1680 |
|
| 1681 |
// Calculate sun position based on raw day phase (linear progression)
|
| 1682 |
const p = ((t / CYCLE) % 1 + 1) % 1; // 0 to 1, linear throughout the day
|
| 1683 |
+
// Daytime is p=0 to p=0.5 (DUSK_START), night is p=0.5833 to p=0.9167
|
| 1684 |
+
// Sun moves from left to right across the sky during the day only
|
| 1685 |
+
let sunPhase;
|
| 1686 |
+
if (p < DUSK_START) {
|
| 1687 |
+
// Daytime: sun moves from left to right
|
| 1688 |
+
sunPhase = p / DUSK_START; // 0 to 1 during daytime
|
| 1689 |
+
} else if (p < DAWN_START) {
|
| 1690 |
+
// Night: sun is set, shadows are at sunset position
|
| 1691 |
+
sunPhase = 1;
|
| 1692 |
+
} else {
|
| 1693 |
+
// Dawn: sun is rising, shadows are at sunrise position
|
| 1694 |
+
sunPhase = 0;
|
| 1695 |
+
}
|
| 1696 |
+
|
| 1697 |
+
// Sun angle: -1.25 to +1.25 radians (left to right)
|
| 1698 |
+
const sunAngle = (sunPhase - 0.5) * Math.PI * 0.8;
|
| 1699 |
+
const shadowAngle = Math.atan2(1, Math.tan(sunAngle + Math.PI/2));
|
| 1700 |
|
| 1701 |
for (const f of fishes) {
|
| 1702 |
// Fish blocks light, casting a shadow that extends down to the sand at an angle
|