threejs-physics
/threejs-physics
Dodaje fizykę brył sztywnych w three.js i R3F przez Rapier: kolizje, ciała dynamiczne i kinematyczne oraz kontrolery postaci.
- Autor
- emiliodominguez ↗
- Repozytorium
- threejs-skills ↗
- Licencja
- MIT
- Ostatnia zmiana repozytorium
- 27.10.2026
Ocena i bezpieczeństwo
- Pliki w paczce
- 4
- Skrypty
- 0
- Komentarze HTML
- 0
- Adresy URL w SKILL.md
- 0
Brak sygnałów. Repozytorium zmienione 27.10.2026, bez odwołań do wycofanych modeli i API.
MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.
Co robi i kiedy
Dodaje fizykę brył sztywnych w three.js i R3F przez Rapier: kolizje, ciała dynamiczne i kinematyczne oraz kontrolery postaci.
Oryginalny opis (EN)
Rigid-body physics for three.js and R3F with Rapier: colliders from glTF models, dynamic and kinematic bodies, collision events, character controllers. Use when objects fall, collide, get thrown or walked on. Hands off to `threejs-performance`.
Jak działa
- Process
- Anti-patterns
- Done when
Podgląd SKILL.md
---
name: threejs-physics
description: "Rigid-body physics for three.js and R3F with Rapier: colliders from glTF models, dynamic and kinematic bodies, collision events, character controllers. Use when objects fall, collide, get thrown or walked on. Hands off to `threejs-performance`."
---
# Physics with Rapier
Rapier (`@dimforge/rapier3d-compat` 0.21, `@react-three/rapier` 2.2) is the default physics engine for three.js
work: WASM, deterministic, with character controllers and good React bindings. Most physics bugs are scale and
shape problems, not engine problems: bodies in centimeters fall 100 times too slowly, triangle-mesh colliders on
moving bodies tunnel or explode, and rendering at a variable rate while stepping at it makes motion jitter.
## Process
1. Inspect every model that gets a collider (`threejs-model-inspect`): scale must be meters (fix `scale-large`
first; physics in centimeters behaves like slow motion), and note which nodes are the floor, walls and props.
2. Choose collider shapes per object, cheapest that fits:
| Object | Body | Collider |
| --- | --- | --- |
| Floor, walls, level geometry | fixed | trimesh (static only) or cuboids |
| Props that move | dynamic | cuboid, ball, capsule, or convex hull |
| Concave props that move (chairs, cups) | dynamic | several convex shapes, never trimesh |
| Player | kinematicPosition + character controller | capsule |
| Triggers (pickups, zones) | fixed | sensor collider |
3. Read the recipe file for the stack: `references/vanilla.md` or `references/r3f.md`.
4. Step the world at a fixed rate (60 Hz) decoupled from rendering, and interpolate or sync transforms after the
step. `@react-three/rapier` does this with `timeStep={1/60}` and `interpolate` (the defaults).
5. Turn on the debug view while building (`debug` prop, or `world.debugRender()` lines) and check that every
collider hugs its mesh. Turn it off before shipping.
6. Test edge cases on screen: fast objects (enable CCD), stacking (sleeping, friction), and the player on slopes and
steps (autostep, snap to ground).
## Anti-patterns
- Trimesh colliders on dynamic bodies: they collide poorly with other trimeshes and cost far more than hulls.
- Scaling a mesh after its collider was built; the collider keeps the old size. Build colliders from final transforms.
- Setting a dynamic body's mesh position directly; the next step overwrites it. Move bodies through the body API
(`setTranslation`, `applyImpulse`, `setLinvel`) or make them kinematic.
- `world.step()` once per rendered frame on 120 Hz screens: physics runs twice as fast. Accumulate time and step at
a fixed rate.
## Done when
- The debug view shows colliders matching the meshes, and objects rest without jitter.
- Behavior is the same at 60 Hz and 120 Hz refresh rates.
- Fast objects do not pass through thin walls.
Next: `threejs-performance` if body counts grow (instancing with `InstancedRigidBodies`, sleeping, simpler shapes).
Pliki w paczce (4)
- SKILL.md 3 KB
- agents/openai.yaml 1 KB
- references/r3f.md 5 KB
- references/vanilla.md 5 KB
Wersje
W bazie nie ma innych skilli o nazwie threejs-physics.
Migawka bazy z 13.11.2026 · wersja paczki ba9262d760b7 (skrót SHA-256 całej paczki)
Pobrania w ostatnich 30 dniach: 0 · ranking
Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.
Podobne skille
- 100threejs-impl-physics
Dodaje fizykę do sceny Three.js: ciała sztywne, kolizje i ograniczenia z użyciem cannon-es lub Rapier. - 100rapier-physics-3d
Pomaga w fizyce 3D Rapier w Three.js: ciała sztywne, kontakty, złącza, ciągi i masy, a nie fizyka 2D. - 100r3f-physics
Dodaje fizykę 3D w React Three Fiber przez @react-three/rapier: RigidBody, collidery, złącza, kontroler postaci, przeciąganie na sprężynach i wizualizator debugowania. - 903d-physics-game
Buduje responsywne gry 3D w przeglądarce, kontrolery postaci i symulacje fizyki w React Three Fiber i Three.js. - 100iwsdk-physics
Dodaje lub naprawia w IWSDK symulację brył sztywnych, kształty kolizji, siły i chwytanie z fizyką, w tym strojenie grawitacji. - 100physics-engine
Wyjaśnia i projektuje fizykę ciał sztywnych: fazy wykrywania kolizji, solwery więzów, CCD i kontrolery postaci.