lib/three-2-csg.js
/**
 * Converts a ThreeJS 3D object into a CSG solid
 * @param {ThreeJS_Mesh} three_model ThreeJS Mesh (or Geometry) which needs to be converted
 * @returns {CSG_solid}
 */
Converts a ThreeJS 3D object into a CSG solid
@param {ThreeJS_Mesh} three_model ThreeJS Mesh (or Geometry) which needs to be converted
@returns {CSG_solid}
Converts a ThreeJS 3D object into a CSG solid @param { ThreeJS_Mesh } three_model ThreeJS Mesh ( or Geometry ) which needs to be converted @returns { CSG_solid }
function toCSG ( three_model ) {
    var i, geometry, polygons, vertices;
     if ( !CSG ) {
         throw 'CSG library not loaded. Please get a copy from https://github.com/evanw/csg.js';
     }
    if ( three_model instanceof THREE_Mesh ) {
        geometry = new THREE_Geometry();
        geometry.mergeMesh(three_model);
    } else if ( three_model instanceof THREE_Geometry ) {
        geometry = three_model;
    } else {
        throw 'Model type not supported.';
    }
    var polygons = [];
    for ( i = 0; i < geometry.faces.length; i++ ) {
        if ( geometry.faces[i] instanceof THREE_Face3 ) {
            polygons.push( ThreeFace3_to_CsgPoly(geometry.faces[i], geometry.vertices) );
        } else if ( geometry.faces[i] instanceof THREE_Face4 ) {
            polygons.push.apply(polygons,  ThreeFace4_to_CsgPoly(geometry.faces[i], geometry.vertices) );
        } else {
            throw 'Model contains unsupported face.';
        }
    }
    return CSG.fromPolygons( polygons );
}
function toCSG ( three_model ) { var i , geometry , polygons , vertices ; if ( ! CSG ) { throw 'CSG library not loaded. Please get a copy from https://github.com/evanw/csg.js' ; } if ( three_model instanceof THREE_Mesh ) { geometry = new THREE_Geometry ( ) ; geometry . mergeMesh ( three_model ) ; } else if ( three_model instanceof THREE_Geometry ) { geometry = three_model ; } else { throw 'Model type not supported.' ; } var polygons = [ ] ; for ( i = 0 ; i < geometry . faces . length ; i ++ ) { if ( geometry . faces [ i ] instanceof THREE_Face3 ) { polygons . push ( ThreeFace3_to_CsgPoly ( geometry . faces [ i ] , geometry . vertices ) ) ; } else if ( geometry . faces [ i ] instanceof THREE_Face4 ) { polygons . push . apply ( polygons , ThreeFace4_to_CsgPoly ( geometry . faces [ i ] , geometry . vertices ) ) ; } else { throw 'Model contains unsupported face.' ; } } return CSG . fromPolygons ( polygons ) ; }
Converts a ThreeJS 3D object into a CSG solid
 @param {ThreeJS_Mesh} three_model ThreeJS Mesh (or Geometry) which needs to be converted
 @returns {CSG_solid}
Converts a ThreeJS 3D object into a CSG solid @param { ThreeJS_Mesh } three_model ThreeJS Mesh ( or Geometry ) which needs to be converted @returns { CSG_solid }
// [ThreeFace4_to_CsgPoly] return an array
