@metamesh/modeling 0.0.0-stage → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/CHANGELOG.md +111 -0
  2. package/LICENSE +200 -0
  3. package/README.md +376 -2
  4. package/THIRD_PARTY_NOTICES.md +153 -0
  5. package/dist/api/engine.d.ts +71 -0
  6. package/dist/api/geometry.d.ts +3136 -0
  7. package/dist/api/index.d.ts +2087 -0
  8. package/dist/api/text.d.ts +93 -0
  9. package/dist/engine/construction-operations.js +189 -0
  10. package/dist/engine/execution.js +227 -0
  11. package/dist/engine/export-3mf.js +100 -0
  12. package/dist/engine/extrusion-finishing.js +82 -0
  13. package/dist/engine/finalization.js +214 -0
  14. package/dist/engine/index.js +83 -0
  15. package/dist/engine/inspection-operations.js +52 -0
  16. package/dist/engine/kernel/LICENSE +201 -0
  17. package/dist/engine/kernel/manifold.js +2 -0
  18. package/dist/engine/kernel/manifold.wasm +0 -0
  19. package/dist/engine/loft-operations.js +156 -0
  20. package/dist/engine/mechanical-operations.js +51 -0
  21. package/dist/engine/modeling-context.js +38 -0
  22. package/dist/engine/native/adapter.js +20 -0
  23. package/dist/engine/native/context.js +209 -0
  24. package/dist/engine/native/copied-views.js +46 -0
  25. package/dist/engine/native/index.js +13 -0
  26. package/dist/engine/native/operations.js +115 -0
  27. package/dist/engine/native/ownership.js +98 -0
  28. package/dist/engine/native/regions.js +138 -0
  29. package/dist/engine/native/scoped-primitives.js +127 -0
  30. package/dist/engine/native/scoped-threads.js +34 -0
  31. package/dist/engine/native/threads.js +52 -0
  32. package/dist/engine/native/transforms.js +111 -0
  33. package/dist/engine/operation-environment.js +20 -0
  34. package/dist/engine/pattern-operations.js +36 -0
  35. package/dist/engine/pattern-placements.js +176 -0
  36. package/dist/engine/primitive-anchors.js +70 -0
  37. package/dist/engine/primitive-correspondence.js +74 -0
  38. package/dist/engine/primitive-operations.js +151 -0
  39. package/dist/engine/primitive-profile-types.js +1 -0
  40. package/dist/engine/primitive-profiles.js +250 -0
  41. package/dist/engine/profile-mesh.js +279 -0
  42. package/dist/engine/section-operations.js +93 -0
  43. package/dist/engine/shape-anchors.js +88 -0
  44. package/dist/engine/transform-operations.js +225 -0
  45. package/dist/engine/types.js +1 -0
  46. package/dist/geometry/anchors.js +226 -0
  47. package/dist/geometry/curves/evaluation.js +162 -0
  48. package/dist/geometry/curves/sampling.js +266 -0
  49. package/dist/geometry/curves/types.js +1 -0
  50. package/dist/geometry/cylinder.js +117 -0
  51. package/dist/geometry/edge-finishing.js +160 -0
  52. package/dist/geometry/errors.js +76 -0
  53. package/dist/geometry/extrusion.js +150 -0
  54. package/dist/geometry/heightfield.js +115 -0
  55. package/dist/geometry/index.js +42 -0
  56. package/dist/geometry/loft-correspondence.js +204 -0
  57. package/dist/geometry/loft-geometry.js +184 -0
  58. package/dist/geometry/loft-options.js +56 -0
  59. package/dist/geometry/loft-simple-mesh.js +92 -0
  60. package/dist/geometry/loft-triangulation.js +64 -0
  61. package/dist/geometry/loft.js +95 -0
  62. package/dist/geometry/math/vector3.js +71 -0
  63. package/dist/geometry/mechanical/gear-motion.js +94 -0
  64. package/dist/geometry/mechanical/gears.js +484 -0
  65. package/dist/geometry/mechanical/index.js +13 -0
  66. package/dist/geometry/mechanical/standards.js +67 -0
  67. package/dist/geometry/mechanical/thread-helices.js +44 -0
  68. package/dist/geometry/mechanical/thread-mesh-plan.js +358 -0
  69. package/dist/geometry/mechanical/thread-mesh.js +142 -0
  70. package/dist/geometry/mechanical/thread-profiles.js +373 -0
  71. package/dist/geometry/mechanical/thread-solids.js +230 -0
  72. package/dist/geometry/mechanical/thread-surface.js +433 -0
  73. package/dist/geometry/mechanical/threads.js +138 -0
  74. package/dist/geometry/mesh-edge-table.js +126 -0
  75. package/dist/geometry/mesh-planar.js +408 -0
  76. package/dist/geometry/mesh-quality.js +396 -0
  77. package/dist/geometry/mesh-signature.js +137 -0
  78. package/dist/geometry/mesh.js +283 -0
  79. package/dist/geometry/model-limits.js +50 -0
  80. package/dist/geometry/numeric.js +11 -0
  81. package/dist/geometry/paths/frames.js +118 -0
  82. package/dist/geometry/paths/helix.js +49 -0
  83. package/dist/geometry/paths/path.js +32 -0
  84. package/dist/geometry/paths/planar.js +135 -0
  85. package/dist/geometry/paths/resampling.js +125 -0
  86. package/dist/geometry/polygon-clipping.js +52 -0
  87. package/dist/geometry/primitive-options.js +1 -0
  88. package/dist/geometry/primitive-resolution.js +17 -0
  89. package/dist/geometry/primitive-resolvers.js +235 -0
  90. package/dist/geometry/profiles/matched.js +192 -0
  91. package/dist/geometry/profiles/open-profile.js +137 -0
  92. package/dist/geometry/profiles/profiles.js +91 -0
  93. package/dist/geometry/profiles/rectangle.js +249 -0
  94. package/dist/geometry/profiles/shapes.js +41 -0
  95. package/dist/geometry/profiles/span-sampling.js +28 -0
  96. package/dist/geometry/profiles/types.js +1 -0
  97. package/dist/geometry/profiles/validation.js +20 -0
  98. package/dist/geometry/regions.js +371 -0
  99. package/dist/geometry/resolution.js +236 -0
  100. package/dist/geometry/revolve/revolve-mesh.js +129 -0
  101. package/dist/geometry/sampling-limits.js +29 -0
  102. package/dist/geometry/stroke-path.js +181 -0
  103. package/dist/geometry/svg/errors.js +23 -0
  104. package/dist/geometry/svg/fill.js +172 -0
  105. package/dist/geometry/svg/index.js +1 -0
  106. package/dist/geometry/svg/matrix.js +130 -0
  107. package/dist/geometry/svg/parser.js +536 -0
  108. package/dist/geometry/svg/path.js +349 -0
  109. package/dist/geometry/svg/types.js +1 -0
  110. package/dist/geometry/svg-import.js +662 -0
  111. package/dist/geometry/sweeps/options.js +28 -0
  112. package/dist/geometry/sweeps/orientation.js +106 -0
  113. package/dist/geometry/sweeps/stations.js +161 -0
  114. package/dist/geometry/sweeps/sweep-closed.js +96 -0
  115. package/dist/geometry/sweeps/sweep-mesh.js +30 -0
  116. package/dist/geometry/sweeps/sweep-open.js +76 -0
  117. package/dist/geometry/sweeps/validation.js +116 -0
  118. package/dist/geometry/text-contours.js +32 -0
  119. package/dist/geometry/text-layout.js +1 -0
  120. package/dist/geometry/tolerance.js +53 -0
  121. package/dist/geometry/transform-geometry.js +41 -0
  122. package/dist/geometry/transform3.js +340 -0
  123. package/dist/geometry/types.js +1 -0
  124. package/dist/index.js +1 -0
  125. package/dist/model/execution-binding.js +30 -0
  126. package/dist/model/operations.js +154 -0
  127. package/dist/model/options.js +1 -0
  128. package/dist/model/types.js +1 -0
  129. package/dist/text/index.js +58 -0
  130. package/dist/text/vector-text-layout.js +279 -0
  131. package/package.json +100 -3
