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

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

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

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

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

var bgFill = pMagenta;
var ambiFill = '#ccc';
var innerDomeFill = pBrightBlue;
var outerDomeFill = pDarkBlue;
var torusesFill = pWhite;
var midTorsFill = pGreen;
var bigTorsFill = pBrightBlue;

var pointR = 10;
var pointG = 240;
var pointB = 7;

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);
	
	smallTorus = loadModel('https://cdn.glitch.me/4976d32d-fd94-4dd4-8b88-2150e673b6a1%2FsmallTorus.obj', true);
	
	midTorus = loadModel('https://cdn.glitch.me/4976d32d-fd94-4dd4-8b88-2150e673b6a1%2FmidTorus.obj', true);
	
	// bigTorus = loadModel('https://cdn.glitch.me/4976d32d-fd94-4dd4-8b88-2150e673b6a1%2FbigTorus.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);
	
	push();
	translate(100,100,0) 
	// ^ just translated the whole thing 100px XY 
	//   so that our 0,0 will be there.
	pointLight(pointR, pointG, pointB, 1000, 1000, 1000);
	pointLight(point2R, point2G, point2B, -1000, 1000, 1000);
	
	

	// ================ | DRAWING
	
	// ------------------------- | inner center dome	

	push();
	fill(innerDomeFill);
	scale(0.2);
	rotateX(map(mouseY,0, windowHeight, 360,180))
	domeObj();
	pop();
	
	// ------------------------- | outer center dome	

	push();
	fill(outerDomeFill);
	rotateY(map(mouseX,0, windowWidth, 360,180))
	scale(0.3);
	domeObj();
	pop();
	
	// ------------------------- | torus S
	push();
	noStroke();
	fill(torusesFill);
	rotateY(map(mouseX,0, windowWidth, 0, 20));
	rotateX(map(mouseY,0, windowHeight, 10, 45));
	rotateZ(map(mouseX,0, windowWidth, 15, 45));
	scale(map(mouseY,0, windowHeight, 1, 2),0.5,2);
	sTorusObj()
	pop();
	

	// ------------------------- | torus M
	
	push();
	noStroke();
  rotateY(map(mouseX,0, windowWidth, 0, 30));
	rotateX(map(mouseY,0, windowHeight, 10, 55));
	rotateZ(map(mouseY,0, windowHeight, 10, 35));
	translate(-100,0,0)
	fill(midTorsFill);
	scale(map(mouseY,0, windowHeight, 2, 4),1,3);
  mTorusObj()
	pop();
	
	
		// ------------------------- | torus L
	
	push();
	noStroke();
  rotateY(map(mouseY,0, windowHeight, 2, 60));
	rotateX(map(mouseX,0, windowWidth, 15, 85));
	rotateZ(map(mouseX,0, windowWidth, 15, 65));
	translate(-100,0,0)
	fill(bigTorsFill);
	scale(map(mouseY,0, windowHeight, 3, 4.5),2,4);
  mTorusObj()
	pop();
	
	
  pop();
	
}

	










//================================================//
// ================ | BASE SHAPES | ============= // 
//================================================//
// setting the base shapes to the ideal parameters after loading & before using them

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();
}


function sTorusObj(){
	push();
	noStroke();
	rotateX(90);
	model(smallTorus);
	pop();
}

function mTorusObj(){
	push();
	noStroke();
	rotateX(90);
	model(midTorus);
	pop();
}

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

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

	// push();
	// rotateX();
	// rotateZ();
	// translate();
	// fill(pWhite);
	// 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, 255, 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