
Product
Socket for Jira Is Now Available
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.
occt-import-js
Advanced tools
The emscripten interface for OpenCascade import functionalities. It runs entirely in the browser, and allows you to import brep, step and iges files and access the result in JSON format.
See it in action in Online 3D Viewer, or check this fiddle for a code example.
You can get occt-import-js from npm:
npm install occt-import-js
The library runs in the browser and as a node.js module as well.
You will need two files from the dist folder: occt-import-js.js and occt-import-js.wasm. The wasm file is loaded runtime by the js file. There are three public functions in the library:
ReadBrepFile to import brep file.ReadStepFile to import step file.ReadIgesFile to import iges file.All functions have two parameters:
content: The file content as a Uint8Array object.params: Triangulation parameters as an object, can be null.
linearUnit: Defines the linear unit of the output. Possible values: millimeter, centimeter, meter, inch, foot. Default is millimeter. Has no effect on brep files.linearDeflectionType: Defines what the linear deflection value means. Default is bounding_box_ratio. Possible values:
bounding_box_ratio: The linearDeflection value contains a ratio of the average bounding box.absolute_value: The linearDeflection value contains an absolute value in the unit defined by linearUnit.linearDeflection: The linear deflection value based on the value of the linearDeflectionType parameter.angularDeflection: The angular deflection value.You can find more information about deflection values here.
First, include the occt-import-js.js file in your website.
<script type="text/javascript" src="occt-import-js.js"></script>
After that, download the model file, and pass them to occt-import-js.
occtimportjs ().then (async function (occt) {
let fileUrl = '../test/testfiles/simple-basic-cube/cube.stp';
let response = await fetch (fileUrl);
let buffer = await response.arrayBuffer ();
let fileBuffer = new Uint8Array (buffer);
let result = occt.ReadStepFile (fileBuffer, null);
console.log (result);
});
You should require the occt-import-js module in your script.
let fs = require ('fs');
const occtimportjs = require ('occt-import-js')();
occtimportjs.then ((occt) => {
let fileUrl = '../test/testfiles/simple-basic-cube/cube.stp';
let fileContent = fs.readFileSync (fileUrl);
let result = occt.ReadStepFile (fileContent, null);
console.log (result);
});
The result of the import is a JSON object with the following structure.
A set of batch scripts are prepared for building on Windows.
Install CMake (3.6 minimum version is needed). Make sure that the cmake executable is in the PATH.
Run the Emscripten setup script.
tools\setup_emscripten_win.bat
Run the release build script.
tools\build_wasm_win_release.bat
If you want to debug the code, it's useful to build a native project. To do that, just use cmake to generate the project of your choice.
To run the demo and the examples locally, you have to start a web server. Run npm install from the root directory, run npm start and visit http://localhost:8080.
FAQs
Javascript interface for the occt library.
The npm package occt-import-js receives a total of 38,961 weekly downloads. As such, occt-import-js popularity was classified as popular.
We found that occt-import-js demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.