// RedeDeBlocos: blocos 3D ligados por trilhos no chão; pacotes de luz (bolinhas) correm pelos trilhos de um bloco ao outro. // Os blocos sobem do chão em sequência; a mesa gira devagar. Mostra "sistemas que conversam". import React from 'react'; import {useCurrentFrame} from 'remotion'; import {COR, c01, e5, eb, seg} from '../base'; import {Cubo, CuboSVG, SombraSVG, profundidade, proj, tom} from '../formas/iso'; export type RedeDeBlocosProps = { /** nós da rede (o primeiro pode ser a plataforma, sem ligação) */ blocos: Cubo[]; /** pares de índices ligados por trilho em L */ ligacoes: [number, number][]; inicio?: number; y?: number; escala?: number; giro?: number; angulo?: number; }; export const RedeDeBlocos: React.FC = ({blocos, ligacoes, inicio = 0, y = 800, escala = 100, giro = 0.45, angulo = 40}) => { const f = useCurrentFrame(); const ang = ((angulo + (f - inicio) * giro) * Math.PI) / 180; const ordem = blocos.map((b, i) => ({b, i})).sort((a, c) => profundidade(a.b, ang) - profundidade(c.b, ang)); const sobe = (i: number) => {const t0 = inicio + 2 + i * 4; return {p: eb(seg(f, t0, t0 + 16)), v: c01((f - t0) / 3)};}; const caminho = (a: Cubo, b: Cubo) => [[a.x, a.y], [b.x, a.y], [b.x, b.y]]; const ponto = (c: number[][], t: number) => { const l1 = Math.abs(c[1][0] - c[0][0]) + Math.abs(c[1][1] - c[0][1]), l2 = Math.abs(c[2][0] - c[1][0]) + Math.abs(c[2][1] - c[1][1]), L = l1 + l2 || 1, d = t * L; const [a, b, k] = d < l1 ? [c[0], c[1], d / (l1 || 1)] : [c[1], c[2], (d - l1) / (l2 || 1)]; return [a[0] + (b[0] - a[0]) * k, a[1] + (b[1] - a[1]) * k]; }; const pol = (c: number[][], z: number) => c.map((p) => {const q = proj(p[0], p[1], z, ang, escala); return `${q.x.toFixed(1)},${q.y.toFixed(1)}`;}).join(' '); const cheg = e5(seg(f, inicio + 14, inicio + 34)); return {ligacoes.map(([a, b], k) => {const c = caminho(blocos[a], blocos[b]); return ;})} {ligacoes.map(([a, b], k) => { const c = caminho(blocos[a], blocos[b]); return [0, 1, 2].map((n) => {const t = (((f - inicio) * 0.022 + n / 3 + k * 0.17) % 1 + 1) % 1, p = ponto(c, t), q = proj(p[0], p[1], 0.18, ang, escala); return ;}); })} {ordem.map(({b, i}) => {const e = sobe(i); return e.v > 0 ? : null;})} {ordem.map(({b, i}) => {const e = sobe(i); return e.v > 0 ? : null;})} ; };