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.

2.1 KB
Raw Blame
// `thumbnail_glb` — render any public GLB URL to a PNG via three.ws's
// hosted headless-chromium pipeline (the same three-light rig and
// bounding-box framing that powers three.ws OG cards).
//
// Returns a base64 PNG data URL the client can display inline, plus
// width/height and the upstream endpoint that produced it.
//
// This is the single most-requested capability for any 3D MCP — without
// it the agent is "blind" to how a model actually looks.

import { z } from 'zod';

import { renderGlbThumbnail } from '../lib/render.js';
import { pngRenderFields, resultShape } from '../lib/output-shapes.js';

const outputSchema = resultShape({
	...pngRenderFields,
	glbUrl: z.string().optional().describe('The rendered GLB URL (echoed).'),
});

export const def = {
	name: 'thumbnail_glb',
	title: 'Render a GLB to a PNG thumbnail',
	// MCP ToolAnnotations — safety hints surfaced to MCP clients.
	annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
	description:
		'Render any public GLB URL to a PNG via three.ws\'s hosted three-light rig + auto-framing camera. Returns the PNG inline as a base64 data URL (≤ ~4 MB) plus dimensions. Background defaults to #0a0a0a; pass "transparent" for compositing. Use this for a quick preview image of any GLB; to apply a pose, camera orbit, or facial expression, call render_avatar instead.',
	inputSchema: {
		glbUrl: z.string().url().describe('Public http(s) URL of a .glb file.'),
		width: z.number().int().min(64).max(2048).optional().describe('Output width in pixels (default 1024).'),
		height: z.number().int().min(64).max(2048).optional().describe('Output height in pixels (default 1024).'),
		background: z.string().optional().describe('CSS color (e.g. "#0a0a0a") or "transparent". Default "#0a0a0a".'),
	},
	outputSchema,
	async handler(args) {
		const { glbUrl, width, height, background } = args || {};
		if (!glbUrl) return { ok: false, error: 'invalid_input', message: 'glbUrl is required' };
		const out = await renderGlbThumbnail({ glbUrl, width, height, background });
		return {
			...out,
			glbUrl,
		};
	},
};