Closed danieljfarrell closed 5 years ago
Hi @danieljfarrell,
I'm also interested in such a feature. As far as I can see, meshcat-python doesn't provide such an API. However, Three.js supports transparent objects, so it can be added quite easily. This
patch adds a transparency
and opacity
field to the MeshMaterial object for configuring these properties.
So the following code
import meshcat
visualizer = meshcat.visualizer.Visualizer()
sphere = meshcat.geometry.Sphere(1.0)
material = meshcat.geometry.MeshLambertMaterial()
material.transparency = True
material.opacity = 0.5
visualizer["sphere"].set_object(sphere, material)
renders a transparent sphere:
@rdeits Do you confirm this isn't currently possible with meshcat? If so, I can make a PR with this patch.
Would be really interested in knowing how you solved this problem. Would you upload your fork to GitHub?
@danieljfarrell Sure! There isn't anything more than what was in the patch, it's just a few lines of code to have meshcat communicate an extra attribute to Three.js FYI, I found the information about transparency in Three.js in the doc: https://threejs.org/docs/#api/en/materials/Material.opacity
I just created a PR for this issue.
Oh sorry! Missed the link to the patch in the original comment.
Ok, this should now be available in meshcat v0.0.15. You should be able to pip install --upgrade meshcat
to get the newest version. Thank you @matthieuvigne for the PR!
It is possible to render objects as semi-transparent so that the interior remains visible? Or another alternative could be wireframing objects. I can see the different material classes in
geometry.py
such asMeshPhongMaterial
andMeshToonMaterial
but these shaders make the surface opaque. Maybe a surface texture is the way to do this? But I'm unsure how to proceed.