This repository has been archived by the owner on Oct 22, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
93 lines (75 loc) · 2.37 KB
/
index.html
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Nine</title>
<style>
body {
margin: 0;
}
canvas {
display: block;
}
</style>
</head>
<body>
<script type="module">
// Find the latest version by visiting https://unpkg.com/three. The URL will redirect to the newest stable release.
import * as THREE from "https://unpkg.com/[email protected]/build/three.module.js";
import { GLTFLoader } from 'https://unpkg.com/[email protected]/examples/jsm/loaders/GLTFLoader.js';
const scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera(
75,
window.innerWidth / window.innerHeight,
0.1,
1000
);
// var renderer = new THREE.WebGLRenderer();
var renderer = new THREE.WebGLRenderer({ alpha: true });
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
//camera.position.z = 0.025;
camera.position.z = 2;
var light = new THREE.AmbientLight(0x404040, 30); // soft white light
scene.add(light);
var light = new THREE.PointLight(0xff0000, 1, 100);
light.position.set(50, 50, 50);
scene.add(light);
var light = new THREE.PointLight(0xffffff, 5, 100);
light.position.set(-50, -50, 50);
scene.add(light);
var nine;
var loader = new GLTFLoader();
loader.load(
"scene.gltf",
function(gltf) {
nine = gltf.scene;
scene.add(nine);
},
undefined,
function(error) {
console.error(error);
}
);
/*
var loadingManager = new THREE.LoadingManager(function() {
scene.add(nine);
});
var textureLoader = new THREE.TextureLoader();
var texture = textureLoader.load("../model/car_white.jpg");
var loader = new THREE.ColladaLoader(loadingManager);
loader.load("./models/nine/nine.dae", function(collada) {
nine = collada.scene;
});
*/
var animate = function() {
requestAnimationFrame(animate);
if (nine.rotation != null) {
nine.rotation.y += 0.01;
}
renderer.render(scene, camera);
};
animate();
</script>
</body>
</html>