JSCAD User Group

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    1. Home
    2. hrgdavor
    3. Best
    • Profile
    • Following 2
    • Followers 1
    • Topics 21
    • Posts 171
    • Best 16
    • Controversial 0
    • Groups 0

    Best posts made by hrgdavor

    • RE: Embedding a design in a website

      Unfortunately, things that would make this possible easily are still in develompment.

      option1 (future)

      3mf serializer is on the way and with it you would be able to export colors I think and then use threjs 3mf import

      Option 2 (you can do right now)

      you can use my nasty coded(below linked) jscad prototype to load jscad script(only single file scripts currently) and do 3mf export there(it does have a bug with instances right now, but I could get to fixing it if you rly need this).

      Option 3 (you can do right now)

      If you are eager to do it and not have time to wait these things in jscad core, here is a link to my nasty code that runs jscad using threejs instead of regl
      http://3d.hrg.hr/jscad/three/threejscad2.html?

      You need to export json (it is just JSON.stringify of the geometries)

      Make a page with threejs, load json, and then convert those to BufferGeometry

      code I have to convert from jscad to threejs is in these 2 scripts:

      http://3d.hrg.hr/jscad/three/CSGToBuffers.js
      http://3d.hrg.hr/jscad/three/CSG2Object3D.js

      I have cleaning to do to bring this to jscad, along with some other changes needed in jscad inernally.

      If you want to use this right now, and you have questions about the scripts I can also be reached on discord.

      posted in General Discussions
      hrgdavor
      hrgdavor
    • new JSCAD prototype progress 2022-01

      There is some progress in the prototype of jscad that is able to run 3 different 3D engines:

      • regl
      • Three.js
      • Babylon.js

      https://github.com/jscad/OpenJSCAD.org/discussions/944

      81ead24e-f169-4387-9451-33c04daaaf15-image.png

      https://user-images.githubusercontent.com/2480762/152607806-0d244616-f0b5-4212-8db5-691e5d5ec0b7.mp4

      posted in Development Discussions
      hrgdavor
      hrgdavor
    • RE: fetch() in a design

      @Andreas-Plesch jscad.app has been just updated, and the example:

      const jscad = require('@jscad/modeling')
      const { deserializers } = require('@jscad/io')
      const { translate, scale, rotateZ } = jscad.transforms
      
      const main = async () => {
        const url = 'https://raw.githubusercontent.com/jscad/OpenJSCAD.org/master/packages/io/x3d-deserializer/tests/ElevationGrids.x3d'
        
        const response = await fetch(url)
        const cadX3D = await response.text()
        const cad = deserializers.x3d({ output: 'geometry' }, cadX3D)
      
        console.log(cad[1], jscad.geometries.geom3.isA(cad[1]))
      
        return cad[1]
      }
      
      module.exports = { main }
      

      works now

      posted in Design Discussions
      hrgdavor
      hrgdavor
    • RE: Hosting/publishing a shape?

      I am using github gists, and then make a link to openjscad taht opens that gist

      example:
      https://jscad.xyz/#https://gist.githubusercontent.com/hrgdavor/7419194097fc2ffd42d840f82fc83ca1/raw/31e0194693629e780e3b82848f9082d1796814ec/rounded_top.js

      and gist is :
      https://gist.github.com/hrgdavor/7419194097fc2ffd42d840f82fc83ca1/

      posted in General Discussions
      hrgdavor
      hrgdavor
    • cadhub.xyz integration

      as discussed here: https://github.com/jscad/OpenJSCAD.org/discussions/893

      Initial test integration is available (now: 2021-08-01) https://cadhub.xyz/dev-ide/jscad

      bc8e69e7-5fe4-4325-86b4-6bec0f0e6a00-image.png

      check it out, feedback is appreciated.

      posted in Development Discussions
      hrgdavor
      hrgdavor
    • RE: Initial release of FlexiSystem

      nice prototype 🙂

      is it opensource ?

      posted in General Discussions
      hrgdavor
      hrgdavor
    • cadhub.xyz integration is now live !

      visit https://cadhub.xyz/projects to see our first example there ... I chose the prettiest one :), although the slowest one I have 😞

      3085c0d5-242a-46e7-9fd3-66e1ac80623f-image.png

      posted in Development Discussions
      hrgdavor
      hrgdavor
    • RE: Auto-reload and external editor workflows

      Hi,
      kudos for the atx connector generator, pretty nice one 🙂

      I am using windows 10 and chrome. Auto-reload on jscad.xyz works just fine for me.

      Bu it only works for me if I drag and drop the jscad file on the button, but not if I click the button and chose the file.
      dab061a7-76ad-47a6-afd4-929e73ed9edf-image.png

      I have used livereload for many years now and I use the one from npm:
      https://www.npmjs.com/package/livereload
      It may not have been developed for years but it just works.

      livereload is actually not required, but it helps to reload changes faster (notice changes faster)
      without livereload jscad has to scan project files/files periodically which can become slow

      ...
      I have also converted from OpenSCAD when I discovered openjscad.

      posted in General Discussions
      hrgdavor
      hrgdavor
    • Multipart project template others could find useful

      copy pasta from https://github.com/jscad/OpenJSCAD.org/discussions/1141

      Sharing this idea and also calling to discuss improvements to it.
      Even ideas how jscad could be improved to better facilitate use case like this are welcome.

      Very often when creating thins for 3d print I have multiple parts, so in time I have created a sort of template I like to use. Even if I have single piece I tend to split design in few parts to more easily handle it.

      This is the latest iteration that solves few issues for me

      • parameter definition to select a part is generated automatically
      • no need to declare configurable parameters in each function ( func that creates a part)
      • can reuse one part in another part
      const jscad = require('@jscad/modeling')
      const {sphere, cube} = jscad.primitives 
      const {translate} = jscad.transforms
      
      // all of the functions that generate parts will see the parameters without declaring them explicitly
      const main = ({//@jscad-params
        size=10, // {type:'slider'}
        part,
      }, getParams)=>{
      
        // UTILITY placeholder for part generator functions
        const parts = {}
      
        // CTRL+R in vscode works just fine
        parts.Sample_Cube = ()=>cube({size})
      
        parts.Sample_Sphere = ()=>{
          return sphere({radius:size/2})
        }
      
        // parts can easily be combined
        parts.Assembly = ()=>([
          // jump to definition in vscode (ALT+click) works
          parts.Sample_Cube(),
          translate([size+5,0,0], parts.Sample_Sphere()),
        ])
      
        /*********************** UTILITY below is just utility code. do not change **************** */
      
        // we were called by getParameterDefinitions so we need to provide list of parts
        if(getParams === true){
          const values = Object.keys(parts)
          return {values, initial: values[0]}
        }
      
        // make sure we always call one of the functions
        if(!parts[part]) part = Object.keys(parts)[0]
        return parts[part]()
      }
      
      const getParameterDefinitions = ()=>[{ name: 'part', caption:'Part', type: 'choice', ...main({}, true)}]
      
      module.exports = {main, getParameterDefinitions}
      

      image

      posted in Development Discussions
      hrgdavor
      hrgdavor
    • RE: Auto-reload and external editor workflows

      @rich-27 thanks for the feedback 🙂 ... it is nice see more people join the community. Have fun and create more cool stuff 🙂

      posted in General Discussions
      hrgdavor
      hrgdavor
    • some more progress with prototype.

      Loading of folder projects works, it can handle ESM modules, cjs scripts (require) and even typescript projects. Also worker improvements that allow script developers to optimize execution when parameters change and cache expensive operations.

      current jscad

      https://user-images.githubusercontent.com/2480762/213881095-dcd72bce-881a-463d-a105-c9ad9c0b44bb.mp4

      my new prototype is still ugly, but things are progressing bit by bit

      It was my mission from the first attempt at making a new jscad prototype to allow script developers to optimize for performance and bling.

      in this example I took a complex model and added caching so that model is kept in case only View Options parameters change. Those only affect rotation of the parts.

      also I enhanced parameter definition to allow for live updates for any of the parameter (it is not default, but opt-in)

      https://user-images.githubusercontent.com/2480762/213881066-e947e0ae-1b80-4a06-8234-fa9b1c974a19.mp4

      posted in Development Discussions
      hrgdavor
      hrgdavor
    • RE: Auto-reload and external editor workflows

      @rich-27 Browser glitches are pain to investigate and fix.

      I am not a dev here, but I am curious.

      Could you just for sake of more info test your "dice charging station" in chrome incognito(without plugins or ad blockers)

      make sure "Enable Auto-reload" is checked and then use drag and drop to load the project file.

      posted in General Discussions
      hrgdavor
      hrgdavor
    • three.js integration part2 (threejscad)

      Hello ppl, here is my second update regarding the three.js integration.

      The effort now has a code-name: threejscad 😄

      I very much dislike functional style programming so I hope my explorations with threejs will give ideas for improvement in jscad as it is not very likely I would be able to bring those improvements to jscad codebase.

      I appreciate all the effort that went into making jscad v1 and v2, it really is refreshing and smooth experience after using OpenSCAD. Generating a bit more complex model to STL would take ages in OpenSCAD so it quickly became annoying to work with.

      I have tested most of the jscad examples that do not load additional resources, and have found an example where threejscad is faster.

      565d6b47-2a82-4255-92d4-9716d82aa003-image.png

      • jscad: colorCube.js
      • threejscad colorCube.js

      click both urls and play with "Colorize Method" parameter to compare how long it takes to show the result in each instance.
      Performance is gained by reusing the geometry so webgl ony needs to upload it in GPU once and then render it in different locations with different color.

      Another example that intrigued me was parametric_butt_hinge.

      3c5710a3-2c8f-4b25-8baa-bcb7d5a5ab1e-image.png

      • jscad: parametric_butt_hinge
      • threejscad parametric_butt_hinge

      You may notice that I have implemented my own generator for forms based on parameter definitions, and improved the slider a bit

      • it show the value
      • it has an additional option live=1 to render the scene while dragging the slider (I just love to do it when render is fast)

      In this example jscad takes quite a long time to render (which is just fine and not too long when all you ned is to generate STL from it).
      But this is a great example where rendering is too slow for animating and caching the shapes makes it smooooooth.

      This optimization works by making a small change in original theparametric_butt_hinge code:

      create cahce variable outside main method

      let cache = {}
      

      Generate cache key by serializing params object. To have the same key regardless of the view options, those options are set to fixed value before serialization. Generate new model only if cache key changes.

        const key = JSON.stringify({...params,m_flip_model:0,m_throw_angle:0})
        if(cache.key != key){
          cache.key = key
          cache.female = leaf(params, C_FEMALE)
          cache.male = leaf(params, C_MALE)
        }
      

      This optimization currenty works in threejscad but not in jscad. The reason is that jscad runs the whole model file from scratch, but threejscad re-runs the main method, allowing this type of caching to work.

      After making the jscad models work in three.js and loading this one, I just enjoyed dragging the "Throw angle" slider and seeing the hinge move instantly.

      posted in General Discussions
      hrgdavor
      hrgdavor
    • RE: Embedding a design in a website

      @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

      posted in General Discussions
      hrgdavor
      hrgdavor
    • RE: [Christmas Update!]New application of JSCAD: Fully 3D-printed music box

      Very glad to see interesting uses of jscad. Nice idea if I have seen correctly, that u are using hairpins for music.

      Also if you at some point want to share the project, there is rather new project for sharing code-cad projects: https://cadhub.xyz

      posted in General Discussions
      hrgdavor
      hrgdavor
    • RE: How do I code directly in VSCode and preview the result on my web page?

      @ucimo there are two plugins for vscode to preview jscad designs on the market.

      Also you can edit your script in vscode and drag drop the file to https://openjscad.xyz after enabling auto-reload there. It will not work for typescript out of the box, but you can setup esbuild to bundle into js file and drag drop that file in openjscad for preview.

      There is also https://jscad.app that is not yet official, it is a protoype for new jscad preview/edit . It supports typescript (transpiles it on the fly) and has some perf improvements too. If you feel chatty you can join the jscad discord channel also.

      posted in General Discussions
      hrgdavor
      hrgdavor