three-csg-ts
Advanced tools
Comparing version 3.1.6 to 3.1.7
{ | ||
"name": "three-csg-ts", | ||
"version": "3.1.6", | ||
"version": "3.1.7", | ||
"description": "CSG library for use with THREE.js", | ||
@@ -37,5 +37,5 @@ "main": "lib/cjs/index.js", | ||
"devDependencies": { | ||
"@types/jest": "^26.0.23", | ||
"@types/jest": "^27.0.1", | ||
"@types/node": "^14.14.45", | ||
"@types/three": "^0.130.0", | ||
"@types/three": "^0.131.0", | ||
"@typescript-eslint/eslint-plugin": "^4.23.0", | ||
@@ -53,4 +53,4 @@ "@typescript-eslint/parser": "^4.23.0", | ||
"standard-version": "^9.3.0", | ||
"three": "^0.130.1", | ||
"ts-jest": "^27.0.3", | ||
"three": "^0.131.3", | ||
"ts-jest": "^27.0.5", | ||
"ts-loader": "^9.2.3", | ||
@@ -57,0 +57,0 @@ "typescript": "^4.2.4", |
@@ -9,2 +9,4 @@ # three-csg-ts | ||
![Screenshot 2021-07-19 at 17 32 20](https://user-images.githubusercontent.com/935782/126194933-45ac18d0-2459-4213-97d2-d46ffb67483c.png) | ||
## Concept | ||
@@ -33,15 +35,15 @@ | ||
// Make 2 box meshes.. | ||
const meshA = new THREE.Mesh(new THREE.BoxGeometry(1,1,1), new THREE.MeshNormalMaterial()); | ||
const meshB = new THREE.Mesh(new THREE.BoxGeometry(1,1,1)); | ||
// Make 2 meshes.. | ||
const box = new THREE.Mesh(new THREE.BoxGeometry(2, 2, 2), new THREE.MeshNormalMaterial()); | ||
const sphere = new THREE.Mesh(new THREE.SphereGeometry(1.2, 8, 8)); | ||
// Offset one of the boxes by half its width.. | ||
meshB.position.add(new THREE.Vector3(0.5, 0.5, 0.5)); | ||
// Make sure the .matrix of each mesh is current | ||
meshA.updateMatrix(); | ||
meshB.updateMatrix(); | ||
box.updateMatrix(); | ||
sphere.updateMatrix(); | ||
// Subtract meshB from meshA | ||
const meshResult = CSG.subtract(meshA, meshB); | ||
// Perform CSG operations | ||
// The result is a THREE.Mesh that you can add to your scene... | ||
const subRes = CSG.subtract(box, sphere); | ||
const uniRes = CSG.union(box, sphere); | ||
const intRes = CSG.intersect(box, sphere); | ||
``` |
56491
48