Claude 如何用 3,809 行 Python 构建 3D GT 赛车
How Claude built a 3D GT race car in 3,809 lines of Python
作者展示了 Claude 如何编写单个 Python 脚本,在 Blender 无窗口运行 35 秒生成一辆 94,079 三角形的 3D GT 赛车,包含三个车身套件和八套涂装。
文章将脚本化建模、独立视觉评审与分阶段重建串成可复用流程,并给出具体提示词与验证方法。

No downloaded model. No AI-generated mesh. No hand modelling in Blender.
The GT race car in our browser racing game is one Python script. Blender runs it without a window, and 35 seconds later you have a 94,079-triangle car, three body kits, eight liveries painted by the script and a shadow hull. Claude wrote every line of it over three days.
The code is clever in places. But the code isn't why the car looks the way it does. A loop is: look at it where the player sees it, let an agent that didn't build it judge it, and when that judge says "no", change the method, not just the part.
Here's how it was made, and how to do it yourself.
Why a script, and not a download
We tried the easy routes first.
- Downloading: no free GT3-class car could be fetched without an account. The free ones that could looked like toys.
- A concept car with a wing bolted on: a judge called it "a smooth, swollen road-car shell with a wing bolted on".
- Image-to-3D: rejected before trying. It would give "a fused lump with painted-on wheels and somebody's real car in it".
A GT car is made of regular, engineered parts: a lofted body, cut openings, lathed wheels, an aerofoil wing, a livery. That is exactly what code is good at. And a script can keep the one thing a download never will: the exact wheel positions and tyre radius the physics already uses, so the car still drives the same.
Rule of thumb: when an object is engineered and has a contract with your code, script it.
Step zero: words before geometry
Before a single vertex, Claude studied reference screenshots from the best racing games and wrote notes. Proportions in metres ("width over height near 1.8", "tyre gap under 4 cm"). The 12 things that make a GT car read as a race car at a glance: stance, wing, splitter, a black lower body, openings with depth, a dense livery. And what the chase camera actually sees from 6.6 m back.
Then it read the game's code and wrote down the contract at the top of the script:
- Wheel nodes named WheelFrontL and so on, at fixed centres, under a z-up root.
- The game overwrites the wheels' spin, so the right-hand wheels must be meshes of their own, not mirrored copies.
- The physics body ends 1.89 m behind the origin, so the tail had to be shortened to fit.
- Material names the game looks up: Paint, Brakelight, Glass.
Every later decision traces back to those two pages.
The whole body is 15 curves

This is the part I'd steal first.
Each feature line of the car is a smooth 1-D function along its length: half-width, shoulder height, the valley between wing and cabin, the cowl, the roof, the floor. About 15 of them. Each one is a handful of (position, value) pairs, joined with straight lines and then blurred with a Hann window.
At each station along the car, those curves give the 14 points of half a cross-section: floor, sill, side, shoulder, wing top, bonnet or cabin, roof centre. Stack the sections into a cage, mirror it, put a subdivision surface on it, apply it. That's the body.
Two small tricks do a lot of work:
- Near the wheels, the stations follow the arch circle, so the arch is part of the grid instead of a hole cut later.
- A shut line is three stations close together with the middle one pushed in. After subdivision that becomes a real groove that catches light.
Cut it, don't paint it
Openings are real. Some are cage cells pushed inward. The rest are exact boolean cuts whose walls take the cutter's dark material, so the inside of every cut is dark automatically. Shut lines and the tail band are cut as real gaps a few millimetres wide, not painted lines.
Everything that sits on the body (mirrors, wing mounts, lamps, vents) is placed by ray casts against a BVH tree of the finished body. That's how parts sit on a compound curve with no gaps and no clipping, without anyone nudging them by hand.
The wing is a real aerofoil with chord, thickness, camber and a flap. The wheels are lathed from a tyre profile, 48 segments, with ten crowned spokes and three motion-blur stand-ins the game swaps in at speed.
The livery is painted in the car's own metres

This is the cleverest part of the script.
- It sorts every face by the way it faces (left, right, top, front, rear) and projects it into its own rectangle of one square texture, at a fixed number of pixels per metre.
- It draws the body's triangles into that texture, so every texel knows its (x, y, z) position on the car, in metres.
- The livery is then just numpy. "A dark wedge rising along the doors to the tail" is one line of arithmetic on z and y. Edges are softened over 3.5 mm so they don't stair-step at a distance.
So the livery is designed in the car's metres, not in UV space. Lettering is drawn once with Blender's own font and stamped on. There are eight colour schemes, one per car on the grid.

Day one looked great. In Blender.

The first version took one afternoon. The first commit was 745 lines: a body cage and wheels. By the evening it had openings, aero, lamps, a cabin, a projected livery and shut lines, and it looked like a race car in Blender's studio light.
Then it went into the game, and a judge looked at it from behind at play distance. Verdict, in short: a flat slab with pictogram lamps, a comb for a diffuser, and no tyre showing.
Lesson one: what a model looks like in Blender is not what the game draws. Soft studio light hides flatness. Judge it where the player sees it.
The fresh judge

