webxos commited on
Commit
87c7331
·
verified ·
1 Parent(s): 1465cac

Upload webXOS_timelink_finalv1.html

Browse files
Files changed (1) hide show
  1. webXOS_timelink_finalv1.html +2225 -0
webXOS_timelink_finalv1.html ADDED
@@ -0,0 +1,2225 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>TIMELINK v1.0 - by webXOS</title>
7
+
8
+ <!-- Libraries -->
9
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
10
+ <script src="https://cdn.jsdelivr.net/npm/three@0.128.0/examples/js/controls/OrbitControls.min.js"></script>
11
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
12
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/2.0.5/FileSaver.min.js"></script>
13
+
14
+ <style>
15
+ * {
16
+ margin: 0;
17
+ padding: 0;
18
+ box-sizing: border-box;
19
+ }
20
+
21
+ body {
22
+ font-family: 'Courier New', monospace;
23
+ background: #000000;
24
+ color: #00ff00;
25
+ overflow: hidden;
26
+ height: 100vh;
27
+ width: 100vw;
28
+ }
29
+
30
+ /* Main Canvas */
31
+ #threeCanvas {
32
+ position: fixed;
33
+ top: 0;
34
+ left: 0;
35
+ width: 100vw;
36
+ height: 100vh;
37
+ z-index: 1;
38
+ }
39
+
40
+ /* UI Overlay */
41
+ #ui-overlay {
42
+ position: fixed;
43
+ top: 0;
44
+ left: 0;
45
+ width: 100vw;
46
+ height: 100vh;
47
+ z-index: 2;
48
+ pointer-events: none;
49
+ }
50
+
51
+ /* Minimal Header */
52
+ #minimal-header {
53
+ position: absolute;
54
+ top: 0;
55
+ left: 0;
56
+ width: 100%;
57
+ background: rgba(0, 20, 0, 0.85);
58
+ padding: 10px 20px;
59
+ display: flex;
60
+ justify-content: space-between;
61
+ align-items: center;
62
+ border-bottom: 1px solid #00ff00;
63
+ backdrop-filter: blur(5px);
64
+ pointer-events: auto;
65
+ height: 50px;
66
+ }
67
+
68
+ .minimal-logo {
69
+ font-size: 16px;
70
+ font-weight: bold;
71
+ color: #00ff00;
72
+ text-shadow: 0 0 10px #00ff00;
73
+ }
74
+
75
+ .minimal-stats {
76
+ display: flex;
77
+ gap: 20px;
78
+ font-size: 12px;
79
+ }
80
+
81
+ .stat-item {
82
+ display: flex;
83
+ flex-direction: column;
84
+ align-items: center;
85
+ }
86
+
87
+ .stat-label {
88
+ color: #00cc00;
89
+ font-size: 10px;
90
+ }
91
+
92
+ .stat-value {
93
+ color: #00ff00;
94
+ font-weight: bold;
95
+ }
96
+
97
+ /* Control Panel */
98
+ #control-panel {
99
+ position: absolute;
100
+ top: 60px;
101
+ left: 20px;
102
+ width: 200px;
103
+ background: rgba(0, 30, 0, 0.95);
104
+ border: 2px solid #00ff00;
105
+ border-radius: 8px;
106
+ padding: 15px;
107
+ backdrop-filter: blur(5px);
108
+ pointer-events: auto;
109
+ }
110
+
111
+ .control-title {
112
+ color: #00ff00;
113
+ font-size: 14px;
114
+ margin-bottom: 15px;
115
+ text-align: center;
116
+ border-bottom: 1px solid rgba(0, 255, 0, 0.3);
117
+ padding-bottom: 5px;
118
+ }
119
+
120
+ .shape-selector {
121
+ display: flex;
122
+ flex-direction: column;
123
+ gap: 8px;
124
+ margin-bottom: 15px;
125
+ }
126
+
127
+ .shape-btn {
128
+ background: rgba(0, 40, 0, 0.7);
129
+ border: 1px solid #00ff00;
130
+ color: #00ff00;
131
+ padding: 8px;
132
+ font-size: 12px;
133
+ cursor: pointer;
134
+ border-radius: 4px;
135
+ transition: all 0.3s;
136
+ text-align: center;
137
+ }
138
+
139
+ .shape-btn:hover {
140
+ background: rgba(0, 255, 0, 0.1);
141
+ box-shadow: 0 0 10px #00ff00;
142
+ }
143
+
144
+ .shape-btn.active {
145
+ background: rgba(0, 255, 0, 0.2);
146
+ box-shadow: 0 0 15px #00ff00;
147
+ border-color: #00ffff;
148
+ }
149
+
150
+ /* Central Generate Button */
151
+ #central-generate-btn {
152
+ position: fixed;
153
+ bottom: 40px;
154
+ left: 50%;
155
+ transform: translateX(-50%);
156
+ width: 280px;
157
+ background: linear-gradient(45deg, #006600, #00cc00);
158
+ border: none;
159
+ color: white;
160
+ padding: 20px 40px;
161
+ font-family: 'Courier New', monospace;
162
+ font-size: 18px;
163
+ font-weight: bold;
164
+ cursor: pointer;
165
+ border-radius: 12px;
166
+ text-transform: uppercase;
167
+ letter-spacing: 2px;
168
+ transition: all 0.3s;
169
+ z-index: 10;
170
+ pointer-events: auto;
171
+ box-shadow: 0 0 30px rgba(0, 255, 0, 0.5);
172
+ text-align: center;
173
+ }
174
+
175
+ #central-generate-btn:hover {
176
+ background: linear-gradient(45deg, #00cc00, #00ff00);
177
+ box-shadow: 0 0 40px rgba(0, 255, 0, 0.8);
178
+ transform: translateX(-50%) scale(1.05);
179
+ }
180
+
181
+ #central-generate-btn.generating {
182
+ background: linear-gradient(45deg, #cc0000, #ff0000);
183
+ animation: pulse 2s infinite;
184
+ box-shadow: 0 0 40px rgba(255, 0, 0, 0.6);
185
+ }
186
+
187
+ #central-generate-btn.paused {
188
+ background: linear-gradient(45deg, #666600, #cccc00);
189
+ box-shadow: 0 0 30px rgba(204, 204, 0, 0.6);
190
+ }
191
+
192
+ /* Time Scale Control */
193
+ .time-control {
194
+ margin-top: 10px;
195
+ padding-top: 10px;
196
+ border-top: 1px solid rgba(0, 255, 0, 0.3);
197
+ }
198
+
199
+ .time-slider {
200
+ width: 100%;
201
+ margin: 10px 0;
202
+ }
203
+
204
+ .time-value {
205
+ text-align: center;
206
+ font-size: 12px;
207
+ color: #00cc00;
208
+ margin-top: 5px;
209
+ }
210
+
211
+ /* Export Panel */
212
+ #export-panel {
213
+ position: absolute;
214
+ bottom: 20px;
215
+ right: 20px;
216
+ width: 200px;
217
+ background: rgba(0, 30, 0, 0.95);
218
+ border: 2px solid #00ff00;
219
+ border-radius: 8px;
220
+ padding: 15px;
221
+ backdrop-filter: blur(5px);
222
+ pointer-events: auto;
223
+ }
224
+
225
+ .export-btn {
226
+ width: 100%;
227
+ background: rgba(0, 60, 0, 0.8);
228
+ border: 1px solid #00ff00;
229
+ color: #00ff00;
230
+ padding: 10px;
231
+ font-family: 'Courier New', monospace;
232
+ font-size: 12px;
233
+ cursor: pointer;
234
+ border-radius: 4px;
235
+ margin: 5px 0;
236
+ transition: all 0.3s;
237
+ }
238
+
239
+ .export-btn:hover {
240
+ background: rgba(0, 255, 0, 0.1);
241
+ box-shadow: 0 0 10px #00ff00;
242
+ }
243
+
244
+ .export-btn.ready {
245
+ background: linear-gradient(45deg, #006600, #00cc00);
246
+ color: white;
247
+ font-weight: bold;
248
+ }
249
+
250
+ /* Full Screen Button */
251
+ #fullscreen-btn {
252
+ position: absolute;
253
+ top: 10px;
254
+ right: 10px;
255
+ background: rgba(0, 40, 0, 0.8);
256
+ border: 1px solid #00ff00;
257
+ color: #00ff00;
258
+ padding: 6px 12px;
259
+ font-family: 'Courier New', monospace;
260
+ font-size: 11px;
261
+ cursor: pointer;
262
+ border-radius: 4px;
263
+ z-index: 3;
264
+ pointer-events: auto;
265
+ transition: all 0.3s;
266
+ }
267
+
268
+ #fullscreen-btn:hover {
269
+ background: rgba(0, 255, 0, 0.1);
270
+ box-shadow: 0 0 10px #00ff00;
271
+ }
272
+
273
+ /* Emergency Stop Button */
274
+ #emergency-btn {
275
+ position: absolute;
276
+ bottom: 20px;
277
+ left: 20px;
278
+ background: rgba(60, 0, 0, 0.8);
279
+ border: 1px solid #ff0000;
280
+ color: #ff0000;
281
+ padding: 10px 15px;
282
+ font-family: 'Courier New', monospace;
283
+ font-size: 12px;
284
+ cursor: pointer;
285
+ border-radius: 4px;
286
+ pointer-events: auto;
287
+ transition: all 0.3s;
288
+ }
289
+
290
+ #emergency-btn:hover {
291
+ background: rgba(255, 0, 0, 0.1);
292
+ box-shadow: 0 0 15px #ff0000;
293
+ }
294
+
295
+ /* Progress Display */
296
+ #progress-display {
297
+ position: absolute;
298
+ top: 60px;
299
+ right: 20px;
300
+ width: 200px;
301
+ background: rgba(0, 30, 0, 0.95);
302
+ border: 2px solid #00ff00;
303
+ border-radius: 8px;
304
+ padding: 15px;
305
+ backdrop-filter: blur(5px);
306
+ pointer-events: auto;
307
+ }
308
+
309
+ .progress-item {
310
+ margin: 8px 0;
311
+ }
312
+
313
+ .progress-label {
314
+ display: flex;
315
+ justify-content: space-between;
316
+ font-size: 11px;
317
+ color: #00cc00;
318
+ margin-bottom: 3px;
319
+ }
320
+
321
+ .progress-bar {
322
+ width: 100%;
323
+ height: 6px;
324
+ background: rgba(0, 0, 0, 0.5);
325
+ border: 1px solid #00ff00;
326
+ border-radius: 3px;
327
+ overflow: hidden;
328
+ }
329
+
330
+ .progress-fill {
331
+ height: 100%;
332
+ background: linear-gradient(90deg, #00ff00, #00cc00);
333
+ width: 0%;
334
+ transition: width 0.5s ease;
335
+ }
336
+
337
+ /* Crystal Info */
338
+ .crystal-info {
339
+ font-size: 10px;
340
+ color: #00ff00;
341
+ text-align: center;
342
+ margin-top: 10px;
343
+ padding-top: 10px;
344
+ border-top: 1px solid rgba(0, 255, 0, 0.3);
345
+ }
346
+
347
+ /* Image Capture Panel */
348
+ #capture-panel {
349
+ position: absolute;
350
+ top: 280px;
351
+ left: 20px;
352
+ width: 200px;
353
+ background: rgba(0, 30, 0, 0.95);
354
+ border: 2px solid #00ff00;
355
+ border-radius: 8px;
356
+ padding: 15px;
357
+ backdrop-filter: blur(5px);
358
+ pointer-events: auto;
359
+ }
360
+
361
+ .capture-controls {
362
+ display: flex;
363
+ gap: 10px;
364
+ margin-top: 10px;
365
+ }
366
+
367
+ .capture-btn {
368
+ flex: 1;
369
+ background: rgba(0, 60, 0, 0.8);
370
+ border: 1px solid #00ff00;
371
+ color: #00ff00;
372
+ padding: 8px;
373
+ font-size: 11px;
374
+ cursor: pointer;
375
+ border-radius: 4px;
376
+ text-align: center;
377
+ }
378
+
379
+ .capture-btn:hover {
380
+ background: rgba(0, 255, 0, 0.1);
381
+ box-shadow: 0 0 10px #00ff00;
382
+ }
383
+
384
+ /* System Warning */
385
+ #system-warning {
386
+ position: fixed;
387
+ top: 50%;
388
+ left: 50%;
389
+ transform: translate(-50%, -50%);
390
+ background: rgba(0, 20, 0, 0.95);
391
+ border: 2px solid #ff0000;
392
+ padding: 30px;
393
+ color: #ff0000;
394
+ text-align: center;
395
+ display: none;
396
+ z-index: 100;
397
+ max-width: 400px;
398
+ border-radius: 8px;
399
+ backdrop-filter: blur(10px);
400
+ pointer-events: auto;
401
+ }
402
+
403
+ /* Notification */
404
+ #notification {
405
+ position: fixed;
406
+ top: 50%;
407
+ left: 50%;
408
+ transform: translate(-50%, -50%);
409
+ background: rgba(0, 30, 0, 0.95);
410
+ border: 2px solid #00ff00;
411
+ padding: 30px;
412
+ color: #00ff00;
413
+ text-align: center;
414
+ display: none;
415
+ z-index: 100;
416
+ max-width: 400px;
417
+ border-radius: 8px;
418
+ backdrop-filter: blur(10px);
419
+ pointer-events: auto;
420
+ }
421
+
422
+ /* Animations */
423
+ @keyframes pulse {
424
+ 0%, 100% { opacity: 1; }
425
+ 50% { opacity: 0.7; }
426
+ }
427
+
428
+ @keyframes glow {
429
+ 0%, 100% { box-shadow: 0 0 10px #00ff00; }
430
+ 50% { box-shadow: 0 0 20px #00ff00, 0 0 30px #00ff00; }
431
+ }
432
+
433
+ @keyframes float {
434
+ 0%, 100% { transform: translateX(-50%) translateY(0px); }
435
+ 50% { transform: translateX(-50%) translateY(-10px); }
436
+ }
437
+
438
+ .glow {
439
+ animation: glow 2s infinite;
440
+ }
441
+
442
+ .float {
443
+ animation: float 3s ease-in-out infinite;
444
+ }
445
+
446
+ /* Time Display */
447
+ #time-display {
448
+ position: absolute;
449
+ top: 120px;
450
+ left: 50%;
451
+ transform: translateX(-50%);
452
+ background: rgba(0, 30, 0, 0.9);
453
+ border: 2px solid #00ff00;
454
+ padding: 10px 20px;
455
+ border-radius: 8px;
456
+ min-width: 200px;
457
+ backdrop-filter: blur(5px);
458
+ pointer-events: auto;
459
+ text-align: center;
460
+ }
461
+
462
+ .time-scale-value {
463
+ font-size: 24px;
464
+ color: #00ff00;
465
+ font-weight: bold;
466
+ font-family: monospace;
467
+ margin: 5px 0;
468
+ text-shadow: 0 0 10px #00ff00;
469
+ }
470
+
471
+ .time-label {
472
+ color: #00cc00;
473
+ font-size: 10px;
474
+ letter-spacing: 1px;
475
+ }
476
+ </style>
477
+ </head>
478
+ <body>
479
+ <canvas id="threeCanvas"></canvas>
480
+
481
+ <div id="ui-overlay">
482
+ <!-- Minimal Header -->
483
+ <div id="minimal-header">
484
+ <div class="minimal-logo">TIMELINK // by webXOS</div>
485
+ <div class="minimal-stats">
486
+ <div class="stat-item">
487
+ <div class="stat-label">CRYSTALS</div>
488
+ <div class="stat-value" id="crystalCount">0</div>
489
+ </div>
490
+ <div class="stat-item">
491
+ <div class="stat-label">IMAGES</div>
492
+ <div class="stat-value" id="imageCount">0</div>
493
+ </div>
494
+ <div class="stat-item">
495
+ <div class="stat-label">FPS</div>
496
+ <div class="stat-value" id="fpsCounter">60</div>
497
+ </div>
498
+ </div>
499
+ </div>
500
+
501
+ <!-- Control Panel -->
502
+ <div id="control-panel">
503
+ <div class="control-title">CRYSTAL SHAPES</div>
504
+
505
+ <div class="shape-selector">
506
+ <button class="shape-btn active" onclick="selectShape('quantum_spiral')">🌀 QUANTUM SPIRAL</button>
507
+ <button class="shape-btn" onclick="selectShape('fractal_matrix')">⬢ FRACTAL MATRIX</button>
508
+ <button class="shape-btn" onclick="selectShape('neural_lattice')">⊞ NEURAL LATTICE</button>
509
+ <button class="shape-btn" onclick="selectShape('temporal_ring')">⭕ TEMPORAL RING</button>
510
+ </div>
511
+
512
+ <div class="time-control">
513
+ <div class="time-label">TIME SCALE</div>
514
+ <input type="range" id="timeScale" class="time-slider" min="0.1" max="5.0" value="1.0" step="0.1">
515
+ <div class="time-value" id="timeScaleValue">1.0x</div>
516
+ </div>
517
+ </div>
518
+
519
+ <!-- Capture Panel -->
520
+ <div id="capture-panel">
521
+ <div class="control-title">IMAGE CAPTURE</div>
522
+
523
+ <div class="progress-item">
524
+ <div class="progress-label">
525
+ <span>CAPTURED</span>
526
+ <span id="captureCount">0</span>
527
+ </div>
528
+ <div class="progress-bar">
529
+ <div id="captureProgress" class="progress-fill"></div>
530
+ </div>
531
+ </div>
532
+
533
+ <div class="capture-controls">
534
+ <button class="capture-btn" onclick="captureImage()">📸 CAPTURE</button>
535
+ <button class="capture-btn" onclick="toggleAutoCapture()" id="autoCaptureBtn">⚙ AUTO: OFF</button>
536
+ </div>
537
+
538
+ <div class="crystal-info">
539
+ <div>Quality: HD (1280x720)</div>
540
+ <div>Format: PNG + JSON</div>
541
+ </div>
542
+ </div>
543
+
544
+ <!-- Progress Display -->
545
+ <div id="progress-display">
546
+ <div class="control-title">GENERATION PROGRESS</div>
547
+
548
+ <div class="progress-item">
549
+ <div class="progress-label">
550
+ <span>CURRENT CRYSTAL</span>
551
+ <span id="crystalProgressText">0%</span>
552
+ </div>
553
+ <div class="progress-bar">
554
+ <div id="crystalProgress" class="progress-fill"></div>
555
+ </div>
556
+ </div>
557
+
558
+ <div class="progress-item">
559
+ <div class="progress-label">
560
+ <span>DATASET SIZE</span>
561
+ <span id="datasetSize">0 MB</span>
562
+ </div>
563
+ <div class="progress-bar">
564
+ <div id="datasetProgress" class="progress-fill"></div>
565
+ </div>
566
+ </div>
567
+
568
+ <div class="crystal-info">
569
+ <div id="currentCrystalInfo">READY TO START</div>
570
+ <div id="vertexCount">0 vertices / 0 edges</div>
571
+ </div>
572
+ </div>
573
+
574
+ <!-- Export Panel -->
575
+ <div id="export-panel">
576
+ <div class="control-title">DATASET EXPORT</div>
577
+
578
+ <button class="export-btn" onclick="exportCurrentCrystal()">
579
+ 💾 EXPORT CURRENT
580
+ </button>
581
+
582
+ <button class="export-btn" onclick="exportCompleteDataset()">
583
+ 📦 EXPORT COMPLETE
584
+ </button>
585
+
586
+ <button class="export-btn" onclick="exportHuggingFace()">
587
+ 🤗 HUGGING FACE
588
+ </button>
589
+
590
+ <div class="crystal-info" style="margin-top: 10px;">
591
+ <div>Includes: Images + Data</div>
592
+ <div>Ready: <span id="exportReady">NO</span></div>
593
+ </div>
594
+ </div>
595
+
596
+ <!-- Central Generate Button -->
597
+ <button id="central-generate-btn" onclick="toggleAutomatedGeneration()" class="float">
598
+ ⚡ GENERATE CRYSTALS
599
+ </button>
600
+
601
+ <!-- Full Screen Button -->
602
+ <button id="fullscreen-btn" onclick="toggleFullscreen()">⛶ FULLSCREEN</button>
603
+
604
+ <!-- Emergency Stop -->
605
+ <button id="emergency-btn" onclick="emergencyStop()">🛑 EMERGENCY STOP</button>
606
+
607
+ <!-- Time Display -->
608
+ <div id="time-display">
609
+ <div class="time-label">AUTOMATED GENERATOR</div>
610
+ <div class="time-scale-value" id="timeDisplay">00:00:00</div>
611
+ <div class="time-label">TOTAL TIME: <span id="totalTime">0s</span></div>
612
+ </div>
613
+
614
+ <!-- System Warning -->
615
+ <div id="system-warning">
616
+ <h3>⚠️ SYSTEM LIMIT REACHED</h3>
617
+ <p>Memory usage approaching browser limits.</p>
618
+ <p>Auto-exporting current dataset...</p>
619
+ <div style="margin-top: 20px;">
620
+ <button onclick="continueGeneration()" style="background: rgba(0,60,0,0.8); border: 1px solid #00ff00; color: #00ff00; padding: 10px 20px; cursor: pointer; margin: 5px;">
621
+ CONTINUE
622
+ </button>
623
+ <button onclick="emergencyStop()" style="background: rgba(60,0,0,0.8); border: 1px solid #ff0000; color: #ff0000; padding: 10px 20px; cursor: pointer; margin: 5px;">
624
+ STOP
625
+ </button>
626
+ </div>
627
+ </div>
628
+
629
+ <!-- Notification -->
630
+ <div id="notification">
631
+ <h3 id="notificationTitle">EXPORTING</h3>
632
+ <p id="notificationMessage">Preparing dataset...</p>
633
+ <div class="progress-bar" style="margin: 20px auto; width: 80%;">
634
+ <div id="notificationProgress" class="progress-fill"></div>
635
+ </div>
636
+ </div>
637
+ </div>
638
+
639
+ <script>
640
+ // ==================== GLOBAL STATE ====================
641
+ let scene, camera, renderer, controls;
642
+ let currentCrystal = null;
643
+ let isGenerating = false;
644
+ let generationInterval = null;
645
+ let animationId = null;
646
+ let isFullscreen = false;
647
+ let autoCaptureEnabled = false;
648
+
649
+ // Crystal generation state
650
+ let generationState = {
651
+ active: false,
652
+ crystalCount: 0,
653
+ currentShape: 'quantum_spiral',
654
+ timeScale: 1.0,
655
+ startTime: 0,
656
+ totalGenerationTime: 0,
657
+ currentCrystal: {
658
+ vertices: [],
659
+ edges: [],
660
+ size: 0,
661
+ targetSize: 200,
662
+ currentStep: 0,
663
+ maxSteps: 300,
664
+ color: new THREE.Color(0x00ff00),
665
+ shape: 'quantum_spiral'
666
+ }
667
+ };
668
+
669
+ // Dataset collection
670
+ let dataset = {
671
+ crystals: [],
672
+ currentCrystalData: [],
673
+ capturedImages: [],
674
+ autoCaptureCount: 0,
675
+ manualCaptureCount: 0,
676
+ totalImages: 0,
677
+ isExporting: false,
678
+ lastExportTime: 0
679
+ };
680
+
681
+ // System monitoring
682
+ let systemMonitor = {
683
+ fps: 60,
684
+ memoryUsage: 0,
685
+ performanceLevel: 'high',
686
+ frameCount: 0,
687
+ lastFrameTime: performance.now(),
688
+ lastCleanup: 0,
689
+ warningShown: false
690
+ };
691
+
692
+ // Color palettes for each shape
693
+ const SHAPE_COLORS = {
694
+ quantum_spiral: [0x00ff00, 0x00cc00, 0x009900], // Greens
695
+ fractal_matrix: [0x00ffff, 0x00cccc, 0x009999], // Cyans
696
+ neural_lattice: [0xff00ff, 0xcc00cc, 0x990099], // Magentas
697
+ temporal_ring: [0xffff00, 0xcccc00, 0x999900] // Yellows
698
+ };
699
+
700
+ // ==================== THREE.JS INITIALIZATION ====================
701
+ function initThreeJS() {
702
+ try {
703
+ const canvas = document.getElementById('threeCanvas');
704
+
705
+ // Scene
706
+ scene = new THREE.Scene();
707
+ scene.background = new THREE.Color(0x000000);
708
+
709
+ // Camera
710
+ const width = window.innerWidth;
711
+ const height = window.innerHeight;
712
+ camera = new THREE.PerspectiveCamera(75, width / height, 0.1, 5000);
713
+ camera.position.set(0, 150, 300);
714
+
715
+ // Renderer with better quality for image capture
716
+ renderer = new THREE.WebGLRenderer({
717
+ canvas: canvas,
718
+ antialias: true,
719
+ alpha: true,
720
+ preserveDrawingBuffer: true // Required for image capture
721
+ });
722
+ renderer.setSize(width, height);
723
+ renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
724
+
725
+ // Controls
726
+ controls = new THREE.OrbitControls(camera, renderer.domElement);
727
+ controls.enableDamping = true;
728
+ controls.dampingFactor = 0.05;
729
+ controls.minDistance = 50;
730
+ controls.maxDistance = 1000;
731
+
732
+ // Enhanced lighting for better visuals
733
+ const ambientLight = new THREE.AmbientLight(0xffffff, 0.5);
734
+ scene.add(ambientLight);
735
+
736
+ const directionalLight1 = new THREE.DirectionalLight(0xffffff, 0.8);
737
+ directionalLight1.position.set(100, 200, 100);
738
+ scene.add(directionalLight1);
739
+
740
+ const directionalLight2 = new THREE.DirectionalLight(0xffffff, 0.4);
741
+ directionalLight2.position.set(-100, -200, -100);
742
+ scene.add(directionalLight2);
743
+
744
+ // Create enhanced background
745
+ createEnhancedBackground();
746
+
747
+ console.log("TIMELINK: Three.js initialized with enhanced visuals");
748
+ return true;
749
+
750
+ } catch (error) {
751
+ console.error("TIMELINK: Three.js error:", error);
752
+ showNotification("ERROR", "Graphics system initialization failed");
753
+ return false;
754
+ }
755
+ }
756
+
757
+ function createEnhancedBackground() {
758
+ // Create multiple layers of particles for depth
759
+ createParticleLayer(5000, 500, 1000, 0x00ff00, 0.3); // Near layer
760
+ createParticleLayer(3000, 1000, 2000, 0x00ffff, 0.2); // Middle layer
761
+ createParticleLayer(2000, 2000, 4000, 0xff00ff, 0.1); // Far layer
762
+
763
+ // Add central glow effect
764
+ const glowGeometry = new THREE.SphereGeometry(10, 32, 32);
765
+ const glowMaterial = new THREE.MeshBasicMaterial({
766
+ color: 0x00ff00,
767
+ transparent: true,
768
+ opacity: 0.2,
769
+ wireframe: true
770
+ });
771
+ const centralGlow = new THREE.Mesh(glowGeometry, glowMaterial);
772
+ scene.add(centralGlow);
773
+ }
774
+
775
+ function createParticleLayer(count, minRadius, maxRadius, baseColor, opacity) {
776
+ const geometry = new THREE.BufferGeometry();
777
+ const positions = new Float32Array(count * 3);
778
+ const colors = new Float32Array(count * 3);
779
+ const sizes = new Float32Array(count);
780
+
781
+ const color = new THREE.Color(baseColor);
782
+
783
+ for (let i = 0; i < count * 3; i += 3) {
784
+ const radius = minRadius + Math.random() * (maxRadius - minRadius);
785
+ const theta = Math.random() * Math.PI * 2;
786
+ const phi = Math.acos(2 * Math.random() - 1);
787
+
788
+ positions[i] = radius * Math.sin(phi) * Math.cos(theta);
789
+ positions[i + 1] = radius * Math.sin(phi) * Math.sin(theta);
790
+ positions[i + 2] = radius * Math.cos(phi);
791
+
792
+ // Color variation
793
+ const colorVariation = Math.random() * 0.3;
794
+ colors[i] = color.r + colorVariation;
795
+ colors[i + 1] = color.g + colorVariation;
796
+ colors[i + 2] = color.b + colorVariation;
797
+
798
+ sizes[i/3] = 0.5 + Math.random() * 2;
799
+ }
800
+
801
+ geometry.setAttribute('position', new THREE.BufferAttribute(positions, 3));
802
+ geometry.setAttribute('color', new THREE.BufferAttribute(colors, 3));
803
+ geometry.setAttribute('size', new THREE.BufferAttribute(sizes, 1));
804
+
805
+ const material = new THREE.PointsMaterial({
806
+ size: 1.5,
807
+ vertexColors: true,
808
+ transparent: true,
809
+ opacity: opacity,
810
+ sizeAttenuation: true
811
+ });
812
+
813
+ const particles = new THREE.Points(geometry, material);
814
+ scene.add(particles);
815
+
816
+ // Store for animation
817
+ if (!window.particleLayers) window.particleLayers = [];
818
+ window.particleLayers.push(particles);
819
+ }
820
+
821
+ // ==================== CENTRAL GENERATE BUTTON ====================
822
+ function toggleAutomatedGeneration() {
823
+ if (generationState.active) {
824
+ pauseGeneration();
825
+ } else {
826
+ startGeneration();
827
+ }
828
+ }
829
+
830
+ function selectShape(shape) {
831
+ generationState.currentShape = shape;
832
+ updateShapeButtons();
833
+
834
+ if (generationState.active) {
835
+ showNotification("SHAPE CHANGED", `Next crystal will be ${formatShapeName(shape)}`);
836
+ } else {
837
+ showNotification("SHAPE SELECTED", `${formatShapeName(shape)} ready for generation`);
838
+ }
839
+ }
840
+
841
+ function formatShapeName(shape) {
842
+ return shape.split('_').map(word => word.charAt(0).toUpperCase() + word.slice(1)).join(' ');
843
+ }
844
+
845
+ // ==================== CRYSTAL GENERATION SYSTEM ====================
846
+ function startGeneration() {
847
+ if (generationState.active) return;
848
+
849
+ console.log("TIMELINK: Starting automated crystal generation...");
850
+
851
+ generationState.active = true;
852
+ generationState.startTime = Date.now();
853
+ generationState.crystalCount = 0;
854
+
855
+ // Update central generate button
856
+ const centralBtn = document.getElementById('central-generate-btn');
857
+ centralBtn.textContent = '⏸ STOP GENERATION';
858
+ centralBtn.classList.add('generating');
859
+ centralBtn.classList.remove('paused');
860
+ centralBtn.classList.remove('float'); // Remove floating animation when active
861
+
862
+ // Start first crystal
863
+ initializeCrystal();
864
+
865
+ // Start generation loop
866
+ generationInterval = setInterval(growCrystalStep, 50); // 20 FPS
867
+
868
+ // Start floating animation for button
869
+ centralBtn.style.animation = 'none';
870
+ setTimeout(() => {
871
+ centralBtn.style.animation = 'pulse 2s infinite';
872
+ }, 100);
873
+
874
+ showNotification("GENERATION STARTED", `Automated ${formatShapeName(generationState.currentShape)} crystal generation active`);
875
+ }
876
+
877
+ function pauseGeneration() {
878
+ if (!generationState.active) return;
879
+
880
+ console.log("TIMELINK: Pausing generation");
881
+
882
+ generationState.active = false;
883
+ clearInterval(generationInterval);
884
+ generationInterval = null;
885
+
886
+ // Update central generate button
887
+ const centralBtn = document.getElementById('central-generate-btn');
888
+ centralBtn.textContent = '▶ RESUME GENERATION';
889
+ centralBtn.classList.remove('generating');
890
+ centralBtn.classList.add('paused');
891
+ centralBtn.classList.add('float'); // Add floating animation when paused
892
+
893
+ // Restore floating animation
894
+ centralBtn.style.animation = 'float 3s ease-in-out infinite';
895
+
896
+ showNotification("GENERATION PAUSED", "Click RESUME to continue automated generation");
897
+ }
898
+
899
+ function initializeCrystal() {
900
+ // Clean up previous crystal
901
+ if (currentCrystal) {
902
+ scene.remove(currentCrystal);
903
+ currentCrystal = null;
904
+ }
905
+
906
+ // Reset crystal data
907
+ generationState.currentCrystal = {
908
+ vertices: [],
909
+ edges: [],
910
+ size: 0,
911
+ targetSize: 200,
912
+ currentStep: 0,
913
+ maxSteps: 300,
914
+ color: new THREE.Color(SHAPE_COLORS[generationState.currentShape][0]),
915
+ shape: generationState.currentShape
916
+ };
917
+
918
+ dataset.currentCrystalData = [];
919
+
920
+ // Create initial vertex at center
921
+ generationState.currentCrystal.vertices.push({
922
+ x: 0, y: 0, z: 0,
923
+ connections: [],
924
+ generation: 0,
925
+ energy: 1.0,
926
+ color: generationState.currentCrystal.color.getHex(),
927
+ shape: generationState.currentShape,
928
+ temporalPhase: null // Initialize all vertices with temporalPhase
929
+ });
930
+
931
+ // Set color based on shape
932
+ const colors = SHAPE_COLORS[generationState.currentShape];
933
+ generationState.currentCrystal.color = new THREE.Color(colors[Math.floor(Math.random() * colors.length)]);
934
+
935
+ updateCrystalInfo();
936
+ updateCrystalProgress(0);
937
+
938
+ console.log(`TIMELINK: Initialized ${generationState.currentShape} crystal`);
939
+ }
940
+
941
+ function growCrystalStep() {
942
+ if (!generationState.active) return;
943
+
944
+ const crystal = generationState.currentCrystal;
945
+
946
+ // Check if crystal is complete
947
+ if (crystal.currentStep >= crystal.maxSteps || crystal.vertices.length >= crystal.targetSize) {
948
+ completeCurrentCrystal();
949
+ startNewCrystal();
950
+ return;
951
+ }
952
+
953
+ crystal.currentStep++;
954
+ crystal.size = (crystal.currentStep / crystal.maxSteps) * crystal.targetSize;
955
+
956
+ // Grow based on selected shape
957
+ switch(crystal.shape) {
958
+ case 'quantum_spiral':
959
+ growQuantumSpiral();
960
+ break;
961
+ case 'fractal_matrix':
962
+ growFractalMatrix();
963
+ break;
964
+ case 'neural_lattice':
965
+ growNeuralLattice();
966
+ break;
967
+ case 'temporal_ring':
968
+ growTemporalRing();
969
+ break;
970
+ }
971
+
972
+ // Update visualization
973
+ updateCrystalVisualization();
974
+
975
+ // Auto-capture images
976
+ if (autoCaptureEnabled && crystal.currentStep % 10 === 0) {
977
+ captureImage();
978
+ }
979
+
980
+ // Update UI
981
+ updateUI();
982
+ }
983
+
984
+ // ==================== SHAPE ALGORITHMS ====================
985
+ function growQuantumSpiral() {
986
+ const crystal = generationState.currentCrystal;
987
+ const time = generationState.totalGenerationTime;
988
+
989
+ const layers = Math.max(3, Math.floor(crystal.size / 20));
990
+ const currentLayer = Math.floor(crystal.vertices.length / 4);
991
+
992
+ for (let i = 0; i < 3 && crystal.vertices.length < crystal.targetSize; i++) {
993
+ // Calculate spiral position with time-based animation
994
+ const timeWarp = Math.sin(time * 0.5 + i * 0.5) * 0.3;
995
+ const radius = 15 + (currentLayer * 4) + timeWarp * 8;
996
+ const height = currentLayer * 12;
997
+ const angle = (currentLayer / layers) * Math.PI * 6 + (i / 3) * Math.PI * 2;
998
+
999
+ const x = Math.cos(angle + time * 0.2) * radius;
1000
+ const y = height + Math.sin(time * 0.3 + i) * 4;
1001
+ const z = Math.sin(angle + time * 0.2) * radius;
1002
+
1003
+ // Find nearest vertex for connection
1004
+ let nearestIndex = 0;
1005
+ let minDistance = Infinity;
1006
+
1007
+ for (let j = 0; j < crystal.vertices.length; j++) {
1008
+ const v = crystal.vertices[j];
1009
+ const dx = x - v.x;
1010
+ const dy = y - v.y;
1011
+ const dz = z - v.z;
1012
+ const distance = Math.sqrt(dx*dx + dy*dy + dz*dz);
1013
+
1014
+ if (distance < minDistance && distance < 30) {
1015
+ minDistance = distance;
1016
+ nearestIndex = j;
1017
+ }
1018
+ }
1019
+
1020
+ // Create new vertex
1021
+ const newVertex = {
1022
+ x: x,
1023
+ y: y,
1024
+ z: z,
1025
+ connections: [nearestIndex],
1026
+ generation: currentLayer,
1027
+ energy: 0.7 + Math.random() * 0.3,
1028
+ color: crystal.color.getHex(),
1029
+ shape: crystal.shape,
1030
+ temporalPhase: null // Add temporalPhase for consistency
1031
+ };
1032
+
1033
+ crystal.vertices.push(newVertex);
1034
+
1035
+ // Create reciprocal connection
1036
+ if (nearestIndex < crystal.vertices.length) {
1037
+ crystal.vertices[nearestIndex].connections.push(crystal.vertices.length - 1);
1038
+ crystal.edges.push([nearestIndex, crystal.vertices.length - 1]);
1039
+ }
1040
+ }
1041
+ }
1042
+
1043
+ function growFractalMatrix() {
1044
+ const crystal = generationState.currentCrystal;
1045
+
1046
+ // Start with central connections
1047
+ if (crystal.vertices.length === 1) {
1048
+ // Create initial fractal arms
1049
+ for (let i = 0; i < 6; i++) {
1050
+ const angle = (i / 6) * Math.PI * 2;
1051
+ const length = 20;
1052
+
1053
+ crystal.vertices.push({
1054
+ x: Math.cos(angle) * length,
1055
+ y: Math.sin(angle) * length,
1056
+ z: 0,
1057
+ connections: [0],
1058
+ generation: 1,
1059
+ energy: 0.9,
1060
+ color: crystal.color.getHex(),
1061
+ shape: crystal.shape,
1062
+ temporalPhase: null // Add temporalPhase for consistency
1063
+ });
1064
+ crystal.vertices[0].connections.push(crystal.vertices.length - 1);
1065
+ crystal.edges.push([0, crystal.vertices.length - 1]);
1066
+ }
1067
+ } else {
1068
+ // Fractal branching from existing vertices
1069
+ const verticesToBranch = [];
1070
+
1071
+ // Select vertices with few connections
1072
+ for (let i = 0; i < crystal.vertices.length; i++) {
1073
+ const vertex = crystal.vertices[i];
1074
+ if (vertex.connections.length < 4 && vertex.generation < 5) {
1075
+ verticesToBranch.push(i);
1076
+ }
1077
+ }
1078
+
1079
+ // Branch from selected vertices
1080
+ verticesToBranch.forEach(vertexIndex => {
1081
+ const vertex = crystal.vertices[vertexIndex];
1082
+ const branches = 1 + Math.floor(Math.random() * 3);
1083
+
1084
+ for (let b = 0; b < branches && crystal.vertices.length < crystal.targetSize; b++) {
1085
+ // Calculate branch direction
1086
+ const baseAngle = vertex.generation * Math.PI / 2;
1087
+ const branchAngle = baseAngle + (b / branches) * Math.PI * 2;
1088
+ const pitch = Math.random() * Math.PI;
1089
+
1090
+ // Fractal scaling
1091
+ const scale = Math.pow(0.6, vertex.generation);
1092
+ const length = 12 + Math.random() * 10;
1093
+
1094
+ const x = vertex.x + Math.sin(pitch) * Math.cos(branchAngle) * length * scale;
1095
+ const y = vertex.y + Math.cos(pitch) * length * scale;
1096
+ const z = vertex.z + Math.sin(pitch) * Math.sin(branchAngle) * length * scale;
1097
+
1098
+ const newVertex = {
1099
+ x: x,
1100
+ y: y,
1101
+ z: z,
1102
+ connections: [vertexIndex],
1103
+ generation: vertex.generation + 1,
1104
+ energy: vertex.energy * (0.6 + Math.random() * 0.4),
1105
+ color: crystal.color.getHex(),
1106
+ shape: crystal.shape,
1107
+ temporalPhase: null // Add temporalPhase for consistency
1108
+ };
1109
+
1110
+ crystal.vertices.push(newVertex);
1111
+ vertex.connections.push(crystal.vertices.length - 1);
1112
+ crystal.edges.push([vertexIndex, crystal.vertices.length - 1]);
1113
+ }
1114
+ });
1115
+ }
1116
+ }
1117
+
1118
+ function growNeuralLattice() {
1119
+ const crystal = generationState.currentCrystal;
1120
+ const time = generationState.totalGenerationTime;
1121
+
1122
+ if (crystal.vertices.length < 15) {
1123
+ // Initial random points for neural network
1124
+ for (let i = 0; i < 4 && crystal.vertices.length < crystal.targetSize; i++) {
1125
+ const radius = 25 + crystal.size;
1126
+ const theta = Math.random() * Math.PI * 2;
1127
+ const phi = Math.acos(2 * Math.random() - 1);
1128
+
1129
+ const x = radius * Math.sin(phi) * Math.cos(theta);
1130
+ const y = radius * Math.sin(phi) * Math.sin(theta);
1131
+ const z = radius * Math.cos(phi);
1132
+
1133
+ const newVertex = {
1134
+ x: x,
1135
+ y: y,
1136
+ z: z,
1137
+ connections: [],
1138
+ generation: Math.floor(crystal.vertices.length / 5),
1139
+ energy: 0.8 + Math.random() * 0.2,
1140
+ color: crystal.color.getHex(),
1141
+ shape: crystal.shape,
1142
+ temporalPhase: null // Add temporalPhase for consistency
1143
+ };
1144
+
1145
+ // Connect to 3 nearest neighbors
1146
+ const neighbors = [];
1147
+ for (let j = 0; j < crystal.vertices.length; j++) {
1148
+ const v = crystal.vertices[j];
1149
+ const dx = x - v.x;
1150
+ const dy = y - v.y;
1151
+ const dz = z - v.z;
1152
+ const distance = Math.sqrt(dx*dx + dy*dy + dz*dz);
1153
+ neighbors.push({index: j, distance: distance});
1154
+ }
1155
+
1156
+ neighbors.sort((a, b) => a.distance - b.distance);
1157
+
1158
+ const maxConnections = Math.min(3, neighbors.length);
1159
+ for (let n = 0; n < maxConnections; n++) {
1160
+ if (neighbors[n].distance < 40) {
1161
+ newVertex.connections.push(neighbors[n].index);
1162
+ crystal.vertices[neighbors[n].index].connections.push(crystal.vertices.length);
1163
+ crystal.edges.push([neighbors[n].index, crystal.vertices.length]);
1164
+ }
1165
+ }
1166
+
1167
+ crystal.vertices.push(newVertex);
1168
+ }
1169
+ } else {
1170
+ // Neural network style connections
1171
+ // Add new connections between existing vertices
1172
+ const newConnections = Math.min(8, Math.floor(crystal.vertices.length / 20));
1173
+
1174
+ for (let c = 0; c < newConnections; c++) {
1175
+ const i = Math.floor(Math.random() * crystal.vertices.length);
1176
+ const j = Math.floor(Math.random() * crystal.vertices.length);
1177
+
1178
+ if (i !== j && !crystal.vertices[i].connections.includes(j)) {
1179
+ const v1 = crystal.vertices[i];
1180
+ const v2 = crystal.vertices[j];
1181
+ const dx = v1.x - v2.x;
1182
+ const dy = v1.y - v2.y;
1183
+ const dz = v1.z - v2.z;
1184
+ const distance = Math.sqrt(dx*dx + dy*dy + dz*dz);
1185
+
1186
+ // Connection probability based on distance
1187
+ const connectionProbability = Math.exp(-distance / 30) * (0.5 + 0.5 * Math.sin(time * 0.5));
1188
+
1189
+ if (distance < 50 && Math.random() < connectionProbability) {
1190
+ crystal.vertices[i].connections.push(j);
1191
+ crystal.vertices[j].connections.push(i);
1192
+ crystal.edges.push([i, j]);
1193
+ }
1194
+ }
1195
+ }
1196
+
1197
+ // Add new neurons occasionally
1198
+ if (Math.random() > 0.8 && crystal.vertices.length < crystal.targetSize) {
1199
+ const radius = 40 + crystal.size / 2;
1200
+ const theta = Math.random() * Math.PI * 2;
1201
+ const phi = Math.acos(2 * Math.random() - 1);
1202
+
1203
+ const x = radius * Math.sin(phi) * Math.cos(theta);
1204
+ const y = radius * Math.sin(phi) * Math.sin(theta);
1205
+ const z = radius * Math.cos(phi);
1206
+
1207
+ const newVertex = {
1208
+ x: x,
1209
+ y: y,
1210
+ z: z,
1211
+ connections: [],
1212
+ generation: Math.floor(crystal.vertices.length / 25),
1213
+ energy: 0.7 + Math.random() * 0.3,
1214
+ color: crystal.color.getHex(),
1215
+ shape: crystal.shape,
1216
+ temporalPhase: null // Add temporalPhase for consistency
1217
+ };
1218
+
1219
+ crystal.vertices.push(newVertex);
1220
+ }
1221
+ }
1222
+ }
1223
+
1224
+ function growTemporalRing() {
1225
+ const crystal = generationState.currentCrystal;
1226
+ const time = generationState.totalGenerationTime;
1227
+
1228
+ const segments = Math.min(120, 30 + Math.floor(crystal.size / 2));
1229
+ const currentSegment = crystal.vertices.length;
1230
+
1231
+ if (currentSegment >= segments) return;
1232
+
1233
+ const radius = 30 + crystal.size / 3;
1234
+ const angle = (currentSegment / segments) * Math.PI * 2;
1235
+
1236
+ // Time-based distortion effects
1237
+ const timeDistortion = Math.sin(time * 0.5 + currentSegment * 0.1) * 0.5;
1238
+ const phaseShift = time * 0.3;
1239
+ const verticalWave = Math.sin(angle * 3 + time * 0.4) * 10;
1240
+
1241
+ const x = Math.cos(angle + phaseShift) * radius * (1 + timeDistortion * 0.2);
1242
+ const z = Math.sin(angle + phaseShift) * radius * (1 + timeDistortion * 0.2);
1243
+ const y = verticalWave;
1244
+
1245
+ const newVertex = {
1246
+ x: x,
1247
+ y: y,
1248
+ z: z,
1249
+ connections: [],
1250
+ generation: currentSegment,
1251
+ energy: 0.8 + Math.abs(Math.sin(angle)) * 0.2,
1252
+ color: crystal.color.getHex(),
1253
+ shape: crystal.shape,
1254
+ temporalPhase: angle
1255
+ };
1256
+
1257
+ // Connect to previous vertex
1258
+ if (currentSegment > 0) {
1259
+ newVertex.connections.push(currentSegment - 1);
1260
+ crystal.vertices[currentSegment - 1].connections.push(currentSegment);
1261
+ crystal.edges.push([currentSegment - 1, currentSegment]);
1262
+ }
1263
+
1264
+ // Connect to opposite side
1265
+ if (currentSegment > segments / 4 && currentSegment % (segments/8) === 0) {
1266
+ const oppositeIndex = Math.floor((currentSegment + segments/2) % segments);
1267
+ if (oppositeIndex < crystal.vertices.length) {
1268
+ newVertex.connections.push(oppositeIndex);
1269
+ crystal.vertices[oppositeIndex].connections.push(currentSegment);
1270
+ crystal.edges.push([oppositeIndex, currentSegment]);
1271
+ }
1272
+ }
1273
+
1274
+ // Connect to center
1275
+ if (currentSegment % (segments/12) === 0) {
1276
+ newVertex.connections.push(0);
1277
+ crystal.vertices[0].connections.push(currentSegment);
1278
+ crystal.edges.push([0, currentSegment]);
1279
+ }
1280
+
1281
+ crystal.vertices.push(newVertex);
1282
+ }
1283
+
1284
+ function updateCrystalVisualization() {
1285
+ const crystal = generationState.currentCrystal;
1286
+
1287
+ if (crystal.vertices.length === 0) return;
1288
+
1289
+ // Create or update crystal geometry
1290
+ if (!currentCrystal) {
1291
+ const geometry = new THREE.BufferGeometry();
1292
+ const material = new THREE.LineBasicMaterial({
1293
+ color: crystal.color,
1294
+ linewidth: 2,
1295
+ transparent: true,
1296
+ opacity: 0.9
1297
+ });
1298
+
1299
+ currentCrystal = new THREE.LineSegments(geometry, material);
1300
+ scene.add(currentCrystal);
1301
+
1302
+ // Add vertex points for better visualization
1303
+ const pointGeometry = new THREE.BufferGeometry();
1304
+ const pointMaterial = new THREE.PointsMaterial({
1305
+ color: crystal.color,
1306
+ size: 3,
1307
+ transparent: true,
1308
+ opacity: 0.7
1309
+ });
1310
+
1311
+ currentCrystal.points = new THREE.Points(pointGeometry, pointMaterial);
1312
+ scene.add(currentCrystal.points);
1313
+ }
1314
+
1315
+ // Update line geometry
1316
+ const positions = new Float32Array(crystal.vertices.length * 3);
1317
+ const indices = [];
1318
+
1319
+ for (let i = 0; i < crystal.vertices.length; i++) {
1320
+ const v = crystal.vertices[i];
1321
+ positions[i * 3] = v.x;
1322
+ positions[i * 3 + 1] = v.y;
1323
+ positions[i * 3 + 2] = v.z;
1324
+ }
1325
+
1326
+ for (const [a, b] of crystal.edges) {
1327
+ indices.push(a, b);
1328
+ }
1329
+
1330
+ // Update line geometry
1331
+ currentCrystal.geometry.dispose();
1332
+ currentCrystal.geometry = new THREE.BufferGeometry();
1333
+ currentCrystal.geometry.setAttribute('position', new THREE.BufferAttribute(positions, 3));
1334
+ currentCrystal.geometry.setIndex(indices);
1335
+
1336
+ // Update point geometry
1337
+ currentCrystal.points.geometry.dispose();
1338
+ currentCrystal.points.geometry = new THREE.BufferGeometry();
1339
+ currentCrystal.points.geometry.setAttribute('position', new THREE.BufferAttribute(positions, 3));
1340
+
1341
+ // Update material with time-based effects
1342
+ const pulse = 0.8 + 0.2 * Math.sin(generationState.totalGenerationTime * 2);
1343
+ currentCrystal.material.opacity = pulse * 0.9;
1344
+ currentCrystal.material.color = crystal.color;
1345
+ currentCrystal.points.material.color = crystal.color;
1346
+ currentCrystal.points.material.opacity = pulse * 0.7;
1347
+
1348
+ // Add subtle rotation
1349
+ currentCrystal.rotation.y += 0.001 * generationState.timeScale;
1350
+ currentCrystal.points.rotation.y = currentCrystal.rotation.y;
1351
+ }
1352
+
1353
+ function completeCurrentCrystal() {
1354
+ const crystal = generationState.currentCrystal;
1355
+
1356
+ // Final image capture
1357
+ captureImage();
1358
+
1359
+ // Normalize vertex data for consistency (ensure all vertices have temporalPhase)
1360
+ const normalizedVertices = crystal.vertices.map(v => ({
1361
+ ...v,
1362
+ temporalPhase: v.temporalPhase !== undefined ? v.temporalPhase : null
1363
+ }));
1364
+
1365
+ // Store crystal data
1366
+ const crystalData = {
1367
+ id: generationState.crystalCount,
1368
+ shape: crystal.shape,
1369
+ vertices: crystal.vertices.length,
1370
+ edges: crystal.edges.length,
1371
+ size: crystal.size,
1372
+ generationSteps: crystal.currentStep,
1373
+ generationTime: crystal.currentStep * 0.05,
1374
+ color: crystal.color.getHex(),
1375
+ vertexData: normalizedVertices,
1376
+ edgeData: crystal.edges,
1377
+ images: dataset.capturedImages.filter(img => img.metadata.crystalId === generationState.crystalCount)
1378
+ };
1379
+
1380
+ dataset.crystals.push(crystalData);
1381
+ generationState.crystalCount++;
1382
+
1383
+ console.log(`TIMELINK: Completed crystal #${generationState.crystalCount} with ${crystal.vertices.length} vertices`);
1384
+ }
1385
+
1386
+ function startNewCrystal() {
1387
+ if (!generationState.active) return;
1388
+
1389
+ // Reset for new crystal
1390
+ initializeCrystal();
1391
+ }
1392
+
1393
+ // ==================== IMAGE CAPTURE SYSTEM ====================
1394
+ function captureImage() {
1395
+ try {
1396
+ const canvas = document.getElementById('threeCanvas');
1397
+
1398
+ // Ensure canvas is ready
1399
+ if (!canvas || canvas.width === 0) {
1400
+ console.warn("Canvas not ready for capture");
1401
+ return;
1402
+ }
1403
+
1404
+ // Capture at high quality
1405
+ const imageData = canvas.toDataURL('image/png', 1.0);
1406
+
1407
+ // Create metadata for the image
1408
+ const imageMetadata = {
1409
+ timestamp: Date.now(),
1410
+ crystalId: generationState.crystalCount,
1411
+ crystalShape: generationState.currentShape,
1412
+ step: generationState.currentCrystal.currentStep,
1413
+ vertices: generationState.currentCrystal.vertices.length,
1414
+ edges: generationState.currentCrystal.edges.length,
1415
+ size: generationState.currentCrystal.size,
1416
+ timeScale: generationState.timeScale,
1417
+ generationTime: generationState.totalGenerationTime
1418
+ };
1419
+
1420
+ // Store image with metadata
1421
+ dataset.capturedImages.push({
1422
+ data: imageData,
1423
+ metadata: imageMetadata,
1424
+ type: 'manual'
1425
+ });
1426
+
1427
+ dataset.totalImages++;
1428
+ dataset.manualCaptureCount++;
1429
+
1430
+ // Update UI
1431
+ document.getElementById('imageCount').textContent = dataset.totalImages;
1432
+ document.getElementById('captureCount').textContent = dataset.totalImages;
1433
+
1434
+ const captureProgress = Math.min((dataset.totalImages / 100) * 100, 100);
1435
+ document.getElementById('captureProgress').style.width = captureProgress + '%';
1436
+
1437
+ // Flash effect for visual feedback
1438
+ if (dataset.totalImages % 5 === 0) {
1439
+ showNotification("IMAGE CAPTURED", `Saved image #${dataset.totalImages} for dataset`);
1440
+ }
1441
+
1442
+ } catch (error) {
1443
+ console.error("TIMELINK: Image capture error:", error);
1444
+ }
1445
+ }
1446
+
1447
+ function toggleAutoCapture() {
1448
+ autoCaptureEnabled = !autoCaptureEnabled;
1449
+ const btn = document.getElementById('autoCaptureBtn');
1450
+
1451
+ if (autoCaptureEnabled) {
1452
+ btn.textContent = '⚙ AUTO: ON';
1453
+ btn.classList.add('ready');
1454
+ showNotification("AUTO CAPTURE", "Auto-capture enabled (every 10 steps)");
1455
+ } else {
1456
+ btn.textContent = '⚙ AUTO: OFF';
1457
+ btn.classList.remove('ready');
1458
+ showNotification("AUTO CAPTURE", "Auto-capture disabled");
1459
+ }
1460
+ }
1461
+
1462
+ // ==================== EXPORT FUNCTIONS ====================
1463
+ async function exportCurrentCrystal() {
1464
+ if (generationState.currentCrystal.vertices.length === 0) {
1465
+ showNotification("ERROR", "No crystal data to export");
1466
+ return;
1467
+ }
1468
+
1469
+ showNotification("EXPORTING", "Exporting current crystal dataset...");
1470
+
1471
+ try {
1472
+ const zip = new JSZip();
1473
+ const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
1474
+ const crystalId = generationState.crystalCount;
1475
+ const shapeName = formatShapeName(generationState.currentShape).toLowerCase().replace(' ', '_');
1476
+
1477
+ // Create metadata
1478
+ const metadata = {
1479
+ crystal_id: crystalId,
1480
+ shape: generationState.currentShape,
1481
+ shape_name: formatShapeName(generationState.currentShape),
1482
+ vertices: generationState.currentCrystal.vertices.length,
1483
+ edges: generationState.currentCrystal.edges.length,
1484
+ generation_time: generationState.totalGenerationTime,
1485
+ export_time: new Date().toISOString(),
1486
+ time_scale: generationState.timeScale,
1487
+ images_captured: dataset.capturedImages.filter(img => img.metadata.crystalId === crystalId).length
1488
+ };
1489
+
1490
+ zip.file("metadata.json", JSON.stringify(metadata, null, 2));
1491
+
1492
+ // Export crystal data
1493
+ const crystalData = {
1494
+ vertices: generationState.currentCrystal.vertices,
1495
+ edges: generationState.currentCrystal.edges,
1496
+ parameters: {
1497
+ target_size: generationState.currentCrystal.targetSize,
1498
+ color: generationState.currentCrystal.color.getHex(),
1499
+ time_scale: generationState.timeScale
1500
+ }
1501
+ };
1502
+
1503
+ zip.file("crystal_data.json", JSON.stringify(crystalData, null, 2));
1504
+
1505
+ // Export images
1506
+ const imgFolder = zip.folder("images");
1507
+ const crystalImages = dataset.capturedImages.filter(img => img.metadata.crystalId === crystalId);
1508
+
1509
+ crystalImages.forEach((image, index) => {
1510
+ const base64Data = image.data.replace(/^data:image\/png;base64,/, "");
1511
+ imgFolder.file(`step_${index.toString().padStart(4, '0')}.png`, base64Data, {base64: true});
1512
+ });
1513
+
1514
+ // Create README
1515
+ const readme = generateCrystalReadme(metadata, crystalImages.length);
1516
+ zip.file("README.md", readme);
1517
+
1518
+ // Generate and download
1519
+ const content = await zip.generateAsync({type: "blob"});
1520
+ const filename = `timelink_${shapeName}_crystal_${timestamp}.zip`;
1521
+
1522
+ saveAs(content, filename);
1523
+
1524
+ showNotification("SUCCESS", `Exported ${shapeName} crystal dataset`);
1525
+
1526
+ } catch (error) {
1527
+ console.error("TIMELINK: Export error:", error);
1528
+ showNotification("ERROR", `Export failed: ${error.message}`);
1529
+ }
1530
+ }
1531
+
1532
+ async function exportCompleteDataset() {
1533
+ if (dataset.crystals.length === 0 && generationState.currentCrystal.vertices.length === 0) {
1534
+ showNotification("ERROR", "No dataset to export");
1535
+ return;
1536
+ }
1537
+
1538
+ showNotification("EXPORTING", "Preparing complete dataset package...");
1539
+
1540
+ try {
1541
+ const zip = new JSZip();
1542
+ const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
1543
+
1544
+ // Create dataset structure with proper row-oriented format
1545
+ const datasetRows = [];
1546
+
1547
+ dataset.crystals.forEach((crystal, index) => {
1548
+ // Normalize vertex data to ensure consistency
1549
+ const normalizedVertexData = crystal.vertexData.map(vertex => ({
1550
+ ...vertex,
1551
+ temporalPhase: vertex.temporalPhase !== undefined ? vertex.temporalPhase : null
1552
+ }));
1553
+
1554
+ // Create a row for each crystal
1555
+ const row = {
1556
+ id: crystal.id,
1557
+ shape: crystal.shape,
1558
+ vertices: crystal.vertices,
1559
+ edges: crystal.edges,
1560
+ size: crystal.size,
1561
+ generationSteps: crystal.generationSteps,
1562
+ generationTime: parseFloat(crystal.generationTime),
1563
+ color: crystal.color,
1564
+ vertexData: normalizedVertexData,
1565
+ edgeData: crystal.edgeData,
1566
+ // Note: images are not included in JSON to avoid large files
1567
+ images_count: crystal.images ? crystal.images.length : 0
1568
+ };
1569
+
1570
+ datasetRows.push(row);
1571
+
1572
+ // Export images for this crystal
1573
+ const crystalFolder = zip.folder(`crystal_${crystal.id}_${crystal.shape}`);
1574
+
1575
+ // Export crystal metadata
1576
+ crystalFolder.file("metadata.json", JSON.stringify({
1577
+ id: crystal.id,
1578
+ shape: crystal.shape,
1579
+ vertices: crystal.vertices,
1580
+ edges: crystal.edges,
1581
+ generationTime: parseFloat(crystal.generationTime),
1582
+ export_time: new Date().toISOString()
1583
+ }, null, 2));
1584
+
1585
+ // Export images if available
1586
+ if (crystal.images && crystal.images.length > 0) {
1587
+ const imgFolder = crystalFolder.folder("images");
1588
+ crystal.images.forEach((image, imgIndex) => {
1589
+ const base64Data = image.data.replace(/^data:image\/png;base64,/, "");
1590
+ imgFolder.file(`step_${imgIndex.toString().padStart(4, '0')}.png`, base64Data, {base64: true});
1591
+ });
1592
+ }
1593
+ });
1594
+
1595
+ // Comprehensive metadata
1596
+ const metadata = {
1597
+ total_crystals: dataset.crystals.length,
1598
+ total_images: dataset.totalImages,
1599
+ total_generation_time: generationState.totalGenerationTime,
1600
+ start_time: new Date(generationState.startTime).toISOString(),
1601
+ export_time: new Date().toISOString(),
1602
+ shapes_generated: [...new Set(dataset.crystals.map(c => c.shape))],
1603
+ system_info: {
1604
+ memory_usage: `${systemMonitor.memoryUsage} MB`,
1605
+ performance_level: systemMonitor.performanceLevel
1606
+ },
1607
+ // Dataset structure information
1608
+ data_format: "row-oriented JSON (list of objects)",
1609
+ features: {
1610
+ id: "int64 - Crystal ID",
1611
+ shape: "string - Crystal shape type",
1612
+ vertices: "int64 - Number of vertices",
1613
+ edges: "int64 - Number of edges",
1614
+ size: "float64 - Crystal size metric",
1615
+ generationSteps: "int64 - Steps to generate",
1616
+ generationTime: "float64 - Time to generate (seconds)",
1617
+ color: "int64 - Hex color code",
1618
+ vertexData: "list of structs - Vertex information",
1619
+ edgeData: "list of lists - Edge connections",
1620
+ images_count: "int64 - Number of images captured"
1621
+ }
1622
+ };
1623
+
1624
+ // Main dataset file - row-oriented JSON
1625
+ zip.file("dataset.json", JSON.stringify(datasetRows, null, 2));
1626
+ zip.file("dataset_metadata.json", JSON.stringify(metadata, null, 2));
1627
+
1628
+ // Export summary and README
1629
+ const summary = generateDatasetSummary(metadata);
1630
+ zip.file("summary.txt", summary);
1631
+
1632
+ const readme = generateCompleteReadme(metadata);
1633
+ zip.file("README.md", readme);
1634
+
1635
+ // Generate and download
1636
+ const content = await zip.generateAsync({type: "blob"});
1637
+ const filename = `timelink_complete_dataset_${timestamp}.zip`;
1638
+
1639
+ saveAs(content, filename);
1640
+
1641
+ showNotification("SUCCESS", `Exported complete dataset (${metadata.total_crystals} crystals, ${metadata.total_images} images)`);
1642
+
1643
+ } catch (error) {
1644
+ console.error("TIMELINK: Export error:", error);
1645
+ showNotification("ERROR", `Export failed: ${error.message}`);
1646
+ }
1647
+ }
1648
+
1649
+ async function exportHuggingFace() {
1650
+ if (dataset.crystals.length === 0) {
1651
+ showNotification("ERROR", "No dataset to export for Hugging Face");
1652
+ return;
1653
+ }
1654
+
1655
+ showNotification("EXPORTING", "Preparing Hugging Face dataset...");
1656
+
1657
+ try {
1658
+ const zip = new JSZip();
1659
+ const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
1660
+
1661
+ // Prepare the data in Hugging Face format: a list of crystal objects
1662
+ const hfData = dataset.crystals.map(crystal => {
1663
+ // Normalize vertex data: ensure every vertex has temporalPhase (set to null if missing)
1664
+ const normalizedVertexData = crystal.vertexData.map(vertex => {
1665
+ // Ensure all vertices have the same fields
1666
+ const normalizedVertex = { ...vertex };
1667
+
1668
+ // Ensure temporalPhase exists (null for non-temporal shapes)
1669
+ if (!('temporalPhase' in normalizedVertex)) {
1670
+ normalizedVertex.temporalPhase = null;
1671
+ }
1672
+
1673
+ // Return standardized vertex structure
1674
+ return {
1675
+ x: parseFloat(normalizedVertex.x) || 0.0,
1676
+ y: parseFloat(normalizedVertex.y) || 0.0,
1677
+ z: parseFloat(normalizedVertex.z) || 0.0,
1678
+ connections: normalizedVertex.connections || [],
1679
+ generation: parseInt(normalizedVertex.generation) || 0,
1680
+ energy: parseFloat(normalizedVertex.energy) || 0.0,
1681
+ color: parseInt(normalizedVertex.color) || 0x00ff00,
1682
+ shape: normalizedVertex.shape || crystal.shape,
1683
+ temporalPhase: normalizedVertex.temporalPhase !== null ?
1684
+ parseFloat(normalizedVertex.temporalPhase) : null
1685
+ };
1686
+ });
1687
+
1688
+ // Normalize edgeData: ensure it's a list of [int, int]
1689
+ const normalizedEdgeData = crystal.edgeData.map(edge => {
1690
+ if (Array.isArray(edge) && edge.length === 2) {
1691
+ return [parseInt(edge[0]) || 0, parseInt(edge[1]) || 0];
1692
+ } else {
1693
+ return [0, 0];
1694
+ }
1695
+ });
1696
+
1697
+ // Create standardized row for Hugging Face
1698
+ return {
1699
+ id: crystal.id,
1700
+ shape: crystal.shape,
1701
+ vertices: parseInt(crystal.vertices) || 0,
1702
+ edges: parseInt(crystal.edges) || 0,
1703
+ size: parseFloat(crystal.size) || 0.0,
1704
+ generationSteps: parseInt(crystal.generationSteps) || 0,
1705
+ generationTime: parseFloat(crystal.generationTime) || 0.0,
1706
+ color: parseInt(crystal.color) || 0x00ff00,
1707
+ vertexData: normalizedVertexData,
1708
+ edgeData: normalizedEdgeData
1709
+ // Note: we are not including base64 images in the JSON
1710
+ };
1711
+ });
1712
+
1713
+ // Hugging Face specific metadata
1714
+ const hfMetadata = {
1715
+ "description": `TIMELINK Time Crystal Dataset - ${dataset.crystals.length} crystals`,
1716
+ "citation": "@misc{timelink2025,\n title={TIMELINK: Quantum Time Crystal Generation},\n author={WebXOS Research},\n year={2025},\n note={Dataset of algorithmically generated time crystal structures}\n}",
1717
+ "license": "mit",
1718
+ "language": "en",
1719
+ "size_categories": ["n<1K", "1K<n<10K"],
1720
+ "task_categories": ["graph-generation", "image-generation"],
1721
+ "task_ids": ["graph-generation", "image-generation", "time-series-generation"],
1722
+ "pretty_name": "TIMELINK Time Crystal Dataset",
1723
+ "tags": ["quantum", "crystal", "graph", "3d", "generation", "time-series"],
1724
+ "dataset_info": {
1725
+ "features": {
1726
+ "id": {"dtype": "int64", "nullable": false},
1727
+ "shape": {"dtype": "string", "nullable": false},
1728
+ "vertices": {"dtype": "int64", "nullable": false},
1729
+ "edges": {"dtype": "int64", "nullable": false},
1730
+ "size": {"dtype": "float64", "nullable": false},
1731
+ "generationSteps": {"dtype": "int64", "nullable": false},
1732
+ "generationTime": {"dtype": "float64", "nullable": false},
1733
+ "color": {"dtype": "int64", "nullable": false},
1734
+ "vertexData": {
1735
+ "feature": {
1736
+ "x": {"dtype": "float64", "nullable": false},
1737
+ "y": {"dtype": "float64", "nullable": false},
1738
+ "z": {"dtype": "float64", "nullable": false},
1739
+ "connections": {"dtype": "int64", "list": true, "nullable": false},
1740
+ "generation": {"dtype": "int64", "nullable": false},
1741
+ "energy": {"dtype": "float64", "nullable": false},
1742
+ "color": {"dtype": "int64", "nullable": false},
1743
+ "shape": {"dtype": "string", "nullable": false},
1744
+ "temporalPhase": {"dtype": "float64", "nullable": true}
1745
+ },
1746
+ "list": true,
1747
+ "nullable": false
1748
+ },
1749
+ "edgeData": {
1750
+ "feature": {
1751
+ "dtype": "int64",
1752
+ "list": true,
1753
+ "nullable": false
1754
+ },
1755
+ "list": true,
1756
+ "nullable": false
1757
+ }
1758
+ },
1759
+ "splits": {
1760
+ "train": {
1761
+ "name": "train",
1762
+ "num_bytes": Math.round(systemMonitor.memoryUsage * 1024 * 1024),
1763
+ "num_examples": dataset.crystals.length
1764
+ }
1765
+ }
1766
+ }
1767
+ };
1768
+
1769
+ zip.file("dataset_info.json", JSON.stringify(hfMetadata, null, 2));
1770
+ zip.file("data.json", JSON.stringify(hfData, null, 2));
1771
+
1772
+ // Export images in organized folders (separate from JSON to avoid large files)
1773
+ dataset.crystals.forEach((crystal, index) => {
1774
+ const crystalImages = dataset.capturedImages.filter(img => img.metadata.crystalId === crystal.id);
1775
+ if (crystalImages.length > 0) {
1776
+ const imgFolder = zip.folder(`images/crystal_${crystal.id}`);
1777
+ crystalImages.forEach((image, imgIndex) => {
1778
+ const base64Data = image.data.replace(/^data:image\/png;base64,/, "");
1779
+ imgFolder.file(`${crystal.shape}_${imgIndex}.png`, base64Data, {base64: true});
1780
+ });
1781
+ }
1782
+ });
1783
+
1784
+ // Create dataset card for Hugging Face
1785
+ const datasetCard = generateHuggingFaceDatasetCard(hfMetadata, dataset.crystals.length);
1786
+ zip.file("README.md", datasetCard);
1787
+
1788
+ // Add dataset_infos.json for Hugging Face
1789
+ const datasetInfos = {
1790
+ "default": hfMetadata
1791
+ };
1792
+ zip.file("dataset_infos.json", JSON.stringify(datasetInfos, null, 2));
1793
+
1794
+ // Generate and download
1795
+ const content = await zip.generateAsync({type: "blob"});
1796
+ const filename = `timelink_huggingface_dataset_${timestamp}.zip`;
1797
+
1798
+ saveAs(content, filename);
1799
+
1800
+ showNotification("SUCCESS", "Hugging Face dataset exported! Upload data.json and images folder to HF");
1801
+
1802
+ } catch (error) {
1803
+ console.error("TIMELINK: Export error:", error);
1804
+ showNotification("ERROR", `Export failed: ${error.message}`);
1805
+ }
1806
+ }
1807
+
1808
+ function generateCrystalReadme(metadata, imageCount) {
1809
+ return `# TIMELINK Crystal Dataset
1810
+
1811
+ ## Crystal Information
1812
+ - **ID**: ${metadata.crystal_id}
1813
+ - **Shape**: ${metadata.shape_name}
1814
+ - **Vertices**: ${metadata.vertices}
1815
+ - **Edges**: ${metadata.edges}
1816
+ - **Generation Time**: ${metadata.generation_time.toFixed(2)} seconds
1817
+ - **Images Captured**: ${imageCount}
1818
+ - **Export Time**: ${metadata.export_time}
1819
+
1820
+ ## Contents
1821
+ - \`metadata.json\` - Crystal metadata
1822
+ - \`crystal_data.json\` - Complete crystal structure data
1823
+ - \`images/\` - Captured PNG images of growth steps
1824
+ - \`README.md\` - This file
1825
+
1826
+ ## Usage
1827
+ This dataset can be used for:
1828
+ 1. Graph neural network training
1829
+ 2. 3D structure analysis
1830
+ 3. Time series generation studies
1831
+ 4. Quantum crystal simulation
1832
+
1833
+ ## License
1834
+ MIT License - Free for academic and research use.
1835
+ `;
1836
+ }
1837
+
1838
+ function generateCompleteReadme(metadata) {
1839
+ return `# TIMELINK Complete Dataset
1840
+
1841
+ ## Dataset Overview
1842
+ Total Crystals: ${metadata.total_crystals}
1843
+ Total Images: ${metadata.total_images}
1844
+ Generation Time: ${metadata.total_generation_time.toFixed(2)} seconds
1845
+ Shapes Generated: ${metadata.shapes_generated.join(', ')}
1846
+
1847
+ ## File Structure
1848
+ \`\`\`
1849
+ dataset.zip/
1850
+ ├── dataset.json # Main dataset file (row-oriented)
1851
+ ├── dataset_metadata.json # Complete dataset metadata
1852
+ ├── summary.txt # Statistical summary
1853
+ ├── README.md # This file
1854
+ └── crystal_*/ # Individual crystal folders
1855
+ ├── images/ # Crystal growth images
1856
+ └── metadata.json # Crystal-specific metadata
1857
+ \`\`\`
1858
+
1859
+ ## Data Format
1860
+ Each crystal in dataset.json includes:
1861
+ - 3D vertex positions (x, y, z)
1862
+ - Edge connections between vertices
1863
+ - Growth time series data
1864
+ - Comprehensive metadata
1865
+
1866
+ Note: Images are stored separately in crystal folders to avoid large JSON files.
1867
+
1868
+ ## Applications
1869
+ - Machine learning training data
1870
+ - 3D graph generation research
1871
+ - Quantum system simulation
1872
+ - Time series analysis
1873
+ - Computer graphics research
1874
+
1875
+ ## Citation
1876
+ @misc{timelink2025,
1877
+ title={TIMELINK: Hybrid Time Scaling Crystal Generator},
1878
+ author={WebXOS Research},
1879
+ year={2025},
1880
+ note={Complete time crystal growth dataset}
1881
+ }
1882
+
1883
+ ## License
1884
+ MIT License
1885
+ `;
1886
+ }
1887
+
1888
+ function generateHuggingFaceDatasetCard(metadata, crystalCount) {
1889
+ return `# TIMELINK Time Crystal Dataset
1890
+
1891
+ ## Dataset Description
1892
+ This dataset contains ${crystalCount} algorithmically generated time crystal structures with corresponding growth images.
1893
+
1894
+ ### Dataset Summary
1895
+ Time crystals are quantum systems that exhibit periodic motion in their ground state. This dataset captures complete growth trajectories of algorithmically generated time crystals.
1896
+
1897
+ ### Supported Tasks
1898
+ - Graph generation and completion
1899
+ - Image generation from 3D structures
1900
+ - Time series forecasting
1901
+ - 3D structure prediction
1902
+
1903
+ ### Languages
1904
+ English
1905
+
1906
+ ## Dataset Structure
1907
+ ### Data Instances
1908
+ Each instance represents a complete time crystal with:
1909
+ - 3D vertex positions in vertexData
1910
+ - Edge connections in edgeData
1911
+ - Growth images in the images folder
1912
+ - Metadata including generation parameters
1913
+
1914
+ ### Data Fields
1915
+ - \`id\`: Unique crystal identifier
1916
+ - \`shape\`: Crystal shape type (quantum_spiral, fractal_matrix, neural_lattice, temporal_ring)
1917
+ - \`vertices\`: Number of vertices
1918
+ - \`edges\`: Number of edges
1919
+ - \`size\`: Crystal size metric
1920
+ - \`generationSteps\`: Steps taken to generate the crystal
1921
+ - \`generationTime\`: Time taken to generate (seconds)
1922
+ - \`color\`: Hex color code
1923
+ - \`vertexData\`: List of vertex objects with x, y, z coordinates and properties
1924
+ - \`edgeData\`: List of edge connections between vertices
1925
+
1926
+ ## Usage
1927
+ \`\`\`python
1928
+ from datasets import load_dataset
1929
+
1930
+ # Load the dataset
1931
+ dataset = load_dataset("json", data_files="data.json")
1932
+
1933
+ # Access the first crystal
1934
+ first_crystal = dataset['train'][0]
1935
+ print(f"Crystal ID: {first_crystal['id']}")
1936
+ print(f"Shape: {first_crystal['shape']}")
1937
+ print(f"Vertices: {first_crystal['vertices']}")
1938
+ \`\`\`
1939
+
1940
+ ## Citation
1941
+ ${metadata.citation}
1942
+
1943
+ ## License
1944
+ ${metadata.license.toUpperCase()} License
1945
+
1946
+ ## Dataset Creation
1947
+ This dataset was generated using TIMELINK v1.0 - Central Control Crystal Generator.
1948
+ `;
1949
+ }
1950
+
1951
+ function generateDatasetSummary(metadata) {
1952
+ return `TIMELINK DATASET SUMMARY
1953
+ ============================
1954
+ Total Crystals: ${metadata.total_crystals}
1955
+ Total Images: ${metadata.total_images}
1956
+ Total Generation Time: ${metadata.total_generation_time.toFixed(2)} seconds
1957
+ Shapes Generated: ${metadata.shapes_generated.join(', ')}
1958
+ Export Time: ${metadata.export_time}
1959
+ Memory Usage: ${metadata.system_info.memory_usage}
1960
+ Performance Level: ${metadata.system_info.performance_level}
1961
+ `;
1962
+ }
1963
+
1964
+ // ==================== UI FUNCTIONS ====================
1965
+ function updateUI() {
1966
+ // Update crystal count
1967
+ document.getElementById('crystalCount').textContent = generationState.crystalCount;
1968
+
1969
+ // Update crystal info
1970
+ updateCrystalInfo();
1971
+
1972
+ // Update progress
1973
+ const crystalProgress = (generationState.currentCrystal.currentStep / generationState.currentCrystal.maxSteps) * 100;
1974
+ updateCrystalProgress(crystalProgress);
1975
+
1976
+ // Update time display
1977
+ updateTimeDisplay();
1978
+
1979
+ // Update dataset size
1980
+ updateDatasetSize();
1981
+ }
1982
+
1983
+ function updateCrystalInfo() {
1984
+ const crystal = generationState.currentCrystal;
1985
+ document.getElementById('currentCrystalInfo').textContent =
1986
+ `${formatShapeName(crystal.shape)} #${generationState.crystalCount + 1}`;
1987
+ document.getElementById('vertexCount').textContent =
1988
+ `${crystal.vertices.length} vertices / ${crystal.edges.length} edges`;
1989
+ }
1990
+
1991
+ function updateCrystalProgress(percent) {
1992
+ document.getElementById('crystalProgress').style.width = percent + '%';
1993
+ document.getElementById('crystalProgressText').textContent = Math.round(percent) + '%';
1994
+ }
1995
+
1996
+ function updateTimeDisplay() {
1997
+ generationState.totalGenerationTime = (Date.now() - generationState.startTime) / 1000;
1998
+
1999
+ const totalSeconds = Math.floor(generationState.totalGenerationTime);
2000
+ const hours = Math.floor(totalSeconds / 3600);
2001
+ const minutes = Math.floor((totalSeconds % 3600) / 60);
2002
+ const seconds = totalSeconds % 60;
2003
+
2004
+ const timeString = `${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`;
2005
+ document.getElementById('timeDisplay').textContent = timeString;
2006
+ document.getElementById('totalTime').textContent = totalSeconds + 's';
2007
+ }
2008
+
2009
+ function updateDatasetSize() {
2010
+ // Estimate dataset size
2011
+ const dataSize = JSON.stringify(dataset.crystals).length / (1024 * 1024);
2012
+ const imageSize = dataset.totalImages * 0.5; // ~0.5MB per image
2013
+ systemMonitor.memoryUsage = Math.round(dataSize + imageSize);
2014
+
2015
+ document.getElementById('datasetSize').textContent = `${systemMonitor.memoryUsage} MB`;
2016
+
2017
+ const datasetProgress = Math.min((systemMonitor.memoryUsage / 500) * 100, 100);
2018
+ document.getElementById('datasetProgress').style.width = datasetProgress + '%';
2019
+
2020
+ // Update export ready status
2021
+ document.getElementById('exportReady').textContent =
2022
+ dataset.crystals.length > 0 ? 'YES' : 'NO';
2023
+ }
2024
+
2025
+ function updateShapeButtons() {
2026
+ document.querySelectorAll('.shape-btn').forEach(btn => {
2027
+ btn.classList.remove('active');
2028
+ if (btn.textContent.includes(formatShapeName(generationState.currentShape).toUpperCase())) {
2029
+ btn.classList.add('active');
2030
+ }
2031
+ });
2032
+ }
2033
+
2034
+ function toggleFullscreen() {
2035
+ const elem = document.documentElement;
2036
+
2037
+ if (!document.fullscreenElement) {
2038
+ if (elem.requestFullscreen) elem.requestFullscreen();
2039
+ else if (elem.webkitRequestFullscreen) elem.webkitRequestFullscreen();
2040
+ else if (elem.msRequestFullscreen) elem.msRequestFullscreen();
2041
+
2042
+ document.getElementById('fullscreen-btn').textContent = '🗗 EXIT FULLSCREEN';
2043
+ isFullscreen = true;
2044
+ } else {
2045
+ if (document.exitFullscreen) document.exitFullscreen();
2046
+ else if (document.webkitExitFullscreen) document.webkitExitFullscreen();
2047
+ else if (document.msExitFullscreen) document.msExitFullscreen();
2048
+
2049
+ document.getElementById('fullscreen-btn').textContent = '⛶ FULLSCREEN';
2050
+ isFullscreen = false;
2051
+ }
2052
+ }
2053
+
2054
+ function emergencyStop() {
2055
+ console.log("TIMELINK: Emergency stop activated");
2056
+
2057
+ generationState.active = false;
2058
+ if (generationInterval) {
2059
+ clearInterval(generationInterval);
2060
+ generationInterval = null;
2061
+ }
2062
+
2063
+ const centralBtn = document.getElementById('central-generate-btn');
2064
+ centralBtn.textContent = '⚡ GENERATE CRYSTALS';
2065
+ centralBtn.classList.remove('generating', 'paused');
2066
+ centralBtn.classList.add('float');
2067
+ centralBtn.style.animation = 'float 3s ease-in-out infinite';
2068
+
2069
+ if (generationState.currentCrystal.vertices.length > 0) {
2070
+ exportCompleteDataset();
2071
+ }
2072
+
2073
+ showNotification("EMERGENCY STOP", "Generation stopped. Dataset exported.");
2074
+ }
2075
+
2076
+ function continueGeneration() {
2077
+ hideSystemWarning();
2078
+ systemMonitor.warningShown = false;
2079
+ }
2080
+
2081
+ function showSystemWarning() {
2082
+ document.getElementById('system-warning').style.display = 'block';
2083
+ }
2084
+
2085
+ function hideSystemWarning() {
2086
+ document.getElementById('system-warning').style.display = 'none';
2087
+ }
2088
+
2089
+ function showNotification(title, message) {
2090
+ const notification = document.getElementById('notification');
2091
+ document.getElementById('notificationTitle').textContent = title;
2092
+ document.getElementById('notificationMessage').textContent = message;
2093
+ notification.style.display = 'block';
2094
+
2095
+ setTimeout(() => {
2096
+ notification.style.display = 'none';
2097
+ }, 3000);
2098
+ }
2099
+
2100
+ // ==================== ANIMATION LOOP ====================
2101
+ function animate(currentTime) {
2102
+ animationId = requestAnimationFrame(animate);
2103
+
2104
+ // Calculate FPS
2105
+ if (!systemMonitor.lastFrameTime) {
2106
+ systemMonitor.lastFrameTime = currentTime;
2107
+ systemMonitor.frameCount = 0;
2108
+ }
2109
+
2110
+ systemMonitor.frameCount++;
2111
+ const deltaTime = currentTime - systemMonitor.lastFrameTime;
2112
+
2113
+ if (deltaTime >= 1000) {
2114
+ systemMonitor.fps = Math.round((systemMonitor.frameCount * 1000) / deltaTime);
2115
+ document.getElementById('fpsCounter').textContent = systemMonitor.fps;
2116
+ systemMonitor.frameCount = 0;
2117
+ systemMonitor.lastFrameTime = currentTime;
2118
+ }
2119
+
2120
+ // Animate background particles
2121
+ if (window.particleLayers) {
2122
+ window.particleLayers.forEach((particles, index) => {
2123
+ const positions = particles.geometry.attributes.position.array;
2124
+ for (let i = 0; i < positions.length; i += 3) {
2125
+ const speed = 0.05 * (index + 1);
2126
+ positions[i] += (Math.random() - 0.5) * speed;
2127
+ positions[i + 1] += (Math.random() - 0.5) * speed;
2128
+ positions[i + 2] += (Math.random() - 0.5) * speed;
2129
+ }
2130
+ particles.geometry.attributes.position.needsUpdate = true;
2131
+ });
2132
+ }
2133
+
2134
+ // Animate crystal rotation
2135
+ if (currentCrystal && generationState.active) {
2136
+ currentCrystal.rotation.y += 0.002 * generationState.timeScale;
2137
+ if (currentCrystal.points) {
2138
+ currentCrystal.points.rotation.y = currentCrystal.rotation.y;
2139
+ }
2140
+ }
2141
+
2142
+ // Update controls
2143
+ if (controls) {
2144
+ controls.update();
2145
+ }
2146
+
2147
+ // Render
2148
+ if (renderer && scene && camera) {
2149
+ renderer.render(scene, camera);
2150
+ }
2151
+ }
2152
+
2153
+ // ==================== INITIALIZATION ====================
2154
+ function init() {
2155
+ console.log("TIMELINK v1.0 - Central Control Generator - Initializing...");
2156
+
2157
+ if (initThreeJS()) {
2158
+ // Setup event listeners
2159
+ document.getElementById('timeScale').addEventListener('input', function() {
2160
+ generationState.timeScale = parseFloat(this.value);
2161
+ document.getElementById('timeScaleValue').textContent = this.value + 'x';
2162
+ });
2163
+
2164
+ document.addEventListener('fullscreenchange', updateFullscreenButton);
2165
+ document.addEventListener('webkitfullscreenchange', updateFullscreenButton);
2166
+ document.addEventListener('msfullscreenchange', updateFullscreenButton);
2167
+
2168
+ window.addEventListener('resize', onWindowResize);
2169
+
2170
+ // Start animation loop
2171
+ animate(0);
2172
+
2173
+ console.log("TIMELINK: System ready with central generate button");
2174
+ showNotification("SYSTEM READY", "Click the central GENERATE CRYSTALS button to start");
2175
+ }
2176
+ }
2177
+
2178
+ function updateFullscreenButton() {
2179
+ const btn = document.getElementById('fullscreen-btn');
2180
+ if (document.fullscreenElement || document.webkitFullscreenElement || document.msFullscreenElement) {
2181
+ btn.textContent = '🗗 EXIT FULLSCREEN';
2182
+ isFullscreen = true;
2183
+ } else {
2184
+ btn.textContent = '⛶ FULLSCREEN';
2185
+ isFullscreen = false;
2186
+ }
2187
+ }
2188
+
2189
+ function onWindowResize() {
2190
+ if (camera && renderer) {
2191
+ const width = window.innerWidth;
2192
+ const height = window.innerHeight;
2193
+
2194
+ camera.aspect = width / height;
2195
+ camera.updateProjectionMatrix();
2196
+ renderer.setSize(width, height);
2197
+ }
2198
+ }
2199
+
2200
+ // Cleanup on page unload
2201
+ window.addEventListener('beforeunload', (e) => {
2202
+ if (generationState.active) {
2203
+ e.preventDefault();
2204
+ e.returnValue = 'Crystal generation in progress. Are you sure you want to leave?';
2205
+ emergencyStop();
2206
+ }
2207
+ });
2208
+
2209
+ // Start when page loads
2210
+ window.addEventListener('load', init);
2211
+
2212
+ // Global functions
2213
+ window.toggleAutomatedGeneration = toggleAutomatedGeneration;
2214
+ window.selectShape = selectShape;
2215
+ window.captureImage = captureImage;
2216
+ window.toggleAutoCapture = toggleAutoCapture;
2217
+ window.exportCurrentCrystal = exportCurrentCrystal;
2218
+ window.exportCompleteDataset = exportCompleteDataset;
2219
+ window.exportHuggingFace = exportHuggingFace;
2220
+ window.toggleFullscreen = toggleFullscreen;
2221
+ window.emergencyStop = emergencyStop;
2222
+ window.continueGeneration = continueGeneration;
2223
+ </script>
2224
+ </body>
2225
+ </html>