j-fu / PlutoVista.jl

Plot library for Pluto notebooks based on plotly.js for 1D data and vtk.js (thus using WebGL) for 2/3D data.
Other
26 stars 4 forks source link

Example of 3D plot with colored blocks #8

Closed juliohm closed 1 year ago

juliohm commented 2 years ago

Suppose you have a random set of 3D blocks:

grid = CartesianGrid(100, 100, 100)

blocks = sample(grid, UniformSampling(1000))

blocks[1] # access first block (or hexahedron)

Can we use this package to create a visualization in Pluto where each block is colored according to a given variable?

j-fu commented 2 years ago

Hi, this sounds like volume rendering. If so, this is currently not supported. The vtk.js backend certainly has this possibility, so there would be a way to add this. May be DashVTK.jl can help here (but AFAIU not in a pluto notebook).

What this package can do is that you can interpolate your data onto the nodes of the hexahedra. These you can pass to the package, then you can visualize different transparent isosurface levels. For more or less smooth functions this is a good alternative to volume rendering.

juliohm commented 2 years ago

Maybe it is not volume rendering, just a scatter plot of repeated meshes with different color. That is what I do with Makie in MeshViz.jl, I simply create a prototype hexahedron and copy it all over the place with scattermesh

j-fu commented 2 years ago

Can you send me a screenshot? - Maybe I just misunderstood you.

juliohm commented 2 years ago

I am far from my work station, but the following code should do it:

using Meshes
using MeshViz

import GLMakie as Mke

grid = CartesianGrid(100, 100, 100)

blocks = sample(grid, UniformSampling(1000))

viz(blocks, color=1:1000)
j-fu commented 2 years ago

Hi, I tried it out, well, through some hoops it might be possible by supplying all cube surfaces in triangulated form with a boundary region number for each cube and a corresponding color scale for the boundary (may be this would need some fixes). No interior tets needed (not sure if this works in the moment, but that could be rather easily fixed).

juliohm commented 1 year ago

Closing the issue as not relevant in the near future.