Communitygithub.com

2d-in-3d

Make a vertical 3D cartoon Short (1080x1920, 30 fps) purely from code, from a user-supplied voiceover and script. three.js world plus 2D character cards, rendered on the local GPU with a measured film look (moonlit grade, bloom, DOF, motion blur, camera moves), a generated march score with sound effects mixed under the voice, and word-by-word captions. New characters and a new environment every video, at the same quality level, enforced by a measured quality gate. Use when the user gives a voiceover and script and asks for a video "like this", a code-made animated Short, or a three.js cartoon video.

What is 2d-in-3d?

2d-in-3d is a Claude Code agent skill that make a vertical 3D cartoon Short (1080x1920, 30 fps) purely from code, from a user-supplied voiceover and script. three.js world plus 2D character cards, rendered on the local GPU with a measured film look (moonlit grade, bloom, DOF, motion blur, camera moves), a generated march score with sound effects mixed under the voice, and word-by-word captions. New characters and a new environment every video, at the same quality level, enforced by a measured quality gate. Use when the user gives a voiceover and script and asks for a video "like this", a code-made animated Short, or a three.js cartoon video.

Works with✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/Manickavasagan-26/2d-stickman-in-3d-world-skill/tree/HEAD/2d-in-3d

Ask in your favorite AI

Open a new chat with this agent skill pre-loaded.

Documentation

What does 2d-in-3d do?

Input: the user's voiceover audio file and its script text. Output: out/final.mp4, vertical 1080x1920 at 30 fps, with the voiceover, a generated march score and effects, and burned word-by-word captions.

What changes every video: the story world, the sets, the cast and the props. What never changes: the look (lighting rig, grade, post chain), camera language, character style, pipeline and quality gate.

  • Skill folder: ~/.claude/skills/2d-in-3d/, written $SK below.
  • engine/
    • core.js: renderer, look presets, lights, sky, builders, card system, post chain, motion blur, start()
    • cards.js: character drawer with open part registries
    • index.html, render.mjs, scene.example.js
  • scripts/
    • new_project.py, fetch_polyhaven.py, align.py, captions.py, gate.py, sheet.py, finish.py
    • audio.py: procedural march score with twist hit and drone, plus effects from a cue table
    • mix.py: voice + music + effects at measured levels
  • reference/
    • look.md: measured numbers, presets, post chain
    • camera.md: moves and timeline rules
    • characters.md
    • pitfalls.md
    • sound.md: music recipe, effect cue rules, mix targets
  • history.json: what each past video used, so the next one differs

Read reference/look.md and reference/camera.md before writing any scene. Read reference/sound.md before writing the cue table. Read pitfalls.md before the first test render.

Requirements (this machine)

  • Node with playwright and three in ~/shorts/node_modules.
    • Put projects under ~/shorts/<slug>/ so imports resolve.
  • Chromium headless shell from Playwright. It renders on the GPU through ANGLE D3D11 (RTX 2050 measured at about 0.22 s per frame).
  • Python with faster-whisper (model small.en is cached), opencv-python, numpy, scipy and soundfile. ffmpeg and ffprobe must be on PATH.
  • Downloads need the user's OK before they happen: Poly Haven assets, and any whisper model other than the cached small.en.
    • State the names and approximate size when asking.

Process

1. Set up the project

python $SK/scripts/new_project.py ~/shorts/<slug>
  • Copy the voiceover to audio/vo.<ext>.
  • Save the script as audio/script.txt.

2. Get word timing

python -I $SK/scripts/align.py audio/vo.wav audio/script.txt web/words.json
  • This prints the sentences with start and end times.
  • Check the "matched" count. Below 80 %, the script does not match the audio: ask the user.

3. Plan (write plan.md before any code)

  • World: one sentence on the setting. Make it different from the entries in history.json.

  • Sets: 2-4 locations. Each gets a key direction, a look preset and at least one warm practical.

  • Cast: new designs (see reference/characters.md). Give each a signature colour.

  • Shot table: one beat per sentence or phrase (see reference/camera.md).

    • Columns: frames from words.json, set, look, camera move, actors and expressions on the trigger word, props and FX.
    • At most 3 hard cuts per 10 s. Everything else is a camera move.
  • Assets: search Poly Haven for the setting, then list the models and textures to fetch:

    python -I $SK/scripts/fetch_polyhaven.py search models <keywords>
    python -I $SK/scripts/fetch_polyhaven.py search textures <keywords>
    
    • Prefer 8-16 models and 4-7 textures, about 30-60 MB at 1k.
    • Ask the user before downloading, then fetch:
    python -I $SK/scripts/fetch_polyhaven.py fetch web/assets --models a,b --tex c,d
    

