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: improve camera distance calculation to ensure full avatar framing
nirholas1f0b19b8dd28
diff --git a/src/viewer.js b/src/viewer.jsindex 125b6cb08..d82d9f27c 100644--- a/src/viewer.js+++ b/src/viewer.js@@ -625,25 +625,28 @@ export class Viewer {const vFovRad = this.defaultCamera.fov * (Math.PI / 180);const aspect = Math.max(this.defaultCamera.aspect, 0.01);const hFovRad = 2 * Math.atan(Math.tan(vFovRad / 2) * aspect);- const distV = (bbSize.y / 2 * 1.0) / Math.tan(vFovRad / 2);- const distH = (bbSize.x / 2 * 1.0) / Math.tan(hFovRad / 2);- const dist = Math.max(distV, distH);- // Orbital focus: 10% above bbox centre — upper-chest framing for humanoids.- const focusY = bbSize.y * 0.1;+ // Centre the avatar vertically for a tight full-body frame.+ const focusY = 0;++ // 2% breathing room ensures the full body (head + feet) stays in frame.+ const extentV = (bbSize.y / 2) * 1.02;+ const distV = extentV / Math.tan(vFovRad / 2);+ const distH = (bbSize.x / 2) / Math.tan(hFovRad / 2);+ const dist = Math.max(distV, distH);// Final framed camera (the position the user should end up at).const framedPos = new Vector3();if (this.options.cameraPosition) {framedPos.fromArray(this.options.cameraPosition);} else {- // 3/4 angle: shift target right so avatar sits left of centre in viewport.- const panX = dist * 0.18;- framedPos.set(dist * 0.12 + panX, focusY, dist);+ // Slight 3/4 angle — minimal lateral offset keeps the avatar large.+ const panX = dist * 0.06;+ framedPos.set(panX, focusY, dist);}const orbitalTarget = this.options.cameraPosition? new Vector3()- : new Vector3(dist * 0.18, focusY, 0);+ : new Vector3(dist * 0.06, focusY, 0);// In kiosk / embed modes (and on subsequent loads), snap straight to// the framed position. On the first interactive load we tween in from