glTF Physics and Rigid Body Mechanics Explained
The proposed Khronos draft extension for glTF physics, primarily
formulated as KHR_physics_rigid_bodies, standardizes how
real-time physics data is authored and exchanged across 3D tools and
runtime engines. This article examines the extension's architecture,
outlining how it integrates rigid body dynamics, collision shapes,
physical materials, and joint constraints into glTF's node
hierarchy.
Modular Architecture
The glTF physics draft decouples visual assets from simulation data while keeping them linked to the scene graph. The specification structures rigid body mechanics into four primary elements:
- Collision Shapes: Geometric definitions used strictly for collision detection.
- Physics Materials: Surface properties affecting interaction behaviors, such as friction and restitution.
- Rigid Bodies: Dynamic properties applied to specific nodes, defining mass and motion state.
- Constraints: Joints that restrict relative translation and rotation between connected bodies.
Collision Shapes and Materials
Collision detection is handled separately from visual rendering to optimize performance. The draft defines primitive colliders (spheres, boxes, capsules, and cylinders) as well as complex geometries (convex hulls and triangle meshes).
These colliders reference physics materials that govern contact behavior:
- Static and Dynamic Friction: Dictate resistance to sliding motion.
- Restitution: Governs the bounciness of an object upon impact.
- Combine Modes: Specify mathematical rules (average, minimum, maximum, or multiply) for resolving interactions when two different materials collide.
Rigid Body Definition and Motion Types
A rigid body is instantiated by extending a node in the glTF
hierarchy with the KHR_physics_rigid_bodies extension. The
specification categorizes motion into three distinct types:
- Dynamic: Fully simulated objects influenced by forces, impulses, gravity, and collisions.
- Kinematic: Objects driven explicitly by transforms, timelines, or programmatic input, moving without being displaced by dynamic objects.
- Static: Immovable environment geometry that collides with dynamic objects but possesses infinite mass and zero velocity.
For dynamic bodies, the extension defines mass properties including total mass, the center of mass offset relative to the node, and the inertia tensor. It also supports initial linear and angular velocity vectors, gravity scale multipliers, and flags to designate whether a body serves as a solid collider or a non-solid trigger/sensor.
Joint Constraints
To model articulated mechanics such as hinges, ragdolls, suspension, and mechanical linkages, the draft introduces physics constraints. Constraints bind two rigid bodies (or one body and the world frame) via local reference frames.
The extension defines multiple constraint archetypes:
- Fixed: Completely locks relative translation and rotation.
- Revolute (Hinge): Permits rotation around a single axis while locking other degrees of freedom.
- Prismatic (Slider): Permits linear translation along a single axis.
- Spherical (Ball-and-Socket): Permits free three-axis rotation around a shared point while locking linear displacement.
- Generic (6-DOF): Provides configurable linear and angular limits, springs, and dampening parameters across all three positional and rotational axes.
Collision Filtering
To control which objects interact, the draft integrates a collision filtering system based on collision groups and mask layers. Objects are assigned to one or more bitmask categories, allowing runtimes to skip broadphase and narrowphase collision checks between non-interacting layers (such as debris passing through friendly characters).