zalo / CascadeStudio

A Full Live-Scripted CAD Kernel in the Browser
https://zalo.github.io/CascadeStudio/
MIT License
1.05k stars 136 forks source link

Add Color() for viewing? #29

Open johnsonm opened 4 years ago

johnsonm commented 4 years ago

I could imagine Color("colorspec", [oc.TopoDS_Shape]) or something like that to apply a color to a list of objects.

Sometimes I apply random colors to objects just to be able to tell them apart easily when I'm making a complex model.

If the "colorspec" included alpha it could be used for debugging as well; if that's hard to do with oc then perhaps instead there could be a separate Transparency() that is like it but provides, say a 0-1 range of transparency for the object.

zalo commented 4 years ago

This is a good idea. It'll be slightly tricky to implement since I recently refactored the drawing system to draw everything in a single draw-call (to make editing .STL Meshes feasible), but this may be worth adding the additional complexity...

It would be really slick to propagate colors through changed faces on CSG operations, but that requires a level of OpenCASCADE access that is beyond my familiarity right now.

EDIT: Oh, actually I just remembered that I’m propagating face index into vertex color for the color picking, so it may be reasonable to propagate actual color information that way too... another good reason to fork the MatcapMaterial and begin adding custom features (colors, per-face highlighting, proper envmap reflections, etc.)

flolu commented 2 years ago

@zalo You mentioned "per-face highlighting". Would #147 be possible?