How to Create a 3D Rotating Cube in Javascript | ThreeJS | Basic Explanation

Publicado em: 03 Agosto 2019
no canal de: Major Mango
12,245
153

How to Create a 3D Rotating Cube in Javascript, using ThreeJS!
In this video you will find a detailed explanation for beginners to the world of 3D Rendering using the WebGL Library ThreeJS.

ThreeJS is a Javascript Library which makes it simple to use WebGL components in our web applications.

Download the ~500KB ThreeJS library:
https://github.com/mrdoob/three.js/tr...

Like the video to support future videos. Subscribe to know more interesting stuff about the coding world.

Here is the finished Javascript code from the Video:
-START OF CODE-

var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera(
75, window.innerWidth/window.innerHeight,
0.5, 1000
);
camera.position.z = 5;

var renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);

//Cube
var geometry = new THREE.BoxGeometry(1, 1, 1);
var material = new THREE.MeshNormalMaterial({color: 0x00aaff});

var cube = new THREE.Mesh(geometry, material);
scene.add(cube);

function animate(){
requestAnimationFrame(animate);

cube.rotation.x += 0.01;
cube.rotation.y += 0.01;

renderer.render(scene, camera);
}

animate();

-END OF CODE-

Subscribe to the channel :)


Nesta página do site você pode assistir ao vídeo on-line How to Create a 3D Rotating Cube in Javascript | ThreeJS | Basic Explanation duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário Major Mango 03 Agosto 2019, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 12,245 vezes e gostou 153 espectadores. Boa visualização!