Match trajectory to user-drawn line: high cruise, gentle climb

User sketched a near-horizontal red line in the upper third of the
viewport, slightly higher on the left than on the right. Mapping
that to world coords with the camera at z=22 and 40° vfov:
- right end (entrance): y ≈ +3.5
- left end (exit):      y ≈ +5

So the plane keeps cruising in the upper portion of the frame and
climbs ~1.5 world units across 40 horizontal units — about 2° of
slope. Pitch follows: rotation.z = -0.06 - p·0.01 (3.5–4° nose-up,
matching the slope). Roll softened to 0.04 ± 0.02 since the path is
nearly straight.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
MVA Global Fret 2026-05-05 12:39:42 +02:00
parent 6cf619857a
commit 6fcc772bf0

View File

@ -125,26 +125,25 @@ function tick() {
root.style.setProperty('--mx', ((mouse.px - 0.5) * 2).toFixed(4)); root.style.setProperty('--mx', ((mouse.px - 0.5) * 2).toFixed(4));
root.style.setProperty('--my', ((mouse.py - 0.5) * 2).toFixed(4)); root.style.setProperty('--my', ((mouse.py - 0.5) * 2).toFixed(4));
/* Trajectoire droite gauche, en descente (approche) : /* Trajectoire droite gauche, en très légère montée :
- p = 0 entre haut-droite (hors champ) - p = 0 entre par la droite à mi-hauteur haute (y 3.5)
- p = 0.5 traverse en diagonale descendante - p = 0.5 traverse à y 4.25
- p = 1 sort bas-gauche (hors champ) - p = 1 sort par la gauche un peu plus haut (y 5)
Pente 1.5/40 2° (presque horizontal).
*/ */
const px = 18 - p * 40; // +18 → -22 const px = 18 - p * 40; // +18 → -22 (toujours bien hors champ aux deux bouts)
const py = 6 - p * 16; // +6 (haut) → -10 (bas hors champ) const py = 3.5 + p * 1.5; // +3.5 → +5 (douce montée)
const bob = Math.sin(t * 0.9) * 0.10; const bob = Math.sin(t * 0.9) * 0.08;
planeHolder.position.set(px, py + bob, 0); planeHolder.position.set(px, py + bob, 0);
/* Pour un avion volant -X (nez à gauche), avec up = +Y : /* Avec nez à -X et up = +Y :
- rotation.z (axe latéral du monde) = PITCH. Positif nez baissé. - rotation.z = PITCH (négatif = nez en l'air)
- rotation.x (axe longitudinal du monde) = ROLL. - rotation.x = ROLL
- rotation.y (axe vertical du monde) = YAW. Pente de 2° on relève le nez légèrement pour suivre la trajectoire.
Slope de la trajectoire -16/40 = -22° on incline le nez de
manière analogue pour suivre la pente.
*/ */
const targetPitch = 0.32 + p * 0.05; // nez en bas ~18°-21° (descente) const targetPitch = -0.06 - p * 0.01; // nez ~3.5°-4° en l'air
const targetRoll = 0.12 + (p - 0.5) * 0.10; // léger roulis const targetRoll = 0.04 + (p - 0.5) * 0.04; // roulis très subtil
const targetYaw = 0; const targetYaw = 0;
planeHolder.rotation.z += (targetPitch - planeHolder.rotation.z) * 0.08; planeHolder.rotation.z += (targetPitch - planeHolder.rotation.z) * 0.08;
planeHolder.rotation.x += (targetRoll - planeHolder.rotation.x) * 0.08; planeHolder.rotation.x += (targetRoll - planeHolder.rotation.x) * 0.08;