Skip to content
Snippets Groups Projects
Commit 2052c026 authored by DESERT Romain's avatar DESERT Romain
Browse files

ajout FPS/IPS

parent a4eb5abe
No related branches found
No related tags found
No related merge requests found
......@@ -9,6 +9,9 @@ import {OBJLoader} from 'three/addons/loaders/OBJLoader.js';
import {OrbitControls} from 'three/addons/controls/OrbitControls.js';
import * as dat from 'https://cdn.jsdelivr.net/npm/dat.gui@0.7.9/build/dat.gui.module.js';
import {MTLLoader} from 'three/addons/loaders/MTLLoader.js';
import Stats from 'https://cdn.jsdelivr.net/npm/three@0.130.1/examples/jsm/libs/stats.module.js';
window.scene = new THREE.Scene();
......@@ -18,6 +21,10 @@ var cameraControls;
var clock = new THREE.Clock();
var beton;
var car;
var stats = new Stats();
stats.showPanel(0); // 0: afficher le panneau des FPS
document.body.appendChild(stats.dom);
window.carSpeed = 50;
window.carMoving = true;
......@@ -73,7 +80,7 @@ function fillScene() {
scene.add(road);
// DALLE DE BÉTON
// DALLE DE BÉTON (sous la maisonnette)
var betonTexture = texture.load('textures/beton.jpg');
betonTexture.wrapS = THREE.RepeatWrapping;
betonTexture.wrapT = THREE.RepeatWrapping;
......@@ -90,6 +97,9 @@ function fillScene() {
scene.add(beton);
// CAPSULE EN BÉTON (sous les pompes à essence)
var capsuleLength = 5700; // Longueur de la capsule
var capsuleHeight = 800; // Largeur de la capsule
......@@ -122,13 +132,13 @@ function fillScene() {
const grayMaterial = new THREE.MeshStandardMaterial({ color: 0x888888 }); // Gris
// Bas du poteau (rouge)
const bottomPoleGeometry = new THREE.CylinderGeometry(30, 30, 1500, 32);
const bottomPoleGeometry = new THREE.CylinderGeometry(30, 30, 1000, 32);
const bottomPole = new THREE.Mesh(bottomPoleGeometry, redMaterial);
bottomPole.position.set(-5000, 750, 6000);
scene.add(bottomPole);
// Haut du poteau (gris)
const topPoleGeometry = new THREE.CylinderGeometry(30, 30, 1500, 32);
const topPoleGeometry = new THREE.CylinderGeometry(20, 30, 2000, 32);
const topPole = new THREE.Mesh(topPoleGeometry, grayMaterial);
topPole.position.set(-5000, 2250, 6000);
scene.add(topPole);
......@@ -191,7 +201,9 @@ function fillScene() {
loadCar();
}
// Charger la voiture
/**
* Charge la voiture
*/
function loadCar() {
new OBJLoader().load('car.obj', function (object) {
car = object;
......@@ -240,6 +252,8 @@ function init() {
function animate() {
window.requestAnimationFrame(animate);
stats.begin();
if (car && window.carMoving) {
car.position.z += window.carSpeed; // Avance sur l'axe Z
......@@ -250,6 +264,8 @@ function animate() {
}
render();
stats.end();
}
function render() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment