Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. Game Engine Development
  3. csg.js

csg.js

MITJavaScript

A JavaScript library for constructive solid geometry (CSG) operations on 3D meshes using BSP trees.

Visit WebsiteGitHubGitHub
1.9k stars265 forks0 contributors

What is csg.js?

csg.js is a JavaScript library that implements constructive solid geometry (CSG) operations on 3D meshes using binary space partitioning (BSP) trees. It enables developers to perform Boolean operations like union, subtraction, and intersection to combine or modify 3D solids programmatically. The library handles complex edge cases, such as overlapping coplanar polygons, ensuring robust geometric computations.

Target Audience

Developers and researchers working with 3D graphics, computational geometry, or web-based 3D modeling tools who need to perform solid modeling operations in JavaScript.

Value Proposition

csg.js offers a clean, concise, and well-documented implementation of CSG algorithms, making it both a practical library for 3D mesh manipulation and an educational resource for understanding BSP trees and Boolean operations in geometry.

Overview

Constructive solid geometry on meshes using BSP trees in JavaScript

Use Cases

Best For

  • Performing Boolean operations (union, subtraction, intersection) on 3D meshes in web applications
  • Implementing constructive solid geometry in JavaScript-based 3D modeling tools
  • Educational projects demonstrating BSP tree algorithms and CSG techniques
  • Prototyping 3D geometry operations without heavy dependencies
  • Handling complex edge cases like overlapping coplanar polygons in solid modeling
  • Building custom 3D editors or visualization tools with mesh manipulation capabilities

Not Ideal For

  • Real-time 3D applications requiring high-performance mesh processing for complex scenes
  • Projects needing advanced mesh features beyond Boolean operations, such as UV mapping or animation
  • Teams seeking a plug-and-play 3D library with built-in import/export for common formats like OBJ or STL
  • Industrial CAD software handling massive, intricate geometries where scalability is critical

Pros & Cons

Pros

Elegant BSP Implementation

Uses binary space partitioning trees for efficient and robust CSG operations, with clear algorithmic logic documented in the README.

Robust Coplanar Handling

Correctly manages edge cases involving overlapping coplanar polygons in both solids, ensuring accurate Boolean operations as highlighted in the demos.

Clean and Simple API

Provides intuitive methods like clipTo() and invert(), making it straightforward to implement union, subtraction, and intersection with minimal code.

Educational Clarity

Serves as a concise reference implementation with well-commented code and Docco-generated documentation, ideal for learning CSG and BSP algorithms.

Cons

Limited Mesh Formats

Lacks built-in support for importing or exporting common 3D file formats, requiring additional coding effort to integrate with other tools.

Performance Constraints

The BSP tree approach can be memory-intensive and slow for large or complex meshes, as noted in its lightweight, unoptimized design.

Minimal Ecosystem Integration

Does not directly work with popular 3D frameworks like Three.js, necessitating custom bridging code for practical web applications.

Frequently Asked Questions

Quick Stats

Stars1,863
Forks265
Contributors0
Open Issues12
Last commit6 years ago
CreatedSince 2011

Tags

#boolean-operations#geometry#javascript-library#3d-modeling#mesh-operations#computational-geometry#constructive-solid-geometry

Built With

J
JavaScript

Links & Resources

Website

Included in

Game Engine Development1.3k
Auto-fetched 19 hours ago

Related Projects

three-bvh-csgthree-bvh-csg

A flexible, memory compact, fast and dynamic CSG implementation on top of three-mesh-bvh

Stars931
Forks84
Last commit5 months ago
three-csgmeshthree-csgmesh

Conversion of a CSG library for use with modern THREE.js

Stars494
Forks60
Last commit1 year ago
Constructive Solid GeometryConstructive Solid Geometry

Technique using boolean operations to combine primitive objects

Stars0
Forks0
Last commit
Mesh TransformsMesh Transforms

Apple's private API for manipulation of UIView meshes. [Source]

Stars0
Forks0
Last commit
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub