```import peasy.*; PeasyCam cam; PVector [][] globe; int total =50;```
```float aVel = 0.0; float aAcc = 0.001; PImage imgForClr; color colrfromImg;```
```void setup(){ size(1200,848,P3D); cam = new PeasyCam(this,500); globe = new PVector[total+1][total+1];//take off 1 and there would be an incomplete sphere```
```frameRate(5); imgForClr = loadImage("img.jpg"); imgForClr.loadPixels(); }```
```void draw(){ background(0); noFill(); lights(); float r = 200.0;//radius for (int i=0;i<total+1;i++){ float lat = map(i,0,total,0,PI);```
```for (int j=0;j<total+1;j++){ float lon = map(j,0,total,0,TWO_PI);//PI =180 //polar to cartesian convertion float x = r* sin(lat) * cos (lon);//wikipedia float y = r* sin(lat) * sin (lon); float z = r* cos(lat); globe[i][j] = new PVector(x,y,z);//pos x, y, z are saved for every [lon] and [lat]```
```PVector v = PVector.random3D(); v.mult(10);```
```globe[i][j].add(v); lat +=aVel; lon +=aVel; } } aVel += aAcc; aVel = constrain(aVel,0,0.5); if (aVel>=0.2){ aVel = 0; aVel += aAcc; println(aVel); } for (int i=0;i<total;i++){ if (i%2==0){//everyother row fill(0); }else{ fill(10); } beginShape(TRIANGLE_STRIP); for (int j=0;j<total+1;j++){ PVector v1 = globe[i][j]; float xclr = random(width); float yclr = random(height); colrfromImg = imgForClr.get(int(xclr),int(yclr)); fill(colrfromImg); noStroke(); vertex(v1.x,v1.y,v1.z); PVector v2 = globe[i+1][j];//go down one to create triangle vertex(v2.x,v2.y,v2.z); } endShape(); } }```