Add 1 files
Browse files- index.html +584 -235
index.html
CHANGED
|
@@ -3,77 +3,142 @@
|
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
-
<title>Visualisation Mathématique
|
| 7 |
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
|
| 9 |
<script src="https://cdn.jsdelivr.net/npm/three@0.128.0/examples/js/controls/OrbitControls.min.js"></script>
|
| 10 |
<style>
|
| 11 |
-
#
|
| 12 |
width: 100%;
|
| 13 |
height: 100vh;
|
| 14 |
overflow: hidden;
|
| 15 |
-
background: linear-gradient(135deg, #
|
| 16 |
}
|
| 17 |
-
.
|
| 18 |
position: absolute;
|
| 19 |
-
|
| 20 |
-
left:
|
|
|
|
|
|
|
| 21 |
z-index: 100;
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
}
|
| 24 |
</style>
|
| 25 |
</head>
|
| 26 |
<body>
|
| 27 |
-
<div id="
|
| 28 |
-
|
| 29 |
-
<button onclick="showMenu()" class="menu-button bg-blue-500 text-white px-5 py-3 rounded-lg hover:bg-blue-600 transition flex items-center">
|
| 30 |
-
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-2" viewBox="0 0 20 20" fill="currentColor">
|
| 31 |
-
<path fill-rule="evenodd" d="M3 5a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zM3 10a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zM3 15a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1z" clip-rule="evenodd" />
|
| 32 |
-
</svg>
|
| 33 |
-
</button>
|
| 34 |
|
| 35 |
-
<div
|
| 36 |
-
<div class="
|
| 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 |
</svg>
|
| 78 |
</button>
|
| 79 |
</div>
|
|
@@ -81,22 +146,23 @@
|
|
| 81 |
|
| 82 |
<script>
|
| 83 |
// Initialisation Three.js
|
| 84 |
-
let scene, camera, renderer, controls,
|
|
|
|
| 85 |
|
| 86 |
function init() {
|
| 87 |
// Création de la scène
|
| 88 |
scene = new THREE.Scene();
|
| 89 |
-
scene.background = new THREE.Color(
|
| 90 |
|
| 91 |
// Configuration de la caméra
|
| 92 |
-
camera = new THREE.PerspectiveCamera(60,
|
| 93 |
-
camera.position.set(0,
|
| 94 |
|
| 95 |
// Configuration du rendu
|
| 96 |
renderer = new THREE.WebGLRenderer({ antialias: true });
|
| 97 |
-
renderer.setSize(
|
| 98 |
renderer.shadowMap.enabled = true;
|
| 99 |
-
document.getElementById('
|
| 100 |
|
| 101 |
// Lumière directionnelle
|
| 102 |
const directionalLight = new THREE.DirectionalLight(0xffffff, 0.8);
|
|
@@ -122,6 +188,14 @@
|
|
| 122 |
requestAnimationFrame(animate);
|
| 123 |
controls.update();
|
| 124 |
renderer.render(scene, camera);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 125 |
}
|
| 126 |
animate();
|
| 127 |
|
|
@@ -129,159 +203,291 @@
|
|
| 129 |
window.addEventListener('resize', onWindowResize);
|
| 130 |
|
| 131 |
// Chargement initial
|
| 132 |
-
|
| 133 |
}
|
| 134 |
|
| 135 |
function onWindowResize() {
|
| 136 |
-
camera.aspect =
|
| 137 |
camera.updateProjectionMatrix();
|
| 138 |
-
renderer.setSize(
|
| 139 |
}
|
| 140 |
|
| 141 |
-
//
|
| 142 |
-
function
|
|
|
|
| 143 |
clearScene();
|
|
|
|
| 144 |
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 151 |
});
|
| 152 |
-
const platform = new THREE.Mesh(platformGeometry, platformMaterial);
|
| 153 |
-
platform.position.y = -0.5;
|
| 154 |
-
platform.receiveShadow = true;
|
| 155 |
-
scene.add(platform);
|
| 156 |
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 160 |
const material = new THREE.MeshPhongMaterial({
|
| 161 |
-
color:
|
| 162 |
transparent: true,
|
| 163 |
opacity: 0.9
|
| 164 |
});
|
| 165 |
-
const
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
sphere.position.z = Math.sin(angle) * radius;
|
| 172 |
-
sphere.position.y = 0.5;
|
| 173 |
-
sphere.castShadow = true;
|
| 174 |
-
|
| 175 |
-
scene.add(sphere);
|
| 176 |
-
cubes.push(sphere);
|
| 177 |
}
|
| 178 |
}
|
| 179 |
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
clearScene();
|
| 183 |
-
createPlatform();
|
| 184 |
|
| 185 |
// Premier groupe (bleu)
|
| 186 |
-
const group1 =
|
| 187 |
|
| 188 |
// Deuxième groupe (rouge)
|
| 189 |
-
const group2 =
|
| 190 |
|
| 191 |
// Animation pour montrer l'addition
|
| 192 |
setTimeout(() => {
|
| 193 |
-
|
| 194 |
-
|
|
|
|
| 195 |
});
|
| 196 |
}, 1000);
|
| 197 |
}
|
| 198 |
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
clearScene();
|
| 202 |
-
createPlatform();
|
| 203 |
|
| 204 |
// Groupe initial
|
| 205 |
-
const initialGroup =
|
| 206 |
|
| 207 |
// Animation de la soustraction
|
| 208 |
setTimeout(() => {
|
| 209 |
-
const removedGroup =
|
| 210 |
-
|
| 211 |
-
|
|
|
|
| 212 |
});
|
| 213 |
}, 1000);
|
| 214 |
}
|
| 215 |
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
clearScene();
|
| 219 |
-
createPlatform();
|
| 220 |
|
| 221 |
// Création de groupes égaux
|
| 222 |
-
const group1 =
|
| 223 |
-
const group2 =
|
| 224 |
-
const group3 =
|
| 225 |
|
| 226 |
// Animation pour montrer la multiplication
|
| 227 |
setTimeout(() => {
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
|
|
|
| 232 |
});
|
| 233 |
}, 1000);
|
| 234 |
}
|
| 235 |
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
clearScene();
|
| 239 |
-
createPlatform();
|
| 240 |
|
| 241 |
// Groupe initial
|
| 242 |
-
const initialGroup =
|
| 243 |
|
| 244 |
// Animation de la division
|
| 245 |
setTimeout(() => {
|
| 246 |
-
const group1 =
|
| 247 |
-
const group2 =
|
| 248 |
-
const group3 =
|
| 249 |
|
| 250 |
setTimeout(() => {
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
| 254 |
}, 1000);
|
| 255 |
}, 1000);
|
| 256 |
}
|
| 257 |
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 262 |
|
| 263 |
// Création d'un nombre à 3 chiffres
|
| 264 |
-
createPlaceValueBlock(1, -4, 0, 0x3b82f6);
|
| 265 |
-
createPlaceValueBlock(2, 0, 0, 0x10b981);
|
| 266 |
-
createPlaceValueBlock(3, 4, 0, 0xef4444);
|
| 267 |
|
| 268 |
// Animation pour montrer la décomposition
|
| 269 |
setTimeout(() => {
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
}
|
| 274 |
-
});
|
| 275 |
}, 1000);
|
| 276 |
}
|
| 277 |
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
clearScene();
|
| 281 |
-
createPlatform();
|
| 282 |
|
| 283 |
// Création d'un grand cube représentant 1000
|
| 284 |
-
const cubeGeometry = new THREE.BoxGeometry(
|
| 285 |
const cubeMaterial = new THREE.MeshPhongMaterial({
|
| 286 |
color: 0x8b5cf6,
|
| 287 |
transparent: true,
|
|
@@ -289,39 +495,182 @@
|
|
| 289 |
wireframe: false
|
| 290 |
});
|
| 291 |
const thousandCube = new THREE.Mesh(cubeGeometry, cubeMaterial);
|
| 292 |
-
thousandCube.position.y =
|
| 293 |
thousandCube.castShadow = true;
|
| 294 |
scene.add(thousandCube);
|
|
|
|
| 295 |
|
| 296 |
-
//
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
|
|
|
| 303 |
|
| 304 |
-
//
|
| 305 |
-
const
|
| 306 |
-
for (let x =
|
| 307 |
-
for (let y = 0
|
| 308 |
-
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 313 |
}
|
| 314 |
}
|
|
|
|
|
|
|
| 315 |
|
| 316 |
// Animation
|
| 317 |
setTimeout(() => {
|
| 318 |
-
animateObject(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 319 |
}, 1000);
|
| 320 |
}
|
| 321 |
|
| 322 |
// Fonctions utilitaires
|
| 323 |
-
function
|
| 324 |
-
const geometry = new THREE.CylinderGeometry(
|
| 325 |
const material = new THREE.MeshPhongMaterial({
|
| 326 |
color: 0xffffff,
|
| 327 |
transparent: true,
|
|
@@ -334,7 +683,7 @@
|
|
| 334 |
return platform;
|
| 335 |
}
|
| 336 |
|
| 337 |
-
function
|
| 338 |
const group = new THREE.Group();
|
| 339 |
|
| 340 |
for (let i = 0; i < count; i++) {
|
|
@@ -351,37 +700,51 @@
|
|
| 351 |
}
|
| 352 |
|
| 353 |
scene.add(group);
|
|
|
|
| 354 |
return group;
|
| 355 |
}
|
| 356 |
|
| 357 |
-
function createPlaceValueBlock(value, xPos, zPos, color) {
|
| 358 |
const group = new THREE.Group();
|
| 359 |
|
| 360 |
-
// Création des unités
|
| 361 |
for (let i = 0; i < value; i++) {
|
| 362 |
-
const geometry = new THREE.BoxGeometry(
|
| 363 |
const material = new THREE.MeshPhongMaterial({
|
| 364 |
color: color,
|
| 365 |
transparent: true,
|
| 366 |
opacity: 0.9
|
| 367 |
});
|
| 368 |
const cube = new THREE.Mesh(geometry, material);
|
| 369 |
-
cube.position.set(xPos,
|
| 370 |
cube.castShadow = true;
|
| 371 |
group.add(cube);
|
| 372 |
}
|
| 373 |
|
| 374 |
scene.add(group);
|
|
|
|
| 375 |
return group;
|
| 376 |
}
|
| 377 |
|
| 378 |
-
function
|
| 379 |
-
const
|
| 380 |
-
const
|
| 381 |
-
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 385 |
|
| 386 |
const startTime = Date.now();
|
| 387 |
|
|
@@ -389,9 +752,11 @@
|
|
| 389 |
const elapsed = Date.now() - startTime;
|
| 390 |
const progress = Math.min(elapsed / duration, 1);
|
| 391 |
|
| 392 |
-
|
| 393 |
-
|
| 394 |
-
|
|
|
|
|
|
|
| 395 |
|
| 396 |
if (progress < 1) {
|
| 397 |
requestAnimationFrame(update);
|
|
@@ -403,62 +768,46 @@
|
|
| 403 |
update();
|
| 404 |
}
|
| 405 |
|
| 406 |
-
function
|
| 407 |
-
|
| 408 |
-
|
| 409 |
-
obj.parent.remove(obj);
|
| 410 |
-
} else {
|
| 411 |
-
scene.remove(obj);
|
| 412 |
-
}
|
| 413 |
-
});
|
| 414 |
-
cubes = [];
|
| 415 |
|
| 416 |
-
|
| 417 |
-
|
| 418 |
-
|
| 419 |
-
|
| 420 |
-
|
| 421 |
-
}
|
| 422 |
-
});
|
| 423 |
|
| 424 |
-
|
| 425 |
-
|
| 426 |
-
|
| 427 |
-
|
| 428 |
-
|
| 429 |
-
document.getElementById('menu-panel').classList.remove('hidden');
|
| 430 |
-
}
|
| 431 |
-
|
| 432 |
-
function hideMenu() {
|
| 433 |
-
document.getElementById('menu-panel').classList.add('hidden');
|
| 434 |
-
}
|
| 435 |
-
|
| 436 |
-
function loadConcept(concept) {
|
| 437 |
-
hideMenu();
|
| 438 |
|
| 439 |
-
|
| 440 |
-
|
| 441 |
-
|
| 442 |
-
|
| 443 |
-
|
| 444 |
-
|
| 445 |
-
|
| 446 |
-
|
| 447 |
-
|
| 448 |
-
|
| 449 |
-
|
| 450 |
-
|
| 451 |
-
|
| 452 |
-
|
| 453 |
-
|
| 454 |
-
|
| 455 |
-
|
| 456 |
-
|
| 457 |
-
|
| 458 |
-
|
| 459 |
-
|
| 460 |
-
break;
|
| 461 |
}
|
|
|
|
|
|
|
| 462 |
}
|
| 463 |
|
| 464 |
// Initialisation au chargement
|
|
|
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Visualisation Mathématique</title>
|
| 7 |
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
|
| 9 |
<script src="https://cdn.jsdelivr.net/npm/three@0.128.0/examples/js/controls/OrbitControls.min.js"></script>
|
| 10 |
<style>
|
| 11 |
+
#math-container {
|
| 12 |
width: 100%;
|
| 13 |
height: 100vh;
|
| 14 |
overflow: hidden;
|
| 15 |
+
background: linear-gradient(135deg, #f0f4ff 0%, #d9e4ff 100%);
|
| 16 |
}
|
| 17 |
+
.control-panel {
|
| 18 |
position: absolute;
|
| 19 |
+
bottom: 20px;
|
| 20 |
+
left: 0;
|
| 21 |
+
right: 0;
|
| 22 |
+
margin: auto;
|
| 23 |
z-index: 100;
|
| 24 |
+
width: 90%;
|
| 25 |
+
max-width: 600px;
|
| 26 |
+
}
|
| 27 |
+
.concept-btn {
|
| 28 |
+
transition: all 0.3s ease;
|
| 29 |
+
filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.1));
|
| 30 |
+
}
|
| 31 |
+
.concept-btn:hover {
|
| 32 |
+
transform: translateY(-5px) scale(1.05);
|
| 33 |
+
}
|
| 34 |
+
.active-concept {
|
| 35 |
+
transform: scale(1.1);
|
| 36 |
+
box-shadow: 0 0 15px rgba(59, 130, 246, 0.5);
|
| 37 |
}
|
| 38 |
</style>
|
| 39 |
</head>
|
| 40 |
<body>
|
| 41 |
+
<div id="math-container"></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
+
<div class="control-panel bg-white bg-opacity-90 p-4 rounded-xl shadow-xl">
|
| 44 |
+
<div class="grid grid-cols-7 gap-2">
|
| 45 |
+
<!-- Nombres -->
|
| 46 |
+
<button onclick="loadConcept('numbers')" class="concept-btn bg-blue-50 p-3 rounded-lg flex items-center justify-center">
|
| 47 |
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 text-blue-600" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
| 48 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"/>
|
| 49 |
+
</svg>
|
| 50 |
+
</button>
|
| 51 |
+
|
| 52 |
+
<!-- Addition -->
|
| 53 |
+
<button onclick="loadConcept('addition')" class="concept-btn bg-green-50 p-3 rounded-lg flex items-center justify-center">
|
| 54 |
+
<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">
|
| 55 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"/>
|
| 56 |
+
</svg>
|
| 57 |
+
</button>
|
| 58 |
+
|
| 59 |
+
<!-- Soustraction -->
|
| 60 |
+
<button onclick="loadConcept('subtraction')" class="concept-btn bg-red-50 p-3 rounded-lg flex items-center justify-center">
|
| 61 |
+
<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">
|
| 62 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20 12H4"/>
|
| 63 |
+
</svg>
|
| 64 |
+
</button>
|
| 65 |
+
|
| 66 |
+
<!-- Multiplication -->
|
| 67 |
+
<button onclick="loadConcept('multiplication')" class="concept-btn bg-yellow-50 p-3 rounded-lg flex items-center justify-center">
|
| 68 |
+
<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">
|
| 69 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/>
|
| 70 |
+
</svg>
|
| 71 |
+
</button>
|
| 72 |
+
|
| 73 |
+
<!-- Division -->
|
| 74 |
+
<button onclick="loadConcept('division')" class="concept-btn bg-purple-50 p-3 rounded-lg flex items-center justify-center">
|
| 75 |
+
<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">
|
| 76 |
+
<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"/>
|
| 77 |
+
</svg>
|
| 78 |
+
</button>
|
| 79 |
+
|
| 80 |
+
<!-- Fractions -->
|
| 81 |
+
<button onclick="loadConcept('fractions')" class="concept-btn bg-pink-50 p-3 rounded-lg flex items-center justify-center">
|
| 82 |
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 text-pink-600" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
| 83 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 10h18M3 14h18m-9-4v8m-7 0h14a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z"/>
|
| 84 |
+
</svg>
|
| 85 |
+
</button>
|
| 86 |
+
|
| 87 |
+
<!-- Géométrie -->
|
| 88 |
+
<button onclick="loadConcept('geometry')" class="concept-btn bg-indigo-50 p-3 rounded-lg flex items-center justify-center">
|
| 89 |
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 text-indigo-600" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
| 90 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4"/>
|
| 91 |
+
</svg>
|
| 92 |
+
</button>
|
| 93 |
+
</div>
|
| 94 |
+
|
| 95 |
+
<div class="grid grid-cols-7 gap-2 mt-2">
|
| 96 |
+
<!-- Valeur positionnelle -->
|
| 97 |
+
<button onclick="loadConcept('place-value')" class="concept-btn bg-teal-50 p-3 rounded-lg flex items-center justify-center">
|
| 98 |
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 text-teal-600" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
| 99 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"/>
|
| 100 |
+
</svg>
|
| 101 |
+
</button>
|
| 102 |
+
|
| 103 |
+
<!-- Grands nombres -->
|
| 104 |
+
<button onclick="loadConcept('large-numbers')" class="concept-btn bg-amber-50 p-3 rounded-lg flex items-center justify-center">
|
| 105 |
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 text-amber-600" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
| 106 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 5a1 1 0 011-1h14a1 1 0 011 1v14a1 1 0 01-1 1H5a1 1 0 01-1-1V5z"/>
|
| 107 |
+
</svg>
|
| 108 |
+
</button>
|
| 109 |
+
|
| 110 |
+
<!-- Pourcentages -->
|
| 111 |
+
<button onclick="loadConcept('percentages')" class="concept-btn bg-rose-50 p-3 rounded-lg flex items-center justify-center">
|
| 112 |
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 text-rose-600" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
| 113 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 17v-2m3 2v-4m3 4v-6m2 10H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"/>
|
| 114 |
+
</svg>
|
| 115 |
+
</button>
|
| 116 |
+
|
| 117 |
+
<!-- Algèbre -->
|
| 118 |
+
<button onclick="loadConcept('algebra')" class="concept-btn bg-lime-50 p-3 rounded-lg flex items-center justify-center">
|
| 119 |
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 text-lime-600" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
| 120 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21a4 4 0 01-4-4V5a2 2 0 012-2h4a2 2 0 012 2v12a4 4 0 01-4 4zm0 0h12a2 2 0 002-2v-4a2 2 0 00-2-2h-2.343M11 7.343l1.657-1.657a2 2 0 012.828 0l2.829 2.829a2 2 0 010 2.828l-8.486 8.485M7 17h.01"/>
|
| 121 |
+
</svg>
|
| 122 |
+
</button>
|
| 123 |
+
|
| 124 |
+
<!-- Mesures -->
|
| 125 |
+
<button onclick="loadConcept('measurement')" class="concept-btn bg-cyan-50 p-3 rounded-lg flex items-center justify-center">
|
| 126 |
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 text-cyan-600" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
| 127 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6V4m0 2a2 2 0 100 4m0-4a2 2 0 110 4m-6 8a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4m6 6v10m6-2a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4"/>
|
| 128 |
+
</svg>
|
| 129 |
+
</button>
|
| 130 |
+
|
| 131 |
+
<!-- Statistiques -->
|
| 132 |
+
<button onclick="loadConcept('statistics')" class="concept-btn bg-violet-50 p-3 rounded-lg flex items-center justify-center">
|
| 133 |
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 text-violet-600" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
| 134 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"/>
|
| 135 |
+
</svg>
|
| 136 |
+
</button>
|
| 137 |
+
|
| 138 |
+
<!-- Probabilités -->
|
| 139 |
+
<button onclick="loadConcept('probability')" class="concept-btn bg-fuchsia-50 p-3 rounded-lg flex items-center justify-center">
|
| 140 |
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 text-fuchsia-600" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
| 141 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 8h14M5 8a2 2 0 110-4h14a2 2 0 110 4M5 8v10a2 2 0 002 2h10a2 2 0 002-2V8m-9 4h4"/>
|
| 142 |
</svg>
|
| 143 |
</button>
|
| 144 |
</div>
|
|
|
|
| 146 |
|
| 147 |
<script>
|
| 148 |
// Initialisation Three.js
|
| 149 |
+
let scene, camera, renderer, controls, activeConcept = 'numbers';
|
| 150 |
+
const objects = [];
|
| 151 |
|
| 152 |
function init() {
|
| 153 |
// Création de la scène
|
| 154 |
scene = new THREE.Scene();
|
| 155 |
+
scene.background = new THREE.Color(0xf0f4ff);
|
| 156 |
|
| 157 |
// Configuration de la caméra
|
| 158 |
+
camera = new THREE.PerspectiveCamera(60, window.innerWidth / window.innerHeight, 0.1, 1000);
|
| 159 |
+
camera.position.set(0, 5, 15);
|
| 160 |
|
| 161 |
// Configuration du rendu
|
| 162 |
renderer = new THREE.WebGLRenderer({ antialias: true });
|
| 163 |
+
renderer.setSize(window.innerWidth, window.innerHeight);
|
| 164 |
renderer.shadowMap.enabled = true;
|
| 165 |
+
document.getElementById('math-container').appendChild(renderer.domElement);
|
| 166 |
|
| 167 |
// Lumière directionnelle
|
| 168 |
const directionalLight = new THREE.DirectionalLight(0xffffff, 0.8);
|
|
|
|
| 188 |
requestAnimationFrame(animate);
|
| 189 |
controls.update();
|
| 190 |
renderer.render(scene, camera);
|
| 191 |
+
|
| 192 |
+
// Animation des objets
|
| 193 |
+
objects.forEach(obj => {
|
| 194 |
+
if (obj.userData.animate) {
|
| 195 |
+
obj.rotation.x += 0.01;
|
| 196 |
+
obj.rotation.y += 0.01;
|
| 197 |
+
}
|
| 198 |
+
});
|
| 199 |
}
|
| 200 |
animate();
|
| 201 |
|
|
|
|
| 203 |
window.addEventListener('resize', onWindowResize);
|
| 204 |
|
| 205 |
// Chargement initial
|
| 206 |
+
loadConcept('numbers');
|
| 207 |
}
|
| 208 |
|
| 209 |
function onWindowResize() {
|
| 210 |
+
camera.aspect = window.innerWidth / window.innerHeight;
|
| 211 |
camera.updateProjectionMatrix();
|
| 212 |
+
renderer.setSize(window.innerWidth, window.innerHeight);
|
| 213 |
}
|
| 214 |
|
| 215 |
+
// Fonctions de chargement des concepts
|
| 216 |
+
function loadConcept(concept) {
|
| 217 |
+
activeConcept = concept;
|
| 218 |
clearScene();
|
| 219 |
+
updateActiveButton();
|
| 220 |
|
| 221 |
+
switch(concept) {
|
| 222 |
+
case 'numbers':
|
| 223 |
+
createNumberTower(10);
|
| 224 |
+
break;
|
| 225 |
+
case 'addition':
|
| 226 |
+
demonstrateAddition();
|
| 227 |
+
break;
|
| 228 |
+
case 'subtraction':
|
| 229 |
+
demonstrateSubtraction();
|
| 230 |
+
break;
|
| 231 |
+
case 'multiplication':
|
| 232 |
+
demonstrateMultiplication();
|
| 233 |
+
break;
|
| 234 |
+
case 'division':
|
| 235 |
+
demonstrateDivision();
|
| 236 |
+
break;
|
| 237 |
+
case 'fractions':
|
| 238 |
+
demonstrateFractions();
|
| 239 |
+
break;
|
| 240 |
+
case 'geometry':
|
| 241 |
+
demonstrateGeometry();
|
| 242 |
+
break;
|
| 243 |
+
case 'place-value':
|
| 244 |
+
demonstratePlaceValue();
|
| 245 |
+
break;
|
| 246 |
+
case 'large-numbers':
|
| 247 |
+
demonstrateLargeNumbers();
|
| 248 |
+
break;
|
| 249 |
+
case 'percentages':
|
| 250 |
+
demonstratePercentages();
|
| 251 |
+
break;
|
| 252 |
+
case 'algebra':
|
| 253 |
+
demonstrateAlgebra();
|
| 254 |
+
break;
|
| 255 |
+
case 'measurement':
|
| 256 |
+
demonstrateMeasurement();
|
| 257 |
+
break;
|
| 258 |
+
case 'statistics':
|
| 259 |
+
demonstrateStatistics();
|
| 260 |
+
break;
|
| 261 |
+
case 'probability':
|
| 262 |
+
demonstrateProbability();
|
| 263 |
+
break;
|
| 264 |
+
}
|
| 265 |
+
}
|
| 266 |
+
|
| 267 |
+
function updateActiveButton() {
|
| 268 |
+
document.querySelectorAll('.concept-btn').forEach(btn => {
|
| 269 |
+
btn.classList.remove('active-concept');
|
| 270 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
| 271 |
|
| 272 |
+
const activeBtn = document.querySelector(`[onclick="loadConcept('${activeConcept}')"]`);
|
| 273 |
+
if (activeBtn) {
|
| 274 |
+
activeBtn.classList.add('active-concept');
|
| 275 |
+
}
|
| 276 |
+
}
|
| 277 |
+
|
| 278 |
+
function clearScene() {
|
| 279 |
+
// Supprimer tous les objets sauf les lumières et helpers
|
| 280 |
+
const toRemove = [];
|
| 281 |
+
scene.children.forEach(child => {
|
| 282 |
+
if (!(child instanceof THREE.Light || child instanceof THREE.GridHelper)) {
|
| 283 |
+
toRemove.push(child);
|
| 284 |
+
}
|
| 285 |
+
});
|
| 286 |
+
|
| 287 |
+
toRemove.forEach(child => scene.remove(child));
|
| 288 |
+
objects.length = 0;
|
| 289 |
+
}
|
| 290 |
+
|
| 291 |
+
// Fonctions de démonstration des concepts
|
| 292 |
+
function createNumberTower(count) {
|
| 293 |
+
const baseGeometry = new THREE.CylinderGeometry(8, 8, 0.5, 32);
|
| 294 |
+
const baseMaterial = new THREE.MeshPhongMaterial({ color: 0xffffff, transparent: true, opacity: 0.9 });
|
| 295 |
+
const base = new THREE.Mesh(baseGeometry, baseMaterial);
|
| 296 |
+
base.position.y = -0.5;
|
| 297 |
+
base.receiveShadow = true;
|
| 298 |
+
scene.add(base);
|
| 299 |
+
|
| 300 |
+
for (let i = 1; i <= count; i++) {
|
| 301 |
+
const geometry = new THREE.BoxGeometry(1, 1, 1);
|
| 302 |
const material = new THREE.MeshPhongMaterial({
|
| 303 |
+
color: new THREE.Color(`hsl(${i * 36}, 70%, 60%)`),
|
| 304 |
transparent: true,
|
| 305 |
opacity: 0.9
|
| 306 |
});
|
| 307 |
+
const cube = new THREE.Mesh(geometry, material);
|
| 308 |
+
cube.position.set(0, i * 1.1 - 0.5, 0);
|
| 309 |
+
cube.castShadow = true;
|
| 310 |
+
cube.userData.animate = true;
|
| 311 |
+
scene.add(cube);
|
| 312 |
+
objects.push(cube);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 313 |
}
|
| 314 |
}
|
| 315 |
|
| 316 |
+
function demonstrateAddition() {
|
| 317 |
+
createMathBase();
|
|
|
|
|
|
|
| 318 |
|
| 319 |
// Premier groupe (bleu)
|
| 320 |
+
const group1 = createSphereGroup(3, -4, 0, 0x3b82f6);
|
| 321 |
|
| 322 |
// Deuxième groupe (rouge)
|
| 323 |
+
const group2 = createSphereGroup(2, 4, 0, 0xef4444);
|
| 324 |
|
| 325 |
// Animation pour montrer l'addition
|
| 326 |
setTimeout(() => {
|
| 327 |
+
animateGroup(group2, { x: -1, y: 0, z: 0 }, 1000, () => {
|
| 328 |
+
const resultGroup = createSphereGroup(5, 0, 0, 0x10b981);
|
| 329 |
+
animateGroup(resultGroup, { y: 2 }, 800);
|
| 330 |
});
|
| 331 |
}, 1000);
|
| 332 |
}
|
| 333 |
|
| 334 |
+
function demonstrateSubtraction() {
|
| 335 |
+
createMathBase();
|
|
|
|
|
|
|
| 336 |
|
| 337 |
// Groupe initial
|
| 338 |
+
const initialGroup = createSphereGroup(5, 0, 0, 0x3b82f6);
|
| 339 |
|
| 340 |
// Animation de la soustraction
|
| 341 |
setTimeout(() => {
|
| 342 |
+
const removedGroup = createSphereGroup(2, 0, 0, 0xef4444);
|
| 343 |
+
animateGroup(removedGroup, { x: 3, y: 0, z: 0 }, 1000, () => {
|
| 344 |
+
const resultGroup = createSphereGroup(3, -3, 0, 0x10b981);
|
| 345 |
+
animateGroup(resultGroup, { y: 2 }, 800);
|
| 346 |
});
|
| 347 |
}, 1000);
|
| 348 |
}
|
| 349 |
|
| 350 |
+
function demonstrateMultiplication() {
|
| 351 |
+
createMathBase();
|
|
|
|
|
|
|
| 352 |
|
| 353 |
// Création de groupes égaux
|
| 354 |
+
const group1 = createSphereGroup(4, -3, -2, 0x3b82f6);
|
| 355 |
+
const group2 = createSphereGroup(4, -3, 0, 0x3b82f6);
|
| 356 |
+
const group3 = createSphereGroup(4, -3, 2, 0x3b82f6);
|
| 357 |
|
| 358 |
// Animation pour montrer la multiplication
|
| 359 |
setTimeout(() => {
|
| 360 |
+
animateGroup(group1, { x: 0, z: -2 }, 800);
|
| 361 |
+
animateGroup(group2, { x: 0, z: 0 }, 800);
|
| 362 |
+
animateGroup(group3, { x: 0, z: 2 }, 800, () => {
|
| 363 |
+
const resultGroup = createSphereGroup(12, 3, 0, 0x10b981);
|
| 364 |
+
animateGroup(resultGroup, { y: 2 }, 800);
|
| 365 |
});
|
| 366 |
}, 1000);
|
| 367 |
}
|
| 368 |
|
| 369 |
+
function demonstrateDivision() {
|
| 370 |
+
createMathBase();
|
|
|
|
|
|
|
| 371 |
|
| 372 |
// Groupe initial
|
| 373 |
+
const initialGroup = createSphereGroup(12, 0, 0, 0x3b82f6);
|
| 374 |
|
| 375 |
// Animation de la division
|
| 376 |
setTimeout(() => {
|
| 377 |
+
const group1 = createSphereGroup(4, -3, -2, 0xef4444);
|
| 378 |
+
const group2 = createSphereGroup(4, -3, 0, 0xef4444);
|
| 379 |
+
const group3 = createSphereGroup(4, -3, 2, 0xef4444);
|
| 380 |
|
| 381 |
setTimeout(() => {
|
| 382 |
+
animateGroup(group1, { x: -3, z: -2 }, 800);
|
| 383 |
+
animateGroup(group2, { x: -3, z: 0 }, 800);
|
| 384 |
+
animateGroup(group3, { x: -3, z: 2 }, 800);
|
| 385 |
}, 1000);
|
| 386 |
}, 1000);
|
| 387 |
}
|
| 388 |
|
| 389 |
+
function demonstrateFractions() {
|
| 390 |
+
createMathBase();
|
| 391 |
+
|
| 392 |
+
// Création d'un cercle fractionné
|
| 393 |
+
const circleGeometry = new THREE.CircleGeometry(3, 32);
|
| 394 |
+
|
| 395 |
+
// Demi-cercle (1/2)
|
| 396 |
+
const halfCircle1 = new THREE.Mesh(
|
| 397 |
+
new THREE.ShapeGeometry(new THREE.Shape(circleGeometry.attributes.position.array.slice(0, 97))),
|
| 398 |
+
new THREE.MeshPhongMaterial({ color: 0x3b82f6, side: THREE.DoubleSide })
|
| 399 |
+
);
|
| 400 |
+
halfCircle1.position.set(-4, 0, 0);
|
| 401 |
+
scene.add(halfCircle1);
|
| 402 |
+
objects.push(halfCircle1);
|
| 403 |
+
|
| 404 |
+
const halfCircle2 = new THREE.Mesh(
|
| 405 |
+
new THREE.ShapeGeometry(new THREE.Shape(circleGeometry.attributes.position.array.slice(96))),
|
| 406 |
+
new THREE.MeshPhongMaterial({ color: 0xef4444, side: THREE.DoubleSide })
|
| 407 |
+
);
|
| 408 |
+
halfCircle2.position.set(-4, 0, 0);
|
| 409 |
+
scene.add(halfCircle2);
|
| 410 |
+
objects.push(halfCircle2);
|
| 411 |
+
|
| 412 |
+
// Quart de cercle (1/4)
|
| 413 |
+
const quarterCircle = new THREE.Mesh(
|
| 414 |
+
new THREE.ShapeGeometry(new THREE.Shape(circleGeometry.attributes.position.array.slice(0, 49))),
|
| 415 |
+
new THREE.MeshPhongMaterial({ color: 0x10b981, side: THREE.DoubleSide })
|
| 416 |
+
);
|
| 417 |
+
quarterCircle.position.set(4, 0, 0);
|
| 418 |
+
scene.add(quarterCircle);
|
| 419 |
+
objects.push(quarterCircle);
|
| 420 |
+
|
| 421 |
+
// Animation
|
| 422 |
+
setTimeout(() => {
|
| 423 |
+
animateObject(halfCircle1, { rotation: { z: Math.PI } }, 1000);
|
| 424 |
+
animateObject(halfCircle2, { rotation: { z: Math.PI } }, 1000);
|
| 425 |
+
animateObject(quarterCircle, { rotation: { z: Math.PI * 2 } }, 1500);
|
| 426 |
+
}, 1000);
|
| 427 |
+
}
|
| 428 |
+
|
| 429 |
+
function demonstrateGeometry() {
|
| 430 |
+
createMathBase();
|
| 431 |
+
|
| 432 |
+
// Cube
|
| 433 |
+
const cubeGeometry = new THREE.BoxGeometry(2, 2, 2);
|
| 434 |
+
const cubeMaterial = new THREE.MeshPhongMaterial({ color: 0x3b82f6, wireframe: false });
|
| 435 |
+
const cube = new THREE.Mesh(cubeGeometry, cubeMaterial);
|
| 436 |
+
cube.position.set(-4, 1, 0);
|
| 437 |
+
cube.castShadow = true;
|
| 438 |
+
cube.userData.animate = true;
|
| 439 |
+
scene.add(cube);
|
| 440 |
+
objects.push(cube);
|
| 441 |
+
|
| 442 |
+
// Sphère
|
| 443 |
+
const sphereGeometry = new THREE.SphereGeometry(1, 32, 32);
|
| 444 |
+
const sphereMaterial = new THREE.MeshPhongMaterial({ color: 0xef4444, wireframe: false });
|
| 445 |
+
const sphere = new THREE.Mesh(sphereGeometry, sphereMaterial);
|
| 446 |
+
sphere.position.set(0, 1, 0);
|
| 447 |
+
sphere.castShadow = true;
|
| 448 |
+
sphere.userData.animate = true;
|
| 449 |
+
scene.add(sphere);
|
| 450 |
+
objects.push(sphere);
|
| 451 |
+
|
| 452 |
+
// Cylindre
|
| 453 |
+
const cylinderGeometry = new THREE.CylinderGeometry(1, 1, 2, 32);
|
| 454 |
+
const cylinderMaterial = new THREE.MeshPhongMaterial({ color: 0x10b981, wireframe: false });
|
| 455 |
+
const cylinder = new THREE.Mesh(cylinderGeometry, cylinderMaterial);
|
| 456 |
+
cylinder.position.set(4, 1, 0);
|
| 457 |
+
cylinder.castShadow = true;
|
| 458 |
+
cylinder.userData.animate = true;
|
| 459 |
+
scene.add(cylinder);
|
| 460 |
+
objects.push(cylinder);
|
| 461 |
+
|
| 462 |
+
// Animation pour montrer les faces
|
| 463 |
+
setTimeout(() => {
|
| 464 |
+
cubeMaterial.wireframe = true;
|
| 465 |
+
sphereMaterial.wireframe = true;
|
| 466 |
+
cylinderMaterial.wireframe = true;
|
| 467 |
+
}, 1500);
|
| 468 |
+
}
|
| 469 |
+
|
| 470 |
+
function demonstratePlaceValue() {
|
| 471 |
+
createMathBase();
|
| 472 |
|
| 473 |
// Création d'un nombre à 3 chiffres
|
| 474 |
+
const hundreds = createPlaceValueBlock(1, -4, 0, 0x3b82f6, 10);
|
| 475 |
+
const tens = createPlaceValueBlock(2, 0, 0, 0x10b981, 5);
|
| 476 |
+
const units = createPlaceValueBlock(3, 4, 0, 0xef4444, 1);
|
| 477 |
|
| 478 |
// Animation pour montrer la décomposition
|
| 479 |
setTimeout(() => {
|
| 480 |
+
animateGroup(hundreds, { y: 2 }, 800);
|
| 481 |
+
animateGroup(tens, { y: 2 }, 800);
|
| 482 |
+
animateGroup(units, { y: 2 }, 800);
|
|
|
|
|
|
|
| 483 |
}, 1000);
|
| 484 |
}
|
| 485 |
|
| 486 |
+
function demonstrateLargeNumbers() {
|
| 487 |
+
createMathBase();
|
|
|
|
|
|
|
| 488 |
|
| 489 |
// Création d'un grand cube représentant 1000
|
| 490 |
+
const cubeGeometry = new THREE.BoxGeometry(8, 8, 8);
|
| 491 |
const cubeMaterial = new THREE.MeshPhongMaterial({
|
| 492 |
color: 0x8b5cf6,
|
| 493 |
transparent: true,
|
|
|
|
| 495 |
wireframe: false
|
| 496 |
});
|
| 497 |
const thousandCube = new THREE.Mesh(cubeGeometry, cubeMaterial);
|
| 498 |
+
thousandCube.position.y = 4;
|
| 499 |
thousandCube.castShadow = true;
|
| 500 |
scene.add(thousandCube);
|
| 501 |
+
objects.push(thousandCube);
|
| 502 |
|
| 503 |
+
// Animation
|
| 504 |
+
setTimeout(() => {
|
| 505 |
+
animateObject(thousandCube, { y: 6 }, 1000);
|
| 506 |
+
}, 1000);
|
| 507 |
+
}
|
| 508 |
+
|
| 509 |
+
function demonstratePercentages() {
|
| 510 |
+
createMathBase();
|
| 511 |
|
| 512 |
+
// Création d'une grille 10x10
|
| 513 |
+
const group = new THREE.Group();
|
| 514 |
+
for (let x = 0; x < 10; x++) {
|
| 515 |
+
for (let y = 0; y < 10; y++) {
|
| 516 |
+
const geometry = new THREE.BoxGeometry(0.8, 0.8, 0.8);
|
| 517 |
+
const material = new THREE.MeshPhongMaterial({
|
| 518 |
+
color: y < 3 ? 0x3b82f6 : 0xdddddd,
|
| 519 |
+
transparent: true,
|
| 520 |
+
opacity: 0.9
|
| 521 |
+
});
|
| 522 |
+
const cube = new THREE.Mesh(geometry, material);
|
| 523 |
+
cube.position.set((x - 4.5) * 1, 0.5, (y - 4.5) * 1);
|
| 524 |
+
group.add(cube);
|
| 525 |
}
|
| 526 |
}
|
| 527 |
+
scene.add(group);
|
| 528 |
+
objects.push(group);
|
| 529 |
|
| 530 |
// Animation
|
| 531 |
setTimeout(() => {
|
| 532 |
+
animateObject(group, { rotation: { y: Math.PI * 2 } }, 2000);
|
| 533 |
+
}, 1000);
|
| 534 |
+
}
|
| 535 |
+
|
| 536 |
+
function demonstrateAlgebra() {
|
| 537 |
+
createMathBase();
|
| 538 |
+
|
| 539 |
+
// Création d'une balance
|
| 540 |
+
const balanceBase = new THREE.Mesh(
|
| 541 |
+
new THREE.CylinderGeometry(0.5, 0.5, 0.2, 32),
|
| 542 |
+
new THREE.MeshPhongMaterial({ color: 0x888888 })
|
| 543 |
+
);
|
| 544 |
+
balanceBase.position.y = 5;
|
| 545 |
+
scene.add(balanceBase);
|
| 546 |
+
|
| 547 |
+
const balanceBeam = new THREE.Mesh(
|
| 548 |
+
new THREE.BoxGeometry(10, 0.1, 0.2),
|
| 549 |
+
new THREE.MeshPhongMaterial({ color: 0x555555 })
|
| 550 |
+
);
|
| 551 |
+
balanceBeam.position.y = 5.2;
|
| 552 |
+
balanceBeam.position.x = 0;
|
| 553 |
+
balanceBeam.rotation.z = Math.PI / 20;
|
| 554 |
+
scene.add(balanceBeam);
|
| 555 |
+
|
| 556 |
+
// Création des poids
|
| 557 |
+
const leftWeight = createAlgebraCube(3, -2.5, 4.5, 0x3b82f6);
|
| 558 |
+
const rightWeight = createAlgebraCube(2, 2.5, 4.5, 0xef4444);
|
| 559 |
+
|
| 560 |
+
// Animation
|
| 561 |
+
setTimeout(() => {
|
| 562 |
+
animateObject(balanceBeam, { rotation: { z: -Math.PI / 20 } }, 1500, () => {
|
| 563 |
+
const xCube = createAlgebraCube(1, 0, 4.5, 0x10b981);
|
| 564 |
+
animateObject(xCube, { x: 5 }, 1000);
|
| 565 |
+
});
|
| 566 |
+
}, 1000);
|
| 567 |
+
}
|
| 568 |
+
|
| 569 |
+
function demonstrateMeasurement() {
|
| 570 |
+
createMathBase();
|
| 571 |
+
|
| 572 |
+
// Règle
|
| 573 |
+
const ruler = new THREE.Mesh(
|
| 574 |
+
new THREE.BoxGeometry(8, 0.2, 0.5),
|
| 575 |
+
new THREE.MeshPhongMaterial({ color: 0x3b82f6 })
|
| 576 |
+
);
|
| 577 |
+
ruler.position.set(0, 0.5, 0);
|
| 578 |
+
scene.add(ruler);
|
| 579 |
+
|
| 580 |
+
// Objets à mesurer
|
| 581 |
+
const smallCube = new THREE.Mesh(
|
| 582 |
+
new THREE.BoxGeometry(1.5, 1.5, 1.5),
|
| 583 |
+
new THREE.MeshPhongMaterial({ color: 0xef4444 })
|
| 584 |
+
);
|
| 585 |
+
smallCube.position.set(-3, 1, 0);
|
| 586 |
+
scene.add(smallCube);
|
| 587 |
+
|
| 588 |
+
const largeCube = new THREE.Mesh(
|
| 589 |
+
new THREE.BoxGeometry(3, 3, 3),
|
| 590 |
+
new THREE.MeshPhongMaterial({ color: 0x10b981 })
|
| 591 |
+
);
|
| 592 |
+
largeCube.position.set(3, 1.5, 0);
|
| 593 |
+
scene.add(largeCube);
|
| 594 |
+
|
| 595 |
+
// Animation
|
| 596 |
+
setTimeout(() => {
|
| 597 |
+
animateObject(smallCube, { x: -2, z: 2 }, 800);
|
| 598 |
+
animateObject(largeCube, { x: 2, z: 2 }, 800);
|
| 599 |
+
}, 1000);
|
| 600 |
+
}
|
| 601 |
+
|
| 602 |
+
function demonstrateStatistics() {
|
| 603 |
+
createMathBase();
|
| 604 |
+
|
| 605 |
+
// Diagramme en barres
|
| 606 |
+
const barChartGroup = new THREE.Group();
|
| 607 |
+
|
| 608 |
+
const bar1 = new THREE.Mesh(
|
| 609 |
+
new THREE.BoxGeometry(1, 3, 1),
|
| 610 |
+
new THREE.MeshPhongMaterial({ color: 0x3b82f6 })
|
| 611 |
+
);
|
| 612 |
+
bar1.position.set(-3, 1.5, 0);
|
| 613 |
+
barChartGroup.add(bar1);
|
| 614 |
+
|
| 615 |
+
const bar2 = new THREE.Mesh(
|
| 616 |
+
new THREE.BoxGeometry(1, 5, 1),
|
| 617 |
+
new THREE.MeshPhongMaterial({ color: 0xef4444 })
|
| 618 |
+
);
|
| 619 |
+
bar2.position.set(-1, 2.5, 0);
|
| 620 |
+
barChartGroup.add(bar2);
|
| 621 |
+
|
| 622 |
+
const bar3 = new THREE.Mesh(
|
| 623 |
+
new THREE.BoxGeometry(1, 2, 1),
|
| 624 |
+
new THREE.MeshPhongMaterial({ color: 0x10b981 })
|
| 625 |
+
);
|
| 626 |
+
bar3.position.set(1, 1, 0);
|
| 627 |
+
barChartGroup.add(bar3);
|
| 628 |
+
|
| 629 |
+
const bar4 = new THREE.Mesh(
|
| 630 |
+
new THREE.BoxGeometry(1, 6, 1),
|
| 631 |
+
new THREE.MeshPhongMaterial({ color: 0x8b5cf6 })
|
| 632 |
+
);
|
| 633 |
+
bar4.position.set(3, 3, 0);
|
| 634 |
+
barChartGroup.add(bar4);
|
| 635 |
+
|
| 636 |
+
scene.add(barChartGroup);
|
| 637 |
+
objects.push(barChartGroup);
|
| 638 |
+
|
| 639 |
+
// Animation
|
| 640 |
+
setTimeout(() => {
|
| 641 |
+
animateObject(barChartGroup, { rotation: { y: Math.PI / 4 } }, 1000);
|
| 642 |
+
}, 1000);
|
| 643 |
+
}
|
| 644 |
+
|
| 645 |
+
function demonstrateProbability() {
|
| 646 |
+
createMathBase();
|
| 647 |
+
|
| 648 |
+
// Sphère avec sections colorées
|
| 649 |
+
const sphereGeometry = new THREE.SphereGeometry(3, 32, 32);
|
| 650 |
+
|
| 651 |
+
// Matériaux pour les différentes sections
|
| 652 |
+
const materials = [
|
| 653 |
+
new THREE.MeshPhongMaterial({ color: 0x3b82f6 }),
|
| 654 |
+
new THREE.MeshPhongMaterial({ color: 0xef4444 }),
|
| 655 |
+
new THREE.MeshPhongMaterial({ color: 0x10b981 }),
|
| 656 |
+
new THREE.MeshPhongMaterial({ color: 0x8b5cf6 })
|
| 657 |
+
];
|
| 658 |
+
|
| 659 |
+
const probabilitySphere = new THREE.Mesh(sphereGeometry, materials);
|
| 660 |
+
probabilitySphere.position.set(0, 3, 0);
|
| 661 |
+
probabilitySphere.userData.animate = true;
|
| 662 |
+
scene.add(probabilitySphere);
|
| 663 |
+
objects.push(probabilitySphere);
|
| 664 |
+
|
| 665 |
+
// Animation
|
| 666 |
+
setTimeout(() => {
|
| 667 |
+
animateObject(probabilitySphere, { rotation: { x: Math.PI * 2, y: Math.PI * 2 } }, 2000);
|
| 668 |
}, 1000);
|
| 669 |
}
|
| 670 |
|
| 671 |
// Fonctions utilitaires
|
| 672 |
+
function createMathBase() {
|
| 673 |
+
const geometry = new THREE.CylinderGeometry(10, 10, 0.5, 32);
|
| 674 |
const material = new THREE.MeshPhongMaterial({
|
| 675 |
color: 0xffffff,
|
| 676 |
transparent: true,
|
|
|
|
| 683 |
return platform;
|
| 684 |
}
|
| 685 |
|
| 686 |
+
function createSphereGroup(count, xPos, zPos, color) {
|
| 687 |
const group = new THREE.Group();
|
| 688 |
|
| 689 |
for (let i = 0; i < count; i++) {
|
|
|
|
| 700 |
}
|
| 701 |
|
| 702 |
scene.add(group);
|
| 703 |
+
objects.push(group);
|
| 704 |
return group;
|
| 705 |
}
|
| 706 |
|
| 707 |
+
function createPlaceValueBlock(value, xPos, zPos, color, size = 1) {
|
| 708 |
const group = new THREE.Group();
|
| 709 |
|
|
|
|
| 710 |
for (let i = 0; i < value; i++) {
|
| 711 |
+
const geometry = new THREE.BoxGeometry(size, size, size);
|
| 712 |
const material = new THREE.MeshPhongMaterial({
|
| 713 |
color: color,
|
| 714 |
transparent: true,
|
| 715 |
opacity: 0.9
|
| 716 |
});
|
| 717 |
const cube = new THREE.Mesh(geometry, material);
|
| 718 |
+
cube.position.set(xPos, size/2 + i * size * 1.1, zPos);
|
| 719 |
cube.castShadow = true;
|
| 720 |
group.add(cube);
|
| 721 |
}
|
| 722 |
|
| 723 |
scene.add(group);
|
| 724 |
+
objects.push(group);
|
| 725 |
return group;
|
| 726 |
}
|
| 727 |
|
| 728 |
+
function createAlgebraCube(size, xPos, yPos, color) {
|
| 729 |
+
const geometry = new THREE.BoxGeometry(size, size, size);
|
| 730 |
+
const material = new THREE.MeshPhongMaterial({
|
| 731 |
+
color: color,
|
| 732 |
+
transparent: true,
|
| 733 |
+
opacity: 0.9
|
| 734 |
+
});
|
| 735 |
+
const cube = new THREE.Mesh(geometry, material);
|
| 736 |
+
cube.position.set(xPos, yPos, 0);
|
| 737 |
+
cube.castShadow = true;
|
| 738 |
+
scene.add(cube);
|
| 739 |
+
objects.push(cube);
|
| 740 |
+
return cube;
|
| 741 |
+
}
|
| 742 |
+
|
| 743 |
+
function animateGroup(group, target, duration, callback) {
|
| 744 |
+
const startPositions = [];
|
| 745 |
+
group.children.forEach(child => {
|
| 746 |
+
startPositions.push(child.position.clone());
|
| 747 |
+
});
|
| 748 |
|
| 749 |
const startTime = Date.now();
|
| 750 |
|
|
|
|
| 752 |
const elapsed = Date.now() - startTime;
|
| 753 |
const progress = Math.min(elapsed / duration, 1);
|
| 754 |
|
| 755 |
+
group.children.forEach((child, index) => {
|
| 756 |
+
if (target.x !== undefined) child.position.x = startPositions[index].x + (target.x - startPositions[index].x) * progress;
|
| 757 |
+
if (target.y !== undefined) child.position.y = startPositions[index].y + (target.y - startPositions[index].y) * progress;
|
| 758 |
+
if (target.z !== undefined) child.position.z = startPositions[index].z + (target.z - startPositions[index].z) * progress;
|
| 759 |
+
});
|
| 760 |
|
| 761 |
if (progress < 1) {
|
| 762 |
requestAnimationFrame(update);
|
|
|
|
| 768 |
update();
|
| 769 |
}
|
| 770 |
|
| 771 |
+
function animateObject(object, target, duration, callback) {
|
| 772 |
+
const startPosition = object.position.clone();
|
| 773 |
+
const startRotation = object.rotation.clone();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 774 |
|
| 775 |
+
const changePos = new THREE.Vector3(
|
| 776 |
+
target.x !== undefined ? target.x - object.position.x : 0,
|
| 777 |
+
target.y !== undefined ? target.y - object.position.y : 0,
|
| 778 |
+
target.z !== undefined ? target.z - object.position.z : 0
|
| 779 |
+
);
|
|
|
|
|
|
|
| 780 |
|
| 781 |
+
const changeRot = new THREE.Vector3(
|
| 782 |
+
target.rotation?.x !== undefined ? target.rotation.x - object.rotation.x : 0,
|
| 783 |
+
target.rotation?.y !== undefined ? target.rotation.y - object.rotation.y : 0,
|
| 784 |
+
target.rotation?.z !== undefined ? target.rotation.z - object.rotation.z : 0
|
| 785 |
+
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 786 |
|
| 787 |
+
const startTime = Date.now();
|
| 788 |
+
|
| 789 |
+
function update() {
|
| 790 |
+
const elapsed = Date.now() - startTime;
|
| 791 |
+
const progress = Math.min(elapsed / duration, 1);
|
| 792 |
+
|
| 793 |
+
object.position.x = startPosition.x + changePos.x * progress;
|
| 794 |
+
object.position.y = startPosition.y + changePos.y * progress;
|
| 795 |
+
object.position.z = startPosition.z + changePos.z * progress;
|
| 796 |
+
|
| 797 |
+
if (target.rotation) {
|
| 798 |
+
object.rotation.x = startRotation.x + changeRot.x * progress;
|
| 799 |
+
object.rotation.y = startRotation.y + changeRot.y * progress;
|
| 800 |
+
object.rotation.z = startRotation.z + changeRot.z * progress;
|
| 801 |
+
}
|
| 802 |
+
|
| 803 |
+
if (progress < 1) {
|
| 804 |
+
requestAnimationFrame(update);
|
| 805 |
+
} else if (callback) {
|
| 806 |
+
callback();
|
| 807 |
+
}
|
|
|
|
| 808 |
}
|
| 809 |
+
|
| 810 |
+
update();
|
| 811 |
}
|
| 812 |
|
| 813 |
// Initialisation au chargement
|