Skip to content
Snippets Groups Projects
Commit da096c60 authored by MEHIAOUI Mohamed's avatar MEHIAOUI Mohamed
Browse files

ajout du fichier js

parent ba8e9b7b
No related branches found
No related tags found
No related merge requests found
......@@ -4,9 +4,7 @@
////////////////////////////////////////////////////////////////////////////////
/*global THREE, document, window, $*/
import * as THREE from 'three';
import { OBJLoader } from 'three/addons/loaders/OBJLoader.js';
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
import {dat} from '../../lib/dat.gui.min.js';
var camera, scene, renderer;
......@@ -14,7 +12,7 @@ var camera, scene, renderer;
var windowScale;
window.scene = new THREE.Scene();
import {Coordinates} from '../../lib/Coordinates.js';
import { Coordinates } from '../../lib/Coordinates.js';
var cameraControls;
......@@ -49,19 +47,58 @@ function fillScene() {
bol.position.set(-15, 5, 5);
bol.rotation.x = Math.PI;
//fonction pour creer une pomme
function createApple(x, y, z, color) {
var apple = new THREE.Mesh(new THREE.SphereGeometry(1.5, 22, 22), new THREE.MeshPhongMaterial({color: color}));
apple.position.set(x, y, z);
// tige de la pomme
var tige = new THREE.Mesh(new THREE.CylinderGeometry(0.1, 0.1, 1, 32), new THREE.MeshPhongMaterial({color: 0x8B4513}));
tige.position.set(x, y+1, z);
window.scene.add(tige);
window.scene.add(apple);
}
//Remplir le bol de pommes à des positions différentes
createApple(-15, 2, 5, 0xFF0000);
createApple(-14, 4, 7, 0x00FF00);
createApple(-17, 3, 6, 0xFFFF00);
createApple(-16, 5, 5, 0xFF0000);
createApple(-17, 3, 3, 0x00FF00);
createApple(-13, 3, 3, 0xFFFF00);
createApple(-14, 5, 3, 0xFF0000);
// Créer un vase de fleurs à côté du bol sur l'autre côté de la table
var vase = new THREE.Group();
//Materiaux transparant rouge pour le vase
var glassMaterial = new THREE.MeshPhongMaterial({
color: 0xFF0000,
transparent: true,
opacity: 0.6,
shininess: 100,
side: THREE.DoubleSide
});
//corps du vase : rectangle
var corpsGeometry = new THREE.BoxGeometry(3, 13, 3);
var corps = new THREE.Mesh(corpsGeometry, glassMaterial);
corps.position.set(-9, 1, -1);
vase.add(corps);
// Partie supérieure du vase : trapèze
var hautGeometry = new THREE.CylinderGeometry(2, 3.2, 3, 4);
var haut = new THREE.Mesh(hautGeometry, glassMaterial);
haut.position.set(-9, 9, -1);
vase.add(haut);
// retourner le trapeze pour sa base soit en bas
haut.rotation.x = Math.PI;
haut.rotation.y = Math.PI / 4;
// pomme sur la table
//var apple = new THREE.Mesh(new THREE.SphereGeometry(1, 22, 22), new THREE.MeshPhongMaterial({color: 0x00ff00}));
//apple.position.set(-15, 1.5, 10);
// tige de la pomme
//var tige = new THREE.Mesh(new THREE.CylinderGeometry(0.1, 0.1, 1, 32), new THREE.MeshPhongMaterial({color: 0x8B4513}));
//tige.position.set(-15, 2.5, 10);
// texture de la pomme
/*var texture = new THREE.TextureLoader().load('textures_Pommes/texture_pomme_rouge.jpg');
var material = new THREE.MeshPhongMaterial({map: texture});
apple.material = material;*/
// mur derrière la table
var mur = new THREE.Mesh(new THREE.BoxGeometry(50, 50, 1), new THREE.MeshPhongMaterial({color: 0x8B413}));
......@@ -73,6 +110,7 @@ function fillScene() {
window.scene.add(table);
window.scene.add(mur);
window.scene.add(bol);
window.scene.add(vase);
Coordinates.drawGround({size:10000}); // width and height of ground plane
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment