ai21.net
语言

港口水母水体物理效果对比

演示视频

港口水母水体物理效果对比 — 1

提示词

Build "Harbor Jelly" — a single self-contained HTML file (no external requests, no libraries) that renders an interactive 3D diorama with WebGPU/WGSL: a small working container harbor set inside a square block of wobbly, translucent jelly sea, sitting on a paper studio backdrop. It belongs to a series called "Material Studies", so match that look: warm paper background, serif italic display title ("Harbor Jelly."), small uppercase eyebrow "MATERIAL STUDIES", a status pill top-right ("WebGPU · Live"), a frosted control panel on the right, and a "How to play" line bottom-left. English UI. Light theme only, by design.

THE BLOCK
- A 5.2 × 5.2 block seen from a 3/4 orbit camera. The ground and sea are cut flat at the block's sides, so you see candy-coloured soil strata in cross-section, and the sea's cut faces show everything underwater through the jelly.
- The water is a real-time linear shallow-water simulation on a staggered grid (heights at cell centres, velocities on faces) with a little surface tension, so it feels like jelly. Render it with refraction, absorption by depth, caustics projected onto the floor, light shafts, a Fresnel studio reflection, foam (wakes, splashes, a shoreline lace) and a bright meniscus on the cut edges.
- The whole block can be tipped by dragging its side. The water sloshes to the low side, the jelly shears and quivers, then it settles flat again.

THE HARBOR (layout)
- Along the back runs a vertical concrete quay wall, with rubber fenders, bollards, ladders, and mussels and weed crusting it below the waterline.
- Left part: a container terminal. A flat asphalt yard with painted lines, concrete strips with two crane rails, light towers, and a small terminal office. Hundreds of colourful containers are stacked in neat rows. Each is a ribbed steel box with door ends and darker corner posts, drawn as GPU instances in about ten liveries.
- Right part: an old stone fishing quay with a cobbled promenade, a corrugated fish-market shed and lamp posts. A timber pier stands on mussel-covered piles with cross-bracing, with two small fishing boats moored alongside.
- Behind it all, a town climbs a grassy hill: three rows of gabled houses in Nordic harbour colours (falu red, ochre, white, pale blue, mint, pink) with tiled or slate roofs, white-framed windows, doors and chimneys. There is a white church with a green copper spire, and some round trees.
- A rubble breakwater shelters the fishing harbour, with a concrete crown wall. Big rocks sit near the crest, smaller weedy ones tumble down under water. On its head stands a red-and-white banded lighthouse with a gallery and a glass lantern, whose lamp slowly turns.
- In the open basin: two small yachts swinging on their moorings (white hulls, coloured stripe, fin keels visible through the jelly, furled sails), yellow mooring buoys, and a green channel buoy, all bobbing on the waves.
- On the floor: pale sand with drifts of silt, weed tufts, stones, starfish, an old anchor with chain, a lost tyre.

THE SHIP'S DAY (fully automatic loop, about 100 s)
1. A small feeder container ship (navy topsides, red antifouling, white accommodation block at the stern with bridge wings, funnel with a yellow band, turning radar, visible propeller) lies alongside with containers on deck, 6 bays × 4 rows × 2 tiers.
2. Two ship-to-shore gantry cranes on the rails, one red and one blue, each with portal legs, a backreach with a machinery house, an A-frame with forestays, a hinged boom, a trolley with a hanging cab, and a yellow spreader on four wire falls. They lower their booms and swap boxes: unload from the tops of the ship's stacks into yard stacks, then load other boxes aboard. Every move is a smooth sequence: travel, trolley out, lower onto the box (tracking the ship's bobbing), latch, hoist, trolley across, lower, unlatch. Cranes never get closer than their leg width; an idle crane moves out of the other's way.
3. When the work is done the trolleys park, the booms swing up, and a tug comes round to the bow. The tug has a black hull, white and red superstructure, a tyre fender all round, a big bow fender, and puffs of funnel smoke. It passes a tow line and backs away, pulling the bow off the quay while the ship swings out. Then the line is cast off, the tug pivots on the spot and goes home, and the ship sounds her horn.
4. The ship sails a lap of the harbour along a smooth path, past the lighthouse. She rides the water on several sample points (heave, pitch, roll) and hands the displaced water back to the sim, so she leaves a real bow wave, wake and white water.
5. Meanwhile the tug goes out to a standby spot. When the ship stops off the quay, the tug noses in and pushes her sideways onto the fenders, with prop wash churning. Then it backs off, the booms come down, and the cranes start again.
- Keep everything collision-free (ship and tug vs. quay, breakwater, pier, yachts and buoy; no grounding). Check it with a headless node test.

