JSCAD integration #411
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I've been talking to @hrgdavor about the a possible JSCAD integration. I think what I'd like to do is setup a branch for you with a bunch of things setup in the UI ready for you so you can focus on the "kernel" so to speak.
I'm going to try and describe our architecture below so hopefully I can put into the readme as well. (you might notice that the following ignores the customizer, that's just because we haven't worked that detail out yet)
Visually our the setup looks like this

Because we want to have a lot of consistency from one package to the other and to make integrations easier, theoretically when integrating a new package, the only new things that need to be added is the Cad Kernel. So long as it takes code and produces a 3d artifact as well as any logs or error messages it should work fine.
Existing packages (OpenSCAD, and CadQuery) make sever requests to get the 3d artifacts, but this is not a requirement, however we at least want to have the ability to run things outside the browser for future features (such as github integration producing new artifacts on push to master).
New cad kernals should be added into
app/web/src/helpers/cadPackages/using the naming convention<kernalName>Controller.ts. The default export for this file, as well as the return types of the render function have TS definitions already sorted, See the demoController for boilerplate on adding a new CAD kernel.Note that if the typescript definitions are too strict for an edge case specific to your package, raise it and we'll figure out a way of making the definitions more flexible.
The new cad kernel controller then should be imported into
app/web/src/helpers/cadPackages/index.tsfrom there the rest of the integration into the UI itself, for the time being it's probably best to get @Irev-Dev to handle it.jscad definitely works on server-side, so when the time comes for that part of integration it should not be a problem.
I finally got around to adding a branch for you @hrgdavor, it's at
kurt/411-demo-branchand the diff is here https://github.com/Irev-Dev/cadhub/compare/kurt/411-demo-branch?expand=1
Basically all I've done is made it so you can navigate to http://localhost:8910/dev-ide/jscad

and but since I've only implemented a dumby jscad controller it will only ever look like this.
But as soon as your able to return geometry from that controller it should work 🤞 (I'm sure there's something I'm forgetting)
Is that helpful?
app/web/src/helpers/cadPackages/jsCadController.tsis a typescript file, but as we spoke about earlier feel free to strip out the types and work is js, the function basically just needs to return an object of this shape for it to work (I think):I think this should be closed now that projects can be saved #506
Sill a few points in #444