Generalized Coding with Large Models: Building 3D Spaces Through Code with Visual Self-Checking
This article explores how large language models go beyond writing functions and APIs to "generalized coding" — using code to build a freely explorable 3D hot pot restaurant inside a 450㎡ virtual bare-shell space with web-based 3D rendering. It covers the experiment design with rigid constraints, the dual-loop workflow of modular code construction plus screenshot-based visual self-correction, a four-level spatial consistency verification, and three reusable practices: front-loading constraints, encouraging self-inspection, and layered acceptance.
1. What Is “Generalized Coding”: From Writing APIs to Building Spaces
Traditionally, our understanding of “models that can write code” stops at generating functions, completing APIs, and fixing errors. Generalized coding refers to a much broader coordinate system: anything that can be precisely described in a formal language — the DOM structure of a webpage, the geometry and materials of a 3D scene, a piece of interaction logic, or even a set of physics rules — can become the target of code generation.
This capability rests on two prerequisites. The first is stability of code generation: the model must be able to decompose complex tasks, organize modular code structures, and maintain consistency across multiple generations. The second is perception: the model needs visual understanding so it can “see” the rendered output of its own work and feed what it observes back into the code-revision loop. Only with both in place can a model extend from writing webpages and editing APIs to complex engineering tasks like spatial construction and interactive creation.
2. Experiment Design: Turning a 450㎡ Bare-Shell Room into a 3D Hot Pot Restaurant
To validate this capability, I designed a tightly constrained test task: given a 450㎡ virtual bare-shell room, generate — from scratch, using web-based 3D rendering — a complete hot pot restaurant that users can freely navigate.
The difficulty lies not in “stacking models” but in the rigidity of the constraints:
- Immutable structural locks. The positions of load-bearing columns, doors, windows, and the main walkway are all locked. Every piece of furniture placement and spatial division must work around these hard constraints.
- Multi-zone coordination. The storefront, main dining hall, private rooms, and kitchen circulation must form complete functional zones, with proportions between zones consistent with real commercial-space common sense.
- Dual-state switching. The same camera position must support toggling at any time between “bare shell” and “renovated.” This means every renovation element must sit strictly on top of the bare-shell coordinate system. Even a slight coordinate offset, a distorted proportion, or a single case of geometry clipping will be exposed the moment you switch the camera.
In other words, this task tests four dimensions simultaneously: spatial reasoning, geometric computation, modular engineering organization, and fidelity of visual detail.
3. Execution: The Dual Loop of Code Construction + Screenshot Self-Checking
The model’s actual workflow exhibits a clear two-layer loop.
The outer layer is the structural loop: the model first decomposes the entire space into modules — storefront and street front, dining hall tables and chairs, private-room partitions, table-level details — builds each one in code, then assembles them into a unified world coordinate system. This “decompose first, assemble later” approach is essentially the software-engineering principle of modularity transplanted into 3D space.
The inner layer is the visual self-check loop: after completing each module, the model proactively invokes its preview capability to screenshot the rendered result and inspects the image for problems that are hard to catch by reading code alone. In actual testing, it corrected an occlusion error where a wooden grille blocked a private-room doorway, and fixed a purely geometric detail where the divider inside a dual-flavor hot pot was misaligned with the red/white broth split — exactly the kinds of flaws that are easy to miss when only reading code.
The significance of this closed loop deserves emphasis. Traditional code generation is a one-way “generate–execute–read errors” pipeline. With visual feedback, it becomes an iterative “generate–render–observe–revise” process, and the granularity of the feedback signal rises from text logs to the pixel level.
4. Result Verification: Four Levels of Spatial Consistency
The final output is a complete webpage supporting multiple camera presets and free drag navigation. Verification can proceed from far to near across four levels:
- Street level. The signage, portico, and interior depth behind the glass curtain wall must connect naturally, immediately establishing the impression that “this is a real restaurant.”
- Main hall level. With the camera fixed, toggling back and forth between pre- and post-renovation, the four load-bearing columns and the 2.6-meter central axis walkway must remain completely still, while tables and booths unfold symmetrically on both sides — spatial order stays stable.
- Private-room level. Door openings, wooden grilles, and circulation paths align; from the entrance you can see straight through to the dining table inside, with no “looks like a restaurant from afar, falls apart up close” patchwork feel.
- Micro level. The red and white broths of the dual-flavor pot are cleanly separated along the divider, and teacups have realistic wall thickness and a visible tea surface. These details best test the model’s understanding of real-world physical common sense.
5. Practical Takeaways: How to Get the Most Out of Generalized Coding
This experiment yields three reusable lessons:
First, front-load constraints. Writing “what must not move” explicitly into the prompt is far more efficient than correcting errors afterward. The clearer the hard constraints, the more the model’s search space converges, and the more stable the output.
Second, encourage self-checking. Explicitly requiring the model in the task description to “render, take a screenshot, inspect, then revise” significantly activates its visual feedback loop and reduces low-level clipping errors.
Third, use layered acceptance. Complex spatial tasks should be verified in layers — “distant view, mid-shot, close-up, detail.” Different layers expose different types of problems, and layered checking helps locate root causes faster.
From a broader perspective, the fusion of code generation and visual understanding marks large models evolving from “text-to-text translators” into “intent-to-deliverable engineering executors.” When the geometry, materials, and interaction rules of 3D worlds can all be precisely described in code, the application scenarios of generalized coding will expand from web development into architectural design previews, game prototyping, virtual showrooms, and even digital twins. For developers, now is a good time to rethink the question: “What can be described in code?”
