Skip to content

Commit 3df326f

Browse files
committed
Fix surfacegrid divide by zero error
1 parent d016867 commit 3df326f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

pythreejs/pythreejs.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ def _update_surface(self, change):
7373
dx, dy = np.gradient(z, self.width/nx, self.height/ny)
7474
normals = np.dstack((-dx, -dy, np.ones_like(dx))).reshape(nx * ny, 3).astype(np.float32)
7575

76-
vmin = np.min(positions, 0)
77-
vrange = np.max(positions, 0) - vmin
78-
uvs = ((positions - vmin) / vrange)[:, :2]
76+
vmin = np.min(positions, 0)[:2]
77+
vrange = np.max(positions, 0)[:2] - vmin
78+
uvs = ((positions[:, :2] - vmin) / vrange)
7979

8080
indices = np.array(tuple(grid_indices_gen(nx, ny)), dtype=np.uint16).ravel()
8181

0 commit comments

Comments
 (0)