{"_id":"@tx-code/occt-js","_rev":"6-a21457c37ce038c39f433e73a116f361","name":"@tx-code/occt-js","dist-tags":{"latest":"0.1.7"},"versions":{"0.1.0":{"name":"@tx-code/occt-js","version":"0.1.0","keywords":["occt","opencascade","step","stp","cad","brep","wasm","webassembly","3d","mesh","triangulation"],"license":"LGPL-2.1","_id":"@tx-code/occt-js@0.1.0","maintainers":[{"name":"tang.xing1","email":"tang.xing1@outlook.com"}],"homepage":"https://github.com/tx-code/occt-js#readme","bugs":{"url":"https://github.com/tx-code/occt-js/issues"},"dist":{"shasum":"71c6af61f9ec668a8de4d36df13f194d7b2ccf75","tarball":"https://registry.npmjs.org/@tx-code/occt-js/-/occt-js-0.1.0.tgz","fileCount":6,"integrity":"sha512-ipliGWRo0lICLSuUos25xm5lTQc60wHq2nEAx2xMZ2WylH0bgLr36do+8rpe1lkS27+AMAdjirVJt5+oe4rINQ==","signatures":[{"sig":"MEQCIENJEJLv5CxY6D9tjozYjSkE70Z8J+MZf3/peW9cttsPAiAZe6NjQSDDK6T/6xAl8UxqPfloxVYq+/G+sCop4s6yQQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":9380420},"main":"dist/occt-js.js","types":"dist/occt-js.d.ts","gitHead":"04454e8ce0a6d99ddc8cd1a989ceccfa2e0460db","scripts":{"test":"node test/test_mvp_acceptance.mjs","build:wasm":"bash tools/build_wasm.sh"},"_npmUser":{"name":"tang.xing1","email":"tang.xing1@outlook.com"},"repository":{"url":"git+https://github.com/tx-code/occt-js.git","type":"git"},"_npmVersion":"11.6.2","description":"OCCT STEP import via WebAssembly — read STEP files in the browser","directories":{},"_nodeVersion":"24.12.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/occt-js_0.1.0_1774309190458_0.800787733843237","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@tx-code/occt-js","version":"0.1.1","keywords":["occt","opencascade","step","iges","igs","stp","cad","brep","wasm","webassembly","3d","mesh","triangulation"],"license":"LGPL-2.1","_id":"@tx-code/occt-js@0.1.1","maintainers":[{"name":"tang.xing1","email":"tang.xing1@outlook.com"}],"homepage":"https://github.com/tx-code/occt-js#readme","bugs":{"url":"https://github.com/tx-code/occt-js/issues"},"dist":{"shasum":"bc30c7fea23c368258a7c18e35dbb734ec790436","tarball":"https://registry.npmjs.org/@tx-code/occt-js/-/occt-js-0.1.1.tgz","fileCount":6,"integrity":"sha512-iJFm0TMp00pvGeNtqMU16SjFls9yW+ofd8BKMBYtr7q0YlEYQXZTDAqQzWMn0Ew9ub2WNTMRj7+FPc0+Rgl9gA==","signatures":[{"sig":"MEUCIQCKRhUWB8wYTAHmbO4wYJ38c5MlN8v95mdV72WrepHhpAIgTKnHUiMC2Gtqt3zbU724J5tv4Ir6RtaBAPQtbEaHKFM=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":10480903},"main":"dist/occt-js.js","types":"dist/occt-js.d.ts","gitHead":"c9f92360266fee9b16b250b1d1980967ad84944d","scripts":{"test":"node test/test_multi_format_exports.mjs && node test/test_mvp_acceptance.mjs","build:wasm":"bash tools/build_wasm.sh"},"_npmUser":{"name":"tang.xing1","email":"tang.xing1@outlook.com"},"repository":{"url":"git+https://github.com/tx-code/occt-js.git","type":"git"},"_npmVersion":"11.6.2","description":"OCCT CAD import via WebAssembly — read STEP/IGES/BREP files in the browser","directories":{},"_nodeVersion":"24.12.0","_hasShrinkwrap":false,"devDependencies":{"@playwright/test":"^1.58.2"},"_npmOperationalInternal":{"tmp":"tmp/occt-js_0.1.1_1774396526623_0.46523584127978634","host":"s3://npm-registry-packages-npm-production"}},"0.1.2":{"name":"@tx-code/occt-js","version":"0.1.2","keywords":["occt","opencascade","step","iges","igs","stp","cad","brep","wasm","webassembly","3d","mesh","triangulation"],"license":"LGPL-2.1","_id":"@tx-code/occt-js@0.1.2","maintainers":[{"name":"tang.xing1","email":"tang.xing1@outlook.com"}],"homepage":"https://github.com/tx-code/occt-js#readme","bugs":{"url":"https://github.com/tx-code/occt-js/issues"},"dist":{"shasum":"a6ab48cc2ac1af5277cbcc032ae0ea81c75354f2","tarball":"https://registry.npmjs.org/@tx-code/occt-js/-/occt-js-0.1.2.tgz","fileCount":6,"integrity":"sha512-W/NJ+FI3JtBBu0DgI4BZhmrVY4s8Tt9SkZRQkVU1UHR0M1G/YWZIaRjXaDuoSB53UMEI4W+kqIiqpjfm2aHk1Q==","signatures":[{"sig":"MEUCIFVGXEHXijp/zUCm3G69q0vayfH3uAIN5/U2SB7Fe2ofAiEA6K2pS0OqdyP5jlwZPwIbVDN9pFehWLeo7PtGX1HBhPs=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":10481245},"main":"dist/occt-js.js","types":"dist/occt-js.d.ts","gitHead":"6bb1949ce2e980a94e054e328e9f71581d3d8ad9","scripts":{"test":"node test/test_multi_format_exports.mjs && node test/test_mvp_acceptance.mjs","build:wasm":"bash tools/build_wasm.sh"},"_npmUser":{"name":"tang.xing1","email":"tang.xing1@outlook.com"},"repository":{"url":"git+https://github.com/tx-code/occt-js.git","type":"git"},"_npmVersion":"11.6.2","description":"OCCT CAD import via WebAssembly — read STEP/IGES/BREP files in the browser","directories":{},"_nodeVersion":"24.12.0","_hasShrinkwrap":false,"devDependencies":{"@playwright/test":"^1.58.2"},"_npmOperationalInternal":{"tmp":"tmp/occt-js_0.1.2_1774485618150_0.5650597657484282","host":"s3://npm-registry-packages-npm-production"}},"0.1.3":{"name":"@tx-code/occt-js","version":"0.1.3","keywords":["occt","opencascade","step","iges","igs","stp","cad","brep","wasm","webassembly","3d","mesh","triangulation"],"license":"LGPL-2.1","_id":"@tx-code/occt-js@0.1.3","maintainers":[{"name":"tang.xing1","email":"tang.xing1@outlook.com"}],"homepage":"https://github.com/tx-code/occt-js#readme","bugs":{"url":"https://github.com/tx-code/occt-js/issues"},"dist":{"shasum":"0239ab5a913e964e72a651a20390ebdc351dcae3","tarball":"https://registry.npmjs.org/@tx-code/occt-js/-/occt-js-0.1.3.tgz","fileCount":6,"integrity":"sha512-I2FmkIMHZIoF6hX22ML6F3ZjsqpIa1sip+G46bhhzTPWoy3CliVyv4TchLhTHSs2Qwy+YRK4kfa7vbvAukh84A==","signatures":[{"sig":"MEYCIQD/sUKIugR2Rp7+kz28lAbS9EvhGkALYvsXx0KdSuE4oAIhAKYtCoAQBSbTxj3CGKZqXYtYvDcZx6jwbbuUlbIXFz+m","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":10481245},"main":"dist/occt-js.js","types":"dist/occt-js.d.ts","gitHead":"f1763536806a8147a7a8f411c6d7f767cbc64e7d","scripts":{"test":"node test/test_multi_format_exports.mjs && node test/test_mvp_acceptance.mjs","build:wasm":"bash tools/build_wasm.sh"},"_npmUser":{"name":"tang.xing1","email":"tang.xing1@outlook.com"},"repository":{"url":"git+https://github.com/tx-code/occt-js.git","type":"git"},"_npmVersion":"11.6.2","description":"OCCT CAD import via WebAssembly — read STEP/IGES/BREP files in the browser","directories":{},"_nodeVersion":"24.12.0","_hasShrinkwrap":false,"devDependencies":{"@playwright/test":"^1.58.2"},"_npmOperationalInternal":{"tmp":"tmp/occt-js_0.1.3_1774528113904_0.009366285598866098","host":"s3://npm-registry-packages-npm-production"}},"0.1.4":{"name":"@tx-code/occt-js","version":"0.1.4","keywords":["occt","opencascade","step","iges","igs","stp","cad","brep","wasm","webassembly","3d","mesh","triangulation"],"license":"LGPL-2.1","_id":"@tx-code/occt-js@0.1.4","maintainers":[{"name":"tang.xing1","email":"tang.xing1@outlook.com"}],"homepage":"https://github.com/tx-code/occt-js#readme","bugs":{"url":"https://github.com/tx-code/occt-js/issues"},"dist":{"shasum":"78417534f57fe62f40d75d7da1dc018d302683cc","tarball":"https://registry.npmjs.org/@tx-code/occt-js/-/occt-js-0.1.4.tgz","fileCount":6,"integrity":"sha512-UGwMkA5op8c1d2Auw17NkoC92Ct/+60JSJnWN2xmC65ZUhYvf+NzThZ16CXycPHL8vuvWh8THJabWe1+Xsn5Tw==","signatures":[{"sig":"MEUCIQCDg8wznc2Dabu6kp36wF7u3JQjcBcpVDDCj/eYk70LAwIgXBrWhGRbYv21vf/EUePfFIoOMpIVtsAjmpWnnAPJ/Fw=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":10481230},"main":"dist/occt-js.js","types":"dist/occt-js.d.ts","gitHead":"764b26f23a1c00a46ce2f5abf08aebdf861168b0","scripts":{"test":"node test/test_multi_format_exports.mjs && node test/test_mvp_acceptance.mjs","build:wasm":"bash tools/build_wasm.sh"},"_npmUser":{"name":"tang.xing1","email":"tang.xing1@outlook.com"},"repository":{"url":"git+https://github.com/tx-code/occt-js.git","type":"git"},"_npmVersion":"11.6.2","description":"OCCT CAD import via WebAssembly — read STEP/IGES/BREP files in the browser","directories":{},"_nodeVersion":"24.12.0","_hasShrinkwrap":false,"devDependencies":{"@playwright/test":"^1.58.2"},"_npmOperationalInternal":{"tmp":"tmp/occt-js_0.1.4_1774532095430_0.9138325076770326","host":"s3://npm-registry-packages-npm-production"}},"0.1.7":{"name":"@tx-code/occt-js","version":"0.1.7","description":"OCCT CAD import via WebAssembly — read STEP/IGES/BREP files in the browser","main":"dist/occt-js.js","types":"dist/occt-js.d.ts","scripts":{"build:wasm":"bash tools/build_wasm.sh","build:wasm:win":"tools\\build_wasm_win_dist.bat","test":"node --test test/load_occt_factory.test.mjs test/wasm_build_prereqs.test.mjs && node test/test_multi_format_exports.mjs && node test/test_iges_degenerated_edges.mjs && node test/test_step_iges_root_mode.mjs && node test/test_brep_root_mode.mjs && node test/test_optimal_orientation_api.mjs && node test/test_optimal_orientation_reference.mjs && node test/test_mvp_acceptance.mjs"},"repository":{"type":"git","url":"git+https://github.com/tx-code/occt-js.git"},"license":"LGPL-2.1","keywords":["occt","opencascade","step","iges","igs","stp","cad","brep","wasm","webassembly","3d","mesh","triangulation"],"devDependencies":{"@playwright/test":"^1.58.2"},"gitHead":"bdb80fca8ece2e32dc9444fdd41607decb393d92","_id":"@tx-code/occt-js@0.1.7","bugs":{"url":"https://github.com/tx-code/occt-js/issues"},"homepage":"https://github.com/tx-code/occt-js#readme","_nodeVersion":"24.12.0","_npmVersion":"11.6.2","dist":{"integrity":"sha512-yhkAZacBIBEh+RVhvjzOMizrzYehc3aS8g2of52HZeq4k3BwjKnlXgtWd4rd+i5/xO8dos1Izu4ABYSSOYZyAQ==","shasum":"b7439ef7c1e325bdf7dc2a6c71d90429ca8fa2ae","tarball":"https://registry.npmjs.org/@tx-code/occt-js/-/occt-js-0.1.7.tgz","fileCount":6,"unpackedSize":10547511,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDpUbDqjG/sZ7aF9s6mIC4i5QCubXt89rdDQ0bQubIU/wIgIjvXHeG57/kJaAsGPG3MiZZOeSDDwtjHBV7u5bPGufc="}]},"_npmUser":{"name":"tang.xing1","email":"tang.xing1@outlook.com"},"directories":{},"maintainers":[{"name":"tang.xing1","email":"tang.xing1@outlook.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/occt-js_0.1.7_1774955328834_0.720886205454522"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-23T23:39:50.354Z","modified":"2026-03-31T11:08:49.296Z","0.1.0":"2026-03-23T23:39:50.804Z","0.1.1":"2026-03-24T23:55:27.011Z","0.1.2":"2026-03-26T00:40:18.457Z","0.1.3":"2026-03-26T12:28:34.237Z","0.1.4":"2026-03-26T13:34:55.733Z","0.1.7":"2026-03-31T11:08:49.191Z"},"bugs":{"url":"https://github.com/tx-code/occt-js/issues"},"license":"LGPL-2.1","homepage":"https://github.com/tx-code/occt-js#readme","keywords":["occt","opencascade","step","iges","igs","stp","cad","brep","wasm","webassembly","3d","mesh","triangulation"],"repository":{"type":"git","url":"git+https://github.com/tx-code/occt-js.git"},"description":"OCCT CAD import via WebAssembly — read STEP/IGES/BREP files in the browser","maintainers":[{"name":"tang.xing1","email":"tang.xing1@outlook.com"}],"readme":"# occt-js\r\n\r\nWebAssembly build of [OpenCASCADE Technology (OCCT)](https://dev.opencascade.org/) v7.9.3 for CAD import and triangulation. Designed for use in browser-based CAD viewers (e.g., Babylon.js).\r\n\r\n**[Live Demo](https://tx-code.github.io/occt-js/)** — drag and drop STEP/IGES/BREP files, face/edge/vertex picking, hover preview\r\n\r\n## Features\r\n\r\n- Import STEP / IGES / BREP files from memory (`Uint8Array`)\r\n- Full B-Rep topology output (Face/Edge/Vertex with stable IDs and adjacency)\r\n- XDE assembly tree traversal with names and per-face colors\r\n- BRepMesh triangulation with configurable deflection\r\n- Manufacturing-oriented single-part orientation analysis for STEP / IGES / BREP\r\n- Embind-based API returning a structured scene graph\r\n- Babylon.js demo with interactive face/edge/vertex selection\r\n\r\n## Prerequisites\r\n\r\n| Tool | Version |\r\n|------|---------|\r\n| Emscripten SDK | 3.1.69 |\r\n| CMake | 3.20+ |\r\n| Git | (for OCCT submodule) |\r\n\r\n## Setup\r\n\r\n```bash\r\n# Clone with submodule\r\ngit clone --recurse-submodules <repo-url>\r\ncd occt-js\r\n\r\n# If you already cloned the repo or are working in a fresh git worktree:\r\ngit submodule update --init --recursive occt\r\n\r\n# Windows: install Emscripten into build/wasm/emsdk\r\ntools\\setup_emscripten_win.bat\r\n\r\n# Linux/macOS: install Emscripten manually or use emsdk\r\n```\r\n\r\n## Build\r\n\r\n```bash\r\n# Windows\r\nnpm run build:wasm:win\r\n\r\n# Linux/macOS: activate Emscripten first, then:\r\nbash tools/build_wasm.sh\r\n```\r\n\r\nOutput files are written to `dist/`:\r\n- `occt-js.js` — ES module loader\r\n- `occt-js.wasm` — WebAssembly binary\r\n- `occt-js.d.ts` — tracked TypeScript definitions published with the package\r\n\r\nRoot tests and downstream consumers require the generated `dist/occt-js.js` and `dist/occt-js.wasm` artifacts to exist. In a clean clone or worktree, build them before running `npm test`.\r\nThe tracked `dist/occt-js.d.ts` file is not regenerated by the Wasm build and should not be deleted. If it is missing, restore it with:\r\n\r\n```bash\r\ngit restore --source=HEAD -- dist/occt-js.d.ts\r\n```\r\n\r\nThe Windows build entrypoint fails early with a clear error if either prerequisite is missing:\r\n- `occt/src/Standard` from the `occt` git submodule\r\n- `build/wasm/emsdk/emsdk_env.bat` from `tools\\setup_emscripten_win.bat`\r\n\r\nWindows build failures retain a log file at `build/wasm-build.log`. If a parallel build fails intermittently, retry with lower parallelism:\r\n\r\n```bash\r\nset BUILD_JOBS=1 && tools\\build_wasm_win.bat Release\r\n```\r\n\r\n## Repository Layout (2026-03-30)\r\n\r\nThis stays a single `occt-js` repository without Babylon fork maintenance.  \r\nWithin this repository we keep two maintained modules:\r\n\r\n- `@tx-code/occt-core` (`packages/occt-core`)\r\n  - OCCT Wasm runtime binding and normalized CAD model output.\r\n  - Unified import API for `step` / `iges` / `brep`.\r\n- `@tx-code/occt-babylon-loader` (`packages/occt-babylon-loader`)\r\n  - Babylon-facing model loader and scene builder.\r\n  - Delegates CAD parsing to `occt-core`.\r\n\r\n## Babylon Packages\r\n\r\n- `@tx-code/occt-babylon-loader`: OCCT model to Babylon nodes.\r\n- `@tx-code/occt-babylon-viewer`: scene-first Babylon viewer runtime helpers.\r\n- `@tx-code/occt-babylon-widgets`: optional viewer widgets such as ViewCube.\r\n\r\n## API\r\n\r\n```js\r\nimport OcctJS from './dist/occt-js.js';\r\n\r\nconst occt = await OcctJS();\r\n\r\nconst buffer = new Uint8Array(/* ... CAD file bytes ... */);\r\nconst result = occt.ReadFile(\"step\", buffer, {\r\n    rootMode: \"one-shape\",\r\n    linearUnit: \"millimeter\",\r\n    linearDeflectionType: \"bounding_box_ratio\",\r\n    linearDeflection: 0.1,\r\n    angularDeflection: 0.5,\r\n    readNames: true,\r\n    readColors: true\r\n});\r\n\r\n// Also available:\r\n// occt.ReadIgesFile(buffer, options)\r\n// occt.ReadBrepFile(buffer, options)\r\n\r\n// result.success       — boolean\r\n// result.sourceFormat  — \"step\"\r\n// result.rootNodes     — tree of nodes with children, transforms, meshes[]\r\n// result.geometries    — array of { positions, normals, indices, faces, edges, vertices, triangleToFaceMap }\r\n// result.materials     — deduplicated color list\r\n// result.stats         — { rootCount, nodeCount, partCount, triangleCount, ... }\r\n```\r\n\r\n`rootMode` behavior by format:\r\n\r\n- `\"one-shape\"`: default. Multiple top-level XDE free shapes are exposed under one logical root node.\r\n- `\"multiple-shapes\"`: preserves each top-level free shape as an independent root node.\r\n- `BREP one-shape`: keeps the current single-root behavior.\r\n- `BREP multiple-shapes`: if the imported file resolves to a compound/compsolid wrapper chain, `occt-js` unwraps single-child wrappers and exposes the first meaningful compound level as multiple root nodes.\r\n\r\n## Orientation Analysis\r\n\r\n`occt-js` also exposes a separate manufacturing-oriented orientation analysis API for single parts:\r\n\r\n```js\r\nconst orientation = occt.AnalyzeOptimalOrientation(\"step\", buffer, {\r\n    mode: \"manufacturing\",\r\n    linearUnit: \"millimeter\"\r\n});\r\n\r\nif (orientation.success) {\r\n    // 4x4 transform that aligns the part into its suggested working pose.\r\n    console.log(orientation.transform);\r\n\r\n    // Local reference frame derived from the oriented bounding box.\r\n    console.log(orientation.localFrame);\r\n\r\n    // Analysis diagnostics.\r\n    console.log(orientation.strategy);   // e.g. \"planar-base-with-cylinder-support+projected-min-area-rect\"\r\n    console.log(orientation.stage1);     // base face / detected axis\r\n    console.log(orientation.stage2);     // rotationAroundZDeg\r\n    console.log(orientation.confidence); // 0..1 heuristic score\r\n}\r\n```\r\n\r\nSupported formats for `AnalyzeOptimalOrientation(...)`:\r\n\r\n- `step`\r\n- `iges`\r\n- `brep`\r\n\r\nCurrent scope:\r\n\r\n- single-part / `one-shape` analysis\r\n- manufacturing-oriented heuristic based on exact B-Rep geometry\r\n- optional `presetAxis` override to constrain stage 1 alignment\r\n\r\n## License\r\n\r\nThis project links against OCCT which is licensed under the [GNU Lesser General Public License v2.1](https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html).\r\n","readmeFilename":"README.md"}