Learning-threejs-06
How do I make an learning-threejs-06?
This is a multi-part walkthrough for creating photorealistic 3D graphics on the web. I will teach you how to build a simple 3D scene with three.js and make it look semi-photorealistic using some common lighting, texturing and animation techniques. The purpose of this walkthrough is to build a simple and comprehensible example that is also interesting and engaging. To learn more about three.js and 3D graphics on the web, check out my course on lynda.com. What is a learning-threejs-06? How do you make a learning-threejs-06? This script and codes were developed by Engin Arslan on 16 December 2022, Friday.
Learning-threejs-06 - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>learning-threejs-06</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div id="webgl"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/86/three.min.js"></script> <script src="js/index.js"></script>
</body>
</html>
Learning-threejs-06 - Script Codes CSS Codes
body { margin: 0; padding: 0; overflow: hidden;
}
Learning-threejs-06 - Script Codes JS Codes
function init() { var scene = new THREE.Scene(); var camera = new THREE.PerspectiveCamera( 45, window.innerWidth/window.innerHeight, 1, 1000 ); var spotLight_01 = getSpotlight(0xffffff, 1); var spotLight_02 = getSpotlight(0xffffff, 1); // create geometric objects var plane = getPlane(50, 50); var sphere = getSphere(1); sphere.name = 'sphere'; // add objects to the scene scene.add(sphere); scene.add(plane); scene.add(spotLight_01); scene.add(spotLight_02); // transform objects camera.position.x = 0; camera.position.y = 6; camera.position.z = 6; camera.lookAt(new THREE.Vector3(0, 0, 0)); spotLight_01.position.x = 6; spotLight_01.position.y = 8; spotLight_01.position.z = -20; spotLight_02.position.x = -12; spotLight_02.position.y = 6; spotLight_02.position.z = -10; plane.rotation.x = Math.PI/2; sphere.position.y = sphere.geometry.parameters.radius; // material adjustments var planeMaterial = plane.material; planeMaterial.roughness = 0.65; planeMaterial.metalness = 0.75; var renderer = new THREE.WebGLRenderer(); renderer.shadowMap.enabled = true; document.getElementById('webgl').appendChild(renderer.domElement); renderer.setSize(window.innerWidth, window.innerHeight); update(renderer, scene, camera);
}
function getSphere(radius) { var geo = new THREE.SphereGeometry(radius, 24, 24); var material = new THREE.MeshStandardMaterial({ color: 0xffffff, }); var mesh = new THREE.Mesh(geo, material); mesh.castShadow = true; return mesh;
}
function getPlane(w, h) { var geo = new THREE.PlaneGeometry(w, h); var material = new THREE.MeshStandardMaterial({ color: 0xffffff, side: THREE.DoubleSide, }); var mesh = new THREE.Mesh(geo, material); mesh.receiveShadow = true; return mesh;
}
function getSpotlight(color, intensity) { var light = new THREE.SpotLight(color, intensity); light.castShadow = true; light.shadow.mapSize.x = 4096; light.shadow.mapSize.y = 4096; return light;
}
function update(renderer, scene, camera) { renderer.render(scene, camera); requestAnimationFrame(function() { update(renderer, scene, camera); })
}
init();
Developer | Engin Arslan |
Username | enginarslan |
Uploaded | December 16, 2022 |
Rating | 3 |
Size | 2,628 Kb |
Views | 8,096 |
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 |
Book-cover-step-13 | 2,076 Kb |
Learning-threejs-08 | 165,404 Kb |
Learning-threejs-02 | 2,211 Kb |
Learning-threejs-00 | 1,752 Kb |
Book-cover-step-01 | 1,824 Kb |
Book-cover-step-14 | 2,091 Kb |
P5.js basic template | 1,807 Kb |
P5.js template | 1,827 Kb |
Book-cover-step-06 | 1,943 Kb |
P5.js generative art | 2,180 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 |
Delete Hover | Chungman93 | 2,557 Kb |
Sample Profile Screen | OurDailyBread | 5,375 Kb |
React Recipe Box | Krokodill | 5,347 Kb |
Vue.js | Thommyboy02 | 1,506 Kb |
Mobile Sub Menu Concept | Berdejitendra | 2,790 Kb |
Expert Help | SinceSidSlid | 4,064 Kb |
Animated Donut Chart | Jplhomer | 3,808 Kb |
Pruebas de d3.js | Juanmanuelcarnerero | 2,485 Kb |
A bit of elegance | Hackthevoid | 9,095 Kb |
TweetBox with React JS | J0zelito | 3,325 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!