-
Notifications
You must be signed in to change notification settings - Fork 0
/
baron_in_page.html
234 lines (175 loc) · 5.48 KB
/
baron_in_page.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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
<!DOCTYPE html>
<html lang="en">
<head>
<title>three.js webgl - collada - blender</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<style>
body {
background-color: #000;
}
#baron_pit {
height: 500px;
width: 1000px;
margin: auto;
background-image: url("baron_pit.jpg");
background-size: cover;
position: relative;
}
h1 {
text-align: center;
font-size: 28pt;
color: #DAA520;
text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;
font-family: "Adobe Garamond Pro", Garamond, Baskerville, "Baskerville Old Face", "Hoefler Text", "Times New Roman", serif;
-webkit-touch-callout: none; /* iOS Safari */
-webkit-user-select: none; /* Chrome/Safari/Opera */
-khtml-user-select: none; /* Konqueror */
-moz-user-select: none; /* Firefox */
-ms-user-select: none; /* Internet Explorer/Edge */
user-select: none;
}
#baron_hp_bar {
height: 18px;
width: 180px;
position: absolute;
top: 99px;
left: 42%;
background-color: black;
border: solid;
border-width: 2px;
border-color: rgba(206, 169, 73, 0.7);
-webkit-touch-callout: none; /* iOS Safari */
-webkit-user-select: none; /* Chrome/Safari/Opera */
-khtml-user-select: none; /* Konqueror */
-moz-user-select: none; /* Firefox */
-ms-user-select: none; /* Internet Explorer/Edge */
user-select: none;
}
.hp_unit {
background-color: #bf1515;
width:17px;
height:18px;
margin-right: -3px;
display: inline-block;
}
.hp_unit_empty {
display: none;
}
.texture-loader {
height: 1px;
width: 1px;
}
</style>
</head>
<body>
<!-- pit to render the baron in -->
<img src = "SRU_Baron_TX_CM.bmp" class="texture-loader"/>
<h1>Introducing the new Baron Nashor</h1>
<div id = "baron_pit">
<div id = "baron_hp_bar">
<div class = "hp_unit"></div>
<div class = "hp_unit"></div>
<div class = "hp_unit"></div>
<div class = "hp_unit"></div>
<div class = "hp_unit"></div>
<div class = "hp_unit"></div>
<div class = "hp_unit"></div>
<div class = "hp_unit"></div>
<div class = "hp_unit"></div>
<div class = "hp_unit"></div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<script src="build/three.js"></script>
<script src="js/loaders/collada/Animation.js"></script>
<script src="js/loaders/collada/AnimationHandler.js"></script>
<script src="js/loaders/collada/KeyFrameAnimation.js"></script>
<script src="js/controls/OrbitControls.js"></script>
<script src="js/loaders/ColladaLoader.js"></script>
<script src="js/Detector.js"></script>
<script src="js/libs/stats.min.js"></script>
<script>
if ( ! Detector.webgl ) Detector.addGetWebGLMessage();
var container, stats;
var camera, controls, scene, renderer, objects;
var particleLight, pointLight;
var dae;
var clock = new THREE.Clock();
var mixer;
// Collada model
var loader = new THREE.ColladaLoader();
loader.options.convertUpAxis = true;
loader.load( 'best_baron3.dae', function ( collada ) {
console.log("*****");
dae = collada.scene;
dae.traverse( function ( child ) {
if ( child instanceof THREE.SkinnedMesh ) {
var animation = new THREE.Animation( child, child.geometry.animation );
animation.play();
}
} );
dae.scale.x = dae.scale.y = dae.scale.z = 0.006;
dae.position.z = 1.5;
dae.position.x = 1;
dae.rotation.x = Math.PI / 2;
dae.updateMatrix();
init();
animate();
} );
// initialize the baron and add to baron pit
function init() {
container = $("#baron_pit");
// set up click handler for removing hp
container.on("click", removeHP);
// interval to gradually restore hp
setInterval(restoreHP, 1000);
camera = new THREE.PerspectiveCamera( 50, container.width() /container.height(), 1, 2000 );
camera.position.set( 3.79, 8.57, 6.99 );
scene = new THREE.Scene();
// Add Blender exported Collada model
// Add the COLLADA
scene.add( dae );
// Lights
var ambient = new THREE.AmbientLight( 0x404040 );
ambient.intensity = 5.0;
scene.add( ambient );
//pointLight = new THREE.PointLight( 0xfffff, 5, 30 );
//pointLight.position.set( 5, 0, 0 );
//scene.add( pointLight );
// Renderer
renderer = new THREE.WebGLRenderer({ alpha: true });
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( container.width(), container.height() );
container.prepend( renderer.domElement );
}
// animation handler
function animate() {
requestAnimationFrame( animate );
var delta = clock.getDelta();
// animate Collada model
THREE.AnimationHandler.update( delta );
render();
}
// render loop
function render() {
var timer = Date.now() * 0.0005;
camera.lookAt( scene.position );
renderer.render( scene, camera );
}
// remove HP
function removeHP() {
var currHp = $("#baron_hp_bar .hp_unit").last();
currHp.removeClass("hp_unit");
currHp.addClass("hp_unit_empty");
}
function restoreHP() {
var currHp = $("#baron_hp_bar .hp_unit_empty").first();
if (currHp.length > 0) {
currHp.removeClass("hp_unit_empty");
currHp.addClass("hp_unit");
}
}
</script>
</body>
</html>