diff --git a/MATEJKA_MAURICE_COLIN/checklistProjet.md b/MATEJKA_MAURICE_COLIN/checklistProjet.md index e6f0aa4723aaec46f996e417f752e43a65c8bf0d..389fc58879194796db6335fe200bd54d8258852a 100644 --- a/MATEJKA_MAURICE_COLIN/checklistProjet.md +++ b/MATEJKA_MAURICE_COLIN/checklistProjet.md @@ -9,12 +9,12 @@ - [X] Ombres portées - [X] Position de la caméra - [X] Brouillard -- [ ] Effet miroir +- [X] Effet miroir - [X] Texture classique - [X] Texture avec transparence - [X] Sprites -- [ ] Environment map +- [X] Environment map - [X] Skybox - [X] Animations -- [ ] normal maps +- [X] normal maps - [X] Interaction par GUI \ No newline at end of file diff --git a/MATEJKA_MAURICE_COLIN/index.js b/MATEJKA_MAURICE_COLIN/index.js index 8306be13494386fb9e12016861ea8492d25a2643..edb8221f4a1bef917af4960afe2069154649f51f 100644 --- a/MATEJKA_MAURICE_COLIN/index.js +++ b/MATEJKA_MAURICE_COLIN/index.js @@ -40,24 +40,38 @@ function init() { 'textures/6.jpg' ]); scene.background = texture; - - //Chargement de la texture du sol + scene.environment = texture; + //Map + // Chargement de la texture du sol avec displacement map var textureLoader = new THREE.TextureLoader(); var grassTexture = textureLoader.load('textures/grass.jpg'); + var displacementMap = textureLoader.load('textures/displacement.png'); // Image en niveaux de gris + grassTexture.wrapS = THREE.RepeatWrapping; grassTexture.wrapT = THREE.RepeatWrapping; - grassTexture.repeat.set(2000, 2000); + grassTexture.repeat.set(50, 50); + + displacementMap.wrapS = THREE.RepeatWrapping; + displacementMap.wrapT = THREE.RepeatWrapping; + displacementMap.repeat.set(50, 50); - //Création du sol + // Création du sol avec displacement map solidGround = new THREE.Mesh( - new THREE.PlaneGeometry(50, 50, 1, 1), - new THREE.MeshLambertMaterial({ map: grassTexture }) + new THREE.PlaneGeometry(50, 50, 256, 256), + new THREE.MeshStandardMaterial({ + map: grassTexture, + displacementMap: displacementMap, + displacementScale: 0.3, // Ajuste la hauteur du relief + displacementBias: 0.4, // Ajuste le niveau de base + roughness: 0.8 + }) ); - solidGround.position.x = 12.5; - solidGround.position.z = -20.4; + solidGround.position.set(12.5, -0.5, -20.4); // Ajustement pour éviter des creux trop bas solidGround.rotation.x = -Math.PI / 2; solidGround.receiveShadow = true; + scene.add(solidGround); + //Map fin // Chargement du modèle de l'homme const loader = new OBJLoader(); @@ -66,7 +80,7 @@ function init() { (object) => { object.traverse((child) => { if (child.isMesh) { - child.material = new THREE.MeshStandardMaterial({ color: 0x0000FF, metalness: 0.5, roughness: 0.5 }); + child.material = new THREE.MeshStandardMaterial({ color: 0x0000FF, metalness: 0.5, roughness: 0.5, envMap: texture }); child.castShadow = true; child.receiveShadow = true; } @@ -105,13 +119,13 @@ function init() { } ); - - // --- Chargement et génération de la forêt --- + + // --- Chargement et génération de la forêt --- console.log('Début du chargement de la forêt'); const mtlLoader = new MTLLoader(); mtlLoader.load('textures/Tree.mtl', (materials) => { console.log('Matériaux chargés'); - materials.preload(); + materials.preload(); const objLoader = new OBJLoader(); objLoader.setMaterials(materials); objLoader.load('textures/Tree.obj', (object) => { @@ -122,9 +136,11 @@ function init() { //Fonction pour générer une forêt function generateForest(objModel, numTrees) { console.log('Début de la génération de la forêt'); - const minDistance = 0.25; - const minX = -8.5, maxX = -12; - const minZ = -4, maxZ = -15; + const minDistance = 0.25; + const minX = -8.5, + maxX = -12; + const minZ = -4, + maxZ = -15; let treePositions = []; @@ -133,7 +149,7 @@ function init() { let attempts = 0; let placed = false; - while (!placed && attempts < 10) { + while (!placed && attempts < 10) { const x = Math.random() * (maxX - minX) + minX; const z = Math.random() * (maxZ - minZ) + minZ; const y = -0.25; @@ -153,10 +169,11 @@ function init() { } console.log("foret ok"); } + function addGrass() { - const numGrassBlades = 100000; - const areaSize = 50; - + const numGrassBlades = 100000; + const areaSize = 50; + const grassGeometry = new THREE.CylinderGeometry(0.0, 0.05, 0.5, 3, 1); const grassMaterial = new THREE.MeshStandardMaterial({ map: new THREE.TextureLoader().load('textures/grassblade.png'), @@ -165,25 +182,25 @@ function init() { emissive: 0x000000, roughness: 0.6, }); - + const grassMesh = new THREE.InstancedMesh(grassGeometry, grassMaterial, numGrassBlades); - + const dummy = new THREE.Object3D(); - + for (let i = 0; i < numGrassBlades; i++) { const x = Math.random() * areaSize - areaSize / 4; - const z = Math.random() * areaSize - areaSize / 1.1 ; + const z = Math.random() * areaSize - areaSize / 1.1; const y = 0.1; - + dummy.position.set(x, y, z); dummy.rotation.y = Math.random() * Math.PI * 2; dummy.rotation.x = Math.random() * Math.PI * 0.1; dummy.scale.set(0.5 + Math.random() * 0.5, 1, 0.5 + Math.random() * 0.5); dummy.updateMatrix(); - + grassMesh.setMatrixAt(i, dummy.matrix); } - + scene.add(grassMesh); } @@ -192,18 +209,18 @@ function init() { function addVillageImage() { const textureLoader = new THREE.TextureLoader(); textureLoader.load('textures/village.jpg', (texture) => { - const geometry = new THREE.PlaneGeometry(75, 50); - const material = new THREE.MeshBasicMaterial({ + const geometry = new THREE.PlaneGeometry(75, 50); + const material = new THREE.MeshBasicMaterial({ map: texture, - color: 0x777777 + color: 0x777777 }); const plane = new THREE.Mesh(geometry, material); - plane.position.set(0, 18, -150); + plane.position.set(0, 18, -150); scene.add(plane); console.log('Image du village ajouté'); }); } - + addVillageImage(); @@ -214,7 +231,7 @@ function init() { object.traverse((child) => { if (child.isMesh) { child.material = new THREE.MeshStandardMaterial({ color: 0xfff5c3, metalness: 0.2, roughness: 0.7 }); - child.castShadow = true; + child.castShadow = true; child.receiveShadow = true; } }); @@ -236,6 +253,23 @@ function init() { candleLight.position.y = object.position.y + 0.35 + Math.random() * 0.02; //Léger mouvement } animateCandleLight(); + + const sphereGeometry = new THREE.SphereGeometry(0.3, 32, 32); + const sphereMaterial = new THREE.MeshStandardMaterial({ + color: 0xffffff, + metalness: 1.0, + roughness: 0.0, + envMap: scene.background + }); + const mirrorSphere = new THREE.Mesh(sphereGeometry, sphereMaterial); + mirrorSphere.position.set( + object.position.x + 3, + object.position.y + 0.8, // 0.8 unités au-dessus de la bougie + object.position.z + ); + mirrorSphere.castShadow = true; + mirrorSphere.receiveShadow = true; + scene.add(mirrorSphere); } ); @@ -244,7 +278,7 @@ function init() { scene.add(ambientLight); window.addEventListener('resize', onWindowResize); - + setupGUI(); animate(); } @@ -255,6 +289,7 @@ const guiParams = { function setupGUI() { gui.add(guiParams, 'intensity', 0.01, 5, 0.1).name('Intensité Bougie'); + } function onWindowResize() { diff --git a/MATEJKA_MAURICE_COLIN/textures/1.png b/MATEJKA_MAURICE_COLIN/textures/1.png new file mode 100644 index 0000000000000000000000000000000000000000..339d4cd82d8b68f28b5f791bcb7efa93e8ebf28c Binary files /dev/null and b/MATEJKA_MAURICE_COLIN/textures/1.png differ diff --git a/MATEJKA_MAURICE_COLIN/textures/2.png b/MATEJKA_MAURICE_COLIN/textures/2.png new file mode 100644 index 0000000000000000000000000000000000000000..ea7b4f05b177a8b51b1a95c4ee5807ddf8da1ac7 Binary files /dev/null and b/MATEJKA_MAURICE_COLIN/textures/2.png differ diff --git a/MATEJKA_MAURICE_COLIN/textures/3.png b/MATEJKA_MAURICE_COLIN/textures/3.png new file mode 100644 index 0000000000000000000000000000000000000000..b705d81b88b09851cfc0102395bf0ed1b69640d9 Binary files /dev/null and b/MATEJKA_MAURICE_COLIN/textures/3.png differ diff --git a/MATEJKA_MAURICE_COLIN/textures/4.png b/MATEJKA_MAURICE_COLIN/textures/4.png new file mode 100644 index 0000000000000000000000000000000000000000..666f259ce56c3ee5d635977fc34a3d4e23c8a40b Binary files /dev/null and b/MATEJKA_MAURICE_COLIN/textures/4.png differ diff --git a/MATEJKA_MAURICE_COLIN/textures/5.png b/MATEJKA_MAURICE_COLIN/textures/5.png new file mode 100644 index 0000000000000000000000000000000000000000..319f6993f0f0e243fbb7ec16910155e418cdf455 Binary files /dev/null and b/MATEJKA_MAURICE_COLIN/textures/5.png differ diff --git a/MATEJKA_MAURICE_COLIN/textures/6.png b/MATEJKA_MAURICE_COLIN/textures/6.png new file mode 100644 index 0000000000000000000000000000000000000000..34496ff86de86719ab7c7c2b03e86b8a05914e31 Binary files /dev/null and b/MATEJKA_MAURICE_COLIN/textures/6.png differ diff --git a/MATEJKA_MAURICE_COLIN/textures/displacement.png b/MATEJKA_MAURICE_COLIN/textures/displacement.png new file mode 100644 index 0000000000000000000000000000000000000000..48d19703251a93172d55e546f1a1fabfca9c5c8e Binary files /dev/null and b/MATEJKA_MAURICE_COLIN/textures/displacement.png differ