webxos commited on
Commit
cb8dc94
·
verified ·
1 Parent(s): 917ee3e

Delete generator

Browse files
generator/txt.txt DELETED
File without changes
generator/webXOS_geometrica v2.0.html DELETED
@@ -1,1607 +0,0 @@
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>GEOMETRICA v2.0 - by webXOS 2026</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
- <script src="https://cdn.jsdelivr.net/npm/gif.js@0.2.0/dist/gif.js"></script>
14
- <script src="https://cdn.jsdelivr.net/npm/ccapture.js@1.1.0/build/CCapture.all.min.js"></script>
15
-
16
- <style>
17
- * {
18
- margin: 0;
19
- padding: 0;
20
- box-sizing: border-box;
21
- }
22
-
23
- body {
24
- font-family: 'Courier New', monospace;
25
- background: #000000;
26
- color: #00ff00;
27
- overflow: hidden;
28
- height: 100vh;
29
- display: flex;
30
- flex-direction: column;
31
- }
32
-
33
- /* Header */
34
- #header {
35
- background: rgba(0, 30, 0, 0.95);
36
- border-bottom: 2px solid #00ff00;
37
- padding: 10px 20px;
38
- display: flex;
39
- justify-content: space-between;
40
- align-items: center;
41
- z-index: 100;
42
- height: 60px;
43
- box-shadow: 0 0 20px rgba(0, 255, 0, 0.3);
44
- }
45
-
46
- .logo {
47
- font-size: 22px;
48
- font-weight: bold;
49
- color: #00ff00;
50
- text-shadow: 0 0 10px #00ff00;
51
- letter-spacing: 2px;
52
- }
53
-
54
- .logo-sub {
55
- font-size: 12px;
56
- color: #00cc00;
57
- margin-left: 10px;
58
- }
59
-
60
- .status-indicator {
61
- display: flex;
62
- align-items: center;
63
- gap: 10px;
64
- }
65
-
66
- .live-dot {
67
- width: 12px;
68
- height: 12px;
69
- border-radius: 50%;
70
- background: #ff0000;
71
- box-shadow: 0 0 10px #ff0000;
72
- animation: pulse 1s infinite;
73
- }
74
-
75
- .live-dot.active {
76
- background: #00ff00;
77
- box-shadow: 0 0 15px #00ff00;
78
- }
79
-
80
- .header-buttons {
81
- display: flex;
82
- gap: 10px;
83
- }
84
-
85
- .header-btn {
86
- background: transparent;
87
- border: 1px solid #00ff00;
88
- color: #00ff00;
89
- padding: 8px 15px;
90
- font-family: 'Courier New', monospace;
91
- cursor: pointer;
92
- font-size: 14px;
93
- transition: all 0.3s;
94
- }
95
-
96
- .header-btn:hover {
97
- background: rgba(0, 255, 0, 0.1);
98
- box-shadow: 0 0 10px #00ff00;
99
- }
100
-
101
- .header-btn.active {
102
- background: rgba(0, 255, 0, 0.2);
103
- box-shadow: 0 0 15px #00ff00;
104
- animation: neonPulse 1.5s infinite alternate;
105
- }
106
-
107
- /* Main Content */
108
- #main-content {
109
- display: flex;
110
- flex: 1;
111
- overflow: hidden;
112
- }
113
-
114
- /* Config Panel */
115
- #config-panel {
116
- flex: 0 0 400px;
117
- background: rgba(0, 20, 0, 0.95);
118
- border-right: 2px solid #00ff00;
119
- padding: 20px;
120
- overflow-y: auto;
121
- z-index: 10;
122
- box-shadow: 5px 0 15px rgba(0, 255, 0, 0.2);
123
- }
124
-
125
- .config-section {
126
- margin-bottom: 25px;
127
- padding-bottom: 15px;
128
- border-bottom: 1px solid rgba(0, 255, 0, 0.2);
129
- }
130
-
131
- .config-title {
132
- color: #00ff00;
133
- font-size: 16px;
134
- margin-bottom: 15px;
135
- text-shadow: 0 0 5px #00ff00;
136
- }
137
-
138
- .config-group {
139
- margin-bottom: 12px;
140
- }
141
-
142
- .config-label {
143
- color: #00cc00;
144
- font-size: 13px;
145
- margin-bottom: 5px;
146
- display: block;
147
- }
148
-
149
- .config-input {
150
- width: 100%;
151
- background: rgba(0, 30, 0, 0.8);
152
- border: 1px solid #00ff00;
153
- color: #00ff00;
154
- padding: 8px 10px;
155
- font-family: 'Courier New', monospace;
156
- font-size: 14px;
157
- border-radius: 3px;
158
- }
159
-
160
- .config-input:focus {
161
- outline: none;
162
- box-shadow: 0 0 10px rgba(0, 255, 0, 0.3);
163
- }
164
-
165
- .config-select {
166
- width: 100%;
167
- background: rgba(0, 30, 0, 0.8);
168
- border: 1px solid #00ff00;
169
- color: #00ff00;
170
- padding: 8px 10px;
171
- font-family: 'Courier New', monospace;
172
- font-size: 14px;
173
- }
174
-
175
- .config-checkbox {
176
- margin-right: 8px;
177
- }
178
-
179
- .config-slider {
180
- width: 100%;
181
- margin: 10px 0;
182
- }
183
-
184
- .config-value {
185
- color: #00ff00;
186
- font-size: 12px;
187
- float: right;
188
- }
189
-
190
- /* Visualization */
191
- #visualization {
192
- flex: 1;
193
- position: relative;
194
- background: #000;
195
- }
196
-
197
- #threeCanvas {
198
- position: absolute;
199
- top: 0;
200
- left: 0;
201
- width: 100%;
202
- height: 100%;
203
- display: block;
204
- }
205
-
206
- /* Stats Panel */
207
- #stats-panel {
208
- position: absolute;
209
- bottom: 20px;
210
- right: 20px;
211
- background: rgba(0, 30, 0, 0.9);
212
- border: 2px solid #00ff00;
213
- padding: 15px;
214
- font-size: 12px;
215
- width: 300px;
216
- z-index: 5;
217
- backdrop-filter: blur(5px);
218
- }
219
-
220
- .stat-row {
221
- display: flex;
222
- justify-content: space-between;
223
- margin: 6px 0;
224
- padding: 3px 0;
225
- border-bottom: 1px solid rgba(0, 255, 0, 0.1);
226
- }
227
-
228
- .stat-label {
229
- color: #00cc00;
230
- }
231
-
232
- .stat-value {
233
- color: #00ff00;
234
- font-weight: bold;
235
- }
236
-
237
- /* Dataset Panel */
238
- #dataset-panel {
239
- position: absolute;
240
- top: 20px;
241
- right: 20px;
242
- background: rgba(0, 30, 0, 0.9);
243
- border: 2px solid #00ff00;
244
- padding: 15px;
245
- font-size: 12px;
246
- width: 350px;
247
- z-index: 5;
248
- backdrop-filter: blur(5px);
249
- }
250
-
251
- .dataset-progress {
252
- width: 100%;
253
- height: 10px;
254
- background: rgba(0, 0, 0, 0.5);
255
- border: 1px solid #00ff00;
256
- margin: 10px 0;
257
- overflow: hidden;
258
- }
259
-
260
- .dataset-progress-fill {
261
- height: 100%;
262
- background: linear-gradient(90deg, #00ff00, #00cc00);
263
- width: 0%;
264
- transition: width 0.5s ease-out;
265
- }
266
-
267
- /* Animations */
268
- @keyframes pulse {
269
- 0%, 100% { opacity: 1; }
270
- 50% { opacity: 0.5; }
271
- }
272
-
273
- @keyframes neonPulse {
274
- 0% { box-shadow: 0 0 10px #00ff00; }
275
- 100% { box-shadow: 0 0 20px #00ff00, 0 0 30px #00ff00; }
276
- }
277
-
278
- @keyframes blink {
279
- 0%, 100% { opacity: 1; }
280
- 50% { opacity: 0; }
281
- }
282
-
283
- .cursor {
284
- animation: blink 1s infinite;
285
- }
286
-
287
- /* Scrollbar */
288
- #config-panel::-webkit-scrollbar {
289
- width: 8px;
290
- }
291
-
292
- #config-panel::-webkit-scrollbar-track {
293
- background: rgba(0, 20, 0, 0.5);
294
- }
295
-
296
- #config-panel::-webkit-scrollbar-thumb {
297
- background: #00ff00;
298
- border-radius: 5px;
299
- }
300
-
301
- /* Pattern Card */
302
- .pattern-card {
303
- background: rgba(0, 40, 0, 0.8);
304
- border: 1px solid #00ff00;
305
- padding: 15px;
306
- margin-bottom: 15px;
307
- border-radius: 5px;
308
- cursor: pointer;
309
- transition: all 0.3s;
310
- }
311
-
312
- .pattern-card:hover {
313
- background: rgba(0, 60, 0, 0.9);
314
- box-shadow: 0 0 15px rgba(0, 255, 0, 0.3);
315
- }
316
-
317
- .pattern-name {
318
- color: #00ff00;
319
- font-size: 16px;
320
- margin-bottom: 10px;
321
- }
322
-
323
- .pattern-metrics {
324
- display: grid;
325
- grid-template-columns: 1fr 1fr;
326
- gap: 10px;
327
- font-size: 12px;
328
- }
329
-
330
- .metric-value {
331
- color: #00ff00;
332
- font-weight: bold;
333
- }
334
-
335
- /* Parameter Panel */
336
- #param-panel {
337
- position: absolute;
338
- top: 20px;
339
- left: 20px;
340
- background: rgba(0, 30, 0, 0.9);
341
- border: 2px solid #00ff00;
342
- padding: 15px;
343
- font-size: 12px;
344
- width: 250px;
345
- z-index: 5;
346
- backdrop-filter: blur(5px);
347
- }
348
-
349
- .param-group {
350
- margin-bottom: 10px;
351
- }
352
-
353
- .param-label {
354
- color: #00cc00;
355
- font-size: 11px;
356
- display: block;
357
- margin-bottom: 3px;
358
- }
359
-
360
- .param-slider {
361
- width: 100%;
362
- margin: 5px 0;
363
- }
364
-
365
- .param-value {
366
- color: #00ff00;
367
- font-size: 11px;
368
- float: right;
369
- }
370
- </style>
371
- </head>
372
- <body>
373
- <!-- Header -->
374
- <div id="header">
375
- <div>
376
- <div class="logo">GEOMETRICA v2.0 // webXOS 2026</div>
377
- <span class="logo-sub">Wireframe Pattern Dataset Generator</span>
378
- </div>
379
-
380
- <div class="status-indicator">
381
- <div class="live-dot" id="liveDot"></div>
382
- <span id="statusText">INITIALIZING</span>
383
- </div>
384
-
385
- <div class="header-buttons">
386
- <button class="header-btn" onclick="toggleAnimation()" id="animateBtn">▶ ANIMATE</button>
387
- <button class="header-btn" onclick="toggleCapture()" id="captureBtn">⏺ CAPTURE</button>
388
- <button class="header-btn" onclick="exportDataset()">📤 EXPORT DATASET</button>
389
- <button class="header-btn" onclick="randomizePattern()">🎲 RANDOMIZE</button>
390
- </div>
391
- </div>
392
-
393
- <!-- Main Content -->
394
- <div id="main-content">
395
- <!-- Configuration Panel -->
396
- <div id="config-panel">
397
- <div class="config-section">
398
- <div class="config-title">DATASET CONFIGURATION</div>
399
-
400
- <div class="config-group">
401
- <label class="config-label">Dataset Name</label>
402
- <input type="text" id="datasetName" class="config-input" value="wireframe_patterns_v1">
403
- </div>
404
-
405
- <div class="config-group">
406
- <label class="config-label">Dataset Size (frames)</label>
407
- <input type="range" id="datasetSize" class="config-slider" min="10" max="1000" value="100" step="10">
408
- <span id="datasetSizeValue" class="config-value">100</span>
409
- </div>
410
-
411
- <div class="config-group">
412
- <label class="config-label">Pattern Type</label>
413
- <select id="patternType" class="config-select">
414
- <option value="spiral_tower">Spiral Tower</option>
415
- <option value="fractal_sphere">Fractal Sphere</option>
416
- <option value="lattice">3D Lattice</option>
417
- <option value="helix">Double Helix</option>
418
- <option value="cube_field">Cube Field</option>
419
- <option value="wireframe_mesh">Wireframe Mesh</option>
420
- </select>
421
- </div>
422
-
423
- <div class="config-group">
424
- <label class="config-label">Export Format</label>
425
- <select id="exportFormat" class="config-select">
426
- <option value="huggingface">Hugging Face Dataset</option>
427
- <option value="images">Image Sequence (PNG)</option>
428
- <option value="gif">Animated GIF</option>
429
- <option value="json">JSON Parameters</option>
430
- </select>
431
- </div>
432
- </div>
433
-
434
- <div class="config-section">
435
- <div class="config-title">WIREFRAME STYLE</div>
436
-
437
- <div class="config-group">
438
- <label class="config-label">Line Color</label>
439
- <input type="color" id="lineColor" class="config-input" value="#00ff00" style="height: 40px;">
440
- </div>
441
-
442
- <div class="config-group">
443
- <label class="config-label">Background Color</label>
444
- <input type="color" id="bgColor" class="config-input" value="#000000" style="height: 40px;">
445
- </div>
446
-
447
- <div class="config-group">
448
- <label>
449
- <input type="checkbox" id="enableGlow" class="config-checkbox" checked>
450
- <span class="config-label">Enable Line Glow</span>
451
- </label>
452
- </div>
453
-
454
- <div class="config-group">
455
- <label>
456
- <input type="checkbox" id="enableAnimation" class="config-checkbox" checked>
457
- <span class="config-label">Enable Animation</span>
458
- </label>
459
- </div>
460
- </div>
461
-
462
- <div class="config-section">
463
- <div class="config-title">PRESET PATTERNS</div>
464
- <div id="patternCards">
465
- <div class="pattern-card" onclick="loadPreset('infinity_spiral')">
466
- <div class="pattern-name">∞ Infinity Spiral</div>
467
- <div class="pattern-metrics">
468
- <div>Complexity: <span class="metric-value">High</span></div>
469
- <div>Frames: <span class="metric-value">360</span></div>
470
- </div>
471
- </div>
472
-
473
- <div class="pattern-card" onclick="loadPreset("quantum_lattice")">
474
- <div class="pattern-name">Quantum Lattice</div>
475
- <div class="pattern-metrics">
476
- <div>Complexity: <span class="metric-value">Medium</span></div>
477
- <div>Frames: <span class="metric-value">240</span></div>
478
- </div>
479
- </div>
480
-
481
- <div class="pattern-card" onclick="loadPreset("neural_web")">
482
- <div class="pattern-name">Neural Web</div>
483
- <div class="pattern-metrics">
484
- <div>Complexity: <span class="metric-value">High</span></div>
485
- <div>Frames: <span class="metric-value">180</span></div>
486
- </div>
487
- </div>
488
- </div>
489
- </div>
490
-
491
- <div class="config-section">
492
- <div class="config-title">EXPORT SETTINGS</div>
493
-
494
- <div class="config-group">
495
- <label>
496
- <input type="checkbox" id="exportMetadata" class="config-checkbox" checked>
497
- <span class="config-label">Export Metadata</span>
498
- </label>
499
- </div>
500
-
501
- <div class="config-group">
502
- <label>
503
- <input type="checkbox" id="exportParams" class="config-checkbox" checked>
504
- <span class="config-label">Export Parameters</span>
505
- </label>
506
- </div>
507
-
508
- <div class="config-group">
509
- <label>
510
- <input type="checkbox" id="exportPreviews" class="config-checkbox" checked>
511
- <span class="config-label">Export Preview Images</span>
512
- </label>
513
- </div>
514
-
515
- <div class="config-group">
516
- <label class="config-label">Frame Rate (GIF)</label>
517
- <input type="range" id="frameRate" class="config-slider" min="5" max="60" value="30" step="5">
518
- <span id="frameRateValue" class="config-value">30 FPS</span>
519
- </div>
520
- </div>
521
- </div>
522
-
523
- <!-- Visualization -->
524
- <div id="visualization">
525
- <canvas id="threeCanvas"></canvas>
526
-
527
- <!-- Dataset Panel -->
528
- <div id="dataset-panel">
529
- <div class="stat-row">
530
- <span class="stat-label">STATUS:</span>
531
- <span class="stat-value" id="datasetStatus">READY</span>
532
- </div>
533
- <div class="stat-row">
534
- <span class="stat-label">CAPTURED FRAMES:</span>
535
- <span class="stat-value" id="capturedFrames">0</span>
536
- </div>
537
- <div class="stat-row">
538
- <span class="stat-label">TARGET FRAMES:</span>
539
- <span class="stat-value" id="targetFrames">100</span>
540
- </div>
541
- <div class="dataset-progress">
542
- <div id="captureProgress" class="dataset-progress-fill"></div>
543
- </div>
544
- <div class="stat-row">
545
- <span class="stat-label">MEMORY USAGE:</span>
546
- <span class="stat-value" id="memoryUsage">0 MB</span>
547
- </div>
548
- </div>
549
-
550
- <!-- Stats Panel -->
551
- <div id="stats-panel">
552
- <div class="stat-row">
553
- <span class="stat-label">PATTERN:</span>
554
- <span class="stat-value" id="patternName">Spiral Tower</span>
555
- </div>
556
- <div class="stat-row">
557
- <span class="stat-label">FPS:</span>
558
- <span class="stat-value" id="fpsCounter">0</span>
559
- </div>
560
- <div class="stat-row">
561
- <span class="stat-label">VERTICES:</span>
562
- <span class="stat-value" id="vertexCount">0</span>
563
- </div>
564
- <div class="stat-row">
565
- <span class="stat-label">EDGES:</span>
566
- <span class="stat-value" id="edgeCount">0</span>
567
- </div>
568
- <div class="stat-row">
569
- <span class="stat-label">ANIMATION TIME:</span>
570
- <span class="stat-value" id="animationTime">0.0s</span>
571
- </div>
572
- </div>
573
-
574
- <!-- Parameter Panel -->
575
- <div id="param-panel">
576
- <div class="param-group">
577
- <span class="param-label">COMPLEXITY</span>
578
- <span id="complexityValue" class="param-value">5</span>
579
- <input type="range" id="complexity" class="param-slider" min="1" max="10" value="5" step="1">
580
- </div>
581
-
582
- <div class="param-group">
583
- <span class="param-label">SIZE</span>
584
- <span id="sizeValue" class="param-value">50</span>
585
- <input type="range" id="size" class="param-slider" min="10" max="100" value="50" step="5">
586
- </div>
587
-
588
- <div class="param-group">
589
- <span class="param-label">DETAIL</span>
590
- <span id="detailValue" class="param-value">32</span>
591
- <input type="range" id="detail" class="param-slider" min="4" max="64" value="32" step="4">
592
- </div>
593
-
594
- <div class="param-group">
595
- <span class="param-label">SPEED</span>
596
- <span id="speedValue" class="param-value">1.0</span>
597
- <input type="range" id="speed" class="param-slider" min="0.1" max="3.0" value="1.0" step="0.1">
598
- </div>
599
-
600
- <div class="param-group">
601
- <span class="param-label">TWIST</span>
602
- <span id="twistValue" class="param-value">2.0</span>
603
- <input type="range" id="twist" class="param-slider" min="0" max="5" value="2.0" step="0.1">
604
- </div>
605
- </div>
606
- </div>
607
- </div>
608
-
609
- <script>
610
- // ==================== GLOBAL STATE ====================
611
- let animationRunning = false;
612
- let capturingFrames = false;
613
- let animationId = null;
614
- let capturer = null;
615
-
616
- let capturedFrames = [];
617
- let capturedCount = 0;
618
- let targetFrames = 100;
619
- let animationTime = 0;
620
-
621
- let lastFrameTime = performance.now();
622
- let fps = 0;
623
- let frameCount = 0;
624
- let fpsLastTime = performance.now();
625
-
626
- // Pattern parameters
627
- let patternParams = {
628
- type: 'spiral_tower',
629
- complexity: 5,
630
- size: 50,
631
- detail: 32,
632
- speed: 1.0,
633
- twist: 2.0,
634
- lineColor: '#00ff00',
635
- bgColor: '#000000',
636
- glow: true,
637
- animate: true
638
- };
639
-
640
- // Three.js components
641
- let scene, camera, renderer, controls;
642
- let patternMesh = null;
643
- let patternLines = null;
644
-
645
- // Presets
646
- const presets = {
647
- 'infinity_spiral': {
648
- type: 'spiral_tower',
649
- complexity: 8,
650
- size: 60,
651
- detail: 48,
652
- speed: 1.5,
653
- twist: 3.0,
654
- lineColor: '#00ffff'
655
- },
656
- 'quantum_lattice': {
657
- type: 'lattice',
658
- complexity: 7,
659
- size: 40,
660
- detail: 24,
661
- speed: 0.8,
662
- twist: 1.0,
663
- lineColor: '#00ff00'
664
- },
665
- 'neural_web': {
666
- type: 'wireframe_mesh',
667
- complexity: 9,
668
- size: 70,
669
- detail: 36,
670
- speed: 1.2,
671
- twist: 0.5,
672
- lineColor: '#ff00ff'
673
- }
674
- };
675
-
676
- // ==================== PATTERN GENERATORS ====================
677
- function generateSpiralTower(params) {
678
- const geometry = new THREE.BufferGeometry();
679
- const vertices = [];
680
- const indices = [];
681
-
682
- const layers = Math.floor(params.complexity * 3);
683
- const radius = params.size;
684
- const height = params.size * 2;
685
- const twist = params.twist;
686
- const segments = params.detail;
687
-
688
- // Generate vertices
689
- for (let layer = 0; layer < layers; layer++) {
690
- const y = (layer / layers) * height - height / 2;
691
- const layerRadius = radius * (1 - layer / layers * 0.3);
692
- const angleOffset = (layer / layers) * Math.PI * twist;
693
-
694
- for (let i = 0; i < segments; i++) {
695
- const angle = (i / segments) * Math.PI * 2 + angleOffset;
696
- const x = Math.cos(angle) * layerRadius;
697
- const z = Math.sin(angle) * layerRadius;
698
-
699
- vertices.push(x, y, z);
700
-
701
- // Connect to next vertex in same layer
702
- if (i < segments - 1) {
703
- const currentIndex = layer * segments + i;
704
- indices.push(currentIndex, currentIndex + 1);
705
- } else {
706
- // Connect last to first
707
- const currentIndex = layer * segments + i;
708
- indices.push(currentIndex, layer * segments);
709
- }
710
-
711
- // Connect to vertex in layer above
712
- if (layer < layers - 1) {
713
- const currentIndex = layer * segments + i;
714
- const nextIndex = (layer + 1) * segments + i;
715
- indices.push(currentIndex, nextIndex);
716
- }
717
- }
718
- }
719
-
720
- geometry.setAttribute('position', new THREE.Float32BufferAttribute(vertices, 3));
721
- geometry.setIndex(indices);
722
-
723
- return geometry;
724
- }
725
-
726
- function generateFractalSphere(params) {
727
- const geometry = new THREE.IcosahedronGeometry(params.size, params.complexity);
728
- const wireframe = new THREE.WireframeGeometry(geometry);
729
-
730
- // Add fractal displacement
731
- const positions = wireframe.attributes.position.array;
732
- for (let i = 0; i < positions.length; i += 3) {
733
- const x = positions[i], y = positions[i+1], z = positions[i+2];
734
- const noise = 0.1 * (Math.sin(x) + Math.cos(y) + Math.sin(z));
735
- positions[i] *= 1 + noise;
736
- positions[i+1] *= 1 + noise;
737
- positions[i+2] *= 1 + noise;
738
- }
739
-
740
- return wireframe;
741
- }
742
-
743
- function generateLattice(params) {
744
- const geometry = new THREE.BufferGeometry();
745
- const vertices = [];
746
- const indices = [];
747
-
748
- const gridSize = Math.floor(params.complexity);
749
- const spacing = params.size / gridSize;
750
-
751
- // Create grid points
752
- for (let x = 0; x <= gridSize; x++) {
753
- for (let y = 0; y <= gridSize; y++) {
754
- for (let z = 0; z <= gridSize; z++) {
755
- const px = (x - gridSize/2) * spacing;
756
- const py = (y - gridSize/2) * spacing;
757
- const pz = (z - gridSize/2) * spacing;
758
-
759
- // Add some noise for organic feel
760
- const noiseX = (Math.random() - 0.5) * spacing * 0.3;
761
- const noiseY = (Math.random() - 0.5) * spacing * 0.3;
762
- const noiseZ = (Math.random() - 0.5) * spacing * 0.3;
763
-
764
- vertices.push(px + noiseX, py + noiseY, pz + noiseZ);
765
- }
766
- }
767
- }
768
-
769
- // Connect points in grid
770
- const totalPoints = (gridSize + 1) * (gridSize + 1) * (gridSize + 1);
771
- for (let i = 0; i < totalPoints; i++) {
772
- const x = i % (gridSize + 1);
773
- const y = Math.floor(i / (gridSize + 1)) % (gridSize + 1);
774
- const z = Math.floor(i / ((gridSize + 1) * (gridSize + 1)));
775
-
776
- // Connect to right neighbor
777
- if (x < gridSize) {
778
- const rightIndex = i + 1;
779
- indices.push(i, rightIndex);
780
- }
781
-
782
- // Connect to above neighbor
783
- if (y < gridSize) {
784
- const aboveIndex = i + (gridSize + 1);
785
- indices.push(i, aboveIndex);
786
- }
787
-
788
- // Connect to forward neighbor
789
- if (z < gridSize) {
790
- const forwardIndex = i + (gridSize + 1) * (gridSize + 1);
791
- indices.push(i, forwardIndex);
792
- }
793
- }
794
-
795
- geometry.setAttribute('position', new THREE.Float32BufferAttribute(vertices, 3));
796
- geometry.setIndex(indices);
797
-
798
- return geometry;
799
- }
800
-
801
- function generateDoubleHelix(params) {
802
- const geometry = new THREE.BufferGeometry();
803
- const vertices = [];
804
- const indices = [];
805
-
806
- const segments = params.detail * 2;
807
- const radius = params.size / 2;
808
- const height = params.size * 1.5;
809
-
810
- // Create two interwoven helices
811
- for (let strand = 0; strand < 2; strand++) {
812
- const strandOffset = strand * Math.PI;
813
-
814
- for (let i = 0; i < segments; i++) {
815
- const t = i / segments;
816
- const y = (t - 0.5) * height;
817
- const angle = t * Math.PI * 4 + strandOffset;
818
-
819
- const x = Math.cos(angle) * radius;
820
- const z = Math.sin(angle) * radius;
821
-
822
- vertices.push(x, y, z);
823
-
824
- // Connect segments
825
- if (i < segments - 1) {
826
- const currentIndex = strand * segments + i;
827
- indices.push(currentIndex, currentIndex + 1);
828
- }
829
- }
830
- }
831
-
832
- // Connect strands with cross-links
833
- const crossLinks = Math.floor(params.complexity * 2);
834
- for (let i = 0; i < crossLinks; i++) {
835
- const t = i / crossLinks;
836
- const index1 = Math.floor(t * segments);
837
- const index2 = segments + Math.floor((1 - t) * segments);
838
- indices.push(index1, index2);
839
- }
840
-
841
- geometry.setAttribute('position', new THREE.Float32BufferAttribute(vertices, 3));
842
- geometry.setIndex(indices);
843
-
844
- return geometry;
845
- }
846
-
847
- function generateCubeField(params) {
848
- const geometry = new THREE.BufferGeometry();
849
- const vertices = [];
850
- const indices = [];
851
-
852
- const count = Math.floor(params.complexity);
853
- const spacing = params.size * 1.5 / count;
854
-
855
- // Create grid of cubes
856
- let vertexIndex = 0;
857
- for (let x = 0; x < count; x++) {
858
- for (let y = 0; y < count; y++) {
859
- for (let z = 0; z < count; z++) {
860
- const px = (x - count/2) * spacing;
861
- const py = (y - count/2) * spacing;
862
- const pz = (z - count/2) * spacing;
863
-
864
- const size = spacing * 0.3;
865
-
866
- // Cube vertices
867
- const cubeVertices = [
868
- [px-size, py-size, pz-size], [px+size, py-size, pz-size],
869
- [px+size, py+size, pz-size], [px-size, py+size, pz-size],
870
- [px-size, py-size, pz+size], [px+size, py-size, pz+size],
871
- [px+size, py+size, pz+size], [px-size, py+size, pz+size]
872
- ];
873
-
874
- // Add cube vertices
875
- cubeVertices.forEach(v => {
876
- vertices.push(...v);
877
- });
878
-
879
- // Cube edges
880
- const cubeEdges = [
881
- [0,1], [1,2], [2,3], [3,0], // bottom
882
- [4,5], [5,6], [6,7], [7,4], // top
883
- [0,4], [1,5], [2,6], [3,7] // sides
884
- ];
885
-
886
- // Add cube edges with offset
887
- cubeEdges.forEach(edge => {
888
- indices.push(vertexIndex + edge[0], vertexIndex + edge[1]);
889
- });
890
-
891
- vertexIndex += 8;
892
- }
893
- }
894
- }
895
-
896
- geometry.setAttribute('position', new THREE.Float32BufferAttribute(vertices, 3));
897
- geometry.setIndex(indices);
898
-
899
- return geometry;
900
- }
901
-
902
- function generateWireframeMesh(params) {
903
- const geometry = new THREE.BufferGeometry();
904
- const vertices = [];
905
- const indices = [];
906
-
907
- const points = params.detail * 4;
908
- const radius = params.size;
909
-
910
- // Create random points on sphere surface
911
- for (let i = 0; i < points; i++) {
912
- // Random point on sphere
913
- const theta = Math.random() * Math.PI * 2;
914
- const phi = Math.acos(2 * Math.random() - 1);
915
-
916
- const x = radius * Math.sin(phi) * Math.cos(theta);
917
- const y = radius * Math.sin(phi) * Math.sin(theta);
918
- const z = radius * Math.cos(phi);
919
-
920
- vertices.push(x, y, z);
921
- }
922
-
923
- // Connect points based on proximity
924
- const maxConnections = Math.floor(params.complexity * 2);
925
-
926
- for (let i = 0; i < points; i++) {
927
- const connections = [];
928
- const ix = i * 3;
929
-
930
- for (let j = 0; j < points; j++) {
931
- if (i === j) continue;
932
-
933
- const jx = j * 3;
934
- const dx = vertices[ix] - vertices[jx];
935
- const dy = vertices[ix+1] - vertices[jx+1];
936
- const dz = vertices[ix+2] - vertices[jx+2];
937
- const distance = Math.sqrt(dx*dx + dy*dy + dz*dz);
938
-
939
- connections.push({index: j, distance: distance});
940
- }
941
-
942
- // Sort by distance and connect to closest ones
943
- connections.sort((a, b) => a.distance - b.distance);
944
-
945
- for (let k = 0; k < Math.min(maxConnections, connections.length); k++) {
946
- indices.push(i, connections[k].index);
947
- }
948
- }
949
-
950
- geometry.setAttribute('position', new THREE.Float32BufferAttribute(vertices, 3));
951
- geometry.setIndex(indices);
952
-
953
- return geometry;
954
- }
955
-
956
- // ==================== THREE.JS SETUP ====================
957
- function initThreeJS() {
958
- try {
959
- // Scene
960
- scene = new THREE.Scene();
961
- scene.background = new THREE.Color(patternParams.bgColor);
962
-
963
- // Camera
964
- const canvas = document.getElementById('threeCanvas');
965
- camera = new THREE.PerspectiveCamera(60, canvas.clientWidth / canvas.clientHeight, 0.1, 1000);
966
- camera.position.set(0, 50, 150);
967
-
968
- // Renderer
969
- renderer = new THREE.WebGLRenderer({
970
- canvas,
971
- antialias: true,
972
- alpha: true,
973
- powerPreference: "high-performance"
974
- });
975
- renderer.setSize(canvas.clientWidth, canvas.clientHeight);
976
- renderer.setPixelRatio(window.devicePixelRatio);
977
-
978
- // Controls
979
- controls = new THREE.OrbitControls(camera, renderer.domElement);
980
- controls.enableDamping = true;
981
- controls.dampingFactor = 0.05;
982
-
983
- // Lighting
984
- const ambientLight = new THREE.AmbientLight(0xffffff, 0.3);
985
- scene.add(ambientLight);
986
-
987
- const directionalLight = new THREE.DirectionalLight(0xffffff, 0.7);
988
- directionalLight.position.set(50, 100, 50);
989
- scene.add(directionalLight);
990
-
991
- // Initialize pattern
992
- updatePattern();
993
-
994
- console.log('[Three.js] Initialized successfully');
995
- return true;
996
-
997
- } catch (error) {
998
- console.error('[Three.js] Error:', error);
999
- return false;
1000
- }
1001
- }
1002
-
1003
- function updatePattern() {
1004
- // Remove old pattern
1005
- if (patternLines) {
1006
- scene.remove(patternLines);
1007
- }
1008
-
1009
- // Generate new pattern based on type
1010
- let geometry;
1011
- switch(patternParams.type) {
1012
- case 'spiral_tower':
1013
- geometry = generateSpiralTower(patternParams);
1014
- break;
1015
- case 'fractal_sphere':
1016
- geometry = generateFractalSphere(patternParams);
1017
- break;
1018
- case 'lattice':
1019
- geometry = generateLattice(patternParams);
1020
- break;
1021
- case 'helix':
1022
- geometry = generateDoubleHelix(patternParams);
1023
- break;
1024
- case 'cube_field':
1025
- geometry = generateCubeField(patternParams);
1026
- break;
1027
- case 'wireframe_mesh':
1028
- geometry = generateWireframeMesh(patternParams);
1029
- break;
1030
- default:
1031
- geometry = generateSpiralTower(patternParams);
1032
- }
1033
-
1034
- // Create line material with glow effect
1035
- const lineColor = new THREE.Color(patternParams.lineColor);
1036
- const material = new THREE.LineBasicMaterial({
1037
- color: lineColor,
1038
- linewidth: patternParams.glow ? 2 : 1,
1039
- transparent: true,
1040
- opacity: 0.9
1041
- });
1042
-
1043
- // Create line segments
1044
- patternLines = new THREE.LineSegments(geometry, material);
1045
- scene.add(patternLines);
1046
-
1047
- // Update stats
1048
- updateStats();
1049
- }
1050
-
1051
- function updatePatternAnimation(deltaTime) {
1052
- if (!patternLines || !patternParams.animate || !animationRunning) return;
1053
-
1054
- // Different animations for different patterns
1055
- switch(patternParams.type) {
1056
- case 'spiral_tower':
1057
- patternLines.rotation.y += deltaTime * patternParams.speed * 0.5;
1058
- patternLines.rotation.x = Math.sin(animationTime * 0.5) * 0.1;
1059
- break;
1060
- case 'fractal_sphere':
1061
- patternLines.rotation.x += deltaTime * patternParams.speed * 0.3;
1062
- patternLines.rotation.y += deltaTime * patternParams.speed * 0.4;
1063
- break;
1064
- case 'lattice':
1065
- patternLines.rotation.y += deltaTime * patternParams.speed * 0.6;
1066
- const scale = 1 + Math.sin(animationTime) * 0.05;
1067
- patternLines.scale.setScalar(scale);
1068
- break;
1069
- case 'helix':
1070
- patternLines.rotation.y += deltaTime * patternParams.speed * 0.8;
1071
- break;
1072
- case 'cube_field':
1073
- patternLines.rotation.x += deltaTime * patternParams.speed * 0.2;
1074
- patternLines.rotation.y += deltaTime * patternParams.speed * 0.3;
1075
- break;
1076
- case 'wireframe_mesh':
1077
- patternLines.rotation.x = Math.sin(animationTime * 0.3) * 0.3;
1078
- patternLines.rotation.y = Math.cos(animationTime * 0.4) * 0.3;
1079
- break;
1080
- }
1081
- }
1082
-
1083
- // ==================== CAPTURE & DATASET ====================
1084
- function startCapture() {
1085
- if (capturingFrames) return;
1086
-
1087
- capturingFrames = true;
1088
- capturedFrames = [];
1089
- capturedCount = 0;
1090
- targetFrames = parseInt(document.getElementById('datasetSize').value);
1091
-
1092
- document.getElementById('captureBtn').classList.add('active');
1093
- document.getElementById('captureBtn').textContent = '⏹ STOP CAPTURE';
1094
- document.getElementById('datasetStatus').textContent = 'CAPTURING';
1095
-
1096
- console.log(`[Capture] Starting capture of ${targetFrames} frames`);
1097
- }
1098
-
1099
- function stopCapture() {
1100
- capturingFrames = false;
1101
- document.getElementById('captureBtn').classList.remove('active');
1102
- document.getElementById('captureBtn').textContent = '⏺ CAPTURE';
1103
- document.getElementById('datasetStatus').textContent = 'READY';
1104
-
1105
- console.log(`[Capture] Stopped capture. Captured ${capturedFrames.length} frames`);
1106
- }
1107
-
1108
- function captureFrame() {
1109
- if (!capturingFrames || capturedCount >= targetFrames) return;
1110
-
1111
- const canvas = document.getElementById('threeCanvas');
1112
- const imageData = canvas.toDataURL('image/png');
1113
-
1114
- const frameData = {
1115
- frame: capturedCount,
1116
- timestamp: Date.now(),
1117
- animationTime: animationTime,
1118
- params: {...patternParams},
1119
- camera: {
1120
- position: {x: camera.position.x, y: camera.position.y, z: camera.position.z},
1121
- rotation: {x: camera.rotation.x, y: camera.rotation.y, z: camera.rotation.z}
1122
- }
1123
- };
1124
-
1125
- capturedFrames.push({
1126
- data: frameData,
1127
- image: imageData
1128
- });
1129
-
1130
- capturedCount++;
1131
-
1132
- // Update UI
1133
- document.getElementById('capturedFrames').textContent = capturedCount;
1134
- document.getElementById('targetFrames').textContent = targetFrames;
1135
- const progress = (capturedCount / targetFrames) * 100;
1136
- document.getElementById('captureProgress').style.width = progress + '%';
1137
-
1138
- // Update memory usage
1139
- const memory = Math.round(JSON.stringify(capturedFrames).length / 1024);
1140
- document.getElementById('memoryUsage').textContent = memory + ' KB';
1141
-
1142
- // Stop if reached target
1143
- if (capturedCount >= targetFrames) {
1144
- stopCapture();
1145
- }
1146
- }
1147
-
1148
- async function exportDataset() {
1149
- if (capturedFrames.length === 0) {
1150
- alert('No frames captured! Start capture first.');
1151
- return;
1152
- }
1153
-
1154
- console.log('[Export] Preparing dataset export...');
1155
-
1156
- try {
1157
- const zip = new JSZip();
1158
- const datasetName = document.getElementById('datasetName').value;
1159
- const exportFormat = document.getElementById('exportFormat').value;
1160
-
1161
- // 1. Dataset metadata
1162
- const metadata = {
1163
- name: datasetName,
1164
- version: "2.0",
1165
- created: new Date().toISOString(),
1166
- frames: capturedFrames.length,
1167
- patternType: patternParams.type,
1168
- exportFormat: exportFormat,
1169
- description: "Wireframe geometric pattern dataset generated by Geometrica v2.0",
1170
- license: "MIT",
1171
- citation: "@misc{wireframe_patterns_2024,\n title={Wireframe Geometric Patterns},\n author={Geometrica v2.0},\n year={2024},\n url={https://github.com/your-username/dataset}\n}"
1172
- };
1173
-
1174
- zip.file("metadata.json", JSON.stringify(metadata, null, 2));
1175
-
1176
- // 2. Frames data
1177
- if (document.getElementById('exportParams').checked) {
1178
- const framesData = capturedFrames.map(f => f.data);
1179
- zip.file("frames.json", JSON.stringify(framesData, null, 2));
1180
- }
1181
-
1182
- // 3. Images
1183
- if (exportFormat === 'images' || exportFormat === 'huggingface') {
1184
- const imgFolder = zip.folder("images");
1185
- for (let i = 0; i < capturedFrames.length; i++) {
1186
- const base64Data = capturedFrames[i].image.replace(/^data:image\/png;base64,/, "");
1187
- imgFolder.file(`frame_${i.toString().padStart(4, '0')}.png`, base64Data, {base64: true});
1188
- }
1189
- }
1190
-
1191
- // 4. Configuration
1192
- const config = {
1193
- patternParams: patternParams,
1194
- cameraSettings: {
1195
- position: camera.position,
1196
- rotation: camera.rotation,
1197
- fov: camera.fov
1198
- },
1199
- generationSettings: {
1200
- targetFrames: targetFrames,
1201
- capturedFrames: capturedCount,
1202
- animationEnabled: patternParams.animate,
1203
- glowEnabled: patternParams.glow
1204
- }
1205
- };
1206
-
1207
- zip.file("config.json", JSON.stringify(config, null, 2));
1208
-
1209
- // 5. README
1210
- const readme = generateReadme(metadata, config);
1211
- zip.file("README.md", readme);
1212
-
1213
- // 6. Generate and download
1214
- const content = await zip.generateAsync({type: "blob"});
1215
- const filename = `${datasetName}_${exportFormat}_${Date.now()}.zip`;
1216
- saveAs(content, filename);
1217
-
1218
- console.log(`[Export] Dataset exported: ${filename}`);
1219
- console.log(`[Export] Total frames: ${capturedFrames.length}`);
1220
- console.log(`[Export] Size: ${(content.size / 1024 / 1024).toFixed(2)} MB`);
1221
-
1222
- } catch (error) {
1223
- console.error('[Export] Error:', error);
1224
- alert('Export failed: ' + error.message);
1225
- }
1226
- }
1227
-
1228
- function generateReadme(metadata, config) {
1229
- return `# ${metadata.name}
1230
-
1231
- ## Dataset Description
1232
-
1233
- This dataset contains wireframe geometric patterns generated using Geometrica v2.0, focusing on procedural generation of abstract geometric structures with infinite loop animations.
1234
-
1235
- ## Dataset Contents
1236
-
1237
- - **Total Frames:** ${metadata.frames}
1238
- - **Pattern Type:** ${metadata.patternType}
1239
- - **Generation Date:** ${metadata.created}
1240
- - **Export Format:** ${metadata.exportFormat}
1241
-
1242
- ## Pattern Parameters
1243
-
1244
- - **Complexity:** ${config.patternParams.complexity}
1245
- - **Size:** ${config.patternParams.size}
1246
- - **Detail Level:** ${config.patternParams.detail}
1247
- - **Animation Speed:** ${config.patternParams.speed}
1248
- - **Line Color:** ${config.patternParams.lineColor}
1249
- - **Background Color:** ${config.patternParams.bgColor}
1250
-
1251
- ## File Structure
1252
-
1253
- \`\`\`
1254
- dataset.zip/
1255
- ├── metadata.json # Dataset information
1256
- ├── config.json # Generation parameters
1257
- ├── frames.json # Frame-by-frame data (optional)
1258
- ├── images/ # PNG images of each frame
1259
- │ └── frame_*.png
1260
- └── README.md # This file
1261
- \`\`\`
1262
-
1263
- ## Usage Examples
1264
-
1265
- ### Python (Loading Images)
1266
-
1267
- \`\`\`python
1268
- import os
1269
- from PIL import Image
1270
- import json
1271
-
1272
- # Load metadata
1273
- with open('metadata.json', 'r') as f:
1274
- metadata = json.load(f)
1275
-
1276
- # Load images
1277
- images = []
1278
- for i in range(metadata['frames']):
1279
- img_path = f'images/frame_{i:04d}.png'
1280
- img = Image.open(img_path)
1281
- images.append(img)
1282
- \`\`\`
1283
-
1284
- ### JavaScript (Three.js Recreation)
1285
-
1286
- \`\`\`javascript
1287
- // Load configuration
1288
- const config = await fetch('config.json').then(r => r.json());
1289
-
1290
- // Recreate pattern based on parameters
1291
- function recreatePattern(params) {
1292
- // Implementation depends on pattern type
1293
- // Use the parameters from config.patternParams
1294
- }
1295
- \`\`\`
1296
-
1297
- ## Citation
1298
-
1299
- If you use this dataset in your research, please cite:
1300
-
1301
- \`\`\`bibtex
1302
- ${metadata.citation}
1303
- \`\`\`
1304
-
1305
- ## License
1306
-
1307
- ${metadata.license} License
1308
-
1309
- ## Contact
1310
-
1311
- Generated by Geometrica v2.0 - Wireframe Pattern Dataset Generator
1312
- `;
1313
- }
1314
-
1315
- // ==================== GIF CAPTURE ====================
1316
- function startGifCapture() {
1317
- const frameRate = parseInt(document.getElementById('frameRate').value);
1318
-
1319
- capturer = new CCapture({
1320
- format: 'gif',
1321
- workersPath: '',
1322
- verbose: false,
1323
- framerate: frameRate,
1324
- quality: 90,
1325
- timeLimit: 5,
1326
- autoSaveTime: 0
1327
- });
1328
-
1329
- capturer.start();
1330
- console.log('[GIF] Started recording');
1331
- }
1332
-
1333
- function stopGifCapture() {
1334
- if (capturer) {
1335
- capturer.stop();
1336
- capturer.save();
1337
- capturer = null;
1338
- console.log('[GIF] Saved recording');
1339
- }
1340
- }
1341
-
1342
- // ==================== UI CONTROLS ====================
1343
- function toggleAnimation() {
1344
- animationRunning = !animationRunning;
1345
- const btn = document.getElementById('animateBtn');
1346
-
1347
- if (animationRunning) {
1348
- btn.classList.add('active');
1349
- btn.textContent = '⏸ PAUSE';
1350
- document.getElementById('statusText').textContent = 'ANIMATING';
1351
- document.getElementById('liveDot').classList.add('active');
1352
-
1353
- if (!animationId) {
1354
- lastFrameTime = performance.now();
1355
- animationId = requestAnimationFrame(animationLoop);
1356
- }
1357
- } else {
1358
- btn.classList.remove('active');
1359
- btn.textContent = '▶ ANIMATE';
1360
- document.getElementById('statusText').textContent = 'PAUSED';
1361
- document.getElementById('liveDot').classList.remove('active');
1362
- }
1363
- }
1364
-
1365
- function toggleCapture() {
1366
- if (capturingFrames) {
1367
- stopCapture();
1368
- } else {
1369
- startCapture();
1370
- }
1371
- }
1372
-
1373
- function randomizePattern() {
1374
- const types = ['spiral_tower', 'fractal_sphere', 'lattice', 'helix', 'cube_field', 'wireframe_mesh'];
1375
- const colors = ['#00ff00', '#00ffff', '#ff00ff', '#ffff00', '#ff0000', '#ffffff'];
1376
-
1377
- patternParams.type = types[Math.floor(Math.random() * types.length)];
1378
- patternParams.complexity = Math.floor(Math.random() * 10) + 1;
1379
- patternParams.size = Math.floor(Math.random() * 50) + 20;
1380
- patternParams.detail = Math.floor(Math.random() * 10) * 4 + 8;
1381
- patternParams.speed = Math.random() * 2 + 0.5;
1382
- patternParams.twist = Math.random() * 5;
1383
- patternParams.lineColor = colors[Math.floor(Math.random() * colors.length)];
1384
-
1385
- // Update UI
1386
- document.getElementById('patternType').value = patternParams.type;
1387
- document.getElementById('lineColor').value = patternParams.lineColor;
1388
- document.getElementById('complexity').value = patternParams.complexity;
1389
- document.getElementById('size').value = patternParams.size;
1390
- document.getElementById('detail').value = patternParams.detail;
1391
- document.getElementById('speed').value = patternParams.speed;
1392
- document.getElementById('twist').value = patternParams.twist;
1393
-
1394
- updateUIValues();
1395
- updatePattern();
1396
-
1397
- console.log('[Pattern] Randomized:', patternParams);
1398
- }
1399
-
1400
- function loadPreset(presetName) {
1401
- if (presets[presetName]) {
1402
- patternParams = {...patternParams, ...presets[presetName]};
1403
-
1404
- // Update UI
1405
- document.getElementById('patternType').value = patternParams.type;
1406
- document.getElementById('lineColor').value = patternParams.lineColor;
1407
- document.getElementById('complexity').value = patternParams.complexity;
1408
- document.getElementById('size').value = patternParams.size;
1409
- document.getElementById('detail').value = patternParams.detail;
1410
- document.getElementById('speed').value = patternParams.speed;
1411
- document.getElementById('twist').value = patternParams.twist;
1412
-
1413
- updateUIValues();
1414
- updatePattern();
1415
- updatePatternName();
1416
-
1417
- console.log(`[Pattern] Loaded preset: ${presetName}`);
1418
- }
1419
- }
1420
-
1421
- // ==================== ANIMATION LOOP ====================
1422
- function animationLoop(currentTime) {
1423
- const deltaTime = (currentTime - lastFrameTime) / 1000;
1424
- lastFrameTime = currentTime;
1425
-
1426
- // Update animation time
1427
- if (animationRunning) {
1428
- animationTime += deltaTime * patternParams.speed;
1429
- document.getElementById('animationTime').textContent = animationTime.toFixed(1) + 's';
1430
- }
1431
-
1432
- // Update pattern animation
1433
- updatePatternAnimation(deltaTime);
1434
-
1435
- // Update controls
1436
- controls.update();
1437
-
1438
- // Render
1439
- renderer.render(scene, camera);
1440
-
1441
- // Capture frame if capturing
1442
- if (animationRunning && capturingFrames) {
1443
- captureFrame();
1444
- }
1445
-
1446
- // Capture GIF frame
1447
- if (capturer) {
1448
- capturer.capture(renderer.domElement);
1449
- }
1450
-
1451
- // Update FPS
1452
- frameCount++;
1453
- if (currentTime - fpsLastTime >= 1000) {
1454
- fps = Math.round((frameCount * 1000) / (currentTime - fpsLastTime));
1455
- frameCount = 0;
1456
- fpsLastTime = currentTime;
1457
- document.getElementById('fpsCounter').textContent = fps;
1458
- }
1459
-
1460
- animationId = requestAnimationFrame(animationLoop);
1461
- }
1462
-
1463
- // ==================== UI UPDATES ====================
1464
- function updateStats() {
1465
- if (patternLines && patternLines.geometry) {
1466
- const vertices = patternLines.geometry.attributes.position.count;
1467
- const edges = patternLines.geometry.index ? patternLines.geometry.index.count / 2 : vertices * 1.5;
1468
-
1469
- document.getElementById('vertexCount').textContent = vertices;
1470
- document.getElementById('edgeCount').textContent = Math.floor(edges);
1471
- }
1472
- }
1473
-
1474
- function updatePatternName() {
1475
- const select = document.getElementById('patternType');
1476
- document.getElementById('patternName').textContent = select.options[select.selectedIndex].text;
1477
- }
1478
-
1479
- function updateUIValues() {
1480
- document.getElementById('complexityValue').textContent = patternParams.complexity;
1481
- document.getElementById('sizeValue').textContent = patternParams.size;
1482
- document.getElementById('detailValue').textContent = patternParams.detail;
1483
- document.getElementById('speedValue').textContent = patternParams.speed.toFixed(1);
1484
- document.getElementById('twistValue').textContent = patternParams.twist.toFixed(1);
1485
- }
1486
-
1487
- // ==================== INITIALIZATION ====================
1488
- function initialize() {
1489
- console.log('[System] Initializing Geometric Pattern Generator...');
1490
-
1491
- try {
1492
- // Initialize Three.js
1493
- initThreeJS();
1494
-
1495
- // Setup event listeners
1496
- setupEventListeners();
1497
-
1498
- // Start animation loop
1499
- lastFrameTime = performance.now();
1500
- animationId = requestAnimationFrame(animationLoop);
1501
-
1502
- // Update UI
1503
- document.getElementById('statusText').textContent = 'READY';
1504
- updatePatternName();
1505
- updateUIValues();
1506
-
1507
- // Set initial target frames
1508
- targetFrames = parseInt(document.getElementById('datasetSize').value);
1509
- document.getElementById('targetFrames').textContent = targetFrames;
1510
-
1511
- console.log('[System] Initialization complete');
1512
-
1513
- } catch (error) {
1514
- console.error('[System] Initialization failed:', error);
1515
- }
1516
- }
1517
-
1518
- function setupEventListeners() {
1519
- // Pattern type
1520
- document.getElementById('patternType').addEventListener('change', function() {
1521
- patternParams.type = this.value;
1522
- updatePattern();
1523
- updatePatternName();
1524
- });
1525
-
1526
- // Line color
1527
- document.getElementById('lineColor').addEventListener('input', function() {
1528
- patternParams.lineColor = this.value;
1529
- scene.background = new THREE.Color(document.getElementById('bgColor').value);
1530
- updatePattern();
1531
- });
1532
-
1533
- // Background color
1534
- document.getElementById('bgColor').addEventListener('input', function() {
1535
- patternParams.bgColor = this.value;
1536
- scene.background = new THREE.Color(this.value);
1537
- });
1538
-
1539
- // Glow effect
1540
- document.getElementById('enableGlow').addEventListener('change', function() {
1541
- patternParams.glow = this.checked;
1542
- updatePattern();
1543
- });
1544
-
1545
- // Animation
1546
- document.getElementById('enableAnimation').addEventListener('change', function() {
1547
- patternParams.animate = this.checked;
1548
- });
1549
-
1550
- // Dataset size
1551
- const datasetSize = document.getElementById('datasetSize');
1552
- const datasetSizeValue = document.getElementById('datasetSizeValue');
1553
-
1554
- datasetSize.addEventListener('input', function() {
1555
- const value = parseInt(this.value);
1556
- datasetSizeValue.textContent = value;
1557
- targetFrames = value;
1558
- document.getElementById('targetFrames').textContent = value;
1559
- });
1560
-
1561
- // Frame rate
1562
- const frameRate = document.getElementById('frameRate');
1563
- const frameRateValue = document.getElementById('frameRateValue');
1564
-
1565
- frameRate.addEventListener('input', function() {
1566
- frameRateValue.textContent = this.value + ' FPS';
1567
- });
1568
-
1569
- // Parameter sliders
1570
- const sliders = ['complexity', 'size', 'detail', 'speed', 'twist'];
1571
- sliders.forEach(id => {
1572
- const slider = document.getElementById(id);
1573
- const valueSpan = document.getElementById(id + 'Value');
1574
-
1575
- slider.addEventListener('input', function() {
1576
- const value = this.name === 'speed' || this.name === 'twist' ?
1577
- parseFloat(this.value) : parseInt(this.value);
1578
- patternParams[this.name || id] = value;
1579
- valueSpan.textContent = this.name === 'speed' || this.name === 'twist' ?
1580
- value.toFixed(1) : value;
1581
- updatePattern();
1582
- });
1583
- });
1584
- }
1585
-
1586
- function handleResize() {
1587
- if (camera && renderer) {
1588
- const canvas = document.getElementById('threeCanvas');
1589
- camera.aspect = canvas.clientWidth / canvas.clientHeight;
1590
- camera.updateProjectionMatrix();
1591
- renderer.setSize(canvas.clientWidth, canvas.clientHeight);
1592
- }
1593
- }
1594
-
1595
- // Start the system
1596
- window.addEventListener('load', initialize);
1597
- window.addEventListener('resize', handleResize);
1598
-
1599
- // Export to global scope for button clicks
1600
- window.toggleAnimation = toggleAnimation;
1601
- window.toggleCapture = toggleCapture;
1602
- window.exportDataset = exportDataset;
1603
- window.randomizePattern = randomizePattern;
1604
- window.loadPreset = loadPreset;
1605
- </script>
1606
- </body>
1607
- </html>