jscad / csg.js

DEPRECATED: CSG Library for JSCAD (See the link below)
https://github.com/jscad/OpenJSCAD.org/tree/master/packages/modeling
MIT License
217 stars 56 forks source link

Color information lost after boolean operations #199

Closed bitbybit-dev closed 3 years ago

bitbybit-dev commented 3 years ago

Great work on the library. If I understand it correctly in V1 API after applying boolean operations colour data was transferred further down the chain and existed as a property on each polygon. In V2 I see that applying booleans on coloured meshes returns objects that 'forget' about original colour. Is there some way to force that in V2? Thank you.

z3dev commented 3 years ago

Correct. Colors are not transferred, and apply only to the geometry as a whole.

When using V2, be sure to set color as the last step, after applying other operations.

bitbybit-dev commented 3 years ago

Thanks, I will keep that in mind.

z3dev commented 3 years ago

@bitbybit-dev thanks again.

just one more tip... a design can return one or more geometries. many of the export formats (like DXF) will convert each geometry into appropriate objects. so, your design can choose to combine everything into ONE BIG GEOMETRY, or return a bunch of little geometries. it just depends on what you want to do with it.

bitbybit-dev commented 3 years ago

@z3dev also thanks for fast reply and suggestions!

I sort of imagined that coloured 3D printers would use this info from V1 when printing single mesh, but saving multiple objects with different colours before going to 3D print probably is also ok. My experience in that is a bit limited. In any case, users of my platform will need to make this choice themselves, I am exposing csg as it is and so far it works really well.

z3dev commented 3 years ago

@bitbybit-dev nice feedback. keep in touch and let us know if there are any issues. i would expect a few in V2. ;)

fyi, i discussed color prints with Mr. Prusa at Makers Faire Tokyo. (We had a great discussion). For multi-color prints, each part must be seperate, and have a unique color. The Prusa slicer uses that information to activate the nozzle (color), and create the multi-color print. P.S. His file format of choice is 3MF, which is coming in JSCAD.

bitbybit-dev commented 3 years ago

That sounds great! I will follow the development of 3MF integration then. I get that V2 can be a bit unstable, but I like the API choices you've made and unit tests make a big difference :) I'll be testing csg quite extensively through https://bitbybit.dev UI, if something comes up I'll let you know. Prusa slicer looks great, I was only familiar with Cura...

z3dev commented 3 years ago

@bitbybit-dev oh... by the way, this library is now part of OpenJSCAD.org repository, and known as the 'modeling' package. you should be working with that repository now, as this one (CSG.js) is no longer maintained.

bitbybit-dev commented 3 years ago

Ah :) That is some very valuable information, had an idea that csg.js was part of OpenJSCAD.org as it was not marked deprecated. Last commit was suspiciously old indeed... I will clone it through OpenJSCAD.org then and use modeling package. Thanks!

z3dev commented 3 years ago

Excellent. Here's a starting point...

https://openjscad.org/dokuwiki/doku.php?id=early_v2

FYI, you can also find the @jscad/modeling library on NPM. It was published today! :)

bitbybit-dev commented 3 years ago

Haha, that's some top-notch support. NPM package will be very helpful as I only need that part at this moment, thanks! Its probably not the best place to throw these questions, but if it is possible to publish io package to npm that would be awesome as well ;)

z3dev commented 3 years ago

Should be there... here's the list of published packages.

Successfully published:

bitbybit-dev commented 3 years ago

OK, amazing @z3dev, thanks a lot for all the help here! I have everything I need to continue ;) And it all started with colors... Now I just need to code it out.