@metamesh/modeling 0.7.0 → 0.9.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.
- package/CHANGELOG.md +36 -0
- package/README.md +86 -4
- package/dist/api/engine.d.ts +4 -0
- package/dist/api/geometry.d.ts +1067 -908
- package/dist/api/index.d.ts +203 -18
- package/dist/api/text.d.ts +21 -7
- package/dist/engine/construction-operations.js +52 -10
- package/dist/engine/execution.js +55 -2
- package/dist/engine/export-3mf.js +17 -1
- package/dist/engine/finalization.js +27 -18
- package/dist/engine/inspection-operations.js +26 -22
- package/dist/engine/loft-operations.js +1 -1
- package/dist/engine/mechanical-operations.js +5 -8
- package/dist/engine/mesh-view-cache.js +23 -0
- package/dist/engine/native/adapter.js +2 -4
- package/dist/engine/native/distance.js +42 -0
- package/dist/engine/native/status.js +16 -0
- package/dist/engine/operation-environment.js +2 -1
- package/dist/engine/section-operations.js +3 -3
- package/dist/geometry/heightfield.js +101 -42
- package/dist/geometry/index.js +3 -0
- package/dist/geometry/loft-simple-mesh.js +2 -3
- package/dist/geometry/loft-triangulation.js +12 -9
- package/dist/geometry/loft.js +2 -6
- package/dist/geometry/mechanical/standards.js +2 -3
- package/dist/geometry/mechanical/threads.js +2 -3
- package/dist/geometry/mesh-centroid.js +36 -0
- package/dist/geometry/mesh-solid-intersections.js +123 -0
- package/dist/geometry/mesh-solid.js +284 -0
- package/dist/geometry/profiles/cross-section.js +102 -0
- package/dist/geometry/svg-import.js +8 -1
- package/dist/geometry/sweeps/sweep-closed.js +4 -4
- package/dist/geometry/sweeps/sweep-mesh.js +2 -6
- package/dist/geometry/sweeps/sweep-open.js +4 -4
- package/dist/geometry/sweeps/validation.js +1 -2
- package/dist/model/operations.js +10 -3
- package/dist/text/vector-text-layout.js +46 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,41 @@
|
|
|
1
1
|
# @metamesh/modeling
|
|
2
2
|
|
|
3
|
+
## 0.9.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- e405876: Add a bounded closed XY cross-section parameter with immutable values, strict validation,
|
|
8
|
+
normalization, presets, and runtime compatibility checks. Add `sampleCrossSection` for physical
|
|
9
|
+
curve sampling and validated closed-loop geometry. Existing side-profile values remain compatible.
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- e405876: Ignore fully transparent CSS color fills and strokes when importing SVG geometry.
|
|
14
|
+
|
|
15
|
+
## 0.8.0
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- bf1abe4: Add circular baselines to prepared vector text and Generator text services. Shaped glyphs and attached marks rotate rigidly around a millimetre radius, preserving kerning, ligatures, exact curve bounds and logical advances. Circular text is limited to one line, baseline vertical alignment, less than one revolution, and outlines that stay clear of the circle's center axis.
|
|
20
|
+
- bf1abe4: Complete solid splitting, plane clipping, Section hull/component/simplification operations, minimum-distance
|
|
21
|
+
queries and inspection facts. Add optional bounded geometric solid
|
|
22
|
+
validation at build/export boundaries and a pure uniform-density volume centroid helper.
|
|
23
|
+
Reuse immutable native inspection facts within a build and fresh owned topology analysis during
|
|
24
|
+
solid validation; share checks for identical buffer ranges without trusting mutable external facts.
|
|
25
|
+
|
|
26
|
+
Unify SVG default/preset limits and strict preset metadata checks. Preserve structured validation
|
|
27
|
+
codes and nested paths, add physical mesh assertions, and require runtime 2.1 for the current host
|
|
28
|
+
surface and issue metadata.
|
|
29
|
+
|
|
30
|
+
- bf1abe4: Add explicit uneven XY coordinates and optional shorter-edge or centre-error diagonal selection to heightfield and heightfieldMesh. Preserve uniform-grid sampling and fixed triangulation by default, with unchanged mesh allocation counts and strict Float32 coordinate checks.
|
|
31
|
+
|
|
32
|
+
Reject out-of-range section miter limits and inherited names in mechanical standards and thread-fit lookups. Avoid copying section polygons when only their count is needed.
|
|
33
|
+
|
|
34
|
+
### Patch Changes
|
|
35
|
+
|
|
36
|
+
- bf1abe4: Reject cap triangulation workloads that cannot fit the comparison budget before ear clipping, preserving the existing work ceiling and input vertices.
|
|
37
|
+
- bf1abe4: Detect triangle crossings when an edge endpoint lies within the solid-validation tolerance, and avoid redundant topology analysis during solid validation.
|
|
38
|
+
|
|
3
39
|
## 0.7.0
|
|
4
40
|
|
|
5
41
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -102,6 +102,16 @@ work limits remain fixed operation safeguards.
|
|
|
102
102
|
|
|
103
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
104
|
|
|
105
|
+
Build and 3MF export accept `meshValidation: "solid"` for bounded geometric validation in addition
|
|
106
|
+
to their default indexed topology checks. This rejects intersecting/touching separate shells and
|
|
107
|
+
incorrectly oriented nested boundaries while preserving inward cavity shells. Checks apply to each
|
|
108
|
+
part independently; separate semantic parts may intentionally overlap. It uses the same pure
|
|
109
|
+
`validateSolidMesh` capability described below. Finalization reuses fresh topology facts for its
|
|
110
|
+
privately owned selected buffers; export captures mutable input before fresh analysis. Within one
|
|
111
|
+
operation, identical buffer ranges share checks. No caller-supplied or cross-operation facts are
|
|
112
|
+
trusted. Its additional work and failure ceilings are explicit;
|
|
113
|
+
the default `"topology"` mode retains the existing large-model workflow.
|
|
114
|
+
|
|
105
115
|
## Resolution and conventions
|
|
106
116
|
|
|
107
117
|
Primitive and pure loop factories share named options and these conventions:
|
|
@@ -200,7 +210,13 @@ so the requested radius reaches the faces. `CylinderOptions` uses the same sizin
|
|
|
200
210
|
## Profiles and mechanical construction
|
|
201
211
|
|
|
202
212
|
`sampleOpenProfile` samples upward radius/height line and cubic chains. Consumers own closure and
|
|
203
|
-
product constraints. `
|
|
213
|
+
product constraints. `sampleCrossSection` samples 2–32 explicitly closed XY line/cubic segments
|
|
214
|
+
after positive width/height scaling, using the shared physical curve policy. It returns one
|
|
215
|
+
immutable CCW loop without a repeated seam, rejecting sampled self-intersections, zero area,
|
|
216
|
+
nonfinite coordinates, and exhausted budgets. Its default unique vertex ceiling is the smaller of
|
|
217
|
+
4096 and `limits.maxProfilePoints`; each segment also obeys `limits.maxPathPoints`. It accepts plain
|
|
218
|
+
curve coordinates without an SDK dependency, editor modes, or a normalized-range requirement.
|
|
219
|
+
`circleLoop`, `rectangleLoop`, and other point factories return ordered loops.
|
|
204
220
|
`Profile` owns identified components, contours, and landmarks; `CorrespondingProfile` retains their
|
|
205
221
|
shared sampled slots.
|
|
206
222
|
|
|
@@ -323,8 +339,10 @@ All loft routes share `LoftOptions`. Pure `loftMesh` requires an explicit method
|
|
|
323
339
|
closed simple-loop mesh without an engine. Selected sampling/output budgets apply before expanded
|
|
324
340
|
grids and mesh buffers; fixed aggregate safeguards bound correspondence at eight million comparisons
|
|
325
341
|
and the complete grid at one million logical slots. Simple-loop cap triangulation also has an
|
|
326
|
-
eight-million-comparison work ceiling.
|
|
327
|
-
|
|
342
|
+
eight-million-comparison work ceiling. Caps whose minimum comparison count exceeds that ceiling
|
|
343
|
+
reject before ear clipping; other caps retain the running work check. Complexity rejects instead of
|
|
344
|
+
reducing fidelity or substituting another method. Pure counterparts also include `sweepMesh`,
|
|
345
|
+
`extrudeMesh` and `revolveMesh`.
|
|
328
346
|
|
|
329
347
|
### Patterns and bounded surfaces
|
|
330
348
|
|
|
@@ -342,24 +360,88 @@ algorithm ceiling and selected output budgets reject before predictable native c
|
|
|
342
360
|
varying factories are checked cumulatively before each transform. Path input and placement counts
|
|
343
361
|
also obey `maxPathPoints`. Copies use the shared transform and lifetime checks.
|
|
344
362
|
|
|
345
|
-
`
|
|
363
|
+
`heightfield` returns a Solid for transforms and booleans; `heightfieldMesh` returns the same
|
|
364
|
+
closed construction as pure indexed data. Supply `size`, `segments`, and optional `origin` for a
|
|
365
|
+
uniform grid, or `coordinates: { x, y }` for absolute, unevenly spaced XY samples. Explicit axes
|
|
366
|
+
must increase strictly and remain distinct in Float32. This lets callers refine narrow borders
|
|
367
|
+
without remapping mesh vertices. Heights remain absolute Z values strictly above `baseZ` (default
|
|
368
|
+
zero); sampling never rescales the field.
|
|
369
|
+
|
|
370
|
+
`triangulation` defaults to `"fixed"`, preserving the lower-left to upper-right diagonal.
|
|
371
|
+
`"min-edge"` chooses the shorter 3D diagonal without extra sampling. `"center-error"` samples the
|
|
372
|
+
physical cell centre once and chooses the diagonal whose interpolated height is closer there.
|
|
373
|
+
Ties retain the fixed diagonal. Every policy uses two top triangles per cell and the same closed
|
|
374
|
+
walls and flat base; centre agreement does not guarantee accuracy elsewhere. Allocation and
|
|
375
|
+
coordinate precision are checked before height callbacks. Each grid point is sampled once, with
|
|
376
|
+
one additional callback per cell for `"center-error"`.
|
|
377
|
+
|
|
378
|
+
```ts
|
|
379
|
+
heightfield({
|
|
380
|
+
coordinates: { x: [-15, -14.5, 0, 14.5, 15], y: [-10, -9.5, 0, 9.5, 10] },
|
|
381
|
+
triangulation: "min-edge",
|
|
382
|
+
height: ([x, y]) => 3 + Math.cos(x / 5) * Math.cos(y / 5),
|
|
383
|
+
});
|
|
384
|
+
```
|
|
346
385
|
|
|
347
386
|
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
387
|
|
|
388
|
+
`split(solid, cutter)` returns intersection followed by subtraction as two same-build handles.
|
|
389
|
+
`splitByPlane(solid, { normal, offset })` returns the positive-normal side followed by the negative
|
|
390
|
+
side. Destructure `[positive]` or `[, negative]` to retain just one side. The nonzero normal is
|
|
391
|
+
normalized and `offset` is the signed distance from the world origin in millimetres (default zero).
|
|
392
|
+
Empty results are valid handles
|
|
393
|
+
for `isEmpty`, inspection and further operations, but cannot be finalized as manufacturing parts.
|
|
394
|
+
|
|
395
|
+
`hull` accepts Solid inputs/XYZ points or Section inputs/XY points. `components` and `simplify`
|
|
396
|
+
also preserve either dimension. Solid components are disconnected surface shells: inward cavity
|
|
397
|
+
shells count separately in `inspectSolid().parts` and cannot be finalized alone. Section components
|
|
398
|
+
are filled islands that retain their holes. `inspectSolid` includes surface area, native tolerance and emptiness;
|
|
399
|
+
`inspectSection` includes emptiness. Both return immutable native facts shared by repeated
|
|
400
|
+
inspections of the same shape within one build, including aliases and derived resolution contexts.
|
|
401
|
+
Transforms, Booleans and tolerance changes have their own facts. The execution clears these caches
|
|
402
|
+
on disposal; retained facts contain no live native values.
|
|
403
|
+
|
|
404
|
+
`distance(a, b)` measures the minimum separation between two nonempty solids in millimetres.
|
|
405
|
+
It returns zero for contact or overlapping material. The kernel's search range is managed internally;
|
|
406
|
+
there is no caller-supplied distance cutoff. Queries use native geometry and precision without
|
|
407
|
+
extracting a triangle mesh; empty, expired and foreign-build handles reject.
|
|
408
|
+
|
|
409
|
+
Installed Generators using these added host operations or Section overloads declare minimum runtime
|
|
410
|
+
2.1.0. Imported operations require the current host context; package metadata declares the runtime
|
|
411
|
+
capabilities the Generator uses.
|
|
412
|
+
|
|
349
413
|
`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
414
|
|
|
351
415
|
## Prepared text and SVG
|
|
352
416
|
|
|
353
417
|
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
418
|
|
|
419
|
+
`baseline: { kind: "arc", radius }` places one line on a circle centered at the XY origin, in millimetres. Alignment defaults to `"center"` at `centerAngleDegrees` (90° from +X by default); `"left"` and `"right"` place the logical start and end at that datum. Direction defaults to `"clockwise"`, giving upright top lettering at 90°; `"counterclockwise"` at 270° gives upright bottom lettering. Shaped glyphs and attached zero-advance marks rotate rigidly, preserving their proportions, kerning and ligatures. Exact ink bounds describe the placed curves; `logicalWidth` and `advance[0]` retain the unwrapped arc length including spaces. Radius must be positive and at most 10000 mm. Arcs require baseline vertical alignment and reject multiline text, logical spans of a full revolution, and glyph outlines crossing the circle's center axis. Adjacent glyph collision and fit within a particular face remain consumer policy.
|
|
420
|
+
|
|
355
421
|
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
422
|
|
|
357
423
|
`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
424
|
|
|
425
|
+
Zero-alpha colors and zero-opacity paint channels contribute no geometry. Positive alpha contributes
|
|
426
|
+
the full painted region; presentation transparency does not reduce its physical area.
|
|
427
|
+
|
|
359
428
|
## Final triangle topology
|
|
360
429
|
|
|
361
430
|
`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
431
|
|
|
432
|
+
Pure `validateSolidMesh(mesh, options)` adds spatial triangle tests, a single closed incident fan at
|
|
433
|
+
every vertex, and shell containment/orientation checks, including cavity boundaries and islands.
|
|
434
|
+
It never repairs or changes input buffers.
|
|
435
|
+
Floating-point contacts within the selected `tolerance` reject conservatively; this is not an exact
|
|
436
|
+
predicate or a manufacturing certification. Its fixed ceilings are 200,000 triangles and 2,000,000
|
|
437
|
+
spatial/containment tests. `maximumTests` may lower the work ceiling. Exhaustion throws
|
|
438
|
+
`COMPLEXITY_LIMIT` and never returns an unchecked result. All position vertices must be referenced.
|
|
439
|
+
|
|
440
|
+
`computeTriangleMeshCentroid(mesh)` returns an immutable uniform-density volume centroid in
|
|
441
|
+
millimetres for consistently oriented closed geometry, accounting for inward cavity shells.
|
|
442
|
+
It checks indexed closure and positive aggregate volume; use solid validation first for untrusted
|
|
443
|
+
geometric shell arrangements.
|
|
444
|
+
|
|
363
445
|
The optional `meshTopologyMode: "optimized"` build setting runs bounded planar edge flips for either
|
|
364
446
|
execution lane. It preserves vertices, boundaries, winding, closure, reconstructability, area, and
|
|
365
447
|
volume. This is local connectivity cleanup, not general remeshing; source buffers never change in place.
|
package/dist/api/engine.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ declare const defaultModelingLimits: Readonly<ModelingLimits>;
|
|
|
6
6
|
|
|
7
7
|
/** Execution settings supplied by the host, independently of generator metadata. */
|
|
8
8
|
export interface BuildOptions {
|
|
9
|
+
/** Optional bounded intersection and nested-shell checks; defaults to indexed topology validation. */
|
|
10
|
+
readonly meshValidation?: "topology" | "solid";
|
|
9
11
|
/** Per-build limits, no larger than the configured engine ceilings. */
|
|
10
12
|
readonly limits?: Partial<ModelingLimits>;
|
|
11
13
|
/** Physical sampling defaults; model-derived contexts and exact counts override these. */
|
|
@@ -37,6 +39,8 @@ export interface ExportMeshPart extends TriangleMesh {
|
|
|
37
39
|
* Completed-snapshot serialization settings; filename selection belongs to the host.
|
|
38
40
|
*/
|
|
39
41
|
export interface Export3mfOptions {
|
|
42
|
+
/** Optional bounded geometric solid checks on captured buffers; defaults to indexed topology validation. */
|
|
43
|
+
readonly meshValidation?: "topology" | "solid";
|
|
40
44
|
/** Document display name; defaults to MetaMesh model. */
|
|
41
45
|
readonly name?: string;
|
|
42
46
|
}
|