The most useful thing in the whole process was a second agent that did not build the car.
It gets only picture files: in-game shots at the player's distance, the same shots from before the change, and reference shots. It owes the builder nothing. And it must answer in this form and nothing else:
- told apart: yes or no
- first: the one thing that most gives it away, and the file it shows in
- also: everything else
- not given away by: what already works
- can it reach the bar as made: yes or no, split into what the model needs and what the renderer needs
- how sure
The fixed form matters. A builder grading its own work is always kinder than a judge. Every builder's self-assessment here was kinder than the judge's. A form makes "it's getting there" impossible to write.
"No, change the way first"
On day two at noon the tail had been rebuilt as detailed parts on a hull. The judge:
"The tail reads as a flat upright board with parts laid on it, not a built car."
And then the line that changed the project:
"The rest of the car by the same way: no, change the way first."
Not "fix the lamps". Change the method. So Claude rebuilt one piece only, the tail panel and lamps, a new way, and sent that piece back to a new judge before touching anything else.

The new tail was built depth first, from the inside out. Lamps: housing, then a chrome bowl, then a light-guide blade, then brake blocks, then a domed lens with a chamfered rim. Behind the grille: real mesh bars over a bay 42 cm deep, with a silencer, a cross-member and pipes running through a heat shield.
The next judge: "Can the piece reach the bar as made: yes. The structure is right; the faults are tone, scale and drawing."
Three rules worth more than any code

- Depth first. Recesses, things behind openings, bevelled edges. Decals and fasteners come after. Geometry made by script reads as flat without them.
- Tone against the references before detail. A recess must be dark and a mesh black. The rebuilt tail gained depth and then lost it again because the inside was lit too brightly.
- Judge at play distance first. 6 to 8 m behind, in the game, where the player spends the race. Then close up. Large form before small recesses.
Plus one more from the diffuser: hard parts come from clean profiles (lathe, prism, extruded outline), never from warped shapes.
The whole loop

Once the method was proven on the tail, the work split. Parallel helper agents each took one area (bodies and kits, wheels, the tail's face, front lamps and cabin, paint), all sharing one common brief: what to read and no more, where to put evidence, a budget, and "decide, don't ask". Then everything was merged back into one script, now able to build three different car shapes from one body.

The numbers
- 1 script: 3,809 lines of bpy, bmesh and numpy
- 35 seconds to build the car from nothing, headless
- 94,079 triangles, 3.1 MB glTF, three body kits
- 8 liveries at up to 4096×4096, painted pixel by pixel
- 35 commits, 15 kept versions, 3 days (19 to 21 November)
- First commit: 745 lines
And it is reproducible. A week later I re-ran the script from a clean folder: the .glb came out the same size to the byte, and the liveries were byte-identical.
Steal this: the prompts
Here's the sequence, condensed from the real prompts. It works for any hard-surface asset.
- Study before modelling. "Before writing any code, write notes.md: the proportions in metres, the 10 to 12 things that make this read as a GT race car at a glance, and what the player's camera sees. Then read the game code that loads the model and write down the contract."
- Build by script, in stages, looking each time. "One Blender script, run headless. After each stage render fixed views beside the references, look at them, and write what is still wrong before going on."
- Judge with a fresh agent. "You did not make this and owe its maker nothing. Use only these files. Answer in this form and nothing else."
- Rebuild one piece. "The judge said [quote]. Remake only the tail panel and lamps, depth first. Look at every round in the game at 6 to 8 m first, then close up."
- Then parallel helpers, one area each, merged into one script.
What made these prompts work: they are narrow (one piece, and an explicit list of what to read "and no more"), they quote the judge word for word, they set a bar ("would a player tell it apart from the best games of its kind?"), and they demand evidence as picture files, not claims.
What tripped us up
- Sidewall lettering came out mirrored. The tyre's UV axis was flipped.
- Decals got cut in half where two projections meet at the shoulder. Keep marks away from seams.
- The wing's wordmark sat on its top face, where the chase camera couldn't read it. It moved to the flap's underside, which that camera does see.
- The lamps sat 5 to 13 cm behind the body's surface. The lamps followed the function for the tail's shape, but the body didn't. Now both do, to within a centimetre.
- The inside of the wheel barrel mirrored the sky, "an empty bright bowl". It's now dark, matt and closed at the back.
- We nearly lost the story. Keeping every version and the brief that produced it is the only reason this write-up exists.
Try it
I packed everything into a teaching kit: the script, every commit of it, the real builder and judge prompts, every judge's verdict word for word, and the pictures from every stage. One command rebuilds the car.
https://github.com/satyam-fp/gt-car-from-scratch
If you build something with this loop, a vehicle, a weapon, a building, I'd love to see it. Reply with it.
Credits: the driver figure is built from Blender Studio's CC0 Human Base Meshes, and the sky is Poly Haven's evening_road_01 (CC0). All sponsor names on the car are invented.
来源:Satyam Kumar · x.com