Jotley / website / docs / video-fixes / rounded-device-screen.patch
| 1 | --- a/composition/shared/social-stage.js |
| 2 | +++ b/composition/shared/social-stage.js |
| 3 | @@ -208,6 +208,14 @@ |
| 4 | const corners = [new THREE.Vector3(), new THREE.Vector3(), new THREE.Vector3(), new THREE.Vector3()]; |
| 5 | const normal = new THREE.Vector3(), centre = new THREE.Vector3(), toCam = new THREE.Vector3(); |
| 6 | const mapScreen = (el, group, dims) => { |
| 7 | + // The footage is a DOM layer above WebGL. Clip it in screen-local space |
| 8 | + // before the perspective transform, using the same quadratic corners as |
| 9 | + // roundedPlane(), so no rectangular video corners cover the device bezel. |
| 10 | + const w = el.offsetWidth, h = el.offsetHeight; |
| 11 | + const rx = dims.sr / dims.sw * w, ry = dims.sr / dims.sh * h; |
| 12 | + el.style.borderRadius = "0"; |
| 13 | + el.style.overflow = "hidden"; |
| 14 | + el.style.clipPath = `path("M ${rx} 0 H ${w - rx} Q ${w} 0 ${w} ${ry} V ${h - ry} Q ${w} ${h} ${w - rx} ${h} H ${rx} Q 0 ${h} 0 ${h - ry} V ${ry} Q 0 0 ${rx} 0 Z")`; |
| 15 | const z = dims.d / 2 + 0.0016; |
| 16 | corners[0].set(-dims.sw / 2, dims.sh / 2, z); |
| 17 | corners[1].set(dims.sw / 2, dims.sh / 2, z); |