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(avatars): serve avatar GLBs from the public bucket when the signed R2 read is refused

nirholas8366bb914e7b
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d2540c1cb..6c800b801 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,7 @@ Public history for [three.ws](https://three.ws), newest first. New pages come fr
## 2026-09-08
+- **Avatars keep their real skin, eyes and hair, and we can prove it on a phone**: Every avatar the platform loads gets its skin, eyes, hair and teeth re-shaded with real-world material values the moment it appears: skin at the roughness bare skin actually has with a warm scattering layer, a wet cornea that catches a highlight, and hair that reads as strands rather than a helmet. That pass was already running, but the check meant to prove it was pointed at the wrong page and had been quietly reporting nothing at all, so it could not have caught the day it broke. It now runs against the same embed page your visitors see, at phone, tablet and desktop widths, and records exactly which materials it upgraded and to what values. Alongside it, a new check loads a full 4K-textured model on an emulated iPhone and Android phone over a slow mobile connection and measures the real bytes and load time, so a model that would not open on a phone is caught before it ships rather than after. `[improvement, infra]`
- **Forge tells you when uploads are down, instead of blaming your connection**: Adding a photo on the Forge could fail with "Network error during upload" when nothing was wrong with your network or your photo. Our asset storage had stopped accepting our credential, but the page had no way to know that: the browser is handed a short-lived upload address and sends the image straight to storage, and when storage refuses, the refusal comes back without the header a browser needs in order to show the page what happened. So a platform outage arrived looking exactly like a bad phone signal, and Retry could never fix it. The page now checks that storage will actually accept an upload before handing one out, and says so plainly when it will not, so you can tell "come back in a few minutes" apart from "try a different photo". The same fix covers the Forge Studio and 3D print upload paths. (`/forge`) `[fix]`
- **Robinhood Portfolios can now show you what a basket would have done, and what the rebalancing did to it**: Every generated portfolio now comes with a backtest, and it runs the basket twice: once rebalanced on the schedule it published, and once left alone. The gap between those two lines is the whole reason to pick one schedule over another, and it goes both ways, since rebalancing quietly harvests the swings in a basket whose holdings move against each other and quietly gives up gains in one where a single holding keeps winning. Coverage is stated rather than glossed over: a holding with no price history is named and left out, the window shown is only the stretch where every remaining holding has real observations, and nothing is filled in to close a gap. Getting that history at all took some doing, because this chain keeps no price archive and produces about 864,000 blocks a day, so reading a month of prices back off the chain is not something a page can do while you wait. Tokenized stocks are covered from their price feeds going back weeks, and a nightly snapshot now records the whole market so coverage keeps growing for everything else, memecoins included. Sharing a portfolio also got fixed: a link now carries the portfolio itself rather than the sentence that produced it, so what you send is exactly what the other person opens, where before the wording was re-run and could quietly come back as a different basket. There is a new endpoint for checking that a portfolio document really is the one a portfolio was published under, and a client library for developers who want the market, the generator, the backtest and that check from their own code. Along the way two data bugs were fixed that were quietly under-reporting the market: the tokenized-stock board had been describing only a couple of tokens per batch instead of all thirty, and the price-history reads had been silently returning less history the more of it you asked for. (`/markets/robinhood/portfolios`) `[feature, improvement]`
- **The club now takes $THREE at the door and at the stage, not just USDC**: The club has always advertised two ways to pay: USDC or $THREE, on Solana, for both the cover charge and every dance tip. Only one of them was reachable. The checkout window picked the first token a service offered and gave you no way to choose the other, so $THREE was quoted on every paid page and payable on none of them. Across every club tip ever settled, not one was paid in $THREE, which is what you would expect from a menu with a hidden second item. The checkout now shows a token picker whenever a service quotes more than one, with each token's real price on it, so you can compare 0.001 USDC against its $THREE equivalent before you approve anything, and the price at the top of the window follows what you pick. If you have agent wallets, they still pay in USDC only, and the window now says so instead of quietly hiding them when you switch tokens. Two settlement bugs behind the door were fixed at the same time. The first would have hit the very first person to pay in $THREE: sending a token to a wallet that has never held it requires opening an account for it on-chain, and the check that decides whether we can afford to sponsor a payment was ignoring that cost, so the payment would have been accepted and then failed on-chain for a reason that looked like something else entirely. The second was making the club look open when it was not: a healthy payer covering their own fees could reset a shared 'we can still sponsor payments' flag that belonged to a different wallet, so the door kept quoting prices it could not actually take. Finally, when payments are paused because the wallet that settles them needs topping up, the checkout now says that in a sentence and tells you nothing was charged, instead of showing you the raw error envelope it used to paste in, which read like a broken link. (`/club`) `[fix, improvement]`
diff --git a/api/avatars/[id]/[action].js b/api/avatars/[id]/[action].js
index 4aaa58b47..5bc45cd61 100644
--- a/api/avatars/[id]/[action].js
+++ b/api/avatars/[id]/[action].js
@@ -3,6 +3,9 @@
// (from [action] filename) automatically. Each handler below is unchanged
// from its prior single-file form.
+import { Readable } from 'node:stream';
+import { pipeline } from 'node:stream/promises';
+
import { GetObjectCommand } from '@aws-sdk/client-s3';
import { z } from 'zod';
@@ -14,7 +17,13 @@ import { limits, clientIp } from '../../_lib/rate-limit.js';
import { parse, isUuid } from '../../_lib/validate.js';
import { readStorageMode, storageModeSchema, defaultStorageMode } from '../../_lib/storage-mode.js';
import { getAvatar, resolveAvatarUrl } from '../../_lib/avatars.js';
-import { r2, publicUrl, thumbnailUrl } from '../../_lib/r2.js';
+import {
+ r2,
+ publicUrl,
+ publicUrlOrNull,
+ thumbnailUrl,
+ isStorageInfrastructureError,
+} from '../../_lib/r2.js';
import { env } from '../../_lib/env.js';
import { fetchUpstream } from '../../_lib/upstream-fetch.js';
@@ -673,11 +682,54 @@ async function handleGlb(req, res) {
} catch {}
});
} catch (err) {
- // 404 if R2 doesn't know the key (deleted out-of-band); 502 otherwise.
+ // 404 if R2 doesn't know the key (deleted out-of-band).
const code = err?.Code || err?.name;
if (code === 'NoSuchKey' || code === 'NotFound') {
return error(res, 404, 'not_found', 'avatar glb missing from storage');
}
+ // The signed read is broken, not the object: the credential is rejected
+ // or the endpoint is unreachable, and the same key is readable
+ // unauthenticated on the bucket's public domain. api/cdn-object.js grew
+ // this rung on 2026-09-07 and this route never did, so a rejected R2
+ // secret answered 502 for EVERY avatar GLB on the site: /pay, /walk and
+ // every embed swapped the user's avatar for the "robot" placeholder
+ // while the public domain served those same bytes with a 200 throughout.
+ //
+ // cdn-object redirects; this route must not. Its entire reason to exist
+ // is that the public r2.dev domain sends no access-control-allow-origin
+ // at all, so a 302 there turns a 502 into a CORS failure for the embed
+ // SDK and every cross-origin GLTFLoader. Streaming the bytes through
+ // keeps the wildcard CORS headers set at the top of this handler, so the
+ // contract callers depend on survives the degraded path unchanged.
+ //
+ // The permission gate above has already run, so this changes who may
+ // read nothing: it only changes which origin the bytes come from.
+ const fallbackUrl = isStorageInfrastructureError(err) ? publicUrlOrNull(key) : null;
+ if (fallbackUrl) {
+ console.error('[avatars/glb] signed read failed, streaming public bucket domain:', key, err?.message);
+ try {
+ const upstream = await fetchUpstream(
+ fallbackUrl,
+ { headers: { accept: 'model/gltf-binary,*/*' } },
+ { name: 'r2:public-glb', timeoutMs: 20_000, attempts: 2 },
+ );
+ res.statusCode = 200;
+ res.setHeader('content-type', 'model/gltf-binary');
+ const len = upstream.headers.get('content-length');
+ if (len) res.setHeader('content-length', len);
+ const etag = upstream.headers.get('etag');
+ if (etag) res.setHeader('etag', etag);
+ // Never cache the degraded path: the moment the credential is
+ // healthy again traffic has to return to the signed read with no
+ // stale hop pinned at the edge.
+ res.setHeader('cache-control', 'no-store');
+ await pipeline(Readable.fromWeb(upstream.body), res);
+ return;
+ } catch (fallbackErr) {
+ console.error('[avatars/glb] public bucket domain failed too:', key, fallbackErr?.message);
+ if (res.headersSent) return res.destroy(fallbackErr);
+ }
+ }
console.error('[avatars/glb] r2 fetch failed:', err);
return error(res, 502, 'upstream_error', 'failed to fetch avatar glb');
}
diff --git a/data/changelog.json b/data/changelog.json
index cba5b0c5b..6d0abb567 100644
--- a/data/changelog.json
+++ b/data/changelog.json
@@ -1,6 +1,12 @@
{
"$comment": "Curated changelog entries for three.ws, the editorial layer of the public changelog. New PAGE launches are tracked automatically via the `added` field in data/pages.json; this file is for everything else holders care about: improvements, fixes, SDK releases, trading/payments capabilities, security work. scripts/build-page-index.mjs merges both sources into CHANGELOG.md, public/changelog.json, and public/changelog.xml. Newest first. Allowed tags: feature, improvement, fix, sdk, infra, docs, security. `link` is optional and must be a live three.ws path.",
"entries": [
+ {
+ "date": "2026-09-08",
+ "title": "Avatars keep their real skin, eyes and hair, and we can prove it on a phone",
+ "summary": "Every avatar the platform loads gets its skin, eyes, hair and teeth re-shaded with real-world material values the moment it appears: skin at the roughness bare skin actually has with a warm scattering layer, a wet cornea that catches a highlight, and hair that reads as strands rather than a helmet. That pass was already running, but the check meant to prove it was pointed at the wrong page and had been quietly reporting nothing at all, so it could not have caught the day it broke. It now runs against the same embed page your visitors see, at phone, tablet and desktop widths, and records exactly which materials it upgraded and to what values. Alongside it, a new check loads a full 4K-textured model on an emulated iPhone and Android phone over a slow mobile connection and measures the real bytes and load time, so a model that would not open on a phone is caught before it ships rather than after.",
+ "tags": ["improvement", "infra"]
+ },
{
"date": "2026-09-08",
"title": "The club now takes $THREE at the door and at the stage, not just USDC",
diff --git a/public/changelog.json b/public/changelog.json
index 383b06f56..fc3832f95 100644
--- a/public/changelog.json
+++ b/public/changelog.json
@@ -1,11 +1,22 @@
{
- "generated_at": "2026-09-08T01:53:55.822Z",
+ "generated_at": "2026-09-08T16:54:11.538Z",
"generated_by": "scripts/build-page-index.mjs from data/pages.json + data/changelog.json",
"site": {
"name": "three.ws",
"url": "https://three.ws"
},
"entries": [
+ {
+ "date": "2026-09-08",
+ "type": "update",
+ "title": "Avatars keep their real skin, eyes and hair, and we can prove it on a phone",
+ "summary": "Every avatar the platform loads gets its skin, eyes, hair and teeth re-shaded with real-world material values the moment it appears: skin at the roughness bare skin actually has with a warm scattering layer, a wet cornea that catches a highlight, and hair that reads as strands rather than a helmet. That pass was already running, but the check meant to prove it was pointed at the wrong page and had been quietly reporting nothing at all, so it could not have caught the day it broke. It now runs against the same embed page your visitors see, at phone, tablet and desktop widths, and records exactly which materials it upgraded and to what values. Alongside it, a new check loads a full 4K-textured model on an emulated iPhone and Android phone over a slow mobile connection and measures the real bytes and load time, so a model that would not open on a phone is caught before it ships rather than after.",
+ "link": null,
+ "tags": [
+ "improvement",
+ "infra"
+ ]
+ },
{
"date": "2026-09-08",
"type": "update",
diff --git a/public/changelog.xml b/public/changelog.xml
index 31ff5828b..bf515b976 100644
--- a/public/changelog.xml
+++ b/public/changelog.xml
@@ -6,6 +6,14 @@
<atom:link href="https://three.ws/changelog.xml" rel="self" type="application/rss+xml"/>
<description>What's new on three.ws: features, improvements, and releases, newest first.</description>
<language>en</language>
+ <item>
+ <title>Avatars keep their real skin, eyes and hair, and we can prove it on a phone</title>
+ <link>https://three.ws/changelog</link>
+ <guid isPermaLink="false">2026-09-08:Avatars keep their real skin, eyes and hair, and we can prove it on a phone</guid>
+ <pubDate>Tue, 08 Sep 2026 12:00:00 GMT</pubDate>
+ <category>improvement</category>
+ <description>Every avatar the platform loads gets its skin, eyes, hair and teeth re-shaded with real-world material values the moment it appears: skin at the roughness bare skin actually has with a warm scattering layer, a wet cornea that catches a highlight, and hair that reads as strands rather than a helmet. That pass was already running, but the check meant to prove it was pointed at the wrong page and had been quietly reporting nothing at all, so it could not have caught the day it broke. It now runs against the same embed page your visitors see, at phone, tablet and desktop widths, and records exactly which materials it upgraded and to what values. Alongside it, a new check loads a full 4K-textured model on an emulated iPhone and Android phone over a slow mobile connection and measures the real bytes and load time, so a model that would not open on a phone is caught before it ships rather than after.</description>
+ </item>
<item>
<title>Forge tells you when uploads are down, instead of blaming your connection</title>
<link>https://three.ws/forge</link>
diff --git a/public/features.json b/public/features.json
index 14288747d..5e730b855 100644
--- a/public/features.json
+++ b/public/features.json
@@ -1,5 +1,5 @@
{
- "generated_at": "2026-09-08T01:53:55.812Z",
+ "generated_at": "2026-09-08T16:54:11.457Z",
"generated_by": "scripts/build-page-index.mjs from data/pages.json",
"site": {
"name": "three.ws",