# Fruit Fly Simulation: Explore a Fruit Fly Brain in Your Browser

Source: [Canonical page](https://dirs.apphall.org/blog/fruit-fly-simulation-explore-a-fruit-fly-brain-in-your-browser)

Fruit Fly Simulation is an interactive browser-based neuroscience project that lets users stimulate neurons, observe activity spreading through a large fruit fly connectome, and watch a 3D fly respond. Powered by WebGPU and Three.js, it demonstrates how complex biological simulations can run directly in the browser.

[**Fruit Fly Simulation**](<https://huggingface.co/spaces/Xenova/fruit-fly-simulation>) is an interactive browser-based project that lets users explore how neural activity can propagate through a fruit fly connectome and influence the movement of a 3D fly.

Created by Xenova and available as a Hugging Face Space, the project combines neuroscience data, WebGPU computing, interactive visualization, and Three.js animation into a surprisingly accessible experience.

Instead of looking at a static neural network diagram, users can directly stimulate groups of neurons and watch the simulated activity spread through the network. The resulting signals are then translated into behaviors such as walking, turning, and flight-related movement.

The entire experience runs directly in the browser.

## What Is Fruit Fly Simulation?

Fruit Fly Simulation, also known as **Neural Canvas**, turns a large fruit fly neural connectivity dataset into an interactive experiment.

The interface includes a neural canvas where users can paint over or select neurons. Once those neurons are stimulated, the application calculates how activity propagates through the connectome.

At the same time, a 3D fruit fly responds to the simulated neural output.

The interaction can be summarized as:

```
Select neurons 
↓ 
Stimulate the network 
↓ 
Propagate neural activity 
↓ 
Convert neural output into movement 
↓ 
Watch the 3D fly respond
```

This approach makes an extremely complex biological dataset much easier to understand.

Rather than dealing with large connectivity tables or abstract graphs, users can interact with the nervous system visually and immediately see the result.

## A Large-Scale Fruit Fly Connectome

The project is built around a large fruit fly nervous system connectivity dataset.

A **connectome** is essentially a wiring map of a nervous system. It describes how neurons are connected to one another and can be used as a foundation for studying how signals may travel through neural circuits.

Fruit Fly Simulation includes roughly **166,700 neural entries** and more than **25 million directed connections**.

That scale is important.

Even a relatively small biological nervous system contains an enormous number of relationships between neurons. Visualizing and processing such a network interactively is computationally demanding.

The project solves part of that challenge by representing neural propagation as a sparse computational problem and running much of the workload on the user's GPU.

## WebGPU-Powered Neural Simulation

One of the most notable features of Fruit Fly Simulation is its use of **WebGPU**.

WebGPU is a modern browser technology that gives web applications direct access to GPU computing capabilities. It is often associated with machine learning, graphics, and AI inference, but this project demonstrates a different use case: biological network simulation.

The application uses WebGPU to accelerate neural propagation across a large sparse network.

Its codebase includes dedicated GPU logic and WGSL shaders for processing neural activity.

In simplified form, the pipeline works like this:

```
Neural connectivity data 
↓ 
Selected neurons receive stimulation 
↓ 
Activity propagates across connections
↓ 
WebGPU performs parallel calculations 
↓
Updated neural activity is produced
```

This allows the simulation to feel responsive even though the underlying network contains millions of connections.

The project also uses Hugging Face's experimental @huggingface/kernels package, which helps run computational kernels through modern browser GPU technologies.

For systems without WebGPU support, the application provides a JavaScript compute fallback.

## From Neural Signals to Fly Behavior

After neural activity is calculated, the project converts parts of the simulated output into movement controls for the 3D fly.

These controls influence behaviors such as:

- walking,

- turning left,

- turning right,

- and flight-related movement.

However, it is important to understand what the project is—and what it is not.

Fruit Fly Simulation is not a complete digital reconstruction of a real fruit fly's behavior.

The movement system is intentionally designed to demonstrate how neural signals can be connected to visible actions. The walking and flying behaviors should therefore be viewed as illustrative outputs rather than scientifically validated predictions of exactly how a real fruit fly would behave under the same neural stimulation.

That distinction makes the project more useful as an educational, visualization, and computational experiment rather than a complete biological simulation.

## Interactive 3D Visualization with Three.js

The 3D fly is rendered using **Three.js**, one of the most widely used JavaScript libraries for browser-based 3D graphics.

The fly is articulated rather than simply being a prerecorded animation.

The project includes logic for:

- body structure,

- leg movement,

- gait control,

- camera perspectives,

- and inverse kinematics.

This helps create a more dynamic connection between neural activity and physical movement.

Instead of simply switching between static animation clips, the fly's movements can respond continuously to control parameters generated by the simulation.

Users can also view the fly from different perspectives, making the application feel closer to a small interactive laboratory environment.

## No Remote AI Server Required

A particularly interesting aspect of the project is its architecture.

Many AI and simulation applications depend on a remote backend. A typical workflow might look like this:

```markdown
Browser 
↓ 
API request 
↓
Python backend
↓ 
Cloud GPU 
↓
Response
```

Fruit Fly Simulation takes a different approach.

Its important assets, neural data, rendering components, and compute logic are delivered directly to the browser.

The browser then performs the computation locally using WebGPU and renders the fly using WebGL.

The architecture is closer to:

```markdown
Static website 
      ↓ 
    Browser 
      ↙ ↘ 
WebGPU  WebGL
compute  rendering
```

This means the project does not require an API key or a remote inference server for its core functionality.

It can effectively behave like a static web application while still running a computationally interesting neural simulation.

That is one of the strongest demonstrations of what modern browser technology can now support.

## Why Fruit Fly Simulation Stands Out

Fruit Fly Simulation is interesting for several reasons.

### It Makes Neuroscience Easier to Explore

Connectome datasets are usually difficult for non-specialists to interpret.

By allowing users to directly stimulate neurons and watch activity spread through the system, Neural Canvas turns complex neural connectivity into something visual and interactive.

This can make the underlying concepts much easier to understand.

### It Shows a Different Side of WebGPU

Most discussions around WebGPU focus on running language models, image generation systems, or other AI workloads in the browser.

Fruit Fly Simulation shows that WebGPU can also be useful for scientific computing, sparse graph processing, and neural network propagation.

This makes the project relevant not only to neuroscience enthusiasts but also to developers interested in browser-based GPU computing.

### It Combines Multiple Technologies in a Simple Interface

Behind the interface, the project brings together several technically interesting components:

- large-scale biological connectivity data,

- sparse network computation,

- WebGPU,

- WGSL kernels,

- Three.js,

- inverse kinematics,

- and browser-native deployment.

Yet the user experience remains straightforward.

Users simply select neurons, stimulate them, and observe the result.

### It Hints at the Future of Browser-Based Scientific Tools

As biological datasets become larger and more detailed, interactive tools like this may become increasingly valuable.

Future applications could combine connectome data with richer neural dynamics, sensory systems, virtual environments, and biomechanical models.

That could make it possible to create more advanced digital experiments that run entirely on consumer hardware.

Fruit Fly Simulation offers an early glimpse of what that kind of platform might look like.

## Who Might Find It Useful?

Fruit Fly Simulation is likely to be interesting to several types of users.

**Neuroscience enthusiasts** can use it to explore connectome concepts in a more intuitive way.

**Developers** can study the project as an example of WebGPU-based scientific computing.

**AI and machine learning researchers** may find the browser-based GPU architecture interesting because it demonstrates a workload very different from traditional neural network inference.

**Students and educators** can use the interactive visualization to explain neural connectivity, signal propagation, and the concept of a connectome.

It may also appeal to anyone interested in computational biology, artificial life, neural simulation, or interactive scientific visualization.

## Final Thoughts

Fruit Fly Simulation is a creative example of how biological data, GPU computing, and interactive web technologies can be combined into a single experience.

Its main strength is not that it perfectly recreates a fruit fly brain. Instead, it makes a large neural connectivity network accessible, interactive, and visually understandable.

By letting users stimulate neurons, simulate activity propagation, and watch a 3D fly respond, the project transforms an abstract connectome into something users can actively explore.

At the same time, its architecture demonstrates how far browser-based computing has evolved.

With WebGPU handling computation and Three.js handling visualization, sophisticated scientific experiments can increasingly run without dedicated desktop software or remote GPU infrastructure.

Fruit Fly Simulation is therefore both an engaging neuroscience demo and a compelling example of the future of browser-native scientific computing.
