{"_id":"@cadbuildr/cad-kernel-r3f","_rev":"3-eed9db30186ef415c2e237bab658e358","name":"@cadbuildr/cad-kernel-r3f","dist-tags":{"latest":"0.2.0"},"versions":{"0.1.0":{"name":"@cadbuildr/cad-kernel-r3f","version":"0.1.0","keywords":["cad","threejs","react-three-fiber","stl","viewer"],"license":"MIT","_id":"@cadbuildr/cad-kernel-r3f@0.1.0","maintainers":[{"name":"clemcadbuildr","email":"clement@cadbuildr.com"}],"homepage":"https://github.com/cadbuildr/cad-kernel-r3f#readme","bugs":{"url":"https://github.com/cadbuildr/cad-kernel-r3f/issues"},"dist":{"shasum":"b4985f18be50f10ff5b1bf1f18b20bb20e5f89e6","tarball":"https://registry.npmjs.org/@cadbuildr/cad-kernel-r3f/-/cad-kernel-r3f-0.1.0.tgz","fileCount":30,"integrity":"sha512-adz9Xn6YPcvK02WkStnZCcsUx9zWLMJlPdeEPpJECwx7Lj5zFR7qDfOKzb8r16RQnZ8Id+jZmzt4rLuxnfKUMw==","signatures":[{"sig":"MEQCIE2hurovO5vM6vWGiPQEEj3o5RZWFbTUzaOeiv59AnqVAiBmBhoF/w1X54kImKN+FrX6K70NerughpLVyNFwcDrm9Q==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":38975},"main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"test":"jest","build":"tsc","type-check":"tsc --noEmit","prepublishOnly":"npm run build"},"_npmUser":{"name":"clemcadbuildr","email":"clement@cadbuildr.com"},"repository":{"url":"git+https://github.com/cadbuildr/cad-kernel-r3f.git","type":"git"},"_npmVersion":"11.3.0","description":"Render CAD DAGs in React Three Fiber through kernel-api STL output","directories":{},"sideEffects":false,"_nodeVersion":"24.1.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","react":"^19.0.0","three":"^0.169.0","ts-jest":"^29.2.5","typescript":"^5.7.2","@types/jest":"^29.5.14","@types/node":"^22.10.0","@types/react":"^19.0.0","@types/three":"^0.169.0"},"peerDependencies":{"react":">=18.0.0","three":">=0.169.0","@react-three/fiber":">=9.0.0"},"_npmOperationalInternal":{"tmp":"tmp/cad-kernel-r3f_0.1.0_1775950391658_0.5779549671426609","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@cadbuildr/cad-kernel-r3f","version":"0.1.1","keywords":["cad","threejs","react-three-fiber","stl","viewer"],"license":"MIT","_id":"@cadbuildr/cad-kernel-r3f@0.1.1","maintainers":[{"name":"clemcadbuildr","email":"clement@cadbuildr.com"}],"homepage":"https://github.com/cadbuildr/cad-kernel-r3f#readme","bugs":{"url":"https://github.com/cadbuildr/cad-kernel-r3f/issues"},"dist":{"shasum":"7b93f5e27d692aeecc99dcd355a8f553a0caa68e","tarball":"https://registry.npmjs.org/@cadbuildr/cad-kernel-r3f/-/cad-kernel-r3f-0.1.1.tgz","fileCount":30,"integrity":"sha512-/bxFm6rZst6ZH50WgnarpuoDJEa2dxAhc4jSNRZjEN88o+seDzDUuViFNETivS4vhjwfSiiSgXJG4Wra+h8+ZA==","signatures":[{"sig":"MEUCIQDGe8OYjgfjbaqBmruWhbWUI2jz23CUPyCM8d4Tcw6itgIgAPIa+HsbW+RTQl1R+s2GISM1FfgRlQfWNVLG/wHNMxU=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":39530},"main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"test":"jest","build":"rm -f tsconfig.tsbuildinfo && tsc","prepack":"npm run build","type-check":"tsc --noEmit","prepublishOnly":"npm run build"},"_npmUser":{"name":"clemcadbuildr","email":"clement@cadbuildr.com"},"repository":{"url":"git+https://github.com/cadbuildr/cad-kernel-r3f.git","type":"git"},"_npmVersion":"11.3.0","description":"Render CAD DAGs in React Three Fiber through kernel-api STL output","directories":{},"sideEffects":false,"_nodeVersion":"24.1.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","react":"^19.0.0","three":"^0.169.0","ts-jest":"^29.2.5","typescript":"^5.7.2","@types/jest":"^29.5.14","@types/node":"^22.10.0","@types/react":"^19.0.0","@types/three":"^0.169.0"},"peerDependencies":{"react":">=18.0.0","three":">=0.169.0","@react-three/fiber":">=9.0.0"},"_npmOperationalInternal":{"tmp":"tmp/cad-kernel-r3f_0.1.1_1775951064796_0.3533247702925204","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"name":"@cadbuildr/cad-kernel-r3f","version":"0.2.0","description":"Render CAD DAGs in React Three Fiber through kernel-api STL output","main":"./dist/index.js","types":"./dist/index.d.ts","sideEffects":false,"scripts":{"build":"rm -f tsconfig.tsbuildinfo && tsc","type-check":"tsc --noEmit","test":"jest","prepack":"npm run build","prepublishOnly":"npm run build"},"keywords":["cad","threejs","react-three-fiber","stl","viewer"],"repository":{"type":"git","url":"git+https://github.com/cadbuildr/cad-kernel-r3f.git"},"license":"MIT","publishConfig":{"access":"public"},"peerDependencies":{"@react-three/fiber":">=9.0.0","react":">=18.0.0","three":">=0.169.0"},"devDependencies":{"@types/jest":"^29.5.14","@types/node":"^22.10.0","@types/react":"^19.0.0","@types/three":"^0.169.0","jest":"^29.7.0","react":"^19.0.0","three":"^0.169.0","ts-jest":"^29.2.5","typescript":"^5.7.2"},"_id":"@cadbuildr/cad-kernel-r3f@0.2.0","bugs":{"url":"https://github.com/cadbuildr/cad-kernel-r3f/issues"},"homepage":"https://github.com/cadbuildr/cad-kernel-r3f#readme","_nodeVersion":"24.1.0","_npmVersion":"11.3.0","dist":{"integrity":"sha512-ckl6f+y8AeiHAm82aMD8G9rt8zsTAoYcCsAJErgiKKNaLcrmOcAEK9dtVDFK//9zrDZLf8AfmnOD+FSwJvPBRA==","shasum":"0c9478701222db96e0bc9185e7e5e2ed604d70d6","tarball":"https://registry.npmjs.org/@cadbuildr/cad-kernel-r3f/-/cad-kernel-r3f-0.2.0.tgz","fileCount":34,"unpackedSize":46201,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDyqg9qpvbGMtrGU2ey1qVu1gQsuv4/OgYRuI97FHCaMwIhAOFkejMjyOUAPWb1KjoXZbN6RkFIiA5M22CfDMGQdUaw"}]},"_npmUser":{"name":"clemcadbuildr","email":"clement@cadbuildr.com"},"directories":{},"maintainers":[{"name":"clemcadbuildr","email":"clement@cadbuildr.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/cad-kernel-r3f_0.2.0_1779426850031_0.5346338564294428"},"_hasShrinkwrap":false}},"time":{"created":"2026-04-11T23:33:11.587Z","modified":"2026-05-22T05:14:10.282Z","0.1.0":"2026-04-11T23:33:11.794Z","0.1.1":"2026-04-11T23:44:24.958Z","0.2.0":"2026-05-22T05:14:10.183Z"},"bugs":{"url":"https://github.com/cadbuildr/cad-kernel-r3f/issues"},"license":"MIT","homepage":"https://github.com/cadbuildr/cad-kernel-r3f#readme","keywords":["cad","threejs","react-three-fiber","stl","viewer"],"repository":{"type":"git","url":"git+https://github.com/cadbuildr/cad-kernel-r3f.git"},"description":"Render CAD DAGs in React Three Fiber through kernel-api STL output","maintainers":[{"name":"clemcadbuildr","email":"clement@cadbuildr.com"}],"readme":"# cad-kernel-r3f\n\nR3F/Three.js addon to render DAG payloads by calling `kernel-api` and displaying STL meshes.\n\n## Summary\n\nThis package provides:\n\n- a typed `kernel-api` STL client (`fetchKernelStl`, `compileDagToStl`)\n- STL-to-`THREE.BufferGeometry` conversion (`createGeometryFromStlBytes`)\n- **JSON mesh helpers** for `format: \"json\"`: `createBufferGeometryFromKernelFaces`, **`getOrCreateMeshGeometryByHash`** (cache by kernel mesh `hash` for repeated parts)\n- a React hook (`useKernelStl`)\n- a ready-to-use R3F component (`KernelStlMesh`)\n\n## Install\n\n```bash\nnpm install @cadbuildr/cad-kernel-r3f\n```\n\nPeer dependencies:\n\n- `react`\n- `three`\n- `@react-three/fiber`\n\n## Quick start\n\n```tsx\nimport { Canvas } from \"@react-three/fiber\";\nimport { KernelStlMesh, createKernelApiClient } from \"@cadbuildr/cad-kernel-r3f\";\n\nconst dag = {\n  version: \"1.0\",\n  rootNodeId: \"root\",\n  DAG: {},\n  serializableNodes: {},\n};\n\nconst client = createKernelApiClient({ defaultKernel: \"replicad\" });\n\nexport function App() {\n  return (\n    <Canvas camera={{ position: [6, 5, 8], fov: 45 }}>\n      <ambientLight intensity={1.2} />\n      <directionalLight intensity={0.8} position={[10, 10, 10]} />\n      <KernelStlMesh dag={dag} client={client} color=\"#f97316\" />\n    </Canvas>\n  );\n}\n```\n\n## API\n\nAll render requests go to `https://kernel-api.cadbuildr.com` (see exported `CADBUILDR_KERNEL_API_BASE_URL`). The base URL is not configurable.\n\nApps that need **per-instance colors** call the same endpoint with `format: \"json\"`, then build meshes from `mesh.store` / `mesh.partInstances`. Use **`getOrCreateMeshGeometryByHash(hash, faces)`** so identical topologies share one `BufferGeometry`.\n\n- `fetchKernelStl(args)` -> fetches binary STL from `POST /v1/kernels/:kernel/render`\n- `compileDagToStl(args)` -> same call with normalized response shape\n- `createGeometryFromStlBytes(bytes)` -> converts binary STL to `BufferGeometry`\n- `createBufferGeometryFromKernelFaces(faces)` / `getOrCreateMeshGeometryByHash(hash, faces, options?)` -> JSON mesh faces to `BufferGeometry` (cached)\n- `clearKernelJsonMeshGeometryCache()` / `getKernelJsonMeshGeometryCacheSize()` / `configureKernelJsonMeshGeometryCache(cap)` -> cache control\n- `useKernelStl(options)` -> hook returning `{ geometry, stlBytes, isLoading, error, requestId }`\n- `KernelStlMesh` -> opinionated render component over `useKernelStl`\n\n## Development\n\n```bash\nnpm install\nnpm test\nnpm run type-check\n```\n\n## Publishing\n\nEnsure you are logged into npm with access to the `@cadbuildr` scope, then:\n\n```bash\nnpm publish --access public\n```\n\n## Browser pipeline (with cad-pyodide-runtime)\n\nA typical static app combines `@cadbuildr/cad-pyodide-runtime` (run foundation Python in Pyodide and read the DAG) with this package (post the DAG to `kernel-api` and render STL in R3F). Keep that wiring in the consuming app; this package stays focused on the kernel STL client and mesh rendering.\n\n`KernelApiClient` binds `globalThis.fetch` when calling the kernel: Pyodide replaces `fetch`, and an unbound reference would throw `Illegal invocation` in strict mode.\n","readmeFilename":"README.md"}