@faicad/faijs 0.18.3 → 0.19.0
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/dist/api/api-namespace.d.ts.map +1 -1
- package/dist/api/api-namespace.js +4 -1
- package/dist/api/api-namespace.js.map +1 -1
- package/dist/api/brep-mirror/joinery-brep.d.ts +1 -1
- package/dist/api/brep-mirror/joinery-brep.d.ts.map +1 -1
- package/dist/api/brep-mirror/joinery-brep.js +19 -19
- package/dist/api/brep-mirror/joinery-brep.js.map +1 -1
- package/dist/api/index.d.ts +4 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +3 -0
- package/dist/api/index.js.map +1 -1
- package/dist/api/profile.d.ts.map +1 -1
- package/dist/api/profile.js +113 -182
- package/dist/api/profile.js.map +1 -1
- package/dist/api/punch-hole.d.ts +74 -0
- package/dist/api/punch-hole.d.ts.map +1 -0
- package/dist/api/punch-hole.js +207 -0
- package/dist/api/punch-hole.js.map +1 -0
- package/dist/api/sketch-on-face.d.ts +85 -0
- package/dist/api/sketch-on-face.d.ts.map +1 -0
- package/dist/api/sketch-on-face.js +136 -0
- package/dist/api/sketch-on-face.js.map +1 -0
- package/dist/api/sketch-on-plane.d.ts +81 -0
- package/dist/api/sketch-on-plane.d.ts.map +1 -0
- package/dist/api/sketch-on-plane.js +103 -0
- package/dist/api/sketch-on-plane.js.map +1 -0
- package/dist/boolean/csg-backend.d.ts +6 -6
- package/dist/boolean/csg-backend.d.ts.map +1 -1
- package/dist/boolean/csg-backend.js +9 -9
- package/dist/boolean/csg-backend.js.map +1 -1
- package/dist/boolean/csg-core.d.ts +10 -10
- package/dist/boolean/csg-core.d.ts.map +1 -1
- package/dist/boolean/csg-core.js +24 -24
- package/dist/boolean/csg-core.js.map +1 -1
- package/dist/boolean/extrude-helpers.d.ts +8 -8
- package/dist/boolean/extrude-helpers.d.ts.map +1 -1
- package/dist/boolean/extrude-helpers.js +13 -13
- package/dist/boolean/extrude-helpers.js.map +1 -1
- package/dist/brep/brep-ops.d.ts +20 -6
- package/dist/brep/brep-ops.d.ts.map +1 -1
- package/dist/brep/brep-ops.js +38 -12
- package/dist/brep/brep-ops.js.map +1 -1
- package/dist/browser-host/csg-worker-protocol.d.ts +3 -3
- package/dist/browser-host/csg-worker-protocol.d.ts.map +1 -1
- package/dist/browser-host/csg-worker-protocol.js.map +1 -1
- package/dist/browser-host/csg-worker.js +3 -3
- package/dist/browser-host/csg-worker.js.map +1 -1
- package/dist/browser-host/inline-csg-backend.d.ts +3 -3
- package/dist/browser-host/inline-csg-backend.d.ts.map +1 -1
- package/dist/browser-host/inline-csg-backend.js +3 -3
- package/dist/browser-host/inline-csg-backend.js.map +1 -1
- package/dist/browser-host/worker-csg-backend.d.ts +3 -3
- package/dist/browser-host/worker-csg-backend.d.ts.map +1 -1
- package/dist/browser-host/worker-csg-backend.js.map +1 -1
- package/dist/cad-runtime/ports.d.ts +3 -3
- package/dist/cad-runtime/ports.d.ts.map +1 -1
- package/dist/cad-runtime/ports.js.map +1 -1
- package/dist/geometry2d/adapt.d.ts +46 -0
- package/dist/geometry2d/adapt.d.ts.map +1 -0
- package/dist/geometry2d/adapt.js +41 -0
- package/dist/geometry2d/adapt.js.map +1 -0
- package/dist/geometry2d/bbox2d.d.ts +82 -0
- package/dist/geometry2d/bbox2d.d.ts.map +1 -0
- package/dist/geometry2d/bbox2d.js +123 -0
- package/dist/geometry2d/bbox2d.js.map +1 -0
- package/dist/geometry2d/blueprint-sketcher.d.ts +27 -0
- package/dist/geometry2d/blueprint-sketcher.d.ts.map +1 -0
- package/dist/geometry2d/blueprint-sketcher.js +29 -0
- package/dist/geometry2d/blueprint-sketcher.js.map +1 -0
- package/dist/geometry2d/blueprint.d.ts +102 -0
- package/dist/geometry2d/blueprint.d.ts.map +1 -0
- package/dist/geometry2d/blueprint.js +225 -0
- package/dist/geometry2d/blueprint.js.map +1 -0
- package/dist/geometry2d/blueprints.d.ts +58 -0
- package/dist/geometry2d/blueprints.d.ts.map +1 -0
- package/dist/geometry2d/blueprints.js +72 -0
- package/dist/geometry2d/blueprints.js.map +1 -0
- package/dist/geometry2d/bridge/lift-on-plane.d.ts +50 -0
- package/dist/geometry2d/bridge/lift-on-plane.d.ts.map +1 -0
- package/dist/geometry2d/bridge/lift-on-plane.js +72 -0
- package/dist/geometry2d/bridge/lift-on-plane.js.map +1 -0
- package/dist/geometry2d/bridge/on-surface.d.ts +98 -0
- package/dist/geometry2d/bridge/on-surface.d.ts.map +1 -0
- package/dist/geometry2d/bridge/on-surface.js +94 -0
- package/dist/geometry2d/bridge/on-surface.js.map +1 -0
- package/dist/geometry2d/bridge/plane.d.ts +69 -0
- package/dist/geometry2d/bridge/plane.d.ts.map +1 -0
- package/dist/geometry2d/bridge/plane.js +96 -0
- package/dist/geometry2d/bridge/plane.js.map +1 -0
- package/dist/geometry2d/canned-blueprints.d.ts +44 -0
- package/dist/geometry2d/canned-blueprints.d.ts.map +1 -0
- package/dist/geometry2d/canned-blueprints.js +94 -0
- package/dist/geometry2d/canned-blueprints.js.map +1 -0
- package/dist/geometry2d/compound-blueprint.d.ts +72 -0
- package/dist/geometry2d/compound-blueprint.d.ts.map +1 -0
- package/dist/geometry2d/compound-blueprint.js +95 -0
- package/dist/geometry2d/compound-blueprint.js.map +1 -0
- package/dist/geometry2d/curve2d.d.ts +298 -0
- package/dist/geometry2d/curve2d.d.ts.map +1 -0
- package/dist/geometry2d/curve2d.js +1110 -0
- package/dist/geometry2d/curve2d.js.map +1 -0
- package/dist/geometry2d/index.d.ts +22 -0
- package/dist/geometry2d/index.d.ts.map +1 -0
- package/dist/geometry2d/index.js +21 -0
- package/dist/geometry2d/index.js.map +1 -0
- package/dist/geometry2d/organise.d.ts +28 -0
- package/dist/geometry2d/organise.d.ts.map +1 -0
- package/dist/geometry2d/organise.js +108 -0
- package/dist/geometry2d/organise.js.map +1 -0
- package/dist/geometry2d/pen-sketcher.d.ts +340 -0
- package/dist/geometry2d/pen-sketcher.d.ts.map +1 -0
- package/dist/geometry2d/pen-sketcher.js +477 -0
- package/dist/geometry2d/pen-sketcher.js.map +1 -0
- package/dist/geometry2d/point.d.ts +44 -0
- package/dist/geometry2d/point.d.ts.map +1 -0
- package/dist/geometry2d/point.js +57 -0
- package/dist/geometry2d/point.js.map +1 -0
- package/dist/geometry2d/svg-ellipse.d.ts +74 -0
- package/dist/geometry2d/svg-ellipse.d.ts.map +1 -0
- package/dist/geometry2d/svg-ellipse.js +163 -0
- package/dist/geometry2d/svg-ellipse.js.map +1 -0
- package/dist/lang/symbol-table.generated.d.ts +3 -0
- package/dist/lang/symbol-table.generated.d.ts.map +1 -1
- package/dist/lang/symbol-table.generated.js +3 -0
- package/dist/lang/symbol-table.generated.js.map +1 -1
- package/dist/mesh/types.d.ts +1 -1
- package/dist/mesh/types.d.ts.map +1 -1
- package/dist/mesh/types.js.map +1 -1
- package/package.json +9 -1
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* geometry2d — SVG-style elliptical arc construction (SVG endpoint form).
|
|
3
|
+
*
|
|
4
|
+
* Ported from brepjs `2d/blueprints/ellipseUtils.ts` (Apache-2.0). Adapts the
|
|
5
|
+
* SVG F.6.5/F.6.6 endpoint→center conversion onto the pure `Curve2dObj` base:
|
|
6
|
+
* the resulting elliptical arc is a `TrimmedCurve2d` over an `Ellipse2d`, whose
|
|
7
|
+
* parameter is the sweep angle in radians (CCW positive).
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
*/
|
|
11
|
+
import { type Curve2dObj } from './curve2d.js';
|
|
12
|
+
/** A `[x, y]` 2D point. */
|
|
13
|
+
type Pt = [number, number];
|
|
14
|
+
/**
|
|
15
|
+
* Normalize ellipse radii so the major axis is horizontal, adjusting rotation.
|
|
16
|
+
* @param horizontalRadius - the radius along the SVG x-axis.
|
|
17
|
+
* @param verticalRadius - the radius along the SVG y-axis.
|
|
18
|
+
* @param rotation - rotation in degrees.
|
|
19
|
+
* @returns the normalized radius set.
|
|
20
|
+
*/
|
|
21
|
+
export declare function normalizeEllipseRadii(horizontalRadius: number, verticalRadius: number, rotation: number): {
|
|
22
|
+
majorRadius: number;
|
|
23
|
+
minorRadius: number;
|
|
24
|
+
rotationAngle: number;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Convert SVG elliptical-arc endpoint parameters to the centerly parametrization
|
|
28
|
+
* (SVG F6.5.1–F6.5.6).
|
|
29
|
+
* @param x1 - start x.
|
|
30
|
+
* @param y1 - start y.
|
|
31
|
+
* @param x2 - end x.
|
|
32
|
+
* @param y2 - end y.
|
|
33
|
+
* @param rx - x radius.
|
|
34
|
+
* @param ry - y radius.
|
|
35
|
+
* @param phi - rotation angle (radians).
|
|
36
|
+
* @param fA - large-arc flag.
|
|
37
|
+
* @param fS - sweep flag.
|
|
38
|
+
* @returns the center, radii and angular parametrization.
|
|
39
|
+
*/
|
|
40
|
+
export declare function convertSvgEllipseParams(x1: number, y1: number, x2: number, y2: number, rx: number, ry: number, phi: number, fA: boolean, fS: boolean): {
|
|
41
|
+
cx: number;
|
|
42
|
+
cy: number;
|
|
43
|
+
startAngle: number;
|
|
44
|
+
endAngle: number;
|
|
45
|
+
clockwise: boolean;
|
|
46
|
+
rx: number;
|
|
47
|
+
ry: number;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Build an elliptical arc `Curve2dObj` from SVG endpoint parameters.
|
|
51
|
+
* @param startUV - the start point.
|
|
52
|
+
* @param endUV - the end point.
|
|
53
|
+
* @param majorRadius - the major radius.
|
|
54
|
+
* @param minorRadius - the minor radius.
|
|
55
|
+
* @param rotationAngleDeg - rotation in degrees.
|
|
56
|
+
* @param longAxis - SVG large-arc flag.
|
|
57
|
+
* @param sweep - SVG sweep flag.
|
|
58
|
+
* @returns a trimmed elliptical arc.
|
|
59
|
+
*/
|
|
60
|
+
export declare function makeEllipseArcFromSvgParams(startUV: Pt, endUV: Pt, majorRadius: number, minorRadius: number, rotationAngleDeg: number, longAxis: boolean, sweep: boolean): Curve2dObj;
|
|
61
|
+
/**
|
|
62
|
+
* Build an elliptical arc as a trimmed ellipse over an angle range.
|
|
63
|
+
* @param rx - x radius.
|
|
64
|
+
* @param ry - y radius.
|
|
65
|
+
* @param startAngle - start angle (radians, ellipse-param space).
|
|
66
|
+
* @param endAngle - end angle (radians).
|
|
67
|
+
* @param center - the ellipse center.
|
|
68
|
+
* @param xDir - the in-plane X axis of the ellipse.
|
|
69
|
+
* @param clockwise - sweep direction.
|
|
70
|
+
* @returns a trimmed elliptical arc.
|
|
71
|
+
*/
|
|
72
|
+
export declare function makeEllipseArcFromCenter(rx: number, ry: number, startAngle: number, endAngle: number, center: Pt, xDir: Pt, clockwise: boolean): Curve2dObj;
|
|
73
|
+
export {};
|
|
74
|
+
//# sourceMappingURL=svg-ellipse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"svg-ellipse.d.ts","sourceRoot":"","sources":["../../src/geometry2d/svg-ellipse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAiB,KAAK,UAAU,EAAE,MAAM,WAAW,CAAA;AAM1D,2BAA2B;AAC3B,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AA0C1B;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,gBAAgB,EAAE,MAAM,EACxB,cAAc,EAAE,MAAM,EACtB,QAAQ,EAAE,MAAM,GACf;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAA;CAAE,CAKrE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,uBAAuB,CACrC,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,GAAG,EAAE,MAAM,EACX,EAAE,EAAE,OAAO,EACX,EAAE,EAAE,OAAO,GACV;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,OAAO,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAiC9G;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,EAAE,EACX,KAAK,EAAE,EAAE,EACT,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,EACnB,gBAAgB,EAAE,MAAM,EACxB,QAAQ,EAAE,OAAO,EACjB,KAAK,EAAE,OAAO,GACb,UAAU,CASZ;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CACtC,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,EAAE,EACV,IAAI,EAAE,EAAE,EACR,SAAS,EAAE,OAAO,GACjB,UAAU,CAOZ"}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* geometry2d — SVG-style elliptical arc construction (SVG endpoint form).
|
|
3
|
+
*
|
|
4
|
+
* Ported from brepjs `2d/blueprints/ellipseUtils.ts` (Apache-2.0). Adapts the
|
|
5
|
+
* SVG F.6.5/F.6.6 endpoint→center conversion onto the pure `Curve2dObj` base:
|
|
6
|
+
* the resulting elliptical arc is a `TrimmedCurve2d` over an `Ellipse2d`, whose
|
|
7
|
+
* parameter is the sweep angle in radians (CCW positive).
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
*/
|
|
11
|
+
import { makeEllipse2d } from './curve2d.js';
|
|
12
|
+
import { normalize2d } from './point.js';
|
|
13
|
+
const DEG2RAD = Math.PI / 180;
|
|
14
|
+
const TWO_PI = Math.PI * 2;
|
|
15
|
+
function bug(caller, message) {
|
|
16
|
+
throw new Error(`[geometry2d/svg-ellipse] ${caller}: ${message}`);
|
|
17
|
+
}
|
|
18
|
+
/** Rotate a 2D point by `rad` radians. */
|
|
19
|
+
function rotate2d([x, y], rad) {
|
|
20
|
+
return [x * Math.cos(rad) - y * Math.sin(rad), x * Math.sin(rad) + y * Math.cos(rad)];
|
|
21
|
+
}
|
|
22
|
+
/** Signed angle from `[ux,uy]` to `[vx,vy]` in `[−π, π]`. */
|
|
23
|
+
function radianAngle(ux, uy, vx, vy) {
|
|
24
|
+
const dot = ux * vx + uy * vy;
|
|
25
|
+
const mod = Math.sqrt((ux * ux + uy * uy) * (vx * vx + vy * vy));
|
|
26
|
+
if (mod < 1e-12)
|
|
27
|
+
bug('radianAngle', 'Cannot compute angle between zero-length vectors');
|
|
28
|
+
let rad = Math.acos(Math.max(-1, Math.min(1, dot / mod)));
|
|
29
|
+
if (ux * vy - uy * vx < 0)
|
|
30
|
+
rad = -rad;
|
|
31
|
+
return rad;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Compute arc start/end angles from the unit-circle parameterization (SVG F6.5.5).
|
|
35
|
+
* @param xcr1 - first unit-circle x.
|
|
36
|
+
* @param ycr1 - first unit-circle y.
|
|
37
|
+
* @param xcr2 - second unit-circle x.
|
|
38
|
+
* @param ycr2 - second unit-circle y.
|
|
39
|
+
* @param fS - sweep flag.
|
|
40
|
+
* @returns the `{ startAngle, endAngle }` pair (radians).
|
|
41
|
+
*/
|
|
42
|
+
function computeArcAngles(xcr1, ycr1, xcr2, ycr2, fS) {
|
|
43
|
+
const startAngle = radianAngle(1, 0, xcr1, ycr1);
|
|
44
|
+
let deltaAngle = radianAngle(xcr1, ycr1, -xcr2, -ycr2);
|
|
45
|
+
while (deltaAngle > TWO_PI)
|
|
46
|
+
deltaAngle -= TWO_PI;
|
|
47
|
+
while (deltaAngle < 0)
|
|
48
|
+
deltaAngle += TWO_PI;
|
|
49
|
+
if (!fS)
|
|
50
|
+
deltaAngle -= TWO_PI;
|
|
51
|
+
let endAngle = startAngle + deltaAngle;
|
|
52
|
+
while (endAngle > TWO_PI)
|
|
53
|
+
endAngle -= TWO_PI;
|
|
54
|
+
while (endAngle < 0)
|
|
55
|
+
endAngle += TWO_PI;
|
|
56
|
+
return { startAngle, endAngle };
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Normalize ellipse radii so the major axis is horizontal, adjusting rotation.
|
|
60
|
+
* @param horizontalRadius - the radius along the SVG x-axis.
|
|
61
|
+
* @param verticalRadius - the radius along the SVG y-axis.
|
|
62
|
+
* @param rotation - rotation in degrees.
|
|
63
|
+
* @returns the normalized radius set.
|
|
64
|
+
*/
|
|
65
|
+
export function normalizeEllipseRadii(horizontalRadius, verticalRadius, rotation) {
|
|
66
|
+
if (horizontalRadius < verticalRadius) {
|
|
67
|
+
return { majorRadius: verticalRadius, minorRadius: horizontalRadius, rotationAngle: rotation + 90 };
|
|
68
|
+
}
|
|
69
|
+
return { majorRadius: horizontalRadius, minorRadius: verticalRadius, rotationAngle: rotation };
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Convert SVG elliptical-arc endpoint parameters to the centerly parametrization
|
|
73
|
+
* (SVG F6.5.1–F6.5.6).
|
|
74
|
+
* @param x1 - start x.
|
|
75
|
+
* @param y1 - start y.
|
|
76
|
+
* @param x2 - end x.
|
|
77
|
+
* @param y2 - end y.
|
|
78
|
+
* @param rx - x radius.
|
|
79
|
+
* @param ry - y radius.
|
|
80
|
+
* @param phi - rotation angle (radians).
|
|
81
|
+
* @param fA - large-arc flag.
|
|
82
|
+
* @param fS - sweep flag.
|
|
83
|
+
* @returns the center, radii and angular parametrization.
|
|
84
|
+
*/
|
|
85
|
+
export function convertSvgEllipseParams(x1, y1, x2, y2, rx, ry, phi, fA, fS) {
|
|
86
|
+
if (rx < 0)
|
|
87
|
+
rx = -rx;
|
|
88
|
+
if (ry < 0)
|
|
89
|
+
ry = -ry;
|
|
90
|
+
if (rx < 1e-10 || ry < 1e-10)
|
|
91
|
+
bug('convertSvgEllipseParams', 'rx and ry cannot be 0');
|
|
92
|
+
const s_phi = Math.sin(phi);
|
|
93
|
+
const c_phi = Math.cos(phi);
|
|
94
|
+
const hd_x = (x1 - x2) / 2;
|
|
95
|
+
const hd_y = (y1 - y2) / 2;
|
|
96
|
+
const hs_x = (x1 + x2) / 2;
|
|
97
|
+
const hs_y = (y1 + y2) / 2;
|
|
98
|
+
// F6.5.1: transform to (x', y')
|
|
99
|
+
const x1_ = c_phi * hd_x + s_phi * hd_y;
|
|
100
|
+
const y1_ = c_phi * hd_y - s_phi * hd_x;
|
|
101
|
+
// F.6.6: correct out-of-range radii
|
|
102
|
+
const lambda = (x1_ * x1_) / (rx * rx) + (y1_ * y1_) / (ry * ry);
|
|
103
|
+
if (lambda > 1) {
|
|
104
|
+
rx = rx * Math.sqrt(lambda);
|
|
105
|
+
ry = ry * Math.sqrt(lambda);
|
|
106
|
+
}
|
|
107
|
+
const rxry = rx * ry;
|
|
108
|
+
const rxy1_ = rx * y1_;
|
|
109
|
+
const ryx1_ = ry * x1_;
|
|
110
|
+
const sum_of_sq = rxy1_ * rxy1_ + ryx1_ * ryx1_;
|
|
111
|
+
if (!sum_of_sq)
|
|
112
|
+
bug('convertSvgEllipseParams', 'Start point cannot be the same as end point');
|
|
113
|
+
let coe = Math.sqrt(Math.abs((rxry * rxry - sum_of_sq) / sum_of_sq));
|
|
114
|
+
if (fA === fS)
|
|
115
|
+
coe = -coe;
|
|
116
|
+
const cx_ = (coe * rxy1_) / ry;
|
|
117
|
+
const cy_ = (-coe * ryx1_) / rx;
|
|
118
|
+
// F6.5.3: back-transform to absolute center
|
|
119
|
+
const cx = c_phi * cx_ - s_phi * cy_ + hs_x;
|
|
120
|
+
const cy = s_phi * cx_ + c_phi * cy_ + hs_y;
|
|
121
|
+
const { startAngle, endAngle } = computeArcAngles((x1_ - cx_) / rx, (y1_ - cy_) / ry, (x1_ + cx_) / rx, (y1_ + cy_) / ry, fS);
|
|
122
|
+
return { cx, cy, startAngle, endAngle, clockwise: fS, rx, ry };
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Build an elliptical arc `Curve2dObj` from SVG endpoint parameters.
|
|
126
|
+
* @param startUV - the start point.
|
|
127
|
+
* @param endUV - the end point.
|
|
128
|
+
* @param majorRadius - the major radius.
|
|
129
|
+
* @param minorRadius - the minor radius.
|
|
130
|
+
* @param rotationAngleDeg - rotation in degrees.
|
|
131
|
+
* @param longAxis - SVG large-arc flag.
|
|
132
|
+
* @param sweep - SVG sweep flag.
|
|
133
|
+
* @returns a trimmed elliptical arc.
|
|
134
|
+
*/
|
|
135
|
+
export function makeEllipseArcFromSvgParams(startUV, endUV, majorRadius, minorRadius, rotationAngleDeg, longAxis, sweep) {
|
|
136
|
+
const radRotation = rotationAngleDeg * DEG2RAD;
|
|
137
|
+
const xDir = normalize2d(rotate2d([1, 0], radRotation));
|
|
138
|
+
const phi = Math.atan2(xDir[1], xDir[0]);
|
|
139
|
+
const { majorRadius: maAxis, minorRadius: miAxis } = normalizeEllipseRadii(majorRadius, minorRadius, rotationAngleDeg);
|
|
140
|
+
const { cx, cy, startAngle, endAngle, clockwise, rx, ry } = convertSvgEllipseParams(startUV[0], startUV[1], endUV[0], endUV[1], maAxis, miAxis, phi, longAxis, sweep);
|
|
141
|
+
return makeEllipseArcFromCenter(rx, ry, startAngle, endAngle, [cx, cy], xDir, clockwise);
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Build an elliptical arc as a trimmed ellipse over an angle range.
|
|
145
|
+
* @param rx - x radius.
|
|
146
|
+
* @param ry - y radius.
|
|
147
|
+
* @param startAngle - start angle (radians, ellipse-param space).
|
|
148
|
+
* @param endAngle - end angle (radians).
|
|
149
|
+
* @param center - the ellipse center.
|
|
150
|
+
* @param xDir - the in-plane X axis of the ellipse.
|
|
151
|
+
* @param clockwise - sweep direction.
|
|
152
|
+
* @returns a trimmed elliptical arc.
|
|
153
|
+
*/
|
|
154
|
+
export function makeEllipseArcFromCenter(rx, ry, startAngle, endAngle, center, xDir, clockwise) {
|
|
155
|
+
const sense = !clockwise;
|
|
156
|
+
const aStart = sense ? startAngle : -startAngle;
|
|
157
|
+
let aEnd = sense ? endAngle : -endAngle;
|
|
158
|
+
if (aEnd < aStart - 1e-9)
|
|
159
|
+
aEnd += TWO_PI;
|
|
160
|
+
const ellipse = makeEllipse2d(center[0], center[1], rx, ry, xDir[0], xDir[1], sense);
|
|
161
|
+
return { kind2d: 'trimmed', basis: ellipse, tStart: aStart, tEnd: aEnd };
|
|
162
|
+
}
|
|
163
|
+
//# sourceMappingURL=svg-ellipse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"svg-ellipse.js","sourceRoot":"","sources":["../../src/geometry2d/svg-ellipse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,aAAa,EAAmB,MAAM,WAAW,CAAA;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAErC,MAAM,OAAO,GAAG,IAAI,CAAC,EAAE,GAAG,GAAG,CAAA;AAC7B,MAAM,MAAM,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC,CAAA;AAK1B,SAAS,GAAG,CAAC,MAAc,EAAE,OAAe;IAC1C,MAAM,IAAI,KAAK,CAAC,4BAA4B,MAAM,KAAK,OAAO,EAAE,CAAC,CAAA;AACnE,CAAC;AAED,0CAA0C;AAC1C,SAAS,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAK,EAAE,GAAW;IACvC,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,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AAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,CAAA;AAC1E,CAAC","sourcesContent":["/**\n * geometry2d — SVG-style elliptical arc construction (SVG endpoint form).\n *\n * Ported from brepjs `2d/blueprints/ellipseUtils.ts` (Apache-2.0). Adapts the\n * SVG F.6.5/F.6.6 endpoint→center conversion onto the pure `Curve2dObj` base:\n * the resulting elliptical arc is a `TrimmedCurve2d` over an `Ellipse2d`, whose\n * parameter is the sweep angle in radians (CCW positive).\n *\n * @module\n */\n\nimport { makeEllipse2d, type Curve2dObj } from './curve2d'\nimport { normalize2d } from './point'\n\nconst DEG2RAD = Math.PI / 180\nconst TWO_PI = Math.PI * 2\n\n/** A `[x, y]` 2D point. */\ntype Pt = [number, number]\n\nfunction bug(caller: string, message: string): never {\n throw new Error(`[geometry2d/svg-ellipse] ${caller}: ${message}`)\n}\n\n/** Rotate a 2D point by `rad` radians. */\nfunction rotate2d([x, y]: Pt, rad: number): Pt {\n return [x * Math.cos(rad) - y * Math.sin(rad), x * Math.sin(rad) + y * Math.cos(rad)]\n}\n\n/** Signed angle from `[ux,uy]` to `[vx,vy]` in `[−π, π]`. */\nfunction radianAngle(ux: number, uy: number, vx: number, vy: number): number {\n const dot = ux * vx + uy * vy\n const mod = Math.sqrt((ux * ux + uy * uy) * (vx * vx + vy * vy))\n if (mod < 1e-12) bug('radianAngle', 'Cannot compute angle between zero-length vectors')\n let rad = Math.acos(Math.max(-1, Math.min(1, dot / mod)))\n if (ux * vy - uy * vx < 0) rad = -rad\n return rad\n}\n\n/**\n * Compute arc start/end angles from the unit-circle parameterization (SVG F6.5.5).\n * @param xcr1 - first unit-circle x.\n * @param ycr1 - first unit-circle y.\n * @param xcr2 - second unit-circle x.\n * @param ycr2 - second unit-circle y.\n * @param fS - sweep flag.\n * @returns the `{ startAngle, endAngle }` pair (radians).\n */\nfunction computeArcAngles(xcr1: number, ycr1: number, xcr2: number, ycr2: number, fS: boolean): { startAngle: number; endAngle: number } {\n const startAngle = radianAngle(1, 0, xcr1, ycr1)\n let deltaAngle = radianAngle(xcr1, ycr1, -xcr2, -ycr2)\n while (deltaAngle > TWO_PI) deltaAngle -= TWO_PI\n while (deltaAngle < 0) deltaAngle += TWO_PI\n if (!fS) deltaAngle -= TWO_PI\n let endAngle = startAngle + deltaAngle\n while (endAngle > TWO_PI) endAngle -= TWO_PI\n while (endAngle < 0) endAngle += TWO_PI\n return { startAngle, endAngle }\n}\n\n/**\n * Normalize ellipse radii so the major axis is horizontal, adjusting rotation.\n * @param horizontalRadius - the radius along the SVG x-axis.\n * @param verticalRadius - the radius along the SVG y-axis.\n * @param rotation - rotation in degrees.\n * @returns the normalized radius set.\n */\nexport function normalizeEllipseRadii(\n horizontalRadius: number,\n verticalRadius: number,\n rotation: number,\n): { majorRadius: number; minorRadius: number; rotationAngle: number } {\n if (horizontalRadius < verticalRadius) {\n return { majorRadius: verticalRadius, minorRadius: horizontalRadius, rotationAngle: rotation + 90 }\n }\n return { majorRadius: horizontalRadius, minorRadius: verticalRadius, rotationAngle: rotation }\n}\n\n/**\n * Convert SVG elliptical-arc endpoint parameters to the centerly parametrization\n * (SVG F6.5.1–F6.5.6).\n * @param x1 - start x.\n * @param y1 - start y.\n * @param x2 - end x.\n * @param y2 - end y.\n * @param rx - x radius.\n * @param ry - y radius.\n * @param phi - rotation angle (radians).\n * @param fA - large-arc flag.\n * @param fS - sweep flag.\n * @returns the center, radii and angular parametrization.\n */\nexport function convertSvgEllipseParams(\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n rx: number,\n ry: number,\n phi: number,\n fA: boolean,\n fS: boolean,\n): { cx: number; cy: number; startAngle: number; endAngle: number; clockwise: boolean; rx: number; ry: number } {\n if (rx < 0) rx = -rx\n if (ry < 0) ry = -ry\n if (rx < 1e-10 || ry < 1e-10) bug('convertSvgEllipseParams', 'rx and ry cannot be 0')\n const s_phi = Math.sin(phi)\n const c_phi = Math.cos(phi)\n const hd_x = (x1 - x2) / 2\n const hd_y = (y1 - y2) / 2\n const hs_x = (x1 + x2) / 2\n const hs_y = (y1 + y2) / 2\n // F6.5.1: transform to (x', y')\n const x1_ = c_phi * hd_x + s_phi * hd_y\n const y1_ = c_phi * hd_y - s_phi * hd_x\n // F.6.6: correct out-of-range radii\n const lambda = (x1_ * x1_) / (rx * rx) + (y1_ * y1_) / (ry * ry)\n if (lambda > 1) {\n rx = rx * Math.sqrt(lambda)\n ry = ry * Math.sqrt(lambda)\n }\n const rxry = rx * ry\n const rxy1_ = rx * y1_\n const ryx1_ = ry * x1_\n const sum_of_sq = rxy1_ * rxy1_ + ryx1_ * ryx1_\n if (!sum_of_sq) bug('convertSvgEllipseParams', 'Start point cannot be the same as end point')\n let coe = Math.sqrt(Math.abs((rxry * rxry - sum_of_sq) / sum_of_sq))\n if (fA === fS) coe = -coe\n const cx_ = (coe * rxy1_) / ry\n const cy_ = (-coe * ryx1_) / rx\n // F6.5.3: back-transform to absolute center\n const cx = c_phi * cx_ - s_phi * cy_ + hs_x\n const cy = s_phi * cx_ + c_phi * cy_ + hs_y\n const { startAngle, endAngle } = computeArcAngles((x1_ - cx_) / rx, (y1_ - cy_) / ry, (x1_ + cx_) / rx, (y1_ + cy_) / ry, fS)\n return { cx, cy, startAngle, endAngle, clockwise: fS, rx, ry }\n}\n\n/**\n * Build an elliptical arc `Curve2dObj` from SVG endpoint parameters.\n * @param startUV - the start point.\n * @param endUV - the end point.\n * @param majorRadius - the major radius.\n * @param minorRadius - the minor radius.\n * @param rotationAngleDeg - rotation in degrees.\n * @param longAxis - SVG large-arc flag.\n * @param sweep - SVG sweep flag.\n * @returns a trimmed elliptical arc.\n */\nexport function makeEllipseArcFromSvgParams(\n startUV: Pt,\n endUV: Pt,\n majorRadius: number,\n minorRadius: number,\n rotationAngleDeg: number,\n longAxis: boolean,\n sweep: boolean,\n): Curve2dObj {\n const radRotation = rotationAngleDeg * DEG2RAD\n const xDir = normalize2d(rotate2d([1, 0], radRotation))\n const phi = Math.atan2(xDir[1], xDir[0])\n const { majorRadius: maAxis, minorRadius: miAxis } = normalizeEllipseRadii(majorRadius, minorRadius, rotationAngleDeg)\n const { cx, cy, startAngle, endAngle, clockwise, rx, ry } = convertSvgEllipseParams(\n startUV[0], startUV[1], endUV[0], endUV[1], maAxis, miAxis, phi, longAxis, sweep,\n )\n return makeEllipseArcFromCenter(rx, ry, startAngle, endAngle, [cx, cy], xDir, clockwise)\n}\n\n/**\n * Build an elliptical arc as a trimmed ellipse over an angle range.\n * @param rx - x radius.\n * @param ry - y radius.\n * @param startAngle - start angle (radians, ellipse-param space).\n * @param endAngle - end angle (radians).\n * @param center - the ellipse center.\n * @param xDir - the in-plane X axis of the ellipse.\n * @param clockwise - sweep direction.\n * @returns a trimmed elliptical arc.\n */\nexport function makeEllipseArcFromCenter(\n rx: number,\n ry: number,\n startAngle: number,\n endAngle: number,\n center: Pt,\n xDir: Pt,\n clockwise: boolean,\n): Curve2dObj {\n const sense = !clockwise\n const aStart = sense ? startAngle : -startAngle\n let aEnd = sense ? endAngle : -endAngle\n if (aEnd < aStart - 1e-9) aEnd += TWO_PI\n const ellipse = makeEllipse2d(center[0], center[1], rx, ry, xDir[0], xDir[1], sense)\n return { kind2d: 'trimmed', basis: ellipse, tStart: aStart, tEnd: aEnd }\n}"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"symbol-table.generated.d.ts","sourceRoot":"","sources":["../../src/lang/symbol-table.generated.ts"],"names":[],"mappings":"AAAA;;;;;GAKG
|
|
1
|
+
{"version":3,"file":"symbol-table.generated.d.ts","sourceRoot":"","sources":["../../src/lang/symbol-table.generated.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACH,wBAgGC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"symbol-table.generated.js","sourceRoot":"","sources":["../../src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EAAE,EAAE;IACd,OAAO,EAAE,EAAE;IACX,KAAK,EAAE,EAAE;IACT,OAAO,EAAE,EAAE;IACX,eAAe,EAAE,EAAE;IACnB,iBAAiB,EAAE,EAAE;IACrB,aAAa,EAAE,EAAE;IACjB,oBAAoB,EAAE,EAAE;IACxB,YAAY,EAAE,EAAE;IAChB,QAAQ,EAAE,EAAE;IACZ,OAAO,EAAE,EAAE;IACX,OAAO,EAAE,EAAE;IACX,MAAM,EAAE,EAAE;IACV,kBAAkB,EAAE,EAAE;IACtB,MAAM,EAAE,EAAE;IACV,QAAQ,EAAE,EAAE;IACZ,QAAQ,EAAE,EAAE;IACZ,cAAc,EAAE,EAAE;IAClB,YAAY,EAAE,EAAE;IAChB,aAAa,EAAE,EAAE;IACjB,cAAc,EAAE,EAAE;IAClB,gBAAgB,EAAE,EAAE;IACpB,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,EAAE;IACV,OAAO,EAAE,EAAE;IACX,QAAQ,EAAE,EAAE;IACZ,MAAM,EAAE,EAAE;IACV,QAAQ,EAAE,EAAE;IACZ,YAAY,EAAE,EAAE;IAChB,aAAa,EAAE,EAAE;IACjB,WAAW,EAAE,EAAE;IACf,QAAQ,EAAE,EAAE;IACZ,aAAa,EAAE,EAAE;IACjB,QAAQ,EAAE,EAAE;IACZ,QAAQ,EAAE,EAAE;IACZ,MAAM,EAAE,EAAE;IACV,UAAU,EAAE,EAAE;IACd,SAAS,EAAE,EAAE;IACb,aAAa,EAAE,EAAE;IACjB,UAAU,EAAE,EAAE;IACd,UAAU,EAAE,EAAE;IACd,WAAW,EAAE,EAAE;IACf,qBAAqB,EAAE,EAAE;CAC1B,CAAA","sourcesContent":["/**\n * symbol-table 生成文件 — 禁手改。\n * 由 scripts/gen-symbol-table.ts 从 api-namespace 的 cad 命名空间生成(键存在性)。\n * keep-syntax P1 后符号表只承载 check() 符号检查(\"函数不存在\"判定);\n * 保留语义由 keep 声明表达,不再有 readonly 标注。\n */\nexport default {\n \"box\": {},\n \"sphere\": {},\n \"cylinder\": {},\n \"cone\": {},\n \"wedge\": {},\n \"screw\": {},\n \"profile\": {},\n \"wire\": {},\n \"helix\": {},\n \"sdf\": {},\n \"translate\": {},\n \"rotate_euler\": {},\n \"scale\": {},\n \"scale3d\": {},\n \"engrave\": {},\n \"chamfer\": {},\n \"fillet\": {},\n \"knurl\": {},\n \"shell\": {},\n \"draft\": {},\n \"thicken\": {},\n \"filletVariable\": {},\n \"splitByPlane\": {},\n \"sectionByPlane\": {},\n \"defeature\": {},\n \"reverseShape\": {},\n \"unifySameDomain\": {},\n \"sew\": {},\n \"sewAndSolidify\": {},\n \"removeHolesFromFace\": {},\n \"union\": {},\n \"subtract\": {},\n \"intersect\": {},\n \"extrude\": {},\n \"revolve\": {},\n \"sweep\": {},\n \"loft\": {},\n \"faceNormal\": {},\n \"bboxCenter\": {},\n \"bboxMin\": {},\n \"bboxMax\": {},\n \"edgeRef\": {},\n \"faceRef\": {},\n \"jointTrajectory\": {},\n \"inverseKinematics\": {},\n \"mechanismDOF\": {},\n \"asset\": {},\n \"import_brep\": {},\n \"import_step\": {},\n \"compound\": {},\n \"place\": {},\n \"cut\": {},\n \"split\": {},\n \"linearPattern\": {},\n \"circularPattern\": {},\n \"gridPattern\": {},\n \"rectangularPattern\": {},\n \"mirrorJoin\": {},\n \"mirror\": {},\n \"clone\": {},\n \"torus\": {},\n \"fuse\": {},\n \"inspectMassProps\": {},\n \"area\": {},\n \"length\": {},\n \"volume\": {},\n \"centerOfMass\": {},\n \"viewCamera\": {},\n \"projectView\": {},\n \"projectSheet\": {},\n \"complexExtrude\": {},\n \"twistExtrude\": {},\n \"roof\": {},\n \"drill\": {},\n \"pocket\": {},\n \"boss\": {},\n \"thread\": {},\n \"convexHull\": {},\n \"makeBaseBox\": {},\n \"ellipsoid\": {},\n \"rotate\": {},\n \"applyMatrix\": {},\n \"locate\": {},\n \"offset\": {},\n \"heal\": {},\n \"simplify\": {},\n \"isValid\": {},\n \"isSameShape\": {},\n \"autoHeal\": {},\n \"fixShape\": {},\n \"healSolid\": {},\n \"fixSelfIntersection\": {}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"symbol-table.generated.js","sourceRoot":"","sources":["../../src/lang/symbol-table.generated.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAe;IACb,KAAK,EAAE,EAAE;IACT,QAAQ,EAAE,EAAE;IACZ,UAAU,EAAE,EAAE;IACd,MAAM,EAAE,EAAE;IACV,OAAO,EAAE,EAAE;IACX,OAAO,EAAE,EAAE;IACX,SAAS,EAAE,EAAE;IACb,eAAe,EAAE,EAAE;IACnB,cAAc,EAAE,EAAE;IAClB,WAAW,EAAE,EAAE;IACf,MAAM,EAAE,EAAE;IACV,OAAO,EAAE,EAAE;IACX,KAAK,EAAE,EAAE;IACT,WAAW,EAAE,EAAE;IACf,cAAc,EAAE,EAAE;IAClB,OAAO,EAAE,EAAE;IACX,SAAS,EAAE,EAAE;IACb,SAAS,EAAE,EAAE;IACb,SAAS,EAAE,EAAE;IACb,QAAQ,EAAE,EAAE;IACZ,OAAO,EAAE,EAAE;IACX,OAAO,EAAE,EAAE;IACX,OAAO,EAAE,EAAE;IACX,SAAS,EAAE,EAAE;IACb,gBAAgB,EAAE,EAAE;IACpB,cAAc,EAAE,EAAE;IAClB,gBAAgB,EAAE,EAAE;IACpB,WAAW,EAAE,EAAE;IACf,cAAc,EAAE,EAAE;IAClB,iBAAiB,EAAE,EAAE;IACrB,KAAK,EAAE,EAAE;IACT,gBAAgB,EAAE,EAAE;IACpB,qBAAqB,EAAE,EAAE;IACzB,OAAO,EAAE,EAAE;IACX,UAAU,EAAE,EAAE;IACd,WAAW,EAAE,EAAE;IACf,SAAS,EAAE,EAAE;IACb,SAAS,EAAE,EAAE;IACb,OAAO,EAAE,EAAE;IACX,MAAM,EAAE,EAAE;IACV,YAAY,EAAE,EAAE;IAChB,YAAY,EAAE,EAAE;IAChB,SAAS,EAAE,EAAE;IACb,SAAS,EAAE,EAA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C1B,CAAA","sourcesContent":["/**\n * symbol-table 生成文件 — 禁手改。\n * 由 scripts/gen-symbol-table.ts 从 api-namespace 的 cad 命名空间生成(键存在性)。\n * keep-syntax P1 后符号表只承载 check() 符号检查(\"函数不存在\"判定);\n * 保留语义由 keep 声明表达,不再有 readonly 标注。\n */\nexport default {\n \"box\": {},\n \"sphere\": {},\n \"cylinder\": {},\n \"cone\": {},\n \"wedge\": {},\n \"screw\": {},\n \"profile\": {},\n \"sketchOnPlane\": {},\n \"sketchOnFace\": {},\n \"punchHole\": {},\n \"wire\": {},\n \"helix\": {},\n \"sdf\": {},\n \"translate\": {},\n \"rotate_euler\": {},\n \"scale\": {},\n \"scale3d\": {},\n \"engrave\": {},\n \"chamfer\": {},\n \"fillet\": {},\n \"knurl\": {},\n \"shell\": {},\n \"draft\": {},\n \"thicken\": {},\n \"filletVariable\": {},\n \"splitByPlane\": {},\n \"sectionByPlane\": {},\n \"defeature\": {},\n \"reverseShape\": {},\n \"unifySameDomain\": {},\n \"sew\": {},\n \"sewAndSolidify\": {},\n \"removeHolesFromFace\": {},\n \"union\": {},\n \"subtract\": {},\n \"intersect\": {},\n \"extrude\": {},\n \"revolve\": {},\n \"sweep\": {},\n \"loft\": {},\n \"faceNormal\": {},\n \"bboxCenter\": {},\n \"bboxMin\": {},\n \"bboxMax\": {},\n \"edgeRef\": {},\n \"faceRef\": {},\n \"jointTrajectory\": {},\n \"inverseKinematics\": {},\n \"mechanismDOF\": {},\n \"asset\": {},\n \"import_brep\": {},\n \"import_step\": {},\n \"compound\": {},\n \"place\": {},\n \"cut\": {},\n \"split\": {},\n \"linearPattern\": {},\n \"circularPattern\": {},\n \"gridPattern\": {},\n \"rectangularPattern\": {},\n \"mirrorJoin\": {},\n \"mirror\": {},\n \"clone\": {},\n \"torus\": {},\n \"fuse\": {},\n \"inspectMassProps\": {},\n \"area\": {},\n \"length\": {},\n \"volume\": {},\n \"centerOfMass\": {},\n \"viewCamera\": {},\n \"projectView\": {},\n \"projectSheet\": {},\n \"complexExtrude\": {},\n \"twistExtrude\": {},\n \"roof\": {},\n \"drill\": {},\n \"pocket\": {},\n \"boss\": {},\n \"thread\": {},\n \"convexHull\": {},\n \"makeBaseBox\": {},\n \"ellipsoid\": {},\n \"rotate\": {},\n \"applyMatrix\": {},\n \"locate\": {},\n \"offset\": {},\n \"heal\": {},\n \"simplify\": {},\n \"isValid\": {},\n \"isSameShape\": {},\n \"autoHeal\": {},\n \"fixShape\": {},\n \"healSolid\": {},\n \"fixSelfIntersection\": {}\n}\n"]}
|
package/dist/mesh/types.d.ts
CHANGED
|
@@ -233,7 +233,7 @@ export interface DrillParams {
|
|
|
233
233
|
/** Parameters for extruding a face bounded by a plane. */
|
|
234
234
|
export interface ExtrudeParams {
|
|
235
235
|
normal: Vec3;
|
|
236
|
-
|
|
236
|
+
planeDistance: number;
|
|
237
237
|
length: number;
|
|
238
238
|
mode?: 'centered' | 'forward' | 'backward';
|
|
239
239
|
}
|
package/dist/mesh/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/mesh/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,MAAM,MAAM,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;AAE3C;;GAEG;AACH,MAAM,MAAM,SAAS,GACjB,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,SAAS,EAAE,GACX;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAA;AAI9B;;;;;GAKG;AACH,MAAM,WAAW,KAAK;IACpB,SAAS,EAAE,YAAY,CAAA;IACvB,OAAO,EAAE,WAAW,CAAA;CACrB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,KAAK,CAElD;AAID,8DAA8D;AAC9D,eAAO,MAAM,YA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AS,IAAI,CAAC,CAAA;AAC3E,CAAC;AAED,aAAa;AAEb,8DAA8D;AAC9D,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,CAAA;AAC9B,4CAA4C;AAC5C,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAA;AACzB,4CAA4C;AAC5C,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAG,CAAA;AAE3B;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CAAC,CAAqB;IAC7C,IAAI,CAAC,KAAK,SAAS;QAAE,OAAO,YAAY,CAAA;IACxC,OAAO,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAC9D,CAAC","sourcesContent":["/**\n * mesh 类型定义 — 纯数据几何 API 的类型契约\n *\n * 设计原则(§5.1):\n * - 全部纯数据:输入输出是 ManifoldMeshData 或 JSON 值,不碰 THREE 场景、不读 store\n * - 不可变:每个 API 返回新几何,不修改输入\n * - 坐标系:右手系 +Z 向上、毫米、角度用度\n * - 坐标空间:所有 API 输入/输出均为**世界空间** ManifoldMeshData\n * (局部↔世界变换由执行器负责,mesh 不感知 mesh.matrixWorld)\n *\n * P1 阶段 Shape = ManifoldMeshData(无 worker)。\n * P3+ 阶段 Shape 将变为 worker 内 Manifold 对象的句柄。\n */\n\n// ── 基础类型 ──\n\nexport type Vec3 = [number, number, number]\n\n/**\n * A JSON-serializable value: scalar, null, array, or plain object.\n */\nexport type JsonValue =\n | string\n | number\n | boolean\n | null\n | JsonValue[]\n | { [k: string]: JsonValue }\n\n// ── Shape ──\n\n/**\n * A mesh shape — the core data type of the mesh API.\n *\n * Shape is defined directly in mesh/types.ts rather than re-exported from\n * ops/types.ts; ops/types.ts imports it from here, removing the type cycle.\n */\nexport interface Shape {\n positions: Float32Array\n indices: Uint32Array\n}\n\n/**\n * Structural guard: returns true when the value looks like a mesh Shape\n * (duck-typed via positions/indices, with no requirements on third-party\n * types).\n *\n * Per the keep-syntax design, hosts use this guard to distinguish mesh Shapes\n * from compounds when consuming ExecutionResult.outputs, in the same style as\n * the runtime-internal isShapeLike.\n * @param v - the value to test.\n * @returns true when the value is a mesh Shape.\n */\nexport function isMeshShape(v: unknown): v is Shape {\n return !!v && typeof v === 'object' && 'positions' in v && 'indices' in v\n}\n\n// ── 创建参数 ──\n\n/** Default radial segment count used for rounded geometry. */\nexport const NRAD_DEFAULT = 64\n/** Minimum allowed radial segment count. */\nexport const NRAD_MIN = 3\n/** Maximum allowed radial segment count. */\nexport const NRAD_MAX = 128\n\n/**\n * Clamp an nRad value into the legal range [NRAD_MIN, NRAD_MAX], rounding to\n * the nearest integer; undefined falls back to NRAD_DEFAULT.\n * @param n - the requested radial segment count, or undefined.\n * @returns the clamped radial segment count.\n */\nexport function clampNRad(n: number | undefined): number {\n if (n === undefined) return NRAD_DEFAULT\n return Math.max(NRAD_MIN, Math.min(NRAD_MAX, Math.round(n)))\n}\n\n/**\n * Parameters for creating a box (brepjs `box(width, depth, height, {at?, centered?, segments?})`\n * contract, §4.1 A 决策). Default: min-corner at the origin. `centered: true` shifts so the\n * box is centered at the origin; `at` is CENTER semantics and takes precedence over `centered`.\n */\nexport interface BoxParams {\n /** Side length along X (mm). */\n width: number\n /** Side length along Y (mm). */\n depth: number\n /** Side length along Z (mm). */\n height: number\n /** Center position (brepjs `at`, CENTER semantics); takes precedence over `centered`. */\n at?: Vec3\n /** Center the box at the origin when `at` is absent. Default: false (min-corner at origin). */\n centered?: boolean\n /** Tessellation segment count (box: affects only brep/mesh tessellation, not topology). */\n segments?: number\n /** Internal historical alias for `segments` (accepted by clampNRad, §5.1). */\n nRad?: number\n}\n\n/** Parameters for creating a sphere. */\nexport interface SphereParams {\n radius: number\n segments?: number\n center?: Vec3\n nRad?: number\n}\n\n/** Parameters for creating a cylinder (brepjs contract, §4.3 A). */\nexport interface CylinderParams {\n /** Radius (mm). */\n radius: number\n /** Height along +Z (mm). */\n height: number\n /** Base circle center (brepjs `at`, BASE semantics; default [0, 0, 0]). */\n at?: Vec3\n /** Center the cylinder (base at −h/2 / center at `at`) instead of base at `at`/origin. */\n centered?: boolean\n /** Tessellation segment count (cylinder: affects only tessellation, not topology). */\n segments?: number\n /** Internal historical alias for `segments` (accepted by clampNRad, §5.1). */\n nRad?: number\n}\n\n/** Parameters for creating a cone (or a truncated cone). */\nexport interface ConeParams {\n /** Radius at the base (mm). */\n radiusBottom: number\n /** Radius at the top (mm); 0 for a pointed cone, === radiusBottom for a cylinder. */\n radiusTop: number\n /** Height along +Z (mm). */\n height: number\n /** Base circle center (brepjs `at`, BASE semantics; default [0, 0, 0]). */\n at?: Vec3\n /** Center the cone (base at −h/2 / center at `at`) instead of base at `at`/origin. */\n centered?: boolean\n /** Tessellation segment count (cone: affects only mere tessellation, not topology). */\n segments?: number\n /** Internal historical alias for `segments` (accepted by clampNRad, §5.1). */\n nRad?: number\n}\n\n/**\n * Parameters for creating a wedge (trapezoidal prism).\n */\nexport interface WedgeParams {\n /** Width of the base edge (mm), along the Y axis. */\n width: number\n /** Height of the trapezoid (mm), along the Z axis. */\n height: number\n /** Angle between the base edge and the slope (degrees). */\n angle: number\n /** Total extrusion length (mm), along the X axis. */\n length: number\n center?: Vec3\n nRad?: number\n}\n\n/** Parameters for creating 3D text. */\nexport interface TextParams {\n text: string\n size: number\n depth: number\n}\n\n/** Parameters for extruding an SVG into a solid. */\nexport interface SvgExtrudeParams {\n svg: string\n depth: number\n targetLongSide: number\n naturalWidth?: number\n naturalHeight?: number\n}\n\n/** Parameters for building a solid from an SDF (signed distance function). */\nexport interface SdfParams {\n code: string\n box?: [Vec3, Vec3]\n resolution?: number\n params?: Record<string, number>\n}\n\n// ── 变换参数 ──\n\n/** Parameters for translating a shape. */\nexport interface TranslateParams {\n offset: Vec3\n}\n\n/** Parameters for rotating a shape. */\nexport interface RotateParams {\n anglesDeg: Vec3\n pivot?: Vec3\n}\n\n/** Parameters for scaling a shape. */\nexport interface ScaleParams {\n factor: number | Vec3\n}\n\n// ── 布尔参数 ──\n\n/** Kinds of binary boolean operations. */\nexport type BooleanOperation = 'union' | 'subtract' | 'intersect'\n\n// ── 分割参数 ──\n\n/** A cutting plane defined by a unit normal and a signed offset. */\nexport interface SplitPlane {\n normal: Vec3\n offset: number\n}\n\n/** Parameters for a dovetail split, including the cutting plane setup. */\nexport interface DovetailSplitParams {\n plane: SplitPlane\n planeCenter: Vec3\n widthDir: Vec3\n bboxWidthOnWidthDir: number\n groove: {\n depth: number\n depthTolerance: number\n width: number\n widthTolerance: number\n flapsAngle: number\n }\n}\n\n/** Parameters for a dowel-pin split, including the cutting plane setup. */\nexport interface DowelSplitParams {\n plane: SplitPlane\n planeCenter: Vec3\n widthDir: Vec3\n dowel: {\n diameter: number\n diameterTolerance: number\n height: number\n heightTolerance: number\n }\n selectedSections?: number[] | null\n}\n\n/** Parameters for a straight-tenon split, including the cutting plane setup. */\nexport interface TenonSplitParams {\n plane: SplitPlane\n planeCenter: Vec3\n widthDir: Vec3\n tenon: {\n sideLength: number\n sideLengthTolerance: number\n height: number\n heightTolerance: number\n }\n selectedSections?: number[] | null\n}\n\n/** Result of a joinery split: the two halves plus the cut-out wedge. */\nexport interface SplitResult {\n front: Shape\n back: Shape\n wedge: Shape | null\n}\n\n// ── 钻孔参数 ──\n\n/** Parameters for drilling a hole. */\nexport interface DrillParams {\n diameter: number\n depth?: number\n type: 'through' | 'blind'\n position: Vec3\n direction: Vec3\n faceNormal: Vec3\n tolerance?: number\n holeType?: 'simple' | 'screw'\n screwSystem?: string\n screwSpecIdx?: number\n screwThread?: string\n screwHead?: string\n}\n\n// ── 拉伸参数 ──\n\n/** Parameters for extruding a face bounded by a plane. */\nexport interface ExtrudeParams {\n normal: Vec3\n
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/mesh/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AA8BH;;;;;;;;;;GAUG;AACH,MAAM,UAAU,WAAW,CAAC,CAAU;IACpC,OAAO,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,WAAW,IAAI,CAAC,IAAI,SAAS,IAAI,CAAC,CAAA;AAC3E,CAAC;AAED,aAAa;AAEb,8DAA8D;AAC9D,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,CAAA;AAC9B,4CAA4C;AAC5C,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAA;AACzB,4CAA4C;AAC5C,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAG,CAAA;AAE3B;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CAAC,CAAqB;IAC7C,IAAI,CAAC,KAAK,SAAS;QAAE,OAAO,YAAY,CAAA;IACxC,OAAO,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAC9D,CAAC","sourcesContent":["/**\n * mesh 类型定义 — 纯数据几何 API 的类型契约\n *\n * 设计原则(§5.1):\n * - 全部纯数据:输入输出是 ManifoldMeshData 或 JSON 值,不碰 THREE 场景、不读 store\n * - 不可变:每个 API 返回新几何,不修改输入\n * - 坐标系:右手系 +Z 向上、毫米、角度用度\n * - 坐标空间:所有 API 输入/输出均为**世界空间** ManifoldMeshData\n * (局部↔世界变换由执行器负责,mesh 不感知 mesh.matrixWorld)\n *\n * P1 阶段 Shape = ManifoldMeshData(无 worker)。\n * P3+ 阶段 Shape 将变为 worker 内 Manifold 对象的句柄。\n */\n\n// ── 基础类型 ──\n\nexport type Vec3 = [number, number, number]\n\n/**\n * A JSON-serializable value: scalar, null, array, or plain object.\n */\nexport type JsonValue =\n | string\n | number\n | boolean\n | null\n | JsonValue[]\n | { [k: string]: JsonValue }\n\n// ── Shape ──\n\n/**\n * A mesh shape — the core data type of the mesh API.\n *\n * Shape is defined directly in mesh/types.ts rather than re-exported from\n * ops/types.ts; ops/types.ts imports it from here, removing the type cycle.\n */\nexport interface Shape {\n positions: Float32Array\n indices: Uint32Array\n}\n\n/**\n * Structural guard: returns true when the value looks like a mesh Shape\n * (duck-typed via positions/indices, with no requirements on third-party\n * types).\n *\n * Per the keep-syntax design, hosts use this guard to distinguish mesh Shapes\n * from compounds when consuming ExecutionResult.outputs, in the same style as\n * the runtime-internal isShapeLike.\n * @param v - the value to test.\n * @returns true when the value is a mesh Shape.\n */\nexport function isMeshShape(v: unknown): v is Shape {\n return !!v && typeof v === 'object' && 'positions' in v && 'indices' in v\n}\n\n// ── 创建参数 ──\n\n/** Default radial segment count used for rounded geometry. */\nexport const NRAD_DEFAULT = 64\n/** Minimum allowed radial segment count. */\nexport const NRAD_MIN = 3\n/** Maximum allowed radial segment count. */\nexport const NRAD_MAX = 128\n\n/**\n * Clamp an nRad value into the legal range [NRAD_MIN, NRAD_MAX], rounding to\n * the nearest integer; undefined falls back to NRAD_DEFAULT.\n * @param n - the requested radial segment count, or undefined.\n * @returns the clamped radial segment count.\n */\nexport function clampNRad(n: number | undefined): number {\n if (n === undefined) return NRAD_DEFAULT\n return Math.max(NRAD_MIN, Math.min(NRAD_MAX, Math.round(n)))\n}\n\n/**\n * Parameters for creating a box (brepjs `box(width, depth, height, {at?, centered?, segments?})`\n * contract, §4.1 A 决策). Default: min-corner at the origin. `centered: true` shifts so the\n * box is centered at the origin; `at` is CENTER semantics and takes precedence over `centered`.\n */\nexport interface BoxParams {\n /** Side length along X (mm). */\n width: number\n /** Side length along Y (mm). */\n depth: number\n /** Side length along Z (mm). */\n height: number\n /** Center position (brepjs `at`, CENTER semantics); takes precedence over `centered`. */\n at?: Vec3\n /** Center the box at the origin when `at` is absent. Default: false (min-corner at origin). */\n centered?: boolean\n /** Tessellation segment count (box: affects only brep/mesh tessellation, not topology). */\n segments?: number\n /** Internal historical alias for `segments` (accepted by clampNRad, §5.1). */\n nRad?: number\n}\n\n/** Parameters for creating a sphere. */\nexport interface SphereParams {\n radius: number\n segments?: number\n center?: Vec3\n nRad?: number\n}\n\n/** Parameters for creating a cylinder (brepjs contract, §4.3 A). */\nexport interface CylinderParams {\n /** Radius (mm). */\n radius: number\n /** Height along +Z (mm). */\n height: number\n /** Base circle center (brepjs `at`, BASE semantics; default [0, 0, 0]). */\n at?: Vec3\n /** Center the cylinder (base at −h/2 / center at `at`) instead of base at `at`/origin. */\n centered?: boolean\n /** Tessellation segment count (cylinder: affects only tessellation, not topology). */\n segments?: number\n /** Internal historical alias for `segments` (accepted by clampNRad, §5.1). */\n nRad?: number\n}\n\n/** Parameters for creating a cone (or a truncated cone). */\nexport interface ConeParams {\n /** Radius at the base (mm). */\n radiusBottom: number\n /** Radius at the top (mm); 0 for a pointed cone, === radiusBottom for a cylinder. */\n radiusTop: number\n /** Height along +Z (mm). */\n height: number\n /** Base circle center (brepjs `at`, BASE semantics; default [0, 0, 0]). */\n at?: Vec3\n /** Center the cone (base at −h/2 / center at `at`) instead of base at `at`/origin. */\n centered?: boolean\n /** Tessellation segment count (cone: affects only mere tessellation, not topology). */\n segments?: number\n /** Internal historical alias for `segments` (accepted by clampNRad, §5.1). */\n nRad?: number\n}\n\n/**\n * Parameters for creating a wedge (trapezoidal prism).\n */\nexport interface WedgeParams {\n /** Width of the base edge (mm), along the Y axis. */\n width: number\n /** Height of the trapezoid (mm), along the Z axis. */\n height: number\n /** Angle between the base edge and the slope (degrees). */\n angle: number\n /** Total extrusion length (mm), along the X axis. */\n length: number\n center?: Vec3\n nRad?: number\n}\n\n/** Parameters for creating 3D text. */\nexport interface TextParams {\n text: string\n size: number\n depth: number\n}\n\n/** Parameters for extruding an SVG into a solid. */\nexport interface SvgExtrudeParams {\n svg: string\n depth: number\n targetLongSide: number\n naturalWidth?: number\n naturalHeight?: number\n}\n\n/** Parameters for building a solid from an SDF (signed distance function). */\nexport interface SdfParams {\n code: string\n box?: [Vec3, Vec3]\n resolution?: number\n params?: Record<string, number>\n}\n\n// ── 变换参数 ──\n\n/** Parameters for translating a shape. */\nexport interface TranslateParams {\n offset: Vec3\n}\n\n/** Parameters for rotating a shape. */\nexport interface RotateParams {\n anglesDeg: Vec3\n pivot?: Vec3\n}\n\n/** Parameters for scaling a shape. */\nexport interface ScaleParams {\n factor: number | Vec3\n}\n\n// ── 布尔参数 ──\n\n/** Kinds of binary boolean operations. */\nexport type BooleanOperation = 'union' | 'subtract' | 'intersect'\n\n// ── 分割参数 ──\n\n/** A cutting plane defined by a unit normal and a signed offset. */\nexport interface SplitPlane {\n normal: Vec3\n offset: number\n}\n\n/** Parameters for a dovetail split, including the cutting plane setup. */\nexport interface DovetailSplitParams {\n plane: SplitPlane\n planeCenter: Vec3\n widthDir: Vec3\n bboxWidthOnWidthDir: number\n groove: {\n depth: number\n depthTolerance: number\n width: number\n widthTolerance: number\n flapsAngle: number\n }\n}\n\n/** Parameters for a dowel-pin split, including the cutting plane setup. */\nexport interface DowelSplitParams {\n plane: SplitPlane\n planeCenter: Vec3\n widthDir: Vec3\n dowel: {\n diameter: number\n diameterTolerance: number\n height: number\n heightTolerance: number\n }\n selectedSections?: number[] | null\n}\n\n/** Parameters for a straight-tenon split, including the cutting plane setup. */\nexport interface TenonSplitParams {\n plane: SplitPlane\n planeCenter: Vec3\n widthDir: Vec3\n tenon: {\n sideLength: number\n sideLengthTolerance: number\n height: number\n heightTolerance: number\n }\n selectedSections?: number[] | null\n}\n\n/** Result of a joinery split: the two halves plus the cut-out wedge. */\nexport interface SplitResult {\n front: Shape\n back: Shape\n wedge: Shape | null\n}\n\n// ── 钻孔参数 ──\n\n/** Parameters for drilling a hole. */\nexport interface DrillParams {\n diameter: number\n depth?: number\n type: 'through' | 'blind'\n position: Vec3\n direction: Vec3\n faceNormal: Vec3\n tolerance?: number\n holeType?: 'simple' | 'screw'\n screwSystem?: string\n screwSpecIdx?: number\n screwThread?: string\n screwHead?: string\n}\n\n// ── 拉伸参数 ──\n\n/** Parameters for extruding a face bounded by a plane. */\nexport interface ExtrudeParams {\n normal: Vec3\n planeDistance: number\n length: number\n mode?: 'centered' | 'forward' | 'backward'\n}\n\n// ── 雕刻参数 ──\n\n/** Parameters for engraving text or an SVG onto a face. */\nexport interface EngraveParams {\n mode: 'convex' | 'concave'\n depth: number\n face: {\n center: Vec3\n normal: Vec3\n }\n text?: string\n textSize?: number\n svg?: string\n svgNaturalWidth?: number\n svgNaturalHeight?: number\n svgSize?: number\n}\n\n/** Parameters for applying a knurl texture to a face. */\nexport interface KnurlParams {\n face: {\n center: Vec3\n normal: Vec3\n }\n knurlTextureHeight: number\n knurlInvertDisplacement: boolean\n knurlRefineLength: number\n knurlScaleU: number\n knurlScaleV: number\n knurlMappingMode: number\n}\n\n// ── 查询结果 ──\n\n/** Axis-aligned bounding box in world space. */\nexport interface BoundingBox {\n min: Vec3\n max: Vec3\n}\n\n/** Description of a face on a shape: center, normal and area. */\nexport interface FaceDescriptor {\n center: Vec3\n normal: Vec3\n area: number\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faicad/faijs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -118,6 +118,14 @@
|
|
|
118
118
|
"types": "./dist/boolean/*.d.ts",
|
|
119
119
|
"default": "./dist/boolean/*.js"
|
|
120
120
|
},
|
|
121
|
+
"./geometry2d": {
|
|
122
|
+
"types": "./dist/geometry2d/index.d.ts",
|
|
123
|
+
"default": "./dist/geometry2d/index.js"
|
|
124
|
+
},
|
|
125
|
+
"./geometry2d/*": {
|
|
126
|
+
"types": "./dist/geometry2d/*.d.ts",
|
|
127
|
+
"default": "./dist/geometry2d/*.js"
|
|
128
|
+
},
|
|
121
129
|
"./env-agnostic": {
|
|
122
130
|
"types": "./dist/env-agnostic.d.ts",
|
|
123
131
|
"default": "./dist/env-agnostic.js"
|