File size: 30,142 Bytes
963fa3a
088dc72
963fa3a
 
1e88ce2
2867105
963fa3a
9465b53
 
963fa3a
08cdd0b
9465b53
a3ed783
9465b53
08cdd0b
088dc72
08cdd0b
9465b53
08cdd0b
 
 
 
9465b53
08cdd0b
 
 
2867105
08cdd0b
 
 
2867105
08cdd0b
 
2867105
08cdd0b
 
9465b53
2867105
 
 
 
 
 
 
 
 
 
963fa3a
 
a3ed783
08cdd0b
a3ed783
08cdd0b
2867105
08cdd0b
2867105
08cdd0b
 
 
 
 
 
2867105
08cdd0b
 
 
 
 
 
2867105
08cdd0b
 
 
 
 
 
2867105
08cdd0b
 
 
 
 
 
2867105
 
9465b53
1e88ce2
088dc72
 
9465b53
2867105
08cdd0b
9465b53
 
 
 
08cdd0b
9465b53
 
08cdd0b
 
9465b53
 
 
08cdd0b
9465b53
08cdd0b
9465b53
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
08cdd0b
 
 
 
 
 
 
 
088dc72
9465b53
 
 
 
 
 
2867105
9465b53
 
 
08cdd0b
9465b53
08cdd0b
9465b53
 
2867105
 
 
9465b53
08cdd0b
2867105
9465b53
2867105
 
 
 
 
 
 
 
 
 
 
 
08cdd0b
2867105
08cdd0b
 
2867105
08cdd0b
 
2867105
08cdd0b
 
2867105
08cdd0b
2867105
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
08cdd0b
2867105
 
08cdd0b
2867105
 
08cdd0b
2867105
 
08cdd0b
 
 
 
 
2867105
 
088dc72
9465b53
2867105
08cdd0b
2867105
08cdd0b
 
 
2867105
 
 
 
 
 
 
 
 
 
 
08cdd0b
 
 
 
 
 
 
 
 
 
 
 
 
2867105
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9465b53
 
 
2867105
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9465b53
08cdd0b
 
2867105
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
08cdd0b
 
2867105
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9465b53
 
 
08cdd0b
 
9465b53
 
 
a3ed783
9465b53
 
 
 
 
 
 
 
08cdd0b
9465b53
 
 
 
 
 
 
a3ed783
9465b53
 
 
 
 
 
 
 
08cdd0b
9465b53
 
 
2867105
9465b53
 
2867105
 
9465b53
 
 
a3ed783
9465b53
 
2867105
9465b53
 
 
 
 
08cdd0b
9465b53
 
 
08cdd0b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2867105
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
08cdd0b
 
 
 
 
9465b53
 
 
 
 
 
 
08cdd0b
 
 
 
 
9465b53
 
 
 
 
 
 
 
 
 
 
08cdd0b
 
 
9465b53
08cdd0b
2867105
 
 
08cdd0b
9465b53
08cdd0b
 
 
 
 
9465b53
08cdd0b
 
 
 
 
 
2867105
 
 
 
 
08cdd0b
 
 
 
 
 
 
 
 
 
 
 
9465b53
08cdd0b
 
9465b53
 
 
 
088dc72
963fa3a
 
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
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
<!DOCTYPE html>
<html lang="fr">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Arithmétique Visuelle</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/three@0.128.0/examples/js/controls/OrbitControls.min.js"></script>
    <style>
        #math-container {
            width: 100%;
            height: 100vh;
            overflow: hidden;
            background: linear-gradient(135deg, #f0f4ff 0%, #d9e4ff 100%);
        }
        .control-panel {
            position: absolute;
            bottom: 20px;
            left: 0;
            right: 0;
            margin: auto;
            z-index: 100;
            width: 90%;
            max-width: 600px;
        }
        .operation-btn {
            transition: all 0.3s ease;
            filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.1));
        }
        .operation-btn:hover {
            transform: translateY(-5px) scale(1.05);
        }
        .active-operation {
            transform: scale(1.1);
            box-shadow: 0 0 15px rgba(59, 130, 246, 0.5);
        }
        .experience-btn {
            transition: all 0.2s ease;
        }
        .experience-btn:hover {
            transform: scale(1.1);
        }
        .active-experience {
            background-color: rgba(59, 130, 246, 0.2);
            border: 2px solid rgba(59, 130, 246, 0.8);
        }
    </style>
