roundedBoxGeometry

This commit is contained in:
2026-01-24 01:17:42 +01:00
parent baa6a8405e
commit f9c920cff7
2 changed files with 11 additions and 6 deletions

View File

@@ -182,8 +182,7 @@ class Stats {
if (speechSynthesisAvailable && this.settings.sfxVolume) { if (speechSynthesisAvailable && this.settings.sfxVolume) {
if (tSpin) speak(tSpin, this.settings.sfxVolume); if (tSpin) speak(tSpin, this.settings.sfxVolume);
if (nbClearedLines == 4) speak(`Tétra`, this.settings.sfxVolume); if (nbClearedLines) speak(CLEARED_LINES_NAMES[nbClearedLines], this.settings.sfxVolume);
else if (nbClearedLines) speak(CLEARED_LINES_NAMES[nbClearedLines], this.settings.sfxVolume);
} }
this.goal -= awardedLineClears this.goal -= awardedLineClears

View File

@@ -1,4 +1,5 @@
import * as THREE from 'three' import * as THREE from 'three'
import { RoundedBoxGeometry } from 'three/addons/geometries/RoundedBoxGeometry.js'
import { scheduler } from './scheduler.js' import { scheduler } from './scheduler.js'
import { TileMaterial } from './TileMaterial.js' import { TileMaterial } from './TileMaterial.js'
@@ -71,6 +72,10 @@ const sideMaterial = new THREE.MeshStandardMaterial({
export class InstancedMino extends THREE.InstancedMesh { export class InstancedMino extends THREE.InstancedMesh {
constructor() { constructor() {
const roundedBoxGeometry = new RoundedBoxGeometry(1.03, 1.03, 1.03, 4, 0.15)
roundedBoxGeometry.translate(0.5, 0.5, 0)
super(roundedBoxGeometry, undefined, 2*ROWS*COLUMNS)
this.roundedBoxGeometry = roundedBoxGeometry
let minoFaceShape = new THREE.Shape() let minoFaceShape = new THREE.Shape()
minoFaceShape.moveTo(.1, .1) minoFaceShape.moveTo(.1, .1)
minoFaceShape.lineTo(.1, .9) minoFaceShape.lineTo(.1, .9)
@@ -86,8 +91,7 @@ export class InstancedMino extends THREE.InstancedMesh {
bevelOffset: 0, bevelOffset: 0,
bevelSegments: 1 bevelSegments: 1
} }
const geometry = new THREE.ExtrudeGeometry(minoFaceShape, minoExtrudeSettings) this.extrudeGeometry = new THREE.ExtrudeGeometry(minoFaceShape, minoExtrudeSettings)
super(geometry, undefined, 2*ROWS*COLUMNS)
this.offsets = new Uint8Array(2*this.count) this.offsets = new Uint8Array(2*this.count)
} }
@@ -95,6 +99,7 @@ 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 {
@@ -124,6 +129,7 @@ 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]
} }
@@ -173,8 +179,8 @@ InstancedMino.prototype.materials = {
envMap: environment, envMap: environment,
side: THREE.DoubleSide, side: THREE.DoubleSide,
transparent: true, transparent: true,
opacity: 0.7, opacity: 0.6,
roughness: 0.6, roughness: 0.3,
metalness: 1, metalness: 1,
}), }),
Espace: new THREE.MeshStandardMaterial({ Espace: new THREE.MeshStandardMaterial({