File size: 4,026 Bytes
29eb60e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<!doctype html>
<html lang="ar" dir="rtl">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>تجربة محاكاة السماء والقبلة</title>
  <style>
    body {
      margin: 0;
      font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      background: #071326;
      color: #fff;
    }

    .sky {
      position: relative;
      min-height: 100vh;
      overflow: hidden;
      transition: background 900ms linear;
    }

    .sun,
    .moon,
    .kaaba {
      position: absolute;
      left: 50%;
      top: 50%;
      width: 40px;
      height: 40px;
      border-radius: 50%;
      transform: translate(-50%, -50%);
      transition: left 900ms linear, top 900ms linear, opacity 500ms linear;
    }

    .sun {
      background: #ffd45c;
      box-shadow: 0 0 36px rgba(255, 212, 92, .72);
    }

    .kaaba {
      right: 24px;
      bottom: 82px;
      left: auto;
      top: auto;
      width: 54px;
      height: 54px;
      border-radius: 8px;
      background: linear-gradient(180deg, #191919, #050505);
      border: 3px solid #d7b56d;
    }

    .shadow-base {
      position: absolute;
      right: 50%;
      bottom: 86px;
      width: 10px;
      height: 64px;
      background: rgba(255, 255, 255, .72);
      border-radius: 8px;
    }

    .shadow {
      position: absolute;
      right: calc(50% + 4px);
      bottom: 86px;
      height: 10px;
      width: 80px;
      background: rgba(0, 0, 0, .42);
      border-radius: 999px;
      transform-origin: right center;
      transition: width 900ms linear, transform 900ms linear, opacity 500ms linear;
    }

    .horizon {
      position: absolute;
      inset-inline: 0;
      bottom: 0;
      height: 105px;
      background: linear-gradient(180deg, rgba(38, 79, 56, .2), rgba(21, 73, 45, .9));
    }

    .info {
      position: absolute;
      inset-inline: 16px;
      bottom: 16px;
      padding: 12px 14px;
      border-radius: 8px;
      background: rgba(0, 0, 0, .42);
      backdrop-filter: blur(8px);
      line-height: 1.7;
      font-size: 14px;
    }

    .controls {
      position: absolute;
      top: 16px;
      inset-inline: 16px;
      display: flex;
      gap: 8px;
      flex-wrap: wrap;
    }

    button {
      border: 0;
      border-radius: 8px;
      padding: 10px 12px;
      font: inherit;
      cursor: pointer;
    }
  </style>
</head>
<body>
  <main id="sky" class="sky">
    <div class="controls">
      <button id="enableCompass">تفعيل اتجاه الهاتف</button>
    </div>
    <div id="sun" class="sun"></div>
    <div id="moon" class="moon"></div>
    <div id="kaaba" class="kaaba" title="محاكاة اتجاه القبلة"></div>
    <div class="shadow-base"></div>
    <div id="shadow" class="shadow"></div>
    <div class="horizon"></div>
    <div id="info" class="info">جاري تشغيل المحاكاة...</div>
  </main>

  <script src="./celestial_simulation.js"></script>
  <script>
    async function main() {
      const registry = await fetch("./sky_simulation_registry.json").then((response) => response.json());
      const renderer = new CelestialSimulation.SkySimulationRenderer({
        container: document.getElementById("sky"),
        sun: document.getElementById("sun"),
        moon: document.getElementById("moon"),
        kaaba: document.getElementById("kaaba"),
        shadow: document.getElementById("shadow"),
        info: document.getElementById("info")
      }, registry);

      const controller = new CelestialSimulation.CelestialSimulationController({
        location: { lat: 31.9539, lng: 35.9106 },
        registry,
        renderer
      });

      controller.start({ intervalMs: 60000 });
      document.getElementById("enableCompass").addEventListener("click", () => {
        controller.enableCompass((message) => {
          document.getElementById("info").textContent = message;
        });
      });
    }

    main();
  </script>
</body>
</html>