Skip to content

majiayu000/spellbook / skills/code-built-3d

code-built-3d

Unverified

用代码从零件搭 3D 场景并能反过来拆开:每个物件是一个往 Assembly 里加零件的函数(盒子、圆柱、球、线),渲染成技术插画(白灰三档面、细黑描边、白雾),正交等距相机在镜头之间连续运镜,外壳可以降下去露出内部,选中的部分能爆炸成零件并列出零件清单,场景按块无限生成。零图片、零外部资源,three.js 已内置。演示是「无尽楼」:向上无尽的公寓楼,电梯一直往上走,点任意一层进去看、拆开。当用户说「用代码搭一个 3D 场景」「等距 3D 城市」「做成 Train of Thoughts 那种」「全程代码生成不要图片」「能剖开 / 去壳 / 爆炸的 3D」「无限生成的场景」「three.js 做构造」时使用。只在明确请求时触发,忽略顺带提及。

FileKindSize
SKILL.mdskill md7.0 KB
assets/demo.htmlother14.8 KB
assets/kit.jsscript14.9 KB
assets/tower.jsscript21.4 KB
scripts/check.mjsscript7.6 KB
scripts/lib/env.mjsscript3.5 KB
scripts/package.jsonmanifest289 B
scripts/serve.mjsscript1.5 KB

scripts/lib/env.mjs

View on GitHub
// Find a Chromium and an ffmpeg that already exist on this machine, so the
// scripts run without `npx playwright install` or a PATH tweak.
import { existsSync, readdirSync } from 'node:fs';
import { join } from 'node:path';
import { homedir, platform } from 'node:os';
import { execFileSync } from 'node:child_process';
import { createRequire } from 'node:module';

const require = createRequire(import.meta.url);

function cacheDirs() {
  const h = homedir();
  return [
    process.env.PLAYWRIGHT_BROWSERS_PATH,
    platform() === 'darwin' && join(h, 'Library/Caches/ms-playwright'),
    platform() === 'linux' && join(h, '.cache/ms-playwright'),
    platform() === 'win32' && join(h, 'AppData/Local/ms-playwright'),
  ].filter(Boolean);
}

// Relative paths of the executable inside a ms-playwright browser folder.
const EXES = [
  'chrome-headless-shell-mac-arm64/chrome-headless-shell',
  'chrome-headless-shell-mac-x64/chrome-headless-shell',
  'chrome-headless-shell-linux64/chrome-headless-shell',
  'chrome-headless-shell-win64/chrome-headless-shell.exe',
  'chrome-mac-arm64/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing',
  'chrome-mac-x64/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing',
  'chrome-linux64/chrome',
  'chrome-mac/Chromium.app/Contents/MacOS/Chromium',
  'chrome-mac-arm64/Chromium.app/Contents/MacOS/Chromium',
  'chrome-linux/chrome',
  'chrome-win/chrome.exe',
];
const SYSTEM = [
  '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
  '/Applications/Chromium.app/Contents/MacOS/Chromium',
  '/usr/bin/chromium', '/usr/bin/chromium-browser', '/usr/bin/google-chrome',
];

export function findChromium() {
  if (process.env.CHROMIUM_PATH && existsSync(process.env.CHROMIUM_PATH)) return { path: process.env.CHROMIUM_PATH, from: 'CHROMIUM_PATH' };
  // What the installed playwright expects, if it is there.
  try {
    const p = require('playwright').chromium.executablePath();
    if (p && existsSync(p)) return { path: p, from: 'playwright default' };
  } catch {}
  // Newest cached build of any version: headless shell first, then full chromium.
  for (const dir of cacheDirs()) {
    if (!existsSync(dir)) continue;
    const names = readdirSync(dir).filter(n => /^chromium(_headless_shell)?-\d+$/.test(n))
      .sort((a, b) => (b.includes('headless') - a.includes('headless')) || (+b.split('-')[1] - +a.split('-')[1]));
    for (const n of names) for (const e of EXES) {
      const p = join(dir, n, e);
      if (existsSync(p)) return { path: p, from: `cache ${n}` };
    }
  }
  for (const p of SYSTEM) if (existsSync(p)) return { path: p, from: 'system browser' };
  return null;
}

export function findFfmpeg() {
  const cands = [process.env.FFMPEG_PATH, 'ffmpeg', '/opt/homebrew/bin/ffmpeg', '/usr/local/bin/ffmpeg', '/usr/bin/ffmpeg'].filter(Boolean);
  for (const c of cands) {
    try { execFileSync(c, ['-version'], { stdio: 'ignore' }); return { path: c, from: c === 'ffmpeg' ? 'PATH' : c }; } catch {}
  }
  // Playwright ships an ffmpeg for video recording, but without libx264, so it is only a last resort.
  return null;
}

export async function launch(opts = {}) {
  let chromium;
  try { ({ chromium } = require('playwright')); }
  catch { throw new Error('playwright is not installed: run `PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm install` in ' + new URL("..", import.meta.url).pathname); }
  const c = findChromium();
  if (!c) throw new Error('no Chromium found: run `npx playwright install chromium-headless-shell` or set CHROMIUM_PATH');
  return chromium.launch({ executablePath: c.path, ...opts });
}
receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementationStars: 322kUpdated Claude CodeCodexVerifiedInstall
requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirementsStars: 322kUpdated Claude CodeCodexVerifiedInstall
using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallbackStars: 322kUpdated Claude CodeCodexVerifiedInstall
verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions alwaysStars: 322kUpdated Claude CodeCodexVerifiedInstall