package/README.md CHANGED
@@ -1,3 +1,377 @@
1
- # Temporary Holding Version
1
+ # `@metamesh/modeling`
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Standalone geometry foundations and a modeling engine for Node applications, browser Workers, and MetaMesh Generators.
4
+
5
+ > **Preview:** `0.x` minor releases may break compatibility. Patches remain compatible within the same minor line. Stable support requires an explicit `1.0.0` review.
6
+
7
+ Applications initialize one engine and build models with imported functions. Generator hosts supply
8
+ the same execution scope and own WASM initialization and native cleanup. Modeling requires no SDK
9
+ or Testkit.
10
+
11
+ ## API discovery and ownership
12
+
13
+ | Entry point | Responsibility |
14
+ | ----------------------------- | ------------------------------------------------------------------------------------------- |
15
+ | `@metamesh/modeling` | Imported modeling functions, opaque handles, output descriptors, and finalized results |
16
+ | `@metamesh/modeling/geometry` | Pure math, paths, profiles, regions, transforms, meshes, mechanical kernels, and SVG import |
17
+ | `@metamesh/modeling/engine` | Host initialization, scoped modeling, finalization, resource limits, and snapshot export |
18
+ | `@metamesh/modeling/text` | Optional font-byte preparation and synchronous vector layout |
19
+
20
+ These four entry points are the complete workspace and published API. Pure helpers cannot import
21
+ the engine, native kernel, browser APIs, Studio, or Generators. Fontkit and WOFF2 decoding are optional
22
+ peers used only by `/text`. Hosts own acquisition, worker lifecycle, and loading. API reports define
23
+ supported symbols; consumer fixtures verify published use.
24
+
25
+ ## Modeling and lifecycle
26
+
27
+ Install the package and create an engine in the application:
28
+
29
+ ```bash
30
+ pnpm add @metamesh/modeling
31
+ ```
32
+
33
+ ```ts
34
+ import { box, cylinder, subtract } from "@metamesh/modeling";
35
+ import { createModelEngine } from "@metamesh/modeling/engine";
36
+
37
+ const engine = await createModelEngine();
38
+ const snapshot = engine.build(
39
+ () => {
40
+ const body = box({ size: [30, 20, 6] });
41
+ const bore = cylinder({ height: 8, radius: 3, sizing: "face" });
42
+ return [{ id: "plate", solid: subtract(body, [bore]), color: "#67e8f9" }];
43
+ },
44
+ { resolution: { maxChordError: 0.025 } }
45
+ );
46
+ const bytes = await engine.export3mf(snapshot.parts, { name: "Plate" });
47
+ ```
48
+
49
+ The package includes the pinned Manifold JS/WASM kernel and its license, without Manifold's CLI or glTF dependency tree. Node and unbundled browser modules resolve the installed WASM automatically. Browser bundlers must retain or emit the relative asset and can pass their emitted URL explicitly:
50
+
51
+ ```ts
52
+ import { box } from "@metamesh/modeling";
53
+ import { createModelEngine, modelingWasmUrl } from "@metamesh/modeling/engine";
54
+
55
+ const engine = await createModelEngine({ locateFile: () => modelingWasmUrl });
56
+ const snapshot = engine.build(() => box({ size: [10, 20, 30] }));
57
+ ```
58
+
59
+ Imported functions and `ModelingContext` methods execute the same operations. Imports do not
60
+ initialize the kernel. The host binds the active context through a versioned symbol shared across
61
+ bundles, then clears it in `finally`. Calls outside `build` throw.
62
+
63
+ Builds are synchronous and cannot nest, including across engines in one JavaScript realm.
64
+ Hosts finish asynchronous loading and service preparation before `build`; separate Workers have
65
+ independent execution scopes.
66
+ An engine rejects builds or exports while its asynchronous exporter is busy.
67
+
68
+ `Solid` and `Section` are opaque immutable handles belonging to one synchronous build. Sections are
69
+ native filled XY shapes, including holes and disconnected components. `union`, `subtract`, and
70
+ `intersect` accept either Solid or Section operands and reject mixed dimensions. Offsets and Booleans
71
+ retain native sections; `fromRegion` and `toRegion` are explicit conversion boundaries. Repeated
72
+ sweeps and loft stations extract each Section once per execution; `toRegion` returns fresh immutable
73
+ snapshots.
74
+
75
+ Handles cannot cross builds or survive disposal. All native values dispose in reverse construction
76
+ order from `finally`, including on failure. Installed bundles call host-owned methods, avoiding
77
+ package-local native class or module identity.
78
+
79
+ Builds return a bare solid (part ID `model`) or named `{ id, solid, color? }` / `{ id, mesh, color? }`
80
+ descriptors. IDs are unique lowercase kebab-case strings of at most 64 characters; colors are
81
+ six-digit hex RGB. Direct meshes are copied and checked for finite, nondegenerate, oriented closed
82
+ topology and kernel reconstructability without copying them back from the kernel. Native extraction
83
+ allows one bounded retry for collapsed Float32 stitches.
84
+
85
+ Descriptors for the same Solid share one extraction, copied manufacturing buffers, and immutable
86
+ facts. `toTriangleMesh` inspection returns independent copies; mutable mesh inputs are captured and
87
+ validated afresh for every build. Finalized parts retain shared bounds, counts, signed volume, area,
88
+ and topology facts. Render normals remain outside manufacturing data.
89
+
90
+ Default limits are 64 parts, 1,000,000 vertices, 2,000,000 triangles, and 96 MiB of unique backing storage. Trusted applications may configure higher or lower ceilings through `createModelEngine({ limits })`. Per-build limits may only lower those configured ceilings, and snapshot export uses them too. Generator hosts own ceilings; generators receive no engine. Predictable allocations preflight safe-integer counts. Algorithm-specific numeric limits remain documented by their operations. Complexity fails explicitly instead of reducing fidelity.
91
+
92
+ The same `limits` policy includes `maxPathPoints` (100,000), `maxProfilePoints` (100,000),
93
+ `maxSweepProfilePoints` (4,096), and `maxCircularSegments` (512). Pure helpers accept explicit
94
+ limits and use these defaults when omitted. Mesh constructors also accept the selected output
95
+ budgets. Engines supply their configured policy to bound operations; operation limits may lower
96
+ it. Exact samples override physical sampling without raising an allocation ceiling. Excessive
97
+ counts fail before predictable array or mesh-buffer allocation, with required and allowed counts.
98
+
99
+ SVG, text, strokes and gear outlines also honor these selected sampling ceilings. Separate SVG
100
+ source, XML and recursion bounds, region intersection work limits, and native implicit-field
101
+ work limits remain fixed operation safeguards.
102
+
103
+ `engine.export3mf` consumes selected finalized buffers without preparation or generation. Its lazy ZIP/XML serializer preserves exact selected vertices, triangle indices, semantic part names, and optional RGB display colors without a native or glTF conversion. Hosts own revisions, appearance overrides, filenames, delivery, and persistence.
104
+
105
+ ## Resolution and conventions
106
+
107
+ Primitive and pure loop factories share named options and these conventions:
108
+
109
+ | Concept | Convention |
110
+ | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
111
+ | Units | Lengths are millimetres; modeling rotations use degrees. Pure transform constructors require explicit `{ degrees }` or `{ radians }`. |
112
+ | Dimensions | `rectangle` / `rectangleLoop` take `size: number \| [width, depth]`. `circle` / `circleLoop` and `sphere` take exactly one `radius` or `diameter`. `ellipse` / `ellipseLoop` take exactly one XY `radius` tuple or full `size` tuple. |
113
+ | Cylinders | +Z height and exactly one `radius` or `diameter`; either a uniform scalar or `[bottom, top]` tuple. One tuple end may be zero for a cone. |
114
+ | Origins | Shapes are centered by default. `center: false` places the box/rectangle minimum corner or cylinder/tube bottom at zero. Circles, ellipses, spheres and regular polygons remain centered. |
115
+ | Radial sizing | Circle, cylinder and regular polygon `sizing` defaults to `"vertex"`; `"face"` compensates polygon faceting to reach the nominal dimension at faces. Physical clearance is separate from Boolean overtravel. |
116
+ | Treatments | Corners and supported rims share `round` (radius), `chamfer` (distance), `smooth` (tangent setbacks), and `profile` (explicit millimetre points). Offsets use lowercase `join: "round" \| "miter" \| "square"`. |
117
+ | Sampling | Exact local `segments` override physical `resolution`; selected allocation ceilings still apply. Pure circle/ellipse loops use physical defaults when `segments` is omitted. |
118
+
119
+ Applicable edges, corners and supported rims share `EdgeTreatment`. `{ kind: "round", radius }`
120
+ uses an actual circular radius; `{ kind: "chamfer", distance }` uses equal setbacks, or
121
+ `distance: [first, second]` for unequal setbacks. `{ kind: "smooth", distance }` uses the same
122
+ setbacks with a cubic transition whose curvature reaches zero at both straight joins.
123
+ Its size is a setback, rather than a circular radius. Round `segments` describes a complete
124
+ circle and must divide by four for rectangle corners; smooth `segments` is an exact cubic
125
+ interval count. Physical cubic sampling uses chord error and segment length.
126
+
127
+ Rectangles select a uniform treatment or a tuple ordered top-right, top-left, bottom-left,
128
+ bottom-right; the tuple accepts `{ kind: "square" }`. Boxes select a uniform treatment or a map
129
+ of named edges and groups, such as `treatment: { top: { kind: "round", radius: 1 }, bottom:
130
+ { kind: "chamfer", distance: 1 } }`. Groups select the four top/bottom rim edges or `vertical`
131
+ edges; individual names include `"top-front"` and `"front-left"`. Overlapping selections fail.
132
+ Named faces use +Z top, +Y front
133
+ and +X right. Selected edge masks meet by intersection; they do not promise spherical three-edge
134
+ blends. Omitted selection retains the spherical all-edge circular box treatment.
135
+
136
+ `ends: { bottom, top }` independently finishes cylinder/frustum rims and straight convex
137
+ extrusions. Cylinder rounds account for the actual sloped side's angle. Extrusion finishing
138
+ requires one strictly convex contour without holes, twist, top scaling or divisions. Inward
139
+ parallel offsets preserve its original edge correspondence; disappearing/reversed edges fail.
140
+ Use explicit loft profiles for concave or holed transitions.
141
+
142
+ Custom `{ kind: "profile", profile }` treatments use exact sampled points from `[positive, 0]`
143
+ to `[0, positive]`, with decreasing first and increasing second coordinates. These are setbacks
144
+ along the two inward surface directions, in millimetres. Cylinder/extrusion ends use cap inset
145
+ first and side setback second. Rectangle corners follow the incoming and outgoing CCW edges.
146
+ For a named box edge, the first coordinate lies on the first named face and the second on the
147
+ second named face. Samples are captured per call, checked for fit and bounded before allocation;
148
+ no analytic curve or outward moulding is inferred. Ordinary curve helpers can prepare the points.
149
+
150
+ Primitive `placement: { source, target, ... }` maps a named or explicit local anchor onto a world
151
+ anchor, with optional alignment, gap and degree spin. Placement follows local construction,
152
+ including `center`; Section placement must preserve the XY plane.
153
+
154
+ Rectangle round radii may vary from zero (square corners) through half the smallest dimension
155
+ (a capsule or circle). Saturated tangent endpoints are emitted once. Uniform rectangle chamfers
156
+ and all-edge box rounds/chamfers require positive sizes smaller than half every dimension.
157
+ Selected box treatments must leave positive flat space between opposing setbacks.
158
+
159
+ Authored box, cylinder/frustum, tube, sphere, torus, rectangle, circle and ellipse handles know
160
+ `center`, `left`, `right`, `back`, `front`, `bottom` and `top` anchors. `left/right` follow −X/+X,
161
+ `back/front` follow −Y/+Y and `bottom/top` follow −Z/+Z. Regular polygons and stars provide `center`.
162
+ These are nominal construction datums: sampling and finishing do not move them; tube cap and torus
163
+ axial centers may lie over an opening. A cone omits the cap anchor at its zero-radius apex.
164
+ `anchor(shape, name)` reads its immutable frame, and `attach(pin, "bottom", anchor(base, "top"))`
165
+ mates opposed directions by default. Affine transforms and patterns carry positions, outward
166
+ normals and roll tangents with the shape, including nonuniform scaling and reflection.
167
+
168
+ `withAnchors(shape, { mount: createAnchor3(position, direction, up) })` returns a new same-kind handle
169
+ with copied definitions, retaining existing names unless replaced. Each shape supports at most 128
170
+ lowercase kebab-case names of at most 64 characters. Looking up an absent name reports the available
171
+ names. Shape lookup requires the exact active build; the returned `Anchor3` is copied plain data.
172
+ Boolean and other geometry construction results require deliberate definitions rather than
173
+ inheriting anchors that may no longer describe their surfaces. Custom rigid frames remain useful;
174
+ pure `boxAnchor3` and `cylinderAnchor3` calculate dimension-based frames without a native shape.
175
+
176
+ `GeometryResolution` defaults to 0.05 mm maximum chord error and 16–512 segments per complete circle.
177
+ Precedence is exact local segments, operation resolution, context-derived resolution, then engine
178
+ defaults. Exact counts express deliberate faceting or fixed correspondence; adaptive curves retain
179
+ physical deviation and edge-length constraints.
180
+
181
+ `model.withResolution(policy)` and imported `modelingFunctions(policy)` return a local method set
182
+ for the same build. Destructure those methods to apply the local policy; other imports retain the
183
+ original build policy. There is no global resolution or font state.
184
+
185
+ Revolution `segments` describes a complete circle; partial revolutions scale that count to the
186
+ angular span and round up. Native filled revolutions need at least three intervals: adaptive
187
+ sampling refines to that minimum, while exact counts below it fail explicitly. Pure `revolveMesh`
188
+ supports one interval.
189
+
190
+ `resamplePolyline2` and `resamplePolyline3` share physical sampling options and return immutable
191
+ points with directed unit tangents. Open paths retain both endpoints; `closed: true` includes the
192
+ closing edge and omits a repeated seam vertex. Exact closed counts require at least three segments.
193
+
194
+ `regularPolygonLoop({ radius, sides, rotationDegrees, sizing })` creates a centered CCW point loop
195
+ with an implicit seam. `RadialSizing` defaults to `"vertex"`; `"face"` compensates polygon faceting
196
+ so the requested radius reaches the faces. `CylinderOptions` uses the same sizing option.
197
+
198
+ `normalizeLoop2`, `normalizePolygon2`, and `normalizeRegion2` return immutable geometry and may reuse internally validated results. External objects are validated even when frozen. Mutable mesh buffers are analyzed freshly at external boundaries; engine facts are reused inside their owner.
199
+
200
+ ## Profiles and mechanical construction
201
+
202
+ `sampleOpenProfile` samples upward radius/height line and cubic chains. Consumers own closure and
203
+ product constraints. `circleLoop`, `rectangleLoop`, and other point factories return ordered loops.
204
+ `Profile` owns identified components, contours, and landmarks; `CorrespondingProfile` retains their
205
+ shared sampled slots.
206
+
207
+ `rectangle`, `rectangleLoop`, and `rectangleProfile` share `size`, `center`, and `treatment` options.
208
+ Use root primitives for ordinary modeling and pure loops/profiles for custom data and explicit
209
+ correspondence. Native filled sections do not promise stable vertex ordering.
210
+
211
+ For a closed planar XYZ path, map the canonical loop with
212
+ `rectangleLoop(options).map(([x, y]) => [x, y, 0] as const)`. Before sampling, cap its
213
+ `limits.maxProfilePoints` at the smaller selected profile and path point ceilings. This keeps
214
+ path allocation bounded and preserves all corner tangent endpoints and the implicit seam.
215
+
216
+ ### Extrusion and sweep
217
+
218
+ `extrude(shape, { height, ... })`, `revolve(shape, options)` and `sweep(shape, path, options)` accept a filled Section or CorrespondingProfile, including holes and disconnected components. Open sweeps have watertight end caps; `closed: true` joins the path back to its beginning. Sweep options share degree twist, positive uniform or XY scale, and an XY scale pair per normalized path station. Closed scales interpolate along the implicit closing edge. A rotational symmetry seam uses `seamProfileOffset`, a counterclockwise logical point advance that reverses for clockwise hole contours; every contour must geometrically match the total twist. Incompatible seams fail explicitly.
219
+
220
+ Adaptive extrusion sampling bounds the entire side triangles, including the interaction between
221
+ profile edges, twist and unequal top scaling. `resolveExtrusionDivisions(profile, height, options)`
222
+ accepts a `Loop2` or filled `Region2` and measures every outer and hole edge; it is an optional estimate
223
+ using the same policy as construction. Exact `divisions` and deliberate angular counts retain their
224
+ precedence. Tight physical requests reject at selected sampling or output ceilings.
225
+
226
+ Nonzero sweep twist inserts stations according to `resolution`, including the deviation of side
227
+ triangles across profile edges. A full turn on a two-point path remains a full turn. Original
228
+ path stations retain their scales, twist progression and orientation-guide indices; `twistBy`
229
+ defaults to `"length"`, so angular progression follows physical path travel, including the implicit
230
+ closing edge. Choose `"stations"` for a deliberately authored station schedule. Inserted
231
+ stations interpolate centers, scales and shortest frame rotations. Guides run once per original
232
+ normalized station. Zero twist preserves the supplied path's existing mesh sampling. Explicit
233
+ `resolution.circularSegments` selects deliberate angular faceting; allocation ceilings still
234
+ apply. Adaptive scale changes can require subdivisions independently of angular travel; those
235
+ gaps use the selected full-curve interval ceiling. Refinement checks path and mesh budgets before
236
+ allocating the added station arrays.
237
+
238
+ Sweep `orientation` is one explicit policy shared by pure, filled, open and closed construction:
239
+ `{ kind: "transport", initialNormal? }` (default), `{ kind: "fixed-normal", normal }`,
240
+ `{ kind: "guide", normal: (point, index) => vector }`, or `{ kind: "frenet" }`. Transport minimizes
241
+ rotation and initially projects +X, then +Y, then +Z when no preference is supplied. A preferred
242
+ normal sets profile X; fixed and guide normals remain directed and project perpendicular to each
243
+ local tangent. Guide signs are preserved. Frenet uses projected neighboring sampled tangent changes
244
+ as curvature normals. Zero curvature and parallel explicit normals reject instead of switching
245
+ policies. For a planar closed path whose profile X should stay vertical, request
246
+ `orientation: { kind: "transport", initialNormal: [0, 0, 1] }`. Closed policies use cyclic tangents
247
+ and the same first frame on their closing gap.
248
+
249
+ ### Loft correspondence
250
+
251
+ `loft(stations, options)` accepts a `profile` and exactly one horizontal `z` height or explicit
252
+ right-handed `frame` per station. Stations stay in input order. Ordinary primitives keep the
253
+ simple case at the root entry point:
254
+
255
+ ```ts
256
+ import { circle, loft, rectangle } from "@metamesh/modeling";
257
+
258
+ export function build() {
259
+ return loft([
260
+ { profile: circle({ diameter: 20 }), z: 0 },
261
+ { profile: rectangle({ size: [30, 15], treatment: { kind: "round", radius: 3 } }), z: 40 },
262
+ ]);
263
+ }
264
+ ```
265
+
266
+ With omitted `correspondence`, compatible rectangle stations, circle/ellipse rings, equal-sided
267
+ regular polygons and equal-pointed stars use their retained authored landmarks. Rectangle corners
268
+ can change among square, round and chamfer treatments, including collapsed or saturated rounds.
269
+ Circle/ellipse and rectangle stations also share those quadrant/corner landmarks: a circular
270
+ inlet can become a rounded rectangle directly.
271
+ Exact circular counts for this mixed family must divide by four; other deliberately faceted counts
272
+ need an explicit geometric method. Adaptive counts align upward within the selected ceilings.
273
+ XY affine transforms preserve these identities; this semantic path requires consistent handedness.
274
+ Other unlike retained primitive families use direct perimeter subdivision from their construction-local
275
+ +X ray seam. Every physical input vertex remains, including corner tangent endpoints. Retained
276
+ curves use the selected loft resolution under every method, accounting for transform magnification.
277
+ Exact primitive samples preserve deliberate faceting; `refine` can deliberately add collinear density.
278
+ When an exact primitive is paired with a finer member, a shared union of parameter knots retains
279
+ its original polygon and inserts only collinear points on its facets. Adaptive members retain
280
+ physical curve sampling. Circle face sizing uses the actual minimum facet support from the local
281
+ origin, so collapsed slots, unequal quarter counts and collinear refinements preserve nominal clearance.
282
+
283
+ Boolean, offset and import operations discard primitive identity. Their Sections and plain point
284
+ loops require an explicitly selected correspondence method. This choice associates ordered
285
+ contours by component and hole index; it does not identify arbitrary components or repair changed
286
+ topology. Use identified profiles when those identities matter. Explicitly choosing a method on
287
+ known primitives also runs that geometric method, rather than substituting semantic matching.
288
+
289
+ | `correspondence` | Association |
290
+ | ----------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
291
+ | `"direct"` | Preserve each seam and subdivide edges to a common count without dropping vertices. |
292
+ | `"reindex"` | Direct subdivision, then choose the next contour's cyclic phase with the least total world-space connection length. |
293
+ | `"fast-distance"` | Keep the supplied seams and minimize connection length over ordered closed vertex associations, repeating vertices for triangular fans. |
294
+ | `"distance"` | The same ordered optimization over every cyclic phase of the next contour. |
295
+
296
+ One method applies to every gap; an array supplies one per gap. `distribution` defaults to
297
+ `"perimeter"` for direct/reindex and `"segments"` when any distance method is present. It controls
298
+ where extra subdivisions go; distance methods require segments. `refine` is a positive integer
299
+ multiplier, uniformly or per input profile. `slices` is a nonnegative intermediate-profile count,
300
+ uniformly or per gap. Slices interpolate the corresponding placed world vertices, never frame axes.
301
+ Insertions propagate across a shared grid, so mixed methods retain each middle profile without
302
+ T-junctions. Phase ties keep the earliest phase; ordered optimization prefers diagonal, previous-only,
303
+ then next-only advances. Its objective sums connection lengths with the closing seam counted once.
304
+ No tangent/supporting-plane association is exposed: general concave and spatial stations do not
305
+ provide the convexity contract that such a method needs.
306
+
307
+ Identified `ProfileSpan2` supports lines, arcs, and cubic Béziers with `start`, `control1`, `control2`,
308
+ and `end`. Cubics reuse the curve evaluator and physical subdivision policy, selecting one uniform
309
+ parameter grid for corresponding spans. Fully collapsed spans retain logical slots without moving
310
+ endpoints. Sampled contours and components use `CorrespondingContour` and `CorrespondingComponent`.
311
+ Pass the complete family to `matchProfiles` with optional `limits.maxProfilePoints`; its default is
312
+ 100,000 points per profile, while a separate one-million-slot family work bound remains in force.
313
+
314
+ For precise custom correspondence, prepare `matchProfiles` over explicit `Profile` specifications.
315
+ It chooses the maximum physical interval count for each paired span across the family, including
316
+ span-local `resolution`; identified line, arc and cubic kinds may change while IDs, order and
317
+ connected endpoints remain valid. `CorrespondingProfile` landmarks are authoritative, so geometric
318
+ remapping methods are rejected; direct refinement preserves every paired slot. `rectangleProfile`
319
+ is the canonical identified rectangle factory. Changed IDs, winding or filled topology fail.
320
+ Lofting merges coincident world vertices, omits degenerate faces and triangulates hole caps natively.
321
+
322
+ All loft routes share `LoftOptions`. Pure `loftMesh` requires an explicit method and returns a
323
+ closed simple-loop mesh without an engine. Selected sampling/output budgets apply before expanded
324
+ grids and mesh buffers; fixed aggregate safeguards bound correspondence at eight million comparisons
325
+ and the complete grid at one million logical slots. Simple-loop cap triangulation also has an
326
+ eight-million-comparison work ceiling. Complexity rejects instead of reducing fidelity
327
+ or substituting another method. Pure counterparts also include `sweepMesh`, `extrudeMesh` and `revolveMesh`.
328
+
329
+ ### Patterns and bounded surfaces
330
+
331
+ `linearPattern(shape, { count, length })` determines equal intervals from exactly two of `count`,
332
+ signed `spacing`, and signed total `length`; its direction defaults to +X. Length and spacing must
333
+ fit a whole interval count. `gridPattern(shape, { count: [3, 2], spacing: [10, 8] })` supports XY
334
+ or XYZ tuples, optional centering and an explicit frame; X varies fastest. `pathPattern(shape,
335
+ path, { count })` distributes copies by physical arc length, including both endpoints for open
336
+ paths and omitting a repeated closed seam. Its optional `orientation: "tangent"` aligns local +Z
337
+ to the containing segment by the shortest rotation from world +Z (a -Z tangent uses a +X half turn);
338
+ the default preserves source orientation. These placements transform the source's local origin.
339
+ All four pattern families, including `radialPattern`, accept a same-build Solid or an `(index) =>
340
+ Solid` factory for per-copy variation. Factories run once in ascending index order. The 100000-copy
341
+ algorithm ceiling and selected output budgets reject before predictable native copy allocation;
342
+ varying factories are checked cumulatively before each transform. Path input and placement counts
343
+ also obey `maxPathPoints`. Copies use the shared transform and lifetime checks.
344
+
345
+ `heightfieldMesh` and the modeling `heightfield` create a closed grid surface with explicit XY size, segment counts, and base Z. Heights are absolute Z values strictly above the base. Allocation is checked before sampling, and the height callback runs once per grid point.
346
+
347
+ Pure mechanical modules own thread profiles, sampling, printable fit, meshes, and allocation-free `preflightThreadedRod`, `preflightInternalThreadCutter`, and `preflightThreadedNut`. Engine methods own native construction. `pitch` is adjacent axial spacing; `lead = pitch × starts` is advance per turn. Internal cutters extend beyond requested faces and compensate faceting while preserving end treatments. Printable modeling forms are not certified thread classes or structural ratings.
348
+
349
+ `implicit` samples a finite positive-inside field within explicit bounds and grid spacing. Grid allocations and field evaluations are bounded. `components` returns same-build handles. `simplify` requires explicit millimetre tolerance and preserves native original-surface cleanup semantics.
350
+
351
+ ## Prepared text and SVG
352
+
353
+ Preparation shapes text once with the host's exact font service and retains immutable `VectorTextLayout`. Imported `textSection(layout, options)` consumes vector paths directly, without font shaping, fetching, or ambient providers. Paths and metrics use Y-up millimetres and a baseline origin. Empty layouts are measurable but cannot create sections. Font preparation remains optional and outside synchronous builds.
354
+
355
+ Install `fontkit` to use `prepareVectorFont` from `/text`, and `woff2-encoder` when decoding WOFF2. These optional peers are loaded only when preparing fonts. `sampleTextContours` from `/geometry` and `textSection` share bounded path sampling and need no font dependencies for an already prepared layout.
356
+
357
+ `svgSection` imports bounded painted SVG documents; `svgPathSection` imports filled path data. Y-down coordinates convert to Y-up; nonzero/even-odd filling preserves counters. Sampling applies after transforms and unit conversion. Basic shapes, groups, affine transforms, physical units, viewBox, fills, and strokes are supported. Text must be outlined. External resources, scripts, clipping, masks, filters, and unsupported content fail contextually. Pure parsers are shared with validation and the vector editor.
358
+
359
+ ## Final triangle topology
360
+
361
+ `analyzeTriangleMesh` validates and supplies bounds, counts, area, and signed volume in one traversal, with optional edge/component facts. Measurements, bounds, and signatures are independent immutable snapshots; external mutable buffers are inspected freshly on each call. Closed-edge checks require two oppositely wound faces per edge; they do not detect every geometric self-intersection. `createTriangleMeshSignature` adds quantized bounds, volume, topology, and a regression fingerprint, not a cryptographic digest.
362
+
363
+ The optional `meshTopologyMode: "optimized"` build setting runs bounded planar edge flips for either
364
+ execution lane. It preserves vertices, boundaries, winding, closure, reconstructability, area, and
365
+ volume. This is local connectivity cleanup, not general remeshing; source buffers never change in place.
366
+
367
+ Models above 200,000 triangles skip optimization. Unsupported or failed candidates retain their
368
+ original part, as do models whose optimized buffers would exceed an execution ceiling. Equal shared
369
+ mesh views reuse one optimized candidate.
370
+
371
+ ## Quality gates
372
+
373
+ Follow the [workspace instructions](https://github.com/JasonKoolman/metamesh/blob/main/packages/modeling/AGENTS.md#verification) for required checks. Timing and sampled process memory are diagnostics, not deterministic assertions or WASM heap measurements. The [publication contract](https://github.com/JasonKoolman/metamesh/blob/main/docs/continuous-delivery.md#public-library-publication) owns tarballs, clean standalone Node/Worker consumers, and release identity. Installed dependency size and browser bundles are measured separately; ZIP serialization and optional font dependencies load only through their capabilities.
374
+
375
+ ## License
376
+
377
+ Apache-2.0. Bundled offline artifacts also carry `THIRD_PARTY_NOTICES.md`.
@@ -0,0 +1,153 @@
1
+ # Third-party notices
2
+
3
+ `dist/geometry-module.js` includes source from the packages listed below. The private
4
+ `dist/engine/kernel/` contains exact Manifold 3.5.4 JS/WASM bytes, verified by SHA-256 during the
5
+ build. Its complete Apache-2.0 license is distributed at `dist/engine/kernel/LICENSE`.
6
+
7
+ ## Manifold 3.5.4 (Apache-2.0)
8
+
9
+ Source: https://github.com/elalish/manifold
10
+
11
+ The package incorporates only the kernel loader and WASM, with their license. Upstream CLI,
12
+ glTF utilities, examples, and their dependencies are excluded.
13
+
14
+ ## polygon-clipping 0.15.7 (MIT)
15
+
16
+ Copyright (c) 2018 Mike Fogel <mike@fogel.ca> - covers everything not specially attributed to
17
+ others below.
18
+
19
+ Copyright (c) 2016 Alexander Milevski <info@w8r.name> - covers all portions originally part of
20
+ github:w8r/martinez, from which this project was forked on February 2, 2018.
21
+
22
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
23
+ associated documentation files (the "Software"), to deal in the Software without restriction,
24
+ including without limitation the rights to use, copy, modify, merge, publish, distribute,
25
+ sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
26
+ furnished to do so, subject to the following conditions:
27
+
28
+ The above copyright notice and this permission notice shall be included in all copies or
29
+ substantial portions of the Software.
30
+
31
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
32
+ NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
33
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
34
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
35
+ OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
36
+
37
+ ## splaytree 3.1.2 (MIT)
38
+
39
+ Copyright (c) 2019 Alexander Milevski <info@w8r.name>
40
+
41
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
42
+ associated documentation files (the "Software"), to deal in the Software without restriction,
43
+ including without limitation the rights to use, copy, modify, merge, publish, distribute,
44
+ sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
45
+ furnished to do so, subject to the following conditions:
46
+
47
+ The above copyright notice and this permission notice shall be included in all copies or
48
+ substantial portions of the Software.
49
+
50
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
51
+ NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
52
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
53
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
54
+ OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
55
+
56
+ ## TypeScript runtime helpers in polygon-clipping 0.15.7 (Apache-2.0)
57
+
58
+ Copyright (c) Microsoft Corporation. All rights reserved.
59
+
60
+ Licensed under the Apache License, Version 2.0. A copy of that license is included in `LICENSE`.
61
+
62
+ ## svg-pathdata 9.0.0 (MIT)
63
+
64
+ Copyright © 2017 Nicolas Froidure
65
+
66
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
67
+ associated documentation files (the "Software"), to deal in the Software without restriction,
68
+ including without limitation the rights to use, copy, modify, merge, publish, distribute,
69
+ sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
70
+ furnished to do so, subject to the following conditions:
71
+
72
+ The above copyright notice and this permission notice shall be included in all copies or
73
+ substantial portions of the Software.
74
+
75
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
76
+ NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
77
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
78
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
79
+ OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
80
+
81
+ ## saxes 6.0.0 (ISC)
82
+
83
+ Copyright (c) Contributors
84
+
85
+ Permission to use, copy, modify, and/or distribute this software for any purpose with or without
86
+ fee is hereby granted, provided that the above copyright notice and this permission notice appear
87
+ in all copies.
88
+
89
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
90
+ SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
91
+ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
92
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
93
+ NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
94
+ OF THIS SOFTWARE.
95
+
96
+ Saxes is forked from sax, which carries the following notice:
97
+
98
+ Copyright (c) Isaac Z. Schlueter and Contributors
99
+
100
+ Permission to use, copy, modify, and/or distribute this software for any purpose with or without
101
+ fee is hereby granted, provided that the above copyright notice and this permission notice appear
102
+ in all copies.
103
+
104
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
105
+ SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
106
+ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
107
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
108
+ NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
109
+ OF THIS SOFTWARE.
110
+
111
+ ## xmlchars 2.2.0 (MIT)
112
+
113
+ Copyright Louis-Dominique Dubeau and contributors to xmlchars
114
+
115
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
116
+ associated documentation files (the "Software"), to deal in the Software without restriction,
117
+ including without limitation the rights to use, copy, modify, merge, publish, distribute,
118
+ sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
119
+ furnished to do so, subject to the following conditions:
120
+
121
+ The above copyright notice and this permission notice shall be included in all copies or
122
+ substantial portions of the Software.
123
+
124
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
125
+ NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
126
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
127
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
128
+ OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
129
+
130
+ ## robust-predicates (Unlicense)
131
+
132
+ The browser distribution bundled by polygon-clipping 0.15.7 contains robust-predicates code but
133
+ does not identify a more specific embedded version.
134
+
135
+ This is free and unencumbered software released into the public domain.
136
+
137
+ Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in
138
+ source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by
139
+ any means.
140
+
141
+ In jurisdictions that recognize copyright laws, the author or authors of this software dedicate
142
+ any and all copyright interest in the software to the public domain. We make this dedication for
143
+ the benefit of the public at large and to the detriment of our heirs and successors. We intend this
144
+ dedication to be an overt act of relinquishment in perpetuity of all present and future rights to
145
+ this software under copyright law.
146
+
147
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
148
+ NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
149
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
150
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
151
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
152
+
153
+ For more information, please refer to <http://unlicense.org/>.
@@ -0,0 +1,71 @@
1
+ import type { TriangleMesh } from "@metamesh/modeling/geometry";
2
+ import type { BuildOutput, FinalizedModel, GeometryResolution, ModelingContext, ModelingLimits, FinalizedPart, GeometrySamplingLimits } from "@metamesh/modeling";
3
+ /** Default host resource ceilings for parts, vertices, triangles, and transferable bytes. */
4
+ declare const defaultModelingLimits: Readonly<ModelingLimits>;
5
+
6
+
7
+ /** Execution settings supplied by the host, independently of generator metadata. */
8
+ export interface BuildOptions {
9
+ /** Per-build limits, no larger than the configured engine ceilings. */
10
+ readonly limits?: Partial<ModelingLimits>;
11
+ /** Physical sampling defaults; model-derived contexts and exact counts override these. */
12
+ readonly resolution?: GeometryResolution;
13
+ /** Optional bounded planar cleanup; unsupported candidates preserve the original part. */
14
+ readonly meshTopologyMode?: "original" | "optimized";
15
+ }
16
+ /**
17
+ * Host engine. No native values or manually disposable handles are exposed.
18
+ */
19
+ export interface ModelEngine {
20
+ /** Immutable resource ceilings selected when this engine was initialized. */
21
+ readonly limits: ModelingLimits;
22
+ /** Runs once, finalizes copied parts, and disposes all native values on every exit. */
23
+ build(build: (model: ModelingContext) => BuildOutput, options?: BuildOptions): FinalizedModel;
24
+ /** Serializes already finalized mesh parts; never prepares or builds a generator again. */
25
+ export3mf(parts: readonly ExportMeshPart[], options?: Export3mfOptions): Promise<ArrayBuffer>;
26
+ }
27
+ /**
28
+ * Manufacturing buffers accepted by the snapshot exporter.
29
+ */
30
+ export interface ExportMeshPart extends TriangleMesh {
31
+ /** Stable canonical lowercase identity; unique within the containing topology or output. */
32
+ readonly id: string;
33
+ /** Optional six-digit hex RGB display color. */
34
+ readonly color?: string;
35
+ }
36
+ /**
37
+ * Completed-snapshot serialization settings; filename selection belongs to the host.
38
+ */
39
+ export interface Export3mfOptions {
40
+ /** Document display name; defaults to MetaMesh model. */
41
+ readonly name?: string;
42
+ }
43
+ /** Kernel asset initialization. Networking and Worker ownership remain with the host. */
44
+ export interface ModelEngineOptions {
45
+ /** Resolves the kernel's WASM asset. Browser hosts supply their bundled asset URL. */
46
+ readonly locateFile?: () => string;
47
+ /** Trusted application ceilings. Builds may lower them; generators receive no engine. */
48
+ readonly limits?: Partial<ModelingLimits>;
49
+ }
50
+
51
+
52
+
53
+
54
+ export { defaultModelingLimits };
55
+ /** URL of the package's pinned WASM asset; browser bundlers may replace it with their emitted URL. */
56
+ export declare const modelingWasmUrl: string;
57
+
58
+ /**
59
+ * Initializes one host kernel and returns a lifecycle-safe engine. No generator initializes WASM.
60
+ *
61
+ * @example Build a box in a host application
62
+ * ```ts
63
+ * import { box } from "@metamesh/modeling";
64
+ * import { createModelEngine } from "@metamesh/modeling/engine";
65
+ *
66
+ * const engine = await createModelEngine();
67
+ * const snapshot = engine.build(() => box({ size: [30, 20, 8] }));
68
+ * ```
69
+ */
70
+ export declare function createModelEngine(options?: ModelEngineOptions): Promise<ModelEngine>;
71
+ export type { BuildOutput, FinalizedModel, FinalizedPart, ModelingContext, ModelingLimits, GeometryResolution, GeometrySamplingLimits, };