User avatar
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:

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.
JSCAD.n_42.png (193.2 KiB) Viewed 475 times [304+402+536fps]

User avatar
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 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=","+encodeURIComponent(e);})()
Open and use editor, finally click on "saveToAdd" bookmark.
Copy address bar to somewhere, or save as new bookmark for using again.


Not a bookmarklet, but view_gzb64 tool gzips JSCAD file first, and then base64 encodes it.
Finally it opens much shorter ",base64,..." URL in browser then: ... view_gzb64 [304+402+536fps]

Return to “Other programming languages”