3D Convex Hull Libraries for glTF Geometry

Computing three-dimensional convex hulls from glTF (GL Transmission Format) assets is a common task in game development, physics simulation, robotics, and 3D web applications. Because glTF files store geometry as indexed vertex buffers, processing them requires either an integrated 3D library capable of both parsing glTF and generating hulls, or a combination of a dedicated glTF parser and a computational geometry library. This guide covers the leading open-source libraries across Python, JavaScript, and C++ that can compute 3D convex hulls from glTF geometry.

1. Trimesh (Python)

Trimesh is a comprehensive Python library for loading, manipulating, and analyzing triangular meshes. It features native, out-of-the-box support for both .gltf and .glb files.

  • How it works: When you load a glTF file using trimesh.load(), it parses the scene graph and extracts the mesh nodes. Calling the .convex_hull property on any loaded mesh or scene automatically computes a watertight 3D convex hull using Qhull under the hood.
  • Best for: Rapid prototyping, offline asset preprocessing, robotics simulation pipelines, and data analysis.

2. Three.js (JavaScript / WebGL)

Three.js is the standard 3D library for the web and provides complete tooling for loading glTF models and generating convex hulls directly in the browser or in Node.js.

  • How it works: Geometry is imported using GLTFLoader. Once the target Mesh or BufferGeometry is retrieved, its vertex attributes are passed to ConvexGeometry (found in the Three.js addon modules). Internally, ConvexGeometry executes an implementation of the Quickhull algorithm to build a new mesh representing the hull.
  • Best for: Web applications, browser-based games, and client-side bounding geometry generation.

3. Open3D (C++ and Python)

Open3D is a modern library geared toward 3D data processing, computer vision, and geometry computation.

  • How it works: Open3D natively imports glTF and GLB files into its TriangleMesh data structure via open3d.io.read_triangle_mesh. Once imported, you can invoke the compute_convex_hull() method, which calculates the 3D convex hull along with a vertex-to-original-mesh mapping.
  • Best for: High-performance desktop software, point cloud processing, and research applications where performance in both C++ and Python is required.

4. Modular C++ Pipelines: tinygltf / cgltf + Qhull / Bullet

In high-performance game engines or custom C++ renderers, developers typically decouple file parsing from geometric computation:

  • glTF Parsers:
    • tinygltf: A single-header C++ library that parses glTF 2.0 files and decodes vertex buffers into standard arrays.
    • cgltf: A lightweight, single-file C library for glTF 2.0 parsing.
  • Convex Hull Solvers:
    • Qhull: The industry-standard C library that implements the Quickhull algorithm for computing convex hulls in arbitrary dimensions.
    • Bullet Physics (btShapeHull): If the glTF geometry is intended for collision detection, Bullet's collision engine extracts raw vertex arrays and uses btShapeHull to produce a simplified, watertight convex collision shape.
  • Best for: Custom game engines, embedded systems, and AAA simulation systems that require strict memory and performance controls.