From 18d302732cc866c1b6e223bb95201266b63bc983 Mon Sep 17 00:00:00 2001 From: adrien Date: Thu, 26 Mar 2026 20:58:56 +0100 Subject: [PATCH] pause on fullscreen exit --- app.js | 11 ++++++----- jsm/Menu.js | 1 + jsm/TetraScene.js | 8 ++++---- jsm/Tetrominoes.js | 12 ++++++------ 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/app.js b/app.js index 57e4a00..142c454 100644 --- a/app.js +++ b/app.js @@ -148,19 +148,20 @@ let game = { fullscreen: function() { if (document.fullscreenElement) { if (document.exitFullscreen) { - document.exitFullscreen(); + document.exitFullscreen() } } else { - document.body.requestFullscreen(); + document.body.requestFullscreen() } } } document.onfullscreenchange = function() { if (document.fullscreenElement) { - menu.settings.fullscreenButton.name("Quitter le plein écran"); + menu.settings.fullscreenButton.name("Quitter le plein écran") } else { - menu.settings.fullscreenButton.name("Plein écran"); + menu.settings.fullscreenButton.name("Plein écran") + game.pause() } } @@ -292,7 +293,7 @@ function resumeOnKeyDown(event) { let loadingManager = new THREE.LoadingManager( function() { loadingDiv.style.display = "none" - menu.startButton.show() + if (!game.playing) menu.startButton.show() scene.renderer.setAnimationLoop(animate) }, function (url, itemsLoaded, itemsTotal) { diff --git a/jsm/Menu.js b/jsm/Menu.js index 9f3c0ae..0ccb247 100644 --- a/jsm/Menu.js +++ b/jsm/Menu.js @@ -111,6 +111,7 @@ export class Menu extends GUI { }) let minoMaterial = scene.minoes.material instanceof Array ? scene.minoes.material[0] : scene.minoes.material + if ("color" in minoMaterial) material.addColor(minoMaterial, "color" ) if ("opacity" in minoMaterial) material.add(minoMaterial, "opacity" ).min(0).max(1) if ("reflectivity" in minoMaterial) material.add(minoMaterial, "reflectivity" ).min(0).max(1) if ("roughness" in minoMaterial) material.add(minoMaterial, "roughness" ).min(0).max(1) diff --git a/jsm/TetraScene.js b/jsm/TetraScene.js index c6dc1b7..9ce2d11 100644 --- a/jsm/TetraScene.js +++ b/jsm/TetraScene.js @@ -66,8 +66,8 @@ export class TetraScene extends THREE.Scene { }.bind(this)) this.floorSound = new THREE.Audio(listener) audioLoader.load('audio/floor.ogg', function( buffer ) { - this.floorSoung.setBuffer(buffer) - this.floorSoung.setVolume(settings.sfxVolume/100) + this.floorSound.setBuffer(buffer) + this.floorSound.setVolume(settings.sfxVolume/100) }.bind(this)) this.moveSound = new THREE.Audio(listener) audioLoader.load('audio/move.ogg', function( buffer ) { @@ -93,7 +93,7 @@ export class TetraScene extends THREE.Scene { case "Plasma": this.ambientLight.intensity = 1 this.directionalLight.intensity = 3 - this.directionalLight.position.set(5, -20, -10) + this.directionalLight.position.set(5, 50, -20) this.music.src = "audio/Moon-Over-Moscow-DJ-ResiDance-Mix-2022.mp3" this.background = new THREE.Color(0xffffff) this.fog.color.set(0xffffff) @@ -103,7 +103,7 @@ export class TetraScene extends THREE.Scene { case "Space": this.ambientLight.intensity = 3 this.directionalLight.intensity = 10 - this.directionalLight.position.set(2, 15, 20) + this.directionalLight.position.set(2, 15, -20) this.music.src = "audio/benevolence.m4a" this.background = new THREE.Color(0x000000) this.fog.color.set(0x000000) diff --git a/jsm/Tetrominoes.js b/jsm/Tetrominoes.js index 3a200e6..64caee9 100644 --- a/jsm/Tetrominoes.js +++ b/jsm/Tetrominoes.js @@ -93,7 +93,7 @@ export class InstancedMino extends THREE.InstancedMesh { color: COLORS.RETRO, map: texture, bumpMap: texture, - bumpScale: 5, + bumpScale: 1, envMap: environment, envMapIntensity: 5, roughness: 0.03, @@ -109,7 +109,7 @@ export class InstancedMino extends THREE.InstancedMesh { color: COLORS.RETRO, map: texture, bumpMap: texture, - bumpScale: 5, + bumpScale: 1, envMap: environment, envMapIntensity: 5, roughness: 0.03, @@ -170,7 +170,7 @@ InstancedMino.prototype.materials = { transparent: true, opacity: 0.66, roughness: 0.1, - metalness: 0.95, + metalness: 0.6, onBeforeCompile: shader => { shader.vertexShader = ` varying vec3 vPos; @@ -478,8 +478,8 @@ class Playfield extends THREE.Group { .lineTo(COLUMNS, 0) .lineTo(COLUMNS, SKYLINE) .lineTo(COLUMNS + 1, SKYLINE) - .lineTo(COLUMNS + 1, -1) - .lineTo(-1, -1) + .lineTo(COLUMNS + 1, -6/8) + .lineTo(-1, -6/8) .moveTo(-1, SKYLINE) const retroEdgeTexture = new THREE.TextureLoader(loadingManager).load("images/edge.png", (texture) => { texture.wrapS = THREE.RepeatWrapping @@ -489,7 +489,7 @@ class Playfield extends THREE.Group { color: COLORS.RETRO, map: retroEdgeTexture, bumpMap: retroEdgeTexture, - bumpScale: 5, + bumpScale: 1, envMap: environment, envMapIntensity: 5, roughness: 0.03,