@barocss/cad-interop
@barocss/cad-interop bridges exact @barocss/cad B-Rep geometry and native face/curve packets into third-party WebGL/WebGPU scene graphs (Three.js, Babylon.js, Pixi3D) and binary glTF / GLB preview assets.
Use @barocss/cad-interop when your application already renders with Three.js, Babylon.js, or Pixi3D and wants to embed BaroCSS CAD's pure-TypeScript B-Rep modeling engine without replacing your existing 3D engine.
Core Capabilities
| Entry Point | Target Engine / Format | What It Provides |
|---|---|---|
@barocss/cad-interop | Engine-agnostic packets & GLB | copyCadPreviewPacket, prepareCadPreviewMesh, prepareOwnNativeFaceMesh, encodeCadPreviewGlb, encodeOwnNativeFaceMeshGlb |
@barocss/cad-interop/three | Three.js (three) | Direct BufferGeometry & scene adapters (/three-document, /three-assembly, /three-boolean-mesh, /three-uniform-curve, /qualified-body-boundary-mesh-three) |
@barocss/cad-interop/babylon | Babylon.js (@babylonjs/core) | Babylon mesh & assembly adapters (/babylon-document, /babylon-assembly, /babylon-boolean-mesh, /babylon-uniform-curve, /qualified-body-boundary-mesh-babylon) |
@barocss/cad-interop/pixi3d | Pixi3D (pixi3d) | Pixi3D mesh & document adapters (/pixi3d-document, /pixi3d-assembly, /pixi3d-boolean-mesh, /qualified-body-boundary-mesh-pixi3d) |
@barocss/cad-interop/document-glb | glTF 2.0 Binary (.glb) | Document, boolean mesh (/boolean-mesh-glb), and boolean extrusion (/boolean-extrusion-glb) GLB encoders |
@barocss/cad-interop/native | Native CAD loaders | Qualified body, native uniform curve (/native-uniform-curve), assembly (/assembly), and model-set (/model-set) loaders |
All engine peer dependencies (three, @babylonjs/core, pixi.js, pixi3d) are optional — install only the renderer your app uses.
Engine-Agnostic Packet & GLB Export
The root entry point prepares detached, bounds-verified preview meshes and encodes binary .glb buffers directly from pure TypeScript:
import {
prepareCadPreviewMesh,
encodeCadPreviewGlb,
type CadPreviewPacket,
} from '@barocss/cad-interop';
export function buildPreviewGlb(packet: CadPreviewPacket): Uint8Array {
// Validates & normalizes positions, normals, indices, and metadata
const prepared = prepareCadPreviewMesh(packet);
// Encodes a self-contained binary glTF 2.0 (.glb) buffer in memory
return encodeCadPreviewGlb(prepared);
}Cross-Format Interchange Reporting
When exporting across formats (STEP, IGES, STL, 3MF, GLB), @barocss/cad-interop and Studio attach structured interchange reports (interchange-report) declaring the exact export target, output units, body count, and any representation loss (such as analytic B-Rep surfaces approximated into triangle meshes for STL/GLB) so downstream recipients never receive silent format degradation.
Choosing Between @barocss/cad-interop and @barocss/cad-react/sdk
- Already using Three.js, Babylon.js, or Pixi3D? Use
@barocss/cad-interopadapters to mount exact BaroCSS B-Rep solids, curves, and assemblies into your existing camera, lighting, and shader pipeline. - Building a CAD viewer or product configurator in React from scratch? Use
@barocss/cad-react/sdk(<CadViewport />+<CadDrawing />) powered by BaroCSS's native WebGPU renderer and exact 2D HLR projection. - Need manufacturing exchange formats (STEP, IGES, DXF, STL)? Those live directly in
@barocss/cadExchange formats.