Esta página se muestra en inglés. Una traducción al español está en curso.
ConfigsMay 30, 2026·3 min de lectura

Rapier — Fast 2D and 3D Physics Engine in Rust

A high-performance open-source physics engine for rigid body simulation, collision detection, and joint constraints, with native Rust and JavaScript/WASM bindings.

Listo para agents

Instalación lista para agent

Este activo puede instalarse después de elegir el runtime, revisar el plan y ejecutar el comando correspondiente.

Native · 98/100Política: permitir
Superficie agent
Cualquier agent MCP/CLI
Tipo
Skill
Instalación
Single
Confianza
Confianza: Established
Entrada
Rapier
Comando de instalación directa
npx -y tokrepo@latest install ccb8bee3-5bdf-11f1-9bc6-00163e2b0d79 --target codex

Ejecutar después de confirmar el plan con dry-run.

Introduction

Rapier is a set of 2D and 3D physics simulation libraries written in Rust with first-class WebAssembly support. It provides rigid body dynamics, collision detection, and joint constraints suitable for games, robotics simulations, and interactive applications.

What Rapier Does

  • Simulates rigid body dynamics with gravity, forces, and impulses
  • Detects collisions between convex shapes, trimeshes, and heightfields
  • Supports joints and constraints including revolute, prismatic, and fixed types
  • Provides continuous collision detection (CCD) to prevent tunneling
  • Exposes a deterministic simulation mode for lockstep multiplayer

Architecture Overview

Rapier is built on the nalgebra linear algebra library and uses an island-based constraint solver with SIMD acceleration. The collision detection pipeline implements a broad-phase sweep-and-prune algorithm followed by narrow-phase GJK/EPA queries. The engine compiles natively to Rust targets and to WebAssembly via wasm-bindgen, sharing the same core simulation code across platforms.

Self-Hosting & Configuration

  • Add rapier2d or rapier3d as a Cargo dependency for Rust projects
  • Use the @dimforge/rapier2d or rapier3d npm packages for JavaScript/WASM
  • Configure gravity, timestep, and solver iterations via IntegrationParameters
  • Enable CCD on fast-moving bodies to prevent objects passing through walls
  • Use debug rendering with Bevy or other engines via the rapier-debug-render feature

Key Features

  • Cross-platform via native Rust and WebAssembly compilation
  • Deterministic simulation for reproducible physics across clients
  • Bevy integration through the bevy_rapier plugin for game development
  • Event system for collision start/stop and contact force reporting
  • Serialization support for saving and restoring simulation state

Comparison with Similar Tools

  • Box2D — mature 2D engine but C++ only, no built-in Rust or WASM support
  • Bullet — feature-rich 3D engine but heavier and more complex API
  • PhysX — high-performance but proprietary NVIDIA SDK
  • Cannon.js — JavaScript-native physics but slower than WASM-based Rapier
  • Avian (formerly heron) — Bevy-specific wrapper but Rapier powers it underneath

FAQ

Q: Can Rapier handle soft bodies or fluids? A: No. Rapier focuses on rigid body simulation. For soft bodies, consider complementary libraries.

Q: Is the WASM build slower than native Rust? A: WASM performance is typically 1.5-3x slower than native, but still fast enough for real-time game physics in the browser.

Q: Does Rapier support multithreading? A: Yes. The parallel feature enables rayon-based multithreaded simulation on native targets.

Q: What game engines integrate with Rapier? A: Bevy (via bevy_rapier), Godot (via godot-rapier), and any engine that can call Rust or WASM code.

Sources

Discusión

Inicia sesión para unirte a la discusión.
Aún no hay comentarios. Sé el primero en compartir tus ideas.

Activos relacionados