Skip to content

Commit

Permalink
Update body collide event to correctly return collided bodies
Browse files Browse the repository at this point in the history
  • Loading branch information
codynova committed Apr 6, 2020
1 parent 02842c8 commit 1f0cef6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "use-cannon",
"version": "0.4.1",
"version": "0.4.2",
"description": "physics based hooks for react-three-fiber",
"keywords": [
"cannon",
Expand Down
6 changes: 3 additions & 3 deletions src/Provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ export type WorkerCollideEvent = {
data: {
op: 'event'
type: 'collide'
body: string
target: string
body: string
contact: {
ni: number[]
ri: number[]
Expand Down Expand Up @@ -143,10 +143,10 @@ export default function Provider({
case 'event':
switch (e.data.type) {
case 'collide':
events[e.data.body]({
events[e.data.target]({
...e.data,
body: refs[e.data.body],
target: refs[e.data.target],
body: refs[e.data.body],
})
break
case 'rayhit':
Expand Down
2 changes: 1 addition & 1 deletion src/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ self.onmessage = (e) => {
world.addBody(body)

if (onCollide)
body.addEventListener('collide', ({ type, contact, target }) => {
body.addEventListener('collide', ({ type, body, target, contact }) => {
const { ni, ri, rj } = contact
self.postMessage({
op: 'event',
Expand Down

1 comment on commit 1f0cef6

@codynova
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addresses #65

Please sign in to comment.