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 diagnostic functionality for avatar animations with GLTFLoader and AnimationManager
fudjia627d87862e48
diff --git a/public/tour-builder/diag.html b/public/tour-builder/diag.htmlnew file mode 100644index 000000000..724480b51--- /dev/null+++ b/public/tour-builder/diag.html@@ -0,0 +1,35 @@+<!doctype html><meta charset=utf8><body><script type="importmap">+{"imports":{"three":"https://unpkg.com/[email protected]/build/three.module.js","three/addons/":"https://unpkg.com/[email protected]/examples/jsm/","@three-ws/walk":"/tour-builder/walk.mjs"}}+</script>+<script type="module">+import * as THREE from 'three';+import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';+import { MeshoptDecoder } from 'three/addons/libs/meshopt_decoder.module.js';+import { canonicalizeGLBBones } from '/src/glb-canonicalize.js';+import { canonicalNodeMapFromObject, retargetClipToObject, parseClipJSON } from '/src/animation-retarget.js';+import { AnimationManager } from '/src/animation-manager.js';+window.RESULTS = {};+async function diag(name){+ const ab = await fetch('/avatars/'+name+'.glb').then(r=>r.arrayBuffer());+ const { buffer } = canonicalizeGLBBones(ab);+ const gltf = await new GLTFLoader().setMeshoptDecoder(MeshoptDecoder).parseAsync(buffer, '');+ const root = gltf.scene; root.updateWorldMatrix(true,true);+ // upper-arm world direction at REST (bind)+ const map0 = canonicalNodeMapFromObject(root);+ const map = (map0 instanceof Map) ? Object.fromEntries(map0) : map0;+ window.RESULTS[name+'_keys'] = Object.keys(map).filter(k=>/Arm|Fore/.test(k));+ const la = root.getObjectByName('LeftArm'), lf = root.getObjectByName('LeftForeArm');+ function armDir(a,b){ if(!a||!b) return null; const pa=new THREE.Vector3(),pb=new THREE.Vector3(); a.getWorldPosition(pa); b.getWorldPosition(pb); const d=pb.sub(pa).normalize(); return {x:+d.x.toFixed(2),y:+d.y.toFixed(2),z:+d.z.toFixed(2)}; }+ const restDir = armDir(la,lf);+ // now attach AnimationManager + play idle, then re-measure+ const mgr = new AnimationManager(); mgr.attach(root);+ const supports = mgr.supportsCanonicalClips();+ const idleJSON = await fetch('/animations/clips/idle.json').then(r=>r.json());+ mgr.setAnimationDefs([{name:'idle',url:'/animations/clips/idle.json',loop:true}]);+ await mgr.loadAll();+ mgr.crossfadeTo('idle',0); mgr.update(0.3); mgr.update(0.3); root.updateWorldMatrix(true,true);+ const idleDir = armDir(la,lf);+ window.RESULTS[name] = { restDir, supports, idleDir, hasLA: !!la, hasLF: !!lf };+}+(async()=>{ for(const n of ['realistic-female','realistic-male','selfie-girl','michelle','robot','xbot','fox','default']) { try{ await diag(n);}catch(e){ window.RESULTS[n]={err:String(e)}; } } window.DONE=true; })();+</script></body>