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.

Add webgl-support helper; changelog and features update

nirholas07d3ed4b613b
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 568b65abe..6e2b19e63 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -17,11 +17,12 @@ Public history for [three.ws](https://three.ws), newest first. New pages come fr
- **Embedded avatars never show a blank frame** — A walking-avatar embed whose avatar can't load — a deleted or mistyped ID, a private avatar a public page can't read, or a dropped connection — now shows the default avatar walking with a short 'couldn't load that avatar — showing the default' note, instead of leaving an empty, all-dark frame on the host page. The embed always renders a body. The embed editor now flags an avatar ID it can't find with a clear 'not found' marker and tells you to pick a public or unlisted avatar, rather than silently keeping a dead ID. And owners can now load their own private avatar's 3D file when signed in, which previously failed even for the avatar's owner. (`/embed`) `[fix]`
- **Fix the location-proof behind IRL 'agents near me'** — The step that proves you're physically where you say you are — so the 'agents near me' view only reveals pins around your real location, never somewhere you point at from afar — could fail and return an error on every attempt. That same failure meant the privacy check it powers wasn't being enforced. It now works reliably with or without a configured signing secret: locally and in preview it stays open so testing isn't blocked, and in production each nearby read is bound to a genuine, freshly-signed location fix that expires in a few minutes and can't be forged or replayed from a distance. Nothing changes in how you use IRL — your location is still read only to mint the short-lived proof, never stored or logged. (`/irl`) `[fix, security]`
- **Fix: agent reputation scores now read correctly** — Two places that read an agent's ERC-8004 reputation were decoding it wrong. The on-chain registry returns the average rating already worked out (and signed, so it can go negative); both the paid reputation MCP tool and the trust check that guards autonomous agent-to-agent payments were dividing that value a second time — understating every score, and turning a negative reputation into a meaninglessly large positive one. The MCP tool was also listening for the wrong on-chain event, so it always reported zero past vouches even when an agent had many. Both now report the true average, handle negative reputations correctly, and surface real review history — so a 'pay only above this score' rule actually does what it says. `[fix]`
+- **Fix: live trade tape, 3D generation, and agent minting hold up under pressure** — Tightened three backend paths that could fail loudly under load or flaky upstreams. The live DEX trade tape on graduated coins (including $THREE) used to blank out whenever its market-data source got rate-limited; it now keeps showing the last good trades and quietly backs off the source instead of hammering it, so the tape stays populated through a rate-limit blip. Forge 3D generations are now pulled into our own storage with automatic retries, so a momentary network hiccup while saving a freshly generated model no longer loses the result. And minting an agent on-chain now returns a clear 'network busy, try again' message when every Solana RPC is congested, instead of a generic error — the same graceful handling the rest of checkout already had. Your home feed also stays up during database upgrades rather than erroring. `[fix, infra]`
- **Fix: token art loads reliably and 3D embeds never blank out** — Hardened two things that could fail quietly on the platform. Token artwork is fetched through our own image proxy so it loads cross-origin without errors; a slow or dead image host could previously hang that proxy until it was killed, leaving art stuck loading — it now bounds every lookup and falls back to a clean on-brand placeholder fast, so art always resolves. And every embedded 3D view (agent stages, model viewers, profile avatars) now degrades to a tasteful 'not available on this device' state instead of throwing when a browser or GPU refuses a WebGL context — so a low-end or locked-down device sees a graceful fallback rather than a broken page. `[fix, infra]`
- **Forge polish: engine picker, honest wording, keyboard tabs, full-length remix** — A round of Forge fixes. The engine picker now wraps all eight lanes — NVIDIA, Hunyuan3D, Fast, Meshy, Tripo, Rodin, Stability, Replicate — cleanly inside its selector instead of spilling past the panel edge, so every engine stays readable at a glance. The build estimate is honest to the tab you're on: on Describe it it reads 'renders a preview image, then builds 3D' (it never asked you for an image), on From photos 'builds from your reference photos', and a credit figure now only appears on metered lanes so a free build never reads 'Free · ~N credits'. The Describe it / From photos / From a sketch tabs are now fully keyboard-navigable with the arrow keys and announce correctly to screen readers. And opening a remix link keeps your whole prompt — long prompts are no longer clipped to 300 characters. (`/forge`) `[fix, improvement]`
- **Free Forge on the IBM demo stays reliable while the GPU warms up** — The free, no-wallet 'forge a 3D model' widget on the IBM partnership page no longer shows a false 'briefly unreachable' error when the free GPU is cold. It used to fire up to six generation requests behind a single click, which spent the free lane's hourly limit about six times faster — a few tries could lock you out — and a slow cold start would surface as an error even though the model was still on its way. Now it makes one request per click (the server already falls back across NVIDIA, TRELLIS, and Hugging Face on its own), shows honest progress while a cold start warms up (which can take up to a minute), and, if the free lane is genuinely at its hourly limit, says exactly that and when to try again — pointing you to the instant paid Forge above. A model reliably comes back to orbit and download. (`/ibm/x402-demo`) `[fix, improvement]`
-- **Hide the controls in IRL for an unobstructed AR view** — On a phone, the IRL controls (the top bar, the bottom row of buttons, the room badges, the compass and on-screen hints) could cover so much of the screen that you couldn't see the camera view or move your avatar past them. There's now a one-tap hide button on the right edge: tap it and all of that chrome slides away, leaving just the live AR scene — the on-screen joystick and drag-to-look still work, so you can walk around and look about with nothing in the way. Tap the same button (it stays put and glows green) to bring everything back; on a keyboard, Esc restores it too. (`/irl`) `[feature, improvement]`
- **IBM x402 demo works when embedded in IBM's CMS** — The five live demos on the IBM partnership page — Forge, x402 micropayments, the 3D agent, Play, and IRL — now run correctly when the page is embedded inside IBM's content platform, not only when opened directly. IBM serves the embed from a Seismic gateway address, and the browser was silently blocking it: the free 3D generator reported 'briefly unreachable' and the wallet payment couldn't reach the Solana network, because three.ws didn't yet recognize that gateway as an allowed origin. three.ws now trusts IBM's Seismic-served origins for both data calls and embedding, so the free Forge, the on-chain payment flow, and the inline Play/IRL worlds all work on the embedded page. (`/ibm/x402-demo`) `[fix, infra]`
+- **IRL gets a clean, get-out-of-the-way immersive mode** — On a phone, the IRL controls (top bar, the row of buttons, room badges, compass and hints) could cover so much of the screen that you couldn't see the camera view or move your avatar past them. Now the controls get out of your way on their own: once the camera is live they fade after a few idle seconds, leaving just the AR scene — the joystick and drag-to-look keep working, so you can walk around and look about with nothing in the way. Tap anywhere on the empty view (or the eye button on the right edge) to bring them back, and they fade again when you go quiet. On desktop it's a focus/cinematic mode that works like a video player — move the mouse to reveal the controls, leave it still to hide them — plus real keyboard shortcuts: H to hide or show the interface, F for true fullscreen, Esc to restore. A one-time hint shows you how the first time the controls disappear, and the whole thing respects reduced-motion settings. (`/irl`) `[feature, improvement]`
- **Live webinar stage on the IBM x402 demo page** — The IBM × three.ws demo page now opens with a webinar stage: a live countdown to the session, with one-click Add to Calendar (Google + .ics). When the talk goes live, the same stage becomes the player — a pre-recorded video plays synced to wall-clock like a broadcast premiere (everyone sees the same moment, latecomers join in progress), or a live feed streams in its place. The recording stays on the page afterward, and the x402 demos sit right below so you can watch and try them on one screen. (`/ibm/x402-demo`) `[feature]`
- **New doc: every NVIDIA model three.ws runs for free** — A new docs page maps the entire free NVIDIA inference layer the platform runs on — one free key unlocks all of it. It covers what each model does and where it's used: TRELLIS for free text→3D in Forge, FLUX.1-schnell for text→image, the Llama 3.3 / Nemotron / Llama 4 chat lineup in the Brain workbench, Nemotron vision for photo checks and alt-text, nv-embedqa embeddings for agent memory, the cross-encoder reranker, NemoGuard content safety, and Magpie multilingual text-to-speech. Each entry lists the model, the use case, and the free-first fallback behind it. (`/docs/nvidia-models`) `[docs]`
- **New docs: agent reputation on Solana** — A new guide explains how an agent earns a trust record on Solana, where there's no single on-chain reputation registry like the EVM side has. It covers the two systems three.ws uses together: attestation reputation — anyone can leave a permanent, on-chain vouch for an agent with a tiny signed memo (optionally backed by SOL stake), which the Agent Passport renders as an at-a-glance A–D trust grade weighted toward the most trustworthy reviews; and AgenC, a Solana program where agents earn reputation by completing real paid work, with stake that gets slashed for misbehavior. It also explains the identity bridge that lets one agent hold both a Solana and an Ethereum (ERC-8004) identity. A companion tutorial walks through reading a Solana agent's grade from the Passport and the API, then leaving your own on-chain vouch. New glossary entries: AgenC, trust grade, and memo attestation. (`/docs/solana-reputation`) `[docs]`
diff --git a/data/changelog.json b/data/changelog.json
index 9b8491a11..2880c3935 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-06-22",
+ "title": "Fix: live trade tape, 3D generation, and agent minting hold up under pressure",
+ "summary": "Tightened three backend paths that could fail loudly under load or flaky upstreams. The live DEX trade tape on graduated coins (including $THREE) used to blank out whenever its market-data source got rate-limited; it now keeps showing the last good trades and quietly backs off the source instead of hammering it, so the tape stays populated through a rate-limit blip. Forge 3D generations are now pulled into our own storage with automatic retries, so a momentary network hiccup while saving a freshly generated model no longer loses the result. And minting an agent on-chain now returns a clear 'network busy, try again' message when every Solana RPC is congested, instead of a generic error — the same graceful handling the rest of checkout already had. Your home feed also stays up during database upgrades rather than erroring.",
+ "tags": ["fix", "infra"]
+ },
{
"date": "2026-06-22",
"title": "Fix: token art loads reliably and 3D embeds never blank out",
@@ -35,8 +41,8 @@
},
{
"date": "2026-06-22",
- "title": "Hide the controls in IRL for an unobstructed AR view",
- "summary": "On a phone, the IRL controls (the top bar, the bottom row of buttons, the room badges, the compass and on-screen hints) could cover so much of the screen that you couldn't see the camera view or move your avatar past them. There's now a one-tap hide button on the right edge: tap it and all of that chrome slides away, leaving just the live AR scene — the on-screen joystick and drag-to-look still work, so you can walk around and look about with nothing in the way. Tap the same button (it stays put and glows green) to bring everything back; on a keyboard, Esc restores it too.",
+ "title": "IRL gets a clean, get-out-of-the-way immersive mode",
+ "summary": "On a phone, the IRL controls (top bar, the row of buttons, room badges, compass and hints) could cover so much of the screen that you couldn't see the camera view or move your avatar past them. Now the controls get out of your way on their own: once the camera is live they fade after a few idle seconds, leaving just the AR scene — the joystick and drag-to-look keep working, so you can walk around and look about with nothing in the way. Tap anywhere on the empty view (or the eye button on the right edge) to bring them back, and they fade again when you go quiet. On desktop it's a focus/cinematic mode that works like a video player — move the mouse to reveal the controls, leave it still to hide them — plus real keyboard shortcuts: H to hide or show the interface, F for true fullscreen, Esc to restore. A one-time hint shows you how the first time the controls disappear, and the whole thing respects reduced-motion settings.",
"tags": ["feature", "improvement"],
"link": "/irl"
},
diff --git a/public/changelog.json b/public/changelog.json
index 347550b89..e7e84c9fb 100644
--- a/public/changelog.json
+++ b/public/changelog.json
@@ -1,5 +1,5 @@
{
- "generated_at": "2026-06-22T23:42:13.630Z",
+ "generated_at": "2026-06-22T23:48:49.304Z",
"generated_by": "scripts/build-page-index.mjs from data/pages.json + data/changelog.json",
"site": {
"name": "three.ws",
@@ -117,6 +117,17 @@
"fix"
]
},
+ {
+ "date": "2026-06-22",
+ "type": "update",
+ "title": "Fix: live trade tape, 3D generation, and agent minting hold up under pressure",
+ "summary": "Tightened three backend paths that could fail loudly under load or flaky upstreams. The live DEX trade tape on graduated coins (including $THREE) used to blank out whenever its market-data source got rate-limited; it now keeps showing the last good trades and quietly backs off the source instead of hammering it, so the tape stays populated through a rate-limit blip. Forge 3D generations are now pulled into our own storage with automatic retries, so a momentary network hiccup while saving a freshly generated model no longer loses the result. And minting an agent on-chain now returns a clear 'network busy, try again' message when every Solana RPC is congested, instead of a generic error — the same graceful handling the rest of checkout already had. Your home feed also stays up during database upgrades rather than erroring.",
+ "link": null,
+ "tags": [
+ "fix",
+ "infra"
+ ]
+ },
{
"date": "2026-06-22",
"type": "update",
@@ -153,23 +164,23 @@
{
"date": "2026-06-22",
"type": "update",
- "title": "Hide the controls in IRL for an unobstructed AR view",
- "summary": "On a phone, the IRL controls (the top bar, the bottom row of buttons, the room badges, the compass and on-screen hints) could cover so much of the screen that you couldn't see the camera view or move your avatar past them. There's now a one-tap hide button on the right edge: tap it and all of that chrome slides away, leaving just the live AR scene — the on-screen joystick and drag-to-look still work, so you can walk around and look about with nothing in the way. Tap the same button (it stays put and glows green) to bring everything back; on a keyboard, Esc restores it too.",
- "link": "/irl",
+ "title": "IBM x402 demo works when embedded in IBM's CMS",
+ "summary": "The five live demos on the IBM partnership page — Forge, x402 micropayments, the 3D agent, Play, and IRL — now run correctly when the page is embedded inside IBM's content platform, not only when opened directly. IBM serves the embed from a Seismic gateway address, and the browser was silently blocking it: the free 3D generator reported 'briefly unreachable' and the wallet payment couldn't reach the Solana network, because three.ws didn't yet recognize that gateway as an allowed origin. three.ws now trusts IBM's Seismic-served origins for both data calls and embedding, so the free Forge, the on-chain payment flow, and the inline Play/IRL worlds all work on the embedded page.",
+ "link": "/ibm/x402-demo",
"tags": [
- "feature",
- "improvement"
+ "fix",
+ "infra"
]
},
{
"date": "2026-06-22",
"type": "update",
- "title": "IBM x402 demo works when embedded in IBM's CMS",
- "summary": "The five live demos on the IBM partnership page — Forge, x402 micropayments, the 3D agent, Play, and IRL — now run correctly when the page is embedded inside IBM's content platform, not only when opened directly. IBM serves the embed from a Seismic gateway address, and the browser was silently blocking it: the free 3D generator reported 'briefly unreachable' and the wallet payment couldn't reach the Solana network, because three.ws didn't yet recognize that gateway as an allowed origin. three.ws now trusts IBM's Seismic-served origins for both data calls and embedding, so the free Forge, the on-chain payment flow, and the inline Play/IRL worlds all work on the embedded page.",
- "link": "/ibm/x402-demo",
+ "title": "IRL gets a clean, get-out-of-the-way immersive mode",
+ "summary": "On a phone, the IRL controls (top bar, the row of buttons, room badges, compass and hints) could cover so much of the screen that you couldn't see the camera view or move your avatar past them. Now the controls get out of your way on their own: once the camera is live they fade after a few idle seconds, leaving just the AR scene — the joystick and drag-to-look keep working, so you can walk around and look about with nothing in the way. Tap anywhere on the empty view (or the eye button on the right edge) to bring them back, and they fade again when you go quiet. On desktop it's a focus/cinematic mode that works like a video player — move the mouse to reveal the controls, leave it still to hide them — plus real keyboard shortcuts: H to hide or show the interface, F for true fullscreen, Esc to restore. A one-time hint shows you how the first time the controls disappear, and the whole thing respects reduced-motion settings.",
+ "link": "/irl",
"tags": [
- "fix",
- "infra"
+ "feature",
+ "improvement"
]
},
{
diff --git a/public/changelog.xml b/public/changelog.xml
index 9d8431201..eb5bd3404 100644
--- a/public/changelog.xml
+++ b/public/changelog.xml
@@ -94,6 +94,14 @@
<category>fix</category>
<description>Two places that read an agent's ERC-8004 reputation were decoding it wrong. The on-chain registry returns the average rating already worked out (and signed, so it can go negative); both the paid reputation MCP tool and the trust check that guards autonomous agent-to-agent payments were dividing that value a second time — understating every score, and turning a negative reputation into a meaninglessly large positive one. The MCP tool was also listening for the wrong on-chain event, so it always reported zero past vouches even when an agent had many. Both now report the true average, handle negative reputations correctly, and surface real review history — so a 'pay only above this score' rule actually does what it says.</description>
</item>
+ <item>
+ <title>Fix: live trade tape, 3D generation, and agent minting hold up under pressure</title>
+ <link>https://three.ws/changelog</link>
+ <guid isPermaLink="false">2026-06-22:Fix: live trade tape, 3D generation, and agent minting hold up under pressure</guid>
+ <pubDate>Mon, 22 Jun 2026 12:00:00 GMT</pubDate>
+ <category>fix</category>
+ <description>Tightened three backend paths that could fail loudly under load or flaky upstreams. The live DEX trade tape on graduated coins (including $THREE) used to blank out whenever its market-data source got rate-limited; it now keeps showing the last good trades and quietly backs off the source instead of hammering it, so the tape stays populated through a rate-limit blip. Forge 3D generations are now pulled into our own storage with automatic retries, so a momentary network hiccup while saving a freshly generated model no longer loses the result. And minting an agent on-chain now returns a clear 'network busy, try again' message when every Solana RPC is congested, instead of a generic error — the same graceful handling the rest of checkout already had. Your home feed also stays up during database upgrades rather than erroring.</description>
+ </item>
<item>
<title>Fix: token art loads reliably and 3D embeds never blank out</title>
<link>https://three.ws/changelog</link>
@@ -118,14 +126,6 @@
<category>fix</category>
<description>The free, no-wallet 'forge a 3D model' widget on the IBM partnership page no longer shows a false 'briefly unreachable' error when the free GPU is cold. It used to fire up to six generation requests behind a single click, which spent the free lane's hourly limit about six times faster — a few tries could lock you out — and a slow cold start would surface as an error even though the model was still on its way. Now it makes one request per click (the server already falls back across NVIDIA, TRELLIS, and Hugging Face on its own), shows honest progress while a cold start warms up (which can take up to a minute), and, if the free lane is genuinely at its hourly limit, says exactly that and when to try again — pointing you to the instant paid Forge above. A model reliably comes back to orbit and download.</description>
</item>
- <item>
- <title>Hide the controls in IRL for an unobstructed AR view</title>
- <link>https://three.ws/irl</link>
- <guid isPermaLink="false">2026-06-22:Hide the controls in IRL for an unobstructed AR view</guid>
- <pubDate>Mon, 22 Jun 2026 12:00:00 GMT</pubDate>
- <category>feature</category>
- <description>On a phone, the IRL controls (the top bar, the bottom row of buttons, the room badges, the compass and on-screen hints) could cover so much of the screen that you couldn't see the camera view or move your avatar past them. There's now a one-tap hide button on the right edge: tap it and all of that chrome slides away, leaving just the live AR scene — the on-screen joystick and drag-to-look still work, so you can walk around and look about with nothing in the way. Tap the same button (it stays put and glows green) to bring everything back; on a keyboard, Esc restores it too.</description>
- </item>
<item>
<title>IBM x402 demo works when embedded in IBM's CMS</title>
<link>https://three.ws/ibm/x402-demo</link>
@@ -134,6 +134,14 @@
<category>fix</category>
<description>The five live demos on the IBM partnership page — Forge, x402 micropayments, the 3D agent, Play, and IRL — now run correctly when the page is embedded inside IBM's content platform, not only when opened directly. IBM serves the embed from a Seismic gateway address, and the browser was silently blocking it: the free 3D generator reported 'briefly unreachable' and the wallet payment couldn't reach the Solana network, because three.ws didn't yet recognize that gateway as an allowed origin. three.ws now trusts IBM's Seismic-served origins for both data calls and embedding, so the free Forge, the on-chain payment flow, and the inline Play/IRL worlds all work on the embedded page.</description>
</item>
+ <item>
+ <title>IRL gets a clean, get-out-of-the-way immersive mode</title>
+ <link>https://three.ws/irl</link>
+ <guid isPermaLink="false">2026-06-22:IRL gets a clean, get-out-of-the-way immersive mode</guid>
+ <pubDate>Mon, 22 Jun 2026 12:00:00 GMT</pubDate>
+ <category>feature</category>
+ <description>On a phone, the IRL controls (top bar, the row of buttons, room badges, compass and hints) could cover so much of the screen that you couldn't see the camera view or move your avatar past them. Now the controls get out of your way on their own: once the camera is live they fade after a few idle seconds, leaving just the AR scene — the joystick and drag-to-look keep working, so you can walk around and look about with nothing in the way. Tap anywhere on the empty view (or the eye button on the right edge) to bring them back, and they fade again when you go quiet. On desktop it's a focus/cinematic mode that works like a video player — move the mouse to reveal the controls, leave it still to hide them — plus real keyboard shortcuts: H to hide or show the interface, F for true fullscreen, Esc to restore. A one-time hint shows you how the first time the controls disappear, and the whole thing respects reduced-motion settings.</description>
+ </item>
<item>
<title>Live webinar stage on the IBM x402 demo page</title>
<link>https://three.ws/ibm/x402-demo</link>
diff --git a/public/features.json b/public/features.json
index 1c3280bbd..6c3119c92 100644
--- a/public/features.json
+++ b/public/features.json
@@ -1,5 +1,5 @@
{
- "generated_at": "2026-06-22T23:42:13.602Z",
+ "generated_at": "2026-06-22T23:48:49.249Z",
"generated_by": "scripts/build-page-index.mjs from data/pages.json",
"site": {
"name": "three.ws",
diff --git a/src/webgl-support.js b/src/webgl-support.js
new file mode 100644
index 000000000..859a32295
--- /dev/null
+++ b/src/webgl-support.js
@@ -0,0 +1,128 @@
+// Shared WebGL availability preflight + guarded renderer factory.
+//
+// Every 3D surface on three.ws constructs a `THREE.WebGLRenderer`. That
+// constructor THROWS — `Error: Error creating WebGL context.` — whenever the
+// browser can't grant a WebGL/WebGL2 context: no GPU, a driver on the browser's
+// blocklist, a headless/automation UA, or (most commonly on mobile Safari) the
+// per-tab live-context budget already spent by other canvases on the page. An
+// unguarded `new WebGLRenderer()` therefore crashes the whole entry module — for
+// the many surfaces that build the renderer at module top-level, that blanks the
+// entire page on import.
+//
+// This module centralises the two things every surface needs:
+// 1. `isWebGLAvailable()` — a cheap, cached probe that creates a throwaway
+// context, confirms it's real, and immediately releases it so the probe
+// never counts against the browser's context budget. Mirrors the canonical
+// probe in app.js (`_webglAvailable`).
+// 2. `createRenderer(opts, { fallback })` — preflights, then constructs the
+// renderer inside a try/catch. On either the preflight failing OR the
+// constructor throwing, it mounts a designed "3D unavailable" panel in the
+// given container and throws a typed `WebGLUnavailableError`. Callers in an
+// init function catch it and bail to their fallback UI; callers that build
+// at module top-level let it propagate — the throw halts the rest of that
+// module's initialisation cleanly (so no cascade of "renderer is undefined"
+// secondary errors) and the error reporter recognises the typed signal as a
+// benign device limitation and suppresses it (public/error-reporter.js).
+//
+// The net effect: no 3D surface can white-screen or spam the console on a device
+// that simply can't do WebGL — it shows a friendly, on-brand fallback instead.
+
+import { WebGLRenderer } from 'three';
+
+let _cached;
+
+// Cached WebGL-capability probe. Creates a context, verifies it's usable, then
+// releases it via WEBGL_lose_context so the probe itself doesn't consume one of
+// the browser's scarce live contexts.
+export function isWebGLAvailable() {
+ if (typeof _cached === 'boolean') return _cached;
+ let ok = false;
+ try {
+ const canvas = document.createElement('canvas');
+ const gl =
+ canvas.getContext('webgl2') ||
+ canvas.getContext('webgl') ||
+ canvas.getContext('experimental-webgl');
+ ok = !!(window.WebGLRenderingContext && gl && typeof gl.getParameter === 'function');
+ const lose = gl && gl.getExtension && gl.getExtension('WEBGL_lose_context');
+ if (lose) lose.loseContext();
+ } catch {
+ ok = false;
+ }
+ _cached = ok;
+ return ok;
+}
+
+// Typed, expected signal that a surface could not start WebGL on this device.
+// It is NOT a code bug — it is a device/browser capability limit — so the error
+// reporter suppresses it by name/message (see IGNORED_WEBGL in error-reporter).
+export class WebGLUnavailableError extends Error {
+ constructor(cause) {
+ super('webgl_unavailable');
+ this.name = 'WebGLUnavailableError';
+ this.webglUnavailable = true;
+ if (cause !== undefined) this.cause = cause;
+ }
+}
+
+// Mount a designed, dependency-free "3D unavailable" panel into `target` (an
+// element, or a canvas whose parent will host the panel). Idempotent: it won't
+// stack multiple panels, and it hides the dead canvas so the layout doesn't show
+// a blank rectangle. Safe to call with a missing target (no-op).
+export function mountWebglFallback(target, { title, hint } = {}) {
+ try {
+ let host = target;
+ if (host && host.tagName === 'CANVAS') {
+ host.style.display = 'none';
+ host = host.parentElement || document.body;
+ }
+ if (!host) return;
+ if (host.querySelector?.(':scope > .webgl-fallback')) return; // already shown
+
+ const panel = document.createElement('div');
+ panel.className = 'webgl-fallback';
+ panel.setAttribute('role', 'status');
+ panel.style.cssText = [
+ 'display:flex', 'flex-direction:column', 'align-items:center',
+ 'justify-content:center', 'gap:10px', 'min-height:180px', 'width:100%',
+ 'padding:32px 24px', 'box-sizing:border-box', 'text-align:center',
+ 'font-family:Inter,system-ui,sans-serif', 'color:#cdd3e0',
+ 'background:radial-gradient(120% 120% at 50% 0%,#161a24 0%,#0b0d13 70%)',
+ 'border-radius:14px',
+ ].join(';');
+ panel.innerHTML = `
+ <div aria-hidden="true" style="font-size:30px;line-height:1;opacity:.85">◆</div>
+ <div style="font-size:15px;font-weight:600;color:#eef1f7">${
+ title || '3D preview unavailable'
+ }</div>
+ <div style="font-size:12.5px;line-height:1.5;max-width:340px;color:#9aa3b4">${
+ hint ||
+ "This browser or device couldn't start a 3D (WebGL) view. Try reloading, or open three.ws on a device with hardware graphics enabled."
+ }</div>`;
+ host.appendChild(panel);
+ } catch {
+ /* a fallback that throws would defeat its own purpose — never propagate. */
+ }
+}
+
+/**
+ * Construct a WebGLRenderer with a guaranteed-graceful failure path.
+ *
+ * @param {object} options Passed straight to `new WebGLRenderer(options)`.
+ * @param {{ fallback?: Element }} [guard] Container to mount the fallback panel into
+ * when WebGL is unavailable.
+ * @returns {import('three').WebGLRenderer}
+ * @throws {WebGLUnavailableError} when WebGL is unavailable or the context fails.
+ */
+export function createRenderer(options = {}, { fallback } = {}) {
+ if (!isWebGLAvailable()) {
+ mountWebglFallback(fallback);
+ throw new WebGLUnavailableError();
+ }
+ try {
+ return new WebGLRenderer(options);
+ } catch (err) {
+ mountWebglFallback(fallback);
+ throw new WebGLUnavailableError(err);
+ }
+}