dist/index.js
function fit(object, x, y, z, keep_aspect_ratio) {
  var a;
  if (Array.isArray(x)) {
    a = x;
    keep_aspect_ratio = y;
    x = a[0];
    y = a[1];
    z = a[2];
  } else {
    a = [x, y, z];
  }

  // var c = util.centroid(object);
  var size = this.size(object.getBounds());

  function scale(size, value) {
    if (value == 0) return 1;
    return value / size;
  }

  var s = [scale(size.x, x), scale(size.y, y), scale(size.z, z)];
  var min = util.array.min(s);
  return util.centerWith(
    object.scale(
      s.map(function(d, i) {
        if (a[i] === 0) return 1; // don't scale when value is zero
        return keep_aspect_ratio ? min : d;
      })
    ),
    "xyz",
    object
  );
}
function fit(object, x, y, z, keep_aspect_ratio) {
  var a;
  if (Array.isArray(x)) {
    a = x;
    keep_aspect_ratio = y;
    x = a[0];
    y = a[1];
    z = a[2];
  } else {
    a = [x, y, z];
  }

  // var c = util.centroid(object);
  var size = this.size(object.getBounds());

  function scale(size, value) {
    if (value == 0) return 1;
    return value / size;
  }

  var s = [scale(size.x, x), scale(size.y, y), scale(size.z, z)];
  var min = util.array.min(s);
  return util.centerWith(
    object.scale(
      s.map(function(d, i) {
        if (a[i] === 0) return 1; // don't scale when value is zero
        return keep_aspect_ratio ? min : d;
      })
    ),
    "xyz",
    object
  );
}
function fit ( object , x , y , z , keep_aspect_ratio ) { var a ; if ( Array . isArray ( x ) ) { a = x ; keep_aspect_ratio = y ; x = a [ 0 ] ; y = a [ 1 ] ; z = a [ 2 ] ; } else { a = [ x , y , z ] ; } // var c = util.centroid(object); var size = this . size ( object . getBounds ( ) ) ; function scale ( size , value ) { if ( value == 0 ) return 1 ; return value / size ; } var s = [ scale ( size . x , x ) , scale ( size . y , y ) , scale ( size . z , z ) ] ; var min = util . array . min ( s ) ; return util . centerWith ( object . scale ( s . map ( function ( d , i ) { if ( a [ i ] === 0 ) return 1 ; // don't scale when value is zero return keep_aspect_ratio ? min : d ; } ) ) , "xyz" , object ) ; }
Fit an object inside a bounding box.  Often used
with text labels.
@param  {CSG} object            [description]
@param  {number | array} x                 [description]
@param  {number} y                 [description]
@param  {number} z                 [description]
@param  {boolean} keep_aspect_ratio [description]
@return {CSG}                   [description]
Fit an object inside a bounding box . Often used with text labels .