A 3D cellular automata simulation synchronized with electronic music. All of the code is contained within the main.html file.
The live website can be viewed here: 3D Cellular Automata Simulation.
The grid size should be kept less than or equal to 20x20x20, you can set this by adjusting the grid size parameter in the menu. No performance optimizations are used, so this simulation is only suitable for smaller grids. You can also adjust the fraction of cubes alive, this value should be a float between 0 and 1, note that a value of 0 will kill all of the cubes. You can also adjust the cube size, you may also need to adjust the cube spacing, if you make the cubes too big and they start to overlap strange behavior can occur. You can change the background color to a solid rgb color, make sure the format remains consistent to what is preset in the text input. If you let the simulation run you will notice the background is a pulsing radial gradient, setting the background color will only change the center of the radial gradient. If you want to get rid of the radial gradient you can modify the code. The rotational velocity dictates how fast the cube rotates in the x & y directions, by default this is set to be a function of the song's frequency, so if you want full control, use the pause button in the settings menu.
The update rules of the automata are governed by two sets, rule 1 and rule 2. I have called rule 1 the survival criterion, any cube with n neighbors where n is also a member of rule 1 will survive to a future generation, all other live cubes will die. Rule 2 is the Rebirth criterion, any dead cube with m neighbors where m is also a member of rule 2 will be reborn. There are two neighborhood functions that I have defined, you have full control to select which neighborhood to run your simulation. The standard neighborhood only considers cubes the border one of the cubes 6 faces to be a neighbor. The extended neighborhood, considers all 26 cubes surrounding a single cube a neighbor. The simulation speed, is how fast the updates are applied to the 3D grid of cubes. The spatial oscillation checkbox refers to the dynamic change in inter-cube spacing, you can make this feature more pronounced by setting the javaScript variables upperOscLimit & lowerOscLimit.
The longer a cube survives the whiter it becomes. I have preset 3 themes (yellow, black, and green), one of these themes is randomly selected when the page is loaded, I have added a slight probabalistic edge for black becuase it is my favorite. To make the simulation more interesting the rule sets mutates over time, the neighborhood function may also periodically change. The flashing light on the screen border is also synchronized with the audio frequency.
Due to the audio api I am using, this simulation will only work on the Google Chrome web browser.