Learning-threejs-06

Developer
Size
2,628 Kb
Views
8,096

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 Previews

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();
Learning-threejs-06 - Script Codes
Learning-threejs-06 - Script Codes
Home Page Home
Developer Engin Arslan
Username enginarslan
Uploaded December 16, 2022
Rating 3
Size 2,628 Kb
Views 8,096
Do you need developer help for Learning-threejs-06?

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!

Engin Arslan (enginarslan) Script Codes
Create amazing captions with AI!

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!