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 · 未聲明授權