hastearcade / snowglobe Goto Github PK
View Code? Open in Web Editor NEWA JS port of CrystalOrb
License: Other
A JS port of CrystalOrb
License: Other
Cloneable
all-together by enforcing snapshots and commands be JSON-serializable?Getting the ActiveClient
instance from a client is a little hairy and error-prone. You have to do stuff like:
if (client.state() === StageState.Ready) {
client.stage().ready!...
}
Where we have to manually assert the presence of the ready
property. We could take advantage of a union type/type narrowing to make this more intuitive and "safer".
Furthermore, getting deeply nested properties off of ActiveClient
and company can be really nasty, e.g.
mockClientServer.client1.stage().ready!.timekeepingSimulations.stepper
.lastReceivedSnapshotTimestamp!
By the looks of it, we didn't port over a few methods that would make this a bit cleaner, like this one from ready.rs
:
pub fn last_received_snapshot_timestamp(&self) -> &Option<Timestamp> {
&self
.0
.borrow()
.timekeeping_simulations
.last_received_snapshot_timestamp
}
The equivalent in snowglobe would let us rewrite the above TypeScript snippet as:
mockClientServer.client1.stage().ready!.lastReceivedSnapshotTimestamp()
This function originally tanked performance when we were still using objects for timestamps. I think it's still pretty slow. We should take a look at how it's used to see if we can replace it with a simple comparison, or consider memoizing the result to prevent excess memory allocations and CPU usage.
You use Mock, MockNetwork everywhere, in fact everywhere
I would like to ask you to write an example using Colyseus or Socket.io or Geckos.io, it will help a lot of people
Do a pass over our modules to ensure we're using access modifiers where necessary, using member initialization patterns consistently, naming variables consistently, etc.
CrystalOrb is able to generate unique type identifiers for network messages (clock-sync events, snapshots, commands) using some kind of reflection/metaprogramming feature that we don't have in TypeScript. I quickly decided to categorize message types using integer ids using a function called makeTypeId
.
I made a impulse decision to make Timestamped
entities not "wrapped" like in CrystalOrb. Instead, snowglobe mutates the original object by adding a property with a Symbol key ($timestamp`). At the time, this seemed like it'd be more memory-efficient but may not be ideal.
Do some surface-level performance profiling to get a sense for how many concurrent clients snowglobe can support in a medium-sized simulation.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.