Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <html>
  <head>
   <!-- add link to p5js	-->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.0/p5.min.js"></script>
  </head>
  <body>
  </body>
</html>

              
            
!

CSS

              
                /* - reset css - */ 
html,body,div,form,fieldset,legend,label{margin:0;padding:0;}
table{border-collapse:collapse;border-spacing:0;}
th,td{text-align:left;vertical-align:top;}
h1,h2,h3,h4,h5,h6,th,td,caption{font-weight:normal;}
img{border:0;}
canvas{display:block;}


              
            
!

JS

              
                //plan for creative code: 
//different rain color every time the drops "reborn"
//drops scale from 0 to their sizes and move down until they disappear 
//and when they do they reposition and rescale with a different color from the palette. 


//================================================//
// ========= | PRELOAD + INITIAL VARS | ========= // 
//================================================//

//-------------- | color palette

var pMagenta = '#D037F5';
var pDarkBlue = '#0A1045';
var pBrightBlue = '#003ACC';
var pLightPurple = '#8098FF';
var pGreen = '#0AF007';
var pWhite = '#ffffff'

//-------------- | initial vars


var bgFill = pBrightBlue;
var ambiFill = pLightPurple;
var cloudFill = pWhite;
var drop1Fill = pMagenta;
var drop2Fill = drop1Fill;
var drop3Fill = drop1Fill;

var pointR = 208;
var pointG = 55;
var pointB = 245;

var point2R = 255;
var point2G = 255;
var point2B = 255;


//-------------- | preload building blocks

function preload() {
  dome = loadModel('https://cdn.glitch.me/4976d32d-fd94-4dd4-8b88-2150e673b6a1%2Fdome.obj', true);
	
	
	hollowCone = loadModel('https://cdn.glitch.me/4976d32d-fd94-4dd4-8b88-2150e673b6a1%2Fcone.obj', true);
	
	drop = loadModel('https://cdn.glitch.me/4976d32d-fd94-4dd4-8b88-2150e673b6a1%2Fdrop.obj', true);
}



//================================================//
// ========== | SETUP + GENERATE ONCE | ========= // 
//================================================//


function setup() {
	createCanvas(500, 500, WEBGL);
angleMode(DEGREES);
}




//================================================//
// ============= | GENERATE CONTINOUS | ========= // 
//================================================//

