{"_id":"@archiyou/meshup","_rev":"2-ef0cb3515983522cdaf82ff646064912","name":"@archiyou/meshup","dist-tags":{"latest":"0.3.0"},"versions":{"0.2.0":{"name":"@archiyou/meshup","version":"0.2.0","keywords":["3d","mesh","csg","geometry","cad","wasm","gltf","sdf","3d-printing","nurbs"],"author":{"url":"Archiyou","name":"Mark van der Net"},"license":"Apache-2.0","_id":"@archiyou/meshup@0.2.0","maintainers":[{"name":"mvdnet","email":"info@archiyou.com"}],"homepage":"https://github.com/ArchiyouApp/meshup#readme","bugs":{"url":"https://github.com/ArchiyouApp/meshup/issues"},"dist":{"shasum":"a60a8f958ece61794cf48523ee60f0bb7ae9729a","tarball":"https://registry.npmjs.org/@archiyou/meshup/-/meshup-0.2.0.tgz","fileCount":42,"integrity":"sha512-8pk65erz385R2PMyxFRHH2uWEF19MFwE8V19xnqnbkdHfrUsjx3E/W9PQeAo89MuFLV640kmhejG9FZ/F8MJjw==","signatures":[{"sig":"MEQCIBlRwg7TuJMC0FU5iu3NnsLstUc/FkcbvnuJO+xR9PwmAiA5hCYSmTVujWDX8b6tcOIswxuGZCWfJkvdQ97U0Uk73A==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":29532759},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","engines":{"node":">=20.19"},"exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"./src/*":"./src/*.ts","./package.json":"./package.json"},"scripts":{"lint":"tsc --noEmit -p tsconfig.lint.json","test":"vitest","build":"tsup","test:run":"vitest run","build:wasm":"tsx buildscripts/build-wasm.ts","check:pack":"tsx buildscripts/check-pack.ts","rust:check":"cd ./rust && cargo check --features wasm --target wasm32-unknown-unknown","prepublishOnly":"pnpm build","check:wasm-integrity":"tsx buildscripts/check-wasm-integrity.ts"},"_npmUser":{"name":"mvdnet","email":"info@archiyou.com"},"repository":{"url":"git+https://github.com/ArchiyouApp/meshup.git","type":"git"},"_npmVersion":"10.9.4","description":"General purpose 3D mesh library with various modeling techniques (CSG, 2D, quasi-CAD) and target applications (3D printing, craft, CNC) in Typescript and powered by Rust (CSGRS). ","directories":{},"_nodeVersion":"22.22.1","dependencies":{"@gltf-transform/core":"^4.3.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"packageManager":"pnpm@10.32.1","devDependencies":{"tsx":"^4.20.0","tsup":"^8.5.1","vitest":"^4.0.15","typescript":"^5.9.3","@types/node":"^25.0.2"},"_npmOperationalInternal":{"tmp":"tmp/meshup_0.2.0_1787058440669_0.6800584294440994","host":"s3://npm-registry-packages-npm-production"}},"0.3.0":{"name":"@archiyou/meshup","version":"0.3.0","description":"General purpose 3D mesh library with various modeling techniques (CSG, 2D, quasi-CAD) and target applications (3D printing, craft, CNC) in Typescript and powered by Rust (CSGRS). ","type":"module","main":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"./package.json":"./package.json"},"keywords":["3d","mesh","csg","geometry","cad","wasm","gltf","sdf","3d-printing","nurbs"],"author":{"name":"Mark van der Net","url":"Archiyou"},"license":"Apache-2.0","repository":{"type":"git","url":"git+https://github.com/ArchiyouApp/meshup.git"},"homepage":"https://github.com/ArchiyouApp/meshup#readme","bugs":{"url":"https://github.com/ArchiyouApp/meshup/issues"},"engines":{"node":">=20.19"},"publishConfig":{"access":"public"},"devDependencies":{"@types/node":"^25.0.2","tsup":"^8.5.1","tsx":"^4.20.0","typescript":"^5.9.3","vitest":"^4.0.15"},"dependencies":{"@gltf-transform/core":"^4.3.0"},"scripts":{"build":"tsup","build:wasm":"tsx buildscripts/build-wasm.ts","rust:check":"cd ./rust && cargo check --features wasm --target wasm32-unknown-unknown","test":"vitest","test:run":"vitest run","lint":"tsc --noEmit -p tsconfig.lint.json","check:wasm-integrity":"tsx buildscripts/check-wasm-integrity.ts","check:pack":"tsx buildscripts/check-pack.ts"},"_id":"@archiyou/meshup@0.3.0","_integrity":"sha512-4ReNUQVk0FYv5mW0KQwq4BmCMUdGp3qnuPozYNQ0S69LJQG63E23mxnklchYIGRQPsRKO9B0dK527mwS4T02GQ==","_resolved":"/tmp/e69e3e9099bd3dbc422e1a3260643062/archiyou-meshup-0.3.0.tgz","_from":"file:archiyou-meshup-0.3.0.tgz","_nodeVersion":"22.22.1","_npmVersion":"10.9.4","dist":{"integrity":"sha512-4ReNUQVk0FYv5mW0KQwq4BmCMUdGp3qnuPozYNQ0S69LJQG63E23mxnklchYIGRQPsRKO9B0dK527mwS4T02GQ==","shasum":"2e05d0a6ca20a2865729f6703ce2e805e84c6471","tarball":"https://registry.npmjs.org/@archiyou/meshup/-/meshup-0.3.0.tgz","fileCount":42,"unpackedSize":29544896,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDh+05CSU3qgJlecTZxfq5ty+jL6xaeh5qRrH24wSvbnwIhANSjjNQw8Czy2iKhwBRghAlXHEqak6NVzAw6zeRvlkGw"}]},"_npmUser":{"name":"mvdnet","email":"info@archiyou.com"},"directories":{},"maintainers":[{"name":"mvdnet","email":"info@archiyou.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/meshup_0.3.0_1787165760148_0.4968444779195531"},"_hasShrinkwrap":false}},"time":{"created":"2026-08-18T13:07:20.332Z","modified":"2026-08-19T18:56:00.705Z","0.2.0":"2026-08-18T13:07:21.010Z","0.3.0":"2026-08-19T18:56:00.476Z"},"bugs":{"url":"https://github.com/ArchiyouApp/meshup/issues"},"author":{"name":"Mark van der Net","url":"Archiyou"},"license":"Apache-2.0","homepage":"https://github.com/ArchiyouApp/meshup#readme","keywords":["3d","mesh","csg","geometry","cad","wasm","gltf","sdf","3d-printing","nurbs"],"repository":{"type":"git","url":"git+https://github.com/ArchiyouApp/meshup.git"},"description":"General purpose 3D mesh library with various modeling techniques (CSG, 2D, quasi-CAD) and target applications (3D printing, craft, CNC) in Typescript and powered by Rust (CSGRS). ","maintainers":[{"name":"mvdnet","email":"info@archiyou.com"}],"readme":"# Meshup (`@archiyou/meshup`)\n\n[![License](https://img.shields.io/github/license/ArchiyouApp/meshup)](https://github.com/ArchiyouApp/meshup/blob/main/LICENSE) [![CI](https://github.com/ArchiyouApp/meshup/actions/workflows/ci.yml/badge.svg)](https://github.com/ArchiyouApp/meshup/actions/workflows/ci.yml) [![npm version](https://img.shields.io/npm/v/@archiyou/meshup.svg)](https://www.npmjs.com/package/@archiyou/meshup)\n\n<img width=\"50%\" src=\"./assets/meshup_archiyou_ani.gif\">\n\nA general-purpose 3D mesh/curve modeling library for TypeScript, powered by a Rust/WASM\nkernel (a fork of [csgrs](https://github.com/timschmidt/csgrs), vendored in `rust/`, in process of rebasing). It combines CSG\n(constructive solid geometry), quasi-CAD curve/sketch tooling, and mesh utilities behind a\nfluent, chainable JS API — built as the modeling kernel for\n[Archiyou](https://archiyou.com) Script CAD, but usable standalone in Node or the browser.\n\n\n## Features\n\n- **Shapes**: `Mesh` (solids: cube, sphere, cylinder, custom polygons/points, SDF) and\n  `Curve` (2D/3D: lines, polylines, arcs, circles, ellipses/elliptical arcs, rectangles,\n  interpolated splines, compounds) as first-class, chainable objects.\n- **CSG booleans**: `union`, `difference`/`subtract`, `intersection`, `split` on meshes; exact 2D\n  boolean ops on curves — arcs and lines are preserved rather than tessellated. Curve\n  booleans require both curves to be closed and coplanar; a failure warns and returns\n  `null` (there is no tessellated fallback).\n- **Corner operations**: `fillet`/`chamfer` on every corner or only selected ones\n  (`curve.fillet(5, 0)`, `curve.fillet(5, [10, 10, 0])`, `curve.fillet(5, 'vertex<<->[0,0,0]')`).\n- **Edges & selection**: `mesh.edges()` returns deduplicated model edges grouped into\n  `boundary` / `crease` / `flat`, and `mesh.select()` / `collection.select()` can query them\n  (`'edge|z'`, `'edge<<->[0,0,0]'`).\n- **Transforms & alignment**: move/rotate/mirror/scale, `alignByPoints`, `rotateSwing`,\n  bounding boxes (`Bbox`, oriented `OBbox`), replication (`replicate`, `row`, grids).\n- **Sketch & text**: 2D sketch primitives, TrueType and Hershey stroke-font text\n  (`Sketch.textOutline/textSolid/textStroke`).\n- **2D projection & drawings**: `ShapeCollection.isometry()`, `elevation()` and `section()`\n  turn 3D models into line work, with switchable hidden-line removal (`'exact'` (default),\n  `'raycast'`, `'clip'`, `'painter'`) — `isometry([-1,-1,1], 'exact', { hiddenLines: true })`.\n- **Styling**: per-shape `Style` (color, opacity, stroke width/dash/cap/join, point\n  markers, PBR materials) that flows through to exported geometry.\n- **Scene graph**: `SceneNode` hierarchy with layers, named lookup (`find`/`findAll`),\n  active-layer tracking, and cascading style.\n- **Export**: glTF/GLB via `GLTFBuilder`/`SceneNode.toGLTF()`/`toGLB()`, including custom\n  extensions for line style, point style, and edge visibility; SVG for 2D line work\n  (`ShapeCollection.toSVG()`, `SceneNode.toSVG()`); STL via\n  `Mesh.toSTLBinary()`/`toSTLAscii()`.\n- **Import**: `Importer`/static `from*` factories for SVG, GeoJSON, DXF (2D curves), and\n  OBJ, STL, glTF/GLB, AMF, 3MF (meshes) — auto-detected via `Importer.load()`.\n\n## Installation\n\n```bash\npnpm add @archiyou/meshup\n# or: npm install @archiyou/meshup / yarn add @archiyou/meshup\n```\n## Usage\n\nMeshup loads its WASM kernel asynchronously. Call `init()` once before using any shape\nclasses:\n\n```ts\nimport { init, Mesh, Curve, Point } from '@archiyou/meshup';\n\nawait init();\n\nconst box = Mesh.Cube(10).moveTo([0, 0, 5]).color('blue');\nconst hole = Mesh.Cylinder(3, 20).moveTo([0, 0, 5]);\n\nconst result = box.difference(hole);\n\nconst glb = await result.toGLB(); // Uint8Array, ready to save or stream\n```\n\n### Node.js\n\n```ts\nimport { init, Mesh } from '@archiyou/meshup';\nimport { writeFileSync } from 'node:fs';\n\nawait init();\nconst mesh = Mesh.Sphere(10);\nwriteFileSync('sphere.glb', await mesh.toGLB());\n```\n\n### Browser\n\n```html\n<script type=\"module\">\n  import { init, Mesh } from 'https://esm.sh/@archiyou/meshup';\n\n  await init();\n  const mesh = Mesh.Cylinder(5, 10).color('red');\n  const glb = await mesh.toGLB(); // feed into three.js / Babylon.js GLTFLoader\n</script>\n```\n\nA CDN like esm.sh serves the `.wasm` alongside the JS, so this streams the binary. Where it\ncan't be fetched, the embedded base64 takes over — either way there is no `.wasm` MIME type\nor asset copying to configure.\n\n## Examples\n\n### Curves\n\n<img width=\"40%\" align=\"right\" src=\"./assets/meshup_curves.png\">\n\n```ts\nimport { initAsync, Curve } from '@archiyou/meshup';\n\n// Load kernel\nawait initAsync();   \n\nconst r1 = Curve.Rect(100, 300)\n    .color('blue')\n    .strokeWidth(2);\n\nconst r2 = Curve.Rect(200, 40)\n    .move(100)\n    .color('green')\n    .strokeWidth(2);\n\nconst r1f = r1.copy().moveZ(-50)\n    .fillet(20)!\n    .color('gray');\n\nconst offsets = r1f.copy().replicate(10,\n    (r, i) =>\n        r.offset(10 * i)!\n            .alpha(1 - i * 0.1)\n            .strokeWidth(2 - i * 0.2));\n\nconst r12u = (r1.copy().union(r2) as Curve).moveZ(100);\nconst r12s = (r1.copy().subtract(r2) as Curve)\n              .moveZ(200).color('gray');\nconst r12sf = r12s.copy().fillet(10)!.moveZ(50);\n\nconst c = Curve.Circle(50).align(r2, 'center', 'right')\n    .color('orange').strokeWidth(2);\n\nconst csub = (c.copy().subtract(r2) as Curve).moveZ(150);\n\n// output\nconst all = new ShapeCollection(r1, r2, r1f, offsets,\n           r12u, r12s, r12sf, c, csub);\nconst gltf = await all.toGLTF(); // or all.toSVG()\n// write bytes to file or send to a viewer\n```\n\n### Meshes\n\n<img width=\"40%\" align=\"right\" src=\"./assets/meshup_solids.png\">\n\n```ts\n\nimport { initAsync, Mesh, \n      Polygon, ShapeCollection } \n  from '@archiyou/meshup';\n\nawait initAsync();\n\n// boxes\nconst bx1 = Mesh.Box(50).color('blue');\nconst bx2 = Mesh.Box(50, 40, 100)\n              .move(100).color('blue');\nconst bx3 = Mesh.BoxBetween(\n                [170, 50, 0], [220, -30, 40])\n              .color('blue');\nconst bx4 = Mesh.BoxBetween(\n              [250, 0, 0], [280, 10, 200])\n                .color('blue');\n\n// others\nconst sph = Mesh.Sphere(30)\n              .move(0, -150).color('red');\nconst pl = Polygon.planeBetween(\n          [50, 0, 0], [120, 30, 0])\n    .moveY(-150).color('red');\nconst extr = pl.copy().extrude(30).color('red');\nconst extr2 = pl.move(100)\n              .extrude(50, [1, 1, 1]).color('red');\n\n// aligning\nconst stack0 = bx1.copy().move(400)\n    .color('green');\n    \nconst stack1 = bx3.copy()\n    // align to, pivot and place at other\n    .align(stack0, 'centerbottom', 'centertop')   \n    .color('purple');\nconst stack2 = sph.copy()\n    .align(stack1, 'frontbottom', 'fronttop')\n    .color('red');\nconst stack3 = extr2.copy()\n    .align(stack2, 'frontleftbottom', 'top')\n    .color('black');\n\n// booleans\nconst boolbox = bx2.copy().moveTo(600)\n    .subtract(sph.copy().moveTo(600)) as Mesh;\n\nboolbox.subtract(\n    Mesh.Box(40).align(\n        boolbox.select('V||topfrontright'),\n        'center',\n        'center')\n).union(\n    Mesh.Box(20, 20, 40).align(\n        boolbox.select('V||topbackleft'),\n        'center',\n        'center')\n).color('purple');\n\n// gather what you want out to export\nconst all = new ShapeCollection(bx1, bx2, bx3, \n              bx4, sph, extr, extr2,\n              stack0, stack1, stack2, stack3, boolbox);\nconst glb = await all.toGLB();\n// ===> do something with the bytes\n```\n\n### Manage your scene\n\n```ts\nimport { init, Mesh, SceneNode } from '@archiyou/meshup';\n\nawait init();\n\nconst scene = SceneNode.root();\nscene.addLayer('walls', Mesh.Cube(100));\nscene.addLayer('roof', Mesh.Cylinder(50, 20).moveToZ(100));\n\nconst glb = await scene.toGLB();\n```\n\n## More examples\n\nCheck tests/examples.\n\n\n### WASM hints\n\nThe core of Meshup works with a WASM file; This might complicate develop and deployment. Some notes:\n\n**Automatic WASM finding and inline base64 fallback**. Meshup tries to find .wasm automatically. Most bundlers detect it and make it work for you. If it fails, the WASM is loaded from a internal base64 string. Because base64 (~8mb) encoding is bigger make sure you fix the WASM file (~6mb) before using in production.\n\n**Manually point to WASM file** `init()` accepts anything wasm-bindgen does — a URL, a `Response`, raw bytes or a compiled `WebAssembly.Module`. Supplying one **disables the fallback**: a wrong source fails loudly\ninstead of quietly costing a 7.8 MB base64 download.\n\n```ts\nawait init({ wasm: 'https://cdn.example.com/meshup_bg.wasm' }); // your own hosting\n```\n\n**For Vite users:** if you install meshup from npm (rather than linking it in a workspace),\nVite's dependency pre-bundling copies the module into `node_modules/.vite/deps/` and the\n`.wasm` no longer sits beside it, so dev mode logs a 404 and falls back to base64. Builds\nare unaffected. To keep the file path in dev too:\n\n```ts\n// vite.config.ts\nexport default { optimizeDeps: { exclude: ['@archiyou/meshup'] } };\n```\n\n\n\n## Known limitations\n\nThings are the radar:\n\n- `Polygon.offset()` and holes\n- `ShapeCollection.offset()` only offsets `Curve`\n- `Sketch.loft()` does not work\n-  no PLY import yet\n- `Mesh.edges()` classifies an edge by the angle between adjacent face normals, so a\n  smooth-shaded curved surface (sphere, cylinder wall) yields many near-coplanar edges.\n  Raise `featureAngle` to thin them out.\n\n## Development\n\nThe Rust kernel lives in `rust/` (a fork of csgrs). It pulls in five git submodules —\n`rust/hypercurve`, `rust/hyperreal`, `rust/hypersolve`, `rust/hyperlattice`,\n`rust/hyperlimit`. `hypercurve` is a path dependency of the `rust/` crate; the other four\nare wired up by the root `Cargo.toml` via `[patch.crates-io]`. Either way a non-recursive\nclone cannot build the WASM.\n\nBoth generated artifacts (`src/wasm/` and the base64 blob `src/meshup-js-binary.ts`) are\ncommitted, so **you only need the Rust toolchain if you change Rust code**.\n\n```bash\n# clone including the Rust submodules\ngit clone --recursive https://github.com/ArchiyouApp/meshup\n# (already cloned? git submodule update --init --recursive)\n\n# install JS/TS dependencies\npnpm install\n\n# Rust toolchain, for building the WASM kernel: https://rustup.rs/\ncargo install wasm-pack\n\n# quick Rust sanity check\npnpm rust:check\n# build the WASM kernel + regenerate the embedded base64 binary\npnpm build:wasm\n\n# build the TS package\npnpm build\n\n# run tests\npnpm test        # watch mode\npnpm test:run    # single run\n\n# type-check\npnpm lint\n\n# release gates (also run in CI)\npnpm check:wasm-integrity   # base64 blob matches src/wasm/meshup_bg.wasm\npnpm check:pack             # the tarball contains exactly what it should\n```\n\nNever hand-roll `wasm-pack`/`cargo build` invocations for the WASM output — always use\n`pnpm build:wasm` (see `AGENTS.md`), so the generated bindings and embedded binary stay in\nsync with the TS side. That script also strips wasm-pack scaffolding that would otherwise\nbreak the published package, so bypassing it will produce a broken tarball.\n\n## License\n\nApache-2.0 — see [LICENSE](./LICENSE).\n\nThe Rust kernel this package compiles to WebAssembly is a fork of\n[csgrs](https://github.com/timschmidt/csgrs) (MIT, © Timothy Schmidt, deriving from csg.js\n© Evan Wallace). That MIT-licensed code is part of the published bundle, so its notice\ntravels with this package: see [NOTICE](./NOTICE) and\n[THIRD-PARTY-NOTICES.txt](./THIRD-PARTY-NOTICES.txt).\n","readmeFilename":"README.md"}