Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/looeee/threejs-csg
Constructive Solid Geometry for three.js, ES6 + BufferGeometry
https://github.com/looeee/threejs-csg
3d 3d-graphics 3d-models boolean-operations constructive-solid-geometry csg threejs threejs-csg webgl webgl2
Last synced: 3 months ago
JSON representation
Constructive Solid Geometry for three.js, ES6 + BufferGeometry
- Host: GitHub
- URL: https://github.com/looeee/threejs-csg
- Owner: looeee
- License: mit
- Created: 2020-05-26T09:45:54.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-03-05T12:00:14.000Z (almost 2 years ago)
- Last Synced: 2024-10-12T22:25:58.617Z (4 months ago)
- Topics: 3d, 3d-graphics, 3d-models, boolean-operations, constructive-solid-geometry, csg, threejs, threejs-csg, webgl, webgl2
- Language: JavaScript
- Homepage: https://csg.lewy.blue/
- Size: 6.39 MB
- Stars: 134
- Watchers: 3
- Forks: 16
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# threejs-csg (Experimental)
Constructive Solid Geometry for three.js, ES6 + BufferGeometry.
Note: I have stopped working on this for now and there are bugs, although it should work for simple shapes.
# Developing
Run `npm install` then `npm start`
To view the demo, direct your browser to
http://127.0.0.1:8080/demo/tests/index.html# Usage
```
const box = new Mesh(new BoxBufferGeometry(0.2, 0.2, 1), material);
box.position.set(0.1, 0.1, 0);const sphere = new Mesh(new SphereBufferGeometry(0.1), material);
sphere.position.set(0, 0, -0.3);const sphereB = sphere.clone();
sphereB.position.set(0, 0, 0.3);const csg = new CSG();
csg.subtract([box, sphere, sphereB]);
// csg.union([box, sphere, sphereB]);
// csg.intersect([box, sphere]);const resultMesh = csg.toMesh();
```# TODO
* Only the material from the first mesh is used.
* Vertex colors are ignored.
* Make it faster!!# Prior Work
http://evanw.github.io/csg.js/docs
https://github.com/jscad/csg.js
http://sandervanrossen.blogspot.com/2010/05/csg-operations.html
https://www.geometrictools.com/Documentation/ClipMesh.pdf