roundedBox for every themes

This commit is contained in:
2026-01-25 12:50:13 +01:00
parent 1e7d29d6e3
commit 1227a93475
4 changed files with 12 additions and 27 deletions

4
app.js
View File

@@ -135,7 +135,7 @@ let game = {
window.onblur = null window.onblur = null
renderer.domElement.onfocus = null renderer.domElement.onfocus = null
menu.settings.domElement.onfocus = null menu.settings.domElement.onfocus = null
game.playing = false this.playing = false
scene.music.pause() scene.music.pause()
stats.clock.stop() stats.clock.stop()
messagesSpan.addNewChild("div", { className: "show-level-animation", innerHTML: `<h1>GAME<br/>OVER</h1>` }) messagesSpan.addNewChild("div", { className: "show-level-animation", innerHTML: `<h1>GAME<br/>OVER</h1>` })
@@ -347,5 +347,5 @@ window.addEventListener("resize", () => {
window.onbeforeunload = function (event) { window.onbeforeunload = function (event) {
menu.save() menu.save()
localStorage["teTraHighScore"] = stats.highScore localStorage["teTraHighScore"] = stats.highScore
return !game.playing if (game.playing) return false;
} }

View File

@@ -47,8 +47,8 @@ export class TetraScene extends THREE.Scene {
set theme(theme) { set theme(theme) {
switch (theme) { switch (theme) {
case "Plasma": case "Plasma":
this.ambientLight.intensity = 0.6 this.ambientLight.intensity = 0
this.directionalLight.intensity = 11 this.directionalLight.intensity = 1.75
this.directionalLight.position.set(5, -20, 20) this.directionalLight.position.set(5, -20, 20)
break break
case "Espace": case "Espace":

View File

@@ -75,23 +75,6 @@ export class InstancedMino extends THREE.InstancedMesh {
const roundedBoxGeometry = new RoundedBoxGeometry(1.03, 1.03, 1.03, 4, 0.15) const roundedBoxGeometry = new RoundedBoxGeometry(1.03, 1.03, 1.03, 4, 0.15)
roundedBoxGeometry.translate(0.5, 0.5, 0) roundedBoxGeometry.translate(0.5, 0.5, 0)
super(roundedBoxGeometry, undefined, 2*ROWS*COLUMNS) super(roundedBoxGeometry, undefined, 2*ROWS*COLUMNS)
this.roundedBoxGeometry = roundedBoxGeometry
let minoFaceShape = new THREE.Shape()
minoFaceShape.moveTo(.1, .1)
minoFaceShape.lineTo(.1, .9)
minoFaceShape.lineTo(.9, .9)
minoFaceShape.lineTo(.9, .1)
minoFaceShape.lineTo(.1, .1)
let minoExtrudeSettings = {
steps: 1,
depth: .8,
bevelEnabled: true,
bevelThickness: .1,
bevelSize: .1,
bevelOffset: 0,
bevelSegments: 1
}
this.extrudeGeometry = new THREE.ExtrudeGeometry(minoFaceShape, minoExtrudeSettings)
this.offsets = new Uint8Array(2*this.count) this.offsets = new Uint8Array(2*this.count)
} }
@@ -99,14 +82,14 @@ export class InstancedMino extends THREE.InstancedMesh {
if (theme == "Rétro") { if (theme == "Rétro") {
this.resetColor() this.resetColor()
this.update = this.updateOffset this.update = this.updateOffset
this.geometry = this.extrudeGeometry
if (this.materials["Rétro"]) { if (this.materials["Rétro"]) {
this.material = this.materials["Rétro"] this.material = this.materials["Rétro"]
} else { } else {
this.materials["Rétro"] = [] this.materials["Rétro"] = []
const loadingManager = new THREE.LoadingManager(() => this.material = this.materials["Rétro"]) const loadingManager = new THREE.LoadingManager(() => this.material = this.materials["Rétro"])
new THREE.TextureLoader(loadingManager).load("images/sprites.png", (texture) => { new THREE.TextureLoader(loadingManager).load("images/sprites.png", (texture) => {
this.materials.Rétro[0] = this.materials.Rétro[2] = new TileMaterial({ this.materials.Rétro[4] =
this.materials.Rétro[5] = new TileMaterial({
color: COLORS.RETRO, color: COLORS.RETRO,
map: texture, map: texture,
bumpMap: texture, bumpMap: texture,
@@ -117,7 +100,10 @@ export class InstancedMino extends THREE.InstancedMesh {
}, 8, 8) }, 8, 8)
}) })
new THREE.TextureLoader(loadingManager).load("images/edges.png", (texture) => { new THREE.TextureLoader(loadingManager).load("images/edges.png", (texture) => {
this.materials.Rétro[1] = this.materials.Rétro[3] = this.materials.Rétro[4] = this.materials.Rétro[5] = new TileMaterial({ this.materials.Rétro[0] =
this.materials.Rétro[1] =
this.materials.Rétro[2] =
this.materials.Rétro[3] = new TileMaterial({
color: COLORS.RETRO, color: COLORS.RETRO,
map: texture, map: texture,
bumpMap: texture, bumpMap: texture,
@@ -129,7 +115,6 @@ export class InstancedMino extends THREE.InstancedMesh {
}) })
} }
} else { } else {
this.geometry = this.roundedBoxGeometry
this.update = this.updateColor this.update = this.updateColor
this.material = this.materials[theme] this.material = this.materials[theme]
} }

View File

@@ -47,7 +47,7 @@ export class Vortex extends THREE.Group {
texture.repeat.set(1, 2) texture.repeat.set(1, 2)
this.darkCylinder.material.map = texture this.darkCylinder.material.map = texture
}) })
this.darkCylinder.material.opacity = 0.05 this.darkCylinder.material.opacity = 0.14
new THREE.TextureLoader(this.loadingManager).load("./images/plasma2.jpg", texture => { new THREE.TextureLoader(this.loadingManager).load("./images/plasma2.jpg", texture => {
texture.wrapS = THREE.RepeatWrapping texture.wrapS = THREE.RepeatWrapping
@@ -55,7 +55,7 @@ export class Vortex extends THREE.Group {
texture.repeat.set(2, 2) texture.repeat.set(2, 2)
this.colorFullCylinder.material.map = texture this.colorFullCylinder.material.map = texture
}) })
this.colorFullCylinder.material.opacity = 0.8 this.colorFullCylinder.material.opacity = 0.6
this.globalRotation = 0.028 this.globalRotation = 0.028
this.darkTextureRotation = 0.005 this.darkTextureRotation = 0.005