ai21.net
語言

可互動的果凍西瓜玩具

示範影片

可互動的果凍西瓜玩具 — 1

提示詞

Build "Whole Melon": a single self-contained HTML file (all JS/CSS inline, no build step, no libraries) with a big whole watermelon made of glossy jelly that you can grab, wobble and cut into pieces with a knife. Render with raw WebGPU (WGSL); if WebGPU is missing, show a clean fallback card.

SHAPE AND MATERIAL
- The melon is a signed distance field: an ellipsoid (~32 cm long) lying on its side with a softly flattened belly.
- Layers by depth under the skin: dark-green skin with irregular darker stripes running pole to pole (seamless all the way around), a pale pith band, then translucent red flesh that brightens toward the rind. Add a pale yellow field spot on the belly, a stem scar at one end and a blossom end at the other.
- About 700 seeds in a three-lobed ring at roughly two thirds of the radius (teardrops, wide end pointing outward), plus tiny air bubbles. Mesh seeds only near cut faces; a seed the knife goes through is kept by one side and eased just under the new face, so it shows through a thin film of jelly.
- Three varieties: Crimson, Golden, Rosé.

PIECES AND CUTTING
- Every piece is the melon SDF clipped by the half-spaces of the cuts that made it, with the fresh edges rounded (smooth max). All pieces share the melon's original rest frame, so rind, pith, stripes and seeds stay exactly where they grew.
- Knife tool: the user draws a line across the melon. Read the stroke on top of what it crosses to get a vertical blade plane. For each piece the plane passes through, fit the piece's best rotation, carry the plane into rest space, and split the piece in two.
- Build the new pieces cooperatively (generators with a per-frame time budget) while a steel knife (brushed blade, wooden handle with rivets) lines up over the stroke and presses a groove into the jelly. Swap the new pieces in the moment the edge breaks through, carrying over the position and velocity of the flesh they came from, and let the blade wedge them apart as it sinks. Allow up to about 24 pieces and reject slivers.
- For each piece: a surface-nets render skin (evaluate only the blocks near the surface, one Newton step onto it), a hex lattice in the piece's principal frame with boundary nodes snapped onto the surface, and a fast barycentric embedding.

PHYSICS (XPBD on the CPU, fixed 60 Hz, 6 substeps)
- Cell-wise co-rotational shape matching (8-node cells, warm-started rotation, strain stiffening), tet volume constraints for near-incompressibility, rind firmer than flesh.
- Edge damping, plus damping of each piece's deformation relative to its rigid motion (never its fall or tumble), rolling resistance on the table, and sleep when calm.
- Piece-to-piece contact against each other's exact SDF in a best-fit frame; sleeping pieces act as walls. Floor contact with Coulomb friction.
- Hand tool: grab any piece and pull (soft patch attachment, with enough reach to drag pieces across a wide table). Scroll or a second finger twists while holding. Pinch or scroll zooms; dragging the empty table orbits the camera.

RENDERING (a photographic product shot)
- Procedural studio: pale paper sweep, overhead softbox, back-left strip light, cool fill card.
- Jelly: front faces refract the scene behind by the view-ray thickness (nearest-back-face pass), with Beer–Lambert absorption per material, milky scattering in the pith, a back-lit glow at thin edges, sugar glints, Fresnel studio reflections and GGX highlights.
- Seeds, bubbles and the knife are drawn before the jelly, so they are seen refracted through it.
- Normals follow the jelly's local deformation (cofactor of the node-averaged deformation gradient).
- A soft key shadow coloured by what the light crossed first (rosy through flesh, dark through rind), plus contact occlusion from a top-down height map. MSAA, Khronos PBR Neutral tone mapping.

UI (editorial, like a material study)
- Kicker "Material Studies / No. 010" and a big italic serif title "Whole / Melon."
- A panel with Tool (Hand / Knife), Variety, Firmness and Internal damping sliders, Nudge, Reset, ¼ speed, Show mesh and Pause.
- Live readouts: mass, volume %, kinetic energy, piece count. A collapsible "Inside the experiment" note.
- Responsive down to phones.

Quality bar: it should look and move like a real glossy jelly watermelon, and every cut face should look like a sliced jelly melon with seeds just under the surface. Test headlessly with screenshots: the whole melon, mid-cut, many pieces, a close-up of a cut face, and mobile.

中文翻譯

構建 "Whole Melon":一個單一的自包含 HTML 文件(所有 JS/CSS 內聯,無構建步驟,無庫),其中包含一個由光澤果凍製成的大個完整西瓜,你可以抓取、晃動並用刀切成塊。使用原生 WebGPU(WGSL)渲染;如果沒有 WebGPU,顯示一張簡潔的降級提示卡。

