I will now explore the files in the project to see the current setup and existing dependencies.
I will now read package.json to check for Three.js and physics library dependencies.
I will now install three, @types/three, cannon-es, and lucide-react to build our 3D ragdoll physics simulation.
I will now read index.html to see the current page title and layout structure.
I will now read src/App.tsx to understand the initial application setup.
I will now update index.html to set an appropriate title for the 3D Ragdoll Physics simulation.
I will now create src/types/physics.ts to define types for ragdoll anatomy, physics parameters, simulation scenarios, and interactive controls.
I will now create src/physics/RagdollBuilder.ts which constructs the 11 rigid bodies and 10 realistic constraints per fighter, creates Three.js meshes with visual styling, and provides methods to spawn and manipulate them.
I will now update src/physics/RagdollBuilder.ts to export BODY_PARTS and derive PARTS_LIST cleanly from it to resolve the unused variable warning.
I will now create src/physics/scenarios.ts to define the various physical interaction test scenarios for our 3D ragdoll fighters.
I will now create src/components/PhysicsArena.tsx to handle the Three.js 3D viewport, Cannon-es physics loop, interactive mouse dragging of ragdoll limbs, lighting, shadows, and real-time simulation statistics.
I will now edit src/components/PhysicsArena.tsx to fix the solver casting, add the floor shape to the floor body, and resolve the unused variable warnings.
I will now edit src/components/PhysicsArena.tsx to fix world.solver type casting and attach floorShape to the floor physics body.
I will now read lines 600-630 of src/components/PhysicsArena.tsx to inspect the grounding stats update logic.
I will now read lines 1-15 of src/components/PhysicsArena.tsx to check imports.
I will now edit src/components/PhysicsArena.tsx to fix the property name mapping for grounding statistics.
I will now create src/components/WorkbenchOverlay.tsx to provide an interactive validation workbench for inspecting joints, applying forces, switching spawn configurations, and modifying environment physics parameters.
I will now remove the unused ShieldAlert and Maximize2 imports from src/components/WorkbenchOverlay.tsx.
I will now update src/App.tsx to integrate the 3D Physics Arena and Workbench Overlay, along with keyboard shortcut listeners for scenario resetting and control toggling.
I will now edit src/App.tsx to remove the unused React import.
I will now build the project to verify that all TypeScript types, Three.js shaders, and Cannon.js bindings compile cleanly.
I have created a 3D humanoid ragdoll physics simulation and validation scene using Three.js and CANNON.ES.
What Was Built:
-
Anatomically Accurate Humanoid Fighters:
- Each fighter is constructed from 11 distinct rigid bodies: Head, Upper Torso (Chest), Lower Torso (Pelvis), Left/Right Upper Arms (Shoulders), Left/Right Lower Arms (Forearms), Left/Right Upper Legs (Thighs), and Left/Right Lower Legs (Shins).
- Visual Differentiation: Sentinel Blue (Fighter 1) with cobalt metallic armor and neon cyan joints/visor vs. Striker Crimson (Fighter 2) with crimson armor and glowing amber joints/visor.
-
Realistic Joint Constraints & Articulation:
- Connected by 10 physics constraints per fighter.
- Elbows & Knees: Built using
CANNON.HingeConstraint with specific bending axes so limbs bend realistically like human joints.
- Shoulders, Hips, Neck & Spine: Built using
CANNON.PointToPointConstraint (ball-and-socket joints).
- Stability Optimization: All joints have
collideConnected = false and the physics solver is configured with iterations = 35 to ensure stable articulation without jitter or joint separation under high impact.
-
Arena Ground Plane & Physical Environment:
- Both fighters stand on a flat arena ground plane (
CANNON.Plane) with custom friction and restitution contact materials.
- Includes lighting with soft shadows (
PCFSoftShadowMap) to highlight contact points and elevation differences as the ragdolls collapse.
-
Natural Standing Spawn & Unscripted Interaction Scenarios:
- When the scene starts, both fighters spawn in a standing position (
Y ~ 1.80m total height). Without scripted balance animations, gravity naturally pulls their torsos and limbs, causing their knees to buckle and bodies to tangle and collapse.
- Includes 7 Validation Scenarios accessible via the control panel or keyboard (
1-7 keys):
- 🤼 Standing Grapple (Default): Fighters stand facing at close range, leaning slightly into each other so their shoulders and arms tangle as they collapse.
- 💥 High-Speed Clash: Spawned further apart and launched toward each other at 4.8 m/s, colliding in mid-stride.
- 🧍♂️ Side-by-Side Domino: Standing shoulder-to-shoulder; one buckles into the other, triggering a chain reaction fall.
Files built: index.html, src/types/physics.ts, src/physics/RagdollBuilder.ts, src/physics/scenarios.ts, src/components/PhysicsArena.tsx, src/components/WorkbenchOverlay.tsx, src/App.tsx