kwakseongjae/oh-my-design / skills/omd-3d-hero
omd-3d-hero
VerifiedA rendered 3D hero from the project's DESIGN.md: a soft-lit studio (cyclorama, contact shadows, ambient occlusion) with a floating pile of brand-colored objects shaped by the radius tokens, and the headline in real DOM text. On desktop the pile is live (the cursor pushes it, a click scatters it, setSpec() morphs it into another brand or between the light and dark schemes) and a hard plane keeps every object out of the copy column. Two engines from one spec: three.js in the browser (default) or headless Blender (Cycles poster + EEVEE loop) from the same settled poses. Poster first: phones, reduced motion and no-WebGL get the still. Never invents colors or shapes; verifies five paths on a real GPU, including a pointer sweep that measures contrast and clearance. Use for a launch page, product hero, campaign or showcase first screen that should look rendered, not drawn. Triggers: '3D 히어로', '블렌더 느낌 배경', '3D 배경 만들어줘', 'three.js 히어로', '렌더 느낌 첫 화면', '클레이 렌더 배경', 'Blender style hero', '3D hero from DESIGN.md', 'three.js background', 'studio render hero', '3Dヒーロー', 'Blender風の背景', '3D 主視覺'. Two flat brand inks instead of light and depth → omd-shader-hero. A CJK headline effect → omd-cjk-type-shader. Product renders from a parts list are out of scope. No DESIGN.md → omd-init first.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 23.0 KB |
| engines/blender/scene.py | script | 9.8 KB |
| engines/three/pile.js | script | 12.6 KB |
| engines/three/scene.js | script | 19.2 KB |
| examples/hero.html | other | 6.2 KB |
| scripts/blender.mjs | script | 3.1 KB |
| scripts/spec.mjs | script | 15.2 KB |
| scripts/verify.mjs | script | 16.7 KB |
scripts/verify.mjs
View on GitHub#!/usr/bin/env node
// omd-3d-hero real-GPU proof. Same four passes as omd-shader-hero/scripts/verify.mjs, plus the checks a live
// 3D scene needs: the poster is on screen before the canvas, frame time on the GPU pass, and an interaction
// sweep (the pointer drags across the pile and into the copy column, then clicks) during which no object may
// reach the headline and contrast is measured on every sampled frame.
//
// node verify.mjs <hero.html|url> <outDir> [--steps 8] [--headed]
// node verify.mjs <hero.html|url> --bake poster.webp # three branch: still of the live scene at t=0
//
// Needs playwright-core (`npm i -D playwright-core && npx playwright-core install chromium`).
// Set PW_CORE=<dir containing node_modules/playwright-core> to reuse an existing install.
import { mkdirSync, writeFileSync, readFileSync, existsSync } from 'node:fs';
import { createServer } from 'node:http';
import { createRequire } from 'node:module';
import path from 'node:path';
const args = process.argv.slice(2);
const flag = (n, d) => { const i = args.indexOf(`--${n}`); return i >= 0 ? args[i + 1] : d; };
const positional = args.filter((a, i) => !a.startsWith('--') && !['--steps', '--bake', '--encode'].includes(args[i - 1]));
const [target, outDir = 'hero-verify'] = positional;
const ENCODE = flag('encode'); // --encode in.png out.webp: the browser's WebP encoder, so no libwebp is needed
if (ENCODE) {
const { chromium } = createRequire(process.env.PW_CORE ? process.env.PW_CORE + '/' : path.join(process.cwd(), 'noop.js'))('playwright-core');
const b = await chromium.launch(); const p = await b.newPage();
const data = await p.evaluate(async (src) => {
const img = new Image(); img.src = 'data:image/png;base64,' + src; await img.decode();
const c = document.createElement('canvas'); c.width = img.width; c.height = img.height; c.getContext('2d').drawImage(img, 0, 0);
return c.toDataURL('image/webp', 0.86);
}, readFileSync(ENCODE).toString('base64'));
writeFileSync(positional[0], Buffer.from(data.split(',')[1], 'base64'));
await b.close();
console.log(JSON.stringify({ encoded: positional[0], kib: Math.round(readFileSync(positional[0]).length / 1024) }));
process.exit(0);
}
if (!target) { console.error('usage: node verify.mjs <hero.html|url> <outDir> [--steps 8] | --bake poster.webp | --encode in.png out.webp'); process.exit(2); }
const STEPS = Number(flag('steps', 8));
const BAKE = flag('bake');
const HEADED = args.includes('--headed');
// ES modules don't load over file:// (CORS), so a local file is served over http from its parent's parent
// (the example imports ../engines/three/scene.js).
let url = target, server;
if (!/^https?:/.test(target)) {
const abs = path.resolve(target.replace(/^file:\/\//, ''));
const root = path.dirname(path.dirname(abs));
const TYPES = { '.html': 'text/html; charset=utf-8', '.js': 'text/javascript', '.mjs': 'text/javascript', '.json': 'application/json', '.webp': 'image/webp', '.png': 'image/png', '.webm': 'video/webm', '.mp4': 'video/mp4', '.css': 'text/css' };
server = createServer((req, res) => {
const f = path.join(root, decodeURIComponent(new URL(req.url, 'http://x').pathname));
if (!f.startsWith(root) || !existsSync(f)) { res.writeHead(404); return res.end(); }
res.writeHead(200, { 'content-type': TYPES[path.extname(f)] ?? 'application/octet-stream' });
res.end(readFileSync(f));
});
await new Promise((r) => server.listen(0, '127.0.0.1', r));
url = `http://127.0.0.1:${server.address().port}/${path.relative(root, abs).split(path.sep).join('/')}`;
}
process.on('exit', () => server?.close());
const require = createRequire(process.env.PW_CORE ? process.env.PW_CORE + '/' : path.join(process.cwd(), 'noop.js'));
const { chromium } = require('playwright-core');
const GPU_ARGS = ['--enable-gpu', '--ignore-gpu-blocklist', ...(process.platform === 'darwin' ? ['--use-angle=metal'] : [])];
// Context exists but every shader fails to compile (taste-skill's consistency check, MIT): a second failure
// path that the no-WebGL stub doesn't cover.
const SHADER_FAIL = () => {
for (const C of [window.WebGLRenderingContext, window.WebGL2RenderingContext]) {
if (!C) continue;
const orig = C.prototype.shaderSource;
C.prototype.shaderSource = function (sh) { return orig.call(this, sh, '#version 300 es\nthis does not compile'); };
}
};
const NO_GL = () => {
const orig = HTMLCanvasElement.prototype.getContext;
HTMLCanvasElement.prototype.getContext = function (t, ...r) { return /webgl/i.test(t) ? null : orig.call(this, t, ...r); };
};
async function open({ width = 1440, height = 900, reduce = false, noGL = false, shaderFail = false, dpr = 1 } = {}) {
const browser = await chromium.launch({ headless: !HEADED, args: GPU_ARGS });
const ctx = await browser.newContext({ viewport: { width, height }, deviceScaleFactor: dpr, reducedMotion: reduce ? 'reduce' : 'no-preference' });
if (noGL) await ctx.addInitScript(NO_GL);
if (shaderFail) await ctx.addInitScript(SHADER_FAIL);
// Record when the poster and the live layer first appear, from the page's own clock.
await ctx.addInitScript(() => {
window.__omd3dTimeline = {};
const mark = () => {
const hero = document.querySelector('.hero');
if (!hero) return;
const t = window.__omd3dTimeline;
if (t.poster == null && getComputedStyle(hero).backgroundImage.includes('url(')) t.poster = performance.now();
if (t.live == null && 'live' in hero.dataset) t.live = performance.now();
if (t.live == null) requestAnimationFrame(mark);
};
document.addEventListener('DOMContentLoaded', mark);
});
const page = await ctx.newPage();
const logs = [];
page.on('console', (m) => { if (['error', 'warning'].includes(m.type())) logs.push(`[${m.type()}] ${m.text()}`); });
page.on('pageerror', (e) => logs.push(`[pageerror] ${e.message}`));
await page.goto(url, { waitUntil: 'networkidle' });
await page.waitForFunction(() => window.__omd3dState, null, { timeout: 30000 });
return { browser, page, logs };
}
const hideCopy = (page, h) => page.evaluate((h) => document.querySelectorAll('.hero .copy *').forEach((e) => { e.style.visibility = h ? 'hidden' : ''; }), h);
// Measure where the glyphs are: the union of the text's line boxes, not the block (which spans the column).
const rectsOf = (page) => page.evaluate(() => ['.hero h1', '.hero .copy p'].map((s) => {
const range = document.createRange(); range.selectNodeContents(document.querySelector(s));
const rs = [...range.getClientRects()].filter((r) => r.width > 1);
const x = Math.min(...rs.map((r) => r.x)), y = Math.min(...rs.map((r) => r.y));
return { x, y, width: Math.max(...rs.map((r) => r.right)) - x, height: Math.max(...rs.map((r) => r.bottom)) - y };
}));
const textColor = (page) => page.evaluate(() => { const c = getComputedStyle(document.querySelector('.hero h1')).color.match(/\d+/g).map(Number); return '#' + c.slice(0, 3).map((v) => v.toString(16).padStart(2, '0')).join(''); });
async function worstContrast(page, png, rects, text) {
return page.evaluate(async ([src, rects, text]) => {
const img = new Image(); img.src = 'data:image/png;base64,' + src; await img.decode();
const c = new OffscreenCanvas(img.width, img.height); const x = c.getContext('2d'); x.drawImage(img, 0, 0);
const s = img.width / innerWidth;
const lin = (v) => { v /= 255; return v <= 0.04045 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4; };
const L = (r, g, b) => 0.2126 * lin(r) + 0.7152 * lin(g) + 0.0722 * lin(b);
const Lt = L(...[1, 3, 5].map((i) => parseInt(text.slice(i, i + 2), 16)));
return rects.map((r) => {
const d = x.getImageData(Math.round(r.x * s), Math.round(r.y * s), Math.max(1, Math.round(r.width * s)), Math.max(1, Math.round(r.height * s))).data;
let worst = Infinity;
for (let k = 0; k < d.length; k += 16) { const Lb = L(d[k], d[k + 1], d[k + 2]); worst = Math.min(worst, (Math.max(Lt, Lb) + 0.05) / (Math.min(Lt, Lb) + 0.05)); }
return +worst.toFixed(2);
});
}, [png.toString('base64'), rects, text]);
}
async function diff(page, a, b) {
return page.evaluate(async ([a, b]) => {
const load = async (s) => { const i = new Image(); i.src = 'data:image/png;base64,' + s; await i.decode(); return i; };
const [ia, ib] = await Promise.all([load(a), load(b)]);
const c = new OffscreenCanvas(ia.width, ia.height); const x = c.getContext('2d');
x.drawImage(ia, 0, 0); const da = x.getImageData(0, 0, ia.width, ia.height).data;
x.clearRect(0, 0, ia.width, ia.height); x.drawImage(ib, 0, 0); const db = x.getImageData(0, 0, ia.width, ia.height).data;
let n = 0; for (let k = 0; k < da.length; k += 4) if (Math.abs(da[k] - db[k]) + Math.abs(da[k + 1] - db[k + 1]) + Math.abs(da[k + 2] - db[k + 2]) > 18) n++;
return +(n / (da.length / 4)).toFixed(4);
}, [a.toString('base64'), b.toString('base64')]);
}
// ---------- bake: a still of the live three.js scene, encoded by the browser as WebP ----------
if (BAKE) {
// 1600x900 CSS px at 1.2x = a 1920x1080 still: 16:9, the framing the scene is composed for (the hero caps at 900px tall).
const { browser, page, logs } = await open({ width: 1600, height: 900, dpr: 1.2 });
await page.waitForFunction(() => window.__omd3d && 'live' in document.querySelector('.hero').dataset, null, { timeout: 30000 });
await page.evaluate(() => window.__omd3d.setTime(0));
const webp = await page.evaluate(() => {
const c = document.querySelector('.hero > canvas');
window.__omd3d.setTime(0); // render into the drawing buffer right before reading it
return c.toDataURL('image/webp', 0.86);
});
writeFileSync(BAKE, Buffer.from(webp.split(',')[1], 'base64'));
console.log(JSON.stringify({ baked: BAKE, renderer: await page.evaluate(() => window.__omd3d.renderer), logs }));
await browser.close();
server?.close();
process.exit(0);
}
mkdirSync(outDir, { recursive: true });
async function pass(label, opts) {
const { browser, page, logs } = await open(opts);
await page.waitForTimeout(1200);
const state = await page.evaluate(() => { const h = document.querySelector('.hero'); const b = h.querySelector('.pause'); return { ...window.__omd3dState, live: 'live' in h.dataset, fallback: h.dataset.fallback ?? null, layers: h.querySelectorAll(':scope > canvas, :scope > video').length, pauseVisible: !!b && !b.hidden, h1Opacity: getComputedStyle(h.querySelector('h1')).opacity, timeline: window.__omd3dTimeline }; });
const rects = await rectsOf(page), text = await textColor(page);
const live = state.engine === 'three' && state.live && !!(await page.evaluate(() => window.__omd3d));
const r = { label, ...state, text, logs };
if (live) r.renderer = await page.evaluate(() => window.__omd3d.renderer);
let wh = Infinity, wp = Infinity;
const steps = live ? STEPS : 1;
for (let i = 0; i < steps; i++) {
if (live) { await page.evaluate((t) => window.__omd3d.setTime(t), (i / steps) * 8); await page.waitForTimeout(40); }
await page.screenshot({ path: path.join(outDir, `${label}-${String(i).padStart(2, '0')}.png`) });
await hideCopy(page, true); const bare = await page.screenshot(); await hideCopy(page, false);
const [h, p] = await worstContrast(page, bare, rects, text);
wh = Math.min(wh, h); wp = Math.min(wp, p);
}
r.worstContrast = { headline: wh, subcopy: wp };
if (live) {
await page.evaluate(() => window.__omd3d.setTime(0)); await page.waitForTimeout(40); const a = await page.screenshot();
await page.evaluate(() => window.__omd3d.setTime(2)); await page.waitForTimeout(40); const b = await page.screenshot();
r.animates = await diff(page, a, b);
// Interaction sweep on the real clock: the pointer enters from the right, drags through the pile and on into
// the copy column, clicks the pile (scatter), and wanders over the copy. Every few moves: the leftmost
// screen x any object reaches, and the headline contrast on that frame.
await page.evaluate(() => { window.__omd3d.setTime(0); window.__omd3d.release(); });
const vw = opts.width ?? 1440, vh = opts.height ?? 900;
const textRight = Math.max(...rects.map((q) => q.x + q.width));
const route = [];
for (let i = 0; i <= 40; i++) route.push([vw * (0.95 - i * 0.016), vh * (0.3 + i * 0.008)]);
route.push('click');
for (let i = 0; i <= 30; i++) route.push([vw * (0.42 + 0.06 * Math.sin(i / 3)), vh * (0.25 + i * 0.018)]);
let minLeft = Infinity, wi = Infinity, n = 0;
await page.mouse.move(vw * 0.95, vh * 0.3);
for (const [k, pt] of route.entries()) {
if (pt === 'click') { await page.mouse.move(vw * 0.72, vh * 0.48, { steps: 4 }); await page.mouse.down(); await page.mouse.up(); continue; }
await page.mouse.move(pt[0], pt[1]);
await page.waitForTimeout(24);
minLeft = Math.min(minLeft, await page.evaluate(() => window.__omd3d.leftmost()));
if (k % 6 === 0) {
await hideCopy(page, true); const bare = await page.screenshot(); await hideCopy(page, false);
const [h] = await worstContrast(page, bare, rects, text); wi = Math.min(wi, h); n++;
}
}
await page.mouse.move(vw - 4, vh - 80);
r.interaction = { samples: n, worstHeadline: wi, minLeft: +minLeft.toFixed(1), textRight: +textRight.toFixed(1) };
r.worstContrast.headline = Math.min(r.worstContrast.headline, wi);
// Frame time with the real clock: 3 s of rAF deltas from the scene's own loop.
await page.evaluate(() => { window.__omd3d.release(); window.__omd3d.frameTimes.length = 0; });
await page.waitForTimeout(3000);
const ft = await page.evaluate(() => [...window.__omd3d.frameTimes].slice(1).sort((x, y) => x - y));
const q = (p) => +ft[Math.min(ft.length - 1, Math.floor(p * ft.length))].toFixed(2);
r.frameMs = { n: ft.length, median: q(0.5), p95: q(0.95) };
r.pixelRatioAfter = await page.evaluate(() => window.__omd3d.pixelRatio);
r.aoAfter = await page.evaluate(() => window.__omd3d.ao);
}
// WCAG 2.2.2: the pause control must stop the motion.
if (state.live && state.pauseVisible) {
await page.click('.hero .pause');
await page.waitForTimeout(300);
// While paused the pointer must not move anything either.
const a = await page.screenshot();
const vw = opts.width ?? 1440, vh = opts.height ?? 900;
for (let i = 0; i <= 20; i++) { await page.mouse.move(vw * (0.9 - i * 0.02), vh * 0.45); await page.waitForTimeout(30); }
if (state.engine === 'three') { await page.mouse.move(vw * 0.72, vh * 0.48); await page.mouse.down(); await page.mouse.up(); }
await page.mouse.move(vw - 4, vh - 80);
await page.waitForTimeout(400); const b = await page.screenshot();
r.pausedDiff = await diff(page, a, b);
await page.click('.hero .pause');
}
await browser.close();
return r;
}
const report = { url, date: new Date().toISOString(), chromium: chromium.executablePath(), passes: [] };
report.passes.push(await pass('gpu', { width: 1440, height: 900 }));
report.passes.push(await pass('mobile', { width: 390, height: 844, dpr: 2 }));
report.passes.push(await pass('reduced-motion', { width: 1440, height: 900, reduce: true }));
report.passes.push(await pass('no-webgl', { width: 1440, height: 900, noGL: true }));
report.passes.push(await pass('shader-fail', { width: 1440, height: 900, shaderFail: true }));
const [gpu, mobile, still, nogl, sfail] = report.passes;
const tl = gpu.timeline || {};
report.checks = {
liveOnDesktop: gpu.mounted && gpu.live && gpu.layers === 1,
animates: gpu.engine !== 'three' || (gpu.animates ?? 0) > 0.002,
posterBeforeLive: tl.poster != null && (tl.live == null || tl.poster <= tl.live),
headlineVisibleAtLoad: gpu.h1Opacity === '1',
contrastHeadline: report.passes.every((p) => p.worstContrast.headline >= 4.5),
contrastSubcopy: report.passes.every((p) => p.worstContrast.subcopy >= 4.5),
mobilePosterOnly: mobile.layers === 0,
reducedMotionPosterOnly: still.layers === 0,
noWebGLPosterOnly: gpu.engine !== 'three' || nogl.layers === 0,
shaderFailPosterOnly: gpu.engine !== 'three' || (!sfail.live && sfail.fallback === 'shader-error'),
pauseStopsMotion: gpu.pauseVisible === true && (gpu.pausedDiff ?? 1) < 0.002,
pointerKeepsCopyClear: gpu.engine !== 'three' || (gpu.interaction != null && gpu.interaction.minLeft >= gpu.interaction.textRight + 8),
softwareRenderer: /swiftshader|llvmpipe|software/i.test(gpu.renderer || ''),
};
writeFileSync(path.join(outDir, 'report.json'), JSON.stringify(report, null, 2));
console.log(JSON.stringify({ engine: gpu.engine, renderer: gpu.renderer, frameMs: gpu.frameMs, pixelRatioAfter: gpu.pixelRatioAfter, aoAfter: gpu.aoAfter, interaction: gpu.interaction, pausedDiff: gpu.pausedDiff, timeline: tl, ...report.checks, contrast: Object.fromEntries(report.passes.map((p) => [p.label, p.worstContrast])) }, null, 2));
const fail = Object.entries(report.checks).filter(([k, v]) => k !== 'softwareRenderer' && !v);
server?.close();
if (fail.length) { console.error('FAIL:', fail.map(([k]) => k).join(', ')); process.exit(1); }
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation). | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK). | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |