Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

4.3 KB
Raw Blame
<!doctype html>
<html lang="en">
	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1" />
		<title data-i18n="demos_agents_holds_cta.meta_title">Holds the CTA — three.ws</title>
		<meta name="robots" content="noindex" />
		<link rel="stylesheet" href="/fonts/fonts.css" />
		<link rel="stylesheet" href="/demos/agents/_shared.css" />
		<style>
			#cta-btn { will-change: transform; transition: transform 0.18s cubic-bezier(0.16,1,0.3,1); }
		</style>
	</head>
	<body>
		<div class="stage">
			<div class="hero-eyebrow">Holds the CTA up</div>
			<h1 class="hero-title" data-i18n-html="demos_agents_holds_cta.she_s_working_for_you">She's <em>working</em> for you.</h1>
			<p class="hero-sub" data-i18n="demos_agents_holds_cta.a_second_agent_crouches_under_the_button">
				A second agent crouches under the button, holding it up. Hover the
				CTA and she struggles; click and she drops it.
			</p>
			<div class="cta-row">
				<button type="button" class="btn btn-primary" id="cta-btn" data-i18n-html="demos_agents_holds_cta.build_your_agent_free"><span>Build your agent for free</span><span>→</span></button>
			</div>
		</div>
		<canvas id="avatar-canvas"></canvas>
		<div class="hint">hover the CTA</div>

		<script type="module">
			import * as THREE from 'three';
			import {
				createStage, loadAvatar, loadClips, startLoop,
				fireSplash, fireShockwave, mountChrome,
			} from './_lib.js';

			mountChrome('Holds the CTA up');

			const canvas = document.getElementById('avatar-canvas');
			const ctaBtn = document.getElementById('cta-btn');
			const stage  = createStage(canvas);
			const { avatar, mixer, rootBone, baseRootPos } = await loadAvatar();
			stage.scene.add(avatar);

			const A = await loadClips(mixer, {
				pray:     '/animations/clips/pray.json',
				idle:     '/animations/clips/idle.json',
				defeated: '/animations/clips/defeated.json',
			});
			A.pray.setLoop(THREE.LoopRepeat, Infinity);
			A.idle.setLoop(THREE.LoopRepeat, Infinity);
			A.defeated.setLoop(THREE.LoopOnce, 1); A.defeated.clampWhenFinished = true;
			A.pray.play();
			let current = A.pray;

			function under() {
				const r = ctaBtn.getBoundingClientRect();
				return stage.domToWorld(r.left + r.width / 2, r.bottom + 100);
			}
			let home = under();
			avatar.position.set(home.x, home.y, 0);
			window.addEventListener('resize', () => { home = under(); });

			function switchTo(next, fade = 0.25) {
				if (next === current) return;
				next.reset();
				next.crossFadeFrom(current, fade, false).play();
				current = next;
			}

			let strain = 0;          // 0..1 — how hard she's straining
			let dropped = false;

			ctaBtn.addEventListener('mouseenter', () => { strain = 1; });
			ctaBtn.addEventListener('mouseleave', () => { strain = 0; });
			ctaBtn.addEventListener('click', () => {
				if (dropped) return;
				dropped = true;
				// Button thuds down 50px, she collapses.
				ctaBtn.style.transform = 'translateY(40px) rotate(-3deg)';
				ctaBtn.style.boxShadow = '0 2px 0 0 #005a8a, 0 4px 14px rgba(61, 193, 255,0.18)';
				switchTo(A.defeated, 0.15);
				const r = ctaBtn.getBoundingClientRect();
				fireSplash(r.left + r.width / 2, r.bottom, { count: 22, color: 'gold' });
				fireShockwave(r.left + r.width / 2, r.bottom, { size: 28, max: 180, color: '#ffd23d' });
				setTimeout(() => {
					ctaBtn.style.transform = '';
					ctaBtn.style.boxShadow = '';
					dropped = false;
					switchTo(A.pray, 0.4);
				}, 2400);
			});

			startLoop(stage.renderer, stage.scene, stage.camera, mixer, (dt) => {
				home = under();
				avatar.position.x = home.x;
				avatar.position.y = home.y;
				// Wobble harder when strained.
				const t = performance.now() / 1000;
				const wob = Math.sin(t * (5 + strain * 8)) * (0.012 + strain * 0.05);
				avatar.position.y += wob;
				avatar.rotation.z = Math.sin(t * (6 + strain * 6)) * (strain * 0.08);
				// Mirror small strain wobble onto the button.
				if (!dropped) {
					const bx = Math.sin(t * 14) * strain * 1.5;
					const by = Math.sin(t * 11) * strain * 2;
					ctaBtn.style.transform = `translate(${bx.toFixed(1)}px, ${by.toFixed(1)}px)`;
				}
			}, rootBone, baseRootPos);
		</script>
		<script src="/brand.js" defer></script>
	<!-- Runtime i18n: detects locale, swaps annotated copy, mounts <lang-switcher>. -->
	<script type="module" src="/i18n.js"></script>
</body>
</html>