Skip to content

Sean-Bradley/THREE-CSGMesh

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

THREE-CSGMesh

This repo is originally forked from https://github.com/manthrax/THREE-CSGMesh which contains work,

My modifications,

Constructive Solid Geometry

Perform binary operations on mesh geometries. Works with geometries of base type THREE.BufferGeometry only.

  • Union : Return a new CSG solid consisting of A and B
  • Subtract : Return a new CSG solid where B is subtracted from A
  • Intersect : Return a new CSG solid where both A and B overlap

Example 1 : https://sbcode.net/threejs/csg/

Example 2 : https://sbcode.net/threejs/engraving/

Example

Download CSGMesh.js from CDN

import { CSG } from 'https://cdn.jsdelivr.net/gh/Sean-Bradley/THREE-CSGMesh@master/dist/client/CSGMesh.js'

Download Project

git clone https://github.com/Sean-Bradley/THREE-CSGMesh.git
cd THREE-CSGMesh
npm install
npm run dev

Visit http://127.0.0.1:8080

This is a TypeScript project consisting of two subprojects with their own tsconfig.json

To edit the client ./src/client/client.ts. If you started using npm run dev, changes will be auto rebuilt and your browser refreshed due to Webpack hot module reloading.

The server component in folder ./src/server/ is not used in development mode. It is useful if you want to run the production build through a NodeJS express server. See ./src/server/server.ts for further instructions.

Operations

Union

Return a new CSG solid consisting of A and B

A.union(B)

+-------+            +-------+
|       |            |       |
|   A   |            |       |
|    +--+----+   =   |       +----+
+----+--+    |       +----+       |
     |   B   |            |       |
     |       |            |       |
     +-------+            +-------+

Subtract

Return a new CSG solid where B is subtracted from A

A.subtract(B)

+-------+            +-------+
|       |            |       |
|   A   |            |       |
|    +--+----+   =   |    +--+
+----+--+    |       +----+
     |   B   |
     |       |
     +-------+

Intersect

Return a new CSG solid where both A and B overlap

A.intersect(B)

+-------+
|       |
|   A   |
|    +--+----+   =   +--+
+----+--+    |       +--+
     |   B   |
     |       |
     +-------+

Three.js TypeScript Course

Visit https://github.com/Sean-Bradley/Three.js-TypeScript-Boilerplate for a Three.js TypeScript boilerplate containing many extra branches that demonstrate many examples of Three.js.

To help support this Three.js example, please take a moment to look at my official Three.js TypeScript course at

Three.js TypeScript Course

Three.js and TypeScript

Discount Coupons @ https://sbcode.net/coupons

About

Constructive Solid Geometry

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 96.4%
  • JavaScript 3.6%