-
Notifications
You must be signed in to change notification settings - Fork 0
/
cafe.html
144 lines (124 loc) · 4.88 KB
/
cafe.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<!DOCTYPE html>
<html>
<head>
<title>KT 융합기술원 - 1층 카페/ 이벤트 참가</title>
<meta name="author" content="Sean Bradley" />
<link rel="stylesheet" href="/stylesheets/style.css" />
<style>
body {
overflow: hidden;
margin: 0px;
}
a {
color: #ffffff;
}
#progressBar {
width: 500px;
height: 24px;
position: absolute;
left: 50%;
top: 25px;
margin-left: -250px;
}
#instructions {
color: white;
position: absolute;
left: 50%;
top: 10px;
margin-left: -120px;
font-family: monospace;
}
</style>
</head>
<body>
<a href="/view_source/loader-fbx.html" id="vwSrcLink" target="_blank"><></a>
<progress value="0" max="100" id="progressBar"></progress>
<div id="instructions">
Model from <a href="https://www.mixamo.com" target="_blank" rel="nofollow noopener">Mixamo</a>
</div>
<script type="module">
import * as THREE from 'https://cdn.skypack.dev/three@0.135.0/build/three.module.js'
import { OrbitControls } from 'https://cdn.skypack.dev/three@0.135.0/examples/jsm/controls/OrbitControls.js'
import { FBXLoader } from 'https://cdn.skypack.dev/three@0.135.0/examples/jsm/loaders/FBXLoader.js'
import Stats from 'https://cdn.skypack.dev/three@0.135.0/examples/jsm/libs/stats.module.js'
const scene = new THREE.Scene()
scene.background = new THREE.Color( 0xFFFFFF );
scene.add(new THREE.AxesHelper(5))
/*
const light = new THREE.PointLight()
light.position.set(0,0,0)
scene.add(light)
const directionalLight = new THREE.DirectionalLight( 0x111111, 0.1 );
scene.add( directionalLight );
*/
const ambientLight = new THREE.AmbientLight( 0xffffff, 1.0 )
scene.add(ambientLight)
const camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 0.1, 1000)
camera.position.set(0.001, 0, 0)
const renderer = new THREE.WebGLRenderer()
renderer.setSize(window.innerWidth, window.innerHeight)
document.body.appendChild(renderer.domElement)
const controls = new OrbitControls(camera, renderer.domElement)
controls.enableDamping = true
controls.target.set(0, 0, 0)
const material = new THREE.MeshNormalMaterial()
const fbxLoader = new FBXLoader()
fbxLoader.load(
'asset/cafe/cafe.fbx',
(object) => {
/*
object.traverse(function (child) {
if (child.isMesh) {
//child.material = material
if (child.material) {
child.material.transparent = false
}
}
})
*/
object.scale.set(0.01, 0.01, 0.01)
scene.add(object)
progressBar.style.display = 'none'
},
(xhr) => {
if (xhr.lengthComputable) {
var percentComplete = (xhr.loaded / xhr.total) * 100
progressBar.value = percentComplete
progressBar.style.display = 'block'
}
},
(error) => {
console.log(error)
}
)
window.addEventListener('resize', onWindowResize, false)
function onWindowResize() {
camera.aspect = window.innerWidth / window.innerHeight
camera.updateProjectionMatrix()
renderer.setSize(window.innerWidth, window.innerHeight)
render()
}
// Add event listener on keydown
document.addEventListener('keydown', (event) => {
var name = event.key;
var code = event.code;
if (name === 'Control') {
window.location = "index.html"
return;
}
}, false);
const stats = Stats()
document.body.appendChild(stats.dom)
function animate() {
requestAnimationFrame(animate)
controls.update()
render()
stats.update()
}
function render() {
renderer.render(scene, camera)
}
animate()
</script>
</body>
</html>