Skip to content

armgit / 67.js

Public Imported from GitHub
0

3D engine that AI agents drive

Add the showcase page and point the home gallery at it

Nguyen Xuan An53318837da54
diff --git a/changes/showcase.md b/changes/showcase.md
new file mode 100644
index 00000000..1f4fdbe0
--- /dev/null
+++ b/changes/showcase.md
@@ -0,0 +1 @@
+- Add a showcase page (`showcase.html`) of live scenes built from real PBR models: an airport ramp, an AI data center and a container port, each a GLB with a Poly Haven sky and credits in `public/showcase/<id>/scene.json`. The home page gallery shows these scenes instead of the older demos.
diff --git a/index.html b/index.html
index 3309f7e3..2aeb50d7 100644
--- a/index.html
+++ b/index.html
@@ -86,23 +86,14 @@ renderer.render({
</section>
<section id="examples" class="examples" aria-labelledby="examples-title">
- <h2 id="examples-title">Rendered by the engine</h2>
+ <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>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>Humanoid retargeting</li><li>GLB import and export</li><li>PNG and MP4 export</li>
</ul>
<div class="gallery">
- <a class="example" href="./object.html"><img src="./previews/wall-e.webp" alt="WALL·E model rendered in 67js" width="1280" height="720" loading="lazy" /><div class="example-caption"><h3>WALL·E</h3></div><p>574 parts you can pull apart</p></a>
- <a class="example" href="./nature.html"><img src="./previews/nature.webp" alt="A winding stream through Silverwater valley" width="1280" height="720" loading="lazy" /><div class="example-caption"><h3>Silverwater valley</h3></div><p>Light, wind and fog in a landscape</p></a>
- <a class="example" href="./film.html"><img src="./previews/film-contact.webp" alt="Scenes from the Oppenheimer 3D trailer study rendered in 67js" width="1280" height="720" loading="lazy" /><div class="example-caption"><h3>Oppenheimer</h3></div><p>A short film on one timeline</p></a>
- <a class="example" href="./modeling.html"><img src="./previews/modeling.webp" alt="A porcelain and brass lantern built with profile, extrusion and curve tools" width="1280" height="720" loading="lazy" /><div class="example-caption"><h3>Aster lantern</h3></div><p>Modeling from profiles and curves</p></a>
- <a class="example" href="./view2d.html"><img src="./previews/view2d.webp" alt="A flat orbital poster rendered through an orthographic camera" width="960" height="540" loading="lazy" /><div class="example-caption"><h3>Orbital field</h3></div><p>Orthographic and 2D views</p></a>
- <a class="example" href="./assets.html"><img src="./previews/assets.webp" alt="An imported geometric study displayed in the asset viewer" width="960" height="540" loading="lazy" /><div class="example-caption"><h3>Your models</h3></div><p>Open a GLB and play its clips</p></a>
- <a class="example" href="./terrain.md"><img src="./previews/terrain.webp" alt="Rolling hills of scanned grass and mud rising to rocky ridges under a cloudy sky" width="1280" height="720" loading="lazy" /><div class="example-caption"><h3>Terrain</h3></div><p>Scanned ground layers blended by slope and height</p></a>
- <a class="example" href="./vegetation.md"><img src="./previews/forest.webp" alt="Birch, beech and fir trees with scanned leaves over a grassy slope" width="1280" height="720" loading="lazy" /><div class="example-caption"><h3>Forest</h3></div><p>Seeded trees with scanned leaves and bark</p></a>
- <a class="example" href="./grass.md"><img src="./previews/grass.webp" alt="A meadow of clumped grass blades with a path, in front of a tree line" width="1280" height="720" loading="lazy" /><div class="example-caption"><h3>Grass</h3></div><p>Clumped blades that roll in the wind</p></a>
- <a class="example" href="./spume.md"><img src="./previews/spume.webp" alt="A jet of baked liquid hitting a concrete slab, refracting the columns behind it" width="1280" height="720" loading="lazy" /><div class="example-caption"><h3>Spume liquid</h3></div><p>Baked water that refracts and sprays</p></a>
- <a class="example" href="./vehicle.md"><img src="./previews/vehicle.webp" alt="A jeep leaning into a bend as it follows a marked path" width="1280" height="720" loading="lazy" /><div class="example-caption"><h3>Vehicles</h3></div><p>Steering, roll and wheels on a path</p></a>
- <a class="example" href="./lighting.md"><img src="./previews/lighting.webp" alt="Metal spheres of rising roughness lit by an HDR environment" width="1280" height="720" loading="lazy" /><div class="example-caption"><h3>HDRI lighting</h3></div><p>Reflections that blur with roughness</p></a>
+ <a class="example" href="./showcase.html?scene=airport"><img src="./previews/showcase-airport.webp" alt="Airport ramp, rendered by 67js" width="1280" height="720" loading="lazy" /><div class="example-caption"><h3>Airport ramp</h3></div><p>A widebody at the stand with its service trucks</p></a>
+ <a class="example" href="./showcase.html?scene=datacenter"><img src="./previews/showcase-datacenter.webp" alt="AI data center, rendered by 67js" width="1280" height="720" loading="lazy" /><div class="example-caption"><h3>AI data center</h3></div><p>Rows of racks, power and cooling, cut open</p></a>
+ <a class="example" href="./showcase.html?scene=port"><img src="./previews/showcase-port.webp" alt="Container port, rendered by 67js" width="1280" height="720" loading="lazy" /><div class="example-caption"><h3>Container port</h3></div><p>A ship at berth under the quay cranes</p></a>
</div>
</section>
diff --git a/scripts/smoke-site.mjs b/scripts/smoke-site.mjs
index 2addd8e9..de1359f3 100644
--- a/scripts/smoke-site.mjs
+++ b/scripts/smoke-site.mjs
@@ -66,7 +66,7 @@ try {
if (route === '/') {
assert.equal(await page.locator('video').count(), 0, 'Homepage still embeds video');
assert.equal(await page.locator('#downloads').count(), 1, 'Homepage install controls are missing');
- const scenePaths = await page.locator('.gallery .example').evaluateAll(links => links.map(link => new URL(link.href).pathname));
+ const scenePaths = await page.locator('.gallery .example').evaluateAll(links => links.map(link => { const url = new URL(link.href); return url.pathname + url.search; }));
assert.equal(new Set(scenePaths).size, scenePaths.length, 'Showcase repeats the same scene');
await page.locator('#home-preview').scrollIntoViewIfNeeded();
await page.waitForFunction(() => window.__homePreview?.renderer && window.__homePreview.state.visible);
diff --git a/showcase.html b/showcase.html
new file mode 100644
index 00000000..fa05e9a4
--- /dev/null
+++ b/showcase.html
@@ -0,0 +1,45 @@
+<!doctype html>
+<html lang="en">
+ <head>
+ <meta charset="UTF-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+ <meta name="description" content="Live 67js scenes: an airport ramp, an AI data center and a container port, built from real PBR models and rendered in the browser." />
+ <link rel="canonical" href="https://67js.codepawl.com/showcase.html" />
+ <title>Showcase · 67js</title>
+ <link rel="icon" href="/favicon.svg" />
+ </head>
+ <body class="site showcase">
+ <a class="skip-link" href="#content">Skip to content</a>
+ <header class="navigation">
+ <a class="brand" href="/" aria-label="67js home">67js</a>
+ <nav aria-label="Library">
+ <a href="/docs.html">Docs</a>
+ </nav>
+ <a class="site-nav-cta" href="https://github.com/anxuanng/67.js"><span class="package-logo package-logo-github" aria-hidden="true"></span>GitHub</a>
+ </header>
+ <main id="content">
+ <section class="showcase-stage" aria-labelledby="showcase-title">
+ <div class="showcase-head">
+ <div>
+ <h1 id="showcase-title">Showcase</h1>
+ <p id="showcase-blurb"></p>
+ </div>
+ <div id="showcase-tabs" class="showcase-tabs" role="group" aria-label="Scene"></div>
+ </div>
+ <div class="showcase-frame">
+ <canvas id="showcase-viewport" tabindex="0" aria-label="Live 3D scene. Drag to orbit, scroll to zoom."></canvas>
+ <p id="showcase-status" role="status">◷ Loading the scene…</p>
+ </div>
+ <details class="showcase-credits">
+ <summary>Models and licences</summary>
+ <ul id="showcase-credits"></ul>
+ </details>
+ </section>
+ </main>
+ <footer class="site-footer" aria-label="Site footer">
+ <p><a class="brand" href="/" aria-label="67js home">67js</a> by <a href="https://codepawl.com">CodePawl</a></p>
+ <nav class="footer-links" aria-label="Project links"><a href="https://github.com/anxuanng/67.js">GitHub</a><a href="https://www.npmjs.com/package/@codepawlhq/67js">npm</a><a href="/changelog.md">Changelog</a><a href="/license.txt">MIT license</a></nav>
+ </footer>
+ <script type="module" src="/src/showcase.js"></script>
+ </body>
+</html>
diff --git a/src/showcase.css b/src/showcase.css
new file mode 100644
index 00000000..35c99823
--- /dev/null
+++ b/src/showcase.css
@@ -0,0 +1,18 @@
+/* The showcase page: one live scene at a time, picked with quiet text tabs. */
+.showcase-stage { display: grid; gap: 16px; }
+.showcase-head { display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 16px 24px; }
+.showcase-head > div:first-child { display: grid; gap: 10px; }
+.showcase-head p { color: var(--muted); font-size: 17px; }
+.showcase-tabs { display: flex; flex-wrap: wrap; gap: 4px; }
+.site .showcase-tabs button { min-height: 36px; padding: 6px 14px; background: transparent; color: var(--muted); font-size: 14px; }
+.site .showcase-tabs button:hover { background: var(--bg); color: var(--text); }
+.site .showcase-tabs button[aria-pressed=true] { background: var(--surface); color: var(--text); }
+.showcase-frame { position: relative; overflow: hidden; border-radius: var(--panel-radius); background: var(--surface); }
+#showcase-viewport { display: block; width: 100%; height: clamp(360px, 62vh, 760px); touch-action: none; cursor: grab; }
+#showcase-viewport:active { cursor: grabbing; }
+#showcase-status { position: absolute; inset: auto 16px 16px 16px; margin: 0; color: var(--muted); font-size: 14px; pointer-events: none; }
+#showcase-status[data-failed=true] { color: var(--error); }
+.showcase-credits { color: var(--muted); font-size: 14px; }
+.showcase-credits summary { cursor: pointer; width: max-content; }
+.showcase-credits ul { margin: 10px 0 0; padding-left: 18px; display: grid; gap: 4px; }
+.showcase-credits a { color: var(--text); text-decoration: underline; }
diff --git a/src/showcase.js b/src/showcase.js
new file mode 100644
index 00000000..99c6ddff
--- /dev/null
+++ b/src/showcase.js
@@ -0,0 +1,148 @@
+import './site.css';
+import './brand.js';
+import './showcase.css';
+import { Renderer67 } from './renderer.js';
+import { loadGltf } from './gltf.js';
+import { loadHdri } from './hdri.js';
+import { createCascadedShadows } from './cascaded-shadows.js';
+
+// Each scene lives in public/showcase/<id>/scene.json: its GLB, sky, camera, renderer and frame options, and credits.
+const SCENE_LABELS = { airport: 'Airport ramp', datacenter: 'AI data center', port: 'Container port' };
+const SCENE_IDS = Object.keys(SCENE_LABELS);
+
+const canvas = document.querySelector('#showcase-viewport');
+const status = document.querySelector('#showcase-status');
+const tabs = document.querySelector('#showcase-tabs');
+const title = document.querySelector('#showcase-title');
+const blurb = document.querySelector('#showcase-blurb');
+const creditList = document.querySelector('#showcase-credits');
+const orbit = { yaw: 0, pitch: 0, distance: 1, target: [0, 0, 0] };
+let renderer = null;
+let scene = null;
+let loadingRequest = 0;
+let scheduledFrame = 0;
+let pointer = null;
+
+function showStatus(message, failed = false) {
+ status.hidden = false;
+ status.dataset.failed = failed ? 'true' : 'false';
+ status.textContent = `${failed ? '⚠' : '◷'} ${message}`;
+}
+
+function orbitFromCamera(eye, target) {
+ const offset = eye.map((value, axis) => value - target[axis]);
+ const distance = Math.hypot(...offset);
+ orbit.target = [...target];
+ orbit.distance = distance;
+ orbit.yaw = Math.atan2(offset[0], offset[2]);
+ orbit.pitch = Math.asin(offset[1] / distance);
+}
+
+function eyeFromOrbit() {
+ const horizontal = Math.cos(orbit.pitch) * orbit.distance;
+ return [
+ orbit.target[0] + Math.sin(orbit.yaw) * horizontal,
+ orbit.target[1] + Math.sin(orbit.pitch) * orbit.distance,
+ orbit.target[2] + Math.cos(orbit.yaw) * horizontal,
+ ];
+}
+
+function draw() {
+ scheduledFrame = 0;
+ if (!renderer || !scene) return;
+ renderer.render({ ...scene.frame, eye: eyeFromOrbit(), target: orbit.target });
+}
+
+function requestDraw() {
+ if (!scheduledFrame) scheduledFrame = requestAnimationFrame(draw);
+}
+
+function renderTabs() {
+ for (const id of SCENE_IDS) {
+ const button = document.createElement('button');
+ button.type = 'button';
+ button.dataset.scene = id;
+ button.textContent = SCENE_LABELS[id];
+ button.addEventListener('click', () => selectScene(id));
+ tabs.append(button);
+ }
+}
+
+async function readDescription(id) {
+ const response = await fetch(`/showcase/${id}/scene.json`);
+ if (!response.ok) throw new Error(`scene ${id} is not available (${response.status})`);
+ return response.json();
+}
+
+function showCredits(credits = []) {
+ creditList.replaceChildren(...credits.map(credit => {
+ const item = document.createElement('li');
+ const link = document.createElement('a');
+ link.href = credit.source;
+ link.textContent = credit.model;
+ item.append(link, ` by ${credit.author}, ${credit.licence}`);
+ return item;
+ }));
+}
+
+async function selectScene(id) {
+ const request = ++loadingRequest;
+ history.replaceState(null, '', `?scene=${id}`);
+ for (const button of tabs.querySelectorAll('button')) button.setAttribute('aria-pressed', String(button.dataset.scene === id));
+ showStatus('Loading the scene…');
+ try {
+ const description = await readDescription(id);
+ title.textContent = description.title;
+ blurb.textContent = description.blurb;
+ showCredits(description.credits);
+ const [asset, map] = await Promise.all([
+ loadGltf(description.glb),
+ loadHdri(description.hdri, description.hdriOptions ?? {}),
+ ]);
+ if (request !== loadingRequest) return;
+ renderer?.dispose();
+ const rendererOptions = description.renderer ?? {};
+ // scene.json stores cascades as plain options; the renderer takes the cascade object built from them.
+ const shadowCascades = rendererOptions.shadowCascades ? createCascadedShadows(rendererOptions.shadowCascades) : undefined;
+ renderer = new Renderer67(canvas, asset.parts, {
+ ground: false, hdr: true, samples: 4, memoryBudgetMiB: 384,
+ ...rendererOptions,
+ shadowCascades,
+ environment: { ...(rendererOptions.environment ?? {}), map },
+ });
+ scene = { frame: { exposure: description.exposure ?? 1, ...(description.frame ?? {}) } };
+ orbitFromCamera(description.eye, description.target);
+ window.__showcase = { renderer, scene, orbit, draw };
+ status.hidden = true;
+ requestDraw();
+ } catch (error) {
+ if (request === loadingRequest) showStatus(`Could not open this scene: ${error.message}`, true);
+ }
+}
+
+canvas.addEventListener('pointerdown', event => {
+ pointer = { x: event.clientX, y: event.clientY };
+ canvas.setPointerCapture(event.pointerId);
+});
+canvas.addEventListener('pointermove', event => {
+ if (!pointer) return;
+ orbit.yaw -= (event.clientX - pointer.x) * 0.005;
+ orbit.pitch = Math.max(0.05, Math.min(1.45, orbit.pitch + (event.clientY - pointer.y) * 0.004));
+ pointer = { x: event.clientX, y: event.clientY };
+ requestDraw();
+});
+canvas.addEventListener('pointerup', () => { pointer = null; });
+canvas.addEventListener('pointercancel', () => { pointer = null; });
+canvas.addEventListener('wheel', event => {
+ event.preventDefault();
+ orbit.distance *= Math.exp(event.deltaY * 0.001);
+ requestDraw();
+}, { passive: false });
+window.addEventListener('resize', () => {
+ renderer?.resize();
+ requestDraw();
+});
+
+renderTabs();
+const requested = new URLSearchParams(location.search).get('scene');
+selectScene(SCENE_IDS.includes(requested) ? requested : SCENE_IDS[0]);
diff --git a/src/site.css b/src/site.css
index 42ec4902..79638f02 100644
--- a/src/site.css
+++ b/src/site.css
@@ -240,3 +240,6 @@ body.site > main { flex: 1; width: var(--page); margin-inline: auto; padding-blo
.site .agent-cards a:hover { background: var(--border); }
}
.site .site-footer p { display: flex; align-items: center; gap: 5px; }
+.site .section-heading { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 8px 20px; }
+.site .section-heading a { color: var(--muted); font-size: 15px; }
+.site .section-heading a:hover { color: var(--text); text-decoration: underline; }
diff --git a/vite.config.js b/vite.config.js
index 2439bc44..50db8eef 100644
--- a/vite.config.js
+++ b/vite.config.js
@@ -24,6 +24,7 @@ export default defineConfig({
assets: 'assets.html',
guide: 'getting-started.html',
docs: 'docs.html',
+ showcase: 'showcase.html',
},
},
},