self-doc / index.html
olinux's picture
Add 1 files
2867105 verified
Raw History Blame Contribute Delete
30.1 kB
<!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>