One commited on
Commit
7e356c3
·
verified ·
1 Parent(s): 6db340c

Upload index.html

Browse files
Files changed (1) hide show
  1. 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
- // Sun moves from left to right across the sky during the day
1684
- // p=0 (dawn): sun on left, shadows point right
1685
- // p=0.5 (noon): sun overhead, shadows are short and straight down
1686
- // p=1 (dusk): sun on right, shadows point left
1687
- const sunAngle = (p - 0.5) * Math.PI * 0.8; // -1.25 to +1.25 radians
1688
- const shadowAngle = Math.atan2(1, Math.tan(sunAngle + Math.PI/2)); // convert to shadow angle
 
 
 
 
 
 
 
 
 
 
 
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