Skip to content

Port of the OpenCascade library to JavaScript / WebAssembly using Emscripten

License

Notifications You must be signed in to change notification settings

womaas/opencascade.js

 
 

Repository files navigation

opencascade.js - Build Library OpenCascade Version

Logo

OpenCascade.js

A port of the OpenCascade CAD library to JavaScript and WebAssembly via Emscripten.
Explore the docs »

Examples · Issues · Discuss

Projects & Examples:

Getting Started

(These instructions are for the upcoming @beta release. All information is likely to change. See here for instructions of the v1.1.1 release.)

  1. Add the library as a dependency to your project

    npm install opencascade.js@beta
    
  2. Configure your bundler to load .wasm files as URLs. If you don't want to use a bundler, you can manually pass in the URLs to the WASM files in the next step.

    For webpack, first add the file-loader dependency.

    npm install file-loader --save-dev
    

    Then add the following configuration to your webpack.config.js.

    module: {
      rules: [
        {
          test: /\.wasm$/,
          type: "javascript/auto",
          loader: "file-loader"
        }
      ]
    },
    node: {
      fs: "empty"
    }
  3. In your JavaScript file, instantiate the library:

    import {
      initOpenCascade,
      ocCore,
      ocModelingAlgorithms,
      ocVisualApplication,
      ocDataExchangeBase,
      ocDataExchangeExtra,
    } from "opencascade.js";
    
    initOpenCascade({
      libs: [ // Specify which modules to use and the sequence in which to load them
        ocCore,
        ocModelingAlgorithms,
        ocVisualApplication,
        ocDataExchangeBase,
        ocDataExchangeExtra,
      ]
    }).then(oc => {
      // Check out the examples on how to use this library!
    });

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.

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 91.8%
  • Dockerfile 5.9%
  • Shell 2.3%