形狀與材質
- 瓜體是一個有符號距離場:一個側躺的橢球體(長約 32 cm),腹部柔和地壓扁。
- 表皮下按深度分層:深綠色表皮,帶有從一極延伸到另一極的不規則深色條紋(整圈無縫),一條淺色白瓤帶,然後是半透明紅色果肉,越靠近外皮越亮。在腹部添加一塊淡黃色的着地斑,在一端添加一個瓜蒂疤痕,在另一端添加花蒂端。
- 約 700 顆種子,位於半徑約三分之二處的三瓣環上(淚滴形,寬端朝外),外加細小的氣泡。僅對切面附近的種子進行網格化;被刀切穿的一顆種子由其中一側保留,並被輕輕移到新切面之下,讓它透過一層薄薄的果凍顯現出來。
- 三個品種:Crimson、Golden、Rosé。

切塊與切割
- 每一塊都是瓜體 SDF 被構成它的那些切割的半空間裁剪後的結果,新切出的邊緣做了圓角處理(smooth max)。所有塊共享瓜體原始的靜止座標系,因此瓜皮、白瓤、條紋和種子都停留在它們原本生長的確切位置。
- 刀具:用戶橫跨瓜體畫一條線。讀取疊加在它所穿過對象上的筆畫,得到一個豎直的刀片平面。對於該平面穿過的每一塊,擬合該塊的最佳旋轉,把平面帶入靜止空間,然後將該塊一分爲二。
- 以協作方式構建新的塊(使用帶每幀時間預算的生成器),同時一把鋼刀(拉絲刀身、帶鉚釘的木柄)在筆畫上方對準,並在果凍上壓出一道凹槽。在刀刃切穿的那一刻換入新的塊,沿用它們所來自的果肉的位置和速度,並讓刀身在下沉時把它們楔開。最多允許約 24 塊,並拒絕薄片。
- 對每一塊:一個 surface-nets 渲染表皮(只對表面附近的塊求值,並對其做一步 Newton 迭代)、一個位於該塊主軸座標系中的六面體晶格且邊界節點吸附到表面,以及一個快速的重心座標嵌入。

物理(CPU 上的 XPBD,固定 60 Hz,6 個子步)
- 逐單元的共旋轉形狀匹配(8 節點單元、熱啓動旋轉、應變硬化)、用於近似不可壓縮性的四面體體積約束,瓜皮比果肉更硬。
- 邊阻尼,加上每一塊相對於其剛體運動的形變阻尼(絕不是其下落或翻滾),桌面上的滾動阻力,以及靜止時休眠。
- 塊與塊之間的接觸在最佳擬合座標系中針對彼此精確的 SDF 計算;休眠的塊充當牆壁。與地板接觸並帶庫侖摩擦。
- 手部工具:抓住任意一塊並拉動(軟性面片附着,作用範圍足以在寬大的桌面上拖動各塊)。按住時滾動或第二根手指會扭轉。捏合或滾動可縮放;拖動空桌面則環繞相機。

渲染(一張攝影級產品照)
- 程序化影棚:淺色無縫背景紙、頂部柔光箱、左後方條形燈、冷色補光板。
- 果凍:正面按視線射線厚度(最近背面通道)折射其後的場景,並按材質應用 Beer–Lambert 吸收、白瓤中的乳濁散射、薄邊緣處的背光發光、糖晶閃爍、Fresnel 影棚反射和 GGX 高光。
- 種子、氣泡和刀在果凍之前繪製,因此會透過果凍被折射看到。
- 法線跟隨果凍的局部形變(節點平均形變梯度的餘子式)。
- 一片柔和的主光陰影,其顏色由光線最先穿過的材質決定(穿過果肉呈玫瑰色,穿過瓜皮呈深色),再加上來自俯視高度圖的接觸遮蔽。MSAA、Khronos PBR Neutral 色調映射。

界面(編輯風格,像一份材質研究)
- 眉題 "Material Studies / No. 010",以及大號斜體襯線標題 "Whole / Melon."
- 一個面板,包含 Tool (Hand / Knife)、Variety、Firmness 和 Internal damping 滑塊,以及 Nudge、Reset、¼ speed、Show mesh 和 Pause。
- 實時讀數:質量、體積 %、動能、塊數。一段可摺疊的 "Inside the experiment" 說明。
- 響應式,可適配到手機。

質量標準:它的外觀和運動都應該像一個真實的、有光澤的果凍西瓜,每個切面都應該看起來像切開的果凍西瓜,種子就在表面之下。用截圖進行無頭測試:完整西瓜、切割中、許多塊、一個切面特寫,以及移動端。

溯源

原作者
vib3coded
發佈日期
2026-10-02(由推文 ID 反解)
原始出處
查看原帖 ↗
收錄來源
zhuyansen/awesome-opus-5.5-video · 2106056420131029473 · 未聲明授權