LIFE
- Fish schools (mackerel, herring, small orange wrasse) as boids that stay in the water and under the hulls, scatter from fingers, splashes and moving ships, and come to food.
- Moon jellyfish: glassy pulsing bells with four pink rings, frilly oral arms and a fringe of tentacles. They drift with the water flow.
- Herring gulls (white body, grey mantle, black wingtips, yellow bill with a red spot). They circle, bank and glide, and land on perches: lamps, roof ridges, the church spire, the lighthouse gallery, the crane apexes, the ship's mast, the tug, the yachts' masthead. Perches on moving things move with them. They all take off when the horn sounds, and some dive at food.
- Steam puffs from the ship's funnel on the horn; tiny bubbles caught in the jelly.

CONTROLS (right panel; bottom sheet on phones)
- "Cast off" sends the ship early (cranes finish the box in hand). At sea the button becomes "Call her in" and hurries her home; it greys out while busy.
- "Horn" (also Space) plays a synthesized WebAudio ship horn: two low detuned sawtooth reeds a fifth apart, low-passed, starting only after a user gesture. It also blows steam and scatters the gulls.
- "Feed the fish" scatters pellets off the end of the pier; fish rush in and gulls swoop down.
- Tally: Boxes moved / Voyages / Fed. A ship status line ("Unloading 3 / 8", "Loading", "Booms up", "Tug coming", "Casting off", "At sea 40%", "Coming in", "Berthing"). A small activity meter.
- Flavour swatches change the water colour and strata: Sea glass (teal-mint), Blueberry (deep blue), Lime.
- Sliders: Firmness, Wave damping, Tide (±10 cm; the sea level, ships and floating things follow).
- Buttons: Reset, Pause, Sound on/off, Reset view.

POINTER INTERACTION
- Drag across the water to make waves (with a crosshair cursor).
- Drag the side of the block to tip it.
- Pick up an orange-and-white lifebuoy and throw it. Lifebuoys float flat on the waves, bounce off the pier, buildings and breakwater, and are shoved aside by the ship and tug.
- Drag empty space or right-drag to orbit; scroll or pinch to zoom.
- On phones: touch orbit, pinch zoom, and a collapsible bottom sheet for the controls.

RENDERING DETAILS
- Pipeline: shadow map → caustics pass → opaque scene (with a distance buffer) → back-face pass of the water → water pass over a copy of the scene → tone map + dither.
- Moving rigs are static vertex buffers whose vertices carry an object id; about 24 object transforms (position + quaternion) live in the uniform buffer. Cables are drawn with one end in each object's frame, so they stretch: crane falls, forestays, the tow line.
- Material kinds in the prop shader: matte paint, glass, gloss steel, roof tiles, timber grain, corrugated sheet (normal-perturbed ribs), dressed-stone masonry, rubber, rock, glowing lamps, swaying weed, and hulls with antifouling below a boot-top line.
- The jelly shear and squash wobble applies to everything inside the block.

QUALITY BAR
- Smooth on a laptop; simulation under about 2 ms per frame.
- A friendly fallback screen if WebGPU is missing or the adapter fails.
- No console errors, no page scroll. Respect prefers-reduced-motion.
- Ship it with a headless test of the choreography and a Playwright end-to-end test.

中文译文

构建 “Harbor Jelly” —— 一个单一的自包含 HTML 文件(不发起任何外部请求,不使用任何库),用 WebGPU/WGSL 渲染一个可交互的 3D 立体微缩景观:一座小型、正在运转的集装箱港口,坐落在一块方形、晃动而半透明的果冻海之中,整体置于纸质摄影棚背景上。它属于一个名为 “Material Studies” 的系列,所以要贴合那种观感:暖色纸质背景、衬线斜体展示标题(“Harbor Jelly.”)、小号大写眉题 “MATERIAL STUDIES”、右上角一枚状态胶囊(“WebGPU · Live”)、右侧一块磨砂控制面板,以及左下角一行 “How to play”。界面为英文。仅浅色主题,这是设计使然。

