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.

-
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} -
As @hrgdavor mentioned, colors can be set per polygon. This will allow you to control the rendering. Are you exporting to a specific format?
-
@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.

-
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.

Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login