function deriveBoundingBox(rootBox, level, x, y, z) {
  //>>includeStart('debug', pragmas.debug);
  Check.typeOf.object("rootBox", rootBox);
  Check.typeOf.number("level", level);
  Check.typeOf.number("x", x);
  Check.typeOf.number("y", y);
  if (defined(z)) {
    Check.typeOf.number("z", z);
  }
  //>>includeEnd('debug');

  if (level === 0) {
    return rootBox;
  }

  const rootCenter = Cartesian3.unpack(rootBox, 0, scratchRootCenter);
  const rootHalfAxes = Matrix3.unpack(rootBox, 3, scratchHalfAxes);

  const tileScale = Math.pow(2, -level);
  const modelSpaceX = -1 + (2 * x + 1) * tileScale;
  const modelSpaceY = -1 + (2 * y + 1) * tileScale;

  let modelSpaceZ = 0;
  const scaleFactors = Cartesian3.fromElements(
    tileScale,
    tileScale,
    1,
    scratchScaleFactors,
  );

  if (defined(z)) {
    modelSpaceZ = -1 + (2 * z + 1) * tileScale;
    scaleFactors.z = tileScale;
  }

  let center = Cartesian3.fromElements(
    modelSpaceX,
    modelSpaceY,
    modelSpaceZ,
    scratchCenter,
  );
  center = Matrix3.multiplyByVector(rootHalfAxes, center, scratchCenter);
  center = Cartesian3.add(center, rootCenter, scratchCenter);

  let halfAxes = Matrix3.clone(rootHalfAxes);
  halfAxes = Matrix3.multiplyByScale(halfAxes, scaleFactors, halfAxes);

  const childBox = new Array(12);
  Cartesian3.pack(center, childBox);
  Matrix3.pack(halfAxes, childBox, 3);
  return childBox;
}
Derive a bounding volume for a descendant tile (child, grandchild, etc.),
assuming a quadtree or octree implicit tiling scheme. The (level, x, y, [z])
coordinates are given to select the descendant tile and compute its position
and dimensions.
<p>
If z is present, octree subdivision is used. Otherwise, quadtree subdivision
is used. Quadtrees are always divided at the midpoint of the the horizontal
dimensions, i.e. (x, y), leaving the z axis unchanged.
</p>
<p>
This computes the child volume directly from the root bounding volume rather
than recursively subdividing to minimize floating point error.
</p>

@param {number[]} rootBox An array of 12 numbers representing the bounding box of the root tile
@param {number} level The level of the descendant tile relative to the root implicit tile
@param {number} x The x coordinate of the descendant tile
@param {number} y The y coordinate of the descendant tile
@param {number} [z] The z coordinate of the descendant tile (octree only)
@returns {number[]} An array of 12 numbers representing the bounding box of the descendant tile.
@private