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.

18.6 KB
Raw Blame
<!doctype html>
<html lang="en">
	<head>
		<meta charset="utf-8" />
		<title data-i18n="avatar_artifact.meta_title">
			Avatar Artifact: standalone 3D avatar viewer · three.ws
		</title>
		<link rel="icon" href="/favicon.ico" sizes="any" />
		<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
		<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png" />
		<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png" />
		<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
		<link rel="manifest" href="/manifest.webmanifest" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<meta name="theme-color" content="#080808" />
		<style>
			* {
				margin: 0;
				padding: 0;
				box-sizing: border-box;
			}
			/* three.ws hidden-guard: make the `hidden` attribute authoritative even
			   against the display rules below; see scripts/lib/hidden-guard.mjs */
			[hidden] {
				display: none !important;
			}
			:root {
				--ink: #eaf0ff;
				--muted: #8b94b8;
				--accent: #6699ff;
			}
			html,
			body {
				height: 100%;
			}
			body {
				background: #080808;
				overflow: hidden;
				font-family:
					-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial,
					sans-serif;
				color: var(--ink);
			}
			canvas {
				display: block;
				touch-action: none; /* we own the gesture for parallax */
			}

			/* Chrome overlay: keeps the viewer from being a dead-end */
			.chrome {
				position: fixed;
				inset: 0;
				pointer-events: none;
				z-index: 10;
				display: flex;
				flex-direction: column;
				justify-content: space-between;
			}
			.bar {
				display: flex;
				align-items: center;
				justify-content: space-between;
				flex-wrap: wrap;
				gap: 10px;
				padding: 14px 18px;
				background: linear-gradient(180deg, rgba(8, 8, 12, 0.7), rgba(8, 8, 12, 0));
			}
			.bar.bottom {
				background: linear-gradient(0deg, rgba(8, 8, 12, 0.7), rgba(8, 8, 12, 0));
				justify-content: flex-start;
				/* The bottom-right corner belongs to the shared corner stack
				   (public/corner-stack.js: language switcher, search pill), fixed at
				   right:18px with a 380px cap. Reserve that lane so this page's own
				   controls are never covered by it. */
				padding-right: calc(30px + min(380px, 55vw));
			}
			.chrome a,
			.chrome button {
				pointer-events: auto;
				font: inherit;
				color: var(--ink);
				text-decoration: none;
				font-size: 14px;
				font-weight: 600;
				letter-spacing: 0.01em;
				display: inline-flex;
				align-items: center;
				gap: 7px;
				padding: 8px 12px;
				border-radius: 10px;
				border: 1px solid rgba(255, 255, 255, 0.08);
				background: rgba(255, 255, 255, 0.04);
				cursor: pointer;
				transition:
					background 0.18s ease,
					border-color 0.18s ease,
					transform 0.18s ease;
			}
			.chrome a:hover,
			.chrome button:hover {
				background: rgba(255, 255, 255, 0.1);
				border-color: rgba(255, 255, 255, 0.18);
			}
			.chrome a:active,
			.chrome button:active {
				transform: translateY(1px);
			}
			.chrome a:focus-visible,
			.chrome button:focus-visible {
				outline: 2px solid var(--accent);
				outline-offset: 2px;
			}
			.brand {
				font-weight: 700;
			}
			.brand .dot {
				color: var(--accent);
			}
			.foot-links {
				display: flex;
				gap: 8px;
				flex-wrap: wrap;
				pointer-events: none;
			}
			.hint {
				pointer-events: none;
				color: var(--muted);
				font-size: 12px;
				font-weight: 400;
			}
			h1.hint {
				font-size: 12px;
			}
			.status {
				color: var(--accent);
			}
			.status:empty {
				display: none;
			}
			/* The artifact's own name, once one is loaded: the h1 stops being a
			   tagline and starts being the subject's title. */
			h1.hint[data-i18n-owned='1'] {
				font-size: 14px;
				font-weight: 700;
				color: var(--ink);
			}

			/* Embed snippet: the manual path when the clipboard is unavailable
			   (cross-origin iframes and Safari both refuse the write). */
			.snippet {
				pointer-events: auto;
				display: flex;
				align-items: center;
				gap: 8px;
				width: 100%;
				max-width: 560px;
			}
			.snippet[hidden] {
				display: none;
			}
			.snippet label {
				font-size: 12px;
				color: var(--muted);
				white-space: nowrap;
			}
			.snippet input {
				flex: 1;
				min-width: 0;
				font: inherit;
				font-size: 12px;
				color: var(--ink);
				background: rgba(255, 255, 255, 0.06);
				border: 1px solid rgba(255, 255, 255, 0.14);
				border-radius: 8px;
				padding: 7px 9px;
			}
			.snippet input:focus-visible {
				outline: 2px solid var(--accent);
				outline-offset: 1px;
			}

			/* Loading + error states */
			.overlay {
				position: fixed;
				inset: 0;
				z-index: 20;
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: center;
				gap: 16px;
				text-align: center;
				padding: 24px;
				background: #080808;
				transition: opacity 0.4s ease;
			}
			.overlay[hidden] {
				display: none;
			}
			.overlay.fade {
				opacity: 0;
				pointer-events: none;
			}
			.overlay .foot-links {
				pointer-events: auto;
			}
			.overlay a,
			.overlay button {
				pointer-events: auto;
				font: inherit;
				font-size: 14px;
				font-weight: 600;
				color: var(--ink);
				text-decoration: none;
				display: inline-flex;
				align-items: center;
				padding: 8px 12px;
				border-radius: 10px;
				border: 1px solid rgba(255, 255, 255, 0.08);
				background: rgba(255, 255, 255, 0.04);
				cursor: pointer;
				transition:
					background 0.18s ease,
					border-color 0.18s ease,
					transform 0.18s ease;
			}
			.overlay a:hover,
			.overlay button:hover {
				background: rgba(255, 255, 255, 0.1);
				border-color: rgba(255, 255, 255, 0.18);
			}
			.overlay a:active,
			.overlay button:active {
				transform: translateY(1px);
			}
			.overlay a:focus-visible,
			.overlay button:focus-visible {
				outline: 2px solid var(--accent);
				outline-offset: 2px;
			}
			.spinner {
				width: 38px;
				height: 38px;
				border-radius: 50%;
				border: 3px solid rgba(102, 153, 255, 0.18);
				border-top-color: var(--accent);
				animation: spin 0.9s linear infinite;
			}
			@keyframes spin {
				to {
					transform: rotate(360deg);
				}
			}
			.overlay p {
				color: var(--muted);
				font-size: 14px;
				max-width: 34ch;
				line-height: 1.5;
			}
			.overlay h2 {
				font-size: 18px;
				font-weight: 700;
			}
			@media (prefers-reduced-motion: reduce) {
				.spinner {
					animation-duration: 2.4s;
				}
			}

			/* Mobile adaptation: the bars wrap instead of dropping links, so no
			   navigation target becomes unreachable on a phone. */
			@media (max-width: 640px) {
				.bar {
					padding: 11px 12px;
				}
				.chrome a,
				.chrome button {
					font-size: 13px;
					padding: 7px 10px;
				}
				.bar.top .hint {
					display: none;
				}
				.bar.bottom {
					/* Too narrow to reserve a side lane: lift the row above the corner
					   stack instead, so the widgets and these controls never collide. */
					padding-right: 12px;
					padding-bottom: 60px;
				}
			}
		</style>

		<meta
			name="description"
			content="Standalone Three.js viewer for avatar artifacts: embeddable and shareable without any wrapper page."
		 data-i18n-attr="content:avatar_artifact.meta_description"/>
		<link rel="canonical" href="https://three.ws/avatar-artifact" />
		<meta property="og:type" content="website" />
		<meta property="og:site_name" content="three.ws" />
		<meta property="og:title" content="Avatar Artifact · three.ws"  data-i18n-attr="content:avatar_artifact.meta_og_title"/>
		<meta
			property="og:description"
			content="Standalone Three.js viewer for avatar artifacts: embeddable and shareable without any wrapper page."
		 data-i18n-attr="content:avatar_artifact.meta_og_description"/>
		<meta property="og:url" content="https://three.ws/avatar-artifact" />
		<meta property="og:image" content="https://three.ws/api/page-og?s=labs&amp;t=Avatar+Artifact&amp;d=Standalone+Three.js+viewer+for+avatar+artifacts%3A+embeddable+and+shareable+without+any+wrapper+page.&amp;p=%2Favatar-artifact" />
		<meta property="og:image:width" content="1200" />
		<meta property="og:image:height" content="630" />
		<meta name="twitter:card" content="summary_large_image" />
		<meta name="twitter:title" content="Avatar Artifact · three.ws"  data-i18n-attr="content:avatar_artifact.meta_twitter_title"/>
		<meta
			name="twitter:description"
			content="Standalone Three.js viewer for avatar artifacts: embeddable and shareable without any wrapper page."
		 data-i18n-attr="content:avatar_artifact.meta_twitter_description"/>
		<meta name="twitter:image" content="https://three.ws/api/page-og?s=labs&amp;t=Avatar+Artifact&amp;d=Standalone+Three.js+viewer+for+avatar+artifacts%3A+embeddable+and+shareable+without+any+wrapper+page.&amp;p=%2Favatar-artifact" />
		<script type="application/ld+json">
			{
				"@context": "https://schema.org",
				"@type": "WebPage",
				"name": "Avatar Artifact",
				"description": "Standalone Three.js viewer for avatar artifacts: embeddable and shareable without any wrapper page.",
				"url": "https://three.ws/avatar-artifact",
				"isPartOf": { "@type": "WebSite", "name": "three.ws", "url": "https://three.ws" }
			}
		</script>

	<meta name="robots" content="index, follow, max-image-preview:large, max-snippet:-1">
	<meta property="og:locale" content="en_US">
	<meta property="og:image:alt" content="Avatar Artifact, a live Three.js portrait on three.ws">
	<meta name="twitter:site" content="@trythreews">
