liquidfun-play-2 icon indicating copy to clipboard operation
liquidfun-play-2 copied to clipboard

liquidfun-play-2

Note: Requires Chrome/Chromium-based browser in development. Firefox and Safari supported after production bundle.

Demo

Demonstrates functionality of box2d-wasm's liquidfun release.

Iterates on my previous liquidfun-play repository with the following changes:

  • introduces WebAssembly SIMD optimization from newer box2d-wasm release
  • no longer delegates physics to a Web Worker; workers have disadvantages:
    • more difficult to develop
    • various features either unsupported or complex to bundle for some browsers
    • the main thread had no work to do anyway! better to have fewer cores active, so CPU can boost to higher clock speeds
  • implements water shaders from Liquidfun's EyeCandy demo

Achieves high framerate by:

  • avoiding allocations in main loop
    • no new
    • no []
    • no {}
    • pre-allocate structures
    • fewer allocations = (fewer?) (shorter?) GC pauses
  • minimize JS->wasm calls in favour of accessing Emscripten heap directly
  • physics via WebAssembly with SIMD acceleration
  • rendering in WebGL

Usage

npm start

Runs the app in the development mode. Open http://localhost:8080 to view it in the browser.

License

This repository is Zlib-licensed (full text in LICENSE.zlib.txt).
Additionally, contributions ported or adapted from the liquidfun repository are licensed as described in LICENSE.liquidfun.txt.