Skip to content
Snippets Groups Projects
Commit ca19c989 authored by HERRY Matteo's avatar HERRY Matteo
Browse files

table taille + nappe taille + bougeoir position + boussole possition + carré de scène

parent 6656ed9e
Branches
No related tags found
No related merge requests found
......@@ -56,7 +56,7 @@ function CreationTable() {
var material = new THREE.MeshStandardMaterial({ color: 0x8B4513 });
// Tabletop
var tabletopGeometry = new THREE.BoxGeometry(6, 0.2, 3);
var tabletopGeometry = new THREE.BoxGeometry(7, 0.2, 3);
var tabletop = new THREE.Mesh(tabletopGeometry, material);
tabletop.position.set(0, 2.6, 0);
tableGroup.add(tabletop);
......@@ -79,6 +79,30 @@ function CreationTable() {
tableGroup.position.set(5, 0, 0); // Positionner la table à droite
scene.add(tableGroup);
}
function CreationCarré() {
// Charger la texture
const textureLoader = new THREE.TextureLoader();
const texture = textureLoader.load('textures/fond.png'); // Remplace par le chemin de ta texture .png
// Matériau avec la texture
var material = new THREE.MeshStandardMaterial({
map: texture, // Appliquer la texture
side: THREE.DoubleSide // Voir les faces intérieures aussi
});
// Définir la taille de la boîte
var boxGeometry = new THREE.BoxGeometry(40, 40.01, 40);
// Créer la boîte avec la texture
var box = new THREE.Mesh(boxGeometry, material);
// Positionner la boîte
box.position.set(5, 20, 0);
// Ajouter la boîte à la scène
scene.add(box);
}
function CreationNappe() {
var clothMaterial = new THREE.MeshStandardMaterial({
......@@ -88,7 +112,7 @@ function CreationNappe() {
});
// Création d'un plan subdivisé pour permettre des déformations
var clothGeometry = new THREE.PlaneGeometry(6.2, 3.2, 20, 20); // Légèrement plus grand que la table
var clothGeometry = new THREE.PlaneGeometry(7.2, 3.2, 20, 20); // Légèrement plus grand que la table
// Déformation légère pour un effet plus naturel
var vertices = clothGeometry.attributes.position;
......@@ -103,22 +127,13 @@ function CreationNappe() {
scene.add(cloth);
}
function ImageDeFond() {
const loader = new THREE.TextureLoader();
loader.load('textures/fond.png', function(texture) {
scene.background = texture;
}, undefined, function(err) {
console.error('Erreur lors du chargement de la texture :', err);
});
}
function fillScene() {
scene = new THREE.Scene();
// LIGHT
var light = new THREE.DirectionalLight(0xFFFFFF, 3);
var light = new THREE.DirectionalLight(0xFFFFFF, 7);
light.position.set(1, 1, 1);
scene.add(light);
var light2 = new THREE.AmbientLight(0xFFFFFF, 1);
......@@ -211,7 +226,7 @@ var mtlLoader1 = new MTLLoader();
objLoader1.load(
'boussole.obj',
function (object) {
normalizeAndPosition(object, 0.5, new THREE.Vector3(2.35, 2.77, 0.9));
normalizeAndPosition(object, 0.5, new THREE.Vector3(2, 2.77, 0.9));
object.rotation.y = 5;
scene.add(object);
},
......@@ -255,7 +270,7 @@ var mtlLoader1 = new MTLLoader();
loader6.load(
'bougeoir.obj',
function (object) {
normalizeAndPosition(object, 1, new THREE.Vector3(3.6, 2.71, -14));
normalizeAndPosition(object, 1, new THREE.Vector3(3.1, 2.71, -14));
var material = new THREE.MeshStandardMaterial({
color: new THREE.Color(42 / 255, 23 / 255, 13 / 255), // Conversion des valeurs RGB (de 0 à 1)
......@@ -283,9 +298,9 @@ var mtlLoader1 = new MTLLoader();
'verre.obj',
function (object) {
normalizeAndPosition(object, 0.8, new THREE.Vector3(2.6, 3.3, -0.1));
object.rotation.x = 4;
object.rotation.y = -0.2;
object.rotation.z = 1.0;
object.rotation.x = -3.3;
object.rotation.y = -0.4;
object.rotation.z = 1.02;
var material = new THREE.MeshPhysicalMaterial({
color: new THREE.Color(107 / 255, 109 / 255, 115 / 255),
......@@ -301,7 +316,7 @@ var mtlLoader1 = new MTLLoader();
envMapIntensity: 2.5, // J'ai monté encore plus fort
});
//Création de la caméra pour gérer les reflets
// Création de la caméra pour gérer les reflets
const cubeRenderTarget = new THREE.WebGLCubeRenderTarget(128);
const camera = new THREE.CubeCamera(1, 1000, cubeRenderTarget);
scene.add(camera);
......@@ -316,7 +331,7 @@ var mtlLoader1 = new MTLLoader();
scene.add(object);
//Stocker la caméra pour la mettre à jour à chaque frame
// Stocker la caméra pour la mettre à jour à chaque frame
object.userData.cubeCamera = camera;
},
function (xhr) {
......@@ -327,10 +342,10 @@ var mtlLoader1 = new MTLLoader();
}
);
CreationCarré();
CreationTable();
CreationNappe();
ImageDeFond()
}
function animate() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment