Cartoon: rig, movimento e lip sync dos personagens
- 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>
This commit is contained in:
@@ -7,6 +7,34 @@ Versão semântica da **skill** (não do projeto):
|
||||
|
||||
Mantido pelo subagente `cenaforge-skill-updater`. Entradas mais novas no topo.
|
||||
|
||||
## 1.48.0 — 17/11/2026
|
||||
|
||||
Cartoon: acabamento de ilustração dos personagens (detalhe de rosto/corpo, acessórios, enquadramento e textura).
|
||||
- `references/cartoon.md`: campos opcionais do `look` (`head`, `nose`, `lids`, `wrinkles`, `belly`, `accessories`,
|
||||
`accessoryColor`); `lid` em `FaceParams`; `framing` do ator e `grain` do spec; acabamento do `CharacterFigure`;
|
||||
`describeToLook` com regras de detalhe e profissões novas; `planCartoon` escolhe `framing`; campos novos no studio; medição.
|
||||
- `references/gotchas.md`: novos 163 (curva da boca — registrado de fato só agora; o 1.47.0 o citava sem ele existir no
|
||||
arquivo), 164 (Python grava JSON sem `encoding="utf-8"` estraga acento), 165 (sombra em elipse parece mancha).
|
||||
- `SKILL.md`: versão, `description`, linha do personagem, faixa de itens do Cartoon (156, 157, 160–165). Sem crescer.
|
||||
- Evidência: conferido em `character.ts`, `rig.ts`, `spec.ts`, `Shot.tsx`, `overlays.tsx`, `characters.ts`,
|
||||
`montage-cartoon.ts`; `cd cartoon && npx tsx --test tests/*.test.ts` → 16 pass (reexecutado). Informados, não
|
||||
reexecutados: painel 78/78, `tsc`, 4 personagens por descrição, close falando renderizado.
|
||||
|
||||
## 1.47.0 — 17/11/2026
|
||||
|
||||
Cartoon: rig de expressões, ações de movimento combináveis e fala sincronizada (ferramenta, não template).
|
||||
- `references/cartoon.md`: nova seção "Rig, movimento e fala" (`rig.ts`: `FaceParams`/`BodyParams`, 20 expressões e 17 poses
|
||||
como atalhos; `motion.ts`: `Action`, 19 ações, `evaluate`, `startOf`/`cue`, `validateTimeline`; `lipsync.ts`: `visemeAt`,
|
||||
`emphasisAt`, `speak`); contrato do ator com `face`/`body`/`timeline` e `spec.audioEnv`; `timelineFor`/`audioEnvelope` no
|
||||
plano do painel; exports `./motion` e `./rig`; prévia de movimento no `character-studio`; medições.
|
||||
- `references/gotchas.md`: novo 163 (curva quadrática da boca só chega à metade do controle).
|
||||
- `references/tools.md`: contagem de testes (cartoon 16, painel 10 no arquivo do Cartoon).
|
||||
- `SKILL.md`: versão, `description`, linha de personagem com rig/movimento e `animacao.md`; resumo de armadilhas enxugado
|
||||
(a lista longa de itens saiu: vale o `gotchas.md`).
|
||||
- Evidência: conferido no código (`package.json` exports, `rig.ts`, `motion.ts`, `lipsync.ts`, `montage-cartoon.ts`);
|
||||
`cd cartoon && npx tsx --test tests/*.test.ts` → 16 pass (reexecutado). Informados, não reexecutados: painel 78/78, `tsc`,
|
||||
grade das 20 expressões, narração real da ilha ep01-01 e sequência de 7 s renderizada em 5,6 s.
|
||||
|
||||
## 1.46.0 — 17/11/2026
|
||||
|
||||
Cartoon por peças: lugares montados pelo texto e biblioteca de personagens reaproveitados entre histórias.
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -8,7 +8,7 @@ cena é montada **por peças** a partir do texto (parque de dia, cemitério, bun
|
||||
criados uma vez, na biblioteca, e reaproveitados em várias histórias. Não crie "cena pronta" nova; crie peça ou regra.
|
||||
|
||||
Guias do projeto (fonte de detalhe, não duplicar aqui): `doc/cartoon/cenas.md` (camadas, receitas por situação,
|
||||
composição), `doc/cartoon/personagens.md` (ficha, agente), estudo de referência `doc/estudo-estilo-cartoon-explicativo.md`.
|
||||
composição), `doc/cartoon/personagens.md` (ficha, agente), `doc/cartoon/animacao.md` (expressões e movimento, guia do agente), estudo de referência `doc/estudo-estilo-cartoon-explicativo.md`.
|
||||
|
||||
## Contrato da cena (`cartoon/src/spec.ts`, `schemaVersion` 1; `validateSpec` recusa o resto)
|
||||
|
||||
@@ -22,7 +22,11 @@ composição), `doc/cartoon/personagens.md` (ficha, agente), estudo de referênc
|
||||
`z` 0 = frente, 1 = fundo. 24 peças em `ELEMENTS`: tree, deadtree, pine, bush, rock, mountain, cloud, bench, lamp,
|
||||
gravestone, cross, fence, house, building, car, sign, door, window, table, bed, shelf, crate, tent, fire.
|
||||
Peça nova = entrada em `ELEMENTS` + desenho em `cartoon/src/places.tsx`.
|
||||
- `actors`: `person` com `character {name, caption, look}`, `expression`, `pose`, `item` (objeto na mão), `flip`
|
||||
- `grain` (0 desliga, padrão 0,11): textura de papel sobre a cena (`Grain` em `overlays.tsx`, feTurbulence com mix-blend overlay;
|
||||
também no `CharacterCard`).
|
||||
- `actors`: `person` com `character {name, caption, look}`, `expression`, `pose`, `item` (objeto na mão), `flip`,
|
||||
`framing` `full|medium|close` (Shot: zoom 1/1,9/2,9 e base y = `y`/0,98/1,15; a etiqueta vai para o lado),
|
||||
`face`/`body` (ajustes finos do rig), `timeline` (ações de movimento, até 40); `spec.audioEnv {fps, values}`
|
||||
(campos antigos `label`/`hair`/`glasses`/`pointing` ainda valem); `crowd` (entra antes do personagem, atrás, pés em y 0,6).
|
||||
|
||||
## Peças (`cartoon/src/`)
|
||||
@@ -46,22 +50,61 @@ personagem:** `tsx cartoon/render.ts --still --props x.json --out y.png [--frame
|
||||
- **Contrato** `cartoon/src/character.ts` (`Character`, `schemaVersion` 1): `id`, `name`, `caption`, `description`,
|
||||
`kind` `cartoon|3d`, `look {build slim|average|heavy, height 0,6–1,2, skin, hair{style short|side|bun|long|curly|spiky|
|
||||
bald|cap, color}, beard none|stubble|mustache|full|goatee, glasses none|round|square|sun, brows thin|thick,
|
||||
top{shirt|jacket|hoodie|dress|uniform, color, accent}, bottom pants|shorts|skirt, shoes}`. `EXPRESSIONS`: neutral, happy,
|
||||
sad, worried, angry, surprised, scared. `POSES`: stand, point, wave, hold, arms_up, shrug, think. `validateLook`.
|
||||
- **Desenho** `CharacterFigure.tsx`: SVG puro (sem Remotion), `viewBox` 200×440, pés em (100,440); `t` anima respirar,
|
||||
piscar e acenar. O painel importa o mesmo componente (prévia ao vivo): dependência `"cenaforge-cartoon": "workspace:*"` em
|
||||
`panel/package.json`, `transpilePackages` em `panel/next.config.ts`, `exports` do pacote `./character`, `./figure`, `./spec`.
|
||||
top{shirt|jacket|hoodie|dress|uniform, color, accent}, bottom pants|shorts|skirt, shoes}`. `EXPRESSIONS`/`POSES`
|
||||
vêm do rig (reexportados). `validateLook`.
|
||||
**Acabamento (17/11/2026), campos OPCIONAIS do `look`:** `head` (`HEAD_SHAPES` round|oval|square|wide), `nose` (`NOSES`
|
||||
button|curve|round|long|wide), `lids` (0–0,8, pálpebra de base), `wrinkles` (0–1), `belly` (bool), `accessories`
|
||||
(`ACCESSORIES`: towel, whistle, tie, vest, helmet, watch, badge, apron, scarf, headset, chain) e `accessoryColor`.
|
||||
- **Desenho** `CharacterFigure.tsx`: SVG puro (sem Remotion), `viewBox` 200×440, pés em (100,440), escrito sobre o rig (seção
|
||||
"Rig, movimento e fala"). O painel importa o mesmo componente (prévia ao vivo): dependência `"cenaforge-cartoon": "workspace:*"` em
|
||||
`panel/package.json`, `transpilePackages` em `panel/next.config.ts`, `exports` do pacote `./character`, `./figure`, `./spec`, `./motion`, `./rig`.
|
||||
- **Arquivos:** `assets/characters/<id>/character.json`; elenco da história `stories/<id>/cast.json` (`{"cast":[ids]}`).
|
||||
- **Painel** `panel/src/lib/characters.ts`: `listCharacters`/`getCharacter`/`saveCharacter`/`deleteCharacter` (não apaga
|
||||
quem está em elenco), `describeToLook` (descrição pt-BR → `look` + `caption` por regras: idade, gênero, criança,
|
||||
profissão → uniforme/cor, cabelo, barba, óculos, corpo, cor de roupa), `getCast`/`setCast`. Rotas: `GET/POST
|
||||
profissão → uniforme/cor, cabelo, barba, óculos, corpo, cor de roupa; **e o acabamento**: `nose`, `lids`, `wrinkles`,
|
||||
`head`, `belly` e `accessories` por idade, "barrigudo", "narigudo", "cansado" e profissão — técnico: apito + relógio;
|
||||
obra: capacete + colete laranja; porteiro: crachá; merendeira: avental; roupeiro: toalha; empresário: gravata + relógio;
|
||||
`PROFESSIONS` inclui técnico, porteiro, merendeira, roupeiro, operário, empresário), `getCast`/`setCast`. Rotas: `GET/POST
|
||||
/api/characters`, `GET/PUT/DELETE /api/characters/[id]`, `POST /api/characters/[id]/agent`, `GET/PUT
|
||||
/api/stories/[storyId]/cast`. Página `/characters` (aba "Personagens"; `components/character-studio.tsx`: criar pela
|
||||
descrição, prévia com expressão/pose, formulário peça por peça, "Refinar com o agente", apagar).
|
||||
descrição, prévia com expressão/pose, formulário peça por peça — inclui Cabeça, Nariz, Pálpebra, Rugas, Barriga, Cor dos acessórios e chips de Acessórios —,
|
||||
"Refinar com o agente", apagar).
|
||||
- **Agente:** `AgentKind` `"character"` (`types.ts`; `agents.ts`: orçamento US$ 0,5, Sonnet, Claude preferido; `prompts.ts`
|
||||
manda ler SÓ `doc/cartoon/personagens.md` e gravar a ficha).
|
||||
- Para testar a API com acento use Python/UTF-8 (gotchas 153); o `id` sai do nome sem acento.
|
||||
|
||||
## Rig, movimento e fala (FERRAMENTA, não template)
|
||||
|
||||
Princípio do dono: expressão e movimento são **parâmetros contínuos e ações combináveis**; os presets são só atalhos.
|
||||
Detalhe e exemplos: `doc/cartoon/animacao.md`.
|
||||
|
||||
- **`rig.ts`:** `FaceParams` (`browL/browR {y, tilt}` tilt + = ponta de dentro sobe, `eyeL/eyeR` 0–1,35, `pupil`,
|
||||
`gazeX/gazeY`, `mouthOpen`, `smile` −1…1, `mouthWidth`, `mouthRound`, `lid` (pálpebra, somada ao `lids` do personagem: surpreso/medo −0,5, sono 0,6, desconfiado 0,45; os presets usam `lid` em vez de fechar o olho), `teeth`, `blush`, `sweat`, `tears`, `anger`) e
|
||||
`BodyParams` (`lean`, `headTilt`, `headTurn` −1…1, `headNod`, `armL/armR/legL/legR {raise, bend}` em 2 segmentos, `crouch`).
|
||||
20 `EXPRESSION_PRESETS` (neutral, smile, happy, laugh, proud, sad, cry, worried, angry, furious, surprised, scared,
|
||||
shocked, suspicious, smirk, confused, disgusted, sleepy, determined, embarrassed) e 17 `POSE_PRESETS` (stand, point, wave,
|
||||
hold, arms_up, celebrate, shrug, think, hands_on_hips, cross_arms, facepalm, cover_mouth, defend, reach, sit, kneel,
|
||||
lean_in). `faceOf`/`bodyOf(nome, ajuste)`, `withFace`/`withBody` (aceitam `brows`/`eyes`/`arms`/`legs`), `blendFace`/`blendBody`.
|
||||
- **`motion.ts`:** `Action {do, at|atP|cue, dur, cueEnd, expression/face, pose/body, to, dir, times, height, text}`; `ACTIONS`:
|
||||
express, pose, walk, run, enter, exit, jump, nod, shake_head, tremble, bounce, fall, sit, stand_up, turn, talk, look, emote,
|
||||
wave. `evaluate(actor, t, durationS, seed, {words, env})` → `{face, body, x, dx, dy, rot, sx, sy, flip, emote}`; `startOf`
|
||||
resolve `cue` pela palavra falada (prefixo normalizado); piscar em intervalos variados, respirar e balanço sempre ligados;
|
||||
`validateTimeline` (até 40 ações). `Shot.tsx` aplica `evaluate` por ator (posição/giro/escala/espelho no container).
|
||||
- **`lipsync.ts`:** `visemeAt(palavras, t, env)` (forma por letra: a abre, e/i esticam, o/u arredondam, m/b/p fecham, f/v
|
||||
dentes; vogal pesa 1,7 e consoante 0,8; coarticulação na 2ª metade da letra; fecha 60 ms após a palavra; `env` fecha nas
|
||||
pausas), `emphasisAt` (sobrancelhas no pico), `speak(face, viseme)` (mantém cantos/sobrancelhas/olhos da expressão). `talk`
|
||||
usa as palavras entre `cue` e `cueEnd`, ou `text` repartido por `dur`.
|
||||
- **Desenho:** prop `state` (de `evaluate`); sem ele usa `expression`/`pose` + vida. Boca contínua com `clipPath`; olho de
|
||||
riso em arco; balão de emote; mão no rosto desenhada por cima da cabeça. **Acabamento do desenho:** pálpebra recortada
|
||||
(`clipPath` por olho) com borda mais escura; 5 narizes; rugas; cabeça por formato (`headPath`) com sombra de baixo e
|
||||
brilho na testa; orelha com dobra; mão com polegar; tronco com sombra lateral, gola em V e zíper; barriga = elipse + curva
|
||||
de volume (**só a sombra em elipse parecia mancha**); `Accessories` (capacete e fone na cabeça, relógio no pulso esquerdo).
|
||||
**Armadilha:** a curva quadrática só chega à
|
||||
METADE do controle, então os controles da boca ficam no dobro da abertura.
|
||||
- **Painel:** `character-studio.tsx` lista as 20 expressões e 17 poses em pt-BR e tem "Movimento (prévia)" (`MovePreview`,
|
||||
loop de 2,6 s). `CharacterCard` aceita framing `"face"` (recorte do rosto). Agente `character` lê `animacao.md` se o
|
||||
pedido falar de expressão/movimento.
|
||||
|
||||
## Plano no painel (`panel/src/lib/montage-cartoon.ts`, sem banco)
|
||||
|
||||
- Tipos vêm de `"cenaforge-cartoon/spec"` (não há mais espelho). `planCartoon(shot, ctx, variant)` com
|
||||
@@ -71,6 +114,8 @@ personagem:** `tsx cartoon/render.ts --still --props x.json --out y.png [--frame
|
||||
paleta/luz própria). Sem lugar reconhecido cai nas cenas antigas.
|
||||
- **Personagem:** `expressionOf`/`poseOf` pelo texto; quem é citado pelo nome entra com a aparência da biblioteca; com 1
|
||||
personagem só, ele aparece nos trechos pares ou quando o texto diz "ele/ela"; objeto pequeno vai para a mão (`item`).
|
||||
- **Enquadramento do personagem** (`framing`): `close` quando ele fala sozinho (há `talk`, 1 personagem); `medium` sozinho
|
||||
sem objetos nem multidão; `full` no resto.
|
||||
- Ícones por palavra-chave; "pessoas/vizinhos" vira multidão; "nunca/não" + perigo risca o objeto; sons viram
|
||||
onomatopeia (motor só com gerador/motor/moto/carro perto; barulho genérico = "Crec"); texto na tela numérico vira `big`,
|
||||
senão etiqueta; `variant` troca arranjo e seed.
|
||||
@@ -85,13 +130,27 @@ personagem:** `tsx cartoon/render.ts --still --props x.json --out y.png [--frame
|
||||
geração); "Gerar de novo" troca `cartoonVariant`; `hudFor` = 2 primeiras palavras do título + "Ep. N".
|
||||
- **UI** (`montage-editor.tsx`, recebe `storyId`): opção de estilo, bloco `CartoonSetup` (paleta da série + elenco por chips,
|
||||
só no estilo Cartoon), botão "Cartoon" no trecho, `CartoonPreview`.
|
||||
- **Testes:** `panel/src/lib/montage-cartoon.test.ts` (9).
|
||||
- **Movimento pelo texto:** `timelineFor(texto, x)` (`EMOTIONS` por palavra → `express` com `cue`; `MOVES` por verbo → ações;
|
||||
`quoteOf`: fala entre aspas/travessão → `talk` com `cue`/`cueEnd`; começa `neutral` se houver `express`).
|
||||
`audioEnvelope(file)` (FFmpeg mono 8 kHz, RMS por quadro normalizado pelo p95; ~199 quadros para 6,6 s) →
|
||||
`cartoonSpec(scene, dur, words, env)`; `montage.ts` passa o env.
|
||||
- **Testes:** `panel/src/lib/montage-cartoon.test.ts` (10).
|
||||
|
||||
## Medido (17/11/2026)
|
||||
|
||||
Mesmo personagem em parque (`day`), cemitério (`dusk` + fog + `vignette`) e bunker (`sepia` + `spot` + indoor): 3 trechos de
|
||||
4 s em ~2,6–2,8 s cada. Plano com elenco "Marta" → parque de dia (acenando) e cemitério (com medo, "Crec") renderizados.
|
||||
Testes: painel 77/77, cartoon 5/5; `tsc` ok nos dois (informados pelo dono; cartoon 5/5 reexecutado na skill).
|
||||
Testes (antes do rig): painel 77/77, cartoon 5/5.
|
||||
|
||||
Rig/movimento (17/11/2026, informado pelo dono): grade das 20 expressões conferida de perto; personagem falando narração
|
||||
real (ilha ep01-01) com `worried` mantida e "não" balançando a cabeça na palavra; sequência enter→jump→sit→stand_up→wave→
|
||||
scared+"!"→tremble→fall de 7 s renderizada em 5,6 s. Testes: painel 78/78 e `tsc` ok (informados); cartoon 16/16
|
||||
(`tests/motion.test.ts` 11 novos) reexecutado na skill. Renders não reexecutados.
|
||||
|
||||
Acabamento de ilustração (17/11/2026, informado pelo dono; referência: reel de série de cartoon, cujos personagens são
|
||||
ilustrações paradas com textura, só a câmera desliza — o rig mantém a animação): 4 personagens criados só pela descrição
|
||||
(porteiro 64, técnico barrigudo 52, mestre de obra 38, merendeira 70) saíram com os detalhes certos; close falando
|
||||
renderizado. Testes: cartoon 16/16 reexecutado na skill; painel 78/78 e `tsc` informados. Renders não reexecutados.
|
||||
|
||||
## Ainda não existe (próximo passo)
|
||||
|
||||
|
||||
@@ -756,6 +756,13 @@ observada num envio real ainda. Contexto em [publishing.md](publishing.md).
|
||||
162. **Regex com `\b` escrita por heredoc/Python sem string raw vira um caractere de controle (backspace, 0x08)** (aconteceu 2x ao
|
||||
editar `montage-cartoon.ts`): a regex deixa de casar, sem erro. Use `r"..."` ou o Edit (item 44) e confira com
|
||||
`grep -nP "\x08" <arquivo>` que não sobrou nenhum.
|
||||
163. **Cartoon: a boca (curva quadrática) só chega à METADE do ponto de controle.** Controles da boca ficam no dobro da
|
||||
abertura desejada. Onde: `cartoon/src/CharacterFigure.tsx`.
|
||||
164. **Script de teste em Python que grava JSON com `open(..., "w")` sem `encoding` estraga acento no Windows** (cp1252; o
|
||||
render lê UTF-8). Sempre `open(..., "w", encoding="utf-8")` (e `ensure_ascii=False` se quiser acento legível). Mesma
|
||||
família do item 153. Onde: ao gerar `character.json`/spec por script.
|
||||
165. **Cartoon: sombra do corpo/barriga em elipse parece mancha.** Correção: elipse + curva de volume (contorno) e sombra
|
||||
lateral recortada por `clipPath`. Onde: `cartoon/src/CharacterFigure.tsx`.
|
||||
|
||||
Relacionadas, já registradas acima:
|
||||
- Patch por script em arquivos CRLF do painel (`lib/metrics.ts`, `components/metrics-view.tsx`, `dashboard-controls.tsx`,
|
||||
|
||||
@@ -35,8 +35,8 @@ Estilo Cartoon (`cartoon/`, 17/11/2026; contrato e uso em [cartoon.md](cartoon.m
|
||||
| Fontes Anton e Bebas Neue | `assets/fonts/` (`publicDir` = `assets`) | texto das etiquetas e legenda | ver licenças em "Clipador" |
|
||||
|
||||
Licença da Remotion: grátis para pessoa física e empresa pequena; empresa maior paga. **Conferir os termos antes de uso
|
||||
comercial** (não verificado aqui). Testes: `npx tsx --test tests/*.test.ts` em `cartoon/` (5 testes de `spec.test.ts`);
|
||||
painel: `montage-cartoon.test.ts` (9). Cartoon 5/5 reexecutado em 17/11/2026; painel 77/77 informado pelo dono.
|
||||
comercial** (não verificado aqui). Testes: `npx tsx --test tests/*.test.ts` em `cartoon/` (5 de `spec.test.ts` + 11 de `motion.test.ts`);
|
||||
painel: `montage-cartoon.test.ts` (10). Cartoon 16/16 reexecutado em 17/11/2026; painel 78/78 informado pelo dono.
|
||||
|
||||
Hardware do teste de referência: i9-13900K, 64 GB, RTX 2060 SUPER. Tempos: prévia 540×960
|
||||
42–44 s; final 1080×1920 ~160 s. A etapa de render da Godot ocupa 94–96% do total, dominada
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
"exports": {
|
||||
"./character": "./src/character.ts",
|
||||
"./figure": "./src/CharacterFigure.tsx",
|
||||
"./spec": "./src/spec.ts"
|
||||
"./spec": "./src/spec.ts",
|
||||
"./motion": "./src/motion.ts",
|
||||
"./rig": "./src/rig.ts"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import React from "react";
|
||||
import { AbsoluteFill, useCurrentFrame, useVideoConfig } from "remotion";
|
||||
import { CharacterFigure } from "./CharacterFigure";
|
||||
import { TagLabel } from "./overlays";
|
||||
import { Grain, TagLabel } from "./overlays";
|
||||
import { loadFonts } from "./theme";
|
||||
import type { CharacterLook, Expression, Pose } from "./character";
|
||||
import type { IconId } from "./spec";
|
||||
@@ -13,25 +13,36 @@ loadFonts();
|
||||
export type CardProps = {
|
||||
width: number; height: number;
|
||||
background?: string;
|
||||
/** "face": enquadra só a cabeça (conferir expressões de perto). */
|
||||
framing?: "full" | "face";
|
||||
figures: { look: CharacterLook; expression?: Expression; pose?: Pose; item?: IconId; label?: string }[];
|
||||
};
|
||||
|
||||
export function CharacterCard({ figures, background = "#2a2e45" }: CardProps) {
|
||||
export function CharacterCard({ figures, background = "#2a2e45", framing = "full" }: CardProps) {
|
||||
const frame = useCurrentFrame();
|
||||
const { fps } = useVideoConfig();
|
||||
const n = Math.max(1, figures.length);
|
||||
return (
|
||||
<AbsoluteFill style={{ background, containerType: "size" }}>
|
||||
<div style={{ position: "absolute", inset: "8% 2% 4%", display: "grid", gridTemplateColumns: `repeat(${n}, 1fr)`, alignItems: "end" }}>
|
||||
<div style={{ position: "absolute", inset: "8% 2% 4%", display: "grid", gridTemplateColumns: `repeat(${n}, minmax(0, 1fr))`, alignItems: "end" }}>
|
||||
{figures.map((f, i) => (
|
||||
<div key={i} style={{ position: "relative", height: "100%", display: "flex", flexDirection: "column", alignItems: "center", justifyContent: "flex-end" }}>
|
||||
{f.label && <div style={{ marginBottom: "4%" }}><TagLabel text={f.label} size={n > 3 ? 2.2 : 3.4} /></div>}
|
||||
<div style={{ width: "90%", aspectRatio: "200 / 440", maxHeight: "86%" }}>
|
||||
{framing === "face" ? (
|
||||
<div style={{ width: "92%", aspectRatio: "1 / 1", overflow: "hidden", position: "relative" }}>
|
||||
<div style={{ position: "absolute", left: "-60%", top: "-64%", width: "220%", aspectRatio: "200 / 440" }}>
|
||||
<CharacterFigure look={f.look} expression={f.expression} pose={f.pose} item={f.item} t={frame / fps} />
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<div style={{ width: "90%", aspectRatio: "200 / 440", maxHeight: "86%" }}>
|
||||
<CharacterFigure look={f.look} expression={f.expression} pose={f.pose} item={f.item} t={frame / fps} />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
<Grain />
|
||||
</AbsoluteFill>
|
||||
);
|
||||
}
|
||||
|
||||
+294
-133
@@ -1,78 +1,100 @@
|
||||
// Desenho do personagem a partir das peças (character.ts). SVG puro, sem Remotion: o painel usa o mesmo
|
||||
// componente na prévia ao vivo da aba Personagens. viewBox 200×440 com os pés em (100, 440).
|
||||
// `t` (segundos) só move detalhes vivos: respiração, piscar, braço acenando.
|
||||
import React from "react";
|
||||
// Desenho do personagem a partir do RIG (rig.ts): rosto e corpo por parâmetros contínuos, braços e pernas em
|
||||
// dois segmentos (ombro/cotovelo, quadril/joelho). SVG puro, sem Remotion: o painel usa o mesmo componente.
|
||||
// viewBox 200×440, pés em (100, 440). O movimento (andar, pular, falar…) vem de motion.ts como `state`; sem ele,
|
||||
// usa a expressão/pose pedida com a "vida" (piscar, respirar). Posição, giro e espelho ficam por conta de quem
|
||||
// desenha a cena (Shot.tsx).
|
||||
import React, { useId } from "react";
|
||||
import { Icon } from "./icons";
|
||||
import type { IconId } from "./spec";
|
||||
import { DEFAULT_LOOK, type CharacterLook, type Expression, type Pose } from "./character";
|
||||
import { DEFAULT_LOOK, type CharacterLook } from "./character";
|
||||
import { evaluate, type ActorState } from "./motion";
|
||||
import type { BodyParams, FaceParams, Limb } from "./rig";
|
||||
|
||||
const INK = "#15161f";
|
||||
|
||||
/** Ângulo dos braços por pose (graus; 0 = para baixo). Direito negativo = para fora; esquerdo positivo = para fora. */
|
||||
const ARMS: Record<Pose, [number, number]> = {
|
||||
stand: [-8, 8], point: [-95, 8], wave: [-150, 8], hold: [-38, 8], arms_up: [-160, 160], shrug: [-55, 55], think: [150, 8],
|
||||
};
|
||||
|
||||
function shade(hex: string, k: number): string {
|
||||
const n = parseInt(hex.slice(1), 16);
|
||||
const c = (v: number) => Math.max(0, Math.min(255, Math.round(v * k))).toString(16).padStart(2, "0");
|
||||
return `#${c((n >> 16) & 255)}${c((n >> 8) & 255)}${c(n & 255)}`;
|
||||
}
|
||||
/** Ponta de um segmento: ângulo de tela em graus (0 = para baixo). */
|
||||
const tip = (x: number, y: number, deg: number, len: number) => {
|
||||
const r = (deg * Math.PI) / 180;
|
||||
return { x: x - Math.sin(r) * len, y: y + Math.cos(r) * len };
|
||||
};
|
||||
|
||||
function Mouth({ expression }: { expression: Expression }) {
|
||||
const common = { stroke: INK, strokeWidth: 4.5, fill: "none", strokeLinecap: "round" as const };
|
||||
switch (expression) {
|
||||
case "happy": return <path d="M84 131 Q100 150 116 131 Q100 140 84 131 Z" fill={INK} />;
|
||||
case "sad": return <path d="M87 141 Q100 129 113 141" {...common} />;
|
||||
case "worried": return <path d="M86 139 Q93 133 100 139 Q107 145 114 139" {...common} />;
|
||||
case "angry": return <path d="M87 139 L113 136" {...common} strokeWidth={6} />;
|
||||
case "surprised": return <ellipse cx={100} cy={139} rx={8} ry={10} fill={INK} />;
|
||||
case "scared": return <ellipse cx={100} cy={140} rx={10} ry={7} fill={INK} />;
|
||||
default: return <path d="M88 136 Q100 140 112 136" {...common} />;
|
||||
}
|
||||
function Segment({ x, y, deg, len, w, fill }: { x: number; y: number; deg: number; len: number; w: number; fill: string }) {
|
||||
return <rect x={x - w / 2} y={y - w / 2} width={w} height={len + w / 2} rx={w / 2} fill={fill} transform={`rotate(${deg} ${x} ${y})`} />;
|
||||
}
|
||||
|
||||
function Brows({ expression, thick, color }: { expression: Expression; thick: boolean; color: string }) {
|
||||
// Inclinação da sobrancelha esquerda (a direita espelha): + sobe por dentro (triste/preocupado), − desce (bravo).
|
||||
const tilt = { neutral: 0, happy: -6, sad: 16, worried: 14, angry: -18, surprised: 0, scared: 18 }[expression];
|
||||
const lift = expression === "surprised" || expression === "scared" ? -7 : expression === "happy" ? -3 : 0;
|
||||
const w = thick ? 7 : 4.5;
|
||||
return (
|
||||
<g stroke={color} strokeWidth={w} strokeLinecap="round">
|
||||
<line x1={71} y1={89 + lift} x2={92} y2={89 + lift} transform={`rotate(${tilt} 92 ${89 + lift})`} />
|
||||
<line x1={108} y1={89 + lift} x2={129} y2={89 + lift} transform={`rotate(${-tilt} 108 ${89 + lift})`} />
|
||||
</g>
|
||||
);
|
||||
function Mouth({ f, uid }: { f: FaceParams; uid: string }) {
|
||||
const w = 32 * f.mouthWidth * (1 - f.mouthRound * 0.35);
|
||||
const cy = 137 - f.smile * 6;
|
||||
if (f.mouthOpen < 0.06 && f.mouthRound < 0.3) {
|
||||
return <path d={`M${100 - w / 2} ${cy} Q100 ${137 + f.smile * 12} ${100 + w / 2} ${cy}`} stroke={INK} strokeWidth={5} fill="none" strokeLinecap="round" />;
|
||||
}
|
||||
|
||||
function Eyes({ expression, t }: { expression: Expression; t: number }) {
|
||||
const big = expression === "surprised" || expression === "scared";
|
||||
const r = big ? 12.5 : 10.5;
|
||||
const pupil = expression === "scared" ? 3.4 : big ? 5.5 : 5;
|
||||
const blink = (t % 3.7) < 0.12 && !big ? 0.12 : 1;
|
||||
const squint = expression === "angry" ? 0.7 : expression === "happy" ? 0.8 : 1;
|
||||
const open = Math.max(f.mouthOpen, f.mouthRound * 0.25);
|
||||
// A curva quadrática só chega à metade do ponto de controle: os controles ficam no dobro da abertura desejada.
|
||||
const up = cy + f.smile * 2 - open * 8 - f.mouthRound * 6;
|
||||
const low = cy + open * 46 * (1 + f.mouthRound * 0.3) + f.smile * 12;
|
||||
const d = `M${100 - w / 2} ${cy} Q100 ${up} ${100 + w / 2} ${cy} Q100 ${low} ${100 - w / 2} ${cy} Z`;
|
||||
return (
|
||||
<g>
|
||||
{[82, 118].map((x) => (
|
||||
<g key={x} transform={`translate(${x} 108) scale(1 ${blink * squint})`}>
|
||||
<circle r={r} fill="#ffffff" />
|
||||
<circle r={pupil} cx={expression === "worried" ? -1.5 : 0} cy={expression === "sad" ? 2 : 0} fill={INK} />
|
||||
<defs><clipPath id={`m${uid}`}><path d={d} /></clipPath></defs>
|
||||
<path d={d} fill={INK} />
|
||||
<g clipPath={`url(#m${uid})`}>
|
||||
{f.teeth && open > 0.12 && <rect x={60} y={Math.min(up, cy) - 10} width={80} height={(cy - Math.min(up, cy)) + 10 + (low - cy) * 0.16} fill="#f7f7f2" />}
|
||||
{open > 0.4 && <ellipse cx={100} cy={cy + (low - cy) * 0.5} rx={w * 0.3} ry={(low - cy) * 0.16} fill="#d9534f" />}
|
||||
</g>
|
||||
))}
|
||||
</g>
|
||||
);
|
||||
}
|
||||
|
||||
function Glasses({ kind }: { kind: CharacterLook["glasses"] }) {
|
||||
if (kind === "none") return null;
|
||||
const lens = kind === "sun" ? INK : "none";
|
||||
function Eyes({ f, lid, skin, uid }: { f: FaceParams; lid: number; skin: string; uid: string }) {
|
||||
const big = Math.max(f.eyeL, f.eyeR);
|
||||
const r = 10.5 + Math.max(0, big - 1) * 7;
|
||||
const cover = Math.max(0, Math.min(0.85, lid));
|
||||
const eye = (x: number, open: number) => {
|
||||
// Olho de riso: fechado em arco para cima quando quase fechado e sorrindo.
|
||||
if (open < 0.3 && f.smile > 0.55) return <path key={x} d={`M${x - 10} 110 Q${x} 98 ${x + 10} 110`} stroke={INK} strokeWidth={4.5} fill="none" strokeLinecap="round" />;
|
||||
if (open < 0.14) return <path key={x} d={`M${x - 10} 108 Q${x} 113 ${x + 10} 108`} stroke={INK} strokeWidth={4} fill="none" strokeLinecap="round" />;
|
||||
return (
|
||||
<g stroke={INK} strokeWidth={4} fill={lens}>
|
||||
{kind === "square"
|
||||
? <><rect x={67} y={95} width={30} height={25} rx={5} /><rect x={103} y={95} width={30} height={25} rx={5} /></>
|
||||
: <><circle cx={82} cy={108} r={15} /><circle cx={118} cy={108} r={15} /></>}
|
||||
<line x1={97} y1={107} x2={103} y2={107} />
|
||||
<line x1={55} y1={104} x2={67} y2={106} /><line x1={133} y1={106} x2={145} y2={104} />
|
||||
<g key={x} transform={`translate(${x} 108) scale(1 ${Math.min(1.2, open)})`}>
|
||||
<defs><clipPath id={`e${uid}${x}`}><circle r={r} /></clipPath></defs>
|
||||
<circle r={r} fill="#ffffff" />
|
||||
<circle r={Math.max(2.2, 5 * f.pupil)} cx={f.gazeX * 4} cy={f.gazeY * 3 + cover * 3} fill={INK} />
|
||||
<circle r={1.6} cx={f.gazeX * 4 + 1.8} cy={f.gazeY * 3 - 1.8 + cover * 3} fill="#ffffff" opacity={0.85} />
|
||||
{cover > 0.02 && (
|
||||
<g clipPath={`url(#e${uid}${x})`}>
|
||||
<rect x={-r - 1} y={-r - 1} width={2 * r + 2} height={2 * r * cover + 1} fill={skin} />
|
||||
<path d={`M${-r} ${-r + 2 * r * cover} Q0 ${-r + 2 * r * cover + 3} ${r} ${-r + 2 * r * cover}`} stroke={shade(skin, 0.6)} strokeWidth={2.6} fill="none" />
|
||||
</g>
|
||||
)}
|
||||
</g>
|
||||
);
|
||||
};
|
||||
return <g>{eye(82, f.eyeL)}{eye(118, f.eyeR)}</g>;
|
||||
}
|
||||
|
||||
function Brows({ f, thick, color }: { f: FaceParams; thick: boolean; color: string }) {
|
||||
return (
|
||||
<g stroke={color} strokeWidth={thick ? 7 : 4.5} strokeLinecap="round">
|
||||
<line x1={71} y1={89 + f.browL.y} x2={92} y2={89 + f.browL.y} transform={`rotate(${-f.browL.tilt} 92 ${89 + f.browL.y})`} />
|
||||
<line x1={108} y1={89 + f.browR.y} x2={129} y2={89 + f.browR.y} transform={`rotate(${f.browR.tilt} 108 ${89 + f.browR.y})`} />
|
||||
</g>
|
||||
);
|
||||
}
|
||||
|
||||
function Extras({ f, t }: { f: FaceParams; t: number }) {
|
||||
return (
|
||||
<g>
|
||||
{f.blush > 0.02 && <><ellipse cx={72} cy={124} rx={11} ry={6} fill="#ff6b8b" opacity={0.55 * f.blush} /><ellipse cx={128} cy={124} rx={11} ry={6} fill="#ff6b8b" opacity={0.55 * f.blush} /></>}
|
||||
{f.sweat && <path d="M146 74 Q152 86 146 92 Q140 86 146 74 Z" fill="#8fd3ff" stroke="#3a8fd0" strokeWidth={1.5} />}
|
||||
{f.tears && [78, 122].map((x, i) => {
|
||||
const k = ((t * 1.4 + i * 0.5) % 1);
|
||||
return <path key={x} d={`M${x} ${116 + k * 26} q4 6 0 9 q-4 -3 0 -9 Z`} fill="#8fd3ff" opacity={1 - k * 0.6} />;
|
||||
})}
|
||||
{f.anger && <g stroke="#e8463d" strokeWidth={4} strokeLinecap="round" fill="none"><path d="M128 62 q6 4 12 0" /><path d="M128 74 q6 -4 12 0" /><path d="M128 62 q-4 6 0 12" /><path d="M140 62 q4 6 0 12" /></g>}
|
||||
</g>
|
||||
);
|
||||
}
|
||||
@@ -81,15 +103,57 @@ function Beard({ style, color }: { style: CharacterLook["beard"]["style"]; color
|
||||
switch (style) {
|
||||
case "full": return <path d="M56 108 Q58 168 100 172 Q142 168 144 108 Q138 128 124 126 Q100 122 76 126 Q62 128 56 108 Z" fill={color} />;
|
||||
case "stubble": return <path d="M60 116 Q64 162 100 166 Q136 162 140 116 Q130 132 100 128 Q70 132 60 116 Z" fill={color} opacity={0.35} />;
|
||||
case "goatee": return <path d="M88 146 Q100 166 112 146 Q100 152 88 146 Z" fill={color} />;
|
||||
case "mustache": return <path d="M82 128 Q100 120 118 128 Q110 134 100 130 Q90 134 82 128 Z" fill={color} />;
|
||||
case "goatee": return <path d="M88 150 Q100 168 112 150 Q100 156 88 150 Z" fill={color} />;
|
||||
case "mustache": return <path d="M76 134 Q80 117 100 121 Q120 117 124 134 Q113 128 100 131 Q87 128 76 134 Z" fill={color} />;
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
|
||||
function HairBack({ look }: { look: CharacterLook }) {
|
||||
if (look.hair.style !== "long") return null;
|
||||
return <path d="M50 100 Q48 40 100 38 Q152 40 150 100 L156 190 Q100 205 44 190 Z" fill={look.hair.color} />;
|
||||
function Nose({ kind, skin }: { kind: NonNullable<CharacterLook["nose"]>; skin: string }) {
|
||||
const dark = shade(skin, 0.72);
|
||||
switch (kind) {
|
||||
case "curve": return <path d="M97 110 Q86 123 95 128 Q101 131 105 126" stroke={dark} strokeWidth={3.6} fill="none" strokeLinecap="round" />;
|
||||
case "round": return <><circle cx={100} cy={121} r={9} fill={shade(skin, 0.9)} /><circle cx={97} cy={118} r={2.5} fill="#ffffff" opacity={0.35} /></>;
|
||||
case "long": return <path d="M99 104 L104 126 Q100 131 94 127" stroke={dark} strokeWidth={3.4} fill="none" strokeLinecap="round" strokeLinejoin="round" />;
|
||||
case "wide": return <><ellipse cx={100} cy={123} rx={11} ry={7} fill={shade(skin, 0.9)} /><circle cx={95} cy={125} r={2} fill={dark} /><circle cx={105} cy={125} r={2} fill={dark} /></>;
|
||||
default: return <ellipse cx={100} cy={123} rx={6} ry={4.5} fill={shade(skin, 0.86)} />;
|
||||
}
|
||||
}
|
||||
|
||||
function Wrinkles({ k, skin }: { k: number; skin: string }) {
|
||||
if (k <= 0.05) return null;
|
||||
const c = shade(skin, 0.78);
|
||||
return (
|
||||
<g stroke={c} strokeWidth={3} fill="none" strokeLinecap="round" opacity={Math.min(1, 0.5 + k * 0.5)}>
|
||||
<path d="M80 72 Q100 66 120 72" />
|
||||
{k > 0.35 && <path d="M84 80 Q100 75 116 80" />}
|
||||
{k > 0.5 && <><path d="M62 104 l-6 -3 M62 110 l-7 0" /><path d="M138 104 l6 -3 M138 110 l7 0" /></>}
|
||||
{k > 0.4 && <><path d="M76 128 Q72 138 76 146" /><path d="M124 128 Q128 138 124 146" /></>}
|
||||
</g>
|
||||
);
|
||||
}
|
||||
|
||||
/** Formato da cabeça (centro (100,106)). */
|
||||
function headPath(shape: CharacterLook["head"]): string {
|
||||
switch (shape) {
|
||||
case "oval": return "M100 54 C126 54 143 76 143 106 C143 140 124 160 100 160 C76 160 57 140 57 106 C57 76 74 54 100 54 Z";
|
||||
case "square": return "M100 56 C130 56 147 72 147 100 L146 128 C144 150 126 158 100 158 C74 158 56 150 54 128 L53 100 C53 72 70 56 100 56 Z";
|
||||
case "wide": return "M100 58 C124 58 140 74 143 98 C148 124 140 154 100 158 C60 154 52 124 57 98 C60 74 76 58 100 58 Z";
|
||||
default: return "M100 56 C126 56 147 78 147 106 C147 134 126 156 100 156 C74 156 53 134 53 106 C53 78 74 56 100 56 Z";
|
||||
}
|
||||
}
|
||||
|
||||
function Glasses({ kind }: { kind: CharacterLook["glasses"] }) {
|
||||
if (kind === "none") return null;
|
||||
return (
|
||||
<g stroke={INK} strokeWidth={4} fill={kind === "sun" ? INK : "none"}>
|
||||
{kind === "square"
|
||||
? <><rect x={67} y={95} width={30} height={25} rx={5} /><rect x={103} y={95} width={30} height={25} rx={5} /></>
|
||||
: <><circle cx={82} cy={108} r={15} /><circle cx={118} cy={108} r={15} /></>}
|
||||
<line x1={97} y1={107} x2={103} y2={107} />
|
||||
<line x1={55} y1={104} x2={67} y2={106} /><line x1={133} y1={106} x2={145} y2={104} />
|
||||
</g>
|
||||
);
|
||||
}
|
||||
|
||||
function HairFront({ look }: { look: CharacterLook }) {
|
||||
@@ -107,92 +171,189 @@ function HairFront({ look }: { look: CharacterLook }) {
|
||||
}
|
||||
}
|
||||
|
||||
function Torso({ look, w }: { look: CharacterLook; w: number }) {
|
||||
const { top } = look;
|
||||
const x0 = 100 - 36 * w;
|
||||
const x1 = 100 + 36 * w;
|
||||
const bottomY = top.style === "dress" ? 345 : 290;
|
||||
const flare = top.style === "dress" ? 14 : 0;
|
||||
const body = `M${x0} 172 Q${x0} 158 ${x0 + 14} 156 L${x1 - 14} 156 Q${x1} 158 ${x1} 172 L${x1 + flare} ${bottomY} L${x0 - flare} ${bottomY} Z`;
|
||||
const accent = top.accent ?? shade(top.color, 1.3);
|
||||
/** Cabeça inteira no sistema antigo (centro ~ (100,106)); `turn` desloca o rosto para fingir 3/4, `nod` sobe/desce. */
|
||||
function Head({ look, f, b, t, uid }: { look: CharacterLook; f: FaceParams; b: BodyParams; t: number; uid: string }) {
|
||||
const fx = b.headTurn * 9;
|
||||
const fy = b.headNod * 6;
|
||||
const browColor = look.hair.style === "bald" || look.hair.style === "cap" ? look.beard.color : look.hair.color;
|
||||
return (
|
||||
<g>
|
||||
{top.style === "hoodie" && <path d={`M${x0 + 6} 160 Q100 132 ${x1 - 6} 160 Z`} fill={shade(top.color, 0.8)} />}
|
||||
<path d={body} fill={top.color} />
|
||||
{top.style === "uniform" && <rect x={x0} y={248} width={x1 - x0} height={11} fill={accent} />}
|
||||
{top.style === "shirt" && top.accent && <rect x={x0} y={252} width={x1 - x0} height={9} fill={accent} />}
|
||||
{top.style === "jacket" && <><path d={`M100 158 L100 ${bottomY}`} stroke={shade(top.color, 0.6)} strokeWidth={4} /><path d="M86 158 L100 186 L114 158 Z" fill={accent} /></>}
|
||||
{top.style === "hoodie" && <rect x={84} y={240} width={32} height={22} rx={6} fill={shade(top.color, 0.85)} />}
|
||||
{top.style === "dress" && [0, 1, 2, 3].map((i) => <circle key={i} cx={84 + (i % 2) * 32} cy={196 + Math.floor(i / 2) * 70} r={3.5} fill="#ffffff" opacity={0.5} />)}
|
||||
{[53, 147].map((x, i) => (
|
||||
<g key={x} transform={`translate(${x + b.headTurn * 7} 112) scale(${1 - (i === 0 ? Math.max(0, b.headTurn) : -Math.min(0, b.headTurn)) * 0.5} 1)`}>
|
||||
<ellipse rx={9} ry={12} fill={shade(look.skin, 0.94)} />
|
||||
<path d={i === 0 ? "M3 -6 Q-4 0 3 6" : "M-3 -6 Q4 0 -3 6"} stroke={shade(look.skin, 0.72)} strokeWidth={2.4} fill="none" strokeLinecap="round" />
|
||||
</g>
|
||||
);
|
||||
}
|
||||
|
||||
function Legs({ look, w }: { look: CharacterLook; w: number }) {
|
||||
const { bottom } = look;
|
||||
const gap = 10 * w;
|
||||
const legW = 20 * w;
|
||||
const left = 100 - gap - legW;
|
||||
const right = 100 + gap;
|
||||
const skinTop = look.top.style === "dress" ? 345 : bottom.style === "shorts" ? 330 : bottom.style === "skirt" ? 345 : 440;
|
||||
return (
|
||||
<g>
|
||||
<rect x={left} y={286} width={legW} height={140} rx={6} fill={look.skin} />
|
||||
<rect x={right} y={286} width={legW} height={140} rx={6} fill={look.skin} />
|
||||
{look.top.style !== "dress" && bottom.style === "pants" && <><rect x={left} y={284} width={legW} height={142} rx={4} fill={bottom.color} /><rect x={right} y={284} width={legW} height={142} rx={4} fill={bottom.color} /></>}
|
||||
{look.top.style !== "dress" && bottom.style === "shorts" && <path d={`M${left - 2} 284 L${right + legW + 2} 284 L${right + legW + 2} ${skinTop} L${left - 2} ${skinTop} Z`} fill={bottom.color} />}
|
||||
{look.top.style !== "dress" && bottom.style === "skirt" && <path d={`M${left + 2} 284 L${right + legW - 2} 284 L${right + legW + 12} ${skinTop} L${left - 12} ${skinTop} Z`} fill={bottom.color} />}
|
||||
<rect x={left - 4} y={422} width={legW + 10} height={16} rx={7} fill={look.shoes} />
|
||||
<rect x={right - 6} y={422} width={legW + 10} height={16} rx={7} fill={look.shoes} />
|
||||
))}
|
||||
<defs><clipPath id={`h${uid}`}><path d={headPath(look.head)} /></clipPath></defs>
|
||||
<path d={headPath(look.head)} fill={look.skin} />
|
||||
{/* Sombra suave do lado de baixo/direito e brilho na testa: volume de ilustração. */}
|
||||
<g clipPath={`url(#h${uid})`}>
|
||||
<ellipse cx={128} cy={140} rx={44} ry={34} fill={shade(look.skin, 0.86)} opacity={0.55} />
|
||||
<ellipse cx={86} cy={72} rx={22} ry={12} fill="#ffffff" opacity={0.12} />
|
||||
</g>
|
||||
);
|
||||
}
|
||||
|
||||
export function CharacterFigure({ look = DEFAULT_LOOK, expression = "neutral", pose = "stand", item, t = 0 }: {
|
||||
look?: CharacterLook; expression?: Expression; pose?: Pose; item?: IconId; t?: number;
|
||||
}) {
|
||||
const w = look.build === "slim" ? 0.86 : look.build === "heavy" ? 1.22 : 1;
|
||||
const breathe = Math.sin(t * 2.2) * 1.6;
|
||||
const [r0, l0] = ARMS[pose];
|
||||
const swing = pose === "wave" ? Math.sin(t * 9) * 14 : Math.sin(t * 1.4) * 2.5;
|
||||
const rAngle = r0 + swing;
|
||||
const lAngle = l0 - (pose === "wave" ? 0 : swing);
|
||||
const shoulderY = 168;
|
||||
const sx = 34 * w;
|
||||
const sleeve = look.top.style === "dress" ? look.skin : look.top.color;
|
||||
const arm = (side: 1 | -1, angle: number, holds?: IconId) => (
|
||||
<g transform={`rotate(${angle} ${100 + side * sx} ${shoulderY})`}>
|
||||
<rect x={100 + side * sx - 9} y={shoulderY - 6} width={18} height={104} rx={9} fill={sleeve} />
|
||||
<circle cx={100 + side * sx} cy={shoulderY + 102} r={11} fill={look.skin} />
|
||||
{holds && (
|
||||
<g transform={`translate(${100 + side * sx - 26} ${shoulderY + 96}) rotate(${-angle} 26 26)`}>
|
||||
<svg x={0} y={0} width={52} height={52} viewBox="0 0 100 100" overflow="visible"><Icon id={holds} /></svg>
|
||||
<g transform={`translate(${fx} ${fy})`}>
|
||||
<Wrinkles k={look.wrinkles ?? 0} skin={look.skin} />
|
||||
<Beard style={look.beard.style} color={look.beard.color} />
|
||||
<Extras f={f} t={t} />
|
||||
<Eyes f={f} lid={(look.lids ?? 0) + f.lid} skin={look.skin} uid={uid} />
|
||||
{look.nose && <Nose kind={look.nose} skin={look.skin} />}
|
||||
<Brows f={f} thick={look.brows === "thick"} color={browColor} />
|
||||
<Glasses kind={look.glasses} />
|
||||
<Mouth f={f} uid={uid} />
|
||||
</g>
|
||||
<g transform={`translate(${fx * 0.4} 0)`}><HairFront look={look} /></g>
|
||||
{look.accessories?.includes("helmet") && (
|
||||
<g transform={`translate(${fx * 0.4} 0)`}>
|
||||
<path d="M50 92 Q50 42 100 42 Q150 42 150 92 Z" fill={look.accessoryColor ?? "#f2c230"} />
|
||||
<rect x={42} y={88} width={116} height={10} rx={5} fill={shade(look.accessoryColor ?? "#f2c230", 0.85)} />
|
||||
<path d="M100 44 L100 90" stroke={shade(look.accessoryColor ?? "#f2c230", 0.85)} strokeWidth={6} />
|
||||
</g>
|
||||
)}
|
||||
{look.accessories?.includes("headset") && (
|
||||
<g><path d="M52 100 Q52 44 100 44 Q148 44 148 100" stroke={INK} strokeWidth={6} fill="none" /><rect x={142} y={96} width={14} height={26} rx={6} fill={INK} /><path d="M150 120 Q140 142 116 140" stroke={INK} strokeWidth={3} fill="none" /></g>
|
||||
)}
|
||||
</g>
|
||||
);
|
||||
}
|
||||
|
||||
/** Acessórios por cima da roupa (combináveis). Capacete e fone são desenhados na cabeça. */
|
||||
function Accessories({ look, x0, x1, top, bottom, hipY }: { look: CharacterLook; x0: number; x1: number; top: number; bottom: number; hipY: number }) {
|
||||
const acc = look.accessories ?? [];
|
||||
const c = look.accessoryColor;
|
||||
return (
|
||||
<g>
|
||||
{acc.includes("vest") && <>
|
||||
<path d={`M${x0 + 2} ${top + 8} L${x0 + 30} ${top + 4} L${x0 + 30} ${bottom} L${x0 + 2} ${bottom} Z`} fill={c ?? "#ff8a2a"} />
|
||||
<path d={`M${x1 - 2} ${top + 8} L${x1 - 30} ${top + 4} L${x1 - 30} ${bottom} L${x1 - 2} ${bottom} Z`} fill={c ?? "#ff8a2a"} />
|
||||
<rect x={x0 + 2} y={hipY - 70} width={x1 - x0 - 4} height={8} fill="#d9dde3" opacity={0.95} />
|
||||
<rect x={x0 + 2} y={hipY - 40} width={x1 - x0 - 4} height={8} fill="#d9dde3" opacity={0.95} />
|
||||
</>}
|
||||
{acc.includes("apron") && <path d={`M${x0 + 10} ${top + 30} L${x1 - 10} ${top + 30} L${x1 - 4} ${hipY + 70} L${x0 + 4} ${hipY + 70} Z`} fill={c ?? "#e9ecef"} />}
|
||||
{acc.includes("tie") && <><path d={`M95 ${top + 4} L105 ${top + 4} L102 ${top + 14} L98 ${top + 14} Z`} fill={c ?? "#2b3a67"} /><path d={`M98 ${top + 14} L102 ${top + 14} L108 ${top + 80} L100 ${top + 92} L92 ${top + 80} Z`} fill={c ?? "#2b3a67"} /></>}
|
||||
{acc.includes("scarf") && <><rect x={82} y={top - 6} width={36} height={16} rx={7} fill={c ?? "#c8443a"} /><rect x={104} y={top + 6} width={12} height={40} rx={5} fill={c ?? "#c8443a"} /></>}
|
||||
{acc.includes("whistle") && <><path d={`M86 ${top + 4} L100 ${top + 52} L114 ${top + 4}`} stroke="#e8463d" strokeWidth={2.5} fill="none" /><rect x={94} y={top + 50} width={14} height={9} rx={4} fill="#c0c4cc" /></>}
|
||||
{acc.includes("chain") && <path d={`M84 ${top + 4} Q100 ${top + 48} 116 ${top + 4}`} stroke="#d4a63a" strokeWidth={3.5} fill="none" strokeDasharray="4 2" />}
|
||||
{acc.includes("badge") && <rect x={x0 + 14} y={top + 26} width={18} height={12} rx={2} fill={c ?? "#d4a63a"} />}
|
||||
{acc.includes("towel") && <path d={`M${x1 - 26} ${top - 4} Q${x1 - 6} ${top - 6} ${x1 - 4} ${top + 12} L${x1 - 10} ${hipY - 20} L${x1 - 34} ${hipY - 24} L${x1 - 36} ${top + 6} Z`} fill={c ?? "#efe6d2"} stroke={shade(c ?? "#efe6d2", 0.85)} strokeWidth={2} />}
|
||||
</g>
|
||||
);
|
||||
}
|
||||
|
||||
export function CharacterFigure({ look = DEFAULT_LOOK, expression, pose, item, t = 0, state }: {
|
||||
look?: CharacterLook; expression?: string; pose?: string; item?: IconId; t?: number;
|
||||
/** Estado calculado pela linha do tempo (motion.ts). Sem ele: expressão/pose pedidas + piscar/respirar. */
|
||||
state?: Pick<ActorState, "face" | "body" | "emote">;
|
||||
}) {
|
||||
const uid = useId().replace(/:/g, "");
|
||||
const st = state ?? evaluate({ x: 0, expression, pose }, t, 3600, 1);
|
||||
const f = st.face;
|
||||
const b = st.body;
|
||||
const w = look.build === "slim" ? 0.86 : look.build === "heavy" ? 1.22 : 1;
|
||||
const breathe = Math.sin(t * 2.2) * 1.4;
|
||||
|
||||
// Quadril desce ao sentar; coxas abrem e encurtam (perspectiva), canelas voltam para baixo.
|
||||
const hipY = 290 + b.crouch * 62;
|
||||
const legW = 20 * w;
|
||||
const pants = look.top.style === "dress" || look.bottom.style !== "pants" ? look.skin : look.bottom.color;
|
||||
const leg = (s: 1 | -1, l: Limb) => {
|
||||
const hx = 100 + s * 20 * w;
|
||||
const thighDeg = -s * (l.raise + b.crouch * 55);
|
||||
const knee = tip(hx, hipY, thighDeg, 72 * (1 - 0.72 * b.crouch));
|
||||
const shinDeg = thighDeg + s * (l.bend + b.crouch * 55);
|
||||
const foot = tip(knee.x, knee.y, shinDeg, 68);
|
||||
const shorts = look.bottom.style === "shorts" && look.top.style !== "dress";
|
||||
return (
|
||||
<g key={s}>
|
||||
<Segment x={hx} y={hipY} deg={thighDeg} len={72 * (1 - 0.72 * b.crouch)} w={legW} fill={shorts ? look.bottom.color : pants} />
|
||||
<Segment x={knee.x} y={knee.y} deg={shinDeg} len={68} w={legW * 0.95} fill={pants} />
|
||||
<rect x={foot.x - legW * 0.5 - (s < 0 ? 6 : 0)} y={foot.y - 8} width={legW + 10} height={16} rx={7} fill={look.shoes} />
|
||||
</g>
|
||||
);
|
||||
};
|
||||
|
||||
const sx = 34 * w;
|
||||
const shY = hipY - 122;
|
||||
const longSleeve = ["jacket", "hoodie", "uniform"].includes(look.top.style);
|
||||
const sleeve = look.top.style === "dress" ? look.skin : look.top.color;
|
||||
const arm = (s: 1 | -1, l: Limb, holds?: IconId) => {
|
||||
const x = 100 + s * sx;
|
||||
const upperDeg = -s * l.raise;
|
||||
const elbow = tip(x, shY, upperDeg, 54);
|
||||
const foreDeg = upperDeg + s * l.bend;
|
||||
const hand = tip(elbow.x, elbow.y, foreDeg, 50);
|
||||
return (
|
||||
<g key={s}>
|
||||
<Segment x={x} y={shY} deg={upperDeg} len={54} w={18} fill={sleeve} />
|
||||
<Segment x={elbow.x} y={elbow.y} deg={foreDeg} len={50} w={16} fill={longSleeve ? sleeve : look.skin} />
|
||||
<circle cx={hand.x} cy={hand.y} r={11} fill={look.skin} />
|
||||
<ellipse cx={hand.x - s * 8} cy={hand.y - 6} rx={4.5} ry={7} fill={shade(look.skin, 0.94)} transform={`rotate(${-s * 25} ${hand.x - s * 8} ${hand.y - 6})`} />
|
||||
{s < 0 && look.accessories?.includes("watch") && <rect x={hand.x - 9} y={hand.y - 22} width={18} height={8} rx={3} fill="#d4a63a" />}
|
||||
{holds && <svg x={hand.x - 26} y={hand.y - 30} width={52} height={52} viewBox="0 0 100 100" overflow="visible"><Icon id={holds} /></svg>}
|
||||
</g>
|
||||
);
|
||||
};
|
||||
// Mão perto do rosto (pensar, tapar a boca, mão na testa) é desenhada por cima da cabeça.
|
||||
const handOnFace = b.armR.raise < 45 && b.armR.bend > 135;
|
||||
|
||||
const top = look.top;
|
||||
const x0 = 100 - 36 * w;
|
||||
const x1 = 100 + 36 * w;
|
||||
const torsoTop = hipY - 134;
|
||||
const torsoBottom = top.style === "dress" ? hipY + 55 : hipY;
|
||||
const flare = top.style === "dress" ? 14 : 0;
|
||||
const accent = top.accent ?? shade(top.color, 1.3);
|
||||
const belly = !!look.belly;
|
||||
const torsoPath = `M${x0} ${torsoTop + 16} Q${x0} ${torsoTop + 2} ${x0 + 14} ${torsoTop} L${x1 - 14} ${torsoTop} Q${x1} ${torsoTop + 2} ${x1} ${torsoTop + 16} L${x1 + flare} ${torsoBottom} L${x0 - flare} ${torsoBottom} Z`;
|
||||
const holdItem = b.armR.raise > 20 || b.armR.bend > 40 ? item : undefined;
|
||||
|
||||
return (
|
||||
<svg viewBox="0 0 200 440" width="100%" height="100%" overflow="visible">
|
||||
<g transform={`translate(100 440) scale(${look.height}) translate(-100 -440) translate(0 ${breathe * 0.3})`}>
|
||||
<HairBack look={look} />
|
||||
<Legs look={look} w={w} />
|
||||
{arm(-1, lAngle)}
|
||||
<Torso look={look} w={w} />
|
||||
{pose !== "think" && arm(1, rAngle, pose === "hold" || pose === "point" ? item : undefined)}
|
||||
<rect x={90} y={146} width={20} height={16} fill={shade(look.skin, 0.9)} />
|
||||
<g transform={`translate(0 ${breathe * 0.4})`}>
|
||||
<ellipse cx={53} cy={112} rx={8} ry={11} fill={shade(look.skin, 0.92)} />
|
||||
<ellipse cx={147} cy={112} rx={8} ry={11} fill={shade(look.skin, 0.92)} />
|
||||
<ellipse cx={100} cy={106} rx={47} ry={50} fill={look.skin} />
|
||||
<Beard style={look.beard.style} color={look.beard.color} />
|
||||
<Eyes expression={expression} t={t} />
|
||||
<Brows expression={expression} thick={look.brows === "thick"} color={look.hair.style === "bald" || look.hair.style === "cap" ? look.beard.color : look.hair.color} />
|
||||
<Glasses kind={look.glasses} />
|
||||
<Mouth expression={expression} />
|
||||
<HairFront look={look} />
|
||||
<g transform={`translate(100 440) scale(${look.height}) translate(-100 -440)`}>
|
||||
{look.hair.style === "long" && (
|
||||
<g transform={`rotate(${b.lean} 100 ${hipY})`}>
|
||||
<path d={`M50 ${torsoTop - 34} Q48 ${torsoTop - 94} 100 ${torsoTop - 96} Q152 ${torsoTop - 94} 150 ${torsoTop - 34} L156 ${torsoTop + 56} Q100 ${torsoTop + 71} 44 ${torsoTop + 56} Z`} fill={look.hair.color} />
|
||||
</g>
|
||||
)}
|
||||
{leg(-1, b.legL)}
|
||||
{leg(1, b.legR)}
|
||||
{look.bottom.style === "skirt" && look.top.style !== "dress" && (
|
||||
<path d={`M${100 - 30 * w} ${hipY - 6} L${100 + 30 * w} ${hipY - 6} L${100 + 42 * w} ${hipY + 52} L${100 - 42 * w} ${hipY + 52} Z`} fill={look.bottom.color} />
|
||||
)}
|
||||
<g transform={`rotate(${b.lean} 100 ${hipY}) translate(0 ${breathe * 0.3})`}>
|
||||
{arm(-1, b.armL)}
|
||||
<g>
|
||||
{top.style === "hoodie" && <path d={`M${x0 + 6} ${torsoTop + 4} Q100 ${torsoTop - 24} ${x1 - 6} ${torsoTop + 4} Z`} fill={shade(top.color, 0.8)} />}
|
||||
<defs><clipPath id={`t${uid}`}><path d={torsoPath} /></clipPath></defs>
|
||||
<path d={torsoPath} fill={top.color} />
|
||||
{belly && <ellipse cx={100} cy={hipY - 44} rx={44 * w} ry={40} fill={top.color} />}
|
||||
<g clipPath={`url(#t${uid})`}>
|
||||
<rect x={100 + 14 * w} y={torsoTop} width={40 * w} height={torsoBottom - torsoTop + 2} fill="#000000" opacity={0.1} />
|
||||
</g>
|
||||
{/* Volume da barriga: curva de baixo mais escura e brilho em cima, sem "mancha". */}
|
||||
{belly && <><path d={`M${100 - 38 * w} ${hipY - 22} Q100 ${hipY + 4} ${100 + 38 * w} ${hipY - 22}`} stroke={shade(top.color, 0.72)} strokeWidth={4} fill="none" strokeLinecap="round" />
|
||||
<ellipse cx={100 - 14 * w} cy={hipY - 62} rx={16 * w} ry={10} fill="#ffffff" opacity={0.035} /></>}
|
||||
{(top.style === "shirt" || top.style === "uniform") && <path d={`M88 ${torsoTop} L100 ${torsoTop + 16} L112 ${torsoTop} Z`} fill={shade(top.color, 0.78)} />}
|
||||
{(top.style === "jacket" || top.style === "hoodie") && <path d={`M100 ${torsoTop + 6} L100 ${torsoBottom}`} stroke={shade(top.color, 0.65)} strokeWidth={3} />}
|
||||
{top.style === "uniform" && <rect x={x0} y={hipY - 42} width={x1 - x0} height={11} fill={accent} />}
|
||||
{top.style === "shirt" && top.accent && <rect x={x0} y={hipY - 38} width={x1 - x0} height={9} fill={accent} />}
|
||||
{top.style === "jacket" && <><path d={`M100 ${torsoTop + 2} L100 ${torsoBottom}`} stroke={shade(top.color, 0.6)} strokeWidth={4} /><path d={`M86 ${torsoTop + 2} L100 ${torsoTop + 30} L114 ${torsoTop + 2} Z`} fill={accent} /></>}
|
||||
{top.style === "hoodie" && <rect x={84} y={hipY - 50} width={32} height={22} rx={6} fill={shade(top.color, 0.85)} />}
|
||||
{top.style === "dress" && [0, 1, 2, 3].map((i) => <circle key={i} cx={84 + (i % 2) * 32} cy={torsoTop + 40 + Math.floor(i / 2) * 70} r={3.5} fill="#ffffff" opacity={0.5} />)}
|
||||
<Accessories look={look} x0={x0} x1={x1} top={torsoTop} bottom={torsoBottom} hipY={hipY} />
|
||||
</g>
|
||||
{!handOnFace && arm(1, b.armR, holdItem)}
|
||||
<rect x={90} y={torsoTop - 12} width={20} height={16} fill={shade(look.skin, 0.9)} />
|
||||
<g transform={`translate(0 ${torsoTop - 156 + breathe * 0.4}) rotate(${b.headTilt} 100 150)`}>
|
||||
<Head look={look} f={f} b={b} t={t} uid={uid} />
|
||||
{st.emote && (
|
||||
<g transform={`translate(150 30) scale(${0.4 + 0.6 * st.emote.k})`} opacity={st.emote.k}>
|
||||
<circle r={24} fill="#ffffff" stroke={INK} strokeWidth={3} />
|
||||
<text y={10} textAnchor="middle" fontSize={30} fontWeight={800} fill={st.emote.text === "!" || st.emote.text === "💢" ? "#e8463d" : INK}>{st.emote.text}</text>
|
||||
</g>
|
||||
)}
|
||||
</g>
|
||||
{handOnFace && arm(1, b.armR)}
|
||||
</g>
|
||||
{/* Pensando: a mão vai ao queixo, por cima da barba. */}
|
||||
{pose === "think" && arm(1, rAngle)}
|
||||
</g>
|
||||
</svg>
|
||||
);
|
||||
|
||||
+19
-8
@@ -4,9 +4,10 @@ import React from "react";
|
||||
import { AbsoluteFill, useCurrentFrame, useVideoConfig } from "remotion";
|
||||
import { CrowdFigure, PersonFigure } from "./actors";
|
||||
import { Icon } from "./icons";
|
||||
import { Captions, CrossOut, Hud, Rings, TagLabel, TextLayer, pop, shake } from "./overlays";
|
||||
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";
|
||||
@@ -35,16 +36,25 @@ export function Shot(spec: ShotSpec) {
|
||||
);
|
||||
}
|
||||
if (a.character) {
|
||||
// Personagem da biblioteca: mesmo visual em toda cena; muda expressão, pose e objeto na mão.
|
||||
const ch = height * 0.36 * (a.scale ?? 1);
|
||||
// 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: a.x * width - cw / 2, top: a.y * height - ch, width: cw, height: ch,
|
||||
opacity: Math.min(1, k * 1.5), transform: `translateY(${(1 - k) * 10}%) scaleX(${a.flip ? -1 : 1})` }}>
|
||||
<CharacterFigure look={a.character.look} expression={a.expression} pose={a.pose} item={a.item} t={frame / fps} />
|
||||
{label && (
|
||||
<div style={{ position: "absolute", left: "50%", top: "-15%", transform: `translateX(-50%) scaleX(${a.flip ? -1 : 1})`, textAlign: "center" }}>
|
||||
<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>
|
||||
@@ -80,6 +90,7 @@ export function Shot(spec: ShotSpec) {
|
||||
<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>
|
||||
|
||||
@@ -9,11 +9,18 @@ export const GLASSES = ["none", "round", "square", "sun"] as const;
|
||||
export const BROWS = ["thin", "thick"] as const;
|
||||
export const TOP_STYLES = ["shirt", "jacket", "hoodie", "dress", "uniform"] as const;
|
||||
export const BOTTOM_STYLES = ["pants", "shorts", "skirt"] as const;
|
||||
export const EXPRESSIONS = ["neutral", "happy", "sad", "worried", "angry", "surprised", "scared"] as const;
|
||||
export const POSES = ["stand", "point", "wave", "hold", "arms_up", "shrug", "think"] as const;
|
||||
export const HEAD_SHAPES = ["round", "oval", "square", "wide"] as const;
|
||||
export const NOSES = ["button", "curve", "round", "long", "wide"] as const;
|
||||
/** Acessórios desenhados por cima da roupa (combináveis). */
|
||||
export const ACCESSORIES = ["towel", "whistle", "tie", "vest", "helmet", "watch", "badge", "apron", "scarf", "headset", "chain"] as const;
|
||||
export type Accessory = (typeof ACCESSORIES)[number];
|
||||
// Expressões e poses são ATALHOS do rig (rig.ts): parâmetros contínuos que dá para ajustar e misturar.
|
||||
import { EXPRESSION_NAMES, POSE_NAMES, type ExpressionName, type PoseName } from "./rig";
|
||||
|
||||
export type Expression = (typeof EXPRESSIONS)[number];
|
||||
export type Pose = (typeof POSES)[number];
|
||||
export const EXPRESSIONS = EXPRESSION_NAMES;
|
||||
export const POSES = POSE_NAMES;
|
||||
export type Expression = ExpressionName;
|
||||
export type Pose = PoseName;
|
||||
|
||||
export type CharacterLook = {
|
||||
build: (typeof BUILDS)[number];
|
||||
@@ -27,6 +34,18 @@ export type CharacterLook = {
|
||||
top: { style: (typeof TOP_STYLES)[number]; color: string; accent?: string };
|
||||
bottom: { style: (typeof BOTTOM_STYLES)[number]; color: string };
|
||||
shoes: string;
|
||||
/** Detalhe de ilustração (opcionais; sem eles o personagem sai no traço simples). */
|
||||
head?: (typeof HEAD_SHAPES)[number];
|
||||
nose?: (typeof NOSES)[number];
|
||||
/** Pálpebra de cima de base (0 olho aberto … 0,6 meio caído, olhar cansado/esperto). */
|
||||
lids?: number;
|
||||
/** Rugas (0 nenhuma … 1 muitas: testa e canto dos olhos). */
|
||||
wrinkles?: number;
|
||||
/** Barriga saliente (o "forte" de barriga). */
|
||||
belly?: boolean;
|
||||
accessories?: Accessory[];
|
||||
/** Cor dos acessórios principais (toalha, gravata, colete, capacete…). */
|
||||
accessoryColor?: string;
|
||||
};
|
||||
|
||||
/** Ficha do personagem na biblioteca. `kind: "3d"` aponta para a pessoa articulada da Godot (godot/kits). */
|
||||
@@ -73,8 +92,14 @@ export function validateLook(look: unknown): string[] {
|
||||
if (!one(BROWS, l.brows)) errors.push(`brows: ${BROWS.join("|")}`);
|
||||
if (!one(TOP_STYLES, l.top?.style)) errors.push(`top.style: ${TOP_STYLES.join("|")}`);
|
||||
if (!one(BOTTOM_STYLES, l.bottom?.style)) errors.push(`bottom.style: ${BOTTOM_STYLES.join("|")}`);
|
||||
if (l.head !== undefined && !one(HEAD_SHAPES, l.head)) errors.push(`head: ${HEAD_SHAPES.join("|")}`);
|
||||
if (l.nose !== undefined && !one(NOSES, l.nose)) errors.push(`nose: ${NOSES.join("|")}`);
|
||||
if (l.lids !== undefined && !(typeof l.lids === "number" && l.lids >= 0 && l.lids <= 0.8)) errors.push("lids entre 0 e 0,8");
|
||||
if (l.wrinkles !== undefined && !(typeof l.wrinkles === "number" && l.wrinkles >= 0 && l.wrinkles <= 1)) errors.push("wrinkles entre 0 e 1");
|
||||
if (l.accessories !== undefined && (!Array.isArray(l.accessories) || l.accessories.some((a) => !one(ACCESSORIES, a)))) errors.push(`accessories: ${ACCESSORIES.join("|")}`);
|
||||
if (l.accessoryColor !== undefined && !HEX.test(l.accessoryColor)) errors.push("accessoryColor: cor #rrggbb");
|
||||
return errors;
|
||||
}
|
||||
|
||||
export const isExpression = (v: unknown): v is Expression => one(EXPRESSIONS, v);
|
||||
export const isPose = (v: unknown): v is Pose => one(POSES, v);
|
||||
export const isExpression = (v: unknown): v is Expression => typeof v === "string" && (EXPRESSIONS as string[]).includes(v);
|
||||
export const isPose = (v: unknown): v is Pose => typeof v === "string" && (POSES as string[]).includes(v);
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
// Boca acompanhando a fala SEM perder a expressão. O formato vem das letras da palavra que está sendo dita
|
||||
// (tempos de cada palavra da transcrição): "a" abre, "e/i" esticam, "o/u" arredondam, "m/b/p" fecham, "f/v"
|
||||
// mostram os dentes; vogal dura mais que consoante e as letras vizinhas se misturam (coarticulação). Se houver
|
||||
// o volume do áudio quadro a quadro (`env`), ele fecha a boca nas pausas e abre mais nas sílabas fortes.
|
||||
// A expressão continua por cima: os cantos (sorriso/tristeza), as sobrancelhas e os olhos são dela.
|
||||
import type { FaceParams } from "./rig";
|
||||
|
||||
export type Viseme = { open: number; wide: number; round: number; teeth: boolean };
|
||||
export type SpokenWord = { text: string; startS: number; endS: number };
|
||||
|
||||
const CLOSED: Viseme = { open: 0, wide: 0, round: 0, teeth: false };
|
||||
const V: Record<string, Viseme> = {
|
||||
a: { open: 0.85, wide: 0.3, round: 0, teeth: false },
|
||||
e: { open: 0.55, wide: 0.65, round: 0, teeth: true },
|
||||
i: { open: 0.3, wide: 0.95, round: 0, teeth: true },
|
||||
o: { open: 0.65, wide: 0, round: 0.75, teeth: false },
|
||||
u: { open: 0.35, wide: 0, round: 1, teeth: false },
|
||||
mbp: { open: 0, wide: 0.1, round: 0, teeth: false },
|
||||
fv: { open: 0.12, wide: 0.2, round: 0, teeth: true },
|
||||
cons: { open: 0.3, wide: 0.3, round: 0, teeth: true },
|
||||
};
|
||||
|
||||
function visemeOf(ch: string): Viseme {
|
||||
if ("aáàâã".includes(ch)) return V.a;
|
||||
if ("eéê".includes(ch)) return V.e;
|
||||
if ("iíy".includes(ch)) return V.i;
|
||||
if ("oóôõ".includes(ch)) return V.o;
|
||||
if ("uúü".includes(ch)) return V.u;
|
||||
if ("mbp".includes(ch)) return V.mbp;
|
||||
if ("fv".includes(ch)) return V.fv;
|
||||
return V.cons;
|
||||
}
|
||||
const isVowel = (ch: string) => /[aáàâãeéêiíyoóôõuúü]/.test(ch);
|
||||
|
||||
function mix(a: Viseme, b: Viseme, k: number): Viseme {
|
||||
return { open: a.open + (b.open - a.open) * k, wide: a.wide + (b.wide - a.wide) * k, round: a.round + (b.round - a.round) * k, teeth: k < 0.5 ? a.teeth : b.teeth };
|
||||
}
|
||||
|
||||
/** Formato da boca no instante `t` (segundos do trecho) para as palavras dadas; fechada fora das palavras. */
|
||||
export function visemeAt(words: SpokenWord[], t: number, env?: { values: number[]; fps: number }): Viseme {
|
||||
const w = words.find((x) => t >= x.startS && t < x.endS);
|
||||
if (!w) {
|
||||
// Fim de palavra: fecha em ~60 ms em vez de bater a boca.
|
||||
const prev = [...words].reverse().find((x) => x.endS <= t);
|
||||
return prev && t - prev.endS < 0.06 ? mix(V.cons, CLOSED, (t - prev.endS) / 0.06) : CLOSED;
|
||||
}
|
||||
const letters = [...w.text.toLowerCase().replace(/(ch|lh|nh|qu)/g, "c").replace(/[^a-záàâãéêíóôõúüçy]/g, "")];
|
||||
if (!letters.length) return CLOSED;
|
||||
// Vogal pesa o dobro da consoante no tempo da palavra.
|
||||
const weights = letters.map((ch) => (isVowel(ch) ? 1.7 : 0.8));
|
||||
const total = weights.reduce((a, b) => a + b, 0);
|
||||
let pos = ((t - w.startS) / Math.max(0.04, w.endS - w.startS)) * total;
|
||||
let i = 0;
|
||||
while (i < letters.length - 1 && pos > weights[i]) { pos -= weights[i]; i++; }
|
||||
const frac = Math.min(1, pos / weights[i]);
|
||||
const cur = visemeOf(letters[i]);
|
||||
const next = i + 1 < letters.length ? visemeOf(letters[i + 1]) : CLOSED;
|
||||
// Coarticulação: a 2ª metade da letra já caminha para a próxima.
|
||||
let v = frac > 0.5 ? mix(cur, next, (frac - 0.5) * 0.9) : cur;
|
||||
if (env?.values.length) {
|
||||
const a = env.values[Math.min(env.values.length - 1, Math.max(0, Math.floor(t * env.fps)))] ?? 0;
|
||||
const k = Math.max(0, Math.min(1.15, (a - 0.03) / 0.3));
|
||||
v = { ...v, open: v.open * (0.25 + 0.75 * Math.min(1, k)) * (k < 0.05 ? 0.2 : 1) };
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
/** Ênfase (0–1) no instante: o volume perto do pico levanta um pouco as sobrancelhas. */
|
||||
export function emphasisAt(t: number, env?: { values: number[]; fps: number }): number {
|
||||
if (!env?.values.length) return 0;
|
||||
const a = env.values[Math.min(env.values.length - 1, Math.max(0, Math.floor(t * env.fps)))] ?? 0;
|
||||
return Math.max(0, Math.min(1, (a - 0.45) / 0.4));
|
||||
}
|
||||
|
||||
/** Põe a fala na boca mantendo a expressão (cantos, sobrancelhas, olhos). `k` = quanto da fala entra (0–1). */
|
||||
export function speak(face: FaceParams, v: Viseme, k = 1, emphasis = 0): FaceParams {
|
||||
const open = Math.max(face.mouthOpen * 0.35, v.open * 0.9);
|
||||
return {
|
||||
...face,
|
||||
mouthOpen: face.mouthOpen + (open - face.mouthOpen) * k,
|
||||
mouthWidth: face.mouthWidth * (1 + (v.wide * 0.22 - v.round * 0.45) * k),
|
||||
mouthRound: face.mouthRound + (v.round - face.mouthRound) * k,
|
||||
teeth: k > 0.5 ? v.teeth && v.open > 0.1 : face.teeth,
|
||||
browL: { ...face.browL, y: face.browL.y - emphasis * 3 * k },
|
||||
browR: { ...face.browR, y: face.browR.y - emphasis * 3 * k },
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,216 @@
|
||||
// Movimento do personagem: uma LINHA DO TEMPO de ações que se combinam (não animações prontas). Cada ação tem
|
||||
// início (segundos `at`, fração do trecho `atP` ou a palavra da narração `cue`) e duração; o estado em cada
|
||||
// quadro sai de aplicar as ações em ordem sobre a expressão/pose de base, mais a "vida" (piscar, respirar).
|
||||
// Ações permanentes mudam o estado dali em diante (express, pose, walk, sit, fall, turn, look); as momentâneas
|
||||
// voltam ao fim (nod, shake_head, tremble, bounce, wave, jump, talk, emote).
|
||||
import { emphasisAt, speak, visemeAt, type SpokenWord } from "./lipsync";
|
||||
import { blendBody, blendFace, bodyOf, faceOf, withBody, withFace, type BodyParams, type BodyPatch, type FaceParams, type FacePatch } from "./rig";
|
||||
|
||||
export const ACTIONS = ["express", "pose", "walk", "run", "enter", "exit", "jump", "nod", "shake_head", "tremble", "bounce", "fall",
|
||||
"sit", "stand_up", "turn", "talk", "look", "emote", "wave"] as const;
|
||||
export type ActionKind = (typeof ACTIONS)[number];
|
||||
|
||||
export type Action = {
|
||||
do: ActionKind;
|
||||
/** Início: segundos, fração do trecho (0–1) ou a 1ª palavra da narração que começa com `cue`. */
|
||||
at?: number; atP?: number; cue?: string;
|
||||
dur?: number;
|
||||
/** talk: termina no fim desta palavra da narração (a fala vai de `cue` até `cueEnd`). */
|
||||
cueEnd?: string;
|
||||
expression?: string; face?: FacePatch;
|
||||
pose?: string; body?: BodyPatch;
|
||||
/** walk/run/enter: x de destino (fração). */
|
||||
to?: number;
|
||||
/** look: para onde; fall: para que lado. */
|
||||
dir?: "left" | "right" | "up" | "down";
|
||||
/** nod/shake_head/bounce/wave: repetições. jump: altura (fração da altura do quadro). */
|
||||
times?: number; height?: number;
|
||||
/** emote: símbolo sobre a cabeça ("!", "?", "…", "♥", "zzz", "💢"). talk: o texto falado (sem tempos de palavra, é
|
||||
* repartido pela duração). */
|
||||
text?: string;
|
||||
};
|
||||
|
||||
export type ActorInput = {
|
||||
x: number; expression?: string; pose?: string; face?: FacePatch; body?: BodyPatch; flip?: boolean; timeline?: Action[];
|
||||
};
|
||||
|
||||
export type ActorState = {
|
||||
face: FaceParams; body: BodyParams;
|
||||
x: number; dy: number; dx: number; rot: number; sx: number; sy: number; flip: boolean;
|
||||
emote: { text: string; k: number } | null;
|
||||
};
|
||||
|
||||
const DEFAULT_DUR: Record<ActionKind, number> = {
|
||||
express: 0.25, pose: 0.35, walk: 1.6, run: 0.9, enter: 1.2, exit: 1.2, jump: 0.8, nod: 0.7, shake_head: 0.8, tremble: 1, bounce: 0.8,
|
||||
fall: 0.6, sit: 0.5, stand_up: 0.5, turn: 0.3, talk: 1.5, look: 0.3, emote: 1.2, wave: 1.2,
|
||||
};
|
||||
|
||||
const clamp01 = (v: number) => Math.max(0, Math.min(1, v));
|
||||
const ease = (p: number) => (p < 0.5 ? 2 * p * p : 1 - (-2 * p + 2) ** 2 / 2);
|
||||
/** Passa um pouco do alvo e volta (dá vida às poses). */
|
||||
const easeBack = (p: number) => { const c = 1.4; return 1 + (c + 1) * (p - 1) ** 3 + c * (p - 1) ** 2; };
|
||||
const norm = (s: string) => s.normalize("NFD").replace(/[̀-ͯ]/g, "").toLowerCase().replace(/[^a-z0-9]/g, "");
|
||||
|
||||
/** Início da ação em segundos (cue = palavra falada; sem a palavra, cai para atP/at/0). */
|
||||
export function startOf(a: Action, durationS: number, words: { text: string; startS: number }[] = []): number {
|
||||
if (a.cue) {
|
||||
const c = norm(a.cue);
|
||||
const w = words.find((x) => norm(x.text).startsWith(c));
|
||||
if (w) return w.startS;
|
||||
}
|
||||
if (a.atP !== undefined) return a.atP * durationS;
|
||||
return a.at ?? 0;
|
||||
}
|
||||
|
||||
/** Piscar em intervalos variados (2,4–4,6 s), determinístico pela semente. */
|
||||
function blinkAt(t: number, seed: number): number {
|
||||
let s = 0.6 + (seed % 7) * 0.13;
|
||||
let k = 1;
|
||||
while (s < t + 0.2) {
|
||||
const d = t - s;
|
||||
if (d >= 0 && d < 0.13) k = Math.min(k, Math.abs(d - 0.065) / 0.065);
|
||||
s += 2.4 + ((Math.sin(s * 12.9898 + seed) + 1) / 2) * 2.2;
|
||||
}
|
||||
return k;
|
||||
}
|
||||
|
||||
/** Fala do trecho: palavras com tempo (narração) e, se houver, o volume do áudio quadro a quadro. */
|
||||
export type Speech = { words: SpokenWord[]; env?: { values: number[]; fps: number } };
|
||||
|
||||
/** Fim da fala: o fim da palavra `cueEnd` (depois do início), senão início + dur. */
|
||||
function endOf(a: Action, s: number, words: SpokenWord[]): number | null {
|
||||
if (!a.cueEnd) return null;
|
||||
const c = norm(a.cueEnd);
|
||||
const w = words.find((x) => x.startS >= s - 0.01 && norm(x.text).startsWith(c));
|
||||
return w ? w.endS : null;
|
||||
}
|
||||
|
||||
export function evaluate(actor: ActorInput, t: number, durationS: number, seed = 1, speech: Speech = { words: [] }): ActorState {
|
||||
const words = speech.words;
|
||||
const st: ActorState = {
|
||||
face: faceOf(actor.expression, actor.face), body: bodyOf(actor.pose, actor.body),
|
||||
x: actor.x, dy: 0, dx: 0, rot: 0, sx: 1, sy: 1, flip: !!actor.flip, emote: null,
|
||||
};
|
||||
const timeline = (actor.timeline ?? []).map((a) => ({ a, s: startOf(a, durationS, words) })).sort((p, q) => p.s - q.s);
|
||||
for (const { a, s } of timeline) {
|
||||
if (t < s) break;
|
||||
const end = a.do === "talk" ? endOf(a, s, words) : null;
|
||||
const d = Math.max(0.05, end !== null ? end - s : a.dur ?? DEFAULT_DUR[a.do]);
|
||||
const p = clamp01((t - s) / d);
|
||||
const active = t - s < d;
|
||||
const env = active ? Math.min(1, (t - s) / 0.15, (s + d - t) / 0.15) : 0; // entra e sai suave (momentâneas)
|
||||
switch (a.do) {
|
||||
case "express": {
|
||||
const target = a.expression ? faceOf(a.expression, a.face) : withFace(st.face, a.face);
|
||||
st.face = blendFace(st.face, target, ease(p));
|
||||
break;
|
||||
}
|
||||
case "pose": {
|
||||
const target = a.pose ? bodyOf(a.pose, a.body) : withBody(st.body, a.body);
|
||||
st.body = blendBody(st.body, target, clamp01(easeBack(p)));
|
||||
break;
|
||||
}
|
||||
case "walk": case "run": case "enter": case "exit": {
|
||||
const from = a.do === "enter" ? (a.to ?? st.x) < 0.5 ? -0.25 : 1.25 : st.x;
|
||||
const to = a.do === "exit" ? (st.x < 0.5 ? -0.3 : 1.3) : a.to ?? st.x;
|
||||
const run = a.do === "run";
|
||||
st.x = from + (to - from) * (run ? p : ease(p));
|
||||
if (to !== from) st.flip = to < from;
|
||||
if (active) {
|
||||
const phase = (t - s) * Math.PI * 2 * (run ? 3.2 : 2.1);
|
||||
const amp = run ? 1.6 : 1;
|
||||
const sw = Math.sin(phase);
|
||||
st.body = withBody(st.body, {
|
||||
armL: { raise: 8 + sw * 20 * amp, bend: run ? 85 : 15 }, armR: { raise: 8 - sw * 20 * amp, bend: run ? 85 : 15 },
|
||||
legL: { raise: 3 + Math.max(0, sw) * 6, bend: Math.max(0, sw) * 38 * amp }, legR: { raise: 3 + Math.max(0, -sw) * 6, bend: Math.max(0, -sw) * 38 * amp },
|
||||
lean: (to < from ? -1 : 1) * (run ? 8 : 3),
|
||||
});
|
||||
st.dy -= Math.abs(Math.sin(phase)) * (run ? 0.012 : 0.006);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "jump": {
|
||||
if (!active) break;
|
||||
const h = a.height ?? 0.08;
|
||||
if (p < 0.15) { st.sy *= 1 - 0.1 * (p / 0.15); st.sx *= 1 + 0.06 * (p / 0.15); st.body = withBody(st.body, { crouch: 0.35 * (p / 0.15) }); }
|
||||
else if (p < 0.85) {
|
||||
const q = (p - 0.15) / 0.7;
|
||||
st.dy -= h * 4 * q * (1 - q);
|
||||
st.sy *= 1.07; st.sx *= 0.95;
|
||||
st.body = withBody(st.body, { arms: { raise: 120, bend: -10 }, legs: { raise: 6, bend: 30 } });
|
||||
} else { const q = (p - 0.85) / 0.15; st.sy *= 1 - 0.08 * (1 - q); st.sx *= 1 + 0.05 * (1 - q); }
|
||||
break;
|
||||
}
|
||||
case "nod": st.body = withBody(st.body, { headNod: st.body.headNod + Math.sin(p * Math.PI * 2 * (a.times ?? 2)) * 0.6 * env }); break;
|
||||
case "shake_head": st.body = withBody(st.body, { headTurn: st.body.headTurn + Math.sin(p * Math.PI * 2 * (a.times ?? 2)) * 0.7 * env }); break;
|
||||
case "tremble": if (active) { st.dx += Math.sin(t * 77.7) * 0.004 * env; st.dy += Math.cos(t * 91.3) * 0.002 * env; } break;
|
||||
case "bounce": st.dy -= Math.abs(Math.sin(p * Math.PI * (a.times ?? 2))) * 0.02 * env; break;
|
||||
case "fall": {
|
||||
const side = a.dir === "right" ? 1 : -1;
|
||||
st.rot = side * 88 * ease(p);
|
||||
st.dy += 0.02 * ease(p);
|
||||
st.face = blendFace(st.face, faceOf("shocked"), Math.min(1, p * 3));
|
||||
break;
|
||||
}
|
||||
case "sit": st.body = blendBody(st.body, withBody(st.body, { crouch: 1, arms: { raise: 14, bend: 40 } }), ease(p)); break;
|
||||
case "stand_up": st.body = blendBody(st.body, withBody(st.body, { crouch: 0 }), ease(p)); break;
|
||||
case "turn": {
|
||||
const flipped = !st.flip;
|
||||
if (p >= 0.5) st.flip = flipped;
|
||||
if (active) st.sx *= Math.max(0.15, Math.abs(Math.cos(p * Math.PI)));
|
||||
break;
|
||||
}
|
||||
case "talk": {
|
||||
if (!active) break;
|
||||
// Palavras da narração dentro da fala; sem elas, o texto da ação repartido pela duração (vogal pesa mais).
|
||||
let spoken = words.filter((w) => w.endS > s && w.startS < s + d);
|
||||
if (!spoken.length && a.text) {
|
||||
const list = a.text.split(/\s+/).filter(Boolean);
|
||||
const total = list.reduce((n, w) => n + w.length + 1, 0);
|
||||
let c = s;
|
||||
spoken = list.map((w) => { const len = (d * (w.length + 1)) / total; const out = { text: w, startS: c, endS: c + len * 0.88 }; c += len; return out; });
|
||||
}
|
||||
if (spoken.length) {
|
||||
st.face = speak(st.face, visemeAt(spoken, t, speech.env), Math.min(1, (t - s) / 0.08, (s + d - t) / 0.08 + 0.2), emphasisAt(t, speech.env));
|
||||
} else {
|
||||
const flap = Math.abs(Math.sin((t - s) * Math.PI * 2 * 4.3 + seed)) * (0.6 + 0.4 * Math.sin((t - s) * 9.1 + seed));
|
||||
st.face = { ...st.face, mouthOpen: Math.max(st.face.mouthOpen, (0.12 + 0.5 * flap) * env), teeth: st.face.teeth || flap > 0.6 };
|
||||
}
|
||||
// Quem fala mexe a cabeça de leve e acompanha as sílabas fortes.
|
||||
st.body = withBody(st.body, { headTilt: st.body.headTilt + Math.sin((t - s) * 5.3) * 2 * env, headNod: st.body.headNod + emphasisAt(t, speech.env) * 0.25 });
|
||||
break;
|
||||
}
|
||||
case "look": {
|
||||
const gx = a.dir === "left" ? -0.9 : a.dir === "right" ? 0.9 : 0;
|
||||
const gy = a.dir === "up" ? -0.8 : a.dir === "down" ? 0.8 : 0;
|
||||
const k = ease(p);
|
||||
st.face = { ...st.face, gazeX: st.face.gazeX + (gx - st.face.gazeX) * k, gazeY: st.face.gazeY + (gy - st.face.gazeY) * k };
|
||||
st.body = withBody(st.body, { headTurn: st.body.headTurn + (gx * 0.5 - st.body.headTurn) * k, headNod: st.body.headNod + (gy * -0.4 - st.body.headNod) * k });
|
||||
break;
|
||||
}
|
||||
case "emote": if (active) st.emote = { text: a.text ?? "!", k: env }; break;
|
||||
case "wave": if (active) st.body = withBody(st.body, { armR: { raise: 140 * Math.min(1, env * 1.5), bend: -25 + Math.sin(p * Math.PI * 2 * (a.times ?? 3)) * 30 } }); break;
|
||||
}
|
||||
}
|
||||
// Vida: piscar (a não ser de olhos quase fechados), respirar e um balanço leve de cabeça.
|
||||
const blink = blinkAt(t, seed);
|
||||
if (blink < 1) st.face = { ...st.face, eyeL: st.face.eyeL * Math.max(0.08, blink), eyeR: st.face.eyeR * Math.max(0.08, blink) };
|
||||
st.body = withBody(st.body, { headTilt: st.body.headTilt + Math.sin(t * 0.9 + seed) * 1.2 });
|
||||
return st;
|
||||
}
|
||||
|
||||
/** Confere uma linha do tempo (lista de problemas; vazia = ok). */
|
||||
export function validateTimeline(timeline: unknown): string[] {
|
||||
if (timeline === undefined) return [];
|
||||
if (!Array.isArray(timeline) || timeline.length > 40) return ["timeline: lista de até 40 ações"];
|
||||
const errors: string[] = [];
|
||||
timeline.forEach((a: Partial<Action>, i) => {
|
||||
if (!a || !ACTIONS.includes(a.do as ActionKind)) errors.push(`timeline[${i}].do: ${ACTIONS.join(", ")}`);
|
||||
for (const k of ["at", "atP", "dur", "to", "times", "height"] as const) {
|
||||
if (a[k] !== undefined && (typeof a[k] !== "number" || !Number.isFinite(a[k]))) errors.push(`timeline[${i}].${k}: número`);
|
||||
}
|
||||
if (a.atP !== undefined && !(a.atP >= 0 && a.atP <= 1)) errors.push(`timeline[${i}].atP entre 0 e 1`);
|
||||
if (a.dur !== undefined && !(a.dur > 0 && a.dur <= 30)) errors.push(`timeline[${i}].dur entre 0 e 30 s`);
|
||||
});
|
||||
return errors;
|
||||
}
|
||||
@@ -130,3 +130,16 @@ export function Captions({ words, frame, fps, y = 0.665 }: { words: Word[]; fram
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/** Textura de papel/granulado por cima de tudo: tira a cara de "vetor de computador" (acabamento de ilustração). */
|
||||
export function Grain({ opacity = 0.11, seed = 3 }: { opacity?: number; seed?: number }) {
|
||||
return (
|
||||
<svg width="100%" height="100%" style={{ position: "absolute", inset: 0, mixBlendMode: "overlay", opacity, pointerEvents: "none" }}>
|
||||
<filter id={`grain${seed}`}>
|
||||
<feTurbulence type="fractalNoise" baseFrequency="0.85" numOctaves={2} seed={seed} stitchTiles="stitch" />
|
||||
<feColorMatrix type="saturate" values="0" />
|
||||
</filter>
|
||||
<rect width="100%" height="100%" filter={`url(#grain${seed})`} />
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,163 @@
|
||||
// Rig do personagem: o rosto e o corpo são PARÂMETROS contínuos, não desenhos prontos. Uma expressão ou uma
|
||||
// pose é só um conjunto de valores; dá para misturar (blend), ajustar um valor ("sorriso 0,3 a mais") e criar
|
||||
// novas sem mexer no desenho. Ângulos em graus; "para fora" positivo nos dois lados (o desenho espelha).
|
||||
|
||||
export type FaceParams = {
|
||||
/** Sobrancelha: y (px; negativo sobe) e tilt (graus; positivo = ponta de dentro sobe, como triste/preocupado). */
|
||||
browL: { y: number; tilt: number };
|
||||
browR: { y: number; tilt: number };
|
||||
/** Abertura dos olhos (0 fechado · 1 normal · 1,35 arregalado). */
|
||||
eyeL: number;
|
||||
eyeR: number;
|
||||
/** Tamanho da pupila (0,4 pavor · 1 normal · 1,3 encantado). */
|
||||
pupil: number;
|
||||
/** Direção do olhar (-1…1). */
|
||||
gazeX: number;
|
||||
gazeY: number;
|
||||
/** Boca: abertura 0…1, sorriso -1 (triste) … 1 (feliz), largura 0,5…1,4, dentes à mostra. */
|
||||
mouthOpen: number;
|
||||
smile: number;
|
||||
mouthWidth: number;
|
||||
/** Arredondamento dos lábios (0 normal … 1 bico de "o/u"): vem da fala (lipsync.ts). */
|
||||
mouthRound: number;
|
||||
/** Pálpebra de cima somada à de base do personagem (−0,5 arregala … 0,6 quase fecha). */
|
||||
lid: number;
|
||||
teeth: boolean;
|
||||
/** Extras: rubor 0…1, gota de suor, lágrimas, veia de raiva. */
|
||||
blush: number;
|
||||
sweat: boolean;
|
||||
tears: boolean;
|
||||
anger: boolean;
|
||||
};
|
||||
|
||||
export type Limb = {
|
||||
/** Abertura a partir do corpo (0 = para baixo; 90 = horizontal para fora; 180 = para cima). */
|
||||
raise: number;
|
||||
/** Dobra do cotovelo/joelho (positivo = antebraço/canela para dentro, na frente do corpo). */
|
||||
bend: number;
|
||||
};
|
||||
|
||||
export type BodyParams = {
|
||||
/** Inclinação do tronco (graus; positivo = para a direita de quem olha). */
|
||||
lean: number;
|
||||
/** Cabeça: inclinação (graus), virada (-1…1, finge 3/4) e aceno (-1 olha para cima … 1 para baixo). */
|
||||
headTilt: number;
|
||||
headTurn: number;
|
||||
headNod: number;
|
||||
armL: Limb;
|
||||
armR: Limb;
|
||||
legL: Limb;
|
||||
legR: Limb;
|
||||
/** Agachar/sentar: 0 em pé … 1 sentado (quadril desce, coxa encurta em perspectiva). */
|
||||
crouch: number;
|
||||
};
|
||||
|
||||
export const NEUTRAL_FACE: FaceParams = {
|
||||
browL: { y: 0, tilt: 0 }, browR: { y: 0, tilt: 0 }, eyeL: 1, eyeR: 1, pupil: 1, gazeX: 0, gazeY: 0,
|
||||
mouthOpen: 0, smile: 0.1, mouthWidth: 1, mouthRound: 0, lid: 0, teeth: false, blush: 0, sweat: false, tears: false, anger: false,
|
||||
};
|
||||
|
||||
export const NEUTRAL_BODY: BodyParams = {
|
||||
lean: 0, headTilt: 0, headTurn: 0, headNod: 0,
|
||||
armL: { raise: 8, bend: 6 }, armR: { raise: 8, bend: 6 }, legL: { raise: 2, bend: 0 }, legR: { raise: 2, bend: 0 }, crouch: 0,
|
||||
};
|
||||
|
||||
type FacePatch = Partial<Omit<FaceParams, "browL" | "browR">> & { browL?: Partial<FaceParams["browL"]>; browR?: Partial<FaceParams["browR"]>; brows?: Partial<FaceParams["browL"]>; eyes?: number };
|
||||
type BodyPatch = Partial<Omit<BodyParams, "armL" | "armR" | "legL" | "legR">> & { armL?: Partial<Limb>; armR?: Partial<Limb>; legL?: Partial<Limb>; legR?: Partial<Limb>; arms?: Partial<Limb>; legs?: Partial<Limb> };
|
||||
|
||||
/** Aplica um ajuste parcial (aceita `brows`/`eyes`/`arms`/`legs` para os dois lados de uma vez). */
|
||||
export function withFace(base: FaceParams, p: FacePatch = {}): FaceParams {
|
||||
const { brows, eyes, browL, browR, ...rest } = p;
|
||||
return {
|
||||
...base, ...rest,
|
||||
browL: { ...base.browL, ...brows, ...browL }, browR: { ...base.browR, ...brows, ...browR },
|
||||
eyeL: rest.eyeL ?? eyes ?? base.eyeL, eyeR: rest.eyeR ?? eyes ?? base.eyeR,
|
||||
};
|
||||
}
|
||||
export function withBody(base: BodyParams, p: BodyPatch = {}): BodyParams {
|
||||
const { arms, legs, armL, armR, legL, legR, ...rest } = p;
|
||||
return {
|
||||
...base, ...rest,
|
||||
armL: { ...base.armL, ...arms, ...armL }, armR: { ...base.armR, ...arms, ...armR },
|
||||
legL: { ...base.legL, ...legs, ...legL }, legR: { ...base.legR, ...legs, ...legR },
|
||||
};
|
||||
}
|
||||
|
||||
/** Expressões prontas = atalhos de parâmetros (dá para ajustar qualquer valor por cima com `face`). */
|
||||
export const EXPRESSION_PRESETS = {
|
||||
neutral: {},
|
||||
smile: { smile: 0.7, eyes: 0.9 },
|
||||
happy: { smile: 0.9, mouthOpen: 0.3, teeth: true, eyes: 0.85, brows: { y: -3 } },
|
||||
laugh: { smile: 1, mouthOpen: 0.75, teeth: true, eyes: 0.18, brows: { y: -5 }, blush: 0.4 },
|
||||
proud: { smile: 0.6, lid: 0.35, brows: { y: -2 } },
|
||||
sad: { smile: -0.7, brows: { tilt: 16 }, eyes: 0.8, gazeY: 0.5 },
|
||||
cry: { smile: -0.9, mouthOpen: 0.35, brows: { tilt: 20 }, eyes: 0.4, tears: true },
|
||||
worried: { smile: -0.3, brows: { tilt: 14, y: -2 }, eyes: 1.05, sweat: true },
|
||||
angry: { smile: -0.4, brows: { tilt: -18, y: 3 }, lid: 0.25, mouthWidth: 0.9 },
|
||||
furious: { smile: -0.6, mouthOpen: 0.6, teeth: true, brows: { tilt: -24, y: 4 }, lid: 0.3, anger: true },
|
||||
surprised: { mouthOpen: 0.6, mouthWidth: 0.55, smile: 0, brows: { y: -8 }, eyes: 1.25, pupil: 0.8, lid: -0.5 },
|
||||
scared: { mouthOpen: 0.5, mouthWidth: 0.9, smile: -0.5, teeth: true, brows: { tilt: 18, y: -6 }, eyes: 1.3, pupil: 0.55, sweat: true, lid: -0.5 },
|
||||
shocked: { mouthOpen: 0.95, mouthWidth: 0.6, smile: 0, brows: { y: -10 }, eyes: 1.35, pupil: 0.45, lid: -0.5 },
|
||||
suspicious: { smile: -0.1, mouthWidth: 0.8, browL: { y: -6, tilt: 0 }, browR: { y: 4, tilt: -10 }, lid: 0.45, gazeX: 0.6 },
|
||||
smirk: { smile: 0.45, mouthWidth: 0.8, browL: { y: -5 }, lid: 0.3, gazeX: -0.3 },
|
||||
confused: { smile: -0.2, mouthWidth: 0.75, browL: { y: -7 }, browR: { tilt: -8 }, gazeY: -0.6, gazeX: 0.4 },
|
||||
disgusted: { smile: -0.7, mouthWidth: 1.1, brows: { tilt: -10, y: 2 }, lid: 0.35 },
|
||||
sleepy: { lid: 0.6, brows: { y: 3 }, mouthOpen: 0.1, smile: 0 },
|
||||
determined: { smile: 0.1, mouthWidth: 0.85, brows: { tilt: -10, y: 2 }, lid: 0.2 },
|
||||
embarrassed: { smile: 0.3, blush: 1, gazeY: 0.6, gazeX: -0.4, eyes: 0.8, sweat: true },
|
||||
} satisfies Record<string, FacePatch>;
|
||||
|
||||
/** Poses prontas = atalhos de ângulos (ajustáveis por cima com `body`). */
|
||||
export const POSE_PRESETS = {
|
||||
stand: {},
|
||||
point: { armR: { raise: 92, bend: 0 } },
|
||||
wave: { armR: { raise: 140, bend: -25 } },
|
||||
hold: { armR: { raise: 28, bend: 75 } },
|
||||
arms_up: { arms: { raise: 158, bend: -10 } },
|
||||
celebrate: { arms: { raise: 150, bend: -30 }, headNod: -0.4 },
|
||||
shrug: { arms: { raise: 38, bend: 100 }, headTilt: 7 },
|
||||
think: { armR: { raise: 18, bend: 150 }, headTilt: -6 },
|
||||
hands_on_hips: { arms: { raise: 42, bend: 105 } },
|
||||
cross_arms: { arms: { raise: 22, bend: 128 } },
|
||||
facepalm: { armR: { raise: 26, bend: 158 }, headNod: 0.5, headTilt: 5 },
|
||||
cover_mouth: { armR: { raise: 16, bend: 168 } },
|
||||
defend: { arms: { raise: 62, bend: 118 }, lean: -4 },
|
||||
reach: { armR: { raise: 70, bend: -10 }, lean: 6 },
|
||||
sit: { crouch: 1, arms: { raise: 14, bend: 40 } },
|
||||
kneel: { crouch: 0.6, arms: { raise: 10, bend: 20 } },
|
||||
lean_in: { lean: 8, headTilt: 6 },
|
||||
} satisfies Record<string, BodyPatch>;
|
||||
|
||||
export type ExpressionName = keyof typeof EXPRESSION_PRESETS;
|
||||
export type PoseName = keyof typeof POSE_PRESETS;
|
||||
export const EXPRESSION_NAMES = Object.keys(EXPRESSION_PRESETS) as ExpressionName[];
|
||||
export const POSE_NAMES = Object.keys(POSE_PRESETS) as PoseName[];
|
||||
|
||||
export const faceOf = (name: string | undefined, patch?: FacePatch): FaceParams =>
|
||||
withFace(withFace(NEUTRAL_FACE, (EXPRESSION_PRESETS as Record<string, FacePatch>)[name ?? "neutral"] ?? {}), patch);
|
||||
export const bodyOf = (name: string | undefined, patch?: BodyPatch): BodyParams =>
|
||||
withBody(withBody(NEUTRAL_BODY, (POSE_PRESETS as Record<string, BodyPatch>)[name ?? "stand"] ?? {}), patch);
|
||||
|
||||
const lerp = (a: number, b: number, k: number) => a + (b - a) * k;
|
||||
const limb = (a: Limb, b: Limb, k: number): Limb => ({ raise: lerp(a.raise, b.raise, k), bend: lerp(a.bend, b.bend, k) });
|
||||
|
||||
/** Mistura duas expressões (k = 0 → a, 1 → b). Os "liga/desliga" trocam na metade. */
|
||||
export function blendFace(a: FaceParams, b: FaceParams, k: number): FaceParams {
|
||||
const pick = <T,>(x: T, y: T) => (k < 0.5 ? x : y);
|
||||
return {
|
||||
browL: { y: lerp(a.browL.y, b.browL.y, k), tilt: lerp(a.browL.tilt, b.browL.tilt, k) },
|
||||
browR: { y: lerp(a.browR.y, b.browR.y, k), tilt: lerp(a.browR.tilt, b.browR.tilt, k) },
|
||||
eyeL: lerp(a.eyeL, b.eyeL, k), eyeR: lerp(a.eyeR, b.eyeR, k), pupil: lerp(a.pupil, b.pupil, k),
|
||||
gazeX: lerp(a.gazeX, b.gazeX, k), gazeY: lerp(a.gazeY, b.gazeY, k),
|
||||
mouthOpen: lerp(a.mouthOpen, b.mouthOpen, k), smile: lerp(a.smile, b.smile, k), mouthWidth: lerp(a.mouthWidth, b.mouthWidth, k), mouthRound: lerp(a.mouthRound, b.mouthRound, k), lid: lerp(a.lid, b.lid, k),
|
||||
teeth: pick(a.teeth, b.teeth), blush: lerp(a.blush, b.blush, k), sweat: pick(a.sweat, b.sweat), tears: pick(a.tears, b.tears), anger: pick(a.anger, b.anger),
|
||||
};
|
||||
}
|
||||
export function blendBody(a: BodyParams, b: BodyParams, k: number): BodyParams {
|
||||
return {
|
||||
lean: lerp(a.lean, b.lean, k), headTilt: lerp(a.headTilt, b.headTilt, k), headTurn: lerp(a.headTurn, b.headTurn, k), headNod: lerp(a.headNod, b.headNod, k),
|
||||
armL: limb(a.armL, b.armL, k), armR: limb(a.armR, b.armR, k), legL: limb(a.legL, b.legL, k), legR: limb(a.legR, b.legR, k), crouch: lerp(a.crouch, b.crouch, k),
|
||||
};
|
||||
}
|
||||
|
||||
export type { FacePatch, BodyPatch };
|
||||
+23
-2
@@ -3,6 +3,8 @@
|
||||
// do quadro (0 = esquerda/topo, 1 = direita/base). Tempos em segundos, a partir do início do trecho.
|
||||
|
||||
import { EXPRESSIONS, POSES, validateLook, type CharacterLook, type Expression, type Pose } from "./character";
|
||||
import { validateTimeline, type Action } from "./motion";
|
||||
import type { BodyPatch, FacePatch } from "./rig";
|
||||
import { ELEMENTS, GROUNDS, PALETTES, type PaletteId, type Place } from "./places";
|
||||
|
||||
/** "place" = lugar montado por peças (ver places.tsx); os demais são fundos prontos da 1ª versão. */
|
||||
@@ -27,6 +29,13 @@ export type Person = {
|
||||
item?: IconId;
|
||||
/** Olha para a esquerda (espelha o desenho). */
|
||||
flip?: boolean;
|
||||
/** Enquadramento: corpo inteiro (padrão), meio corpo ou de perto (rosto grande, como ilustração de destaque). */
|
||||
framing?: "full" | "medium" | "close";
|
||||
/** Ajuste fino por cima da expressão/pose (ex.: { smile: 0.3, browL: { y: -6 } } ou { armR: { raise: 60 } }). */
|
||||
face?: FacePatch;
|
||||
body?: BodyPatch;
|
||||
/** Movimento: ações com início (at/atP/cue) — andar, pular, falar, trocar de expressão… (motion.ts). */
|
||||
timeline?: Action[];
|
||||
/** Cor da roupa (hex). */
|
||||
outfit?: string;
|
||||
hair?: "short" | "bun" | "none";
|
||||
@@ -78,6 +87,8 @@ export type ShotSpec = {
|
||||
palette?: PaletteId;
|
||||
/** Lugar montado por peças (scene.kind "place"). */
|
||||
place?: Place;
|
||||
/** Textura de papel por cima (0 desliga; padrão 0,11). */
|
||||
grain?: number;
|
||||
/** Luz por cima: foco do teto ("spot") ou vinheta. */
|
||||
light?: (typeof LIGHTS)[number];
|
||||
/** push = zoom no fim do trecho (1 = parado); panX = deslocamento horizontal da câmera (fração). */
|
||||
@@ -86,8 +97,10 @@ export type ShotSpec = {
|
||||
actors?: Actor[];
|
||||
props?: Prop[];
|
||||
texts?: TextItem[];
|
||||
/** Legenda palavra por palavra (tempos da narração). Vazio = sem legenda. */
|
||||
/** Legenda palavra por palavra (tempos da narração). Vazio = sem legenda. A boca de quem "fala" usa os mesmos tempos. */
|
||||
words?: Word[];
|
||||
/** Volume do áudio do trecho quadro a quadro (0–1): fecha a boca nas pausas e abre nas sílabas fortes. */
|
||||
audioEnv?: { fps: number; values: number[] };
|
||||
card?: { title: string; subtitle?: string; footer?: string };
|
||||
};
|
||||
|
||||
@@ -129,8 +142,15 @@ export function validateSpec(spec: unknown): string[] {
|
||||
} else if (a.kind === "person" && a.expression !== undefined && !EXPRESSIONS.includes(a.expression)) errors.push(`actors[${i}]: expressão (${EXPRESSIONS.join(", ")})`);
|
||||
else if (a.kind === "person" && a.pose !== undefined && !POSES.includes(a.pose)) errors.push(`actors[${i}]: pose (${POSES.join(", ")})`);
|
||||
else if (a.kind === "person" && a.item !== undefined && !ICONS.includes(a.item)) errors.push(`actors[${i}]: item "${a.item}" não existe`);
|
||||
else if (a.kind === "person") {
|
||||
for (const e of validateTimeline(a.timeline)) errors.push(`actors[${i}].${e}`);
|
||||
for (const [j, act] of (a.timeline ?? []).entries()) {
|
||||
if (act.expression !== undefined && !EXPRESSIONS.includes(act.expression as Expression)) errors.push(`actors[${i}].timeline[${j}]: expressão "${act.expression}" não existe`);
|
||||
if (act.pose !== undefined && !POSES.includes(act.pose as Pose)) errors.push(`actors[${i}].timeline[${j}]: pose "${act.pose}" não existe`);
|
||||
}
|
||||
}
|
||||
else if (a.kind === "crowd" && (!finite(a.count) || a.count < 1 || a.count > 40 || !frac(a.y))) errors.push(`actors[${i}]: crowd inválida`);
|
||||
else if (a.kind !== "person" && a.kind !== "crowd") errors.push(`actors[${i}]: kind inválido`);
|
||||
else if ((a as { kind: string }).kind !== "crowd") errors.push(`actors[${i}]: kind inválido`);
|
||||
}
|
||||
for (const [i, p] of (s.props ?? []).entries()) {
|
||||
if (!ICONS.includes(p.icon)) errors.push(`props[${i}]: ícone "${p.icon}" não existe (${ICONS.join(", ")})`);
|
||||
@@ -142,6 +162,7 @@ export function validateSpec(spec: unknown): string[] {
|
||||
if (typeof t.text !== "string" || !t.text.trim()) errors.push(`texts[${i}]: texto vazio`);
|
||||
if (!frac(t.x) || !frac(t.y)) errors.push(`texts[${i}]: x/y fora do quadro`);
|
||||
}
|
||||
if (s.audioEnv !== undefined && (!finite(s.audioEnv.fps) || !Array.isArray(s.audioEnv.values) || s.audioEnv.values.length > 36000)) errors.push("audioEnv: { fps, values[] } (até 36 mil valores)");
|
||||
for (const [i, w] of (s.words ?? []).entries()) {
|
||||
if (typeof w.text !== "string" || !finite(w.startS) || !finite(w.endS) || w.endS < w.startS) errors.push(`words[${i}]: inválida`);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { describe, it } from "node:test";
|
||||
import { visemeAt, speak } from "../src/lipsync";
|
||||
import { evaluate, startOf, validateTimeline } from "../src/motion";
|
||||
import { EXPRESSION_NAMES, blendFace, faceOf } from "../src/rig";
|
||||
|
||||
const words = [
|
||||
{ text: "Mamãe", startS: 0.2, endS: 0.7 },
|
||||
{ text: "não", startS: 0.8, endS: 1.2 },
|
||||
{ text: "ouviu", startS: 1.3, endS: 1.8 },
|
||||
];
|
||||
|
||||
describe("rig: expressões como parâmetros", () => {
|
||||
it("toda expressão pronta vira parâmetros válidos e se mistura com outra", () => {
|
||||
for (const name of EXPRESSION_NAMES) assert.ok(Number.isFinite(faceOf(name).smile), name);
|
||||
const half = blendFace(faceOf("sad"), faceOf("happy"), 0.5);
|
||||
assert.ok(half.smile > faceOf("sad").smile && half.smile < faceOf("happy").smile);
|
||||
});
|
||||
it("ajuste fino por cima de uma expressão", () => {
|
||||
assert.equal(faceOf("neutral", { smile: 0.8, browL: { y: -6 } }).browL.y, -6);
|
||||
});
|
||||
});
|
||||
|
||||
describe("linha do tempo", () => {
|
||||
it("cue = palavra falada; atP = fração do trecho", () => {
|
||||
assert.equal(startOf({ do: "nod", cue: "nao" }, 4, words), 0.8);
|
||||
assert.equal(startOf({ do: "nod", atP: 0.5 }, 4, words), 2);
|
||||
assert.equal(startOf({ do: "nod", cue: "inexistente", at: 1 }, 4, words), 1);
|
||||
});
|
||||
it("andar chega ao destino e vira para o lado certo; é determinístico", () => {
|
||||
const actor = { x: 0.7, timeline: [{ do: "walk" as const, at: 0, to: 0.3, dur: 1 }] };
|
||||
const end = evaluate(actor, 2, 4);
|
||||
assert.ok(Math.abs(end.x - 0.3) < 1e-9);
|
||||
assert.equal(end.flip, true);
|
||||
assert.deepEqual(evaluate(actor, 0.5, 4), evaluate(actor, 0.5, 4));
|
||||
});
|
||||
it("trocar expressão é suave e permanente", () => {
|
||||
const actor = { x: 0.5, timeline: [{ do: "express" as const, at: 1, expression: "happy", dur: 0.4 }] };
|
||||
const mid = evaluate(actor, 1.2, 4).face.smile;
|
||||
assert.ok(mid > faceOf("neutral").smile && mid < faceOf("happy").smile);
|
||||
assert.ok(Math.abs(evaluate(actor, 3, 4).face.smile - faceOf("happy").smile) < 1e-9);
|
||||
});
|
||||
it("pular sobe e volta ao chão", () => {
|
||||
const actor = { x: 0.5, timeline: [{ do: "jump" as const, at: 0, dur: 1 }] };
|
||||
assert.ok(evaluate(actor, 0.5, 4).dy < -0.05);
|
||||
assert.equal(evaluate(actor, 2, 4).dy, 0);
|
||||
});
|
||||
it("valida a linha do tempo", () => {
|
||||
assert.deepEqual(validateTimeline([{ do: "walk", to: 0.3 }]), []);
|
||||
assert.match(validateTimeline([{ do: "voar" }]).join(), /do:/);
|
||||
});
|
||||
});
|
||||
|
||||
describe("fala: boca pelas letras, expressão mantida", () => {
|
||||
it("m fecha, a abre, o arredonda; fora das palavras fica fechada", () => {
|
||||
assert.equal(visemeAt(words, 0.21).open, 0); // "M" do começo
|
||||
assert.ok(visemeAt([{ text: "aaa", startS: 0, endS: 1 }], 0.5).open > 0.7);
|
||||
assert.ok(visemeAt([{ text: "oo", startS: 0, endS: 1 }], 0.5).round > 0.6);
|
||||
assert.equal(visemeAt(words, 3).open, 0);
|
||||
});
|
||||
it("falando bravo continua bravo (sobrancelhas e cantos da boca)", () => {
|
||||
const angry = faceOf("angry");
|
||||
const talking = speak(angry, visemeAt([{ text: "aaa", startS: 0, endS: 1 }], 0.5));
|
||||
assert.equal(talking.browL.tilt, angry.browL.tilt);
|
||||
assert.equal(talking.smile, angry.smile);
|
||||
assert.ok(talking.mouthOpen > 0.5);
|
||||
});
|
||||
it("a ação falar vai da palavra de início até o fim da palavra final", () => {
|
||||
const actor = { x: 0.5, timeline: [{ do: "talk" as const, cue: "mamae", cueEnd: "ouviu" }] };
|
||||
assert.ok(evaluate(actor, 0.45, 4, 1, { words }).face.mouthOpen > 0.2);
|
||||
assert.ok(evaluate(actor, 2.5, 4, 1, { words }).face.mouthOpen < 0.05);
|
||||
});
|
||||
it("com o volume do áudio, a boca fecha na pausa", () => {
|
||||
const env = { fps: 10, values: Array.from({ length: 20 }, (_, i) => (i === 5 ? 0 : 0.9)) };
|
||||
const loud = visemeAt([{ text: "aaaaaaaaaa", startS: 0, endS: 2 }], 0.25, env).open;
|
||||
const pause = visemeAt([{ text: "aaaaaaaaaa", startS: 0, endS: 2 }], 0.55, env).open;
|
||||
assert.ok(loud > 0.5 && pause < 0.2);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,79 @@
|
||||
# Expressões, movimento e fala do estilo Cartoon
|
||||
|
||||
Nada aqui é animação pronta: o personagem tem um **rig** (rosto e corpo por parâmetros) e uma **linha do
|
||||
tempo** de ações que se combinam. Expressões e poses com nome são só atalhos — ajuste qualquer valor por cima
|
||||
ou crie combinações novas. Código: `cartoon/src/rig.ts`, `motion.ts`, `lipsync.ts`, `CharacterFigure.tsx`.
|
||||
|
||||
## Rosto (FaceParams)
|
||||
|
||||
| Parâmetro | Faixa | Efeito |
|
||||
|---|---|---|
|
||||
| `browL` / `browR` `{ y, tilt }` | y −10…6 px · tilt −25…25° | y negativo sobe; tilt + = ponta de dentro sobe (triste), − = desce (bravo) |
|
||||
| `eyeL` / `eyeR` | 0…1,35 | 0 fechado · 1 normal · 1,35 arregalado (fechado + sorriso = olho de riso em arco) |
|
||||
| `pupil` | 0,4…1,3 | pupila pequena = pavor |
|
||||
| `gazeX` / `gazeY` | −1…1 | para onde olha |
|
||||
| `mouthOpen` | 0…1 | abertura |
|
||||
| `smile` | −1…1 | cantos para baixo (triste/bravo) ou para cima (feliz) |
|
||||
| `mouthWidth` | 0,5…1,4 | estreita (O de susto) ou larga |
|
||||
| `mouthRound` | 0…1 | bico de "o/u" (a fala usa) |
|
||||
| `teeth` | sim/não | dentes à mostra |
|
||||
| `blush`, `sweat`, `tears`, `anger` | 0…1 / sim/não | rubor, gota de suor, lágrimas escorrendo, veia de raiva |
|
||||
|
||||
Atalhos (`expression`): neutral, smile, happy, laugh, proud, sad, cry, worried, angry, furious, surprised,
|
||||
scared, shocked, suspicious, smirk, confused, disgusted, sleepy, determined, embarrassed.
|
||||
Ajuste fino no ator: `"face": { "smile": 0.3, "browL": { "y": -6 } }` (aceita `brows` e `eyes` para os dois
|
||||
lados). Expressão nova = combinação de parâmetros; não precisa de desenho novo.
|
||||
|
||||
## Corpo (BodyParams)
|
||||
|
||||
Braços e pernas em dois segmentos: `raise` (abre a partir do corpo: 0 baixo, 90 horizontal, 180 para cima) e
|
||||
`bend` (dobra o cotovelo/joelho para dentro). Mais `lean` (tronco), `headTilt`, `headTurn` (−1…1, finge 3/4),
|
||||
`headNod` (−1 olha para cima … 1 para baixo) e `crouch` (0 em pé … 1 sentado).
|
||||
|
||||
Atalhos (`pose`): stand, point, wave, hold, arms_up, celebrate, shrug, think, hands_on_hips, cross_arms,
|
||||
facepalm, cover_mouth, defend, reach, sit, kneel, lean_in. Ajuste: `"body": { "armR": { "raise": 60 } }`.
|
||||
|
||||
## Linha do tempo (`timeline` do ator)
|
||||
|
||||
Cada ação começa em `at` (segundos), `atP` (fração do trecho) ou **`cue`** (a palavra da narração: começa quando
|
||||
a voz diz essa palavra — o jeito preferido). `dur` muda a duração.
|
||||
|
||||
| Ação | Efeito | Campos |
|
||||
|---|---|---|
|
||||
| `express` | troca de expressão (suave, fica) | `expression` e/ou `face` |
|
||||
| `pose` | troca de pose (com leve passada do ponto) | `pose` e/ou `body` |
|
||||
| `walk` / `run` | anda/corre até `to` (x), virando para o lado | `to` |
|
||||
| `enter` / `exit` | entra de fora do quadro / sai | `to` |
|
||||
| `jump` | preparação, salto com esticada, aterrissagem | `height` |
|
||||
| `nod` / `shake_head` | sim / não com a cabeça | `times` |
|
||||
| `tremble` · `bounce` | tremer · quicar de alegria | `times` |
|
||||
| `fall` | cai de lado (cara de choque) | `dir` |
|
||||
| `sit` / `stand_up` | senta / levanta | — |
|
||||
| `turn` | vira (espelha passando pelo perfil) | — |
|
||||
| `look` | olhar e cabeça para um lado | `dir` left/right/up/down |
|
||||
| `wave` | acena | `times` |
|
||||
| `emote` | balão sobre a cabeça | `text` "!", "?", "…" |
|
||||
| `talk` | fala: boca pelas letras e volume | `cue` + `cueEnd` (palavras) ou `text` + `dur` |
|
||||
|
||||
Sempre há "vida": piscar em intervalos variados, respirar e balanço leve de cabeça.
|
||||
|
||||
## Fala com expressão
|
||||
|
||||
`talk` usa os tempos de cada palavra (transcrição do áudio do trecho) e o volume do áudio quadro a quadro
|
||||
(`audioEnv`, gerado pelo painel). A boca segue as letras — "a" abre, "e/i" esticam, "o/u" arredondam,
|
||||
"m/b/p" fecham, "f/v" mostram os dentes —, fecha nas pausas e abre mais nas sílabas fortes. **A expressão
|
||||
continua**: os cantos da boca, as sobrancelhas e os olhos são dela (bravo falando segue bravo).
|
||||
Para um personagem dizer uma fala da narração: `{ "do": "talk", "cue": "primeira", "cueEnd": "ultima" }`.
|
||||
|
||||
## Como o plano automático usa isso (panel/src/lib/montage-cartoon.ts → `timelineFor`)
|
||||
|
||||
- Emoção na palavra: "medo" → `express scared` com `cue: "medo"` (o personagem começa neutro).
|
||||
- Verbos viram ações: andou/correu/pulou/caiu/sentou/levantou/negou/concordou/tremeu/riu/chorou/olhou/virou/
|
||||
pensou/acenou/apontou/cruzou os braços/comemorou; "de repente" → balão "!"; "por que/será" → "?".
|
||||
- Fala entre aspas ou depois de travessão → `talk` do personagem de `cue` (1ª palavra) a `cueEnd` (última).
|
||||
|
||||
## Boas práticas
|
||||
|
||||
- Uma mudança de expressão por frase basta; muitas trocas parecem tique.
|
||||
- Ação no verbo, emoção na palavra da emoção: o público vê acontecer quando ouve.
|
||||
- Movimento grande (correr, cair) pede câmera parada; parado falando pede `push` lento.
|
||||
@@ -46,6 +46,12 @@ cria (pela descrição), ajusta e apaga. O elenco de cada história fica em `sto
|
||||
| `top.style` | `shirt`, `jacket`, `hoodie`, `dress`, `uniform` (`accent` = faixa/gola) |
|
||||
| `bottom.style` | `pants`, `shorts`, `skirt` |
|
||||
| cores | sempre `#rrggbb` |
|
||||
| `head` (opcional) | `round`, `oval`, `square`, `wide` |
|
||||
| `nose` (opcional) | `button`, `curve` (de perfil, tipo C), `round`, `long`, `wide` |
|
||||
| `lids` (opcional) | 0 a 0,6 — pálpebra de cima de base: olhar caído, experiente (o que mais dá "cara de ilustração") |
|
||||
| `wrinkles` (opcional) | 0 a 1 — testa, canto dos olhos e bigode chinês |
|
||||
| `belly` (opcional) | barriga saliente |
|
||||
| `accessories` (opcional) | `towel`, `whistle`, `tie`, `vest`, `helmet`, `watch`, `badge`, `apron`, `scarf`, `headset`, `chain` (+ `accessoryColor`) |
|
||||
|
||||
`kind: "3d"` reserva o personagem para a Godot (pessoa articulada de `godot/kits/`, parâmetros em `godot`);
|
||||
o Cartoon ignora esses.
|
||||
@@ -54,13 +60,19 @@ o Cartoon ignora esses.
|
||||
|
||||
No spec do trecho (`cartoon/src/spec.ts`), um ator `person` com `character` (nome, legenda, look) e:
|
||||
|
||||
- `expression`: `neutral`, `happy`, `sad`, `worried`, `angry`, `surprised`, `scared`
|
||||
- `pose`: `stand`, `point`, `wave`, `hold`, `arms_up`, `shrug`, `think`
|
||||
- `expression` e `pose`: atalhos do rig (20 expressões, 17 poses) com ajuste fino `face`/`body`, e
|
||||
`timeline` com movimento e fala — tudo em `doc/cartoon/animacao.md`.
|
||||
- `item` (com `hold`/`point`): ícone na mão — `phone`, `fuel`, `battery`, `money`, `bulb`, `clock`, …
|
||||
- `flip`: olha para a esquerda.
|
||||
|
||||
## Como criar um bom personagem
|
||||
|
||||
Nível de acabamento de ilustração (referência estudada em 17/11/2026: ilustrações de série no Instagram):
|
||||
pálpebra caída (`lids` 0,25–0,35) + nariz + rugas para os mais velhos, uma marca de profissão nos acessórios
|
||||
(apito do técnico, capacete e colete do operário, avental da merendeira), corpo com formato (barriga, ombro) e,
|
||||
quando ele é o centro da cena, enquadramento `medium` ou `close`. A cena inteira ganha textura de papel (`grain`).
|
||||
A descrição em texto já preenche tudo isso por regras (idade, profissão, "barrigudo", "narigudo", "cansado"…).
|
||||
|
||||
- Uma silhueta reconhecível de longe: **uma** marca forte (careca + barba grisalha, coque branco, boné vermelho).
|
||||
- Roupa de cor chapada que contraste com a paleta da série (sépia pede verde/azul; noite pede amarelo/roxo).
|
||||
- `caption` curta, com função e idade ("Engenheiro de minas · 58 anos"): aparece na 1ª cena.
|
||||
|
||||
@@ -4,10 +4,11 @@
|
||||
// escolhe daqui (montagem Cartoon).
|
||||
import { useEffect, useState } from "react";
|
||||
import {
|
||||
BEARD_STYLES, BOTTOM_STYLES, BROWS, BUILDS, EXPRESSIONS, GLASSES, HAIR_STYLES, POSES, TOP_STYLES,
|
||||
ACCESSORIES, BEARD_STYLES, BOTTOM_STYLES, BROWS, BUILDS, EXPRESSIONS, GLASSES, HAIR_STYLES, HEAD_SHAPES, NOSES, POSES, TOP_STYLES,
|
||||
type Character, type CharacterLook, type Expression, type Pose,
|
||||
} from "cenaforge-cartoon/character";
|
||||
import { CharacterFigure } from "cenaforge-cartoon/figure";
|
||||
import { ACTIONS, evaluate, type ActionKind } from "cenaforge-cartoon/motion";
|
||||
import { apiCall } from "./api-client";
|
||||
import { askConfirm } from "./confirm-dialog";
|
||||
import { PlusIcon, SparkIcon, TrashIcon, UsersIcon } from "./icons";
|
||||
@@ -20,8 +21,17 @@ const LABEL: Record<string, string> = {
|
||||
round: "redondo", square: "quadrado", sun: "escuro", thin: "finas", thick: "grossas",
|
||||
shirt: "camisa", jacket: "jaqueta", hoodie: "moletom", dress: "vestido", uniform: "uniforme",
|
||||
pants: "calça", shorts: "bermuda", skirt: "saia",
|
||||
neutral: "neutro", happy: "feliz", sad: "triste", worried: "preocupado", angry: "bravo", surprised: "surpreso", scared: "com medo",
|
||||
stand: "em pé", point: "apontando", wave: "acenando", hold: "segurando", arms_up: "braços pra cima", shrug: "ombros", think: "pensando",
|
||||
neutral: "neutro", smile: "sorriso", happy: "feliz", laugh: "rindo", proud: "orgulhoso", sad: "triste", cry: "chorando", worried: "preocupado",
|
||||
angry: "bravo", furious: "furioso", surprised: "surpreso", scared: "com medo", shocked: "chocado", suspicious: "desconfiado", smirk: "sorriso de canto",
|
||||
confused: "confuso", disgusted: "enojado", sleepy: "com sono", determined: "decidido", embarrassed: "envergonhado",
|
||||
stand: "em pé", point: "apontando", wave: "acenando", hold: "segurando", arms_up: "braços pra cima", celebrate: "comemorando", shrug: "ombros",
|
||||
think: "pensando", hands_on_hips: "mãos na cintura", cross_arms: "braços cruzados", facepalm: "mão na testa", cover_mouth: "mão na boca",
|
||||
defend: "se defendendo", reach: "alcançando", sit: "sentado", kneel: "ajoelhado", lean_in: "inclinado",
|
||||
express: "trocar expressão", pose: "trocar pose", walk: "andar", run: "correr", enter: "entrar", exit: "sair", jump: "pular", nod: "acenar que sim",
|
||||
shake_head: "balançar que não", tremble: "tremer", bounce: "quicar", fall: "cair", stand_up: "levantar", turn: "virar", talk: "falar", look: "olhar",
|
||||
emote: "balão (!)",
|
||||
oval: "oval", wide: "largo", button: "botão", curve: "curvo (perfil)", towel: "toalha no ombro", whistle: "apito", tie: "gravata",
|
||||
vest: "colete refletivo", helmet: "capacete", watch: "relógio", badge: "crachá", apron: "avental", scarf: "lenço", headset: "fone", chain: "corrente",
|
||||
};
|
||||
const label = (v: string) => LABEL[v] ?? v;
|
||||
|
||||
@@ -56,6 +66,8 @@ export function CharacterStudio({ initial }: { initial: Character[] }) {
|
||||
const [draft, setDraft] = useState<Character | null>(initial[0] ?? null);
|
||||
const [expression, setExpression] = useState<Expression>("neutral");
|
||||
const [pose, setPose] = useState<Pose>("stand");
|
||||
// Movimento da prévia: a ação toca em repetição a cada 2,6 s (o mesmo motor do render).
|
||||
const [move, setMove] = useState<ActionKind | "">("");
|
||||
const [t, setT] = useState(0);
|
||||
const [busy, setBusy] = useState<string | null>(null);
|
||||
const [message, setMessage] = useState<{ ok: boolean; text: React.ReactNode } | null>(null);
|
||||
@@ -175,10 +187,16 @@ export function CharacterStudio({ initial }: { initial: Character[] }) {
|
||||
<div className="grid gap-5 xl:grid-cols-[minmax(0,18rem)_minmax(0,1fr)]">
|
||||
<div className="grid content-start gap-3">
|
||||
<div className="grid place-items-center rounded-lg border border-line-strong bg-[#2a2e45] p-4">
|
||||
<div className="h-80 w-36"><CharacterFigure look={look} expression={expression} pose={pose} item={pose === "hold" || pose === "point" ? "phone" : undefined} t={t} /></div>
|
||||
<MovePreview look={look} expression={expression} pose={pose} move={move} t={t} />
|
||||
</div>
|
||||
<Opt name="Expressão (prévia)" list={EXPRESSIONS} value={expression} onChange={setExpression} />
|
||||
<Opt name="Pose (prévia)" list={POSES} value={pose} onChange={setPose} />
|
||||
<Field label="Movimento (prévia)">
|
||||
<Select value={move} onChange={(e) => setMove(e.target.value as ActionKind | "")}>
|
||||
<option value="">parado (só respira e pisca)</option>
|
||||
{ACTIONS.filter((a) => !["express", "pose", "enter", "exit"].includes(a)).map((a) => <option key={a} value={a}>{label(a)}</option>)}
|
||||
</Select>
|
||||
</Field>
|
||||
</div>
|
||||
<div className="grid content-start gap-4">
|
||||
<div className="grid gap-3 sm:grid-cols-2">
|
||||
@@ -205,6 +223,37 @@ export function CharacterStudio({ initial }: { initial: Character[] }) {
|
||||
<Color name="Detalhe (faixa/gola)" value={look.top.accent ?? "#e8b13a"} onChange={(v) => setLook((l) => ({ ...l, top: { ...l.top, accent: v } }))} />
|
||||
<Opt name="Parte de baixo" list={BOTTOM_STYLES} value={look.bottom.style} onChange={(v) => setLook((l) => ({ ...l, bottom: { ...l.bottom, style: v } }))} />
|
||||
<Color name="Cor de baixo" value={look.bottom.color} onChange={(v) => setLook((l) => ({ ...l, bottom: { ...l.bottom, color: v } }))} />
|
||||
<Opt name="Cabeça" list={HEAD_SHAPES} value={look.head ?? "round"} onChange={(v) => setLook((l) => ({ ...l, head: v }))} />
|
||||
<Opt name="Nariz" list={NOSES} value={look.nose ?? "button"} onChange={(v) => setLook((l) => ({ ...l, nose: v }))} />
|
||||
<Field label={`Pálpebra (${(look.lids ?? 0).toFixed(2)})`} hint="Olhar caído/experiente">
|
||||
<input type="range" min={0} max={0.6} step={0.02} value={look.lids ?? 0} className="h-9 w-full accent-accent"
|
||||
onChange={(e) => setLook((l) => ({ ...l, lids: Number(e.target.value) }))} />
|
||||
</Field>
|
||||
<Field label={`Rugas (${(look.wrinkles ?? 0).toFixed(1)})`}>
|
||||
<input type="range" min={0} max={1} step={0.1} value={look.wrinkles ?? 0} className="h-9 w-full accent-accent"
|
||||
onChange={(e) => setLook((l) => ({ ...l, wrinkles: Number(e.target.value) }))} />
|
||||
</Field>
|
||||
<label className="flex items-center gap-2 self-end pb-2 text-[0.8125rem] text-fg-muted">
|
||||
<input type="checkbox" className="size-4 accent-accent" checked={!!look.belly} onChange={(e) => setLook((l) => ({ ...l, belly: e.target.checked }))} />
|
||||
Barriga
|
||||
</label>
|
||||
<Color name="Cor dos acessórios" value={look.accessoryColor ?? "#efe6d2"} onChange={(v) => setLook((l) => ({ ...l, accessoryColor: v }))} />
|
||||
</div>
|
||||
<div className="grid gap-1.5">
|
||||
<span className="text-[0.8125rem] font-medium text-fg-muted">Acessórios</span>
|
||||
<div className="flex flex-wrap gap-1.5">
|
||||
{ACCESSORIES.map((a) => {
|
||||
const on = look.accessories?.includes(a) ?? false;
|
||||
return (
|
||||
<button key={a} type="button" aria-pressed={on}
|
||||
onClick={() => setLook((l) => ({ ...l, accessories: on ? (l.accessories ?? []).filter((x) => x !== a) : [...(l.accessories ?? []), a] }))}
|
||||
className={cx("h-8 rounded-full border px-3 text-xs font-medium transition-colors",
|
||||
on ? "border-accent/60 bg-accent-soft text-accent" : "border-line-strong bg-raised text-fg-muted hover:text-fg")}>
|
||||
{label(a)}
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<Button onClick={() => void save()} disabled={busy !== null || !dirty}>{busy === "save" ? <><Spinner />Salvando…</> : "Salvar"}</Button>
|
||||
@@ -230,3 +279,20 @@ export function CharacterStudio({ initial }: { initial: Character[] }) {
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/** Prévia com movimento: aplica a ação escolhida em repetição, com posição, giro e espelho como no render. */
|
||||
function MovePreview({ look, expression, pose, move, t }: { look: CharacterLook; expression: Expression; pose: Pose; move: ActionKind | ""; t: number }) {
|
||||
const loop = 2.6;
|
||||
const lt = t % loop;
|
||||
const timeline = move
|
||||
? [move === "walk" || move === "run" ? { do: move, at: 0.3, to: 0.62 } : move === "talk" ? { do: move, at: 0.3, dur: 1.8, text: "olha só que coisa interessante aconteceu" } : move === "emote" ? { do: move, at: 0.3, text: "!" } : move === "look" ? { do: move, at: 0.3, dir: "left" as const } : { do: move, at: 0.3 }]
|
||||
: [];
|
||||
const st = evaluate({ x: 0.5, expression, pose, timeline: timeline as never }, move ? lt : t, loop, 1);
|
||||
return (
|
||||
<div className="relative h-80 w-full overflow-hidden">
|
||||
<div className="absolute bottom-0 h-full w-36" style={{ left: `calc(${(st.x + st.dx) * 100}% - 4.5rem)`, transform: `translateY(${st.dy * 100}%) rotate(${st.rot}deg) scale(${(st.flip ? -1 : 1) * st.sx}, ${st.sy})`, transformOrigin: "50% 100%" }}>
|
||||
<CharacterFigure look={look} item={pose === "hold" || pose === "point" ? "phone" : undefined} t={t} state={st} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -104,6 +104,12 @@ const PROFESSIONS: [RegExp, { top: CharacterLook["top"]; caption: string }][] =
|
||||
[/bombeir/, { top: { style: "uniform", color: "#c8352f", accent: "#f2c230" }, caption: "Bombeiro" }],
|
||||
[/militar|soldad/, { top: { style: "uniform", color: "#5b6b3a", accent: "#3a4a2a" }, caption: "Militar" }],
|
||||
[/professor/, { top: { style: "jacket", color: "#7a5232", accent: "#e9ecef" }, caption: "Professor" }],
|
||||
[/tecnico|treinador/, { top: { style: "jacket", color: "#1f3a7a", accent: "#f2c230" }, caption: "Técnico" }],
|
||||
[/porteiro|seguranca|vigia/, { top: { style: "jacket", color: "#2f4f86", accent: "#e9ecef" }, caption: "Porteiro" }],
|
||||
[/merendeir|cozinheir/, { top: { style: "shirt", color: "#c85a5a" }, caption: "Merendeira" }],
|
||||
[/roupeiro/, { top: { style: "jacket", color: "#56704a", accent: "#e9ecef" }, caption: "Roupeiro" }],
|
||||
[/obra|pedreiro|operario/, { top: { style: "shirt", color: "#56704a" }, caption: "Operário" }],
|
||||
[/empresari|executiv|advogad/, { top: { style: "jacket", color: "#3a3f4f", accent: "#e9ecef" }, caption: "Empresário" }],
|
||||
];
|
||||
|
||||
/** Aparência e legenda a partir de uma descrição curta ("Otávio, 58, engenheiro, barba grisalha, óculos"). */
|
||||
@@ -138,6 +144,26 @@ export function describeToLook(description: string): { look: CharacterLook; capt
|
||||
bottom: { style: /\b(short|bermuda)\b/.test(t) || child ? "shorts" : /\bsaia\b/.test(t) ? "skirt" : "pants", color: female && /saia/.test(t) ? top.color : "#2c3346" },
|
||||
shoes: child ? "#f2f2f2" : "#1d1d24",
|
||||
};
|
||||
// Detalhe de ilustração: nariz, pálpebra, rugas, formato da cabeça, barriga e acessórios pela descrição.
|
||||
look.nose = /narigud|nariz grande|nariz comprido/.test(t) ? "long" : /nariz largo|nariz de batata/.test(t) ? "wide" : old && !female ? "curve" : child ? "button" : female ? "button" : "round";
|
||||
look.lids = Math.min(0.6, (old ? 0.3 : 0.1) + (/cansad|sonolent|olhar caido|desconfiad/.test(t) ? 0.2 : 0));
|
||||
look.wrinkles = age >= 60 || /idos|velh/.test(t) ? 0.7 : age >= 45 ? 0.4 : old ? 0.6 : 0;
|
||||
look.head = /rosto quadrado|queixo quadrado/.test(t) ? "square" : /rosto fino|rosto comprido/.test(t) ? "oval" : look.build === "heavy" ? "wide" : "round";
|
||||
if (/barrig|panca/.test(t) || (look.build === "heavy" && age >= 40 && !female)) look.belly = true;
|
||||
const acc = new Set<NonNullable<CharacterLook["accessories"]>[number]>();
|
||||
if (/tecnico|treinador|juiz|arbitr|professor de educacao fisica/.test(t)) { acc.add("whistle"); acc.add("watch"); }
|
||||
if (/obra|pedreiro|operario|mestre de obra/.test(t)) { acc.add("helmet"); acc.add("vest"); look.accessoryColor = "#ff8a2a"; }
|
||||
if (/porteiro|seguranca|vigia|crach/.test(t)) acc.add("badge");
|
||||
if (/merendeir|cozinheir|padeir|avental/.test(t)) { acc.add("apron"); look.accessoryColor ??= "#f4f1e8"; }
|
||||
if (/roupeiro|massagista|toalha/.test(t)) acc.add("towel");
|
||||
if (/empresari|executiv|advogad|gerente|gravata/.test(t)) { acc.add("tie"); acc.add("watch"); }
|
||||
if (/cachecol|lenco/.test(t)) acc.add("scarf");
|
||||
if (/fone|locutor|radialista|atendente/.test(t)) acc.add("headset");
|
||||
if (/correntao|corrente de ouro|cordao/.test(t)) acc.add("chain");
|
||||
if (/capacete/.test(t)) acc.add("helmet");
|
||||
if (/colete/.test(t)) acc.add("vest");
|
||||
if (/relogio/.test(t)) acc.add("watch");
|
||||
if (acc.size) look.accessories = [...acc];
|
||||
const caption = [profession?.caption, age > 0 ? `${age} anos` : ""].filter(Boolean).join(" · ") || undefined;
|
||||
return { look, caption };
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { describe, it } from "node:test";
|
||||
import { describeToLook } from "./characters";
|
||||
import { cartoonKey, cartoonSpec, planCartoon, wordTimings } from "./montage-cartoon";
|
||||
import { cartoonKey, cartoonSpec, planCartoon, timelineFor, wordTimings } from "./montage-cartoon";
|
||||
|
||||
const shot = (narration: string, onScreen = "", index = 0) => ({ index, narration, onScreen, visualHint: "" });
|
||||
|
||||
@@ -52,7 +52,9 @@ describe("estilo Cartoon: plano por regras", () => {
|
||||
const actor = plan.actors?.find((a) => a.kind === "person");
|
||||
assert.ok(actor && actor.kind === "person" && actor.character);
|
||||
assert.equal(actor.character!.look.hair.style, "bald");
|
||||
assert.equal(actor.expression, "scared");
|
||||
// Começa neutro; o medo entra quando a voz diz "medo" (linha do tempo).
|
||||
assert.equal(actor.expression, "neutral");
|
||||
assert.deepEqual(actor.timeline?.find((x) => x.do === "express"), { do: "express", cue: "medo", expression: "scared" });
|
||||
assert.equal(plan.palette, "sepia");
|
||||
assert.equal(plan.light, "spot");
|
||||
});
|
||||
@@ -64,6 +66,15 @@ describe("estilo Cartoon: plano por regras", () => {
|
||||
assert.equal(describeToLook("menino de 9 anos, cabelo cacheado").look.height, 0.78);
|
||||
});
|
||||
|
||||
it("linha do tempo pelo texto: emoção e verbos na palavra; fala entre aspas na boca", () => {
|
||||
const tl = timelineFor("Ele ficou com medo, correu e caiu. Depois gritou: “Socorro, alguém me ajuda!”", 0.5);
|
||||
assert.deepEqual(tl.find((a) => a.do === "express"), { do: "express", cue: "medo", expression: "scared" });
|
||||
assert.equal(tl.find((a) => a.do === "run")?.cue, "correu");
|
||||
assert.equal(tl.find((a) => a.do === "fall")?.cue, "caiu");
|
||||
const talk = tl.find((a) => a.do === "talk");
|
||||
assert.deepEqual([talk?.cue, talk?.cueEnd], ["socorro", "ajuda"]);
|
||||
});
|
||||
|
||||
it("a chave muda com a cena, a duração e o áudio", () => {
|
||||
const plan = planCartoon(shot("A rua está escura."));
|
||||
const k = cartoonKey(plan, 3.2, "abc");
|
||||
|
||||
@@ -8,8 +8,9 @@ import { spawn } from "node:child_process";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import type { CharacterLook, Expression, Pose } from "cenaforge-cartoon/character";
|
||||
import type { Action } from "cenaforge-cartoon/motion";
|
||||
import type { IconId, ShotSpec, Word } from "cenaforge-cartoon/spec";
|
||||
import type { JobHook } from "./montage-ffmpeg";
|
||||
import { ffmpegBin, type JobHook } from "./montage-ffmpeg";
|
||||
import { transcribe } from "./voice";
|
||||
|
||||
export type CartoonIcon = IconId;
|
||||
@@ -93,6 +94,75 @@ function expressionOf(text: string): Expression {
|
||||
return "neutral";
|
||||
}
|
||||
|
||||
/** 1ª palavra do trecho que casa com a regra (é o "cue": a ação começa quando a voz diz essa palavra). */
|
||||
function cueOf(text: string, re: RegExp): string | null {
|
||||
const m = re.exec(text);
|
||||
if (!m) return null;
|
||||
return m[0].trim().split(/\s+/)[0].replace(/[^a-z0-9]/g, "").slice(0, 12) || null;
|
||||
}
|
||||
|
||||
/** Verbos e emoções do texto → linha do tempo do personagem (cada ação começa na palavra que a provocou). */
|
||||
const MOVES: { re: RegExp; act: (cue: string, x: number) => Action[] }[] = [
|
||||
{ re: /\b(andou|caminhou|foi ate|se aproximou|chegou perto)\b/, act: (cue, x) => [{ do: "walk", cue, to: x < 0.5 ? x + 0.2 : x - 0.2 }] },
|
||||
{ re: /\b(correu|fugiu|disparou|saiu correndo)\b/, act: (cue, x) => [{ do: "run", cue, to: x < 0.5 ? x + 0.3 : x - 0.3 }] },
|
||||
{ re: /\b(pulou|saltou)\b/, act: (cue) => [{ do: "jump", cue }] },
|
||||
{ re: /\b(caiu|desmaiou|tropecou|despencou)\b/, act: (cue) => [{ do: "fall", cue }] },
|
||||
{ re: /\b(sentou|se sentou)\b/, act: (cue) => [{ do: "sit", cue }] },
|
||||
{ re: /\b(levantou|se levantou|ficou de pe)\b/, act: (cue) => [{ do: "stand_up", cue }] },
|
||||
{ re: /\b(balancou a cabeca|negou|disse que nao)\b/, act: (cue) => [{ do: "shake_head", cue }] },
|
||||
{ re: /\b(concordou|assentiu|acenou com a cabeca)\b/, act: (cue) => [{ do: "nod", cue }] },
|
||||
{ re: /\b(tremia|tremeu|tremendo|arrepiou|arrepio)\b/, act: (cue) => [{ do: "tremble", cue, dur: 1.4 }] },
|
||||
{ re: /\b(riu|gargalhou|caiu na risada|rindo)\b/, act: (cue) => [{ do: "express", cue, expression: "laugh" }, { do: "bounce", cue, times: 3 }] },
|
||||
{ re: /\b(chorou|chorando|lagrimas)\b/, act: (cue) => [{ do: "express", cue, expression: "cry" }] },
|
||||
{ re: /\b(olhou para os lados|olhou em volta|procurou)\b/, act: (cue) => [{ do: "look", cue, dir: "left" }, { do: "shake_head", cue, times: 1, dur: 1.2 }] },
|
||||
{ re: /\b(olhou para cima|olhou pro ceu)\b/, act: (cue) => [{ do: "look", cue, dir: "up" }] },
|
||||
{ re: /\b(virou|deu as costas)\b/, act: (cue) => [{ do: "turn", cue }] },
|
||||
{ re: /\b(pensou|lembrou|imaginou|calculou|planejou)\b/, act: (cue) => [{ do: "pose", cue, pose: "think" }] },
|
||||
{ re: /\b(acenou|tchau|chamou)\b/, act: (cue) => [{ do: "wave", cue }] },
|
||||
{ re: /\b(apontou|mostrou)\b/, act: (cue) => [{ do: "pose", cue, pose: "point" }] },
|
||||
{ re: /\b(cruzou os bracos)\b/, act: (cue) => [{ do: "pose", cue, pose: "cross_arms" }] },
|
||||
{ re: /\b(desesper|mao na cabeca|nao acreditou)\w*/, act: (cue) => [{ do: "pose", cue, pose: "facepalm" }] },
|
||||
{ re: /\b(comemorou|vibrou|venceu|conseguiu)\b/, act: (cue) => [{ do: "pose", cue, pose: "celebrate" }, { do: "bounce", cue, times: 2 }] },
|
||||
{ re: /\b(de repente|susto|assustou)\b/, act: (cue) => [{ do: "emote", cue, text: "!" }] },
|
||||
{ re: /\b(por que|sera que|duvida|estranh)\w*/, act: (cue) => [{ do: "emote", cue, text: "?" }] },
|
||||
];
|
||||
const EMOTIONS: { re: RegExp; expression: Expression }[] = [
|
||||
{ re: /\b(medo|apavorad|assust|pavor|terror|socorro)\w*/, expression: "scared" },
|
||||
{ re: /\b(furios|grit)\w*/, expression: "furious" },
|
||||
{ re: /\b(raiva|bravo|brava|irritad)\w*/, expression: "angry" },
|
||||
{ re: /\b(de repente|surpres|choc|inacredit)\w*/, expression: "surprised" },
|
||||
{ re: /\b(trist|perdeu|saudade|sozinh)\w*/, expression: "sad" },
|
||||
{ re: /\b(preocup|problema|nervos|ansios)\w*/, expression: "worried" },
|
||||
{ re: /\b(desconfi|suspeit)\w*/, expression: "suspicious" },
|
||||
{ re: /\b(feliz|alegr|sorri)\w*/, expression: "happy" },
|
||||
];
|
||||
|
||||
/** Fala entre aspas ou depois de travessão: [1ª palavra, última palavra, texto] (normalizados). */
|
||||
function quoteOf(original: string): { first: string; last: string; text: string } | null {
|
||||
const m = /[“"«]([^”"»]{3,})[”"»]|(?:^|\s)[—–-]\s*([^—–\n]{3,})/.exec(original);
|
||||
const said = (m?.[1] ?? m?.[2] ?? "").trim();
|
||||
if (!said) return null;
|
||||
const ws = norm(said).split(/[^a-z0-9]+/).filter(Boolean);
|
||||
return ws.length ? { first: ws[0], last: ws[ws.length - 1], text: said } : null;
|
||||
}
|
||||
|
||||
/** Linha do tempo do personagem principal do trecho: emoção na palavra, verbos viram movimento, fala na boca. */
|
||||
export function timelineFor(original: string, x: number): Action[] {
|
||||
const text = norm(original);
|
||||
const out: Action[] = [];
|
||||
for (const e of EMOTIONS) {
|
||||
const cue = cueOf(text, e.re);
|
||||
if (cue) { out.push({ do: "express", cue, expression: e.expression }); break; }
|
||||
}
|
||||
for (const m of MOVES) {
|
||||
const cue = cueOf(text, m.re);
|
||||
if (cue) out.push(...m.act(cue, x));
|
||||
}
|
||||
const quote = quoteOf(original);
|
||||
if (quote) out.push({ do: "talk", cue: quote.first, cueEnd: quote.last, text: quote.text });
|
||||
return out.slice(0, 12);
|
||||
}
|
||||
|
||||
function poseOf(text: string, hasProp: boolean): Pose {
|
||||
if (/acen|tchau|chamou/.test(text)) return "wave";
|
||||
if (/comemor|venceu|gritou de alegria/.test(text)) return "arms_up";
|
||||
@@ -137,7 +207,14 @@ export function planCartoon(shot: ShotText, ctx: PlanContext = {}, variant = 0):
|
||||
actors.push({
|
||||
kind: "person", x: castIn.length > 1 ? (i === 0 ? 0.3 : 0.7) : props.length ? 0.34 : 0.5, y: 0.74, enterS: 0.15 + i * 0.3,
|
||||
character: { name: c.name, caption: i === 0 && shot.index === 0 ? c.caption : undefined, look: c.look },
|
||||
expression: expressionOf(text), pose: i === 0 ? poseOf(text, props.length > 0) : "stand",
|
||||
// Começa neutro e a emoção/movimento entram na palavra (linha do tempo); sem gatilho no texto, fica a
|
||||
// expressão geral do trecho desde o início.
|
||||
expression: timelineFor(original, 0.5).some((a) => a.do === "express") ? "neutral" : expressionOf(text),
|
||||
pose: i === 0 ? poseOf(text, props.length > 0) : "stand",
|
||||
...(i === 0 ? { timeline: timelineFor(original, castIn.length > 1 ? 0.3 : props.length ? 0.34 : 0.5) } : {}),
|
||||
// Enquadramento: de perto quando fala; meio corpo sozinho em cena; corpo inteiro com mais gente/objetos.
|
||||
framing: i === 0 && timelineFor(original, 0.5).some((a) => a.do === "talk") && castIn.length === 1 ? "close"
|
||||
: castIn.length === 1 && !crowd && props.length === 0 ? "medium" : "full",
|
||||
item: i === 0 && props.length === 1 && ["phone", "fuel", "battery", "money", "bulb"].includes(props[0].icon) ? props[0].icon : undefined,
|
||||
flip: i === 1,
|
||||
});
|
||||
@@ -239,8 +316,39 @@ export async function wordTimings(input: { repoRoot: string; audio: string; spok
|
||||
}
|
||||
|
||||
/** Monta o spec completo de um trecho (o que o render recebe). */
|
||||
export function cartoonSpec(scene: CartoonScene, durationS: number, words: CartoonWord[]): CartoonSpec {
|
||||
return { schemaVersion: 1, width: 1080, height: 1920, fps: 30, durationS: Math.round(durationS * 1000) / 1000, ...scene, words };
|
||||
export function cartoonSpec(scene: CartoonScene, durationS: number, words: CartoonWord[], audioEnv?: ShotSpec["audioEnv"]): CartoonSpec {
|
||||
return { schemaVersion: 1, width: 1080, height: 1920, fps: 30, durationS: Math.round(durationS * 1000) / 1000, ...scene, words, ...(audioEnv ? { audioEnv } : {}) };
|
||||
}
|
||||
|
||||
/**
|
||||
* Volume do áudio quadro a quadro (0–1, normalizado pelo percentil 95): a boca fecha nas pausas e abre nas
|
||||
* sílabas fortes. Lê o áudio em mono 8 kHz pelo FFmpeg. Sem FFmpeg ou com erro, devolve undefined (a boca
|
||||
* segue só pelas palavras).
|
||||
*/
|
||||
export async function audioEnvelope(file: string, fps = 30): Promise<ShotSpec["audioEnv"]> {
|
||||
try {
|
||||
const pcm = await new Promise<Buffer>((resolve, reject) => {
|
||||
const child = spawn(ffmpegBin("ffmpeg"), ["-v", "error", "-i", file, "-ac", "1", "-ar", "8000", "-f", "s16le", "-"], { windowsHide: true });
|
||||
const chunks: Buffer[] = [];
|
||||
child.stdout.on("data", (d: Buffer) => chunks.push(d));
|
||||
child.on("error", reject);
|
||||
child.on("close", (code) => (code === 0 ? resolve(Buffer.concat(chunks)) : reject(new Error(`ffmpeg ${code}`))));
|
||||
});
|
||||
const samples = new Int16Array(pcm.buffer, pcm.byteOffset, Math.floor(pcm.length / 2));
|
||||
const per = Math.round(8000 / fps);
|
||||
const rms: number[] = [];
|
||||
for (let i = 0; i < samples.length; i += per) {
|
||||
let sum = 0;
|
||||
const end = Math.min(samples.length, i + per);
|
||||
for (let j = i; j < end; j++) sum += (samples[j] / 32768) ** 2;
|
||||
rms.push(Math.sqrt(sum / Math.max(1, end - i)));
|
||||
}
|
||||
const sorted = [...rms].sort((a, b) => a - b);
|
||||
const ref = sorted[Math.floor(sorted.length * 0.95)] || 1;
|
||||
return { fps, values: rms.map((v) => Math.round(Math.min(1, v / ref) * 100) / 100) };
|
||||
} catch {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,7 +16,7 @@ import { LAST_PAD_S, PAD_S, buildCredits, buildSegment, concatSegments, ffmpegBi
|
||||
import { downloadImage, searchFirst } from "./image-search";
|
||||
import { DOC2D_TEMPLATES, planScene, planShot, planShot3d, renderGodotScene, sceneKey, scriptEntities, type Doc2DScene } from "./montage-godot";
|
||||
import { getCast } from "./characters";
|
||||
import { cartoonKey, cartoonSpec, planCartoon, renderCartoonShots, wordTimings, type CartoonScene, type PlanContext } from "./montage-cartoon";
|
||||
import { audioEnvelope, cartoonKey, cartoonSpec, planCartoon, renderCartoonShots, wordTimings, type CartoonScene, type PlanContext } from "./montage-cartoon";
|
||||
import { listLibrary, paramsFor } from "./scene-library";
|
||||
import { killTree } from "./proc";
|
||||
import { parseScript } from "./script-doc";
|
||||
@@ -289,7 +289,9 @@ async function renderCartoonInternal(ep: EpisodeView, montage: Montage, shots: M
|
||||
const words = montage.captions
|
||||
? await wordTimings({ repoRoot: REPO_ROOT, audio: shot.audio.file, spoken: shot.spoken, durationS: duration, scene, log })
|
||||
: [];
|
||||
jobs.push({ shot, scene, duration, spec: cartoonSpec(scene, duration, words) });
|
||||
// Volume do áudio quadro a quadro: a boca de quem fala fecha nas pausas e abre nas sílabas fortes.
|
||||
const env = await audioEnvelope(path.join(REPO_ROOT, shot.audio.file));
|
||||
jobs.push({ shot, scene, duration, spec: cartoonSpec(scene, duration, words, env) });
|
||||
}
|
||||
const files = await renderCartoonShots({
|
||||
repoRoot: REPO_ROOT, specDir: path.join(storyDir(ep.story_id), "cartoon"), outDir: path.join(OUTPUT_DIR, "cartoon", `${ep.story_id}-${ep.file_key}`),
|
||||
|
||||
@@ -52,7 +52,7 @@ export function buildPrompt(input: { kind: AgentKind; provider: Provider; reques
|
||||
branches: "Leia SÓ: `doc/roteiro/comum.md`, `doc/roteiro/ficcao.md` e a pasta da história; para a cena, use o script `new_scene.py` indicado abaixo. Não carregue a skill inteira.",
|
||||
godot: "Leia SÓ: `doc/godot/cenas.md` e `doc/godot/api.md` (assinaturas das peças e cenas; NÃO leia os .gd inteiros de outras cenas). Não carregue a skill `cenaforge`.",
|
||||
scene: "Siga a skill `cenaforge` (.claude/skills/cenaforge/SKILL.md): leia só as seções que a tarefa pedir.",
|
||||
character: "Leia SÓ: `doc/cartoon/personagens.md`. Não carregue a skill `cenaforge`.",
|
||||
character: "Leia SÓ: `doc/cartoon/personagens.md` (e `doc/cartoon/animacao.md` se o pedido falar de expressão ou movimento). Não carregue a skill `cenaforge`.",
|
||||
free: "Siga o CLAUDE.md; consulte a skill `cenaforge` (.claude/skills/cenaforge/SKILL.md) só no que a tarefa pedir.",
|
||||
};
|
||||
const lines: (string | null)[] = [
|
||||
|
||||
@@ -11,23 +11,41 @@
|
||||
"key": "1nav1j0"
|
||||
},
|
||||
"visual": {
|
||||
"kind": "godot3d",
|
||||
"file": "output/runs/20261117-153148-naufragos-na-ilha-das-cobras-ep01-t01-final/naufragos-na-ilha-das-cobras-ep01-t01-final.mp4",
|
||||
"kind": "cartoon",
|
||||
"file": null,
|
||||
"credit": "",
|
||||
"license": "",
|
||||
"sourceUrl": "",
|
||||
"scene": {
|
||||
"kind": "doc3d",
|
||||
"template": "castaways",
|
||||
"params": {
|
||||
"moment": "waiting",
|
||||
"camera": "close",
|
||||
"variant": 0
|
||||
}
|
||||
},
|
||||
"auto": false,
|
||||
"inset": null,
|
||||
"sceneKey": "99c75s"
|
||||
"cartoon": {
|
||||
"seed": 1,
|
||||
"scene": {
|
||||
"kind": "street",
|
||||
"time": "dawn",
|
||||
"litHouse": false
|
||||
},
|
||||
"camera": {
|
||||
"push": 1.05,
|
||||
"panX": -0.05
|
||||
},
|
||||
"hud": {
|
||||
"badge": "Três dias",
|
||||
"label": "Ep. 1"
|
||||
},
|
||||
"actors": [],
|
||||
"props": [],
|
||||
"texts": [
|
||||
{
|
||||
"kind": "tag",
|
||||
"text": "3 dias na Ilha das Cobras",
|
||||
"x": 0.5,
|
||||
"y": 0.17,
|
||||
"atS": 0.1,
|
||||
"tone": "info"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"1": {
|
||||
|
||||
Reference in New Issue
Block a user