css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              
<div id = "stage"> </div>
            
          
!
            
              html, body {
  margin: 0;
  padding: 0;
  background-color: rgba(68, 68, 68, .001);
/*     background: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/255459/tiny-squares.png) no-repeat center center fixed; 
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover; */
  
}

button {
  height: 75px;
  width: 200px;
  background-color: #444;
  color: white;
  font-size: 27px;
}
            
          
!
            
              let angle = 0;
let t =1;
let shapes = [];
let lat, long;
let terminal;
let padding;
let r,h,x,y,z;
let c;
let flag;
let rotation;
let windowX, windowY;
let v, v1, v2, globalV;
let tamrLight = "rgb(217, 239, 248)";
let tamrDark = "rgb(12, 96, 142)";

responsiveCanvas = () =>{
  windowX = (windowWidth - width) / 2;
  windowY = (windowHeight - height) / 2;
  c.position(windowX, windowY);
}

 setup = () => { 
  c = createCanvas(900, 600, WEBGL);
   responsiveCanvas() ;
      
     // ortho(-width, width, height, -height/2, 0.1, 100);
   ortho()
   // noLoop()
   // flag = false;
   rotation = -90;
   globalV = createVector(250, -400, -95)
   globalV.normalize
   
   v1 = createVector(300,500, 50);
   v2 = createVector(-300,-500, -50);

 
   // variables for all shapes
   let shapeWidth = 40;
   let perRow = 5;

   // placing the shapes
   // let shapeR = random(35, shapeWidth)
   let shapeR = 30;
   let shapeH = random(20,60)

   let rowOneY = 100;
   let rowOneX = 0;
  for (var i = 0;i<perRow;i++){ 
    shapes.push(new Structure(shapeR, shapeH, rowOneX, rowOneY, 0, .5))
    
    rowOneX += shapeWidth*TWO_PI;
   }
   
     let rowTwoY = 300;
   let rowTwoX = 0;
  for (var i = 0;i<perRow;i++){ 
    shapes.push(new Structure(shapeR, shapeH, rowTwoX, rowTwoY, 0, -3))
    
    rowTwoX += shapeWidth*TWO_PI;
   }
   
     let rowThreeY = 500;
   let rowThreeX = 0;
  for (var i = 0;i<perRow;i++){ 
    shapes.push(new Structure(shapeR, shapeH, rowThreeX, rowThreeY, 0, -3))
    
    rowThreeX += shapeWidth*TWO_PI;
   }
  padding = 200;
  // frameRate(.5);
} 
 

 draw = () => {
   
     //drag to move the world.

  rotateX(mouseX)
  v1.normalize()
  v2.normalize()

   translate(-500, -300, 0)
   
   
  // camera(0,0, (height/2)/tan(PI/6), 50, 0, 0, 1, 0, 0)
   // ortho(600,-600,900,-900/2,0.01,1000)
   // ortho(600,-600,900,-900/2,0.01,1000)

  // background('rgba(119, 20, 39,.9)')
  // background("rgba(211, 246, 250, .2)")
      background(tamrDark)

   
     //drag to move the world.
  // orbitControl();

            /* LIGHTS  */

   // light grey
   // ambientLight("rgb(243, 244, 245)")
   // light blue
  // normalMaterial("rgba(12,56,95, 1")
  
   /* active lights and material*/
      // ambientLight("rgbs(15, 127, 201)")
   // directionalLight(12,56, 95, v1)
   
     /* OK SO SETTING AMBIENT COLOR IN DRAW AFFECTS ALL SHAPES PRETTY EQUAL BUT SETTING AN AMBIENT LIGHT ON EACH ELEMENT HAS AN INTERESTING AFFECT */
   
   // red/orange
 // ambientLight("rgb(226, 32, 27)")
   
   // directionalLight("rgb(141, 173, 201)", v2)
 // directionalLight("rgb(226, 32, 27)", globalV)
   
  // ambientMaterial("rgba(12,56,95, 1")
      // ambientMaterial("white")

   
           /* MATTER */
   for (var i = 0; i < shapes.length; i++) {
// var force = attractor.calculateAttraction(orbiters[i]); 
     push();
     shapes[i].show();
     pop();
// shapes[i].applyForce(force);
// shapes[i].update();
}
 }
 
       /* CONSTRUCTOR */
 class Structure {
   
   constructor (r, h, x, y, z, rot){
     this.r = r;
     this.h = h;
     this.x = x;
     this.y = y;
     this.z = z;
     this.rot = rot;
     
   }
   move(){
     
   }
   show(){
     // globalV = createVector(-20,-400, -95)
     // globalV.normalize
    
     
     
     /*Active lights*/

     /* OK SO SETTING AMBIENT COLOR IN DRAW AFFECTS ALL SHAPES PRETTY EQUAL BUT SETTING AN AMBIENT LIGHT ON EACH ELEMENT HAS AN INTERESTING AFFECT */
        // stroke(252)
     let activeColor = "rgb(15, 127, 201)";
     // blue-uncmmenting this des smething very interesting lol
      // ambientLight("rgba(12, 56, 95, 1)")

     
     // alt blue - coming out black--start here why?
     // directionalLight(activeColor, globalV)
       directionalLight(12, 56, 95, 0.1, -1, 0, sin(t / 2));

  // directionalLight(217, 239, 248, 0.1, 1, 0, sin(t));
    ambientMaterial(tamrLight)
     
        // light grey
   // ambientLight("rgb(243, 244, 245)")
     
     
 // directionalLight(12,56, 95, v)
  // rotateY(angle)
  // rotateZ(angle/HALF_PI)
       // translate(this.x, this.y, this.z);
   translate(this.x, this.y, this.z);
  // rotateX(this.rot)
     // rotateZ(10)
     // rotateY(30)
     
     rotateX(rotation)
     cylinder(this.r, this.h)
     // rotation -= .001
//      if (frameCount > 220){
//        noLoop()
//      console.log(frameCount)
     
//      }
    // cylinder(this.r, 0)
     
  // let thing = cylinder(this.r, this.h,20,20)
  
  // let thingTwo = cylinder(this.r, this.h,100,100)
  // rotateX(-90)
     
     
     // angle += 0.0007;
   }
}

windowResized = () => {
  // resizeCanvas(windowWidth, windowHeight);
  responsiveCanvas();
  
  // howManyShapes = round(windowWidth/shapeSize)-5;
}

   // button off- goes back in setup to turn on with function below
   // let button = createButton("Transition 1")
   // button.position(100,40)
   // button.mousePressed(transOne)

function transOne(){
   console.log('working')
 flag = true;   
   loop()
 }
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console