├── .gitignore ├── README.md ├── demo ├── index.html └── scene.config.js ├── dist └── THREE.CSG.js ├── lib ├── CSG.js └── FontSet.js ├── package.json ├── rollup.config.js └── src └── index.js /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled source # 2 | ################### 3 | *.com 4 | *.class 5 | *.dll 6 | *.exe 7 | *.o 8 | *.so 9 | 10 | # Packages # 11 | ############ 12 | # it's better to unpack these files and commit the raw source 13 | # git has its own built in compression methods 14 | *.7z 15 | *.dmg 16 | *.gz 17 | *.iso 18 | *.jar 19 | *.rar 20 | *.tar 21 | *.zip 22 | 23 | # Logs and databases # 24 | ###################### 25 | *.log 26 | *.sql 27 | *.sqlite 28 | 29 | # OS generated files # 30 | ###################### 31 | .DS_Store 32 | .DS_Store? 33 | ._* 34 | .Spotlight-V100 35 | .Trashes 36 | ehthumbs.db 37 | Thumbs.db 38 | 39 | # Node modules # 40 | ###################### 41 | node_modules/ -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # THREE.CSG 2 | > A [THREE.js](http://threejs.org/) plugin to allow implementing boolean operations on THREE Objects(Mesh, Geometry). The boolean operations are supported by [csg.js](http://threejs.org/). For an overview of the CSG process, see the orginal [csg.js](https://evanw.github.io/csg.js/) code. 3 | 4 | ## Include in Your HTML 5 | Remember to include THREE.js before including this plugin. 6 | ``` bash 7 | 8 | ``` 9 | 10 | 11 | ## Usage 12 | 13 | ### Convert between THREE object and CSG object 14 | ``` bash 15 | # convert THREE.Geometry to CSG format 16 | var csg = THREE.CSG.fromGeometry(geometry) 17 | 18 | # convert THREE.Mesh to CSG format 19 | var csg = THREE.CSG.fromMesh(mesh) 20 | 21 | # convert to THREE.Geometry 22 | var geometry = THREE.CSG.toGeometry(csg) 23 | 24 | # convert to THREE.Mesh 25 | var mesh = THREE.CSG.toMesh(csg, material) 26 | ``` 27 | 28 | ### Boolean Operations 29 | ``` bash 30 | # Union 31 | var result = A.union(B) 32 | 33 | # Subtract 34 | var result = A.subtract(B) 35 | 36 | # Intersect 37 | var result = A.intersect(B) 38 | ``` 39 | NOTE: Both A and B should be in CSG format for boolean operations. 40 | 41 | ## Live Demo 42 | [live Demo](http://oathihs.github.io/ThreeCSG/) 43 | 44 | ## Development 45 | ``` bash 46 | # install dependencies 47 | npm install 48 | 49 | # build for production 50 | npm run build 51 | ``` 52 | -------------------------------------------------------------------------------- /demo/index.html: -------------------------------------------------------------------------------- 1 | 2 |
3 | 4 | 5 |