Pulley gltf

three.js gltf example

by frogman_pep

HTML

<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
		<link type="text/css" rel="stylesheet" href="main.css">
	</head>
	<body>

		<div id="container"></div>
    
    <script type="module">

			import * as THREE from './module/three.module.js';

			

			import { OrbitControls } from './module/OrbitControls.js';
			import { GLTFLoader } from './module/GLTFLoader.js';
			import { RoughnessMipmapper } from './module/RoughnessMipmapper.js';


			var container = document.getElementById( 'container' );

			var renderer, scene, camera;
			
			window.addEventListener( 'load', init );

			function init() {

				renderer = new THREE.WebGLRenderer( { antialias: true } );
				renderer.setPixelRatio( window.devicePixelRatio );
				renderer.setSize( window.innerWidth, window.innerHeight );				
				container.appendChild( renderer.domElement );

				scene = new THREE.Scene();
				scene.background = new THREE.Color (0x2d2d2d);

				camera = new THREE.PerspectiveCamera( 12, window.innerWidth / window.innerHeight, .2, 6 );
				camera.position.set( - 2.8, 0.0, -1.0 );
				

				var controls = new OrbitControls( camera, renderer.domElement );
				controls.minDistance = 2;
				controls.maxDistance = 4.9;
				controls.target.set( 0, 0, 0 );
				controls.update();

				scene.add( new THREE.AmbientLight( 0x443333 ) );

				var light = new THREE.DirectionalLight( 0xffddcc, 1 );
				light.position.set( 1, 0.75, 0.5 );
				scene.add( light );

				var light = new THREE.DirectionalLight( 0xccccff, 1 );
				light.position.set( - 1, 0.75, - 0.5 );
				scene.add( light );

				loadLeePerrySmith();

				window.addEventListener( 'resize', onWindowResize, false );

				onWindowResize();
				animate();

			}

			function loadLeePerrySmith() {				

				var loader = new GLTFLoader();

				loader.load( 'Face_Pulley.gltf', function ( gltf ) {

						scene.add( gltf.scene...

CSS

body {
	margin: 0;
	background-color: #b13939;
	color: #fff;
	font-family: Monospace;
	font-size: 13px;
	line-height: 24px;
	overscroll-behavior: none;
}

a {
	color: #ff0;
	text-decoration: none;
}

a:hover {
	text-decoration: underline;
}

button {
	cursor: pointer;
	text-transform: uppercase;
}

canvas {
	display: block;
	background-color: #b13939;
}

#info {
	position: absolute;
	top: 0px;
	width: 100%;
	padding: 10px;
	box-sizing: border-box;
	text-align: center;
	-moz-user-select: none;
	-webkit-user-select: none;
	-ms-user-select: none;
	user-select: none;
	pointer-events: none;
	z-index: 1; /* TODO Solve this in HTML */
}

a, button, input, select {
	pointer-events: auto;
}

.dg.ac {
	-moz-user-select: none;
	-webkit-user-select: none;
	-ms-user-select: none;
	user-select: none;
	z-index: 2 !important; /* TODO Solve this in HTML */
}

#overlay {
	position: absolute;
	z-index: 2;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(97, 97, 97, 0.7);
}

	#overlay button {
		background: #ffffff;
		border: 0;
		color: #000000;
		padding: 16px 20px;
		text-transform: uppercase;
		cursor: pointer;
	}

#notSupported {
	width: 50%;
	margin: auto;
	background-color: #f00;
	margin-top: 20px;
	padding: 10px;
}