fluidcad 0.0.33 → 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 +72 -2
- package/bin/commands/init.js +55 -0
- package/bin/commands/login.js +120 -0
- package/bin/commands/mcp.js +33 -0
- package/bin/commands/pack.js +49 -0
- package/bin/commands/publish.js +136 -0
- package/bin/commands/serve.js +77 -0
- package/bin/fluidcad.js +21 -107
- 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/scene-object.d.ts +2 -1
- package/lib/dist/common/scene-object.js +3 -2
- 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/tarc.d.ts +20 -2
- package/lib/dist/core/2d/tarc.js +24 -0
- 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 +55 -25
- 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 +72 -54
- 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.d.ts +8 -2
- package/lib/dist/features/2d/arc.js +94 -17
- package/lib/dist/features/2d/back.js +3 -2
- 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.d.ts +4 -0
- package/lib/dist/features/2d/sketch.js +25 -0
- 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-constrained.d.ts +2 -0
- package/lib/dist/features/2d/tarc-constrained.js +8 -0
- package/lib/dist/features/2d/tarc-radius-to-object.d.ts +16 -0
- package/lib/dist/features/2d/tarc-radius-to-object.js +58 -0
- package/lib/dist/features/2d/tarc-to-object.d.ts +18 -0
- package/lib/dist/features/2d/tarc-to-object.js +66 -0
- package/lib/dist/features/2d/tarc-to-point-tangent.d.ts +2 -0
- package/lib/dist/features/2d/tarc-to-point-tangent.js +6 -0
- package/lib/dist/features/2d/tarc-to-point.d.ts +2 -0
- package/lib/dist/features/2d/tarc-to-point.js +6 -0
- package/lib/dist/features/2d/tarc-with-tangent.d.ts +2 -0
- package/lib/dist/features/2d/tarc-with-tangent.js +6 -0
- package/lib/dist/features/2d/tarc.d.ts +2 -0
- package/lib/dist/features/2d/tarc.js +6 -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 +13 -3
- package/lib/dist/features/extrude-base.js +32 -3
- package/lib/dist/features/extrude-to-face.js +1 -5
- package/lib/dist/features/extrude-two-distances.js +1 -2
- package/lib/dist/features/extrude.js +1 -2
- package/lib/dist/features/mirror-feature.d.ts +3 -2
- package/lib/dist/features/mirror-feature.js +1 -1
- 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 +8 -7
- package/lib/dist/features/repeat-circular.js +7 -3
- package/lib/dist/features/repeat-linear.d.ts +9 -7
- package/lib/dist/features/repeat-linear.js +9 -3
- package/lib/dist/features/repeat-matrix.d.ts +3 -1
- package/lib/dist/features/repeat-matrix.js +7 -2
- package/lib/dist/features/shell.d.ts +4 -1
- package/lib/dist/features/shell.js +14 -3
- package/lib/dist/helpers/clone-transform.d.ts +2 -1
- package/lib/dist/index.d.ts +12 -1
- package/lib/dist/index.js +11 -4
- 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 +36 -0
- package/lib/dist/math/lazy-matrix.js +134 -0
- package/lib/dist/oc/boolean-ops.d.ts +2 -2
- package/lib/dist/oc/constraints/constraint-solver-adaptor.d.ts +5 -0
- package/lib/dist/oc/constraints/constraint-solver-adaptor.js +16 -0
- package/lib/dist/oc/constraints/constraint-solver.d.ts +4 -0
- package/lib/dist/oc/constraints/curve/curve-constraint-solver.d.ts +4 -0
- package/lib/dist/oc/constraints/curve/curve-constraint-solver.js +3 -0
- package/lib/dist/oc/constraints/geometric/geometric-constraint-solver.d.ts +6 -1
- package/lib/dist/oc/constraints/geometric/geometric-constraint-solver.js +4 -0
- package/lib/dist/oc/constraints/geometric/tangent-arc-from-point-tangent.d.ts +8 -0
- package/lib/dist/oc/constraints/geometric/tangent-arc-from-point-tangent.js +111 -0
- package/lib/dist/oc/constraints/geometric/tangent-arc-radius-to-object.d.ts +8 -0
- package/lib/dist/oc/constraints/geometric/tangent-arc-radius-to-object.js +161 -0
- package/lib/dist/oc/mesh.d.ts +9 -4
- package/lib/dist/oc/mesh.js +14 -13
- package/lib/dist/oc/shell-ops.d.ts +2 -1
- package/lib/dist/oc/shell-ops.js +5 -2
- package/lib/dist/param-registry.d.ts +34 -0
- package/lib/dist/param-registry.js +60 -0
- package/lib/dist/rendering/mesh-builder.d.ts +3 -0
- package/lib/dist/rendering/mesh-builder.js +10 -5
- package/lib/dist/rendering/render-edge.d.ts +2 -1
- package/lib/dist/rendering/render-edge.js +2 -2
- package/lib/dist/rendering/render-face.d.ts +2 -1
- package/lib/dist/rendering/render-face.js +2 -2
- package/lib/dist/rendering/render-solid.d.ts +2 -1
- package/lib/dist/rendering/render-solid.js +2 -2
- package/lib/dist/rendering/render-wire.d.ts +2 -1
- package/lib/dist/rendering/render-wire.js +2 -2
- package/lib/dist/rendering/render.d.ts +3 -0
- package/lib/dist/rendering/render.js +7 -2
- package/lib/dist/scene-manager.d.ts +4 -2
- package/lib/dist/scene-manager.js +12 -4
- package/lib/dist/tests/features/2d/arc.test.js +64 -0
- package/lib/dist/tests/features/2d/back.test.js +17 -1
- package/lib/dist/tests/features/2d/tarc.test.js +157 -0
- 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/tests/features/repeat-user-repro.test.d.ts +1 -0
- package/lib/dist/tests/features/repeat-user-repro.test.js +60 -0
- package/lib/dist/tests/features/shell.test.js +36 -0
- package/lib/dist/tests/global-setup.js +2 -1
- package/lib/dist/tests/helpers/extract-blocks.d.ts +9 -0
- package/lib/dist/tests/helpers/extract-blocks.js +56 -0
- package/lib/dist/tests/llm-docs-examples.test.d.ts +1 -0
- package/lib/dist/tests/llm-docs-examples.test.js +62 -0
- package/lib/dist/tests/setup.js +2 -1
- package/lib/dist/tsconfig.tsbuildinfo +1 -1
- package/llm-docs/.coverage-allowlist.txt +9 -0
- package/llm-docs/api/arc.md +48 -0
- package/llm-docs/api/axis.md +42 -0
- package/llm-docs/api/bezier.md +41 -0
- package/llm-docs/api/booleans.md +44 -0
- package/llm-docs/api/chamfer.md +40 -0
- package/llm-docs/api/circle.md +36 -0
- package/llm-docs/api/color.md +34 -0
- package/llm-docs/api/connect.md +41 -0
- package/llm-docs/api/constraint-qualifiers.md +48 -0
- package/llm-docs/api/copy.md +63 -0
- package/llm-docs/api/cursor-lines.md +50 -0
- package/llm-docs/api/cursor-move.md +61 -0
- package/llm-docs/api/cut.md +55 -0
- package/llm-docs/api/draft.md +36 -0
- package/llm-docs/api/edge-filter.md +57 -0
- package/llm-docs/api/ellipse.md +34 -0
- package/llm-docs/api/extrude.md +74 -0
- package/llm-docs/api/face-filter.md +61 -0
- package/llm-docs/api/fillet.md +51 -0
- package/llm-docs/api/index.json +139 -0
- package/llm-docs/api/line.md +42 -0
- package/llm-docs/api/load.md +37 -0
- package/llm-docs/api/local.md +38 -0
- package/llm-docs/api/loft.md +37 -0
- package/llm-docs/api/mirror.md +44 -0
- package/llm-docs/api/offset.md +36 -0
- package/llm-docs/api/part.md +40 -0
- package/llm-docs/api/plane.md +44 -0
- package/llm-docs/api/polygon.md +37 -0
- package/llm-docs/api/primitive-solids.md +39 -0
- package/llm-docs/api/project-intersect.md +48 -0
- package/llm-docs/api/rect.md +48 -0
- package/llm-docs/api/remove.md +32 -0
- package/llm-docs/api/repeat.md +79 -0
- package/llm-docs/api/revolve.md +38 -0
- package/llm-docs/api/rib.md +40 -0
- package/llm-docs/api/rotate.md +37 -0
- package/llm-docs/api/select.md +41 -0
- package/llm-docs/api/shell.md +41 -0
- package/llm-docs/api/sketch.md +76 -0
- package/llm-docs/api/slot.md +36 -0
- package/llm-docs/api/split-trim.md +42 -0
- package/llm-docs/api/sweep.md +43 -0
- package/llm-docs/api/tarc.md +45 -0
- package/llm-docs/api/tcircle.md +38 -0
- package/llm-docs/api/tline.md +42 -0
- package/llm-docs/api/translate.md +40 -0
- package/llm-docs/api/types/aline.md +35 -0
- package/llm-docs/api/types/arc-angles.md +29 -0
- package/llm-docs/api/types/arc-points.md +48 -0
- package/llm-docs/api/types/axis-like.md +38 -0
- package/llm-docs/api/types/axis.md +21 -0
- package/llm-docs/api/types/boolean-operation.md +50 -0
- package/llm-docs/api/types/circular-repeat-options.md +31 -0
- package/llm-docs/api/types/common.md +32 -0
- package/llm-docs/api/types/cut.md +125 -0
- package/llm-docs/api/types/draft.md +21 -0
- package/llm-docs/api/types/extrudable-geometry.md +23 -0
- package/llm-docs/api/types/extrude.md +194 -0
- package/llm-docs/api/types/geometry.md +51 -0
- package/llm-docs/api/types/hline.md +35 -0
- package/llm-docs/api/types/linear-repeat-options.md +31 -0
- package/llm-docs/api/types/loft.md +154 -0
- package/llm-docs/api/types/mirror.md +35 -0
- package/llm-docs/api/types/offset.md +31 -0
- package/llm-docs/api/types/plane-like.md +35 -0
- package/llm-docs/api/types/plane-transform-options.md +29 -0
- package/llm-docs/api/types/plane.md +21 -0
- package/llm-docs/api/types/point-like.md +22 -0
- package/llm-docs/api/types/point2dlike.md +26 -0
- package/llm-docs/api/types/polygon.md +46 -0
- package/llm-docs/api/types/rect.md +128 -0
- package/llm-docs/api/types/revolve.md +102 -0
- package/llm-docs/api/types/rib.md +133 -0
- package/llm-docs/api/types/scene-object.md +33 -0
- package/llm-docs/api/types/select.md +21 -0
- package/llm-docs/api/types/shell.md +54 -0
- package/llm-docs/api/types/slot.md +43 -0
- package/llm-docs/api/types/sweep.md +189 -0
- package/llm-docs/api/types/tangent-arc-two-objects.md +46 -0
- package/llm-docs/api/types/transformable.md +93 -0
- package/llm-docs/api/types/trim.md +27 -0
- package/llm-docs/api/types/two-objects-tangent-line.md +46 -0
- package/llm-docs/api/types/vertex.md +17 -0
- package/llm-docs/api/types/vline.md +35 -0
- package/llm-docs/concepts/coordinate-system.md +45 -0
- package/llm-docs/concepts/history-and-rollback.md +40 -0
- package/llm-docs/concepts/last-selection.md +49 -0
- package/llm-docs/concepts/scene-graph.md +37 -0
- package/llm-docs/index.json +1750 -0
- package/mcp/dist/client.d.ts +65 -0
- package/mcp/dist/client.js +255 -0
- package/mcp/dist/discovery.d.ts +11 -0
- package/mcp/dist/discovery.js +78 -0
- package/mcp/dist/docs-index.d.ts +81 -0
- package/mcp/dist/docs-index.js +261 -0
- package/mcp/dist/resources.d.ts +4 -0
- package/mcp/dist/resources.js +115 -0
- package/mcp/dist/server.d.ts +12 -0
- package/mcp/dist/server.js +502 -0
- package/mcp/dist/tools/coordination.d.ts +9 -0
- package/mcp/dist/tools/coordination.js +46 -0
- package/mcp/dist/tools/docs.d.ts +66 -0
- package/mcp/dist/tools/docs.js +122 -0
- package/mcp/dist/tools/engine.d.ts +72 -0
- package/mcp/dist/tools/engine.js +190 -0
- package/mcp/dist/tools/inspection.d.ts +75 -0
- package/mcp/dist/tools/inspection.js +121 -0
- package/mcp/dist/tools/screenshot.d.ts +63 -0
- package/mcp/dist/tools/screenshot.js +263 -0
- package/mcp/dist/tools/source.d.ts +84 -0
- package/mcp/dist/tools/source.js +434 -0
- package/mcp/dist/tools/workspaces.d.ts +13 -0
- package/mcp/dist/tools/workspaces.js +33 -0
- package/mcp/dist/types.d.ts +18 -0
- package/mcp/dist/types.js +11 -0
- package/package.json +27 -7
- package/server/dist/api.d.ts +37 -0
- package/server/dist/api.js +44 -0
- package/server/dist/code-editor.d.ts +100 -0
- package/server/dist/code-editor.js +528 -2
- package/server/dist/fluidcad-server.d.ts +118 -1
- package/server/dist/fluidcad-server.js +350 -62
- package/server/dist/global-registry.d.ts +30 -0
- package/server/dist/global-registry.js +126 -0
- 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 +175 -123
- package/server/dist/instance-file.d.ts +31 -0
- package/server/dist/instance-file.js +73 -0
- package/server/dist/lint-fluid-js.d.ts +15 -0
- package/server/dist/lint-fluid-js.js +271 -0
- 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/editor.d.ts +24 -0
- package/server/dist/routes/editor.js +44 -0
- package/server/dist/routes/export.d.ts +1 -1
- package/server/dist/routes/export.js +45 -8
- package/server/dist/routes/health.d.ts +7 -0
- package/server/dist/routes/health.js +14 -0
- package/server/dist/routes/hit-test.d.ts +3 -0
- package/server/dist/routes/hit-test.js +17 -0
- package/server/dist/routes/lint.d.ts +10 -0
- package/server/dist/routes/lint.js +28 -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/render.d.ts +33 -0
- package/server/dist/routes/render.js +34 -0
- package/server/dist/routes/scene.d.ts +5 -0
- package/server/dist/routes/scene.js +48 -0
- package/server/dist/routes/screenshot.js +68 -1
- 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 +156 -3
- 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-CFi9p7wR.js +0 -4946
- package/ui/dist/assets/index-DR7c2Qk9.css +0 -2
package/bin/fluidcad.js
CHANGED
|
@@ -1,115 +1,29 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { Command } from 'commander';
|
|
4
|
+
import { readFileSync } from 'fs';
|
|
5
|
+
import { dirname, resolve } from 'path';
|
|
5
6
|
import { fileURLToPath } from 'url';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { registerInitCommand } from './commands/init.js';
|
|
8
|
+
import { registerServeCommand } from './commands/serve.js';
|
|
9
|
+
import { registerMcpCommand } from './commands/mcp.js';
|
|
10
|
+
import { registerPackCommand } from './commands/pack.js';
|
|
11
|
+
import { registerLoginCommand } from './commands/login.js';
|
|
12
|
+
import { registerPublishCommand } from './commands/publish.js';
|
|
9
13
|
|
|
10
14
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
15
|
+
const pkg = JSON.parse(readFileSync(resolve(__dirname, '..', 'package.json'), 'utf8'));
|
|
11
16
|
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
},
|
|
17
|
-
allowPositionals: true,
|
|
18
|
-
});
|
|
17
|
+
const program = new Command()
|
|
18
|
+
.name('fluidcad')
|
|
19
|
+
.description('FluidCAD CLI')
|
|
20
|
+
.version(pkg.version);
|
|
19
21
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
registerInitCommand(program);
|
|
23
|
+
registerServeCommand(program);
|
|
24
|
+
registerMcpCommand(program);
|
|
25
|
+
registerPackCommand(program);
|
|
26
|
+
registerLoginCommand(program);
|
|
27
|
+
registerPublishCommand(program);
|
|
22
28
|
|
|
23
|
-
|
|
24
|
-
if (existsSync(initPath)) {
|
|
25
|
-
console.error('init.js already exists in this directory.');
|
|
26
|
-
process.exit(1);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
writeFileSync(initPath, `import { init } from 'fluidcad'\n\nexport default await init()\n`);
|
|
30
|
-
|
|
31
|
-
const testPath = resolve(cwd, 'test.fluid.js');
|
|
32
|
-
if (!existsSync(testPath)) {
|
|
33
|
-
writeFileSync(testPath, `import { extrude, fillet, rect, shell, sketch } from "fluidcad/core";
|
|
34
|
-
|
|
35
|
-
sketch("xy", () => {
|
|
36
|
-
rect(100, 50).radius(10).centered();
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
const e = extrude(30);
|
|
40
|
-
|
|
41
|
-
fillet(4, e.startEdges());
|
|
42
|
-
|
|
43
|
-
shell(-2, e.endFaces());
|
|
44
|
-
`);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const jsconfigPath = resolve(cwd, 'jsconfig.json');
|
|
48
|
-
if (!existsSync(jsconfigPath)) {
|
|
49
|
-
writeFileSync(jsconfigPath, JSON.stringify({
|
|
50
|
-
compilerOptions: {
|
|
51
|
-
checkJs: true,
|
|
52
|
-
module: 'node20',
|
|
53
|
-
},
|
|
54
|
-
}, null, 2) + '\n');
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
console.log('FluidCAD initialized.');
|
|
58
|
-
process.exit(0);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const serverEntry = resolve(__dirname, '..', 'server', 'dist', 'index.js');
|
|
62
|
-
|
|
63
|
-
const server = fork(serverEntry, [], {
|
|
64
|
-
env: {
|
|
65
|
-
...process.env,
|
|
66
|
-
FLUIDCAD_SERVER_PORT: values.port,
|
|
67
|
-
FLUIDCAD_WORKSPACE_PATH: resolve(values.workspace),
|
|
68
|
-
},
|
|
69
|
-
stdio: ['pipe', 'pipe', 'pipe', 'ipc'],
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
server.stdout.on('data', (data) => {
|
|
73
|
-
process.stdout.write(data);
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
server.stderr.on('data', (data) => {
|
|
77
|
-
process.stderr.write(data);
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
const workspacePath = resolve(values.workspace);
|
|
81
|
-
let watcher;
|
|
82
|
-
|
|
83
|
-
server.on('message', (msg) => {
|
|
84
|
-
if (msg.type === 'ready') {
|
|
85
|
-
console.log(`FluidCAD server ready at ${msg.url}`);
|
|
86
|
-
}
|
|
87
|
-
if (msg.type === 'init-complete') {
|
|
88
|
-
if (msg.success) {
|
|
89
|
-
console.log('FluidCAD initialized successfully.');
|
|
90
|
-
watcher = createFileWatcher(workspacePath, server);
|
|
91
|
-
|
|
92
|
-
const files = findFluidFiles(workspacePath);
|
|
93
|
-
if (files.length > 0) {
|
|
94
|
-
server.send({ type: 'process-file', filePath: files[0] });
|
|
95
|
-
}
|
|
96
|
-
} else {
|
|
97
|
-
console.error(`FluidCAD initialization failed: ${msg.error}`);
|
|
98
|
-
process.exit(1);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
server.on('exit', (code) => {
|
|
104
|
-
process.exit(code || 0);
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
process.on('SIGINT', () => {
|
|
108
|
-
if (watcher) { watcher.close(); }
|
|
109
|
-
server.kill('SIGINT');
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
process.on('SIGTERM', () => {
|
|
113
|
-
if (watcher) { watcher.close(); }
|
|
114
|
-
server.kill('SIGTERM');
|
|
115
|
-
});
|
|
29
|
+
program.parseAsync(process.argv);
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { getHubUrl } from './config.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Tiny client for the hub API. The CLI commands are pure API clients — open a
|
|
5
|
+
* browser, store a token, POST a package — so this just wraps `fetch` with the
|
|
6
|
+
* bearer header and a uniform `{ status, body }` result.
|
|
7
|
+
*/
|
|
8
|
+
export class HubClient {
|
|
9
|
+
constructor(hubUrl, token) {
|
|
10
|
+
this.base = getHubUrl(hubUrl);
|
|
11
|
+
this.token = token;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
#authHeaders(extra = {}) {
|
|
15
|
+
return { ...(this.token ? { authorization: `Bearer ${this.token}` } : {}), ...extra };
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async #result(res) {
|
|
19
|
+
const body = await res.json().catch(() => ({}));
|
|
20
|
+
return { status: res.status, body };
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async postJson(path, body) {
|
|
24
|
+
const res = await fetch(this.base + path, {
|
|
25
|
+
method: 'POST',
|
|
26
|
+
headers: this.#authHeaders({ 'content-type': 'application/json' }),
|
|
27
|
+
body: JSON.stringify(body),
|
|
28
|
+
});
|
|
29
|
+
return this.#result(res);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async postForm(path, form) {
|
|
33
|
+
const res = await fetch(this.base + path, {
|
|
34
|
+
method: 'POST',
|
|
35
|
+
headers: this.#authHeaders(),
|
|
36
|
+
body: form,
|
|
37
|
+
});
|
|
38
|
+
return this.#result(res);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import open from 'open';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Best-effort browser open, shared by `login` and `publish`. The caller always
|
|
5
|
+
* prints the URL too, so a failure here (headless box, SSH, no DISPLAY) is
|
|
6
|
+
* non-fatal — the user can open it manually.
|
|
7
|
+
*/
|
|
8
|
+
export async function openBrowser(url) {
|
|
9
|
+
try {
|
|
10
|
+
const child = await open(url);
|
|
11
|
+
// Detach so a one-shot CLI process isn't held open by the browser handle.
|
|
12
|
+
child.unref?.();
|
|
13
|
+
} catch {
|
|
14
|
+
/* ignore — the URL is printed regardless */
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { homedir } from 'os';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
import { mkdirSync, readFileSync, writeFileSync, existsSync, chmodSync } from 'fs';
|
|
4
|
+
|
|
5
|
+
// Where the CLI keeps its hub credentials. XDG-ish; one file, mode 0600.
|
|
6
|
+
const CONFIG_DIR = join(homedir(), '.config', 'fluidcad');
|
|
7
|
+
export const CREDENTIALS_PATH = join(CONFIG_DIR, 'credentials.json');
|
|
8
|
+
|
|
9
|
+
const DEFAULT_HUB_URL = 'https://hub.fluidcad.io';
|
|
10
|
+
|
|
11
|
+
/** Resolve the hub base URL: explicit override → $FLUIDCAD_HUB_URL → default. */
|
|
12
|
+
export function getHubUrl(override) {
|
|
13
|
+
const url = override || process.env.FLUIDCAD_HUB_URL || DEFAULT_HUB_URL;
|
|
14
|
+
return url.replace(/\/+$/, '');
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** Read saved credentials, or null if not logged in / unreadable. */
|
|
18
|
+
export function readCredentials() {
|
|
19
|
+
try {
|
|
20
|
+
const creds = JSON.parse(readFileSync(CREDENTIALS_PATH, 'utf8'));
|
|
21
|
+
return creds && creds.token ? creds : null;
|
|
22
|
+
} catch {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Persist credentials at mode 0600 (re-chmod in case the file pre-existed). */
|
|
28
|
+
export function writeCredentials(creds) {
|
|
29
|
+
mkdirSync(CONFIG_DIR, { recursive: true });
|
|
30
|
+
writeFileSync(CREDENTIALS_PATH, JSON.stringify(creds, null, 2) + '\n', { mode: 0o600 });
|
|
31
|
+
chmodSync(CREDENTIALS_PATH, 0o600);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Forget saved credentials (used by `logout`). */
|
|
35
|
+
export function clearCredentials() {
|
|
36
|
+
if (existsSync(CREDENTIALS_PATH)) {
|
|
37
|
+
writeFileSync(CREDENTIALS_PATH, '{}\n', { mode: 0o600 });
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { readFileSync, writeFileSync } from 'fs';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
|
|
4
|
+
// `fluidcad.json` at the workspace root holds the stable, hub-minted model
|
|
5
|
+
// identity (and room to grow: default visibility, name, …). It's meant to be
|
|
6
|
+
// committed — like `fly.toml`, it ties a workspace to the model it publishes
|
|
7
|
+
// to, so re-publishing creates a new VERSION rather than an unrelated model.
|
|
8
|
+
const FILENAME = 'fluidcad.json';
|
|
9
|
+
|
|
10
|
+
export function modelConfigPath(workspace) {
|
|
11
|
+
return join(workspace, FILENAME);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** Read `fluidcad.json`, or an empty object if missing/unreadable. */
|
|
15
|
+
export function readModelConfig(workspace) {
|
|
16
|
+
try {
|
|
17
|
+
const cfg = JSON.parse(readFileSync(modelConfigPath(workspace), 'utf8'));
|
|
18
|
+
return cfg && typeof cfg === 'object' ? cfg : {};
|
|
19
|
+
} catch {
|
|
20
|
+
return {};
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** The persisted hub model id for this workspace, or null on first publish. */
|
|
25
|
+
export function readModelId(workspace) {
|
|
26
|
+
const cfg = readModelConfig(workspace);
|
|
27
|
+
return typeof cfg.modelId === 'string' && cfg.modelId ? cfg.modelId : null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Persist the hub-minted model id, preserving any other fields already in
|
|
32
|
+
* `fluidcad.json`. Called after the first publish writes back the new id.
|
|
33
|
+
*/
|
|
34
|
+
export function writeModelId(workspace, modelId) {
|
|
35
|
+
const cfg = readModelConfig(workspace);
|
|
36
|
+
cfg.modelId = modelId;
|
|
37
|
+
writeFileSync(modelConfigPath(workspace), JSON.stringify(cfg, null, 2) + '\n');
|
|
38
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { readFileSync, existsSync, readdirSync } from 'fs';
|
|
2
|
+
import { dirname, join, resolve } from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
|
|
5
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
6
|
+
|
|
7
|
+
// Shared by `pack` and `publish`: both resolve the entry `.fluid.js` the same
|
|
8
|
+
// way and stamp the same fluidcad version onto the package.
|
|
9
|
+
|
|
10
|
+
/** The installed fluidcad version (from the package's own package.json). */
|
|
11
|
+
export function readPackageVersion() {
|
|
12
|
+
try {
|
|
13
|
+
const pkgPath = resolve(__dirname, '..', '..', 'package.json');
|
|
14
|
+
return JSON.parse(readFileSync(pkgPath, 'utf8')).version ?? '0.0.0';
|
|
15
|
+
} catch {
|
|
16
|
+
return '0.0.0';
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Read the MODEL workspace's own `package.json` for publish prefills: name and
|
|
22
|
+
* description (→ short description). Distinct from `readPackageVersion`, which
|
|
23
|
+
* reads the fluidcad engine's version. Missing/unreadable fields come back
|
|
24
|
+
* undefined. (The published version number is hub-assigned, not read here.)
|
|
25
|
+
*/
|
|
26
|
+
export function readWorkspacePackage(workspace) {
|
|
27
|
+
try {
|
|
28
|
+
const pkg = JSON.parse(readFileSync(join(workspace, 'package.json'), 'utf8'));
|
|
29
|
+
return {
|
|
30
|
+
name: typeof pkg.name === 'string' ? pkg.name : undefined,
|
|
31
|
+
description: typeof pkg.description === 'string' ? pkg.description : undefined,
|
|
32
|
+
};
|
|
33
|
+
} catch {
|
|
34
|
+
return {};
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** Resolve the entry `.fluid.js`: the override if given, else the sole one. */
|
|
39
|
+
export function findEntry(workspace, override) {
|
|
40
|
+
if (override) {
|
|
41
|
+
const abs = resolve(workspace, override);
|
|
42
|
+
if (!existsSync(abs)) {
|
|
43
|
+
throw new Error(`Entry file not found: ${abs}`);
|
|
44
|
+
}
|
|
45
|
+
return abs;
|
|
46
|
+
}
|
|
47
|
+
const candidates = readdirSync(workspace).filter((f) => f.endsWith('.fluid.js'));
|
|
48
|
+
if (candidates.length === 0) {
|
|
49
|
+
throw new Error('No .fluid.js files found in the workspace. Pass --entry to specify one.');
|
|
50
|
+
}
|
|
51
|
+
if (candidates.length > 1) {
|
|
52
|
+
throw new Error(
|
|
53
|
+
`Multiple .fluid.js files found: ${candidates.join(', ')}. Pass --entry to choose one.`,
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
return resolve(workspace, candidates[0]);
|
|
57
|
+
}
|
|
@@ -2,6 +2,7 @@ import { Shape, ShapeFilter } from "./shape.js";
|
|
|
2
2
|
import { Face } from "./face.js";
|
|
3
3
|
import { Edge } from "./edge.js";
|
|
4
4
|
import { Matrix4 } from "../math/matrix4.js";
|
|
5
|
+
import { LazyMatrix } from "../math/lazy-matrix.js";
|
|
5
6
|
import { ISceneObject } from "../core/interfaces.js";
|
|
6
7
|
import { FusionScope, OperationMode } from "../features/extrude-options.js";
|
|
7
8
|
import { ShapeType } from "./shape-type.js";
|
|
@@ -90,7 +91,7 @@ export declare abstract class SceneObject implements Comparable<SceneObject>, Se
|
|
|
90
91
|
getDependencies(): SceneObject[];
|
|
91
92
|
createCopy(remap: Map<SceneObject, SceneObject>): SceneObject;
|
|
92
93
|
clone(): SceneObject[];
|
|
93
|
-
setTransform(matrix: Matrix4): void;
|
|
94
|
+
setTransform(matrix: Matrix4 | LazyMatrix): void;
|
|
94
95
|
getTransform(): Matrix4 | null;
|
|
95
96
|
setCloneSource(source: SceneObject): void;
|
|
96
97
|
getCloneSource(): SceneObject | null;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { randomUUID } from "crypto";
|
|
2
|
+
import { LazyMatrix } from "../math/lazy-matrix.js";
|
|
2
3
|
export class SceneObject {
|
|
3
4
|
state;
|
|
4
5
|
children = [];
|
|
@@ -200,10 +201,10 @@ export class SceneObject {
|
|
|
200
201
|
return result;
|
|
201
202
|
}
|
|
202
203
|
setTransform(matrix) {
|
|
203
|
-
this._transform = matrix;
|
|
204
|
+
this._transform = matrix instanceof LazyMatrix ? matrix : LazyMatrix.of(matrix);
|
|
204
205
|
}
|
|
205
206
|
getTransform() {
|
|
206
|
-
return this._transform;
|
|
207
|
+
return this._transform ? this._transform.resolve() : null;
|
|
207
208
|
}
|
|
208
209
|
setCloneSource(source) {
|
|
209
210
|
this._cloneSource = source;
|
|
@@ -3,6 +3,7 @@ import { Solid } from "./solid.js";
|
|
|
3
3
|
import { Wire } from "./wire.js";
|
|
4
4
|
import { Face } from "./face.js";
|
|
5
5
|
import { Edge } from "./edge.js";
|
|
6
|
+
import { Vertex } from "./vertex.js";
|
|
6
7
|
export declare class ShapeFactory {
|
|
7
|
-
static fromShape(shape: TopoDS_Shape): Edge | Wire | Solid | Face;
|
|
8
|
+
static fromShape(shape: TopoDS_Shape): Vertex | Edge | Wire | Solid | Face;
|
|
8
9
|
}
|
|
@@ -3,6 +3,7 @@ import { Solid } from "./solid.js";
|
|
|
3
3
|
import { Wire } from "./wire.js";
|
|
4
4
|
import { Face } from "./face.js";
|
|
5
5
|
import { Edge } from "./edge.js";
|
|
6
|
+
import { Vertex } from "./vertex.js";
|
|
6
7
|
export class ShapeFactory {
|
|
7
8
|
static fromShape(shape) {
|
|
8
9
|
if (Explorer.isSolid(shape)) {
|
|
@@ -17,6 +18,9 @@ export class ShapeFactory {
|
|
|
17
18
|
if (Explorer.isEdge(shape)) {
|
|
18
19
|
return Edge.fromTopoDSEdge(Explorer.toEdge(shape));
|
|
19
20
|
}
|
|
21
|
+
if (Explorer.isVertex(shape)) {
|
|
22
|
+
return Vertex.fromTopoDSVertex(Explorer.toVertex(shape));
|
|
23
|
+
}
|
|
20
24
|
if (Explorer.isCompound(shape) || Explorer.isCompoundSolid(shape)) {
|
|
21
25
|
const solids = Explorer.findShapes(shape, Explorer.getOcShapeType("solid"));
|
|
22
26
|
if (solids.length === 1) {
|
|
@@ -3,14 +3,15 @@ import { Matrix4 } from "../math/matrix4.js";
|
|
|
3
3
|
import type { AxisLike } from "../math/axis.js";
|
|
4
4
|
import type { PlaneLike } from "../math/plane.js";
|
|
5
5
|
import type { PointLike } from "../math/point.js";
|
|
6
|
+
import { type NumberParam } from "../core/param.js";
|
|
6
7
|
export declare abstract class TransformablePrimitive extends SceneObject {
|
|
7
8
|
transform(matrix: Matrix4): this;
|
|
8
|
-
translate(x:
|
|
9
|
-
translate(x:
|
|
10
|
-
translate(x:
|
|
9
|
+
translate(x: NumberParam): this;
|
|
10
|
+
translate(x: NumberParam, y: NumberParam): this;
|
|
11
|
+
translate(x: NumberParam, y: NumberParam, z: NumberParam): this;
|
|
11
12
|
translate(p: PointLike): this;
|
|
12
|
-
rotate(angle:
|
|
13
|
-
rotate(axis: AxisLike, angle:
|
|
13
|
+
rotate(angle: NumberParam): this;
|
|
14
|
+
rotate(axis: AxisLike, angle: NumberParam): this;
|
|
14
15
|
mirror(plane: PlaneLike): this;
|
|
15
16
|
mirror(axis: AxisLike): this;
|
|
16
17
|
}
|
|
@@ -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]);
|