function draw() {
	scale(0.5);
	background(bgFill);
	// orbitControl(4);
	// drawAxis();
	// drawGrid();

	ambientLight(ambiFill);
	// pointLight(pointR, pointG, pointB, 1000, 1000, 1000);
	pointLight(point2R, point2G, point2B, -1000, 1000, 1000);

	
// ------------------------- | 1st from right dome	
	push();
	translate(200, -70,0);
	rotateX(0);
	rotateY(020);
	rotateZ(170);
	scale(0.7);
	
		// I used these individual pushes before creating the OBJ functions. 
    // I think they will be very annoying to replace, so will do next time.
		push();
		noStroke();
		fill(cloudFill);
		rotateX(0);
		rotateY(0);
		rotateZ(map(mouseX, 0, windowWidth, 0,45));
		translate(-50, 0,0);
		model(dome);
		pop();

	pop();


// ------------------------- | 2nd from right dome	

	push();
	translate(80,-150,0);
	rotateX(0);
	rotateY(200);
	rotateZ(20);
	scale(1.2);
	
		push();
		noStroke();
		fill(cloudFill);
		rotateX(0);
		rotateY(0);
		rotateZ(map(mouseX, 0, windowWidth, 0,45));
		translate(-50, 0,0);
		model(dome);
		pop();

	pop();
	
	// ------------------------- | 3rd from right dome	

	push();
	translate(-30,-250,0);
	rotateX(-00);
	rotateY(-35);
	rotateZ(45);
	scale(0.9);
	
		push();
		noStroke();
		fill(cloudFill);
		rotateX(0);
		rotateY(0);
		rotateZ(map(mouseX, 0, windowWidth, 0,85));
		translate(-50, 0,0);
		model(dome);
		pop();

	pop();
	
		// ------------------------- | 4th from right dome	

	push();
	translate(-130,-120,0);
	rotateX(0);
	rotateY(-20);
	rotateZ(45);
	scale(1);
	
		push();
		noStroke();
		fill(cloudFill);
		rotateX(0);
		rotateY(0);
		rotateZ(map(mouseX, 0, windowWidth, 0,35));
		translate(-50, 0,0);
		model(dome);
		pop();

	pop();
	
	
// ------------------------- | 5th from right dome	
	push();
	translate(-250, -70,0);
	rotateX(50);
	rotateY(000);
	rotateZ(180);
	scale(0.7);
	  
		push();
		noStroke();
		fill(cloudFill);
		rotateX(180);
		rotateY(180);
		rotateZ(map(mouseX, 0, windowWidth, 0,55));
		translate(-50, 0,0);
		model(dome);
		pop();

	pop();
	
	// ------------------------- | middle DROP	
  push();
	// rotateX();
	// rotateZ();
  translate(0,map(mouseX, 0, windowWidth, -300,100),0);	
	scale(map(mouseY, 0, windowHeight, 00,1));
	fill(drop2Fill);
  dropObj()
	pop();


	// ------------------------- | right DROP	
  push();
	// rotateX();
	// rotateZ();
  translate(100,map(mouseX, 0, windowWidth, 0,50),0);	
	scale(map(mouseY*0.8, 0, windowHeight, 0,0.9));
	fill(drop1Fill);
  dropObj()
	pop();

	
	
	// ------------------------- | left DROP	
  push();
	// rotateX();
	// rotateZ();
  translate(-100,map(mouseX, 0, windowWidth, -100,20),0);	
	scale(map(mouseY*0.6, 0, windowHeight, 0,0.7));
	fill(drop3Fill);
  dropObj()
	pop();
	
	
}






//================================================//
// ================ | BASE SHAPES | ============= // 
//================================================//


function domeObj(){
		push();
	  noStroke();
		rotateX(-90);
		rotateZ(-91); // to align it perfectly
		translate(-50, 0,0);
		model(dome);
		pop();
}



function dropObj(){
	push();
	noStroke();
	rotateZ(180);
	translate(0,-100,0);
	model(drop);
	pop();
}


function coneObj(){
	push();
	noStroke();
	translate(-7.5,0,-61);//to align
	rotateY(7);//to fix the crooked position
	rotateY(180); // to flip 
	model(hollowCone);
	pop();
}






//================================================//
// =============== | NOTES | ============ // 
//================================================//

// -------------- | Basic stuff I'd want to do with a model

	// push();
	// rotateX();
	// rotateZ();
	// translate();
	// fill('#0E8AE3');
	// domeObj()
	// pop();



	//  rotateZ(map(mouseX, 0, windowWidth, -(Zrot/2),Zrot/2));
	// Xrot, Yrot, Zrot is a degree, preferably not more than 55

  //	translate(0,map(mouseX, 0, windowWidth, 0,Ytran),0);
	// Ytran is a distance, scl is scale 























	//===============| guides & grid

function drawAxis() {
	push();
	strokeWeight(3);
	stroke(255, 0, 0);
	line(0, 0, 0, 100, 0, 0);
	stroke(0, 0, 0);
	line(0, 0, 0, 0, 100, 0);
	stroke(0, 0, 255);
	line(0, 0, 0, 0, 0, 100);
	pop();
}

function drawGrid() {
	let sz = 1000;
	let num = 10;
	push();
	translate(-sz / 2, -sz / 2, 0);
	stroke(200);
	for (var i = 0; i < num + 1; i++) {
		line((i * sz) / num, 0, 0, (i * sz) / num, sz, 0);
		line(0, (i * sz) / num, 0, sz, (i * sz) / num, 0);
	}
	pop();
}

              
            
!
999px

Console