htdt/godogen / skills/engine-guide
engine-guide
VerifiedBuilding on Godot 4 (C# or GDScript), Bevy, Babylon.js, three.js or HTML: which to choose, installing its toolchain, the project sketch, build commands, headless capture to screenshots and video, and the traps that fail silently. Use when starting or working on a game, a video made in an engine (presentation, explainer, trailer, product showcase), an interactive 3D or 2D page, or anything else built on one of these engines.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 5.0 KB |
| babylon.md | markdown | 2.8 KB |
| bevy.md | markdown | 4.0 KB |
| godot-gdscript.md | markdown | 6.5 KB |
| godot.md | markdown | 5.7 KB |
| html.md | markdown | 3.0 KB |
| setup.md | markdown | 3.0 KB |
| threejs.md | markdown | 3.7 KB |
threejs.md
View on GitHub# three.js engine guide
Stack: **three.js** (`three`), **Vite**, **TypeScript**, Node (current LTS).
> three ships a release a month and deprecates as it goes, so the installed one is likely newer than this model's training data. When the console warns that something is deprecated, follow it; for exact shapes read `node_modules/three/src` (addons under `node_modules/three/examples/jsm`), not memory.
## Project shape
A plain Vite + TS project is enough. Scaffold one (`npm create vite@latest . -- --template vanilla-ts`), add `three` and `@types/three` on the same `0.N` release (three ships no types of its own), then:
- A fullscreen `<canvas>`, a `WebGLRenderer` driven by `renderer.setAnimationLoop`, and resize on `window`. Addons (loaders, controls, postprocessing, `SkeletonUtils`) import from `three/addons/...`.
- Put gameplay in `src/` modules; keep generated assets under `src/assets/` and load them through Vite (`import url from './assets/x.glb?url'`).
- three is a renderer, not an engine — physics, UI, and audio are yours to choose. For physics, `@dimforge/rapier3d-compat` inlines its wasm (`await RAPIER.init()` before use); the plain `@dimforge/rapier3d` imports `.wasm` as a module, which Vite doesn't handle without a plugin.
Commands: `npm install` · `npm run dev` · `npm run build`.
**Bind the dev server to `0.0.0.0` on a fixed port** (`server: { host: true, port: 5173 }`) so `http://<host>:5173` is reachable from other machines on the LAN or through a tunnel.
## Quirks worth knowing (silent-failure)
- **Color space.** Textures you load or build yourself default to `NoColorSpace`; set `colorSpace = SRGBColorSpace` on color maps (albedo, sprites, UI, sky) or they render washed out. The glTF loader tags its own.
- **Lights are physical.** Point and spot lights fall off with inverse-square (`decay = 2`) — intensities from older examples leave the scene near-black a few meters out. A directional light's shadow camera spans ±5 units: size `light.shadow.camera` to the play area and move it with the player, or shadows stop at its edge.
- **Rigged clones.** `clone()` on a skinned GLB keeps the copy bound to the original's bones, so it renders in the original's pose. Clone rigs with `SkeletonUtils.clone()`.
- **WebGPU falls back.** `WebGPURenderer` (`three/webgpu`, TSL node materials) runs on its WebGL2 backend when the browser has no WebGPU adapter, with only a console warning — check `renderer.backend.isWebGPUBackend` before trusting a capture of a WebGPU-only effect.
## Capture
Load the running dev URL in headless Chrome/Chromium (`playwright-core`, or `google-chrome --headless`) and screenshot.
- **Use a real GPU.** Headless Chrome silently falls back to SwiftShader/llvmpipe, which renders slowly or blank. On Linux, run under `xvfb-run` and request hardware (`--use-angle=vulkan`); read the WebGL `RENDERER` string and warn if it contains `swiftshader`/`llvmpipe`/`lavapipe`.
- **Wait before shooting.** Capture only after the scene has rendered a frame and textures/GLBs have loaded — gate on a ready flag the game sets. Screenshotting too early gives a misleading blank frame.
- **Step time from the capture script.** A screenshot takes longer than a frame, so shooting the live loop on an interval gives a sped-up, stuttering clip. Give the game a capture mode (a query flag) that stops `setAnimationLoop` and exposes a hook advancing one fixed 1/30 s step and rendering; shoot after each call — 450 steps = 15 s. Reading pixels with `canvas.toDataURL()` returns blank unless it runs right after `render()` in the same task, or the renderer has `preserveDrawingBuffer: true`.
- **Video:** encode the frames at ~720p: `ffmpeg -framerate 30 -i frame_%04d.png -c:v libx264 -pix_fmt yuv420p video.mp4`.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |