xxxxxxxxxx
30
let myModel;
function preload() {
// Assuming you've converted your model to OBJ format
myModel = loadModel('Lego.stl', true);
}
function setup() {
createCanvas(windowWidth, windowHeight, WEBGL);
// Setting up a default camera view
camera(0, 0, (height/2) / tan(PI/6), 0, 0, 0, 0, 1, 0);
document.oncontextmenu = function() { return false; };
document.onmousedown = function() { return false; };
}
function draw() {
background(100);
// Use different variable names to avoid naming conflicts
let angleX = map(mouseY, 0, height, -PI, PI);
let angleY = map(mouseX, 0, width, -PI, PI);
push(); // Start a new drawing state
scale(0.6); // Adjust scale if needed
rotateX(angleX);
rotateY(angleY);
model(myModel);
pop(); // Restore original state
}