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/lib/dist/core/repeat.js
CHANGED
|
@@ -1,15 +1,37 @@
|
|
|
1
1
|
import { registerBuilder } from "../index.js";
|
|
2
|
-
import {
|
|
2
|
+
import { Axis } from "../math/axis.js";
|
|
3
|
+
import { SceneObject } from "../common/scene-object.js";
|
|
3
4
|
import { Matrix4 } from "../math/matrix4.js";
|
|
5
|
+
import { LazyMatrix } from "../math/lazy-matrix.js";
|
|
4
6
|
import { rad } from "../helpers/math-helpers.js";
|
|
5
7
|
import { RepeatLinear } from "../features/repeat-linear.js";
|
|
6
8
|
import { RepeatCircular } from "../features/repeat-circular.js";
|
|
7
9
|
import { cloneWithTransform } from "../helpers/clone-transform.js";
|
|
8
|
-
import {
|
|
9
|
-
import { PlaneObject } from "../features/plane.js";
|
|
10
|
+
import { isNumberParam, resolveParam } from "./param.js";
|
|
10
11
|
import { MirrorFeature } from "../features/mirror-feature.js";
|
|
11
12
|
import { RepeatMatrix } from "../features/repeat-matrix.js";
|
|
13
|
+
import { resolveAxis, resolvePlane } from "../helpers/resolve.js";
|
|
14
|
+
import { normalizeAxis } from "../helpers/normalize.js";
|
|
12
15
|
import { AxisObjectBase } from "../features/axis-renderable-base.js";
|
|
16
|
+
/**
|
|
17
|
+
* Resolve a repeat axis argument to a value usable by LazyMatrix. Scene-
|
|
18
|
+
* resident sources (AxisObjectBase or an edge SceneObject) go through
|
|
19
|
+
* resolveAxis so they end up in the scene and get built before consumers.
|
|
20
|
+
* Primitive inputs (world-axis string, raw Axis) stay as concrete Axis
|
|
21
|
+
* values — no extra scene object, no rendered world-axis line.
|
|
22
|
+
*/
|
|
23
|
+
function resolveRepeatAxis(arg, context) {
|
|
24
|
+
if (arg instanceof AxisObjectBase) {
|
|
25
|
+
return arg;
|
|
26
|
+
}
|
|
27
|
+
if (arg instanceof SceneObject) {
|
|
28
|
+
return resolveAxis(arg, context);
|
|
29
|
+
}
|
|
30
|
+
if (arg instanceof Axis) {
|
|
31
|
+
return arg;
|
|
32
|
+
}
|
|
33
|
+
return normalizeAxis(arg);
|
|
34
|
+
}
|
|
13
35
|
function build(context) {
|
|
14
36
|
return (function repeat() {
|
|
15
37
|
const args = Array.from(arguments);
|
|
@@ -23,8 +45,9 @@ function build(context) {
|
|
|
23
45
|
const objects = restObjects.length > 0
|
|
24
46
|
? restObjects
|
|
25
47
|
: [context.getSceneObjects().at(-1)];
|
|
26
|
-
const
|
|
27
|
-
const
|
|
48
|
+
const lazy = LazyMatrix.of(matrix);
|
|
49
|
+
const feature = new RepeatMatrix(lazy, objects);
|
|
50
|
+
const cloned = cloneWithTransform(objects, lazy, feature);
|
|
28
51
|
context.addSceneObject(feature);
|
|
29
52
|
context.addSceneObjects(cloned);
|
|
30
53
|
return feature;
|
|
@@ -35,25 +58,25 @@ function build(context) {
|
|
|
35
58
|
const type = args[0];
|
|
36
59
|
if (type === 'linear' || type === 'circular') {
|
|
37
60
|
const axisArg = args[1];
|
|
38
|
-
const
|
|
39
|
-
? axisArg.map(a =>
|
|
40
|
-
: [
|
|
61
|
+
const axisSources = Array.isArray(axisArg)
|
|
62
|
+
? axisArg.map(a => resolveRepeatAxis(a, context))
|
|
63
|
+
: [resolveRepeatAxis(axisArg, context)];
|
|
41
64
|
const options = args[2];
|
|
42
65
|
const restObjects = args.slice(3);
|
|
43
66
|
const objects = restObjects.length > 0
|
|
44
67
|
? restObjects
|
|
45
68
|
: [context.getSceneObjects().at(-1)];
|
|
46
69
|
if (type === 'linear') {
|
|
47
|
-
const counts = Array.isArray(options.count) ? options.count : [options.count];
|
|
70
|
+
const counts = Array.isArray(options.count) ? options.count : [resolveParam(options.count)];
|
|
48
71
|
const offsets = options.offset != null
|
|
49
|
-
? (Array.isArray(options.offset) ? options.offset : [options.offset])
|
|
72
|
+
? (Array.isArray(options.offset) ? options.offset : [resolveParam(options.offset)])
|
|
50
73
|
: null;
|
|
51
74
|
const lengths = 'length' in options && options.length != null
|
|
52
|
-
? (Array.isArray(options.length) ? options.length : [options.length])
|
|
75
|
+
? (Array.isArray(options.length) ? options.length : [resolveParam(options.length)])
|
|
53
76
|
: null;
|
|
54
|
-
const repeat = new RepeatLinear(
|
|
77
|
+
const repeat = new RepeatLinear(axisSources, options, objects);
|
|
55
78
|
const transformedObjects = [];
|
|
56
|
-
const axisOffsets =
|
|
79
|
+
const axisOffsets = axisSources.map((axis, i) => {
|
|
57
80
|
const count = counts[i] ?? counts[0];
|
|
58
81
|
const offset = offsets != null
|
|
59
82
|
? (offsets[i] ?? offsets[0])
|
|
@@ -88,19 +111,26 @@ function build(context) {
|
|
|
88
111
|
if (options.skip?.some(s => s.length === indices.length && s.every((v, i) => v === indices[i]))) {
|
|
89
112
|
continue;
|
|
90
113
|
}
|
|
91
|
-
//
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
114
|
+
// Capture per-axis offset + signed index for this instance; the
|
|
115
|
+
// axis direction is read lazily at build time so an AxisObjectBase
|
|
116
|
+
// can still be unbuilt at parse time.
|
|
117
|
+
const perAxis = axisOffsets.map((entry, a) => {
|
|
95
118
|
const idx = options.centered
|
|
96
|
-
? indices[a] - Math.floor(
|
|
119
|
+
? indices[a] - Math.floor(entry.count / 2)
|
|
97
120
|
: indices[a];
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
121
|
+
return { axis: entry.axis, offset: entry.offset, idx };
|
|
122
|
+
});
|
|
123
|
+
const lazy = LazyMatrix.from(() => {
|
|
124
|
+
let dx = 0, dy = 0, dz = 0;
|
|
125
|
+
for (const { axis, offset, idx } of perAxis) {
|
|
126
|
+
const dir = (axis instanceof AxisObjectBase ? axis.getAxis() : axis).direction;
|
|
127
|
+
dx += dir.x * offset * idx;
|
|
128
|
+
dy += dir.y * offset * idx;
|
|
129
|
+
dz += dir.z * offset * idx;
|
|
130
|
+
}
|
|
131
|
+
return Matrix4.fromTranslation(dx, dy, dz);
|
|
132
|
+
});
|
|
133
|
+
const cloned = cloneWithTransform(objects, lazy, repeat);
|
|
104
134
|
transformedObjects.push(...cloned);
|
|
105
135
|
}
|
|
106
136
|
context.addSceneObject(repeat);
|
|
@@ -108,16 +138,17 @@ function build(context) {
|
|
|
108
138
|
return repeat;
|
|
109
139
|
}
|
|
110
140
|
if (type === 'circular') {
|
|
111
|
-
const axis =
|
|
141
|
+
const axis = axisSources[0];
|
|
112
142
|
const circularOptions = options;
|
|
113
|
-
const
|
|
143
|
+
const count = resolveParam(circularOptions.count);
|
|
144
|
+
const { centered, skip } = circularOptions;
|
|
114
145
|
const repeat = new RepeatCircular(axis, circularOptions, objects);
|
|
115
146
|
let offset;
|
|
116
147
|
if ('offset' in circularOptions && circularOptions.offset !== undefined) {
|
|
117
|
-
offset = circularOptions.offset;
|
|
148
|
+
offset = resolveParam(circularOptions.offset);
|
|
118
149
|
}
|
|
119
150
|
else {
|
|
120
|
-
const angle = circularOptions.angle;
|
|
151
|
+
const angle = resolveParam(circularOptions.angle);
|
|
121
152
|
offset = angle % 360 === 0 ? angle / count : angle / (count - 1);
|
|
122
153
|
}
|
|
123
154
|
const startOffset = centered ? -(count * offset) / 2 : 0;
|
|
@@ -127,8 +158,8 @@ function build(context) {
|
|
|
127
158
|
continue;
|
|
128
159
|
}
|
|
129
160
|
const angle = startOffset + offset * i;
|
|
130
|
-
const
|
|
131
|
-
const cloned = cloneWithTransform(objects,
|
|
161
|
+
const lazy = LazyMatrix.rotation(axis, rad(angle));
|
|
162
|
+
const cloned = cloneWithTransform(objects, lazy, repeat);
|
|
132
163
|
transformedObjects.push(...cloned);
|
|
133
164
|
}
|
|
134
165
|
context.addSceneObject(repeat);
|
|
@@ -142,44 +173,31 @@ function build(context) {
|
|
|
142
173
|
const targetObjects = restObjects.length > 0
|
|
143
174
|
? restObjects
|
|
144
175
|
: [context.getSceneObjects().at(-1)];
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
planeObj.build();
|
|
150
|
-
normalizedPlane = planeObj.getPlane();
|
|
151
|
-
}
|
|
152
|
-
else {
|
|
153
|
-
normalizedPlane = normalizePlane(planeArg);
|
|
154
|
-
planeObj = new PlaneObject(normalizedPlane);
|
|
155
|
-
planeObj.build();
|
|
156
|
-
context.addSceneObject(planeObj);
|
|
157
|
-
}
|
|
158
|
-
const matrix = Matrix4.mirrorPlane(normalizedPlane.normal, normalizedPlane.origin);
|
|
159
|
-
const mirrorFeature = new MirrorFeature(planeObj, matrix);
|
|
160
|
-
const mirrorTree = cloneWithTransform(targetObjects, matrix, mirrorFeature);
|
|
176
|
+
const planeObj = resolvePlane(planeArg, context);
|
|
177
|
+
const lazy = LazyMatrix.mirror(planeObj);
|
|
178
|
+
const mirrorFeature = new MirrorFeature(planeObj, lazy);
|
|
179
|
+
const mirrorTree = cloneWithTransform(targetObjects, lazy, mirrorFeature);
|
|
161
180
|
context.addSceneObject(mirrorFeature);
|
|
162
181
|
context.addSceneObjects(mirrorTree);
|
|
163
182
|
return mirrorFeature;
|
|
164
183
|
}
|
|
165
184
|
if (type === 'rotate') {
|
|
166
185
|
const axisArg = args[1];
|
|
167
|
-
const axis = axisArg instanceof AxisObjectBase
|
|
168
|
-
? axisArg.getAxis()
|
|
169
|
-
: normalizeAxis(axisArg);
|
|
170
186
|
let angle = 90;
|
|
171
187
|
let restStart = 2;
|
|
172
|
-
if (
|
|
173
|
-
angle = args[2];
|
|
188
|
+
if (isNumberParam(args[2])) {
|
|
189
|
+
angle = resolveParam(args[2]);
|
|
174
190
|
restStart = 3;
|
|
175
191
|
}
|
|
176
192
|
const restObjects = args.slice(restStart);
|
|
177
193
|
const objects = restObjects.length > 0
|
|
178
194
|
? restObjects
|
|
179
195
|
: [context.getSceneObjects().at(-1)];
|
|
180
|
-
const
|
|
181
|
-
const
|
|
182
|
-
const
|
|
196
|
+
const axis = resolveRepeatAxis(axisArg, context);
|
|
197
|
+
const lazy = LazyMatrix.rotation(axis, rad(angle));
|
|
198
|
+
const sources = axis instanceof AxisObjectBase ? [axis] : [];
|
|
199
|
+
const feature = new RepeatMatrix(lazy, objects, sources);
|
|
200
|
+
const cloned = cloneWithTransform(objects, lazy, feature);
|
|
183
201
|
context.addSceneObject(feature);
|
|
184
202
|
context.addSceneObjects(cloned);
|
|
185
203
|
return feature;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AxisLike } from "../math/axis.js";
|
|
2
2
|
import { IRevolve, ISceneObject } from "./interfaces.js";
|
|
3
|
+
import { type NumberParam } from "./param.js";
|
|
3
4
|
interface RevolveFunction {
|
|
4
5
|
/**
|
|
5
6
|
* Revolves the last sketch 360 degrees around an axis.
|
|
@@ -13,7 +14,7 @@ interface RevolveFunction {
|
|
|
13
14
|
* @param angle - The sweep angle in degrees
|
|
14
15
|
* @param target - The sketch to revolve
|
|
15
16
|
*/
|
|
16
|
-
(axisLike: AxisLike, angle:
|
|
17
|
+
(axisLike: AxisLike, angle: NumberParam, target?: ISceneObject): IRevolve;
|
|
17
18
|
}
|
|
18
19
|
declare const _default: RevolveFunction;
|
|
19
20
|
export default _default;
|
package/lib/dist/core/revolve.js
CHANGED
|
@@ -2,6 +2,7 @@ import { registerBuilder } from "../index.js";
|
|
|
2
2
|
import { Revolve } from "../features/revolve.js";
|
|
3
3
|
import { resolveAxis } from "../helpers/resolve.js";
|
|
4
4
|
import { SceneObject } from "../common/scene-object.js";
|
|
5
|
+
import { isNumberParam, resolveParam } from "./param.js";
|
|
5
6
|
function isExtrudable(obj) {
|
|
6
7
|
return obj instanceof SceneObject && obj.isExtrudable();
|
|
7
8
|
}
|
|
@@ -16,8 +17,8 @@ function build(context) {
|
|
|
16
17
|
// (axis, angle)
|
|
17
18
|
if (params.length === 2) {
|
|
18
19
|
const axis = resolveAxis(params[0], context);
|
|
19
|
-
if (
|
|
20
|
-
return new Revolve(axis, params[1], extrudable);
|
|
20
|
+
if (isNumberParam(params[1])) {
|
|
21
|
+
return new Revolve(axis, resolveParam(params[1]), extrudable);
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
24
|
throw new Error("Invalid parameters for revolve function.");
|
package/lib/dist/core/rib.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { IRib, ISceneObject } from "./interfaces.js";
|
|
2
|
+
import { type NumberParam } from "./param.js";
|
|
2
3
|
interface RibFunction {
|
|
3
4
|
/**
|
|
4
5
|
* Creates a rib from the last sketch with the given thickness.
|
|
@@ -6,13 +7,13 @@ interface RibFunction {
|
|
|
6
7
|
* surrounding solids. Positive thickness = forward, negative = reverse.
|
|
7
8
|
* @param thickness - Wall thickness (sign controls direction)
|
|
8
9
|
*/
|
|
9
|
-
(thickness:
|
|
10
|
+
(thickness: NumberParam): IRib;
|
|
10
11
|
/**
|
|
11
12
|
* Creates a rib from an explicit sketch spine with the given thickness.
|
|
12
13
|
* @param thickness - Wall thickness (sign controls direction)
|
|
13
14
|
* @param spine - The sketch providing the rib spine wire and plane
|
|
14
15
|
*/
|
|
15
|
-
(thickness:
|
|
16
|
+
(thickness: NumberParam, spine: ISceneObject): IRib;
|
|
16
17
|
}
|
|
17
18
|
declare const _default: RibFunction;
|
|
18
19
|
export default _default;
|
package/lib/dist/core/rib.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { SceneObject } from "../common/scene-object.js";
|
|
2
2
|
import { registerBuilder } from "../index.js";
|
|
3
3
|
import { Rib } from "../features/rib.js";
|
|
4
|
+
import { isNumberParam, resolveParam } from "./param.js";
|
|
4
5
|
function isExtrudable(obj) {
|
|
5
6
|
return obj instanceof SceneObject && obj.isExtrudable();
|
|
6
7
|
}
|
|
@@ -11,8 +12,11 @@ function build(context) {
|
|
|
11
12
|
if (args.length === 0) {
|
|
12
13
|
throw new Error("rib() requires at least a thickness argument.");
|
|
13
14
|
}
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
if (!isNumberParam(args[0])) {
|
|
16
|
+
throw new Error("rib() thickness must be a non-zero number.");
|
|
17
|
+
}
|
|
18
|
+
const thickness = resolveParam(args[0]);
|
|
19
|
+
if (thickness === 0) {
|
|
16
20
|
throw new Error("rib() thickness must be a non-zero number.");
|
|
17
21
|
}
|
|
18
22
|
let spine;
|
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
import { AxisLike } from "../math/axis.js";
|
|
2
2
|
import { IRotate, ISceneObject } from "./interfaces.js";
|
|
3
|
+
import { type NumberParam, type BooleanParam } from "./param.js";
|
|
3
4
|
interface RotateFunction {
|
|
4
5
|
/**
|
|
5
6
|
* [2D] Rotates geometry by an angle inside a sketch.
|
|
6
7
|
* @param angle - The rotation angle in degrees
|
|
7
8
|
* @param targets - The geometries to rotate (defaults to last object)
|
|
8
9
|
*/
|
|
9
|
-
(angle:
|
|
10
|
+
(angle: NumberParam, ...targets: ISceneObject[]): IRotate;
|
|
10
11
|
/**
|
|
11
12
|
* [2D] Rotates geometry by an angle inside a sketch, optionally making a copy.
|
|
12
13
|
* @param angle - The rotation angle in degrees
|
|
13
14
|
* @param copy - Whether to copy instead of move
|
|
14
15
|
* @param targets - The geometries to rotate (defaults to last object)
|
|
15
16
|
*/
|
|
16
|
-
(angle:
|
|
17
|
+
(angle: NumberParam, copy: BooleanParam, ...targets: ISceneObject[]): IRotate;
|
|
17
18
|
/**
|
|
18
19
|
* [3D] Rotates objects around an axis by an angle.
|
|
19
20
|
* @param axis - The axis to rotate around
|
|
20
21
|
* @param angle - The rotation angle in degrees
|
|
21
22
|
* @param targets - The objects to rotate (defaults to last object)
|
|
22
23
|
*/
|
|
23
|
-
(axis: AxisLike, angle:
|
|
24
|
+
(axis: AxisLike, angle: NumberParam, ...targets: ISceneObject[]): IRotate;
|
|
24
25
|
/**
|
|
25
26
|
* [3D] Rotates objects around an axis by an angle, optionally making a copy.
|
|
26
27
|
* @param axis - The axis to rotate around
|
|
@@ -28,7 +29,7 @@ interface RotateFunction {
|
|
|
28
29
|
* @param copy - Whether to copy instead of move
|
|
29
30
|
* @param targets - The objects to rotate (defaults to last object)
|
|
30
31
|
*/
|
|
31
|
-
(axis: AxisLike, angle:
|
|
32
|
+
(axis: AxisLike, angle: NumberParam, copy: BooleanParam, ...targets: ISceneObject[]): IRotate;
|
|
32
33
|
}
|
|
33
34
|
declare const _default: RotateFunction;
|
|
34
35
|
export default _default;
|
package/lib/dist/core/rotate.js
CHANGED
|
@@ -5,6 +5,7 @@ import { SceneObject } from "../common/scene-object.js";
|
|
|
5
5
|
import { AxisObjectBase } from "../features/axis-renderable-base.js";
|
|
6
6
|
import { AxisObject } from "../features/axis.js";
|
|
7
7
|
import { Rotate2D } from "../features/rotate2d.js";
|
|
8
|
+
import { isBooleanParam, resolveParam } from "./param.js";
|
|
8
9
|
function build(context) {
|
|
9
10
|
return function rotate() {
|
|
10
11
|
const args = Array.from(arguments);
|
|
@@ -15,13 +16,13 @@ function build(context) {
|
|
|
15
16
|
targets.unshift(args.pop());
|
|
16
17
|
}
|
|
17
18
|
// Extract copy flag from the end (if boolean)
|
|
18
|
-
const copy =
|
|
19
|
+
const copy = isBooleanParam(args[args.length - 1]) ? resolveParam(args.pop()) : false;
|
|
19
20
|
// 2D: rotate(angle, copy?, ...targets)
|
|
20
21
|
if (args.length === 1) {
|
|
21
22
|
if (!activeSketch) {
|
|
22
23
|
throw new Error("rotate(angle) is only valid inside a sketch. For 3D rotation, specify an axis: rotate(axis, angle).");
|
|
23
24
|
}
|
|
24
|
-
const angle = args[0];
|
|
25
|
+
const angle = resolveParam(args[0]);
|
|
25
26
|
const rotate = new Rotate2D(angle, copy, ...targets);
|
|
26
27
|
context.addSceneObject(rotate);
|
|
27
28
|
return rotate;
|
|
@@ -40,7 +41,7 @@ function build(context) {
|
|
|
40
41
|
axis = new AxisObject(a);
|
|
41
42
|
context.addSceneObject(axis);
|
|
42
43
|
}
|
|
43
|
-
const angle = args[1];
|
|
44
|
+
const angle = resolveParam(args[1]);
|
|
44
45
|
const rotate = new Rotate(axis, angle, copy, ...targets);
|
|
45
46
|
context.addSceneObject(rotate);
|
|
46
47
|
return rotate;
|
package/lib/dist/core/shell.d.ts
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { ISceneObject, IShell } from "./interfaces.js";
|
|
2
|
+
import { type NumberParam } from "./param.js";
|
|
2
3
|
interface ShellFunction {
|
|
3
4
|
/**
|
|
4
5
|
* Hollows out a solid with the given wall thickness.
|
|
5
6
|
* @param thickness - The wall thickness (defaults to 2.5)
|
|
6
7
|
*/
|
|
7
|
-
(thickness?:
|
|
8
|
+
(thickness?: NumberParam): IShell;
|
|
8
9
|
/**
|
|
9
10
|
* Hollows out a solid, removing the selected faces.
|
|
10
11
|
* @param thickness - The wall thickness
|
|
11
12
|
* @param selections - The face selections to remove
|
|
12
13
|
*/
|
|
13
|
-
(thickness:
|
|
14
|
+
(thickness: NumberParam, ...selections: ISceneObject[]): IShell;
|
|
14
15
|
}
|
|
15
16
|
declare const _default: ShellFunction;
|
|
16
17
|
export default _default;
|
package/lib/dist/core/shell.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Shell } from "../features/shell.js";
|
|
2
2
|
import { SceneObject } from "../common/scene-object.js";
|
|
3
3
|
import { registerBuilder } from "../index.js";
|
|
4
|
+
import { isNumberParam, resolveParam } from "./param.js";
|
|
4
5
|
function build(context) {
|
|
5
6
|
return function shell() {
|
|
6
7
|
const args = Array.from(arguments);
|
|
@@ -14,8 +15,8 @@ function build(context) {
|
|
|
14
15
|
selections.push(implicit);
|
|
15
16
|
}
|
|
16
17
|
}
|
|
17
|
-
const thickness = (args.length >= 1 &&
|
|
18
|
-
? args[0]
|
|
18
|
+
const thickness = (args.length >= 1 && isNumberParam(args[0]))
|
|
19
|
+
? resolveParam(args[0])
|
|
19
20
|
: 2.5;
|
|
20
21
|
for (const sel of selections) {
|
|
21
22
|
context.addSceneObject(sel);
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { ITransformable } from "./interfaces.js";
|
|
2
|
+
import { type NumberParam } from "./param.js";
|
|
2
3
|
interface SphereFunction {
|
|
3
4
|
/**
|
|
4
5
|
* Creates a full sphere with the given radius.
|
|
5
6
|
* @param radius - The sphere radius
|
|
6
7
|
*/
|
|
7
|
-
(radius:
|
|
8
|
+
(radius: NumberParam): ITransformable;
|
|
8
9
|
/**
|
|
9
10
|
* Creates a partial sphere with the given radius and sweep angle.
|
|
10
11
|
* @param radius - The sphere radius
|
|
11
12
|
* @param angle - The sweep angle in degrees
|
|
12
13
|
*/
|
|
13
|
-
(radius:
|
|
14
|
+
(radius: NumberParam, angle: NumberParam): ITransformable;
|
|
14
15
|
}
|
|
15
16
|
declare const _default: SphereFunction;
|
|
16
17
|
export default _default;
|
package/lib/dist/core/sphere.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Sphere } from "../features/sphere.js";
|
|
2
2
|
import { rad } from "../helpers/math-helpers.js";
|
|
3
3
|
import { registerBuilder } from "../index.js";
|
|
4
|
+
import { resolveParam } from "./param.js";
|
|
4
5
|
function build(context) {
|
|
5
6
|
return function sphere(radius, angle = 360) {
|
|
6
|
-
const sphere = new Sphere(radius, rad(angle));
|
|
7
|
+
const sphere = new Sphere(resolveParam(radius), rad(resolveParam(angle)));
|
|
7
8
|
context.addSceneObject(sphere);
|
|
8
9
|
return sphere;
|
|
9
10
|
};
|
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
import { PointLike } from "../math/point.js";
|
|
2
2
|
import { ISceneObject, ITranslate } from "./interfaces.js";
|
|
3
|
+
import { type NumberParam, type BooleanParam } from "./param.js";
|
|
3
4
|
interface TranslateFunction {
|
|
4
5
|
/**
|
|
5
6
|
* Translates objects along the X axis.
|
|
6
7
|
* @param x - The X distance
|
|
7
8
|
* @param targets - The objects to translate (defaults to last object)
|
|
8
9
|
*/
|
|
9
|
-
(x:
|
|
10
|
+
(x: NumberParam, ...targets: ISceneObject[]): ITranslate;
|
|
10
11
|
/**
|
|
11
12
|
* Translates objects along the X axis, optionally making a copy.
|
|
12
13
|
* @param x - The X distance
|
|
13
14
|
* @param copy - Whether to copy instead of move
|
|
14
15
|
* @param targets - The objects to translate (defaults to last object)
|
|
15
16
|
*/
|
|
16
|
-
(x:
|
|
17
|
+
(x: NumberParam, copy: BooleanParam, ...targets: ISceneObject[]): ITranslate;
|
|
17
18
|
/**
|
|
18
19
|
* Translates objects along the X and Y axes.
|
|
19
20
|
* @param x - The X distance
|
|
20
21
|
* @param y - The Y distance
|
|
21
22
|
* @param targets - The objects to translate (defaults to last object)
|
|
22
23
|
*/
|
|
23
|
-
(x:
|
|
24
|
+
(x: NumberParam, y: NumberParam, ...targets: ISceneObject[]): ITranslate;
|
|
24
25
|
/**
|
|
25
26
|
* Translates objects along the X and Y axes, optionally making a copy.
|
|
26
27
|
* @param x - The X distance
|
|
@@ -28,7 +29,7 @@ interface TranslateFunction {
|
|
|
28
29
|
* @param copy - Whether to copy instead of move
|
|
29
30
|
* @param targets - The objects to translate (defaults to last object)
|
|
30
31
|
*/
|
|
31
|
-
(x:
|
|
32
|
+
(x: NumberParam, y: NumberParam, copy: BooleanParam, ...targets: ISceneObject[]): ITranslate;
|
|
32
33
|
/**
|
|
33
34
|
* Translates objects along all three axes.
|
|
34
35
|
* @param x - The X distance
|
|
@@ -36,7 +37,7 @@ interface TranslateFunction {
|
|
|
36
37
|
* @param z - The Z distance
|
|
37
38
|
* @param targets - The objects to translate (defaults to last object)
|
|
38
39
|
*/
|
|
39
|
-
(x:
|
|
40
|
+
(x: NumberParam, y: NumberParam, z: NumberParam, ...targets: ISceneObject[]): ITranslate;
|
|
40
41
|
/**
|
|
41
42
|
* Translates objects along all three axes, optionally making a copy.
|
|
42
43
|
* @param x - The X distance
|
|
@@ -45,7 +46,7 @@ interface TranslateFunction {
|
|
|
45
46
|
* @param copy - Whether to copy instead of move
|
|
46
47
|
* @param targets - The objects to translate (defaults to last object)
|
|
47
48
|
*/
|
|
48
|
-
(x:
|
|
49
|
+
(x: NumberParam, y: NumberParam, z: NumberParam, copy: BooleanParam, ...targets: ISceneObject[]): ITranslate;
|
|
49
50
|
/**
|
|
50
51
|
* Translates objects by a point-like offset.
|
|
51
52
|
* @param distance - The offset as a point
|
|
@@ -5,6 +5,7 @@ import { Point } from "../math/point.js";
|
|
|
5
5
|
import { SceneObject } from "../common/scene-object.js";
|
|
6
6
|
import { Vertex } from "../common/vertex.js";
|
|
7
7
|
import { LazyVertex } from "../features/lazy-vertex.js";
|
|
8
|
+
import { isNumberParam, isBooleanParam, resolveParam } from "./param.js";
|
|
8
9
|
function build(context) {
|
|
9
10
|
return function translate() {
|
|
10
11
|
const args = Array.from(arguments);
|
|
@@ -14,12 +15,12 @@ function build(context) {
|
|
|
14
15
|
targets.unshift(args.pop());
|
|
15
16
|
}
|
|
16
17
|
// Extract copy flag from the end (if boolean)
|
|
17
|
-
const copy =
|
|
18
|
+
const copy = isBooleanParam(args[args.length - 1]) ? resolveParam(args.pop()) : false;
|
|
18
19
|
// translate(x, y?, z?)
|
|
19
|
-
if (
|
|
20
|
-
const x = args[0];
|
|
21
|
-
const y = args[1]
|
|
22
|
-
const z = args[2]
|
|
20
|
+
if (isNumberParam(args[0])) {
|
|
21
|
+
const x = resolveParam(args[0]);
|
|
22
|
+
const y = isNumberParam(args[1]) ? resolveParam(args[1]) : 0;
|
|
23
|
+
const z = isNumberParam(args[2]) ? resolveParam(args[2]) : 0;
|
|
23
24
|
const vertex = Vertex.fromPoint(new Point(x, y, z));
|
|
24
25
|
const lazyVertex = LazyVertex.fromVertex(vertex);
|
|
25
26
|
const translate = new Translate(lazyVertex, copy, ...targets);
|
|
@@ -2,9 +2,9 @@ import { Point2DLike } from "../../math/point.js";
|
|
|
2
2
|
import { PlaneObjectBase } from "../plane-renderable-base.js";
|
|
3
3
|
import { GeometrySceneObject } from "./geometry.js";
|
|
4
4
|
import { LazyVertex } from "../lazy-vertex.js";
|
|
5
|
-
import { IArcPoints, IArcAngles } from "../../core/interfaces.js";
|
|
5
|
+
import { IArcPoints, IArcRadius, IArcCenter, IArcAngles } from "../../core/interfaces.js";
|
|
6
6
|
import { SceneObject } from "../../common/scene-object.js";
|
|
7
|
-
export declare class Arc extends GeometrySceneObject implements IArcPoints, IArcAngles {
|
|
7
|
+
export declare class Arc extends GeometrySceneObject implements IArcPoints, IArcRadius, IArcCenter, IArcAngles {
|
|
8
8
|
private _startPoint;
|
|
9
9
|
private _endPoint;
|
|
10
10
|
private _arcRadius;
|
|
@@ -13,18 +13,24 @@ export declare class Arc extends GeometrySceneObject implements IArcPoints, IArc
|
|
|
13
13
|
private _bulgeRadius;
|
|
14
14
|
private _centerPoint;
|
|
15
15
|
private _centered;
|
|
16
|
+
private _clockwise;
|
|
17
|
+
private _major;
|
|
16
18
|
private _targetPlane;
|
|
17
19
|
constructor(targetPlane?: PlaneObjectBase | null);
|
|
18
20
|
static toPoint(endPoint: LazyVertex, targetPlane?: PlaneObjectBase | null): Arc;
|
|
19
21
|
static twoPoints(startPoint: LazyVertex, endPoint: LazyVertex, targetPlane?: PlaneObjectBase | null): Arc;
|
|
20
22
|
static fromAngles(arcRadius: number, startAngle: number, endAngle: number, targetPlane?: PlaneObjectBase | null): Arc;
|
|
23
|
+
private static circumcenter;
|
|
21
24
|
radius(value: number): this;
|
|
22
25
|
center(value: Point2DLike): this;
|
|
23
26
|
centered(): this;
|
|
27
|
+
cw(): this;
|
|
28
|
+
major(): this;
|
|
24
29
|
build(): void;
|
|
25
30
|
private buildTwoPointsCenter;
|
|
26
31
|
private buildTwoPointsBulge;
|
|
27
32
|
private buildToPoint;
|
|
33
|
+
private makeMajorArc;
|
|
28
34
|
private buildWithCenter;
|
|
29
35
|
private buildFromAngles;
|
|
30
36
|
getType(): string;
|