Interactive 3D mascots in React, without Three.js or Spline.

Adding a living character to an AI workspace, onboarding flow or empty state usually means shipping a 400 KB 3D runtime or pre-baked Lottie files that can’t track a pointer or deform when poked. Here is how signed-distance-field shaders in raw WebGL2 deliver Plush, Clay and Jelly physics at 60 fps with zero dependencies.

3D runtime dependencies
0 KB
shared WebGL2 context
1
real-time tactile materials
3
at 4× CPU throttle
60 fps

Updated December 1, 2026. Benchmarks verified in Chromium at 4× CPU slowdown.

01Live studio

Touch real-time Plush, Clay and Jelly shaders

Switch characters, materials and moods below—then rub across the fur, click clay to leave a healing thumbprint dent, or drag and fling jelly.

Pet fur · Click clay to dent · Drag to fling

Character

Material shader

Reactive mood

<Mascot character="cat" material="plush" mood="idle" />Open full 8-character studio

02Trade-offs

Lottie / Rive vs. Spline / Three.js vs. raw WebGL2 SDF

Every approach has a place. Choose based on whether you need custom artwork, imported 3D scenes, or lightweight reactive UI physics.

Comparison of Lottie/Rive, Spline/Three.js and raw WebGL2 SDF mascots in React
DimensionLottie / RiveSpline / Three.jsWebGL2 SDF (Hairline)
Runtime bundle40–180 KB runtime + JSON/riv binary assets per animation state.200–700 KB Three.js / Spline runtime + external .glb or .splinecode downloads.Zero runtime dependencies (~16 KB source file). No 3D meshes or network asset fetches.
Continuous physics & touchPre-authored state machines; smooth blending between arbitrary drags is hard to author.Full 3D scene graph, though adding custom fur combing or healing thumbprint dents is heavy.Analytic SDF + damped springs: pet fur fibers, press real clay dents, grab & fling with inner-eye lag.
Theme & dark mode syncRequires exporting separate dark assets or manually remapping vector layers.Lighting and background often need manual scene re-authoring for dark mode.Transparent canvas with adaptive dark shading plus tone="primary" reading shadcn --primary directly.
Multi-instance GPU costLight on GPU for simple vectors; heavier on CPU when many instances animate.Each scene usually spawns its own WebGL context, hitting browser 8-context eviction limits.Single shared offscreen WebGL2 context blitted to one 2D canvas per mascot — scales past 10+ instances at 60 fps.
Best fitBest when an illustrator already drew bespoke 2D brand art in Rive or After Effects.Best for complex imported 3D hardware models, CAD views or multi-object hero scenes.Best for living AI companions, context meters, empty states, streaks and voice headers inside React apps.

03Architecture

How to keep 10 live mascots smooth at 60 fps

Four engineering choices prevent shader-compile freezes on Windows Chrome and keep GPU cost near zero on mobile.

mascots-pro-gl.ts
// 1. One shared offscreen WebGL2 context + lazy per-material shader cache// Avoids browser 8-context eviction and prevents scroll-time compile stalls.let sharedGl: SharedMascotGL | null = null;function getMaterialProgram(shared: SharedMascotGL, material: "plush" | "clay" | "jelly") {  if (shared.programs[material]) return shared.programs[material];  // Compile only the material needed (#define MAT_MODE 0|1|2)  const fs = compileShader(shared.gl, shared.gl.FRAGMENT_SHADER, buildFragSrc(MAT_ID[material]));  // ...link once, cache forever across every <Mascot /> on the page}// 2. Dynamic loop lower bound inside GLSL prevents Windows ANGLE/D3D11 FXC// from unrolling SDF raymarch loops into 50,000-instruction HLSL blobs://   #define ZERO (min(uShape, 0))//   for (int i = ZERO; i < 20; i++) { ... }// Cuts first-paint shader compile on Windows Chrome from ~50s down to ~100ms.// 3. Blit the exact viewport slice onto each mascot's single 2D display canvasgl.viewport(0, 0, w, h);gl.scissor(0, 0, w, h);gl.drawArrays(gl.TRIANGLES, 0, 3);ctx2d.clearRect(0, 0, w, h);ctx2d.drawImage(glCanvas, 0, glCanvas.height - h, w, h, 0, 0, w, h);
  • Precomputed 3D noise volume. Instead of evaluating 16-tap procedural 3D Worley and value noise per raymarch step, compute one seamless 32×32×32 TEXTURE_3D (~128 KB) once per page load and sample it in a single hardware trilinear tap.
  • Per-material split shaders + dynamic loop bounds. Compiling Plush, Clay and Jelly as separate small programs with min(uShape, 0) stops Windows ANGLE/D3D11 FXC from unrolling SDF loops into massive HLSL blobs.
  • Single shared WebGL2 context. Every mascot blits its rendered viewport slice onto one 2D canvas, halving DOM canvases and bypassing the browser 8-context cap.

