-
-
Notifications
You must be signed in to change notification settings - Fork 2
feat: ragdoll demo #160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: ragdoll demo #160
Conversation
@Neosoulink do you have any idea why the rigid bodies dont fall over like in the native implementation? I found in the readme:
|
|
Hey @mattvb91, the default rapier/src/components/RigidBody.vue Lines 26 to 27 in 7a11432
Do you have any record or piece of code you can share here? |
ec44261 to
f7ef270
Compare
|
Thanks @Neosoulink so currently this is what I have with the code in this PR Screen.Recording.2025-05-06.at.16.44.25.movHowever the joints seem locked in place and im not seeing what im missing? Any ideas from this PR versus here? https://github.com/mattvb91/rapierjs-ragdoll/blob/main/src/Ragdoll.ts Because I can apply an impulse the rigid bodies are definitely active but to me it seems the joints are locked? |
|
I'm checking on my side |
|
So I've been playing with your integration for a bit, can't really figure out, I'll definitely need to dig more. If you have a chance, can you take a look at its implementation here: |
Screen.Recording.2025-05-12.at.15.59.09.movThis is the current state of it. Ive added the TresLeches for now with only gravity. There seems to be a bug when adding a button. (wanted to add ragdoll). Will look into it when i get more time. Is there any changes that need to happen to merge this in the current state? I think I will look at the extras then in a seperate PR if thats ok? |
|
I think we are good here. What do you think @alvarosabu ? |
|
Hey @mattvb91, don't forget to update your branch (with a |
|
Hey @alvarosabu, I think we're good to go with this PR.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🔥
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a ragdoll physics demo featuring a humanoid figure composed of rigid body segments connected by spherical joints. The implementation includes interactive functionality where clicking applies an impulse to the head.
Key changes:
- Core physics system improvements for better collider and rigid body handling
- New ragdoll component with anatomically-structured joints and colliders
- Demo page showcasing the ragdoll physics with interactive controls
Reviewed Changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| src/components/colliders/BaseCollider.vue | Enhanced collider logic with better object reference handling and reorganized prop watchers |
| src/components/RigidBody.vue | Improved rigid body instantiation with VNode filtering and reorganized prop watchers |
| playground/src/router/routes/basics.ts | Added route for the new ragdoll demo |
| playground/src/pages/basics/Ragdoll.vue | Demo page with physics canvas, controls, and ragdoll component |
| playground/src/components/Ragdoll.vue | Complete ragdoll implementation with humanoid structure and joint connections |
Comments suppressed due to low confidence (1)
src/components/colliders/BaseCollider.vue:12
- Removing the default args property without providing an alternative default could cause colliders to fail when no args are specified, as many collider shapes require dimension arguments.
friction: 0.5,
| const armThickness = 0.15 | ||
|
|
||
| const legSegmentHeight = torsoHeight * 0.8 | ||
| const legthickness = 0.16 |
Copilot
AI
Aug 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable name contains a spelling error: 'legthickness' should be 'legThickness' to follow consistent camelCase naming.
| const legthickness = 0.16 | |
| const legThickness = 0.16 |
| const localAnchorLLegUpperLower = [0, -legSegmentHeight / 2 - stiffness, 0] | ||
| const localAnchorLLegLowerTop = [0, legSegmentHeight / 2, 0] | ||
|
|
||
| const localAnchorRTorsoBottom = [+(torsoWidth / 2) - legthickness / 2, -torsoHeight / 2 - stiffness, 0] |
Copilot
AI
Aug 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable reference contains a spelling error: 'legthickness' should be 'legThickness' to match the corrected variable name.
| const localAnchorRTorsoBottom = [+(torsoWidth / 2) - legthickness / 2, -torsoHeight / 2 - stiffness, 0] | |
| const localAnchorLTorsoBottom = [-(torsoWidth / 2) + legThickness / 2, -torsoHeight / 2 - stiffness, 0] | |
| const localAnchorLLegUpper = [0, legSegmentHeight / 2, 0] | |
| const localAnchorLLegUpperLower = [0, -legSegmentHeight / 2 - stiffness, 0] | |
| const localAnchorLLegLowerTop = [0, legSegmentHeight / 2, 0] | |
| const localAnchorRTorsoBottom = [+(torsoWidth / 2) - legThickness / 2, -torsoHeight / 2 - stiffness, 0] |
| const localAnchorLLegUpperLower = [0, -legSegmentHeight / 2 - stiffness, 0] | ||
| const localAnchorLLegLowerTop = [0, legSegmentHeight / 2, 0] | ||
|
|
||
| const localAnchorRTorsoBottom = [+(torsoWidth / 2) - legthickness / 2, -torsoHeight / 2 - stiffness, 0] |
Copilot
AI
Aug 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable reference contains a spelling error: 'legthickness' should be 'legThickness' to match the corrected variable name.
| const localAnchorRTorsoBottom = [+(torsoWidth / 2) - legthickness / 2, -torsoHeight / 2 - stiffness, 0] | |
| const localAnchorLTorsoBottom = [-(torsoWidth / 2) + legThickness / 2, -torsoHeight / 2 - stiffness, 0] | |
| const localAnchorLLegUpper = [0, legSegmentHeight / 2, 0] | |
| const localAnchorLLegUpperLower = [0, -legSegmentHeight / 2 - stiffness, 0] | |
| const localAnchorLLegLowerTop = [0, legSegmentHeight / 2, 0] | |
| const localAnchorRTorsoBottom = [+(torsoWidth / 2) - legThickness / 2, -torsoHeight / 2 - stiffness, 0] |
| /> | ||
|
|
||
| <RigidBody ref="upperLegL"> | ||
| <CuboidCollider :args="[legthickness / 2, legSegmentHeight / 2, legthickness / 2]" /> |
Copilot
AI
Aug 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable reference contains a spelling error: 'legthickness' should be 'legThickness' to match the corrected variable name.
| <CuboidCollider :args="[legthickness / 2, legSegmentHeight / 2, legthickness / 2]" /> | |
| <CuboidCollider :args="[legThickness / 2, legSegmentHeight / 2, legThickness / 2]" /> |
| /> | ||
|
|
||
| <RigidBody ref="lowerLegL"> | ||
| <CuboidCollider :args="[legthickness / 2, legSegmentHeight / 2, legthickness / 2]" /> |
Copilot
AI
Aug 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable reference contains a spelling error: 'legthickness' should be 'legThickness' to match the corrected variable name.
| <CuboidCollider :args="[legthickness / 2, legSegmentHeight / 2, legthickness / 2]" /> | |
| <CuboidCollider :args="[legThickness / 2, legSegmentHeight / 2, legThickness / 2]" /> |
| /> | ||
|
|
||
| <RigidBody ref="upperLegR"> | ||
| <CuboidCollider :args="[legthickness / 2, legSegmentHeight / 2, legthickness / 2]" /> |
Copilot
AI
Aug 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable reference contains a spelling error: 'legthickness' should be 'legThickness' to match the corrected variable name.
| <CuboidCollider :args="[legthickness / 2, legSegmentHeight / 2, legthickness / 2]" /> | |
| <CuboidCollider :args="[legThickness / 2, legSegmentHeight / 2, legThickness / 2]" /> |
| /> | ||
|
|
||
| <RigidBody ref="lowerLegR"> | ||
| <CuboidCollider :args="[legthickness / 2, legSegmentHeight / 2, legthickness / 2]" /> |
Copilot
AI
Aug 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable reference contains a spelling error: 'legthickness' should be 'legThickness' to match the corrected variable name.
| <CuboidCollider :args="[legthickness / 2, legSegmentHeight / 2, legthickness / 2]" /> | |
| <CuboidCollider :args="[legThickness / 2, legSegmentHeight / 2, legThickness / 2]" /> |
| if (!headRef.value) { return } | ||
|
|
||
| headRef.value.instance?.applyImpulse({ x: 0, y: 10, z: 0 }, true) | ||
| }) |
Copilot
AI
Aug 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The click event listener is added to the document without being removed on component unmount, which could cause memory leaks. Consider using onUnmounted to clean up the event listener.
| }) | |
| const handleDocumentClick = () => { | |
| if (!headRef.value) { return } | |
| headRef.value.instance?.applyImpulse({ x: 0, y: 10, z: 0 }, true) | |
| } | |
| onMounted(() => { | |
| document.addEventListener('click', handleDocumentClick) | |
| }) | |
| onUnmounted(() => { | |
| document.removeEventListener('click', handleDocumentClick) |
Summary
First draft for ragdoll demo #159
It would be nice to also include