Pure Vibe Coding in Practice: Building an AI-Generated 3D Physics Pinball Game
This article documents a hands-on vibe coding experiment that builds a single-file 3D physics pinball prototype using only natural language prompts. It covers the acceptance criteria, the alignment between the physics world and the rendering world, continuous collision handling, performance boundaries, and reusable prompt engineering patterns, along with a verification checklist for AI-generated graphics projects.
1. Why a 3D Physics Pinball Game Is a Good Test of AI Coding
When evaluating AI coding tools, parameters and benchmark scores only reflect static capability. What actually separates tools is an engineering task with medium complexity, tight coupling, and immediate visual feedback. A 3D physics pinball game meets all three criteria: it involves 3D coordinate systems, rigid body dynamics, the rendering pipeline, human-computer interaction, and UI layout at the same time, and any mistake in one of these areas shows up on screen immediately.
The goal of this hands-on test is to build a single-file 3D pinball prototype from scratch, using a common web rendering approach and a common rigid body physics approach, without hand-writing the core logic. The only input is natural language prompts that drive the AI coding tool. The test also observes how the result performs in terms of correctness, synchronization accuracy, and runtime stability. Note that the rendering and physics approaches used here are common open-source technology routes; this article does not evaluate any specific product or tool.
2. Preparation and Acceptance Criteria
The technology choices stay minimal: a single HTML file that loads a common 3D rendering library and a common rigid body physics library from a public CDN, with no build toolchain. The value of this setup is that AI-generated output can be run and verified immediately, keeping the feedback loop as short as possible.
Before starting, define quantifiable acceptance criteria instead of relying on a vague “it looks like it runs” judgment:
- Scene correctness: full-screen adaptation, a reasonable camera view, no clipping between the grid and the base plate, and no console errors.
- Synchronization accuracy: each rigid body’s position and quaternion must be mapped to the render object every frame, with no perceptible offset between the visuals and the collider.
- Stability: when many balls collide continuously, the frame rate does not drop off a cliff, and memory and VRAM do not keep growing.
- Interaction completeness: the orbit controller damping feels natural, and UI elements do not overlap in narrow viewports.
3. Hands-On Process and Key Issues
3.1 Step 1: Scene Initialization and Self-Healing
The first prompt only describes intent and does not prescribe implementation details, for example: “Build a single-file 3D pinball skeleton with full-screen adaptation, a dark tech-style grid floor, a damped orbit controller, and a tilted pinball base plate.”
The ideal output is not just “a cube plus a grid.” It should include a reasonable initial camera pose, renderer pixel ratio and color management settings, resize handling, and the tilt angle of the base plate. More importantly, watch for self-healing behavior: during preview, the tool detected that the text in the left and right info panels overlapped in a narrow viewport and adjusted the layout constraints on its own. This kind of “fix it after running” loop has more engineering value than generating correct code in one shot.
3.2 Step 2: Aligning the Physics World and the Rendering World
This is the step most likely to go wrong. There are three common mistakes: first, the physics world and the rendering world use different unit scales, which distorts the feel of gravity; second, only the render mesh of the tilted base plate is rotated while the rigid body is not, so the ball appears to float above the plate; third, the per-frame synchronization order is reversed, causing one frame of visual lag.
The correct approach is to establish a single source of truth: the physics world is the authoritative state, and render objects only read from it every frame without writing back.
// Advance physics with a fixed step to avoid tunneling caused by frame rate fluctuationconst fixedStep = 1 / 120;world.step(fixedStep, deltaTime, 3);// The render layer only performs read-only synchronizationmesh.position.copy(body.position);mesh.quaternion.copy(body.quaternion);
Also make sure the gravity direction matches the tilt direction of the base plate. Friction and restitution coefficients need to be tuned as a pair; otherwise you end up with two extremes: the ball stays still and never slides, or it bounces forever.
3.3 Step 3: Continuous Collision and Performance Boundaries
As the number of balls increases, the question shifts from “is it correct” to “is it stable.” The combination of thin, elongated objects and fast-moving balls is the most likely to cause tunneling. In engineering practice, this is usually addressed from three directions: increasing the physics step frequency, limiting the maximum number of substeps per frame, and adding thickness to key colliders or switching to more regular convex shapes.
On the rendering side, avoid creating a separate geometry and material for each ball; use instanced drawing to share resources instead. Textures and geometries should be reused throughout the page lifecycle, and creating objects inside the animation loop is forbidden. This is the baseline for preventing continuous growth of VRAM and memory.
// Instanced drawing: shared geometry and material significantly reduce draw callsconst instanced = new THREE.InstancedMesh(geo, mat, COUNT);scene.add(instanced);
4. Reusable Prompt Engineering Patterns
What actually worked in this test was not “making a wish in one sentence,” but breaking requirements into verifiable small steps: first the skeleton and adaptation, then physics alignment, then interaction feel, and finally performance and boundaries. Each round introduces only one new variable, so when something breaks, the cause can be located immediately. In addition, explicitly stating “do not introduce a build tool,” “deliver a single file,” and “fix errors yourself and explain the reason” significantly reduces wasted back-and-forth.
5. Conclusion and Recommendations
There are three conclusions. First, current AI coding tools can independently build the backbone of a medium-complexity graphics project and already have a basic awareness of runtime self-checking and correction. Second, physics and rendering synchronization and continuous collision stability still rely heavily on the user’s engineering judgment; specifying constraints and acceptance criteria in the prompt matters more than describing the appearance. Third, AI output should be treated as a high-quality draft and must be paired with three checks: zero console errors, cross-viewport layout, and a memory curve over long-running sessions.
Practical recommendations: put the acceptance criteria into the prompt up front; stick to fixed-step physics and read-only synchronization; use instancing and resource reuse to hold the performance baseline; and run the same verification checklist on every generated result. With this workflow, even when driven entirely by natural language, you can reliably deliver a playable and maintainable 3D physics mini-game prototype.
