{"_id":"@beanjs/three-csg-modeller","name":"@beanjs/three-csg-modeller","dist-tags":{"latest":"0.1.10"},"versions":{"0.1.10":{"name":"@beanjs/three-csg-modeller","version":"0.1.10","description":"Solid mesh modeling for three.js","repository":{"type":"git","url":"git+https://github.com/ycw/three-csg-modeller.git"},"author":{"name":"ycw","url":"https://github.com/ycw"},"type":"module","main":"src/index.js","typings":"src/index.d.ts","scripts":{"build":"rollup -c rollup.config.js"},"license":"MIT","keywords":["CSG","modeling","threejs"],"peerDependencies":{"three":">= 0.120.0"},"devDependencies":{"rollup":"^2.29.0","rollup-plugin-terser":"^7.0.2","terser":"^5.3.4"},"dependencies":{},"gitHead":"d89b58ec510220acb8dd8c7865ee51878a398f34","bugs":{"url":"https://github.com/ycw/three-csg-modeller/issues"},"homepage":"https://github.com/ycw/three-csg-modeller#readme","_id":"@beanjs/three-csg-modeller@0.1.10","_nodeVersion":"16.20.0","_npmVersion":"8.19.4","dist":{"integrity":"sha512-XbwQaQCnGHLwQ8H+F/KhdTN3pOzh09FBQqTQFUwOYFiVvYUkjHFd8rSIBzSfo5EQ4sLpRbLI/DFNsv4YtbNgtw==","shasum":"d49dd2212bf57c44da4eec81852a42699b7164f7","tarball":"https://registry.npmjs.org/@beanjs/three-csg-modeller/-/three-csg-modeller-0.1.10.tgz","fileCount":8,"unpackedSize":33502,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIElYiHZrmAVwvAZHsAzZGIZXIn+aJt8KgEWpJ7M9D0dlAiBExD2aSUen1HFB1DZ9H/aub/QjXktYVdYc9vEgctFFoA=="}]},"_npmUser":{"name":"beanjs","email":"445212619@qq.com"},"directories":{},"maintainers":[{"name":"beanjs","email":"445212619@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/three-csg-modeller_0.1.10_1684805067705_0.6803102405463544"},"_hasShrinkwrap":false}},"time":{"created":"2023-05-23T01:24:27.641Z","0.1.10":"2023-05-23T01:24:27.900Z","modified":"2023-05-23T01:24:28.053Z"},"maintainers":[{"name":"beanjs","email":"445212619@qq.com"}],"description":"Solid mesh modeling for three.js","homepage":"https://github.com/ycw/three-csg-modeller#readme","keywords":["CSG","modeling","threejs"],"repository":{"type":"git","url":"git+https://github.com/ycw/three-csg-modeller.git"},"author":{"name":"ycw","url":"https://github.com/ycw"},"bugs":{"url":"https://github.com/ycw/three-csg-modeller/issues"},"license":"MIT","readme":"# About\n\nSolid mesh modeling for three.js.\n\n## Featrues\n\n- Manipulate `BufferGeometry` directly.\n- Support vertex color and mutli-material.\n- Dump mesh with indexed `BufferGeometry`.\n\n## Examples\n\n- [Gradient Crown](https://ycw.github.io/three-csg-modeller/examples/gradient-crown/) (vertex color)\n- [Gallery Frame](https://ycw.github.io/three-csg-modeller/examples/gallery-frame/) (mutli-material)\n- [Extrude Inwards](https://ycw.github.io/three-csg-modeller/examples/extrude-inwards/) (set operations)\n\n## Installation\n\nVia npm ( `npm i ycw/three-csg-modeller#v0.1.10` )\n\n```js\nimport { CSGModeller } from \"three-csg-modeller\"\n```\n\nVia cdn\n\n```js\nimport { CSGModeller } from \"https://cdn.jsdelivr.net/gh/ycw/three-csg-modeller@0.1.10/dist/lib.esm.js\"\n```\n\n## Usage\n\n```js\n// Ex. Subtract a box from a sphere.\nconst modeller = new CSGModeller(THREE);\nconst sphereModel = modeller.model(new THREE.Mesh(\n  new THREE.SphereBufferGeometry(0.5),\n  new THREE.MeshLambertMaterial({ color: \"black\" })\n));\nconst boxModel = modeller.model(new THREE.Mesh(\n  new THREE.BoxBufferGeometry(0.5, 0.5, 1),\n  new THREE.MeshLambertMaterial({ color: \"white\" })\n));\nconst model = sphereModel.subtract(boxModel);\nconst mesh = model.build();\n```\n\nLive result: [Basic Subtract](https://ycw.github.io/three-csg-modeller/examples/basic-subtract/). See also: [Basic Multi-Material](https://ycw.github.io/three-csg-modeller/examples/basic-multi-material/).\n\n## API\n\n### `CSGModeller`\n\n`new CSGModeller(THREE)`\n- Construct a modeller. `THREE` is the three.js lib.\n\n`.model(mesh)`\n- Create a `Model` instance from a mesh whose `.geometry` must be a `BufferGeometry`.\n\n### `Model`\n\n`.union(model)`\n- Return a new model holding result of `this` &cup; `model`.\n\n`.subtract(model)`\n- Return a new model holding result of `this` &minus; `model`.\n\n`.intersect(model)`\n- Return a new model holding result of `this` &cap; `model`.\n\n`.applyMatrix4(matrix)` \n- Return a new transformed model. Param `matrix` is a `THREE.Matrix4`.\n\n`.build()`\n- Build and return a mesh holding an indexed `BufferGeometry`.\n\n## Credits\n\n- [evanw/csg.js](https://evanw.github.io/csg.js/)\n- [mrdoob/three.js](https://github.com/mrdoob/three.js)\n\n## License\n\n[MIT](LICENSE)","readmeFilename":"README.md"}