how to create a multicolor polyhedron ?
-
Hello, to unfold my volumes I usually use a graphical editor (Wings 3d) and split it into pieces by painting each piece faces of the same color. I am wondering if there is a way to code that. Basically I have two splitting techniques, first one is to choose a number of pieces (N) then split the model into pieces having each (model faces count / N) faces. And second one is to make as many faces path as needed, it is hard to explain in few words. I am aware that is not something that JSCAD is made for but it is something that I'm willing to try for some time.
-
I changed my obj importer code to make it work with obj without groups. Now I can start to colorize my models by code. And there's one nice thing about that : I can use that faces coloring to store a volume's unfold pattern.
-
@z3dev I have an app that uses .obj so this format is my preffered one. For the moment when I export a polyhedron where I changed polygons.color values, I first need to import/export with Wings 3d for my app to be able to use it correctly, JSCAD doesn't create groups but add usemtl, I will look at my code to make it work without "g" lines.
-
As @hrgdavor mentioned, colors can be set per polygon. This will allow you to control the rendering. Are you exporting to a specific format?
-
looking at jscad sourcecode you can set color on each polygon,
const jscad = require('@jscad/modeling') const { cube } = jscad.primitives function main(){ const c = cube({size:10}) c.polygons[0].color = [1,0,0] c.polygons[2].color = [0,1,0] console.log(c) return c } module.exports = {main}