partforge 0.164.0 → 0.164.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/docs/AUTHORING-PARTS.md
CHANGED
|
@@ -1761,8 +1761,10 @@ const plate = k.shape2d(roundedRectProfile(40, 24, 4))
|
|
|
1761
1761
|
.extrude({ h: 3 }); // sugar for k.extrude({ profile: …, h: 3 }); .revolve({ degrees }) too
|
|
1762
1762
|
```
|
|
1763
1763
|
|
|
1764
|
-
A `Shape2D` also carries `.extrude({ h, twist?, scaleTop? })` and `.revolve({ degrees? })`
|
|
1765
|
-
sugar (equivalent to the `k.extrude`/`k.revolve` forms
|
|
1764
|
+
A `Shape2D` also carries `.extrude({ h, twist?, scaleTop?, bevel? })` and `.revolve({ degrees? })`
|
|
1765
|
+
sugar (equivalent to the `k.extrude`/`k.revolve` forms — every option is passed through, so
|
|
1766
|
+
`shape.extrude({ h, bevel: 1 })` bevels the rims exactly as `k.extrude` does; before partforge
|
|
1767
|
+
0.163.2 the sugar dropped `bevel` and any unknown key without a word), and `.regions()` — scission, which
|
|
1766
1768
|
returns each disjoint region as its own live `Shape2D` (vs `.toRegions()`, which returns raw
|
|
1767
1769
|
`{outer, holes}` data).
|
|
1768
1770
|
|
package/package.json
CHANGED
|
@@ -135,7 +135,7 @@ export const ROUTED_CAD_OPS = ["shell"];
|
|
|
135
135
|
* @property {(tolerance:number) => Shape2D} simplify corner-preserving decimation/refit within tolerance
|
|
136
136
|
* @property {() => {index:number,point:number[],interiorAngleDeg:number,convex:boolean,segTypes:string[]}[]} corners corner list (the positional order fillet/chamfer `{indices}` index into)
|
|
137
137
|
* @property {(p:number[]) => boolean} contains is point [x,y] inside the shape (holes excluded)
|
|
138
|
-
* @property {(o?:{h:number,twist?:number,scaleTop?:number}) => Solid} extrude sugar for k.extrude({profile:this,…})
|
|
138
|
+
* @property {(o?:{h:number,twist?:number,scaleTop?:number,bevel?:number|{bottom?:number,top?:number}}) => Solid} extrude sugar for k.extrude({profile:this,…}); every option is forwarded
|
|
139
139
|
* @property {(o?:{degrees?:number}) => Solid} revolve sugar for k.revolve({profile:this,…})
|
|
140
140
|
*
|
|
141
141
|
* @typedef {Object} GeometryKernel
|
|
@@ -14,12 +14,17 @@ export function addShape2dSugar(s, { shape2d, extrude, revolve }) {
|
|
|
14
14
|
// lifted and resolved by every boolean since — re-lifting them untrusted would
|
|
15
15
|
// re-run profile validation on machine-produced geometry on every call.
|
|
16
16
|
s.regions = () => s.toRegions().map((r) => shape2d.trusted(r));
|
|
17
|
-
// .extrude({ h, twist?, scaleTop? }) / .revolve({ degrees? }) → Solid. Sugar for
|
|
18
|
-
// k.extrude({ profile: shape, … }) / k.revolve({ profile: shape, … }).
|
|
19
|
-
//
|
|
20
|
-
//
|
|
21
|
-
//
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
// .extrude({ h, twist?, scaleTop?, bevel? }) / .revolve({ degrees? }) → Solid. Sugar for
|
|
18
|
+
// k.extrude({ profile: shape, … }) / k.revolve({ profile: shape, … }). Every option is
|
|
19
|
+
// forwarded as-is, so the kernel op's own key/required-arg validation fires: a missing
|
|
20
|
+
// `h` throws "extrude: h is required", an unknown key throws, and an option the kernel
|
|
21
|
+
// grows later (as `bevel` was) works here with no change. Never list the keys: a list
|
|
22
|
+
// silently drops whatever it leaves out. `profile` is refused — this shape is the profile.
|
|
23
|
+
const sugar = (op, fn) => (o = {}) => {
|
|
24
|
+
if (o.profile !== undefined) throw new Error(`Shape2D.${op}: don't pass profile — the shape you call .${op}() on is the profile`);
|
|
25
|
+
return fn({ ...o, profile: s });
|
|
26
|
+
};
|
|
27
|
+
s.extrude = sugar("extrude", extrude);
|
|
28
|
+
s.revolve = sugar("revolve", revolve);
|
|
24
29
|
return s;
|
|
25
30
|
}
|