ai21.net
语言

从房间缩放到夸克的3D场景

演示视频

从房间缩放到夸克的3D场景 — 1从房间缩放到夸克的3D场景 — 2

提示词

INFINIZOOM

Build infinizoom: a procedural infinite-zoom world. The deliverable is a
self-contained BunJS project. Running `bun run server` must build and serve it
(wire up the corresponding "server" script in package.json). Three local assets
exist in this directory and must be used: ./macbook_interior.png (a real MacBook
Pro teardown photo), ./apple_m4_scheme.png (Apple's M4 die floorplan diagram),
and ./wallpaper.jpg (a 1920×1200 desktop wallpaper photo). Load the wallpaper
from this local file — never fetch content from external servers (the sole
exception: three.js itself may be imported from a CDN by URL).

The world

A single 3D world is traveled indefinitely along a fixed camera track that zooms
through these levels:

Main route: a room → a desk → a MacBook Pro → inside the chassis → the logic
board → the Apple M4 package → the M4 die → a performance core → an integer ALU
block → a standard logic cell → a FinFET transistor → a material cross-section
inside the fin → the silicon crystal lattice → one unit cell → an atom → its
nucleus → a nucleon → a quark. Logic gates and circuits (AND, OR, etc.) should
be animated as it computes.

Screen branch: exactly one bifurcation, hovering above the MacBook. Choosing the
other side dives into the display instead: the screen → the display panel →
pixel tiles → a pixel block → one pixel → its R/G/B sub-pixel LEDs → the
emissive layer → an emitter molecule → and converges to the same atom → nucleus
→ nucleon → quark tail. The leds must be accurate: 1-to-1 mapping from screen
pixels to leds, and their colors must match the color of that pixel. The screen
is animated and the LEDs are updated to match the animation in real time.

Riding the track forward IS zooming in; riding backward is zooming out. The
design must extend additively: adding a new structure = one render function +
one call in its parent; adding a bifurcation = one more route; a future backward
extension (t < 0: out the window → city → planet → universe) must require only
prepending track levels. A time parameter must be threaded through everything so
all animation stays possible at any depth.

Architecture (hard constraints)

- Mutable state is EXACTLY: one float t (position along the track), one branch
  bitstring (0 = left/A, 1 = right/D; a bit is pushed when passing a fork and
  popped when backing out below it), and raw input (keys held, mouse position).
  Every frame is a pure function of (t, branches, raw input, wall-clock time).
  No other state — no scene graph, no node objects, no stored world data, no
  caches of world structure.
- Renderers are pure functions that call their children directly: render_room()
  calls render_desk() calls render_macbook() … down to render_quark(). No
  dispatch layer, no classes. The call stack is the scene traversal.
- Scale-space warping via local unit frames: floats cannot hold meters and
  femtometers at once, so every renderer works in its own ~unit-sized local
  frame, and the camera is re-expressed into each child frame. Geometry math is
  done camera-relative in doubles, cast to float only at the very end, so the
  picture is artifact-free across all ~17 decades of scale. The exact same
  layout constants must place structures for rendering AND author the track —
  one source of truth, or the camera drifts visibly off the line.
- Immediate-mode rendering over three.js: every frame, the recursion emits
  primitives into instanced pools; three.js is only a rasterizer. Nothing
  off-screen or sub-pixel is emitted or recursed into.

The track and the camera

- Speed: fast. The whole main ride should take roughly 20 seconds, with a
  comfortable, constant-feeling time per level (exponential zoom feel) and
  gentle easing near the fork and the track ends.
- Shape: gently curved arcs. Not wandering, roundabout, or random-direction —
  but also NOT dead-straight rays. Soft, purposeful curves.
- The green line: the track is always visible in-scene as a translucent green
  line. It must be an infinitesimal line: ~2 pixels wide on screen at EVERY
  distance, implemented as a true GL line primitive (not tubes, not rods, not
  meshes of any kind), transparent (never rock-solid), and it must NEVER grow
  wider as it approaches or passes the camera — it is literally a path line,
  visible both near and far.
- The camera must never look at nothing. At every instant of the ride the view
  must be filled with structure. Concretely: every level approach is a diagonal
  glide (roughly 45°) over the parent surface — never a low horizontal skim
  (which puts empty void in the upper half of the screen) and never a
  straight-down drop (which degenerates the camera roll). Every level must
  render rich, non-uniform content at the distance where the camera arrives —
  never a flat gray plate.
- Dive points land dead-center inside meaningful sub-structures. The line must
  enter the CENTER of one of the small colored squares (a specific core on the
  die, a specific block in the core, a specific pixel on the screen) — never a
  border, edge, gap, seam, or gray filler zone. The boundary transitions between
  levels (e.g. performance core → integer ALU block, "100 µm across") must be
  scrutinized: the camera must be looking at detailed structure the whole way
  through.
- Occlusion never pops: every shell the camera is about to pierce (the keyboard
  deck, the transistor's gate, the LED's cathode, the screen's cover glass…)
  fades away smoothly as a pure function of t shortly before the camera reaches
  it, and fades back identically when riding out.

Controls and HUD

- W rides deeper, S rides back.
- At the bifurcation: a big translucent ‹ on the left edge and › on the right
  edge of the screen, each labeled with its key (A / D), with the currently
  selected side highlighted/glowing. No sentence-style instruction text.
- Mouse moves the glance direction with a full 360° range — the rider can look
  all the way around, including behind.
- A title at the top-left always names where we are right now (e.g. "performance
  core") together with the current physical scale ("3.2 mm across").

Content — fidelity and density

Everything must be densely detailed — think "10× more detail than feels
sufficient" — and hiding must be un-aggressive: distant and peripheral objects
stay visible; more detail is always preferred over less. Everything plausible
must be animated and alive.

- The room and desk: a believable day-lit room (window, curtains, floor, walls,
  shelf, chair, door, rug, a wall clock whose hands actually run, lamps, cables)
  and a believable desk (the MacBook, a potted plant, paper, a mug, books,
  phone, pens…).
- The MacBook exterior: correct proportions, full keyboard with per-key legends,
  trackpad, ports, hinge, screen bezel with notch and camera.
- The MacBook interior: there are many components inside a MacBook — reproduce
  them in pixel-perfect locations matching ./macbook_interior.png: the two fans
  (with visibly SPINNING, clearly readable impeller blades — use few chunky
  blades, not a dense blur), the S-curved heat pipe and heat spreader, the black
  logic board carpeted in passives with EMI shields and chips, the antenna bar
  along the hinge, side port boards, the 4-corner + 2-tall-center battery cell
  layout with printed labels, aluminum struts, the trackpad flex cable running
  down the middle to its gold connector, the flanking speakers, tape, thermal
  pads, screws — all of it.
- The M4 die: block placement faithful to ./apple_m4_scheme.png (4 P-cores +
  shared L2, 6 E-cores + L2, 10 GPU cores, 16 Neural Engine cores, SLC,
  media/display engines, ISP, Secure Enclave, memory PHYs on the edges), with no
  bare/gray substrate anywhere — every area is a labeled block, and blocks show
  interior sub-structure at every intermediate zoom. The CPU interior (core
  floorplan: caches, decoders, schedulers, ALUs, FP units, register files…) must
  be greatly detailed, not a few flat rectangles.
- Digital circuits doing operations — explicitly a top-priority feature: the
  zoom must pass through logic that is visibly COMPUTING. Standard cells are
  real gates (AND/OR/NAND/NOR/XOR/NOT): their input nets carry live 0/1 signals
  (bright = 1, dark = 0), their output is the actual boolean function of the
  inputs, pulses race along wires when gates switch, and whole logic blocks
  twinkle with switching activity at every zoom level.
- Animated electronic simulation: the FinFET's gate runs a live drive waveform,
  and while it is open, charge carriers visibly flow from source to drain.
  Continue through real materials: gate oxide, dopants, the diamond-cubic
  silicon lattice at its true 0.543 nm pitch, into atoms with orbiting
  electrons, a nucleus with protons/neutrons and an animated gluon field, down
  to quarks.
- The screen must be REAL: a real image at real MacBook-panel fidelity — the
  bundled ./wallpaper.jpg photo as the desktop background, with a procedurally
  drawn OS on top (menu bar, dock with recognizable icons, overlapping
  application windows: a code editor with syntax-colored lines, a file browser,
  a terminal with a blinking cursor, and a video window that visibly plays,
  animating at full frame rate). Never a mosaic of colored squares. All levels
  of the screen (full panel → tiles → pixels → sub-pixel brightness) must sample
  the SAME image function so content never changes across zoom, and detail must
  increase strictly monotonically as the camera approaches — at no zoom distance
  may the screen become LESS detailed than it was a moment before.
- The sub-pixel LEDs: each LED is lit by the ACTUAL channel value of the
  on-screen image at that exact pixel — realistic and accurate, not default
  colors. Because the screen animates, the LEDs visibly CHANGE color over time.
  The dive targets a pixel inside the playing video, where R, G and B clearly
  differ from each other and keep changing. Inside, an LED is not a solid: model
  the full OLED stack — the TFT drive circuit with its data/scan lines and
  storage capacitor, the reflective anode, transport layers, the emission layer,
  the semi-transparent cathode, auxiliary wiring, spacers, encapsulation — with
  a live simulation: holes drift up, electrons drift down, they recombine in the
  emission layer with a flash, and photons fly up and out. Below that, the
  emissive layer resolves into a molecular film, then a single emitter molecule
  built of real atoms, joining the shared atomic tail.

Visual-quality laws

- Nothing ever pops, flickers, or z-fights — anywhere, at any scale, moving in
  either direction. In particular: never emit overlapping coplanar surfaces or
  nested coincident translucent volumes; and any material exempted from fog
  (emissive screens, glass, glow) must still be manually distance-faded and
  culled, or shells belonging to enclosing structures will haunt the camera at
  deep zooms as giant flickering planes.
- All LOD transitions are smooth morphs or strictly-finer refinements of
  identical content — never a swap to something coarser, blurrier, or
  differently colored.
- Spinning/periodic animations must be tuned to be perceptible (no temporal
  aliasing that freezes or scrambles them).
- Runs at 60 fps.

Code Quality

Ensure your implementation is concise, minimal, elegant. Use pure functions as
much as possible. Keep it very Haskell-like, even though it is TypeScript. Most
of the complexity of the function comes from the different objects that are
rendered, and each object is a render function. Each renderable object must live
in its own file at src/render/<name>.ts — that directory is the one that scales
as we add more renderables. Organize the project such that it can scale by just
adding more render functions/files under src/render/. Avoid unnecessary
complexity.

中文译文

INFINIZOOM

构建 infinizoom:一个程序化生成的无限缩放世界。交付物是一个自包含的 BunJS 项目。运行 `bun run server` 必须能构建并启动服务(把 package.json 中对应的 "server" 脚本接好)。该目录下存在三个本地资源,必须使用:./macbook_interior.png(一张真实的 MacBook Pro 拆解照片)、./apple_m4_scheme.png(Apple 的 M4 裸片平面图)以及 ./wallpaper.jpg(一张 1920×1200 的桌面壁纸照片)。壁纸要从这个本地文件加载——绝不要从外部服务器获取内容(唯一例外:three.js 本身可以通过 URL 从 CDN 导入)。

世界

沿着一条固定的相机轨道无限穿行于同一个 3D 世界,依次缩放穿过这些层级:

主路线:房间 → 书桌 → MacBook Pro → 机身内部 → 逻辑板 → Apple M4 封装 → M4 裸片 → 一个性能核 → 一个整数 ALU 块 → 一个标准逻辑单元 → 一个 FinFET 晶体管 → 鳍片内部的材料截面 → 硅晶体晶格 → 一个晶胞 → 一个原子 → 它的原子核 → 一个核子 → 一个夸克。逻辑门和电路(AND、OR 等)应在运算时播放动画。

屏幕分支:恰好一个分叉,悬浮在 MacBook 上方。选择另一侧则会潜入显示屏:屏幕 → 显示面板 → 像素瓦片 → 一个像素块 → 一个像素 → 它的 R/G/B 子像素 LED → 发光层 → 一个发光分子 → 并汇聚到同一个原子 → 原子核 → 核子 → 夸克尾段。LED 必须准确:从屏幕像素到 LED 是 1 对 1 映射,且它们的颜色必须与该像素的颜色一致。屏幕是动态的,LED 要实时更新以匹配动画。

沿轨道向前行驶就是放大;向后行驶就是缩小。设计必须可增量扩展:新增一个结构 = 一个渲染函数 + 在其父级中的一次调用;新增一个分叉 = 多一条路线;未来的向后扩展(t < 0:飞出窗户 → 城市 → 行星 → 宇宙)必须只需要在轨道层级前面追加。时间参数必须贯穿所有环节,以便在任何深度都保持一切动画可用。

架构(硬性约束)

- 可变状态恰好是:一个浮点数 t(沿轨道的位置)、一个分支位串(0 = 左/A,1 = 右/D;经过岔口时压入一位,退回其下方时弹出该位),以及原始输入(按住的按键、鼠标位置)。每一帧都是 (t、分支、原始输入、墙上时钟时间) 的纯函数。没有其他状态——没有场景图、没有节点对象、没有存储的世界数据、没有世界结构的缓存。
- 渲染器是直接调用其子级的纯函数:render_room() 调用 render_desk() 调用 render_macbook() ……一路到 render_quark()。没有分发层,没有类。调用栈就是场景遍历。
- 通过局部单位坐标系进行尺度空间扭曲:浮点数无法同时承载米和飞米,因此每个渲染器都在自己约单位大小的局部坐标系中工作,相机则被重新表达到每个子级坐标系中。几何数学以双精度、相对相机完成,只在最后才转换为浮点数,所以画面在约 17 个数量级的尺度范围内都没有伪影。必须用完全相同的布局常量来摆放渲染结构并编排轨道——单一事实来源,否则相机会明显偏离线路。
- 基于 three.js 的即时模式渲染:每一帧,递归把图元发射到实例化池中;three.js 只是一个光栅化器。任何屏幕外或亚像素的东西都不会被发射或递归进入。

轨道与相机

- 速度:快。整段主旅程大约用时 20 秒,每个层级的时间感觉舒适而恒定(指数缩放手感),并在分叉处和轨道两端附近平缓地缓动。
- 形状:平缓弯曲的弧线。不是游移、绕行或随机方向的——但也绝不是完全笔直的射线。柔和且有目的性的曲线。
- 绿线:轨道始终以一条半透明绿线的形式在场景中可见。它必须是一条无限细的线:在每一个距离上屏幕宽度都约为 2 像素,以真正的 GL 线图元实现(不是管、不是杆、不是任何形式的网格),透明(绝不实心),而且当它靠近或经过相机时绝不能变宽——它字面上就是一条路径线,远近都可见。
- 相机绝不能看向空无一物之处。旅程的每一个瞬间,视野都必须被结构填满。具体来说:每次接近一个层级,都是在父级表面上方沿对角线滑翔(约 45°)——绝不是低空水平掠过(那会让屏幕上半部分成为空白虚空),也绝不是垂直下落(那会使相机滚转退化)。每个层级都必须在相机抵达的距离上渲染出丰富、非均匀的内容——绝不是一个平坦的灰色平板。
- 下潜点要正落在有意义的子结构正中央。线路必须进入某个小的彩色方块的中心(裸片上某个特定的核、核内某个特定的块、屏幕上某个特定的像素)——绝不是边界、边缘、间隙、接缝或灰色填充区。层级之间的边界过渡(例如性能核 → 整数 ALU 块,"100 µm across")必须仔细检查:相机在整个过程中都必须一直看着细节丰富的结构。
- 遮挡绝不突兀跳变:相机即将穿透的每一层外壳(键盘面、晶体管的栅极、LED 的阴极、屏幕的盖板玻璃……)都会在相机抵达前不久,作为 t 的纯函数平滑淡出,并在向外返回时以相同方式淡回。

控制与 HUD

- W 向更深处行进,S 往回行进。
- 在分叉处:屏幕左边缘有一个大的半透明 ‹,右边缘有一个 ›,各自标注其按键(A / D),当前选中的一侧高亮/发光。不要有句子式的说明文字。
- 鼠标以完整的 360° 范围移动视线方向——乘坐者可以环顾一整圈,包括身后。
- 左上角始终有一个标题,标明我们此刻所在的位置(例如 "performance core"),以及当前的物理尺度("3.2 mm across")。

内容——保真度与密度

一切都必须细节密集——就按“比感觉足够再多 10× 的细节”去想——并且隐藏必须不激进:远处和周边的物体保持可见;细节总是宁多勿少。一切说得通的东西都必须有动画、有生命。

- 房间与书桌:一个可信的日间采光房间(窗户、窗帘、地板、墙壁、架子、椅子、门、地毯、一个指针真的会走的挂钟、台灯、线缆)和一张可信的书桌(MacBook、一盆植物、纸张、一个马克杯、书、手机、笔……)。
- MacBook 外观:正确的比例、带每个按键字符的完整键盘、触控板、接口、转轴、带刘海和摄像头的屏幕边框。
- MacBook 内部:MacBook 内部有很多组件——按与 ./macbook_interior.png 一致的位置、像素级精确地复现它们:两个风扇(叶轮叶片要能明显看出正在旋转、清晰可辨——用少量厚实的叶片,而不是一片密集的模糊)、S 形弯曲的热管和均热板、铺满无源元件并带有 EMI 屏蔽罩和芯片的黑色逻辑板、沿转轴的天线条、侧边接口板、带印刷标签的 4 个角部 + 2 个竖向中央的电池电芯布局、铝制支撑梁、从中间延伸至其金色连接器的触控板排线、两侧的扬声器、胶带、导热垫、螺丝——所有这些。
- M4 裸片:模块布局忠实于 ./apple_m4_scheme.png(4 个 P 核 + 共享 L2、6 个 E 核 + L2、10 个 GPU 核、16 个 Neural Engine 核、SLC、媒体/显示引擎、ISP、Secure Enclave、边缘的内存 PHY),任何地方都没有裸露/灰色的基板——每个区域都是带标签的块,且每个中间缩放级别下这些块都显示出内部子结构。CPU 内部(核心平面图:缓存、解码器、调度器、ALU、FP 单元、寄存器堆……)必须高度详细,而不是几个扁平矩形。
- 正在执行运算的数字电路——明确列为最高优先级特性:缩放必须穿过肉眼可见正在计算的逻辑。标准单元是真正的门(AND/OR/NAND/NOR/XOR/NOT):它们的输入网络承载实时的 0/1 信号(亮 = 1,暗 = 0),其输出是输入的真正布尔函数,门翻转时脉冲沿导线飞驰,整个逻辑块在每个缩放级别都随开关活动闪烁。
- 动态电子仿真:FinFET 的栅极运行实时驱动波形,当其开启时,电荷载流子明显地从源极流向漏极。继续穿过真实材料:栅氧化层、掺杂剂、真实 0.543 nm 间距的金刚石立方硅晶格,进入带有轨道电子的原子、带有质子/中子和动态胶子场的原子核,直到夸克。
- 屏幕必须是真实的:真实图像,达到真实 MacBook 面板的保真度——以随附的 ./wallpaper.jpg 照片作为桌面背景,上面叠加程序化绘制的操作系统(菜单栏、带可识别图标的程序坞、相互重叠的应用窗口:一个带语法着色代码行的代码编辑器、一个文件浏览器、一个光标闪烁的终端,以及一个能明显播放、以完整帧率动画的视频窗口)。绝不要彩色方块拼成的马赛克。屏幕的所有层级(整个面板 → 瓦片 → 像素 → 子像素亮度)都必须采样同一个图像函数,使内容在缩放过程中永不改变,而且细节必须随相机接近严格单调增加——在任何缩放距离上,屏幕都不能比前一瞬间更不精细。
- 子像素 LED:每个 LED 由该精确像素处屏幕图像的实际通道值点亮——真实而准确,而不是默认颜色。由于屏幕是动态的,LED 的颜色会随时间明显变化。下潜目标是正在播放的视频内的一个像素,那里 R、G、B 三者明显互不相同且持续变化。进入内部后,LED 不是实心体:建模完整的 OLED 堆栈——带数据/扫描线和存储电容的 TFT 驱动电路、反射阳极、传输层、发光层、半透明阴极、辅助布线、间隔物、封装——并配有实时仿真:空穴向上漂移,电子向下漂移,它们在发光层中复合并伴随闪光,光子向上飞出。再往下,发光层解析为分子薄膜,然后是由真实原子构成的单个发光分子,汇入共享的原子尾段。

视觉质量法则

- 任何东西都绝不突兀跳出、闪烁或发生 z-fighting——任何位置、任何尺度、任何移动方向。特别是:绝不发射相互重叠的共面表面或嵌套重合的半透明体;任何免于雾效的材质(自发光屏幕、玻璃、辉光)仍必须手动做距离淡出和剔除,否则属于外层结构的外壳会在深度缩放时以巨大闪烁平面的形式萦绕在相机前。
- 所有 LOD 过渡都是平滑变形,或对相同内容的严格更精细细化——绝不是换成更粗糙、更模糊或颜色不同的东西。
- 旋转/周期性动画必须调到可感知的程度(不要出现让它们冻结或错乱的时间混叠)。
- 以 60 fps 运行。

代码质量

确保你的实现简洁、最小、优雅。尽可能使用纯函数。即使它是 TypeScript,也要保持非常像 Haskell 的风格。函数的大部分复杂性来自被渲染的不同对象,而每个对象都是一个渲染函数。每个可渲染对象都必须位于 src/render/<name>.ts 自己的文件中——随着我们添加更多可渲染对象,扩展的正是这个目录。组织项目,使其只需在 src/render/ 下添加更多渲染函数/文件就能扩展。避免不必要的复杂性。

溯源

原作者
VictorTaelin
发布日期
2026-09-25(由推文 ID 反解)
原始出处
查看原帖 ↗
收录来源
yihui-dev/awesome-opus5-5-videos · victortaelin-875778 · MIT
zhuyansen/awesome-opus-5.5-video · 2103299766473875778 · 未声明许可
本条由 2 个来源合并去重得来