You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Add physics context and integrate into Application and RigidBody components
- Introduced PhysicsProvider to manage physics state and loading.
- Updated ApplicationWithoutCanvas to wrap children with PhysicsProvider.
- Enhanced RigidBody component to check for physics context and handle errors.
- Removed direct dependency on global Ammo instance in favor of context management.
* Update package dependencies and improve error handling in RigidBody component
- Added sync-ammo as a peer dependency in package.json and package-lock.json.
- Updated error message in RigidBody component to guide users on installing sync-ammo if not already done.
- Cleaned up package.json by removing unnecessary dependencies section.
* Enhance physics components and error handling
- Removed outdated comment from physics documentation.
- Updated PhysicsProvider to accept an app prop and manage physics instance count for cleanup.
- Improved error handling in Collision and RigidBody components to use warnOnce utility for better user guidance.
- Modified useComponent hook to handle null component types gracefully.
- Introduced warnOnce utility for logging warnings without repetition.
* Add callout for enabling physics in Collision and RigidBody documentation
- Introduced an info callout in both Collision and RigidBody documentation to guide users on installing `sync-ammo` and enabling physics in the Application.
- Removed outdated note in RigidBody documentation for clarity.
* Update packages/lib/src/contexts/physics-context.tsx
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Update PhysicsProvider to include app dependency in effect hook
- Modified the useEffect hook in PhysicsProvider to include the app dependency for improved state management.
* Add info callout for enabling physics in RigidBody documentation
- Included a callout in the RigidBody documentation to inform users about installing `sync-ammo` and enabling physics in the Application.
- This enhances user guidance and improves clarity in the documentation.
---------
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy file name to clipboardExpand all lines: packages/docs/src/app/docs/api/components/collision/page.mdx
+6Lines changed: 6 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,11 @@
1
1
# Collision
2
2
3
+
import { Callout } from'nextra/components'
4
+
5
+
<Callouttype="info"emoji="️💡">
6
+
Enable physics by installing `npm i sync-ammo` and enabling physics on the Application using`<Application usePhysics/>`.
7
+
</Callout>
8
+
3
9
The `Collision` component attaches a PlayCanvas [Collision Component](https://api.playcanvas.com/classes/Engine.CollisionComponent.html) to an [`Entity`](/api/entity).
4
10
5
11
It allows an [`Entity`](/api/entity) to participate in collision detection with other entities that have collision components. This is useful for physics simulations, trigger zones, and other gameplay mechanics that require detecting when objects intersect.
Copy file name to clipboardExpand all lines: packages/docs/src/app/docs/api/components/rigidbody/page.mdx
+6-4Lines changed: 6 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,13 +1,15 @@
1
1
# Rigidbody
2
2
3
+
import { Callout } from'nextra/components'
4
+
5
+
<Callouttype="info"emoji="️💡">
6
+
Enable physics by installing `npm i sync-ammo` and enabling physics on the Application using`<Application usePhysics/>`.
7
+
</Callout>
8
+
3
9
The `Rigidbody` component enables physics for an [`Entity`](/api/entity), allowing it to interact with the global physics simulation. You can apply forces, torques, and other physics behaviours to an entity with a `Rigidbody` component and it will respond accordingly.
4
10
5
11
You can learn more about how physics work in PlayCanvas in the [Physics docs](https://developer.playcanvas.com/user-manual/physics/).
6
12
7
-
> [!NOTE]
8
-
>
9
-
> To use physics you must enable it on the Application using`<Application usePhysics/>`. See the [Application docs](/api/application) for more information.
// This is a simple physics example and close port of this awesome r3f example - https://codesandbox.io/p/sandbox/bestservedbold-christmas-baubles-forked-wqyzx5
16
-
17
15
const app =useApp();
18
16
const matA =useMaterial({ diffuse: "#c0a0a0", emissive: "red" });
0 commit comments