@nativecad/viewer
v0.2.0
Published
Drop-in browser CAD viewer: the zero-dependency NativeCAD (formerly CADSolver) STEP/STL kernel bundled with a three.js viewer component. One import, no WASM, no server round-trips.
Maintainers
Readme
@nativecad/viewer
Renamed in 0.2.0 — this package was published as
@cadsolver/viewer. NativeCAD (formerly CADSolver) is the same code under a new name; the repository URL is unchanged.
Drop-in browser CAD viewer: the zero-dependency CADSolver STEP/STL kernel bundled with a three.js viewer component. Parse, tessellate, and render CAD files entirely client-side — no WASM, no native binaries, no server round-trips.
The kernel is bundled in (~135 KB gzipped); the only peer dependency is
three (>= 0.150), resolved by your bundler.
Install
npm install @nativecad/viewer threeQuickstart
import { createViewer } from '@nativecad/viewer';
const viewer = createViewer(document.getElementById('viewport'));
// from an <input type=file>
fileInput.addEventListener('change', async (e) => {
const res = await viewer.loadFile(e.target.files[0]); // .step/.stp/.stl
console.log(res.stats); // { vertices, triangles, faces, solids }
});
// or from STEP text you already have
viewer.loadStep(stepText);createViewer sets up the scene, camera, lights, orbit controls, and resize
handling; loadStep/loadStl/loadFile run the kernel and display the mesh
with B-rep feature edges. Escape hatches (viewer.scene, .camera,
.renderer, .controls, .kernel) expose the underlying three.js objects
and the full kernel API (headless solves, the modeling API, STEP save).
Options
createViewer(el, {
background: 0x1a1d21, // scene background
meshColor: 0x3498db, // model color
edgeColor: 0x0a0e12, // feature-edge color
showEdges: true, // draw B-rep feature edges
antialias: true,
targetCount: null, // approximate triangle budget
heal: false, // geometry healing during tessellation
});Script-tag usage (no bundler)
The package also ships the classic IIFE kernel bundle at
@nativecad/viewer/cad-bundle.js — one <script> tag exposing
window.CADSolverBundle (solveStep, solveStl, saveStep, …). Pair it
with your own three.js exactly as in the
embedding guide.
License key
The free tier renders a small "Powered by CADSolver" watermark (plus a one-time console notice). A commercial license key removes it:
const viewer = createViewer(el, { licenseKey: 'CSLV1-…' });
// or later:
viewer.setLicenseKey('CSLV1-…'); // { valid, licensee, tier }
viewer.licenseStatus(); // { licensed, licensee, tier, … }Validation is fully offline — no phone-home, and the kernel is fully functional either way (Indie-tier attribution is required by the license terms anyway; the watermark simply is that attribution).
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.
