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.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
feat: add avatar artifact HTML and GLB model with loading animation
nirholas725e5d4e06de
diff --git a/avatar-artifact.html b/avatar-artifact.htmlnew file mode 100644index 000000000..0e34ceebe--- /dev/null+++ b/avatar-artifact.html@@ -0,0 +1,280 @@+<!DOCTYPE html>+<html>+<head>+ <style>+ * { margin: 0; padding: 0; box-sizing: border-box; }+ body { background: #070714; overflow: hidden; }+ canvas { display: block; }+ </style>+</head>+<body>+<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>+<script>+const W = window.innerWidth, H = window.innerHeight;+const scene = new THREE.Scene();+const camera = new THREE.PerspectiveCamera(42, W / H, 0.1, 100);+camera.position.set(0, 1.6, 4.2);+camera.lookAt(0, 1.6, 0);++const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true });+renderer.setSize(W, H);+renderer.setPixelRatio(Math.min(devicePixelRatio, 2));+renderer.shadowMap.enabled = true;+document.body.appendChild(renderer.domElement);++// Lights+scene.add(new THREE.AmbientLight(0x2a2a5a, 1.2));++const key = new THREE.DirectionalLight(0x99aaff, 2.2);+key.position.set(2, 5, 4);+key.castShadow = true;+scene.add(key);++const rim = new THREE.PointLight(0xff4488, 1.4, 10);+rim.position.set(-3, 2, -1);+scene.add(rim);++const fill = new THREE.PointLight(0x4488ff, 0.8, 8);+fill.position.set(3, 0, 2);+scene.add(fill);++// Materials+const skinMat = new THREE.MeshStandardMaterial({ color: 0x7ba3d4, roughness: 0.25, metalness: 0.05 });+const darkMat = new THREE.MeshStandardMaterial({ color: 0x0d1a2e, roughness: 0.2, metalness: 0.6 });+const irisMat = new THREE.MeshStandardMaterial({ color: 0x55aaff, roughness: 0.05, metalness: 0.3, emissive: 0x1144cc, emissiveIntensity: 0.6 });+const suitMat = new THREE.MeshStandardMaterial({ color: 0x1a2540, roughness: 0.6, metalness: 0.3 });+const glareMat = new THREE.MeshStandardMaterial({ color: 0xffffff, roughness: 0, metalness: 0, transparent: true, opacity: 0.55 });++// ─── Avatar ───────────────────────────────────────────────────────────────────+const avatar = new THREE.Group();+scene.add(avatar);++// Torso+const torsoMesh = new THREE.Mesh(new THREE.CylinderGeometry(0.38, 0.32, 1.0, 20), suitMat);+torsoMesh.position.y = 0.82;+torsoMesh.castShadow = true;+avatar.add(torsoMesh);++// Neck+const neck = new THREE.Mesh(new THREE.CylinderGeometry(0.17, 0.19, 0.28, 16), skinMat);+neck.position.y = 1.47;+avatar.add(neck);++// Head group (rotates for mouse tracking)+const headGroup = new THREE.Group();+headGroup.position.y = 1.94;+avatar.add(headGroup);++const headMesh = new THREE.Mesh(new THREE.SphereGeometry(0.52, 40, 40), skinMat);+headMesh.scale.set(1, 1.08, 0.96);+headMesh.castShadow = true;+headGroup.add(headMesh);++// Eye sockets (slight indents via dark spheres behind eyes)+function makeEye(x) {+ const group = new THREE.Group();+ group.position.set(x, 0.06, 0.44);++ // White+ const white = new THREE.Mesh(new THREE.SphereGeometry(0.105, 20, 20), new THREE.MeshStandardMaterial({ color: 0xddeeff, roughness: 0.3, metalness: 0 }));+ group.add(white);++ // Iris+ const iris = new THREE.Mesh(new THREE.SphereGeometry(0.065, 16, 16), irisMat);+ iris.position.z = 0.055;+ group.add(iris);++ // Pupil+ const pupil = new THREE.Mesh(new THREE.SphereGeometry(0.036, 12, 12), darkMat);+ pupil.position.z = 0.088;+ group.add(pupil);++ // Glare+ const glare = new THREE.Mesh(new THREE.SphereGeometry(0.014, 8, 8), glareMat);+ glare.position.set(0.022, 0.025, 0.1);+ group.add(glare);++ return group;+}++const leftEyeGroup = makeEye(-0.185);+const rightEyeGroup = makeEye( 0.185);+headGroup.add(leftEyeGroup, rightEyeGroup);++// Eyelids (scale Y to blink)+function makeLid(x) {+ const lid = new THREE.Mesh(+ new THREE.SphereGeometry(0.112, 20, 10, 0, Math.PI * 2, 0, Math.PI * 0.5),+ new THREE.MeshStandardMaterial({ color: 0x6a95c0, roughness: 0.3, side: THREE.FrontSide })+ );+ lid.position.set(x, 0.06, 0.43);+ lid.rotation.x = Math.PI;+ lid.scale.y = 0.01; // starts closed-ish (will animate open)+ return lid;+}+const leftLid = makeLid(-0.185);+const rightLid = makeLid( 0.185);+headGroup.add(leftLid, rightLid);++// Eyebrows+function makeBrow(x) {+ const geo = new THREE.BoxGeometry(0.16, 0.03, 0.04);+ const brow = new THREE.Mesh(geo, new THREE.MeshStandardMaterial({ color: 0x3a6090, roughness: 0.5 }));+ brow.position.set(x, 0.215, 0.455);+ brow.rotation.z = x > 0 ? -0.12 : 0.12;+ return brow;+}+headGroup.add(makeBrow(-0.185), makeBrow(0.185));++// Nose+const noseMesh = new THREE.Mesh(new THREE.SphereGeometry(0.07, 12, 12), skinMat);+noseMesh.scale.set(0.7, 0.65, 0.8);+noseMesh.position.set(0, -0.07, 0.5);+headGroup.add(noseMesh);++// Mouth+const mouthGeo = new THREE.TorusGeometry(0.1, 0.025, 8, 20, Math.PI);+const mouth = new THREE.Mesh(mouthGeo, new THREE.MeshStandardMaterial({ color: 0x3a5a80, roughness: 0.5 }));+mouth.position.set(0, -0.2, 0.46);+mouth.rotation.z = Math.PI;+headGroup.add(mouth);++// Shoulders / arms+function makeArm(x) {+ const arm = new THREE.Mesh(new THREE.CylinderGeometry(0.11, 0.09, 0.75, 14), suitMat);+ arm.position.set(x, 0.85, 0);+ arm.rotation.z = x > 0 ? -0.35 : 0.35;+ arm.castShadow = true;+ return arm;+}+avatar.add(makeArm(-0.52), makeArm(0.52));++// Shoulder pads+function makePad(x) {+ const pad = new THREE.Mesh(new THREE.SphereGeometry(0.18, 16, 16), suitMat);+ pad.scale.set(1, 0.7, 1);+ pad.position.set(x, 1.3, 0);+ return pad;+}+avatar.add(makePad(-0.52), makePad(0.52));++// Chest detail (glowing panel)+const panelMat = new THREE.MeshStandardMaterial({ color: 0x1155cc, emissive: 0x0033aa, emissiveIntensity: 1.2, roughness: 0.2 });+const panel = new THREE.Mesh(new THREE.BoxGeometry(0.22, 0.14, 0.04), panelMat);+panel.position.set(0, 0.88, 0.37);+avatar.add(panel);++// Ground plane (subtle)+const ground = new THREE.Mesh(+ new THREE.CircleGeometry(3, 48),+ new THREE.MeshStandardMaterial({ color: 0x0a0a20, roughness: 0.9, metalness: 0.1 })+);+ground.rotation.x = -Math.PI / 2;+ground.receiveShadow = true;+scene.add(ground);++// Fog+scene.fog = new THREE.FogExp2(0x070714, 0.06);++// Particles+const pCount = 120;+const pPos = new Float32Array(pCount * 3);+const pVel = new Float32Array(pCount);+for (let i = 0; i < pCount; i++) {+ pPos[i*3] = (Math.random() - 0.5) * 8;+ pPos[i*3+1] = Math.random() * 5;+ pPos[i*3+2] = (Math.random() - 0.5) * 8;+ pVel[i] = 0.003 + Math.random() * 0.008;+}+const pGeo = new THREE.BufferGeometry();+pGeo.setAttribute('position', new THREE.BufferAttribute(pPos, 3));+const pMat = new THREE.PointsMaterial({ color: 0x6699ff, size: 0.04, transparent: true, opacity: 0.55 });+const pts = new THREE.Points(pGeo, pMat);+scene.add(pts);++// ─── Mouse tracking ───────────────────────────────────────────────────────────+const mouse = { x: 0, y: 0 };+window.addEventListener('mousemove', e => {+ mouse.x = (e.clientX / window.innerWidth - 0.5) * 2;+ mouse.y = (e.clientY / window.innerHeight - 0.5) * 2;+});++// ─── Animate ──────────────────────────────────────────────────────────────────+let t = 0;+let blinkTimer = 0;+let blinkInterval = 3 + Math.random() * 3;+let blinking = false;+let blinkT = 0;++const targetHeadRot = { x: 0, y: 0 };+const currentHeadRot = { x: 0, y: 0 };++function animate() {+ requestAnimationFrame(animate);+ t += 0.016;++ // Breathing+ const breathe = Math.sin(t * 1.15) * 0.025;+ torsoMesh.scale.y = 1 + breathe;+ torsoMesh.position.y = 0.82 + breathe * 0.3;++ // Chest glow pulse+ panelMat.emissiveIntensity = 1.0 + Math.sin(t * 2.3) * 0.3;++ // Head follows mouse (smoothed)+ targetHeadRot.y = mouse.x * 0.35;+ targetHeadRot.x = -mouse.y * 0.2;+ currentHeadRot.x += (targetHeadRot.x - currentHeadRot.x) * 0.06;+ currentHeadRot.y += (targetHeadRot.y - currentHeadRot.y) * 0.06;+ headGroup.rotation.x = currentHeadRot.x;+ headGroup.rotation.y = currentHeadRot.y;++ // Idle body sway+ avatar.rotation.y = Math.sin(t * 0.35) * 0.06;++ // Blink+ blinkTimer += 0.016;+ if (!blinking && blinkTimer > blinkInterval) {+ blinking = true;+ blinkT = 0;+ blinkInterval = 2.5 + Math.random() * 4;+ blinkTimer = 0;+ }+ if (blinking) {+ blinkT += 0.016;+ const half = 0.09;+ const progress = blinkT < half+ ? blinkT / half+ : blinkT < half * 2 ? 1 - (blinkT - half) / half : -1;+ if (progress < 0) {+ leftLid.scale.y = 0.01;+ rightLid.scale.y = 0.01;+ blinking = false;+ } else {+ leftLid.scale.y = progress;+ rightLid.scale.y = progress;+ }+ }++ // Particles drift upward+ const pos = pGeo.attributes.position;+ for (let i = 0; i < pCount; i++) {+ pos.array[i*3+1] += pVel[i];+ if (pos.array[i*3+1] > 5) pos.array[i*3+1] = 0;+ }+ pos.needsUpdate = true;+ pts.rotation.y += 0.0006;++ renderer.render(scene, camera);+}+animate();++window.addEventListener('resize', () => {+ const w = window.innerWidth, h = window.innerHeight;+ camera.aspect = w / h;+ camera.updateProjectionMatrix();+ renderer.setSize(w, h);+});+</script>+</body>+</html>diff --git a/avatar/index.html b/avatar/index.htmlnew file mode 100644index 000000000..f3ec5727f--- /dev/null+++ b/avatar/index.html@@ -0,0 +1,203 @@+<!DOCTYPE html>+<html>+<head>+ <style>+ * { margin: 0; padding: 0; box-sizing: border-box; }+ body { background: #070714; overflow: hidden; font-family: sans-serif; }+ canvas { display: block; }+ #loader {+ position: fixed; inset: 0; display: flex; flex-direction: column;+ align-items: center; justify-content: center; color: #6699ff;+ font-size: 14px; letter-spacing: 0.1em; gap: 16px; z-index: 10;+ }+ #loader-bar-wrap {+ width: 200px; height: 3px; background: #1a1a3a; border-radius: 2px; overflow: hidden;+ }+ #loader-bar { height: 100%; width: 0%; background: #6699ff; transition: width 0.2s; }+ #loader.done { opacity: 0; pointer-events: none; transition: opacity 0.6s; }+ </style>+</head>+<body>+<div id="loader">+ <span>LOADING MODEL</span>+ <div id="loader-bar-wrap"><div id="loader-bar"></div></div>+</div>++<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>+<script src="https://cdn.jsdelivr.net/npm/[email protected]/examples/js/loaders/GLTFLoader.js"></script>++<script>+const GLB_URL = 'https://raw.githubusercontent.com/overstepping/-/main/cz.glb';++// ─── Scene ────────────────────────────────────────────────────────────────────+const scene = new THREE.Scene();+scene.fog = new THREE.FogExp2(0x070714, 0.045);++const camera = new THREE.PerspectiveCamera(42, innerWidth / innerHeight, 0.01, 100);+camera.position.set(0, 1.4, 3.5);+camera.lookAt(0, 1.2, 0);++const renderer = new THREE.WebGLRenderer({ antialias: true });+renderer.setSize(innerWidth, innerHeight);+renderer.setPixelRatio(Math.min(devicePixelRatio, 2));+renderer.shadowMap.enabled = true;+renderer.shadowMap.type = THREE.PCFSoftShadowMap;+renderer.outputEncoding = THREE.sRGBEncoding;+renderer.toneMapping = THREE.ACESFilmicToneMapping;+renderer.toneMappingExposure = 1.1;+document.body.appendChild(renderer.domElement);++// ─── Lights ───────────────────────────────────────────────────────────────────+scene.add(new THREE.AmbientLight(0x2a2a5a, 1.0));++const key = new THREE.DirectionalLight(0xaabbff, 2.0);+key.position.set(2, 5, 4);+key.castShadow = true;+key.shadow.mapSize.set(1024, 1024);+scene.add(key);++const rim = new THREE.PointLight(0xff4488, 1.2, 12);+rim.position.set(-3, 2, -2);+scene.add(rim);++const fill = new THREE.PointLight(0x4466ff, 0.7, 10);+fill.position.set(3, 0, 2);+scene.add(fill);++// ─── Ground ───────────────────────────────────────────────────────────────────+const ground = new THREE.Mesh(+ new THREE.CircleGeometry(4, 64),+ new THREE.MeshStandardMaterial({ color: 0x0a0a20, roughness: 0.9 })+);+ground.rotation.x = -Math.PI / 2;+ground.receiveShadow = true;+scene.add(ground);++// ─── Particles ────────────────────────────────────────────────────────────────+const pCount = 150;+const pPos = new Float32Array(pCount * 3);+const pVel = new Float32Array(pCount);+for (let i = 0; i < pCount; i++) {+ pPos[i*3] = (Math.random() - 0.5) * 10;+ pPos[i*3+1] = Math.random() * 6;+ pPos[i*3+2] = (Math.random() - 0.5) * 10;+ pVel[i] = 0.003 + Math.random() * 0.007;+}+const pGeo = new THREE.BufferGeometry();+pGeo.setAttribute('position', new THREE.BufferAttribute(pPos, 3));+const pts = new THREE.Points(pGeo, new THREE.PointsMaterial({ color: 0x5588ff, size: 0.04, transparent: true, opacity: 0.5 }));+scene.add(pts);++// ─── Mouse ────────────────────────────────────────────────────────────────────+const mouse = { x: 0, y: 0 };+window.addEventListener('mousemove', e => {+ mouse.x = (e.clientX / innerWidth - 0.5) * 2;+ mouse.y = (e.clientY / innerHeight - 0.5) * 2;+});++// ─── Load GLB ─────────────────────────────────────────────────────────────────+const loaderEl = document.getElementById('loader');+const barEl = document.getElementById('loader-bar');++let model = null;+let mixer = null;+let headBone = null;+const targetRot = { x: 0, y: 0 };+const currentRot = { x: 0, y: 0 };++const loader = new THREE.GLTFLoader();+loader.load(+ GLB_URL,+ (gltf) => {+ model = gltf.scene;++ // Auto-center and scale to fit+ const box = new THREE.Box3().setFromObject(model);+ const size = box.getSize(new THREE.Vector3());+ const center = box.getCenter(new THREE.Vector3());+ const maxDim = Math.max(size.x, size.y, size.z);+ const scale = 2.0 / maxDim;+ model.scale.setScalar(scale);+ model.position.sub(center.multiplyScalar(scale));+ model.position.y += size.y * scale * 0.5; // sit on ground++ model.traverse(obj => {+ if (obj.isMesh) {+ obj.castShadow = true;+ obj.receiveShadow = true;+ }+ // Find head bone for mouse tracking+ const name = (obj.name || '').toLowerCase();+ if (!headBone && (name.includes('head') || name.includes('neck'))) {+ headBone = obj;+ }+ });++ scene.add(model);++ // Play first animation if present+ if (gltf.animations.length > 0) {+ mixer = new THREE.AnimationMixer(model);+ mixer.clipAction(gltf.animations[0]).play();+ }++ loaderEl.classList.add('done');+ },+ (xhr) => {+ if (xhr.total) barEl.style.width = (xhr.loaded / xhr.total * 100) + '%';+ },+ (err) => {+ loaderEl.innerHTML = '<span style="color:#ff4466">Failed to load model</span><small>' + err.message + '</small>';+ }+);++// ─── Animate ──────────────────────────────────────────────────────────────────+const clock = new THREE.Clock();++function animate() {+ requestAnimationFrame(animate);+ const dt = clock.getDelta();+ const t = clock.elapsedTime;++ if (mixer) mixer.update(dt);++ if (model) {+ // Idle sway+ model.rotation.y = Math.sin(t * 0.4) * 0.06;++ // Head tracks mouse+ targetRot.y = mouse.x * 0.3;+ targetRot.x = -mouse.y * 0.18;+ currentRot.x += (targetRot.x - currentRot.x) * 0.05;+ currentRot.y += (targetRot.y - currentRot.y) * 0.05;++ if (headBone) {+ headBone.rotation.x = currentRot.x;+ headBone.rotation.y = currentRot.y;+ } else {+ // No head bone found — tilt whole model subtly+ model.rotation.x = currentRot.x * 0.3;+ }+ }++ // Particles drift+ const pa = pGeo.attributes.position;+ for (let i = 0; i < pCount; i++) {+ pa.array[i*3+1] += pVel[i];+ if (pa.array[i*3+1] > 6) pa.array[i*3+1] = 0;+ }+ pa.needsUpdate = true;+ pts.rotation.y += 0.0005;++ renderer.render(scene, camera);+}+animate();++window.addEventListener('resize', () => {+ camera.aspect = innerWidth / innerHeight;+ camera.updateProjectionMatrix();+ renderer.setSize(innerWidth, innerHeight);+});+</script>+</body>+</html>diff --git a/cz-package/cz.glb b/cz-package/cz.glbnew file mode 100644index 000000000..48f6b081eBinary files /dev/null and b/cz-package/cz.glb differdiff --git a/cz-package/package.json b/cz-package/package.jsonnew file mode 100644index 000000000..0ecafb6bf--- /dev/null+++ b/cz-package/package.json@@ -0,0 +1,11 @@+{+ "name": "cz-avatar",+ "version": "1.0.0",+ "description": "CZ 3D avatar GLB model",+ "files": ["cz.glb"],+ "main": "cz.glb",+ "publishConfig": {+ "access": "public",+ "registry": "https://registry.npmjs.org/"+ }+}