xxxxxxxxxx
// Experiment with yaw constrained rotation
document.oncontextmenu=()=>false;
var cam;
function setup() {
createCanvas(windowWidth, windowHeight, WEBGL);
pixelDensity(1);
cam = createEasyCam();
//cam.setRotation([0.98,-0.2,0,0], 1000);
cam.setRotationConstraint(true,false,false);
noStroke();
}
function draw() {
background(0);
const mat = this._renderer.uMVMatrix.mat4;
directionalLight(color("white"), -mat[2], -mat[6], -mat[10]);
ambientLight(64);
specularMaterial(64);
shininess(40);
push();
translate(0,120,0);
fill("green");
cylinder(0.5,200, 8,1); // show Z-axis
pop();
rotateX(PI/2);
translate(0,0,-120);
fill("orange");
annulus(150,185, Math.PI/4);
rotateZ(PI);
annulus(150,185, Math.PI/4);
fill("red");
box(40);
}
function windowResized() {
resizeCanvas(windowWidth, windowHeight);
cam.setViewport([0,0,windowWidth, windowHeight]);
}