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.

fix(selfie): name the dark room before the blur it causes

nirholasdbf410de3e05
diff --git a/src/selfie-gates.js b/src/selfie-gates.js
index a79be1635..7a84985b0 100644
--- a/src/selfie-gates.js
+++ b/src/selfie-gates.js
@@ -189,12 +189,17 @@ export function gradeFrame(m) {
: `Turn your head ${slot === 'left' ? 'left' : 'right'} about 45°.`;
} else if (!centered) {
reason = 'Center your face in the oval.';
- } else if (!blurOk) {
- reason = 'Hold steady. The image is blurry.';
} else if (tooDark) {
+ // Lighting is named before blur on purpose. A dim frame carries little
+ // contrast, so its Laplacian response collapses too and it trips the
+ // blur gate as well: telling that user to "hold steady" sends them to
+ // fix the symptom while the room stays dark. Light is the root cause,
+ // and fixing it usually clears the blur reading with it.
reason = 'Too dark. Find better light.';
} else if (blownOut) {
reason = 'Too bright. Move out of direct light or turn away from the window.';
+ } else if (!blurOk) {
+ reason = 'Hold steady. The image is blurry.';
}
return {
diff --git a/tests/selfie-gates.test.js b/tests/selfie-gates.test.js
index 70f644086..514eee40f 100644
--- a/tests/selfie-gates.test.js
+++ b/tests/selfie-gates.test.js
@@ -177,6 +177,21 @@ describe('gradeFrame', () => {
expect(g.reason).toMatch(/straight on/i);
});
+ it('blames the light, not the hands, when a dim frame also reads as blurry', () => {
+ // A dim room suppresses contrast, so the Laplacian response collapses
+ // and the blur gate trips alongside the luma one. "Hold steady" would
+ // send the user to fix a symptom while the room stayed dark.
+ const g = gradeFrame({ ...goodFrontal, luma: GATES.LUMA_MIN - 5, blur: 0 });
+ expect(g.blurOk).toBe(false);
+ expect(g.lumaOk).toBe(false);
+ expect(g.reason).toMatch(/dark|light/i);
+ });
+
+ it('still names blur when the frame is well lit', () => {
+ const g = gradeFrame({ ...goodFrontal, blur: 0 });
+ expect(g.reason).toMatch(/steady|blurry/i);
+ });
+
it('falls back to the frontal window for an unknown slot', () => {
const g = gradeFrame({ ...goodFrontal, slot: 'profile' });
expect(g.yawOk).toBe(true);