@@ -107,13 +107,19 @@ BARS.defineActions(() => {
107107 for ( let x = start [ 0 ] ; x < end [ 0 ] ; x ++ ) {
108108 for ( let z = start [ 2 ] ; z < end [ 2 ] ; z ++ ) {
109109 for ( let y = start [ 1 ] ; y < end [ 1 ] ; y ++ ) {
110- point . set ( x + 0.5 , y + 0.5 , z + 0.5 ) ;
111- let in_shape = aabbs . some ( box => box . containsPoint ( point ) ) ;
110+ point . set ( x + 0.46 , y + 0.46 , z + 0.46 ) ;
111+ let in_shape : any = aabbs . find ( box => box . containsPoint ( point ) ) ;
112112 if ( ! in_shape && rotated_cubes . length ) {
113113 raycaster . ray . origin . copy ( point ) ;
114- in_shape = rotated_cubes . some ( cube => {
114+ in_shape = rotated_cubes . find ( cube => {
115115 let intersects = raycaster . intersectObject ( cube . mesh ) ;
116- return intersects . length % 2 == 1 ;
116+ let intersection_points = [ ] ;
117+ for ( let intersect of intersects ) {
118+ if ( ! intersection_points . some ( p => p . equals ( intersect . point ) ) ) {
119+ intersection_points . push ( intersect . point ) ;
120+ }
121+ }
122+ return intersection_points . length % 2 == 1 ;
117123 } )
118124 }
119125 matrix . set ( x , y , z , ! ! in_shape ) ;
@@ -246,6 +252,8 @@ BARS.defineActions(() => {
246252 }
247253 }
248254 }
255+
256+ // Grow
249257 for ( let _i = 0 ; _i < grow_iterations ; _i ++ ) {
250258 let keys = Object . keys ( matrix . values ) ;
251259 let key = keys . findLast ( key => matrix . values [ key ] == true ) ;
@@ -280,7 +288,7 @@ BARS.defineActions(() => {
280288 let bb = new BoundingBox ( {
281289 from : [ box [ 0 ] , box [ 1 ] , box [ 2 ] ] ,
282290 to : [ box [ 3 ] + 1 , box [ 4 ] + 1 , box [ 5 ] + 1 ] ,
283- color : i ,
291+ color : 1 ,
284292 name : 'bounding_box'
285293 } ) . addTo ( ) . init ( ) ;
286294 bounding_boxes . push ( bb ) ;
0 commit comments