Skip to content

position.subscribe

Description

When a mesh is assigned to a Cannon body, such as a Box, Sphere, Trimesh, etc., its position and quaternion, will be continually recalculated due to the effects it encounters in the Physics world.

Sometimes you want to override the positioning of a cannon body. You can use the API to update a Cannon bodies position.

In this example, there is a grid of boxes created, and the height of each box is raised and lowered over time to create a wave effect. Dropping a Cannon Sphere onto this wave grid, causes the sphere to roll around.

Working Example

<>
position.subscribe (Working Example) sbedit.net

GitHub Branch

git clone https://github.com/Sean-Bradley/React-Three-Fiber-Boilerplate.git
cd React-Three-Fiber-Boilerplate
git checkout positionSubscribe
npm install
npm start

Comments