Template
Fix/404 tux pattes #3
No files matched your search
@@ -41,17 +41,27 @@ $extraJs[] = fws_url('/p/assets/js/not-found.js');
|
||||
<stop offset="0" stop-color="rgba(56,189,248,0.15)" />
|
||||
<stop offset="1" stop-color="rgba(56,189,248,0)" />
|
||||
</radialGradient>
|
||||
<radialGradient id="nf-ground-shadow" cx="50%" cy="50%" r="50%">
|
||||
<stop offset="0" stop-color="rgba(3,7,15,0.55)" />
|
||||
<stop offset="0.55" stop-color="rgba(3,7,15,0.26)" />
|
||||
<stop offset="1" stop-color="rgba(3,7,15,0)" />
|
||||
</radialGradient>
|
||||
<radialGradient id="nf-tux-glow" cx="50%" cy="50%" r="50%">
|
||||
<stop offset="0" stop-color="rgba(125,211,252,0.22)" />
|
||||
<stop offset="1" stop-color="rgba(125,211,252,0)" />
|
||||
</radialGradient>
|
||||
<linearGradient id="nf-body" x1="0.15" y1="0" x2="0.9" y2="1">
|
||||
<stop offset="0" stop-color="#33405a" />
|
||||
<stop offset="1" stop-color="#151d2b" />
|
||||
<linearGradient id="nf-body" gradientUnits="userSpaceOnUse" x1="140" y1="96" x2="300" y2="370">
|
||||
<stop offset="0" stop-color="#26334a" />
|
||||
<stop offset="0.5" stop-color="#0d1420" />
|
||||
<stop offset="1" stop-color="#05080e" />
|
||||
</linearGradient>
|
||||
<linearGradient id="nf-body-light" x1="0" y1="0" x2="1" y2="1">
|
||||
<stop offset="0" stop-color="#3d4c69" />
|
||||
<stop offset="1" stop-color="#1a2231" />
|
||||
<linearGradient id="nf-body-light" gradientUnits="userSpaceOnUse" x1="265" y1="236" x2="320" y2="270">
|
||||
<stop offset="0" stop-color="#1d2739" />
|
||||
<stop offset="1" stop-color="#080d15" />
|
||||
</linearGradient>
|
||||
<linearGradient id="nf-web" gradientUnits="userSpaceOnUse" x1="112" y1="326" x2="316" y2="384">
|
||||
<stop offset="0" stop-color="#fcd34d" />
|
||||
<stop offset="1" stop-color="#ef8f16" />
|
||||
</linearGradient>
|
||||
<linearGradient id="nf-belly" x1="0" y1="0" x2="0" y2="1">
|
||||
<stop offset="0" stop-color="#ffffff" />
|
||||
@@ -66,17 +76,17 @@ $extraJs[] = fws_url('/p/assets/js/not-found.js');
|
||||
<stop offset="1" stop-color="#b6c2d1" />
|
||||
</linearGradient>
|
||||
<clipPath id="nf-body-clip">
|
||||
<path d="M 180 92 C 138 92 112 124 110 166 C 108 196 126 212 130 234 C 118 266 104 298 104 326 C 104 352 138 364 180 364 C 222 364 256 352 256 326 C 256 298 242 266 230 234 C 234 212 252 196 250 166 C 248 124 222 92 180 92 Z" />
|
||||
<path d="M 215 96 C 172 96 145 124 143 164 C 142 192 155 212 157 232 C 145 258 134 294 134 322 C 134 354 167 370 215 370 C 263 370 296 354 296 322 C 296 294 285 258 273 232 C 275 212 288 192 287 164 C 285 124 258 96 215 96 Z" />
|
||||
</clipPath>
|
||||
</defs>
|
||||
|
||||
<!-- Ambiance -->
|
||||
<ellipse cx="420" cy="330" rx="340" ry="130" fill="url(#nf-ambient)" />
|
||||
<ellipse cx="180" cy="252" rx="185" ry="195" fill="url(#nf-tux-glow)" />
|
||||
<ellipse cx="212" cy="252" rx="190" ry="200" fill="url(#nf-tux-glow)" />
|
||||
|
||||
<!-- ── Switch ──────────────────────────────────────────────────────── -->
|
||||
<g id="nf-switch">
|
||||
<ellipse cx="515" cy="306" rx="190" ry="16" fill="rgba(0,0,0,0.38)" />
|
||||
<ellipse cx="515" cy="304" rx="196" ry="18" fill="url(#nf-ground-shadow)" />
|
||||
<rect x="326" y="196" width="16" height="40" rx="4" fill="#1b2434" />
|
||||
<rect x="688" y="196" width="16" height="40" rx="4" fill="#1b2434" />
|
||||
<rect x="340" y="120" width="350" height="172" rx="20" fill="url(#nf-switch-body)" stroke="rgba(148,163,184,0.28)" stroke-width="2" />
|
||||
@@ -138,54 +148,66 @@ $extraJs[] = fws_url('/p/assets/js/not-found.js');
|
||||
</g>
|
||||
|
||||
<!-- ── Tux ─────────────────────────────────────────────────────────── -->
|
||||
<g id="nf-tux">
|
||||
<ellipse cx="180" cy="362" rx="74" ry="13" fill="rgba(0,0,0,0.35)" />
|
||||
<!-- L'ombre est posée à plat au sol, hors du groupe #nf-tux : c'est le JS
|
||||
qui la tasse et la décale quand Tux se retrouve assis. -->
|
||||
<ellipse id="nf-shadow" cx="215" cy="376" rx="96" ry="17" fill="url(#nf-ground-shadow)" />
|
||||
|
||||
<g id="nf-tux">
|
||||
<!-- Aileron arrière -->
|
||||
<ellipse cx="110" cy="250" rx="18" ry="56" transform="rotate(16 110 250)" fill="url(#nf-body)" stroke="rgba(125,211,252,0.25)" stroke-width="2" />
|
||||
<ellipse cx="132" cy="268" rx="19" ry="58" transform="rotate(12 132 268)" fill="url(#nf-body)" stroke="rgba(125,211,252,0.22)" stroke-width="2" />
|
||||
|
||||
<!-- Corps -->
|
||||
<path d="M 180 92 C 138 92 112 124 110 166 C 108 196 126 212 130 234 C 118 266 104 298 104 326 C 104 352 138 364 180 364 C 222 364 256 352 256 326 C 256 298 242 266 230 234 C 234 212 252 196 250 166 C 248 124 222 92 180 92 Z"
|
||||
fill="url(#nf-body)" stroke="rgba(125,211,252,0.35)" stroke-width="2" />
|
||||
<path d="M 215 96 C 172 96 145 124 143 164 C 142 192 155 212 157 232 C 145 258 134 294 134 322 C 134 354 167 370 215 370 C 263 370 296 354 296 322 C 296 294 285 258 273 232 C 275 212 288 192 287 164 C 285 124 258 96 215 96 Z"
|
||||
fill="url(#nf-body)" stroke="rgba(125,211,252,0.32)" stroke-width="2" />
|
||||
|
||||
<g clip-path="url(#nf-body-clip)">
|
||||
<ellipse cx="180" cy="286" rx="52" ry="72" fill="url(#nf-belly)" />
|
||||
<ellipse cx="152" cy="158" rx="30" ry="37" fill="#ffffff" />
|
||||
<ellipse cx="208" cy="158" rx="30" ry="37" fill="#ffffff" />
|
||||
<path d="M 215 200 C 178 200 162 240 160 286 C 158 320 178 340 215 340 C 252 340 272 320 270 286 C 268 240 252 200 215 200 Z" fill="url(#nf-belly)" />
|
||||
</g>
|
||||
|
||||
<g id="nf-eyes">
|
||||
<circle cx="156" cy="150" r="12" fill="#eef2f7" />
|
||||
<circle cx="204" cy="150" r="12" fill="#eef2f7" />
|
||||
<circle cx="156" cy="150" r="8.5" fill="#101826" />
|
||||
<circle cx="204" cy="150" r="8.5" fill="#101826" />
|
||||
<circle cx="153" cy="147" r="3" fill="#ffffff" />
|
||||
<circle cx="201" cy="147" r="3" fill="#ffffff" />
|
||||
<ellipse cx="190" cy="150" rx="27" ry="31" fill="#f8fafc" />
|
||||
<ellipse cx="238" cy="150" rx="27" ry="31" fill="#f8fafc" />
|
||||
<circle cx="194" cy="153" r="14" fill="#0b1220" />
|
||||
<circle cx="234" cy="153" r="14" fill="#0b1220" />
|
||||
<circle cx="188" cy="146" r="4.5" fill="#ffffff" />
|
||||
<circle cx="228" cy="146" r="4.5" fill="#ffffff" />
|
||||
</g>
|
||||
|
||||
<path d="M 172 178 C 198 180 218 186 230 194 C 216 204 196 208 174 206 C 178 196 176 186 172 178 Z" fill="url(#nf-beak)" />
|
||||
<path d="M 176 195 C 194 199 212 195 226 190" fill="none" stroke="rgba(120,53,15,0.45)" stroke-width="2" stroke-linecap="round" />
|
||||
<!-- Bec -->
|
||||
<path d="M 209 168 C 240 170 266 180 280 193 C 268 212 240 220 211 217 C 189 214 175 202 177 189 C 180 176 192 168 209 168 Z"
|
||||
fill="url(#nf-beak)" stroke="rgba(120,53,15,0.25)" stroke-width="1.5" />
|
||||
<path d="M 186 197 C 208 204 242 200 264 191" fill="none" stroke="rgba(120,53,15,0.45)" stroke-width="2.5" stroke-linecap="round" />
|
||||
|
||||
<!-- Pattes (devant le corps pour rester visibles) -->
|
||||
<!-- Pattes palmées (devant le corps pour rester visibles) -->
|
||||
<g id="nf-foot-l">
|
||||
<ellipse cx="134" cy="358" rx="34" ry="15" fill="url(#nf-beak)" />
|
||||
<path d="M 121 348 L 121 368 M 147 346 L 147 370" stroke="rgba(120,53,15,0.4)" stroke-width="2" stroke-linecap="round" />
|
||||
<g transform="translate(168 346) rotate(-16) scale(-0.82 0.7)">
|
||||
<path d="M -8 -18 C 8 -24 26 -22 38 -14 C 48 -7 49 6 40 16 C 30 26 12 30 -4 26 C -12 18 -14 -6 -8 -18 Z" fill="url(#nf-web)" />
|
||||
<circle cx="48" cy="-16" r="12.5" fill="url(#nf-web)" />
|
||||
<circle cx="49" cy="6" r="12.5" fill="url(#nf-web)" />
|
||||
<circle cx="36" cy="27" r="12.5" fill="url(#nf-web)" />
|
||||
</g>
|
||||
<path d="M 158 342 C 150 343 141 344 133 346 M 156 346 C 150 352 142 357 134 360" fill="none" stroke="rgba(146,64,14,0.45)" stroke-width="2" stroke-linecap="round" />
|
||||
</g>
|
||||
<g id="nf-foot-r">
|
||||
<ellipse cx="226" cy="358" rx="34" ry="15" fill="url(#nf-beak)" />
|
||||
<path d="M 213 346 L 213 370 M 239 348 L 239 368" stroke="rgba(120,53,15,0.4)" stroke-width="2" stroke-linecap="round" />
|
||||
<g transform="translate(262 346) rotate(16) scale(0.82 0.7)">
|
||||
<path d="M -8 -18 C 8 -24 26 -22 38 -14 C 48 -7 49 6 40 16 C 30 26 12 30 -4 26 C -12 18 -14 -6 -8 -18 Z" fill="url(#nf-web)" />
|
||||
<circle cx="48" cy="-16" r="12.5" fill="url(#nf-web)" />
|
||||
<circle cx="49" cy="6" r="12.5" fill="url(#nf-web)" />
|
||||
<circle cx="36" cy="27" r="12.5" fill="url(#nf-web)" />
|
||||
</g>
|
||||
<path d="M 272 342 C 280 343 289 344 297 346 M 274 346 C 280 352 288 357 296 360" fill="none" stroke="rgba(146,64,14,0.45)" stroke-width="2" stroke-linecap="round" />
|
||||
</g>
|
||||
</g>
|
||||
|
||||
<!-- ── Câble (recalculé par le JS) ─────────────────────────────────── -->
|
||||
<path class="nf-cable" d="M 534 236 C 488 305, 340 320, 276 265" fill="none" stroke="#38bdf8" stroke-width="13" stroke-linecap="round" stroke-linejoin="round" opacity="0.12" />
|
||||
<path class="nf-cable" d="M 534 236 C 488 305, 340 320, 276 265" fill="none" stroke="#475569" stroke-width="9" stroke-linecap="round" stroke-linejoin="round" />
|
||||
<path class="nf-cable" d="M 534 236 C 488 305, 340 320, 276 265" fill="none" stroke="#94a3b8" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" opacity="0.5" />
|
||||
<path class="nf-cable" d="M 534 236 C 466 328, 372 328, 304 256" fill="none" stroke="#38bdf8" stroke-width="13" stroke-linecap="round" stroke-linejoin="round" opacity="0.12" />
|
||||
<path class="nf-cable" d="M 534 236 C 466 328, 372 328, 304 256" fill="none" stroke="#475569" stroke-width="9" stroke-linecap="round" stroke-linejoin="round" />
|
||||
<path class="nf-cable" d="M 534 236 C 466 328, 372 328, 304 256" fill="none" stroke="#94a3b8" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" opacity="0.5" />
|
||||
|
||||
<!-- ── Aileron avant (tient le câble) ──────────────────────────────── -->
|
||||
<g id="nf-arm">
|
||||
<ellipse cx="237" cy="245" rx="16" ry="44" transform="rotate(118 237 245)" fill="url(#nf-body-light)" stroke="rgba(125,211,252,0.3)" stroke-width="2" />
|
||||
<ellipse cx="274" cy="263" rx="15" ry="12" fill="url(#nf-body-light)" stroke="rgba(125,211,252,0.3)" stroke-width="2" />
|
||||
<ellipse cx="285" cy="253" rx="25" ry="14.5" transform="rotate(6.5 285 253)" fill="url(#nf-body-light)" stroke="rgba(125,211,252,0.3)" stroke-width="2" />
|
||||
<ellipse cx="304" cy="256" rx="14.5" ry="12.5" fill="url(#nf-body-light)" stroke="rgba(125,211,252,0.3)" stroke-width="2" />
|
||||
</g>
|
||||
|
||||
<!-- ── Connecteur RJ45 ─────────────────────────────────────────────── -->
|
||||
|
||||
+152
-103
@@ -1,14 +1,17 @@
|
||||
/**
|
||||
* FWS Linux — animation de la page 404.
|
||||
*
|
||||
* Une seule fois, puis on s'arrête sur l'image finale : Tux s'approche,
|
||||
* attrape le câble RJ45, le débranche (la LED passe au rouge, une pastille
|
||||
* « link down » apparaît), puis lâche le câble qui tombe au sol et s'immobilise.
|
||||
* Une seule fois, puis on s'arrête sur l'image finale : Tux s'approche du switch,
|
||||
* saisit le câble RJ45 et tire (le connecteur sort du port, la LED passe au
|
||||
* rouge, une pastille « link down » apparaît). Le coup de fil le déséquilibre :
|
||||
* il tombe en arrière sur le fesse et reste assis, le câble toujours dans la
|
||||
* main, tandis que le connecteur finit au sol au pied du switch.
|
||||
*
|
||||
* Le connecteur suit sa cible via un ressort sous-amorti et, à partir du
|
||||
* lâcher, les deux extrémités du câble deviennent des points libres soumis à
|
||||
* la gravité (avec rebond et frottement). Le tracé du câble est recalculé à
|
||||
* chaque image, ce qui donne le fouetté et la chute naturels.
|
||||
* Tant qu'il est branché, le connecteur suit sa cible via un ressort
|
||||
* sous-amorti ; une fois débranché il devient un point libre soumis à la gravité
|
||||
* (rebond, frottement, torsion jusqu'à l'arrêt à plat). Le tracé du câble est
|
||||
* recalculé à chaque image : le mou, le balancement et la traînée au sol en
|
||||
* découlent.
|
||||
*
|
||||
* Sans JavaScript, la scène reste dans son état « branché » défini dans le SVG.
|
||||
*/
|
||||
@@ -21,7 +24,8 @@
|
||||
}
|
||||
|
||||
var el = {
|
||||
switch: svg.querySelector('#nf-switch'),
|
||||
switchBox: svg.querySelector('#nf-switch'),
|
||||
shadow: svg.querySelector('#nf-shadow'),
|
||||
tux: svg.querySelector('#nf-tux'),
|
||||
arm: svg.querySelector('#nf-arm'),
|
||||
connector: svg.querySelector('#nf-connector'),
|
||||
@@ -35,28 +39,42 @@
|
||||
eyes: svg.querySelector('#nf-eyes')
|
||||
};
|
||||
|
||||
if (!el.tux || !el.arm || !el.connector || !el.cables.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Géométrie — doit rester synchronisée avec le dessin dans p/404.php. */
|
||||
var G = {
|
||||
feet: [180, 356],
|
||||
armPivot: [198, 224],
|
||||
hand: [276, 265],
|
||||
walk: [215, 358], // pivot de la marche, entre les deux pattes
|
||||
hip: [215, 322], // fesse : pivot de la chute en arrière
|
||||
shoulder: [265, 250],
|
||||
hand: [304, 256],
|
||||
footL: [168, 346], // chevilles : pivot de la contre-rotation des pattes
|
||||
footR: [262, 346],
|
||||
plugPivot: [555, 236],
|
||||
connAttach: [534, 236]
|
||||
connAttach: [534, 236],
|
||||
ground: 374
|
||||
};
|
||||
|
||||
/* Timeline (ms) : tout se joue une fois, puis l'image finale reste. */
|
||||
var APPROACH_A = 1000, APPROACH_B = 1750;
|
||||
var PULL_A = 1800, RELEASE = 2900;
|
||||
var HAND_RELEASE = 3500, RECOVER = 4600;
|
||||
var TOTAL = 6400;
|
||||
/* Pose finale : assis, dos voûté, câble toujours en main. Les valeurs sont
|
||||
calées pour que le bas du corps touche le sol et que la tête reste dans le
|
||||
cadre (viewBox 0 0 720 440). */
|
||||
var SIT = { deg: -32, x: -20, y: -10, arm: -24, foot: 50, footDropL: 6, footDropR: 62 };
|
||||
|
||||
var PULL_X = -112;
|
||||
var FLOOR = 386;
|
||||
/* Timeline (ms) : tout se joue une fois, puis l'image finale reste. */
|
||||
var APPROACH_A = 700, APPROACH_B = 1500;
|
||||
var PULL_A = 1800;
|
||||
/* La chute part exactement du décrochage : plus de temps mort entre les deux. */
|
||||
var RELEASE = 2900, FALL_A = RELEASE, FALL_B = 4050;
|
||||
var TOTAL = 5500;
|
||||
|
||||
var APPROACH_X = 14, PULL_X = 22, STUMBLE_X = 18;
|
||||
var GRAVITY = 1600;
|
||||
|
||||
/* ── Helpers ─────────────────────────────────────────────────────────── */
|
||||
|
||||
function clamp01(x) { return x < 0 ? 0 : (x > 1 ? 1 : x); }
|
||||
function lerp(a, b, k) { return a + (b - a) * k; }
|
||||
function smoothstep(e0, e1, x) {
|
||||
var t = clamp01((x - e0) / (e1 - e0));
|
||||
return t * t * (3 - 2 * t);
|
||||
@@ -82,8 +100,8 @@
|
||||
}
|
||||
function apply(m, x, y) { return [m[0] * x + m[2] * y + m[4], m[1] * x + m[3] * y + m[5]]; }
|
||||
function tx(x, y, deg, px, py) {
|
||||
return 'translate(' + x + ' ' + y + ')'
|
||||
+ (deg ? ' rotate(' + deg + ' ' + px + ' ' + py + ')' : '');
|
||||
return 'translate(' + x.toFixed(2) + ' ' + y.toFixed(2) + ')'
|
||||
+ (deg ? ' rotate(' + deg.toFixed(2) + ' ' + px.toFixed(1) + ' ' + py.toFixed(1) + ')' : '');
|
||||
}
|
||||
function setOpacity(list, value) {
|
||||
for (var i = 0; i < list.length; i++) {
|
||||
@@ -98,11 +116,10 @@
|
||||
|
||||
/* ── État persistant ─────────────────────────────────────────────────── */
|
||||
|
||||
var springX = 0, springV = 0; // connecteur tant qu'il est tenu
|
||||
var prevPull = 0, gait = 0;
|
||||
var released = false; // le câble est-il lâché (chute libre) ?
|
||||
var endA = { x: 0, y: 0, vx: 0, vy: 0, rest: false }; // extrémité connecteur
|
||||
var endB = { x: 0, y: 0, vx: 0, vy: 0, rest: false }; // extrémité libre (main)
|
||||
var springX = 0, springV = 0; // connecteur tant qu'il est dans le port
|
||||
var gait = 0;
|
||||
var released = false; // le connecteur est-il tombé ?
|
||||
var plug = { x: 0, y: 0, vx: 0, vy: 0, rest: false };
|
||||
var connDeg = 0, connDegV = 0;
|
||||
|
||||
function springStep(pos, vel, target, k, d, dt) {
|
||||
@@ -112,8 +129,8 @@
|
||||
return [pos, vel];
|
||||
}
|
||||
|
||||
/* Chute d'une extrémité : gravité, rebond amorti, frottement au sol. */
|
||||
function fall(pt, dt) {
|
||||
/* Chute du connecteur : gravité, rebond amorti, frottement au sol. */
|
||||
function fallPoint(pt, dt) {
|
||||
if (pt.rest) {
|
||||
return;
|
||||
}
|
||||
@@ -121,15 +138,15 @@
|
||||
pt.vx *= 0.995;
|
||||
pt.x += pt.vx * dt;
|
||||
pt.y += pt.vy * dt;
|
||||
if (pt.y >= FLOOR) {
|
||||
pt.y = FLOOR;
|
||||
if (pt.y >= G.ground) {
|
||||
pt.y = G.ground;
|
||||
if (pt.vy > 40) {
|
||||
pt.vy = -pt.vy * 0.38; // rebond
|
||||
pt.vx *= 0.6;
|
||||
pt.vy = -pt.vy * 0.34; // rebond
|
||||
pt.vx *= 0.55;
|
||||
} else {
|
||||
pt.vy = 0;
|
||||
}
|
||||
pt.vx *= 0.86; // frottement
|
||||
pt.vx *= 0.84; // frottement
|
||||
if (Math.abs(pt.vx) < 7 && Math.abs(pt.vy) < 1) {
|
||||
pt.vx = 0;
|
||||
pt.rest = true;
|
||||
@@ -140,119 +157,151 @@
|
||||
/* ── Un pas d'animation ──────────────────────────────────────────────── */
|
||||
|
||||
function advance(t, dt) {
|
||||
/* Courbe de traction : Tux tire, puis se détend et se relève partiellement */
|
||||
var approach = smoothstep(APPROACH_A, APPROACH_B, t);
|
||||
|
||||
/* Courbe de traction : Tux tire, puis se laisse retomber en arrière. */
|
||||
var pull;
|
||||
if (t <= PULL_A) {
|
||||
pull = 0;
|
||||
} else if (t < RELEASE) {
|
||||
pull = easeInOut((t - PULL_A) / (RELEASE - PULL_A));
|
||||
} else if (t < HAND_RELEASE) {
|
||||
} else if (t < FALL_A) {
|
||||
pull = 1;
|
||||
} else if (t < RECOVER) {
|
||||
pull = 1 - 0.5 * easeInOut((t - HAND_RELEASE) / (RECOVER - HAND_RELEASE));
|
||||
} else {
|
||||
pull = 0.5;
|
||||
pull = 1 - 0.5 * clamp01((t - FALL_A) / (FALL_B - FALL_A));
|
||||
}
|
||||
|
||||
var approach = smoothstep(APPROACH_A, APPROACH_B, t);
|
||||
/* Chute : de la station debout à la pose assise. Courbe rapide au départ
|
||||
(il perd l'équilibre dès que le câble lâche), puis amortie à l'arrivée. */
|
||||
var fall = 1 - Math.pow(1 - clamp01((t - FALL_A) / (FALL_B - FALL_A)), 2.4);
|
||||
|
||||
var sinceRel = (t - RELEASE) / 1000;
|
||||
var yank = (t >= RELEASE && t < RELEASE + 900)
|
||||
? -13 * Math.sin(sinceRel * 13) * Math.exp(-sinceRel * 5) : 0;
|
||||
var struggle = -3 * Math.sin(t / 70) * (pull * (1 - pull) * 4);
|
||||
var yank = 0, yankRot = 0;
|
||||
if (t >= RELEASE) {
|
||||
yank = -11 * Math.sin(sinceRel * 27) * Math.exp(-sinceRel * 6.5);
|
||||
yankRot = 3.4 * Math.sin(sinceRel * 27) * Math.exp(-sinceRel * 6.5);
|
||||
}
|
||||
/* Rebond d'assise : petit amorti au moment où le fesse touche le sol. */
|
||||
var sinceSit = (t - FALL_B) / 1000;
|
||||
var settle = t > FALL_B ? 2 * Math.sin(sinceSit * 32) * Math.exp(-sinceSit * 4.5) : 0;
|
||||
|
||||
var tuxX = 9 * approach + PULL_X * pull + yank + struggle;
|
||||
var tuxRot = 5 * approach - 13 * pull - yank * 0.12;
|
||||
var bob = Math.sin(t / 520) * 1.2 - 2 * pull;
|
||||
var bob = Math.sin(t / 520) * 1.3 * (1 - fall);
|
||||
/* L'élan : il se met à reculer pendant la traction, atteint son maximum à
|
||||
l'instant du décrochage, puis s'amortit. C'est ce recul qui bascule le
|
||||
poids du corps et déclenche la chute. */
|
||||
var slip = clamp01(1 - (t - RELEASE) / 900);
|
||||
var standX = APPROACH_X * approach - PULL_X * pull - STUMBLE_X * slip + yank;
|
||||
var standRot = 4 * approach - 11 * pull - 9 * slip + yankRot;
|
||||
var standY = -1.5 * approach - 2 * pull + bob;
|
||||
|
||||
/* Démarche : la phase avance avec la distance parcourue */
|
||||
var dp = pull - prevPull;
|
||||
gait += Math.abs(dp) * 16;
|
||||
var walk = smoothstep(0.006, 0.05, Math.abs(dp) / Math.max(dt, 0.001) * 0.1);
|
||||
var swing = Math.sin(gait) * 9 * walk;
|
||||
var liftL = Math.max(0, Math.sin(gait)) * 6 * walk;
|
||||
var liftR = Math.max(0, Math.sin(gait + Math.PI)) * 6 * walk;
|
||||
prevPull = pull;
|
||||
/* Démarche : la phase avance avec la vitesse de déplacement. */
|
||||
var walk = smoothstep(APPROACH_A - 120, APPROACH_A + 260, t)
|
||||
* (1 - smoothstep(APPROACH_B - 140, APPROACH_B + 200, t))
|
||||
* (1 - fall);
|
||||
gait += dt * 8.5 * walk;
|
||||
var swing = Math.sin(gait) * 8.5 * walk;
|
||||
var liftL = Math.max(0, Math.sin(gait)) * 5.5 * walk;
|
||||
var liftR = Math.max(0, Math.sin(gait + Math.PI)) * 5.5 * walk;
|
||||
|
||||
el.tux.setAttribute('transform', tx(tuxX, bob, tuxRot, G.feet[0], G.feet[1]));
|
||||
el.footL.setAttribute('transform', 'translate(' + (swing * 0.7).toFixed(2) + ' ' + (-liftL).toFixed(2) + ')');
|
||||
el.footR.setAttribute('transform', 'translate(' + (-swing * 0.7).toFixed(2) + ' ' + (-liftR).toFixed(2) + ')');
|
||||
/* Assis, les deux pattes sont posées à plat au sol devant le corps : on
|
||||
compense la rotation du corps pour les remettre de niveau, et on les
|
||||
descend d'autant pour qu'elles touchent terre. */
|
||||
var footSpin = SIT.foot * fall;
|
||||
el.footL.setAttribute('transform',
|
||||
tx(swing * 0.5, -liftL + SIT.footDropL * fall, footSpin, G.footL[0], G.footL[1]));
|
||||
el.footR.setAttribute('transform',
|
||||
tx(-swing * 0.5, -liftR + SIT.footDropR * fall, footSpin, G.footR[0], G.footR[1]));
|
||||
|
||||
var armRot = 16 * approach - 24 * pull;
|
||||
/* Corps : on interpole le pivot (pattes → fesse), l'angle et le décalage. */
|
||||
var pvX = lerp(G.walk[0], G.hip[0], fall);
|
||||
var pvY = lerp(G.walk[1], G.hip[1], fall);
|
||||
var ang = lerp(standRot, SIT.deg, fall) + settle;
|
||||
var ox = lerp(standX, SIT.x, fall);
|
||||
var oy = lerp(standY, SIT.y, fall);
|
||||
var bodyTf = tx(ox, oy, ang, pvX, pvY);
|
||||
|
||||
el.tux.setAttribute('transform', bodyTf);
|
||||
|
||||
/* Aileron avant : tend le bras, puis garde le câble en l'air en s'asseyant. */
|
||||
var armRot = (16 * approach - 26 * pull) * (1 - fall) + SIT.arm * fall;
|
||||
el.arm.setAttribute('transform',
|
||||
tx(tuxX, bob, tuxRot, G.feet[0], G.feet[1])
|
||||
+ ' rotate(' + armRot + ' ' + G.armPivot[0] + ' ' + G.armPivot[1] + ')');
|
||||
bodyTf + ' rotate(' + armRot.toFixed(2) + ' ' + G.shoulder[0] + ' ' + G.shoulder[1] + ')');
|
||||
|
||||
/* Regard : Tux suit le connecteur, puis regarde le câble au sol */
|
||||
/* L'ombre s'aplatit et se décale vers la fesse quand Tux se pose. */
|
||||
if (el.shadow) {
|
||||
el.shadow.setAttribute('transform',
|
||||
'translate(' + (215 - 40 * fall).toFixed(1) + ' 376)'
|
||||
+ ' scale(1 ' + (1 - 0.5 * fall).toFixed(3) + ')'
|
||||
+ ' translate(-215 -376)');
|
||||
}
|
||||
|
||||
/* Regard : vers le connecteur pendant la traction, vers le câble au sol
|
||||
une fois assis. */
|
||||
var gx = 0, gy = 0;
|
||||
if (t >= HAND_RELEASE) { gx = -2; gy = 5; }
|
||||
else if (t >= RELEASE) { gx = 3; gy = -1.5; }
|
||||
if (t >= FALL_B) { gx = 3; gy = 2.5; }
|
||||
else if (t >= RELEASE) { gx = 1.5; gy = -0.5; }
|
||||
else if (t >= PULL_A) { gx = -1; gy = 0; }
|
||||
if (el.eyes) {
|
||||
el.eyes.setAttribute('transform', 'translate(' + gx + ' ' + gy + ')');
|
||||
}
|
||||
|
||||
/* Connecteur tenu : ressort vers la main tant qu'il est branché/tenu */
|
||||
var target = t >= RELEASE ? tuxX : 0;
|
||||
var sp = springStep(springX, springV, target, 150, 14, dt);
|
||||
springX = sp[0];
|
||||
springV = sp[1];
|
||||
|
||||
var tuxM = mul(tr(tuxX, bob), rot(tuxRot, G.feet[0], G.feet[1]));
|
||||
var armM = mul(tuxM, rot(armRot, G.armPivot[0], G.armPivot[1]));
|
||||
var bodyM = mul(tr(ox, oy), rot(ang, pvX, pvY));
|
||||
var armM = mul(bodyM, rot(armRot, G.shoulder[0], G.shoulder[1]));
|
||||
var hand = apply(armM, G.hand[0], G.hand[1]);
|
||||
|
||||
var heldRot = (t >= RELEASE && t < HAND_RELEASE)
|
||||
? 15 * Math.sin(sinceRel * 7) * Math.exp(-sinceRel * 1.2) : 0;
|
||||
var heldA = [G.connAttach[0] + springX, G.connAttach[1]];
|
||||
/* Connecteur : ressort vers sa cible tant qu'il est dans le port. */
|
||||
var sp = springStep(springX, springV, -34 * pull, 190, 15, dt);
|
||||
springX = sp[0];
|
||||
springV = sp[1];
|
||||
var seated = [G.connAttach[0] + springX, G.connAttach[1]];
|
||||
|
||||
/* Point A = extrémité câble du connecteur ; point B = extrémité libre */
|
||||
/* Point A = extrémité « connecteur » du câble ; point B = main de Tux.
|
||||
Après le débranchement, A devient un point libre et B reste dans la main
|
||||
jusqu'à la fin : c'est ce qui fait que Tux retombe en gardant le câble. */
|
||||
var A, B, deg;
|
||||
if (t < HAND_RELEASE) {
|
||||
A = heldA;
|
||||
if (t < RELEASE) {
|
||||
A = seated;
|
||||
B = hand;
|
||||
deg = heldRot;
|
||||
deg = 0;
|
||||
released = false;
|
||||
} else {
|
||||
if (!released) {
|
||||
/* Lâcher : les deux extrémités deviennent des points libres, avec la
|
||||
vitesse héritée du ressort (le connecteur part vers la gauche). */
|
||||
released = true;
|
||||
endA.x = heldA[0]; endA.y = heldA[1];
|
||||
endA.vx = springV * 0.5 - 140; endA.vy = 0;
|
||||
endB.x = hand[0]; endB.y = hand[1];
|
||||
endB.vx = -14; endB.vy = 0;
|
||||
connDeg = heldRot;
|
||||
connDegV = 60;
|
||||
plug.x = seated[0];
|
||||
plug.y = seated[1];
|
||||
plug.vx = springV * 0.4 - 150;
|
||||
plug.vy = -30;
|
||||
connDeg = 0;
|
||||
connDegV = -140;
|
||||
}
|
||||
fall(endA, dt);
|
||||
fall(endB, dt);
|
||||
/* Le connecteur bascule sur le flanc puis se stabilise */
|
||||
connDegV += (-(connDeg - (-82)) * 130 - connDegV * 12) * dt;
|
||||
fallPoint(plug, dt);
|
||||
connDegV += (-(connDeg - 6) * 95 - connDegV * 11) * dt;
|
||||
connDeg += connDegV * dt;
|
||||
A = [endA.x, endA.y];
|
||||
B = [endB.x, endB.y];
|
||||
A = [plug.x, plug.y];
|
||||
B = hand;
|
||||
deg = connDeg;
|
||||
}
|
||||
|
||||
/* Connecteur : translation calculée pour amener son point d'attache en A */
|
||||
/* Connecteur : translation calculée pour amener son point d'attache en A. */
|
||||
var R = rot(deg, G.plugPivot[0], G.plugPivot[1]);
|
||||
var ar = apply(R, G.connAttach[0], G.connAttach[1]);
|
||||
el.connector.setAttribute('transform',
|
||||
'translate(' + (A[0] - ar[0]).toFixed(2) + ' ' + (A[1] - ar[1]).toFixed(2) + ')'
|
||||
+ ' rotate(' + deg.toFixed(2) + ' ' + G.plugPivot[0] + ' ' + G.plugPivot[1] + ')');
|
||||
|
||||
/* Câble : affaissement réduit quand il se tend, jamais sous le sol */
|
||||
var dist = Math.sqrt((A[0] - B[0]) * (A[0] - B[0]) + (A[1] - B[1]) * (A[1] - B[1]));
|
||||
var taut = clamp01((dist - 150) / 220);
|
||||
var velWorld = released ? endA.vx : springV;
|
||||
var wob = Math.max(-18, Math.min(18, velWorld * 0.05));
|
||||
/* Câble : affaissement réduit quand il se tend, jamais sous le sol. */
|
||||
var dx = A[0] - B[0], dy = A[1] - B[1];
|
||||
var taut = clamp01((Math.sqrt(dx * dx + dy * dy) - 210) / 240);
|
||||
var velWorld = released ? plug.vx : springV;
|
||||
var wob = Math.max(-16, Math.min(16, velWorld * 0.05));
|
||||
var sway = 5 * Math.sin(t / 620) + 2 * Math.sin(t / 370 + 1.3);
|
||||
var sag = 92 * (1 - taut * 0.55) + (released ? 0 : sway);
|
||||
var lim = FLOOR - 3;
|
||||
var sag = 96 * (1 - 0.5 * taut) + (released ? 0 : sway);
|
||||
var lim = G.ground - 3;
|
||||
|
||||
var c1x = A[0] - 46 - 16 * taut;
|
||||
var c1x = A[0] - 48 - 18 * taut;
|
||||
var c1y = Math.min(lim, A[1] + sag);
|
||||
var c2x = B[0] + 64;
|
||||
var c2y = Math.min(lim, Math.min(lim, B[1] + sag * 0.8) + wob);
|
||||
var c2x = B[0] + (released ? 52 : 64);
|
||||
var c2y = Math.min(lim, Math.min(lim, B[1] + sag * 0.85) + wob);
|
||||
setCable('M ' + A[0].toFixed(2) + ' ' + A[1].toFixed(2)
|
||||
+ ' C ' + c1x.toFixed(2) + ' ' + c1y.toFixed(2)
|
||||
+ ', ' + c2x.toFixed(2) + ' ' + c2y.toFixed(2)
|
||||
@@ -282,7 +331,7 @@
|
||||
jx = 4 * Math.sin(sinceRel * 32) * Math.exp(-sinceRel * 7);
|
||||
jr = 0.55 * Math.sin(sinceRel * 32) * Math.exp(-sinceRel * 7);
|
||||
}
|
||||
el.switch.setAttribute('transform', tx(jx, 0, jr, 515, 206));
|
||||
el.switchBox.setAttribute('transform', tx(jx, 0, jr, 515, 206));
|
||||
}
|
||||
|
||||
/* ── Lancement ───────────────────────────────────────────────────────── */
|
||||
|
||||
Reference in new issue
Block a user