Le concept
La cybersickness (mal des transports VR) est causée par le conflit entre le vestibulaire (pas de mouvement réel) et le visuel (mouvement perçu). Solutions : vignettage dynamique (noircir les bords pendant les déplacements), repères visuels fixes (nez virtuel, cadre de cockpit), réduction du champ de vision lors des accélérations.
Le code
// VR comfort: dynamic vignette on movement
let speed = 0, posX = 0;
function setup() { createCanvas(400, 280); }
function draw() {
background(11, 15, 20);
// Virtual world (moves)
posX += speed; speed *= 0.92;
if (keyIsDown(LEFT_ARROW)) speed -= 0.4;
if (keyIsDown(RIGHT_ARROW)) speed += 0.4;
push();
translate(posX % width, 0);
for (let x = -width; x < width*2; x += 60) {
stroke(60,70,90,120); strokeWeight(1);
line(x, 0, x, height);
}
pop();
// Vignette (increases with speed)
let v = min(abs(speed)*8, 200);
noStroke();
for (let r = min(width,height)/2; r > 0; r -= 4) {
let alpha = map(r, 0, min(width,height)/2, v, 0);
fill(0, 0, 0, alpha);
ellipse(width/2, height/2, r*2, r*2);
}
fill(255); textAlign(CENTER);
text('← → pour se déplacer', width/2, height-20);
}Pour aller plus loin
Explorez les autres cours gratuits sur la page Ateliers.
Pratiquer, collaborer, déployer — en 15 min.
Réserver un appel →