JSCAD User Group
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    how to create a multicolor polyhedron ?

    Scheduled Pinned Locked Moved Design Discussions
    5 Posts 3 Posters 1.3k Views 2 Watching
    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.
    • gilboonetG Offline
      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

      z3devZ 1 Reply Last reply Reply Quote 0
      • hrgdavorH Offline
        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
        • z3devZ Offline
          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?

          gilboonetG 1 Reply Last reply Reply Quote 0
          • gilboonetG Offline
            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
            • gilboonetG Offline
              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

              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
              • First post
                Last post
              Powered by NodeBB | Contributors