方块
- 一个 5.2 × 5.2 的方块,由 3/4 环绕相机观看。地面与海在方块的各侧被平整切开,因此你会看到剖面中糖果色的土层,而海的切面则透过果冻显露出水下的一切。
- 水是在交错网格上实时进行的线性浅水模拟(高度位于单元中心,速度位于网格面),并带有一点表面张力,所以触感像果冻。渲染它时要包含折射、按深度衰减的吸收、投射到地面上的焦散、光柱、一次菲涅尔式的影棚反射、泡沫(尾迹、飞溅、岸线蕾丝)以及切边上明亮的水弯月面。
- 整个方块可以通过拖动它的侧面来倾倒。水会涌向较低的一侧,果冻发生剪切并颤动,随后重新静止、恢复平整。

港口(布局)
- 沿后侧横亘着一道竖直的混凝土码头墙,配有橡胶护舷、系缆桩、爬梯,以及水线以下附着结壳的贻贝与水草。
- 左侧部分:一座集装箱码头。平坦的沥青堆场上有画好的标线,混凝土条带上铺着两条起重机轨道,另有高杆照明灯和一间小型码头办公室。成百上千个色彩鲜艳的集装箱整齐成排堆放。每个都是带肋的钢制箱体,端部有箱门,角柱颜色更深,以大约十种涂装作为 GPU 实例绘制。
- 右侧部分:一座古老的石砌渔码头,有鹅卵石步道、波纹铁皮鱼市棚屋和灯柱。一座木制栈桥架在覆满贻贝的桩上,带交叉支撑,旁边系泊着两条小渔船。
- 在这一切之后,一座小镇沿着长满草的山坡向上攀升:三排山墙房屋,用的是北欧港口常见的颜色(法伦红、赭黄、白色、浅蓝、薄荷绿、粉色),屋顶为瓦片或石板瓦,配白色窗框、门和烟囱。还有一座白色教堂,带绿色的铜尖顶,以及几棵圆冠树。
- 一道抛石防波堤为渔港提供遮蔽,顶上有一道混凝土胸墙。大块岩石靠近堤顶,更小、带水草的石头滚落到水下。堤头立着一座红白条纹相间的灯塔,带环廊和玻璃灯室,其中的灯缓慢旋转。
- 在开阔的港池中:两艘小帆船随系泊索摆动(白色船体、彩色条纹、透过果冻可见的鳍状龙骨、收起的帆),黄色系泊浮标,以及一个绿色航道浮标,全都在波浪上起伏。
- 在水底:浅色沙地,带着淤泥的流纹、成簇的水草、石块、海星、一只带着链条的旧锚、一只遗失的轮胎。

船的一天(全自动循环,约 100 秒)
1. 一艘小型支线集装箱船(深蓝色舷侧上部、红色防污漆、船尾白色上层建筑带驾驶台翼桥、带黄色色带的烟囱、旋转的雷达、可见的螺旋桨)靠泊,甲板上装着集装箱,6 舱位 × 4 排 × 2 层。
2. 轨道上有两台岸桥式龙门起重机,一台红色、一台蓝色,每台都有门架支腿、带机房的后伸臂、带前拉索的 A 形架、铰接臂架、带悬挂司机室的小车,以及由四根钢丝绳悬挂的黄色吊具。它们放下臂架并交换箱体:从船上堆垛的顶部卸到堆场堆垛,再把其他箱体装上船。每一次动作都是平滑的序列:大车行走、小车外伸、下降到箱体上(跟随船的起伏)、锁紧、起升、小车横移、下降、解锁。起重机之间永远不会比其支腿宽度更近;空闲的起重机会让开另一台的行进路线。
3. 作业完成后,小车归位停放,臂架向上摆起,一艘拖轮绕到船首。拖轮有黑色船体、白红相间的上层建筑、周身环绕的轮胎护舷、一个大型船首护舷,以及烟囱喷出的阵阵烟雾。它递过一根拖缆并向后倒退,把船首拉离码头,同时船身向外摆开。随后拖缆解掉,拖轮原地转向驶回,船则鸣响汽笛。
4. 船沿着一条平滑路径绕港区航行一圈,经过灯塔。她在若干采样点上随水面运动(垂荡、纵摇、横摇),并把排开的水体交还给模拟,因此留下真实的船首波、尾迹和白水。
5. 与此同时,拖轮驶出到待命位置。当船在码头旁停下时,拖轮探近,用船头顶推她的侧舷靠上护舷,螺旋桨尾流翻搅。随后它倒退离开,臂架落下,起重机重新开始作业。
- 保持一切无碰撞(船和拖轮 相对 码头、防波堤、栈桥、帆船与浮标;不得搁浅)。用一个无头 node 测试来检查。

