Physical UI

Three ordinary forms on three materials. Grab one by its background and pull it about, then let go. Press a button or type and the material takes the hit. Scroll the page and they lag behind. The fields keep focus while this happens, and a click reaches the control that is drawn under the pointer.

Jelly

A soft body. It wobbles and springs back.

<physical-ui material="jelly">

Cloth

Hung from a rail along its top edge. It swings like a pendulum and catches the wind.



<physical-ui material="cloth" wind="0.12">

Paper

Taped at the top corners. Stiff: it bends and lifts rather than stretching.

<physical-ui material="paper">
Show the code forms on jelly and cloth
  1. Wrap a form in <physical-ui material="…">. The form is ordinary HTML and keeps working.
  2. Load the element. Wind and gusts are optional. all is the three elements.
  3. Inside the element: the form becomes a texture that is drawn on a simulated mesh. This is the WebGL route; on WebGPU the call is device.queue.drawElementImageToTexture({ source }, { texture }).
  4. Inside the element: hit testing follows the mesh. Find the triangle under the pointer, work out the affine matrix that carries its flat shape to its bent shape, and hand that to updateElementGeometry(). A click then lands on the control you see.
  5. The whole element.
<script type="module" src="/lib/physical-ui.js"></script>

<physical-ui material="cloth" wind="0.1">
  <form>…a real form…</form>
</physical-ui>

How it works

Live checks

ResultExperimentDetail