Home

Awesome

Reaction-Diffusion Simulation in Three.js

<p align="center"> <a href="https://jons.website/projects/reaction-diffusion"> <img src="/misc/images/reaction-diffusion.png" alt="Image of Reaction-Diffusion Simulator" width="75%"> </a> </br> </br> <a href="https://jons.website/projects/reaction-diffusion">Try it out here!</a> </br> </br> </p>

This project is a reaction-diffusion simulator based on the Gray-Scott model. Reaction-Diffusion is an interesting model for pattern formation, and variations of it have been proposed for such phenomena as pigment formations in animals and plants, the Belousov-Zhabotinsky reaction, and the formation of patterns on various corals.

The simulator is driven by three.js. It's GPU-accelerated, it works on mobile, it's easy to embed on your website, and it's easy to customize for your own needs.

If you want to try out a much more robust version of this, I have an app on the App Store you might be interested in.

Usage

  1. Grab the latest release and unzip it wherever you want. Make sure the file structure is intact!
  2. Import the JS in your HTML: <script src="some-folder/reaction-diffusion.js"></script>
  3. Create a div on the same page with the id reaction-diffusion-container. We'll call this the container from here on. A canvas that shows the simulation will be injected as a child of the container.
    • The simulation canvas will automatically resize to fill the container, so make sure the container gets sized somehow.
    • If there's an error loading, the container div will get the class rd-init-failed added. If it succeeds, the class rd-init-success will be added. You can use that for styling.

Optional attributes

Building

License

This repo is provided under the MIT License. If you use my code, please tell me! I'd love to see what you're working on.

Acknowledgments