Skip to content

Commit

Permalink
tests & docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ffreyer committed Jan 11, 2024
1 parent 2885ae8 commit 0ccdd53
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
2 changes: 1 addition & 1 deletion MakieCore/src/basic_plots.jl
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ representation and may behave a bit differently than usual.
- `uvmap = nothing` defines a map from voxel ids (and optionally sides) to uv coordinates. These uv coordinates are then
used to sample a 2D texture passed through `color` for texture mapping.
- `interpolate = false` controls whether the texture map is sampled with interpolation (i.e. smoothly) or not (i.e. pixelated).
- `gap = 0.0` sets the gap between voxels.
- `gap = 0.0` sets the gap between adjacent voxels in units of the voxel size. This needs to be larger than 0.01 to take effect.
- `_limits`: Internal attribute for keeping track of `extrema(chunk)`.
- `_local_update`: Internal attribute for communicating updates to the backend.
Expand Down
7 changes: 6 additions & 1 deletion ReferenceTests/src/tests/primitives.jl
Original file line number Diff line number Diff line change
Expand Up @@ -538,4 +538,9 @@ end
a2, _ = voxels(fig[1,2], chunk, lowclip = :red, highclip = :red, colorrange = (1.1, 899.9), shading = NoShading)
foreach(a -> update_cam!(a.scene, Vec3f(0, 0, 40), Vec3f(0), Vec3f(0,1,0)), (a1, a2))
fig
end
end

@reference_test "Voxel - gap attribute" begin
# test direct mapping of ids to colors & upsampling of vector colormap
voxels(rand(3,3,3), gap = 0.3)
end
17 changes: 17 additions & 0 deletions docs/reference/plots/voxel.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,23 @@ f, a, p = voxels(-1..1, -1..1, -1..1, cube_with_holes, is_air = x -> !(1.65 <= x
\end{examplefigure}


#### Gap Attribute

The `gap` attribute allows you to specify a gap size between adjacent voxels.
It is given in units of the voxel size (at `gap = 0`) so that `gap = 0` creates no gaps and `gap = 1` reduces the voxel size to 0.
Note that this attribute only takes effect at values `gap > 0.01`.

\begin{examplefigure}{}
```julia
using GLMakie
GLMakie.activate!() # hide

chunk = reshape(collect(1:27), 3, 3, 3)
voxels(chunk, gap = 0.33)
```
\end{examplefigure}


#### Color and the internal representation

Voxels are represented as an `Array{UInt8, 3}` of voxel ids internally.
Expand Down
6 changes: 3 additions & 3 deletions test/primitives.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ end
f, a, p = voxels(
data,
lowclip = RGBf(1, 0, 1), highclip = RGBf(0, 1, 0),
colormap = [RGBf(0, 0, 0), RGBf(1, 1, 1)]
colormap = [RGBf(0, 0, 0), RGBf(1, 1, 1)], gap = 0.1
)

# data conversion pipeline
Expand All @@ -53,8 +53,8 @@ end
@test cc.colormap[][end] == RGBAf(0,1,0,1)

# voxels-as-meshscatter helpers
@test Makie.voxel_size(p) Vec3f(1)
ps = [Point3f(x - 3, y - 2.5, z - 2) for z in 0:3 for y in 0:4 for x in 0:5]
@test Makie.voxel_size(p) Vec3f(0.9)
ps = [Point3f(x - 2.5, y - 2.0, z - 1.5) for z in 0:3 for y in 0:4 for x in 0:5]
@test Makie.voxel_positions(p) ps
@test Makie.voxel_colors(p) == cc.colormap[][p.converted[end][][:]]
end
Expand Down

0 comments on commit 0ccdd53

Please sign in to comment.