1. Products
  2.   CAD
  3.   JavaScript
  4.   OpenCascade.js

PHP Library for AutoCAD DXF Files Reading & Writing 

Free JavaScript Library enables programmers to create and manipulate AutoCAD files. Creating & editing 3D objects via inside JS applications.

OpenCascade.js is a powerful open source and versatile library that allows developers to create and manipulate 3D objects using JavaScript. The library is built on top of Open Cascade Technology (OCCT), which is open-source software for 3D modeling and numerical simulation. It enables software developers to develop powerful applications using the OpenCascade CAD Kernel that can smoothly run in the browser as well as on the server or on pretty much any device that supports WebAssembly. The library is very fast due to the power of Emscripten and WebAssembly, the CAD Kernel runs at near-native speeds and fully supports multi-threading on all modern browsers.

OpenCascade.js library is used in many industries and has been widely adopted for its accuracy, stability, and performance. Another key feature of OpenCascade.js is its ability to work with a wide range of file formats, including STL, IGES, and STEP. This allows developers to easily import 3D objects from other CAD programs or data sources and manipulate them within the library. The library also provides a variety of tools for creating and editing 3D objects, including the ability to create complex shapes, curves, and surfaces, as well as perform geometric transformations, such as scaling, rotating, and translating.

OpenCascade.js library supports visualizing 3D objects in real-time and provides a rich set of features for 3D object rendering, lighting, and shading, making it possible to create highly realistic and interactive 3D environments. The library is very well-documented, enabling software professionals to get started and quickly build complex and sophisticated 3D applications. Overall, the library provides a comprehensive set of tools and functions to design, build, and visualize 3D objects, making it an ideal choice for a wide range of applications, including product design, manufacturing, architecture, and construction.

Previous Next

Getting Started with OpenCascade.js

The recommended way to install is using npm. Please use the following command a smooth installation.

Install OpenCascade.js via npm

 npm install opencascade.js@beta  

You can also install it manually; download the latest release files directly from GitHub repository.

Multi-Threading Support in JavaScript Apps

The open source OpenCascade library supports multi-threading for certain operations. The library does not provide native support for multi-threading, as JavaScript is a single-threaded language. However, developers can use Web Workers in their application to perform certain tasks in a separate thread, which can improve performance and responsiveness. There following example demonstrates how to use a Web Worker to perform a heavy computational task in a separate thread while keeping the main UI responsive.

How to Use Multi-Threading inside JavaScript Apps

// worker.js
onmessage = function(e) {
  // Do heavy computational task here
  postMessage("Task completed!");

// main.js
const worker = new Worker("worker.js");
worker.onmessage = function(e) {
  console.log("Worker said: " + e.data);
worker.postMessage("Start task");

Work with 2D and 3D "Offsets" via JavaScript

The open source OpenCascade library allows software developers to work with 2D and 3D "Offsets" inside their own JavaScript applications. To achieve the tasks first you need to load the required libraries and create a 2D or 3D shape. After that you can offset a 2D shape, you can use the BRepOffsetAPI_MakeOffset class and use the BRepBuilderAPI_MakeSolid class to offset a 3D shape. You can use a 3D modeling software like FreeCAD to display the offset shape.

How to Create 2D shape via JavaScript API

const wire = new BRepBuilderAPI_MakeWire();
wire.Add(new BRepBuilderAPI_MakeEdge(new gp_Pnt(0, 0, 0), new gp_Pnt(1, 0, 0)));
wire.Add(new BRepBuilderAPI_MakeEdge(new gp_Pnt(1, 0, 0), new gp_Pnt(1, 1, 0)));
wire.Add(new BRepBuilderAPI_MakeEdge(new gp_Pnt(1, 1, 0), new gp_Pnt(0, 1, 0)));
wire.Add(new BRepBuilderAPI_MakeEdge(new gp_Pnt(0, 1, 0), new gp_Pnt(0, 0, 0)));
create 3D shape:
onst face = new BRepBuilderAPI_MakeFace(wire.Wire());
// Offset the 2D shape:
const offset = new BRepOffsetAPI_MakeOffset(face.Face(), 1, 1e-6);
// Offset the 3D shape:
const solid = new BRepBuilderAPI_MakeSolid(offset.Shape());