# Interactive 3D Cocktails

> A live 3D cocktail in your browser: flick the glass to spin it, watch the drink slosh, tap to sip, hold to drain and refill it.

- Type: Lab Skill (downloadable Agent Skill)
- Category: [Interactive 3D](https://www.sandbase.ai/skills/interactive-3d)
- Version: 0.1.1
- Runs online: yes
- Page: https://www.sandbase.ai/skills/interactive-3d/cocktail-physics

## What you get

Bring a drink, a glass and optionally the garnish and ice. The Skill returns a downloadable Skill (meta prompt, lessons, verification) and a runnable reference scene.

## Install

Download the Skill package from https://www.sandbase.ai/skills/interactive-3d/cocktail-physics (sign-in required), unzip it into your agent's skills folder, then ask your agent to use it:

```text
/cocktail-physics build an interactive <your drink> in a <your glass> that spins, sloshes and refills
```

## How it works

1. **Fill the drink and glass slots** Cocktail Physics needs the drink and glass slots and takes optional garnish, ice, interaction, background and extraPrompt, each at most 2000 characters. Run node scripts/fill-prompt.mjs --slots slots.json --lang en --out prompt.md, with assets/prompts/examples/pink-coupe.json as the model. Give the prompt and any reference photo to your coding agent, which works locally without calling a model.
2. **Change the profile, colours and garnish** node scripts/new-project.mjs --out my-drink copies the reference app: lathed glass, liquid volume with a surface height function, slosh springs, ice buoyancy, garnish drop, splash droplets, pour stream and synthesized sound. Edit the outer, inner and stem points in src/geometry/profile.ts, the colours in src/components/Liquid.tsx and the garnish. The volume table, waterline and ice floor follow the inner profile.
3. **Shoot the beats and build** npm ci needs Node 22.4 or newer, then npm run build:single writes dist-single/index.html. npm run shoot -- --file dist-single/index.html needs local Chrome and records console errors, CSP violations, interaction proofs, levels, audio state and frame rate. In the sample, one sip leaves the level at 0.88 and a 2-second hold leaves 0.544. Compare beat screenshots with the reference each round.

## FAQ

### What can you do with the Cocktail Physics coupe?

Cocktail Physics shows a clear coupe of pink drink on white. Drag to spin the glass and the drink lags and sloshes while four ice cubes bob. Click or tap to sip, press and hold to drain, and press R or Refill to pour it back. A lemon wheel drops onto the rim at the start, and an empty glass refills itself.

### Is Cocktail Physics a real fluid simulation?

No. Cocktail Physics drives a height field with springs and waves, so the drink can tilt and slosh but cannot pour over the rim or break into spray. The level is measured in volume rather than height, so a wide coupe does not empty its bottom too fast.

### Why does the Cocktail Physics ice not refract the drink?

Cocktail Physics makes the ice opaque with a glassy finish because transmissive objects do not refract each other in three.js. The liquid and garnish also stay opaque and fake their depth, so the ice does not bend the drink behind it.

### Does Cocktail Physics need an API key?

No. Cocktail Physics calls no model or network service, and npm ci only downloads pinned packages. The studio light comes from src/components/ProceduralEnv.tsx instead of a CDN preset, because the sandbox blocks network access.

### How does Cocktail Physics run on phones?

Cocktail Physics gives phones a low tier with a coarser surface grid, half-resolution refraction and no multisampling. Phones were verified under headless touch emulation only, not on devices. Headless capture has no audio, so listening is a manual check.

### Why is the Cocktail Physics backdrop brighter than white in code?

Cocktail Physics sets the backdrop above 1 because the neutral tone mapper never quite reaches white. A last pass scales it to exactly white, which keeps the bloom threshold above the backdrop. Glass on white also needs a dark world behind it and black flags, or it vanishes.

## Examples

- Cocktail Physics interactive demo (scene)
- Blue Hour (scene)
- Pink Coupe (video)
- Blue Hour (video)
