diff --git a/docs/src/.vitepress/config.mts b/docs/src/.vitepress/config.mts index cea0b6f3..6a77ac14 100644 --- a/docs/src/.vitepress/config.mts +++ b/docs/src/.vitepress/config.mts @@ -331,6 +331,7 @@ const viteConfig = defineViteConfig({ items: [ { text: 'archimedean_spiral',link: '/examples/3d/lines3d/archimedean_spiral' }, { text: 'lines3d',link: '/examples/3d/lines3d/line3d' }, + { text: 'Filled 3d curve',link: '/examples/3d/lines3d/filled3d_curve'}, { text: 'lines_wire_contour_3d',link: '/examples/3d/lines3d/lines_wire_contour_3d' }, { text: 'wireframe_torus',link: '/examples/3d/lines3d/wireframe_torus' }, ], diff --git a/examples/3d/lines3d/filled3d_curve.jl b/examples/3d/lines3d/filled3d_curve.jl new file mode 100644 index 00000000..e12ebfd2 --- /dev/null +++ b/examples/3d/lines3d/filled3d_curve.jl @@ -0,0 +1,35 @@ +# ## Filled curve in 3d + +# From: https://discourse.julialang.org/t/fill-a-curve-in-3d/37890/8 + +using GLMakie +GLMakie.activate!() + +x = 0:0.05:3; +y = 0:0.05:3; +z = @. sin(x) * exp(-(x+y)) + +fig = Figure(; size=(600, 400)) +ax = Axis3(fig[1,1]; limits=((0,3), (0,3), (0,0.2)), + perspectiveness = 0.5, + azimuth = -0.5, + elevation = 0.3,) +lines!(Point3f.(x, 0, z), transparency=true) +lines!(Point3f.(0, y, z), transparency=true) +band!(Point3f.(x, y, 0), Point3f.(x, y, z); + color=(:orangered, 0.25), transparency=true) +lines!(Point3f.(x, y, z); color=(:orangered, 0.9), transparency=true) +fig + +# ## Filled gradient under 3D curve + +fig = Figure(; size=(600, 400)) +ax = Axis3(fig[1,1]; limits=((0,3), (0,3), (0,0.2)), + perspectiveness = 0.5, + azimuth = -0.5, + elevation = 0.3,) + +band!(Point3f.(x, y, 0), Point3f.(x, y, z); color = z, + colormap = (:Spectral, 0.85), transparency=true) +lines!(Point3f.(x, y, z); color=(:black, 0.9), transparency=true) +fig diff --git a/examples/3d/meshes/isosurfaces.jl b/examples/3d/meshes/isosurfaces.jl index 7eeb6f92..27911b77 100644 --- a/examples/3d/meshes/isosurfaces.jl +++ b/examples/3d/meshes/isosurfaces.jl @@ -15,11 +15,10 @@ function show_isosurface(f,h,ΞΎ; color=(:dodgerblue,0.5), isoval=100) ## generate the mesh using marching cubes - vts, fcs = isosurface(s, algo) + vts, fcs = Meshing.isosurface(s, algo) + mc = GeometryBasics.Mesh(Point3f.(vts), GeometryBasics.TriangleFace.(fcs)) - ## mc = GeometryBasics.Mesh(s, algo) - - return mesh(f, vts, map(v -> GeometryBasics.TriangleFace(v...), fcs); + return mesh(f, normal_mesh(mc); color, diffuse = Vec3f0(0.8), specular = Vec3f0(1.1), @@ -32,7 +31,7 @@ end # ### Torus -# isosurfaces for h(x,y,z)=0 +# Isosurfaces for ``h(x,y,z)=0`` torus(x,y,z; c=20, a=15) = ((hypot(x,y)-c)^2+z^2-a^2)