Video Summagator
- group .........
- 3D and WebGL scenes
- source ........
- https://ui.aryank.space/components/video-summagator
- markdown ......
- /lab/video-summagator.md
- human .........
- /lab/video-summagator
── WHAT_IT_IS ────────────────────────────────────────────────────────────────────────────────
A clip turned into a solid you can orbit. The video is sampled into 96, 160 or 240 evenly spaced frames and stacked along Z as one Data3DTexture, so width and height stay the picture while depth becomes running time. A GLSL3 ray-marcher reads that cube under an orthographic camera: parallel rays, so the origin is projected back onto the camera plane rather than taken from the camera position. The selected frame splits the volume in two, everything after it opaque and everything before it accumulating over 160 steps, which is why scrubbing slides a solid surface through a smear instead of dissolving it. That surface gets a 1px outline measured in CSS pixels from four projected corners, so it holds its weight at any zoom. Viewers can drop in their own mp4 and it never leaves the browser: frames are seeked, drawn to a canvas and read back on-device. It ships no control panel of its own: every live value is a prop and every one-shot action is a method on the ref, so the controls live wherever the host puts them.
── BEHAVIOUR ────────────────────────────────────────────────────────────────────────────────
* Depth is time, so the cube is the clip
The frames are not planes drawn one behind another. They are one Data3DTexture of w x h x frames, which lets the shader read any (x, y, time) with a single texture fetch. Everything else follows from that: the smear you see through the front face is real integration along the view ray, not a stack of alpha-blended quads.
* The selected frame is a boundary, not a sprite
Everything from the playhead onward is treated as opaque and its boundary plane is intersected analytically, so the march ends exactly on it rather than stepping past it. That is why the surface stays crisp at any density and why scrubbing slides a solid through the haze instead of fading one image into another.
* The rays are parallel, so the origin is recomputed
Under an orthographic camera every ray shares a direction, taken from the view matrix's third column. Starting each ray at cameraPosition, as a perspective setup would, fans them out and skews the volume. Each fragment is projected back onto the camera plane first.
* Sampling is 240 serial seeks, so the volume grows while you wait
No browser API hands you every frame, so each sample is a seek, a drawImage and a getImageData. The texture is uploaded before the loop and re-uploaded as frames land, which is why the cube extrudes along Z during import rather than appearing at the end.
* The outline is measured in CSS pixels
The frame's four corners are projected to screen space each draw and handed to the shader, which strokes 1 CSS px inside the edge. Doing it in world space would make the line thicken as you zoom in and vanish as you zoom out.
* The 3D texture is sRGB but declared NoColorSpace
No sRGB internal format for 3D textures is safe across drivers, so the bytes go up raw and linearRGB decodes them in the shader. Letting three.js tag the texture sRGB double-decodes and washes the volume out.