File size: 31,863 Bytes
4dd230c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Object Remesher | 3D Mesh Optimization</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        .dropzone {
            border: 2px dashed #94a3b8;
            transition: all 0.3s ease;
        }
        .dropzone.active {
            border-color: #6366f1;
            background-color: #e0e7ff;
        }
        .mesh-preview {
            background: linear-gradient(45deg, #f3f4f6 25%, transparent 25%),
                        linear-gradient(-45deg, #f3f4f6 25%, transparent 25%),
                        linear-gradient(45deg, transparent 75%, #f3f4f6 75%),
                        linear-gradient(-45deg, transparent 75%, #f3f4f6 75%);
            background-size: 20px 20px;
            background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
        }
        .progress-bar {
            transition: width 0.3s ease;
        }
        canvas {
            touch-action: none;
        }
        .tooltip {
            position: relative;
        }
        .tooltip-text {
            visibility: hidden;
            width: 200px;
            background-color: #1e293b;
            color: #fff;
            text-align: center;
            border-radius: 6px;
            padding: 5px;
            position: absolute;
            z-index: 1;
            bottom: 125%;
            left: 50%;
            transform: translateX(-50%);
            opacity: 0;
            transition: opacity 0.3s;
        }
        .tooltip:hover .tooltip-text {
            visibility: visible;
            opacity: 1;
        }
    </style>
</head>
<body class="bg-gray-50 text-gray-800">
    <div class="min-h-screen flex flex-col">
        <!-- Header -->
        <header class="bg-indigo-600 text-white shadow-md">
            <div class="container mx-auto px-4 py-4 flex justify-between items-center">
                <div class="flex items-center space-x-2">
                    <i class="fas fa-cube text-2xl"></i>
                    <h1 class="text-2xl font-bold">Object Remesher</h1>
                </div>
                <nav>
                    <ul class="flex space-x-6">
                        <li><a href="#" class="hover:text-indigo-200 transition">Home</a></li>
                        <li><a href="#" class="hover:text-indigo-200 transition">Features</a></li>
                        <li><a href="#" class="hover:text-indigo-200 transition">Documentation</a></li>
                        <li><a href="#" class="hover:text-indigo-200 transition">Contact</a></li>
                    </ul>
                </nav>
            </div>
        </header>

        <!-- Main Content -->
        <main class="flex-grow container mx-auto px-4 py-8">
            <div class="grid grid-cols-1 lg:grid-cols-3 gap-8">
                <!-- Left Panel - Upload and Controls -->
                <div class="lg:col-span-1 space-y-6">
                    <div class="bg-white rounded-xl shadow-md p-6">
                        <h2 class="text-xl font-semibold mb-4 flex items-center">
                            <i class="fas fa-upload mr-2 text-indigo-500"></i>
                            Upload 3D Model
                        </h2>
                        
                        <div id="dropzone" class="dropzone rounded-lg p-8 text-center cursor-pointer mb-4">
                            <i class="fas fa-cloud-upload-alt text-4xl text-indigo-400 mb-2"></i>
                            <p class="text-gray-500">Drag & drop your 3D model file here</p>
                            <p class="text-sm text-gray-400 mt-1">Supported formats: .obj, .stl, .fbx, .gltf</p>
                            <input type="file" id="fileInput" class="hidden" accept=".obj,.stl,.fbx,.gltf">
                            <button id="browseBtn" class="mt-4 bg-indigo-500 hover:bg-indigo-600 text-white px-4 py-2 rounded-md transition">
                                Browse Files
                            </button>
                        </div>
                        
                        <div id="fileInfo" class="hidden bg-gray-100 p-3 rounded-md mb-4">
                            <div class="flex justify-between items-center">
                                <div>
                                    <p class="font-medium" id="fileName">model.obj</p>
                                    <p class="text-sm text-gray-500" id="fileSize">12.4 MB</p>
                                </div>
                                <button id="removeFile" class="text-red-500 hover:text-red-700">
                                    <i class="fas fa-times"></i>
                                </button>
                            </div>
                        </div>
                    </div>
                    
                    <div class="bg-white rounded-xl shadow-md p-6">
                        <h2 class="text-xl font-semibold mb-4 flex items-center">
                            <i class="fas fa-sliders-h mr-2 text-indigo-500"></i>
                            Remeshing Settings
                        </h2>
                        
                        <div class="space-y-4">
                            <div>
                                <label class="block text-sm font-medium text-gray-700 mb-1">Target Density</label>
                                <div class="flex items-center space-x-2">
                                    <input type="range" min="0.1" max="2" step="0.1" value="1" class="w-full" id="densitySlider">
                                    <span class="text-sm w-10 text-center" id="densityValue">1.0</span>
                                </div>
                            </div>
                            
                            <div>
                                <label class="block text-sm font-medium text-gray-700 mb-1">Preserve Features</label>
                                <select class="w-full border border-gray-300 rounded-md px-3 py-2 focus:outline-none focus:ring-2 focus:ring-indigo-500">
                                    <option>Sharp Edges</option>
                                    <option selected>All Features</option>
                                    <option>None</option>
                                </select>
                            </div>
                            
                            <div>
                                <label class="block text-sm font-medium text-gray-700 mb-1">Remeshing Method</label>
                                <div class="grid grid-cols-2 gap-2">
                                    <button class="bg-indigo-100 text-indigo-700 border border-indigo-300 rounded-md px-3 py-2 text-sm font-medium">Isotropic</button>
                                    <button class="bg-white text-gray-700 border border-gray-300 rounded-md px-3 py-2 text-sm font-medium">Anisotropic</button>
                                    <button class="bg-white text-gray-700 border border-gray-300 rounded-md px-3 py-2 text-sm font-medium">Quad Dominant</button>
                                    <button class="bg-white text-gray-700 border border-gray-300 rounded-md px-3 py-2 text-sm font-medium">Adaptive</button>
                                </div>
                            </div>
                            
                            <div class="pt-2">
                                <button id="remeshBtn" class="w-full bg-indigo-600 hover:bg-indigo-700 text-white py-2 px-4 rounded-md font-medium transition flex items-center justify-center">
                                    <i class="fas fa-magic mr-2"></i>
                                    Remesh Model
                                </button>
                            </div>
                        </div>
                    </div>
                    
                    <div class="bg-white rounded-xl shadow-md p-6">
                        <h2 class="text-xl font-semibold mb-4 flex items-center">
                            <i class="fas fa-chart-bar mr-2 text-indigo-500"></i>
                            Mesh Statistics
                        </h2>
                        
                        <div class="space-y-3">
                            <div class="flex justify-between">
                                <span class="text-gray-600">Original Faces:</span>
                                <span class="font-medium" id="originalFaces">0</span>
                            </div>
                            <div class="flex justify-between">
                                <span class="text-gray-600">Remeshed Faces:</span>
                                <span class="font-medium" id="remeshedFaces">0</span>
                            </div>
                            <div class="flex justify-between">
                                <span class="text-gray-600">Reduction:</span>
                                <span class="font-medium" id="reduction">0%</span>
                            </div>
                            <div class="flex justify-between">
                                <span class="text-gray-600">File Size:</span>
                                <span class="font-medium" id="fileSizeStat">0 MB</span>
                            </div>
                        </div>
                    </div>
                </div>
                
                <!-- Right Panel - 3D Viewer and Results -->
                <div class="lg:col-span-2 space-y-6">
                    <div class="bg-white rounded-xl shadow-md overflow-hidden">
                        <div class="flex justify-between items-center border-b border-gray-200 px-6 py-4">
                            <h2 class="text-xl font-semibold flex items-center">
                                <i class="fas fa-cube mr-2 text-indigo-500"></i>
                                3D Model Viewer
                            </h2>
                            <div class="flex space-x-2">
                                <button class="tooltip p-2 text-gray-500 hover:text-indigo-500 rounded-full hover:bg-gray-100 transition">
                                    <i class="fas fa-rotate"></i>
                                    <span class="tooltip-text">Rotate Model</span>
                                </button>
                                <button class="tooltip p-2 text-gray-500 hover:text-indigo-500 rounded-full hover:bg-gray-100 transition">
                                    <i class="fas fa-arrows-up-down-left-right"></i>
                                    <span class="tooltip-text">Pan Model</span>
                                </button>
                                <button class="tooltip p-2 text-gray-500 hover:text-indigo-500 rounded-full hover:bg-gray-100 transition">
                                    <i class="fas fa-search-plus"></i>
                                    <span class="tooltip-text">Zoom In/Out</span>
                                </button>
                                <button class="tooltip p-2 text-gray-500 hover:text-indigo-500 rounded-full hover:bg-gray-100 transition">
                                    <i class="fas fa-border-all"></i>
                                    <span class="tooltip-text">Toggle Wireframe</span>
                                </button>
                            </div>
                        </div>
                        <div class="mesh-preview h-96 relative">
                            <canvas id="modelCanvas" class="w-full h-full"></canvas>
                            <div id="loadingOverlay" class="absolute inset-0 bg-black bg-opacity-50 flex items-center justify-center hidden">
                                <div class="text-center text-white">
                                    <div class="animate-spin rounded-full h-12 w-12 border-t-2 border-b-2 border-indigo-500 mx-auto mb-4"></div>
                                    <p>Processing model...</p>
                                    <div class="w-full bg-gray-200 rounded-full h-2.5 mt-4 mx-auto max-w-md">
                                        <div id="progressBar" class="progress-bar bg-indigo-600 h-2.5 rounded-full" style="width: 0%"></div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                    <div class="bg-white rounded-xl shadow-md overflow-hidden">
                        <div class="border-b border-gray-200">
                            <nav class="flex -mb-px">
                                <button class="tab-button active py-4 px-6 text-center border-b-2 font-medium text-sm border-indigo-500 text-indigo-600">
                                    <i class="fas fa-list mr-2"></i>
                                    Comparison
                                </button>
                                <button class="tab-button py-4 px-6 text-center border-b-2 font-medium text-sm border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300">
                                    <i class="fas fa-download mr-2"></i>
                                    Export
                                </button>
                                <button class="tab-button py-4 px-6 text-center border-b-2 font-medium text-sm border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300">
                                    <i class="fas fa-history mr-2"></i>
                                    History
                                </button>
                            </nav>
                        </div>
                        <div class="p-6">
                            <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                                <div>
                                    <h3 class="font-medium text-gray-700 mb-3">Original Model</h3>
                                    <div class="bg-gray-100 rounded-lg p-4 h-48 flex items-center justify-center">
                                        <p class="text-gray-500">Original mesh will appear here</p>
                                    </div>
                                    <div class="mt-3 text-sm text-gray-600">
                                        <p><span class="font-medium">Vertices:</span> <span id="originalVertices">0</span></p>
                                        <p><span class="font-medium">Faces:</span> <span id="originalFaces2">0</span></p>
                                    </div>
                                </div>
                                <div>
                                    <h3 class="font-medium text-gray-700 mb-3">Remeshed Model</h3>
                                    <div class="bg-gray-100 rounded-lg p-4 h-48 flex items-center justify-center">
                                        <p class="text-gray-500">Optimized mesh will appear here</p>
                                    </div>
                                    <div class="mt-3 text-sm text-gray-600">
                                        <p><span class="font-medium">Vertices:</span> <span id="remeshedVertices">0</span></p>
                                        <p><span class="font-medium">Faces:</span> <span id="remeshedFaces2">0</span></p>
                                    </div>
                                </div>
                            </div>
                            
                            <div class="mt-6">
                                <button class="bg-green-600 hover:bg-green-700 text-white py-2 px-6 rounded-md font-medium transition flex items-center">
                                    <i class="fas fa-download mr-2"></i>
                                    Download Remeshed Model
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </main>
        
        <!-- Footer -->
        <footer class="bg-gray-800 text-white py-8">
            <div class="container mx-auto px-4">
                <div class="grid grid-cols-1 md:grid-cols-4 gap-8">
                    <div>
                        <h3 class="text-lg font-semibold mb-4">Object Remesher</h3>
                        <p class="text-gray-400">Advanced 3D mesh optimization tool for professionals and enthusiasts.</p>
                    </div>
                    <div>
                        <h3 class="text-lg font-semibold mb-4">Quick Links</h3>
                        <ul class="space-y-2">
                            <li><a href="#" class="text-gray-400 hover:text-white transition">Home</a></li>
                            <li><a href="#" class="text-gray-400 hover:text-white transition">Features</a></li>
                            <li><a href="#" class="text-gray-400 hover:text-white transition">Pricing</a></li>
                            <li><a href="#" class="text-gray-400 hover:text-white transition">Blog</a></li>
                        </ul>
                    </div>
                    <div>
                        <h3 class="text-lg font-semibold mb-4">Support</h3>
                        <ul class="space-y-2">
                            <li><a href="#" class="text-gray-400 hover:text-white transition">Documentation</a></li>
                            <li><a href="#" class="text-gray-400 hover:text-white transition">Tutorials</a></li>
                            <li><a href="#" class="text-gray-400 hover:text-white transition">API Reference</a></li>
                            <li><a href="#" class="text-gray-400 hover:text-white transition">Contact Us</a></li>
                        </ul>
                    </div>
                    <div>
                        <h3 class="text-lg font-semibold mb-4">Connect</h3>
                        <div class="flex space-x-4">
                            <a href="#" class="text-gray-400 hover:text-white transition"><i class="fab fa-twitter"></i></a>
                            <a href="#" class="text-gray-400 hover:text-white transition"><i class="fab fa-github"></i></a>
                            <a href="#" class="text-gray-400 hover:text-white transition"><i class="fab fa-discord"></i></a>
                            <a href="#" class="text-gray-400 hover:text-white transition"><i class="fab fa-youtube"></i></a>
                        </div>
                    </div>
                </div>
                <div class="border-t border-gray-700 mt-8 pt-6 text-center text-gray-400">
                    <p>&copy; 2023 Object Remesher. All rights reserved.</p>
                </div>
            </div>
        </footer>
    </div>

    <script>
        // DOM Elements
        const dropzone = document.getElementById('dropzone');
        const fileInput = document.getElementById('fileInput');
        const browseBtn = document.getElementById('browseBtn');
        const fileInfo = document.getElementById('fileInfo');
        const fileName = document.getElementById('fileName');
        const fileSize = document.getElementById('fileSize');
        const removeFile = document.getElementById('removeFile');
        const remeshBtn = document.getElementById('remeshBtn');
        const densitySlider = document.getElementById('densitySlider');
        const densityValue = document.getElementById('densityValue');
        const loadingOverlay = document.getElementById('loadingOverlay');
        const progressBar = document.getElementById('progressBar');
        const tabButtons = document.querySelectorAll('.tab-button');
        
        // Event Listeners
        browseBtn.addEventListener('click', () => fileInput.click());
        
        fileInput.addEventListener('change', handleFileSelect);
        
        dropzone.addEventListener('dragover', (e) => {
            e.preventDefault();
            dropzone.classList.add('active');
        });
        
        dropzone.addEventListener('dragleave', () => {
            dropzone.classList.remove('active');
        });
        
        dropzone.addEventListener('drop', (e) => {
            e.preventDefault();
            dropzone.classList.remove('active');
            
            if (e.dataTransfer.files.length) {
                fileInput.files = e.dataTransfer.files;
                handleFileSelect({ target: fileInput });
            }
        });
        
        removeFile.addEventListener('click', () => {
            fileInfo.classList.add('hidden');
            fileInput.value = '';
        });
        
        densitySlider.addEventListener('input', () => {
            densityValue.textContent = densitySlider.value;
        });
        
        remeshBtn.addEventListener('click', () => {
            if (!fileInput.files.length) {
                alert('Please upload a 3D model first');
                return;
            }
            
            loadingOverlay.classList.remove('hidden');
            simulateProcessing();
        });
        
        tabButtons.forEach(button => {
            button.addEventListener('click', () => {
                tabButtons.forEach(btn => btn.classList.remove('active', 'text-indigo-600', 'border-indigo-500'));
                tabButtons.forEach(btn => btn.classList.add('text-gray-500', 'border-transparent'));
                
                button.classList.add('active', 'text-indigo-600', 'border-indigo-500');
                button.classList.remove('text-gray-500', 'border-transparent');
            });
        });
        
        // Functions
        function handleFileSelect(e) {
            const file = e.target.files[0];
            if (!file) return;
            
            fileName.textContent = file.name;
            fileSize.textContent = formatFileSize(file.size);
            fileInfo.classList.remove('hidden');
            
            // Update stats
            document.getElementById('originalFaces').textContent = Math.floor(Math.random() * 50000) + 10000;
            document.getElementById('originalFaces2').textContent = document.getElementById('originalFaces').textContent;
            document.getElementById('originalVertices').textContent = Math.floor(Math.random() * 25000) + 5000;
            document.getElementById('fileSizeStat').textContent = fileSize.textContent;
            
            // Simulate loading a model
            simulateModelLoad();
        }
        
        function formatFileSize(bytes) {
            if (bytes === 0) return '0 Bytes';
            const k = 1024;
            const sizes = ['Bytes', 'KB', 'MB', 'GB'];
            const i = Math.floor(Math.log(bytes) / Math.log(k));
            return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
        }
        
        function simulateModelLoad() {
            loadingOverlay.classList.remove('hidden');
            let progress = 0;
            
            const interval = setInterval(() => {
                progress += Math.random() * 10;
                if (progress > 100) progress = 100;
                progressBar.style.width = `${progress}%`;
                
                if (progress === 100) {
                    clearInterval(interval);
                    setTimeout(() => {
                        loadingOverlay.classList.add('hidden');
                        progressBar.style.width = '0%';
                        
                        // Initialize a simple 3D viewer (placeholder)
                        init3DViewer();
                    }, 500);
                }
            }, 100);
        }
        
        function simulateProcessing() {
            let progress = 0;
            
            const interval = setInterval(() => {
                progress += Math.random() * 5;
                if (progress > 100) progress = 100;
                progressBar.style.width = `${progress}%`;
                
                if (progress === 100) {
                    clearInterval(interval);
                    setTimeout(() => {
                        loadingOverlay.classList.add('hidden');
                        progressBar.style.width = '0%';
                        
                        // Update stats with "remeshed" values
                        const originalFaces = parseInt(document.getElementById('originalFaces').textContent);
                        const reduction = Math.floor(Math.random() * 70) + 10; // 10-80% reduction
                        const remeshedFaces = Math.floor(originalFaces * (100 - reduction) / 100);
                        
                        document.getElementById('remeshedFaces').textContent = remeshedFaces;
                        document.getElementById('remeshedFaces2').textContent = remeshedFaces;
                        document.getElementById('remeshedVertices').textContent = Math.floor(remeshedFaces * 0.6);
                        document.getElementById('reduction').textContent = `${reduction}%`;
                        
                        // Update the 3D viewer with "remeshed" model
                        update3DViewer();
                    }, 500);
                }
            }, 200);
        }
        
        function init3DViewer() {
            const canvas = document.getElementById('modelCanvas');
            const ctx = canvas.getContext('2d');
            
            // Set canvas dimensions
            canvas.width = canvas.offsetWidth;
            canvas.height = canvas.offsetHeight;
            
            // Draw a placeholder "3D" cube
            drawPlaceholderModel(ctx, canvas.width, canvas.height);
            
            // Add some basic interactivity
            let isDragging = false;
            let lastX = 0;
            let lastY = 0;
            let rotationX = 20;
            let rotationY = 30;
            
            canvas.addEventListener('mousedown', (e) => {
                isDragging = true;
                lastX = e.clientX;
                lastY = e.clientY;
            });
            
            canvas.addEventListener('mousemove', (e) => {
                if (!isDragging) return;
                
                const deltaX = e.clientX - lastX;
                const deltaY = e.clientY - lastY;
                
                rotationY += deltaX * 0.5;
                rotationX += deltaY * 0.5;
                
                lastX = e.clientX;
                lastY = e.clientY;
                
                drawPlaceholderModel(ctx, canvas.width, canvas.height, rotationX, rotationY);
            });
            
            canvas.addEventListener('mouseup', () => {
                isDragging = false;
            });
            
            canvas.addEventListener('mouseleave', () => {
                isDragging = false;
            });
        }
        
        function update3DViewer() {
            const canvas = document.getElementById('modelCanvas');
            const ctx = canvas.getContext('2d');
            
            // Draw a different "remeshed" version
            drawPlaceholderModel(ctx, canvas.width, canvas.height, 20, 30, true);
        }
        
        function drawPlaceholderModel(ctx, width, height, rotX = 20, rotY = 30, isRemeshed = false) {
            ctx.clearRect(0, 0, width, height);
            
            // Simple 3D cube projection
            const size = Math.min(width, height) * 0.3;
            const centerX = width / 2;
            const centerY = height / 2;
            
            // Convert angles to radians
            const radX = rotX * Math.PI / 180;
            const radY = rotY * Math.PI / 180;
            
            // Cube vertices
            const vertices = [
                { x: -1, y: -1, z: -1 },
                { x: 1, y: -1, z: -1 },
                { x: 1, y: 1, z: -1 },
                { x: -1, y: 1, z: -1 },
                { x: -1, y: -1, z: 1 },
                { x: 1, y: -1, z: 1 },
                { x: 1, y: 1, z: 1 },
                { x: -1, y: 1, z: 1 }
            ];
            
            // Project 3D to 2D
            const projected = vertices.map(v => {
                // Rotate around X and Y axes
                let x = v.x;
                let y = v.y * Math.cos(radX) - v.z * Math.sin(radX);
                let z = v.y * Math.sin(radX) + v.z * Math.cos(radX);
                
                let x2 = x * Math.cos(radY) - z * Math.sin(radY);
                let z2 = x * Math.sin(radY) + z * Math.cos(radY);
                
                // Perspective projection
                const distance = 4;
                const factor = distance / (distance + z2);
                return {
                    x: centerX + x2 * factor * size,
                    y: centerY + y * factor * size
                };
            });
            
            // Draw edges
            const edges = [
                [0, 1], [1, 2], [2, 3], [3, 0], // back face
                [4, 5], [5, 6], [6, 7], [7, 4], // front face
                [0, 4], [1, 5], [2, 6], [3, 7]  // connecting edges
            ];
            
            ctx.strokeStyle = isRemeshed ? '#10b981' : '#6366f1';
            ctx.lineWidth = isRemeshed ? 1 : 2;
            
            edges.forEach(edge => {
                const [a, b] = edge;
                ctx.beginPath();
                ctx.moveTo(projected[a].x, projected[a].y);
                ctx.lineTo(projected[b].x, projected[b].y);
                ctx.stroke();
            });
            
            if (isRemeshed) {
                // Add some "remeshed" details
                const faceCenters = [
                    { x: 0, y: 0, z: -1.2 }, // back
                    { x: 0, y: 0, z: 1.2 },  // front
                    { x: -1.2, y: 0, z: 0 }, // left
                    { x: 1.2, y: 0, z: 0 },  // right
                    { x: 0, y: -1.2, z: 0 }, // bottom
                    { x: 0, y: 1.2, z: 0 }   // top
                ];
                
                faceCenters.forEach(center => {
                    // Project this point
                    let x = center.x;
                    let y = center.y * Math.cos(radX) - center.z * Math.sin(radX);
                    let z = center.y * Math.sin(radX) + center.z * Math.cos(radX);
                    
                    let x2 = x * Math.cos(radY) - z * Math.sin(radY);
                    let z2 = x * Math.sin(radY) + z * Math.cos(radY);
                    
                    const distance = 4;
                    const factor = distance / (distance + z2);
                    const px = centerX + x2 * factor * size;
                    const py = centerY + y * factor * size;
                    
                    // Draw a small quad to represent remeshed faces
                    ctx.fillStyle = '#a7f3d0';
                    ctx.fillRect(px - 5, py - 5, 10, 10);
                });
            }
        }
    </script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=CuriousCreator/remesher" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>