Split the Grid System into two pieces. The main thread will have to render it, as a HTMLCanvasRender cannot be run in a web worker. A web worker shall be responsible for building up the scene.
There are multiple challenges with this.
Managing State
Serializing data between the threads.
Consider:
Having two states. The UI state and the Simulation State.
Adopt a micro batching approach to sending data back to the UI for rendering.
This should probably be tunable. One thought is to render a row of cells at a time.
Consider converting Entities and Traits into simple literals. That would eliminate
a large amount of switching in the factories and new-ing up objects. Each entity
is currently reserved in memory twice right now. Once as a deserialized lit, the second
as a provisioned Entity.
Consider using a different data structure to communicate the grid. For example, we could just communicate the alive cells. and assume everything else is dead. Or, adopt a patch approach and only communicate what has changed. ImmerJS can help with that. Could not even have the scene graph on worker thread and try to re-use the same entity for rendering of cells.
Consider using an ArrayBuffer to transfer the cells.
Example of this
Split the Grid System into two pieces. The main thread will have to render it, as a HTMLCanvasRender cannot be run in a web worker. A web worker shall be responsible for building up the scene.
There are multiple challenges with this.
Consider: