Skip to content

Commit b4f7953

Browse files
committed
docs(voxel_grain_explorer): halve the volume (N 48 -> 24) for Pyodide
The explorer re-slices voxels + re-cuts three 2D image panels on every plane drag, which is fine natively but sluggish under Pyodide. Halving N in each dimension quarters both the per-frame on-plane voxel count (6912 -> 1728) and each 2D slice (48² -> 24²), so dragging stays responsive in the browser. Still above the ~1k voxel threshold, so the WebGPU render path is retained. Comments updated for the new counts. Claude-Session: https://claude.ai/code/session_018MLraeaoQBWFDScg72W41h
1 parent c98891f commit b4f7953

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

Examples/Interactive/plot_voxel_grain_explorer.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
rng = np.random.default_rng(11)
3030

3131
# ── 1. Synthetic 3-D polycrystal: nearest-seed voxel grain map ──────────────
32-
N = 48 # volume is N³ voxels, indexed V[z, y, x]
32+
N = 24 # volume is N³ voxels, indexed V[z, y, x]
3333
N_GRAINS = 40
3434

3535
seeds = rng.uniform(0, N, size=(N_GRAINS, 3)) # (z, y, x)
@@ -76,7 +76,8 @@ def random_rotations(n):
7676
# planes. This anchors the highlight exactly where the slices intersect,
7777
# shows real slice contents in 3-D, and scales: the on-plane count is
7878
# ~3·(N/step)² regardless of N, so it stays fast even for a 256³ volume.
79-
VSTEP = max(1, N // 48) # in-plane downsample → ~48² cubes per plane
79+
VSTEP = max(1, N // 48) # in-plane downsample, capping at ~48² cubes/plane
80+
# for large N (no downsampling at this N=24)
8081

8182
# Voxel cube size in data units. A touch larger than VSTEP so the three
8283
# slabs read as solid sheets rather than a dotted grid.
@@ -140,7 +141,7 @@ def slice_voxels(ix, iy, iz):
140141
size=VOXSIZE, alpha=0.55,
141142
x_label="x", y_label="y", z_label="z",
142143
bounds=((0, N - 1),) * 3, zoom=1.1,
143-
# gpu="auto" (default): ~7k cubes is over the ~1k voxel threshold, so the
144+
# gpu="auto" (default): ~1.7k cubes is over the ~1k voxel threshold, so the
144145
# WebGPU instanced path handles each drag re-slice when WebGPU is present.
145146
)
146147
v_vol.set_title("Grain volume — drag a plane to re-slice")

0 commit comments

Comments
 (0)