ai21.net
語言

瀏覽器中可交互的3D果凍橙子

示範影片

瀏覽器中可交互的3D果凍橙子 — 1

提示詞

Build "Whole Orange Jelly" — a single self-contained HTML file (inline JS/CSS, no libraries): a real-time WebGPU soft-body whole orange made of jelly. The user can grab and stretch it, and cut it with a knife into wheels, wedges and small pieces. Every piece is its own wobbling body.

Shape and pieces
- The orange is a signed distance field: a gently oblate ellipsoid (polar half-length 1.27 along x, equatorial radius 1.36) lying on its side, with a softly flattened seat on the floor.
- Every piece is that field clipped by the half-spaces n·X ≤ c of the cuts that made it, with the fresh edges rounded (smooth max, k ≈ 0.085). All pieces share the orange's original rest frame, so the anatomy stays where it grew.
- Per piece:
- a surface-nets render skin (0.042 grid) projected onto the field;
- a hex lattice for the simulation in the piece's own principal frame, with boundary nodes snapped to the surface;
- barycentric embedding of render vertices into the lattice tets.
- Up to 30 pieces; slivers are rejected.

Anatomy (all in rest space, so every cut shows it where it really is)
- Zest (0.07 deep) with oil-gland pores, a mottled tone, a green stem button at one end and a small navel at the other.
- White pith (to 0.19 deep).
- 11 segments around the stem axis, with thin milky membrane walls (slightly jittered, bowed and wandering along the axis) and a pithy core along the axis.
- Juice vesicles: teardrop sacs fanning out from the core within each segment.
- 16 pale citrus pips near the core, pointed end inward; a few small bubbles in the flesh.
- A pip that a cut goes through is kept by the side holding its centre and eased just under the new face.

Physics (XPBD)
- Per piece: hex cells with co-rotational shape matching plus volume constraints on their five tets.
- Zest and pith firmer than the flesh.
- Edge and deformation damping; floor contact with Coulomb friction and a little rolling resistance.
- Piece–piece contact against each other's exact rest shape in a best-fit frame.
- Sleeping pieces that wake on touch; fixed 60 Hz step with small substeps.

Knife
- A nakiri-style knife: draw a stroke across the orange.
- The stroke, read on the top of what it crosses, fixes a vertical blade plane, carried into each crossed piece's rest frame by its best-fit rotation and added as a half-space.
- The new pieces are built incrementally while the knife lines up, presses a groove and cuts straight down. They take over the position and speed of the jelly they came from, and the blade wedges the faces apart.

Rendering (WebGPU / WGSL)
- Procedural photo studio. Soft PCSS key shadow tinted by the jelly, plus contact AO from a height map.
- Back-face thickness; refraction of the scene, with each tap dimmed by its own path length.
- A volumetric march through the jelly in rest space, using a per-vertex inverse deformation gradient:
- zest, pith, membranes/core and flesh each absorb with their own colour (Beer–Lambert);
- scattering is grey (only absorption is coloured), so light scattered out of orange flesh stays orange.
- The white pith, the membrane star and the core read crisply on cut faces.
- Back-lit glow at thin edges, Fresnel studio reflections, GGX highlights, sugar-crystal glints.
- Post: Khronos PBR Neutral tone mapping, sRGB, dither.

UI (editorial "Material Studies / No. 032", English)
- Italic serif title "Whole / Orange." with the caption "Eleven segments, set in jelly. Zest, pith and juice. Cut it as small as you like."
- Status pill "WEBGPU · LIVE".
- Tools: Hand / Knife. Varieties: Navel, Blood, Cara Cara.
- Firmness and Internal damping sliders; Give it a nudge, Reset, Pause; ¼ speed and Show mesh.
- Readouts: Mass (g, 1 unit ≈ 3 cm at 1.3 g/cm³), Volume (% of rest), Kinetic (mJ), Pieces.
- A collapsible "Inside the experiment" with notes on the method.
- Fallback without WebGPU. Stacked mobile layout with no horizontal scroll.

中文翻譯

構建“Whole Orange Jelly”——單個自包含 HTML 文件(內聯 JS/CSS,無庫):一個由果凍製成的實時 WebGPU 軟體完整橙子。用戶可以抓住並拉伸它,用刀把它切成圓片、楔形塊和小塊。每一塊都是自己獨立顫動的物體。

