Rotating Cube
How do I make an rotating cube?
What is a rotating cube? How do you make a rotating cube? This script and codes were developed by Omar Shehata on 13 August 2022, Saturday.
Rotating Cube - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Rotating Cube</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <script src='http://cdnjs.cloudflare.com/ajax/libs/three.js/r70/three.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Rotating Cube - Script Codes CSS Codes
body { margin: 0; } canvas { width: 100%; height: 100% }
Rotating Cube - Script Codes JS Codes
//Create the scene object
var scene = new THREE.Scene();
//We need a camera to see anything!
var camera = new THREE.PerspectiveCamera( 75, window.innerWidth/window.innerHeight, 0.1, 1000 );
//This is our renderer
var renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );
//To create an object, we need 3 things
//The goemetry, which could be a primitive like a box, a sphere, or something custom
var geometry = new THREE.BoxGeometry( 1, 1, 1 );
//The kind of material it's made from
var material = new THREE.MeshBasicMaterial( { color: 0xff0000 } );
//And a mesh object that binds them together
var cube = new THREE.Mesh( geometry, material );
//And don't forget to add it to the scene!
scene.add( cube );
//At this point, the cube is there, but you won't see it because it's right behind the camera
//Let's move the cube back on the Z axis to see it
cube.position.z = -2;
//This function will run 60 times per frame to render our scene
var render = function () { requestAnimationFrame( render ); //Rotate the cube! cube.rotation.x += 0.01; cube.rotation.y += 0.01; renderer.render(scene, camera);
};
render();
Developer | Omar Shehata |
Username | omarshe7ta |
Uploaded | August 13, 2022 |
Rating | 3 |
Size | 2,151 Kb |
Views | 26,312 |
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 |
WebMonkey Test | 8,206 Kb |
Pixijs.v3 Basic Shader | 2,269 Kb |
Ball Demo | 2,055 Kb |
Framebuffer - Final | 2,491 Kb |
Smoke Shader Complete | 3,451 Kb |
Smoke Shader - Frame Buffer | 2,672 Kb |
ACM Drawing Practice | 1,802 Kb |
Featherlight Zoom Test | 1,695 Kb |
Framebuffer - Texture Render | 2,402 Kb |
Smoke Shader - Diffuse | 3,283 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 |
Sidebar Thing | Jonambas | 2,779 Kb |
Responsive scrolling text | Ashdurham | 2,259 Kb |
Brian The CSS Bee | Jonitrythall | 3,922 Kb |
Button shaking | SusanneLundblad | 2,227 Kb |
Mobile Sub Menu Concept | Berdejitendra | 2,790 Kb |
Playing with FlexBox | _Billy_Brown | 3,162 Kb |
Sass Radar | Jlong | 6,887 Kb |
WRENCH - STAFF | Lolita-adams | 1,608 Kb |
SVG email test v2.0 | M_J_Robbins | 2,090 Kb |
Fun form with currentColor | Bnthor | 2,713 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!