jscad / OpenJSCAD.org

JSCAD is an open source set of modular, browser and command line tools for creating parametric 2D and 3D designs with JavaScript code. It provides a quick, precise and reproducible method for generating 3D models, and is especially useful for 3D printing applications.
https://openjscad.xyz/
MIT License
2.61k stars 511 forks source link

V3 : API flattening #1153

Open hrgdavor opened 1 year ago

hrgdavor commented 1 year ago

Specifications

Proposal for API change update

const jscad = require('@jscad/modeling')

and then we need to look into jscad.booleans to get subtract ... even though 99% of the functions in to primitives, booleans etc have unique name.

it would be nicer if they were declared on top level instead:

const { cube, subtract, translate} = require('@jscad/modeling')
// or import for es6 ofc
import { cube, subtract, translate} from '@jscad/modeling'

as a bonus, this would also improve current issue I have with vscode that prefers to generate automatic import like this

const {subtract} = require('@jscad/modeling/booleans')

which then breaks the script

One thing to consider is if we should also keep the old paths too ? jscad.cube and jscad.primitives.cube

z3dev commented 6 months ago

V3 now exports names directly from the various indexes, and pretty much flattens the namespaces in the main index.

export * from './colors/index.js'
export * from './curves/index.js'
export * from './geometries/index.js'
export * from './maths/index.js'
export * from './measurements/index.js'
export * from './primitives/index.js'
export * from './text/index.js'
export { degToRad, flatten, radiusToSegments, radToDeg } from './utils/index.js'

export * from './operations/booleans/index.js'
export * from './operations/extrusions/index.js'
export * from './operations/hulls/index.js'
export * from './operations/modifiers/index.js'
export * from './operations/offsets/index.js'
export * from './operations/transforms/index.js'
hrgdavor commented 6 months ago

@z3dev it may be a strange request, but I would like to be able to support running v2 and v3 in jscadui, and maybe also on the official jscad..

using new package name would help recognize new scripts.

V3

const jscad = require('@jscad/modeling3')

versus V2

const jscad = require('@jscad/modeling')

Especially since our development is rather slow, and in the meantime manifold library is proving to be a beast, I hope to soon attempt at injecting it instead of csg.js into compatible @jscad/modeling package. there is posibility we might even want to drop csg.js instead having it as a choice somehow.

that would be a deeper discussion, after we have a usable replacement tht is working with manifold instead of csg.js

z3dev commented 6 months ago

@z3dev it may be a strange request, but I would like to be able to support running v2 and v3 in jscadui.

Well... I've been watching lately. And my first impression is the you're trying to do too much. If you keep expanding the functionality then nothing is gained except code bloat and maintenance issues.

A long time ago (pre-V2), the decision was made to provide the tools to create more expressive tools. JSCAD can't do everything. And, there have been some really cool websites that use JSCAD components.

There's still lots of areas to improve, and JSCADUI looks really cool. But somewhere down the road, you'll have to make the same decision.

Especially since our development is rather slow...

Slow is relative. I'm sure you know this as author of JSCADUI. :)

V3 is about improving the usability of the API, and moving to ES6. V2 is pretty stable now, but there are a few bugs still. And hopefully, everything will come together to make a better JSCAD.

So far, V3 is moving along pretty much on schedule. @platypii continues to contribute nice improvements. And most of the fundamentals have been completed. But there are some big issues to solve. Resources are short. :( Maybe late 2024, V3 will become mainstream.

z3dev commented 6 months ago

By the way, it may be time to have a little chat about plans for the website. I'd be curious as to what everyone is thinking. The website needs some serious thought and improvements.

hrgdavor commented 6 months ago

V3 is about improving the usability of the API, and moving to ES6.

ok, with that in mind, V3 is not yet the place to consider manifold.

Slow is relative. I'm sure you know this as author of JSCADUI. :)

yeah, I am aware :) it is relative :)

There's still lots of areas to improve, and JSCADUI looks really cool. But somewhere down the road, you'll have to make the same decision.

Yeah, there are some things I do want to make part of jacad.app, but then some other ideas as separate projects/demos. Idea there is that jscad.app becomes something that would improve upon openjscad.xyz and hopefully not too many extra features. I think of it as prototype, there is already few more things there to separate out as useful components.

hrgdavor commented 6 months ago

By the way, it may be time to have a little chat about plans for the website. I'd be curious as to what everyone is thinking. The website needs some serious thought and improvements.

@z3dev would you like to chat on discord in jscad channel, or a more private session somewhere like a meet. I do not have any reliable means to contact you that is more interactive like email, or sth. I can send you my email address in chat in nodebb.

hrgdavor commented 6 months ago

@z3dev you have not responded or contacted me yet :) check nodebb chat if you would like to use email, or join discord jscad channel :)

Regarding the mentioned feature creep. That is in my nature, and because of that there will be always experimental stuff on jscadui. My idea is to take those explorations and to cherry pick things that we together deem fit for maintaining as part of jscad. That way we can have something manageable/maintainable and also I can have space to play/explore.

z3dev commented 6 months ago

@z3dev would you like to chat on discord in jscad channel, or a more private session somewhere like a meet. I do not have any reliable means to contact you that is more interactive like email, or sth. I can send you my email address in chat in nodebb.

I'll set up Discord this weekend, and send a few howdy to the jscad channel. Keep in mind that I'm in Japan, and working full time, so replies might be slow.

A lively discussion about the website would be a lot of fun. Let's hope there's someone good at creating cool websites in the user group. 😃

hrgdavor commented 6 months ago

@z3dev there are few chatty ppl like me there, but I am having hard time attracting users to jscad (hence my tendency to accpet user-ideas more easily). We would need a stonger user-base to attract more contributors.