Figures
The site's agents as its desk draws them: a cube, a sphere, a pyramid, a block or a cloud, in 3D, saying everything with two eyes and the way they move.
// A figure is four choices, kept as they are on the desk: its
// shape, its colourway, its energy, and what it does while it
// waits. No mouth, no hats, no arms or legs.
type Figure = {
shape: "cube" | "sphere" | "pyramid" | "block" | "cloud";
palette: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8;
energy: "calm" | "lively" | "bouncy";
habit: "look" | "hum" | "nap" | "spin" | "wave" | "morph";
};
// Made from a word, the same every time: a hash of it seeds a
// small generator, which picks each part.
const figure = figureFor("Filmmaker");
// Drawn in 3D by one shader for the whole page. Clicked, it's
// petted; dragged, it turns round and springs home.
<AgentFigure figure={figure} size={168} grab />
No mouth, no hats, no arms or legs: what a figure has to say, it says with its eyes and the way it moves. A new agent on the desk gets one made from its name, and the same name always makes the same figure.
Two eyes
// A face is a few numbers: where the upper lid cuts each eye at
// its inner and outer side (li, lo), a lower lid rising in an
// arc (smile), the eyes' size and gaze, and the head's turn.
const FACES = {
neutral: { glyph: "rect", li: 0, lo: 0, size: 1 },
sad: { glyph: "rect", li: 0.05, lo: 0.5, pitch: -14 },
thinking: { glyph: "rect", li: 0.2, dx: 0.045, yaw: 14 },
love: { glyph: "heart", size: 1.15, pitch: 6, roll: -4 },
failed: { glyph: "cross", pitch: -10, roll: -6 },
// …fourteen in all
};
// Every frame the face eases toward the next, number by number,
// and a new glyph is blended in over a sixth of a second.
for (const key of FACE_KEYS) {
face[key] += (goal[key] - face[key]) * k;
}
glyphMix = Math.min(1, glyphMix + dt * 6);
Each face is a few numbers, as Anki's Cozmo has them: where the upper lid cuts each eye at its inner and outer side, how far a lower lid rises in an arc, the eyes' size and gaze, and how the head is held, since it goes where they look. Some faces turn the eyes into a shape, ^ ^, stars, hearts or × ×, and the eyes morph from one into the next. They blink, now and then twice, and on a desktop they follow the pointer.
What they're doing
// What each of an agent's states shows: its expression, the loop
// it moves in, and now and then a move.
const MOOD = {
idle: { expression: "neutral", loop: "breathe" },
thinking: { expression: "thinking", loop: "think" },
working: { expression: "working", loop: "work" },
happy: { expression: "happy", loop: "breathe", now: "pop" },
trouble: { expression: "trouble", loop: "worry", now: "shake" },
sleep: { expression: "sleeping", loop: "rest" },
};
// As it changes, a reaction, each shape playing it its own way.
reactionTo("working", "happy"); // "celebrate"
reactionTo("idle", "sleep"); // "doze"
// A loop that turns something comes home every few seconds and
// stops only there, so the next never starts from a jump.
act.stop ??= stopFor(act, now, shape, speed);
An agent is waiting, setting up, at work, done, in trouble or switched off. Each state has its face and its way of moving, and each shape acts it out in its own way: setting up, the cube solves itself like a Rubik's cube, its colours and eyes travelling with their cubelets; at work, the block's dials roll like wheels and the cloud rains. As the state changes they react: a run finished, the cube bursts and snaps back, the sphere splashes, the pyramid launches its capstone, the block spins its dials like a slot machine and the cloud gets a rainbow. When one has a moment like that, the others turn to look.
How they move
// Every move is a pose as a function of time, from 0 to 1: a
// crouch before a hop, the hop, and a squash as it lands.
const pose = moveAt("hop", p, shape, energy.amp);
// Energy scales them all: how far each goes, and how long it
// takes.
const ENERGY = {
calm: { amp: 0.65, speed: 1.3 },
lively: { amp: 1, speed: 1 },
bouncy: { amp: 1.35, speed: 0.82 },
};
const duration = ONCE_FOR[move] * ENERGY[energy].speed;
Every move is a pose worked out from time alone: a crouch before a hop, the hop, a squash as it lands. Calm makes it smaller and slower, bouncy bigger and quicker. Between moves they breathe, sway and glance about, and while they wait each has a habit: looking around, humming, napping, spinning, wobbling or changing shape for a beat.
One shader
They're solids, found by raymarching distance fields in one fragment shader, with one WebGL 2 context for the whole page: each figure is drawn in it and copied onto its own canvas. The material comes from an earlier experiment, Aura: noise warped by itself, flowing through a palette fitted to the colourway's three colours, a rainbow round the rim, milky toward the middle, and a halo with rings while it listens. Under reduced motion they hold still, drawn once; where a browser has no WebGL 2 they're a flat drawing.