04Where it works

Six product moments where a mascot beats static UI

Mascots earn their keep when they turn invisible system state into immediate physical intuition.

  • AI context window & token compaction

    Instead of a flat progress bar, Munch physically inflates as prompt tokens mount, flattens against the glass at 90%, and squeezes down when you hit Compact.

  • AI voice & chat header

    Tracks cursor gaze while idle, furrows brows while thinking, pulses to real microphone or TTS amplitude while speaking, and relaxes when finished.

  • Upgrade & annual billing toggle

    Switches from calm idle to star-eyed confetti celebration when toggled to Yearly—and pouts playfully when the pointer hovers over "Later".

  • Empty states & deploy recovery

    Turns a dead blank screen into a napping translucent ghost that wakes up on error and celebrates once the first deploy turns green.

  • Habit streaks & growth milestones

    Gives daily check-ins physical emotional payoff without downloading multi-megabyte animation packs.

  • Local-first sync & support check-ins

    Communicates syncing, offline queues, and CSAT feedback at a glance with clear micro-expressions and subtle particles.

05Start free

Install Munch under MIT in 30 seconds

Try the free starter in any React or shadcn/ui repo first; unlock all 8 characters and 3 materials once when you want the full cast.

$ npx shadcn@latest add @hairline/mascot
assistant-header.tsx
import { Mascot } from "@/components/hairline/mascot";export function AssistantHeader({ status }: { status: "idle" | "thinking" | "happy" | "error" }) {  return (    <div className="flex items-center gap-3">      <Mascot mood={status} tone="primary" size={96} />      <p className="text-sm font-medium">Munch is ready</p>    </div>  );}

Want all 8 characters, Stop-Motion Clay, Translucent Jelly and live microphone reactivity? Explore Hairline Mascots ($49 one-time, or included free with Hairline All-Access).

06Questions

Before you install

Why does a shared WebGL2 context matter when showing several mascots?

Desktop and mobile browsers enforce a hard cap of roughly 8 to 16 active WebGL contexts per page, and creating a new context compiles the shader program from scratch. Sharing one offscreen WebGL2 context and blitting onto a single 2D canvas per mascot eliminates context loss and keeps scroll-to-paint under a frame.

How does it avoid draining laptop or phone batteries?

Every mascot observes visibility with IntersectionObserver and listens to document.hidden: the GPU loop stops completely when scrolled off screen or in a background tab, caps pixel density on coarse touch screens, and renders a single crisp static frame under prefers-reduced-motion.

Can I start with a free mascot before buying the full 8-character pack?

Yes. Munch the Plush Cat (@hairline/mascot) is completely free under the MIT license with 6 moods, cursor tracking, fur combing, 4× poke annoyance and fling physics. The Full Pack (@hairline-pro/mascots) unlocks all 8 characters, Plush/Clay/Jelly materials, 9 moods and live audio reactivity for $49 once—or free with Hairline All-Access.

Does it require Next.js, or can I use Vite and plain React?

There are zero Next.js imports in the mascot component or shader engine. Install via shadcn CLI or paste the TypeScript source straight into Next.js, Vite, Remix or any React 18/19 app.

07Keep going

Where to go next

Play with all 8 characters in the Hairline Mascots studio, inspect the live Context window component, read our AI chat components guide and zero-dependency React springs guide, or pair them with Hairline Icons.