Class GltfBoundingBoxReader

java.lang.Object
io.goobi.viewer.model.media.voyager.GltfBoundingBoxReader

public final class GltfBoundingBoxReader extends Object
Reads the axis-aligned bounding box center of a GLTF 2.0 or GLB 3D model without a dedicated GLTF library.

The GLTF 2.0 specification requires that every vertex-position accessor carries min and max arrays. This class extracts those values directly from the JSON metadata, making binary buffer parsing unnecessary.

All methods are static; this class is not meant to be instantiated.

  • Method Details

    • computeBounds

      public static double[][] computeBounds(Path gltfFile) throws IOException
      Returns the axis-aligned bounding box of all meshes in the given GLTF or GLB file.
      Parameters:
      gltfFile - path to a .gltf or .glb file
      Returns:
      double[2][3] where [0] is the global min and [1] is the global max; both are [0,0,0] if no POSITION accessor min/max data is found
      Throws:
      IOException - if the file cannot be read
    • computeCenter

      public static double[] computeCenter(Path gltfFile) throws IOException
      Computes the bounding-box centre of all meshes in the given GLTF or GLB file.
      Parameters:
      gltfFile - path to a .gltf or .glb file
      Returns:
      double[3] with [x, y, z] of the centre; [0, 0, 0] if no POSITION accessor min/max data is found
      Throws:
      IOException - if the file cannot be read