</head>
<body>
    <div id="math-container"></div>
    
    <div class="control-panel bg-white bg-opacity-90 p-4 rounded-xl shadow-xl">
        <div class="grid grid-cols-4 gap-2 mb-4">
            <!-- Addition -->
            <button onclick="loadOperation('addition')" class="operation-btn bg-green-50 p-3 rounded-lg flex items-center justify-center">
                <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 text-green-600" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"/>
                </svg>
            </button>
            
            <!-- Soustraction -->
            <button onclick="loadOperation('subtraction')" class="operation-btn bg-red-50 p-3 rounded-lg flex items-center justify-center">
                <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 text-red-600" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20 12H4"/>
                </svg>
            </button>
            
            <!-- Multiplication -->
            <button onclick="loadOperation('multiplication')" class="operation-btn bg-yellow-50 p-3 rounded-lg flex items-center justify-center">
                <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 text-yellow-600" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/>
                </svg>
            </button>
            
            <!-- Division -->
            <button onclick="loadOperation('division')" class="operation-btn bg-purple-50 p-3 rounded-lg flex items-center justify-center">
                <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 text-purple-600" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 12h14M5 12a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v4a2 2 0 01-2 2M5 12a2 2 0 00-2 2v4a2 2 0 002 2h14a2 2 0 002-2v-4a2 2 0 00-2-2"/>
                </svg>
            </button>
        </div>
        
        <div id="experience-buttons" class="grid grid-cols-3 gap-2 hidden">
            <!-- Les boutons d'expérience seront ajoutés dynamiquement ici -->
        </div>
    </div>

    <script>
        // Initialisation Three.js
        let scene, camera, renderer, controls, activeOperation = 'addition';
        const objects = [];
        
        function init() {
            // Création de la scène
            scene = new THREE.Scene();
            scene.background = new THREE.Color(0xf0f4ff);
            
            // Configuration de la caméra
            camera = new THREE.PerspectiveCamera(60, window.innerWidth / window.innerHeight, 0.1, 1000);
            camera.position.set(0, 5, 15);
            
            // Configuration du rendu
            renderer = new THREE.WebGLRenderer({ antialias: true });
            renderer.setSize(window.innerWidth, window.innerHeight);
            renderer.shadowMap.enabled = true;
            document.getElementById('math-container').appendChild(renderer.domElement);
            
            // Lumière directionnelle
            const directionalLight = new THREE.DirectionalLight(0xffffff, 0.8);
            directionalLight.position.set(5, 10, 7);
            directionalLight.castShadow = true;
            scene.add(directionalLight);
            
            // Lumière ambiante
            const ambientLight = new THREE.AmbientLight(0x404040, 0.5);
            scene.add(ambientLight);
            
            // Contrôles de la caméra
            controls = new THREE.OrbitControls(camera, renderer.domElement);
            controls.enableDamping = true;
            controls.dampingFactor = 0.05;
            
            // Grille de référence
            const gridHelper = new THREE.GridHelper(20, 20, 0x888888, 0xcccccc);
            scene.add(gridHelper);
            
            // Animation
            function animate() {
                requestAnimationFrame(animate);
                controls.update();
                renderer.render(scene, camera);
                
                // Animation des objets
                objects.forEach(obj => {
                    if (obj.userData.animate) {
                        obj.rotation.x += 0.01;
                        obj.rotation.y += 0.01;
                    }
                });
            }
            animate();
            
            // Gestion du redimensionnement
            window.addEventListener('resize', onWindowResize);
            
            // Chargement initial
            loadOperation('addition');
        }
        
        function onWindowResize() {
            camera.aspect = window.innerWidth / window.innerHeight;
            camera.updateProjectionMatrix();
            renderer.setSize(window.innerWidth, window.innerHeight);
        }
        
        // Fonctions de chargement des opérations
        function loadOperation(operation) {
            activeOperation = operation;
            clearScene();
            updateActiveButton();
            createExperienceButtons(operation);
            
            // Charger la première expérience par défaut
            loadExperience(operation, 1);
        }
        
        function createExperienceButtons(operation) {
            const container = document.getElementById('experience-buttons');
            container.innerHTML = '';
            container.classList.remove('hidden');
            
            let experiences = [];
            
            switch(operation) {
                case 'addition':
                    experiences = ['1', '2', '3'];
                    break;
                case 'subtraction':
                    experiences = ['1', '2', '3'];
                    break;
                case 'multiplication':
                    experiences = ['1', '2', '3'];
                    break;
                case 'division':
                    experiences = ['1', '2', '3'];
                    break;
            }
            
            experiences.forEach((exp, index) => {
                const btn = document.createElement('button');
                btn.className = 'experience-btn bg-gray-100 p-2 rounded-lg flex items-center justify-center';
                btn.innerHTML = `
                    <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 text-gray-700" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 10V3L4 14h7v7l9-11h-7z"/>
                    </svg>
                `;
                btn.onclick = () => loadExperience(operation, index + 1);
                container.appendChild(btn);
            });
        }
        
        function loadExperience(operation, experienceNumber) {
            clearScene();
            createMathBase();
            
            // Mettre à jour le bouton d'expérience actif
            updateActiveExperienceButton(experienceNumber);
            
            switch(operation) {
                case 'addition':
                    demonstrateAddition(experienceNumber);
                    break;
                case 'subtraction':
                    demonstrateSubtraction(experienceNumber);
                    break;
                case 'multiplication':
                    demonstrateMultiplication(experienceNumber);
                    break;
                case 'division':
                    demonstrateDivision(experienceNumber);
                    break;
            }
        }
        
        function updateActiveButton() {
            document.querySelectorAll('.operation-btn').forEach(btn => {
                btn.classList.remove('active-operation');
            });
            
            const activeBtn = document.querySelector(`[onclick="loadOperation('${activeOperation}')"]`);
            if (activeBtn) {
                activeBtn.classList.add('active-operation');
            }
        }
        
        function updateActiveExperienceButton(experienceNumber) {
            const buttons = document.querySelectorAll('#experience-buttons button');
            buttons.forEach((btn, index) => {
                if (index === experienceNumber - 1) {
                    btn.classList.add('active-experience');
                } else {
                    btn.classList.remove('active-experience');
                }
            });
        }
        
        function clearScene() {
            // Supprimer tous les objets sauf les lumières et helpers
            const toRemove = [];
            scene.children.forEach(child => {
                if (!(child instanceof THREE.Light || child instanceof THREE.GridHelper)) {
                    toRemove.push(child);
                }
            });
            
            toRemove.forEach(child => scene.remove(child));
            objects.length = 0;
        }
        
        // Fonctions de démonstration des opérations avec différentes expériences
        function demonstrateAddition(experienceNumber) {
            switch(experienceNumber) {
                case 1:
                    // Expérience 1: Addition simple avec sphères
                    const group1 = createSphereGroup(3, -4, 0, 0x3b82f6);
                    const group2 = createSphereGroup(2, 4, 0, 0xef4444);
                    
                    setTimeout(() => {
                        animateGroup(group2, { x: -1, y: 0, z: 0 }, 1000, () => {
                            const resultGroup = createSphereGroup(5, 0, 0, 0x10b981);
                            animateGroup(resultGroup, { y: 2 }, 800);
                        });
                    }, 1000);
                    break;
                    
                case 2:
                    // Expérience 2: Addition avec cubes empilés
                    const base1 = createNumberTower(3, -3, 0, 0x3b82f6);
                    const base2 = createNumberTower(2, 3, 0, 0xef4444);
                    
                    setTimeout(() => {
                        animateGroup(base2, { x: 0 }, 1000, () => {
                            const resultTower = createNumberTower(5, 0, 0, 0x10b981);
                            animateGroup(resultTower, { y: 1 }, 800);
                        });
                    }, 1000);
                    break;
                    
                case 3:
                    // Expérience 3: Addition avec formes géométriques
                    const cube1 = createAlgebraCube(1, -4, 0.5, 0x3b82f6);
                    const cube2 = createAlgebraCube(1, -2, 0.5, 0x3b82f6);
                    const cube3 = createAlgebraCube(1, 2, 0.5, 0xef4444);
                    
                    setTimeout(() => {
                        animateObject(cube3, { x: 0 }, 1000, () => {
                            const bigCube = createAlgebraCube(2, 0, 1, 0x10b981);
                            animateObject(bigCube, { y: 2 }, 800);
                        });
                    }, 1000);
                    break;
            }
        }
        
        function demonstrateSubtraction(experienceNumber) {
            switch(experienceNumber) {
                case 1:
                    // Expérience 1: Soustraction simple avec sphères
                    const initialGroup = createSphereGroup(5, 0, 0, 0x3b82f6);
                    
                    setTimeout(() => {
                        const removedGroup = createSphereGroup(2, 0, 0, 0xef4444);
                        animateGroup(removedGroup, { x: 3, y: 0, z: 0 }, 1000, () => {
                            const resultGroup = createSphereGroup(3, -3, 0, 0x10b981);
                            animateGroup(resultGroup, { y: 2 }, 800);
                        });
                    }, 1000);
                    break;
                    
                case 2:
                    // Expérience 2: Soustraction avec tours
                    const initialTower = createNumberTower(5, 0, 0, 0x3b82f6);
                    
                    setTimeout(() => {
                        const removedTower = createNumberTower(2, 0, 0, 0xef4444);
                        animateGroup(removedTower, { x: 3 }, 1000, () => {
                            const resultTower = createNumberTower(3, -3, 0, 0x10b981);
                            animateGroup(resultTower, { y: 1 }, 800);
                        });
                    }, 1000);
                    break;
                    
                case 3:
                    // Expérience 3: Soustraction avec formes géométriques
                    const bigCube = createAlgebraCube(2, 0, 1, 0x3b82f6);
                    
                    setTimeout(() => {
                        const smallCube = createAlgebraCube(1, 0, 0.5, 0xef4444);
                        animateObject(smallCube, { x: 3 }, 1000, () => {
                            const remainingCube = createAlgebraCube(1, -3, 0.5, 0x10b981);
                            animateObject(remainingCube, { y: 2 }, 800);
                        });
                    }, 1000);
                    break;
            }
        }
        
        function demonstrateMultiplication(experienceNumber) {
            switch(experienceNumber) {
                case 1:
                    // Expérience 1: Multiplication comme addition répétée
                    const group1 = createSphereGroup(4, -3, -2, 0x3b82f6);
                    const group2 = createSphereGroup(4, -3, 0, 0x3b82f6);
                    const group3 = createSphereGroup(4, -3, 2, 0x3b82f6);
                    
                    setTimeout(() => {
                        animateGroup(group1, { x: 0, z: -2 }, 800);
                        animateGroup(group2, { x: 0, z: 0 }, 800);
                        animateGroup(group3, { x: 0, z: 2 }, 800, () => {
                            const resultGroup = createSphereGroup(12, 3, 0, 0x10b981);
                            animateGroup(resultGroup, { y: 2 }, 800);
                        });
                    }, 1000);
                    break;
                    
                case 2:
                    // Expérience 2: Multiplication avec tableau
                    createMultiplicationGrid(3, 4);
                    break;
                    
                case 3:
                    // Expérience 3: Multiplication avec aires
                    const rectangle = createRectangle(3, 4, 0, 0, 0x3b82f6);
                    
                    setTimeout(() => {
                        animateObject(rectangle, { rotation: { y: Math.PI/4 } }, 1000, () => {
                            const areaCube = createAlgebraCube(1, 0, 0.5, 0x10b981);
                            for (let i = 0; i < 12; i++) {
                                setTimeout(() => {
                                    const clone = areaCube.clone();
                                    clone.position.set(Math.random() * 6 - 3, 0.5, Math.random() * 6 - 3);
                                    scene.add(clone);
                                    objects.push(clone);
                                }, i * 100);
                            }
                        });
                    }, 1000);
                    break;
            }
        }
        
        function demonstrateDivision(experienceNumber) {
            switch(experienceNumber) {
                case 1:
                    // Expérience 1: Division comme soustraction répétée
                    const initialGroup = createSphereGroup(12, 0, 0, 0x3b82f6);
                    
                    setTimeout(() => {
                        const group1 = createSphereGroup(4, -3, -2, 0xef4444);
                        const group2 = createSphereGroup(4, -3, 0, 0xef4444);
                        const group3 = createSphereGroup(4, -3, 2, 0xef4444);
                        
                        setTimeout(() => {
                            animateGroup(group1, { x: -3, z: -2 }, 800);
                            animateGroup(group2, { x: -3, z: 0 }, 800);
                            animateGroup(group3, { x: -3, z: 2 }, 800);
                        }, 1000);
                    }, 1000);
                    break;
                    
                case 2:
                    // Expérience 2: Division avec tours
                    const initialTower = createNumberTower(12, 0, 0, 0x3b82f6);
                    
                    setTimeout(() => {
                        const tower1 = createNumberTower(4, -3, -2, 0xef4444);
                        const tower2 = createNumberTower(4, -3, 0, 0xef4444);
                        const tower3 = createNumberTower(4, -3, 2, 0xef4444);
                        
                        setTimeout(() => {
                            animateGroup(tower1, { x: -5, z: -2 }, 800);
                            animateGroup(tower2, { x: -5, z: 0 }, 800);
                            animateGroup(tower3, { x: -5, z: 2 }, 800);
                        }, 1000);
                    }, 1000);
                    break;
                    
                case 3:
                    // Expérience 3: Division avec parts égales
                    const circleGeometry = new THREE.CircleGeometry(3, 32);
                    
                    // Création de 4 parts égales
                    for (let i = 0; i < 4; i++) {
                        const startAngle = (i * Math.PI) / 2;
                        const endAngle = ((i + 1) * Math.PI) / 2;
                        
                        const shape = new THREE.Shape();
                        shape.moveTo(0, 0);
                        
                        for (let angle = startAngle; angle <= endAngle; angle += 0.1) {
                            const x = Math.cos(angle) * 3;
                            const y = Math.sin(angle) * 3;
                            shape.lineTo(x, y);
                        }
                        
                        shape.lineTo(Math.cos(endAngle) * 3, Math.sin(endAngle) * 3);
                        shape.lineTo(0, 0);
                        
                        const part = new THREE.Mesh(
                            new THREE.ShapeGeometry(shape),
                            new THREE.MeshPhongMaterial({ 
                                color: [0x3b82f6, 0xef4444, 0x10b981, 0x8b5cf6][i],
                                side: THREE.DoubleSide
                            })
                        );
                        part.position.set(0, 0.1, 0);
                        scene.add(part);
                        objects.push(part);
                        
                        setTimeout(() => {
                            animateObject(part, { 
                                position: { 
                                    x: Math.cos(startAngle + Math.PI/4) * 2,
                                    z: Math.sin(startAngle + Math.PI/4) * 2
                                },
                                rotation: { y: Math.PI/2 }
                            }, 1000);
                        }, i * 300 + 1000);
                    }
                    break;
            }
        }
        
        // Fonctions utilitaires
        function createMathBase() {
            const geometry = new THREE.CylinderGeometry(10, 10, 0.5, 32);
            const material = new THREE.MeshPhongMaterial({ 
                color: 0xffffff,
                transparent: true,
                opacity: 0.9
            });
            const platform = new THREE.Mesh(geometry, material);
            platform.position.y = -0.5;
            platform.receiveShadow = true;
            scene.add(platform);
            return platform;
        }
        
        function createSphereGroup(count, xPos, zPos, color) {
            const group = new THREE.Group();
            
            for (let i = 0; i < count; i++) {
                const geometry = new THREE.SphereGeometry(0.4, 32, 32);
                const material = new THREE.MeshPhongMaterial({ 
                    color: color,
                    transparent: true,
                    opacity: 0.9
                });
                const sphere = new THREE.Mesh(geometry, material);
                sphere.position.set(xPos, 0.5, zPos + (i - count/2 + 0.5) * 0.8);
                sphere.castShadow = true;
                group.add(sphere);
            }
            
            scene.add(group);
            objects.push(group);
            return group;
        }
        
        function createNumberTower(count, xPos, zPos, color) {
            const group = new THREE.Group();
            
            for (let i = 0; i < count; i++) {
                const geometry = new THREE.BoxGeometry(1, 1, 1);
                const material = new THREE.MeshPhongMaterial({ 
                    color: color,
                    transparent: true,
                    opacity: 0.9
                });
                const cube = new THREE.Mesh(geometry, material);
                cube.position.set(xPos, i * 1.1 + 0.5, zPos);
                cube.castShadow = true;
                group.add(cube);
            }
            
            scene.add(group);
            objects.push(group);
            return group;
        }
        
        function createAlgebraCube(size, xPos, yPos, color) {
            const geometry = new THREE.BoxGeometry(size, size, size);
            const material = new THREE.MeshPhongMaterial({ 
                color: color,
                transparent: true,
                opacity: 0.9
            });
            const cube = new THREE.Mesh(geometry, material);
            cube.position.set(xPos, yPos, 0);
            cube.castShadow = true;
            scene.add(cube);
            objects.push(cube);
            return cube;
        }
        
        function createMultiplicationGrid(rows, cols) {
            const group = new THREE.Group();
            
            for (let x = 0; x < cols; x++) {
                for (let y = 0; y < rows; y++) {
                    const geometry = new THREE.BoxGeometry(0.8, 0.8, 0.8);
                    const material = new THREE.MeshPhongMaterial({ 
                        color: (x + y) % 2 === 0 ? 0x3b82f6 : 0xef4444,
                        transparent: true,
                        opacity: 0.9
                    });
                    const cube = new THREE.Mesh(geometry, material);
                    cube.position.set((x - cols/2 + 0.5) * 1, 0.5, (y - rows/2 + 0.5) * 1);
                    group.add(cube);
                }
            }
            
            scene.add(group);
            objects.push(group);
            
            setTimeout(() => {
                animateObject(group, { rotation: { y: Math.PI } }, 1000, () => {
                    const resultCube = createAlgebraCube(1, 0, 0.5, 0x10b981);
                    for (let i = 0; i < rows * cols; i++) {
                        setTimeout(() => {
                            const clone = resultCube.clone();
                            clone.position.set(Math.random() * 6 - 3, 0.5, Math.random() * 6 - 3);
                            scene.add(clone);
                            objects.push(clone);
                        }, i * 100);
                    }
                });
            }, 1000);
            
            return group;
        }
        
        function createRectangle(width, height, xPos, zPos, color) {
            const shape = new THREE.Shape();
            shape.moveTo(0, 0);
            shape.lineTo(width, 0);
            shape.lineTo(width, height);
            shape.lineTo(0, height);
            shape.lineTo(0, 0);
            
            const geometry = new THREE.ShapeGeometry(shape);
            const material = new THREE.MeshPhongMaterial({ 
                color: color,
                side: THREE.DoubleSide
            });
            const rectangle = new THREE.Mesh(geometry, material);
            rectangle.position.set(xPos - width/2, 0.1, zPos - height/2);
            rectangle.rotation.x = -Math.PI / 2;
            scene.add(rectangle);
            objects.push(rectangle);
            
            return rectangle;
        }
        
        function animateGroup(group, target, duration, callback) {
            const startPositions = [];
            group.children.forEach(child => {
                startPositions.push(child.position.clone());
            });
            
            const startTime = Date.now();
            
            function update() {
                const elapsed = Date.now() - startTime;
                const progress = Math.min(elapsed / duration, 1);
                
                group.children.forEach((child, index) => {
                    if (target.x !== undefined) child.position.x = startPositions[index].x + (target.x - startPositions[index].x) * progress;
                    if (target.y !== undefined) child.position.y = startPositions[index].y + (target.y - startPositions[index].y) * progress;
                    if (target.z !== undefined) child.position.z = startPositions[index].z + (target.z - startPositions[index].z) * progress;
                });
                
                if (progress < 1) {
                    requestAnimationFrame(update);
                } else if (callback) {
                    callback();
                }
            }
            
            update();
        }
        
        function animateObject(object, target, duration, callback) {
            const startPosition = object.position.clone();
            const startRotation = object.rotation.clone();
            
            const changePos = new THREE.Vector3(
                target.position?.x !== undefined ? target.position.x - object.position.x : 0,
                target.position?.y !== undefined ? target.position.y - object.position.y : 0,
                target.position?.z !== undefined ? target.position.z - object.position.z : 0
            );
            
            const changeRot = new THREE.Vector3(
                target.rotation?.x !== undefined ? target.rotation.x - object.rotation.x : 0,
                target.rotation?.y !== undefined ? target.rotation.y - object.rotation.y : 0,
                target.rotation?.z !== undefined ? target.rotation.z - object.rotation.z : 0
            );
            
            const startTime = Date.now();
            
            function update() {
                const elapsed = Date.now() - startTime;
                const progress = Math.min(elapsed / duration, 1);
                
                if (target.position) {
                    object.position.x = startPosition.x + changePos.x * progress;
                    object.position.y = startPosition.y + changePos.y * progress;
                    object.position.z = startPosition.z + changePos.z * progress;
                }
                
                if (target.rotation) {
                    object.rotation.x = startRotation.x + changeRot.x * progress;
                    object.rotation.y = startRotation.y + changeRot.y * progress;
                    object.rotation.z = startRotation.z + changeRot.z * progress;
                }
                
                if (progress < 1) {
                    requestAnimationFrame(update);
                } else if (callback) {
                    callback();
                }
            }
            
            update();
        }
        
        // Initialisation au chargement
        window.onload = init;
    </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=olinux/self-doc" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>