3D engine that AI agents drive
Keep the live homepage hero light and restore the page's lost metadata
Nguyen Xuan An2e524ae88003
diff --git a/changes/agent-home.md b/changes/agent-home.mdindex aebbefea..50bc8910 100644--- a/changes/agent-home.md+++ b/changes/agent-home.md@@ -1 +1 @@-Homepage: add interactive AI Agent 3D Workbench hero preview, engine gzip size comparison, and Trace67 path-tracer identity.+- The homepage hero is a live 3D airport ramp you can orbit or switch between four shots, on wide screens after the page has loaded; phones and data-saver visitors keep the still image. The real-time renderer is also exported as `Glaze` and the path tracer as `Cook` (`Renderer67` and `renderPathTracedImage` keep working).diff --git a/index.html b/index.htmlindex 9a9f41b8..25eb176b 100644--- a/index.html+++ b/index.html@@ -3,14 +3,25 @@<head><meta charset="UTF-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" />- <meta name="description" content="A WebGL2 3D engine that AI agents drive: Glaze real-time rendering, Cook path tracing, and an MCP server in one light package." />- <title>67js — A 3D engine agents can drive</title>+ <meta name="theme-color" content="#09070f" />+ <meta name="description" content="67js is a WebGL2 3D engine that AI agents drive: Glaze real-time rendering, Cook path tracing, GLB, PNG and MP4 export, and an MCP server. Install with npm i @codepawlhq/67js." />+ <meta property="og:type" content="website" />+ <meta property="og:site_name" content="67js" />+ <meta property="og:title" content="67js · a 3D engine agents can drive" />+ <meta property="og:description" content="Real-time WebGL2, offline path tracing and an MCP server in one npm package." />+ <meta property="og:url" content="https://67js.codepawl.com/" />+ <meta property="og:image" content="https://67js.codepawl.com/previews/showcase-airport.webp" />+ <meta property="og:image:alt" content="An airport ramp rendered by 67js" />+ <meta name="twitter:card" content="summary_large_image" />+ <link rel="canonical" href="https://67js.codepawl.com/" />+ <title>67js · a 3D engine agents can drive</title><link rel="icon" href="/favicon.svg" /></head>- <body class="home site">+ <body class="site"><a class="skip-link" href="#content">Skip to content</a><header class="navigation"><a class="brand" href="/" aria-label="67js home">67js</a>+ <span class="version" data-release-version>Loading release</span><nav aria-label="Library"><a href="/docs.html">Docs</a><a href="/changelog.html">Changelog</a></nav>@@ -20,9 +31,9 @@<section class="hero" aria-label="67js introduction and live preview"><div class="hero-frame" data-glow="#ff6a2b"><a class="hero-shot" href="./showcase.html?scene=airport" aria-label="Open the airport ramp as a live 3D scene">- <img src="./previews/helios-relay.webp" alt="Helios-67 orbital Dyson relay with counter-rotating gimbals and basalt monoliths, rendered by 67js" width="1280" height="720" fetchpriority="high" />+ <img src="./previews/showcase-airport.webp" alt="An airport ramp with a 787 at its stand and the turnaround crew, rendered by 67js" width="1280" height="720" fetchpriority="high" /></a>- <canvas id="hero-viewport" class="hero-viewport" aria-label="Live 3D Dyson relay scene. Drag to orbit or switch agent prompts."></canvas>+ <canvas id="hero-viewport" class="hero-viewport" aria-label="Live 3D airport ramp. Drag to orbit, or pick a shot."></canvas><aside class="hero-prompt" aria-label="Agent prompt presets"><div class="hero-prompt-tabs" role="group" aria-label="Agent prompt"><button type="button" data-prompt-preset="model" aria-pressed="true">Stand</button>@@ -76,13 +87,13 @@ renderer.render({ eye: [58, 31, 84], target: [-8, 3, -18] });</code></pre><button data-copy-code="home-code" aria-label="Copy the code example">Copy</button></div></div>- <img class="code-result" src="./previews/helios-relay.webp" alt="Helios-67 orbital Dyson relay rendered in real time by Glaze in 67js" width="1280" height="720" loading="lazy" />+ <img class="code-result" src="./previews/showcase-datacenter.webp" alt="A cutaway AI data center hall rendered by 67js from a GLB and an HDRI" width="1280" height="720" loading="lazy" /></section><section id="examples" class="examples" aria-labelledby="examples-title"><div class="section-heading"><h2 id="examples-title">Showcase</h2><a href="./showcase.html">Open the live scenes</a></div><ul class="capability-list" aria-label="Engine capabilities">- <li>PBR materials</li><li>Shadows</li><li>HDR and bloom</li><li>MSAA</li><li>Mesh blend</li><li>Live cloth</li><li>Volumetric fog</li><li>Skinning and morphs</li><li>Physics</li><li>Spume liquid</li><li>HDRI lighting</li><li>Textured terrain</li><li>Trees and grass</li><li>Vehicles</li><li>GLB import and export</li><li>Cook path tracer</li>+ <li>PBR materials</li><li>Shadows</li><li>HDR and bloom</li><li>MSAA</li><li>Mesh blend</li><li>Live cloth</li><li>Volumetric fog</li><li>Skinning and morphs</li><li>Physics</li><li>Spume liquid</li><li>Glass and leaf cutouts</li><li>HDRI lighting</li><li>Textured terrain</li><li>Trees and grass</li><li>Vehicles</li><li>GLB import and export</li><li>Cook path tracer</li></ul><div class="gallery"><a class="example is-lead" href="./showcase.html?scene=airport" data-glow="#ff6a2b"><span class="work-media"><img src="./previews/showcase-airport.webp" alt="Airport ramp, rendered by 67js" width="1280" height="720" loading="lazy" /></span><span class="work-title"><span class="work-index" aria-hidden="true">01</span><span class="work-name">Airport ramp</span><span class="work-date">A widebody at the stand with its service trucks</span></span></a>@@ -94,7 +105,7 @@ renderer.render({ eye: [58, 31, 84], target: [-8, 3, -18] });</code></pre><section id="agents" class="agents" aria-labelledby="agents-title"><div class="agents-intro"><h2 id="agents-title">Built for agents</h2>- <p>An agent gets a live scene to edit, glaze in real time or cook with path tracing, and review at 2.6× smaller bundle weight.</p>+ <p>An agent gets a live scene to edit, glaze in real time or cook with path tracing, and review.</p><div class="code-block"><pre><code id="home-mcp" data-language="shell">npx 67js-mcp --backend gpu --memory 192</code></pre><button data-copy-code="home-mcp" aria-label="Copy the MCP server command">Copy</button>@@ -112,7 +123,7 @@ renderer.render({ eye: [58, 31, 84], target: [-8, 3, -18] });</code></pre></div><div class="agent-cards"><a href="/mcp.md" data-icon="cube"><h3>22 MCP tools</h3><p>Create, edit, explode, blend and render over stdio.</p></a>- <a href="/path-tracer.md" data-icon="code"><h3>Glaze + Cook</h3><p>Sub-millisecond WebGL2 frames or path-traced stills.</p></a>+ <a href="/path-tracer.md" data-icon="code"><h3>Glaze + Cook</h3><p>Real-time WebGL2 frames or path-traced stills.</p></a><a href="/agent-review.md" data-icon="image"><h3>Visual review</h3><p>Compare labeled views and normals from one snapshot.</p></a></div></section>diff --git a/public/previews/helios-relay.webp b/public/previews/helios-relay.webpdeleted file mode 100644index 2db3b18a..00000000Binary files a/public/previews/helios-relay.webp and /dev/null differdiff --git a/src/home-agent-hero.js b/src/home-agent-hero.jsindex bd3e54bf..d86f760f 100644--- a/src/home-agent-hero.js+++ b/src/home-agent-hero.js@@ -1,7 +1,6 @@-// Live 3D AAA showcase hero for the homepage, powered by Glaze (Renderer67).-// Loads the staged Airport Ramp AAA world (Boeing 787-9 widebody, ground crew characters, pushback tug,-// catering & fuel trucks, terminal pier, control tower, hangars, 3-cascade shadows, and Industrial Sunset HDRI sky)-// and lets users or agents smoothly orbit and switch between 4 camera shots and surface-normal inspection.+// Live hero for the homepage, drawn by Glaze (Renderer67): the staged airport ramp world+// (a 787 at its stand, the turnaround crew, service trucks, terminal and tower) with cascaded+// shadows and an HDRI sky. Visitors orbit it or pick one of four shots, one a surface-normal view.import './replace-textured-parts.js';import { Glaze } from './renderer.js';import { createSharedTextures, loadGltf } from './gltf.js';@@ -90,8 +89,41 @@ async function fetchBlob(url) {return response.blob();}+const LIVE_HERO_QUERY = '(min-width: 961px) and (prefers-reduced-motion: no-preference)';+const AUTO_CYCLE_MS = 7500;++// The live hero only runs where it is cheap to: a wide screen, no data saver, motion allowed.+// Everywhere else the poster image stays, so phones never download the world.+function liveHeroAllowed() {+ if (navigator.connection?.saveData) return false;+ return window.matchMedia(LIVE_HERO_QUERY).matches;+}++function afterPageSettles(start) {+ const whenIdle = () => {+ if ('requestIdleCallback' in window) requestIdleCallback(start, { timeout: 2500 });+ else setTimeout(start, 300);+ };+ if (document.readyState === 'complete') whenIdle();+ else window.addEventListener('load', whenIdle, { once: true });+}+export function mountHeroAgentWorkbench() {- return mountHomeAgentHero();+ if (!liveHeroAllowed()) return;+ afterPageSettles(() => mountHomeAgentHero());+}++function createOrbitState(preset) {+ const orbit = orbitFromCamera(preset.state.eye, preset.state.target);+ return {+ yaw: orbit.yaw,+ pitch: orbit.pitch,+ distance: orbit.distance,+ target: [...orbit.target],+ fov: preset.state.fov,+ exposure: preset.state.exposure,+ inspection: preset.state.inspection,+ };}export async function mountHomeAgentHero() {@@ -102,38 +134,29 @@ export async function mountHomeAgentHero() {let renderer = null;let activeMap = null;let sceneDescription = null;+ let sharedTextures = null;+ let firstAsset = null;+ let firstRanks = null;try {- const descResp = await fetch('/showcase/airport/scene.json');- if (!descResp.ok) throw new Error(`Airport scene description unavailable (${descResp.status})`);- sceneDescription = await descResp.json();+ const descriptionResponse = await fetch('/showcase/airport/scene.json');+ if (!descriptionResponse.ok) throw new Error(`Airport scene description unavailable (${descriptionResponse.status})`);+ sceneDescription = await descriptionResponse.json();const glbUrl = new URL(sceneDescription.glb, location.href);- const previewSkyUrl = new URL(- sceneDescription.hdriPreview ?? sceneDescription.hdri,- location.href,- ).href;- const fullSkyUrl = new URL(sceneDescription.hdri, location.href).href;- const restUrls = (sceneDescription.glbRest ?? []).map(p => new URL(p, location.href).href);-- // Kick off stage-2 downloads in parallel while stage-1 decodes- const remainingPromise = Promise.all([- Promise.all(restUrls.map(url => fetchBlob(url))),- loadHdri(fullSkyUrl, sceneDescription.hdriOptions ?? {}).catch(() => null),- ]);-+ const previewSkyUrl = new URL(sceneDescription.hdriPreview ?? sceneDescription.hdri, location.href).href;const [firstBlob, previewMap] = await Promise.all([fetchBlob(glbUrl.href),loadHdri(previewSkyUrl, sceneDescription.hdriOptions ?? {}),]);- const sharedTextures = createSharedTextures();- const firstAsset = await loadGltf(firstBlob, {+ sharedTextures = createSharedTextures();+ firstAsset = await loadGltf(firstBlob, {baseUrl: new URL('.', glbUrl).href,sharedTextures,...(sceneDescription.gltfOptions ?? {}),});- const firstRanks = await readPartRanks(firstBlob);+ firstRanks = await readPartRanks(firstBlob);activeMap = previewMap;const rendererOptions = sceneDescription.renderer ?? {};@@ -155,54 +178,45 @@ export async function mountHomeAgentHero() {map: activeMap,},});+ } catch (error) {+ window.__heroWorkbench = { error: error.message };+ return;+ }- frame.dataset.live = 'true';- frame.classList.add('is-live-3d');-- // Finish loading full world parts + full HDRI sky- const [restBlobs, fullMap] = await remainingPromise;- if (restBlobs.length > 0) {- const files = [{ parts: firstAsset.parts, ranks: firstRanks }];- for (let i = 0; i < restBlobs.length; i++) {- const baseUrl = new URL('.', new URL(sceneDescription.glbRest[i], location.href)).href;- const restAsset = await loadGltf(restBlobs[i], {- baseUrl,- sharedTextures,- ...(sceneDescription.gltfOptions ?? {}),- });- files.push({ parts: restAsset.parts, ranks: await readPartRanks(restBlobs[i]) });+ // The rest of the world (about 11 MB) and the full sky (about 4 MB) load only once someone+ // engages with the hero, so a visitor who scrolls past pays for the first stage alone.+ let fullWorldRequested = false;+ async function loadFullWorld() {+ if (fullWorldRequested) return;+ fullWorldRequested = true;+ try {+ const restPaths = sceneDescription.glbRest ?? [];+ const fullSkyUrl = new URL(sceneDescription.hdri, location.href).href;+ const [restBlobs, fullMap] = await Promise.all([+ Promise.all(restPaths.map(path => fetchBlob(new URL(path, location.href).href))),+ loadHdri(fullSkyUrl, sceneDescription.hdriOptions ?? {}).catch(() => null),+ ]);+ if (restBlobs.length > 0) {+ const files = [{ parts: firstAsset.parts, ranks: firstRanks }];+ for (let index = 0; index < restBlobs.length; index++) {+ const baseUrl = new URL('.', new URL(restPaths[index], location.href)).href;+ const restAsset = await loadGltf(restBlobs[index], {+ baseUrl,+ sharedTextures,+ ...(sceneDescription.gltfOptions ?? {}),+ });+ files.push({ parts: restAsset.parts, ranks: await readPartRanks(restBlobs[index]) });+ }+ renderer.replaceParts(inWholeWorldOrder(files));}- const allParts = inWholeWorldOrder(files);- renderer.replaceParts(allParts);- }- if (fullMap) {- activeMap = fullMap;+ if (fullMap) activeMap = fullMap;+ } catch (error) {+ window.__heroWorkbench = { ...window.__heroWorkbench, restError: error.message };}- } catch (err) {- window.__heroWorkbench = { error: err.message };- return;}- const initialOrbit = orbitFromCamera(PROMPTS.model.state.eye, PROMPTS.model.state.target);- const current = {- yaw: initialOrbit.yaw,- pitch: initialOrbit.pitch,- distance: initialOrbit.distance,- target: [...initialOrbit.target],- fov: PROMPTS.model.state.fov,- exposure: PROMPTS.model.state.exposure,- inspection: PROMPTS.model.state.inspection,- };- let target = {- yaw: initialOrbit.yaw,- pitch: initialOrbit.pitch,- distance: initialOrbit.distance,- target: [...initialOrbit.target],- fov: PROMPTS.model.state.fov,- exposure: PROMPTS.model.state.exposure,- inspection: PROMPTS.model.state.inspection,- };-+ const current = createOrbitState(PROMPTS.model);+ let target = createOrbitState(PROMPTS.model);let activeKey = 'model';let dragging = false;let userInteracted = false;@@ -210,47 +224,45 @@ export async function mountHomeAgentHero() {let orbitStart = [0, 0];let simTime = 0;let lastNow = performance.now();+ let rafId = 0;+ let heroVisible = true;- const promptEl = document.querySelector('[data-agent-prompt]');+ const promptElement = document.querySelector('[data-agent-prompt]');const presetButtons = [...document.querySelectorAll('[data-prompt-preset]')];+ function markInteracted() {+ userInteracted = true;+ loadFullWorld();+ }+function applyPresetUI(key) {const preset = PROMPTS[key];if (!preset) return;activeKey = key;- const nextOrbit = orbitFromCamera(preset.state.eye, preset.state.target);- target = {- yaw: nextOrbit.yaw,- pitch: nextOrbit.pitch,- distance: nextOrbit.distance,- target: [...nextOrbit.target],- fov: preset.state.fov,- exposure: preset.state.exposure,- inspection: preset.state.inspection,- };- presetButtons.forEach(btn => {- btn.setAttribute('aria-pressed', String(btn.dataset.promptPreset === key));+ target = createOrbitState(preset);+ presetButtons.forEach(button => {+ button.setAttribute('aria-pressed', String(button.dataset.promptPreset === key));});- if (promptEl) promptEl.textContent = preset.prompt;+ if (promptElement) promptElement.textContent = preset.prompt;}- presetButtons.forEach(btn => {- btn.addEventListener('click', () => {- userInteracted = true;- applyPresetUI(btn.dataset.promptPreset);+ presetButtons.forEach(button => {+ button.addEventListener('click', () => {+ markInteracted();+ applyPresetUI(button.dataset.promptPreset);});});const presetKeys = Object.keys(PROMPTS);const autoCycle = setInterval(() => {- if (userInteracted || document.hidden) return;- const nextIdx = (presetKeys.indexOf(activeKey) + 1) % presetKeys.length;- applyPresetUI(presetKeys[nextIdx]);- }, 7500);+ if (userInteracted || document.hidden || !heroVisible) return;+ const nextIndex = (presetKeys.indexOf(activeKey) + 1) % presetKeys.length;+ applyPresetUI(presetKeys[nextIndex]);+ }, AUTO_CYCLE_MS);canvas.addEventListener('pointerdown', event => {dragging = true;- userInteracted = true;+ markInteracted();pointerStart = [event.clientX, event.clientY];orbitStart = [target.yaw, target.pitch];canvas.setPointerCapture?.(event.pointerId);@@ -258,10 +270,10 @@ export async function mountHomeAgentHero() {canvas.addEventListener('pointermove', event => {if (!dragging) return;- const dx = event.clientX - pointerStart[0];- const dy = event.clientY - pointerStart[1];- target.yaw = orbitStart[0] - dx * 0.0055;- target.pitch = Math.max(0.05, Math.min(1.35, orbitStart[1] + dy * 0.0045));+ const deltaX = event.clientX - pointerStart[0];+ const deltaY = event.clientY - pointerStart[1];+ target.yaw = orbitStart[0] - deltaX * 0.0055;+ target.pitch = Math.max(0.05, Math.min(1.35, orbitStart[1] + deltaY * 0.0045));});const endDrag = () => {@@ -278,36 +290,14 @@ export async function mountHomeAgentHero() {const frameDefaults = sceneDescription.frame ?? {};const baseEffects = frameDefaults.effects ?? {};- let rafId = 0;- function tick(now) {- const dt = Math.min(0.05, Math.max(0.001, (now - lastNow) / 1000));- lastNow = now;- simTime += dt;-- const blend = 1 - Math.exp(-dt * 5.2);- if (!dragging) {- target.yaw += dt * 0.018;- }-- current.yaw += (target.yaw - current.yaw) * blend;- current.pitch += (target.pitch - current.pitch) * blend;- current.distance += (target.distance - current.distance) * blend;- for (let i = 0; i < 3; i++) {- current.target[i] += (target.target[i] - current.target[i]) * blend;- }- current.fov += (target.fov - current.fov) * blend;- current.exposure += (target.exposure - current.exposure) * blend;- current.inspection = target.inspection;-- const eye = eyeFromOrbit(current);-+ function renderFrame(time) {renderer.render({...frameDefaults,- eye,+ eye: eyeFromOrbit(current),target: current.target,fov: current.fov,exposure: current.exposure,- time: simTime,+ time,inspection: current.inspection,environment: {...(sceneDescription.renderer?.environment ?? {}),@@ -319,37 +309,63 @@ export async function mountHomeAgentHero() {ambientOcclusionRadius: 4.5,},});+ }++ function tick(now) {+ rafId = 0;+ const deltaSeconds = Math.min(0.05, Math.max(0.001, (now - lastNow) / 1000));+ lastNow = now;+ simTime += deltaSeconds;++ const blend = 1 - Math.exp(-deltaSeconds * 5.2);+ if (!dragging) target.yaw += deltaSeconds * 0.018;++ current.yaw += (target.yaw - current.yaw) * blend;+ current.pitch += (target.pitch - current.pitch) * blend;+ current.distance += (target.distance - current.distance) * blend;+ for (let axis = 0; axis < 3; axis++) {+ current.target[axis] += (target.target[axis] - current.target[axis]) * blend;+ }+ current.fov += (target.fov - current.fov) * blend;+ current.exposure += (target.exposure - current.exposure) * blend;+ current.inspection = target.inspection;+ renderFrame(simTime);+ scheduleTick();+ }++ // Stop drawing while the hero is off screen or the tab is hidden, so the GPU idles while people read.+ function scheduleTick() {+ if (rafId || !heroVisible || document.hidden) return;rafId = requestAnimationFrame(tick);}- renderer.resize();- // Render one synchronous frame before exposing __heroWorkbench so screenshots are guaranteed ready- renderer.render({- ...frameDefaults,- eye: eyeFromOrbit(current),- target: current.target,- fov: current.fov,- exposure: current.exposure,- time: 0,- inspection: current.inspection,- environment: {- ...(sceneDescription.renderer?.environment ?? {}),- map: activeMap,- },- effects: {- ...baseEffects,- ambientOcclusion: 0.55,- ambientOcclusionRadius: 4.5,- },+ const visibilityObserver = new IntersectionObserver(entries => {+ heroVisible = entries.some(entry => entry.isIntersecting);+ lastNow = performance.now();+ scheduleTick();});- rafId = requestAnimationFrame(tick);+ visibilityObserver.observe(frame);+ const onVisibilityChange = () => {+ lastNow = performance.now();+ scheduleTick();+ };+ document.addEventListener('visibilitychange', onVisibilityChange);++ renderer.resize();+ // One synchronous frame before going live, so the canvas never fades in empty.+ renderFrame(0);+ frame.dataset.live = 'true';+ frame.classList.add('is-live-3d');+ scheduleTick();- window.__heroWorkbench = { renderer, applyPresetUI, complete: true };+ window.__heroWorkbench = { renderer, applyPresetUI, loadFullWorld, complete: true };window.addEventListener('pagehide', () => {clearInterval(autoCycle);- cancelAnimationFrame(rafId);+ if (rafId) cancelAnimationFrame(rafId);resizeObserver.disconnect();+ visibilityObserver.disconnect();+ document.removeEventListener('visibilitychange', onVisibilityChange);renderer.dispose();});}diff --git a/src/site.css b/src/site.cssindex fc65765a..ef244b17 100644--- a/src/site.css+++ b/src/site.css@@ -450,26 +450,25 @@ body.site > main > section { scroll-margin-top: 96px; }backdrop-filter: blur(16px) saturate(1.4);}.site .hero-prompt-tabs {- display: grid;- grid-template-columns: repeat(4, minmax(0, 1fr));- gap: 4px;+ display: flex;+ flex-wrap: wrap;+ gap: 2px;}.site .hero-prompt-tabs button {- min-height: 27px;- padding: 3px 6px;+ min-height: 28px;+ padding: 4px 9px;border-radius: 8px;- background: #ffffff0f;+ background: transparent;color: var(--muted);- font-size: 11.5px;+ font-size: 12px;font-weight: 500;white-space: nowrap;- overflow: hidden;- text-overflow: ellipsis;+ user-select: none;}+.site .hero-prompt-tabs button:hover { color: var(--text); }.site .hero-prompt-tabs button[aria-pressed="true"] {- background: var(--primary);- color: var(--primary-text);- font-weight: 600;+ background: #ffffff14;+ color: var(--text);}.site .hero-prompt-text {margin: 0;@@ -483,9 +482,7 @@ body.site > main > section { scroll-margin-top: 96px; }.site .agent-size-bars {display: grid;gap: 8px;- margin-top: 6px;- padding-top: 10px;- border-top: 1px solid #ffffff17;+ margin-top: 14px;}.site .size-bar-row {display: grid;@@ -550,6 +547,5 @@ body.site > main > section { scroll-margin-top: 96px; }max-width: none;}}-@media (max-width: 520px) {- .site .hero-prompt-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }-}+.site .hero-frame:not([data-live="true"]) .hero-prompt { display: none; }+.site .hero-frame:not([data-live="true"]) .hero-viewport { display: none; }