Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

three-2-csg

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

three-2-csg

converts ThreeJS object into CSG and back

  • 1.0.2
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
3
Maintainers
1
Weekly downloads
 
Created
Source

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:

import { toCSG, fromCSG } from 'three-2-csg';

//sphere
var sphere = new THREE.SphereGeometry(2,20,20);
var sphereMesh = new THREE.Mesh( sphere, material );
var sphereCSG = toCSG( sphereMesh ); // converting ThreeJS object to CSG

// cyl
var cylinder = new THREE.CylinderGeometry(0.5, 0.5, 5, 32 );
var cylinderMesh = new THREE.Mesh( cylinder, material );
var cylinderCSG = toCSG( cylinderMesh ); // converting ThreeJS object to CSG

//result
var subtractCSG = sphereCSG.subtract( cylinderCSG );
var result = fromCSG(subtractCSG); // converting CSG back into ThreeJS object

result.geometry.computeVertexNormals();

scene.add( result );

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

toCSG(three_model) ⇒ CSG_solid

Converts a ThreeJS 3D object into a CSG solid

Kind: global function

ParamTypeDescription
three_modelThreeJS_MeshThreeJS Mesh (or Geometry) which needs to be converted

fromCSG(csg_model) ⇒ THREE_Geometry

Converts a CSG solid (3d object) into regular ThreeJS geometry

Kind: global function

ParamTypeDescription
csg_modelCSG_solid= CSG solid to be converted

License

MIT License, http://www.opensource.org/licenses/MIT

Keywords

FAQs

Package last updated on 07 Jan 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc