// Camera: deriva constante por baixo de tudo e um soco em cada batida. O quadro nunca fica parado. import React from 'react'; import {AbsoluteFill, useCurrentFrame} from 'remotion'; import {q} from '../base'; export type CameraProps = {batidas?: number[]; forca?: number; children: React.ReactNode}; export const posCamera = (f: number, batidas: number[], forca = 1) => { let z = 1.02 + 0.012 * Math.sin(f / 60), dx = Math.sin(f / 31) * 14, dy = Math.cos(f / 43) * 10; let rot = Math.sin(f / 71) * 0.004; for (const h of batidas) if (f >= h) { const d = Math.exp(-(f - h) / 7) * forca; z += 0.035 * d; dx += 12 * d * Math.sin((f - h) * 2.7 + h); dy += 12 * d * Math.cos((f - h) * 3.3 + h); rot += 0.004 * 0.8 * d * Math.sin((f - h) * 2 + h); } return {z, dx, dy, rot}; }; export const Camera: React.FC = ({batidas = [], forca = 1, children}) => { const c = posCamera(q(useCurrentFrame()), batidas, forca); return {children}; };