Coder Social home page Coder Social logo

cellular_liquid's Introduction

Liquid simulation cellular automata

Implementation of cellular automata that simulates liquid on top of HTML5 canvas using WebAssembly.

Live demo

Compilation

make compile

Note that you can't just open index.html from local filesystem. You need web-server which sets correct mime type (mime .wasm application/wasm) to run WebAssembly. Simpliest solution is to download Caddy server and just run:

make  # This will compile wasm file and then run caddy server

from project root.

How it works

In few words, all algorithm is built on top of only three rules: falling, spreading and decompressing.

Each cell can have limited mass of liquid and may be under limited pressure.

  • First of all, liquid is falling down until it reaches solid surface or already compressed cell of liquid.
  • Then second rule is applied: right after falling down, cell starts to spread around. So it will spread over the surface.
  • Finally, compressed cells starts to flow back upwards.

Most sensitive part of this algorithm is getStableState function which calculates how much cells will compress and decompress. This function allows fluid to have realistic physics and have the effect of communicating vessels.

cellular_liquid's People

Contributors

pashawnn avatar

Watchers

James Cloos avatar  avatar

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.