Skip to content

Commit

Permalink
Add option to turn off clipping (#4791)
Browse files Browse the repository at this point in the history
* add option to turn off clipping

* adjust refimg to test clip attribute

* update changelog
  • Loading branch information
ffreyer authored Feb 14, 2025
1 parent c7eb320 commit e6c3e37
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
- Fixed issue with `WGLMakie.voxels` not rendering on linux with firefox [#4756](https://github.com/MakieOrg/Makie.jl/pull/4756)
- Cleaned up surface handling in GLMakie: Surface cells are now discarded when there is a nan in x, y or z. Fixed incorrect normal if x or y is nan [#4735](https://github.com/MakieOrg/Makie.jl/pull/4735)
- Cleaned up `volume` plots: Added `:indexedabsorption` and `:additive` to WGLMakie, generalized `:mip` to include negative values, fixed missing conversions for rgba algorithms (`:additive`, `:absorptionrgba`), fixed missing conversion for `absorption` attribute & extended it to `:indexedabsorption` and `absorptionrgba`, added tests and improved docs. [#4726](https://github.com/MakieOrg/Makie.jl/pull/4726)
- Added `Axis3.clip` attribute to allow turning off clipping [#4791](https://github.com/MakieOrg/Makie.jl/pull/4791)
- Fixed `Plane(Vec{N, T}(0), dist)` producing a `NaN` normal, which caused WGLMakie to break. (E.g. when rotating Axis3) [#4772](https://github.com/MakieOrg/Makie.jl/pull/4772)

## [0.22.1] - 2025-01-17
Expand Down
9 changes: 8 additions & 1 deletion ReferenceTests/src/tests/figures_and_makielayout.jl
Original file line number Diff line number Diff line change
Expand Up @@ -406,13 +406,20 @@ end
m = GeometryBasics.mesh(Point3f.(ps), _fs, normal = face_normals(ps, _fs))

# Should create closed square and hexagonal cells
f = Figure()
f = Figure(size = (600, 300))
a = Axis3(f[1, 1], aspect = :data,
xautolimitmargin=(0,0), yautolimitmargin=(0,0), zautolimitmargin=(0,0)
)
lines!(a, ls, linewidth = 3, transparency = true)
mesh!(a, m, color = (:orange, 0.2), transparency = true)
scatter!(a, ps, markersize = 30, transparency = true)

a = Axis3(f[1, 2], aspect = :data, clip = false,
xautolimitmargin=(0,0), yautolimitmargin=(0,0), zautolimitmargin=(0,0)
)
lines!(a, ls, linewidth = 3, transparency = true)
mesh!(a, m, color = (:orange, 0.2), transparency = true)
meshscatter!(a, ps, markersize = 0.15, transparency = false)
f
end

Expand Down
14 changes: 9 additions & 5 deletions src/makielayout/blocks/axis3d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,15 @@ function initialize_block!(ax::Axis3)
ax.scene = scene
cam = Axis3Camera()
cameracontrols!(scene, cam)
scene.theme.clip_planes = map(scene, scene.transformation.model, ax.finallimits) do model, lims
_planes = planes(lims)
_planes = apply_transform.(Ref(model), _planes)
nudge = 1f0 + 1f-5 # clip slightly outside to avoid float precision issues with 0 margin
return map(plane -> Plane3f(plane.normal, nudge * plane.distance), _planes)
scene.theme.clip_planes = map(scene, scene.transformation.model, ax.finallimits, ax.clip) do model, lims, clip
if clip
_planes = planes(lims)
_planes = apply_transform.(Ref(model), _planes)
nudge = 1f0 + 1f-5 # clip slightly outside to avoid float precision issues with 0 margin
return map(plane -> Plane3f(plane.normal, nudge * plane.distance), _planes)
else
return Plane3f[]
end
end

mi1 = Observable(!(pi/2 <= mod1(ax.azimuth[], 2pi) < 3pi/2))
Expand Down
2 changes: 2 additions & 0 deletions src/makielayout/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1679,6 +1679,8 @@ end
a whole with `control + right drag`.
"""
viewmode = :fitzoom # :fit :fitzoom :stretch
"Controls whether content is clipped at the axis frame. Note that you can also overwrite clipping per plot by setting `clip_planes = Plane3f[]`."
clip::Bool = true
"The background color"
backgroundcolor = :transparent
"The x label"
Expand Down

0 comments on commit e6c3e37

Please sign in to comment.