How We Make "In This Town" Videos With Code (No Camera, No Video Editor)
You've probably seen these videos:
- A small, blocky 3D town.
- A narrator starting with "In this town..."
- One word appearing on screen at a time.
- A short story with an unexpected twist.
They look like gameplay recordings, but ours are completely different.
Every frame is generated with code.
We don't use a camera, a game, a 3D modelling program, or a traditional video editor.
Instead, we built a pipeline that turns a single sentence into a complete animated Short.
Here's how it works.
đ§Š Our Entire Video Pipeline
Story Idea
â
Claude Code
â
three.js
â
3D Animation
â
Remotion
â
Final MP4
The audio pipeline runs alongside it:
- Kokoro TTS: Generates the narration.
- Node.js: Creates music and sound effects.
- Timing data: Synchronizes captions, animation, and camera cuts.
Tools We Use
| Tool | Purpose | Cost |
|---|---|---|
| Claude Code | Writes and manages the code | Paid subscription |
| three.js | Builds the 3D town and characters | Free (MIT) |
| Remotion | Renders the video | Free for individuals and small teams; company licensing may apply |
| Kokoro TTS | Generates narration locally | Free (Apache 2.0) |
| Kenney Assets | Provides 3D props | Free (CC0) |
1. Start With a Simple Story
A 25-second video usually needs around 70â90 words.
We don't begin with complicated scripts. We write short lines in a JSON file.
For example:
[
{
"text": "In this town, nobody ever waves back.",
"mood": "sad"
},
{
"text": "Mike waved at everyone, every single day.",
"whoosh": true
},
{
"text": "Then one morning, someone finally did.",
"mood": "warm",
"pause": 0.4
}
]
Our storytelling structure is simple:
- The rule: Start with something strange about the town.
- The character: Introduce someone affected by that rule.
- The escalation: Show three or four increasingly interesting moments.
- The twist: End with something funny, emotional, or unexpected.
The goal is to make viewers curious enough to watch until the end.
2. Generate the Voice and Timing
We use Kokoro TTS, an open-source text-to-speech model that runs locally.
Here's a simplified example:
import { KokoroTTS } from "kokoro-js";
const tts = await KokoroTTS.from_pretrained(
"onnx-community/Kokoro-82M-v1.0-ONNX",
{
dtype: "fp32",
device: "cpu"
}
);
const audio = await tts.generate(
line.text,
{
voice: "am_puck",
speed: 1.2
}
);
But generating the voice is only half the job.
We also generate a word timing file.
export const WORDS = [
{ text: "In", start: 0.08, end: 0.19 },
{ text: "this", start: 0.19, end: 0.38 },
{ text: "town,", start: 0.38, end: 0.71 }
];
Each word has a start and end time.
We use this data to synchronize:
- Captions.
- Character movements.
- Camera cuts.
- Scene transitions.
The voice controls the timing, not the other way around.
A Lesson About Pacing
Our first narration was too slow.
We measured videos in this format and found that approximately 3.5â4 words per second was a useful target.
Our initial version was closer to 2.8 words per second.
That difference matters in short-form content.
3. Build Characters Using Simple Geometry
We don't need complex character models.
A character is basically a collection of rounded boxes:
- Head.
- Body.
- Two arms.
- Two legs.
We draw a simple face on the head using a canvas texture.
For example:
import {
RoundedBoxGeometry
} from "three/examples/jsm/geometries/RoundedBoxGeometry.js";
const rbox = (w, h, d, r = 0.06) =>
new RoundedBoxGeometry(w, h, d, 3, r);
const mike = makeBlocky({
skin: "#c98c62",
shirt: "#e8b93a",
pants: "#2f4a7a",
hair: "spiky",
hairColor: "#2a1a12"
});
One important design decision:
Every character needs a recognizable appearance.
We use different shirt colours, hairstyles, and facial details so viewers can identify characters immediately on a small phone screen.
We also design our own characters instead of copying existing games, characters, or copyrighted assets.
4. Build the Town Once
This is where reusability becomes important.
Our town is built from reusable elements:
- Roads.
- Houses.
- Trees.
- Fences.
- Street decorations.
- Sky and lighting.
Houses are mostly boxes with canvas-based textures.
We also use free CC0 assets for small environmental details.
The best part?
We don't have to rebuild the town for every new video.
We can change:
- The random seed.
- House colours.
- Lighting.
- Time of day.
- Character positions.
- Camera angles.
The same environment can support many different stories.
5. Animate Everything With Remotion
This is one of the most interesting parts of the pipeline.
Remotion lets us create videos using React components.
Instead of manually moving objects on a timeline, we calculate their positions using the current frame number.
For example:
import { useCurrentFrame } from "remotion";
import { ThreeCanvas } from "@remotion/three";
export const TownShort = () => {
const frame = useCurrentFrame();
const t = frame / 30;
return (
<ThreeCanvas width={1080} height={1920}>
<Scene t={t} />
</ThreeCanvas>
);
};
At 30 FPS, every frame represents approximately 1/30 of a second.
We use mathematical functions to control animation.
For example, character movement:
const x = startX + walkSpeed * (t - walkStart);
And camera selection:
const shot = SHOTS.find(
(s) => f >= s.from && f < s.to
);
This means the same frame number always produces the same visual result.
Why is that useful?
If something looks wrong at second 14, we can fix that specific part without manually editing an entire timeline.
6. Display One Word at a Time
The large animated captions are an important part of this video format.
We use React to find the word that should appear at the current time.
const w = words.find(
(w) => t >= w.start && t < w.end + 0.35
);
const k = (t - w.start) * fps;
const scale =
k < 4
? 1.18 - 0.18 * (k / 4)
: 1;
Then we render it:
<div
style={{
fontSize: 124,
fontWeight: 800,
color: "#fff",
WebkitTextStroke: "14px #000",
paintOrder: "stroke fill",
transform: `scale(${scale})`
}}
>
{w.text.toLowerCase()}
</div>
The word appears with a small popping animation.
We also do something important for the opening:
During the first two seconds, we show the entire opening sentence.
This helps viewers understand the hook even when their sound is turned off.
7. Create Music and Sound Effects With Code
We don't depend on a large sound library.
Our Node.js script generates simple audio effects.
For example:
- Sine waves create soft piano-like sounds.
- Filtered noise creates rain.
- Short noise bursts create whooshes.
- Background music is automatically reduced while narration plays.
It's not intended to replace professional film scoring.
It's simply a lightweight way to create synchronized audio without depending on external sound libraries.
8. Render the Final Video
Once everything is ready, Remotion renders the composition into an MP4.
Here's a simplified version:
import { bundle } from "@remotion/bundler";
import {
renderMedia,
selectComposition
} from "@remotion/renderer";
const serveUrl = await bundle({
entryPoint: "src/index.ts"
});
const composition = await selectComposition({
serveUrl,
id: "TownShort"
});
await renderMedia({
composition,
serveUrl,
codec: "h264",
outputLocation: "out/town.mp4"
});
We don't immediately render the entire video.
Our workflow is:
- Generate a few test frames.
- Inspect the characters and environment.
- Check camera angles and captions.
- Fix visual problems.
- Render the complete video.
This saves time when something needs to be corrected.
9. Where Claude Code Comes In
We don't manually write every scene, character, animation, and script.
Instead, we maintain a skill file containing the rules of our video format.
It includes:
- Story structure.
- Narration speed.
- Character design rules.
- Camera movement.
- Caption styling.
- Animation requirements.
- Rendering checks.
Then we give Claude Code a simple instruction:
In this town, every phone rings at the same time.
From that single idea, our workflow can:
- Write the story.
- Generate the narration.
- Create the scene code.
- Build the camera movements.
- Render test frames.
- Inspect the results.
- Fix problems.
- Render the final video.
We also use a second, independent agent to check the output against our production rules.
However, automation doesn't replace human judgment.
A person still approves the script, chooses the voice, and decides whether the final video is good enough to publish.
10. What We Learned From Making These Videos
After experimenting with this format, we learned a few important things.
1. The hook must start immediately.
The first frame should already show something interesting. Don't waste the opening seconds.
2. Keep the narration moving.
Around 3.5â4 words per second is a useful starting point to test.
3. Change the visuals frequently.
We aim for a new shot every 1.5â2.5 seconds.
4. Emotion can be stronger than humour.
One of our best-performing stories was about a town where it only rains on you when you are sad.
It held viewers' attention longer and brought in the most subscribers.
5. Give viewers a reason to comment.
We often end the caption with a question related to the story.
6. Be transparent about AI.
We enable the AI-generated content label when publishing because the narration is synthetic.
Honest Limitations
This pipeline is powerful, but it isn't magic.
- Claude Code requires a paid subscription.
- Rendering takes time, especially on a normal PC.
- The first video takes longer because you need to build the environment and characters.
- AI voices can sound flat, so testing different voices and speeds is important.
- A technically good video doesn't automatically become viral.
The biggest advantage is reusability.
Once the town, characters, animations, and rendering system are ready, creating another story becomes much easier.
Try Building Your Own
You don't need to start with a complicated production system.
Start with:
- One street.
- Two blocky characters.
- Three short story lines.
- One camera movement.
- A 10-second render.
Get that working first.
Then add word-by-word captions, sound effects, more characters, and different camera angles.
The interesting thing about this approach is that you're not editing a video anymore. You're building a system that generates videos.
Have you tried generating animated videos with code?
Which part would you find most challenging: the 3D environment, character animation, voice synchronization, or rendering?
Let me know in the comments!
How We Turn One Sentence Into a 3D Animated Short Using Code
A behind-the-scenes look at how we use Claude Code, three.js, Remotion, and AI-generated voice to create blocky 3D story videos â without a camera, game engine, or video editor.
âļī¸ Watch an example video
Top comments (1)
The part I find particularly interesting is the shift from editing individual videos to building a deterministic production system.
One challenge I'd pay close attention to is keeping procedural animation reproducible across parallel renders. For example, imagine generating a town with seeded building layouts, NPC movement, and dynamic lighting. If any part of the scene relies on
Math.random(),performance.now(), or animation state that accumulates between frames, rendering frame 450 independently might produce a different result than reaching it sequentially during playback.I'd use a seeded PRNG for procedural elements and derive every animation state directly from the frame number. I'd also separate scene generation from rendering, so the same story data always produces the same environment and camera decisions.
Another interesting improvement would be treating narration timestamps as the central timeline, with captions, character actions, camera cuts, and audio ducking all driven by the same event data.
That would make the pipeline much more than an automated video generator. It becomes a reproducible, data-driven animation engine. That's where this approach gets really interesting.