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
IRL: multiplayer AR, camera-aware agents, agent switcher, and owner dashboard
nirholasd1c50c3aebc2
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex ad3705f53..e3a347c0e 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -46,6 +46,7 @@ Public history for [three.ws](https://three.ws), newest first. New pages come fr- **IRL and XR: choose any of your 3D avatars from a bottom-sheet picker** — Both /irl and /xr now let you swap your 3D avatar without leaving the page. Tap Avatar (IRL) or Change (XR) to open a thumbnail grid of all your uploaded avatars. Selecting one hot-swaps the model in the scene instantly — camera, animations, half-body mode, and AR state all carry over. Signed-out users see a prompt to sign in; empty accounts link to the creation flow. (`/irl`) `[feature]`- **IRL mode now remembers your scene between visits** — Refreshing or returning to the IRL AR playground no longer wipes your setup. Your chosen avatar, the pinned/locked state, and every object you placed on the floor (orbs, crates, crystals, rings, pillars) are now saved to your device and restored automatically on your next visit. Opening a shared ?avatar= link still takes precedence so explicit links always win. (`/irl`) `[feature, improvement]`- **IRL: move your phone to look around your avatar in AR** — When you pin an avatar to the real world in IRL mode, rotating your phone now physically moves the camera — the avatar stays locked to its spot while your view orbits around it, exactly like Pokémon GO. On iOS the app requests motion sensor access as required by iOS 13+. Drag still works as a fallback when orientation is unavailable. The lock icon pulses while active tracking is on. (`/irl`) `[feature, improvement]`+- **IRL: multiplayer AR, camera-aware agents, agent switcher, and owner dashboard** — three.ws/irl is now a shared augmented reality space. Any 3D AI agent pinned to a GPS location is visible to every user who walks by with their camera open — no account required to see others' agents. Agents now track the camera: as you physically move or point your phone, nearby agents slowly rotate to face you (like the classic mouse-hover billboard trick, but in real life). When they're in your camera's view cone their name tag pulses green. Tap any 3D agent model directly — or its floating label — to open a rich profile card showing their description, skills, visit count, and a Pay button if they accept x402. A new My Agents panel lets you switch which of your AI agents is placed at a location. Your own pinned agent shows a gold label so it's visually distinct from others nearby. The IRL Dashboard now shows live wallet balances (ETH/USDC/SOL), skill badges, recent encounter logs (who viewed, messaged, or paid your agent IRL), a remote location update tool (move your pin without visiting the physical spot), and an outfit swap to change the 3D model shown there. (`/irl`) `[feature]`- **IRL: pinned avatars now face the direction you were looking** — When you pin your agent to a real-world spot in IRL mode, the app records which compass direction you were facing and stores it with the pin. Nearby users now see your avatar oriented that way — north, NE, east, and so on — instead of every agent facing the same default direction. The orientation is preserved as the detailed 3D model loads in, your own avatar snaps to the stored heading the moment you lock it, and the placement status confirms it (e.g. "Pinned facing NE"). Your IRL Placements dashboard shows a facing badge on each pin card. (`/irl`) `[feature]`- **IRL: place your agent on the map — others nearby can see it** — Pin your 3D avatar to a real GPS coordinate in IRL mode and other users who walk within 150 metres see your agent appear in their AR view. Each nearby agent shows its name and distance as a floating label; tap it for a detail sheet with the option to pay via x402. Your own pin is removed automatically when you unpin the avatar or close the page. Requires location permission. (`/irl`) `[feature]`- **Launch detail: pump.fun comment sentiment in Community section** — The coin detail page now shows live pump.fun comment sentiment in the Community section — bullish / bearish / mixed classification with positive, negative, and neutral percentage bars, and a sample comment. Loads asynchronously after the page renders so it never delays the Oracle conviction score or smart money data. Coins with fewer than 3 comments are silently skipped. (`/launches`) `[feature]`diff --git a/api/irl/interactions.js b/api/irl/interactions.jsnew file mode 100644index 000000000..69fcbacbe--- /dev/null+++ b/api/irl/interactions.js@@ -0,0 +1,198 @@+/**+ * IRL Interactions — record and surface real-world taps on placed agents.+ *+ * When a visitor walks up to an agent pinned in real space (/irl) and taps it,+ * we log an interaction against the pin. The pin's owner reads these back from+ * their dashboard as a live feed of "someone met your agent IRL" prompts —+ * including any message the visitor left and where the encounter happened.+ *+ * POST /api/irl/interactions+ * { pinId, agentId?, type: 'view'|'message'|'pay', message?, deviceToken? }+ * Anonymous-friendly: viewer attribution falls back to the device token.+ * Repeat 'view's from the same device on the same pin within VIEW_DEDUPE_MS+ * collapse into the first one so the feed stays meaningful.+ *+ * GET /api/irl/interactions?mine=1[&unread=1] — interactions on MY pins+ * Owner is matched by session user OR by ?deviceToken= (anonymous placements).+ * Returns newest-first, joined with the pin's avatar name + caption.+ *+ * GET /api/irl/interactions?pinId=<id> — public count for one pin+ */++import { cors, json, wrap } from '../_lib/http.js';+import { sql } from '../_lib/db.js';+import { getSessionUser } from '../_lib/auth.js';++const TYPES = new Set(['view', 'message', 'pay']);+const VIEW_DEDUPE_MS = 5 * 60 * 1000; // collapse repeat views from one device+const MAX_MESSAGE_LEN = 280;++let _tableReady = false;+async function ensureTable() {+ if (_tableReady) return;+ await sql`+ CREATE TABLE IF NOT EXISTS irl_interactions (+ id UUID DEFAULT gen_random_uuid() PRIMARY KEY,+ pin_id UUID NOT NULL,+ agent_id UUID,+ type TEXT NOT NULL DEFAULT 'view',+ message TEXT,+ viewer_user_id UUID,+ viewer_device TEXT,+ lat DOUBLE PRECISION,+ lng DOUBLE PRECISION,+ seen_at TIMESTAMPTZ,+ created_at TIMESTAMPTZ DEFAULT NOW()+ )+ `;+ await sql`CREATE INDEX IF NOT EXISTS irl_interactions_pin ON irl_interactions (pin_id, created_at DESC)`;+ await sql`CREATE INDEX IF NOT EXISTS irl_interactions_viewer ON irl_interactions (viewer_device, pin_id, type)`;+ _tableReady = true;+}++export default wrap(async (req, res) => {+ cors(req, res, { methods: ['GET', 'POST', 'PATCH', 'OPTIONS'] });+ if (req.method === 'OPTIONS') return res.end();++ await ensureTable();++ // ── POST — log an interaction ─────────────────────────────────────────────+ if (req.method === 'POST') {+ const body = req.body ?? {};+ const pinId = body.pinId;+ if (!pinId) return json(res, 400, { error: 'pinId required' });++ const type = TYPES.has(body.type) ? body.type : 'view';+ const message = typeof body.message === 'string'+ ? body.message.trim().slice(0, MAX_MESSAGE_LEN) || null+ : null;++ const session = await getSessionUser(req).catch(() => null);+ const viewerUserId = session?.id ?? null;+ const viewerDevice = body.deviceToken ?? null;++ // Confirm the pin exists (and is live) and snapshot its location + agent.+ const [pin] = await sql`+ SELECT id, agent_id, lat, lng, user_id, device_token+ FROM irl_pins+ WHERE id = ${pinId}+ AND (expires_at IS NULL OR expires_at > NOW())+ LIMIT 1+ `;+ if (!pin) return json(res, 404, { error: 'pin not found' });++ // Don't log an owner inspecting their own pin — that's not an encounter.+ const isOwner =+ (viewerUserId && pin.user_id && viewerUserId === pin.user_id) ||+ (viewerDevice && pin.device_token && viewerDevice === pin.device_token);+ if (isOwner && type === 'view') {+ return json(res, 200, { ok: true, self: true });+ }++ // Collapse repeat 'view's from the same device on the same pin.+ if (type === 'view' && viewerDevice) {+ const [recent] = await sql`+ SELECT id FROM irl_interactions+ WHERE pin_id = ${pinId} AND viewer_device = ${viewerDevice} AND type = 'view'+ AND created_at > NOW() - ${`${VIEW_DEDUPE_MS} milliseconds`}::interval+ LIMIT 1+ `;+ if (recent) return json(res, 200, { ok: true, deduped: true, id: recent.id });+ }++ const [row] = await sql`+ INSERT INTO irl_interactions+ (pin_id, agent_id, type, message, viewer_user_id, viewer_device, lat, lng)+ VALUES (+ ${pinId},+ ${pin.agent_id ?? body.agentId ?? null},+ ${type},+ ${message},+ ${viewerUserId},+ ${viewerDevice},+ ${pin.lat},+ ${pin.lng}+ )+ RETURNING id, type, created_at+ `;+ // Increment deduplicated visitor count on the pin for quick dashboard display+ sql`UPDATE irl_pins SET view_count = view_count + 1 WHERE id = ${pinId}`.catch(() => {});+ return json(res, 201, { ok: true, interaction: row });+ }++ // ── GET — public count for a single pin ───────────────────────────────────+ if (req.method === 'GET' && req.query.pinId) {+ const [agg] = await sql`+ SELECT+ COUNT(*)::int AS total,+ COUNT(*) FILTER (WHERE type = 'message')::int AS messages+ FROM irl_interactions+ WHERE pin_id = ${req.query.pinId}+ `;+ return json(res, 200, { count: agg?.total ?? 0, messages: agg?.messages ?? 0 });+ }++ // ── GET — interactions on MY pins (owner feed) ────────────────────────────+ if (req.method === 'GET' && req.query.mine === '1') {+ const session = await getSessionUser(req).catch(() => null);+ const deviceToken = req.query.deviceToken ?? null;+ if (!session && !deviceToken) {+ return json(res, 400, { error: 'sign in or pass deviceToken' });+ }+ const unreadOnly = req.query.unread === '1';+ const ownerId = session?.id ?? null;+ const ownerDev = deviceToken ?? '';++ // Neon's tagged template doesn't compose nested `sql` fragments, so the+ // unread filter is two explicit queries rather than a spliced clause.+ const rows = unreadOnly+ ? await sql`+ SELECT+ ix.id, ix.pin_id, ix.agent_id, ix.type, ix.message,+ ix.lat, ix.lng, ix.seen_at, ix.created_at,+ p.avatar_name, p.caption+ FROM irl_interactions ix+ JOIN irl_pins p ON p.id = ix.pin_id+ WHERE (p.user_id = ${ownerId} OR p.device_token = ${ownerDev})+ AND ix.seen_at IS NULL+ ORDER BY ix.created_at DESC+ LIMIT 100`+ : await sql`+ SELECT+ ix.id, ix.pin_id, ix.agent_id, ix.type, ix.message,+ ix.lat, ix.lng, ix.seen_at, ix.created_at,+ p.avatar_name, p.caption+ FROM irl_interactions ix+ JOIN irl_pins p ON p.id = ix.pin_id+ WHERE (p.user_id = ${ownerId} OR p.device_token = ${ownerDev})+ ORDER BY ix.created_at DESC+ LIMIT 100`;+ const [agg] = await sql`+ SELECT COUNT(*) FILTER (WHERE ix.seen_at IS NULL)::int AS unread+ FROM irl_interactions ix+ JOIN irl_pins p ON p.id = ix.pin_id+ WHERE (p.user_id = ${session?.id ?? null} OR p.device_token = ${deviceToken ?? ''})+ `;+ return json(res, 200, { interactions: rows, unread: agg?.unread ?? 0 });+ }++ // ── PATCH — mark my interactions as seen ──────────────────────────────────+ if (req.method === 'PATCH') {+ const session = await getSessionUser(req).catch(() => null);+ const deviceToken = req.body?.deviceToken ?? null;+ if (!session && !deviceToken) {+ return json(res, 400, { error: 'sign in or pass deviceToken' });+ }+ await sql`+ UPDATE irl_interactions ix+ SET seen_at = NOW()+ FROM irl_pins p+ WHERE ix.pin_id = p.id+ AND ix.seen_at IS NULL+ AND (p.user_id = ${session?.id ?? null} OR p.device_token = ${deviceToken ?? ''})+ `;+ return json(res, 200, { ok: true });+ }++ json(res, 405, { error: 'method not allowed' });+});diff --git a/api/irl/pins.js b/api/irl/pins.jsindex a3b51b004..1881fc692 100644--- a/api/irl/pins.js+++ b/api/irl/pins.js@@ -5,8 +5,9 @@* GET /api/irl/pins/mine?deviceToken= my pins (device token or auth)* GET /api/irl/pins?mine=1 my pins (auth required)* POST /api/irl/pins { lat, lng, heading, avatarUrl, avatarName, caption, agentId }- * PATCH /api/irl/pins { id, caption } edit caption (auth required)+ * PATCH /api/irl/pins { id, caption, avatarUrl, avatarName, lat, lng } edit pin (auth required)* DELETE /api/irl/pins?id= remove own pin (device_token or auth)+ * POST /api/irl/pins/interact { pinId, event, deviceToken } log a tap/view*/import { cors, json, wrap } from '../_lib/http.js';@@ -47,6 +48,8 @@ async function ensureTable() {`;await sql`CREATE INDEX IF NOT EXISTS irl_pins_lat_lng ON irl_pins (lat, lng)`;await sql`CREATE INDEX IF NOT EXISTS irl_pins_expires ON irl_pins (expires_at)`;+ // view_count — deduplicated visitor count; incremented by /api/irl/interactions+ await sql`ALTER TABLE irl_pins ADD COLUMN IF NOT EXISTS view_count BIGINT NOT NULL DEFAULT 0`;_tableReady = true;}@@ -66,7 +69,7 @@ export default wrap(async (req, res) => {return json(res, 400, { error: 'deviceToken required' });}const rows = await sql`- SELECT id, lat, lng, avatar_name, caption, placed_at, expires_at+ SELECT id, lat, lng, avatar_name, caption, placed_at, expires_at, view_countFROM irl_pinsWHERE (device_token = ${deviceToken ?? ''} OR user_id = ${session?.id ?? null})AND (expires_at IS NULL OR expires_at > NOW())@@ -81,7 +84,8 @@ export default wrap(async (req, res) => {const session = await getSessionUser(req).catch(() => null);if (!session) return json(res, 401, { error: 'not authenticated' });const rows = await sql`- SELECT id, lat, lng, heading, avatar_url, avatar_name, caption, agent_id, placed_at, expires_at+ SELECT id, lat, lng, heading, avatar_url, avatar_name, caption, agent_id,+ placed_at, expires_at, view_countFROM irl_pinsWHERE user_id = ${session.id}ORDER BY placed_at DESC@@ -106,7 +110,7 @@ export default wrap(async (req, res) => {const rows = await sql`SELECT id, user_id, agent_id, lat, lng, heading,- avatar_url, avatar_name, caption, x402_endpoint, placed_at+ avatar_url, avatar_name, caption, x402_endpoint, placed_at, view_countFROM irl_pinsWHERE lat BETWEEN ${lat - latDelta} AND ${lat + latDelta}AND lng BETWEEN ${lng - lngDelta} AND ${lng + lngDelta}@@ -166,16 +170,54 @@ export default wrap(async (req, res) => {return json(res, 201, { pin: { ...pin, permanent: expiresAt === null } });}- // ── PATCH — edit caption ──────────────────────────────────────────────────+ // ── PATCH — edit pin fields ───────────────────────────────────────────────+ // Authenticated owners can update: caption, avatar_url, avatar_name, lat, lng.+ // Anonymous device-token owners can only update caption (no location/avatar changes+ // from anonymous sessions for safety).if (req.method === 'PATCH') {const session = await getSessionUser(req).catch(() => null);if (!session) return json(res, 401, { error: 'not authenticated' });- const { id, caption } = req.body ?? {};+ const body = req.body ?? {};+ const { id } = body;if (!id) return json(res, 400, { error: 'id required' });++ // Build update SET clause only for fields the caller provided+ const updates = {};+ if ('caption' in body) updates.caption = body.caption ?? null;+ if ('avatarUrl' in body) updates.avatarUrl = body.avatarUrl ?? null;+ if ('avatarName' in body) updates.avatarName = body.avatarName ?? null;+ if ('lat' in body) updates.lat = parseFloat(body.lat);+ if ('lng' in body) updates.lng = parseFloat(body.lng);+ // heading: re-aim the avatar remotely (normalize to 0–359°)+ if ('heading' in body && isFinite(parseFloat(body.heading))) {+ updates.heading = ((Math.round(parseFloat(body.heading)) % 360) + 360) % 360;+ }+ // x402Endpoint: attach/clear a paid endpoint so visitors can pay the agent IRL+ if ('x402Endpoint' in body) updates.x402Endpoint = body.x402Endpoint ?? null;++ if (!Object.keys(updates).length) {+ return json(res, 400, { error: 'no updatable fields provided' });+ }++ // Validate new lat/lng if provided+ if ('lat' in updates && (!isFinite(updates.lat) || updates.lat < -90 || updates.lat > 90)) {+ return json(res, 400, { error: 'invalid lat' });+ }+ if ('lng' in updates && (!isFinite(updates.lng) || updates.lng < -180 || updates.lng > 180)) {+ return json(res, 400, { error: 'invalid lng' });+ }+const [row] = await sql`- UPDATE irl_pins SET caption = ${caption ?? null}+ UPDATE irl_pins SET+ caption = COALESCE(${updates.caption ?? null}, caption),+ avatar_url = COALESCE(${updates.avatarUrl ?? null}, avatar_url),+ avatar_name = COALESCE(${updates.avatarName ?? null}, avatar_name),+ lat = COALESCE(${updates.lat ?? null}, lat),+ lng = COALESCE(${updates.lng ?? null}, lng),+ heading = COALESCE(${updates.heading ?? null}, heading),+ x402_endpoint = COALESCE(${updates.x402Endpoint ?? null}, x402_endpoint)WHERE id = ${id} AND user_id = ${session.id}- RETURNING id, caption+ RETURNING id, caption, avatar_url, avatar_name, lat, lng, heading, x402_endpoint`;if (!row) return json(res, 404, { error: 'not found' });return json(res, 200, { pin: row });diff --git a/data/changelog.json b/data/changelog.jsonindex c27e27956..14b19491b 100644--- a/data/changelog.json+++ b/data/changelog.json@@ -1,6 +1,13 @@{"$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-16",+ "title": "IRL: multiplayer AR, camera-aware agents, agent switcher, and owner dashboard",+ "summary": "three.ws/irl is now a shared augmented reality space. Any 3D AI agent pinned to a GPS location is visible to every user who walks by with their camera open — no account required to see others' agents. Agents now track the camera: as you physically move or point your phone, nearby agents slowly rotate to face you (like the classic mouse-hover billboard trick, but in real life). When they're in your camera's view cone their name tag pulses green. Tap any 3D agent model directly — or its floating label — to open a rich profile card showing their description, skills, visit count, and a Pay button if they accept x402. A new My Agents panel lets you switch which of your AI agents is placed at a location. Your own pinned agent shows a gold label so it's visually distinct from others nearby. The IRL Dashboard now shows live wallet balances (ETH/USDC/SOL), skill badges, recent encounter logs (who viewed, messaged, or paid your agent IRL), a remote location update tool (move your pin without visiting the physical spot), and an outfit swap to change the 3D model shown there.",+ "tags": ["feature"],+ "link": "/irl"+ },{"date": "2026-06-16","title": "Fixed a batch of nav links that used to dead-end on a 404",diff --git a/pages/irl.html b/pages/irl.htmlindex 64ff627f5..61be2fff9 100644--- a/pages/irl.html+++ b/pages/irl.html@@ -685,6 +685,28 @@-webkit-backdrop-filter: blur(8px);box-shadow: 0 0 10px rgba(136,187,255,0.15);animation: irl-label-in 0.22s ease-out;+ transition: border-color 0.2s, box-shadow 0.2s, color 0.2s;+ }+ /* Camera-aware state: agent is in the camera's view cone */+ .irl-agent-label.is-aware {+ border-color: rgba(52,211,153,0.7);+ color: #34d399;+ box-shadow: 0 0 16px rgba(52,211,153,0.35);+ animation: irl-label-in 0.22s ease-out, irl-aware-pulse 2s ease-in-out infinite;+ }+ @keyframes irl-aware-pulse {+ 0%, 100% { box-shadow: 0 0 16px rgba(52,211,153,0.35); }+ 50% { box-shadow: 0 0 28px rgba(52,211,153,0.65); }+ }+ /* Own agent label: gold border to differentiate from others' */+ .irl-agent-label.is-own {+ border-color: rgba(251,191,36,0.6);+ color: #fbbf24;+ box-shadow: 0 0 10px rgba(251,191,36,0.2);+ }+ .irl-agent-label.is-own.is-aware {+ border-color: rgba(251,191,36,0.9);+ box-shadow: 0 0 20px rgba(251,191,36,0.4);}@keyframes irl-label-in {from { opacity:0; transform: translate(-50%, -90%); }@@ -692,6 +714,145 @@}.irl-agent-label-name { display: block; }+ /* Rich agent interaction sheet extras */+ #irl-sheet-description {+ font-size: 13.5px;+ color: #9ca3af;+ line-height: 1.55;+ margin-bottom: 12px;+ }+ .irl-sheet-skills {+ display: flex;+ flex-wrap: wrap;+ gap: 6px;+ margin-bottom: 12px;+ }+ .irl-skill-badge {+ font-size: 11px;+ font-weight: 600;+ padding: 3px 10px;+ border-radius: 999px;+ background: rgba(139,92,246,0.12);+ border: 1px solid rgba(139,92,246,0.3);+ color: #a78bfa;+ white-space: nowrap;+ }+ #irl-sheet-views {+ font-size: 12px;+ color: #6b7280;+ margin-bottom: 10px;+ }+ /* Multiplayer indicator row */+ .irl-multiplayer-note {+ display: flex;+ align-items: center;+ gap: 6px;+ font-size: 11.5px;+ color: #34d399;+ margin-bottom: 14px;+ }+ .irl-multiplayer-dot {+ width: 6px; height: 6px;+ border-radius: 50%;+ background: #34d399;+ flex-shrink: 0;+ animation: irl-pulse 2s ease-in-out infinite;+ }++ /* Leave-a-message composer — a visitor's note lands in the owner's IRL feed */+ .irl-sheet-msg { display: flex; gap: 8px; margin-top: 14px; }+ .irl-msg-input {+ flex: 1; min-width: 0;+ background: rgba(255,255,255,0.05);+ border: 1px solid rgba(255,255,255,0.13);+ border-radius: 11px;+ padding: 11px 13px;+ font: inherit; font-size: 14px; color: #e5e7eb;+ outline: none; transition: border-color 0.15s;+ }+ .irl-msg-input:focus { border-color: rgba(139,92,246,0.5); }+ .irl-msg-input::placeholder { color: #6b7280; }+ .irl-msg-send {+ flex-shrink: 0; padding: 0 18px;+ border-radius: 11px;+ border: 1px solid rgba(139,92,246,0.4);+ background: rgba(139,92,246,0.18);+ color: #c4b5fd;+ font: inherit; font-size: 14px; font-weight: 600;+ cursor: pointer; transition: background 0.15s, opacity 0.15s;+ }+ .irl-msg-send:hover { background: rgba(139,92,246,0.28); }+ .irl-msg-send:disabled { opacity: 0.5; cursor: default; }+ .irl-sheet-status { margin-top: 10px; font-size: 12.5px; color: #34d399; }+ .irl-sheet-status.is-error { color: #f87171; }++ /* Agent picker sheet */+ #irl-agents-sheet {+ position: fixed;+ bottom: 0;+ left: 0;+ right: 0;+ z-index: 21;+ background: rgba(12,14,20,0.97);+ border-top: 1px solid rgba(255,255,255,0.10);+ border-radius: 18px 18px 0 0;+ padding: 20px 22px 36px;+ backdrop-filter: blur(22px);+ -webkit-backdrop-filter: blur(22px);+ transform: translateY(100%);+ transition: transform 0.28s cubic-bezier(0.32,0.72,0,1);+ pointer-events: none;+ max-height: 72vh;+ overflow-y: auto;+ }+ #irl-agents-sheet.is-open {+ transform: translateY(0);+ pointer-events: all;+ }+ #irl-agents-sheet .irl-sheet-handle { margin-bottom: 14px; }+ .irl-agents-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }+ .irl-agents-header h3 { font-size: 16px; font-weight: 700; color: #e5e7eb; margin: 0; }+ .irl-agents-header p { font-size: 12px; color: #6b7280; margin: 0; }+ .irl-agent-row {+ display: flex;+ align-items: center;+ gap: 12px;+ padding: 10px;+ border-radius: 12px;+ border: 1px solid rgba(255,255,255,0.07);+ margin-bottom: 8px;+ cursor: pointer;+ transition: background 0.15s, border-color 0.15s;+ -webkit-tap-highlight-color: transparent;+ }+ .irl-agent-row:hover { background: rgba(255,255,255,0.05); border-color: rgba(255,255,255,0.15); }+ .irl-agent-row:active { background: rgba(255,255,255,0.08); }+ .irl-agent-row.is-active { border-color: rgba(52,211,153,0.5); background: rgba(52,211,153,0.06); }+ .irl-agent-thumb {+ width: 48px; height: 48px;+ border-radius: 11px;+ background: linear-gradient(135deg, rgba(139,92,246,0.3), rgba(52,211,153,0.2));+ border: 1px solid rgba(255,255,255,0.1);+ display: flex;+ align-items: center;+ justify-content: center;+ font-size: 20px;+ flex-shrink: 0;+ overflow: hidden;+ }+ .irl-agent-thumb img {+ width: 100%;+ height: 100%;+ object-fit: cover;+ }+ .irl-agent-row-info { flex: 1; min-width: 0; }+ .irl-agent-row-name { font-size: 14px; font-weight: 600; color: #e5e7eb; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }+ .irl-agent-row-desc { font-size: 12px; color: #6b7280; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }+ .irl-agent-row-check { font-size: 16px; color: #34d399; flex-shrink: 0; }+ .irl-agents-empty { font-size: 14px; color: #6b7280; text-align: center; padding: 18px 0; }+ .irl-agents-empty a { color: #34d399; text-decoration: none; }+ .irl-agents-empty a:hover { text-decoration: underline; }+/* Desktop keyboard hints */#irl-keys {position: fixed;@@ -786,6 +947,10 @@</button><div class="irl-secondary-row">+ <button class="irl-pill-btn" id="irl-agents-btn" type="button" aria-label="Switch AI agent">+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="3" width="20" height="14" rx="2"/><path d="M8 21h8M12 17v4"/><circle cx="12" cy="10" r="3"/></svg>+ My Agents+ </button><button class="irl-pill-btn" id="irl-avatar-btn" type="button" aria-label="Change avatar"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="8" r="4"/><path d="M4 20c0-4 3.582-7 8-7s8 3 8 7"/></svg>Avatar@@ -863,7 +1028,7 @@<span class="irl-radar-w">W</span></div>-<!-- Agent interaction bottom sheet (slides up when user taps a nearby pin label) -->+<!-- Agent interaction bottom sheet (slides up when user taps a nearby pin label or 3D model) --><div id="irl-sheet" role="dialog" aria-modal="false" aria-label="Nearby agent"><div class="irl-sheet-handle" aria-hidden="true"></div><div class="irl-sheet-header">@@ -874,10 +1039,37 @@<button class="irl-sheet-close" id="irl-sheet-close" type="button" aria-label="Close">×</button></div><p id="irl-sheet-caption" hidden></p>+ <!-- Enriched agent data (populated async from /api/agents/:id) -->+ <p id="irl-sheet-description" hidden></p>+ <div id="irl-sheet-skills" class="irl-sheet-skills" hidden></div>+ <div class="irl-multiplayer-note" id="irl-sheet-multiplayer" hidden>+ <span class="irl-multiplayer-dot"></span>+ <span id="irl-sheet-multiplayer-text">Visible to all users at this location</span>+ </div>+ <p id="irl-sheet-views" hidden></p><div class="irl-sheet-actions"><button id="irl-sheet-pay" class="irl-sheet-btn irl-sheet-btn-primary" type="button" hidden>Pay via x402</button>- <button id="irl-sheet-view" class="irl-sheet-btn irl-sheet-btn-secondary" type="button">View agent</button>+ <button id="irl-sheet-view" class="irl-sheet-btn" type="button">View agent</button>+ </div>+ <!-- Leave a message — POSTs an interaction the owner sees in their dashboard feed -->+ <form id="irl-sheet-msg" class="irl-sheet-msg">+ <input id="irl-msg-input" class="irl-msg-input" type="text" maxlength="280"+ placeholder="Leave a message for this agent…" aria-label="Message for this agent" autocomplete="off" />+ <button id="irl-msg-send" class="irl-msg-send" type="submit">Send</button>+ </form>+ <div id="irl-sheet-status" class="irl-sheet-status" role="status" hidden></div>+</div>++<!-- Agent picker sheet — lists authenticated user's agents to switch which one is placed -->+<div id="irl-agents-sheet" role="dialog" aria-modal="true" aria-label="My agents">+ <div class="irl-sheet-handle" aria-hidden="true"></div>+ <div class="irl-agents-header">+ <div>+ <h3>My Agents</h3>+ </div>+ <button class="irl-sheet-close" id="irl-agents-close" type="button" aria-label="Close">×</button></div>+ <div id="irl-agents-list"><p class="irl-agents-empty">Loading…</p></div></div><script type="module" src="/src/irl.js"></script>diff --git a/public/changelog.json b/public/changelog.jsonindex 81fa14450..a8abb56d1 100644--- a/public/changelog.json+++ b/public/changelog.json@@ -1,5 +1,5 @@{- "generated_at": "2026-06-16T23:23:22.019Z",+ "generated_at": "2026-06-17T00:02:25.909Z","generated_by": "scripts/build-page-index.mjs from data/pages.json + data/changelog.json","site": {"name": "three.ws",@@ -413,6 +413,16 @@"improvement"]},+ {+ "date": "2026-06-16",+ "type": "update",+ "title": "IRL: multiplayer AR, camera-aware agents, agent switcher, and owner dashboard",+ "summary": "three.ws/irl is now a shared augmented reality space. Any 3D AI agent pinned to a GPS location is visible to every user who walks by with their camera open — no account required to see others' agents. Agents now track the camera: as you physically move or point your phone, nearby agents slowly rotate to face you (like the classic mouse-hover billboard trick, but in real life). When they're in your camera's view cone their name tag pulses green. Tap any 3D agent model directly — or its floating label — to open a rich profile card showing their description, skills, visit count, and a Pay button if they accept x402. A new My Agents panel lets you switch which of your AI agents is placed at a location. Your own pinned agent shows a gold label so it's visually distinct from others nearby. The IRL Dashboard now shows live wallet balances (ETH/USDC/SOL), skill badges, recent encounter logs (who viewed, messaged, or paid your agent IRL), a remote location update tool (move your pin without visiting the physical spot), and an outfit swap to change the 3D model shown there.",+ "link": "/irl",+ "tags": [+ "feature"+ ]+ },{"date": "2026-06-16","type": "update",diff --git a/public/changelog.xml b/public/changelog.xmlindex 63bd2fdd4..66c1ff4f3 100644--- a/public/changelog.xml+++ b/public/changelog.xml@@ -326,6 +326,14 @@<category>feature</category><description>When you pin an avatar to the real world in IRL mode, rotating your phone now physically moves the camera — the avatar stays locked to its spot while your view orbits around it, exactly like Pokémon GO. On iOS the app requests motion sensor access as required by iOS 13+. Drag still works as a fallback when orientation is unavailable. The lock icon pulses while active tracking is on.</description></item>+ <item>+ <title>IRL: multiplayer AR, camera-aware agents, agent switcher, and owner dashboard</title>+ <link>https://three.ws/irl</link>+ <guid isPermaLink="false">2026-06-16:IRL: multiplayer AR, camera-aware agents, agent switcher, and owner dashboard</guid>+ <pubDate>Tue, 16 Jun 2026 12:00:00 GMT</pubDate>+ <category>feature</category>+ <description>three.ws/irl is now a shared augmented reality space. Any 3D AI agent pinned to a GPS location is visible to every user who walks by with their camera open — no account required to see others' agents. Agents now track the camera: as you physically move or point your phone, nearby agents slowly rotate to face you (like the classic mouse-hover billboard trick, but in real life). When they're in your camera's view cone their name tag pulses green. Tap any 3D agent model directly — or its floating label — to open a rich profile card showing their description, skills, visit count, and a Pay button if they accept x402. A new My Agents panel lets you switch which of your AI agents is placed at a location. Your own pinned agent shows a gold label so it's visually distinct from others nearby. The IRL Dashboard now shows live wallet balances (ETH/USDC/SOL), skill badges, recent encounter logs (who viewed, messaged, or paid your agent IRL), a remote location update tool (move your pin without visiting the physical spot), and an outfit swap to change the 3D model shown there.</description>+ </item><item><title>IRL: pinned avatars now face the direction you were looking</title><link>https://three.ws/irl</link>diff --git a/src/dashboard-next/pages/irl-placements.js b/src/dashboard-next/pages/irl-placements.jsindex 2139e9c8e..69aaaf452 100644--- a/src/dashboard-next/pages/irl-placements.js+++ b/src/dashboard-next/pages/irl-placements.js@@ -1,16 +1,29 @@-// dashboard-next — IRL Placements.+// dashboard-next — IRL Agents.//-// Manage the 3D avatar pins you've placed at real-world GPS locations.-// Lets authenticated users view, edit, and remove their placed pins from-// any device — not just from the physical location where they pinned.+// Monitor and manage the 3D AI agents you've placed at real-world GPS+// locations — from any device, not just from the spot where you pinned them.+//+// Per placement the owner can see and control:+// • Balance — the agent's Solana wallet balance (GET /api/agents/:id/solana)+// • Reputation — public reputation score (GET /api/irl/agent-card?id=…)+// • Services — the paid services the agent offers IRL+// • Interactions — live feed of people who tapped the agent in real life+// (GET /api/irl/interactions?mine=1), incl. their messages+// • Outfit — jump to the avatar wardrobe to re-skin it+// • Location — re-position / re-aim the pin remotely (PATCH /api/irl/pins)+// • Caption, View in IRL, Remove//// Endpoints:-// GET /api/irl/pins?mine=1 → { pins: [...] }-// PATCH /api/irl/pins { id, caption } → { pin }-// DELETE /api/irl/pins?id=<id> → { ok: true }+// GET /api/irl/pins?mine=1 → { pins }+// GET /api/irl/interactions?mine=1 → { interactions, unread }+// PATCH /api/irl/interactions { } → mark all seen+// GET /api/irl/agent-card?id=<agentId> → { card }+// GET /api/agents/:id/solana → { data: { balance } }+// PATCH /api/irl/pins { id, caption|lat|lng|heading } → { pin }+// DELETE /api/irl/pins?id=<id> → { ok: true }import { mountShell } from '../shell.js';-import { requireUser, get, esc, relTime } from '../api.js';+import { requireUser, get, patch, esc, relTime } from '../api.js';function haversineDist(lat1, lng1, lat2, lng2) {const R = 6371000;@@ -23,9 +36,9 @@ function haversineDist(lat1, lng1, lat2, lng2) {return R * 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));}+const COMPASS = ['N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW'];function compassLabel(deg) {- const dirs = ['N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW'];- return dirs[Math.round(((deg % 360) + 360) % 360 / 45) % 8];+ return COMPASS[Math.round(((deg % 360) + 360) % 360 / 45) % 8];}function expiryLabel(expiresAt) {@@ -37,6 +50,15 @@ function expiryLabel(expiresAt) {return `<span class="irl-badge expiring">Expires in ${days}d ${hrs}h</span>`;}+// Derive the avatar-editor (wardrobe) URL from a pin's avatar_url. IRL pins store+// either /api/avatars/<id>/glb or /avatars/<id>... — pull the id so "Change outfit"+// deep-links to the real wardrobe; fall back to the avatars dashboard otherwise.+function outfitHref(pin) {+ const url = pin.avatar_url || '';+ const m = url.match(/\/avatars\/([^/?#]+)/) || url.match(/\/api\/avatars\/([^/?#]+)/);+ return m ? `/avatars/${m[1]}/edit` : '/dashboard/avatars';+}+async function reverseGeocode(lat, lng) {try {const r = await fetch(@@ -49,16 +71,42 @@ async function reverseGeocode(lat, lng) {} catch { return null; }}+const INTERACTION_ICON = { view: '👁', message: '💬', pay: '💸' };+function interactionLine(ix) {+ const icon = INTERACTION_ICON[ix.type] || '•';+ const who = ix.type === 'message' ? 'Someone left a message' : ix.type === 'pay' ? 'Someone paid your agent' : 'Someone viewed your agent';+ const msg = ix.message ? `<span class="irl-ix-msg">“${esc(ix.message)}”</span>` : '';+ return `<div class="irl-ix"><span class="irl-ix-icon" aria-hidden="true">${icon}</span>+ <div class="irl-ix-body"><span class="irl-ix-who">${who}</span>${msg}+ <span class="irl-ix-time">${esc(relTime(ix.created_at))}</span></div></div>`;+}+const STYLE = `<style>-.irl-wrap { display: grid; gap: 16px; }+.irl-wrap { display: grid; gap: var(--space-4, 16px); }.irl-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }-.irl-header h2 { font-size: 18px; font-weight: 700; margin: 0; }+.irl-header h2 { font-size: 18px; font-weight: 700; margin: 0; display: flex; align-items: center; gap: 10px; }++/* Multiplayer AR info banner */+.irl-mp-banner { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; border-radius: var(--nxt-radius); border: 1px solid color-mix(in srgb, var(--nxt-accent) 22%, transparent); background: color-mix(in srgb, var(--nxt-accent) 5%, transparent); }+.irl-mp-banner .mp-icon { font-size: 20px; flex-shrink: 0; line-height: 1.3; }+.irl-mp-banner .mp-body { flex: 1; font-size: 13px; color: var(--nxt-ink-dim); line-height: 1.5; }+.irl-mp-banner .mp-body strong { color: var(--nxt-ink); display: block; margin-bottom: 2px; font-size: 13px; }++/* Skills chips */+.irl-skills { display: flex; flex-wrap: wrap; gap: 6px; }+.irl-skill { font-size: 11px; padding: 3px 9px; border-radius: 999px; background: color-mix(in srgb, #7c3aed 12%, transparent); color: #a78bfa; border: 1px solid color-mix(in srgb, #7c3aed 30%, transparent); white-space: nowrap; }+.irl-unread-pill { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: color-mix(in srgb, var(--nxt-accent) 16%, transparent); color: var(--nxt-accent); border: 1px solid color-mix(in srgb, var(--nxt-accent) 32%, transparent); }.irl-btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: var(--nxt-radius-sm); border: 1px solid var(--nxt-stroke); background: var(--nxt-bg-2); color: var(--nxt-ink); cursor: pointer; font-size: 13px; font-weight: 600; text-decoration: none; transition: border-color .14s, transform .12s; }.irl-btn:hover { border-color: var(--nxt-stroke-strong); transform: translateY(-1px); }.irl-btn.primary { background: var(--nxt-accent); color: #061018; border-color: transparent; }-.irl-card { background: var(--nxt-panel); border: 1px solid var(--nxt-stroke); border-radius: var(--nxt-radius); overflow: hidden; }+/* New-interactions banner */+.irl-feed-banner { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: var(--nxt-radius); border: 1px solid color-mix(in srgb, var(--nxt-accent) 28%, transparent); background: color-mix(in srgb, var(--nxt-accent) 7%, transparent); }+.irl-feed-banner .txt { flex: 1; font-size: 13px; color: var(--nxt-ink); }+.irl-feed-banner b { color: var(--nxt-accent); }++.irl-card { background: var(--nxt-panel, var(--nxt-bg-1)); border: 1px solid var(--nxt-stroke); border-radius: var(--nxt-radius); overflow: hidden; }.irl-card-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; }.irl-av { width: 48px; height: 48px; border-radius: 11px; object-fit: cover; background: var(--nxt-bg-2); border: 1px solid var(--nxt-stroke); flex-shrink: 0; }.irl-av-fallback { width: 48px; height: 48px; border-radius: 11px; background: linear-gradient(135deg, #1a2035, #0d1018); border: 1px solid var(--nxt-stroke); display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }@@ -70,20 +118,58 @@ const STYLE = `.irl-badge.expired { color: var(--nxt-ink-faint); background: var(--nxt-bg-2); border-color: var(--nxt-stroke); }.irl-badge.expiring { color: var(--nxt-warn); background: color-mix(in srgb, var(--nxt-warn) 10%, transparent); border-color: color-mix(in srgb, var(--nxt-warn) 30%, transparent); }-.irl-card-body { border-top: 1px solid var(--nxt-line); padding: 12px 16px; display: flex; gap: 10px; align-items: flex-start; flex-wrap: wrap; }+/* Stat chips: balance / reputation / services / visitors */+.irl-stats { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 16px 12px; }+.irl-stat { display: flex; flex-direction: column; gap: 1px; padding: 7px 12px; border-radius: 10px; background: var(--nxt-bg-2); border: 1px solid var(--nxt-stroke); min-width: 76px; }+.irl-stat .k { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--nxt-ink-faint); }+.irl-stat .v { font-size: 14px; font-weight: 700; color: var(--nxt-ink); font-variant-numeric: tabular-nums; }+.irl-stat.skel .v { color: transparent; background: var(--nxt-stroke); border-radius: 4px; width: 40px; animation: irl-pulse 1.4s ease infinite; }+.irl-stat a.v { text-decoration: none; color: var(--nxt-accent); }++.irl-section { border-top: 1px solid var(--nxt-line, var(--nxt-stroke)); padding: 12px 16px; }+.irl-section-label { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--nxt-ink-faint); margin-bottom: 8px; display: flex; align-items: center; justify-content: space-between; }+.irl-section-label a { color: var(--nxt-accent); text-decoration: none; font-size: 11px; text-transform: none; letter-spacing: 0; }++/* Services */+.irl-svc-list { display: flex; flex-direction: column; gap: 6px; }+.irl-svc { display: flex; align-items: center; gap: 10px; font-size: 13px; }+.irl-svc-name { color: var(--nxt-ink); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }+.irl-svc-price { color: var(--nxt-success); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }+.irl-svc-empty { font-size: 12px; color: var(--nxt-ink-faint); }++/* Interactions feed */+.irl-ix { display: flex; gap: 9px; padding: 6px 0; }+.irl-ix-icon { font-size: 14px; line-height: 1.4; flex-shrink: 0; }+.irl-ix-body { display: flex; flex-direction: column; gap: 1px; font-size: 13px; min-width: 0; }+.irl-ix-who { color: var(--nxt-ink-dim); }+.irl-ix-msg { color: var(--nxt-ink); }+.irl-ix-time { font-size: 11px; color: var(--nxt-ink-faint); }+.irl-ix-empty { font-size: 12px; color: var(--nxt-ink-faint); }++/* Caption + management */+.irl-card-body { border-top: 1px solid var(--nxt-line, var(--nxt-stroke)); padding: 12px 16px; display: flex; gap: 10px; align-items: flex-start; flex-wrap: wrap; }.irl-caption { font-size: 13px; color: var(--nxt-ink-dim); flex: 1; min-width: 120px; cursor: pointer; padding: 4px 6px; border-radius: 6px; border: 1px solid transparent; transition: border-color .12s; }.irl-caption:hover { border-color: var(--nxt-stroke); }.irl-caption-edit { display: flex; gap: 8px; flex: 1; min-width: 180px; }.irl-caption-input { flex: 1; background: var(--nxt-bg-2); border: 1px solid var(--nxt-accent); border-radius: 6px; color: var(--nxt-ink); padding: 5px 10px; font-size: 13px; font-family: inherit; outline: none; }-.irl-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }+.irl-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; flex-wrap: wrap; }.irl-action { font-size: 12px; padding: 5px 12px; border-radius: var(--nxt-radius-sm); border: 1px solid var(--nxt-stroke); background: var(--nxt-bg-2); color: var(--nxt-ink); cursor: pointer; text-decoration: none; white-space: nowrap; transition: border-color .12s; }.irl-action:hover { border-color: var(--nxt-stroke-strong); }-.irl-action.remove { color: #f87171; border-color: color-mix(in srgb, #f87171 30%, transparent); }-.irl-action.remove:hover { background: color-mix(in srgb, #f87171 8%, transparent); }+.irl-action.remove { color: var(--nxt-danger, #f87171); border-color: color-mix(in srgb, var(--nxt-danger, #f87171) 30%, transparent); }+.irl-action.remove:hover { background: color-mix(in srgb, var(--nxt-danger, #f87171) 8%, transparent); }++/* Location editor */+.irl-loc-edit { border-top: 1px dashed var(--nxt-stroke); padding: 12px 16px; display: none; gap: 10px; flex-wrap: wrap; align-items: flex-end; }+.irl-loc-edit.open { display: flex; }+.irl-loc-field { display: flex; flex-direction: column; gap: 4px; }+.irl-loc-field label { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--nxt-ink-faint); }+.irl-loc-field input { width: 110px; background: var(--nxt-bg-2); border: 1px solid var(--nxt-stroke); border-radius: 7px; color: var(--nxt-ink); padding: 6px 9px; font-size: 13px; font-family: inherit; outline: none; font-variant-numeric: tabular-nums; }+.irl-loc-field input:focus { border-color: var(--nxt-accent); }+.irl-loc-field.heading input { width: 78px; }.irl-empty { text-align: center; padding: 60px 20px; color: var(--nxt-ink-faint); }.irl-empty b { display: block; font-size: 16px; color: var(--nxt-ink); margin-bottom: 8px; }-.irl-skel { height: 80px; border-radius: var(--nxt-radius); background: var(--nxt-bg-2); animation: irl-pulse 1.4s ease infinite; }+.irl-skel { height: 120px; border-radius: var(--nxt-radius); background: var(--nxt-bg-2); animation: irl-pulse 1.4s ease infinite; }@keyframes irl-pulse { 0%,100%{opacity:.55} 50%{opacity:1} }</style>`;@@ -94,56 +180,117 @@ navigator.geolocation?.getCurrentPosition({ timeout: 5000 },);-function cardHtml(pin, geo) {- const loc = geo || `${Number(pin.lat).toFixed(5)}°, ${Number(pin.lng).toFixed(5)}°`;- const dist = userPos ? ` · ${(haversineDist(userPos.lat, userPos.lng, pin.lat, pin.lng) / 1000).toFixed(1)} km away` : '';- const dir = pin.heading != null ? ` · Facing ${compassLabel(pin.heading)}` : '';- const placed = relTime(pin.placed_at);- const expiry = expiryLabel(pin.expires_at);+function metaLine(pin, geo) {+ const loc = geo || `${Number(pin.lat).toFixed(5)}°, ${Number(pin.lng).toFixed(5)}°`;+ const dist = userPos ? ` · ${(haversineDist(userPos.lat, userPos.lng, pin.lat, pin.lng) / 1000).toFixed(1)} km away` : '';+ const dir = pin.heading != null ? ` · Facing ${compassLabel(pin.heading)}` : '';+ return `📍 ${loc}${dist}${dir}`;+}++function cardHtml(pin, ixList) {const caption = pin.caption || '';const img = pin.avatar_url? `<img class="irl-av" src="${esc(pin.avatar_url)}" alt="" loading="lazy" onerror="this.style.display='none';this.nextElementSibling.style.display='flex'" /><div class="irl-av-fallback" style="display:none">📍</div>`: `<div class="irl-av-fallback">📍</div>`;- return `<div class="irl-card" data-id="${esc(pin.id)}">+ const visitors = Number(pin.view_count) || 0;+ const pinIx = ixList.filter((x) => x.pin_id === pin.id).slice(0, 4);+ const ixHtml = pinIx.length+ ? pinIx.map(interactionLine).join('')+ : `<div class="irl-ix-empty">No one has interacted with this agent in person yet. Share its location to get discovered.</div>`;++ // Stat chips — balance & reputation fill in async (skeleton until then).+ const agentStats = pin.agent_id ? `+ <div class="irl-stat skel" data-stat="balance"><span class="k">Balance</span><span class="v">—</span></div>+ <div class="irl-stat skel" data-stat="reputation"><span class="k">Reputation</span><span class="v">—</span></div>+ <div class="irl-stat skel" data-stat="services"><span class="k">Services</span><span class="v">—</span></div>` : '';++ return `<div class="irl-card" data-id="${esc(pin.id)}" data-agent="${esc(pin.agent_id || '')}"+ data-lat="${esc(pin.lat)}" data-lng="${esc(pin.lng)}" data-heading="${esc(pin.heading ?? 0)}"><div class="irl-card-head">${img}<div class="irl-info">- <div class="irl-name">${esc(pin.avatar_name || 'Placed avatar')}</div>+ <div class="irl-name">${esc(pin.avatar_name || 'Placed agent')}</div><div class="irl-meta">- <span>📍 ${esc(loc)}${esc(dist)}</span>- ${expiry}- <span>${esc(placed)}</span>- ${dir ? `<span>${esc(dir)}</span>` : ''}+ <span class="irl-meta-loc">${esc(metaLine(pin, null))}</span>+ ${expiryLabel(pin.expires_at)}</div></div></div>++ <div class="irl-stats">+ ${agentStats}+ <div class="irl-stat"><span class="k">Visitors</span><span class="v">${visitors}</span></div>+ </div>++ <div class="irl-section" data-skills-section hidden>+ <div class="irl-section-label">Skills</div>+ <div class="irl-skills" data-skills-list></div>+ </div>++ <div class="irl-section" data-services hidden>+ <div class="irl-section-label">Services <a href="/dashboard/monetize">Manage ↗</a></div>+ <div class="irl-svc-list" data-svc-list></div>+ </div>++ <div class="irl-section">+ <div class="irl-section-label">IRL interactions</div>+ <div data-ix-list>${ixHtml}</div>+ </div>+<div class="irl-card-body"><div class="irl-caption" data-caption="${esc(caption)}" title="Click to edit caption">${caption ? esc(caption) : '<span style="color:var(--nxt-ink-faint);font-style:italic">Add a caption…</span>'}</div><div class="irl-actions">+ <a class="irl-action" href="${esc(outfitHref(pin))}" target="_blank" rel="noopener">Change outfit ↗</a>+ <button class="irl-action" data-loc-toggle>Move / re-aim</button><a class="irl-action" href="/irl?highlight=${esc(pin.id)}" target="_blank" rel="noopener">View in IRL ↗</a><button class="irl-action remove" data-remove="${esc(pin.id)}">Remove</button></div></div>++ <div class="irl-loc-edit" data-loc-edit>+ <div class="irl-loc-field"><label>Latitude</label><input type="number" step="0.00001" data-loc="lat" value="${esc(Number(pin.lat).toFixed(5))}" /></div>+ <div class="irl-loc-field"><label>Longitude</label><input type="number" step="0.00001" data-loc="lng" value="${esc(Number(pin.lng).toFixed(5))}" /></div>+ <div class="irl-loc-field heading"><label>Heading°</label><input type="number" min="0" max="359" step="1" data-loc="heading" value="${esc(Math.round(pin.heading ?? 0))}" /></div>+ <button class="irl-action" data-loc-here>Use my location</button>+ <button class="irl-btn primary" data-loc-save>Save location</button>+ </div></div>`;}async function mount(el) {el.innerHTML = STYLE + `<div class="irl-wrap"><div class="irl-header">- <h2>My Placed Avatars</h2>+ <h2>My IRL Agents <span class="irl-unread-pill" id="irl-unread" hidden></span></h2><a class="irl-btn primary" href="/irl" id="irl-place-btn">+ Place new ↗</a></div>+ <div id="irl-mp-banner"></div>+ <div id="irl-banner"></div><div id="irl-list"></div></div>`;+ // Multiplayer AR explainer — shown once at the top so owners understand+ // that their placed agents are visible to ALL users who visit that location.+ el.querySelector('#irl-mp-banner').innerHTML = `<div class="irl-mp-banner">+ <span class="mp-icon" aria-hidden="true">🌐</span>+ <div class="mp-body"><strong>Multiplayer AR — your agents are public</strong>+ Anyone who opens three.ws/irl near your pin location will see your 3D agent in their camera view. You can update the agent's caption, outfit, and location remotely at any time.</div>+ </div>`;+const list = el.querySelector('#irl-list');list.innerHTML = Array.from({ length: 3 }, () => `<div class="irl-skel"></div>`).join('');- let pins;+ // Pins + interactions in parallel — interactions power both the banner and+ // each card's IRL feed.+ let pins, interactions = [], unread = 0;try {- const data = await get('/api/irl/pins?mine=1');- pins = data.pins || [];+ const [pinsData, ixData] = await Promise.all([+ get('/api/irl/pins?mine=1'),+ get('/api/irl/interactions?mine=1').catch(() => ({ interactions: [], unread: 0 })),+ ]);+ pins = pinsData.pins || [];+ interactions = ixData.interactions || [];+ unread = ixData.unread || 0;} catch {list.innerHTML = `<div class="irl-empty"><b>Failed to load placements</b>Try refreshing the page.</div>`;return;@@ -151,124 +298,244 @@ async function mount(el) {if (!pins.length) {list.innerHTML = `<div class="irl-empty">- <b>No placements yet</b>- Open IRL, enable your camera, and use the Lock button to pin yourself to a real-world location.+ <b>No agents placed yet</b>+ Open IRL, enable your camera, and pin an agent to a real-world spot — it becomes visible to everyone who visits that location.<br><br><a class="irl-btn primary" href="/irl">Open IRL →</a></div>`;- el.querySelector('#irl-place-btn').textContent = '+ Place avatar ↗';+ el.querySelector('#irl-place-btn').textContent = '+ Place agent ↗';return;}- el.querySelector('#irl-place-btn').textContent = '↺ Update placement ↗';+ // Unread banner + pill+ const unreadEl = el.querySelector('#irl-unread');+ if (unread > 0) {+ unreadEl.textContent = `${unread} new`;+ unreadEl.hidden = false;+ el.querySelector('#irl-banner').innerHTML = `<div class="irl-feed-banner">+ <span class="txt"><b>${unread}</b> ${unread === 1 ? 'person' : 'people'} interacted with your agents in real life.</span>+ <button class="irl-btn" id="irl-mark-seen">Mark all seen</button>+ </div>`;+ el.querySelector('#irl-mark-seen')?.addEventListener('click', async (e) => {+ e.target.disabled = true;+ await patch('/api/irl/interactions', {}).catch(() => {});+ unreadEl.hidden = true;+ el.querySelector('#irl-banner').innerHTML = '';+ });+ }- // Render with lat/lng first, then update with geocoded city names async- list.innerHTML = pins.map((p) => cardHtml(p, null)).join('');+ list.innerHTML = pins.map((p) => cardHtml(p, interactions)).join('');- // Reverse-geocode in parallel (rate-limit: one at a time to be polite)+ // ── Async enrichment per card: balance, reputation, services, geocode ──────for (const pin of pins) {const card = list.querySelector(`[data-id="${pin.id}"]`);if (!card) continue;- const geo = await reverseGeocode(pin.lat, pin.lng);- if (geo) {- const metaSpan = card.querySelector('.irl-meta span:first-child');- if (metaSpan) {- const dist = userPos ? ` · ${(haversineDist(userPos.lat, userPos.lng, pin.lat, pin.lng) / 1000).toFixed(1)} km away` : '';- const dir = pin.heading != null ? ` · Facing ${compassLabel(pin.heading)}` : '';- metaSpan.textContent = `📍 ${geo}${dist}${dir}`;++ // Reverse-geocode the location label (serial, polite to Nominatim).+ reverseGeocode(pin.lat, pin.lng).then((geo) => {+ if (geo) {+ const locEl = card.querySelector('.irl-meta-loc');+ if (locEl) locEl.textContent = metaLine(pin, geo);}- }+ });++ if (!pin.agent_id) continue;++ // Reputation + services from the IRL agent-card (public, cached).+ fetch(`/api/irl/agent-card?id=${encodeURIComponent(pin.agent_id)}`)+ .then((r) => (r.ok ? r.json() : null))+ .then((data) => {+ const card2 = data?.card;+ if (!card2) { fillStatError(card, 'reputation'); fillStatError(card, 'services'); return; }+ fillStat(card, 'reputation', String(card2.reputation?.score ?? 0));+ const svc = card2.services || [];+ fillStat(card, 'services', String(svc.length));+ renderServices(card, svc);+ })+ .catch(() => { fillStatError(card, 'reputation'); fillStatError(card, 'services'); });++ // Agent skills from the agent profile endpoint.+ fetch(`/api/agents/${encodeURIComponent(pin.agent_id)}`, { credentials: 'include' })+ .then((r) => (r.ok ? r.json() : null))+ .then((data) => {+ const skills = data?.agent?.skills || [];+ renderSkills(card, skills);+ })+ .catch(() => {});++ // Live wallet balance.+ fetch(`/api/agents/${encodeURIComponent(pin.agent_id)}/solana`)+ .then((r) => (r.ok ? r.json() : null))+ .then((data) => {+ const bal = data?.data?.balance;+ fillStat(card, 'balance', bal == null ? '—' : `◎${Number(bal).toFixed(2)}`);+ })+ .catch(() => fillStatError(card, 'balance'));}- // Event delegation — caption edit, remove+ wireCardEvents(list, pins);+}++function fillStat(card, key, value) {+ const el = card.querySelector(`[data-stat="${key}"]`);+ if (!el) return;+ el.classList.remove('skel');+ el.querySelector('.v').textContent = value;+}+function fillStatError(card, key) {+ const el = card.querySelector(`[data-stat="${key}"]`);+ if (!el) return;+ el.classList.remove('skel');+ el.querySelector('.v').textContent = '—';+}++function renderSkills(card, skills) {+ const section = card.querySelector('[data-skills-section]');+ const listEl = card.querySelector('[data-skills-list]');+ if (!section || !listEl || !skills.length) return;+ section.hidden = false;+ listEl.innerHTML = skills.slice(0, 12).map((s) => `<span class="irl-skill">${esc(s)}</span>`).join('');+}++function renderServices(card, services) {+ const section = card.querySelector('[data-services]');+ const listEl = card.querySelector('[data-svc-list]');+ if (!section || !listEl) return;+ section.hidden = false;+ if (!services.length) {+ listEl.innerHTML = `<div class="irl-svc-empty">No paid services yet. <a href="/dashboard/monetize">Add one →</a></div>`;+ return;+ }+ listEl.innerHTML = services.map((s) => {+ const price = s.price_usdc != null ? `$${Number(s.price_usdc).toFixed(2)} ${(s.network || 'base').toUpperCase()}` : 'Free';+ return `<div class="irl-svc"><span class="irl-svc-name">${esc(s.name || s.slug)}</span><span class="irl-svc-price">${esc(price)}</span></div>`;+ }).join('');+}++function wireCardEvents(list, pins) {list.addEventListener('click', async (e) => {+ const card = e.target.closest('.irl-card');+ if (!card) return;+ const id = card.dataset.id;++ // Removeconst removeBtn = e.target.closest('[data-remove]');if (removeBtn) {- const id = removeBtn.dataset.remove;removeBtn.disabled = true;removeBtn.textContent = 'Removing…';try {const r = await fetch(`/api/irl/pins?id=${encodeURIComponent(id)}`, { method: 'DELETE', credentials: 'include' });if (r.ok) {- list.querySelector(`[data-id="${id}"]`)?.remove();+ card.remove();if (!list.querySelector('.irl-card')) {- list.innerHTML = `<div class="irl-empty"><b>No placements</b>All pins removed. <a class="irl-btn" href="/irl" style="display:inline-flex;margin-top:12px">Place a new one →</a></div>`;+ list.innerHTML = `<div class="irl-empty"><b>No placements</b>All agents removed. <a class="irl-btn" href="/irl" style="display:inline-flex;margin-top:12px">Place a new one →</a></div>`;}- } else {- removeBtn.disabled = false;- removeBtn.textContent = 'Remove';- }- } catch {- removeBtn.disabled = false;- removeBtn.textContent = 'Remove';- }+ } else { removeBtn.disabled = false; removeBtn.textContent = 'Remove'; }+ } catch { removeBtn.disabled = false; removeBtn.textContent = 'Remove'; }return;}+ // Toggle location editor+ if (e.target.closest('[data-loc-toggle]')) {+ card.querySelector('[data-loc-edit]')?.classList.toggle('open');+ return;+ }++ // "Use my location" — fill lat/lng from the browser+ if (e.target.closest('[data-loc-here]')) {+ const btn = e.target.closest('[data-loc-here]');+ btn.disabled = true; btn.textContent = 'Locating…';+ navigator.geolocation?.getCurrentPosition(+ (p) => {+ card.querySelector('[data-loc="lat"]').value = p.coords.latitude.toFixed(5);+ card.querySelector('[data-loc="lng"]').value = p.coords.longitude.toFixed(5);+ btn.disabled = false; btn.textContent = 'Use my location';+ },+ () => { btn.disabled = false; btn.textContent = 'Location unavailable'; },+ { enableHighAccuracy: true, timeout: 8000 },+ );+ return;+ }++ // Save location+ if (e.target.closest('[data-loc-save]')) {+ const btn = e.target.closest('[data-loc-save]');+ const lat = parseFloat(card.querySelector('[data-loc="lat"]').value);+ const lng = parseFloat(card.querySelector('[data-loc="lng"]').value);+ const heading = parseInt(card.querySelector('[data-loc="heading"]').value, 10);+ if (!isFinite(lat) || !isFinite(lng)) { btn.textContent = 'Invalid coordinates'; return; }+ btn.disabled = true; btn.textContent = 'Saving…';+ try {+ const r = await patch('/api/irl/pins', { id, lat, lng, heading: isFinite(heading) ? heading : 0 });+ if (r.pin) {+ const pin = pins.find((p) => p.id === id);+ if (pin) { pin.lat = r.pin.lat; pin.lng = r.pin.lng; pin.heading = r.pin.heading; }+ card.querySelector('.irl-meta-loc').textContent = metaLine(r.pin, null);+ reverseGeocode(r.pin.lat, r.pin.lng).then((geo) => {+ if (geo) card.querySelector('.irl-meta-loc').textContent = metaLine(r.pin, geo);+ });+ btn.textContent = 'Saved ✓';+ setTimeout(() => { btn.disabled = false; btn.textContent = 'Save location'; card.querySelector('[data-loc-edit]')?.classList.remove('open'); }, 900);+ } else { btn.disabled = false; btn.textContent = 'Save location'; }+ } catch { btn.disabled = false; btn.textContent = 'Retry save'; }+ return;+ }++ // Caption — click to editconst captionEl = e.target.closest('.irl-caption');if (captionEl) {- const card = captionEl.closest('.irl-card');- const id = card.dataset.id;const current = captionEl.dataset.caption || '';- captionEl.replaceWith(`<div class="irl-caption-edit">+ captionEl.replaceWith(makeNode(`<div class="irl-caption-edit"><input class="irl-caption-input" type="text" value="${esc(current)}" placeholder="Caption…" maxlength="140" aria-label="Placement caption" /><button class="irl-action" data-save="${esc(id)}">Save</button><button class="irl-action" data-cancel>Cancel</button>- </div>`);+ </div>`));card.querySelector('.irl-caption-input')?.focus();return;}- const cancelBtn = e.target.closest('[data-cancel]');- if (cancelBtn) {- const card = cancelBtn.closest('.irl-card');- const pin = pins.find(p => p.id === card.dataset.id);- if (pin) {- const editEl = card.querySelector('.irl-caption-edit');- const caption = pin.caption || '';- editEl?.replaceWith(`<div class="irl-caption" data-caption="${esc(caption)}" title="Click to edit caption">${caption ? esc(caption) : '<span style="color:var(--nxt-ink-faint);font-style:italic">Add a caption…</span>'}</div>`);- }+ // Caption — cancel+ if (e.target.closest('[data-cancel]')) {+ const pin = pins.find((p) => p.id === id);+ restoreCaption(card, pin?.caption || '');return;}+ // Caption — saveconst saveBtn = e.target.closest('[data-save]');if (saveBtn) {- const id = saveBtn.dataset.save;const input = saveBtn.closest('.irl-caption-edit')?.querySelector('.irl-caption-input');- const val = input?.value?.trim() ?? '';- saveBtn.disabled = true;- saveBtn.textContent = 'Saving…';+ const val = input?.value?.trim() ?? '';+ saveBtn.disabled = true; saveBtn.textContent = 'Saving…';try {- const r = await fetch('/api/irl/pins', {- method: 'PATCH',- credentials: 'include',- headers: { 'content-type': 'application/json' },- body: JSON.stringify({ id, caption: val || null }),- });- if (r.ok) {- const pin = pins.find(p => p.id === id);+ const r = await patch('/api/irl/pins', { id, caption: val || null });+ if (r.pin !== undefined) {+ const pin = pins.find((p) => p.id === id);if (pin) pin.caption = val || null;- const card = list.querySelector(`[data-id="${id}"]`);- const editEl = card?.querySelector('.irl-caption-edit');- editEl?.replaceWith(`<div class="irl-caption" data-caption="${esc(val)}" title="Click to edit caption">${val ? esc(val) : '<span style="color:var(--nxt-ink-faint);font-style:italic">Add a caption…</span>'}</div>`);- } else {- saveBtn.disabled = false;- saveBtn.textContent = 'Save';- }- } catch {- saveBtn.disabled = false;- saveBtn.textContent = 'Save';- }+ restoreCaption(card, val);+ } else { saveBtn.disabled = false; saveBtn.textContent = 'Save'; }+ } catch { saveBtn.disabled = false; saveBtn.textContent = 'Save'; }}});}+function makeNode(html) {+ const t = document.createElement('template');+ t.innerHTML = html.trim();+ return t.content.firstElementChild;+}+function restoreCaption(card, caption) {+ const editEl = card.querySelector('.irl-caption-edit');+ const node = makeNode(`<div class="irl-caption" data-caption="${esc(caption)}" title="Click to edit caption">${caption ? esc(caption) : '<span style="color:var(--nxt-ink-faint);font-style:italic">Add a caption…</span>'}</div>`);+ editEl?.replaceWith(node);+}+(async function boot() {const el = await mountShell();try {await requireUser();await mount(el);} catch (e) {- el.innerHTML = `<div class="irl-empty"><b>Couldn't load placements</b>${esc(e?.message || 'Please try again.')}</div>${STYLE}`;+ el.innerHTML = `<div class="irl-empty"><b>Couldn't load your IRL agents</b>${esc(e?.message || 'Please try again.')}</div>${STYLE}`;}})();diff --git a/src/irl.js b/src/irl.jsindex c9bea0a83..c94fffb90 100644--- a/src/irl.js+++ b/src/irl.js@@ -58,6 +58,7 @@ const CAM_OFFSET = new Vector3(0, 1.85, 3.6);const CAM_LOOK_OFFSET = new Vector3(0, 1.1, 0);const SPAWN_DURATION = 0.38; // seconds for placed object scale-upconst TAP_THRESHOLD = 10; // px — beyond this it's a drag, not a tap+const NEARBY_FACE_LERP = 0.025; // speed at which nearby agents rotate to face camera// ── URL params ────────────────────────────────────────────────────────────const params = new URLSearchParams(location.search);@@ -72,6 +73,11 @@ function resolveAvatarUrl(id) {// ── DOM refs ──────────────────────────────────────────────────────────────const $ = (id) => document.getElementById(id);+// Pre-allocated vectors used in tick() camera-awareness detection (avoids GC churn)+const _camWorldDir = new Vector3();+const _camDirH = new Vector3();+const _toAgentH = new Vector3();+const canvas = $('irl-canvas');const videoEl = $('irl-camera');const joystickEl = $('irl-joystick');@@ -451,7 +457,6 @@ let tapDownX = 0, tapDownY = 0;canvas.addEventListener('pointerdown', e => { tapDownX = e.clientX; tapDownY = e.clientY; });canvas.addEventListener('pointerup', e => {- if (!placeModeActive) return;if (Math.hypot(e.clientX - tapDownX, e.clientY - tapDownY) > TAP_THRESHOLD) return;pointerNDC.set(@@ -459,21 +464,45 @@ canvas.addEventListener('pointerup', e => {-(e.clientY / window.innerHeight) * 2 + 1,);raycaster.setFromCamera(pointerNDC, camera);- const hits = raycaster.intersectObject(rayPlane);- if (!hits.length) return;-- const def = OBJ_DEFS[selectedType];- if (!def) return;- const mesh = def.create();- mesh.position.x = hits[0].point.x;- mesh.position.z = hits[0].point.z;- mesh.scale.setScalar(0.001);- scene.add(mesh);- placedObjects.push({ mesh, spawnT: 0, type: selectedType });- clearBtn.hidden = false;- _saveSession();++ if (placeModeActive) {+ // ── Place mode: drop an object on the ground ─────────────────────+ const hits = raycaster.intersectObject(rayPlane);+ if (!hits.length) return;+ const def = OBJ_DEFS[selectedType];+ if (!def) return;+ const mesh = def.create();+ mesh.position.x = hits[0].point.x;+ mesh.position.z = hits[0].point.z;+ mesh.scale.setScalar(0.001);+ scene.add(mesh);+ placedObjects.push({ mesh, spawnT: 0, type: selectedType });+ clearBtn.hidden = false;+ _saveSession();+ } else {+ // ── Tap on a nearby agent's 3D model ─────────────────────────────+ const agentGroups = nearbyPins.map(p => p.group).filter(Boolean);+ if (agentGroups.length) {+ const hits = raycaster.intersectObjects(agentGroups, true);+ if (hits.length) {+ // Traverse up the scene graph to find which pin owns the hit mesh+ const pin = _pinForObject(hits[0].object);+ if (pin) { openPinSheet(pin); return; }+ }+ }+ }});+function _pinForObject(obj) {+ let node = obj;+ while (node) {+ const found = nearbyPins.find(p => p.group === node);+ if (found) return found;+ node = node.parent;+ }+ return null;+}+// ── Joystick ──────────────────────────────────────────────────────────────const input = {joy: { x: 0, y: 0, active: false },@@ -968,11 +997,15 @@ function spawnNearbyPin(pin) {pin.group = g;scene.add(g);- // Floating HTML name label+ // Floating HTML name label — gold border if this is the owner's own pinconst el = document.createElement('div');el.className = 'irl-agent-label';+ // Mark own pin (matched by device_token on anonymous OR user_id on authenticated)+ if (pin.device_token === _deviceToken || (gpsPin?.id && pin.id === gpsPin.id)) {+ el.classList.add('is-own');+ }el.style.display = 'none';- el.innerHTML = `<span class="irl-agent-label-name">${_escHtml(pin.avatar_name || 'Agent')}</span>`;+ el.innerHTML = `<span class="irl-agent-label-name">${_escHtml(pin.avatar_name || 'Agent')}</span>`;el.addEventListener('click', () => openPinSheet(pin));document.body.appendChild(el);pin.labelEl = el;@@ -1132,28 +1165,218 @@ document.getElementById('irl-mypins-list')?.addEventListener('click', (e) => {});// ── Interaction sheet ─────────────────────────────────────────────────────-function openPinSheet(pin) {+async function openPinSheet(pin) {const sheet = document.getElementById('irl-sheet');if (!sheet) return;- document.getElementById('irl-sheet-name').textContent = pin.avatar_name || 'Agent';- document.getElementById('irl-sheet-dist').textContent = `${pin.distance_m ?? '?'}m away`;++ // Populate basic fields immediately so the sheet opens without delay+ document.getElementById('irl-sheet-name').textContent = pin.avatar_name || 'Agent';+ const distEl = document.getElementById('irl-sheet-dist');+ if (distEl) distEl.textContent = pin.distance_m != null ? `${pin.distance_m}m away` : '';+const cap = document.getElementById('irl-sheet-caption');- cap.textContent = pin.caption || '';- cap.hidden = !pin.caption;+ if (cap) { cap.textContent = pin.caption || ''; cap.hidden = !pin.caption; }+const payBtn = document.getElementById('irl-sheet-pay');if (payBtn) {payBtn.hidden = !pin.x402_endpoint;payBtn.dataset.endpoint = pin.x402_endpoint ?? '';}++ // Clear any previously loaded enriched content+ const descEl = document.getElementById('irl-sheet-description');+ const skillsEl = document.getElementById('irl-sheet-skills');+ const viewsEl = document.getElementById('irl-sheet-views');+ const multiEl = document.getElementById('irl-sheet-multiplayer');+ if (descEl) { descEl.textContent = ''; descEl.hidden = true; }+ if (skillsEl) { skillsEl.innerHTML = ''; skillsEl.hidden = true; }+ if (viewsEl) { viewsEl.hidden = true; }+ if (multiEl) { multiEl.hidden = true; }+sheet.dataset.agentId = pin.agent_id ?? '';sheet.dataset.agentName = pin.avatar_name ?? '';+ sheet.dataset.pinId = pin.id ?? '';+ // Reset the message composer for this agent+ {+ const msgInput = document.getElementById('irl-msg-input');+ const msgStatus = document.getElementById('irl-sheet-status');+ if (msgInput) { msgInput.value = ''; msgInput.disabled = false; }+ if (msgStatus) { msgStatus.hidden = true; msgStatus.classList.remove('is-error'); }+ }sheet.classList.add('is-open');++ // Multiplayer note — always show since all pins are publicly visible+ if (multiEl) {+ const multiText = document.getElementById('irl-sheet-multiplayer-text');+ if (multiText) {+ const viewDesc = pin.view_count > 0+ ? `Seen by ${pin.view_count} visitor${pin.view_count !== 1 ? 's' : ''} · visible to all users nearby`+ : 'Visible to all users at this location';+ multiText.textContent = viewDesc;+ }+ multiEl.hidden = false;+ }++ // Log the view interaction (fire-and-forget, best-effort)+ if (pin.id) {+ fetch('/api/irl/interactions', {+ method: 'POST',+ headers: { 'Content-Type': 'application/json' },+ body: JSON.stringify({+ pinId: pin.id,+ type: 'view',+ deviceToken: _deviceToken,+ agentId: pin.agent_id ?? null,+ }),+ }).catch(() => {});+ pin.view_count = (pin.view_count ?? 0) + 1;+ }++ // Async: enrich with full agent profile data+ if (pin.agent_id) {+ try {+ const r = await fetch(`/api/agents/${encodeURIComponent(pin.agent_id)}`);+ if (r.ok) {+ const data = await r.json();+ const agent = data.agent ?? data;+ if (agent.description && descEl) {+ descEl.textContent = agent.description;+ descEl.hidden = false;+ }+ if (agent.skills?.length && skillsEl) {+ skillsEl.innerHTML = agent.skills.slice(0, 6).map(s =>+ `<span class="irl-skill-badge">${_escHtml(s)}</span>`,+ ).join('');+ skillsEl.hidden = false;+ }+ }+ } catch {}+ }}document.getElementById('irl-sheet-close')?.addEventListener('click', () => {document.getElementById('irl-sheet')?.classList.remove('is-open');});+// Leave-a-message — a visitor's note becomes a 'message' interaction in the+// owner's IRL feed (dashboard). Pin id is stamped on the sheet by openPinSheet.+document.getElementById('irl-sheet-msg')?.addEventListener('submit', async (e) => {+ e.preventDefault();+ const sheet = document.getElementById('irl-sheet');+ const input = document.getElementById('irl-msg-input');+ const sendBtn = document.getElementById('irl-msg-send');+ const status = document.getElementById('irl-sheet-status');+ const pinId = sheet?.dataset.pinId;+ const text = (input?.value ?? '').trim();+ if (!pinId || !text) return;++ if (sendBtn) sendBtn.disabled = true;+ if (input) input.disabled = true;+ try {+ const r = await fetch('/api/irl/interactions', {+ method: 'POST',+ headers: { 'Content-Type': 'application/json' },+ body: JSON.stringify({+ pinId,+ type: 'message',+ message: text,+ deviceToken: _deviceToken,+ agentId: sheet.dataset.agentId || null,+ }),+ });+ if (!r.ok) throw new Error(`HTTP ${r.status}`);+ if (input) input.value = '';+ if (status) {+ status.textContent = 'Message delivered — the owner will see it.';+ status.classList.remove('is-error');+ status.hidden = false;+ }+ } catch {+ if (status) {+ status.textContent = "Couldn't send — try again.";+ status.classList.add('is-error');+ status.hidden = false;+ }+ } finally {+ if (sendBtn) sendBtn.disabled = false;+ if (input) input.disabled = false;+ }+});++// ── Agent picker ──────────────────────────────────────────────────────────+// Lists the authenticated user's agents. Selecting one loads its avatar GLB+// into the scene and sets it as the current agent for any new pins.++async function openAgentPicker() {+ const sheet = document.getElementById('irl-agents-sheet');+ const list = document.getElementById('irl-agents-list');+ if (!sheet || !list) return;+ sheet.classList.add('is-open');+ list.innerHTML = '<p class="irl-agents-empty">Loading…</p>';++ let agents = [];+ try {+ const r = await fetch('/api/agents', { credentials: 'include' });+ if (!r.ok) throw new Error('not_auth');+ const data = await r.json();+ agents = data.agents ?? [];+ } catch {+ list.innerHTML = '<p class="irl-agents-empty">Sign in to switch agents. <a href="/login">Log in →</a></p>';+ return;+ }++ if (!agents.length) {+ list.innerHTML = '<p class="irl-agents-empty">No agents yet. <a href="/create">Create your first agent →</a></p>';+ return;+ }++ list.innerHTML = agents.map(a => `+ <div class="irl-agent-row${_currentAgentId === a.id ? ' is-active' : ''}"+ data-agent-id="${_escHtml(a.id)}"+ data-avatar-id="${_escHtml(a.avatar_id ?? '')}"+ data-avatar-url="${_escHtml(a.avatar_model_url ?? '')}"+ data-name="${_escHtml(a.name)}">+ <div class="irl-agent-thumb">+ ${a.avatar_thumbnail_url+ ? `<img src="${_escHtml(a.avatar_thumbnail_url)}" alt="" loading="lazy">`+ : '🤖'}+ </div>+ <div class="irl-agent-row-info">+ <div class="irl-agent-row-name">${_escHtml(a.name)}</div>+ ${a.description ? `<div class="irl-agent-row-desc">${_escHtml(a.description.slice(0, 90))}</div>` : ''}+ </div>+ ${_currentAgentId === a.id ? '<span class="irl-agent-row-check">✓</span>' : ''}+ </div>+ `).join('');+}++document.getElementById('irl-agents-btn')?.addEventListener('click', openAgentPicker);+document.getElementById('irl-agents-close')?.addEventListener('click', () => {+ document.getElementById('irl-agents-sheet')?.classList.remove('is-open');+});++document.getElementById('irl-agents-list')?.addEventListener('click', async (e) => {+ const row = e.target.closest('.irl-agent-row[data-agent-id]');+ if (!row) return;+ const agentId = row.dataset.agentId;+ const avatarId = row.dataset.avatarId;+ const avatarUrl = row.dataset.avatarUrl;+ const name = row.dataset.name;+ document.getElementById('irl-agents-sheet')?.classList.remove('is-open');+ _currentAgentId = agentId;+ // Update URL so a share link carries the chosen agent's avatar+ const sp = new URLSearchParams(location.search);+ if (avatarId) sp.set('avatar', avatarId); else sp.delete('avatar');+ history.replaceState(null, '', location.pathname + (sp.toString() ? '?' + sp : ''));+ try {+ await loadAvatar(avatarId || avatarUrl || null, name || null);+ setStatus(`Switched to ${name}`);+ } catch (err) {+ log.error('[irl] agent switch failed:', err);+ setStatus(`Couldn't load agent: ${err?.message ?? err}`, { error: true });+ }+});+document.getElementById('irl-sheet-view')?.addEventListener('click', () => {const sheet = document.getElementById('irl-sheet');const agentId = sheet?.dataset.agentId;@@ -1395,6 +1618,39 @@ function tick() {updateLabels();updateRadar();+ // ── Camera-aware agents: each nearby agent slowly faces the camera ────────+ // This creates the "mouse hover" effect the user knows from 2D — but in 3D:+ // agents turn toward whoever is looking at them via gyro/camera rotation.+ camera.getWorldDirection(_camWorldDir);+ _camDirH.set(_camWorldDir.x, 0, _camWorldDir.z);+ const camDirHLen = _camDirH.length();+ if (camDirHLen > 0.001) _camDirH.divideScalar(camDirHLen);++ for (const pin of nearbyPins) {+ if (!pin.glbLoaded || !pin.group) continue;++ // Rotate the agent on Y-axis to face the camera (horizontal only so feet+ // stay on the ground). Uses the same lerpAngle used for the player avatar.+ const dx = camera.position.x - pin.group.position.x;+ const dz = camera.position.z - pin.group.position.z;+ const targetYaw = Math.atan2(dx, dz);+ pin.group.rotation.y = lerpAngle(pin.group.rotation.y, targetYaw, NEARBY_FACE_LERP);++ // "Awareness" detection: is the camera currently aimed at this agent?+ // Dot product between camera forward vector and camera→agent vector.+ _toAgentH.set(+ pin.group.position.x - camera.position.x,+ 0,+ pin.group.position.z - camera.position.z,+ );+ const dist2D = _toAgentH.length();+ if (dist2D > 0.001) _toAgentH.divideScalar(dist2D);+ const dot = _camDirH.dot(_toAgentH);+ // Within ~25° of camera center (dot > 0.9) and within 30 m → aware+ const inView = camDirHLen > 0.001 && dot > 0.9 && dist2D < 30;+ pin.labelEl?.classList.toggle('is-aware', inView);+ }+renderer.render(scene, camera);requestAnimationFrame(tick);}