instancedMesh.count

This commit is contained in:
Adrien MALINGREY 2023-07-13 21:05:40 +02:00
parent 5a85c0cae2
commit 75f70a1bac
2 changed files with 3 additions and 8 deletions

View File

@ -12,19 +12,18 @@ export default class MazeMesh extends THREE.InstancedMesh {
this.map = new Array(length).fill().map(() => new Array(width).fill(1)) this.map = new Array(length).fill().map(() => new Array(width).fill(1))
this.start = new THREE.Vector3(width/2, .1, length/2) this.start = new THREE.Vector3(width/2, .1, length/2)
this.exit = new THREE.Vector3(Math.floor(width/2), 0, 1) this.exit = new THREE.Vector3(Math.floor(width/2), 0, 1)
this.count = length * width - 2
this.dig(this.exit) this.dig(this.exit)
this.dig(new THREE.Vector3(Math.floor(width/2), 0, 0)) this.dig(new THREE.Vector3(Math.floor(width/2), 0, 0))
this.build ( this.exit ) this.build ( this.exit )
let matrix = new THREE.Matrix4() let matrix = new THREE.Matrix4()
let i=0 this.count = 0
this.map.forEach((row, z) => { this.map.forEach((row, z) => {
row.forEach((isWall, x) => { row.forEach((isWall, x) => {
if (isWall) { if (isWall) {
matrix.setPosition( x + .5 - width/2, 0.5, z + .5 - length/2) matrix.setPosition( x + .5 - width/2, 0.5, z + .5 - length/2)
this.setMatrixAt( i, matrix ); this.setMatrixAt( this.count, matrix );
i++ this.count++
} }
}) })
}) })

View File

@ -322,8 +322,6 @@ const raftFaceMaterial = new THREE.MeshStandardMaterial({
roughnessMap: woodTexture, roughnessMap: woodTexture,
color: 0xFFFFFF, color: 0xFFFFFF,
emissive: 0, emissive: 0,
specular: 0x505050,
shininess: 1,
bumpMap: woodTexture, bumpMap: woodTexture,
bumpScale: .1, bumpScale: .1,
depthFunc: 3, depthFunc: 3,
@ -338,8 +336,6 @@ const raftSideMaterial = new THREE.MeshStandardMaterial({
roughnessMap: woodTexture, roughnessMap: woodTexture,
color: 0xFFFFFF, color: 0xFFFFFF,
emissive: 0, emissive: 0,
specular: 0x505050,
shininess: 1,
bumpMap: woodTexture, bumpMap: woodTexture,
bumpScale: .1, bumpScale: .1,
depthFunc: 3, depthFunc: 3,