Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
gkjohnson committed Aug 29, 2023
1 parent c8da5e7 commit 13fd069
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/BVH.ResultVolume.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { Brush, Evaluator, SUBTRACTION, computeMeshVolume } from '../src';
import { SphereGeometry } from 'three';

describe( 'CSG', () => {

it( 'subtraction should result in the volume of difference.', () => {

const sphere1 = new Brush( new SphereGeometry() );
const sphere2 = new Brush( new SphereGeometry() );
sphere2.scale.setScalar( 0.5 );
sphere2.updateMatrixWorld( true );

const evaluator = new Evaluator();
const result = evaluator.evaluate( sphere1, sphere2, SUBTRACTION );

const vol1 = computeMeshVolume( sphere1 );
const vol2 = computeMeshVolume( sphere2 );
const finalVol = computeMeshVolume( result );
expect( finalVol ).toBeCloseTo( vol1 - vol2, 10 );

} );

} );
File renamed without changes.

0 comments on commit 13fd069

Please sign in to comment.