4. Build web/scene.js

Replace the example completely. Structure:

import { THREE, setCast, start, mkSet, loadModels, place, pbr, std, glow, plane, add, bladeField, treeField, scatter,
  fire, practical, onUpdate, V, path, num, lerp, ease, seg, shake, rng, fetchJSON, FPS } from './core.js';
setCast({ ... });                                   // new cast
const { words, sentences, duration } = await fetchJSON('words.json');
const at = (i) => Math.round(words[i].t0 * FPS);    // frame of word i
await loadModels([...]);                            // Poly Haven models
const A = mkSet('village', 0, 0, { keyAz: 10, keyEl: 20 });  // sets far apart: x = 0, 3000, 6000...
// ground: pbr texture at high repeat; dense detail: bladeField / treeField / scatter / place(); fire()/practical() warm pools
start({ shots: [ { a, b, set, look, shutter, cam: (f) => ({ pos, look, fov, ap, yaw }), actors: (f) => [...], update: (f, t, cards, origin) => {} }, ... ] });
  • The last shot's b must be at least ceil(duration * 30).
  • Shots must be contiguous: each shot's b equals the next shot's a.
  • The detail budget is what makes the video look rich.
    • Every close shot needs: a textured ground, a foreground element, a midground of props, a background with fog, and sky.
    • Every wide or aerial shot needs thousands of instances: blades, trees, buildings in grids, lights.

5. Test keyframes and look at them

node render.mjs test "<one frame per shot, plus each shot's first and last>"
python -I $SK/scripts/sheet.py test test/sheet.jpg
  • Read sheet.jpg and check:
    • characters are big enough and not cut off
    • the disc (moon or sun) is in frame where it is wanted
    • no blob or prop blocks the camera
    • no character is missing
    • there are warm and cool pools
    • nothing is empty or flat
  • Fix the problems and repeat. Use --sub 1 for fast previews of layout only.

6. Full render, then the quality gate

node render.mjs frames all
python -I $SK/scripts/gate.py frames --look <dominant look>
  • If sets use different looks, gate each shot range separately: --range a-b --look x.

  • Every hard metric must PASS before delivery. Fix the cause, not the number:

    Failing metricFix
    Low sharpness or edgesmore texture, props and instances; less DOF
    Low motionadd camera moves, shake, character motion
    Frozen stretchsomething must move every second
    Contrast or saturation out of rangeadjust the shot's look grade overrides
    Too bright or too darkexposureK, practical intensity, fog
  • Soft warnings (shadow %, colour temperature, cuts): fix them if cheap, otherwise report them.

7. Sound: score, effects, mix

  • Write audio/cues.json from the shot table (see reference/sound.md):
    • key and bpm
    • the twist line: the first words of the reveal sentence, as {"phrase": "…"}
    • one effect cue per on-screen action, on its frame
  • Generate and mix:
python -I $SK/scripts/audio.py .
python -I $SK/scripts/mix.py . audio/vo.wav
  • Check the mix report: music must read voice -6.0 dB, and effect peaks must be ≤70 % of the voice peak.

8. Captions and final encode

python -I $SK/scripts/captions.py web/words.json captions.ass
python -I $SK/scripts/finish.py . audio/vo.wav
  • Captions are one word at a time, white heavy font with black outline, at 70 % of frame height.
  • Move them with --y if a face sits there.
  • Check one frame of out/final.mp4 that has a caption.

9. Deliver and log

  • Send out/final.mp4 and test/sheet.jpg.
  • Report the gate table, comparing the video's numbers with the reference.
  • Append to $SK/history.json: {date, slug, world, sets, looks, cast: {name: colour/pattern/hair}, models, music: {key, bpm}}.

Hard rules

  • Never reuse a previous video's world, cast or palette. Always read history.json first.
  • Never change the post chain order, the card alpha trick, or the measured night_moon values.
    • Tune per shot through look overrides instead.
  • Never cut a whip-pan on both sides of a cut; use the incoming side only.
  • Never deliver with a hard gate failure. If it truly cannot pass, say which metric failed and why.
  • Characters are original designs. Never recreate a specific existing show's characters, logos or sets.
  • Downloads (assets, models) need the user's OK first.

Related Skills