Rotating Cubes with p5.js
How do I make an rotating cubes with p5.js?
What is a rotating cubes with p5.js? How do you make a rotating cubes with p5.js? This script and codes were developed by Ruslan Marin on 07 December 2022, Wednesday.
Rotating Cubes with p5.js - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Rotating Cubes with p5.js</title>
</head>
<body> <div id="canvasContainer"></div> <script src='https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.6/p5.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Rotating Cubes with p5.js - Script Codes JS Codes
var cube3d = { theta: 0, draw: function(p, sizeX, sizeY) { p.push(); p.rotateZ(this.theta); p.rotateX(this.theta); p.rotateY(this.theta); p.box(sizeX/8, sizeX/8, sizeX/8); p.pop(); this.theta += Math.PI/128; }
};
var cube2d = { theta: 0, draw: function(p, sizeX, sizeY) { p.push(); p.rotateZ(-this.theta); p.translate(sizeX/4, -sizeX/16); p.rotateZ(-2*this.theta); p.rect(-sizeX/16, -sizeX/16, sizeX/8, sizeY/8); p.pop(); this.theta += Math.PI/128; }
};
var sketchProc = function(p) { var sizeX = 400; var sizeY = 400; var theta = 0; var objects = [cube3d, cube2d]; p.setup = function() { p.frameRate(30); p.createCanvas(sizeX, sizeY, p.WEBGL); }; // Draw loop p.draw = function(){ p.background(1); objects.forEach(function(obj) { obj.draw(p, sizeX, sizeY); }); };
};
new p5(sketchProc, document.getElementById("canvasContainer"));
Developer | Ruslan Marin |
Username | marinru |
Uploaded | December 07, 2022 |
Rating | 3 |
Size | 1,753 Kb |
Views | 28,336 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Vue.js Basic Component | 1,566 Kb |
Vue.js Attribute Binding | 1,531 Kb |
Simple Component Example 2 | 2,099 Kb |
Vue.js Conditional Visibility | 1,520 Kb |
Component State | 3,702 Kb |
Vue 001. Hello World | 1,438 Kb |
Component Props | 3,113 Kb |
BnW | 1,489 Kb |
Sidescroller with p5.js | 2,455 Kb |
A Pen by Ruslan Marin | 1,561 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Sass Get Function | Lukewatts | 2,155 Kb |
Background Images | Jooonebug | 2,100 Kb |
Parallax scrolling scene | Iharosi | 2,485 Kb |
Retina canvas w. resize | Erikterwan | 1,882 Kb |
Apple website | Jds317 | 1,835 Kb |
Default Input, Textareas, Submits, and Buttons in iOS | Demersdesigns | 2,334 Kb |
Long Shadow Button | Uixcrazy | 3,550 Kb |
Obligatory CSS3 UI Nav | Romandiaz | 9,017 Kb |
CSS3 Snow Animation | NickyCDK | 1,695 Kb |
Amazing CSS Menu with Notification Badges | Faizanasad | 2,549 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!