ammo-mmd-physics-hacks

Diagnose and fix Ammo.js physics failures in WebGL MMD model rendering.

2.7k|303|Updated Jun 29, 2025
One-click install
npx skills add https://github.com/Project-N-E-K-O/N.E.K.O --skill ammo-mmd-physics-hacks
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ammo-mmd-physics-hacks
Source: https://github.com/Project-N-E-K-O/N.E.K.O/tree/main/.agent/skills/ammo-mmd-physics-hacks
Command: npx skills add https://github.com/Project-N-E-K-O/N.E.K.O --skill ammo-mmd-physics-hacks

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

WebGL-based MMD (MikuMikuDance) character rendering with Ammo.js physics frequently suffers from cloth and hair explosions, mesh clipping, catapult-like vertex launches during fast VMD dance motions, and browser freezes with high-density rigid bodies. This Skill provides targeted root-cause analysis and concrete code-level fixes for these extreme edge cases.

Core Features & Use Cases

  • Symptom-to-Cause Mapping: Diagnoses five classic failure modes including drag-induced stretching, rotation tearing, VMD catapult effects, lying-down collapse, and high-density body freezes.
  • Concrete Fix Patterns: Provides specific Ammo.js API corrections such as MotionState synchronization instead of setWorldTransform, velocity limiters, local gravity and floor transforms, and differentiated collision margins.
  • WASM Pitfall Guidance: Covers Bullet/WebAssembly memory leak avoidance and static plane replacement with thin box shapes.
  • Use Case: When your MMD character's skirt explodes into spikes during a fast dance animation in the browser, use this Skill to identify the kinematic sync issue and apply the velocity clamping fix.

Quick Start

Ask the AI to diagnose why my MMD model's clothes explode and clip through the body during fast VMD dance animations in the browser using Ammo.js.

Frequently Asked Questions about ammo-mmd-physics-hacks

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix MMD cloth physics exploding in the browser?

Cloth explosions in Ammo.js MMD physics usually come from incorrect kinematic body synchronization. Replace direct setWorldTransform calls with MotionState-based updates so Bullet computes proper collision momentum, and add a velocity limiter that clamps linear velocity above 50 and angular velocity above 30.

Why does my MMD model's hair stretch when dragging the model?

Hair stretching during dragging happens when Mode 2 rigid bodies are downgraded to Mode 1, losing their anchor points. Restore proper Mode 2 kinematic sync using setCenterOfMassTransform with MotionState updates, and set activation state to 4 to prevent bodies from sleeping.

Does increasing physics iterations fix Ammo.js clipping issues?

No, raising numIterations to high values like 100 destroys browser frame rates on the single-threaded main loop. The recommended approach is code-space constraints such as velocity clamping, differentiated collision margins, and local gravity transforms instead of brute-force solver iterations.

Why do MMD clothes clip through the body during fast dance animations?

Ghost clipping occurs because bone-synced torso bodies use setWorldTransform, which teleports them each frame with no continuous motion state, giving Bullet no momentum feedback. Feeding transforms through getMotionState().setWorldTransform() lets the engine derive impact velocity and repel incoming cloth.

What causes Ammo.js memory leaks in WebGL physics loops?

Creating new Ammo.btVector3 objects inside per-frame loops leaks WASM heap memory because JavaScript garbage collection cannot reach the underlying C++ allocations. Reuse a single persistent vector instance and update it with setValue() each frame instead.

How do I handle MMD physics when the character lies down?

Global downward gravity crushes clothing against the body when the character lies flat. Convert gravity to a local body-relative direction using the mesh quaternion, and bind the floor plane's rotation to the mesh so the ground follows the character's orientation.