fluidcad 0.0.36 → 0.0.37
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/LICENSE.txt +21 -504
- package/README.md +1 -1
- package/lib/dist/common/edge.d.ts +1 -1
- package/lib/dist/common/face.d.ts +1 -1
- package/lib/dist/common/scene-object.d.ts +6 -0
- package/lib/dist/common/scene-object.js +8 -0
- package/lib/dist/common/shape-factory.d.ts +1 -1
- package/lib/dist/common/shape-history-tracker.d.ts +1 -1
- package/lib/dist/common/shape.d.ts +1 -1
- package/lib/dist/common/solid.d.ts +1 -1
- package/lib/dist/common/transformable-primitive.d.ts +12 -1
- package/lib/dist/common/transformable-primitive.js +27 -0
- package/lib/dist/common/vertex.d.ts +1 -1
- package/lib/dist/common/wire.d.ts +1 -1
- package/lib/dist/core/2d/index.d.ts +1 -0
- package/lib/dist/core/2d/index.js +1 -0
- package/lib/dist/core/2d/text.d.ts +30 -0
- package/lib/dist/core/2d/text.js +37 -0
- package/lib/dist/core/helix.d.ts +20 -0
- package/lib/dist/core/helix.js +36 -0
- package/lib/dist/core/index.d.ts +3 -1
- package/lib/dist/core/index.js +2 -0
- package/lib/dist/core/interfaces.d.ts +180 -0
- package/lib/dist/core/wrap.d.ts +17 -0
- package/lib/dist/core/wrap.js +39 -0
- package/lib/dist/features/2d/text.d.ts +67 -0
- package/lib/dist/features/2d/text.js +320 -0
- package/lib/dist/features/cylinder.d.ts +3 -1
- package/lib/dist/features/cylinder.js +5 -2
- package/lib/dist/features/extrude-base.d.ts +1 -0
- package/lib/dist/features/extrude-to-face.d.ts +1 -0
- package/lib/dist/features/extrude-to-face.js +6 -0
- package/lib/dist/features/fillet.d.ts +1 -1
- package/lib/dist/features/helix.d.ts +41 -0
- package/lib/dist/features/helix.js +337 -0
- package/lib/dist/features/select.js +32 -8
- package/lib/dist/features/simple-extruder.d.ts +1 -1
- package/lib/dist/features/simple-extruder.js +7 -2
- package/lib/dist/features/sphere.d.ts +3 -1
- package/lib/dist/features/sphere.js +5 -2
- package/lib/dist/features/sweep.js +7 -2
- package/lib/dist/features/wrap.d.ts +39 -0
- package/lib/dist/features/wrap.js +116 -0
- package/lib/dist/filters/edge/belongs-to-face.d.ts +3 -1
- package/lib/dist/filters/edge/belongs-to-face.js +14 -10
- package/lib/dist/filters/filter.d.ts +1 -1
- package/lib/dist/filters/from-object.d.ts +1 -1
- package/lib/dist/filters/tangent-expander.d.ts +1 -1
- package/lib/dist/filters/tangent-expander.js +57 -40
- package/lib/dist/helpers/scene-helpers.d.ts +2 -0
- package/lib/dist/helpers/scene-helpers.js +1 -1
- package/lib/dist/index.d.ts +2 -0
- package/lib/dist/index.js +3 -1
- package/lib/dist/io/file-import.d.ts +7 -0
- package/lib/dist/io/file-import.js +28 -1
- package/lib/dist/io/font-registry.d.ts +45 -0
- package/lib/dist/io/font-registry.js +272 -0
- package/lib/dist/math/bspline-interpolation.d.ts +29 -0
- package/lib/dist/math/bspline-interpolation.js +194 -0
- package/lib/dist/oc/boolean-ops.d.ts +3 -1
- package/lib/dist/oc/boolean-ops.js +15 -1
- package/lib/dist/oc/color-transfer.d.ts +1 -1
- package/lib/dist/oc/constraints/constraint-helpers.d.ts +4 -4
- package/lib/dist/oc/constraints/curve/tangent-circle-solver.js +10 -9
- package/lib/dist/oc/constraints/curve/tangent-line-solver.js +5 -6
- package/lib/dist/oc/convert.d.ts +1 -1
- package/lib/dist/oc/draft-ops.d.ts +1 -1
- package/lib/dist/oc/edge-ops.d.ts +2 -2
- package/lib/dist/oc/edge-ops.js +13 -14
- package/lib/dist/oc/edge-props.d.ts +1 -1
- package/lib/dist/oc/edge-query.d.ts +1 -1
- package/lib/dist/oc/edge-query.js +3 -8
- package/lib/dist/oc/errors.d.ts +8 -0
- package/lib/dist/oc/errors.js +27 -0
- package/lib/dist/oc/explorer.d.ts +2 -2
- package/lib/dist/oc/extrude-ops.d.ts +28 -2
- package/lib/dist/oc/extrude-ops.js +56 -7
- package/lib/dist/oc/face-ops.d.ts +2 -1
- package/lib/dist/oc/face-ops.js +11 -0
- package/lib/dist/oc/face-props.d.ts +1 -1
- package/lib/dist/oc/face-query.d.ts +12 -1
- package/lib/dist/oc/face-query.js +39 -0
- package/lib/dist/oc/fillet-ops.d.ts +1 -1
- package/lib/dist/oc/fillet-ops.js +4 -4
- package/lib/dist/oc/geometry.d.ts +1 -1
- package/lib/dist/oc/geometry.js +12 -14
- package/lib/dist/oc/helix-ops.d.ts +37 -0
- package/lib/dist/oc/helix-ops.js +88 -0
- package/lib/dist/oc/hit-test.d.ts +1 -1
- package/lib/dist/oc/index.d.ts +4 -0
- package/lib/dist/oc/index.js +2 -0
- package/lib/dist/oc/init.d.ts +1 -1
- package/lib/dist/oc/init.js +1 -1
- package/lib/dist/oc/intersection.js +1 -1
- package/lib/dist/oc/io.d.ts +6 -6
- package/lib/dist/oc/io.js +31 -24
- package/lib/dist/oc/measure/classify.d.ts +34 -0
- package/lib/dist/oc/measure/classify.js +246 -0
- package/lib/dist/oc/measure/measure-ops.d.ts +9 -0
- package/lib/dist/oc/measure/measure-ops.js +210 -0
- package/lib/dist/oc/measure/measure-types.d.ts +39 -0
- package/lib/dist/oc/measure/measure-types.js +1 -0
- package/lib/dist/oc/measure/sampling.d.ts +9 -0
- package/lib/dist/oc/measure/sampling.js +77 -0
- package/lib/dist/oc/measure/vec.d.ts +13 -0
- package/lib/dist/oc/measure/vec.js +23 -0
- package/lib/dist/oc/mesh.d.ts +1 -1
- package/lib/dist/oc/mesh.js +40 -28
- package/lib/dist/oc/path-sampler.d.ts +29 -0
- package/lib/dist/oc/path-sampler.js +63 -0
- package/lib/dist/oc/props.d.ts +1 -1
- package/lib/dist/oc/props.js +4 -1
- package/lib/dist/oc/shape-hash.d.ts +26 -0
- package/lib/dist/oc/shape-hash.js +32 -0
- package/lib/dist/oc/shape-ops.d.ts +5 -3
- package/lib/dist/oc/shape-ops.js +6 -5
- package/lib/dist/oc/sweep-ops.d.ts +22 -1
- package/lib/dist/oc/sweep-ops.js +206 -18
- package/lib/dist/oc/text-outline.d.ts +62 -0
- package/lib/dist/oc/text-outline.js +212 -0
- package/lib/dist/oc/topology-index.d.ts +1 -1
- package/lib/dist/oc/vertex-ops.d.ts +1 -1
- package/lib/dist/oc/wire-ops.d.ts +1 -1
- package/lib/dist/oc/wire-ops.js +1 -1
- package/lib/dist/oc/wrap-development.d.ts +105 -0
- package/lib/dist/oc/wrap-development.js +179 -0
- package/lib/dist/oc/wrap-ops.d.ts +100 -0
- package/lib/dist/oc/wrap-ops.js +406 -0
- package/lib/dist/rendering/render-solid.js +10 -2
- package/lib/dist/scene-manager.d.ts +2 -0
- package/lib/dist/scene-manager.js +29 -0
- package/lib/dist/tests/features/cylinder-curve-filter.test.js +3 -3
- package/lib/dist/tests/features/extrude-to-face.test.js +38 -1
- package/lib/dist/tests/features/helix.test.d.ts +1 -0
- package/lib/dist/tests/features/helix.test.js +295 -0
- package/lib/dist/tests/features/repeat-primitive.test.d.ts +1 -0
- package/lib/dist/tests/features/repeat-primitive.test.js +60 -0
- package/lib/dist/tests/features/rib.test.js +6 -1
- package/lib/dist/tests/features/sweep.test.js +125 -1
- package/lib/dist/tests/features/text.test.d.ts +1 -0
- package/lib/dist/tests/features/text.test.js +347 -0
- package/lib/dist/tests/features/wrap-development.test.d.ts +1 -0
- package/lib/dist/tests/features/wrap-development.test.js +130 -0
- package/lib/dist/tests/features/wrap-extruded-target.test.d.ts +1 -0
- package/lib/dist/tests/features/wrap-extruded-target.test.js +106 -0
- package/lib/dist/tests/features/wrap-repeat.test.d.ts +1 -0
- package/lib/dist/tests/features/wrap-repeat.test.js +93 -0
- package/lib/dist/tests/features/wrap.test.d.ts +1 -0
- package/lib/dist/tests/features/wrap.test.js +331 -0
- package/lib/dist/tests/math/bspline-interpolation.test.d.ts +1 -0
- package/lib/dist/tests/math/bspline-interpolation.test.js +119 -0
- package/lib/dist/tests/measure.test.d.ts +1 -0
- package/lib/dist/tests/measure.test.js +288 -0
- package/lib/dist/tsconfig.tsbuildinfo +1 -1
- package/llm-docs/api/helix.md +64 -0
- package/llm-docs/api/index.json +11 -2
- package/llm-docs/api/text.md +52 -0
- package/llm-docs/api/types/helix.md +105 -0
- package/llm-docs/api/types/text.md +138 -0
- package/llm-docs/api/types/wrap.md +131 -0
- package/llm-docs/api/wrap.md +62 -0
- package/llm-docs/index.json +121 -1
- package/mcp/dist/server.js +20 -1
- package/mcp/dist/tools/inspection.d.ts +17 -0
- package/mcp/dist/tools/inspection.js +14 -0
- package/package.json +7 -3
- package/server/dist/fluidcad-server.d.ts +10 -0
- package/server/dist/fluidcad-server.js +10 -0
- package/server/dist/index.js +4 -2
- package/server/dist/preferences.d.ts +4 -0
- package/server/dist/preferences.js +2 -0
- package/server/dist/routes/measure.d.ts +3 -0
- package/server/dist/routes/measure.js +32 -0
- package/server/dist/routes/preferences.js +6 -0
- package/server/dist/routes/sketch-edits.js +2 -1
- package/ui/dist/assets/{index-CDJmUpFI.css → index-dAFdg2Un.css} +1 -1
- package/ui/dist/assets/{index-MRqwG9Vh.js → index-no7mtr5s.js} +149 -102
- package/ui/dist/index.html +2 -2
|
@@ -3,12 +3,39 @@ 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 { ShapeOps } from "../oc/shape-ops.js";
|
|
6
7
|
import { isNumberParam, resolveParam } from "../core/param.js";
|
|
7
8
|
export class TransformablePrimitive extends SceneObject {
|
|
8
9
|
transform(matrix) {
|
|
9
10
|
this.composeAppliedTransform(matrix);
|
|
10
11
|
return this;
|
|
11
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* Adds a primitive's built shape, baking in the clone transform when this
|
|
15
|
+
* primitive is a repeat/mirror copy. The renderer post-applies the user's
|
|
16
|
+
* own transform (translate/rotate/mirror) after build, so the clone
|
|
17
|
+
* transform is conjugated to land outside it:
|
|
18
|
+
* own · (own⁻¹ · clone · own) = clone · own.
|
|
19
|
+
*/
|
|
20
|
+
addPrimitiveShape(shape, context) {
|
|
21
|
+
const cloneTransform = context?.getTransform() ?? null;
|
|
22
|
+
if (cloneTransform) {
|
|
23
|
+
const own = this.getAppliedTransform();
|
|
24
|
+
const matrix = own
|
|
25
|
+
? own.inverse().multiply(cloneTransform).multiply(own)
|
|
26
|
+
: cloneTransform;
|
|
27
|
+
shape = ShapeOps.transform(shape, matrix);
|
|
28
|
+
}
|
|
29
|
+
this.addShape(shape);
|
|
30
|
+
}
|
|
31
|
+
/** Carries the user's own transform onto a repeat/mirror copy. */
|
|
32
|
+
syncPrimitiveWith(source) {
|
|
33
|
+
const applied = source.getAppliedTransform();
|
|
34
|
+
if (applied) {
|
|
35
|
+
this.transform(applied);
|
|
36
|
+
}
|
|
37
|
+
return this;
|
|
38
|
+
}
|
|
12
39
|
translate(a, b, c) {
|
|
13
40
|
let x, y, z;
|
|
14
41
|
if (isNumberParam(a)) {
|
|
@@ -21,5 +21,6 @@ export { default as offset } from './offset.js';
|
|
|
21
21
|
export { default as project } from './project.js';
|
|
22
22
|
export { default as intersect } from './intersect.js';
|
|
23
23
|
export { default as bezier } from './bezier.js';
|
|
24
|
+
export { default as text } from './text.js';
|
|
24
25
|
export { default as center } from './center.js';
|
|
25
26
|
export { default as back } from './back.js';
|
|
@@ -21,5 +21,6 @@ export { default as offset } from './offset.js';
|
|
|
21
21
|
export { default as project } from './project.js';
|
|
22
22
|
export { default as intersect } from './intersect.js';
|
|
23
23
|
export { default as bezier } from './bezier.js';
|
|
24
|
+
export { default as text } from './text.js';
|
|
24
25
|
export { default as center } from './center.js';
|
|
25
26
|
export { default as back } from './back.js';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { PlaneLike } from "../../math/plane.js";
|
|
2
|
+
import { IText, ISceneObject } from "../interfaces.js";
|
|
3
|
+
interface TextFunction {
|
|
4
|
+
/**
|
|
5
|
+
* Renders a text string as extrudable outline geometry inside the current
|
|
6
|
+
* sketch, at the sketch cursor.
|
|
7
|
+
* @param text - The string to render.
|
|
8
|
+
*/
|
|
9
|
+
(text: string): IText;
|
|
10
|
+
/**
|
|
11
|
+
* Renders a text string on a specific plane (standalone, outside a sketch).
|
|
12
|
+
* @param plane - The plane (e.g. "xy") or face to render the text on.
|
|
13
|
+
* @param text - The string to render.
|
|
14
|
+
*/
|
|
15
|
+
(plane: PlaneLike | ISceneObject, text: string): IText;
|
|
16
|
+
/**
|
|
17
|
+
* Renders a text string following a planar curve. Each glyph is placed
|
|
18
|
+
* upright along the path's arc length; the text plane is the path's plane.
|
|
19
|
+
* Works inside a sketch (following a curve of that sketch) or standalone.
|
|
20
|
+
* The path is left in place — mark it `.guide()` to keep it out of
|
|
21
|
+
* extruded profiles.
|
|
22
|
+
* @param text - The string to render.
|
|
23
|
+
* @param path - The curve to follow: a sketch curve (line/arc/circle), a
|
|
24
|
+
* whole sketch, a planar primitive, or a selected edge/edge loop
|
|
25
|
+
* (e.g. `select(edge().circle())`).
|
|
26
|
+
*/
|
|
27
|
+
(text: string, path: ISceneObject): IText;
|
|
28
|
+
}
|
|
29
|
+
declare const _default: TextFunction;
|
|
30
|
+
export default _default;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Text } from "../../features/2d/text.js";
|
|
2
|
+
import { registerBuilder } from "../../index.js";
|
|
3
|
+
import { isPlaneLike } from "../../math/plane.js";
|
|
4
|
+
import { SceneObject } from "../../common/scene-object.js";
|
|
5
|
+
import { resolvePlane } from "../../helpers/resolve.js";
|
|
6
|
+
function build(context) {
|
|
7
|
+
return function text() {
|
|
8
|
+
const first = arguments[0];
|
|
9
|
+
const second = arguments[1];
|
|
10
|
+
// A trailing scene object is a path to follow: `text("Hi", path)`.
|
|
11
|
+
// Valid both standalone and inside a sketch (following a sketch curve).
|
|
12
|
+
if (arguments.length >= 2 && second instanceof SceneObject) {
|
|
13
|
+
if (typeof first !== "string") {
|
|
14
|
+
throw new Error("text: when following a path, the first argument must be the text string.");
|
|
15
|
+
}
|
|
16
|
+
const obj = new Text(first, null, second);
|
|
17
|
+
context.addSceneObject(obj);
|
|
18
|
+
return obj;
|
|
19
|
+
}
|
|
20
|
+
// A leading plane/face is only valid standalone and only when a string
|
|
21
|
+
// follows it; `text("xy")` (one arg) renders the literal string "xy".
|
|
22
|
+
const standalone = arguments.length >= 2 && (isPlaneLike(first) || first instanceof SceneObject);
|
|
23
|
+
if (standalone) {
|
|
24
|
+
if (context.getActiveSketch() !== null) {
|
|
25
|
+
throw new Error("text(plane, ...) cannot be used inside a sketch. Use text(...) instead.");
|
|
26
|
+
}
|
|
27
|
+
const planeObj = resolvePlane(first, context);
|
|
28
|
+
const obj = new Text(String(arguments[1] ?? ""), planeObj);
|
|
29
|
+
context.addSceneObject(obj);
|
|
30
|
+
return obj;
|
|
31
|
+
}
|
|
32
|
+
const obj = new Text(String(first ?? ""));
|
|
33
|
+
context.addSceneObject(obj);
|
|
34
|
+
return obj;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export default registerBuilder(build);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AxisLike } from "../math/axis.js";
|
|
2
|
+
import { IHelix, ISceneObject } from "./interfaces.js";
|
|
3
|
+
interface HelixFunction {
|
|
4
|
+
/**
|
|
5
|
+
* Creates a helix wire along the given axis. Use chained methods (.pitch(),
|
|
6
|
+
* .turns(), .height(), .radius(), .endRadius()) to configure geometry.
|
|
7
|
+
* @param axis - The axis to build the helix around.
|
|
8
|
+
*/
|
|
9
|
+
(axis: AxisLike): IHelix;
|
|
10
|
+
/**
|
|
11
|
+
* Creates a helix wire derived from a scene object's geometry.
|
|
12
|
+
* - A cylindrical or conical face: axis + radii + height come from the face.
|
|
13
|
+
* - A line edge: axis = the line, height = line length.
|
|
14
|
+
* - A circular edge: axis = circle normal at center, radius = circle radius.
|
|
15
|
+
* @param source - The scene object whose face/edge defines the helix.
|
|
16
|
+
*/
|
|
17
|
+
(source: ISceneObject): IHelix;
|
|
18
|
+
}
|
|
19
|
+
declare const _default: HelixFunction;
|
|
20
|
+
export default _default;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { registerBuilder } from "../index.js";
|
|
2
|
+
import { Helix } from "../features/helix.js";
|
|
3
|
+
import { isAxisLike } from "../math/axis.js";
|
|
4
|
+
import { AxisObject } from "../features/axis.js";
|
|
5
|
+
import { AxisObjectBase } from "../features/axis-renderable-base.js";
|
|
6
|
+
import { SceneObject } from "../common/scene-object.js";
|
|
7
|
+
import { normalizeAxis } from "../helpers/normalize.js";
|
|
8
|
+
function build(context) {
|
|
9
|
+
return function helix() {
|
|
10
|
+
if (arguments.length === 0) {
|
|
11
|
+
throw new Error("helix() requires an axis or scene object argument.");
|
|
12
|
+
}
|
|
13
|
+
const arg = arguments[0];
|
|
14
|
+
let source;
|
|
15
|
+
if (arg instanceof AxisObjectBase) {
|
|
16
|
+
source = arg;
|
|
17
|
+
context.addSceneObject(source);
|
|
18
|
+
}
|
|
19
|
+
else if (isAxisLike(arg)) {
|
|
20
|
+
const axis = normalizeAxis(arg);
|
|
21
|
+
source = new AxisObject(axis);
|
|
22
|
+
context.addSceneObject(source);
|
|
23
|
+
}
|
|
24
|
+
else if (arg instanceof SceneObject) {
|
|
25
|
+
source = arg;
|
|
26
|
+
context.addSceneObject(source);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
throw new Error("helix(): first argument must be an AxisLike or SceneObject.");
|
|
30
|
+
}
|
|
31
|
+
const result = new Helix(source);
|
|
32
|
+
context.addSceneObject(result);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export default registerBuilder(build);
|
package/lib/dist/core/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { ISceneObject, ITransformable, IBooleanOperation, IPlane, IAxis, ISelect, IGeometry, IExtrudableGeometry, IRect, ISlot, IPolygon, ITwoObjectsTangentLine, ITangentArcTwoObjects, IExtrude, ICut, ICommon, ISweep, ILoft, IRevolve, IDraft, IRib } from "./interfaces.js";
|
|
1
|
+
export type { ISceneObject, ITransformable, IBooleanOperation, IPlane, IAxis, ISelect, IGeometry, IExtrudableGeometry, IText, IRect, ISlot, IPolygon, ITwoObjectsTangentLine, ITangentArcTwoObjects, IExtrude, ICut, ICommon, ISweep, ILoft, IRevolve, IDraft, IRib, IHelix, IWrap } from "./interfaces.js";
|
|
2
2
|
export { default as axis } from "./axis.js";
|
|
3
3
|
export { default as local } from "./local.js";
|
|
4
4
|
export { default as plane } from "./plane.js";
|
|
@@ -24,6 +24,8 @@ export { default as load } from "./load.js";
|
|
|
24
24
|
export { default as loft } from "./loft.js";
|
|
25
25
|
export { default as sweep } from "./sweep.js";
|
|
26
26
|
export { default as rib } from "./rib.js";
|
|
27
|
+
export { default as wrap } from "./wrap.js";
|
|
28
|
+
export { default as helix } from "./helix.js";
|
|
27
29
|
export { default as color } from "./color.js";
|
|
28
30
|
export { default as draft } from "./draft.js";
|
|
29
31
|
export { default as remove } from "./remove.js";
|
package/lib/dist/core/index.js
CHANGED
|
@@ -23,6 +23,8 @@ export { default as load } from "./load.js";
|
|
|
23
23
|
export { default as loft } from "./loft.js";
|
|
24
24
|
export { default as sweep } from "./sweep.js";
|
|
25
25
|
export { default as rib } from "./rib.js";
|
|
26
|
+
export { default as wrap } from "./wrap.js";
|
|
27
|
+
export { default as helix } from "./helix.js";
|
|
26
28
|
export { default as color } from "./color.js";
|
|
27
29
|
export { default as draft } from "./draft.js";
|
|
28
30
|
export { default as remove } from "./remove.js";
|
|
@@ -144,6 +144,82 @@ export interface IGeometry extends ISceneObject {
|
|
|
144
144
|
}
|
|
145
145
|
export interface IExtrudableGeometry extends IGeometry {
|
|
146
146
|
}
|
|
147
|
+
export interface IText extends IExtrudableGeometry {
|
|
148
|
+
/**
|
|
149
|
+
* Sets the text height (em size) in model units. Default 10.
|
|
150
|
+
* @param value - The em size.
|
|
151
|
+
*/
|
|
152
|
+
size(value: number): this;
|
|
153
|
+
/**
|
|
154
|
+
* Sets the font. A name without a font extension (e.g. `"Arial"`) is resolved
|
|
155
|
+
* to a system font; a value ending in `.ttf`/`.otf`/`.ttc`/`.woff` (e.g.
|
|
156
|
+
* `"fonts/Brand.ttf"`) is loaded as a workspace-relative file. When omitted, a
|
|
157
|
+
* default system font is used.
|
|
158
|
+
* @param name - A system family name or a workspace-relative font file path.
|
|
159
|
+
*/
|
|
160
|
+
font(name: string): this;
|
|
161
|
+
/**
|
|
162
|
+
* Sets the font weight: a number (100–900) or a name such as `"regular"`,
|
|
163
|
+
* `"medium"`, or `"bold"`. Resolves to the matching face (or the wght axis of a
|
|
164
|
+
* variable font).
|
|
165
|
+
* @param value - The weight as a number or name.
|
|
166
|
+
*/
|
|
167
|
+
weight(value: number | string): this;
|
|
168
|
+
/**
|
|
169
|
+
* Shortcut for `weight(700)`.
|
|
170
|
+
*/
|
|
171
|
+
bold(): this;
|
|
172
|
+
/**
|
|
173
|
+
* Renders the italic/oblique face of the font.
|
|
174
|
+
* @param value - Whether to use italic (defaults to true).
|
|
175
|
+
*/
|
|
176
|
+
italic(value?: boolean): this;
|
|
177
|
+
/**
|
|
178
|
+
* Horizontal alignment of the text. For straight text it is relative to the
|
|
179
|
+
* origin point; for text along a path it positions the run against the
|
|
180
|
+
* path: `"start"` begins at the path's start, `"center"` centers on the
|
|
181
|
+
* midpoint, `"end"` finishes at the path's end, `"space-between"` justifies
|
|
182
|
+
* the glyphs evenly across the whole path, and `"space-around"` spreads
|
|
183
|
+
* them with half a gap before the first glyph and after the last, like the
|
|
184
|
+
* CSS flexbox value (both path text only). `"left"` and `"right"` are
|
|
185
|
+
* synonyms of `"start"` and `"end"`.
|
|
186
|
+
* @param value - `"left"`/`"start"` (default), `"center"`,
|
|
187
|
+
* `"right"`/`"end"`, `"space-between"`, or `"space-around"`.
|
|
188
|
+
*/
|
|
189
|
+
align(value: "left" | "center" | "right" | "start" | "end" | "space-between" | "space-around"): this;
|
|
190
|
+
/**
|
|
191
|
+
* Line-height multiplier for multi-line text (newlines in the string).
|
|
192
|
+
* @param value - Multiplier on the font's natural line height (default 1).
|
|
193
|
+
*/
|
|
194
|
+
lineSpacing(value: number): this;
|
|
195
|
+
/**
|
|
196
|
+
* Extra spacing added between glyphs, in model units (default 0).
|
|
197
|
+
* @param value - The additional advance per glyph.
|
|
198
|
+
*/
|
|
199
|
+
letterSpacing(value: number): this;
|
|
200
|
+
/**
|
|
201
|
+
* Shifts the baseline perpendicular to the path, in model units: positive
|
|
202
|
+
* values move the text toward its "up" side, negative below the path.
|
|
203
|
+
* Only applies to text following a path (`text(string, path)`).
|
|
204
|
+
* @param value - The perpendicular baseline shift.
|
|
205
|
+
*/
|
|
206
|
+
offset(value: number): this;
|
|
207
|
+
/**
|
|
208
|
+
* Mirrors the text to the other side of the path, reversing the reading
|
|
209
|
+
* direction. On a closed path (circle, loop) text sits on the outside by
|
|
210
|
+
* default — `.flip()` moves it inside. On an open path it mirrors the text
|
|
211
|
+
* below the curve. Only applies to text following a path.
|
|
212
|
+
* @param value - Whether to flip (defaults to true).
|
|
213
|
+
*/
|
|
214
|
+
flip(value?: boolean): this;
|
|
215
|
+
/**
|
|
216
|
+
* Shifts where the text starts along the path, as an arc-length distance
|
|
217
|
+
* from the path's start (combines with `align()`). On a closed path the
|
|
218
|
+
* text wraps around. Only applies to text following a path.
|
|
219
|
+
* @param distance - The arc-length shift in model units.
|
|
220
|
+
*/
|
|
221
|
+
startAt(distance: number): this;
|
|
222
|
+
}
|
|
147
223
|
export interface IOffset extends IExtrudableGeometry {
|
|
148
224
|
/**
|
|
149
225
|
* Closes an open offset by joining it back to the source wire with
|
|
@@ -794,6 +870,59 @@ export interface IRib extends IBooleanOperation {
|
|
|
794
870
|
*/
|
|
795
871
|
extend(): this;
|
|
796
872
|
}
|
|
873
|
+
export interface IWrap extends IBooleanOperation {
|
|
874
|
+
/**
|
|
875
|
+
* Selects the faces lying on the target surface (the base of the wrap).
|
|
876
|
+
* @param args - Numeric indices or {@link FaceFilterBuilder} instances to filter the selection.
|
|
877
|
+
*/
|
|
878
|
+
startFaces(...args: (number | FaceFilterBuilder)[]): ISceneObject;
|
|
879
|
+
/**
|
|
880
|
+
* Selects the raised (or recessed) faces offset from the target surface by the wrap thickness.
|
|
881
|
+
* @param args - Numeric indices or {@link FaceFilterBuilder} instances to filter the selection.
|
|
882
|
+
*/
|
|
883
|
+
endFaces(...args: (number | FaceFilterBuilder)[]): ISceneObject;
|
|
884
|
+
/**
|
|
885
|
+
* Selects edges on the base faces of the wrap.
|
|
886
|
+
* @param args - Numeric indices or {@link EdgeFilterBuilder} instances to filter the selection.
|
|
887
|
+
*/
|
|
888
|
+
startEdges(...args: (number | EdgeFilterBuilder)[]): ISceneObject;
|
|
889
|
+
/**
|
|
890
|
+
* Selects edges on the offset faces of the wrap.
|
|
891
|
+
* @param args - Numeric indices or {@link EdgeFilterBuilder} instances to filter the selection.
|
|
892
|
+
*/
|
|
893
|
+
endEdges(...args: (number | EdgeFilterBuilder)[]): ISceneObject;
|
|
894
|
+
/**
|
|
895
|
+
* Selects the wall faces created from the outer boundary of each wrapped region.
|
|
896
|
+
* @param args - Numeric indices or {@link FaceFilterBuilder} instances to filter the selection.
|
|
897
|
+
*/
|
|
898
|
+
sideFaces(...args: (number | FaceFilterBuilder)[]): ISceneObject;
|
|
899
|
+
/**
|
|
900
|
+
* Selects edges on the wall faces, excluding edges shared with base/offset faces.
|
|
901
|
+
* @param args - Numeric indices or {@link EdgeFilterBuilder} instances to filter the selection.
|
|
902
|
+
*/
|
|
903
|
+
sideEdges(...args: (number | EdgeFilterBuilder)[]): ISceneObject;
|
|
904
|
+
/**
|
|
905
|
+
* Selects the wall faces created from holes inside a wrapped region.
|
|
906
|
+
* @param args - Numeric indices or {@link FaceFilterBuilder} instances to filter the selection.
|
|
907
|
+
*/
|
|
908
|
+
internalFaces(...args: (number | FaceFilterBuilder)[]): ISceneObject;
|
|
909
|
+
/**
|
|
910
|
+
* Selects edges bounding the hole walls of the wrap.
|
|
911
|
+
* @param args - Numeric indices or {@link EdgeFilterBuilder} instances to filter the selection.
|
|
912
|
+
*/
|
|
913
|
+
internalEdges(...args: (number | EdgeFilterBuilder)[]): ISceneObject;
|
|
914
|
+
/**
|
|
915
|
+
* Enables or disables drill mode, which partitions the sketch into face regions
|
|
916
|
+
* before wrapping.
|
|
917
|
+
* @param value - `true` to enable (default), `false` to disable.
|
|
918
|
+
*/
|
|
919
|
+
drill(value?: boolean): this;
|
|
920
|
+
/**
|
|
921
|
+
* Restricts wrapping to only the sketch regions containing the given points.
|
|
922
|
+
* @param points - 2D points in the sketch plane identifying regions to wrap.
|
|
923
|
+
*/
|
|
924
|
+
pick(...points: Point2DLike[]): this;
|
|
925
|
+
}
|
|
797
926
|
export type ShellJoinType = 'arc' | 'intersection' | 'tangent';
|
|
798
927
|
export interface IShell extends ISceneObject {
|
|
799
928
|
/**
|
|
@@ -814,3 +943,54 @@ export interface IShell extends ISceneObject {
|
|
|
814
943
|
*/
|
|
815
944
|
join(type: ShellJoinType): this;
|
|
816
945
|
}
|
|
946
|
+
/**
|
|
947
|
+
* A 3D helix wire — a single edge that traces a helix curve on a cylindrical or
|
|
948
|
+
* conical surface. Used as a path for `sweep()` to produce springs, threads, and
|
|
949
|
+
* coils.
|
|
950
|
+
*
|
|
951
|
+
* Created from one of:
|
|
952
|
+
* - An axis (`AxisLike`): user supplies geometry via chained config.
|
|
953
|
+
* - A cylindrical or conical face: axis + radii + height derived from the face.
|
|
954
|
+
* - A line edge: axis = the line, height = line length.
|
|
955
|
+
* - A circular edge: axis = circle normal, radius = circle radius.
|
|
956
|
+
*/
|
|
957
|
+
export interface IHelix extends ISceneObject {
|
|
958
|
+
/**
|
|
959
|
+
* Axial rise per turn (distance along the helix axis covered per full revolution).
|
|
960
|
+
* If unset, derived from `height / turns`.
|
|
961
|
+
*/
|
|
962
|
+
pitch(pitch: number): this;
|
|
963
|
+
/**
|
|
964
|
+
* Number of full turns. Fractional values are allowed. Default 1.
|
|
965
|
+
*/
|
|
966
|
+
turns(turns: number): this;
|
|
967
|
+
/**
|
|
968
|
+
* Shifts the start of the helix along its axis, in axial mm. Positive values
|
|
969
|
+
* trim the start (move it toward the end); negative values extend it. Default 0.
|
|
970
|
+
*/
|
|
971
|
+
startOffset(offset: number): this;
|
|
972
|
+
/**
|
|
973
|
+
* Extends (positive) or trims (negative) the helix at its end, in axial mm.
|
|
974
|
+
* Default 0.
|
|
975
|
+
*/
|
|
976
|
+
endOffset(offset: number): this;
|
|
977
|
+
/**
|
|
978
|
+
* Total axial height. Overrides face/edge-derived height when set. For line-edge
|
|
979
|
+
* input, defaults to the line length. For circular-edge / pure-axis input,
|
|
980
|
+
* defaults to 50 if neither this nor `pitch * turns` determine it.
|
|
981
|
+
*/
|
|
982
|
+
height(height: number): this;
|
|
983
|
+
/**
|
|
984
|
+
* Start radius. Defaults to 20 for axis/line-edge input. For a cylindrical
|
|
985
|
+
* face input, defaults to the face's radius and may be overridden (useful for
|
|
986
|
+
* sweep/fuse workflows where the helix tube must overlap the cylinder
|
|
987
|
+
* volumetrically — offset by ~1mm to avoid pure tangency). Ignored on
|
|
988
|
+
* conical face input (radius is derived from face geometry).
|
|
989
|
+
*/
|
|
990
|
+
radius(radius: number): this;
|
|
991
|
+
/**
|
|
992
|
+
* End radius — when different from `radius()`, produces a conical helix.
|
|
993
|
+
* Defaults to `radius()`. Ignored on face/circle inputs.
|
|
994
|
+
*/
|
|
995
|
+
endRadius(radius: number): this;
|
|
996
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { IWrap, ISceneObject } from "./interfaces.js";
|
|
2
|
+
import { type NumberParam } from "./param.js";
|
|
3
|
+
interface WrapFunction {
|
|
4
|
+
/**
|
|
5
|
+
* Wraps the given sketch onto a curved face, raising it from the surface by
|
|
6
|
+
* the given thickness (emboss). Chain `.remove()` to sink it into the
|
|
7
|
+
* surface instead (deboss), or `.new()` to keep the wrapped pad standalone.
|
|
8
|
+
* The sketch is developed onto the surface with its lengths preserved — a
|
|
9
|
+
* true wrap, not a projection. Cylindrical and conical faces are supported.
|
|
10
|
+
* @param thickness - Pad thickness measured along the surface normal (must be positive)
|
|
11
|
+
* @param sketch - The sketch to wrap onto the face
|
|
12
|
+
* @param face - The target face to wrap onto
|
|
13
|
+
*/
|
|
14
|
+
(thickness: NumberParam, sketch: ISceneObject, face: ISceneObject): IWrap;
|
|
15
|
+
}
|
|
16
|
+
declare const _default: WrapFunction;
|
|
17
|
+
export default _default;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { SceneObject } from "../common/scene-object.js";
|
|
2
|
+
import { registerBuilder } from "../index.js";
|
|
3
|
+
import { Wrap } from "../features/wrap.js";
|
|
4
|
+
import { isNumberParam, resolveParam } from "./param.js";
|
|
5
|
+
function isExtrudable(obj) {
|
|
6
|
+
return obj instanceof SceneObject && obj.isExtrudable();
|
|
7
|
+
}
|
|
8
|
+
function build(context) {
|
|
9
|
+
//@ts-ignore
|
|
10
|
+
return function wrap() {
|
|
11
|
+
const args = [...arguments];
|
|
12
|
+
if (args.length !== 3) {
|
|
13
|
+
throw new Error("wrap() expects (thickness, sketch, face).");
|
|
14
|
+
}
|
|
15
|
+
if (!isNumberParam(args[0])) {
|
|
16
|
+
throw new Error("wrap() thickness must be a positive number.");
|
|
17
|
+
}
|
|
18
|
+
const thickness = resolveParam(args[0]);
|
|
19
|
+
if (!(thickness > 0)) {
|
|
20
|
+
throw new Error("wrap() thickness must be a positive number.");
|
|
21
|
+
}
|
|
22
|
+
const source = args[1];
|
|
23
|
+
if (!(source instanceof SceneObject)) {
|
|
24
|
+
throw new Error("wrap() sketch must be a sketch or face-bearing scene object.");
|
|
25
|
+
}
|
|
26
|
+
const face = args[2];
|
|
27
|
+
if (!(face instanceof SceneObject) || isExtrudable(face)) {
|
|
28
|
+
throw new Error("wrap() requires a target face selection as its last argument.");
|
|
29
|
+
}
|
|
30
|
+
if (!isExtrudable(source)) {
|
|
31
|
+
context.addSceneObject(source);
|
|
32
|
+
}
|
|
33
|
+
context.addSceneObject(face);
|
|
34
|
+
const result = new Wrap(thickness, face, source);
|
|
35
|
+
context.addSceneObject(result);
|
|
36
|
+
return result;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export default registerBuilder(build);
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { SceneObject } from "../../common/scene-object.js";
|
|
2
|
+
import { PlaneObjectBase } from "../plane-renderable-base.js";
|
|
3
|
+
import { ExtrudableGeometryBase } from "./extrudable-base.js";
|
|
4
|
+
import { IText } from "../../core/interfaces.js";
|
|
5
|
+
import { type TextAlign } from "../../oc/text-outline.js";
|
|
6
|
+
import { Plane } from "../../math/plane.js";
|
|
7
|
+
/**
|
|
8
|
+
* 3D text as an extrudable outline profile. Glyph outlines are produced via
|
|
9
|
+
* fontkit and converted to sketch edges; extruding the result gives raised or
|
|
10
|
+
* cut lettering. Works standalone on a plane (`text("xy", "Hi")`), inside a
|
|
11
|
+
* `sketch()` (`text("Hi")`), or following a planar curve
|
|
12
|
+
* (`text("Hi", path)`).
|
|
13
|
+
*/
|
|
14
|
+
export declare class Text extends ExtrudableGeometryBase implements IText {
|
|
15
|
+
text: string;
|
|
16
|
+
private path;
|
|
17
|
+
private _size;
|
|
18
|
+
private _font?;
|
|
19
|
+
private _weight;
|
|
20
|
+
private _italic;
|
|
21
|
+
private _align;
|
|
22
|
+
private _lineSpacing;
|
|
23
|
+
private _letterSpacing;
|
|
24
|
+
private _pathOffset;
|
|
25
|
+
private _flip;
|
|
26
|
+
private _startAt;
|
|
27
|
+
private _pathPlane;
|
|
28
|
+
constructor(text: string, targetPlane?: PlaneObjectBase, path?: SceneObject);
|
|
29
|
+
build(): void;
|
|
30
|
+
private buildAlongPath;
|
|
31
|
+
/**
|
|
32
|
+
* The plane the text lies in: the path object's own plane when it has one
|
|
33
|
+
* (sketch, planar primitive), otherwise a plane fitted through the path.
|
|
34
|
+
* Also verifies the path actually is planar.
|
|
35
|
+
*/
|
|
36
|
+
private resolvePathPlane;
|
|
37
|
+
private pathOwnPlane;
|
|
38
|
+
getPlane(): Plane;
|
|
39
|
+
size(value: number): this;
|
|
40
|
+
font(name: string): this;
|
|
41
|
+
weight(value: number | string): this;
|
|
42
|
+
bold(): this;
|
|
43
|
+
italic(value?: boolean): this;
|
|
44
|
+
align(value: TextAlign): this;
|
|
45
|
+
lineSpacing(value: number): this;
|
|
46
|
+
letterSpacing(value: number): this;
|
|
47
|
+
offset(value: number): this;
|
|
48
|
+
flip(value?: boolean): this;
|
|
49
|
+
startAt(distance: number): this;
|
|
50
|
+
getType(): string;
|
|
51
|
+
getDependencies(): SceneObject[];
|
|
52
|
+
createCopy(remap: Map<SceneObject, SceneObject>): SceneObject;
|
|
53
|
+
compareTo(other: Text): boolean;
|
|
54
|
+
serialize(): {
|
|
55
|
+
text: string;
|
|
56
|
+
size: number;
|
|
57
|
+
font: string;
|
|
58
|
+
weight: number;
|
|
59
|
+
italic: boolean;
|
|
60
|
+
align: TextAlign;
|
|
61
|
+
lineSpacing: number;
|
|
62
|
+
letterSpacing: number;
|
|
63
|
+
offset: number;
|
|
64
|
+
flip: boolean;
|
|
65
|
+
startAt: number;
|
|
66
|
+
};
|
|
67
|
+
}
|