created site just for chat

This commit is contained in:
edbernar
2024-07-30 20:19:29 +02:00
parent 3b0d129479
commit 09dfdbceb8
12 changed files with 408 additions and 1 deletions

71
site/game/light.js Normal file
View File

@ -0,0 +1,71 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* light.js :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: edbernar <edbernar@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/07/30 13:50:46 by edbernar #+# #+# */
/* Updated: 2024/07/30 13:50:47 by edbernar ### ########.fr */
/* */
/* ************************************************************************** */
import * as THREE from 'three';
// ------------------- Spot Light ------------------- //
function createSpotLight(color, target, scene) {
let spotLight = new THREE.SpotLight(color);
spotLight.position.set(0, 1, 0);
spotLight.angle = Math.PI / 4;
spotLight.castShadow = true;
spotLight.angle = 0.1;
spotLight.penumbra = 0.05;
spotLight.decay = 2;
spotLight.distance = 50;
spotLight.intensity = 10;
spotLight.target = target;
scene.add(spotLight);
return spotLight;
}
function refreshSpotLight(scene, spotLight, target) {
scene.remove(spotLight);
spotLight.dispose();
spotLight = createSpotLight(0xffffff, target, scene);
scene.add(spotLight);
return spotLight;
}
// ------------------- Light Ambient ------------------- //
function createLightAmbient(scene) {
let lightAmbient = new THREE.AmbientLight(0x404040);
lightAmbient.intensity = 5;
scene.add(lightAmbient);
return lightAmbient;
}
// ------------------- Light Point ------------------- //
function createLightPoint(scene) {
let lightPoint = new THREE.PointLight(0xffffff, 750, 10000);
lightPoint.position.set(0, 15, -1);
lightPoint.castShadow = true;
scene.add(lightPoint);
return lightPoint;
}
function refreshLightPoint(scene, lightPoint) {
scene.remove(lightPoint);
lightPoint.dispose();
lightPoint = createLightPoint(scene);
scene.add(lightPoint);
return lightPoint;
}
export {
createSpotLight, refreshSpotLight,
createLightAmbient,
createLightPoint, refreshLightPoint
};