OpenJSCAD.org
OpenJSCAD.org copied to clipboard
Loading multiple files via URL
It is possible to open JScad with a URL parameter either by using: https://www.openjscad.org/#https://raw.githubusercontent.com/udif/openjscad-objects/master/flexgrid.jscad or https://www.openjscad.org/?uri=https://raw.githubusercontent.com/udif/openjscad-objects/master/flexgrid.jscad (This was prepared, BTW, as a response to this: http://hackaday.com/2017/08/05/3d-printing-flexible-surfaces-out-of-non-flexible-material/ )
I have some models that uses libraries stored in separate external files. I can load them by selecting those mulitiple files and then using drag-and-drop to open all of them, but it is inconvenient. Is it possible to load those multiple files using multiple URL parameters, so I can easily share and load these projects? I don't want to pack everything into one file. I'm not a front end web developer and don't want to install and use NodeJS just to handle dependencies and packing to a small project.
@udif there was a discussion about this on the OpenJSCAD community. Please read that first, and ask your questions there.
Lets talk there as there may be others that can assist.
Sorry, I was not aware of the Google+ group. Is this the discussion you meant? https://plus.google.com/112547487000950207437/posts/QEVvg2r99Q4
Hi @udif ! Actually I would say exactly the opposite then @z3dev hahaha. I find the Google+ group discussions very hard to follow (no way of displaying code correctly etc ) Anyway: from what I gather you would expect multiple files passed by url to behave the same way as multiple drag & dropped ones ? The way it would work is not very clear : as you can only have one 'main' jscad file, so this is not as trivial as it seems :)
Sorry @kaosat-dev , I somehow missed your issue update.
Yes, I expect it to behave exactly as multiple drag & drop. When I use this, I only have one main file. My use case is libraries: I use external libraries such as https://github.com/johnwebbcole/jscad-utils . Apparently @johnwebbcole is using a NodeJS build system that packs everything into a single minified Javascript file, but I find it much more comfortable to be web-only, as I'm nor a front-end developer. Here is an example of a project using 7 files: https://github.com/udif/openjscad-objects#raspberry-pi-case Being able to put one main file plus several libraries on one URL would allow me to have large OpenJSCAD project easily available as a link.
@udif my first build system copied individual files so you could drag the directory into a OpenJScad window. I changed it to a simple concatenation when I wanted to share the files online. There are a number of security issues with loading remote JavaScript files, and concating them was the easiest solution at the time.
There are a few browsers that support URL loading of JavaScript es6 modules, so this will be a solution in the future.
I plan on looking at the new es6 @jscad modules and coming up with a new build system, but I'm still thinking of bundling into a single file, as is the common method for web development right now.
Will this help? https://gist.github.com/jesperorb/6ca596217c8dfba237744966c2b5ab1e They mention 2 services for proxying accesses (doing CORS for you):
Bypass client-side for production
Proxy
WARNING: Great services, but you are dependent on these services to work, if they break or go down, so does your app
You can use a service that proxies your request and automatically enable CORS for your:
- https://crossorigin.me/
- https://cors-anywhere.herokuapp.com/ Then you have to call your API by prepending one of these URLs to your request, for example:
https://crossorigin.me/http://yourapi.com https://cors-anywhere.herokuapp.com/http://yourapi.com
The original issue was titled 'loading multiple files'.
Even if there are ways around the cross domain access issues (CORS), there is no way to read a file system on the server. That's only possible when the webserver is configured specifically (against many many security policies), and the client (JSCAD) would need specific processing as well.
That's two strikes...
By the way, I'm expecting ES6 imports to the have the same cross domain access restrictions. So this isnt' the solution either.