sgenoud / replicad

The library to build browser based 3D models with code.
https://replicad.xyz
MIT License
323 stars 38 forks source link

Studio share: Share via zipped code in URL #136

Closed Billiam closed 5 months ago

Billiam commented 5 months ago

This PR allows sharing projects with project code zipped in the URL, similar to the studio workbench.

https://replicad.xyz/share/code#code=....

Instead of using a query parameter, I'm using the location hash, which has a couple of advantages:

This is the same change (for the same reasons) to cascade studio here, also hosted on github pages: https://github.com/zalo/CascadeStudio/pull/121

Hash parameters like this could be used for the other share flags (disable-damping, hide-grid etc), but since they're short, they're unlikely to hit any of these limits.

This share URL isn't currently exposed anywhere, since it requires loading the project code (in order to zip it).

I think it could be added to the share panel in the workbench, since that's already zipping the project code, but it would probably want to know about the additional share parameters, and the share URL etc.

Billiam commented 5 months ago

Whoops! Fixed the edit//share links for code-in-param sharing. I think the workbench will want to change to using #code= as well in the future.