JSCAD User Group

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

    import/export of .obj file

    Development Discussions
    3
    8
    1152
    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

      Hello, I'm adding a catalog to my website and I would like to use jscad to show 3d models and was thinking that users could simply export the model to .OBJ to download it, but the it seems that jscad adds faces and holes to the exported model.

      Capture d’écran du 2022-05-26 09-55-23.png
      on the middle is the original model with 400 triangles and no holes
      on the left is the model that JSCAD exported with 416 triangles and 16 holes.

      I will simply only use JSCAD to view the model and add a link for users to download the obj file, but as I'm planning to use JSCAD to dynamically decimate a 3d model, I will certainly export to STL.

      z3dev platypii 3 Replies Last reply Reply Quote 0
      • gilboonet
        gilboonet @platypii last edited by gilboonet

        @platypii Thank you for this investigation. I remember that I tried to get JSCAD to union those groups but then it loses colors. I use Wings 3d to colorize my models, and it does not split them into separate objects (on my screenshot I have only one geometry), only materials are separated into groups.
        Capture d’écran du 2022-06-14 10-11-33.png

        Capture d’écran du 2022-06-14 10-29-42.png

        I splitted the model into 3 geometries and then exported it to .obj and the difference is that it contains 3 lines starting with "o " that defines start of an object. Maybe for the moment JSCAD translate lines starting with "g " like "o ".

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

          @gilboonet I think I understand the issue here.

          The original file st_s001.obj has 3 grouped objects within the obj file:

          g Girafe_412_blue
          ...
          g Girafe_412_lime
          ...
          g Girafe_412_orange
          

          This results in generating 3 different objects being produced:

          const obj = require("./st_s001.obj")
          console.log("number of geometries:", obj.length)
          "number of geometries: 3"
          

          Since these are not closed objects, but rather 3 seperate objects, one for each color, there are seams at the boundaries. Red lines are non-manifold edges:

          giraffe.png

          However, if you remove the "group" lines from the original .obj file, everything works. Including colors, because you can have colored faces in the same object. And since it's one seamless object, the export doesn't introduce gaps.

          Can you give that a try?

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

            @platypii for sure, you can try this one that has exactly the same problem https://openjscad.xyz/#https://raw.githubusercontent.com/gilboonet/gilboonet.github.io/master/creations/source/st_s001.obj and if you need more examples, I started creating links to models on this page : https://gilboonet.github.io/creations/index.html (the models links are numbers followed by a triangle at the beginning of each item)

            Direct link to the obj file : https://github.com/gilboonet/gilboonet.github.io/blob/master/creations/source/st_s001.obj

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

              @gilboonet I suspect that the additional faces and holes might be introduced by either snap or triangulate that is applied when serializing to .obj format.

              There is a serializer option for whether to triangulate or not. We might want to add an option for whether to snap or not. But it would be easy enough to test locally.

              Can you share the obj file?

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

                @z3dev JSCAD exported obj with holes breaks my automatic unfolder, I could add code to make it handle holes (edges without neighbor) as I do for the previous version. The aim of my catalog is to allow users to use the models I already unfold for customized needs (typically change size, crop thtm, and as soon as possible decimate them), and I was willing to to those customization with JSCAD. OBJ is the format I use because it can store color information for each triangle. Apparently for the moment this color information is lost when you import a colored OBJ and export it to OBJ.

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

                  @gilboonet let us know if you think any of the designs seem 'incorrect'. I'd be glad to help out. And of course, fix any bugs. 🐜

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

                    @gilboonet super! Please let us know how the catalogs are published. I'm sure many will want to do the same.

                    OBJ... it's a good format for exchanging designs, but not very popular. I think most users will want to download STL.

                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post
                    Powered by NodeBB | Contributors