// Camera: deriva constante por baixo de tudo (zoom, deslize e giro) e um soco em cada batida. // O quadro nunca fica parado. `batidas` são quadros absolutos do vídeo. import React from 'react'; import {AbsoluteFill, useCurrentFrame} from 'remotion'; export type CameraProps = {batidas?: number[]; forca?: number; children: React.ReactNode}; export const posCamera = (f: number, batidas: number[], forca = 1) => { let z = 1.02 + 0.014 * Math.sin(f / 160) + f * 0.00025, dx = Math.sin(f / 37) * 16, dy = Math.cos(f / 51) * 12; let rot = Math.sin(f / 83) * 0.004; for (const h of batidas) if (f >= h) { const d = Math.exp(-(f - h) / 14) * forca; z += 0.012 * d; dx += 2 * d * Math.sin((f - h) * 2.7 + h); dy += 2 * d * Math.cos((f - h) * 3.3 + h); rot += 0.001 * d * Math.sin((f - h) * 1.9 + h); } return {z, dx, dy, rot}; }; export const Camera: React.FC = ({batidas = [], forca = 1, children}) => { const c = posCamera(useCurrentFrame(), batidas, forca); return {children}; };