形狀與切塊
- 橙子是一個有符號距離場:一個略微扁平的橢球(沿 x 的極半軸長 1.27,赤道半徑 1.36),側放着,底部與地面接觸處有柔和壓扁的坐面。
- 每一塊都是該場被切出它的那些切割的半空間 n·X ≤ c 裁剪後的結果,新切口邊緣經過圓化(smooth max,k ≈ 0.085)。所有切塊共享橙子原本的靜止座標系,因此解剖結構保持在它原本生長的位置。
- 每個切塊:
- 投影到場上的 surface-nets 渲染表皮(0.042 網格);
- 在切塊自身的主座標系中用於模擬的六邊形晶格,邊界節點吸附到表面;
- 將渲染頂點以重心座標嵌入晶格的四面體單元。
- 最多 30 個切塊;薄片會被拒絕。

解剖結構(全部位於靜止空間,因此每一刀都能顯露出它真實所在的位置)
- 果皮(深 0.07),帶有油腺孔、斑駁的色調,一端有綠色果蒂凸起,另一端有一個小臍。
- 白色海綿層(深至 0.19)。
- 圍繞果蒂軸的 11 個瓣,帶有薄薄的乳白色膜壁(略有抖動,沿軸彎曲並蜿蜒)以及沿軸的海綿狀芯。
- 汁胞:在每個瓣內從芯部呈扇形展開的淚滴狀囊。
- 靠近芯部的 16 顆淺色柑橘籽,尖端朝內;果肉中有幾顆小氣泡。
- 被切割穿過的籽,會保留在其中心所在的一側,並被輕緩地安置到新切面正下方。

物理(XPBD)
- 每個切塊:六邊形單元,採用共旋轉形狀匹配,並對其五個四面體施加體積約束。
- 果皮和海綿層比果肉更緊實。
- 邊緣與形變阻尼;與地面接觸時採用庫侖摩擦和少量滾動阻力。
- 切塊之間的接觸,基於彼此在最佳擬合座標系中的精確靜止形狀。
- 休眠的切塊會在觸碰時甦醒;固定的 60 Hz 步長配以小步長子步。

刀
- 一把 nakiri 式刀:在橙子上劃出一道筆畫。
- 該筆畫在其穿過物體的頂部被讀取,確定一個垂直的刀片面;該平面通過最佳擬合旋轉被帶入每個被切到的切塊的靜止座標系,並作爲一個半空間加入。
- 當刀對齊、壓出凹槽並垂直切下時,新切塊會被逐步構建。它們繼承其來源果凍的位置和速度,刀刃將切面楔開。

渲染(WebGPU / WGSL)
- 程序化攝影棚。柔和的 PCSS 主陰影被果凍染色,另有來自高度圖的接觸 AO。
- 背面厚度;對場景進行折射,每次採樣按其自身的光程長度衰減。
- 在靜止空間中對果凍進行體積步進,使用逐頂點的逆變形梯度:
- 果皮、海綿層、膜/芯和果肉各自以自身的顏色吸收(Beer–Lambert);
- 散射爲灰色(只有吸收帶顏色),因此從橙色果肉中散射出的光仍保持橙色。
- 白色海綿層、膜星和芯在切面上清晰可辨。
- 薄邊緣處的逆光發光、菲涅耳影棚反射、GGX 高光、糖晶閃爍。
- 後處理:Khronos PBR Neutral 色調映射、sRGB、抖動。

界面(編輯風格“Material Studies / No. 032”,英文)
- 斜體襯線標題“Whole / Orange.”,配說明文字“Eleven segments, set in jelly. Zest, pith and juice. Cut it as small as you like.”
- 狀態膠囊“WEBGPU · LIVE”。
- 工具:Hand / Knife。品種:Navel、Blood、Cara Cara。
- Firmness 與 Internal damping 滑塊;Give it a nudge、Reset、Pause;¼ 速度與 Show mesh。
- 讀數:Mass(g,1 單位 ≈ 3 cm,按 1.3 g/cm³)、Volume(相對靜止狀態的百分比)、Kinetic(mJ)、Pieces。
- 一個可摺疊的“Inside the experiment”,包含關於方法的說明。
- 無 WebGPU 時的回退方案。無橫向滾動的移動端堆疊佈局。

溯源

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