xxxxxxxxxx
141
let cube = [];
let fish;
let turtle;
let x = 0;
let y = 0;
let nx = 0;
let ny = 0;
let z = 0;
let nz = 0;
let bg = 20;
let buffer;
let dots;
function preload() {
fish = loadModel('fish.obj');
turtle = loadModel('10042_Sea_Turtle_V2_iterations-2.obj');
}
function setup() {
createCanvas(windowWidth, windowHeight, WEBGL);
wordsSetup();
colourpalatte = [];
colourpalatte.push(color(255, 151, 70));
colourpalatte.push(color(249, 212, 35));
colourpalatte.push(color(134, 226, 179));
colourpalatte.push(color(56, 214, 232));
colourpalatte.push(color(255, 71, 61));
colourpalatte.push(color(116, 0, 184));
colourpalatte.push(color(6, 214, 160));
for (let i = 0; i < 100; i++) {
//spacing the cubes out
let x = random(width + 2000);
let y = random(height + 2000);
let r = random(5, 60);
let palette = (colourpalatte[i % colourpalatte.length]);
cube[i] = new Cube(x, y, r, palette);
}
for (let i = 0; i < 100; i++) {
//spacing the spheres out
let x = random(width);
let y = random(height);
let r = random(20, 50);
let palette = 255;
// let palette = (colourpalatte[i % colourpalatte.length]);
sphere[i] = new Sphere(x, y, r, palette);
}
}
function draw() {
background(bg);
x += (nx - x) * 0.1;
y += (ny - y) * 0.1;
z += (nz - z) * 0.1;
let locX = mouseX - height / 2;
let locY = mouseY - width / 2;
ambientLight(150);
directionalLight(255, 0, 0, 0.25, 0.25, 0);
pointLight(0, 0, 255, locX, locY, 250);
//Words
push();
translate(x, y, z);
push();
// words();
pop();
//Cube
translate((-width - 2000) / 2, (-height - 2000) / 2);
for (let i = 0; i < cube.length; i++) {
// cube[i].move();
cube[i].show();
}
pop();
//Sphere
push();
translate(x, y, z);
translate(-width / 2, -height / 2);
for (let i = 0; i < sphere.length; i++) {
sphere[i].show();
}
pop();
// Fish
push();
translate(x, y, z);
fill(255);
scale(10);
rotateX(frameCount * 0.01);
rotateY(frameCount * 0.01);
normalMaterial();
model(fish);
push();
translate(50,50);
model(fish);
pop();
push();
translate(-10,-10);
rotateX(frameCount * 0.05);
// rotateY(frameCount * 0.05);
scale(0.2);
model(turtle);
pop();
pop();
}