I am currently working on a game in JavaScript, in Three.js. I am curious if I can add a height map to the walls that I have to make them more realistic (see image). An image of the game design with the wall that is 2D.
All the tutorials that I have seen use planes instead of rectangles. I am currently using rectangles, and would rather not switch, but if there is no solution with rectangles, I would be happy to know.
I am currently using the class NewObstacle() to make my rectangles:
const wallTexture = new THREE.TextureLoader();
const wallTextureTexture = new THREE.MeshBasicMaterial({
map: wallTexture.load('wall_textures/wall_3.jfif')
})
class NewObstacle{
constructor(sizeX, sizeY, sizeZ, xPos, yPos, zPos){
this.sizeX = sizeX
this.sizeY = sizeY
this.sizeZ = sizeZ
this.xPos = xPos
this.yPos = yPos
this.zPos = zPos
}
makeCube(){
const cubeGeometry = new THREE.BoxGeometry(this.sizeX, this.sizeY, this.sizeZ)
this.box = new THREE.Mesh(cubeGeometry, /*new THREE.MeshBasicMaterial({color:
0x505050})*/wallTextureTexture)
this.box.material.transparent = true
this.box.material.opacity = 1
this.box.position.x = this.xPos
this.box.position.y = this.yPos
this.box.position.z = this.zPos
scene.add(this.box)
}
}
What is the easiest way to implement height maps?