schteppe / p2.js

JavaScript 2D physics library
Other
2.63k stars 330 forks source link

Unmount usage in React #353

Open nickmcmillan opened 4 years ago

nickmcmillan commented 4 years ago

I'm using p2 in a React component. I want to ensure that when the component unmounts that the p2 instance is no longer running.

Aside from removing event listeners and cancelling the requestAnimationFrame loop, is there anything specific that needs to be called to tell p2 that it's done? Something like a destroy() method?

I've noticed p2 has a method called "clear" - is this what I'm after?