xxxxxxxxxx
166
var BoundX = 75;
var BoundY = 75;
var BoundZ = 75;
var num = 15;
timer = 500;
var moonSize = 50;
var count = 0;
starPosition = [];
function setup() {
createCanvas(windowWidth, windowHeight, WEBGL);
for(let i =0; i<15; i++){
let location = createVector(random(-BoundX,BoundX),random(-BoundY,BoundY),random(-BoundZ,BoundZ));
starPosition.push(location);
}
}
function draw() {
background(0);
push();
//rotateY(frameCount*0.005);
let dirX1 = sin(frameCount*0.01);
let dirY1 = sin(frameCount*0.01);
let v1 = createVector(dirX1, -dirY1, -1);
v1.normalize();
colorMode(HSB, 500);
directionalLight(map((sin(frameCount*0.01)),-1,1,0,500), map((sin(frameCount*0.01)),-1,1,0,500), map((sin(frameCount*0.01)),-1,1,0,500), v1);
let dirX2 = sin(frameCount*0.02);
let dirY2 = sin(frameCount*0.02);
let v2 = createVector(-dirX2, dirY2, -1);
v2.normalize();
colorMode(HSB, 500);
directionalLight(map((cos(frameCount*0.01)),-1,1,0,500), map((cos(frameCount*0.01)),-1,1,0,500), map((cos(frameCount*0.01)),-1,1,0,500), v2);
colorMode(RGB, 255, 255, 255, 1);
//directionalLight(255,255,255, v2);
//colorMode(RGB, 255, 255, 255, 1);
noFill();
strokeWeight(1);
stroke(255);
push();
//box(BoundX, BoundY, BoundZ);
pop();
for(let i =0; i <starPosition.length; i++){
push();
noLights();
translate(starPosition[i].x,starPosition[i].y,starPosition[i].z);
sphere(0.35*sin(i*70+frameCount*0.1));
pop();
}
if(count % timer == 0){
starPosition = [];
for(let i =0; i<num; i++){
let location = createVector(random(-75,75),random(-75,75),random(-75,75));
starPosition.push(location);
}
}
//moon
noStroke();
fill(255);
sphere(moonSize);
pop();
count = count + 1;
}
var BoundX = 75;
var BoundY = 75;
var BoundZ = 75;
var num = 15;
timer = 500;
var moonSize = 50;
var count = 0;
starPosition = [];
function setup() {
createCanvas(windowWidth, windowHeight, WEBGL);
for(let i =0; i<15; i++){
let location = createVector(random(-BoundX,BoundX),random(-BoundY,BoundY),random(-BoundZ,BoundZ));
starPosition.push(location);
}
}
function draw() {
background(0);
push();
//rotateY(frameCount*0.005);
let dirX1 = sin(frameCount*0.01);
let dirY1 = sin(frameCount*0.01);
let v1 = createVector(dirX1, -dirY1, -1);
v1.normalize();
colorMode(HSB, 500);
directionalLight(map((sin(frameCount*0.01)),-1,1,0,500), map((sin(frameCount*0.01)),-1,1,0,500), map((sin(frameCount*0.01)),-1,1,0,500), v1);
let dirX2 = sin(frameCount*0.02);
let dirY2 = sin(frameCount*0.02);
let v2 = createVector(-dirX2, dirY2, -1);
v2.normalize();
colorMode(HSB, 500);
directionalLight(map((cos(frameCount*0.01)),-1,1,0,500), map((cos(frameCount*0.01)),-1,1,0,500), map((cos(frameCount*0.01)),-1,1,0,500), v2);
colorMode(RGB, 255, 255, 255, 1);
//directionalLight(255,255,255, v2);
//colorMode(RGB, 255, 255, 255, 1);
noFill();
strokeWeight(1);
stroke(255);
push();
//box(BoundX, BoundY, BoundZ);
pop();
for(let i =0; i <starPosition.length; i++){
push();
noLights();
translate(starPosition[i].x,starPosition[i].y,starPosition[i].z);
sphere(0.35*sin(i*70+frameCount*0.1));
pop();
}
if(count % timer == 0){
starPosition = [];
for(let i =0; i<num; i++){
let location = createVector(random(-75,75),random(-75,75),random(-75,75));
starPosition.push(location);
}
}
//moon
noStroke();
fill(255);
sphere(moonSize);
pop();
count = count + 1;
}