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 · 未声明许可