@rulecad/shapes 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -0
- package/features.d.mts +42 -0
- package/features.mjs +87 -0
- package/ops.d.mts +24 -0
- package/ops.mjs +61 -0
- package/package.json +14 -4
- package/shapes.d.mts +2 -0
- package/shapes.mjs +4 -1
package/README.md
CHANGED
|
@@ -49,3 +49,39 @@ const window = gabled([-1, 1], [-1, 4], [10, 13]);
|
|
|
49
49
|
- `gabled([x0, x1], [y0, y1], [z0, z1], axis)`: a box with a 45 degree gabled roof, for openings in upright walls.
|
|
50
50
|
- `diamond(size, axis, length)`: a square hole turned 45 degrees, for small holes in upright walls.
|
|
51
51
|
- `vents({ count, width, pitch, length, depth })`: slots side by side along x.
|
|
52
|
+
|
|
53
|
+
## Print-aware features
|
|
54
|
+
|
|
55
|
+
Holes, pockets and ribs drawn so they print without supports with the part lying as drawn (z up from the bed).
|
|
56
|
+
Each starts at a point on a face (`at`) and goes into the material (`into`: `'+x'`, `'-x'`, `'+y'`, `'-y'`, `'+z'` up
|
|
57
|
+
from the bed, `'-z'` down from a top). Sizes come from your rules; nothing is built in.
|
|
58
|
+
|
|
59
|
+
```js
|
|
60
|
+
import { countersink, teardropHole, nutPocket, crushRibs, wallOpening } from '@rulecad/shapes'
|
|
61
|
+
|
|
62
|
+
countersink({ hole: v.hole, head: v.csk, length: 16, at: [x, y, 0], into: '+z' }) // flat head flush with the face
|
|
63
|
+
teardropHole({ d: v.hole, length: 20, at: [-10, 0, 5], into: '+x' }) // across a part: a 45° pointed roof
|
|
64
|
+
nutPocket({ flats: v.m3.nut_flats + v.x1c.hole_comp, height: v.m3.nut_height, hole: v.hole, at: [x, y, 0], into: '+z' })
|
|
65
|
+
crushRibs({ at: [[-9.4, 5], [9.4, 5]], into: [[1, 0], [-1, 0]], z: [3, 5], radius: 0.84, protrude: 0.5 }) // to add
|
|
66
|
+
wallOpening({ width: 12.75, height: 6.9, depth: v.wall, at: [x, 0, z], into: '-y', bridge: v.x1c.bridge })
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
- A countersink from the side (`into` ±x or ±y) is a teardrop: its round parts get a 45° ridge on top.
|
|
70
|
+
- A nut pocket going up from the bed gets a 45° hexagonal roof to the hole; across a part, a flat top (a short bridge).
|
|
71
|
+
- An opening wider than the printer's `bridge` rises at 45° each side to a flat that wide.
|
|
72
|
+
- Cutters start a little outside the face they enter by, so no faces lie on each other.
|
|
73
|
+
|
|
74
|
+
## Booleans: JSCAD or Manifold
|
|
75
|
+
|
|
76
|
+
`ops(engine)` gives `union`, `subtract` and `intersect` behind one interface. Designs get it as `v.ops`, so they say
|
|
77
|
+
what they mean and the workspace picks the engine: JSCAD's own (the default, exactly as before) or
|
|
78
|
+
[Manifold](https://github.com/elalish/manifold) (much faster, always watertight), with `"engine": "manifold"` in an
|
|
79
|
+
object's JSON or `CAD_ENGINE=manifold` for every design. Manifold needs `npm install manifold-3d` in the workspace.
|
|
80
|
+
|
|
81
|
+
```js
|
|
82
|
+
export function main (v) {
|
|
83
|
+
return v.ops.subtract(body, holes, pockets) // arrays are fine, as with JSCAD
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
A shape Manifold can't read as a closed solid falls back to JSCAD for that operation (`stats.fallbacks` counts them).
|
package/features.d.mts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/** A flat-head screw's hole and 90° countersink, the head flush with the face at `at`. */
|
|
2
|
+
export function countersink({ hole, head, length, at, into, teardrop }: {
|
|
3
|
+
hole: any;
|
|
4
|
+
head: any;
|
|
5
|
+
length: any;
|
|
6
|
+
at?: number[];
|
|
7
|
+
into?: string;
|
|
8
|
+
teardrop?: boolean;
|
|
9
|
+
}): any;
|
|
10
|
+
/** A round hole across a part, with a 45° roof so it prints without support. */
|
|
11
|
+
export function teardropHole({ d, length, at, into }: {
|
|
12
|
+
d: any;
|
|
13
|
+
length: any;
|
|
14
|
+
at?: number[];
|
|
15
|
+
into?: string;
|
|
16
|
+
}): any;
|
|
17
|
+
/** A hex pocket for a captive nut, open at the face at `at`, with its roof drawn to print. */
|
|
18
|
+
export function nutPocket({ flats, height, hole, at, into }: {
|
|
19
|
+
flats: any;
|
|
20
|
+
height: any;
|
|
21
|
+
hole: any;
|
|
22
|
+
at?: number[];
|
|
23
|
+
into?: string;
|
|
24
|
+
}): any;
|
|
25
|
+
/** Half-round crush ribs on a pocket's wall, for a press fit that takes a range of sizes. To add to the part. */
|
|
26
|
+
export function crushRibs({ at, into, z, radius, protrude }: {
|
|
27
|
+
at: any;
|
|
28
|
+
into: any;
|
|
29
|
+
z: any;
|
|
30
|
+
radius: any;
|
|
31
|
+
protrude: any;
|
|
32
|
+
}): jscad.geometries.geom2.Geom2;
|
|
33
|
+
/** A square-cornered opening through an upright wall, centred on at (a cable's plug, a switch). */
|
|
34
|
+
export function wallOpening({ width, height, depth, at, into, bridge }: {
|
|
35
|
+
width: any;
|
|
36
|
+
height: any;
|
|
37
|
+
depth: any;
|
|
38
|
+
at?: number[];
|
|
39
|
+
into?: string;
|
|
40
|
+
bridge: any;
|
|
41
|
+
}): jscad.geometries.geom3.Geom3;
|
|
42
|
+
import jscad from '@jscad/modeling';
|
package/features.mjs
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// Print-aware features: the holes, pockets and ribs printed parts keep needing, drawn so they print without supports
|
|
2
|
+
// in the part's print orientation (z up, the bed at the bottom). Each returns a JSCAD geom3 to subtract from the part
|
|
3
|
+
// (crushRibs: to add). Sizes come in from rules (m3.csk_head, m3.nut_flats, x1c.hole_comp …): no numbers live here.
|
|
4
|
+
// Every feature starts at a point on a face (at) and goes into the material along a direction (into): '+x', '-x',
|
|
5
|
+
// '+y', '-y', '+z' (up from the bed) or '-z' (down from a top face).
|
|
6
|
+
// countersink({ hole, head, length, at, into, teardrop }) a flat-head screw's hole and its 90° cone, the head flush
|
|
7
|
+
// with the face at `at`
|
|
8
|
+
// teardropHole({ d, length, at, into }) a round hole across a part (into ±x or ±y) with a 45° pointed roof
|
|
9
|
+
// nutPocket({ flats, height, hole, at, into }) a hex pocket for a captive nut, open at the face: going up (+z) it
|
|
10
|
+
// gets a 45° hexagonal roof to the hole; across (±x, ±y) a flat top (a bridge across the flats)
|
|
11
|
+
// crushRibs({ at, into, z, radius, protrude }) half-round ribs standing protrude into a pocket from its wall, each at
|
|
12
|
+
// a point on the wall (at: [[x, y], …]) facing into the pocket (into: [[nx, ny], …], unit vectors), from z[0] to z[1]
|
|
13
|
+
// wallOpening({ width, height, depth, at, into }) a square-cornered opening through an upright wall (into ±x or ±y),
|
|
14
|
+
// from the point at on its face (centred), depth into it. Its top is a bridge as wide as the opening: given the
|
|
15
|
+
// printer's bridge, a wider one rises at 45° each side to a flat that wide (height is the square part)
|
|
16
|
+
import jscad from '@jscad/modeling';
|
|
17
|
+
|
|
18
|
+
const { cylinder, cylinderElliptic, cuboid } = jscad.primitives, { translate, rotateX, rotateY, rotateZ } = jscad.transforms;
|
|
19
|
+
const { hull } = jscad.hulls, { union } = jscad.booleans;
|
|
20
|
+
const TINY = 1e-3; // a slice's thickness, where a hull comes to a point
|
|
21
|
+
const OUT = 0.1; // how far a cutter starts outside the face it enters by, so no faces lie on each other
|
|
22
|
+
const EDGE = 0.05; // a ridge's width: a sharp point, without the slivers a vanishing one leaves
|
|
23
|
+
|
|
24
|
+
// A cutter drawn going down from z = 0 (into = -z), turned to go along `into` from the origin, then moved to `at`
|
|
25
|
+
function along(g, into, at = [0, 0, 0]) {
|
|
26
|
+
const turn = { '-z': (x) => x, '+z': (x) => rotateX(Math.PI, x), '+x': (x) => rotateY(-Math.PI / 2, x), '-x': (x) => rotateY(Math.PI / 2, x),
|
|
27
|
+
'+y': (x) => rotateX(Math.PI / 2, x), '-y': (x) => rotateX(-Math.PI / 2, x) }[into];
|
|
28
|
+
if (!turn) throw new Error(`into must be +x, -x, +y, -y, +z or -z (got ${into})`);
|
|
29
|
+
return translate(at, turn(g));
|
|
30
|
+
}
|
|
31
|
+
// Which way is up (+z in the part) in a cutter's own drawing, for one going across: where its roof points
|
|
32
|
+
const UP = { '+x': [1, 0], '-x': [-1, 0], '+y': [0, 1], '-y': [0, -1] };
|
|
33
|
+
const across = (into) => into in UP;
|
|
34
|
+
|
|
35
|
+
// A round cutter from z = z0 down to z1, and its 45° ridge on the up side (r(z) the radius at each end)
|
|
36
|
+
function tear(r0, r1, z0, z1, up) {
|
|
37
|
+
// The ridge: a thin square turned 45° about the cutter's axis, its far corner at r√2, so the roof meets it at 45°
|
|
38
|
+
const ridge = (r, z) => translate([up[0] * (r * Math.SQRT2 - EDGE / Math.SQRT2), up[1] * (r * Math.SQRT2 - EDGE / Math.SQRT2), z], rotateZ(Math.PI / 4, cuboid({ size: [EDGE, EDGE, TINY] })));
|
|
39
|
+
const round = r0 === r1 ? translate([0, 0, (z0 + z1) / 2], cylinder({ radius: r0, height: Math.abs(z0 - z1), segments: 48 }))
|
|
40
|
+
: translate([0, 0, (z0 + z1) / 2], cylinderElliptic({ height: Math.abs(z0 - z1), startRadius: [r1, r1], endRadius: [r0, r0], segments: 48 }));
|
|
41
|
+
return up ? hull(round, ridge(r0, z0), ridge(r1, z1)) : round;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** A flat-head screw's hole and 90° countersink, the head flush with the face at `at`. */
|
|
45
|
+
export function countersink({ hole, head, length, at = [0, 0, 0], into = '-z', teardrop = across(into) }) {
|
|
46
|
+
const up = teardrop ? UP[into] : null, cone = (head - hole) / 2;
|
|
47
|
+
return along(union(tear(head / 2, head / 2, OUT, 0, up), tear(head / 2, hole / 2, 0, -cone, up), tear(hole / 2, hole / 2, -cone / 2, -length, up)), into, at); // overlapping, not touching: clean seams
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** A round hole across a part, with a 45° roof so it prints without support. */
|
|
51
|
+
export function teardropHole({ d, length, at = [0, 0, 0], into = '+x' }) {
|
|
52
|
+
if (!across(into)) throw new Error('teardropHole goes across a part: into ±x or ±y (a hole up or down is a plain cylinder)');
|
|
53
|
+
return along(tear(d / 2, d / 2, OUT, -length, UP[into]), into, at);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** A hex pocket for a captive nut, open at the face at `at`, with its roof drawn to print. */
|
|
57
|
+
export function nutPocket({ flats, height, hole, at = [0, 0, 0], into = '-z' }) {
|
|
58
|
+
const corner = flats / 2 / Math.cos(Math.PI / 6);
|
|
59
|
+
// Across, a flat on top (a short bridge); going up, a corner along x either way
|
|
60
|
+
const hex = (g) => (across(into) && UP[into][0] !== 0 ? rotateZ(Math.PI / 6, g) : g);
|
|
61
|
+
const pocket = translate([0, 0, -height / 2], cylinder({ radius: corner, height, segments: 6 }));
|
|
62
|
+
if (into !== '+z') return along(hex(pocket), into, at);
|
|
63
|
+
// Going up from the bed face: a 45° hexagonal roof from the corners to the hole, so nothing spans
|
|
64
|
+
const rise = corner - hole / 2;
|
|
65
|
+
const roof = translate([0, 0, -height - rise / 2], cylinderElliptic({ height: rise, startRadius: [hole / 2, hole / 2], endRadius: [corner, corner], segments: 6 }));
|
|
66
|
+
return along(union(pocket, roof), into, at);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Half-round crush ribs on a pocket's wall, for a press fit that takes a range of sizes. To add to the part. */
|
|
70
|
+
export function crushRibs({ at, into, z, radius, protrude }) {
|
|
71
|
+
return union(...at.map(([x, y], i) => {
|
|
72
|
+
const [nx, ny] = into[i] || into[0], back = radius - protrude;
|
|
73
|
+
return translate([x - nx * back, y - ny * back, (z[0] + z[1]) / 2], cylinder({ radius, height: z[1] - z[0], segments: 24 }));
|
|
74
|
+
}));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** A square-cornered opening through an upright wall, centred on at (a cable's plug, a switch). */
|
|
78
|
+
export function wallOpening({ width, height, depth, at = [0, 0, 0], into = '-y', bridge }) {
|
|
79
|
+
if (!across(into)) throw new Error('wallOpening goes through an upright wall: into ±x or ±y');
|
|
80
|
+
const long = depth + OUT, w = into.endsWith('x') ? [long, width, height] : [width, long, height], dir = into[0] === '+' ? 1 : -1;
|
|
81
|
+
const off = into.endsWith('x') ? [dir * (depth - OUT) / 2, 0, 0] : [0, dir * (depth - OUT) / 2, 0];
|
|
82
|
+
const box = cuboid({ size: w });
|
|
83
|
+
if (bridge == null || width <= bridge) return translate(at.map((a, k) => a + off[k]), box);
|
|
84
|
+
// Wider than the printer bridges: the top rises at 45° each side to a flat as wide as it can span
|
|
85
|
+
const rise = (width - bridge) / 2, top = translate([0, 0, height / 2 + rise], cuboid({ size: into.endsWith('x') ? [long, bridge, TINY] : [bridge, long, TINY] }));
|
|
86
|
+
return translate(at.map((a, k) => a + off[k]), hull(box, top));
|
|
87
|
+
}
|
package/ops.d.mts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Booleans for an engine: { engine, union, subtract, intersect, stats: { ops, fallbacks } }.
|
|
3
|
+
* @param {'jscad' | 'manifold'} [engine]
|
|
4
|
+
*/
|
|
5
|
+
export function ops(engine?: "jscad" | "manifold"): Promise<{
|
|
6
|
+
engine: "jscad";
|
|
7
|
+
stats: {
|
|
8
|
+
ops: number;
|
|
9
|
+
fallbacks: number;
|
|
10
|
+
};
|
|
11
|
+
union: (...a: any[]) => jscad.geometries.geom2.Geom2;
|
|
12
|
+
subtract: (...a: any[]) => jscad.geometries.geom2.Geom2;
|
|
13
|
+
intersect: (...a: any[]) => jscad.geometries.geom2.Geom2;
|
|
14
|
+
} | {
|
|
15
|
+
engine: "manifold";
|
|
16
|
+
stats: {
|
|
17
|
+
ops: number;
|
|
18
|
+
fallbacks: number;
|
|
19
|
+
};
|
|
20
|
+
union: (...a: any[]) => any;
|
|
21
|
+
subtract: (...a: any[]) => any;
|
|
22
|
+
intersect: (...a: any[]) => any;
|
|
23
|
+
}>;
|
|
24
|
+
import jscad from '@jscad/modeling';
|
package/ops.mjs
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// Boolean operations behind one interface, so a design can say what it means (v.ops.subtract(case, holes)) and the
|
|
2
|
+
// workspace chooses the engine: JSCAD's own (the default, exactly as before) or Manifold (manifold-3d, WASM: much
|
|
3
|
+
// faster, and always watertight). Each op takes shapes or arrays of them, like JSCAD's. With Manifold, a shape that
|
|
4
|
+
// can't be read as a closed solid falls back to JSCAD for that op (counted in stats.fallbacks).
|
|
5
|
+
// const o = await ops('manifold'); o.union(a, b); o.subtract(a, b, c); o.intersect(a, b); o.stats
|
|
6
|
+
import jscad from '@jscad/modeling';
|
|
7
|
+
|
|
8
|
+
const { geom3, poly3 } = jscad.geometries;
|
|
9
|
+
const flat = (args) => args.flat(Infinity).filter((g) => g != null);
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Booleans for an engine: { engine, union, subtract, intersect, stats: { ops, fallbacks } }.
|
|
13
|
+
* @param {'jscad' | 'manifold'} [engine]
|
|
14
|
+
*/
|
|
15
|
+
export async function ops(engine = 'jscad') {
|
|
16
|
+
const stats = { ops: 0, fallbacks: 0 };
|
|
17
|
+
const { union, subtract, intersect } = jscad.booleans;
|
|
18
|
+
if (engine === 'jscad') return { engine, stats, union: (...a) => (stats.ops++, union(...flat(a))), subtract: (...a) => (stats.ops++, subtract(...flat(a))), intersect: (...a) => (stats.ops++, intersect(...flat(a))) };
|
|
19
|
+
if (engine !== 'manifold') throw new Error(`no boolean engine "${engine}" (jscad or manifold)`);
|
|
20
|
+
let wasm;
|
|
21
|
+
try { wasm = await (await import('manifold-3d')).default(); } catch (e) {
|
|
22
|
+
throw Object.assign(new Error('the manifold engine needs manifold-3d: npm install manifold-3d (in the workspace)'), { code: 'engine.missing', cause: e });
|
|
23
|
+
}
|
|
24
|
+
wasm.setup();
|
|
25
|
+
const { Manifold, Mesh } = wasm;
|
|
26
|
+
// JSCAD → Manifold: the shape's faces as triangles, corners shared where they meet
|
|
27
|
+
const toManifold = (g) => {
|
|
28
|
+
const verts = [], tris = [], index = new Map();
|
|
29
|
+
const at = (v) => { const k = `${v[0]},${v[1]},${v[2]}`; if (!index.has(k)) { index.set(k, verts.length / 3); verts.push(v[0], v[1], v[2]); } return index.get(k); };
|
|
30
|
+
for (const p of geom3.toPolygons(g)) { const ids = p.vertices.map(at); for (let i = 1; i < ids.length - 1; i++) tris.push(ids[0], ids[i], ids[i + 1]); }
|
|
31
|
+
const mesh = new Mesh({ numProp: 3, vertProperties: new Float32Array(verts), triVerts: new Uint32Array(tris) });
|
|
32
|
+
mesh.merge();
|
|
33
|
+
const m = new Manifold(mesh);
|
|
34
|
+
if (m.status() !== 'NoError') { m.delete(); throw new Error(`not a closed solid (${m.status()})`); }
|
|
35
|
+
return m;
|
|
36
|
+
};
|
|
37
|
+
// Manifold → JSCAD: its triangles as faces
|
|
38
|
+
const toGeom = (m) => {
|
|
39
|
+
const { vertProperties: v, triVerts: t, numProp: n } = m.getMesh(), polys = [];
|
|
40
|
+
for (let i = 0; i < t.length; i += 3) polys.push(poly3.create([t[i], t[i + 1], t[i + 2]].map((k) => [v[k * n], v[k * n + 1], v[k * n + 2]])));
|
|
41
|
+
return geom3.create(polys);
|
|
42
|
+
};
|
|
43
|
+
const run = (name, jscadOp, list) => {
|
|
44
|
+
stats.ops++;
|
|
45
|
+
const shapes = flat(list);
|
|
46
|
+
if (shapes.length < 2) return shapes[0] ? jscadOp(...shapes) : geom3.create();
|
|
47
|
+
let made = [];
|
|
48
|
+
try {
|
|
49
|
+
made = shapes.map(toManifold);
|
|
50
|
+
const out = name === 'union' ? Manifold.union(made) : name === 'intersect' ? Manifold.intersection(made)
|
|
51
|
+
: made.slice(1).reduce((a, b) => { const r = a.subtract(b); if (a !== made[0]) a.delete(); return r; }, made[0]);
|
|
52
|
+
const g = toGeom(out);
|
|
53
|
+
if (!made.includes(out)) out.delete();
|
|
54
|
+
return g;
|
|
55
|
+
} catch {
|
|
56
|
+
stats.fallbacks++;
|
|
57
|
+
return jscadOp(...shapes);
|
|
58
|
+
} finally { for (const m of made) m.delete(); }
|
|
59
|
+
};
|
|
60
|
+
return { engine, stats, union: (...a) => run('union', union, a), subtract: (...a) => run('subtract', subtract, a), intersect: (...a) => run('intersect', intersect, a) };
|
|
61
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rulecad/shapes",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Shape helpers for printed JSCAD designs: text that prints cleanly, anchors on a face, clean local cuts, and enclosure pieces (shells, lids, rails, print-safe holes).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -13,7 +13,11 @@
|
|
|
13
13
|
"enclosure.mjs",
|
|
14
14
|
"enclosure.d.mts",
|
|
15
15
|
"README.md",
|
|
16
|
-
"LICENSE"
|
|
16
|
+
"LICENSE",
|
|
17
|
+
"features.mjs",
|
|
18
|
+
"features.d.mts",
|
|
19
|
+
"ops.mjs",
|
|
20
|
+
"ops.d.mts"
|
|
17
21
|
],
|
|
18
22
|
"license": "MIT",
|
|
19
23
|
"keywords": [
|
|
@@ -39,7 +43,13 @@
|
|
|
39
43
|
"@rulecad/variables": "^0.1.0"
|
|
40
44
|
},
|
|
41
45
|
"peerDependencies": {
|
|
42
|
-
"@jscad/modeling": "^2.12.0"
|
|
46
|
+
"@jscad/modeling": "^2.12.0",
|
|
47
|
+
"manifold-3d": "^3.5.0"
|
|
43
48
|
},
|
|
44
|
-
"types": "./shapes.d.mts"
|
|
49
|
+
"types": "./shapes.d.mts",
|
|
50
|
+
"peerDependenciesMeta": {
|
|
51
|
+
"manifold-3d": {
|
|
52
|
+
"optional": true
|
|
53
|
+
}
|
|
54
|
+
}
|
|
45
55
|
}
|
package/shapes.d.mts
CHANGED
|
@@ -22,6 +22,8 @@ export function anchor({ width, depth }: {
|
|
|
22
22
|
/** a with b taken out, cutting only a's faces near b. @param {object} a JSCAD geom3 @param {object} b JSCAD geom3 @param {number} [margin] @returns {object} */
|
|
23
23
|
export function cut(a: object, b: object, margin?: number): object;
|
|
24
24
|
export function size(g: any): number[];
|
|
25
|
+
export { ops } from "./ops.mjs";
|
|
25
26
|
export const scale: typeof jscad.transforms.scale;
|
|
26
27
|
import jscad from '@jscad/modeling';
|
|
27
28
|
export { outline, slab, shell, lid, dovetail, gabled, diamond, vents } from "./enclosure.mjs";
|
|
29
|
+
export { countersink, teardropHole, nutPocket, crushRibs, wallOpening } from "./features.mjs";
|
package/shapes.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Shape helpers for JSCAD designs that are printed: text that prints, placing things on a face, and the pieces of
|
|
2
|
-
// enclosures (enclosure.mjs: outlines, slabs, shells, lids, dovetail rails, print-safe holes, vents)
|
|
2
|
+
// enclosures (enclosure.mjs: outlines, slabs, shells, lids, dovetail rails, print-safe holes, vents), and print-aware
|
|
3
|
+
// features (features.mjs: countersinks, teardrop holes, nut pockets, crush ribs, wall openings).
|
|
3
4
|
// text({ text, height, stroke, segments }) -> a 2D outline of the text, centred on 0: JSCAD's single-line
|
|
4
5
|
// font, scaled so a capital is height tall, each line thickened to stroke wide (whole print lines, so it prints).
|
|
5
6
|
// The arrows the font lacks (up, down, left, right) are drawn in the same stroke.
|
|
@@ -82,3 +83,5 @@ export function cut(a, b, margin = 0.05) {
|
|
|
82
83
|
export const size = (g) => { const [lo, hi] = measureBoundingBox(g); return [hi[0] - lo[0], hi[1] - lo[1]]; };
|
|
83
84
|
export { scale };
|
|
84
85
|
export { outline, slab, shell, lid, dovetail, gabled, diamond, vents } from './enclosure.mjs';
|
|
86
|
+
export { countersink, teardropHole, nutPocket, crushRibs, wallOpening } from './features.mjs';
|
|
87
|
+
export { ops } from './ops.mjs';
|