JavaScript has finally matured as a language and as a global community.
Today, JavaScript is the most widely used programming language on GitHub, and boasting over 2 million packages available on NPM.
Furthermore, a highly active ECMA committee continues to drive continuous improvements to the language.
And, we are finally seeing the decline of CommonJS in favor of native ES modules.
It's time for JSCAD designs to move forward, but there are some things you should know.
Please try all the examples and get a feel for what's new. Let us know if you have any issues!
The old require() statements need to be replaced with import() statements.
In addition, the old namesspaces can be dropped.
All the functions for primitives, operations, etc are available directly.
NOTE: The old V2 namespaces should be considered obsolete.
// v2
const { cuboid } = require('@jscad/modeling').primitives
const { subtract } = require('@jscad/modeling').booleans
// v3
import { cuboid, subtract } from '@jscad/modeling'
In order to improve performance, there have been some changes. If your designs are using the internal data structures then please take note as changes may be required.
| Geometry | V2 | V3 |
|---|---|---|
| geom2 | { sides: [[vec2, vec2],...] } | { outlines: [[vec2, ...], ...] } |
| geom3 | { polygons: [poly3, ...] } | { polygons: [poly3, ...] } |
| path2 | { points: [vec2, ...], isClosed: false } | { points: [vec2, ...], isClosed: false } |
| path3 | { vertices: [vec3, ...], isClosed: false } | |
| poly2 | { vertices: [vec2, ...] } | { points: [vec2, ...] } |
| poly3 | { vertices: [vec3, ...] } | { vertices: [vec3, ...] } |
| slice | { edges: [[vec3, ...], ...] } | { contours: [[vec3, ...], ...] } |
NOTE: The big change is geom2, which now uses outlines, i.e. array of outlines.
If you find some strange results review the V3 API documentation,
as non-camelCase parameter names were corrected.
Please let us know if the following list is missing something.
Most of the API remains intact, but some functions are now obsolete. If your designs rely on these functions then please take the time to make the changes, as obsolete functions may be removed in future releases.