xxxxxxxxxx
330
var cam;
let centralX = 0;
let centralY = -400;
let centralZ = 0;
//Tree tree;
let treeSpacing = 0.2;
let treeSpacingRand = 0.2;
//float treeSpacing = 100;
//float treeSpacingRand = 20;
//Island
let jointSize = 2;
let boxSize = 2;
let trussSize = 5;
let facadeOn = true;
let floorOn = true;
let jointOn = false;
let trussOn = true;
let boxOn = false;
let boxFaceOn = true;
let platformOn = false;
let treetree;
let saving = false;
let xoff01 = 0.0;
/*
int thickness = 300;
int edgeNumber = 10;
int layerNumber = 30;
float randomRange = 100;
float layerHeight = 300;
ArrayList<PVector> jointList;
*/
function preload() {
createVRCanvas();
}
function setup(){
//c = createCanvas(window.innerWidth, window.innerHeight, WEBGL);
//c = createCanvas(windowWidth, windowHeight, WEBGL);
setVRBackgroundColor(200, 0, 150);
//cam = new Dw.EasyCam(this._renderer, {distance:3000, center:[centralX,centralY-200,centralZ]});
treeList= [];
rockList = [];
FTreeLocList = [];
FTreeColorList = [];
FTreeSizeList = [];
for(let i = 0; i<= 1; i+=1){
for(let j =0; j<= 1; j+=1){
//loc = createVector(i*treeSpacing+random(-treeSpacingRand,treeSpacingRand),0,j*treeSpacing+random(-treeSpacingRand,treeSpacingRand));
var loc = createVector(i*treeSpacing,0,j*treeSpacing);
//location, thickness, edgeNumber, layerNumber, randomRange, layerHeight, jointList
var jointList = [];
//PVector loc = new PVector(random(-3000,3000),0,random(-1500,1500));
//Tree(PVector loc, int thick, int eNumber, int lNumber, float rRange, float lHeight )
tree = new Tree(loc, 0.1,5,int(5),0.05,0.15, jointList);
//tree = new Tree(loc, 100,5,8,50,150, jointList);
treeList.push(tree);
}
}
var jointListIsland = [];
//FineCut
//locIsland = createVector(0, 900,0);
//island = new Island(locIsland,320,18,20,60,50, jointListIsland);
//RoughCut
locIsland = createVector(0, -0.8,0);
island = new Island(locIsland,0.64,5,10,0.08,0.1, jointListIsland);
/*
var jointList01 = [];
var jointList02 = [];
loc = createVector(500,0,0);
treetree = new Tree(loc,100,5,int(random(5,8)),50,150, jointList01);
loc2 = createVector(0,0,0);
treetree2 = new Tree(loc2,100,5,int(random(5,10)),50,150, jointList02);
*/
//floatingCube
for(let i = 0; i< 20; i+=1){
locRock = createVector(random(-0.75,0.75),0,random(-0.75,0.75));
floatingRock = new FloatingCube(locRock, random(0.18), random(0.01,0.02), random(5,10), random(-0.1,-0.2), random(0.008,0.01));
rockList.push(floatingRock);
}
//fakeTress
for(let i = 0; i< 10; i+=1){
locFTree = createVector(random(-0.68,0.68),random(-1,-5),random(-0.68,0.68));
FTreeColor = createVector(0,random(100,255),random(200,255));
FTreeSize = random(2,8);
FTreeLocList.push(locFTree);
FTreeColorList.push(FTreeColor);
FTreeSizeList.push(FTreeSize);
}
}
function draw(){
//background(#F5C3C3);
//background(255*abs(sin(frameCount*0.01)));
push();
//directionalLight(255,0,0,1,1,-1);
//directionalLight(255,255,255,1,1,-1);
//directionalLight(255,255,255,1,1,1);
//sun
push();
translate(0,-1.8,0);
rotateX(radians(30+frameCount));
rotateZ(radians(30+frameCount));
noFill();
fill(255,0,0,50);
noStroke();
//strokeWeight(2);
//stroke(200,200,0);
//sphere(400);
pop();
push();
translate(0,-1.8,0);
rotateX(radians(60+frameCount));
rotateZ(radians(60+frameCount));
noFill();
fill(255,200,0, 100);
noStroke();
//noStroke();
//strokeWeight(5);
//stroke(255,200,0);
sphere(400);
pop();
pop();
//bouncing
push();
translate(0, 0.1*sin(frameCount*0.05), 0);
scale(0.5,-0.5,0.5);
//floor
push();
translate(0,50,0);
fill(170);
strokeWeight(2);
stroke(255);
//box(2000,10,2000);
pop();
//fakeTree
/*
pushMatrix();
translate(0,-100,0);
rotateX(PI/2);
fill(#F5C3C3);
strokeWeight(2);
ellipse(0,0,1500,1500);
popMatrix();
*/
/*
push();
translate(0,-2600,0);
fill(255,200,50);
strokeWeight(2);
box(7200,50,4500);
pop();
*/
push();
translate(0,-7.5+0.5,0);
noFill();
strokeWeight(2);
stroke(255);
//box(2000,1500,2000);
pop();
//floatingCube
for(let i = 0; i< rockList.length; i+=1){
rocky = rockList[i];
//rocky.display();
}
//FTree
for(let i = 0; i< FTreeLocList.length; i+=1){
push();
translate(FTreeLocList[i].x, FTreeLocList[i].y, FTreeLocList[i].z);
strokeWeight(FTreeSizeList[i]);
stroke(FTreeColorList[i].x, FTreeColorList[i].y, FTreeColorList[i].z);
point(0,0,0);
pop()
/*
stroke(FTreeColorList[i].x, FTreeColorList[i].y, FTreeColorList[i].z);
strokeWeight(3);
line(FTreeLocList[i].x, FTreeLocList[i].y, FTreeLocList[i].z,0,0,0);
line(FTreeLocList[i].x, FTreeLocList[i].y, FTreeLocList[i].z,FTreeLocList[i].x, 0, FTreeLocList[i].z);
*/
}
for(let i=0; i<treeList.length; i++){
treeList[i].display();
//push();
//scale(1,-1,1);
//treeList[i].display();
//pop();
}
island.display();
//cam.rotateY(0.01);
if (frameCount % 100 == 0){
//jointList = [];
//loc = createVector(0,0,0);
//treetree = new Tree(loc,100,5,int(random(2,8)),50,150);
treeList = [];
for(let i = 0; i<= 1; i+=1){
for(let j =0; j<= 1; j+=1){
//loc = createVector(i*treeSpacing+random(-treeSpacingRand,treeSpacingRand),0,j*treeSpacing+random(-treeSpacingRand,treeSpacingRand));
var loc = createVector(i*treeSpacing,0,j*treeSpacing);
//location, thickness, edgeNumber, layerNumber, randomRange, layerHeight, jointList
var jointList = [];
//PVector loc = new PVector(random(-3000,3000),0,random(-1500,1500));
//Tree(PVector loc, int thick, int eNumber, int lNumber, float rRange, float lHeight )
tree = new Tree(loc, 0.1,5,int(5),0.05,0.15, jointList);
//tree = new Tree(loc, 100,5,8,50,150, jointList);
treeList.push(tree);
}
}
var jointListIsland = [];
//FineCut
//locIsland = createVector(0, 900,0);
//island = new Island(locIsland,320,18,20,60,50, jointListIsland);
//RoughCut
locIsland = createVector(0, 0.8,0);
island = new Island(locIsland,0.64,5,10,0.08,0.1, jointListIsland);
rockList = []
for(let i = 0; i< 20; i+=1){
locRock = createVector(random(-0.75,0.75),0,random(-0.75,0.75));
floatingRock = new FloatingCube(locRock, random(0.18), random(0.01,0.02), random(5,10), random(-0.1,-0.2), random(0.008,0.01));
rockList.push(floatingRock);
}
//fakeTress
FTreeLocList = [];
FTreeColorList = [];
FTreeSizeList = [];
for(let i = 0; i< 10; i+=1){
locFTree = createVector(random(-0.68,0.68),random(-1,-5),random(-0.68,0.68));
FTreeColor = createVector(0,random(100,255),random(200,255));
FTreeSize = random(0.02,0.08);
FTreeLocList.push(locFTree);
FTreeColorList.push(FTreeColor);
FTreeSizeList.push(FTreeSize);
}
}
pop();
}
function windowResized() {
resizeCanvas(windowWidth, windowHeight);
cam.setViewport([0,0,windowWidth, windowHeight]);
}
function keyPressed(){
if(key == 'a'){
let fs = fullscreen();
fullscreen(!fs);
}
if(key == 'f'){
facadeOn = !facadeOn;
}
if(key == 'd'){
floorOn = !floorOn;
}
if(key == 'j'){
jointOn = !jointOn;
}
if(key == 't'){
trussOn = !trussOn;
}
if(key == 'b'){
boxOn = !boxOn;
}
if(key == 'p'){
boxFaceOn = !boxFaceOn;
}
if(key == 'p'){
platformOn = !platformOn;
}
}