What's this?
This is a converter which enables conversion of ThreeJS objects into CSG and back (it works both ways).
CSG objects created by this converter can then be manipulated via @jscad/csg.
This solution is based on ThreeCSG.js converter by Chandler Prall.
Installation
npm i three-2-csg
Example
The following example is based on a Stack overflow example by 4m1r:
; //spherevar sphere = 22020;var sphereMesh = sphere material ;var sphereCSG = ; // converting ThreeJS object to CSG // cylvar cylinder = 05 05 5 32 ;var cylinderMesh = cylinder material ;var cylinderCSG = ; // converting ThreeJS object to CSG //resultvar subtractCSG = sphereCSG;var result = ; // converting CSG back into ThreeJS object resultgeometry; scene;
Functions
- toCSG(three_model) ⇒
CSG_solid
Converts a ThreeJS 3D object into a CSG solid
- fromCSG(csg_model) ⇒
THREE_Geometry
Converts a CSG solid (3d object) into regular ThreeJS geometry
CSG_solid
toCSG(three_model) ⇒ Converts a ThreeJS 3D object into a CSG solid
Kind: global function
Param | Type | Description |
---|---|---|
three_model | ThreeJS_Mesh |
ThreeJS Mesh (or Geometry) which needs to be converted |
THREE_Geometry
fromCSG(csg_model) ⇒ Converts a CSG solid (3d object) into regular ThreeJS geometry
Kind: global function
Param | Type | Description |
---|---|---|
csg_model | CSG_solid |
= CSG solid to be converted |
License
MIT License, http://www.opensource.org/licenses/MIT