Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/karl-/pb_csg
A C# port of CSG.js by Evan W (http://evanw.github.io/csg.js/).
https://github.com/karl-/pb_csg
Last synced: 4 days ago
JSON representation
A C# port of CSG.js by Evan W (http://evanw.github.io/csg.js/).
- Host: GitHub
- URL: https://github.com/karl-/pb_csg
- Owner: karl-
- License: mit
- Created: 2015-04-05T16:14:40.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2024-06-18T16:29:16.000Z (7 months ago)
- Last Synced: 2025-01-03T19:11:41.576Z (11 days ago)
- Language: C#
- Size: 22.4 MB
- Stars: 638
- Watchers: 24
- Forks: 104
- Open Issues: 15
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# pb_CSG
A C# port of [CSG.js](http://evanw.github.io/csg.js/) by Evan W for use in the Unity game engine.
## Install
To install, simply check out this repository in the `My Project/Packages` directory.
```
cd My\ Project/Packages
git clone https://github.com/karl-/pb_CSG.git co.parabox.csg
```## Quick Start
pb_CSG provides an interface in the `CSG` class for creating new meshes from boolean operations. Each function (`Union`, `Subtract`, `Intersect`) accepts 2 gameObjects: the left and right side. A new mesh is returned.
Example use:
// Include the library
using Parabox.CSG;...
// Initialize two new meshes in the scene
GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
sphere.transform.localScale = Vector3.one * 1.3f;// Perform boolean operation
Model result = CSG.Subtract(cube, sphere);// Create a gameObject to render the result
var composite = new GameObject();
composite.AddComponent().sharedMesh = result.mesh;
composite.AddComponent().sharedMaterials = result.materials.ToArray();Result:
![](bin~/images/subtract.PNG?raw=true)