@codexstar/pi-pompom 1.5.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/extensions/pompom.ts +100 -24
- package/package.json +1 -1
package/extensions/pompom.ts
CHANGED
|
@@ -496,45 +496,121 @@ function getPixel(px: number, py: number, objects: RenderObj[], skyColors: Retur
|
|
|
496
496
|
const directHit = getObjHit(px, py, objects);
|
|
497
497
|
if (directHit.hitObj) return shadeObject(directHit, px, py, objects);
|
|
498
498
|
|
|
499
|
+
const w = (skyColors as any).weather as Weather | undefined;
|
|
500
|
+
const tod = (skyColors as any).timeOfDay as TimeOfDay | undefined;
|
|
501
|
+
|
|
499
502
|
const grad = Math.max(0, (1.0 + py) / 2.0);
|
|
500
503
|
let bgR = Math.floor(skyColors.rTop * (1 - grad) + skyColors.rBot * grad);
|
|
501
504
|
let bgG = Math.floor(skyColors.gTop * (1 - grad) + skyColors.gBot * grad);
|
|
502
505
|
let bgB = Math.floor(skyColors.bTop * (1 - grad) + skyColors.bBot * grad);
|
|
503
506
|
|
|
504
|
-
//
|
|
507
|
+
// 5. SNOW: soft glow/haziness across whole sky
|
|
508
|
+
if (w === "snow") {
|
|
509
|
+
bgR = Math.min(255, bgR + 30);
|
|
510
|
+
bgG = Math.min(255, bgG + 30);
|
|
511
|
+
bgB = Math.min(255, bgB + 40);
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
// 3. STARS & MOON
|
|
505
515
|
if (skyColors.isNight) {
|
|
506
|
-
const
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
516
|
+
const moonDist = Math.sqrt((px - 0.4) ** 2 + (py + 0.4) ** 2);
|
|
517
|
+
if (moonDist < 0.15) {
|
|
518
|
+
const moonGlow = 1.0 - (moonDist / 0.15);
|
|
519
|
+
bgR = Math.min(255, bgR + moonGlow * 60);
|
|
520
|
+
bgG = Math.min(255, bgG + moonGlow * 60);
|
|
521
|
+
bgB = Math.min(255, bgB + moonGlow * 80);
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
const starPattern = Math.sin(px * 150) * Math.cos(py * 150 + px * 40);
|
|
525
|
+
if (starPattern > 0.92) {
|
|
526
|
+
const twinkle = Math.sin(time * 3 + px * 30 + py * 40) * 0.5 + 0.5;
|
|
527
|
+
const starColorHash = Math.abs(Math.sin(px * 313 + py * 717));
|
|
528
|
+
let sr = 255, sg = 255, sb = 255;
|
|
529
|
+
if (starColorHash < 0.3) { sr = 180; sg = 200; sb = 255; }
|
|
530
|
+
else if (starColorHash < 0.6) { sr = 255; sg = 255; sb = 180; }
|
|
531
|
+
else if (starColorHash < 0.8) { sr = 255; sg = 180; sb = 150; }
|
|
532
|
+
|
|
533
|
+
const intensity = starPattern > 0.98 ? twinkle : twinkle * 0.4;
|
|
534
|
+
bgR = Math.min(255, bgR + sr * intensity);
|
|
535
|
+
bgG = Math.min(255, bgG + sg * intensity);
|
|
536
|
+
bgB = Math.min(255, bgB + sb * intensity);
|
|
537
|
+
}
|
|
510
538
|
}
|
|
511
539
|
|
|
512
|
-
//
|
|
513
|
-
|
|
540
|
+
// 4. SUNSET/DAWN (SUN DISK)
|
|
541
|
+
if (tod === "sunset" || tod === "dawn") {
|
|
542
|
+
const sunDist = Math.sqrt((px + 0.3) ** 2 + (py - 0.2) ** 2);
|
|
543
|
+
const halo = Math.max(0, 1.0 - sunDist * 2.0);
|
|
544
|
+
if (sunDist < 0.05) {
|
|
545
|
+
bgR = 255; bgG = 240; bgB = 200;
|
|
546
|
+
} else if (halo > 0) {
|
|
547
|
+
const hIntensity = Math.pow(halo, 2);
|
|
548
|
+
bgR = Math.min(255, bgR + hIntensity * 120);
|
|
549
|
+
bgG = Math.min(255, bgG + hIntensity * (tod === "sunset" ? 70 : 90));
|
|
550
|
+
bgB = Math.min(255, bgB + hIntensity * 40);
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
// 1. CLOUDS & 6. STORM CLOUDS
|
|
514
555
|
if (w === "cloudy" || w === "rain" || w === "storm" || w === "snow") {
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
556
|
+
let cloudDensity = w === "storm" ? 0.8 : w === "rain" ? 0.6 : w === "snow" ? 0.5 : 0.4;
|
|
557
|
+
|
|
558
|
+
// Denser in upper half, wispy at lower altitudes
|
|
559
|
+
cloudDensity *= Math.max(0, 1.0 - (py + 1.0) / 1.6);
|
|
560
|
+
|
|
561
|
+
const drift = time * 0.15;
|
|
562
|
+
const n1 = Math.sin((px + drift) * 6) * Math.cos(py * 8) * 0.5 + 0.5;
|
|
563
|
+
const n2 = Math.sin((px - drift * 0.5) * 14 + py * 10) * 0.5 + 0.5;
|
|
564
|
+
const n3 = Math.sin((px + drift * 2) * 25 - py * 20) * 0.5 + 0.5;
|
|
565
|
+
const noise = n1 * 0.5 + n2 * 0.3 + n3 * 0.2;
|
|
566
|
+
|
|
567
|
+
const shadowNoise = Math.sin((px + drift) * 6 + 0.3) * Math.cos((py - 0.08) * 8) * 0.5 + 0.5;
|
|
568
|
+
|
|
569
|
+
if (noise > 1.0 - cloudDensity) {
|
|
570
|
+
const blend = Math.min(1.0, (noise - (1.0 - cloudDensity)) * 4);
|
|
571
|
+
const isShadow = shadowNoise < noise - 0.1;
|
|
572
|
+
|
|
573
|
+
let cr = w === "storm" ? 60 : 200;
|
|
574
|
+
let cg = w === "storm" ? 65 : 205;
|
|
575
|
+
let cb = w === "storm" ? 75 : 215;
|
|
576
|
+
|
|
577
|
+
if (isShadow) {
|
|
578
|
+
cr *= 0.6; cg *= 0.6; cb *= 0.7;
|
|
579
|
+
}
|
|
580
|
+
|
|
521
581
|
bgR = Math.floor(bgR * (1 - blend) + cr * blend);
|
|
522
582
|
bgG = Math.floor(bgG * (1 - blend) + cg * blend);
|
|
523
583
|
bgB = Math.floor(bgB * (1 - blend) + cb * blend);
|
|
524
584
|
}
|
|
525
585
|
}
|
|
526
586
|
|
|
527
|
-
//
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
587
|
+
// 6. STORM LIGHTNING
|
|
588
|
+
if (w === "storm" && Math.sin(time * 47) > 0.99) {
|
|
589
|
+
bgR = Math.min(255, bgR + 180);
|
|
590
|
+
bgG = Math.min(255, bgG + 180);
|
|
591
|
+
bgB = Math.min(255, bgB + 200);
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
// 2. RAIN VISUAL
|
|
595
|
+
if (w === "rain" || w === "storm") {
|
|
596
|
+
if (Math.sin(px * 40 + py * 80 + time * 15) > 0.95) {
|
|
597
|
+
bgR = Math.min(255, bgR + 50);
|
|
598
|
+
bgG = Math.min(255, bgG + 50);
|
|
599
|
+
bgB = Math.min(255, bgB + 70);
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
// 7. FOG/MIST
|
|
604
|
+
if (w === "rain" || w === "snow") {
|
|
605
|
+
const fogDist = Math.max(0, py);
|
|
606
|
+
if (fogDist > 0) {
|
|
607
|
+
const fogBlend = Math.min(1.0, (fogDist / 0.6) * 0.5);
|
|
608
|
+
const fr = w === "snow" ? 220 : 140;
|
|
609
|
+
const fg = w === "snow" ? 220 : 150;
|
|
610
|
+
const fb = w === "snow" ? 230 : 160;
|
|
611
|
+
bgR = Math.floor(bgR * (1 - fogBlend) + fr * fogBlend);
|
|
612
|
+
bgG = Math.floor(bgG * (1 - fogBlend) + fg * fogBlend);
|
|
613
|
+
bgB = Math.floor(bgB * (1 - fogBlend) + fb * fogBlend);
|
|
538
614
|
}
|
|
539
615
|
}
|
|
540
616
|
|