This is OpenCascade.js - a port of the OpenCascade CAD library to JavaScript and WebAssembly via Emscripten.
Current OCCT version: V7_5_0
- CascadeStudio is a SCAD (Scripted-Computer-Aided-Design) editor, which runs in the browser.
- OpenCascade.js-examples contains general examples on how to use the library.
No. This project is making no changes to the OpenCascade library, apart from few very small modifications which are applied as patches. All this project does is
- Download a tagged commit from the OpenCascade git server.
- Compile the OpenCascade library using the Emscripten compiler.
- Analyze the OpenCascade headers using libclang and auto-generate bind-code to expose the library to JavaScript.
- Link the WASM-binaries and provide some convenience functions so that you can easily use the library in your JavaScript projects.
This project is (hopefully) keeping itself (mostly) up-to-date with the OpenCascade library, since most bindings are generated automatically.
-
Add the library as a dependency to your project
# with yarn yarn add opencascade.js # with npm npm install opencascade.js
-
Assuming that you use webpack in your project, you need to add the following configuration to your
webpack.config.js
module: { rules: [ { test: /opencascade\.wasm\.wasm$/, type: "javascript/auto", loader: "file-loader" } ] }, node: { fs: "empty" }
You will also need to add
file-loader
as a dev-dependency to your project, i.e.# with yarn yarn add file-loader --dev # with npm npm install file-loader --save-dev
This will
- make sure that the path to the opencascade WASM file is made available by webpack. This is required to enable support for
WebAssembly.InstantiateStreaming
& Co. - stop webpack from complaining about
fs
being undefined in the Emscripten-generated loading script.
For more info, see here.
- make sure that the path to the opencascade WASM file is made available by webpack. This is required to enable support for
-
Use the library in your project:
import { initOpenCascade } from "opencascade.js"; initOpenCascade().then(openCascade => { // use it! });
This code will load the WebAssembly version of the library.
Contributions are welcome! Feel free to have a look at the todo-list if you need some inspiration on what else needs to be done.