brepjs 18.37.0 → 18.39.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/dist/brepjs.cjs CHANGED
@@ -218,8 +218,8 @@ function pointsInside(mesh, queries, id) {
218
218
  }
219
219
  //#endregion
220
220
  //#region src/voxel/repairFns.ts
221
- var DEFAULT_RESOLUTION = 48;
222
- var DEFAULT_PADDING = 2;
221
+ var DEFAULT_RESOLUTION$1 = 48;
222
+ var DEFAULT_PADDING$1 = 2;
223
223
  /**
224
224
  * Repair a (possibly non-watertight) triangle-soup mesh into a closed surface:
225
225
  * voxelize an FWN-signed SDF, then Surface-Nets contour it back to triangles.
@@ -232,16 +232,16 @@ function repairMesh(mesh, opts, id) {
232
232
  const invalid = validateMesh(mesh);
233
233
  if (invalid) return require_errors.err(invalid);
234
234
  if (mesh.vertices.length === 0 || mesh.triangles.length === 0) return require_errors.err(require_errors.validationError("VOXEL_EMPTY_MESH", "repairMesh requires a non-empty triangle mesh."));
235
- const resolution = opts?.resolution ?? DEFAULT_RESOLUTION;
236
- const padding = opts?.padding ?? DEFAULT_PADDING;
235
+ const resolution = opts?.resolution ?? DEFAULT_RESOLUTION$1;
236
+ const padding = opts?.padding ?? DEFAULT_PADDING$1;
237
237
  if (!Number.isInteger(resolution) || resolution < 1) return require_errors.err(require_errors.validationError("VOXEL_INVALID_RESOLUTION", "resolution must be an integer >= 1."));
238
238
  if (!Number.isInteger(padding) || padding < 1) return require_errors.err(require_errors.validationError("VOXEL_INVALID_PADDING", "padding must be an integer >= 1."));
239
239
  const engine = resolveEngine(id);
240
240
  if (require_errors.isErr(engine)) return engine;
241
241
  try {
242
242
  try {
243
- var _usingCtx$4 = require_shapeTypes._usingCtx();
244
- const repaired = _usingCtx$4.u(engine.value.repair_mesh(mesh.vertices, mesh.triangles, resolution, padding));
243
+ var _usingCtx$5 = require_shapeTypes._usingCtx();
244
+ const repaired = _usingCtx$5.u(engine.value.repair_mesh(mesh.vertices, mesh.triangles, resolution, padding));
245
245
  const vertexCount = repaired.positions.length / 3;
246
246
  return require_errors.ok({
247
247
  vertices: repaired.positions,
@@ -254,13 +254,116 @@ function repairMesh(mesh, opts, id) {
254
254
  faceHash: 0
255
255
  }]
256
256
  });
257
+ } catch (_) {
258
+ _usingCtx$5.e = _;
259
+ } finally {
260
+ _usingCtx$5.d();
261
+ }
262
+ } catch (cause) {
263
+ return require_errors.err(require_errors.computationError("VOXEL_REPAIR_FAILED", cause instanceof Error ? cause.message : "voxel repair failed (grid too large?).", cause));
264
+ }
265
+ }
266
+ //#endregion
267
+ //#region src/lattice/latticeFns.ts
268
+ var LATTICE_TAGS = {
269
+ gyroid: 0,
270
+ schwarzP: 1,
271
+ diamond: 2
272
+ };
273
+ var DEFAULT_RESOLUTION = 48;
274
+ var DEFAULT_PADDING = 2;
275
+ function validateOptions(opts) {
276
+ const tag = LATTICE_TAGS[opts.type];
277
+ if (tag === void 0) return require_errors.err(require_errors.validationError("LATTICE_INVALID_TYPE", `lattice type must be one of gyroid, schwarzP, diamond (got '${opts.type}').`));
278
+ if (!(opts.period > 0)) return require_errors.err(require_errors.validationError("LATTICE_INVALID_PERIOD", "period must be > 0."));
279
+ if (!(opts.thickness > 0)) return require_errors.err(require_errors.validationError("LATTICE_INVALID_THICKNESS", "thickness must be > 0."));
280
+ const resolution = opts.resolution ?? DEFAULT_RESOLUTION;
281
+ const padding = opts.padding ?? DEFAULT_PADDING;
282
+ if (!Number.isInteger(resolution) || resolution < 1) return require_errors.err(require_errors.validationError("LATTICE_INVALID_RESOLUTION", "resolution must be an integer >= 1."));
283
+ if (!Number.isInteger(padding) || padding < 1) return require_errors.err(require_errors.validationError("LATTICE_INVALID_PADDING", "padding must be an integer >= 1."));
284
+ return require_errors.ok({
285
+ tag,
286
+ period: opts.period,
287
+ thickness: opts.thickness,
288
+ resolution,
289
+ padding
290
+ });
291
+ }
292
+ function toMesh(repaired) {
293
+ const vertexCount = repaired.positions.length / 3;
294
+ return {
295
+ vertices: repaired.positions,
296
+ normals: repaired.normals,
297
+ triangles: repaired.indices,
298
+ uvs: new Float32Array(vertexCount * 2),
299
+ faceGroups: [{
300
+ start: 0,
301
+ count: repaired.indices.length / 3,
302
+ faceHash: 0
303
+ }]
304
+ };
305
+ }
306
+ /**
307
+ * Fill a solid mesh with a TPMS lattice infill: intersect the FWN-signed solid
308
+ * with the chosen lattice shell field, then Surface-Nets contour the result.
309
+ *
310
+ * Returns a {@link KernelMeshResult} in world coordinates (a single face group,
311
+ * no UVs). The TPMS field is the approximate implicit (raw trig), so the surface
312
+ * is contoured at the zero level without distance normalization (ADR-0013).
313
+ */
314
+ function latticeInfill(mesh, opts, id) {
315
+ const invalid = validateMesh(mesh);
316
+ if (invalid) return require_errors.err(invalid);
317
+ if (mesh.vertices.length === 0 || mesh.triangles.length === 0) return require_errors.err(require_errors.validationError("LATTICE_EMPTY_MESH", "latticeInfill requires a non-empty triangle mesh."));
318
+ const resolved = validateOptions(opts);
319
+ if (require_errors.isErr(resolved)) return resolved;
320
+ const engine = resolveEngine(id);
321
+ if (require_errors.isErr(engine)) return engine;
322
+ const { tag, period, thickness, resolution, padding } = resolved.value;
323
+ try {
324
+ try {
325
+ var _usingCtx$4 = require_shapeTypes._usingCtx();
326
+ return require_errors.ok(toMesh(_usingCtx$4.u(engine.value.lattice_infill(mesh.vertices, mesh.triangles, resolution, padding, tag, period, thickness))));
257
327
  } catch (_) {
258
328
  _usingCtx$4.e = _;
259
329
  } finally {
260
330
  _usingCtx$4.d();
261
331
  }
262
332
  } catch (cause) {
263
- return require_errors.err(require_errors.computationError("VOXEL_REPAIR_FAILED", cause instanceof Error ? cause.message : "voxel repair failed (grid too large?).", cause));
333
+ return require_errors.err(require_errors.computationError("LATTICE_INFILL_FAILED", cause instanceof Error ? cause.message : "lattice infill failed (grid too large?).", cause));
334
+ }
335
+ }
336
+ /**
337
+ * Contour the infinite TPMS lattice clipped to an axis-aligned box.
338
+ *
339
+ * Returns a {@link KernelMeshResult} in world coordinates (a single face group,
340
+ * no UVs). The TPMS field is the approximate implicit (raw trig), contoured at
341
+ * the zero level without distance normalization (ADR-0013).
342
+ */
343
+ function tpmsLattice(bounds, opts, id) {
344
+ for (let axis = 0; axis < 3; axis++) {
345
+ const lo = bounds.min[axis];
346
+ const hi = bounds.max[axis];
347
+ if (lo === void 0 || hi === void 0 || !(lo < hi)) return require_errors.err(require_errors.validationError("LATTICE_INVALID_BOUNDS", `bounds.min must be strictly less than bounds.max on every axis (axis ${axis}).`));
348
+ }
349
+ const resolved = validateOptions(opts);
350
+ if (require_errors.isErr(resolved)) return resolved;
351
+ const engine = resolveEngine(id);
352
+ if (require_errors.isErr(engine)) return engine;
353
+ const { tag, period, thickness, resolution, padding } = resolved.value;
354
+ const [minX, minY, minZ] = bounds.min;
355
+ const [maxX, maxY, maxZ] = bounds.max;
356
+ try {
357
+ try {
358
+ var _usingCtx3 = require_shapeTypes._usingCtx();
359
+ return require_errors.ok(toMesh(_usingCtx3.u(engine.value.tpms_box(minX, minY, minZ, maxX, maxY, maxZ, resolution, padding, tag, period, thickness))));
360
+ } catch (_) {
361
+ _usingCtx3.e = _;
362
+ } finally {
363
+ _usingCtx3.d();
364
+ }
365
+ } catch (cause) {
366
+ return require_errors.err(require_errors.computationError("TPMS_LATTICE_FAILED", cause instanceof Error ? cause.message : "tpms lattice failed (grid too large?).", cause));
264
367
  }
265
368
  }
