@@ -986,6 +986,8 @@ export class Solid {
986986
987987 // Explicit CSG operations
988988 public static MERGE ( solids : Solid [ ] ) : Solid {
989+ if ( solids . length > 0 && solids [ 0 ] . isNegative )
990+ throw new Error ( 'First solid in MERGE cannot be negative' ) ;
989991 return solids . reduce (
990992 ( accumulator , solid ) => {
991993 const resultBrush = Solid . evaluator . evaluate (
@@ -1019,20 +1021,29 @@ export class Solid {
10191021
10201022 public static GRID_XYZ (
10211023 solid : Solid ,
1022- options : { cols : number ; rows : number ; levels : number ; spacing ?: [ number , number , number ] }
1024+ options : {
1025+ cols : number ;
1026+ rows : number ;
1027+ levels : number ;
1028+ spacing ?: number | [ number , number , number ] ;
1029+ }
10231030 ) : Solid {
10241031 const solids : Solid [ ] = [ ] ;
10251032 const { width, height, depth } = solid . getBounds ( ) ;
1026- const [ spacingX , spacingY , spacingZ ] = options . spacing ?? [ 0 , 0 , 0 ] ;
1033+ const spacingArray =
1034+ typeof options . spacing === 'number'
1035+ ? [ options . spacing , options . spacing , options . spacing ]
1036+ : ( options . spacing ?? [ 0 , 0 , 0 ] ) ;
1037+ const [ spacingX , spacingY , spacingZ ] = spacingArray ;
10271038
10281039 for ( let x = 0 ; x < options . cols ; x ++ )
10291040 for ( let y = 0 ; y < options . rows ; y ++ )
10301041 for ( let z = 0 ; z < options . levels ; z ++ )
10311042 solids . push (
10321043 solid . clone ( ) . move ( {
10331044 x : x * ( width + spacingX ) ,
1034- y : y * ( height + spacingY ) ,
1035- z : z * ( depth + spacingZ )
1045+ y : z * ( height + spacingY ) ,
1046+ z : y * ( depth + spacingZ )
10361047 } )
10371048 ) ;
10381049
@@ -1047,7 +1058,7 @@ export class Solid {
10471058 cols : options . cols ,
10481059 rows : options . rows ,
10491060 levels : 1 ,
1050- spacing : options . spacing ? [ options . spacing [ 0 ] , options . spacing [ 1 ] , 0 ] : undefined
1061+ spacing : options . spacing ? [ options . spacing [ 0 ] , 0 , options . spacing [ 1 ] ] : undefined
10511062 } ) ;
10521063 }
10531064
0 commit comments