From 53b2361e2ba322afe949ee66e3d63ddee0ba4f5c Mon Sep 17 00:00:00 2001 From: adrien Date: Tue, 24 Mar 2026 01:29:44 +0100 Subject: [PATCH] merge space and retro themes --- jsm/Menu.js | 2 +- jsm/TetraScene.js | 14 ++------------ jsm/Tetrominoes.js | 44 +++++++++++++++++++++++++++----------------- jsm/Vortex.js | 6 ------ 4 files changed, 30 insertions(+), 36 deletions(-) diff --git a/jsm/Menu.js b/jsm/Menu.js index f187d9b..9f3c0ae 100644 --- a/jsm/Menu.js +++ b/jsm/Menu.js @@ -26,7 +26,7 @@ export class Menu extends GUI { this.settings = this.addFolder("Options") this.settings.add(settings, "startLevel").name("Niveau initial").min(1).max(15).step(1) - this.settings.add(settings, "theme", ["Plasma", "Space", "Retro"]).name("Thème").onChange(theme => { + this.settings.add(settings, "theme", ["Plasma", "Space"]).name("Thème").onChange(theme => { scene.theme = theme if (dev) changeMaterial() }) diff --git a/jsm/TetraScene.js b/jsm/TetraScene.js index 6d050af..2a01556 100644 --- a/jsm/TetraScene.js +++ b/jsm/TetraScene.js @@ -81,22 +81,12 @@ export class TetraScene extends THREE.Scene { this.playfield.retroEdge.visible = false break case "Space": - this.ambientLight.intensity = 5 - this.directionalLight.intensity = 10 + this.ambientLight.intensity = 2 + this.directionalLight.intensity = 1 this.directionalLight.position.set(2, 15, 20) this.music.src = "audio/benevolence.m4a" this.background = new THREE.Color(0x000000) this.fog.color.set(0x000000) - this.playfield.edge.visible = true - this.playfield.retroEdge.visible = false - break - case "Retro": - this.ambientLight.intensity = 1 - this.directionalLight.intensity = 10 - this.directionalLight.position.set(19, 120, 200) - this.music.src = "audio/Tetris_MkVaffQuasi_Ultimix_OC_ReMix.mp3" - this.background = new THREE.Color(0x000000) - this.fog.color.set(0x000000) this.playfield.edge.visible = false this.playfield.retroEdge.visible = true break diff --git a/jsm/Tetrominoes.js b/jsm/Tetrominoes.js index 7df1d07..8f1a62f 100644 --- a/jsm/Tetrominoes.js +++ b/jsm/Tetrominoes.js @@ -79,7 +79,7 @@ export class InstancedMino extends THREE.InstancedMesh { } set theme(theme) { - if (theme == "Retro") { + if (theme == "Space") { this.resetColor() this.update = this.updateOffset if (this.materials["Retro"]) { @@ -94,8 +94,10 @@ export class InstancedMino extends THREE.InstancedMesh { map: texture, bumpMap: texture, bumpScale: 1.5, - roughness: 0.25, - metalness: 0.9, + envMap: environment, + envMapIntensity: 5, + roughness: 0.07, + metalness: 1, transparent: true, }, 8, 8) }) @@ -108,8 +110,10 @@ export class InstancedMino extends THREE.InstancedMesh { map: texture, bumpMap: texture, bumpScale: 1.5, - roughness: 0.25, - metalness: 0.9, + envMap: environment, + envMapIntensity: 5, + roughness: 0.07, + metalness: 1, transparent: true, }, 1, 1) }) @@ -164,9 +168,9 @@ InstancedMino.prototype.materials = { envMap: environment, side: THREE.DoubleSide, transparent: true, - opacity: 0.55, - roughness: 0.5, - metalness: 0.9, + opacity: 0.6, + roughness: 0.1, + metalness: 0.95, }), Space: new THREE.MeshStandardMaterial({ envMap: environment, @@ -483,8 +487,8 @@ class Playfield extends THREE.Group { .lineTo(COLUMNS, 0) .lineTo(COLUMNS, SKYLINE) .lineTo(COLUMNS + 1, SKYLINE) - .lineTo(COLUMNS + 1, -1/3) - .lineTo(-1, -1/3) + .lineTo(COLUMNS + 1, -1) + .lineTo(-1, -1) .moveTo(-1, SKYLINE) const retroEdgeTexture = new THREE.TextureLoader(loadingManager).load("images/edge.png", (texture) => { texture.wrapS = THREE.RepeatWrapping @@ -494,9 +498,11 @@ class Playfield extends THREE.Group { color: COLORS.RETRO, map: retroEdgeTexture, bumpMap: retroEdgeTexture, + envMap: environment, + envMapIntensity: 5, bumpScale: 1.5, - roughness: 0.25, - metalness: 0.8, + roughness: 0.07, + metalness: 1 }) this.retroEdge = new THREE.Mesh( new THREE.ExtrudeGeometry(retroEdgeShape, { @@ -506,11 +512,15 @@ class Playfield extends THREE.Group { [retroEdgeMaterial, sideMaterial, sideMaterial, sideMaterial, sideMaterial, sideMaterial], ) const back = new THREE.Mesh( - new THREE.PlaneGeometry(COLUMNS, SKYLINE), - new THREE.MeshStandardMaterial({ - color: 0xc5d0a1, - roughness: 0.1, - metalness: 0.9, + new THREE.PlaneGeometry(COLUMNS, SKYLINE), + new THREE.MeshStandardMaterial({ + color: 0xc5d0a1, + envMap: environment, + envMapIntensity: 5, + roughness: 0.1, + metalness: 0.9, + opacity: 0.1, + transparent: true }) ) back.position.set(COLUMNS/2, SKYLINE/2) diff --git a/jsm/Vortex.js b/jsm/Vortex.js index 276de67..805caab 100644 --- a/jsm/Vortex.js +++ b/jsm/Vortex.js @@ -93,12 +93,6 @@ export class Vortex extends THREE.Group { this.visible = true break - - case "Retro": - this.remove(this.transparentCylinder) - this.remove(this.opaqueCylinder) - this.visible = false - break } }