Code viewer for World: All seeing eye

// Cloned by Colin Ekedigwe on 18 Sep 2024 from World "One Cube World (P5)" by Starter user 
// Please leave this clone trail here.

var img, eyeTexture;

function preload() {
   img = loadImage('/uploads/colin110/1663797578.png'); // Main object texture
   eyeTexture = loadImage('/uploads/colin110/1726661575.png'); // Eye image for the floating sphere
}

// make an array of random (x, y, z) positions
const noboxes = 30;  // how many boxes to have 
var a = new Array(noboxes);  // array of the box positions

for (var i = 0; i < noboxes; i++) {
    a[i] = [AB.randomIntAtoB(-500, 500), AB.randomIntAtoB(-500, 500), AB.randomIntAtoB(-500, 500)];
}

const MUSICFILE = '/uploads/colin110/PatrickWatson-JeTeLaisseraiDesMots.mp3';
AB.backgroundMusic(MUSICFILE);

const objectsize = 200; // size of main object
const floatingObjectSize = 70; // size of the floating sphere (larger to make eye texture clear)
const anglechange = 0.001; // how much the rotate angle changes each step

var angle = 0; // rotate angle starts at 0
var floatingAngle = 0; // angle for the floating sphere's orbit

function setup() {
  createCanvas(ABWorld.fullwidth(), ABWorld.fullheight(), WEBGL);
  noStroke();  // Disable the outline stroke for all shapes
}

function draw() {
    background("black"); // Background color
    
    // Draw the main rotating object with the texture
    texture(img);
    rotateX(angle);
    rotateY(angle);
    rotateZ(angle);
    sphere(objectsize); // Main sphere
    
    // Change the angle for rotation of the main sphere
    angle += anglechange;

    // Draw the floating sphere with the eye texture
    let orbitRadius = 300; // Distance from the center for the floating sphere
    let x = orbitRadius * cos(floatingAngle);
    let y = orbitRadius * sin(floatingAngle);
    
    // Move the floating sphere around the main object
    translate(x, y, 0); 
    
    // Set up the texture with the eye image
    texture(eyeTexture);
    sphere(floatingObjectSize); // Draw the floating sphere with the eye image
    
    // Change the angle for the floating sphere's orbit
    floatingAngle += 0.01;
}