Skip to content

armgit / 67.js

Public Imported from GitHub
0

3D engine that AI agents drive

Move installation above live interactive 3D showcase

Nguyen Xuan An4bd7f7903e2d
diff --git a/index.html b/index.html
index c26b7125..2d1c4599 100644
--- a/index.html
+++ b/index.html
@@ -23,18 +23,6 @@
</aside>
<main id="content">
<header class="introduction"><div><h1>Your 3D scene,<br />from browser to film</h1><p>67.js brings browser 3D, animation and image/video export into one workflow. Create interactive experiences and export the same scene as images or video</p><div class="hero-actions"><a href="./object.html" data-icon="cube">Try the object studio</a><a href="./docs.html#install" data-icon="code">Build your first scene</a></div></div></header>
- <section class="feature-showcase" aria-label="67.js rendered animation showcase"><video controls playsinline preload="none" poster="./previews/motion.webp" width="960" height="540"><source src="./media/clockwork.mp4" type="video/mp4"/><p>Your browser cannot play this film. <a href="./motion.html">Open the interactive scene</a>.</p></video><div class="showcase-caption"><div><h2>Clockwork orbit</h2><p>A real 67.js render. Open the scene to scrub time and change the frame.</p></div><a href="./motion.html" data-icon="film">Explore the scene</a></div></section>
- <section class="workflow" aria-label="What you can build"><div><span data-icon="cube"></span><h3>Build and inspect</h3><p>Shared meshes, materials and cameras. Pull a machine apart, explore a world, or bring your own GLB.</p></div><div><span data-icon="film"></span><h3>Make it move</h3><p>Sample keyframes at any time. Give visitors controls and keep the same timeline for your film.</p></div><div><span data-icon="image"></span><h3>Export the result</h3><p>Produce images and videos on GPU or CPU with explicit render budgets and one capture frame at a time.</p></div></section>
- <section id="examples" class="examples" aria-labelledby="examples-title">
- <h2 id="examples-title">Interactive showcase</h2><p>Explore a machine, a world, a film or your own model</p>
- <div class="gallery">
- <a class="example" href="./object.html"><img src="./previews/wall-e.webp" alt="WALL·E model rendered in 67.js" width="1280" height="720" fetchpriority="high" /><div class="example-caption"><h3>WALL·E</h3><span>Object studio <span aria-hidden="true">↗</span></span></div><p>Explore the exterior or separate 574 parts to inspect the machinery</p></a>
- <a class="example" href="./nature.html"><img src="./previews/nature.webp" alt="A winding stream through Silverwater valley" width="1280" height="720" /><div class="example-caption"><h3>Silverwater valley</h3><span>Nature <span aria-hidden="true">↗</span></span></div><p>Move through the landscape and change the light and wind</p></a>
- <a class="example" href="./film.html"><img src="./previews/film-contact.webp" alt="Scenes from CRITICAL, a procedural 3D short film" width="1280" height="720" loading="lazy" /><div class="example-caption"><h3>CRITICAL</h3><span>Short film <span aria-hidden="true">↗</span></span></div><p>Watch a deterministic film with an original synthesized score</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><span>2D and views <span aria-hidden="true">↗</span></span></div><p>Pan a vector scene or inspect a model from front, right and top</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><span>GLB assets <span aria-hidden="true">↗</span></span></div><p>Open a GLB, inspect its materials and sample node animation</p></a>
- </div>
- </section>
<section id="downloads" class="downloads" aria-labelledby="downloads-title">
<div class="section-heading"><h2 id="downloads-title">Downloads</h2><span data-release-version>Loading release</span></div>
<p>Choose your package manager and install the current release</p>
@@ -52,6 +40,24 @@
</div>
<div class="release-links"><a href="./docs.html">Documentation</a><a href="./logo.svg" download>Logo SVG</a><a href="./changelog.md">Changelog</a><span data-release-commit>Release commit</span><a data-release-api aria-disabled="true">API reference ↗</a></div>
</section>
+ <section class="feature-showcase live-showcase" aria-label="Interactive 3D preview">
+ <canvas id="home-preview" tabindex="0" aria-label="Clockwork 3D model. Drag or use arrow keys to rotate. Use plus and minus to zoom."></canvas>
+ <p id="home-preview-status" role="status">Loading 3D preview…</p>
+ <div class="preview-tools" role="group" aria-label="3D preview controls"><button id="preview-play" aria-pressed="false">Animate</button><button id="preview-zoom-in" aria-label="Zoom in">+</button><button id="preview-zoom-out" aria-label="Zoom out">−</button><button id="preview-reset">Reset view</button></div>
+ <div class="showcase-caption"><div><h2>Clockwork orbit</h2><p>Live 3D in your browser. Drag to rotate, zoom in and animate the mechanism.</p></div><a href="./motion.html" data-icon="cube">Open the full studio</a></div>
+ </section>
+ <section class="workflow" aria-label="What you can build"><div><span data-icon="cube"></span><h3>Build and inspect</h3><p>Shared meshes, materials and cameras. Pull a machine apart, explore a world, or bring your own GLB.</p></div><div><span data-icon="film"></span><h3>Make it move</h3><p>Sample keyframes at any time. Give visitors controls and keep the same timeline for your film.</p></div><div><span data-icon="image"></span><h3>Export the result</h3><p>Produce images and videos on GPU or CPU with explicit render budgets and one capture frame at a time.</p></div></section>
+ <section id="examples" class="examples" aria-labelledby="examples-title">
+ <h2 id="examples-title">Interactive showcase</h2><p>Explore a machine, a world, a film or your own model</p>
+ <div class="gallery">
+ <a class="example" href="./object.html"><img src="./previews/wall-e.webp" alt="WALL·E model rendered in 67.js" width="1280" height="720" fetchpriority="high" /><div class="example-caption"><h3>WALL·E</h3><span>Object studio <span aria-hidden="true">↗</span></span></div><p>Explore the exterior or separate 574 parts to inspect the machinery</p></a>
+ <a class="example" href="./nature.html"><img src="./previews/nature.webp" alt="A winding stream through Silverwater valley" width="1280" height="720" /><div class="example-caption"><h3>Silverwater valley</h3><span>Nature <span aria-hidden="true">↗</span></span></div><p>Move through the landscape and change the light and wind</p></a>
+ <a class="example" href="./film.html"><img src="./previews/film-contact.webp" alt="Scenes from CRITICAL, a procedural 3D short film" width="1280" height="720" loading="lazy" /><div class="example-caption"><h3>CRITICAL</h3><span>Short film <span aria-hidden="true">↗</span></span></div><p>Watch a deterministic film with an original synthesized score</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><span>2D and views <span aria-hidden="true">↗</span></span></div><p>Pan a vector scene or inspect a model from front, right and top</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><span>GLB assets <span aria-hidden="true">↗</span></span></div><p>Open a GLB, inspect its materials and sample node animation</p></a>
+ </div>
+ </section>
+
</main>
<script type="module" src="/src/home.js"></script>
</body>
diff --git a/scripts/smoke-site.mjs b/scripts/smoke-site.mjs
index 2a0f3914..1772551b 100644
--- a/scripts/smoke-site.mjs
+++ b/scripts/smoke-site.mjs
@@ -52,6 +52,8 @@ try {
assert.equal(await page.locator('.navigation a[href*="getting-started.html"]').count(), 0, 'Getting started still has separate navigation');
}
if (route === '/') {
+ assert.equal(await page.locator('video').count(), 0, 'Homepage still embeds video');
+ assert.ok(await page.evaluate(() => document.querySelector('#downloads').compareDocumentPosition(document.querySelector('.live-showcase')) & Node.DOCUMENT_POSITION_FOLLOWING));
assert.equal(await page.locator('[data-package-manager]').count(), 4);
assert.equal(await page.locator('[data-release-tarball], [data-release-module]').count(), 0);
const scenePaths = await page.locator('.gallery .example').evaluateAll(links => links.map(link => new URL(link.href).pathname));
@@ -67,6 +69,24 @@ try {
assert.equal(await page.evaluate(() => window.__copiedText), expectedCommand);
}
report.interactions.push('Unified package managers, unique showcase scenes and synchronized Downloads navigation');
+ await page.locator('#home-preview').scrollIntoViewIfNeeded();
+ await page.waitForFunction(() => window.__homePreview?.renderer && window.__homePreview.state.visible);
+ const initialDistance = await page.evaluate(() => window.__homePreview.state.distance);
+ await page.locator('#preview-zoom-in').click();
+ assert.ok(await page.evaluate(() => window.__homePreview.state.distance) < initialDistance);
+ await page.locator('#home-preview').focus();
+ await page.keyboard.press('ArrowRight');
+ assert.ok(await page.evaluate(() => window.__homePreview.state.yaw) > 0.6);
+ await page.locator('#preview-reset').click();
+ assert.equal(await page.evaluate(() => window.__homePreview.state.yaw), 0.6);
+ await page.locator('#preview-play').click();
+ await page.waitForFunction(() => window.__homePreview.state.time > 3.1);
+ await page.locator('#preview-play').click();
+ assert.equal(await page.evaluate(() => window.__homePreview.state.playing), false);
+ assert.equal(await page.evaluate(() => window.__homePreview.renderer.context.getError()), 0);
+ assert.ok(await page.evaluate(() => window.__homePreview.renderer.memoryPlan.estimatedBytes) <= 192 * 1048576);
+ await page.screenshot({ path:'artifacts/home-live-preview.png' });
+ report.interactions.push('Live homepage 3D, keyboard rotation, zoom, reset and animation');
}
if (route === '/getting-started.html') {
assert.match(page.url(), /\/docs(?:\.html)?#install$/);
diff --git a/src/home-preview.js b/src/home-preview.js
new file mode 100644
index 00000000..8cb04895
--- /dev/null
+++ b/src/home-preview.js
@@ -0,0 +1,186 @@
+import { Renderer67 } from './renderer.js';
+import { createMotionScene } from './motion.js';
+
+const canvas = document.querySelector('#home-preview');
+const status = document.querySelector('#home-preview-status');
+const playButton = document.querySelector('#preview-play');
+const reducedMotion = matchMedia('(prefers-reduced-motion: reduce)');
+const state = { yaw:0.6, pitch:0.28, distance:8, time:3, playing:false, visible:false };
+let renderer;
+let scene;
+let scheduledFrame = 0;
+let previousTime = 0;
+let pointer;
+let disposed = false;
+
+function showError(error) {
+ state.playing = false;
+ playButton.setAttribute('aria-pressed', 'false');
+ playButton.textContent = 'Animate';
+ status.hidden = false;
+ status.textContent = `3D preview unavailable: ${error.message}. Open the full studio to retry.`;
+ cancelAnimationFrame(scheduledFrame);
+ scheduledFrame = 0;
+}
+
+function draw() {
+ if (!renderer || disposed || document.hidden || !state.visible) return;
+ try {
+ const frame = scene.sample(state.time);
+ renderer.updateParts(scene.parts);
+ const distance = state.distance * (canvas.clientWidth < 500 ? 1.25 : 1);
+ renderer.render({
+ eye:[Math.sin(state.yaw) * Math.cos(state.pitch) * distance, Math.sin(state.pitch) * distance, Math.cos(state.yaw) * Math.cos(state.pitch) * distance],
+ target:[0,0.1,0], fov:40, time:state.time, exposure:1, effects:frame.effects,
+ });
+ } catch (error) {
+ showError(error);
+ }
+}
+
+function animate(timestamp) {
+ scheduledFrame = 0;
+ if (!state.playing || !state.visible || document.hidden || disposed) return;
+ if (!previousTime || timestamp - previousTime >= 1000 / 24) {
+ state.time = (state.time + (previousTime ? Math.min(0.1, (timestamp - previousTime) / 1000) : 0)) % scene.duration;
+ previousTime = timestamp;
+ draw();
+ }
+ if (state.playing) scheduledFrame = requestAnimationFrame(animate);
+}
+
+function synchronizePlayback() {
+ cancelAnimationFrame(scheduledFrame);
+ scheduledFrame = 0;
+ previousTime = 0;
+ if (state.playing && state.visible && !document.hidden && !disposed) {
+ scheduledFrame = requestAnimationFrame(animate);
+ }
+}
+
+function initialize() {
+ if (renderer || disposed) return;
+ try {
+ scene = createMotionScene();
+ renderer = new Renderer67(canvas, scene.parts, {
+ ground:false, hdr:true, samples:4, pixelRatio:1.25, memoryBudgetMiB:192,
+ });
+ window.__homePreview = { renderer, scene, state, draw };
+ status.hidden = true;
+ draw();
+ } catch (error) {
+ showError(error);
+ }
+}
+
+function zoom(multiplier) {
+ state.distance = Math.max(4.5, Math.min(14, state.distance * multiplier));
+ draw();
+}
+
+function reset() {
+ Object.assign(state, { yaw:0.6, pitch:0.28, distance:8 });
+ draw();
+}
+
+playButton.addEventListener('click', () => {
+ if (!renderer) return;
+ state.playing = !state.playing;
+ playButton.setAttribute('aria-pressed', String(state.playing));
+ playButton.textContent = state.playing ? 'Pause' : 'Animate';
+ synchronizePlayback();
+});
+document.querySelector('#preview-zoom-in').addEventListener('click', () => zoom(0.85));
+document.querySelector('#preview-zoom-out').addEventListener('click', () => zoom(1.15));
+document.querySelector('#preview-reset').addEventListener('click', reset);
+canvas.addEventListener('pointerdown', event => {
+ if (event.button !== 0 || pointer) return;
+ pointer = { id:event.pointerId, x:event.clientX, y:event.clientY };
+ canvas.setPointerCapture(event.pointerId);
+});
+canvas.addEventListener('pointermove', event => {
+ if (!pointer || pointer.id !== event.pointerId) return;
+ state.yaw -= (event.clientX - pointer.x) * 0.008;
+ if (event.pointerType !== 'touch') {
+ state.pitch = Math.max(-1.1, Math.min(1.1, state.pitch + (event.clientY - pointer.y) * 0.008));
+ }
+ pointer.x = event.clientX;
+ pointer.y = event.clientY;
+ draw();
+});
+canvas.addEventListener('lostpointercapture', () => { pointer = undefined; });
+canvas.addEventListener('pointercancel', () => { pointer = undefined; });
+canvas.addEventListener('pointerup', event => {
+ if (canvas.hasPointerCapture(event.pointerId)) canvas.releasePointerCapture(event.pointerId);
+ pointer = undefined;
+});
+canvas.addEventListener('wheel', event => {
+ if (!renderer) return;
+ event.preventDefault();
+ zoom(Math.exp(Math.max(-100, Math.min(100, event.deltaY)) * 0.002));
+}, { passive:false });
+canvas.addEventListener('keydown', event => {
+ if (!['ArrowLeft','ArrowRight','ArrowUp','ArrowDown','+','=','-','Home'].includes(event.key)) return;
+ event.preventDefault();
+ if (event.key === 'ArrowLeft') state.yaw -= 0.12;
+ if (event.key === 'ArrowRight') state.yaw += 0.12;
+ if (event.key === 'ArrowUp') state.pitch = Math.min(1.1, state.pitch + 0.12);
+ if (event.key === 'ArrowDown') state.pitch = Math.max(-1.1, state.pitch - 0.12);
+ if (['+','='].includes(event.key)) zoom(0.85);
+ if (event.key === '-') zoom(1.15);
+ if (event.key === 'Home') reset();
+ draw();
+});
+canvas.addEventListener('webglcontextlost', event => {
+ event.preventDefault();
+ showError(new Error('Graphics context was lost'));
+});
+canvas.addEventListener('webglcontextrestored', () => {
+ renderer?.dispose();
+ renderer = undefined;
+ if (state.visible) initialize();
+});
+
+const resizeObserver = new ResizeObserver(() => {
+ if (!renderer || disposed) return;
+ try {
+ renderer.resize();
+ draw();
+ } catch (error) {
+ showError(error);
+ }
+});
+resizeObserver.observe(canvas);
+const visibilityObserver = new IntersectionObserver(entries => {
+ state.visible = entries[0].isIntersecting;
+ if (state.visible) {
+ initialize();
+ draw();
+ }
+ synchronizePlayback();
+}, { threshold:0.05 });
+visibilityObserver.observe(canvas);
+document.addEventListener('visibilitychange', () => {
+ if (!document.hidden) draw();
+ synchronizePlayback();
+});
+reducedMotion.addEventListener('change', () => {
+ if (!reducedMotion.matches) return;
+ state.playing = false;
+ playButton.setAttribute('aria-pressed', 'false');
+ playButton.textContent = 'Animate';
+ synchronizePlayback();
+});
+window.addEventListener('pagehide', event => {
+ cancelAnimationFrame(scheduledFrame);
+ scheduledFrame = 0;
+ if (event.persisted) return;
+ disposed = true;
+ resizeObserver.disconnect();
+ visibilityObserver.disconnect();
+ renderer?.dispose();
+});
+window.addEventListener('pageshow', () => {
+ draw();
+ synchronizePlayback();
+});
diff --git a/src/home.css b/src/home.css
index ab37869a..02efeece 100644
--- a/src/home.css
+++ b/src/home.css
@@ -126,7 +126,14 @@ button:hover { background:var(--border); }
.hero-actions a { padding:12px 18px; border-radius:var(--radius); background:var(--text); color:var(--window); font-size:14px; }
.hero-actions a+ a { background:var(--bg); color:var(--text); border:1px solid var(--border); }
.feature-showcase { margin:26px 0 42px; border-radius:var(--panel-radius); background:#171717; overflow:hidden; position:relative; }
-.feature-showcase video { display:block; width:100%; aspect-ratio:16/9; background:#171717; }
+.live-showcase canvas { display:block; width:100%; height:clamp(280px,42vw,540px); touch-action:pan-y; cursor:grab; }
+.live-showcase canvas:active { cursor:grabbing; }
+.live-showcase canvas:focus-visible { outline-offset:-4px; }
+.preview-tools { display:flex; flex-wrap:wrap; justify-content:center; gap:8px; padding:16px; }
+.preview-tools button { min-height:40px; background:#2f2f2f; color:#ececec; }
+.preview-tools button[aria-pressed=true] { background:#ececec; color:#171717; }
+#home-preview-status { position:absolute; top:20px; left:20px; right:20px; margin:0; font-size:13px; color:#ececec; pointer-events:none; }
+main > .downloads { margin:28px 0 36px; }
.showcase-caption { display:flex; justify-content:space-between; flex-wrap:wrap; gap:16px; padding:22px 24px; color:#ececec; }
.showcase-caption p { margin:6px 0 0; color:#b4b4b4; }
.showcase-caption a { align-self:center; border-radius:var(--radius); padding:12px 18px; background:#ececec; color:#171717; font-size:14px; }
diff --git a/src/home.js b/src/home.js
index ab3f473f..b4c078c9 100644
--- a/src/home.js
+++ b/src/home.js
@@ -116,7 +116,8 @@ if (downloads) {
const libraryLinks = [...document.querySelectorAll('.navigation nav a')];
let navigationPending = false;
function updateNavigation() {
- const activeHash = downloads.getBoundingClientRect().top <= innerHeight * 0.6 ? '#downloads' : '#examples';
+ const bounds = downloads.getBoundingClientRect();
+ const activeHash = bounds.top <= innerHeight * 0.6 && bounds.bottom > 0 ? '#downloads' : '#examples';
for (const link of libraryLinks) {
if (new URL(link.href).hash === activeHash) {
link.setAttribute('aria-current', 'location');
@@ -163,3 +164,9 @@ document.querySelectorAll('.example img').forEach(image => {
window.__home = { state, loadRelease };
loadRelease();
window.addEventListener('pageshow', event => { if (event.persisted) loadRelease(); });
+
+if (document.querySelector('#home-preview')) {
+ import('./home-preview.js').catch(() => {
+ document.querySelector('#home-preview-status').textContent = '3D preview could not load. Reload the page to retry.';
+ });
+}