- cartoon/src/rig.ts, motion.ts e lipsync.ts: esqueleto do personagem, curvas de movimento e sincronia labial no estilo Cartoon (Remotion) - CharacterFigure/CharacterCard/Shot/overlays e spec atualizados - Painel: estúdio de personagens e montagem cartoon ajustados - Documentação em doc/cartoon/animacao.md e personagens.md; skill atualizada Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
99 lines
5.8 KiB
TypeScript
99 lines
5.8 KiB
TypeScript
// Um trecho do estilo Cartoon: cena de fundo + personagens + objetos + textos + HUD + legenda, com a câmera
|
|
// fazendo um empurrão lento (nunca fica parado, como na referência).
|
|
import React from "react";
|
|
import { AbsoluteFill, useCurrentFrame, useVideoConfig } from "remotion";
|
|
import { CrowdFigure, PersonFigure } from "./actors";
|
|
import { Icon } from "./icons";
|
|
import { Captions, CrossOut, Grain, Hud, Rings, TagLabel, TextLayer, pop, shake } from "./overlays";
|
|
import { SceneBackground } from "./scenes";
|
|
import { CharacterFigure } from "./CharacterFigure";
|
|
import { evaluate } from "./motion";
|
|
import { LightLayer } from "./places";
|
|
import type { ShotSpec } from "./spec";
|
|
import { loadFonts } from "./theme";
|
|
|
|
loadFonts();
|
|
|
|
export function Shot(spec: ShotSpec) {
|
|
const frame = useCurrentFrame();
|
|
const { fps, durationInFrames, width, height } = useVideoConfig();
|
|
const progress = durationInFrames > 1 ? frame / (durationInFrames - 1) : 0;
|
|
const push = spec.camera?.push ?? (spec.scene.kind === "card" ? 1 : 1.07);
|
|
const zoom = 1 + (push - 1) * progress;
|
|
|
|
return (
|
|
<AbsoluteFill style={{ background: "#07080f", containerType: "size", overflow: "hidden" }}>
|
|
<AbsoluteFill style={{ transform: `scale(${zoom})`, transformOrigin: "50% 45%" }}>
|
|
<SceneBackground spec={spec} frame={frame} progress={progress} />
|
|
{(spec.actors ?? []).map((a, i) => {
|
|
const k = pop(frame, fps, a.enterS ?? 0);
|
|
if (a.kind === "crowd") {
|
|
return (
|
|
<div key={i} style={{ position: "absolute", left: "-2%", width: "104%", top: `${(a.y - 0.16) * 100}%`, height: "16%",
|
|
opacity: k, transform: `translateY(${(1 - k) * 8}%)` }}>
|
|
<CrowdFigure c={a} frame={frame} />
|
|
</div>
|
|
);
|
|
}
|
|
if (a.character) {
|
|
// Personagem da biblioteca: mesmo visual em toda cena. Expressão, pose, andar, pular, falar… saem da
|
|
// linha do tempo (motion.ts), com a boca na fala (palavras + volume do áudio).
|
|
const t = frame / fps;
|
|
const st = evaluate({ x: a.x, expression: a.expression, pose: a.pose, face: a.face, body: a.body, flip: a.flip, timeline: a.timeline },
|
|
t, spec.durationS, spec.seed + i * 13, { words: spec.words ?? [], env: spec.audioEnv });
|
|
// Meio corpo / de perto: o personagem cresce e os pés saem do quadro (cabeça perto do terço de cima).
|
|
const zoom = a.framing === "close" ? 2.9 : a.framing === "medium" ? 1.9 : 1;
|
|
const ch = height * 0.36 * (a.scale ?? 1) * zoom;
|
|
const cw = (ch * 200) / 440;
|
|
const baseY = a.framing === "close" ? 1.15 : a.framing === "medium" ? 0.98 : a.y;
|
|
const label = a.label ?? a.character.name;
|
|
const showLabel = label && Math.abs(st.rot) < 30;
|
|
return (
|
|
<div key={i} style={{ position: "absolute", left: (st.x + st.dx) * width - cw / 2, top: (baseY + st.dy) * height - ch, width: cw, height: ch,
|
|
opacity: Math.min(1, k * 1.5), transformOrigin: "50% 100%",
|
|
transform: `translateY(${(1 - k) * 10}%) rotate(${st.rot}deg) scale(${(st.flip ? -1 : 1) * st.sx}, ${st.sy})` }}>
|
|
<CharacterFigure look={a.character.look} item={a.item} t={t} state={st} />
|
|
{showLabel && (
|
|
<div style={{ position: "absolute", left: zoom > 1 ? "8%" : "50%", top: zoom > 1 ? "22%" : "-15%", transform: `translateX(-50%) scaleX(${st.flip ? -1 : 1})`, textAlign: "center" }}>
|
|
<TagLabel text={label} />
|
|
{a.character.caption && <div style={{ marginTop: "0.6cqw" }}><TagLabel text={a.character.caption} tone="ok" size={2.4} /></div>}
|
|
</div>
|
|
)}
|
|
</div>
|
|
);
|
|
}
|
|
const h = height * 0.27 * (a.scale ?? 1);
|
|
return (
|
|
<div key={i} style={{ position: "absolute", left: a.x * width - (h * 200) / 420 / 2, top: a.y * height - h, width: (h * 200) / 420,
|
|
height: h, opacity: Math.min(1, k * 1.5), transform: `translateY(${(1 - k) * 12}%)` }}>
|
|
<PersonFigure p={a} frame={frame} fps={fps} />
|
|
{a.label && <div style={{ position: "absolute", left: "50%", top: "-14%", transform: "translateX(-50%)" }}><TagLabel text={a.label} /></div>}
|
|
</div>
|
|
);
|
|
})}
|
|
{(spec.props ?? []).map((p, i) => {
|
|
const k = pop(frame, fps, p.enterS ?? 0);
|
|
if (k <= 0.001) return null;
|
|
const size = height * (p.size ?? 0.16);
|
|
const s = p.shake ? shake(frame, 2.5) : { x: 0, y: 0 };
|
|
const cross = p.crossed ? pop(frame, fps, (p.enterS ?? 0) + 0.5, 90) : 0;
|
|
return (
|
|
<div key={i} style={{ position: "absolute", left: p.x * width - size / 2 + s.x, top: p.y * height - size / 2 + s.y, width: size, height: size,
|
|
transform: `scale(${0.5 + 0.5 * k})`, opacity: Math.min(1, k * 1.5) }}>
|
|
{p.rings && <div style={{ position: "absolute", inset: "-60%" }}><Rings frame={frame} fps={fps} /></div>}
|
|
<Icon id={p.icon} />
|
|
{p.crossed && <div style={{ position: "absolute", inset: "-8%" }}><CrossOut k={cross} /></div>}
|
|
{p.label && <div style={{ position: "absolute", left: "50%", top: "-22%", transform: "translateX(-50%)" }}><TagLabel text={p.label} tone={p.tone} /></div>}
|
|
</div>
|
|
);
|
|
})}
|
|
<LightLayer light={spec.light} palette={spec.palette} />
|
|
{(spec.texts ?? []).map((t, i) => <TextLayer key={i} t={t} frame={frame} fps={fps} />)}
|
|
</AbsoluteFill>
|
|
{(spec.grain ?? 0.11) > 0 && <Grain opacity={spec.grain ?? 0.11} seed={spec.seed} />}
|
|
{spec.hud && <Hud hud={spec.hud} frame={frame} fps={fps} />}
|
|
{spec.words?.length ? <Captions words={spec.words} frame={frame} fps={fps} /> : null}
|
|
</AbsoluteFill>
|
|
);
|
|
}
|