-
Notifications
You must be signed in to change notification settings - Fork 521
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
V2 backwards compatibility with V1 #1326
Comments
@gfwilliams the example is definitely V1, but it must have been from way before as V2 was the only version available at OpenJSCAD.xyz (Apr 2021). Anyway, V2 has been the main version for a few years now. You should definitely push on as V3 is coming this year. And sorry, but backwards compatibility was never a goal of V2 because the V1 API was a total wreck. |
There are several Discussions about V1 to V2 conversation. Hopefully, those can help. |
Thanks! That's really handy - I'm not sure how many people are like me and had old designs written in V1, but personally it would have been really good if when that error about Also if you google Obviously this is your project, provided for free - and I really like it. But as a user, there's a certain expectation that if I create something in one version of an tool, it'll be usable in subsequent versions - it's kind of at odds with JavaScript development where generally library developers are very willing to break things to make the overall design better. Closing as there's obviously a discussion about this already - and I'm not a big user... I just had ~10 designs written in JSCAD v1 and I needed to tweak one of them to 3D print it again - and for that, using one of the older hosted versions will do what I need. |
There is a helper shim which can help you to migrate designs from V1 to V2 incrementally. I found this project helpful when I was updating my designs to V2: |
Thanks! Yes, that's extremely helpful! Am I right in thinking that's not part of jscad itself though, so I can't use it directly from https://openjscad.xyz with something like It looks like the way I was writing code (with Is V3 going to be backwards compatible with V2? |
Actually, we are currently discussing a new 'shim' for V2 to V3 at #1323 |
Personally it might be nice to move to But if I'm honest, it seems unlikely that OpenJSCAD is the right tool for me. I love the idea of writing models in JS rather than OpenSCAD, but part of that is the convenience of going to a website and using a language I know. I'll make something, then need to tweak it and re-print it a year or so later, but if things are changing such that I can't load models I'd made previously without having to make modifications to them, most of that convenience is gone. I'm not saying it's a bad thing - I love what you're doing and it's good you're making things better. However I think for me, I need to write my v1 models to v2, and then in a few months to v3, and probably when I next need to tweak them again I'll need to write for v4 (unless I download and self-host a version) - and it's just not really worth it for me when OpenSCAD appears to be neglected enough that models I wrote 12 years ago still work fine :) |
@gfwilliams I have a plan of supporting multiple versions of jscad with some simple annotations, so the new runtime for jscad will support old versions too. That way old scripts can be used even without refactoring, by just adding an annotation in a comment line. |
I have a basic jscad example working, no colors yet, and shim is visible in the code for testing I took the code sample from https://neorama.de that is hosting a V1 instance |
draft candidate for full shim: const csg = require('@jscad/csg/api.js')
const {circle, square, polygon, triangle} = csg.primitives2d
const {cube, sphere, cylinder, geodesicSphere, torus, polyhedron} = csg.primitives3d
const {union, difference, intersection} = csg.booleanOps
const {translate, center, scale, rotate, transform, mirror, expand, contract, minkowski, hull, chain_hull} = csg.transformations
const {extrudeInOrthonormalBasis, extrudeInPlane, extrude, linear_extrude, rotate_extrude, rotateExtrude, rectangular_extrude} = csg.extrusions
const {css2rgb, color, rgb2hsl, hsl2rgb, rgb2hsv, hsv2rgb, html2rgb, rgb2html} = csg.color
const {sin, cos, asin, acos, tan, atan, atan2, ceil, floor, abs, min, max, rands, log, lookup, pow, sign, sqrt, round} = csg.maths
const {vector_char, vector_text, vectorChar, vectorText} = csg.text |
@gfwilliams thanks for the feed back. Basically, JSCAD has to move forward just because the language and supporting libraries move forward. The JS engines are also moving as well, including Node. So, there's not much choice. JSCAD has a minimal amount of dependencies which makes maintenance easier. For V3, the big change is import/export, which makes the libraries far more useful to those creating websites, applications, etc. @hrgdavor has been working on the new web UI, which has transcompiling. And a far better design for the web worker, which can import libraries. This will allow designs to use almost anything, which the demos prove. The bad news is that V3 uses imports, and has data structure and API changes. The good news is that V2 designs can be supported by a compatibility shim, and transcompling. As for V1, the overall API is a mess, combining functional and object API. And a interlocking dependencies between everything. But, @hrgdavor likes to support everything so there's still some possibilities. By the way, there are issues raised against V1 still. Those become WILL NOT FIX. Hopefully, you can find some time to move some designs to V2 at least. There's probably a few years of support still. |
@hrgdavor that looks great - it'd be amazing if that could get into the main openjscad.xyz ... even better if as you say there could be some annotations that would then cause that code to be added automatically. @z3dev thanks! Yes, that makes sense - interesting you're moving to transpiling now. I'll definitely start trying to use the v2 API for new stuff, and it's nice to think that maybe when v3 comes out, it won't be quite as difficult to update. |
@gfwilliams @z3dev @platypii there is a draft implementation WIP test url at https://3d.hrg.hr/jscad/v1-support/ most of the examples from v1 branch work, I tried drag drop each that does not use |
transpilation is necessary because there is no way to execute ESM scripts that use sidenote on require: runtime require can be implemented only with sync IO to block until source is loaded, and then to eval it to extract the module exports. XMLHttpRequest in sync mode is used (it is ok to that in worker, but is not advisable on main thread). For drag&drop, service worker is used to expose dropped files to the worker via temporary url. Even though reading files from disk is async, worker thinks files are online on some url .. and again sync XMLHttpRequest is used and require can block. |
Sorry if this has been dealt with before, but I did have a didn't find it in my searches.
I just came back to an old script that I wanted to make a minor change to, and found it no longer works and there's no obvious way of using it any more. Is there any solution or easy way to 'upgrade' old scripts?
Expected Behavior
Script I made a year ago is still usable on https://openjscad.xyz/:
Actual Behavior
Script fails with error about
exports.main
, after that,difference
, after fixing that, size forcube
not being a numberSteps to Reproduce the Problem
Specifications
The text was updated successfully, but these errors were encountered: