JSCAD User Group

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

    how to create a multicolor polyhedron ?

    Design Discussions
    3
    5
    556
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • gilboonet
      gilboonet last edited by gilboonet

      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.
      Capture d’écran de 2022-03-26 11-46-45.png

      z3dev 1 Reply Last reply Reply Quote 0
      • gilboonet
        gilboonet last edited by

        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.
        Capture d’écran de 2022-03-26 21-48-08.png

        1 Reply Last reply Reply Quote 0
        • gilboonet
          gilboonet @z3dev last edited by

          @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.
          Capture d’écran de 2022-03-26 15-52-30.png

          1 Reply Last reply Reply Quote 0
          • z3dev
            z3dev @gilboonet last edited by

            As @hrgdavor mentioned, colors can be set per polygon. This will allow you to control the rendering. Are you exporting to a specific format?

            gilboonet 1 Reply Last reply Reply Quote 0
            • hrgdavor
              hrgdavor last edited by

              looking at jscad sourcecode you can set color on each polygon,
              cd8a6544-f051-4e44-8f65-eec31b05461d-image.png

              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}
              
              1 Reply Last reply Reply Quote 0
              • First post
                Last post
              Powered by NodeBB | Contributors