You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
add_mesh_trimesh ignores transparency from trimesh RGBA colors #525
When a trimesh.Trimesh object is created with RGBA face colors (where the alpha channel defines transparency), and then visualized using server.scene.add_mesh_trimesh, the transparency information is ignored. The resulting mesh in the viser viewer is always rendered as fully opaque.
To Reproduce
This simple script creates three trimesh cylinders. Each is assigned a color with a different alpha value for transparency. When visualized, none of them appear transparent.
#!/usr/bin/env python3"""Simple script to test transparency with trimesh objects in viser."""importviserimporttrimeshimportnumpyasnpimporttimedefmain():
"""Sets up the viser server and adds trimesh objects with alpha values."""print("\n=== Testing trimesh RGBA color settings ===")
server=viser.ViserServer()
# Create three cylindersmesh1=trimesh.creation.cylinder(radius=0.5, height=2.0, sections=16)
mesh2=trimesh.creation.cylinder(radius=0.5, height=2.0, sections=16)
mesh3=trimesh.creation.cylinder(radius=0.5, height=2.0, sections=16)
# Set RGBA colors, where the 4th value is alpha (0-255)# 76/255 is ~30% opaquemesh1.visual.face_colors= [255, 0, 0, 76]
# 153/255 is 60% opaquemesh2.visual.face_colors= [0, 255, 0, 153]
# 255/255 is 100% opaquemesh3.visual.face_colors= [0, 0, 255, 255]
# Add meshes to the sceneserver.scene.add_mesh_trimesh(
"red_transparent",
mesh1,
position=(-1.5, 0.0, 0.0)
)
server.scene.add_mesh_trimesh(
"green_transparent",
mesh2,
position=(0.0, 0.0, 0.0)
)
server.scene.add_mesh_trimesh(
"blue_opaque",
mesh3,
position=(1.5, 0.0, 0.0)
)
print("\nViser server started!")
print("View at http://localhost:8080")
print("Press Ctrl+C to exit")
try:
whileTrue:
time.sleep(1)
exceptKeyboardInterrupt:
print("\nExiting.")
if__name__=="__main__":
main()
I'm not 100% sure this is exactly the same issue, but pointing out I just put up #784 in case this fixes the problem on your end and it's a way simpler fix than #783 ... but again, it could be orthogonal.
Activity
brentyi commentedon Aug 7, 2025
Hi there!
I spent some time looking into this. Here's a quick workaround:
Some notes on the root cause:
mesh.visualis set to an instance ofColorVisuals, trimesh doesn't populate the"materials"field of the glTF output.TextureVisualsvia.to_texture()fixes the problem.I filed a trimesh issue: mikedh/trimesh#2436, we can figure out next steps based on the response there.
Noietch commentedon Aug 11, 2025
Thanks for your reply, it works for me !
brentyi commentedon Oct 11, 2025
I was revisiting this today. Couldn't reproduce the fix above 🤔
New one:
sea-bass commentedon Oct 14, 2026
I'm not 100% sure this is exactly the same issue, but pointing out I just put up #784 in case this fixes the problem on your end and it's a way simpler fix than #783 ... but again, it could be orthogonal.