User avatar
HermannSW
Posts: 6326
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany

JSCAD — JavaScript CAD in your browser

Tue Feb 13, 2024 1:19 pm

You might know OpenSCAD, a CAD system that uses programming to create models.

JSCAD is a CAD system that runs directly in a browser, and is programmed in JavaScript.
It is fast, and has documentation, forum and discord channel, examples, ...

Recently I created JSCAD models from PARI/GP in my new GP3D repo to provide 3D output for PARI/GP:
viewtopic.php?p=2192436&hilit=JSCAD#p2192436

Today I saw something interesting, minimized and transferred complete logic into JSCAD main().
You can see hull() applied to set of integer vertices in ℤ³ with norml2([x,y,z])<=params.n selected via slider bottom left.
Try it out in your browser — you can change code in editor right, press SHIFT+ENTER to redraw.
For bigger n re-rendering takes time, but after that translation/rotation/zooming is superfast.
You can see redraw time reported in browser console.
https://stamm-wilbrandt.de/tqf_3D.4.gp.html
JSCAD.n_42.png
JSCAD.n_42.png
JSCAD.n_42.png (193.2 KiB) Viewed 475 times
https://github.com/Hermann-SW/RSA_numbers_factored
https://stamm-wilbrandt.de/GS [304+402+536fps]
https://hermann-sw.github.io/planar_graph_playground
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de

User avatar
HermannSW
Posts: 6326
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany

Re: JSCAD — JavaScript CAD in your browser

Thu Feb 22, 2024 10:06 pm

There will be some kind of "save" capability in JSCAD, but there is none now.
I did dig into the jscad.app HTML and found "editor-container" id element.
And did dig deeper not nicely (my HTML navigation skills are a bit rusty).
But it works, tested with chromium and firefox browsers.

Store this as "saveToAddress" bookmark in your browser:

Code: Select all

javascript:(function(){e="";Array.from((window.document.getElementById("editor-container")).children[0].children[1].children[1].children).forEach((element) => e=(e+element.textContent)+"\n");window.location="https://jscad.app/#data:application/javascript,"+encodeURIComponent(e);})()
Open jscad.app and use editor, finally click on "saveToAdd" bookmark.
Copy address bar to somewhere, or save as new bookmark for using again.

Demo:
Image


P.S:
Not a bookmarklet, but view_gzb64 tool gzips JSCAD file first, and then base64 encodes it.
Finally it opens much shorter "...data:application/gzip,base64,..." URL in browser then:
https://github.com/Hermann-SW/GP3D/blob ... view_gzb64
https://github.com/Hermann-SW/RSA_numbers_factored
https://stamm-wilbrandt.de/GS [304+402+536fps]
https://hermann-sw.github.io/planar_graph_playground
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de

Return to “Other programming languages”