fluidcad 0.0.34 → 0.0.35
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 +69 -0
- package/bin/commands/login.js +120 -0
- package/bin/commands/pack.js +49 -0
- package/bin/commands/publish.js +136 -0
- package/bin/fluidcad.js +6 -0
- package/bin/lib/api-client.js +40 -0
- package/bin/lib/browser.js +16 -0
- package/bin/lib/config.js +39 -0
- package/bin/lib/model-config.js +38 -0
- package/bin/lib/workspace.js +57 -0
- package/lib/dist/common/shape-factory.d.ts +2 -1
- package/lib/dist/common/shape-factory.js +4 -0
- package/lib/dist/common/transformable-primitive.d.ts +6 -5
- package/lib/dist/common/transformable-primitive.js +8 -7
- package/lib/dist/common/vertex.js +0 -1
- package/lib/dist/core/2d/aline.d.ts +4 -3
- package/lib/dist/core/2d/aline.js +3 -2
- package/lib/dist/core/2d/arc.d.ts +3 -2
- package/lib/dist/core/2d/arc.js +4 -3
- package/lib/dist/core/2d/bezier.d.ts +8 -6
- package/lib/dist/core/2d/circle.d.ts +4 -3
- package/lib/dist/core/2d/circle.js +3 -2
- package/lib/dist/core/2d/ellipse.d.ts +5 -4
- package/lib/dist/core/2d/ellipse.js +5 -4
- package/lib/dist/core/2d/hline.d.ts +4 -3
- package/lib/dist/core/2d/hline.js +5 -3
- package/lib/dist/core/2d/line.js +1 -0
- package/lib/dist/core/2d/offset.d.ts +3 -2
- package/lib/dist/core/2d/offset.js +6 -5
- package/lib/dist/core/2d/polygon.d.ts +5 -4
- package/lib/dist/core/2d/polygon.js +10 -9
- package/lib/dist/core/2d/rect.d.ts +4 -3
- package/lib/dist/core/2d/rect.js +10 -9
- package/lib/dist/core/2d/slot.d.ts +14 -6
- package/lib/dist/core/2d/slot.js +19 -8
- package/lib/dist/core/2d/vline.d.ts +4 -3
- package/lib/dist/core/2d/vline.js +5 -3
- package/lib/dist/core/chamfer.d.ts +5 -4
- package/lib/dist/core/chamfer.js +7 -6
- package/lib/dist/core/color.d.ts +3 -2
- package/lib/dist/core/color.js +2 -1
- package/lib/dist/core/cut.d.ts +4 -3
- package/lib/dist/core/cut.js +5 -4
- package/lib/dist/core/cylinder.d.ts +2 -1
- package/lib/dist/core/cylinder.js +2 -1
- package/lib/dist/core/draft.d.ts +3 -2
- package/lib/dist/core/draft.js +3 -2
- package/lib/dist/core/extrude.d.ts +4 -3
- package/lib/dist/core/extrude.js +5 -4
- package/lib/dist/core/fillet.d.ts +5 -4
- package/lib/dist/core/fillet.js +6 -5
- package/lib/dist/core/index.d.ts +1 -0
- package/lib/dist/core/index.js +1 -0
- package/lib/dist/core/interfaces.d.ts +25 -24
- package/lib/dist/core/param.d.ts +74 -0
- package/lib/dist/core/param.js +147 -0
- package/lib/dist/core/repeat.d.ts +2 -1
- package/lib/dist/core/repeat.js +10 -8
- package/lib/dist/core/revolve.d.ts +2 -1
- package/lib/dist/core/revolve.js +3 -2
- package/lib/dist/core/rib.d.ts +3 -2
- package/lib/dist/core/rib.js +6 -2
- package/lib/dist/core/rotate.d.ts +5 -4
- package/lib/dist/core/rotate.js +4 -3
- package/lib/dist/core/shell.d.ts +3 -2
- package/lib/dist/core/shell.js +3 -2
- package/lib/dist/core/sphere.d.ts +3 -2
- package/lib/dist/core/sphere.js +2 -1
- package/lib/dist/core/translate.d.ts +7 -6
- package/lib/dist/core/translate.js +6 -5
- package/lib/dist/features/2d/arc.js +5 -5
- package/lib/dist/features/2d/bezier.js +16 -16
- package/lib/dist/features/2d/circle.js +4 -0
- package/lib/dist/features/2d/ellipse.js +4 -0
- package/lib/dist/features/2d/hline.d.ts +3 -0
- package/lib/dist/features/2d/hline.js +9 -2
- package/lib/dist/features/2d/line.d.ts +3 -0
- package/lib/dist/features/2d/line.js +11 -3
- package/lib/dist/features/2d/sketch.js +5 -1
- package/lib/dist/features/2d/slot.d.ts +5 -0
- package/lib/dist/features/2d/slot.js +52 -7
- package/lib/dist/features/2d/tarc-to-point-tangent.js +3 -0
- package/lib/dist/features/2d/tarc-to-point.js +3 -0
- package/lib/dist/features/2d/tarc-with-tangent.js +3 -0
- package/lib/dist/features/2d/tarc.js +3 -0
- package/lib/dist/features/2d/vline.d.ts +3 -0
- package/lib/dist/features/2d/vline.js +9 -2
- package/lib/dist/features/copy-circular.d.ts +4 -3
- package/lib/dist/features/copy-circular.js +16 -9
- package/lib/dist/features/copy-circular2d.js +16 -9
- package/lib/dist/features/copy-linear.d.ts +4 -3
- package/lib/dist/features/copy-linear.js +18 -12
- package/lib/dist/features/copy-linear2d.js +18 -12
- package/lib/dist/features/extrude-base.d.ts +4 -3
- package/lib/dist/features/extrude-base.js +10 -3
- package/lib/dist/features/mirror-shape2d.js +2 -2
- package/lib/dist/features/repeat-base.d.ts +13 -0
- package/lib/dist/features/repeat-base.js +21 -0
- package/lib/dist/features/repeat-circular.d.ts +6 -5
- package/lib/dist/features/repeat-circular.js +3 -6
- package/lib/dist/features/repeat-linear.d.ts +7 -7
- package/lib/dist/features/repeat-linear.js +3 -6
- package/lib/dist/index.d.ts +5 -0
- package/lib/dist/index.js +8 -1
- package/lib/dist/io/file-import.d.ts +7 -0
- package/lib/dist/io/file-import.js +30 -10
- package/lib/dist/math/lazy-matrix.d.ts +5 -0
- package/lib/dist/math/lazy-matrix.js +78 -10
- package/lib/dist/oc/boolean-ops.d.ts +2 -2
- package/lib/dist/param-registry.d.ts +34 -0
- package/lib/dist/param-registry.js +60 -0
- package/lib/dist/rendering/mesh-builder.js +2 -1
- package/lib/dist/tests/features/copy-circular.test.js +1 -1
- package/lib/dist/tests/features/copy-linear.test.js +10 -10
- package/lib/dist/tests/features/repeat-user-repro-cache.test.d.ts +1 -0
- package/lib/dist/tests/features/repeat-user-repro-cache.test.js +97 -0
- package/lib/dist/tsconfig.tsbuildinfo +1 -1
- package/llm-docs/api/bezier.md +10 -11
- package/llm-docs/api/index.json +1 -1
- package/llm-docs/api/types/arc-points.md +2 -2
- package/llm-docs/api/types/cut.md +10 -10
- package/llm-docs/api/types/extrude.md +10 -10
- package/llm-docs/api/types/loft.md +6 -6
- package/llm-docs/api/types/revolve.md +6 -6
- package/llm-docs/api/types/rib.md +2 -2
- package/llm-docs/api/types/slot.md +2 -2
- package/llm-docs/api/types/sweep.md +10 -10
- package/llm-docs/api/types/transformable.md +14 -14
- package/llm-docs/index.json +12 -12
- package/mcp/dist/client.d.ts +1 -0
- package/mcp/dist/client.js +8 -1
- package/mcp/dist/server.js +14 -1
- package/mcp/dist/tools/engine.d.ts +16 -0
- package/mcp/dist/tools/engine.js +45 -0
- package/package.json +9 -3
- package/server/dist/api.d.ts +37 -0
- package/server/dist/api.js +44 -0
- package/server/dist/code-editor.d.ts +64 -0
- package/server/dist/code-editor.js +520 -2
- package/server/dist/fluidcad-server.d.ts +68 -1
- package/server/dist/fluidcad-server.js +224 -88
- package/server/dist/host/blocked-imports.d.ts +8 -0
- package/server/dist/host/blocked-imports.js +30 -0
- package/server/dist/{vite-manager.d.ts → host/local-scene-host.d.ts} +3 -1
- package/server/dist/{vite-manager.js → host/local-scene-host.js} +6 -26
- package/server/dist/host/scene-host.d.ts +19 -0
- package/server/dist/host/scene-host.js +1 -0
- package/server/dist/index.js +24 -117
- package/server/dist/model-package/capture-params.d.ts +19 -0
- package/server/dist/model-package/capture-params.js +42 -0
- package/server/dist/model-package/pack.d.ts +23 -0
- package/server/dist/model-package/pack.js +229 -0
- package/server/dist/model-package/types.d.ts +78 -0
- package/server/dist/model-package/types.js +17 -0
- package/server/dist/routes/hit-test.d.ts +3 -0
- package/server/dist/routes/hit-test.js +17 -0
- package/server/dist/routes/pack.d.ts +10 -0
- package/server/dist/routes/pack.js +47 -0
- package/server/dist/routes/params.d.ts +3 -0
- package/server/dist/routes/params.js +75 -0
- package/server/dist/routes/sketch-edits.d.ts +3 -0
- package/server/dist/routes/sketch-edits.js +542 -0
- package/server/dist/routes/timeline.d.ts +3 -0
- package/server/dist/routes/timeline.js +49 -0
- package/server/dist/server-core.d.ts +53 -0
- package/server/dist/server-core.js +147 -0
- package/server/dist/ws-protocol.d.ts +101 -2
- package/ui/dist/assets/index-CDJmUpFI.css +2 -0
- package/ui/dist/assets/index-MRqwG9Vh.js +5417 -0
- package/ui/dist/index.html +2 -2
- package/server/dist/routes/actions.d.ts +0 -3
- package/server/dist/routes/actions.js +0 -309
- package/ui/dist/assets/index-BdqrMDRu.js +0 -4946
- package/ui/dist/assets/index-DR7c2Qk9.css +0 -2
|
@@ -3,6 +3,7 @@ import { Matrix4 } from "../math/matrix4.js";
|
|
|
3
3
|
import { Point } from "../math/point.js";
|
|
4
4
|
import { Vector3d } from "../math/vector3d.js";
|
|
5
5
|
import { rad } from "../helpers/math-helpers.js";
|
|
6
|
+
import { isNumberParam, resolveParam } from "../core/param.js";
|
|
6
7
|
export class TransformablePrimitive extends SceneObject {
|
|
7
8
|
transform(matrix) {
|
|
8
9
|
this.composeAppliedTransform(matrix);
|
|
@@ -10,10 +11,10 @@ export class TransformablePrimitive extends SceneObject {
|
|
|
10
11
|
}
|
|
11
12
|
translate(a, b, c) {
|
|
12
13
|
let x, y, z;
|
|
13
|
-
if (
|
|
14
|
-
x = a;
|
|
15
|
-
y = b
|
|
16
|
-
z = c
|
|
14
|
+
if (isNumberParam(a)) {
|
|
15
|
+
x = resolveParam(a);
|
|
16
|
+
y = b != null ? resolveParam(b) : 0;
|
|
17
|
+
z = c != null ? resolveParam(c) : 0;
|
|
17
18
|
}
|
|
18
19
|
else if (Array.isArray(a)) {
|
|
19
20
|
x = a[0] ?? 0;
|
|
@@ -31,16 +32,16 @@ export class TransformablePrimitive extends SceneObject {
|
|
|
31
32
|
let origin;
|
|
32
33
|
let direction;
|
|
33
34
|
let angleDeg;
|
|
34
|
-
if (
|
|
35
|
+
if (isNumberParam(a)) {
|
|
35
36
|
origin = new Point(0, 0, 0);
|
|
36
37
|
direction = Vector3d.unitZ();
|
|
37
|
-
angleDeg = a;
|
|
38
|
+
angleDeg = resolveParam(a);
|
|
38
39
|
}
|
|
39
40
|
else {
|
|
40
41
|
const resolved = resolveAxisLike(a);
|
|
41
42
|
origin = resolved.origin;
|
|
42
43
|
direction = resolved.direction;
|
|
43
|
-
angleDeg = b;
|
|
44
|
+
angleDeg = resolveParam(b);
|
|
44
45
|
}
|
|
45
46
|
return this.transform(Matrix4.fromRotationAroundAxis(origin, direction, rad(angleDeg)));
|
|
46
47
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { PlaneLike } from "../../math/plane.js";
|
|
2
2
|
import { IALine, ISceneObject } from "../interfaces.js";
|
|
3
|
+
import { type NumberParam } from "../param.js";
|
|
3
4
|
interface ALineFunction {
|
|
4
5
|
/**
|
|
5
6
|
* Draws a line at the given angle with the given length.
|
|
@@ -7,7 +8,7 @@ interface ALineFunction {
|
|
|
7
8
|
* @param angle - The angle in degrees
|
|
8
9
|
* @param length - The line length
|
|
9
10
|
*/
|
|
10
|
-
(angle:
|
|
11
|
+
(angle: NumberParam, length: NumberParam): IALine;
|
|
11
12
|
/**
|
|
12
13
|
* Draws a line at the given angle that ends where it intersects the target
|
|
13
14
|
* geometry. The nearest intersection along the line's direction (in either
|
|
@@ -15,14 +16,14 @@ interface ALineFunction {
|
|
|
15
16
|
* @param angle - The angle in degrees
|
|
16
17
|
* @param target - The geometry to intersect with
|
|
17
18
|
*/
|
|
18
|
-
(angle:
|
|
19
|
+
(angle: NumberParam, target: ISceneObject): IALine;
|
|
19
20
|
/**
|
|
20
21
|
* Draws a line at the given angle on a specific plane.
|
|
21
22
|
* @param targetPlane - The plane to draw on
|
|
22
23
|
* @param angle - The angle in degrees
|
|
23
24
|
* @param length - The line length
|
|
24
25
|
*/
|
|
25
|
-
(targetPlane: PlaneLike | ISceneObject, angle:
|
|
26
|
+
(targetPlane: PlaneLike | ISceneObject, angle: NumberParam, length: NumberParam): IALine;
|
|
26
27
|
}
|
|
27
28
|
declare const _default: ALineFunction;
|
|
28
29
|
export default _default;
|
|
@@ -3,6 +3,7 @@ import { registerBuilder } from "../../index.js";
|
|
|
3
3
|
import { isPlaneLike } from "../../math/plane.js";
|
|
4
4
|
import { SceneObject } from "../../common/scene-object.js";
|
|
5
5
|
import { resolvePlane } from "../../helpers/resolve.js";
|
|
6
|
+
import { resolveParam } from "../param.js";
|
|
6
7
|
function build(context) {
|
|
7
8
|
return function line() {
|
|
8
9
|
let planeObj = null;
|
|
@@ -22,11 +23,11 @@ function build(context) {
|
|
|
22
23
|
argOffset = 1;
|
|
23
24
|
}
|
|
24
25
|
}
|
|
25
|
-
const angle = arguments[argOffset];
|
|
26
|
+
const angle = resolveParam(arguments[argOffset]);
|
|
26
27
|
const second = arguments[argOffset + 1];
|
|
27
28
|
const lengthOrTarget = second instanceof SceneObject
|
|
28
29
|
? second
|
|
29
|
-
: second;
|
|
30
|
+
: resolveParam(second);
|
|
30
31
|
const aline = new AngledLine(angle, lengthOrTarget, planeObj);
|
|
31
32
|
context.addSceneObject(aline);
|
|
32
33
|
return aline;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Point2DLike } from "../../math/point.js";
|
|
2
2
|
import { PlaneLike } from "../../math/plane.js";
|
|
3
3
|
import { IArcPoints, IArcAngles, ISceneObject } from "../interfaces.js";
|
|
4
|
+
import { type NumberParam } from "../param.js";
|
|
4
5
|
interface ArcFunction {
|
|
5
6
|
/**
|
|
6
7
|
* Draws an arc to an end point from the current position.
|
|
@@ -25,7 +26,7 @@ interface ArcFunction {
|
|
|
25
26
|
* @param startAngle - The start angle in degrees, relative to the current tangent (defaults to 0)
|
|
26
27
|
* @param endAngle - The end angle in degrees, relative to the current tangent (defaults to 180)
|
|
27
28
|
*/
|
|
28
|
-
(radius:
|
|
29
|
+
(radius: NumberParam, startAngle?: NumberParam, endAngle?: NumberParam): IArcAngles;
|
|
29
30
|
/**
|
|
30
31
|
* Draws an arc to an end point on a specific plane.
|
|
31
32
|
* @param targetPlane - The plane to draw on
|
|
@@ -46,7 +47,7 @@ interface ArcFunction {
|
|
|
46
47
|
* @param startAngle - The start angle in degrees
|
|
47
48
|
* @param endAngle - The end angle in degrees
|
|
48
49
|
*/
|
|
49
|
-
(targetPlane: PlaneLike | ISceneObject, radius:
|
|
50
|
+
(targetPlane: PlaneLike | ISceneObject, radius: NumberParam, startAngle: NumberParam, endAngle: NumberParam): IArcAngles;
|
|
50
51
|
}
|
|
51
52
|
declare const _default: ArcFunction;
|
|
52
53
|
export default _default;
|
package/lib/dist/core/2d/arc.js
CHANGED
|
@@ -5,6 +5,7 @@ import { registerBuilder } from "../../index.js";
|
|
|
5
5
|
import { isPlaneLike } from "../../math/plane.js";
|
|
6
6
|
import { SceneObject } from "../../common/scene-object.js";
|
|
7
7
|
import { resolvePlane } from "../../helpers/resolve.js";
|
|
8
|
+
import { resolveParam } from "../param.js";
|
|
8
9
|
function build(context) {
|
|
9
10
|
return function arc() {
|
|
10
11
|
let planeObj = null;
|
|
@@ -37,9 +38,9 @@ function build(context) {
|
|
|
37
38
|
return arcObj;
|
|
38
39
|
}
|
|
39
40
|
// (radius, startAngle?, endAngle?) — all numeric args
|
|
40
|
-
const radius = arguments[argOffset] || 100;
|
|
41
|
-
const startAngle = arguments[argOffset + 1] || 0;
|
|
42
|
-
const endAngle = argCount >= 3 ? arguments[argOffset + 2] : 180;
|
|
41
|
+
const radius = resolveParam(arguments[argOffset]) || 100;
|
|
42
|
+
const startAngle = resolveParam(arguments[argOffset + 1]) || 0;
|
|
43
|
+
const endAngle = argCount >= 3 ? resolveParam(arguments[argOffset + 2]) : 180;
|
|
43
44
|
const arcObj = Arc.fromAngles(radius, startAngle, endAngle, planeObj);
|
|
44
45
|
context.addSceneObject(arcObj);
|
|
45
46
|
return arcObj;
|
|
@@ -2,13 +2,15 @@ import { Point2DLike } from "../../math/point.js";
|
|
|
2
2
|
import { IGeometry } from "../interfaces.js";
|
|
3
3
|
interface BezierFunction {
|
|
4
4
|
/**
|
|
5
|
-
* Draws a bezier curve
|
|
6
|
-
*
|
|
5
|
+
* Draws a bezier curve through the given points. The first argument is the
|
|
6
|
+
* explicit start, the last is the endpoint, and any in between are control
|
|
7
|
+
* points. Sets the sketch cursor to the endpoint.
|
|
7
8
|
* With 0 args: interactive mode placeholder (no geometry).
|
|
8
|
-
* With 1 arg:
|
|
9
|
-
* With 2 args: degree
|
|
10
|
-
* With 3 args: degree
|
|
11
|
-
*
|
|
9
|
+
* With 1 arg: places only the start point (no curve yet).
|
|
10
|
+
* With 2 args: degree 1 (straight line from start to end).
|
|
11
|
+
* With 3 args: degree 2 (quadratic bezier with 1 control point).
|
|
12
|
+
* With 4 args: degree 3 (cubic bezier with 2 control points).
|
|
13
|
+
* @param points - Start, optional control points, and end point
|
|
12
14
|
*/
|
|
13
15
|
(...points: Point2DLike[]): IGeometry;
|
|
14
16
|
}
|
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
import { Point2DLike } from "../../math/point.js";
|
|
2
2
|
import { PlaneLike } from "../../math/plane.js";
|
|
3
3
|
import { IExtrudableGeometry, ISceneObject } from "../interfaces.js";
|
|
4
|
+
import { type NumberParam } from "../param.js";
|
|
4
5
|
interface CircleFunction {
|
|
5
6
|
/**
|
|
6
7
|
* Draws a circle at a given center with an optional diameter.
|
|
7
8
|
* @param center - The center point
|
|
8
9
|
* @param diameter - The circle diameter (defaults to 40)
|
|
9
10
|
*/
|
|
10
|
-
(center: Point2DLike, diameter?:
|
|
11
|
+
(center: Point2DLike, diameter?: NumberParam): IExtrudableGeometry;
|
|
11
12
|
/**
|
|
12
13
|
* Draws a circle at the origin with an optional diameter.
|
|
13
14
|
* @param diameter - The circle diameter (defaults to 40)
|
|
14
15
|
*/
|
|
15
|
-
(diameter?:
|
|
16
|
+
(diameter?: NumberParam): IExtrudableGeometry;
|
|
16
17
|
/**
|
|
17
18
|
* Draws a circle with a given diameter on a specific plane.
|
|
18
19
|
* @param targetPlane - The plane to draw on
|
|
19
20
|
* @param diameter - The circle diameter
|
|
20
21
|
*/
|
|
21
|
-
(targetPlane: PlaneLike | ISceneObject, diameter:
|
|
22
|
+
(targetPlane: PlaneLike | ISceneObject, diameter: NumberParam): IExtrudableGeometry;
|
|
22
23
|
}
|
|
23
24
|
declare const _default: CircleFunction;
|
|
24
25
|
export default _default;
|
|
@@ -6,6 +6,7 @@ import { registerBuilder } from "../../index.js";
|
|
|
6
6
|
import { isPlaneLike } from "../../math/plane.js";
|
|
7
7
|
import { SceneObject } from "../../common/scene-object.js";
|
|
8
8
|
import { resolvePlane } from "../../helpers/resolve.js";
|
|
9
|
+
import { resolveParam } from "../param.js";
|
|
9
10
|
function build(context) {
|
|
10
11
|
return function circle() {
|
|
11
12
|
let diameter;
|
|
@@ -31,13 +32,13 @@ function build(context) {
|
|
|
31
32
|
context.addSceneObject(circle);
|
|
32
33
|
}
|
|
33
34
|
else if (argCount === 1) {
|
|
34
|
-
diameter = arguments[argOffset] || 40;
|
|
35
|
+
diameter = resolveParam(arguments[argOffset]) || 40;
|
|
35
36
|
circle = new Circle(diameter, null, planeObj);
|
|
36
37
|
context.addSceneObject(circle);
|
|
37
38
|
}
|
|
38
39
|
else {
|
|
39
40
|
center = normalizePoint2D(arguments[argOffset]);
|
|
40
|
-
diameter = arguments[argOffset + 1] || 40;
|
|
41
|
+
diameter = resolveParam(arguments[argOffset + 1]) || 40;
|
|
41
42
|
circle = new Circle(diameter, null, planeObj);
|
|
42
43
|
const move = new Move(center);
|
|
43
44
|
context.addSceneObjects([move, circle]);
|
|
@@ -1,27 +1,28 @@
|
|
|
1
1
|
import { Point2DLike } from "../../math/point.js";
|
|
2
2
|
import { PlaneLike } from "../../math/plane.js";
|
|
3
3
|
import { IExtrudableGeometry, ISceneObject } from "../interfaces.js";
|
|
4
|
+
import { type NumberParam } from "../param.js";
|
|
4
5
|
interface EllipseFunction {
|
|
5
6
|
/**
|
|
6
7
|
* Draws an ellipse at the current position.
|
|
7
8
|
* @param rx - Semi-radius along the plane's X axis
|
|
8
9
|
* @param ry - Semi-radius along the plane's Y axis
|
|
9
10
|
*/
|
|
10
|
-
(rx:
|
|
11
|
+
(rx: NumberParam, ry: NumberParam): IExtrudableGeometry;
|
|
11
12
|
/**
|
|
12
13
|
* Draws an ellipse at a given center.
|
|
13
14
|
* @param center - The center point
|
|
14
15
|
* @param rx - Semi-radius along the plane's X axis
|
|
15
16
|
* @param ry - Semi-radius along the plane's Y axis
|
|
16
17
|
*/
|
|
17
|
-
(center: Point2DLike, rx:
|
|
18
|
+
(center: Point2DLike, rx: NumberParam, ry: NumberParam): IExtrudableGeometry;
|
|
18
19
|
/**
|
|
19
20
|
* Draws an ellipse on a specific plane.
|
|
20
21
|
* @param targetPlane - The plane to draw on
|
|
21
22
|
* @param rx - Semi-radius along the plane's X axis
|
|
22
23
|
* @param ry - Semi-radius along the plane's Y axis
|
|
23
24
|
*/
|
|
24
|
-
(targetPlane: PlaneLike | ISceneObject, rx:
|
|
25
|
+
(targetPlane: PlaneLike | ISceneObject, rx: NumberParam, ry: NumberParam): IExtrudableGeometry;
|
|
25
26
|
/**
|
|
26
27
|
* Draws an ellipse at a given center on a specific plane.
|
|
27
28
|
* @param targetPlane - The plane to draw on
|
|
@@ -29,7 +30,7 @@ interface EllipseFunction {
|
|
|
29
30
|
* @param rx - Semi-radius along the plane's X axis
|
|
30
31
|
* @param ry - Semi-radius along the plane's Y axis
|
|
31
32
|
*/
|
|
32
|
-
(targetPlane: PlaneLike | ISceneObject, center: Point2DLike, rx:
|
|
33
|
+
(targetPlane: PlaneLike | ISceneObject, center: Point2DLike, rx: NumberParam, ry: NumberParam): IExtrudableGeometry;
|
|
33
34
|
}
|
|
34
35
|
declare const _default: EllipseFunction;
|
|
35
36
|
export default _default;
|
|
@@ -7,6 +7,7 @@ import { registerBuilder } from "../../index.js";
|
|
|
7
7
|
import { isPlaneLike } from "../../math/plane.js";
|
|
8
8
|
import { SceneObject } from "../../common/scene-object.js";
|
|
9
9
|
import { resolvePlane } from "../../helpers/resolve.js";
|
|
10
|
+
import { resolveParam } from "../param.js";
|
|
10
11
|
function toPoint2D(p) {
|
|
11
12
|
if (p instanceof Point2D) {
|
|
12
13
|
return p;
|
|
@@ -35,16 +36,16 @@ function build(context) {
|
|
|
35
36
|
}
|
|
36
37
|
const argCount = arguments.length - argOffset;
|
|
37
38
|
if (argCount === 2) {
|
|
38
|
-
const rx = arguments[argOffset];
|
|
39
|
-
const ry = arguments[argOffset + 1];
|
|
39
|
+
const rx = resolveParam(arguments[argOffset]);
|
|
40
|
+
const ry = resolveParam(arguments[argOffset + 1]);
|
|
40
41
|
const e = new Ellipse(rx, ry, planeObj);
|
|
41
42
|
context.addSceneObject(e);
|
|
42
43
|
return e;
|
|
43
44
|
}
|
|
44
45
|
if (argCount === 3) {
|
|
45
46
|
const centerArg = arguments[argOffset];
|
|
46
|
-
const rx = arguments[argOffset + 1];
|
|
47
|
-
const ry = arguments[argOffset + 2];
|
|
47
|
+
const rx = resolveParam(arguments[argOffset + 1]);
|
|
48
|
+
const ry = resolveParam(arguments[argOffset + 2]);
|
|
48
49
|
if (planeObj) {
|
|
49
50
|
// Standalone (plane, center, rx, ry): center is plane-local. Move
|
|
50
51
|
// can't run outside a sketch, so resolve the center eagerly into the
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { Point2DLike } from "../../math/point.js";
|
|
2
2
|
import { PlaneLike } from "../../math/plane.js";
|
|
3
3
|
import { IHLine, ISceneObject } from "../interfaces.js";
|
|
4
|
+
import { type NumberParam } from "../param.js";
|
|
4
5
|
interface HLineFunction {
|
|
5
6
|
/**
|
|
6
7
|
* Draws a horizontal line of the given distance.
|
|
7
8
|
* Chain `.centered()` to center the line on the current position.
|
|
8
9
|
* @param distance - The line length
|
|
9
10
|
*/
|
|
10
|
-
(distance:
|
|
11
|
+
(distance: NumberParam): IHLine;
|
|
11
12
|
/**
|
|
12
13
|
* Draws a horizontal line that ends where it intersects the target geometry.
|
|
13
14
|
* The nearest intersection (in either direction along the X axis) is used.
|
|
@@ -20,7 +21,7 @@ interface HLineFunction {
|
|
|
20
21
|
* @param start - The start point
|
|
21
22
|
* @param distance - The line length
|
|
22
23
|
*/
|
|
23
|
-
(start: Point2DLike, distance:
|
|
24
|
+
(start: Point2DLike, distance: NumberParam): IHLine;
|
|
24
25
|
/**
|
|
25
26
|
* Draws a horizontal line from a start point that ends where it intersects
|
|
26
27
|
* the target geometry. The nearest intersection (in either direction along
|
|
@@ -34,7 +35,7 @@ interface HLineFunction {
|
|
|
34
35
|
* @param targetPlane - The plane to draw on
|
|
35
36
|
* @param distance - The line length
|
|
36
37
|
*/
|
|
37
|
-
(targetPlane: PlaneLike | ISceneObject, distance:
|
|
38
|
+
(targetPlane: PlaneLike | ISceneObject, distance: NumberParam): IHLine;
|
|
38
39
|
}
|
|
39
40
|
declare const _default: HLineFunction;
|
|
40
41
|
export default _default;
|
|
@@ -6,6 +6,7 @@ import { registerBuilder } from "../../index.js";
|
|
|
6
6
|
import { isPlaneLike } from "../../math/plane.js";
|
|
7
7
|
import { SceneObject } from "../../common/scene-object.js";
|
|
8
8
|
import { resolvePlane } from "../../helpers/resolve.js";
|
|
9
|
+
import { isNumberParam, resolveParam } from "../param.js";
|
|
9
10
|
function build(context) {
|
|
10
11
|
return function line() {
|
|
11
12
|
let planeObj = null;
|
|
@@ -35,18 +36,19 @@ function build(context) {
|
|
|
35
36
|
context.addSceneObject(hline);
|
|
36
37
|
return hline;
|
|
37
38
|
}
|
|
38
|
-
if (argOffset === 0 &&
|
|
39
|
+
if (argOffset === 0 && !isNumberParam(arguments[0])) {
|
|
39
40
|
// hLine(start, distance) or hLine(start, target)
|
|
40
41
|
const start = normalizePoint2D(arguments[0]);
|
|
41
42
|
const second = arguments[1];
|
|
42
43
|
const distanceOrTarget = second instanceof SceneObject
|
|
43
44
|
? second
|
|
44
|
-
: second;
|
|
45
|
+
: resolveParam(second);
|
|
45
46
|
const hline = new HorizontalLine(distanceOrTarget, planeObj);
|
|
47
|
+
hline.setHasExplicitStart();
|
|
46
48
|
context.addSceneObjects([new Move(start), hline]);
|
|
47
49
|
return hline;
|
|
48
50
|
}
|
|
49
|
-
const distance = arguments[argOffset];
|
|
51
|
+
const distance = resolveParam(arguments[argOffset]);
|
|
50
52
|
const hline = new HorizontalLine(distance, planeObj);
|
|
51
53
|
context.addSceneObject(hline);
|
|
52
54
|
return hline;
|
package/lib/dist/core/2d/line.js
CHANGED
|
@@ -33,6 +33,7 @@ function build(context) {
|
|
|
33
33
|
const start = normalizePoint2D(arguments[argOffset]);
|
|
34
34
|
const end = normalizePoint2D(arguments[argOffset + 1]);
|
|
35
35
|
line = new LineTo(end, planeObj);
|
|
36
|
+
line.setHasExplicitStart();
|
|
36
37
|
context.addSceneObjects([new Move(start), line]);
|
|
37
38
|
}
|
|
38
39
|
else {
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { PlaneLike } from "../../math/plane.js";
|
|
2
2
|
import { IOffset, ISceneObject } from "../interfaces.js";
|
|
3
3
|
import { Extrudable } from "../../helpers/types.js";
|
|
4
|
+
import { type NumberParam, type BooleanParam } from "../param.js";
|
|
4
5
|
interface OffsetFunction {
|
|
5
6
|
/**
|
|
6
7
|
* Offsets the current sketch geometry by the given distance.
|
|
7
8
|
* @param distance - The offset distance (defaults to 1)
|
|
8
9
|
* @param removeOriginal - Whether to remove the original geometry
|
|
9
10
|
*/
|
|
10
|
-
(distance?:
|
|
11
|
+
(distance?: NumberParam, removeOriginal?: BooleanParam): IOffset;
|
|
11
12
|
/**
|
|
12
13
|
* Offsets source geometries onto a target plane.
|
|
13
14
|
* @param targetPlane - The plane to offset onto
|
|
@@ -15,7 +16,7 @@ interface OffsetFunction {
|
|
|
15
16
|
* @param removeOriginal - Whether to remove the original geometry
|
|
16
17
|
* @param sourceGeometries - The geometries to offset
|
|
17
18
|
*/
|
|
18
|
-
(targetPlane: PlaneLike | ISceneObject, distance:
|
|
19
|
+
(targetPlane: PlaneLike | ISceneObject, distance: NumberParam, removeOriginal: BooleanParam, ...sourceGeometries: Extrudable[]): IOffset;
|
|
19
20
|
}
|
|
20
21
|
declare const _default: OffsetFunction;
|
|
21
22
|
export default _default;
|
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
import { Offset } from "../../features/2d/offset.js";
|
|
2
2
|
import { registerBuilder } from "../../index.js";
|
|
3
3
|
import { resolvePlane } from "../../helpers/resolve.js";
|
|
4
|
+
import { isNumberParam, isBooleanParam, resolveParam } from "../param.js";
|
|
4
5
|
function build(context) {
|
|
5
6
|
return function offset(...args) {
|
|
6
7
|
// Plane-first mode: offset(plane, distance, removeOriginal, ...sourceGeometries)
|
|
7
8
|
// Detected when first arg is not a number/undefined.
|
|
8
|
-
if (args.length > 0 && args[0] !== undefined &&
|
|
9
|
+
if (args.length > 0 && args[0] !== undefined && !isNumberParam(args[0]) && !isBooleanParam(args[0])) {
|
|
9
10
|
if (context.getActiveSketch() !== null) {
|
|
10
11
|
throw new Error("offset(plane, ...) cannot be used inside a sketch. Use offset(...) instead.");
|
|
11
12
|
}
|
|
12
13
|
const planeObj = resolvePlane(args[0], context);
|
|
13
|
-
const distance = args[1] ?? 1;
|
|
14
|
-
const removeOriginal = args[2] ?? false;
|
|
14
|
+
const distance = resolveParam(args[1]) ?? 1;
|
|
15
|
+
const removeOriginal = resolveParam(args[2]) ?? false;
|
|
15
16
|
const sourceObjects = args.slice(3);
|
|
16
17
|
const off = new Offset(distance, removeOriginal, sourceObjects, planeObj);
|
|
17
18
|
context.addSceneObject(off);
|
|
18
19
|
return off;
|
|
19
20
|
}
|
|
20
21
|
// In-sketch mode: offset(distance, removeOriginal)
|
|
21
|
-
const distance = args[0]
|
|
22
|
-
const removeOriginal = args[1]
|
|
22
|
+
const distance = isNumberParam(args[0]) ? resolveParam(args[0]) : 1;
|
|
23
|
+
const removeOriginal = isBooleanParam(args[1]) ? resolveParam(args[1]) : false;
|
|
23
24
|
const off = new Offset(distance, removeOriginal);
|
|
24
25
|
context.addSceneObject(off);
|
|
25
26
|
return off;
|
|
@@ -2,6 +2,7 @@ import { Point2DLike } from "../../math/point.js";
|
|
|
2
2
|
import { PolygonMode } from "../../features/2d/polygon.js";
|
|
3
3
|
import { PlaneLike } from "../../math/plane.js";
|
|
4
4
|
import { IPolygon, ISceneObject } from "../interfaces.js";
|
|
5
|
+
import { type NumberParam } from "../param.js";
|
|
5
6
|
interface PolygonFunction {
|
|
6
7
|
/**
|
|
7
8
|
* Draws a regular polygon with the given number of sides and diameter.
|
|
@@ -9,7 +10,7 @@ interface PolygonFunction {
|
|
|
9
10
|
* @param diameter - The circumscribed or inscribed diameter
|
|
10
11
|
* @param mode - `'inscribed'` or `'circumscribed'` (defaults to `'inscribed'`)
|
|
11
12
|
*/
|
|
12
|
-
(numberOfSides:
|
|
13
|
+
(numberOfSides: NumberParam, diameter: NumberParam, mode?: PolygonMode): IPolygon;
|
|
13
14
|
/**
|
|
14
15
|
* Draws a regular polygon at a given center point.
|
|
15
16
|
* @param center - The center point
|
|
@@ -17,14 +18,14 @@ interface PolygonFunction {
|
|
|
17
18
|
* @param diameter - The circumscribed or inscribed diameter
|
|
18
19
|
* @param mode - `'inscribed'` or `'circumscribed'` (defaults to `'inscribed'`)
|
|
19
20
|
*/
|
|
20
|
-
(center: Point2DLike, numberOfSides:
|
|
21
|
+
(center: Point2DLike, numberOfSides: NumberParam, diameter: NumberParam, mode?: PolygonMode): IPolygon;
|
|
21
22
|
/**
|
|
22
23
|
* Draws a regular polygon on a specific plane.
|
|
23
24
|
* @param targetPlane - The plane to draw on
|
|
24
25
|
* @param numberOfSides - The number of sides
|
|
25
26
|
* @param diameter - The circumscribed or inscribed diameter
|
|
26
27
|
*/
|
|
27
|
-
(targetPlane: PlaneLike | ISceneObject, numberOfSides:
|
|
28
|
+
(targetPlane: PlaneLike | ISceneObject, numberOfSides: NumberParam, diameter: NumberParam): IPolygon;
|
|
28
29
|
/**
|
|
29
30
|
* Draws a regular polygon with a given mode on a specific plane.
|
|
30
31
|
* @param targetPlane - The plane to draw on
|
|
@@ -32,7 +33,7 @@ interface PolygonFunction {
|
|
|
32
33
|
* @param diameter - The circumscribed or inscribed diameter
|
|
33
34
|
* @param mode - `'inscribed'` or `'circumscribed'`
|
|
34
35
|
*/
|
|
35
|
-
(targetPlane: PlaneLike | ISceneObject, numberOfSides:
|
|
36
|
+
(targetPlane: PlaneLike | ISceneObject, numberOfSides: NumberParam, diameter: NumberParam, mode: PolygonMode): IPolygon;
|
|
36
37
|
}
|
|
37
38
|
declare const _default: PolygonFunction;
|
|
38
39
|
export default _default;
|
|
@@ -6,6 +6,7 @@ import { registerBuilder } from "../../index.js";
|
|
|
6
6
|
import { isPlaneLike } from "../../math/plane.js";
|
|
7
7
|
import { SceneObject } from "../../common/scene-object.js";
|
|
8
8
|
import { resolvePlane } from "../../helpers/resolve.js";
|
|
9
|
+
import { isNumberParam, resolveParam } from "../param.js";
|
|
9
10
|
function build(context) {
|
|
10
11
|
return function polygon() {
|
|
11
12
|
let numberOfSides;
|
|
@@ -30,24 +31,24 @@ function build(context) {
|
|
|
30
31
|
}
|
|
31
32
|
const argCount = arguments.length - argOffset;
|
|
32
33
|
if (argCount === 2) {
|
|
33
|
-
numberOfSides = arguments[argOffset];
|
|
34
|
-
diameter = arguments[argOffset + 1];
|
|
34
|
+
numberOfSides = resolveParam(arguments[argOffset]);
|
|
35
|
+
diameter = resolveParam(arguments[argOffset + 1]);
|
|
35
36
|
mode = 'inscribed';
|
|
36
37
|
poly = new Polygon(numberOfSides, diameter, mode, planeObj);
|
|
37
38
|
context.addSceneObject(poly);
|
|
38
39
|
}
|
|
39
40
|
else if (argCount === 3) {
|
|
40
|
-
if (
|
|
41
|
-
numberOfSides = arguments[argOffset];
|
|
42
|
-
diameter = arguments[argOffset + 1];
|
|
41
|
+
if (isNumberParam(arguments[argOffset])) {
|
|
42
|
+
numberOfSides = resolveParam(arguments[argOffset]);
|
|
43
|
+
diameter = resolveParam(arguments[argOffset + 1]);
|
|
43
44
|
mode = arguments[argOffset + 2];
|
|
44
45
|
poly = new Polygon(numberOfSides, diameter, mode, planeObj);
|
|
45
46
|
context.addSceneObject(poly);
|
|
46
47
|
}
|
|
47
48
|
else {
|
|
48
49
|
center = normalizePoint2D(arguments[argOffset]);
|
|
49
|
-
numberOfSides = arguments[argOffset + 1];
|
|
50
|
-
diameter = arguments[argOffset + 2];
|
|
50
|
+
numberOfSides = resolveParam(arguments[argOffset + 1]);
|
|
51
|
+
diameter = resolveParam(arguments[argOffset + 2]);
|
|
51
52
|
mode = 'inscribed';
|
|
52
53
|
poly = new Polygon(numberOfSides, diameter, mode, planeObj);
|
|
53
54
|
context.addSceneObjects([new Move(center), poly]);
|
|
@@ -55,8 +56,8 @@ function build(context) {
|
|
|
55
56
|
}
|
|
56
57
|
else if (argCount === 4) {
|
|
57
58
|
center = normalizePoint2D(arguments[argOffset]);
|
|
58
|
-
numberOfSides = arguments[argOffset + 1];
|
|
59
|
-
diameter = arguments[argOffset + 2];
|
|
59
|
+
numberOfSides = resolveParam(arguments[argOffset + 1]);
|
|
60
|
+
diameter = resolveParam(arguments[argOffset + 2]);
|
|
60
61
|
mode = arguments[argOffset + 3];
|
|
61
62
|
poly = new Polygon(numberOfSides, diameter, mode, planeObj);
|
|
62
63
|
context.addSceneObjects([new Move(center), poly]);
|
|
@@ -1,27 +1,28 @@
|
|
|
1
1
|
import { Point2DLike } from "../../math/point.js";
|
|
2
2
|
import { PlaneLike } from "../../math/plane.js";
|
|
3
3
|
import { IRect, ISceneObject } from "../interfaces.js";
|
|
4
|
+
import { type NumberParam } from "../param.js";
|
|
4
5
|
interface RectFunction {
|
|
5
6
|
/**
|
|
6
7
|
* Draws a rectangle with the given width and optional height.
|
|
7
8
|
* @param width - The rectangle width
|
|
8
9
|
* @param height - The rectangle height (defaults to width)
|
|
9
10
|
*/
|
|
10
|
-
(width:
|
|
11
|
+
(width: NumberParam, height?: NumberParam): IRect;
|
|
11
12
|
/**
|
|
12
13
|
* Draws a rectangle at a given start point.
|
|
13
14
|
* @param start - The start point (bottom-left corner)
|
|
14
15
|
* @param width - The rectangle width
|
|
15
16
|
* @param height - The rectangle height (defaults to width)
|
|
16
17
|
*/
|
|
17
|
-
(start: Point2DLike, width:
|
|
18
|
+
(start: Point2DLike, width: NumberParam, height?: NumberParam): IRect;
|
|
18
19
|
/**
|
|
19
20
|
* Draws a rectangle with given dimensions on a specific plane.
|
|
20
21
|
* @param targetPlane - The plane to draw on
|
|
21
22
|
* @param width - The rectangle width
|
|
22
23
|
* @param height - The rectangle height
|
|
23
24
|
*/
|
|
24
|
-
(targetPlane: PlaneLike | ISceneObject, width:
|
|
25
|
+
(targetPlane: PlaneLike | ISceneObject, width: NumberParam, height: NumberParam): IRect;
|
|
25
26
|
}
|
|
26
27
|
declare const _default: RectFunction;
|
|
27
28
|
export default _default;
|
package/lib/dist/core/2d/rect.js
CHANGED
|
@@ -6,6 +6,7 @@ import { registerBuilder } from "../../index.js";
|
|
|
6
6
|
import { isPlaneLike } from "../../math/plane.js";
|
|
7
7
|
import { SceneObject } from "../../common/scene-object.js";
|
|
8
8
|
import { resolvePlane } from "../../helpers/resolve.js";
|
|
9
|
+
import { isNumberParam, resolveParam } from "../param.js";
|
|
9
10
|
function build(context) {
|
|
10
11
|
return function cRect() {
|
|
11
12
|
// Detect plane as first argument (only valid outside a sketch)
|
|
@@ -16,8 +17,8 @@ function build(context) {
|
|
|
16
17
|
throw new Error("rect(plane, ...) cannot be used inside a sketch. Use rect(...) instead.");
|
|
17
18
|
}
|
|
18
19
|
const planeObj = resolvePlane(firstArg, context);
|
|
19
|
-
const width = arguments[1];
|
|
20
|
-
const height = arguments[2];
|
|
20
|
+
const width = resolveParam(arguments[1]);
|
|
21
|
+
const height = resolveParam(arguments[2]);
|
|
21
22
|
const rect = new Rect(width, height, planeObj);
|
|
22
23
|
context.addSceneObject(rect);
|
|
23
24
|
return rect;
|
|
@@ -25,22 +26,22 @@ function build(context) {
|
|
|
25
26
|
}
|
|
26
27
|
const argCount = arguments.length;
|
|
27
28
|
if (argCount === 1) {
|
|
28
|
-
const width = arguments[0];
|
|
29
|
+
const width = resolveParam(arguments[0]);
|
|
29
30
|
const rect = new Rect(width, width);
|
|
30
31
|
context.addSceneObject(rect);
|
|
31
32
|
return rect;
|
|
32
33
|
}
|
|
33
34
|
else if (argCount === 2) {
|
|
34
|
-
if (
|
|
35
|
-
const width = arguments[0];
|
|
36
|
-
const height = arguments[1];
|
|
35
|
+
if (isNumberParam(arguments[0])) {
|
|
36
|
+
const width = resolveParam(arguments[0]);
|
|
37
|
+
const height = resolveParam(arguments[1]);
|
|
37
38
|
const rect = new Rect(width, height);
|
|
38
39
|
context.addSceneObject(rect);
|
|
39
40
|
return rect;
|
|
40
41
|
}
|
|
41
42
|
else {
|
|
42
43
|
const start = normalizePoint2D(arguments[0]);
|
|
43
|
-
const width = arguments[1];
|
|
44
|
+
const width = resolveParam(arguments[1]);
|
|
44
45
|
const rect = new Rect(width, width);
|
|
45
46
|
context.addSceneObjects([new Move(start), rect]);
|
|
46
47
|
return rect;
|
|
@@ -48,8 +49,8 @@ function build(context) {
|
|
|
48
49
|
}
|
|
49
50
|
else if (argCount === 3) {
|
|
50
51
|
const start = normalizePoint2D(arguments[0]);
|
|
51
|
-
const width = arguments[1];
|
|
52
|
-
const height = arguments[2];
|
|
52
|
+
const width = resolveParam(arguments[1]);
|
|
53
|
+
const height = resolveParam(arguments[2]);
|
|
53
54
|
const rect = new Rect(width, height);
|
|
54
55
|
context.addSceneObjects([new Move(start), rect]);
|
|
55
56
|
return rect;
|