-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
43 lines (32 loc) · 975 Bytes
/
main.js
File metadata and controls
43 lines (32 loc) · 975 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//import './style.css'
import './three.min.js'
import './GLTFLoader.js'
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000);
const render = new THREE.WebGLRenderer({
canvas: document.querySelector('#render')
});
render.setPixelRatio(window.devicePixelRatio);
render.setSize(window.innerWidth, window.innerHeight);
camera.position.setZ(20);
const loader = new THREE.GLTFLoader();
var obama
loader.load( './obama.glb', function ( gltf ) {
obama = scene.add( gltf.scene );
setup();
}, undefined, function ( error ) {
console.error( error );
} );
function setup() {
const light = new THREE.AmbientLight( 0xffffff ); // soft white light
scene.add( light );
const obamaClone = obama.clone();
scene.add(obamaClone)
obamaClone.position.setZ(30)
animate()
}
function animate() {
requestAnimationFrame(animate);
obama.rotation.y += 0.06
render.render(scene, camera);
}