生命
- 鱼群(鲭鱼、鲱鱼、橙色小隆头鱼)以 boids 行为移动,始终留在水中和船体之下,会因手指、水花和移动的船只而散开,并会聚到食物处。
- 月亮水母:玻璃般的搏动伞盖,带四个粉色环、花边的口腕和一圈触手。它们随水流漂移。
- 鲱鱼鸥(白色身体、灰色背羽、黑色翼尖、带红斑的黄色喙)。它们盘旋、侧倾、滑翔,并降落在栖木上:灯柱、屋脊、教堂尖顶、灯塔环廊、起重机顶端、船桅、拖轮、帆船的桅顶。落在移动物体上的栖木会随其移动。汽笛响起时它们全部起飞,有些会俯冲扑向食物。
- 汽笛响起时,船烟囱喷出蒸汽;微小的气泡被困在果冻里。

控制(右侧面板;手机端为底部抽屉)
- “Cast off” 让船提前出发(起重机把手头的箱体做完)。在海上时,该按钮变为 “Call her in”,催促她回港;忙碌时它变灰。
- “Horn”(也可用空格键)播放合成的 WebAudio 船笛:两个低音、失谐的锯齿波簧片相隔五度,经低通滤波,仅在用户手势之后才开始发声。它还会喷出蒸汽并惊飞海鸥。
- “Feed the fish” 从栈桥末端撒出颗粒饲料;鱼群冲进来,海鸥俯冲而下。
- 计数:Boxes moved / Voyages / Fed。一行船的状态(“Unloading 3 / 8”、“Loading”、“Booms up”、“Tug coming”、“Casting off”、“At sea 40%”、“Coming in”、“Berthing”)。一个小型活动量指示器。
- 风味色块会改变水色与土层:Sea glass(青绿-薄荷)、Blueberry(深蓝)、Lime。
- 滑块:Firmness、Wave damping、Tide(±10 cm;海平面、船只和漂浮物都会跟随)。
- 按钮:Reset、Pause、Sound on/off、Reset view。

指针交互
- 在水面上拖动可制造波浪(光标为十字准星)。
- 拖动方块的侧面可使其倾倒。
- 拾起一个橙白相间的救生圈并把它扔出去。救生圈平浮在波浪上,会从栈桥、建筑和防波堤上弹开,并被船和拖轮推开。
- 拖动空白处或右键拖动可环绕;滚动或双指捏合可缩放。
- 在手机上:触摸环绕、双指捏合缩放,以及一个可折叠的底部抽屉用于控制。

渲染细节
- 管线:阴影贴图 → 焦散通道 → 不透明场景(带距离缓冲)→ 水的背面通道 → 在场景副本之上进行的水通道 → 色调映射 + 抖动。
- 运动中的装置是静态顶点缓冲,其顶点携带对象 id;约 24 个对象变换(位置 + 四元数)存放在 uniform 缓冲中。缆索绘制时两端分别位于各自对象的坐标系中,因此会被拉伸:起重机钢丝绳、前拉索、拖缆。
- 道具着色器中的材质类型:哑光漆、玻璃、亮光钢、屋面瓦、木纹、波纹板(法线扰动的肋条)、琢石砌体、橡胶、岩石、发光的灯、摇曳的水草,以及水线带以下涂有防污漆的船体。
- 果冻的剪切与挤压晃动作用于方块内的一切。

质量标准
- 在笔记本电脑上流畅运行;每帧模拟耗时约 2 ms 以下。
- 若缺少 WebGPU 或适配器失败,显示一个友好的回退界面。
- 无控制台报错,页面不滚动。遵循 prefers-reduced-motion。
- 交付时附带针对编排的无头测试和 Playwright 端到端测试。

溯源

原作者
vib3coded
发布日期
2026-10-12(由推文 ID 反解)
原始出处
查看原帖 ↗
收录来源
zhuyansen/awesome-opus-5.5-video · 2109794326574227823 · 未声明许可