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

    Embedding a design in a website

    Scheduled Pinned Locked Moved General Discussions
    23 Posts 5 Posters 9.2k Views 3 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.
    • platypiiP Offline
      platypii @hrgdavor
      last edited by

      @hrgdavor all my code will be open source. Technically it already is, but I haven't completed PRs yet. [1] [2]

      Really I just took the regl-renderer demo.html that @z3dev linked to and used it for my models. The only things I changed:

      • Include from unpkg.com
      • Remove the axes and grid
      • Added auto-rotate code so that it would spin
      • Some code style cleanup, mostly object value shorthand {camera, controls}
      • Fought with CommonJS vs ES6 module differences.

      The CommonJS vs ES6 module issue is preventing me from using the exact same jscad code for development and rendering. Right now I'm converting jscad CommonJS into ES6 for use in the browser. I might need to use babel or requirejs or something.

      This is how I'm looking to show off the designs in my site:
      Screenshot at 2021-10-10 11-08-15.png

      hrgdavorH 1 Reply Last reply Reply Quote 1
      • hrgdavorH Offline
        hrgdavor @platypii
        last edited by

        @platypii yes, jscad has moved from custom syntax to require from V1 to V2, but in menatime ES6 import is becomming more and more popular, and is looking to take over require in the long run 😞 .

        I am putting 😞 not because I dont like import/export, as it has plenty of advantages(easy tree shaking...). I am 😞 because it is also another layer of confusion for new users ... especially those unfamiliar with javascript and if it takes over require completely, then jscad will need refactoring in the future.

        1 Reply Last reply Reply Quote 0
        • OrganicPandaO Offline
          OrganicPanda @hrgdavor
          last edited by

          Hey @hrgdavor! Well I'm loving your work anyway - where is good to follow you for updates on those efforts?

          hrgdavorH 1 Reply Last reply Reply Quote 0
          • hrgdavorH Offline
            hrgdavor @OrganicPanda
            last edited by

            @OrganicPanda thanks 🙂 ... I will post it on the forum,

            I am preparing a branch on jscad to experiment, and will open a discussion page for it. That branch will contain whatever code, so it will not be added to jscad directly, but serve as starting point for proper implementation after I am satisfied with the prototype.

            One cool thing that was easy to make in threejs was 3d view: anaglyph(red,blue) and stereo side-by.side .. so it will also be part of the exepriments.

            http://3d.hrg.hr/jscad/three/threejscad2.html?stereo=Anaglyph&uri=model.logos.js
            http://3d.hrg.hr/jscad/three/threejscad2.html?stereo=SideBySide&uri=model.logos.js
            http://3d.hrg.hr/jscad/three/threejscad2.html?stereo=ParallaxBarrier&uri=model.logos.js

            This idea was pushed by one of users that likes to do VR stuff. I also trid to enable VR, but that experiment was not as easy, somethig got messed-up

            1 Reply Last reply Reply Quote 1
            • z3devZ Offline
              z3dev @platypii
              last edited by

              @platypii said in Embedding a design in a website:

              This is exactly what I was looking for! Talk about an under-hyped feature

              Cool! Nice to know that your going full speed again.

              So, there are many ways to put together applications now. Any good suggestions on where to put this information?

              1 Reply Last reply Reply Quote 0
              • platypiiP Offline
                platypii
                last edited by

                Final update, I have a solution I am happy with.

                I use browserify plus a small script to combine my designs + jscad modeling + regl-renderer into a single bundle.js. Then all I just include that script via standard <script> tag on my page.

                Final size of bundle.js: 99.9kb gzipped

                Less than 100kb for a fully draggable, zoomable 3d design, directly from CAD files! That's smaller than a screenshot would be.

                Design is live here if you're curious (but the rest of the project is still work-in-progress).


                @z3dev not sure where it should go in docs. But there's a couple cool things I've done with JSCAD that would be hard to do with any other CAD software.

                • From the same source files, I can generate both the colorized "assembled" model above, and a "print version" that has the parts arranged for 3D printing.
                • Integrated into github CI/CD so that I know immediately if I broke my designs. Could easily write tests for things like bounding box size.
                • Use eslint to enforce style rules. Browserify to bundle with any other javascript.
                • Able to put the design in a website super efficiently. Directly from the source CAD files, without rendering to a huge mesh file format.

                parts.png

                hrgdavorH z3devZ 2 Replies Last reply Reply Quote 0
                • hrgdavorH Offline
                  hrgdavor @platypii
                  last edited by

                  @platypii that is great 🙂 for situations where only one model is shown webpack must be doing some tree shaking, because when I tested jscad/modeling package is 150k minimized.

                  Your case is really extreme size optimization, great job.

                  A demo project on git that does this for some simple model would be cool 🙂

                  another use case is a minimal build to run a model, but one that is reusable, it would be bit bigger as it would include whole 150k modeling package, but would be reusable for multiple scripts/models.

                  @z3dev maybe we could create an md or wiki page to list interesting projects done using jscad.

                  1 Reply Last reply Reply Quote 0
                  • z3devZ Offline
                    z3dev @platypii
                    last edited by

                    @platypii Very cool!

                    The combining of design and JSCAD components is a very clean solution. Kudos!

                    I especially like the ability to embed the 'assembled' model directly into GitHub CI.

                    @SimonClark should be interested in the feedback as he is working on a community site for sharing designs / parts.

                    1 Reply Last reply Reply Quote 0
                    • cdubC Offline
                      cdub
                      last edited by

                      Hi Folks. There hasn't been much activity on this topic, but I was hoping to kick this around some more. I'm very interested in the idea of embedding the JSCad viewer into a webpage. More specifically with dynamic user parameter implementation like the current JSCad web implementation.

                      @z3dev wrote the Vue wrapper and was extremely helpful in dissecting this stuff. Tutorial6 gets me most of the way,

                      With the tutorial6 code, I was able to add a numeric spinner to change a radius value (z3dev implemented already). This works o.k. and the new geometries are added to the view after 'compile'.

                      My question is: After the new geometries are added to the JScad viewer, how do I refresh the render to only show the newly added geometries? I don't fully understand the rendering code to know how to approach this. Any help is appreciated.

                      hrgdavorH 1 Reply Last reply Reply Quote 0
                      • hrgdavorH Offline
                        hrgdavor @cdub
                        last edited by hrgdavor

                        @cdub I have been slowly working on providing bits and pieces to create different apps/websites with jscad embeded in different ways here
                        https://github.com/hrgdavor/jscadui/ ... contributors are welcome

                        one of demos is about making a new version of jscad web https://jscad.app that was actually made by @platypii

                        Although my progress is slow there, that is also one place where you could find useful stuff.

                        cdubC 1 Reply Last reply Reply Quote 0
                        • cdubC Offline
                          cdub @hrgdavor
                          last edited by

                          @hrgdavor and @platypii. Thank you for your contributions and for sharing the repos. The work completed here is certainly impressive. I look forward to digging into the code to learn other creative and productive ways of using the JSCAD viewer. The https://jscad.app has a fresh modern cad application feel. Especially with the addition of the orientation cube.

                          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