</head>
	<body
		data-canvas-label="Interactive 3D avatar that follows your cursor, touch, or arrow keys"
		data-i18n-attr="data-canvas-label:avatar_artifact.canvas_label"
	>
		<!-- Persistent chrome so the standalone viewer is never a dead-end -->
		<div class="chrome">
			<div class="bar top">
				<a href="/" aria-label="Back to three.ws home" data-i18n-html="avatar_artifact.three_ws" data-i18n-attr="aria-label:avatar_artifact.back_to_three_ws_home_arialabel">
					<span aria-hidden="true">&#8592;</span>
					<span class="brand">three<span class="dot">.</span>ws</span>
				</a>
				<span class="hint" data-i18n="avatar_artifact.move_your_cursor_drag_on_touch_arrow">Move your cursor · drag on touch · arrow keys</span>
			</div>
			<div class="bar bottom">
				<h1 class="hint" id="artifact-title" data-i18n="avatar_artifact.avatar_artifact_a_live_three_js_portrait">Avatar Artifact: a live Three.js portrait</h1>
				<div class="foot-links">
					<a id="artifact-source" href="/agents" hidden data-i18n="avatar_artifact.open_profile">Open profile</a>
					<button
						type="button"
						id="copy-embed"
						data-copied="Embed code copied"
						data-manual="Copy the snippet below"
						data-i18n="avatar_artifact.copy_embed"
						data-i18n-attr="data-copied:avatar_artifact.embed_code_copied;data-manual:avatar_artifact.copy_the_snippet_below"
					>Copy embed</button>
					<a href="/playground" data-i18n="avatar_artifact.playground">Playground</a>
					<a href="/labs" data-i18n="avatar_artifact.labs">Labs</a>
					<a href="/agents" data-i18n="avatar_artifact.agents">Agents</a>
				</div>
				<span class="hint status" id="copy-status" role="status" aria-live="polite"></span>
				<div class="snippet" id="embed-snippet" hidden>
					<label for="embed-code" data-i18n="avatar_artifact.embed_code">Embed code</label>
					<input id="embed-code" type="text" readonly value="" />
				</div>
			</div>
		</div>

		<!-- Loading state while the Three.js runtime + scene resolve. The three
		     data-note-* strings are the same overlay narrating the artifact lane:
		     resolving the agent, then fetching its model, then its byte progress. -->
		<div
			class="overlay"
			id="loading"
			data-note-agent="Looking up the agent…"
			data-note-model="Fetching the model…"
			data-note-progress="Fetching the model… {pct}%"
			data-i18n-attr="data-note-agent:avatar_artifact.note_agent;data-note-model:avatar_artifact.note_model;data-note-progress:avatar_artifact.note_progress"
		>
			<div class="spinner" role="status" aria-label="Loading avatar"></div>
			<p id="loading-note" data-i18n="avatar_artifact.summoning_the_avatar">Summoning the avatar…</p>
		</div>

		<!-- Designed failure states. Every way this viewer can fail gets its own
		     sentence and its own next move; the data-msg-* copy is selected by
		     src/avatar-artifact.js and stays translatable here with the rest. -->
		<div
			class="overlay"
			id="error"
			hidden
			data-msg-both="Pass either an agent id or a model URL, not both. Drop one from the link and load it again."
			data-msg-not-found="No agent on three.ws matches that id. The link may be old, or the agent may have been deleted."
			data-msg-agent-fetch="The agent lookup did not come back. That is usually a network hiccup, so a retry is worth it."
			data-msg-no-avatar="This agent has not been given an avatar yet, so there is nothing to render. Its profile has the rest of its identity."
			data-msg-avatar-private="This agent's avatar is private, so it cannot be shown outside three.ws. Its profile is still public."
			data-msg-model-blocked="That model link is not an https URL on a host this viewer accepts. Models must be served from three.ws or a known asset host."
			data-msg-model-failed="The model file could not be loaded. It may have moved, or it may use a compression format this viewer does not carry."
			data-msg-no-webgl="This browser could not start WebGL, so the 3D portrait cannot render here. Try another browser or enable hardware acceleration."
			data-action-agents="Browse agents"
			data-action-profile="Open profile"
			data-i18n-attr="data-msg-both:avatar_artifact.err_both;data-msg-not-found:avatar_artifact.err_not_found;data-msg-agent-fetch:avatar_artifact.err_agent_fetch;data-msg-no-avatar:avatar_artifact.err_no_avatar;data-msg-avatar-private:avatar_artifact.err_avatar_private;data-msg-model-blocked:avatar_artifact.err_model_blocked;data-msg-model-failed:avatar_artifact.err_model_failed;data-msg-no-webgl:avatar_artifact.err_no_webgl;data-action-agents:avatar_artifact.action_agents;data-action-profile:avatar_artifact.open_profile"
		>
			<h2 data-i18n="avatar_artifact.couldn_t_load_the_3d_viewer">Couldn’t load the 3D viewer</h2>
			<p id="error-detail" data-i18n="avatar_artifact.the_graphics_runtime_failed_to_load_this">
				The graphics runtime failed to load. That usually means a network
				hiccup, so a reload is worth a try.
			</p>
			<div class="foot-links">
				<a id="error-action" href="/agents" hidden data-i18n="avatar_artifact.action_agents">Browse agents</a>
				<button type="button" id="artifact-retry" data-i18n="avatar_artifact.retry">Retry</button>
				<a href="/" data-i18n="avatar_artifact.back_to_three_ws">Back to three.ws</a>
			</div>
		</div>

		<script>
			// Designed failure state, shared by every boot path: a runtime that
			// never arrives, a browser without WebGL, an agent or model that can't
			// be resolved, and the watchdog below. `action` is the one next move
			// that fits the failure (the agent's profile, the agent index).
			window.__avatarArtifactFailed = function (detail, action) {
				if (window.__avatarArtifactPainted) return;
				clearTimeout(window.__avatarArtifactWatchdog);
				document.getElementById('loading')?.setAttribute('hidden', '');
				if (detail) {
					const el = document.getElementById('error-detail');
					if (el) {
						el.dataset.i18nOwned = '1';
						el.textContent = detail;
					}
				}
				const link = document.getElementById('error-action');
				if (link && action && action.href) {
					link.href = action.href;
					if (action.label) {
						link.dataset.i18nOwned = '1';
						link.textContent = action.label;
					}
					link.removeAttribute('hidden');
				}
				document.getElementById('error')?.removeAttribute('hidden');
			};
			document.getElementById('artifact-retry')?.addEventListener('click', () => {
				location.reload();
			});

			// Watchdog: covers the case where the module script itself never runs
			// (asset 404, blocked by an extension), which no in-script catch can
			// see. Cleared by the first painted frame; re-armed by the heartbeat
			// so a large model that is genuinely still downloading is not called
			// dead at twelve seconds.
			window.__avatarArtifactHeartbeat = function () {
				clearTimeout(window.__avatarArtifactWatchdog);
				window.__avatarArtifactWatchdog = setTimeout(() => {
					window.__avatarArtifactFailed();
				}, 12000);
			};
			window.__avatarArtifactHeartbeat();

			// Embed + share. The snippet is the page's own URL, so the viewer is
			// shareable from inside itself, which is the point of a standalone
			// artifact page. Once a specific artifact resolves, the module hands
			// its query back through __avatarArtifactSetEmbed so the copied iframe
			// shows the avatar on screen rather than the house portrait.
			(function embedControls() {
				const button = document.getElementById('copy-embed');
				const status = document.getElementById('copy-status');
				const panel = document.getElementById('embed-snippet');
				const field = document.getElementById('embed-code');
				if (!button || !status || !panel || !field) return;

				let snippet = '';
				function setEmbed(query) {
					const url = new URL('/avatar-artifact' + (query || ''), location.href).href;
					snippet =
						'<iframe src="' +
						url +
						'" width="100%" height="600" style="border:0" loading="lazy" title="Avatar Artifact"></iframe>';
					field.value = snippet;
				}
				window.__avatarArtifactSetEmbed = setEmbed;
				setEmbed('');

				let clearStatus;
				function announce(message) {
					status.textContent = message;
					clearTimeout(clearStatus);
					clearStatus = setTimeout(() => {
						status.textContent = '';
					}, 4000);
				}

				button.addEventListener('click', async () => {
					try {
						await navigator.clipboard.writeText(snippet);
						panel.setAttribute('hidden', '');
						announce(button.dataset.copied);
					} catch {
						// Clipboard denied (cross-origin frame, insecure context):
						// reveal the snippet so it can still be copied by hand.
						panel.removeAttribute('hidden');
						field.focus();
						field.select();
						announce(button.dataset.manual);
					}
				});
			})();
		</script>
		<!-- Scene + artifact loader. Extracted from this page so the viewer is
		     a real module (src/avatar-artifact.js) the bundler can split, not 450
		     lines of markup-embedded script. -->
		<script type="module" src="/src/avatar-artifact.js"></script>
		<!-- Shared bottom-right corner stack. Without it the widgets that mount
		     themselves there (the Atlas Ctrl+K chip, the language switcher) each fall
		     back to their own fixed position and pile onto the same pixel. -->
		<script src="/corner-stack.js" defer></script>
		<!-- Runtime i18n: detects locale, swaps annotated copy, mounts <lang-switcher>. -->
	<script type="module" src="/i18n.js"></script>
</body>
</html>