Loading - please wait...

Status: {{ state.appStatusMessage }}

© AndrewMarsh.com

This web app provides access to the powerful OpenCascade geometry kernel, either directly or though the higher-level APIs provided. It uses a modern code editing environment linked to an advanced model viewer that lets you select and interact with the resulting shape as well as its surfaces, edges and vertices.

This is not intended as a fully-fledged CAD app (that is coming later), but rather as a tool to let you programmatically generate complex shapes that you can use in other tools and applications. Thus, its core focus is on the creation of single or composite shapes that you can then transfer or export to other environments.

This app was inspired by the work of Johnathon Selstad (zalo) and his Cascade Studio project on GitHub. It was the first viable example of using the OpenCascade.js WASM module I had seen and greatly influenced my approach to building this app.

The best way to get started with this app is to look at some of the included example scripts. These are in the OpenCascade Examples and PD.Shape Examples items in the CODE menu, located in the main navigation bar at the top of the application browser tab.

Using OpenCascade classes and methods directly can be quite daunting, so this app provides a high-level CAD API that lets you use OpenCascade in a much simpler and more intuitive way. The app also provides a lower-level OCC API that offers much greater flexibility and control, but still with a similarly simple and intuitive method structure.

In addition to these APIs, the app offers direct access to the PD.Shape and PD.Polyhedron classes for creating complex faceted geometry using a wide range of shape generation algorithms, and then converting them to OpenCascade shells and solids to operate further on.

The following are some of the stand-out features of this app:

  • It uses the powerful OpenCascade geometry kernel via WASM for its core primitives and CSG operations. In OpenCascade, both curved and flat surfaces are defined by continuous functions rather than discrete facets, so the results of geometric operations retain smoothly curved faces and edges.
  • CSG operations in OpenCascade return edges as well as surfaces, making the results better suited for representation within technical drawings.
  • The interactive viewer allows you to select the faces, edges and vertices of generated shapes. This allows you to visually examine the shape and create arrays of selected face, edge and vertex indices for further processing.
  • The app uses the Monaco code editor which also powers Microsoft Visual Studio Code. This includes IntelliSense and full-featured editing with type definitions for all new and existing objects and methods. The editor is also resizable so you can expand it or move it out of the way as required.
  • In addition to OpenCascade objects and methods, you can also use the PD.Shape and PD.Polyhedron classes, as well as PD.VectorArray for accessing quick-hull, concave-man, perlin-noise, delaunay triangulation, marching cubes, surface nets and volumetric voxelisation algorithms.

I have been experimenting with constructive solid geometry in Javascript for quite a while now, especially after the release of CSG.js on GitHub back in 2011. I watched with interest as that code was used in THREE.js, Babylon.js, OpenJSCAD and some other tools.

Unfortunately CSG.js and its variants don't preserve polygonal boundaries very well as each operation can split surfaces into multiple triangular fragments or shards. That's fine if you are just rendering the surfaces, but architectural and engineering drawings need to show edges and boundary outlines, and the resulting shapes often look like they have been chopped up by a band of particularly angry Ninjas.

I have tried all sorts of solutions attempting to piece adjacent coplanar shards back together into usable bounded polygons, but never with sufficient success or robustness to be useful. I then came across OpenCascade.js, via the Cascade Studio project, and that geometry kernel seemed to solve most of these issues.

As with most of my apps, this one began life as a development tool that let me quickly and easily test the implementation of my OpenCascade support library, and visually validate the results. I have since extended it to include my own PD.Shape and PD.Polyhedron classes, as well as some of my array-based geometry utilities. I think the result is an app that at least rivals the likes of OpenJSCAD, and in several respects may even be better.

© Dr. Andrew J. Marsh, 2012-2025.