Game
- Add changeBarColor - Add changePlane (all in multi)
This commit is contained in:
@ -6,7 +6,7 @@
|
|||||||
/* By: hubourge <hubourge@student.42.fr> +#+ +:+ +#+ */
|
/* By: hubourge <hubourge@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/08/18 00:53:53 by edbernar #+# #+# */
|
/* Created: 2024/08/18 00:53:53 by edbernar #+# #+# */
|
||||||
/* Updated: 2024/09/10 17:16:22 by hubourge ### ########.fr */
|
/* Updated: 2024/09/10 18:32:10 by hubourge ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -174,6 +174,11 @@ function createBarPlayer(color)
|
|||||||
return (mesh);
|
return (mesh);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function changeBarColor(bar, color)
|
||||||
|
{
|
||||||
|
bar.material.color.set(color);
|
||||||
|
}
|
||||||
|
|
||||||
function loop()
|
function loop()
|
||||||
{
|
{
|
||||||
stats.begin();
|
stats.begin();
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: hubourge <hubourge@student.42.fr> +#+ +:+ +#+ */
|
/* By: hubourge <hubourge@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/08/20 14:52:55 by hubourge #+# #+# */
|
/* Created: 2024/08/20 14:52:55 by hubourge #+# #+# */
|
||||||
/* Updated: 2024/08/29 17:52:41 by hubourge ### ########.fr */
|
/* Updated: 2024/09/10 18:27:01 by hubourge ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -64,7 +64,6 @@ class Map
|
|||||||
|
|
||||||
dispose()
|
dispose()
|
||||||
{
|
{
|
||||||
|
|
||||||
videoList.forEach(elem => {
|
videoList.forEach(elem => {
|
||||||
elem.video.pause();
|
elem.video.pause();
|
||||||
elem.video.src = '';
|
elem.video.src = '';
|
||||||
@ -161,6 +160,27 @@ class Map
|
|||||||
return (meshPlane);
|
return (meshPlane);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
changePlane(texture)
|
||||||
|
{
|
||||||
|
console.log(this.arrObject);
|
||||||
|
for (let i = 0; i < this.arrObject.length; i++)
|
||||||
|
{
|
||||||
|
if (this.arrObject[i].name == "planeBottom" || this.arrObject[i].name == "planeTop")
|
||||||
|
{
|
||||||
|
if (this.arrObject[i].mesh.material)
|
||||||
|
this.arrObject[i].mesh.material.dispose();
|
||||||
|
if (typeof(texture) == 'string')
|
||||||
|
{
|
||||||
|
let textureLoader = new THREE.TextureLoader();
|
||||||
|
texture = textureLoader.load(texture);
|
||||||
|
this.arrObject[i].mesh.material.map = texture;
|
||||||
|
}
|
||||||
|
else if (typeof(texture) == 'number')
|
||||||
|
this.arrObject[i].mesh.material.color.set(texture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#createWall(x, y, z, name)
|
#createWall(x, y, z, name)
|
||||||
{
|
{
|
||||||
let geometryWall = null;
|
let geometryWall = null;
|
||||||
@ -319,17 +339,17 @@ class Map
|
|||||||
this.#clearVideoCanvas();
|
this.#clearVideoCanvas();
|
||||||
if (nbImage <= 0)
|
if (nbImage <= 0)
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
let startIndex = 0;
|
let startIndex = 0;
|
||||||
let nbVideos = 1;
|
let nbVideos = 1;
|
||||||
path.sort(() => Math.random() - 0.5);
|
path.sort(() => Math.random() - 0.5);
|
||||||
|
|
||||||
// Create the canvas for the video
|
// Create the canvas for the video
|
||||||
videoCanvas = document.createElement('canvas');
|
videoCanvas = document.createElement('canvas');
|
||||||
ctx = videoCanvas.getContext('2d');
|
ctx = videoCanvas.getContext('2d');
|
||||||
videoCanvas.width = 100 * 2.33 * 20;
|
videoCanvas.width = 100 * 2.33 * 20;
|
||||||
videoCanvas.height = 100;
|
videoCanvas.height = 100;
|
||||||
|
|
||||||
// Get the number of videos to display
|
// Get the number of videos to display
|
||||||
if (vNameNb && typeof(vNameNb) == 'number')
|
if (vNameNb && typeof(vNameNb) == 'number')
|
||||||
nbVideos = vNameNb;
|
nbVideos = vNameNb;
|
||||||
@ -393,14 +413,14 @@ class Map
|
|||||||
requestAnimationFrame(drawVideoOnCanvas);
|
requestAnimationFrame(drawVideoOnCanvas);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the material and the banner
|
// Create the material and the banner
|
||||||
videoCanvasTexture = new THREE.CanvasTexture(videoCanvas);
|
videoCanvasTexture = new THREE.CanvasTexture(videoCanvas);
|
||||||
videoCanvasTexture.wrapS = THREE.RepeatWrapping;
|
videoCanvasTexture.wrapS = THREE.RepeatWrapping;
|
||||||
videoCanvasTexture.wrapT = THREE.RepeatWrapping;
|
videoCanvasTexture.wrapT = THREE.RepeatWrapping;
|
||||||
videoCanvasTexture.repeat.set(-1, 1);
|
videoCanvasTexture.repeat.set(-1, 1);
|
||||||
materialCanvas = new THREE.MeshBasicMaterial({ map: videoCanvasTexture, side: THREE.BackSide , transparent: true});
|
materialCanvas = new THREE.MeshBasicMaterial({ map: videoCanvasTexture, side: THREE.BackSide , transparent: true});
|
||||||
|
|
||||||
// Load the banner
|
// Load the banner
|
||||||
loader.load( '../blender/exported/banner.glb', (gltf) => {
|
loader.load( '../blender/exported/banner.glb', (gltf) => {
|
||||||
this.banner = gltf.scene.children[0];
|
this.banner = gltf.scene.children[0];
|
||||||
@ -452,7 +472,7 @@ class Map
|
|||||||
}
|
}
|
||||||
scene.remove(this.banner);
|
scene.remove(this.banner);
|
||||||
}
|
}
|
||||||
|
|
||||||
#animationGravityChanger(group, onTop)
|
#animationGravityChanger(group, onTop)
|
||||||
{
|
{
|
||||||
let geometryGC = new THREE.TorusGeometry(1.5, 0.05, 12, 24);
|
let geometryGC = new THREE.TorusGeometry(1.5, 0.05, 12, 24);
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: hubourge <hubourge@student.42.fr> +#+ +:+ +#+ */
|
/* By: hubourge <hubourge@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/08/28 12:23:48 by edbernar #+# #+# */
|
/* Created: 2024/08/28 12:23:48 by edbernar #+# #+# */
|
||||||
/* Updated: 2024/09/10 17:16:43 by hubourge ### ########.fr */
|
/* Updated: 2024/09/10 18:13:14 by hubourge ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ class Map
|
|||||||
world = new CANNON.World({
|
world = new CANNON.World({
|
||||||
gravity: new CANNON.Vec3(0, -9.81, 0),
|
gravity: new CANNON.Vec3(0, -9.81, 0),
|
||||||
});
|
});
|
||||||
ground = createGround(scene, '/textures/pastel.jpg');
|
ground = createGround(scene, 0x222222);
|
||||||
wallBottom = createWall(false);
|
wallBottom = createWall(false);
|
||||||
wallTop = createWall(true);
|
wallTop = createWall(true);
|
||||||
spotLight = new THREE.SpotLight({color: 0xffffff});
|
spotLight = new THREE.SpotLight({color: 0xffffff});
|
||||||
|
Reference in New Issue
Block a user