Skip to content

Commit e4d8c53

Browse files
committed
fix call stack error in genChunkGeo
1 parent 9abacde commit e4d8c53

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

src/scripts/world/ChunkMesher.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -272,11 +272,7 @@ class ChunkMesher {
272272
if (mainBlock.boundingBox === 'block') {
273273
for (const side in neighbours) {
274274
const nBlock = neighbours[side]
275-
if (mainBlock.transparent) {
276-
if (nBlock.boundingBox !== 'block') {
277-
this.addFace(tVertexBuffer, VertexBuffer, side, pos)
278-
}
279-
} else if (nBlock.boundingBox !== 'block' || nBlock.transparent) {
275+
if ((mainBlock.transparent && nBlock.boundingBox !== 'block') || (nBlock.boundingBox !== 'block' || nBlock.transparent)) {
280276
this.addFace(tVertexBuffer, VertexBuffer, side, pos)
281277
}
282278
}
@@ -290,11 +286,14 @@ class ChunkMesher {
290286
}
291287
}
292288
}
293-
294-
VertexBuffer.positions.push(...tVertexBuffer.positions)
295-
VertexBuffer.normals.push(...tVertexBuffer.normals)
296-
VertexBuffer.uvs.push(...tVertexBuffer.uvs)
297-
VertexBuffer.colors.push(...tVertexBuffer.colors)
289+
for (let i = 0; i < tVertexBuffer.positions.length; i++) {
290+
VertexBuffer.positions.push(tVertexBuffer.positions[i])
291+
VertexBuffer.normals.push(tVertexBuffer.normals[i])
292+
VertexBuffer.colors.push(tVertexBuffer.colors[i])
293+
}
294+
for (let i = 0; i < tVertexBuffer.uvs.length; i++) {
295+
VertexBuffer.uvs.push(tVertexBuffer.uvs[i])
296+
}
298297
return VertexBuffer
299298
}
300299
}

src/scripts/world/chunk.worker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ class TerrainManager {
128128
loop () {
129129
this.removeChunks()
130130
this.genNearestChunk()
131-
self.requestAnimationFrame(() => {
131+
requestAnimationFrame(() => {
132132
this.loop()
133133
})
134134
}

0 commit comments

Comments
 (0)