You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1.Running the code below, continue moving the mouse up or down until the orientation starts rapidly flipping (seen when the line attached to a cube flips).
2.View the browser/p5 editor log to see that the camera's up vector has not been changed by tilt().
3.Hold down the control key while moving the mouse to apply a workaround that updates the up vector and prevents orientation flipping.
Snippet:
letcam;functionsetup(){angleMode(DEGREES);createCanvas(400,400,WEBGL);cam=createCamera();cam.setPosition(0,0,0);}functiondraw(){background(220);letd=800;drawBox(0,0,-d);drawBox(0,-d,-d);drawBox(0,-d,0);drawBox(0,-d,d);drawBox(0,0,d);drawBox(0,d,d);drawBox(0,d,0);drawBox(0,d,-d);}functiondrawBox(x,y,z){push();stroke("red");strokeWeight(10);translate(x,y,z);line(0,0,0,0,0,200);stroke("black");strokeWeight(1);rotateY(45);box(100);pop();}functionmouseMoved(event){cam.tilt((mouseY-pmouseY)/2);// Hold down control key to set cam.up correctly:if(event.ctrlKey){letforward=createVector(cam.centerX-cam.eyeX,cam.centerY-cam.eyeY,cam.centerZ-cam.eyeZ);letup=createVector(cam.upX,cam.upY,cam.upZ);letright=p5.Vector.cross(forward,up);up=p5.Vector.cross(right,forward).normalize();cam.camera(cam.eyeX,cam.eyeY,cam.eyeZ,cam.centerX,cam.centerY,cam.centerZ,up.x,up.y,up.z);}console.log(cam.upX,cam.upY,cam.upZ);}
The text was updated successfully, but these errors were encountered:
Welcome! 👋 Thanks for opening your first issue here! And to ensure the community is able to respond to your issue, please make sure to fill out the inputs in the issue forms. Thank you!
Most appropriate sub-area of p5.js?
p5.js version
1.11.1 and earlier recent versions
Web browser and version
Firefox 132.0.2 / Edge 130.0.2849.80
Operating system
Windows 11 Home / Pro
Steps to reproduce this
Steps:
1.Running the code below, continue moving the mouse up or down until the orientation starts rapidly flipping (seen when the line attached to a cube flips).
2.View the browser/p5 editor log to see that the camera's up vector has not been changed by tilt().
3.Hold down the control key while moving the mouse to apply a workaround that updates the up vector and prevents orientation flipping.
Snippet:
The text was updated successfully, but these errors were encountered: