1.1.1 • Published 1 year ago

opencascade.js v1.1.1

Weekly downloads
624
License
LGPL-2.1-only
Repository
github
Last release
1 year ago

OpenCascade.js

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

Current OCCT version: V7_4_0p1

opencascade.js - Build Library

Projects & Examples:

FAQ

Which parts of the OpenCascade library are supported?

As of right now, approximately 74% of all classes defined in OpenCascade are supported. Some of those classes have been tested and are confirmed working via WebAssembly. However, large parts of this project are currently untested.

npm.io

Detailed list of supported classes

Many typedef'd template classes are currently not supported by the build system. If you need support for a particular feature, feel free to add it yourself or reach out.

What if I need some parts of the OpenCascade library in my project that are currently not supported by the build system?

Adding missing features is easy. Just go ahead and edit the manualBindings.h header-file and add your custom bindings. Some examples are already in that file. A full overview of Emscripten's Embind system can be found here. Please try to stick to the conventions.

You can also try to modify the binding auto-generation code, although this can be a slightly more difficult challenge.

Please make a pull request if you add or improve anything in this project.

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.

Build it

You can build OpenCascade.js yourself. The easiest way to do that is to build and run the docker container, which is correctly configured for building the library. Follow these steps:

On Linux

If you're using Linux (probably also if you're on MacOS), you may want to use the build.sh script. This is a helper-script, which will allow you to

  • build the container
  • execute the build
  • open a shell inside the container
  • clear your build cache

On Windows

To build the container, open a command prompt or terminal in the directory of opencascade.js and enter:

```
docker build -t opencascade.js .
```

Then execute the build, while sharing several folders with your current directory:

```
docker run -it ^
  -v "%cd%\build":"/opencascade/build/" ^
  -v "%cd%\dist":"/opencascade/dist/" ^
  -v "%cd%\emscripten-cache":"/emscripten/upstream/emscripten/cache/" ^
  -v "%cd%\embind":"/opencascade/embind/" ^
  opencascade.js
```

Re-building

Currrently, you have to run the docker build and docker run commands after each change, for every build.

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.

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

2.0.0

3 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.1.19

4 years ago

0.1.18

4 years ago

0.1.17

4 years ago

0.1.16

4 years ago

0.1.15

4 years ago

0.1.14

4 years ago

0.1.12

4 years ago

0.1.13

4 years ago

0.1.11

4 years ago

0.1.10

4 years ago

0.1.9

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.8

4 years ago

0.1.7

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.0

4 years ago