Giter Club home page Giter Club logo

Comments (8)

mreinstein avatar mreinstein commented on June 4, 2024 1

Oops! I completely misinterpreted what was going on in src/serializer.ts. Thanks again, this is super helpful!

from planck.js.

shakiba avatar shakiba commented on June 4, 2024 1

Current serializer is optimized for saving/loading a world in a readable format, and is not optimized for fast and efficient networking.

For networking I recommend directly iterating over all objects and fields and write to and read from an efficient stream.

from planck.js.

mreinstein avatar mreinstein commented on June 4, 2024

Here's a list of things so far that seem like might be sufficient to sync a physics object's state:

  • object id (does planck.js generate one for all objects/fixtures/etc. ?)
  • angle
  • angularVelocity
  • position (vec)
  • linear velocity (vec)

Are there any other things that might need to be sync'd? I'm not sure how I'd go about syncing a joint constraint for example

from planck.js.

zOadT avatar zOadT commented on June 4, 2024

Hey! There is a serializer in src/serializer already. It isn't optimized for file size, but you can probably follow it for your implementation

from planck.js.

mreinstein avatar mreinstein commented on June 4, 2024

Ah, thanks for the pointer! So it seems this serializer is just enumerating all the object/array props, rather than a hardcoded list.

from planck.js.

zOadT avatar zOadT commented on June 4, 2024

I don't think it just enumerates all props, see for example _serialize in Body.ts. Every class defines what properties are relevant this way (so it is hardcoded per class)

from planck.js.

mreinstein avatar mreinstein commented on June 4, 2024

For networking I recommend directly iterating over all objects and fields and write to and read from an efficient stream.

That's the plan, I just didn't have any list of the "important" fields that one might need to sync for different primitives (fixtures, joints, etc.)

from planck.js.

shakiba avatar shakiba commented on June 4, 2024

Hmm, I'm not quite sure, but happy to help with implementation.

We probably need to implement an interface like current serialize but write to a streaming interface (instead of json).

We also need to find out the answer to your question, probably we can see how this is implemented in C++ for Box2D.

from planck.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.