-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update @dimforge/rapier3d-compat to 0.12.0
- Loading branch information
1 parent
e2b361f
commit 2ff8e9f
Showing
12 changed files
with
252 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
"@react-three/rapier": minor | ||
--- | ||
|
||
feat: update @dimforge/rapier3d-compat to 0.12.0 | ||
|
||
- Physics component | ||
- World integration parameters have changed in the new rapier version. As the new version of rapier has changes to it's constraint solver, there aren't direct alternatives for all old parameters. | ||
- Add 'useSpringJoint' | ||
- Add 'useRopeJoint' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { Sphere } from "@react-three/drei"; | ||
import { | ||
BallCollider, | ||
RapierRigidBody, | ||
RigidBody, | ||
RigidBodyOptions, | ||
useRopeJoint | ||
} from "@react-three/rapier"; | ||
import { useRef } from "react"; | ||
import { Demo } from "../../App"; | ||
|
||
// todo: flesh out this demo | ||
|
||
const RopeJoint = (props: RigidBodyOptions) => { | ||
const anchor = useRef<RapierRigidBody>(null); | ||
const ball = useRef<RapierRigidBody>(null); | ||
|
||
useRopeJoint(anchor, ball, [[0, 0, 0], [0, 0, 0], 1]); | ||
|
||
return ( | ||
<group> | ||
<RigidBody ref={anchor} {...props} /> | ||
|
||
<RigidBody ref={ball} {...props} colliders={false}> | ||
<Sphere scale={0.2} receiveShadow castShadow> | ||
<meshStandardMaterial metalness={1} roughness={0.3} /> | ||
</Sphere> | ||
|
||
<BallCollider args={[0.2]} restitution={1.2} /> | ||
</RigidBody> | ||
</group> | ||
); | ||
}; | ||
|
||
export const RopeJointExample: Demo = () => { | ||
return ( | ||
<group rotation={[1, 0, 0]} scale={3}> | ||
<RopeJoint position={[0, 0, 0]} /> | ||
</group> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { Sphere } from "@react-three/drei"; | ||
import { | ||
BallCollider, | ||
RapierRigidBody, | ||
RigidBody, | ||
RigidBodyOptions, | ||
useSpringJoint | ||
} from "@react-three/rapier"; | ||
import { useRef } from "react"; | ||
import { Demo } from "../../App"; | ||
|
||
const Spring = (props: RigidBodyOptions) => { | ||
const anchor = useRef<RapierRigidBody>(null); | ||
const ball = useRef<RapierRigidBody>(null); | ||
|
||
useSpringJoint(anchor, ball, [[0, 0, 0], [0, 0, 0], 2, 20, 2]); | ||
|
||
return ( | ||
<group> | ||
<RigidBody ref={anchor} {...props} /> | ||
|
||
<RigidBody ref={ball} {...props} colliders={false}> | ||
<Sphere scale={0.2} receiveShadow castShadow> | ||
<meshStandardMaterial metalness={1} roughness={0.3} /> | ||
</Sphere> | ||
|
||
<BallCollider args={[0.2]} restitution={1.2} /> | ||
</RigidBody> | ||
</group> | ||
); | ||
}; | ||
|
||
export const SpringExample: Demo = () => { | ||
return ( | ||
<group rotation={[1, 0, 0]} scale={3}> | ||
<Spring position={[0, 0, 0]} /> | ||
</group> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.