266
369
  //#endregion
@@ -5621,6 +5724,7 @@ exports.kernelCall = require_topologyQueryFns.kernelCall;
5621
5724
  exports.kernelCallRaw = require_topologyQueryFns.kernelCallRaw;
5622
5725
  exports.kernelCallScoped = require_topologyQueryFns.kernelCallScoped;
5623
5726
  exports.kernelError = require_errors.kernelError;
5727
+ exports.latticeInfill = latticeInfill;
5624
5728
  exports.line = require_primitiveFns.line;
5625
5729
  exports.linearPattern = require_historyFns.linearPattern;
5626
5730
  exports.loadFont = require_textBlueprints.loadFont;
@@ -5810,6 +5914,7 @@ exports.toSVGPathD = require_blueprintFns.toSVGPathD;
5810
5914
  exports.toVec2 = require_types.toVec2;
5811
5915
  exports.toVec3 = require_types.toVec3;
5812
5916
  exports.torus = require_primitiveFns.torus;
5917
+ exports.tpmsLattice = tpmsLattice;
5813
5918
  exports.transformCopy = transformCopy;
5814
5919
  Object.defineProperty(exports, "transforms", {
5815
5920
  enumerable: true,
package/dist/brepjs.js CHANGED
@@ -229,8 +229,8 @@ function pointsInside(mesh, queries, id) {
229
229
  }
230
230
  //#endregion
231
231
  //#region src/voxel/repairFns.ts
232
- var DEFAULT_RESOLUTION = 48;
233
- var DEFAULT_PADDING = 2;
232
+ var DEFAULT_RESOLUTION$1 = 48;
233
+ var DEFAULT_PADDING$1 = 2;
234
234
  /**
235
235
  * Repair a (possibly non-watertight) triangle-soup mesh into a closed surface:
236
236
  * voxelize an FWN-signed SDF, then Surface-Nets contour it back to triangles.
@@ -243,16 +243,16 @@ function repairMesh(mesh, opts, id) {
243
243
  const invalid = validateMesh(mesh);
244
244
  if (invalid) return err(invalid);
245
245
  if (mesh.vertices.length === 0 || mesh.triangles.length === 0) return err(validationError("VOXEL_EMPTY_MESH", "repairMesh requires a non-empty triangle mesh."));
246
- const resolution = opts?.resolution ?? DEFAULT_RESOLUTION;
247
- const padding = opts?.padding ?? DEFAULT_PADDING;
246
+ const resolution = opts?.resolution ?? DEFAULT_RESOLUTION$1;
247
+ const padding = opts?.padding ?? DEFAULT_PADDING$1;
248
248
  if (!Number.isInteger(resolution) || resolution < 1) return err(validationError("VOXEL_INVALID_RESOLUTION", "resolution must be an integer >= 1."));
249
249
  if (!Number.isInteger(padding) || padding < 1) return err(validationError("VOXEL_INVALID_PADDING", "padding must be an integer >= 1."));
250
250
  const engine = resolveEngine(id);
251
251
  if (isErr(engine)) return engine;
252
252
  try {
253
253
  try {
254
- var _usingCtx$4 = _usingCtx();
255
- const repaired = _usingCtx$4.u(engine.value.repair_mesh(mesh.vertices, mesh.triangles, resolution, padding));
254
+ var _usingCtx$5 = _usingCtx();
255
+ const repaired = _usingCtx$5.u(engine.value.repair_mesh(mesh.vertices, mesh.triangles, resolution, padding));
256
256
  const vertexCount = repaired.positions.length / 3;
257
257
  return ok({
258
258
  vertices: repaired.positions,
@@ -265,13 +265,116 @@ function repairMesh(mesh, opts, id) {
265
265
  faceHash: 0
266
266
  }]
267
267
  });
268
+ } catch (_) {
269
+ _usingCtx$5.e = _;
270
+ } finally {
271
+ _usingCtx$5.d();
272
+ }
273
+ } catch (cause) {
274
+ return err(computationError("VOXEL_REPAIR_FAILED", cause instanceof Error ? cause.message : "voxel repair failed (grid too large?).", cause));
275
+ }
276
+ }
277
+ //#endregion
278
+ //#region src/lattice/latticeFns.ts
279
+ var LATTICE_TAGS = {
280
+ gyroid: 0,
281
+ schwarzP: 1,
282
+ diamond: 2
283
+ };
284
+ var DEFAULT_RESOLUTION = 48;
285
+ var DEFAULT_PADDING = 2;
286
+ function validateOptions(opts) {
287
+ const tag = LATTICE_TAGS[opts.type];
288
+ if (tag === void 0) return err(validationError("LATTICE_INVALID_TYPE", `lattice type must be one of gyroid, schwarzP, diamond (got '${opts.type}').`));
289
+ if (!(opts.period > 0)) return err(validationError("LATTICE_INVALID_PERIOD", "period must be > 0."));
290
+ if (!(opts.thickness > 0)) return err(validationError("LATTICE_INVALID_THICKNESS", "thickness must be > 0."));
291
+ const resolution = opts.resolution ?? DEFAULT_RESOLUTION;
292
+ const padding = opts.padding ?? DEFAULT_PADDING;
293
+ if (!Number.isInteger(resolution) || resolution < 1) return err(validationError("LATTICE_INVALID_RESOLUTION", "resolution must be an integer >= 1."));
294
+ if (!Number.isInteger(padding) || padding < 1) return err(validationError("LATTICE_INVALID_PADDING", "padding must be an integer >= 1."));
295
+ return ok({
296
+ tag,
297
+ period: opts.period,
298
+ thickness: opts.thickness,
299
+ resolution,
300
+ padding
301
+ });
302
+ }
303
+ function toMesh(repaired) {
304
+ const vertexCount = repaired.positions.length / 3;
305
+ return {
306
+ vertices: repaired.positions,
307
+ normals: repaired.normals,
308
+ triangles: repaired.indices,
309
+ uvs: new Float32Array(vertexCount * 2),
310
+ faceGroups: [{
311
+ start: 0,
312
+ count: repaired.indices.length / 3,
313
+ faceHash: 0
314
+ }]
315
+ };
316
+ }
317
+ /**
318
+ * Fill a solid mesh with a TPMS lattice infill: intersect the FWN-signed solid
319
+ * with the chosen lattice shell field, then Surface-Nets contour the result.
320
+ *
321
+ * Returns a {@link KernelMeshResult} in world coordinates (a single face group,
322
+ * no UVs). The TPMS field is the approximate implicit (raw trig), so the surface
323
+ * is contoured at the zero level without distance normalization (ADR-0013).
324
+ */
325
+ function latticeInfill(mesh, opts, id) {
326
+ const invalid = validateMesh(mesh);
327
+ if (invalid) return err(invalid);
328
+ if (mesh.vertices.length === 0 || mesh.triangles.length === 0) return err(validationError("LATTICE_EMPTY_MESH", "latticeInfill requires a non-empty triangle mesh."));
329
+ const resolved = validateOptions(opts);
330
+ if (isErr(resolved)) return resolved;
331
+ const engine = resolveEngine(id);
332
+ if (isErr(engine)) return engine;
333
+ const { tag, period, thickness, resolution, padding } = resolved.value;
334
+ try {
335
+ try {
336
+ var _usingCtx$4 = _usingCtx();
337
+ return ok(toMesh(_usingCtx$4.u(engine.value.lattice_infill(mesh.vertices, mesh.triangles, resolution, padding, tag, period, thickness))));
268
338
  } catch (_) {
269
339
  _usingCtx$4.e = _;
270
340
  } finally {
271
341
  _usingCtx$4.d();
272
342
  }
273
343
  } catch (cause) {
274
- return err(computationError("VOXEL_REPAIR_FAILED", cause instanceof Error ? cause.message : "voxel repair failed (grid too large?).", cause));
344
+ return err(computationError("LATTICE_INFILL_FAILED", cause instanceof Error ? cause.message : "lattice infill failed (grid too large?).", cause));
345
+ }
346
+ }
347
+ /**
348
+ * Contour the infinite TPMS lattice clipped to an axis-aligned box.
349
+ *
350
+ * Returns a {@link KernelMeshResult} in world coordinates (a single face group,
351
+ * no UVs). The TPMS field is the approximate implicit (raw trig), contoured at
352
+ * the zero level without distance normalization (ADR-0013).
353
+ */
354
+ function tpmsLattice(bounds, opts, id) {
355
+ for (let axis = 0; axis < 3; axis++) {
356
+ const lo = bounds.min[axis];
357
+ const hi = bounds.max[axis];
358
+ if (lo === void 0 || hi === void 0 || !(lo < hi)) return err(validationError("LATTICE_INVALID_BOUNDS", `bounds.min must be strictly less than bounds.max on every axis (axis ${axis}).`));
359
+ }
360
+ const resolved = validateOptions(opts);
361
+ if (isErr(resolved)) return resolved;
362
+ const engine = resolveEngine(id);
363
+ if (isErr(engine)) return engine;
364
+ const { tag, period, thickness, resolution, padding } = resolved.value;
365
+ const [minX, minY, minZ] = bounds.min;
366
+ const [maxX, maxY, maxZ] = bounds.max;
367
+ try {
368
+ try {
369
+ var _usingCtx3 = _usingCtx();
370
+ return ok(toMesh(_usingCtx3.u(engine.value.tpms_box(minX, minY, minZ, maxX, maxY, maxZ, resolution, padding, tag, period, thickness))));
371
+ } catch (_) {
372
+ _usingCtx3.e = _;
373
+ } finally {
374
+ _usingCtx3.d();
375
+ }
376
+ } catch (cause) {
377
+ return err(computationError("TPMS_LATTICE_FAILED", cause instanceof Error ? cause.message : "tpms lattice failed (grid too large?).", cause));
275
378
  }
276
379
  }
277
380
  //#endregion
@@ -5293,4 +5396,4 @@ var csg_exports = /* @__PURE__ */ __exportAll({
5293
5396
  withEvaluator: () => withEvaluator
5294
5397
  });
5295
5398
  //#endregion
5296
- export { BaseSketcher2d, BlueprintSketcher, BrepBugError, BrepErrorCode, BrepWrapperError, BrepkitAdapter, CompoundSketch, DEG2RAD, DisposalScope, FaceSketcher, HASH_CODE_MAX, OK, OcctWasmAdapter, RAD2DEG, Sketch, Sketcher, Sketches, addChild, addHoles, addMate, addStep, adjacentFaces, all, andThen, applyGlue, applyMatrix, approximateCurve, as2D, as3D, asTopo, assignRoles, autoHeal, bezier, blueprintToDXF, booleanPipeline, booleans_exports as booleans, boss, box, bsplineApprox, bug, cameraFromPlane, cameraLookAt, captureHint, cast, castShape, castShape3D, chamfer, chamferDistAngle as chamferDistAngleShape, chamferWithEvolution, checkAllInterferences, checkBoolean, checkInterference, circle, circularPattern, classifyPointOnFace, clearMeshCache, clone, closedWire, collect, collectShapes, colorFaces, colorShape, complexExtrude, composeTransforms, compound, compoundSketchExtrude, compoundSketchFace, compoundSketchLoft, compoundSketchRevolve, computationError, computeStraightSkeleton, cone, construction_exports as construction, convexHull, cornerFinder, countNodes, createAssembly, createAssemblyNode, createBlueprint, createCamera, createCompound, createCompoundBlueprint, createDistanceQuery, createEdge, createFace, createHandle, createHistory, createKernelHandle, createMeshCache, createNamedPlane, createOperationRegistry, createPlane, createRef, createRegistry, createShell, createSolid, createTaskQueue, createVertex, createWire, createWorkerClient, createWorkerHandler, csg_exports as csg, curve2dBoundingBox, curve2dDistanceFrom, curve2dFirstPoint, curve2dIsOnCurve, curve2dLastPoint, curve2dParameter, curve2dSplitAt, curve2dTangentAt, curveEndPoint, curveIsClosed, curveIsPeriodic, curveLength, curvePeriod, curvePointAt, curveStartPoint, curveTangentAt, cut, cut2D, cutAll, cutAllBisect, cutBlueprints, cutWithEvolution, cylinder, defaultScorer, dequeueTask, describe, deserializeDrawing, deserializeHistory, fromBREP as deserializeShape, downcast, draft, draw, drawCircle, drawEllipse, drawFaceOutline, drawParametricFunction, drawPointsInterpolation, drawPolysides, drawProjection, drawRectangle, drawRoundedRectangle, drawSingleCircle, drawSingleEllipse, drawText, drawingChamfer, drawingCut, drawingFillet, drawingFuse, drawingIntersect, drawingToSketchOnPlane, drill, edgeFinder, edgesOfFace, ellipse, ellipseArc, ellipsoid, enqueueTask, err, exportAssemblySTEP, exportDXF, exportGlb, exportGltf, exportIGES, exportOBJ, exportSTEP, exportSTEPConfigured, exportSTL, exportThreeMF, extrude, extrudeAll, face, faceCenter, faceFinder, faceGeomType, faceOrientation, facesOfEdge, fill, filledFace, fillet, filletWithEvolution, findFacesByTag, findNode, findStep, fixSelfIntersection, fixShape, flatMap, flatten, flipFaceOrientation, flipOrientation, fontMetrics, fromBREP$1 as fromBREP, fromKernelDir, fromKernelPnt, fromKernelVec, fromNullable, fuse, fuse2D, fuseAll, fuseAllBisect, fuseBlueprints, fuseWithEvolution, gearGeometry, getActiveVoxelId, getBounds, getBounds2D, getCompSolids, getCurveType, getDisposalStats, getEdges, getFaceColor, getFaceOrigins, getFaceTags, getFaces, getFont, getHashCode, getShape as getHistoryShape, getKernel, getNurbsCurveData, getNurbsSurfaceData, getOrientation, getOrientation2D, getPerformanceStats, getShapeColor, getShapeKind, getShells, getSingleFace, getSolids, getSurfaceType, getTagMetadata, getVertices, getVoxel, getWires, guidedSweep, heal, healFace, healSolid, healWire, helix, hull, importDXF, importGLB, importIGES, importOBJ, importSTEP, importSTL, importSVG, importSVGPathD, importThreeMF, init, initFromManifold, initFromOC, initVoxel, innerWires, interpolateCurve, intersect, intersect2D, intersectBlueprints, intersectWithEvolution, invalidateShapeCache, ioNs_exports as io, ioError, is2D, is3D, isChamferRadius, isClosedWire, isCompSolid, isCompound, isDisposeRequest, isEdge, isEmpty, isEqualShape, isErr, isErrorResponse, isFace, isFilletRadius, isInitRequest, isInside2D, isLive, isManifoldShell, isNumber, isOk, isOperationRequest, isOrientedFace, isPlanarFace, isPlanarWire, isProjectionPlane, isEmpty$1 as isQueueEmpty, isSameShape, isShape1D, isShape3D, isShell, isSolid, isSuccessResponse, isValid, isValidSolid, isVertex, isWire, iterCompSolids, iterEdges, iterFaces, iterShells, iterSolids, iterTopo, iterVertices, iterWires, kernelCall, kernelCallRaw, kernelCallScoped, kernelError, line, linearPattern, loadFont, loft, loftAll, makeBaseBox, makeExternalGear, makeInternalGear, makePlane, makePlanetaryGear, makeProjectedEdges, manifoldShell, map, mapBoth, mapErr, match, measureArea, measureCurvatureAt, measureCurvatureAtMid, measureDistance, measureDistanceProps, measureLength, measureLinearProps, measureSurfaceProps, measureVolume, measureVolumeProps, measurement_exports as measurement, mesh, meshEdges, meshMultiLOD, minkowski, mirror, mirror2D, mirrorDrawing, mirrorJoin, modifiers_exports as modifiers, modifyStep, moduleInitError, multiSectionSweep, normalAt, offset, offsetFace, offsetWire2D, ok, or, orElse, organiseBlueprints, orientedFace, outerWire, patterns_exports as patterns, pendingCount, pipeline, pivotPlane, planarFace, planarWire, planetPlacements, pocket, pointOnSurface, pointsInside, polygon, polyhedron, polysideInnerRadius, polysidesBlueprint, positionOnCurve, prewarm, primitives_exports as primitives, projectEdges, projectPointOnFace, query_exports as query, queryError, rectangularPattern, registerHandler, registerKernel, registerOperation, registerShape, registerVoxel, rejectAll, removeChild, removeHolesFromFace, repairMesh, replayFrom, replayHistory, resetDisposalStats, resetPerformanceStats, resize, resolve, resolve3D, resolveDirection, resolvePlane, resolveRef, reverseCurve, revolve, roof, rotate, rotate2D, rotateDrawing, roundedRectangleBlueprint, scale, scale2D, scaleDrawing, section, sectionToFace, serializeHistory, setShapeOrigin, setTagMetadata, sewShells, shape, shapeType, sharedEdges, shell, shellWithEvolution, simplify, sketchCircle, sketchEllipse, sketchExtrude, sketchFace, sketchFaceOffset, sketchHelix, sketchLoft, sketchOnFace2D, sketchOnPlane2D, sketchParametricFunction, sketchPolysides, sketchRectangle, sketchRevolve, sketchRoundedRectangle, sketchSweep, sketchText, sketchWires, sketcherStateError, slice, solid, solidFromShell, solveAssembly, sphere, split, stepCount, stepsFrom, stretch2D, subFace, supportExtrude, supportsConstraintSketch, supportsProjection, surfaceFromGrid, surfaceFromImage, sweep, tagFaces, tangentArc, tap, tapErr, textBlueprints, textMetrics, thicken, threePointArc, toBREP, toBufferGeometryData, toGroupedBufferGeometryData, toKernelVec, toLODGeometryData, toLineGeometryData, toSVGPathD, toVec2, toVec3, torus, transformCopy, transforms_exports as transforms, translate, translate2D, translateDrawing, translatePlane, tryCatch, tryCatchAsync, twistExtrude, typeCastError, undoLast, unsupportedError, unwrap, unwrapErr, unwrapOr, unwrapOrElse, updateNode, updateRoles, uvBounds, uvCoordinates, validSolid, validatePlanetary, validationError, variableFillet, vecAdd, vecAngle, vecCross, vecDistance, vecDot, vecEquals, vecIsZero, vecLength, vecLengthSq, vecNegate, vecNormalize, vecProjectToPlane, vecRepr, vecRotate, vecScale, vecSub, vertex, vertexFinder, vertexPosition, verticesOfEdge, walkAssembly, windingNumbers, wire, wireFinder, wireLoop, wiresOfFace, withKernel, withKernelDir, withKernelPnt, withKernelVec, withScope, withScopeResult, withScopeResultAsync, zip as zipResults };
5399
+ export { BaseSketcher2d, BlueprintSketcher, BrepBugError, BrepErrorCode, BrepWrapperError, BrepkitAdapter, CompoundSketch, DEG2RAD, DisposalScope, FaceSketcher, HASH_CODE_MAX, OK, OcctWasmAdapter, RAD2DEG, Sketch, Sketcher, Sketches, addChild, addHoles, addMate, addStep, adjacentFaces, all, andThen, applyGlue, applyMatrix, approximateCurve, as2D, as3D, asTopo, assignRoles, autoHeal, bezier, blueprintToDXF, booleanPipeline, booleans_exports as booleans, boss, box, bsplineApprox, bug, cameraFromPlane, cameraLookAt, captureHint, cast, castShape, castShape3D, chamfer, chamferDistAngle as chamferDistAngleShape, chamferWithEvolution, checkAllInterferences, checkBoolean, checkInterference, circle, circularPattern, classifyPointOnFace, clearMeshCache, clone, closedWire, collect, collectShapes, colorFaces, colorShape, complexExtrude, composeTransforms, compound, compoundSketchExtrude, compoundSketchFace, compoundSketchLoft, compoundSketchRevolve, computationError, computeStraightSkeleton, cone, construction_exports as construction, convexHull, cornerFinder, countNodes, createAssembly, createAssemblyNode, createBlueprint, createCamera, createCompound, createCompoundBlueprint, createDistanceQuery, createEdge, createFace, createHandle, createHistory, createKernelHandle, createMeshCache, createNamedPlane, createOperationRegistry, createPlane, createRef, createRegistry, createShell, createSolid, createTaskQueue, createVertex, createWire, createWorkerClient, createWorkerHandler, csg_exports as csg, curve2dBoundingBox, curve2dDistanceFrom, curve2dFirstPoint, curve2dIsOnCurve, curve2dLastPoint, curve2dParameter, curve2dSplitAt, curve2dTangentAt, curveEndPoint, curveIsClosed, curveIsPeriodic, curveLength, curvePeriod, curvePointAt, curveStartPoint, curveTangentAt, cut, cut2D, cutAll, cutAllBisect, cutBlueprints, cutWithEvolution, cylinder, defaultScorer, dequeueTask, describe, deserializeDrawing, deserializeHistory, fromBREP as deserializeShape, downcast, draft, draw, drawCircle, drawEllipse, drawFaceOutline, drawParametricFunction, drawPointsInterpolation, drawPolysides, drawProjection, drawRectangle, drawRoundedRectangle, drawSingleCircle, drawSingleEllipse, drawText, drawingChamfer, drawingCut, drawingFillet, drawingFuse, drawingIntersect, drawingToSketchOnPlane, drill, edgeFinder, edgesOfFace, ellipse, ellipseArc, ellipsoid, enqueueTask, err, exportAssemblySTEP, exportDXF, exportGlb, exportGltf, exportIGES, exportOBJ, exportSTEP, exportSTEPConfigured, exportSTL, exportThreeMF, extrude, extrudeAll, face, faceCenter, faceFinder, faceGeomType, faceOrientation, facesOfEdge, fill, filledFace, fillet, filletWithEvolution, findFacesByTag, findNode, findStep, fixSelfIntersection, fixShape, flatMap, flatten, flipFaceOrientation, flipOrientation, fontMetrics, fromBREP$1 as fromBREP, fromKernelDir, fromKernelPnt, fromKernelVec, fromNullable, fuse, fuse2D, fuseAll, fuseAllBisect, fuseBlueprints, fuseWithEvolution, gearGeometry, getActiveVoxelId, getBounds, getBounds2D, getCompSolids, getCurveType, getDisposalStats, getEdges, getFaceColor, getFaceOrigins, getFaceTags, getFaces, getFont, getHashCode, getShape as getHistoryShape, getKernel, getNurbsCurveData, getNurbsSurfaceData, getOrientation, getOrientation2D, getPerformanceStats, getShapeColor, getShapeKind, getShells, getSingleFace, getSolids, getSurfaceType, getTagMetadata, getVertices, getVoxel, getWires, guidedSweep, heal, healFace, healSolid, healWire, helix, hull, importDXF, importGLB, importIGES, importOBJ, importSTEP, importSTL, importSVG, importSVGPathD, importThreeMF, init, initFromManifold, initFromOC, initVoxel, innerWires, interpolateCurve, intersect, intersect2D, intersectBlueprints, intersectWithEvolution, invalidateShapeCache, ioNs_exports as io, ioError, is2D, is3D, isChamferRadius, isClosedWire, isCompSolid, isCompound, isDisposeRequest, isEdge, isEmpty, isEqualShape, isErr, isErrorResponse, isFace, isFilletRadius, isInitRequest, isInside2D, isLive, isManifoldShell, isNumber, isOk, isOperationRequest, isOrientedFace, isPlanarFace, isPlanarWire, isProjectionPlane, isEmpty$1 as isQueueEmpty, isSameShape, isShape1D, isShape3D, isShell, isSolid, isSuccessResponse, isValid, isValidSolid, isVertex, isWire, iterCompSolids, iterEdges, iterFaces, iterShells, iterSolids, iterTopo, iterVertices, iterWires, kernelCall, kernelCallRaw, kernelCallScoped, kernelError, latticeInfill, line, linearPattern, loadFont, loft, loftAll, makeBaseBox, makeExternalGear, makeInternalGear, makePlane, makePlanetaryGear, makeProjectedEdges, manifoldShell, map, mapBoth, mapErr, match, measureArea, measureCurvatureAt, measureCurvatureAtMid, measureDistance, measureDistanceProps, measureLength, measureLinearProps, measureSurfaceProps, measureVolume, measureVolumeProps, measurement_exports as measurement, mesh, meshEdges, meshMultiLOD, minkowski, mirror, mirror2D, mirrorDrawing, mirrorJoin, modifiers_exports as modifiers, modifyStep, moduleInitError, multiSectionSweep, normalAt, offset, offsetFace, offsetWire2D, ok, or, orElse, organiseBlueprints, orientedFace, outerWire, patterns_exports as patterns, pendingCount, pipeline, pivotPlane, planarFace, planarWire, planetPlacements, pocket, pointOnSurface, pointsInside, polygon, polyhedron, polysideInnerRadius, polysidesBlueprint, positionOnCurve, prewarm, primitives_exports as primitives, projectEdges, projectPointOnFace, query_exports as query, queryError, rectangularPattern, registerHandler, registerKernel, registerOperation, registerShape, registerVoxel, rejectAll, removeChild, removeHolesFromFace, repairMesh, replayFrom, replayHistory, resetDisposalStats, resetPerformanceStats, resize, resolve, resolve3D, resolveDirection, resolvePlane, resolveRef, reverseCurve, revolve, roof, rotate, rotate2D, rotateDrawing, roundedRectangleBlueprint, scale, scale2D, scaleDrawing, section, sectionToFace, serializeHistory, setShapeOrigin, setTagMetadata, sewShells, shape, shapeType, sharedEdges, shell, shellWithEvolution, simplify, sketchCircle, sketchEllipse, sketchExtrude, sketchFace, sketchFaceOffset, sketchHelix, sketchLoft, sketchOnFace2D, sketchOnPlane2D, sketchParametricFunction, sketchPolysides, sketchRectangle, sketchRevolve, sketchRoundedRectangle, sketchSweep, sketchText, sketchWires, sketcherStateError, slice, solid, solidFromShell, solveAssembly, sphere, split, stepCount, stepsFrom, stretch2D, subFace, supportExtrude, supportsConstraintSketch, supportsProjection, surfaceFromGrid, surfaceFromImage, sweep, tagFaces, tangentArc, tap, tapErr, textBlueprints, textMetrics, thicken, threePointArc, toBREP, toBufferGeometryData, toGroupedBufferGeometryData, toKernelVec, toLODGeometryData, toLineGeometryData, toSVGPathD, toVec2, toVec3, torus, tpmsLattice, transformCopy, transforms_exports as transforms, translate, translate2D, translateDrawing, translatePlane, tryCatch, tryCatchAsync, twistExtrude, typeCastError, undoLast, unsupportedError, unwrap, unwrapErr, unwrapOr, unwrapOrElse, updateNode, updateRoles, uvBounds, uvCoordinates, validSolid, validatePlanetary, validationError, variableFillet, vecAdd, vecAngle, vecCross, vecDistance, vecDot, vecEquals, vecIsZero, vecLength, vecLengthSq, vecNegate, vecNormalize, vecProjectToPlane, vecRepr, vecRotate, vecScale, vecSub, vertex, vertexFinder, vertexPosition, verticesOfEdge, walkAssembly, windingNumbers, wire, wireFinder, wireLoop, wiresOfFace, withKernel, withKernelDir, withKernelPnt, withKernelVec, withScope, withScopeResult, withScopeResultAsync, zip as zipResults };
package/dist/index.d.ts CHANGED
@@ -36,6 +36,8 @@ export { importSVGPathD, importSVG, type SVGImportOptions } from './io/svgImport
36
36
  export { exportSTEPConfigured, type StepExportOptions, type StepExportPart, } from './io/stepConfigFns.js';
37
37
  export { initVoxel, registerVoxel, getVoxel, getActiveVoxelId, windingNumbers, pointsInside, repairMesh, } from './voxel/index.js';
38
38
  export type { VoxelEngine, VoxelMeshInput, VoxelRepairResult, RepairOptions, } from './voxel/index.js';
39
+ export { latticeInfill, tpmsLattice } from './lattice/index.js';
40
+ export type { LatticeType, LatticeOptions, LatticeBounds } from './lattice/index.js';
39
41
  export { default as Sketcher } from './sketching/sketcher.js';
40
42
  export { default as FaceSketcher } from './sketching/faceSketcher.js';
41
43
  export { BaseSketcher2d } from './2d/blueprints/baseSketcher2d.js';
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Lattice / TPMS geometry domain (ADR-0013, Layer 3).
3
+ *
4
+ * Builds triangle meshes from triply-periodic minimal surfaces, either filling a
5
+ * solid (infill) or clipped to a box. Sits on the voxel domain's FWN-signed grid
6
+ * and Surface-Nets contour, surfaced through the shared voxel engine registry.
7
+ */
8
+ export { latticeInfill, tpmsLattice } from './latticeFns.js';
9
+ export type { LatticeType, LatticeOptions, LatticeBounds } from './latticeFns.js';
@@ -0,0 +1,40 @@
1
+ import { Result } from '../core/result.js';
2
+ import { KernelMeshResult } from '../kernel/types.js';
3
+ import { VoxelMeshInput } from '../voxel/signFns.js';
4
+ /** TPMS lattice families. Maps to the wasm tag (0=Gyroid, 1=SchwarzP, 2=Diamond). */
5
+ export type LatticeType = 'gyroid' | 'schwarzP' | 'diamond';
6
+ /**
7
+ * TPMS lattice tuning. `period` is the unit-cell size (world units); `thickness`
8
+ * is the strut wall width in field units. `resolution` sizes the longest bbox
9
+ * axis in voxels; `padding` is the positive air-margin ring (>= 1) Surface Nets
10
+ * needs.
11
+ */
12
+ export interface LatticeOptions {
13
+ type: LatticeType;
14
+ period: number;
15
+ thickness: number;
16
+ resolution?: number;
17
+ padding?: number;
18
+ }
19
+ /**
20
+ * Fill a solid mesh with a TPMS lattice infill: intersect the FWN-signed solid
21
+ * with the chosen lattice shell field, then Surface-Nets contour the result.
22
+ *
23
+ * Returns a {@link KernelMeshResult} in world coordinates (a single face group,
24
+ * no UVs). The TPMS field is the approximate implicit (raw trig), so the surface
25
+ * is contoured at the zero level without distance normalization (ADR-0013).
26
+ */
27
+ export declare function latticeInfill(mesh: VoxelMeshInput, opts: LatticeOptions, id?: string): Result<KernelMeshResult>;
28
+ /** Axis-aligned bounds for a clipped TPMS lattice. */
29
+ export interface LatticeBounds {
30
+ min: [number, number, number];
31
+ max: [number, number, number];
32
+ }
33
+ /**
34
+ * Contour the infinite TPMS lattice clipped to an axis-aligned box.
35
+ *
36
+ * Returns a {@link KernelMeshResult} in world coordinates (a single face group,
37
+ * no UVs). The TPMS field is the approximate implicit (raw trig), contoured at
38
+ * the zero level without distance normalization (ADR-0013).
39
+ */
40
+ export declare function tpmsLattice(bounds: LatticeBounds, opts: LatticeOptions, id?: string): Result<KernelMeshResult>;
@@ -13,6 +13,10 @@ export interface VoxelEngine {
13
13
  points_inside(verts: Float32Array, tris: Uint32Array, queries: Float32Array): Uint8Array;
14
14
  /** Voxelize-and-contour a mesh into a closed surface (FWN sign keystone). */
15
15
  repair_mesh(verts: Float32Array, tris: Uint32Array, resolution: number, padding: number): VoxelRepairResult;
16
+ /** Fill an FWN-signed solid with a TPMS lattice infill, contoured to a mesh. */
17
+ lattice_infill(verts: Float32Array, tris: Uint32Array, resolution: number, padding: number, lattice_type: number, period: number, thickness: number): VoxelRepairResult;
18
+ /** Contour the infinite TPMS lattice clipped to an axis-aligned box. */
19
+ tpms_box(min_x: number, min_y: number, min_z: number, max_x: number, max_y: number, max_z: number, resolution: number, padding: number, lattice_type: number, period: number, thickness: number): VoxelRepairResult;
16
20
  /** Engine artifact version, for loader/artifact compatibility checks. */
17
21
  version(): string;
18
22
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "brepjs",
3
- "version": "18.37.0",
3
+ "version": "18.39.0",
4
4
  "description": "Web CAD library with pluggable geometry kernel",
5
5
  "keywords": [
6
6
  "cad",
@@ -29,6 +29,7 @@
29
29
  "packages/brepjs-voxel",
30
30
  "packages/brepjs-agent",
31
31
  "packages/brepjs-viewer",
32
+ "packages/brepjs-vscode",
32
33
  "apps/playground",
33
34
  "apps/docs"
34
35
  ],