Three.js

Three.js (https://github.com/mrdoob/three.jsis an open source library that powers many of the WebGL applications on the web. It aims to create an easy to use, lightweight, 3D library, with multiple renderers that target 2D canvas, WebGL, SVG, and CSS3D. Here's a neat demo of a rotating cube, showcasing the simplicity of the Three.js API:

let
renderer,
scene,
camera,
mesh,
width = window.innerWidth,
height = window.innerHeight;

function init() {
camera = new THREE.PerspectiveCamera(70, width / height, 0.01, 10);
camera.position.z = 1;

scene = new THREE.Scene();

const mesh = new THREE.Mesh(
// geometry
new THREE.BoxGeometry(0.2, 0.2, 0.2),
// material
new THREE.MeshNormalMaterial()
);
scene.add(mesh);

renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setSize(width, height);
document.body.appendChild(renderer.domElement);
}

function render() {
requestAnimationFrame(render);
mesh.rotation.x += 0.01;
mesh.rotation.y += 0.02;
renderer.render(scene, camera);
}

init();
render();

You can see the live demo on their GitHub page, which resembles the following:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.42.196