---
name: wallrusify
description: Turn any existing Three.js scene, HTML page, Vite/React-Three-Fiber project, CodePen, GLSL shader or URL into a working Wallrus live desktop wallpaper on Linux or macOS. Use whenever the user says "wallrus-ify", "make this my wallpaper", "turn this three.js thing into a wallpaper", or points at a scene/repo/link they want on their desktop.
---

# Wallrus-ify: any Three.js scene → live wallpaper

Goal: take something that already renders in a browser and make it a calm, legible, 60 FPS wallpaper with cursor depth parallax.
Work in a copy, never edit the user's original. Pair this with the `wallrus` skill (`wallrus schema` prints the native contract).

## 0. Preflight

```bash
which wallrus || curl -fsSL https://wallrus.pages.dev/install.sh | bash
wallrus doctor
mkdir -p ~/.local/share/wallrus/scenes/<name> && cd $_   # work dir; keep assets next to the scene file
```

## 1. Try it as-is first (it often just works)

`wallrus` takes `.js` ES modules, vanilla Three.js scripts, `.html` pages and `https://` URLs. For HTML it also:
- rewrites the `three` importmap to the bundled offline r170 build,
- hides overlays, GUIs and Stats while pinned, and shows them again in Interactive Mode,
- hooks `WebGLRenderer`/`WebGPURenderer` so the engine can add parallax, swaps First-Person/Fly controls for damped Orbit+WASD, and blocks pointer-lock, fullscreen and audio.

```bash
wallrus check ./scene.html && wallrus set ./scene.html
sleep 4; wallrus screenshot /tmp/wallrusify.png       # LOOK at it
wallrus status --json | jq '{fps, recent_errors}'
wallrus logs
```
If it looks good, has FPS ≥ 30 and no errors, go to step 4. Otherwise pick the matching row in step 2.

## 2. Input → recipe

| Input | What to do |
|---|---|
| Single `.html` with importmap/CDN three | Download into the work dir and `wallrus set` it. CDN addons resolve to the bundle; other CDN imports load normally. |
| Vanilla `.js` that creates its own renderer and `requestAnimationFrame` loop | Usually works as-is. The host tracks its listeners, DOM nodes and rAF callbacks and cleans them up on hot-swap. |
| Vite / webpack / R3F / Svelte project | Build static output with **relative** paths (`vite build --base ./`), then `wallrus set dist/index.html`. Files beside the scene are served, so keep `dist/` intact. |
| Remote URL | `wallrus set https://…` works for quick tries. For anything you keep, mirror it locally (step 1) so it works offline and you can patch it. |
| Shadertoy / GLSL fragment / CodePen canvas | Rewrite as a native module: fullscreen `PlaneGeometry(2,2)` + `ShaderMaterial` with `iTime`/`iResolution` uniforms, updated in `ctx.onTick`. Start from `wallrus init ./scene.js`. |
| `.glb` / `.gltf` model only | Native module: `GLTFLoader` loads the file from beside the scene. Add lights and a sky, set `controls.target` to the model's bounding-box centre, and play `AnimationMixer` clips in `onTick`. |

The size limit is **1 MB per scene source file**. Assets (textures, glb, wasm, built JS chunks) are separate files and don't count.

## 3. Patch list (apply only what the screenshot shows you need)

Make every change with a small, re-runnable patch script (`prepare.py` that reads `upstream.html` and writes `scene.html`) so you can re-apply it after pulling upstream updates.

1. **Hide UI**: inject `<style>#ui,#hud,#intro,#title,.overlay,.lil-gui{display:none!important}</style>` before `</head>`. Match the real ids and classes from the DOM.
2. **Skip intros, click-to-start and loading gates**: auto-call the start function, or set the flag the button sets. Wallpapers never receive a first click.
3. **Freeze the "best moment"**: if the scene has a day cycle, cinematic camera path or tour, pin it to its most beautiful state (golden hour, a moonlit sky) or slow it to ≤ 0.1×. Wallpapers should breathe, not perform.
4. **Camera**: remove auto-orbit and scripted fly-throughs. Set one hero pose. Never overwrite `camera.position` every frame, because the engine owns the parallax rig.
5. **Scenes that drive their own camera from `pointermove`** (custom shader cameras, raymarchers): desktop cursor events don't reach the page, so feed them from the engine's messages instead:
   ```js
   let k = 0.75; // parallax strength from wallrus config
   addEventListener('message', ({ source, data }) => {
     if (source !== parent || !data) return;
     if (data.wallrus === 'parallax') k = data.on ? data.strength : 0;
     if (data.wallrus === 'cursor') { pointer.x = data.x * k; pointer.y = data.y * k; } // x,y in [-1,1], +y = down
   });
   ```
   Keep yaw ≤ ~0.09 rad and pitch ≤ ~0.05 rad. Translating the eye a little sideways sells depth better than rotating.
6. **Performance**: clamp `renderer.setPixelRatio(Math.min(devicePixelRatio, 1.5))`, cut volumetric or raymarch steps by about 30%, and drop shadow-map size to 1024–2048. Target 60 FPS at native resolution.
7. **Legibility**: keep exposure around 0.95–1.15 and bloom threshold ≥ 0.65. Leave a calm area where terminal windows usually sit.
8. **Remove** audio, `alert`/`prompt`, pointer lock, `requestFullscreen`, analytics, and service workers.
9. **Credit**: keep the upstream licence as a comment at the top (`<!-- Adapted from X by Y — MIT … -->`) and put the author in `meta.description` or `<title>`. Don't redistribute anything that has no licence, and tell the user so.

## 4. Optional: port to the native contract (needed to share on wallrus.pages.dev)

Native modules are smaller, hot-reload faster, and get `ctx.noise`, HUD controls and `wallrus send` events. Mapping:

| Original | Native |
|---|---|
| `new WebGLRenderer()`, `new Scene()`, `new PerspectiveCamera()`, `OrbitControls` | Use `ctx.renderer`, `ctx.scene`, `ctx.camera`, `ctx.controls` (don't create your own) |
| `requestAnimationFrame(loop)` | `ctx.onTick(({ dt, elapsed, pointer }) => …)` |
| `window.onresize` | Delete it (the engine handles resizing) |
| `EffectComposer` + `UnrealBloomPass` | `ctx.enableBloom({ strength, radius, threshold })` |
| keyboard toggles | `meta.controls` + `ctx.onKey` (avoid W/A/S/D/Q/E/R/P) |
| GUI params | `ctx.onEvent(name, payload)` → `wallrus send name '{"k":1}'` |

Export `meta` and `setup(ctx)`. Run `wallrus check` until it exits 0. Community uploads are capped at 512 KB.

## 5. Verify (required before you say "done")

```bash
wallrus set <scene> && sleep 5
wallrus screenshot /tmp/wallrusify.png     # view it: framing, contrast, nothing UI-ish left
wallrus status --json | jq '{scene_title, fps, recent_errors}'
wallrus interact                           # orbit/WASD should feel right; Esc pins the pose
```
Move the mouse across the screen while it's pinned: the foreground should shift against the background. If nothing moves, apply patch 5. Report the final path, FPS, licence/credit, and every patch you made.
