@nativecad/kernel
v0.2.0
Published
Zero-dependency JavaScript solid-modeling kernel: STEP AP242 read/write, B-rep feature ops (extrude, revolve, loft, shell, holes, fillets, chamfers, booleans, patterns), watertight surface tessellation, constrained-Delaunay volume meshing, CAE export (Nas
Downloads
110
Maintainers
Readme
@nativecad/kernel
Renamed in 0.2.0 — this package was published as
@cadsolver/kernel. NativeCAD (formerly CADSolver) is the same code under a new name; the repository URL is unchanged.
Zero-dependency JavaScript solid-modeling kernel. STEP AP242 read/write, B-rep
feature operations (extrude, revolve, loft, shell, manufacturing holes,
fillets, chamfers, booleans (including selective/partial booleans with cell
decomposition), patterns), watertight surface tessellation,
constrained-Delaunay volume meshing, CAE export (Nastran / Abaqus / VTK), and
mass properties. No WASM, no native binaries, no third-party geometry kernels
— npm install and you are modeling, versus the request-an-evaluation sales
cycle of traditional CAD SDKs.
For rendering in a page, use @nativecad/viewer
— it bundles the browser build of this kernel plus a drop-in three.js viewer
component. This package is the Node/server-side surface.
Install
npm install @nativecad/kernelQuickstart — STEP file to mesh
const cad = require('@nativecad/kernel'); // or: import cad from '@nativecad/kernel'
const res = cad.solveStepFile('part.step', { targetCount: 20000 });
// res.mesh = { vertices, indices, normals, lineIndices, triangleFaceIds }
// res.stats = { vertices, triangles, faces, solids }
console.log(res.stats);
const props = cad.MassProperties.compute(res.mesh); // volume, centroid, inertiaBuild a part from code
const cad = require('@nativecad/kernel');
const { parser, solidId } = cad.ops.primitives.box(40, 20, 10);
cad.ops.blend.blendConvexEdges(parser, solidId, { radius: 2 });
const stepText = cad.writeStep(parser); // STEP AP242 outOr drive it with a declarative JSON command document (the same format the CADSolver viewer's AI panel executes):
const doc = {
version: 1,
ops: [
{ op: 'box', id: 'block', dx: 40, dy: 20, dz: 10 },
{ op: 'blend', of: 'block', radius: 2 },
{ op: 'save', path: 'out/block.step' },
],
};
const check = cad.commands.validate(doc); // { valid, errors }
if (check.valid) cad.commands.run(doc);Volume meshing + CAE export
const cad = require('@nativecad/kernel');
const res = cad.solveStepFile('bracket.step');
const mesher = new cad.VolumeMesher();
const tets = mesher.mesh(res.mesh); // constrained-Delaunay tets
const deck = cad.CaeExporter.toNastran(tets); // or toAbaqus / toVtkAPI surface
Everything on the package export is supported; see index.d.ts for the typed
surface. Highlights: solveStep / solveStepFile / solveStl / writeStep
(pipeline), StepParser / StepWriter / SurfaceTessellator / Topology
(core classes), ops.* (feature operations), commands.* (JSON command
layer), sketch.* (2D sketch + constraint solver), MassProperties,
GeometryStats, VolumeMesher, CaeExporter.
ops.boolean includes the CADSF-236 selective/partial boolean + cell
decomposition entry points (decomposeCells, selectiveBoolean,
selectiveBooleanStage2) alongside the classic subtract/union/
intersect — see the repo's docs/SELECTIVE_BOOLEAN.md.
ops/offset.js's general body offset (CADSF-262) is aggregated as
ops.offset (offsetBody(parser, solidId, distance, opts) — uniform or,
via opts.faceDistances, per-face variable; see the source header for the
sign convention and the local/convexTrim construction paths). It is not yet
a JSON command-document op (commands.run) — only the JS ops.* entry
point reaches it today (CADSB-302).
Logging: the kernel is quiet by default as a library (CADSOLVER_QUIET=1);
set CADSOLVER_LOG=1 for the diagnostics log. Every solve also returns its
provenance lines in res.log.
Versioning
0.x: minor versions may include breaking changes to the deeper B-rep
machinery; the pipeline surface (solveStep*, writeStep, mesh payload
shape) is stable. From 1.0.0, standard semver.
License
Dual-licensed: free for evaluation, personal, academic, and other non-commercial use; any commercial use requires a paid license — see LICENSE and COMMERCIAL.md (Indie $999/yr if you ship software or $490/yr if you ship hardware, Team $1,900/yr, OEM from $9,500/yr — flat, published, royalty-free). Automatic Support — agent-answered, 24/7/365 — is $499/yr on any plan.
