pause on fullscreen exit

This commit is contained in:
2026-03-26 20:58:56 +01:00
parent 27978c2b32
commit 18d302732c
4 changed files with 17 additions and 15 deletions

11
app.js
View File

@@ -148,19 +148,20 @@ let game = {
fullscreen: function() { fullscreen: function() {
if (document.fullscreenElement) { if (document.fullscreenElement) {
if (document.exitFullscreen) { if (document.exitFullscreen) {
document.exitFullscreen(); document.exitFullscreen()
} }
} else { } else {
document.body.requestFullscreen(); document.body.requestFullscreen()
} }
} }
} }
document.onfullscreenchange = function() { document.onfullscreenchange = function() {
if (document.fullscreenElement) { if (document.fullscreenElement) {
menu.settings.fullscreenButton.name("Quitter le plein écran"); menu.settings.fullscreenButton.name("Quitter le plein écran")
} else { } 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( let loadingManager = new THREE.LoadingManager(
function() { function() {
loadingDiv.style.display = "none" loadingDiv.style.display = "none"
menu.startButton.show() if (!game.playing) menu.startButton.show()
scene.renderer.setAnimationLoop(animate) scene.renderer.setAnimationLoop(animate)
}, },
function (url, itemsLoaded, itemsTotal) { function (url, itemsLoaded, itemsTotal) {

View File

@@ -111,6 +111,7 @@ export class Menu extends GUI {
}) })
let minoMaterial = scene.minoes.material instanceof Array ? scene.minoes.material[0] : scene.minoes.material 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 ("opacity" in minoMaterial) material.add(minoMaterial, "opacity" ).min(0).max(1)
if ("reflectivity" in minoMaterial) material.add(minoMaterial, "reflectivity" ).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) if ("roughness" in minoMaterial) material.add(minoMaterial, "roughness" ).min(0).max(1)

View File

@@ -66,8 +66,8 @@ export class TetraScene extends THREE.Scene {
}.bind(this)) }.bind(this))
this.floorSound = new THREE.Audio(listener) this.floorSound = new THREE.Audio(listener)
audioLoader.load('audio/floor.ogg', function( buffer ) { audioLoader.load('audio/floor.ogg', function( buffer ) {
this.floorSoung.setBuffer(buffer) this.floorSound.setBuffer(buffer)
this.floorSoung.setVolume(settings.sfxVolume/100) this.floorSound.setVolume(settings.sfxVolume/100)
}.bind(this)) }.bind(this))
this.moveSound = new THREE.Audio(listener) this.moveSound = new THREE.Audio(listener)
audioLoader.load('audio/move.ogg', function( buffer ) { audioLoader.load('audio/move.ogg', function( buffer ) {
@@ -93,7 +93,7 @@ export class TetraScene extends THREE.Scene {
case "Plasma": case "Plasma":
this.ambientLight.intensity = 1 this.ambientLight.intensity = 1
this.directionalLight.intensity = 3 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.music.src = "audio/Moon-Over-Moscow-DJ-ResiDance-Mix-2022.mp3"
this.background = new THREE.Color(0xffffff) this.background = new THREE.Color(0xffffff)
this.fog.color.set(0xffffff) this.fog.color.set(0xffffff)
@@ -103,7 +103,7 @@ export class TetraScene extends THREE.Scene {
case "Space": case "Space":
this.ambientLight.intensity = 3 this.ambientLight.intensity = 3
this.directionalLight.intensity = 10 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.music.src = "audio/benevolence.m4a"
this.background = new THREE.Color(0x000000) this.background = new THREE.Color(0x000000)
this.fog.color.set(0x000000) this.fog.color.set(0x000000)

View File

@@ -93,7 +93,7 @@ export class InstancedMino extends THREE.InstancedMesh {
color: COLORS.RETRO, color: COLORS.RETRO,
map: texture, map: texture,
bumpMap: texture, bumpMap: texture,
bumpScale: 5, bumpScale: 1,
envMap: environment, envMap: environment,
envMapIntensity: 5, envMapIntensity: 5,
roughness: 0.03, roughness: 0.03,
@@ -109,7 +109,7 @@ export class InstancedMino extends THREE.InstancedMesh {
color: COLORS.RETRO, color: COLORS.RETRO,
map: texture, map: texture,
bumpMap: texture, bumpMap: texture,
bumpScale: 5, bumpScale: 1,
envMap: environment, envMap: environment,
envMapIntensity: 5, envMapIntensity: 5,
roughness: 0.03, roughness: 0.03,
@@ -170,7 +170,7 @@ InstancedMino.prototype.materials = {
transparent: true, transparent: true,
opacity: 0.66, opacity: 0.66,
roughness: 0.1, roughness: 0.1,
metalness: 0.95, metalness: 0.6,
onBeforeCompile: shader => { onBeforeCompile: shader => {
shader.vertexShader = ` shader.vertexShader = `
varying vec3 vPos; varying vec3 vPos;
@@ -478,8 +478,8 @@ class Playfield extends THREE.Group {
.lineTo(COLUMNS, 0) .lineTo(COLUMNS, 0)
.lineTo(COLUMNS, SKYLINE) .lineTo(COLUMNS, SKYLINE)
.lineTo(COLUMNS + 1, SKYLINE) .lineTo(COLUMNS + 1, SKYLINE)
.lineTo(COLUMNS + 1, -1) .lineTo(COLUMNS + 1, -6/8)
.lineTo(-1, -1) .lineTo(-1, -6/8)
.moveTo(-1, SKYLINE) .moveTo(-1, SKYLINE)
const retroEdgeTexture = new THREE.TextureLoader(loadingManager).load("images/edge.png", (texture) => { const retroEdgeTexture = new THREE.TextureLoader(loadingManager).load("images/edge.png", (texture) => {
texture.wrapS = THREE.RepeatWrapping texture.wrapS = THREE.RepeatWrapping
@@ -489,7 +489,7 @@ class Playfield extends THREE.Group {
color: COLORS.RETRO, color: COLORS.RETRO,
map: retroEdgeTexture, map: retroEdgeTexture,
bumpMap: retroEdgeTexture, bumpMap: retroEdgeTexture,
bumpScale: 5, bumpScale: 1,
envMap: environment, envMap: environment,
envMapIntensity: 5, envMapIntensity: 5,
roughness: 0.03, roughness: 0.03,