Skip to content

Port of the OpenCascade library to JavaScript / WebAssembly using Emscripten

License

Notifications You must be signed in to change notification settings

levivoelz/opencascade.js

 
 

Repository files navigation

OpenCascade.js

This is OpenCascade.js - a port of the OpenCascade CAD library to JavaScript and WebAssembly via Emscripten.

Current OCCT version: V7_5_0

opencascade.js - Build Library

Projects & Examples:

FAQ

Is this a fork of the OpenCascade 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.

Who is going to keep this project up-to-date with the OpenCascade library?

This project is (hopefully) keeping itself (mostly) up-to-date with the OpenCascade library, since most bindings are generated automatically.

Use it

  1. Add the library as a dependency to your project

    # with yarn
    yarn add opencascade.js
    # with npm
    npm install opencascade.js
  2. 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.

  3. 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.

Contributing

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.

About

Port of the OpenCascade library to JavaScript / WebAssembly using Emscripten

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 93.7%
  • Dockerfile 6.2%
  • Shell 0.1%