Skip to content

Laboratorio de Wireshark sin conexión: capturas sintéticas de un pentest, filtros validados al instante, retos guiados y un megalodón 3D en WebGL2.

Facciones del megalodón realistas y cabeza libre del título (1.3.1)

Yoandy Ramírez Delgado68afa04b7fbc
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c179b52..08c2388 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,25 @@
Formato [Keep a Changelog](https://keepachangelog.com/es-ES/1.1.0/) y versionado semántico.
+## [1.3.1] - 2026-11-25
+
+### Cambiado
+- **Facciones del megalodón más realistas**, revisadas con un banco de vistas (perfil, frente, tres cuartos y la pose de la portada):
+ - dientes superiores que cuelgan e inferiores que se alzan y se cruzan en la línea de la boca, en lugar de apuntar hacia delante como un peine;
+ - encía inferior dentro del labio (antes asomaba por fuera como una franja rosa) y fila de reemplazo hundida en la encía;
+ - pliegue de piel en la comisura que se estira al abrir, en vez de dejar ver una cuña negra;
+ - ojo negro azulado con pupila, casi enrasado y con la órbita hundida, sin el aro turquesa;
+ - hocico corto y cónico con la punta redondeada, narinas en la cara inferior y poros de Lorenzini finos;
+ - interior de la boca con carne rosada que se oscurece hacia dentro, suelo cóncavo con el basihial y faringe oscura con arcos branquiales;
+ - mentón y mandíbula inferior más robustos.
+- **Encuadre de la portada**: desde la 1.3.0 la portada es más estrecha y la cabeza quedaba bajo el título. Ahora la cabeza y la boca quedan a su derecha a 1280, 1440 y 1920 px.
+
+### Corregido
+- En inglés, la vista «Plano técnico» fallaba al rotular «Hocico» y «Ojo», que no tenían traducción.
+
+### Añadido
+- Cota «Narina» en el plano técnico y pruebas e2e del plano técnico en inglés y del encuadre de la cabeza.
+
## [1.3.0] - 2026-11-25
### Añadido
diff --git a/README.md b/README.md
index 4f65390..c62f2e8 100644
--- a/README.md
+++ b/README.md
@@ -11,7 +11,7 @@
<p align="center">
<a href="LICENSE"><img alt="Licencia MIT" src="https://img.shields.io/badge/LICENCIA-MIT-4169A1?style=flat"/></a>
- <img alt="Versión 1.3.0" src="https://img.shields.io/badge/versi%C3%B3n-1.3.0-3B8BFF?style=flat"/>
+ <img alt="Versión 1.3.1" src="https://img.shields.io/badge/versi%C3%B3n-1.3.1-3B8BFF?style=flat"/>
<img alt="Filtros de Wireshark 4.x" src="https://img.shields.io/badge/filtros-Wireshark%204.x-1679A7?style=flat"/>
<img alt="Ruta eWPT" src="https://img.shields.io/badge/ruta-eWPT-E07B39?style=flat"/>
<img alt="8 módulos y 58 retos" src="https://img.shields.io/badge/8%20m%C3%B3dulos-58%20retos-7B4FD1?style=flat"/>
@@ -85,7 +85,7 @@ Son **32 lecciones y 58 retos** que se comprueban contra los paquetes al instant
<img src="docs/assets/stack/pruebas.svg" height="48" alt="node:test">
<img src="docs/assets/stack/navegador.svg" height="48" alt="Playwright">
<img src="docs/assets/stack/accesibilidad.svg" height="48" alt="axe-core"><br>
- <sub><code>node:test 18 · Playwright 22 · axe-core 0 violaciones</code></sub>
+ <sub><code>node:test 18 · Playwright 24 · axe-core 0 violaciones</code></sub>
</td>
<td valign="top"><code>╰─ ⌁ seguridad:</code><br><br>
<img src="docs/assets/stack/csp.svg" height="48" alt="CSP">
@@ -96,7 +96,7 @@ Son **32 lecciones y 58 retos** que se comprueban contra los paquetes al instant
</tbody>
<tfoot>
<tr>
- <td colspan="2"><code>version: 1.3.0&nbsp;&nbsp;·&nbsp;&nbsp;filtros: Wireshark 4.x&nbsp;&nbsp;·&nbsp;&nbsp;pruebas: 40 ok&nbsp;&nbsp;·&nbsp;&nbsp;licencia: MIT</code></td>
+ <td colspan="2"><code>version: 1.3.1&nbsp;&nbsp;·&nbsp;&nbsp;filtros: Wireshark 4.x&nbsp;&nbsp;·&nbsp;&nbsp;pruebas: 42 ok&nbsp;&nbsp;·&nbsp;&nbsp;licencia: MIT</code></td>
</tr>
</tfoot>
</table>
@@ -107,6 +107,13 @@ Son **32 lecciones y 58 retos** que se comprueban contra los paquetes al instant
## <img src="docs/assets/icons/sparkles.svg" width="20" height="20" valign="middle"/> Novedades
+### 1.3.1 · noviembre de 2026 · La cara del megalodón
+
+- **Boca de verdad.** Los dientes de arriba cuelgan y los de abajo se alzan y se cruzan en la línea de la boca; la encía queda dentro del labio y la fila de reemplazo, hundida. En la comisura, un pliegue de piel se estira al abrir.
+- **Ojo, hocico y narinas.** Ojo negro azulado, casi enrasado, con la órbita hundida; hocico corto y cónico de punta redondeada, como lo describe la guía de identificación de CITES; narinas en la cara inferior del hocico.
+- **Interior.** Carne rosada que se oscurece hacia la faringe, suelo cóncavo con el basihial y arcos branquiales al fondo.
+- **Encuadre.** Con la barra lateral, la cabeza había quedado detrás del título; ahora está a su derecha, despejada.
+
### 1.3.0 · noviembre de 2026 · Armazón nuevo y todo en inglés
- **Barra lateral a la izquierda**, como en BlueJr y RiskManager-Jr. Muestra los ocho módulos con su progreso: un punto gris si no lo has empezado, ámbar si está a medias y verde si está terminado, y los retos resueltos. Abajo van el nivel y la XP, y un indicador se desliza hasta la sección activa.
@@ -295,7 +302,8 @@ La portada es un megalodón en tiempo real hecho con **WebGL2 puro**, sin librer
</tr>
</table>
-- **Boca documentada:** 13 dientes superiores anchos y 12 inferiores estrechos por lado, el intermedio superior más pequeño, inclinación distal creciente y una fila de reemplazo detrás.
+- **Boca documentada:** 13 dientes superiores anchos y 12 inferiores estrechos por lado, el intermedio superior más pequeño, inclinación distal creciente y una fila de reemplazo hundida en la encía. Los superiores cuelgan y los inferiores se alzan, y se cruzan en la línea de la boca.
+- **Cara:** ojo negro azulado casi enrasado, hocico corto y cónico de punta redondeada, narinas en la cara inferior del hocico, poros de Lorenzini y pliegue de piel en la comisura.
- **Mordisco:** elevación del hocico, descenso de la mandíbula, protrusión del palatocuadrado y sacudida lateral, con los tiempos de Tricas (1985).
- **Piel y agua:** contrasombreado, dentículos, branquias, ampollas de Lorenzini, cáusticas, rayos de luz, nieve marina y bloom.
@@ -384,7 +392,7 @@ flowchart LR
|---|---|---|
| Motor (`engine.test.mjs`) | 13 | Las 8 capturas se generan, se disecan y son deterministas. Exportar a pcap/pcapng y releer conserva cada byte. **Los 58 retos tienen solución comprobable** contra su captura, y las respuestas derivadas (avisos, intervalo del beacon, Base64 exfiltrado, firma ZIP) se recalculan desde los paquetes. Los 60 «Pruébalo» compilan y muestran paquetes. También comprueba la sintaxis de filtros de Wireshark 4.x, la información experta, los objetos HTTP, las credenciales, el flujo UDP y el checksum RFC 1071. |
| Idioma (`i18n.test.mjs`) | 5 | Español e inglés tienen las mismas claves. Los ocho módulos tienen título, subtítulo e insignia en inglés. **Cada error del motor de filtros** y **cada etiqueta del árbol de detalle de los 578 paquetes** están traducidos, sin restos en español. |
-| E2E (`e2e.mjs`) | 22 | **El curso completo se resuelve desde la interfaz** (58 retos y 8 insignias). También cubre: <ul><li>herramientas de analista, buscar e ir al paquete, formato de tiempo y flujo UDP;</li><li>búsqueda `Ctrl K`;</li><li>megalodón 3D: pausa, plano técnico, desmontaje, movimiento reducido y sin WebGL2;</li><li>barra lateral plegable (`[`, ratón y estado guardado);</li><li>interruptores de idioma y de tema;</li><li>móvil con la hoja «Más»;</li><li>CSP estricta y red bloqueada.</li></ul> |
+| E2E (`e2e.mjs`) | 24 | **El curso completo se resuelve desde la interfaz** (58 retos y 8 insignias). También cubre: <ul><li>herramientas de analista, buscar e ir al paquete, formato de tiempo y flujo UDP;</li><li>búsqueda `Ctrl K`;</li><li>megalodón 3D: pausa, plano técnico en español e inglés, cabeza a la derecha del título a 1280, 1440 y 1920 px, desmontaje, movimiento reducido y sin WebGL2;</li><li>barra lateral plegable (`[`, ratón y estado guardado);</li><li>interruptores de idioma y de tema;</li><li>móvil con la hoja «Más»;</li><li>CSP estricta y red bloqueada.</li></ul> |
| Accesibilidad (dentro de `e2e.mjs`) | — | axe-core (WCAG 2.2 A/AA) da **cero violaciones** en: <ul><li>6 vistas, a 1280 y 390 px, en claro y oscuro;</li><li>los diálogos de análisis;</li><li>la barra lateral plegada;</li><li>la interfaz en inglés;</li><li>la hoja «Más».</li></ul> |
La [integración continua](.github/workflows/tests.yml) ejecuta todo en cada *push* y *pull request* y comprueba que los HTML están al día.
@@ -397,6 +405,7 @@ Detalle en [ROADMAP.md](ROADMAP.md).
- [x] 1.1.0 · Megalodón 3D, pruebas, CI y GitHub Pages
- [x] 1.2.0 · Herramientas de analista y recorrido del curso completo
- [x] 1.3.0 · Barra lateral plegable, barra de pestañas en el móvil, interruptores e interfaz en inglés
+- [x] 1.3.1 · Facciones del megalodón: boca, dientes, ojo, hocico, narinas e interior
- [ ] 1.3.x · Lecciones, retos, glosario y campos en inglés, revisados a mano
- [ ] 1.4.0 · Más capturas: SMB y movimiento lateral, VoIP/SIP y DHCP spoofing
diff --git a/ROADMAP.md b/ROADMAP.md
index 1b94928..980c74f 100644
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@ -16,6 +16,11 @@
- [x] Toda la interfaz en inglés, con prueba de paridad de claves y traducción de cada error del filtro
- [x] e2e del lateral, idioma, tema y móvil, y axe en el lateral plegado, el inglés y la hoja «Más»
+## 1.3.1 · Facciones del megalodón ✅
+- [x] Boca, dientes, encías y comisura revisados con un banco de vistas
+- [x] Ojo, hocico, narinas e interior de la boca
+- [x] Encuadre de la portada con la barra lateral y pruebas e2e del plano técnico en inglés
+
## 1.3.x · Contenido en inglés
- [ ] Lecciones, enunciados, pistas, glosario y descripciones de campos en inglés (revisados a mano, no traducción automática)
diff --git a/dist/index.html b/dist/index.html
index 4ff8a83..94bb584 100644
--- a/dist/index.html
+++ b/dist/index.html
@@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
-<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'sha256-y/5U0uCLqnyYytoYMQTZnUNyh772yvAzk5feC5A9+xI='; style-src 'sha256-C96SuEnKUh+J8kkbNV7gTpU17KM0Edca82DmDD9F5Sw='; img-src data: blob:; connect-src 'none'; font-src 'none'; object-src 'none'; frame-src 'none'; base-uri 'none'; form-action 'none'">
+<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'sha256-F6LBR26RgvlOg9FJEtq2yWimgk9Gfkv9nBrSjUBJFIo='; style-src 'sha256-C96SuEnKUh+J8kkbNV7gTpU17KM0Edca82DmDD9F5Sw='; img-src data: blob:; connect-src 'none'; font-src 'none'; object-src 'none'; frame-src 'none'; base-uri 'none'; form-action 'none'">
<meta name="referrer" content="no-referrer">
<meta name="color-scheme" content="dark light">
<meta name="description" content="Megalodon: laboratorio de Wireshark sin conexión. Capturas de un pentest, filtros con validación al instante y retos guiados del saludo TCP a los ataques web.">
@@ -3620,9 +3620,9 @@ function curve(us, vs) { // Hermite con tangen
}
// Perfil lamniforme: hocico cónico, tronco fusiforme alto, pedúnculo estrecho con quilla lateral.
const U = [0, .008, .025, .05, .09, .14, .2, .28, .36, .46, .58, .7, .8, .87, .925];
-const HT = curve(U, [0, .011, .025, .04, .056, .072, .086, .098, .103, .098, .078, .05, .028, .016, .011]);
-const HB = curve(U, [0, .008, .02, .033, .049, .067, .083, .096, .099, .092, .07, .043, .024, .013, .009]);
-const WD = curve(U, [0, .011, .026, .041, .057, .072, .084, .093, .095, .088, .068, .044, .026, .016, .011]);
+const HT = curve(U, [0, .0155, .03, .0445, .0585, .072, .086, .098, .103, .098, .078, .05, .028, .016, .011]);
+const HB = curve(U, [0, .0125, .026, .0405, .0555, .0715, .083, .096, .099, .092, .07, .043, .024, .013, .009]);
+const WD = curve(U, [0, .015, .0305, .0445, .0585, .072, .084, .093, .095, .088, .068, .044, .026, .016, .011]);
const ZC = u => .009 * Math.pow(Math.max(0, 1 - u / .22), 2) - .005 * Math.exp(-(((u - .42) / .22) ** 2));
const KEEL = u => .0042 * sstep(.8, .865, u);
const sgnpow = (v, e) => Math.sign(v) * Math.pow(Math.abs(v), e);
@@ -3768,19 +3768,22 @@ const protW = t => 1 - Math.pow(Math.abs(t), 1.6) * .85; // el frente del pala
// Marco local del arco: T a lo largo del labio, In hacia dentro de la cabeza (contra la normal de la piel),
// Dup sobre la piel, perpendicular al labio y hacia la mandíbula superior.
function archFrame(t) {
+ // Las mandíbulas se cierran en vertical: los dientes de arriba cuelgan y los de abajo se alzan, y se cruzan en
+ // la línea de la boca. Por eso el marco usa la vertical de la cabeza (Up) y la horizontal hacia dentro (In),
+ // no la normal de la piel: bajo el hocico la piel es horizontal y los dientes saldrían hacia delante.
t = clamp(t, -1, 1);
- const P = archLip(t), e = .004, u = archU(t), sd = t < 0 ? -1 : 1;
+ const P = archLip(t), e = .004, u = archU(t);
const T = norm(sub(archLip(Math.min(1, t + e)), archLip(Math.max(-1, t - e))));
- const n = u <= UF + 1e-6 ? [0, -1, 0] : bodyNormal(u, sd * phiM(u));
- let In = mul(n, -1); In = norm(sub(In, mul(T, dot(In, T))));
- let Dup = norm(cross(T, In));
- // hacia la mandíbula superior: un poco más adelante y por encima de la línea de la boca
- const toUp = sub(bodyPt(Math.max(0, u - .008), sd * Math.max(0, phiM(u) - .12)), P);
- if (dot(Dup, toUp) < 0) Dup = mul(Dup, -1);
- return { P, T, In, Dup, Up: Dup, u };
+ let Up = sub([0, 1, 0], mul(T, T[1])); Up = norm(Up);
+ let v = sub([P[0] - .035, ZC(u), 0], P); // hacia el eje, un poco hacia atrás (la garganta)
+ v = sub(v, add(mul(T, dot(v, T)), mul(Up, dot(v, Up))));
+ const In = Math.hypot(...v) > 1e-6 ? norm(v) : [-1, 0, 0];
+ const Out = mul(In, -1);
+ return { P, T, In, Dup: Up, Up, Out, u, front: 1 - Math.abs(t) };
}
-const gumCenter = (f, lower) => add(add(f.P, mul(f.In, GUM.rh * 1.25)), mul(f.Dup, (lower ? -1 : 1) * GUM.rv * .42));
-const gumPt = (f, lower, a, k = 1) => add(add(gumCenter(f, lower), mul(f.In, GUM.rh * Math.cos(a) * k)), mul(f.Dup, GUM.rv * Math.sin(a) * k));
+const gumTaper = u => 1 - sstep(UC - .016, UC + .002, u); // la encía se afina y se cierra en la comisura
+const gumCenter = (f, lower) => add(add(f.P, mul(f.In, GUM.rh * (lower ? 2.15 : 1.45))), mul(f.Dup, (lower ? -1 : 1) * GUM.rv * (lower ? .02 - .45 * f.front ** 2 : .35))); // delante el mentón se curva: la encía sube
+const gumPt = (f, lower, a, k = 1) => { const g = k * (.15 + .85 * gumTaper(f.u)); return add(add(gumCenter(f, lower), mul(f.In, GUM.rh * Math.cos(a) * g)), mul(f.Dup, GUM.rv * Math.sin(a) * g)); };
function buildMouth() {
const NT = 121, NA = 28, NR = 22;
@@ -3790,18 +3793,18 @@ function buildMouth() {
// 1) encía: tubo elíptico a lo largo del arco
const g = frames.map((f, i) => Array.from({ length: NA + 1 }, (_, j) => {
const a = TAU * j / NA, p = gumPt(f, lower, a);
- const n = norm(add(mul(f.In, Math.cos(a) / GUM.rh), mul(f.Up, Math.sin(a) / GUM.rv)));
+ const n = norm(add(mul(f.In, Math.cos(a) / GUM.rh), mul(f.Dup, Math.sin(a) / GUM.rv)));
return vert(p, n, [f.u, -1 + 2 * i / (NT - 1), j / NA, 0], [w, up * protW(-1 + 2 * i / (NT - 1)), 0, 0], 7);
}));
for (let i = 0; i < NT - 1; i++) for (let j = 0; j < NA; j++) { tri(g[i][j], g[i + 1][j], g[i + 1][j + 1]); tri(g[i][j], g[i + 1][j + 1], g[i][j + 1]); }
// 2) paladar (arriba) o suelo con lengua (abajo): del borde interno de la encía a la garganta
const uTh = UC + .035, cT = center(uTh);
- const throat = [.5 - uTh, lower ? cT[1] - .5 * HB(uTh) : cT[1] + .3 * HT(uTh), 0];
+ const throat = [.5 - uTh, lower ? cT[1] - .72 * HB(uTh) : cT[1] + .3 * HT(uTh), 0]; // el suelo baja hacia la faringe
const ref = lower ? [0, 1, 0] : [0, -1, 0]; // normales hacia el interior de la boca
const S = (i, r) => {
const f = frames[i], tt = -1 + 2 * i / (NT - 1), e0 = gumPt(f, lower, 0), rr = Math.pow(r, .85);
const p = lerp3(e0, throat, rr);
- const vault = lower ? .0055 * Math.sin(Math.PI * r) * (1 - tt * tt) - .006 * Math.sin(Math.PI * r) * Math.abs(tt)
+ const vault = lower ? -.0055 * Math.sin(Math.PI * r) * (1 - .5 * tt * tt) + .0042 * Math.exp(-(((r - .22) / .13) ** 2)) * (1 - tt * tt) ** 2 // suelo cóncavo con el basihial delante
: .011 * Math.sin(Math.PI * r) * Math.sqrt(Math.max(0, 1 - tt * tt));
return add(p, [0, vault, 0]);
};
@@ -3820,6 +3823,34 @@ function buildMouth() {
}
}
+/* Comisura: pliegue de piel entre los labios. Cerrada no tiene área; al abrir, cada fila gira con su peso
+ de mandíbula (0 arriba, 1 abajo) y la membrana se tensa como en el animal, sin dejar ver el vacío. */
+function buildCorners() {
+ const NT = 16, NK = 10, T0 = .84;
+ for (const sd of [1, -1]) {
+ const rows = [];
+ for (let i = 0; i <= NT; i++) {
+ const tt = T0 + (1 - T0) * i / NT, f = archFrame(sd * tt), d = (tt - T0) / (1 - T0);
+ const base = add(f.P, mul(f.In, GUM.rh * (.7 + .6 * (1 - d)))); // por dentro del labio: queda en sombra
+ const row = [];
+ for (let k = 0; k <= NK; k++) {
+ const w = k / NK, sag = .0042 * Math.sin(Math.PI * w) * (1 - .6 * d); // la membrana se comba hacia dentro
+ const p = add(base, mul(f.In, sag));
+ const nrm = norm(add(f.Out, mul(f.In, .55 * Math.cos(Math.PI * w))));
+ row.push(vert(p, nrm, [f.u, sd * phiM(f.u), 0, 2], [w, 0, .02 + .25 * Math.sin(Math.PI * w), 0], 0)); // P.w = 2: pliegue de la comisura
+ }
+ rows.push(row);
+ }
+ // cerrada no tiene área: el sentido de cada triángulo se decide con la boca abierta (giro de la bisagra en JS)
+ const opened = i => { const q = vpos(i), w = VB[i * STRIDE + 10], ang = .6 * w, c = Math.cos(ang), sn = Math.sin(ang), dx = q[0] - HINGE[0], dy = q[1] - HINGE[1]; return [HINGE[0] + c * dx + sn * dy, HINGE[1] - sn * dx + c * dy, q[2]]; };
+ const triO = (a, b, c) => { const g = cross(sub(opened(b), opened(a)), sub(opened(c), opened(a))); if (dot(g, vnrm(a)) < 0) IB.push(a, c, b); else IB.push(a, b, c); };
+ for (let i = 0; i < NT; i++) for (let k = 0; k < NK; k++) {
+ const a = rows[i][k], b = rows[i + 1][k], c = rows[i + 1][k + 1], d = rows[i][k + 1];
+ triO(a, b, c); triO(a, c, d);
+ }
+ }
+}
+
/* Diente: corona triangular con bordes convexos y aserrados, raíz hundida en la encía. */
function tooth(base, A, T, h, b, jawW, lipUp, u, slant, narrow) {
const N = norm(cross(T, A)), K = 11, o = [];
@@ -3865,12 +3896,13 @@ function buildTeeth() {
const fr = archFrame(t), dist = mul(fr.T, sd); // hacia la comisura
for (const row of [0, 1]) {
const a = lower ? (row ? Math.PI / 2 - .75 : Math.PI / 2 + .5) : (row ? -Math.PI / 2 + .75 : -Math.PI / 2 - .5);
- const base = gumPt(fr, lower, a, .82);
- let A = norm(add(add(mul(fr.Dup, lower ? .6 : -.85), [0, lower ? .75 : -.5, 0]), mul(fr.In, -.1))); // hacia la otra mandíbula, algo hacia fuera
- if (row) A = norm(add(mul(A, .45), mul(fr.In, 1))); // reemplazo: tumbado hacia dentro
+ const base = gumPt(fr, lower, a, row ? .45 : .82); // el reemplazo nace hundido en la encía
+ const front = 1 - Math.abs(t); // 1 delante, 0 en la comisura
+ let A = norm(add(mul(fr.Dup, lower ? 1 : -1), mul(fr.Out, lower ? .08 + .06 * front : .14 + .04 * front))); // hacia la otra mandíbula, algo hacia fuera
+ if (row) A = norm(add(mul(A, .3), mul(fr.In, 1))); // reemplazo: tumbado hacia dentro, casi oculto // reemplazo: tumbado hacia dentro
A = norm(sub(A, mul(dist, dot(A, dist))));
A = norm(add(A, mul(fr.In, rnd() * .1)));
- const sc = (row ? .74 : 1) * (1 + rnd() * .08);
+ const sc = (row ? .6 : 1) * (1 + rnd() * .08);
const bw = slot * (lower ? .68 : .97) * sc, h = bw * (lower ? 1.95 : 1.42) * (k === 2 && !lower ? .92 : 1);
const slant = lower ? .02 + .1 * k / prof.length : .02 + .5 * Math.pow(k / prof.length, 1.2);
tooth(base, A, dist, h, bw, lower ? 1 : 0, lower ? 0 : protW(t), fr.u, slant, lower);
@@ -3879,11 +3911,21 @@ function buildTeeth() {
}
}
function buildEyes() {
- const r = .0064;
+ const r = .0061, rN = r * .62; // casquete aplanado: apenas sobresale de la órbita
for (const sd of [1, -1]) {
- const S = bodyPt(.088, sd * 1.03), n0 = bodyNormal(.088, sd * 1.03), C = sub(S, mul(n0, r * .42));
- const NA = 18, NB = 12, g = [];
- for (let i = 0; i <= NB; i++) { const row = [], th = Math.PI * i / NB; for (let j = 0; j <= NA; j++) { const ph = TAU * j / NA, n = [Math.sin(th) * Math.cos(ph), Math.cos(th), Math.sin(th) * Math.sin(ph)]; row.push(vert(add(C, mul(n, r)), n, [.088, 0, 0, 0], [0, 0, 9, 0], 4)); } g.push(row); }
+ const S = bodyPt(.088, sd * 1.03), n0 = bodyNormal(.088, sd * 1.03), C = sub(S, mul(n0, rN * .5));
+ let t1 = norm(cross(n0, [0, 1, 0])); const t2 = cross(n0, t1);
+ const NA = 28, NB = 14, g = [];
+ for (let i = 0; i <= NB; i++) {
+ const row = [], th = Math.PI * .62 * i / NB; // solo la parte que asoma
+ for (let j = 0; j <= NA; j++) {
+ const ph = TAU * j / NA, rad = add(mul(t1, Math.cos(ph)), mul(t2, Math.sin(ph)));
+ const p = add(add(C, mul(n0, Math.cos(th) * rN)), mul(rad, Math.sin(th) * r));
+ const n = norm(add(mul(n0, Math.cos(th) / rN), mul(rad, Math.sin(th) / r)));
+ row.push(vert(p, n, [.088, Math.cos(th), 0, 0], [0, 0, 9, 0], 4));
+ }
+ g.push(row);
+ }
for (let i = 0; i < NB; i++) for (let j = 0; j < NA; j++) { tri(g[i][j], g[i + 1][j], g[i + 1][j + 1]); tri(g[i][j], g[i + 1][j + 1], g[i][j + 1]); }
}
}
@@ -3892,8 +3934,9 @@ function buildEyes() {
/* Puntos anatómicos para las cotas del plano técnico (posición en reposo + peso de mandíbula) */
const tD0 = u => ZC(u) + HT(u);
const ANCHORS = [
- { id: 'hoc', p: bodyPt(.03, 1.75), w: 0, t: ['Hocico', 'ampollas de Lorenzini'] },
- { id: 'ojo', p: bodyPt(.088, 1.03), w: 0, t: ['Ojo', 'tapetum lucidum'] },
+ { id: 'nar', p: bodyPt(.03, 2.4), w: 0, t: ['Narina', 'olfato direccional'], te: ['Nostril', 'directional smell'] },
+ { id: 'hoc', p: bodyPt(.03, 1.75), w: 0, t: ['Hocico', 'ampollas de Lorenzini'], te: ['Snout', 'ampullae of Lorenzini'] },
+ { id: 'ojo', p: bodyPt(.088, 1.03), w: 0, t: ['Ojo', 'tapetum lucidum'], te: ['Eye', 'tapetum lucidum'] },
{ id: 'die', p: lerp3(bodyPt(.1, phiM(.1)), center(.1), .1), w: 1, t: ['Dientes aserrados', '2 filas · reemplazo continuo'], te: ['Serrated teeth', '2 rows · constant replacement'] },
{ id: 'bra', p: bodyPt(.215, 1.45), w: 0, t: ['Hendiduras branquiales', '5 por lado'], te: ['Gill slits', '5 per side'] },
{ id: 'dor', p: [X(.445), tD0(.445) + .122, 0], w: 0, t: ['Primera dorsal', 'estabiliza el balanceo'], te: ['First dorsal', 'steadies the roll'] },
@@ -3999,6 +4042,7 @@ vec3 bump(vec3 N, vec3 pos, float h){
vec3 g = sign(det) * (dhx * r1 + dhy * r2);
return normalize(abs(det) * N - g);
}
+float fade0(float x, float y){ return 1. - clamp(max(fwidth(x), fwidth(y)) * .9, 0., 1.); }
float line(float x, float w){ float f = abs(fract(x - .5) - .5), d = fwidth(x); return 1. - smoothstep(w * d, (w + 1.2) * d, f); }
float segD(vec2 p, vec2 a, vec2 b){ vec2 pa = p - a, ba = b - a; float h = clamp(dot(pa, ba) / dot(ba, ba), 0., 1.); return length(pa - ba * h); }
float gills(float u, float a, out float h){
@@ -4046,7 +4090,10 @@ void main(){
bool inside = !gl_FrontFacing && mat == 0;
if (!gl_FrontFacing) N = -N;
if (mat == 0 && inside){ // interior de la boca: encía y paladar
- alb = vec3(.025, .006, .009); rough = .4; ck = 0.;
+ float dl = clamp(vQ.z, 0., 3.); // distancia angular al labio
+ alb = mix(vec3(.46, .17, .19), vec3(.05, .012, .016), smoothstep(.04, .7, dl));
+ alb *= .85 + .3 * fbm(vec2(u * 90., dl * 12.));
+ rough = .28; f0 = .03; sss = .5; ck = .15;
} else if (mat == 0){
float py = mod(vP.y + 3.14159265, 6.2831853) - 3.14159265; // ángulo envuelto por fragmento
float a = abs(py), side = py < 0. ? -1. : 1.;
@@ -4065,16 +4112,26 @@ void main(){
alb = mix(alb, vec3(.025, .015, .02), g); h += gh;
vec2 ep = vec2(u - .088, (a - 1.03) * .058); // cuenca del ojo
float ed = length(ep);
- alb *= 1. - .4 * exp(-pow((ed - .0088) / .003, 2.)); h += .6 * exp(-pow((ed - .009) / .0035, 2.));
- if (u < .1){ // ampollas de Lorenzini y narina
- vec2 q = vec2(u * 520., py * 34.), id = floor(q), f = fract(q) - .5;
+ alb *= 1. - .55 * exp(-pow((ed - .0062) / .0014, 2.)) - .18 * exp(-pow((ed - .0075) / .004, 2.)); // párpado y cuenca
+ h -= .5 * exp(-pow(ed / .0095, 2.)) - .25 * exp(-pow((ed - .0102) / .0022, 2.)); // órbita hundida con reborde suave
+ if (u < .11){ // ampollas de Lorenzini y narinas
+ vec2 q = vec2(u * 980., py * 64.), id = floor(q), f = fract(q) - .5;
float r = hash12(id + side * 13.);
- float pore = step(.72, r) * (1. - smoothstep(.06, .13, length(f + (vec2(hash12(id + 3.), hash12(id + 7.)) - .5) * .5)));
- float m = smoothstep(.1, .03, u) * smoothstep(1., 1.4, a);
- alb *= 1. - .35 * pore * m; h -= pore * m * .4;
- float nd = length(vec2((u - .029) / .0075, (a - 2.25) / .085));
- alb = mix(alb, vec3(.02), 1. - smoothstep(.6, 1., nd));
+ float pore = step(.66, r) * (1. - smoothstep(.07, .16, length(f + (vec2(hash12(id + 3.), hash12(id + 7.)) - .5) * .45)));
+ float m = smoothstep(.11, .035, u) * (smoothstep(.75, 1.6, a) + .35 * smoothstep(.07, .02, u));
+ m *= fade0(u * 980., py * 64.);
+ alb *= 1. - .28 * pore * m; h -= pore * m * .35;
+ // narina: hendidura oblicua por delante de la boca, con el colgajo anterior que la tapa a medias
+ vec2 nq = vec2(u, a * .034);
+ float nd = segD(nq, vec2(.021, 2.2 * .034), vec2(.037, 2.58 * .034));
+ float slit = 1. - smoothstep(.0007, .0013, nd);
+ float flap = exp(-pow((nd - .0016) / .0009, 2.)) * step(0., (nq.y - mix(2.2, 2.58, clamp((u - .021) / .016, 0., 1.)) * .034));
+ alb = mix(alb, vec3(.012, .01, .012), slit * .92); h += -1.1 * slit + .6 * flap;
}
+ // pliegue de la piel en la comisura: la línea de la boca se prolonga un poco, sin surco labial marcado
+ float fur = exp(-pow((a - 2.02) / .03, 2.)) * smoothstep(.142, .15, u) * (1. - smoothstep(.155, .166, u));
+ alb *= 1. - .25 * fur; h -= .5 * fur;
+ if (vP.w > 1.5) alb = mix(alb * .45, vec3(.36, .2, .22), .35); // pliegue de la comisura: hundido y algo rosado
float sc = 1.; // cicatrices de viejas peleas
vec2 pp = vec2(u, a * .06);
sc = min(sc, segD(pp, vec2(.31, 1.0 * .06), vec2(.37, 1.22 * .06)));
@@ -4110,7 +4167,8 @@ void main(){
float r = vQ.z;
alb = mix(vec3(.62, .2, .23), vec3(.3, .045, .06), smoothstep(.05, .55, r));
alb *= .84 + .16 * sin(r * 70. + vP.y * 3.); // pliegues transversales del paladar
- alb = mix(alb, vec3(.012, .002, .004), smoothstep(.55, .98, r));
+ alb *= 1. - .55 * smoothstep(.58, .7, r) * smoothstep(.2, .8, sin(r * 46.) * .5 + .5); // arcos branquiales en la faringe
+ alb = mix(alb, vec3(.012, .002, .004), smoothstep(.72, .99, r));
h = .5 * fbm(vec2(vP.y * 60., r * 18.)) + .35 * sin(r * 70. + vP.y * 3.); bk = .0008;
rough = .22; f0 = .03; sss = .6; ck = .1;
} else if (mat == 3){
@@ -4121,12 +4179,16 @@ void main(){
rough = .17; f0 = .05; sss = .4 + .8 * t; ck = .3;
} else {
// ojo: al morder rota hacia atrás y deja ver el tejido blanco que lo protege
- alb = mix(vec3(.01), vec3(.72, .7, .66), uEye); rough = mix(.07, .35, uEye); f0 = .06; ck = .2;
- emit = vec3(.03, .22, .15) * pow(max(dot(N, V), 0.), 5.) * .8 * (1. - uEye); // brillo del tapetum
+ float c = vP.y; // 1 en el centro, ~0,4 en el borde
+ vec3 iris = mix(vec3(.045, .055, .068), vec3(.018, .022, .03), smoothstep(.5, .8, c));
+ iris *= .85 + .3 * noise(vec2(atan(N0.y, N0.x) * 9., c * 6.)); // fibras del iris, apenas visibles
+ alb = mix(iris, vec3(.003, .003, .004), smoothstep(.86, .93, c)); // pupila
+ alb = mix(alb, vec3(.46, .44, .43), uEye); rough = mix(.09, .4, uEye); f0 = .045; ck = .15;
+ emit = vec3(.02, .12, .09) * pow(max(dot(N, V), 0.), 12.) * smoothstep(.88, .95, c) * .35 * (1. - uEye); // tapetum: solo en la pupila
}
if (bk > 0.) N = bump(N, vW, h * bk);
vec3 col = shade(alb, N, V, rough, f0, sss, ck) + emit;
- if (mat == 6 || mat == 7) col += alb * vec3(.55, .22, .22) * .5 * (mat == 6 ? 1. - smoothstep(.2, .9, vQ.z) : 1.); // luz que entra y se dispersa en la boca
+ if (mat == 6 || mat == 7 || inside) col += alb * vec3(.55, .22, .22) * .5 * (mat == 6 ? 1. - smoothstep(.2, .9, vQ.z) : inside ? 1. - smoothstep(.05, .6, vQ.z) : 1.); // luz que entra y se dispersa en la boca
if (mat == 6) col *= mix(1.1, .3, smoothstep(.15, .95, vQ.z)); // oclusión hacia la garganta
// absorción del agua por canal (Beer-Lambert) y luz dispersada
vec3 T = exp(-uSigma * length(uCam - vW));
@@ -4372,6 +4434,7 @@ const THEMES = {
const ACC = [.12, .83, .54], BPL = [.5, .78, 1];
const SUN = norm([.22, 1, .32]);
const OMEGA = TAU * .42, BITEP = 11, BITE_START = 6.4, BITE = BITE_START + 1.05; // BITE: instante de boca abierta del todo
+let DBG = null; // vista de depuración (solo con navigator.webdriver)
const st = { t: 0, mix: 0, mixTo: 0, mixV: 0, blue: 0, blueTo: 0, px: 0, py: 0, tx: 0, ty: 0 }; // el hero es siempre oscuro
/* Mordisco según Tricas (1985): elevación del hocico + descenso de la mandíbula (apertura máxima a 0,167 s),
@@ -4402,12 +4465,17 @@ function frameState(t) {
s.pos = add(mul(head, .05 * b), [0, .018 * Math.sin(t * .3), 0]);
s.M = model(s.yaw, s.pitch, s.roll, s.pos);
// cámara: ligeramente por debajo, con paralaje del puntero
- const az = .02 + st.px * .07, el = -.13 + st.py * .05, dist = NARROW ? 1.4 : 1.6;
- const tgt = [.04, NARROW ? .02 : .0, 0];
+ let az = .02 + st.px * .07, el = -.13 + st.py * .05, dist = NARROW ? 1.4 : 1.68;
+ let tgt = [.04, NARROW ? .02 : .0, 0];
+ if (DBG) { // solo pruebas automatizadas: cámara libre sobre la cabeza
+ if (DBG.pose) { s.yaw = DBG.pose[0]; s.pitch = DBG.pose[1]; s.roll = DBG.pose[2]; s.M = model(s.yaw, s.pitch, s.roll, s.pos); }
+ az = DBG.az; el = DBG.el; dist = DBG.dist; tgt = DBG.tgt;
+ if (DBG.tgtM) { const m = s.M, q = DBG.tgtM; tgt = [m[0] * q[0] + m[4] * q[1] + m[8] * q[2] + m[12], m[1] * q[0] + m[5] * q[1] + m[9] * q[2] + m[13], m[2] * q[0] + m[6] * q[1] + m[10] * q[2] + m[14]]; }
+ }
s.cam = add(tgt, [Math.sin(az) * Math.cos(el) * dist, Math.sin(el) * dist, Math.cos(az) * Math.cos(el) * dist]);
s.V = M4.look(s.cam, tgt, [0, 1, 0]);
const fov = .56, asp = W / H;
- s.shift = NARROW ? [.1, -.04] : [.34, .02];
+ s.shift = DBG ? [0, 0] : NARROW ? [.1, -.04] : [.64, .035]; // a la derecha del título: la cabeza y la boca quedan despejadas
s.P = M4.persp(fov, asp, .02, 30, s.shift[0], s.shift[1]);
s.VP = M4.mul(s.P, s.V);
s.tan = [Math.tan(fov / 2) * asp, Math.tan(fov / 2)];
@@ -4501,8 +4569,8 @@ function callouts(s) {
const pl = document.createElementNS(NS_SVG, 'polyline'); pl.setAttribute('class', 'ld');
const rc = document.createElementNS(NS_SVG, 'rect'); rc.setAttribute('class', 'plate'); rc.setAttribute('rx', 6);
const dt = document.createElementNS(NS_SVG, 'circle'); dt.setAttribute('class', 'dot'); dt.setAttribute('r', 3);
- const t1 = document.createElementNS(NS_SVG, 'text'); t1.setAttribute('class', 'k'); t1.textContent = (LANG === 'en' ? a.te : a.t)[0];
- const t2 = document.createElementNS(NS_SVG, 'text'); t2.textContent = (LANG === 'en' ? a.te : a.t)[1];
+ const t1 = document.createElementNS(NS_SVG, 'text'); t1.setAttribute('class', 'k'); t1.textContent = ((LANG === 'en' && a.te) || a.t)[0];
+ const t2 = document.createElementNS(NS_SVG, 'text'); t2.textContent = ((LANG === 'en' && a.te) || a.t)[1];
g.append(pl, rc, dt, t1, t2); svg.append(g);
return { a, g, pl, rc, dt, t1, t2, w: 0 };
});
@@ -4572,7 +4640,7 @@ function ensureGL() {
gl = cv.getContext('webgl2', { antialias: false, alpha: false, depth: false, stencil: false, powerPreference: 'high-performance', preserveDrawingBuffer: false });
if (!gl) return (glOk = false);
try {
- if (!geoReady) { buildBody(); buildMouth(); buildFins(); buildTeeth(); buildEyes(); geoReady = true; }
+ if (!geoReady) { buildBody(); buildMouth(); buildCorners(); buildFins(); buildTeeth(); buildEyes(); geoReady = true; }
initGL();
} catch (err) { console.error(err); gl = null; return (glOk = false); }
cv.addEventListener('webglcontextlost', e => { e.preventDefault(); stop(); });
@@ -4631,6 +4699,7 @@ return {
seek(t) { stop(); st.t = clock = t; settle(); },
pause() { paused = true; stop(); },
setMode(m) { st.blueTo = m === 'blue' ? 1 : 0; settle(); },
+ debugView(o) { if (navigator.webdriver) { DBG = o; settle(); } },
stats: () => ({ vertices: VB.length / STRIDE, triangles: IB.length / 3, hdr, quality, running }),
};
})();
diff --git a/docs/capturas/inicio-claro.webp b/docs/capturas/inicio-claro.webp
index ac4e317..4f61938 100644
Binary files a/docs/capturas/inicio-claro.webp and b/docs/capturas/inicio-claro.webp differ
diff --git a/docs/capturas/inicio-oscuro.webp b/docs/capturas/inicio-oscuro.webp
index b245cea..361d4c2 100644
Binary files a/docs/capturas/inicio-oscuro.webp and b/docs/capturas/inicio-oscuro.webp differ
diff --git a/docs/capturas/lateral-plegado.webp b/docs/capturas/lateral-plegado.webp
index e39765d..365e484 100644
Binary files a/docs/capturas/lateral-plegado.webp and b/docs/capturas/lateral-plegado.webp differ
diff --git a/docs/capturas/mordisco.webp b/docs/capturas/mordisco.webp
index b4484fc..bb116a9 100644
Binary files a/docs/capturas/mordisco.webp and b/docs/capturas/mordisco.webp differ
diff --git a/docs/capturas/movil.webp b/docs/capturas/movil.webp
index 08c2df3..126d00f 100644
Binary files a/docs/capturas/movil.webp and b/docs/capturas/movil.webp differ
diff --git a/docs/capturas/plano-tecnico.webp b/docs/capturas/plano-tecnico.webp
index abe81c9..2d5e9c3 100644
Binary files a/docs/capturas/plano-tecnico.webp and b/docs/capturas/plano-tecnico.webp differ
diff --git a/docs/capturas/protrusion.webp b/docs/capturas/protrusion.webp
index 115c393..f05b976 100644
Binary files a/docs/capturas/protrusion.webp and b/docs/capturas/protrusion.webp differ
diff --git a/docs/megalodon-3d.md b/docs/megalodon-3d.md
index b8f486b..4280623 100644
--- a/docs/megalodon-3d.md
+++ b/docs/megalodon-3d.md
@@ -11,9 +11,28 @@ Comparada con fotografías de tiburones blancos con la boca abierta, una boca ab
| Mandíbula superior no soldada al cráneo (suspensión hiostílica); al morder protruye hacia delante y hacia abajo y deja la encía al descubierto | `uProt` desplaza encía, dientes y paladar superiores; el frente protruye más que las comisuras (`protW`) | Tricas (1985); White Shark Ocean, «How a Great White Shark's Jaw Actually Works» (2026) |
| Unos 24 dientes expuestos por mandíbula | 13 superiores y 12 inferiores por lado | Marine Dynamics / Shark Watch SA, «How many teeth does a white shark have?» |
| Dientes superiores anchos y triangulares, aserrados en ambos bordes; inferiores más estrechos y puntiagudos | `tooth()` con bordes convexos y aserrado fino; los inferiores con cuello estrecho | White Shark Ocean (2026); ScienceDirect, «Carcharodon» (el diente intermedio superior es distinto) |
-| Filas de reemplazo detrás de las funcionales | Una fila por mandíbula, tumbada hacia el interior | Natural History Museum, «What can shark teeth tell us?» |
+| Filas de reemplazo detrás de las funcionales | Una fila por mandíbula, tumbada hacia el interior y hundida en la encía (casi oculta, como en el animal) | Natural History Museum, «What can shark teeth tell us?» |
| El tiburón blanco rota el ojo hacia atrás al morder (no tiene membrana nictitante) | `uEye` aclara el ojo durante el mordisco | Descripción divulgativa extendida; dato secundario |
+## Cabeza y facciones (1.3.1)
+
+Revisión hecha con un banco de pruebas de vistas (perfil, frente, tres cuartos y la pose de la portada), boca cerrada, abierta y con protrusión. Lo que fallaba y cómo quedó:
+
+| Rasgo | Antes | Ahora | Fuente |
+|---|---|---|---|
+| Orientación de dientes y encías | El marco seguía la normal de la piel: bajo el hocico la piel es horizontal y los dientes inferiores apuntaban hacia delante, como un peine | Marco con la vertical de la cabeza: los superiores cuelgan, los inferiores se alzan algo procumbentes, y se cruzan en la línea de la boca | Fotografías de boca abierta; White Shark Ocean (2026) |
+| Encía inferior | Asomaba por fuera del labio como una franja rosa | Dentro del labio, al nivel de la línea de la boca, y más alta delante, donde el mentón se curva | — |
+| Comisura | Al abrir se veía una cuña negra hasta la bisagra | Pliegue de piel que se estira en abanico entre los labios (cada fila con su peso de mandíbula) y prolonga apenas la línea de la boca | — |
+| Ojo | Esfera saliente con aro turquesa («ojo de buey») | Casquete casi enrasado, negro azulado con pupila, órbita hundida y brillo del tapetum solo en la pupila | CITES (2022), guía de identificación: «very black eyes» |
+| Hocico | Cono afilado | Cono corto y robusto con la punta redondeada | CITES (2022), guía de identificación: «snout short and conical» |
+| Narinas | Mancha oscura | Hendidura oblicua en la cara inferior del hocico, por delante de la boca, con colgajo anterior | Smithsonian Ocean Portal («nostrils on the underside of the snout»); SeaWorld («ventral external nostrils») |
+| Ampollas de Lorenzini | Motas gruesas | Poros finos concentrados en el hocico | Smithsonian Ocean Portal |
+| Interior de la boca | Negro plano de perfil; suelo como una losa rosa de frente | Carne rosada junto al labio que se oscurece hacia dentro; suelo cóncavo con el basihial; faringe oscura con arcos branquiales | — |
+| Mandíbula inferior | Fina | Mentón y mandíbula más robustos | — |
+| Encuadre en la portada | Con la barra lateral de la 1.3.0, la cabeza quedaba bajo el título | Cabeza y boca a la derecha del título a 1280, 1440 y 1920 px (prueba e2e) | — |
+
+Fuente de la guía: CITES / IUCN SSG, *Full Carcass ID Guide* (2022), ficha de *Carcharodon carcharias*.
+
## Secuencia del mordisco
Tricas, T. C. (1985). *Feeding ethology of the white shark, Carcharodon carcharias*. Memoirs of the Southern California Academy of Sciences, 9, 81-91.
diff --git a/megalodon.html b/megalodon.html
index 4ff8a83..94bb584 100644
--- a/megalodon.html
+++ b/megalodon.html
@@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
-<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'sha256-y/5U0uCLqnyYytoYMQTZnUNyh772yvAzk5feC5A9+xI='; style-src 'sha256-C96SuEnKUh+J8kkbNV7gTpU17KM0Edca82DmDD9F5Sw='; img-src data: blob:; connect-src 'none'; font-src 'none'; object-src 'none'; frame-src 'none'; base-uri 'none'; form-action 'none'">
+<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'sha256-F6LBR26RgvlOg9FJEtq2yWimgk9Gfkv9nBrSjUBJFIo='; style-src 'sha256-C96SuEnKUh+J8kkbNV7gTpU17KM0Edca82DmDD9F5Sw='; img-src data: blob:; connect-src 'none'; font-src 'none'; object-src 'none'; frame-src 'none'; base-uri 'none'; form-action 'none'">
<meta name="referrer" content="no-referrer">
<meta name="color-scheme" content="dark light">
<meta name="description" content="Megalodon: laboratorio de Wireshark sin conexión. Capturas de un pentest, filtros con validación al instante y retos guiados del saludo TCP a los ataques web.">
@@ -3620,9 +3620,9 @@ function curve(us, vs) { // Hermite con tangen
}
// Perfil lamniforme: hocico cónico, tronco fusiforme alto, pedúnculo estrecho con quilla lateral.
const U = [0, .008, .025, .05, .09, .14, .2, .28, .36, .46, .58, .7, .8, .87, .925];
-const HT = curve(U, [0, .011, .025, .04, .056, .072, .086, .098, .103, .098, .078, .05, .028, .016, .011]);
-const HB = curve(U, [0, .008, .02, .033, .049, .067, .083, .096, .099, .092, .07, .043, .024, .013, .009]);
-const WD = curve(U, [0, .011, .026, .041, .057, .072, .084, .093, .095, .088, .068, .044, .026, .016, .011]);
+const HT = curve(U, [0, .0155, .03, .0445, .0585, .072, .086, .098, .103, .098, .078, .05, .028, .016, .011]);
+const HB = curve(U, [0, .0125, .026, .0405, .0555, .0715, .083, .096, .099, .092, .07, .043, .024, .013, .009]);
+const WD = curve(U, [0, .015, .0305, .0445, .0585, .072, .084, .093, .095, .088, .068, .044, .026, .016, .011]);
const ZC = u => .009 * Math.pow(Math.max(0, 1 - u / .22), 2) - .005 * Math.exp(-(((u - .42) / .22) ** 2));
const KEEL = u => .0042 * sstep(.8, .865, u);
const sgnpow = (v, e) => Math.sign(v) * Math.pow(Math.abs(v), e);
@@ -3768,19 +3768,22 @@ const protW = t => 1 - Math.pow(Math.abs(t), 1.6) * .85; // el frente del pala
// Marco local del arco: T a lo largo del labio, In hacia dentro de la cabeza (contra la normal de la piel),
// Dup sobre la piel, perpendicular al labio y hacia la mandíbula superior.
function archFrame(t) {
+ // Las mandíbulas se cierran en vertical: los dientes de arriba cuelgan y los de abajo se alzan, y se cruzan en
+ // la línea de la boca. Por eso el marco usa la vertical de la cabeza (Up) y la horizontal hacia dentro (In),
+ // no la normal de la piel: bajo el hocico la piel es horizontal y los dientes saldrían hacia delante.
t = clamp(t, -1, 1);
- const P = archLip(t), e = .004, u = archU(t), sd = t < 0 ? -1 : 1;
+ const P = archLip(t), e = .004, u = archU(t);
const T = norm(sub(archLip(Math.min(1, t + e)), archLip(Math.max(-1, t - e))));
- const n = u <= UF + 1e-6 ? [0, -1, 0] : bodyNormal(u, sd * phiM(u));
- let In = mul(n, -1); In = norm(sub(In, mul(T, dot(In, T))));
- let Dup = norm(cross(T, In));
- // hacia la mandíbula superior: un poco más adelante y por encima de la línea de la boca
- const toUp = sub(bodyPt(Math.max(0, u - .008), sd * Math.max(0, phiM(u) - .12)), P);
- if (dot(Dup, toUp) < 0) Dup = mul(Dup, -1);
- return { P, T, In, Dup, Up: Dup, u };
+ let Up = sub([0, 1, 0], mul(T, T[1])); Up = norm(Up);
+ let v = sub([P[0] - .035, ZC(u), 0], P); // hacia el eje, un poco hacia atrás (la garganta)
+ v = sub(v, add(mul(T, dot(v, T)), mul(Up, dot(v, Up))));
+ const In = Math.hypot(...v) > 1e-6 ? norm(v) : [-1, 0, 0];
+ const Out = mul(In, -1);
+ return { P, T, In, Dup: Up, Up, Out, u, front: 1 - Math.abs(t) };
}
-const gumCenter = (f, lower) => add(add(f.P, mul(f.In, GUM.rh * 1.25)), mul(f.Dup, (lower ? -1 : 1) * GUM.rv * .42));
-const gumPt = (f, lower, a, k = 1) => add(add(gumCenter(f, lower), mul(f.In, GUM.rh * Math.cos(a) * k)), mul(f.Dup, GUM.rv * Math.sin(a) * k));
+const gumTaper = u => 1 - sstep(UC - .016, UC + .002, u); // la encía se afina y se cierra en la comisura
+const gumCenter = (f, lower) => add(add(f.P, mul(f.In, GUM.rh * (lower ? 2.15 : 1.45))), mul(f.Dup, (lower ? -1 : 1) * GUM.rv * (lower ? .02 - .45 * f.front ** 2 : .35))); // delante el mentón se curva: la encía sube
+const gumPt = (f, lower, a, k = 1) => { const g = k * (.15 + .85 * gumTaper(f.u)); return add(add(gumCenter(f, lower), mul(f.In, GUM.rh * Math.cos(a) * g)), mul(f.Dup, GUM.rv * Math.sin(a) * g)); };
function buildMouth() {
const NT = 121, NA = 28, NR = 22;
@@ -3790,18 +3793,18 @@ function buildMouth() {
// 1) encía: tubo elíptico a lo largo del arco
const g = frames.map((f, i) => Array.from({ length: NA + 1 }, (_, j) => {
const a = TAU * j / NA, p = gumPt(f, lower, a);
- const n = norm(add(mul(f.In, Math.cos(a) / GUM.rh), mul(f.Up, Math.sin(a) / GUM.rv)));
+ const n = norm(add(mul(f.In, Math.cos(a) / GUM.rh), mul(f.Dup, Math.sin(a) / GUM.rv)));
return vert(p, n, [f.u, -1 + 2 * i / (NT - 1), j / NA, 0], [w, up * protW(-1 + 2 * i / (NT - 1)), 0, 0], 7);
}));
for (let i = 0; i < NT - 1; i++) for (let j = 0; j < NA; j++) { tri(g[i][j], g[i + 1][j], g[i + 1][j + 1]); tri(g[i][j], g[i + 1][j + 1], g[i][j + 1]); }
// 2) paladar (arriba) o suelo con lengua (abajo): del borde interno de la encía a la garganta
const uTh = UC + .035, cT = center(uTh);
- const throat = [.5 - uTh, lower ? cT[1] - .5 * HB(uTh) : cT[1] + .3 * HT(uTh), 0];
+ const throat = [.5 - uTh, lower ? cT[1] - .72 * HB(uTh) : cT[1] + .3 * HT(uTh), 0]; // el suelo baja hacia la faringe
const ref = lower ? [0, 1, 0] : [0, -1, 0]; // normales hacia el interior de la boca
const S = (i, r) => {
const f = frames[i], tt = -1 + 2 * i / (NT - 1), e0 = gumPt(f, lower, 0), rr = Math.pow(r, .85);
const p = lerp3(e0, throat, rr);
- const vault = lower ? .0055 * Math.sin(Math.PI * r) * (1 - tt * tt) - .006 * Math.sin(Math.PI * r) * Math.abs(tt)
+ const vault = lower ? -.0055 * Math.sin(Math.PI * r) * (1 - .5 * tt * tt) + .0042 * Math.exp(-(((r - .22) / .13) ** 2)) * (1 - tt * tt) ** 2 // suelo cóncavo con el basihial delante
: .011 * Math.sin(Math.PI * r) * Math.sqrt(Math.max(0, 1 - tt * tt));
return add(p, [0, vault, 0]);
};
@@ -3820,6 +3823,34 @@ function buildMouth() {
}
}
+/* Comisura: pliegue de piel entre los labios. Cerrada no tiene área; al abrir, cada fila gira con su peso
+ de mandíbula (0 arriba, 1 abajo) y la membrana se tensa como en el animal, sin dejar ver el vacío. */
+function buildCorners() {
+ const NT = 16, NK = 10, T0 = .84;
+ for (const sd of [1, -1]) {
+ const rows = [];
+ for (let i = 0; i <= NT; i++) {
+ const tt = T0 + (1 - T0) * i / NT, f = archFrame(sd * tt), d = (tt - T0) / (1 - T0);
+ const base = add(f.P, mul(f.In, GUM.rh * (.7 + .6 * (1 - d)))); // por dentro del labio: queda en sombra
+ const row = [];
+ for (let k = 0; k <= NK; k++) {
+ const w = k / NK, sag = .0042 * Math.sin(Math.PI * w) * (1 - .6 * d); // la membrana se comba hacia dentro
+ const p = add(base, mul(f.In, sag));
+ const nrm = norm(add(f.Out, mul(f.In, .55 * Math.cos(Math.PI * w))));
+ row.push(vert(p, nrm, [f.u, sd * phiM(f.u), 0, 2], [w, 0, .02 + .25 * Math.sin(Math.PI * w), 0], 0)); // P.w = 2: pliegue de la comisura
+ }
+ rows.push(row);
+ }
+ // cerrada no tiene área: el sentido de cada triángulo se decide con la boca abierta (giro de la bisagra en JS)
+ const opened = i => { const q = vpos(i), w = VB[i * STRIDE + 10], ang = .6 * w, c = Math.cos(ang), sn = Math.sin(ang), dx = q[0] - HINGE[0], dy = q[1] - HINGE[1]; return [HINGE[0] + c * dx + sn * dy, HINGE[1] - sn * dx + c * dy, q[2]]; };
+ const triO = (a, b, c) => { const g = cross(sub(opened(b), opened(a)), sub(opened(c), opened(a))); if (dot(g, vnrm(a)) < 0) IB.push(a, c, b); else IB.push(a, b, c); };
+ for (let i = 0; i < NT; i++) for (let k = 0; k < NK; k++) {
+ const a = rows[i][k], b = rows[i + 1][k], c = rows[i + 1][k + 1], d = rows[i][k + 1];
+ triO(a, b, c); triO(a, c, d);
+ }
+ }
+}
+
/* Diente: corona triangular con bordes convexos y aserrados, raíz hundida en la encía. */
function tooth(base, A, T, h, b, jawW, lipUp, u, slant, narrow) {
const N = norm(cross(T, A)), K = 11, o = [];
@@ -3865,12 +3896,13 @@ function buildTeeth() {
const fr = archFrame(t), dist = mul(fr.T, sd); // hacia la comisura
for (const row of [0, 1]) {
const a = lower ? (row ? Math.PI / 2 - .75 : Math.PI / 2 + .5) : (row ? -Math.PI / 2 + .75 : -Math.PI / 2 - .5);
- const base = gumPt(fr, lower, a, .82);
- let A = norm(add(add(mul(fr.Dup, lower ? .6 : -.85), [0, lower ? .75 : -.5, 0]), mul(fr.In, -.1))); // hacia la otra mandíbula, algo hacia fuera
- if (row) A = norm(add(mul(A, .45), mul(fr.In, 1))); // reemplazo: tumbado hacia dentro
+ const base = gumPt(fr, lower, a, row ? .45 : .82); // el reemplazo nace hundido en la encía
+ const front = 1 - Math.abs(t); // 1 delante, 0 en la comisura
+ let A = norm(add(mul(fr.Dup, lower ? 1 : -1), mul(fr.Out, lower ? .08 + .06 * front : .14 + .04 * front))); // hacia la otra mandíbula, algo hacia fuera
+ if (row) A = norm(add(mul(A, .3), mul(fr.In, 1))); // reemplazo: tumbado hacia dentro, casi oculto // reemplazo: tumbado hacia dentro
A = norm(sub(A, mul(dist, dot(A, dist))));
A = norm(add(A, mul(fr.In, rnd() * .1)));
- const sc = (row ? .74 : 1) * (1 + rnd() * .08);
+ const sc = (row ? .6 : 1) * (1 + rnd() * .08);
const bw = slot * (lower ? .68 : .97) * sc, h = bw * (lower ? 1.95 : 1.42) * (k === 2 && !lower ? .92 : 1);
const slant = lower ? .02 + .1 * k / prof.length : .02 + .5 * Math.pow(k / prof.length, 1.2);
tooth(base, A, dist, h, bw, lower ? 1 : 0, lower ? 0 : protW(t), fr.u, slant, lower);
@@ -3879,11 +3911,21 @@ function buildTeeth() {
}
}
function buildEyes() {
- const r = .0064;
+ const r = .0061, rN = r * .62; // casquete aplanado: apenas sobresale de la órbita
for (const sd of [1, -1]) {
- const S = bodyPt(.088, sd * 1.03), n0 = bodyNormal(.088, sd * 1.03), C = sub(S, mul(n0, r * .42));
- const NA = 18, NB = 12, g = [];
- for (let i = 0; i <= NB; i++) { const row = [], th = Math.PI * i / NB; for (let j = 0; j <= NA; j++) { const ph = TAU * j / NA, n = [Math.sin(th) * Math.cos(ph), Math.cos(th), Math.sin(th) * Math.sin(ph)]; row.push(vert(add(C, mul(n, r)), n, [.088, 0, 0, 0], [0, 0, 9, 0], 4)); } g.push(row); }
+ const S = bodyPt(.088, sd * 1.03), n0 = bodyNormal(.088, sd * 1.03), C = sub(S, mul(n0, rN * .5));
+ let t1 = norm(cross(n0, [0, 1, 0])); const t2 = cross(n0, t1);
+ const NA = 28, NB = 14, g = [];
+ for (let i = 0; i <= NB; i++) {
+ const row = [], th = Math.PI * .62 * i / NB; // solo la parte que asoma
+ for (let j = 0; j <= NA; j++) {
+ const ph = TAU * j / NA, rad = add(mul(t1, Math.cos(ph)), mul(t2, Math.sin(ph)));
+ const p = add(add(C, mul(n0, Math.cos(th) * rN)), mul(rad, Math.sin(th) * r));
+ const n = norm(add(mul(n0, Math.cos(th) / rN), mul(rad, Math.sin(th) / r)));
+ row.push(vert(p, n, [.088, Math.cos(th), 0, 0], [0, 0, 9, 0], 4));
+ }
+ g.push(row);
+ }
for (let i = 0; i < NB; i++) for (let j = 0; j < NA; j++) { tri(g[i][j], g[i + 1][j], g[i + 1][j + 1]); tri(g[i][j], g[i + 1][j + 1], g[i][j + 1]); }
}
}
@@ -3892,8 +3934,9 @@ function buildEyes() {
/* Puntos anatómicos para las cotas del plano técnico (posición en reposo + peso de mandíbula) */
const tD0 = u => ZC(u) + HT(u);
const ANCHORS = [
- { id: 'hoc', p: bodyPt(.03, 1.75), w: 0, t: ['Hocico', 'ampollas de Lorenzini'] },
- { id: 'ojo', p: bodyPt(.088, 1.03), w: 0, t: ['Ojo', 'tapetum lucidum'] },
+ { id: 'nar', p: bodyPt(.03, 2.4), w: 0, t: ['Narina', 'olfato direccional'], te: ['Nostril', 'directional smell'] },
+ { id: 'hoc', p: bodyPt(.03, 1.75), w: 0, t: ['Hocico', 'ampollas de Lorenzini'], te: ['Snout', 'ampullae of Lorenzini'] },
+ { id: 'ojo', p: bodyPt(.088, 1.03), w: 0, t: ['Ojo', 'tapetum lucidum'], te: ['Eye', 'tapetum lucidum'] },
{ id: 'die', p: lerp3(bodyPt(.1, phiM(.1)), center(.1), .1), w: 1, t: ['Dientes aserrados', '2 filas · reemplazo continuo'], te: ['Serrated teeth', '2 rows · constant replacement'] },
{ id: 'bra', p: bodyPt(.215, 1.45), w: 0, t: ['Hendiduras branquiales', '5 por lado'], te: ['Gill slits', '5 per side'] },
{ id: 'dor', p: [X(.445), tD0(.445) + .122, 0], w: 0, t: ['Primera dorsal', 'estabiliza el balanceo'], te: ['First dorsal', 'steadies the roll'] },
@@ -3999,6 +4042,7 @@ vec3 bump(vec3 N, vec3 pos, float h){
vec3 g = sign(det) * (dhx * r1 + dhy * r2);
return normalize(abs(det) * N - g);
}
+float fade0(float x, float y){ return 1. - clamp(max(fwidth(x), fwidth(y)) * .9, 0., 1.); }
float line(float x, float w){ float f = abs(fract(x - .5) - .5), d = fwidth(x); return 1. - smoothstep(w * d, (w + 1.2) * d, f); }
float segD(vec2 p, vec2 a, vec2 b){ vec2 pa = p - a, ba = b - a; float h = clamp(dot(pa, ba) / dot(ba, ba), 0., 1.); return length(pa - ba * h); }
float gills(float u, float a, out float h){
@@ -4046,7 +4090,10 @@ void main(){
bool inside = !gl_FrontFacing && mat == 0;
if (!gl_FrontFacing) N = -N;
if (mat == 0 && inside){ // interior de la boca: encía y paladar
- alb = vec3(.025, .006, .009); rough = .4; ck = 0.;
+ float dl = clamp(vQ.z, 0., 3.); // distancia angular al labio
+ alb = mix(vec3(.46, .17, .19), vec3(.05, .012, .016), smoothstep(.04, .7, dl));
+ alb *= .85 + .3 * fbm(vec2(u * 90., dl * 12.));
+ rough = .28; f0 = .03; sss = .5; ck = .15;
} else if (mat == 0){
float py = mod(vP.y + 3.14159265, 6.2831853) - 3.14159265; // ángulo envuelto por fragmento
float a = abs(py), side = py < 0. ? -1. : 1.;
@@ -4065,16 +4112,26 @@ void main(){
alb = mix(alb, vec3(.025, .015, .02), g); h += gh;
vec2 ep = vec2(u - .088, (a - 1.03) * .058); // cuenca del ojo
float ed = length(ep);
- alb *= 1. - .4 * exp(-pow((ed - .0088) / .003, 2.)); h += .6 * exp(-pow((ed - .009) / .0035, 2.));
- if (u < .1){ // ampollas de Lorenzini y narina
- vec2 q = vec2(u * 520., py * 34.), id = floor(q), f = fract(q) - .5;
+ alb *= 1. - .55 * exp(-pow((ed - .0062) / .0014, 2.)) - .18 * exp(-pow((ed - .0075) / .004, 2.)); // párpado y cuenca
+ h -= .5 * exp(-pow(ed / .0095, 2.)) - .25 * exp(-pow((ed - .0102) / .0022, 2.)); // órbita hundida con reborde suave
+ if (u < .11){ // ampollas de Lorenzini y narinas
+ vec2 q = vec2(u * 980., py * 64.), id = floor(q), f = fract(q) - .5;
float r = hash12(id + side * 13.);
- float pore = step(.72, r) * (1. - smoothstep(.06, .13, length(f + (vec2(hash12(id + 3.), hash12(id + 7.)) - .5) * .5)));
- float m = smoothstep(.1, .03, u) * smoothstep(1., 1.4, a);
- alb *= 1. - .35 * pore * m; h -= pore * m * .4;
- float nd = length(vec2((u - .029) / .0075, (a - 2.25) / .085));
- alb = mix(alb, vec3(.02), 1. - smoothstep(.6, 1., nd));
+ float pore = step(.66, r) * (1. - smoothstep(.07, .16, length(f + (vec2(hash12(id + 3.), hash12(id + 7.)) - .5) * .45)));
+ float m = smoothstep(.11, .035, u) * (smoothstep(.75, 1.6, a) + .35 * smoothstep(.07, .02, u));
+ m *= fade0(u * 980., py * 64.);
+ alb *= 1. - .28 * pore * m; h -= pore * m * .35;
+ // narina: hendidura oblicua por delante de la boca, con el colgajo anterior que la tapa a medias
+ vec2 nq = vec2(u, a * .034);
+ float nd = segD(nq, vec2(.021, 2.2 * .034), vec2(.037, 2.58 * .034));
+ float slit = 1. - smoothstep(.0007, .0013, nd);
+ float flap = exp(-pow((nd - .0016) / .0009, 2.)) * step(0., (nq.y - mix(2.2, 2.58, clamp((u - .021) / .016, 0., 1.)) * .034));
+ alb = mix(alb, vec3(.012, .01, .012), slit * .92); h += -1.1 * slit + .6 * flap;
}
+ // pliegue de la piel en la comisura: la línea de la boca se prolonga un poco, sin surco labial marcado
+ float fur = exp(-pow((a - 2.02) / .03, 2.)) * smoothstep(.142, .15, u) * (1. - smoothstep(.155, .166, u));
+ alb *= 1. - .25 * fur; h -= .5 * fur;
+ if (vP.w > 1.5) alb = mix(alb * .45, vec3(.36, .2, .22), .35); // pliegue de la comisura: hundido y algo rosado
float sc = 1.; // cicatrices de viejas peleas
vec2 pp = vec2(u, a * .06);
sc = min(sc, segD(pp, vec2(.31, 1.0 * .06), vec2(.37, 1.22 * .06)));
@@ -4110,7 +4167,8 @@ void main(){
float r = vQ.z;
alb = mix(vec3(.62, .2, .23), vec3(.3, .045, .06), smoothstep(.05, .55, r));
alb *= .84 + .16 * sin(r * 70. + vP.y * 3.); // pliegues transversales del paladar
- alb = mix(alb, vec3(.012, .002, .004), smoothstep(.55, .98, r));
+ alb *= 1. - .55 * smoothstep(.58, .7, r) * smoothstep(.2, .8, sin(r * 46.) * .5 + .5); // arcos branquiales en la faringe
+ alb = mix(alb, vec3(.012, .002, .004), smoothstep(.72, .99, r));
h = .5 * fbm(vec2(vP.y * 60., r * 18.)) + .35 * sin(r * 70. + vP.y * 3.); bk = .0008;
rough = .22; f0 = .03; sss = .6; ck = .1;
} else if (mat == 3){
@@ -4121,12 +4179,16 @@ void main(){
rough = .17; f0 = .05; sss = .4 + .8 * t; ck = .3;
} else {
// ojo: al morder rota hacia atrás y deja ver el tejido blanco que lo protege
- alb = mix(vec3(.01), vec3(.72, .7, .66), uEye); rough = mix(.07, .35, uEye); f0 = .06; ck = .2;
- emit = vec3(.03, .22, .15) * pow(max(dot(N, V), 0.), 5.) * .8 * (1. - uEye); // brillo del tapetum
+ float c = vP.y; // 1 en el centro, ~0,4 en el borde
+ vec3 iris = mix(vec3(.045, .055, .068), vec3(.018, .022, .03), smoothstep(.5, .8, c));
+ iris *= .85 + .3 * noise(vec2(atan(N0.y, N0.x) * 9., c * 6.)); // fibras del iris, apenas visibles
+ alb = mix(iris, vec3(.003, .003, .004), smoothstep(.86, .93, c)); // pupila
+ alb = mix(alb, vec3(.46, .44, .43), uEye); rough = mix(.09, .4, uEye); f0 = .045; ck = .15;
+ emit = vec3(.02, .12, .09) * pow(max(dot(N, V), 0.), 12.) * smoothstep(.88, .95, c) * .35 * (1. - uEye); // tapetum: solo en la pupila
}
if (bk > 0.) N = bump(N, vW, h * bk);
vec3 col = shade(alb, N, V, rough, f0, sss, ck) + emit;
- if (mat == 6 || mat == 7) col += alb * vec3(.55, .22, .22) * .5 * (mat == 6 ? 1. - smoothstep(.2, .9, vQ.z) : 1.); // luz que entra y se dispersa en la boca
+ if (mat == 6 || mat == 7 || inside) col += alb * vec3(.55, .22, .22) * .5 * (mat == 6 ? 1. - smoothstep(.2, .9, vQ.z) : inside ? 1. - smoothstep(.05, .6, vQ.z) : 1.); // luz que entra y se dispersa en la boca
if (mat == 6) col *= mix(1.1, .3, smoothstep(.15, .95, vQ.z)); // oclusión hacia la garganta
// absorción del agua por canal (Beer-Lambert) y luz dispersada
vec3 T = exp(-uSigma * length(uCam - vW));
@@ -4372,6 +4434,7 @@ const THEMES = {
const ACC = [.12, .83, .54], BPL = [.5, .78, 1];
const SUN = norm([.22, 1, .32]);
const OMEGA = TAU * .42, BITEP = 11, BITE_START = 6.4, BITE = BITE_START + 1.05; // BITE: instante de boca abierta del todo
+let DBG = null; // vista de depuración (solo con navigator.webdriver)
const st = { t: 0, mix: 0, mixTo: 0, mixV: 0, blue: 0, blueTo: 0, px: 0, py: 0, tx: 0, ty: 0 }; // el hero es siempre oscuro
/* Mordisco según Tricas (1985): elevación del hocico + descenso de la mandíbula (apertura máxima a 0,167 s),
@@ -4402,12 +4465,17 @@ function frameState(t) {
s.pos = add(mul(head, .05 * b), [0, .018 * Math.sin(t * .3), 0]);
s.M = model(s.yaw, s.pitch, s.roll, s.pos);
// cámara: ligeramente por debajo, con paralaje del puntero
- const az = .02 + st.px * .07, el = -.13 + st.py * .05, dist = NARROW ? 1.4 : 1.6;
- const tgt = [.04, NARROW ? .02 : .0, 0];
+ let az = .02 + st.px * .07, el = -.13 + st.py * .05, dist = NARROW ? 1.4 : 1.68;
+ let tgt = [.04, NARROW ? .02 : .0, 0];
+ if (DBG) { // solo pruebas automatizadas: cámara libre sobre la cabeza
+ if (DBG.pose) { s.yaw = DBG.pose[0]; s.pitch = DBG.pose[1]; s.roll = DBG.pose[2]; s.M = model(s.yaw, s.pitch, s.roll, s.pos); }
+ az = DBG.az; el = DBG.el; dist = DBG.dist; tgt = DBG.tgt;
+ if (DBG.tgtM) { const m = s.M, q = DBG.tgtM; tgt = [m[0] * q[0] + m[4] * q[1] + m[8] * q[2] + m[12], m[1] * q[0] + m[5] * q[1] + m[9] * q[2] + m[13], m[2] * q[0] + m[6] * q[1] + m[10] * q[2] + m[14]]; }
+ }
s.cam = add(tgt, [Math.sin(az) * Math.cos(el) * dist, Math.sin(el) * dist, Math.cos(az) * Math.cos(el) * dist]);
s.V = M4.look(s.cam, tgt, [0, 1, 0]);
const fov = .56, asp = W / H;
- s.shift = NARROW ? [.1, -.04] : [.34, .02];
+ s.shift = DBG ? [0, 0] : NARROW ? [.1, -.04] : [.64, .035]; // a la derecha del título: la cabeza y la boca quedan despejadas
s.P = M4.persp(fov, asp, .02, 30, s.shift[0], s.shift[1]);
s.VP = M4.mul(s.P, s.V);
s.tan = [Math.tan(fov / 2) * asp, Math.tan(fov / 2)];
@@ -4501,8 +4569,8 @@ function callouts(s) {
const pl = document.createElementNS(NS_SVG, 'polyline'); pl.setAttribute('class', 'ld');
const rc = document.createElementNS(NS_SVG, 'rect'); rc.setAttribute('class', 'plate'); rc.setAttribute('rx', 6);
const dt = document.createElementNS(NS_SVG, 'circle'); dt.setAttribute('class', 'dot'); dt.setAttribute('r', 3);
- const t1 = document.createElementNS(NS_SVG, 'text'); t1.setAttribute('class', 'k'); t1.textContent = (LANG === 'en' ? a.te : a.t)[0];
- const t2 = document.createElementNS(NS_SVG, 'text'); t2.textContent = (LANG === 'en' ? a.te : a.t)[1];
+ const t1 = document.createElementNS(NS_SVG, 'text'); t1.setAttribute('class', 'k'); t1.textContent = ((LANG === 'en' && a.te) || a.t)[0];
+ const t2 = document.createElementNS(NS_SVG, 'text'); t2.textContent = ((LANG === 'en' && a.te) || a.t)[1];
g.append(pl, rc, dt, t1, t2); svg.append(g);
return { a, g, pl, rc, dt, t1, t2, w: 0 };
});
@@ -4572,7 +4640,7 @@ function ensureGL() {
gl = cv.getContext('webgl2', { antialias: false, alpha: false, depth: false, stencil: false, powerPreference: 'high-performance', preserveDrawingBuffer: false });
if (!gl) return (glOk = false);
try {
- if (!geoReady) { buildBody(); buildMouth(); buildFins(); buildTeeth(); buildEyes(); geoReady = true; }
+ if (!geoReady) { buildBody(); buildMouth(); buildCorners(); buildFins(); buildTeeth(); buildEyes(); geoReady = true; }
initGL();
} catch (err) { console.error(err); gl = null; return (glOk = false); }
cv.addEventListener('webglcontextlost', e => { e.preventDefault(); stop(); });
@@ -4631,6 +4699,7 @@ return {
seek(t) { stop(); st.t = clock = t; settle(); },
pause() { paused = true; stop(); },
setMode(m) { st.blueTo = m === 'blue' ? 1 : 0; settle(); },
+ debugView(o) { if (navigator.webdriver) { DBG = o; settle(); } },
stats: () => ({ vertices: VB.length / STRIDE, triangles: IB.length / 3, hdr, quality, running }),
};
})();
diff --git a/package.json b/package.json
index 92c8309..bfca960 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "megalodon",
- "version": "1.3.0",
+ "version": "1.3.1",
"description": "Laboratorio de Wireshark sin conexión: capturas sintéticas de un pentest, filtros validados al instante y retos guiados.",
"author": "Yoandy Ramírez Delgado",
"license": "MIT",
diff --git a/scripts/capturas.mjs b/scripts/capturas.mjs
index d921917..47a8736 100644
--- a/scripts/capturas.mjs
+++ b/scripts/capturas.mjs
@@ -8,8 +8,8 @@ const URL0 = 'file://' + fileURLToPath(new URL('../dist/index.html', import.meta
const OUT = fileURLToPath(new URL('../docs/capturas/', import.meta.url));
const SHOTS = [
{ f: 'inicio-oscuro', w: 1280, h: 800, t: 7.45 },
- { f: 'mordisco', w: 1280, h: 800, t: 7.45, clip: { x: 575, y: 70, width: 400, height: 300 }, dsf: 2 },
- { f: 'protrusion', w: 1280, h: 800, t: 8.6, clip: { x: 575, y: 70, width: 400, height: 300 }, dsf: 2 },
+ { f: 'mordisco', w: 1280, h: 800, t: 7.45, clip: { x: 735, y: 60, width: 400, height: 300 }, dsf: 2 },
+ { f: 'protrusion', w: 1280, h: 800, t: 8.6, clip: { x: 735, y: 60, width: 400, height: 300 }, dsf: 2 },
{ f: 'plano-tecnico', w: 1280, h: 800, t: 5, mode: 'blue' },
{ f: 'inicio-claro', w: 1280, h: 800, t: 3, theme: 'light', full: true },
{ f: 'movil', w: 390, h: 844, t: 7.45 },
diff --git a/src/app/48-shark.js b/src/app/48-shark.js
index 00792c1..563b26d 100644
--- a/src/app/48-shark.js
+++ b/src/app/48-shark.js
@@ -35,9 +35,9 @@ function curve(us, vs) { // Hermite con tangen
}
// Perfil lamniforme: hocico cónico, tronco fusiforme alto, pedúnculo estrecho con quilla lateral.
const U = [0, .008, .025, .05, .09, .14, .2, .28, .36, .46, .58, .7, .8, .87, .925];
-const HT = curve(U, [0, .011, .025, .04, .056, .072, .086, .098, .103, .098, .078, .05, .028, .016, .011]);
-const HB = curve(U, [0, .008, .02, .033, .049, .067, .083, .096, .099, .092, .07, .043, .024, .013, .009]);
-const WD = curve(U, [0, .011, .026, .041, .057, .072, .084, .093, .095, .088, .068, .044, .026, .016, .011]);
+const HT = curve(U, [0, .0155, .03, .0445, .0585, .072, .086, .098, .103, .098, .078, .05, .028, .016, .011]);
+const HB = curve(U, [0, .0125, .026, .0405, .0555, .0715, .083, .096, .099, .092, .07, .043, .024, .013, .009]);
+const WD = curve(U, [0, .015, .0305, .0445, .0585, .072, .084, .093, .095, .088, .068, .044, .026, .016, .011]);
const ZC = u => .009 * Math.pow(Math.max(0, 1 - u / .22), 2) - .005 * Math.exp(-(((u - .42) / .22) ** 2));
const KEEL = u => .0042 * sstep(.8, .865, u);
const sgnpow = (v, e) => Math.sign(v) * Math.pow(Math.abs(v), e);
@@ -183,19 +183,22 @@ const protW = t => 1 - Math.pow(Math.abs(t), 1.6) * .85; // el frente del pala
// Marco local del arco: T a lo largo del labio, In hacia dentro de la cabeza (contra la normal de la piel),
// Dup sobre la piel, perpendicular al labio y hacia la mandíbula superior.
function archFrame(t) {
+ // Las mandíbulas se cierran en vertical: los dientes de arriba cuelgan y los de abajo se alzan, y se cruzan en
+ // la línea de la boca. Por eso el marco usa la vertical de la cabeza (Up) y la horizontal hacia dentro (In),
+ // no la normal de la piel: bajo el hocico la piel es horizontal y los dientes saldrían hacia delante.
t = clamp(t, -1, 1);
- const P = archLip(t), e = .004, u = archU(t), sd = t < 0 ? -1 : 1;
+ const P = archLip(t), e = .004, u = archU(t);
const T = norm(sub(archLip(Math.min(1, t + e)), archLip(Math.max(-1, t - e))));
- const n = u <= UF + 1e-6 ? [0, -1, 0] : bodyNormal(u, sd * phiM(u));
- let In = mul(n, -1); In = norm(sub(In, mul(T, dot(In, T))));
- let Dup = norm(cross(T, In));
- // hacia la mandíbula superior: un poco más adelante y por encima de la línea de la boca
- const toUp = sub(bodyPt(Math.max(0, u - .008), sd * Math.max(0, phiM(u) - .12)), P);
- if (dot(Dup, toUp) < 0) Dup = mul(Dup, -1);
- return { P, T, In, Dup, Up: Dup, u };
+ let Up = sub([0, 1, 0], mul(T, T[1])); Up = norm(Up);
+ let v = sub([P[0] - .035, ZC(u), 0], P); // hacia el eje, un poco hacia atrás (la garganta)
+ v = sub(v, add(mul(T, dot(v, T)), mul(Up, dot(v, Up))));
+ const In = Math.hypot(...v) > 1e-6 ? norm(v) : [-1, 0, 0];
+ const Out = mul(In, -1);
+ return { P, T, In, Dup: Up, Up, Out, u, front: 1 - Math.abs(t) };
}
-const gumCenter = (f, lower) => add(add(f.P, mul(f.In, GUM.rh * 1.25)), mul(f.Dup, (lower ? -1 : 1) * GUM.rv * .42));
-const gumPt = (f, lower, a, k = 1) => add(add(gumCenter(f, lower), mul(f.In, GUM.rh * Math.cos(a) * k)), mul(f.Dup, GUM.rv * Math.sin(a) * k));
+const gumTaper = u => 1 - sstep(UC - .016, UC + .002, u); // la encía se afina y se cierra en la comisura
+const gumCenter = (f, lower) => add(add(f.P, mul(f.In, GUM.rh * (lower ? 2.15 : 1.45))), mul(f.Dup, (lower ? -1 : 1) * GUM.rv * (lower ? .02 - .45 * f.front ** 2 : .35))); // delante el mentón se curva: la encía sube
+const gumPt = (f, lower, a, k = 1) => { const g = k * (.15 + .85 * gumTaper(f.u)); return add(add(gumCenter(f, lower), mul(f.In, GUM.rh * Math.cos(a) * g)), mul(f.Dup, GUM.rv * Math.sin(a) * g)); };
function buildMouth() {
const NT = 121, NA = 28, NR = 22;
@@ -205,18 +208,18 @@ function buildMouth() {
// 1) encía: tubo elíptico a lo largo del arco
const g = frames.map((f, i) => Array.from({ length: NA + 1 }, (_, j) => {
const a = TAU * j / NA, p = gumPt(f, lower, a);
- const n = norm(add(mul(f.In, Math.cos(a) / GUM.rh), mul(f.Up, Math.sin(a) / GUM.rv)));
+ const n = norm(add(mul(f.In, Math.cos(a) / GUM.rh), mul(f.Dup, Math.sin(a) / GUM.rv)));
return vert(p, n, [f.u, -1 + 2 * i / (NT - 1), j / NA, 0], [w, up * protW(-1 + 2 * i / (NT - 1)), 0, 0], 7);
}));
for (let i = 0; i < NT - 1; i++) for (let j = 0; j < NA; j++) { tri(g[i][j], g[i + 1][j], g[i + 1][j + 1]); tri(g[i][j], g[i + 1][j + 1], g[i][j + 1]); }
// 2) paladar (arriba) o suelo con lengua (abajo): del borde interno de la encía a la garganta
const uTh = UC + .035, cT = center(uTh);
- const throat = [.5 - uTh, lower ? cT[1] - .5 * HB(uTh) : cT[1] + .3 * HT(uTh), 0];
+ const throat = [.5 - uTh, lower ? cT[1] - .72 * HB(uTh) : cT[1] + .3 * HT(uTh), 0]; // el suelo baja hacia la faringe
const ref = lower ? [0, 1, 0] : [0, -1, 0]; // normales hacia el interior de la boca
const S = (i, r) => {
const f = frames[i], tt = -1 + 2 * i / (NT - 1), e0 = gumPt(f, lower, 0), rr = Math.pow(r, .85);
const p = lerp3(e0, throat, rr);
- const vault = lower ? .0055 * Math.sin(Math.PI * r) * (1 - tt * tt) - .006 * Math.sin(Math.PI * r) * Math.abs(tt)
+ const vault = lower ? -.0055 * Math.sin(Math.PI * r) * (1 - .5 * tt * tt) + .0042 * Math.exp(-(((r - .22) / .13) ** 2)) * (1 - tt * tt) ** 2 // suelo cóncavo con el basihial delante
: .011 * Math.sin(Math.PI * r) * Math.sqrt(Math.max(0, 1 - tt * tt));
return add(p, [0, vault, 0]);
};
@@ -235,6 +238,34 @@ function buildMouth() {
}
}
+/* Comisura: pliegue de piel entre los labios. Cerrada no tiene área; al abrir, cada fila gira con su peso
+ de mandíbula (0 arriba, 1 abajo) y la membrana se tensa como en el animal, sin dejar ver el vacío. */
+function buildCorners() {
+ const NT = 16, NK = 10, T0 = .84;
+ for (const sd of [1, -1]) {
+ const rows = [];
+ for (let i = 0; i <= NT; i++) {
+ const tt = T0 + (1 - T0) * i / NT, f = archFrame(sd * tt), d = (tt - T0) / (1 - T0);
+ const base = add(f.P, mul(f.In, GUM.rh * (.7 + .6 * (1 - d)))); // por dentro del labio: queda en sombra
+ const row = [];
+ for (let k = 0; k <= NK; k++) {
+ const w = k / NK, sag = .0042 * Math.sin(Math.PI * w) * (1 - .6 * d); // la membrana se comba hacia dentro
+ const p = add(base, mul(f.In, sag));
+ const nrm = norm(add(f.Out, mul(f.In, .55 * Math.cos(Math.PI * w))));
+ row.push(vert(p, nrm, [f.u, sd * phiM(f.u), 0, 2], [w, 0, .02 + .25 * Math.sin(Math.PI * w), 0], 0)); // P.w = 2: pliegue de la comisura
+ }
+ rows.push(row);
+ }
+ // cerrada no tiene área: el sentido de cada triángulo se decide con la boca abierta (giro de la bisagra en JS)
+ const opened = i => { const q = vpos(i), w = VB[i * STRIDE + 10], ang = .6 * w, c = Math.cos(ang), sn = Math.sin(ang), dx = q[0] - HINGE[0], dy = q[1] - HINGE[1]; return [HINGE[0] + c * dx + sn * dy, HINGE[1] - sn * dx + c * dy, q[2]]; };
+ const triO = (a, b, c) => { const g = cross(sub(opened(b), opened(a)), sub(opened(c), opened(a))); if (dot(g, vnrm(a)) < 0) IB.push(a, c, b); else IB.push(a, b, c); };
+ for (let i = 0; i < NT; i++) for (let k = 0; k < NK; k++) {
+ const a = rows[i][k], b = rows[i + 1][k], c = rows[i + 1][k + 1], d = rows[i][k + 1];
+ triO(a, b, c); triO(a, c, d);
+ }
+ }
+}
+
/* Diente: corona triangular con bordes convexos y aserrados, raíz hundida en la encía. */
function tooth(base, A, T, h, b, jawW, lipUp, u, slant, narrow) {
const N = norm(cross(T, A)), K = 11, o = [];
@@ -280,12 +311,13 @@ function buildTeeth() {
const fr = archFrame(t), dist = mul(fr.T, sd); // hacia la comisura
for (const row of [0, 1]) {
const a = lower ? (row ? Math.PI / 2 - .75 : Math.PI / 2 + .5) : (row ? -Math.PI / 2 + .75 : -Math.PI / 2 - .5);
- const base = gumPt(fr, lower, a, .82);
- let A = norm(add(add(mul(fr.Dup, lower ? .6 : -.85), [0, lower ? .75 : -.5, 0]), mul(fr.In, -.1))); // hacia la otra mandíbula, algo hacia fuera
- if (row) A = norm(add(mul(A, .45), mul(fr.In, 1))); // reemplazo: tumbado hacia dentro
+ const base = gumPt(fr, lower, a, row ? .45 : .82); // el reemplazo nace hundido en la encía
+ const front = 1 - Math.abs(t); // 1 delante, 0 en la comisura
+ let A = norm(add(mul(fr.Dup, lower ? 1 : -1), mul(fr.Out, lower ? .08 + .06 * front : .14 + .04 * front))); // hacia la otra mandíbula, algo hacia fuera
+ if (row) A = norm(add(mul(A, .3), mul(fr.In, 1))); // reemplazo: tumbado hacia dentro, casi oculto // reemplazo: tumbado hacia dentro
A = norm(sub(A, mul(dist, dot(A, dist))));
A = norm(add(A, mul(fr.In, rnd() * .1)));
- const sc = (row ? .74 : 1) * (1 + rnd() * .08);
+ const sc = (row ? .6 : 1) * (1 + rnd() * .08);
const bw = slot * (lower ? .68 : .97) * sc, h = bw * (lower ? 1.95 : 1.42) * (k === 2 && !lower ? .92 : 1);
const slant = lower ? .02 + .1 * k / prof.length : .02 + .5 * Math.pow(k / prof.length, 1.2);
tooth(base, A, dist, h, bw, lower ? 1 : 0, lower ? 0 : protW(t), fr.u, slant, lower);
@@ -294,11 +326,21 @@ function buildTeeth() {
}
}
function buildEyes() {
- const r = .0064;
+ const r = .0061, rN = r * .62; // casquete aplanado: apenas sobresale de la órbita
for (const sd of [1, -1]) {
- const S = bodyPt(.088, sd * 1.03), n0 = bodyNormal(.088, sd * 1.03), C = sub(S, mul(n0, r * .42));
- const NA = 18, NB = 12, g = [];
- for (let i = 0; i <= NB; i++) { const row = [], th = Math.PI * i / NB; for (let j = 0; j <= NA; j++) { const ph = TAU * j / NA, n = [Math.sin(th) * Math.cos(ph), Math.cos(th), Math.sin(th) * Math.sin(ph)]; row.push(vert(add(C, mul(n, r)), n, [.088, 0, 0, 0], [0, 0, 9, 0], 4)); } g.push(row); }
+ const S = bodyPt(.088, sd * 1.03), n0 = bodyNormal(.088, sd * 1.03), C = sub(S, mul(n0, rN * .5));
+ let t1 = norm(cross(n0, [0, 1, 0])); const t2 = cross(n0, t1);
+ const NA = 28, NB = 14, g = [];
+ for (let i = 0; i <= NB; i++) {
+ const row = [], th = Math.PI * .62 * i / NB; // solo la parte que asoma
+ for (let j = 0; j <= NA; j++) {
+ const ph = TAU * j / NA, rad = add(mul(t1, Math.cos(ph)), mul(t2, Math.sin(ph)));
+ const p = add(add(C, mul(n0, Math.cos(th) * rN)), mul(rad, Math.sin(th) * r));
+ const n = norm(add(mul(n0, Math.cos(th) / rN), mul(rad, Math.sin(th) / r)));
+ row.push(vert(p, n, [.088, Math.cos(th), 0, 0], [0, 0, 9, 0], 4));
+ }
+ g.push(row);
+ }
for (let i = 0; i < NB; i++) for (let j = 0; j < NA; j++) { tri(g[i][j], g[i + 1][j], g[i + 1][j + 1]); tri(g[i][j], g[i + 1][j + 1], g[i][j + 1]); }
}
}
@@ -307,8 +349,9 @@ function buildEyes() {
/* Puntos anatómicos para las cotas del plano técnico (posición en reposo + peso de mandíbula) */
const tD0 = u => ZC(u) + HT(u);
const ANCHORS = [
- { id: 'hoc', p: bodyPt(.03, 1.75), w: 0, t: ['Hocico', 'ampollas de Lorenzini'] },
- { id: 'ojo', p: bodyPt(.088, 1.03), w: 0, t: ['Ojo', 'tapetum lucidum'] },
+ { id: 'nar', p: bodyPt(.03, 2.4), w: 0, t: ['Narina', 'olfato direccional'], te: ['Nostril', 'directional smell'] },
+ { id: 'hoc', p: bodyPt(.03, 1.75), w: 0, t: ['Hocico', 'ampollas de Lorenzini'], te: ['Snout', 'ampullae of Lorenzini'] },
+ { id: 'ojo', p: bodyPt(.088, 1.03), w: 0, t: ['Ojo', 'tapetum lucidum'], te: ['Eye', 'tapetum lucidum'] },
{ id: 'die', p: lerp3(bodyPt(.1, phiM(.1)), center(.1), .1), w: 1, t: ['Dientes aserrados', '2 filas · reemplazo continuo'], te: ['Serrated teeth', '2 rows · constant replacement'] },
{ id: 'bra', p: bodyPt(.215, 1.45), w: 0, t: ['Hendiduras branquiales', '5 por lado'], te: ['Gill slits', '5 per side'] },
{ id: 'dor', p: [X(.445), tD0(.445) + .122, 0], w: 0, t: ['Primera dorsal', 'estabiliza el balanceo'], te: ['First dorsal', 'steadies the roll'] },
@@ -414,6 +457,7 @@ vec3 bump(vec3 N, vec3 pos, float h){
vec3 g = sign(det) * (dhx * r1 + dhy * r2);
return normalize(abs(det) * N - g);
}
+float fade0(float x, float y){ return 1. - clamp(max(fwidth(x), fwidth(y)) * .9, 0., 1.); }
float line(float x, float w){ float f = abs(fract(x - .5) - .5), d = fwidth(x); return 1. - smoothstep(w * d, (w + 1.2) * d, f); }
float segD(vec2 p, vec2 a, vec2 b){ vec2 pa = p - a, ba = b - a; float h = clamp(dot(pa, ba) / dot(ba, ba), 0., 1.); return length(pa - ba * h); }
float gills(float u, float a, out float h){
@@ -461,7 +505,10 @@ void main(){
bool inside = !gl_FrontFacing && mat == 0;
if (!gl_FrontFacing) N = -N;
if (mat == 0 && inside){ // interior de la boca: encía y paladar
- alb = vec3(.025, .006, .009); rough = .4; ck = 0.;
+ float dl = clamp(vQ.z, 0., 3.); // distancia angular al labio
+ alb = mix(vec3(.46, .17, .19), vec3(.05, .012, .016), smoothstep(.04, .7, dl));
+ alb *= .85 + .3 * fbm(vec2(u * 90., dl * 12.));
+ rough = .28; f0 = .03; sss = .5; ck = .15;
} else if (mat == 0){
float py = mod(vP.y + 3.14159265, 6.2831853) - 3.14159265; // ángulo envuelto por fragmento
float a = abs(py), side = py < 0. ? -1. : 1.;
@@ -480,16 +527,26 @@ void main(){
alb = mix(alb, vec3(.025, .015, .02), g); h += gh;
vec2 ep = vec2(u - .088, (a - 1.03) * .058); // cuenca del ojo
float ed = length(ep);
- alb *= 1. - .4 * exp(-pow((ed - .0088) / .003, 2.)); h += .6 * exp(-pow((ed - .009) / .0035, 2.));
- if (u < .1){ // ampollas de Lorenzini y narina
- vec2 q = vec2(u * 520., py * 34.), id = floor(q), f = fract(q) - .5;
+ alb *= 1. - .55 * exp(-pow((ed - .0062) / .0014, 2.)) - .18 * exp(-pow((ed - .0075) / .004, 2.)); // párpado y cuenca
+ h -= .5 * exp(-pow(ed / .0095, 2.)) - .25 * exp(-pow((ed - .0102) / .0022, 2.)); // órbita hundida con reborde suave
+ if (u < .11){ // ampollas de Lorenzini y narinas
+ vec2 q = vec2(u * 980., py * 64.), id = floor(q), f = fract(q) - .5;
float r = hash12(id + side * 13.);
- float pore = step(.72, r) * (1. - smoothstep(.06, .13, length(f + (vec2(hash12(id + 3.), hash12(id + 7.)) - .5) * .5)));
- float m = smoothstep(.1, .03, u) * smoothstep(1., 1.4, a);
- alb *= 1. - .35 * pore * m; h -= pore * m * .4;
- float nd = length(vec2((u - .029) / .0075, (a - 2.25) / .085));
- alb = mix(alb, vec3(.02), 1. - smoothstep(.6, 1., nd));
+ float pore = step(.66, r) * (1. - smoothstep(.07, .16, length(f + (vec2(hash12(id + 3.), hash12(id + 7.)) - .5) * .45)));
+ float m = smoothstep(.11, .035, u) * (smoothstep(.75, 1.6, a) + .35 * smoothstep(.07, .02, u));
+ m *= fade0(u * 980., py * 64.);
+ alb *= 1. - .28 * pore * m; h -= pore * m * .35;
+ // narina: hendidura oblicua por delante de la boca, con el colgajo anterior que la tapa a medias
+ vec2 nq = vec2(u, a * .034);
+ float nd = segD(nq, vec2(.021, 2.2 * .034), vec2(.037, 2.58 * .034));
+ float slit = 1. - smoothstep(.0007, .0013, nd);
+ float flap = exp(-pow((nd - .0016) / .0009, 2.)) * step(0., (nq.y - mix(2.2, 2.58, clamp((u - .021) / .016, 0., 1.)) * .034));
+ alb = mix(alb, vec3(.012, .01, .012), slit * .92); h += -1.1 * slit + .6 * flap;
}
+ // pliegue de la piel en la comisura: la línea de la boca se prolonga un poco, sin surco labial marcado
+ float fur = exp(-pow((a - 2.02) / .03, 2.)) * smoothstep(.142, .15, u) * (1. - smoothstep(.155, .166, u));
+ alb *= 1. - .25 * fur; h -= .5 * fur;
+ if (vP.w > 1.5) alb = mix(alb * .45, vec3(.36, .2, .22), .35); // pliegue de la comisura: hundido y algo rosado
float sc = 1.; // cicatrices de viejas peleas
vec2 pp = vec2(u, a * .06);
sc = min(sc, segD(pp, vec2(.31, 1.0 * .06), vec2(.37, 1.22 * .06)));
@@ -525,7 +582,8 @@ void main(){
float r = vQ.z;
alb = mix(vec3(.62, .2, .23), vec3(.3, .045, .06), smoothstep(.05, .55, r));
alb *= .84 + .16 * sin(r * 70. + vP.y * 3.); // pliegues transversales del paladar
- alb = mix(alb, vec3(.012, .002, .004), smoothstep(.55, .98, r));
+ alb *= 1. - .55 * smoothstep(.58, .7, r) * smoothstep(.2, .8, sin(r * 46.) * .5 + .5); // arcos branquiales en la faringe
+ alb = mix(alb, vec3(.012, .002, .004), smoothstep(.72, .99, r));
h = .5 * fbm(vec2(vP.y * 60., r * 18.)) + .35 * sin(r * 70. + vP.y * 3.); bk = .0008;
rough = .22; f0 = .03; sss = .6; ck = .1;
} else if (mat == 3){
@@ -536,12 +594,16 @@ void main(){
rough = .17; f0 = .05; sss = .4 + .8 * t; ck = .3;
} else {
// ojo: al morder rota hacia atrás y deja ver el tejido blanco que lo protege
- alb = mix(vec3(.01), vec3(.72, .7, .66), uEye); rough = mix(.07, .35, uEye); f0 = .06; ck = .2;
- emit = vec3(.03, .22, .15) * pow(max(dot(N, V), 0.), 5.) * .8 * (1. - uEye); // brillo del tapetum
+ float c = vP.y; // 1 en el centro, ~0,4 en el borde
+ vec3 iris = mix(vec3(.045, .055, .068), vec3(.018, .022, .03), smoothstep(.5, .8, c));
+ iris *= .85 + .3 * noise(vec2(atan(N0.y, N0.x) * 9., c * 6.)); // fibras del iris, apenas visibles
+ alb = mix(iris, vec3(.003, .003, .004), smoothstep(.86, .93, c)); // pupila
+ alb = mix(alb, vec3(.46, .44, .43), uEye); rough = mix(.09, .4, uEye); f0 = .045; ck = .15;
+ emit = vec3(.02, .12, .09) * pow(max(dot(N, V), 0.), 12.) * smoothstep(.88, .95, c) * .35 * (1. - uEye); // tapetum: solo en la pupila
}
if (bk > 0.) N = bump(N, vW, h * bk);
vec3 col = shade(alb, N, V, rough, f0, sss, ck) + emit;
- if (mat == 6 || mat == 7) col += alb * vec3(.55, .22, .22) * .5 * (mat == 6 ? 1. - smoothstep(.2, .9, vQ.z) : 1.); // luz que entra y se dispersa en la boca
+ if (mat == 6 || mat == 7 || inside) col += alb * vec3(.55, .22, .22) * .5 * (mat == 6 ? 1. - smoothstep(.2, .9, vQ.z) : inside ? 1. - smoothstep(.05, .6, vQ.z) : 1.); // luz que entra y se dispersa en la boca
if (mat == 6) col *= mix(1.1, .3, smoothstep(.15, .95, vQ.z)); // oclusión hacia la garganta
// absorción del agua por canal (Beer-Lambert) y luz dispersada
vec3 T = exp(-uSigma * length(uCam - vW));
@@ -787,6 +849,7 @@ const THEMES = {
const ACC = [.12, .83, .54], BPL = [.5, .78, 1];
const SUN = norm([.22, 1, .32]);
const OMEGA = TAU * .42, BITEP = 11, BITE_START = 6.4, BITE = BITE_START + 1.05; // BITE: instante de boca abierta del todo
+let DBG = null; // vista de depuración (solo con navigator.webdriver)
const st = { t: 0, mix: 0, mixTo: 0, mixV: 0, blue: 0, blueTo: 0, px: 0, py: 0, tx: 0, ty: 0 }; // el hero es siempre oscuro
/* Mordisco según Tricas (1985): elevación del hocico + descenso de la mandíbula (apertura máxima a 0,167 s),
@@ -817,12 +880,17 @@ function frameState(t) {
s.pos = add(mul(head, .05 * b), [0, .018 * Math.sin(t * .3), 0]);
s.M = model(s.yaw, s.pitch, s.roll, s.pos);
// cámara: ligeramente por debajo, con paralaje del puntero
- const az = .02 + st.px * .07, el = -.13 + st.py * .05, dist = NARROW ? 1.4 : 1.6;
- const tgt = [.04, NARROW ? .02 : .0, 0];
+ let az = .02 + st.px * .07, el = -.13 + st.py * .05, dist = NARROW ? 1.4 : 1.68;
+ let tgt = [.04, NARROW ? .02 : .0, 0];
+ if (DBG) { // solo pruebas automatizadas: cámara libre sobre la cabeza
+ if (DBG.pose) { s.yaw = DBG.pose[0]; s.pitch = DBG.pose[1]; s.roll = DBG.pose[2]; s.M = model(s.yaw, s.pitch, s.roll, s.pos); }
+ az = DBG.az; el = DBG.el; dist = DBG.dist; tgt = DBG.tgt;
+ if (DBG.tgtM) { const m = s.M, q = DBG.tgtM; tgt = [m[0] * q[0] + m[4] * q[1] + m[8] * q[2] + m[12], m[1] * q[0] + m[5] * q[1] + m[9] * q[2] + m[13], m[2] * q[0] + m[6] * q[1] + m[10] * q[2] + m[14]]; }
+ }
s.cam = add(tgt, [Math.sin(az) * Math.cos(el) * dist, Math.sin(el) * dist, Math.cos(az) * Math.cos(el) * dist]);
s.V = M4.look(s.cam, tgt, [0, 1, 0]);
const fov = .56, asp = W / H;
- s.shift = NARROW ? [.1, -.04] : [.34, .02];
+ s.shift = DBG ? [0, 0] : NARROW ? [.1, -.04] : [.64, .035]; // a la derecha del título: la cabeza y la boca quedan despejadas
s.P = M4.persp(fov, asp, .02, 30, s.shift[0], s.shift[1]);
s.VP = M4.mul(s.P, s.V);
s.tan = [Math.tan(fov / 2) * asp, Math.tan(fov / 2)];
@@ -916,8 +984,8 @@ function callouts(s) {
const pl = document.createElementNS(NS_SVG, 'polyline'); pl.setAttribute('class', 'ld');
const rc = document.createElementNS(NS_SVG, 'rect'); rc.setAttribute('class', 'plate'); rc.setAttribute('rx', 6);
const dt = document.createElementNS(NS_SVG, 'circle'); dt.setAttribute('class', 'dot'); dt.setAttribute('r', 3);
- const t1 = document.createElementNS(NS_SVG, 'text'); t1.setAttribute('class', 'k'); t1.textContent = (LANG === 'en' ? a.te : a.t)[0];
- const t2 = document.createElementNS(NS_SVG, 'text'); t2.textContent = (LANG === 'en' ? a.te : a.t)[1];
+ const t1 = document.createElementNS(NS_SVG, 'text'); t1.setAttribute('class', 'k'); t1.textContent = ((LANG === 'en' && a.te) || a.t)[0];
+ const t2 = document.createElementNS(NS_SVG, 'text'); t2.textContent = ((LANG === 'en' && a.te) || a.t)[1];
g.append(pl, rc, dt, t1, t2); svg.append(g);
return { a, g, pl, rc, dt, t1, t2, w: 0 };
});
@@ -987,7 +1055,7 @@ function ensureGL() {
gl = cv.getContext('webgl2', { antialias: false, alpha: false, depth: false, stencil: false, powerPreference: 'high-performance', preserveDrawingBuffer: false });
if (!gl) return (glOk = false);
try {
- if (!geoReady) { buildBody(); buildMouth(); buildFins(); buildTeeth(); buildEyes(); geoReady = true; }
+ if (!geoReady) { buildBody(); buildMouth(); buildCorners(); buildFins(); buildTeeth(); buildEyes(); geoReady = true; }
initGL();
} catch (err) { console.error(err); gl = null; return (glOk = false); }
cv.addEventListener('webglcontextlost', e => { e.preventDefault(); stop(); });
@@ -1046,6 +1114,7 @@ return {
seek(t) { stop(); st.t = clock = t; settle(); },
pause() { paused = true; stop(); },
setMode(m) { st.blueTo = m === 'blue' ? 1 : 0; settle(); },
+ debugView(o) { if (navigator.webdriver) { DBG = o; settle(); } },
stats: () => ({ vertices: VB.length / STRIDE, triangles: IB.length / 3, hdr, quality, running }),
};
})();
diff --git a/tests/e2e.mjs b/tests/e2e.mjs
index 9d75012..1a4bbda 100644
--- a/tests/e2e.mjs
+++ b/tests/e2e.mjs
@@ -69,12 +69,47 @@ await t('megalodón: pausa accesible y vista de plano técnico con cotas', async
assert(!(await p.evaluate(() => SHARK.stats().running)), 'se detiene');
await p.click('[data-shark-mode]');
assert(await p.getAttribute('[data-shark-mode]', 'aria-pressed') === 'true', 'aria-pressed');
- await p.waitForFunction(() => document.querySelectorAll('.shark-callouts g').length === 8);
+ await p.waitForFunction(() => document.querySelectorAll('.shark-callouts g').length === 9);
const labels = await p.$$eval('.shark-callouts text.k', ns => ns.map(n => n.textContent));
- assert(labels.includes('Dientes aserrados') && labels.includes('Hendiduras branquiales'), labels.join(', '));
+ assert(['Dientes aserrados', 'Hendiduras branquiales', 'Narina', 'Ojo'].every(l => labels.includes(l)), labels.join(', '));
+ assert(!p.errors.length, p.errors.join(' | '));
+ await p.close2();
+});
+
+await t('megalodón: el plano técnico en inglés rotula todas las cotas sin errores', async () => {
+ const p = await page(browser);
+ await p.waitForSelector('[data-shark-pause]');
+ await p.click('[data-lang="en"]');
+ await p.waitForSelector('[data-shark-mode]');
+ await p.evaluate(() => SHARK.pause());
+ await p.click('[data-shark-mode]');
+ await p.waitForFunction(() => document.querySelectorAll('.shark-callouts g').length === 9);
+ const labels = await p.$$eval('.shark-callouts text', ns => ns.map(n => n.textContent));
+ assert(['Snout', 'Eye', 'Nostril', 'Serrated teeth', 'Gill slits'].every(l => labels.includes(l)), labels.join(', '));
+ assert(labels.every(l => l && !/[áéíóúñ]/.test(l)), `restos en español: ${labels.join(', ')}`);
+ assert(!p.errors.length, p.errors.join(' | '));
await p.close2();
});
+await t('megalodón: la cabeza queda a la derecha del título, sin taparse', async () => {
+ for (const w of [1280, 1440, 1920]) {
+ const p = await page(browser, { viewport: { width: w, height: Math.round(w * .62) } });
+ await p.waitForSelector('canvas.shark-cv');
+ await p.evaluate(() => { SHARK.pause(); SHARK.seek(7.45); });
+ // la cota del ojo da la posición real de la cabeza en pantalla
+ await p.click('[data-shark-mode]');
+ await p.waitForFunction(() => document.querySelectorAll('.shark-callouts g').length === 9);
+ await p.waitForTimeout(200);
+ const r = await p.evaluate(() => {
+ const t = document.querySelector('#hero-t').getBoundingClientRect(), dot = [...document.querySelectorAll('.shark-callouts .dot')].map(d => d.getBoundingClientRect());
+ const svg = document.querySelector('.shark-callouts').getBoundingClientRect();
+ return { titleRight: t.right, minDot: Math.min(...dot.map(d => d.left)), svgRight: svg.right };
+ });
+ assert(r.minDot > r.titleRight - 40, `${w}px: la cabeza (${Math.round(r.minDot)}) queda bajo el título (${Math.round(r.titleRight)})`);
+ await p.close2();
+ }
+});
+
await t('megalodón: se desmonta al salir de inicio y vuelve al regresar', async () => {
const p = await page(browser);
await p.waitForSelector('canvas.shark-cv');