WebGL is a cross-platform, royalty-free web standard for a low-level 3D graphics API based on OpenGL ES 2.0, exposed through the HTML5 Canvas element...
Source : https://www.khronos.org/webgl/
JavaScript 3D Library which makes WebGL simpler.
let camera = new THREE.PerspectiveCamera(
70, window.innerWidth / window.innerHeight, 0.01, 2 );
camera.position.z = 1;
let scene = new THREE.Scene();
let geometry = new THREE.BoxGeometry( 0.2, 0.2, 0.2 );
let material = new THREE.MeshNormalMaterial();
let mesh = new THREE.Mesh( geometry, material );
scene.add( mesh );
let renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );
function animate() {
requestAnimationFrame( animate );
renderer.render( scene, camera );
}
animate();
mesh.rotation.x += 0.01;
mesh.rotation.y += 0.02;
let time = Date.now() / 1000;
mesh.position.x = Math.cos(time) * .3;
mesh.position.y = Math.sin(time) * .3;
let time = Date.now() / 1000;
mesh.scale.x = 1 + Math.cos(time) * .8;
mesh.scale.y = 1 + Math.sin(time) * .8;
(field of view)
let camera = new THREE.PerspectiveCamera(75, width / height, 0.01, 2);
(field of view)
let camera = new THREE.PerspectiveCamera(120, width / height, 0.01, 2);
(field of view)
let camera = new THREE.PerspectiveCamera(30, width / height, 0.01, 2);
let camera = new THREE.PerspectiveCamera(75, width / height, 1, 2);
let camera = new THREE.PerspectiveCamera(75, width / height, 0.01, 1);
let geometry = new THREE.SphereGeometry( 0.2, 32, 32 );
let geometry = new THREE.SphereGeometry( 0.2, 8, 8 );
let loader = new THREE.OBJLoader();
loader.load( 'teapot.obj', function ( object ) {
scene.add( object );
}, progressCallback, errorCallback);
let material = new THREE.MeshBasicMaterial({ color: 0x222222 });
let material = new THREE.MeshLambertMaterial({ color: 0x222222,
emissive: 0x000000 });
let material = new THREE.MeshPhongMaterial({ color: 0x222222,
emissive: 0x000000, specular: 0x111111, shininess: 30 });
let material = new THREE.MeshPhongMaterial({ color: 0x222222,
emissive: 0x000000, specular: 0x111111, shininess: 100 });
let material = new THREE.MeshStandardMaterial({ color: 0x222222,
roughness: .3, metalness: 0 });
let material = new THREE.MeshLambertMaterial({ ...,
flatShading: true });
let material = new THREE.MeshLambertMaterial({ ...,
wireframe: true });
let material = new THREE.MeshLambertMaterial({ ...,
transparent: true, opacity: .2 });
let textureLoader = new THREE.TextureLoader();
let texture = textureLoader.load('ball.jpg');
let material = new THREE.MeshLambertMaterial({ ...,
color: 0xffffff, map: texture });
let textureLoader = new THREE.TextureLoader();
let texture = textureLoader.load('ball_normal.jpg');
let material = new THREE.MeshLambertMaterial({ ...,
normalMap: texture, normalScale: new THREE.Vector2(1, 1) });
let urls = [ "posx.jpg", "negx.jpg", "posy.jpg", "negy.jpg", "posz.jpg", "negz.jpg" ];
let texture = new THREE.CubeTextureLoader().load( urls );
let material = new THREE.MeshLambertMaterial({ ...,
envMap: texture, reflectivity: .08 });
let textureLoader = new THREE.TextureLoader();
let texture = textureLoader.load('ball_light.jpg');
let material = new THREE.MeshLambertMaterial({ ...,
lightMap: texture, lightMapIntensity: 1 });
geometry.faceVertexUvs[1] = geometry.faceVertexUvs[0]; // important !
let ambientLight = new THREE.AmbientLight( 0x505050 );
scene.add( ambientLight );
let directionalLight = new THREE.DirectionalLight( 0xffffff, 1 );
scene.add( directionalLight );
let pointLight = new THREE.PointLight( 0xffffff, 1, 10 );
scene.add( pointLight );
let spotLight = new THREE.SpotLight( 0xffffff, 1, 1, 0.3, 1 );
scene.add( spotLight );