Skip to content

Commit 20cb29e

Browse files
committed
fix call stack error
1 parent 4e4e339 commit 20cb29e

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

src/scripts/world/ChunkMesher.js

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -98,19 +98,6 @@ class ChunkMesher {
9898
for (let i = 0; i < 6; i++) {
9999
norm.push(...this.neighbours[type])
100100
}
101-
const ps = (num) => {
102-
const pt = [
103-
[-0.5, -0.5, 0.5],
104-
[0.5, -0.5, 0.5],
105-
[-0.5, 0.5, 0.5],
106-
[0.5, 0.5, 0.5],
107-
[0.5, -0.5, -0.5],
108-
[0.5, 0.5, -0.5],
109-
[-0.5, -0.5, -0.5],
110-
[-0.5, 0.5, -0.5]
111-
]
112-
return [pt[num][0] + pos[0], pt[num][1] + pos[1], pt[num][2] + pos[2]]
113-
}
114101
const px = ({
115102
pz: [0, 1, 2, 3],
116103
nx: [1, 4, 3, 5],
@@ -119,8 +106,23 @@ class ChunkMesher {
119106
py: [5, 7, 3, 2],
120107
ny: [1, 0, 4, 6]
121108
})[type]
109+
const ids = [0, 1, 2, 2, 1, 3]
110+
const posx = []
111+
const pt = [
112+
[-0.5, -0.5, 0.5],
113+
[0.5, -0.5, 0.5],
114+
[-0.5, 0.5, 0.5],
115+
[0.5, 0.5, 0.5],
116+
[0.5, -0.5, -0.5],
117+
[0.5, 0.5, -0.5],
118+
[-0.5, -0.5, -0.5],
119+
[-0.5, 0.5, -0.5]
120+
]
121+
for (let i = 0; i < ids.length; i++) {
122+
posx.push(pt[px[ids[i]]][0] + pos[0], pt[px[ids[i]]][1] + pos[1], pt[px[ids[i]]][2] + pos[2])
123+
}
122124
return {
123-
pos: [...ps(px[0]), ...ps(px[1]), ...ps(px[2]), ...ps(px[2]), ...ps(px[1]), ...ps(px[3])],
125+
pos: posx,
124126
norm,
125127
uv
126128
}

0 commit comments

Comments
 (0)