Skip to content

Commit

Permalink
fix boundary
Browse files Browse the repository at this point in the history
  • Loading branch information
superstar54 committed Nov 14, 2024
1 parent aabb1b4 commit 2c0a802
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/geometry/marchingCubes.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ export function marchingCubes(dims, volume, bounds, isovalue, step_size = 1) {
const scale = [0, 0, 0];
const shift = [0, 0, 0];
for (let i = 0; i < 3; ++i) {
scale[i] = (bounds[1][i] - bounds[0][i]) / dims[i];
scale[i] = (bounds[1][i] - bounds[0][i] + 1) / dims[i];
shift[i] = bounds[0][i];
}

Expand All @@ -339,9 +339,9 @@ export function marchingCubes(dims, volume, bounds, isovalue, step_size = 1) {
}

// Adjust loop bounds to include boundary cubes
for (x[0] = -step_size; x[0] < dims[0]; x[0] += step_size)
for (x[1] = -step_size; x[1] < dims[1]; x[1] += step_size)
for (x[2] = -step_size; x[2] < dims[2]; x[2] += step_size) {
for (x[0] = 0; x[0] < dims[0] + step_size; x[0] += step_size)
for (x[1] = 0; x[1] < dims[1] + step_size; x[1] += step_size)
for (x[2] = 0; x[2] < dims[2] + step_size; x[2] += step_size) {
let cube_index = 0;
for (let i = 0; i < 8; ++i) {
const v = cubeVerts[i];
Expand Down

0 comments on commit 2c0a802

Please sign in to comment.