-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
52 lines (39 loc) · 1.67 KB
/
script.js
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
44
45
46
47
48
49
50
51
52
import * as THREE from 'https://cdn.skypack.dev/[email protected]/build/three.module.js';
import { GLTFLoader } from 'https://cdn.skypack.dev/[email protected]/examples/jsm/loaders/GLTFLoader.js'
import { OrbitControls } from 'https://cdn.skypack.dev/[email protected]/examples/jsm/controls/OrbitControls.js'
// init
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera( 25, window.innerWidth / window.innerHeight, 1, 20000 );
camera.position.set( 1, 1, 20 );
const renderer = new THREE.WebGLRenderer( { alpha: true, antialias: true } );
renderer.setClearColor( 0xffffff, 0);
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1;
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );
// controls
const controls = new OrbitControls( camera, renderer.domElement );
// lights
const ambient = new THREE.PointLight(0xFFFFFF, 1);
ambient.position.set(0, 100, 10);
scene.add(ambient);
const ambient2 = new THREE.PointLight(0xFFFFFF, 1);
ambient2.position.set(10, 0, 100);
scene.add(ambient2);
//load gltf file
var loader = new GLTFLoader();
loader.load( './assets/thisisbowie2.gltf', function ( gltf ) {
var object = gltf.scene;
gltf.scene.scale.set( 2, 2, 2 );
gltf.scene.position.x = 0; //Position (x = right+ left-)
gltf.scene.position.y = 0; //Position (y = up+, down-)
gltf.scene.position.z = 0;
gltf.scene.rotation.x = 90 * Math.PI/180; //Position (z = front +, back-)
scene.add( gltf.scene );
animate();
});
function animate() {
requestAnimationFrame( animate );
controls.update();
renderer.render( scene, camera );
}