piqnt / planck.js

2D JavaScript Physics Engine
http://piqnt.com/planck.js/
MIT License
4.87k stars 236 forks source link

Serialization #36

Open yang opened 6 years ago

yang commented 6 years ago

Thanks for the nice library!

Any advice on how to accurately serialize the state of a planck World? Simply iterating over all bodies/fixtures and copying their positions/velocities/vertices/etc. doesn't work for collisions in progress, etc. There are also a few Function objects in the object hierarchy, hindering more straightforward serialization mechanisms. (FWIW, serialization is something that libraries like matter.js do support out-of-the-box.) Thanks!

shakiba commented 6 years ago

I'm not sure it is possible to correctly serialize when a collision is in progress. Box2D classes have dump function which I did not rewrite in JS, but a similar mechanism is probably the solution.