-
Notifications
You must be signed in to change notification settings - Fork 2
/
Three.js
386 lines (386 loc) · 184 KB
/
Three.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
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
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
// Three.js r34 - http://github.com/mrdoob/three.js
var THREE=THREE||{};THREE.Color=function(a){this.setHex(a)};
THREE.Color.prototype={autoUpdate:!0,setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,b,c){var d,e,g,h,j,k;if(c==0)d=e=g=0;else{h=Math.floor(a*6);j=a*6-h;a=c*(1-b);k=c*(1-b*j);b=c*(1-b*(1-j));switch(h){case 1:d=k;e=c;g=a;break;case 2:d=a;e=c;g=b;break;case 3:d=a;e=k;g=c;break;case 4:d=b;e=a;g=c;break;case 5:d=c;e=a;g=k;break;case 6:case 0:d=c;e=b;g=a}}this.r=d;this.g=e;this.b=g;if(this.autoUpdate){this.updateHex();
this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGB();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGB:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+","+~~(this.g*255)+","+~~(this.b*255)+")"},clone:function(){return new THREE.Color(this.hex)}};
THREE.Vector2=function(a,b){this.set(a||0,b||0)};
THREE.Vector2.prototype={set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.set(a.x,a.y);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y);return this},multiplyScalar:function(a){this.set(this.x*a,this.y*a);return this},negate:function(){this.set(-this.x,-this.y);return this},unit:function(){this.multiplyScalar(1/
this.length());return this},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y},clone:function(){return new THREE.Vector2(this.x,this.y)}};THREE.Vector3=function(a,b,c){this.set(a||0,b||0,c||0)};
THREE.Vector3.prototype={set:function(a,b,c){this.x=a;this.y=b;this.z=c;return this},copy:function(a){this.set(a.x,a.y,a.z);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y,a.z+b.z);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z);return this},addScalar:function(a){this.set(this.x+a,this.y+a,this.z+a);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y,a.z-b.z);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z);return this},cross:function(a,
b){this.set(a.y*b.z-a.z*b.y,a.z*b.x-a.x*b.z,a.x*b.y-a.y*b.x);return this},crossSelf:function(a){var b=this.x,c=this.y,d=this.z;this.set(c*a.z-d*a.y,d*a.x-b*a.z,b*a.y-c*a.x);return this},multiply:function(a,b){this.set(a.x*b.x,a.y*b.y,a.z*b.z);return this},multiplySelf:function(a){this.set(this.x*a.x,this.y*a.y,this.z*a.z);return this},multiplyScalar:function(a){this.set(this.x*a,this.y*a,this.z*a);return this},divideSelf:function(a){this.set(this.x/a.x,this.y/a.y,this.z/a.z);return this},divideScalar:function(a){this.set(this.x/
a,this.y/a,this.z/a);return this},negate:function(){this.set(-this.x,-this.y,-this.z);return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var b=this.x-a.x,c=this.y-a.y;a=this.z-a.z;return b*b+c*c+a*a},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},lengthManhattan:function(){return this.x+this.y+this.z},normalize:function(){var a=
this.length();a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)}};THREE.Vector4=function(a,b,c,d){this.set(a||0,b||0,c||0,d||1)};
THREE.Vector4.prototype={set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.set(a.x,a.y,a.z,a.w||1);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y,a.z+b.z,a.w+b.w);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z,this.w+a.w);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y,a.z-b.z,a.w-b.w);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z,this.w-a.w);return this},multiplyScalar:function(a){this.set(this.x*
a,this.y*a,this.z*a,this.w*a);return this},divideScalar:function(a){this.set(this.x/a,this.y/a,this.z/a,this.w/a);return this},lerpSelf:function(a,b){this.set(this.x+(a.x-this.x)*b,this.y+(a.y-this.y)*b,this.z+(a.z-this.z)*b,this.w+(a.w-this.w)*b)},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)}};THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3};
THREE.Ray.prototype={intersectScene:function(a){var b,c,d=a.objects,e=[];a=0;for(b=d.length;a<b;a++){c=d[a];c instanceof THREE.Mesh&&(e=e.concat(this.intersectObject(c)))}e.sort(function(g,h){return g.distance-h.distance});return e},intersectObject:function(a){function b(F,v,G,w){w=w.clone().subSelf(v);G=G.clone().subSelf(v);var K=F.clone().subSelf(v);F=w.dot(w);v=w.dot(G);w=w.dot(K);var J=G.dot(G);G=G.dot(K);K=1/(F*J-v*v);J=(J*w-v*G)*K;F=(F*G-v*w)*K;return J>0&&F>0&&J+F<1}var c,d,e,g,h,j,k,m,p,y,
t,q=a.geometry,z=q.vertices,C=[];c=0;for(d=q.faces.length;c<d;c++){e=q.faces[c];y=this.origin.clone();t=this.direction.clone();k=a.matrixWorld;g=k.multiplyVector3(z[e.a].position.clone());h=k.multiplyVector3(z[e.b].position.clone());j=k.multiplyVector3(z[e.c].position.clone());k=e instanceof THREE.Face4?k.multiplyVector3(z[e.d].position.clone()):null;m=a.matrixRotationWorld.multiplyVector3(e.normal.clone());p=t.dot(m);if(p<0){m=m.dot((new THREE.Vector3).sub(g,y))/p;y=y.addSelf(t.multiplyScalar(m));
if(e instanceof THREE.Face3){if(b(y,g,h,j)){e={distance:this.origin.distanceTo(y),point:y,face:e,object:a};C.push(e)}}else if(e instanceof THREE.Face4&&(b(y,g,h,k)||b(y,h,j,k))){e={distance:this.origin.distanceTo(y),point:y,face:e,object:a};C.push(e)}}}return C}};
THREE.Rectangle=function(){function a(){g=d-b;h=e-c}var b,c,d,e,g,h,j=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return g};this.getHeight=function(){return h};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(k,m,p,y){j=!1;b=k;c=m;d=p;e=y;a()};this.addPoint=function(k,m){if(j){j=!1;b=k;c=m;d=k;e=m}else{b=b<k?b:k;c=c<m?c:m;d=d>k?d:k;e=e>m?e:m}a()};
this.add3Points=function(k,m,p,y,t,q){if(j){j=!1;b=k<p?k<t?k:t:p<t?p:t;c=m<y?m<q?m:q:y<q?y:q;d=k>p?k>t?k:t:p>t?p:t;e=m>y?m>q?m:q:y>q?y:q}else{b=k<p?k<t?k<b?k:b:t<b?t:b:p<t?p<b?p:b:t<b?t:b;c=m<y?m<q?m<c?m:c:q<c?q:c:y<q?y<c?y:c:q<c?q:c;d=k>p?k>t?k>d?k:d:t>d?t:d:p>t?p>d?p:d:t>d?t:d;e=m>y?m>q?m>e?m:e:q>e?q:e:y>q?y>e?y:e:q>e?q:e}a()};this.addRectangle=function(k){if(j){j=!1;b=k.getLeft();c=k.getTop();d=k.getRight();e=k.getBottom()}else{b=b<k.getLeft()?b:k.getLeft();c=c<k.getTop()?c:k.getTop();d=d>k.getRight()?
d:k.getRight();e=e>k.getBottom()?e:k.getBottom()}a()};this.inflate=function(k){b-=k;c-=k;d+=k;e+=k;a()};this.minSelf=function(k){b=b>k.getLeft()?b:k.getLeft();c=c>k.getTop()?c:k.getTop();d=d<k.getRight()?d:k.getRight();e=e<k.getBottom()?e:k.getBottom();a()};this.instersects=function(k){return Math.min(d,k.getRight())-Math.max(b,k.getLeft())>=0&&Math.min(e,k.getBottom())-Math.max(c,k.getTop())>=0};this.empty=function(){j=!0;e=d=c=b=0;a()};this.isEmpty=function(){return j}};
THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,b=this.m;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};
THREE.Matrix4=function(a,b,c,d,e,g,h,j,k,m,p,y,t,q,z,C){this.set(a||1,b||0,c||0,d||0,e||0,g||1,h||0,j||0,k||0,m||0,p||1,y||0,t||0,q||0,z||0,C||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
THREE.Matrix4.prototype={set:function(a,b,c,d,e,g,h,j,k,m,p,y,t,q,z,C){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=e;this.n22=g;this.n23=h;this.n24=j;this.n31=k;this.n32=m;this.n33=p;this.n34=y;this.n41=t;this.n42=q;this.n43=z;this.n44=C;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,b,c){var d=THREE.Matrix4.__tmpVec1,
e=THREE.Matrix4.__tmpVec2,g=THREE.Matrix4.__tmpVec3;g.sub(a,b).normalize();d.cross(c,g).normalize();e.cross(g,d).normalize();this.n11=d.x;this.n12=e.x;this.n13=g.x;this.n14=a.x;this.n21=d.y;this.n22=e.y;this.n23=g.y;this.n24=a.y;this.n31=d.z;this.n32=e.z;this.n33=g.z;this.n34=a.z;return this},multiplyVector3:function(a){var b=a.x,c=a.y,d=a.z,e=1/(this.n41*b+this.n42*c+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*d+this.n14)*e;a.y=(this.n21*b+this.n22*c+this.n23*d+this.n24)*e;a.z=(this.n31*
b+this.n32*c+this.n33*d+this.n34)*e;return a},multiplyVector3OnlyZ:function(a){var b=a.x,c=a.y;a=a.z;return(this.n31*b+this.n32*c+this.n33*a+this.n34)*(1/(this.n41*b+this.n42*c+this.n43*a+this.n44))},multiplyVector4:function(a){var b=a.x,c=a.y,d=a.z,e=a.w;a.x=this.n11*b+this.n12*c+this.n13*d+this.n14*e;a.y=this.n21*b+this.n22*c+this.n23*d+this.n24*e;a.z=this.n31*b+this.n32*c+this.n33*d+this.n34*e;a.w=this.n41*b+this.n42*c+this.n43*d+this.n44*e;return a},crossVector:function(a){var b=new THREE.Vector4;
b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var c=a.n11,d=a.n12,e=a.n13,g=a.n14,h=a.n21,j=a.n22,k=a.n23,m=a.n24,p=a.n31,y=a.n32,t=a.n33,q=a.n34,z=a.n41,C=a.n42,F=a.n43,v=a.n44,G=b.n11,w=b.n12,K=b.n13,J=b.n14,f=b.n21,N=b.n22,O=b.n23,U=b.n24,Q=b.n31,Z=b.n32,ca=b.n33,L=b.n34;this.n11=
c*G+d*f+e*Q;this.n12=c*w+d*N+e*Z;this.n13=c*K+d*O+e*ca;this.n14=c*J+d*U+e*L+g;this.n21=h*G+j*f+k*Q;this.n22=h*w+j*N+k*Z;this.n23=h*K+j*O+k*ca;this.n24=h*J+j*U+k*L+m;this.n31=p*G+y*f+t*Q;this.n32=p*w+y*N+t*Z;this.n33=p*K+y*O+t*ca;this.n34=p*J+y*U+t*L+q;this.n41=z*G+C*f+F*Q;this.n42=z*w+C*N+F*Z;this.n43=z*K+C*O+F*ca;this.n44=z*J+C*U+F*L+v;return this},multiplyToArray:function(a,b,c){var d=a.n11,e=a.n12,g=a.n13,h=a.n14,j=a.n21,k=a.n22,m=a.n23,p=a.n24,y=a.n31,t=a.n32,q=a.n33,z=a.n34,C=a.n41,F=a.n42,v=
a.n43;a=a.n44;var G=b.n11,w=b.n12,K=b.n13,J=b.n14,f=b.n21,N=b.n22,O=b.n23,U=b.n24,Q=b.n31,Z=b.n32,ca=b.n33,L=b.n34,W=b.n41,ma=b.n42,ba=b.n43;b=b.n44;this.n11=d*G+e*f+g*Q+h*W;this.n12=d*w+e*N+g*Z+h*ma;this.n13=d*K+e*O+g*ca+h*ba;this.n14=d*J+e*U+g*L+h*b;this.n21=j*G+k*f+m*Q+p*W;this.n22=j*w+k*N+m*Z+p*ma;this.n23=j*K+k*O+m*ca+p*ba;this.n24=j*J+k*U+m*L+p*b;this.n31=y*G+t*f+q*Q+z*W;this.n32=y*w+t*N+q*Z+z*ma;this.n33=y*K+t*O+q*ca+z*ba;this.n34=y*J+t*U+q*L+z*b;this.n41=C*G+F*f+v*Q+a*W;this.n42=C*w+F*N+v*
Z+a*ma;this.n43=C*K+F*O+v*ca+a*ba;this.n44=C*J+F*U+v*L+a*b;c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplySelf:function(a){var b=this.n11,c=this.n12,d=this.n13,e=this.n14,g=this.n21,h=this.n22,j=this.n23,k=this.n24,m=this.n31,p=this.n32,y=this.n33,t=this.n34,q=this.n41,z=this.n42,C=this.n43,F=this.n44,
v=a.n11,G=a.n21,w=a.n31,K=a.n12,J=a.n22,f=a.n32,N=a.n13,O=a.n23,U=a.n33,Q=a.n14,Z=a.n24;a=a.n34;this.n11=b*v+c*G+d*w;this.n12=b*K+c*J+d*f;this.n13=b*N+c*O+d*U;this.n14=b*Q+c*Z+d*a+e;this.n21=g*v+h*G+j*w;this.n22=g*K+h*J+j*f;this.n23=g*N+h*O+j*U;this.n24=g*Q+h*Z+j*a+k;this.n31=m*v+p*G+y*w;this.n32=m*K+p*J+y*f;this.n33=m*N+p*O+y*U;this.n34=m*Q+p*Z+y*a+t;this.n41=q*v+z*G+C*w;this.n42=q*K+z*J+C*f;this.n43=q*N+z*O+C*U;this.n44=q*Q+z*Z+C*a+F;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=
a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,b=this.n12,c=this.n13,d=this.n14,e=this.n21,g=this.n22,h=this.n23,j=this.n24,k=this.n31,m=this.n32,p=this.n33,y=this.n34,t=this.n41,q=this.n42,z=this.n43,C=this.n44;return d*h*m*t-c*j*m*t-d*g*p*t+b*j*p*t+c*g*y*t-b*h*y*t-d*h*k*q+c*j*k*q+d*e*p*q-a*j*p*q-c*e*y*q+a*h*y*q+d*g*k*z-b*j*
k*z-d*e*m*z+a*j*m*z+b*e*y*z-a*g*y*z-c*g*k*C+b*h*k*C+c*e*m*C-a*h*m*C-b*e*p*C+a*g*p*C},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32=this.n23;this.n23=a;a=this.n41;this.n41=this.n14;this.n14=a;a=this.n42;this.n42=this.n24;this.n24=a;a=this.n43;this.n43=this.n34;this.n43=a;return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=
this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){this.flattenToArray(this.flat);return this.flat},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArrayOffset:function(a,
b){a[b]=this.n11;a[b+1]=this.n21;a[b+2]=this.n31;a[b+3]=this.n41;a[b+4]=this.n12;a[b+5]=this.n22;a[b+6]=this.n32;a[b+7]=this.n42;a[b+8]=this.n13;a[b+9]=this.n23;a[b+10]=this.n33;a[b+11]=this.n43;a[b+12]=this.n14;a[b+13]=this.n24;a[b+14]=this.n34;a[b+15]=this.n44;return a},setTranslation:function(a,b,c){this.set(1,0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);return this},setScale:function(a,b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},setRotX:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(1,
0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1);return this},setRotY:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotZ:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,b){var c=Math.cos(b),d=Math.sin(b),e=1-c,g=a.x,h=a.y,j=a.z,k=e*g,m=e*h;this.set(k*g+c,k*h-d*j,k*j+d*h,0,k*h+d*j,m*h+c,m*j-d*g,0,k*j-d*h,m*j+d*g,e*j*j+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=
a.y;this.n34=a.z;return this},setRotationFromEuler:function(a){var b=a.x,c=a.y,d=a.z;a=Math.cos(b);b=Math.sin(b);var e=Math.cos(c);c=Math.sin(c);var g=Math.cos(d);d=Math.sin(d);var h=a*c,j=b*c;this.n11=e*g;this.n12=-e*d;this.n13=c;this.n21=j*g+a*d;this.n22=-j*d+a*g;this.n23=-b*e;this.n31=-h*g+b*d;this.n32=h*d+b*g;this.n33=a*e},setRotationFromQuaternion:function(a){var b=a.x,c=a.y,d=a.z,e=a.w,g=b+b,h=c+c,j=d+d;a=b*g;var k=b*h;b*=j;var m=c*h;c*=j;d*=j;g*=e;h*=e;e*=j;this.n11=1-(m+d);this.n12=k-e;this.n13=
b+h;this.n21=k+e;this.n22=1-(a+d);this.n23=c-g;this.n31=b-h;this.n32=c+g;this.n33=1-(a+m)},scale:function(a){var b=a.x,c=a.y;a=a.z;this.n11*=b;this.n12*=c;this.n13*=a;this.n21*=b;this.n22*=c;this.n23*=a;this.n31*=b;this.n32*=c;this.n33*=a;this.n41*=b;this.n42*=c;this.n43*=a;return this}};THREE.Matrix4.translationMatrix=function(a,b,c){var d=new THREE.Matrix4;d.setTranslation(a,b,c);return d};THREE.Matrix4.scaleMatrix=function(a,b,c){var d=new THREE.Matrix4;d.setScale(a,b,c);return d};
THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.setRotX(a);return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.setRotY(a);return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.setRotZ(a);return b};THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var c=new THREE.Matrix4;c.setRotAxis(a,b);return c};
THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,d=a.n12,e=a.n13,g=a.n14,h=a.n21,j=a.n22,k=a.n23,m=a.n24,p=a.n31,y=a.n32,t=a.n33,q=a.n34,z=a.n41,C=a.n42,F=a.n43,v=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=k*q*C-m*t*C+m*y*F-j*q*F-k*y*v+j*t*v;b.n12=g*t*C-e*q*C-g*y*F+d*q*F+e*y*v-d*t*v;b.n13=e*m*C-g*k*C+g*j*F-d*m*F-e*j*v+d*k*v;b.n14=g*k*y-e*m*y-g*j*t+d*m*t+e*j*q-d*k*q;b.n21=m*t*z-k*q*z-m*p*F+h*q*F+k*p*v-h*t*v;b.n22=e*q*z-g*t*z+g*p*F-c*q*F-e*p*v+c*t*v;b.n23=g*k*z-e*m*z-g*h*F+c*m*F+e*h*v-c*k*v;
b.n24=e*m*p-g*k*p+g*h*t-c*m*t-e*h*q+c*k*q;b.n31=j*q*z-m*y*z+m*p*C-h*q*C-j*p*v+h*y*v;b.n32=g*y*z-d*q*z-g*p*C+c*q*C+d*p*v-c*y*v;b.n33=e*m*z-g*j*z+g*h*C-c*m*C-d*h*v+c*j*v;b.n34=g*j*p-d*m*p-g*h*y+c*m*y+d*h*q-c*j*q;b.n41=k*y*z-j*t*z-k*p*C+h*t*C+j*p*F-h*y*F;b.n42=d*t*z-e*y*z+e*p*C-c*t*C-d*p*F+c*y*F;b.n43=e*j*z-d*k*z-e*h*C+c*k*C+d*h*F-c*j*F;b.n44=d*k*p-e*j*p+e*h*y-c*k*y-d*h*t+c*j*t;b.multiplyScalar(1/a.determinant());return b};
THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,d=a.n33*a.n22-a.n32*a.n23,e=-a.n33*a.n21+a.n31*a.n23,g=a.n32*a.n21-a.n31*a.n22,h=-a.n33*a.n12+a.n32*a.n13,j=a.n33*a.n11-a.n31*a.n13,k=-a.n32*a.n11+a.n31*a.n12,m=a.n23*a.n12-a.n22*a.n13,p=-a.n23*a.n11+a.n21*a.n13,y=a.n22*a.n11-a.n21*a.n12;a=a.n11*d+a.n21*h+a.n31*m;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*d;c[1]=a*e;c[2]=a*g;c[3]=a*h;c[4]=a*j;c[5]=a*k;c[6]=a*m;c[7]=a*p;c[8]=a*y;return b};
THREE.Matrix4.makeFrustum=function(a,b,c,d,e,g){var h;h=new THREE.Matrix4;h.n11=2*e/(b-a);h.n12=0;h.n13=(b+a)/(b-a);h.n14=0;h.n21=0;h.n22=2*e/(d-c);h.n23=(d+c)/(d-c);h.n24=0;h.n31=0;h.n32=0;h.n33=-(g+e)/(g-e);h.n34=-2*g*e/(g-e);h.n41=0;h.n42=0;h.n43=-1;h.n44=0;return h};THREE.Matrix4.makePerspective=function(a,b,c,d){var e;a=c*Math.tan(a*Math.PI/360);e=-a;return THREE.Matrix4.makeFrustum(e*b,a*b,e,a,c,d)};
THREE.Matrix4.makeOrtho=function(a,b,c,d,e,g){var h,j,k,m;h=new THREE.Matrix4;j=b-a;k=c-d;m=g-e;h.n11=2/j;h.n12=0;h.n13=0;h.n14=-((b+a)/j);h.n21=0;h.n22=2/k;h.n23=0;h.n24=-((c+d)/k);h.n31=0;h.n32=0;h.n33=-2/m;h.n34=-((g+e)/m);h.n41=0;h.n42=0;h.n43=0;h.n44=1;return h};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.parent=undefined;this.children=[];this.position=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixNeedsUpdate=!0;this.matrixAutoUpdate=!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;
this.visible=!0};
THREE.Object3D.prototype={addChild:function(a){if(this.children.indexOf(a)===-1){a.parent!==undefined&&a.parent.removeChild(a);a.parent=this;this.children.push(a);for(var b=this;b instanceof THREE.Scene===!1&&b!==undefined;)b=b.parent;b!==undefined&&b.addChildRecurse(a)}},removeChild:function(a){var b=this.children.indexOf(a);if(b!==-1){a.parent=undefined;this.children.splice(b,1)}},updateMatrix:function(){this.matrix.setPosition(this.position);this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation);
if(this.scale.x!==1||this.scale.y!==1||this.scale.z!==1){this.matrix.scale(this.scale);this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z))}return!0},update:function(a,b,c){if(this.visible){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);b=1/this.scale.x;a=1/this.scale.y;var d=1/this.scale.z;this.matrixRotationWorld.n11=this.matrixWorld.n11*b;this.matrixRotationWorld.n21=
this.matrixWorld.n21*b;this.matrixRotationWorld.n31=this.matrixWorld.n31*b;this.matrixRotationWorld.n12=this.matrixWorld.n12*a;this.matrixRotationWorld.n22=this.matrixWorld.n22*a;this.matrixRotationWorld.n32=this.matrixWorld.n32*a;this.matrixRotationWorld.n13=this.matrixWorld.n13*d;this.matrixRotationWorld.n23=this.matrixWorld.n23*d;this.matrixRotationWorld.n33=this.matrixWorld.n33*d;this.matrixNeedsUpdate=!1;b=!0}a=0;for(d=this.children.length;a<d;a++)this.children[a].update(this.matrixWorld,b,c)}}};
THREE.Object3DCounter={value:0};THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,d!==undefined?d:1)};
THREE.Quaternion.prototype={set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},setFromEuler:function(a){var b=0.5*Math.PI/360,c=a.x*b,d=a.y*b,e=a.z*b;a=Math.cos(d);d=Math.sin(d);b=Math.cos(-e);e=Math.sin(-e);var g=Math.cos(c);c=Math.sin(c);var h=a*b,j=d*e;this.w=h*g-j*c;this.x=h*c+j*g;this.y=d*b*g+a*e*c;this.z=a*e*g-d*b*c;return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=
-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(a==0)this.w=this.z=this.y=this.x=0;else{a=1/a;this.x*=a;this.y*=a;this.z*=a;this.w*=a}return this},multiplySelf:function(a){var b=this.x,c=this.y,d=this.z,e=this.w,g=a.x,h=a.y,j=a.z;a=a.w;this.x=b*a+e*g+c*j-d*h;this.y=c*a+e*h+d*g-b*j;this.z=d*a+e*j+b*h-c*g;this.w=e*a-b*g-c*h-d*j;return this},
multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,e=a.z,g=this.x,h=this.y,j=this.z,k=this.w,m=k*c+h*e-j*d,p=k*d+j*c-g*e,y=k*e+g*d-h*c;c=-g*c-h*d-j*e;b.x=m*k+c*-g+p*-j-y*-h;b.y=p*k+c*-h+y*-g-m*-j;b.z=y*k+c*-j+m*-h-p*-g;return b}};
THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(e)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var g=Math.acos(e),h=Math.sqrt(1-e*e);if(Math.abs(h)<0.001){c.w=0.5*(a.w+b.w);c.x=0.5*(a.x+b.x);c.y=0.5*(a.y+b.y);c.z=0.5*(a.z+b.z);return c}e=Math.sin((1-d)*g)/h;d=Math.sin(d*g)/h;c.w=a.w*e+b.w*d;c.x=a.x*e+b.x*d;c.y=a.y*e+b.y*d;c.z=a.z*e+b.z*d;return c};
THREE.Vertex=function(a,b){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=b||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.tangent=new THREE.Vector4;this.__visible=!0};
THREE.Face3=function(a,b,c,d,e){this.a=a;this.b=b;this.c=c;this.centroid=new THREE.Vector3;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.materials=e instanceof Array?e:[e]};THREE.Face4=function(a,b,c,d,e,g){this.a=a;this.b=b;this.c=c;this.d=d;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.materials=g instanceof Array?g:[g]};
THREE.UV=function(a,b){this.set(a||0,b||0)};THREE.UV.prototype={set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.set(a.u,a.v);return this}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.faces=[];this.uvs=[];this.uvs2=[];this.colors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1};
THREE.Geometry.prototype={computeCentroids:function(){var a,b,c;a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];c.centroid.set(0,0,0);if(c instanceof THREE.Face3){c.centroid.addSelf(this.vertices[c.a].position);c.centroid.addSelf(this.vertices[c.b].position);c.centroid.addSelf(this.vertices[c.c].position);c.centroid.divideScalar(3)}else if(c instanceof THREE.Face4){c.centroid.addSelf(this.vertices[c.a].position);c.centroid.addSelf(this.vertices[c.b].position);c.centroid.addSelf(this.vertices[c.c].position);
c.centroid.addSelf(this.vertices[c.d].position);c.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,c,d,e,g,h,j=new THREE.Vector3,k=new THREE.Vector3;d=0;for(e=this.vertices.length;d<e;d++){g=this.vertices[d];g.normal.set(0,0,0)}d=0;for(e=this.faces.length;d<e;d++){g=this.faces[d];if(a&&g.vertexNormals.length){j.set(0,0,0);b=0;for(c=g.normal.length;b<c;b++)j.addSelf(g.vertexNormals[b]);j.divideScalar(3)}else{b=this.vertices[g.a];c=this.vertices[g.b];h=this.vertices[g.c];j.sub(h.position,
c.position);k.sub(b.position,c.position);j.crossSelf(k)}j.isZero()||j.normalize();g.normal.copy(j)}},computeVertexNormals:function(){var a,b,c,d;if(this.__tmpVertices==undefined){d=this.__tmpVertices=Array(this.vertices.length);a=0;for(b=this.vertices.length;a<b;a++)d[a]=new THREE.Vector3;a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];if(c instanceof THREE.Face3)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(c instanceof THREE.Face4)c.vertexNormals=[new THREE.Vector3,
new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{d=this.__tmpVertices;a=0;for(b=this.vertices.length;a<b;a++)d[a].set(0,0,0)}a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];if(c instanceof THREE.Face3){d[c.a].addSelf(c.normal);d[c.b].addSelf(c.normal);d[c.c].addSelf(c.normal)}else if(c instanceof THREE.Face4){d[c.a].addSelf(c.normal);d[c.b].addSelf(c.normal);d[c.c].addSelf(c.normal);d[c.d].addSelf(c.normal)}}a=0;for(b=this.vertices.length;a<b;a++)d[a].normalize();a=0;for(b=this.faces.length;a<
b;a++){c=this.faces[a];if(c instanceof THREE.Face3){c.vertexNormals[0].copy(d[c.a]);c.vertexNormals[1].copy(d[c.b]);c.vertexNormals[2].copy(d[c.c])}else if(c instanceof THREE.Face4){c.vertexNormals[0].copy(d[c.a]);c.vertexNormals[1].copy(d[c.b]);c.vertexNormals[2].copy(d[c.c]);c.vertexNormals[3].copy(d[c.d])}}},computeTangents:function(){function a(L,W,ma,ba,na,ga,ia){g=L.vertices[W].position;h=L.vertices[ma].position;j=L.vertices[ba].position;k=e[na];m=e[ga];p=e[ia];y=h.x-g.x;t=j.x-g.x;q=h.y-g.y;
z=j.y-g.y;C=h.z-g.z;F=j.z-g.z;v=m.u-k.u;G=p.u-k.u;w=m.v-k.v;K=p.v-k.v;J=1/(v*K-G*w);O.set((K*y-w*t)*J,(K*q-w*z)*J,(K*C-w*F)*J);U.set((v*t-G*y)*J,(v*z-G*q)*J,(v*F-G*C)*J);f[W].addSelf(O);f[ma].addSelf(O);f[ba].addSelf(O);N[W].addSelf(U);N[ma].addSelf(U);N[ba].addSelf(U)}var b,c,d,e,g,h,j,k,m,p,y,t,q,z,C,F,v,G,w,K,J,f=[],N=[],O=new THREE.Vector3,U=new THREE.Vector3,Q=new THREE.Vector3,Z=new THREE.Vector3,ca=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++){f[b]=new THREE.Vector3;N[b]=new THREE.Vector3}b=
0;for(c=this.faces.length;b<c;b++){d=this.faces[b];e=this.uvs[b];if(d instanceof THREE.Face3){a(this,d.a,d.b,d.c,0,1,2);this.vertices[d.a].normal.copy(d.vertexNormals[0]);this.vertices[d.b].normal.copy(d.vertexNormals[1]);this.vertices[d.c].normal.copy(d.vertexNormals[2])}else if(d instanceof THREE.Face4){a(this,d.a,d.b,d.c,0,1,2);a(this,d.a,d.b,d.d,0,1,3);this.vertices[d.a].normal.copy(d.vertexNormals[0]);this.vertices[d.b].normal.copy(d.vertexNormals[1]);this.vertices[d.c].normal.copy(d.vertexNormals[2]);
this.vertices[d.d].normal.copy(d.vertexNormals[3])}}b=0;for(c=this.vertices.length;b<c;b++){ca.copy(this.vertices[b].normal);d=f[b];Q.copy(d);Q.subSelf(ca.multiplyScalar(ca.dot(d))).normalize();Z.cross(this.vertices[b].normal,d);d=Z.dot(N[b]);d=d<0?-1:1;this.vertices[b].tangent.set(Q.x,Q.y,Q.z,d)}this.hasTangents=!0},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],
z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,c=this.vertices.length;b<c;b++){a=this.vertices[b];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>
this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,c=this.vertices.length;b<c;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}}};THREE.GeometryIdCounter=0;
THREE.Spline=function(){function a(t,q,z,C,F,v,G){t=(z-t)*0.5;C=(C-q)*0.5;return(2*(q-z)+t+C)*G+(-3*(q-z)-2*t-C)*v+t*F+q}var b=[],c={x:0,y:0,z:0},d,e,g,h,j,k,m,p,y;this.get2DPoint=function(t,q){d=(t.length-1)*q;e=Math.floor(d);g=d-e;b[0]=e==0?e:e-1;b[1]=e;b[2]=e>t.length-2?e:e+1;b[3]=e>t.length-3?e:e+2;k=t[b[0]];m=t[b[1]];p=t[b[2]];y=t[b[3]];h=g*g;j=g*h;c.x=a(k.x,m.x,p.x,y.x,g,h,j);c.y=a(k.y,m.y,p.y,y.y,g,h,j);c.z=a(k.z,m.z,p.z,y.z,g,h,j);return c}};
THREE.AnimationHandler=function(){var a=[],b={},c={};c.update=function(e){for(var g=0;g<a.length;g++)a[g].update(e)};c.addToUpdate=function(e){a.indexOf(e)===-1&&a.push(e)};c.removeFromUpdate=function(e){e=a.indexOf(e);e!==-1&&a.splice(e,1)};c.add=function(e){b[e.name]!==undefined&&console.log("THREE.AnimationHandler.add: Warning! "+e.name+" already exists in library. Overwriting.");b[e.name]=e;if(e.initialized!==!0){e.length=parseInt(e.length*1E3,10);e.fps*=0.001;for(var g=0;g<e.hierarchy.length;g++)for(var h=
0;h<e.hierarchy[g].keys.length;h++){if(e.hierarchy[g].keys[h].time<0)e.hierarchy[g].keys[h].time=0;e.hierarchy[g].keys[h].time=parseInt(e.hierarchy[g].keys[h].time*1E3,10);e.hierarchy[g].keys[h].index=h;if(e.hierarchy[g].keys[h].rot!==undefined&&!(e.hierarchy[g].keys[h].rot instanceof THREE.Quaternion)){var j=e.hierarchy[g].keys[h].rot;e.hierarchy[g].keys[h].rot=new THREE.Quaternion(j[0],j[1],j[2],j[3])}}h=parseInt(e.length*e.fps*0.001,10);e.JIT={};e.JIT.hierarchy=[];for(g=0;g<e.hierarchy.length;g++)e.JIT.hierarchy.push(Array(h));
e.initialized=!0}};c.get=function(e){if(typeof e==="string")if(b[e])return b[e];else{console.log("THREE.AnimationHandler.get: Couldn't find animation "+e);return null}};c.parse=function(e){var g=[];if(e instanceof THREE.SkinnedMesh)for(var h=0;h<e.bones.length;h++)g.push(e.bones[h]);else d(e,g);return g};var d=function(e,g){g.push(e);for(var h=0;h<e.children.length;h++)d(e.children[h],g)};c.LINEAR=0;c.CATMULLROM=1;c.CATMULLROM_FORWARD=2;return c}();
THREE.Animation=function(a,b,c,d){this.root=a;this.data=THREE.AnimationHandler.get(b);this.hierarchy=THREE.AnimationHandler.parse(a);this.currentTime=0;this.isPlaying=!1;this.isPaused=!0;this.loop=!0;this.interpolationType=c!==undefined?c:THREE.AnimationHandler.LINEAR;this.JITCompile=d!==undefined?d:!0};
THREE.Animation.prototype.play=function(a,b){if(!this.isPlaying){this.isPlaying=!0;this.loop=a!==undefined?a:!0;this.currentTime=b!==undefined?b:0;for(var c=0;c<this.hierarchy.length;c++){this.hierarchy[c].useQuaternion=!0;this.hierarchy[c].matrixAutoUpdate=!0;if(this.hierarchy[c].animationCache===undefined){this.hierarchy[c].animationCache={};this.hierarchy[c].animationCache.prevKey={pos:0,rot:0,scl:0};this.hierarchy[c].animationCache.nextKey={pos:0,rot:0,scl:0};this.hierarchy[c].animationCache.originalMatrix=
this.hierarchy[c]instanceof THREE.Bone?this.hierarchy[c].skinMatrix:this.hierarchy[c].matrix}var d=this.hierarchy[c].animationCache.prevKey,e=this.hierarchy[c].animationCache.nextKey;d.pos=this.data.hierarchy[c].keys[0];d.rot=this.data.hierarchy[c].keys[0];d.scl=this.data.hierarchy[c].keys[0];e.pos=this.getNextKeyWith("pos",c,1);e.rot=this.getNextKeyWith("rot",c,1);e.scl=this.getNextKeyWith("scl",c,1)}this.update(0)}this.isPaused=!1;THREE.AnimationHandler.addToUpdate(this)};
THREE.Animation.prototype.pause=function(){this.isPaused?THREE.AnimationHandler.addToUpdate(this):THREE.AnimationHandler.removeFromUpdate(this);this.isPaused=!this.isPaused};
THREE.Animation.prototype.stop=function(){this.isPlaying=!1;THREE.AnimationHandler.removeFromUpdate(this);for(var a=0;a<this.hierarchy.length;a++)if(this.hierarchy[a].animationCache!==undefined){if(this.hierarchy[a]instanceof THREE.Bone)this.hierarchy[a].skinMatrix=this.hierarchy[a].animationCache.originalMatrix;else this.hierarchy[a].matrix=this.hierarchy[a].animationCache.originalMatrix;delete this.hierarchy[a].animationCache}};
THREE.Animation.prototype.update=function(a){if(this.isPlaying){var b=["pos","rot","scl"],c,d,e,g,h,j,k,m,p=this.data.JIT.hierarchy,y,t;this.currentTime+=a;t=this.currentTime;y=this.currentTime%=this.data.length;m=parseInt(Math.min(y*this.data.fps,this.data.length*this.data.fps),10);for(var q=0,z=this.hierarchy.length;q<z;q++){a=this.hierarchy[q];k=a.animationCache;if(p[q][m]!==undefined)if(a instanceof THREE.Bone){a.skinMatrix=p[q][m];a.skinMatrix.flattenToArrayOffset(this.root.boneMatrices,q*16);
a.matrixAutoUpdate=!1;a.matrixNeedsUpdate=!1}else{a.matrix=p[q][m];a.matrixAutoUpdate=!1;a.matrixNeedsUpdate=!0}else{if(a instanceof THREE.Bone)a.skinMatrix=a.animationCache.originalMatrix;else a.matrix=a.animationCache.originalMatrix;for(var C=0;C<3;C++){c=b[C];h=k.prevKey[c];j=k.nextKey[c];if(j.time<t){if(y<t)if(this.loop){h=this.data.hierarchy[q].keys[0];j=this.getNextKeyWith(c,q,1)}else{this.stop();return}else{do{h=j;j=this.getNextKeyWith(c,q,j.index+1)}while(j.time<y)}k.prevKey[c]=h;k.nextKey[c]=
j}a.matrixAutoUpdate=!0;a.matrixNeedsUpdate=!0;d=(y-h.time)/(j.time-h.time);e=h[c];g=j[c];if(d<0||d>1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+d);d=d<0?0:1}if(c==="pos")if(this.interpolationType===THREE.AnimationHandler.LINEAR){c=a.position;c.x=e[0]+(g[0]-e[0])*d;c.y=e[1]+(g[1]-e[1])*d;c.z=e[2]+(g[2]-e[2])*d}else{var F=[];F[0]=this.getPrevKeyWith(c,q,h.index-1)[c];F[1]=e;F[2]=g;F[3]=this.getNextKeyWith(c,q,j.index+1)[c];d=d*0.33+0.33;d=this.interpolateCatmullRom(F,d);a.position.x=
d[0];a.position.y=d[1];a.position.z=d[2]}else if(c==="rot")THREE.Quaternion.slerp(e,g,a.quaternion,d);else if(c==="scl"){c=a.scale;c.x=e[0]+(g[0]-e[0])*d;c.y=e[1]+(g[1]-e[1])*d;c.z=e[2]+(g[2]-e[2])*d}}}}if(this.JITCompile&&p[0][m]===undefined){this.hierarchy[0].update(undefined,!0);for(q=0;q<this.hierarchy.length;q++)p[q][m]=this.hierarchy[q]instanceof THREE.Bone?this.hierarchy[q].skinMatrix.clone():this.hierarchy[q].matrix.clone()}}};
THREE.Animation.prototype.interpolateCatmullRom=function(a,b){var c=[],d=[],e,g,h,j,k,m;e=(a.length-1)*b;g=Math.floor(e);e-=g;c[0]=g==0?g:g-1;c[1]=g;c[2]=g>a.length-2?g:g+1;c[3]=g>a.length-3?g:g+2;g=a[c[0]];j=a[c[1]];k=a[c[2]];m=a[c[3]];c=e*e;h=e*c;d[0]=this.interpolate(g[0],j[0],k[0],m[0],e,c,h);d[1]=this.interpolate(g[1],j[1],k[1],m[1],e,c,h);d[2]=this.interpolate(g[2],j[2],k[2],m[2],e,c,h);return d};
THREE.Animation.prototype.interpolate=function(a,b,c,d,e,g,h){a=(c-a)*0.5;d=(d-b)*0.5;return(2*(b-c)+a+d)*h+(-3*(b-c)-2*a-d)*g+a*e+b};THREE.Animation.prototype.getNextKeyWith=function(a,b,c){var d=this.data.hierarchy[b].keys;for(c%=d.length;c<d.length;c++)if(d[c][a]!==undefined)return d[c];return this.data.hierarchy[b].keys[0]};
THREE.Animation.prototype.getPrevKeyWith=function(a,b,c){var d=this.data.hierarchy[b].keys;for(c=c>=0?c:c+d.length;c>=0;c--)if(d[c][a]!==undefined)return d[c];return this.data.hierarchy[b].keys[d.length-1]};
THREE.Camera=function(a,b,c,d,e){THREE.Object3D.call(this);this.fov=a||50;this.aspect=b||1;this.near=c||0.1;this.far=d||2E3;this.target=e||new THREE.Object3D;this.useTarget=!0;this.up=new THREE.Vector3(0,1,0);this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;var g=new THREE.Vector3;this.translateX=function(h,j){g.sub(this.target.position,this.position).normalize().multiplyScalar(h);g.crossSelf(this.up);if(j)g.y=0;this.position.addSelf(g);this.target.position.addSelf(g)};this.translateZ=
function(h,j){g.sub(this.target.position,this.position).normalize().multiplyScalar(h);if(j)g.y=0;this.position.subSelf(g);this.target.position.subSelf(g)};this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.supr=THREE.Object3D.prototype;THREE.Camera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};
THREE.Camera.prototype.update=function(a,b,c){if(this.useTarget){this.matrix.lookAt(this.position,this.target.position,this.up);a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse);b=!0}else{this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixNeedsUpdate=!1;b=!0;THREE.Matrix4.makeInvert(this.matrixWorld,
this.matrixWorldInverse)}}for(a=0;a<this.children.length;a++)this.children[a].update(this.matrixWorld,b,c)};
THREE.QuakeCamera=function(a){function b(c,d){return function(){d.apply(c,arguments)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.movementSpeed=1;this.lookSpeed=0.005;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.domElement=document;if(a){if(a.movementSpeed!==undefined)this.movementSpeed=a.movementSpeed;if(a.lookSpeed!==undefined)this.lookSpeed=a.lookSpeed;if(a.noFly!==undefined)this.noFly=a.noFly;if(a.lookVertical!==
undefined)this.lookVertical=a.lookVertical;if(a.autoForward!==undefined)this.autoForward=a.autoForward;if(a.heightSpeed!==undefined)this.heightSpeed=a.heightSpeed;if(a.heightCoef!==undefined)this.heightCoef=a.heightCoef;if(a.heightMin!==undefined)this.heightMin=a.heightMin;if(a.heightMax!==undefined)this.heightMax=a.heightMax;if(a.domElement!==undefined)this.domElement=a.domElement}this.theta=this.phy=this.lon=this.lat=this.mouseY=this.mouseX=this.autoSpeedFactor=0;this.moveForward=!1;this.moveBackward=
!1;this.moveLeft=!1;this.moveRight=!1;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;this.onMouseDown=function(c){c.preventDefault();c.stopPropagation();switch(c.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}};this.onMouseUp=function(c){c.preventDefault();c.stopPropagation();switch(c.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}};this.onMouseMove=function(c){this.mouseX=c.clientX-this.windowHalfX;this.mouseY=c.clientY-this.windowHalfY};
this.onKeyDown=function(c){switch(c.keyCode){case 38:case 87:this.moveForward=!0;break;case 37:case 65:this.moveLeft=!0;break;case 40:case 83:this.moveBackward=!0;break;case 39:case 68:this.moveRight=!0}};this.onKeyUp=function(c){switch(c.keyCode){case 38:case 87:this.moveForward=!1;break;case 37:case 65:this.moveLeft=!1;break;case 40:case 83:this.moveBackward=!1;break;case 39:case 68:this.moveRight=!1}};this.update=function(){this.autoSpeedFactor=this.heightSpeed?((this.position.y<this.heightMin?
this.heightMin:this.position.y>this.heightMax?this.heightMax:this.position.y)-this.heightMin)*this.heightCoef:0;(this.moveForward||this.autoForward)&&this.translateZ(-(this.movementSpeed+this.autoSpeedFactor),this.noFly);this.moveBackward&&this.translateZ(this.movementSpeed,this.noFly);this.moveLeft&&this.translateX(-this.movementSpeed,this.noFly);this.moveRight&&this.translateX(this.movementSpeed,this.noFly);this.lon+=this.mouseX*this.lookSpeed;this.lookVertical&&(this.lat-=this.mouseY*this.lookSpeed);
this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;var c=this.target.position,d=this.position;c.x=d.x+100*Math.sin(this.phi)*Math.cos(this.theta);c.y=d.y+100*Math.cos(this.phi);c.z=d.z+100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this)};this.domElement.addEventListener("contextmenu",function(c){c.preventDefault()},!1);this.domElement.addEventListener("mousemove",b(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",
b(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup",b(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",b(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",b(this,this.onKeyUp),!1)};THREE.QuakeCamera.prototype=new THREE.Camera;THREE.QuakeCamera.prototype.constructor=THREE.QuakeCamera;THREE.QuakeCamera.prototype.supr=THREE.Camera.prototype;THREE.Light=function(a){THREE.Object3D.call(this);this.color=new THREE.Color(a)};THREE.Light.prototype=new THREE.Object3D;
THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.supr=THREE.Object3D.prototype;THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;THREE.DirectionalLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;
THREE.PointLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||1};THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight;THREE.FlatShading=0;THREE.SmoothShading=1;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;THREE.BillboardBlending=3;THREE.ReverseSubtractiveBlending=4;THREE.MaterialCounter={value:0};THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};
THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
THREE.LineBasicMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;this.depthTest=!0;this.linewidth=1;this.linejoin=this.linecap="round";this.vertexColors=!1;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending;if(a.depthTest!==undefined)this.depthTest=a.depthTest;if(a.linewidth!==undefined)this.linewidth=
a.linewidth;if(a.linecap!==undefined)this.linecap=a.linecap;if(a.linejoin!==undefined)this.linejoin=a.linejoin;if(a.vertexColors!==undefined)this.vertexColors=a.vertexColors}};
THREE.MeshBasicMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.envMap=this.lightMap=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refractionRatio=0.98;this.fog=!0;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.depthTest=!0;this.wireframe=!1;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.vertexColors=!1;this.skinning=!1;if(a){a.color!==undefined&&
this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.map!==undefined)this.map=a.map;if(a.lightMap!==undefined)this.lightMap=a.lightMap;if(a.envMap!==undefined)this.envMap=a.envMap;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refractionRatio!==undefined)this.refractionRatio=a.refractionRatio;if(a.fog!==undefined)this.fog=a.fog;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=
a.blending;if(a.depthTest!==undefined)this.depthTest=a.depthTest;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframeLinewidth!==undefined)this.wireframeLinewidth=a.wireframeLinewidth;if(a.wireframeLinecap!==undefined)this.wireframeLinecap=a.wireframeLinecap;if(a.wireframeLinejoin!==undefined)this.wireframeLinejoin=a.wireframeLinejoin;if(a.vertexColors!==undefined)this.vertexColors=a.vertexColors;if(a.skinning!==undefined)this.skinning=a.skinning}};
THREE.MeshLambertMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.envMap=this.lightMap=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refractionRatio=0.98;this.fog=!0;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.depthTest=!0;this.wireframe=!1;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.vertexColors=!1;this.skinning=!1;if(a){a.color!==undefined&&
this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.map!==undefined)this.map=a.map;if(a.lightMap!==undefined)this.lightMap=a.lightMap;if(a.envMap!==undefined)this.envMap=a.envMap;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refractionRatio!==undefined)this.refractionRatio=a.refractionRatio;if(a.fog!==undefined)this.fog=a.fog;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=
a.blending;if(a.depthTest!==undefined)this.depthTest=a.depthTest;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframeLinewidth!==undefined)this.wireframeLinewidth=a.wireframeLinewidth;if(a.wireframeLinecap!==undefined)this.wireframeLinecap=a.wireframeLinecap;if(a.wireframeLinejoin!==undefined)this.wireframeLinejoin=a.wireframeLinejoin;if(a.vertexColors!==undefined)this.vertexColors=a.vertexColors;if(a.skinning!==undefined)this.skinning=a.skinning}};
THREE.MeshPhongMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.ambient=new THREE.Color(328965);this.specular=new THREE.Color(1118481);this.shininess=30;this.opacity=1;this.envMap=this.lightMap=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refractionRatio=0.98;this.fog=!0;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.depthTest=!0;this.wireframe=!1;this.wireframeLinewidth=1;this.wireframeLinejoin=
this.wireframeLinecap="round";this.vertexColors=!1;this.skinning=!1;if(a){if(a.color!==undefined)this.color=new THREE.Color(a.color);if(a.ambient!==undefined)this.ambient=new THREE.Color(a.ambient);if(a.specular!==undefined)this.specular=new THREE.Color(a.specular);if(a.shininess!==undefined)this.shininess=a.shininess;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.lightMap!==undefined)this.lightMap=a.lightMap;if(a.map!==undefined)this.map=a.map;if(a.envMap!==undefined)this.envMap=a.envMap;if(a.combine!==
undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refractionRatio!==undefined)this.refractionRatio=a.refractionRatio;if(a.fog!==undefined)this.fog=a.fog;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.depthTest!==undefined)this.depthTest=a.depthTest;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframeLinewidth!==undefined)this.wireframeLinewidth=a.wireframeLinewidth;if(a.wireframeLinecap!==
undefined)this.wireframeLinecap=a.wireframeLinecap;if(a.wireframeLinejoin!==undefined)this.wireframeLinejoin=a.wireframeLinejoin;if(a.vertexColors!==undefined)this.vertexColors=a.vertexColors;if(a.skinning!==undefined)this.skinning=a.skinning}};
THREE.MeshDepthMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.depthTest=!0;this.wireframe=!1;this.wireframeLinewidth=1;if(a){if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.depthTest!==undefined)this.depthTest=a.depthTest;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframeLinewidth!==
undefined)this.wireframeLinewidth=a.wireframeLinewidth}};
THREE.MeshNormalMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.opacity=1;this.shading=THREE.FlatShading;this.blending=THREE.NormalBlending;this.depthTest=!0;this.wireframe=!1;this.wireframeLinewidth=1;if(a){if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.depthTest!==undefined)this.depthTest=a.depthTest;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframeLinewidth!==
undefined)this.wireframeLinewidth=a.wireframeLinewidth}};THREE.MeshFaceMaterial=function(){};
THREE.MeshShaderMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.vertexShader=this.fragmentShader="void main() {}";this.uniforms={};this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.depthTest=!0;this.wireframe=!1;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.vertexColors=!1;this.skinning=!1;if(a){if(a.fragmentShader!==undefined)this.fragmentShader=a.fragmentShader;if(a.vertexShader!==undefined)this.vertexShader=
a.vertexShader;if(a.uniforms!==undefined)this.uniforms=a.uniforms;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.depthTest!==undefined)this.depthTest=a.depthTest;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframeLinewidth!==undefined)this.wireframeLinewidth=a.wireframeLinewidth;if(a.wireframeLinecap!==undefined)this.wireframeLinecap=a.wireframeLinecap;if(a.wireframeLinejoin!==
undefined)this.wireframeLinejoin=a.wireframeLinejoin;if(a.vertexColors!==undefined)this.vertexColors=a.vertexColors;if(a.skinning!==undefined)this.skinning=a.skinning}};
THREE.ParticleBasicMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.map=null;this.size=1;this.blending=THREE.NormalBlending;this.depthTest=!0;this.offset=new THREE.Vector2;this.vertexColors=!1;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.map!==undefined)this.map=a.map;if(a.size!==undefined)this.size=a.size;if(a.blending!==undefined)this.blending=a.blending;if(a.depthTest!==
undefined)this.depthTest=a.depthTest;if(a.vertexColors!==undefined)this.vertexColors=a.vertexColors}};THREE.ParticleCircleMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}};
THREE.ParticleDOMMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.domElement=a};THREE.Texture=function(a,b,c,d,e,g){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrapS=c!==undefined?c:THREE.ClampToEdgeWrapping;this.wrapT=d!==undefined?d:THREE.ClampToEdgeWrapping;this.magFilter=e!==undefined?e:THREE.LinearFilter;this.minFilter=g!==undefined?g:THREE.LinearMipMapLinearFilter;this.needsUpdate=!1};
THREE.Texture.prototype={clone:function(){return new THREE.Texture(this.image,this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter)}};THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2;THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLinearFilter=5;THREE.LinearFilter=6;THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;THREE.ByteType=9;THREE.UnsignedByteType=10;
THREE.ShortType=11;THREE.UnsignedShortType=12;THREE.IntType=13;THREE.UnsignedIntType=14;THREE.FloatType=15;THREE.AlphaFormat=16;THREE.RGBFormat=17;THREE.RGBAFormat=18;THREE.LuminanceFormat=19;THREE.LuminanceAlphaFormat=20;
THREE.RenderTarget=function(a,b,c){this.width=a;this.height=b;c=c||{};this.wrapS=c.wrapS!==undefined?c.wrapS:THREE.ClampToEdgeWrapping;this.wrapT=c.wrapT!==undefined?c.wrapT:THREE.ClampToEdgeWrapping;this.magFilter=c.magFilter!==undefined?c.magFilter:THREE.LinearFilter;this.minFilter=c.minFilter!==undefined?c.minFilter:THREE.LinearMipMapLinearFilter;this.format=c.format!==undefined?c.format:THREE.RGBFormat;this.type=c.type!==undefined?c.type:THREE.UnsignedByteType};
var Uniforms={clone:function(a){var b,c,d,e={};for(b in a){e[b]={};for(c in a[b]){d=a[b][c];e[b][c]=d instanceof THREE.Color||d instanceof THREE.Vector3||d instanceof THREE.Texture?d.clone():d}}return e},merge:function(a){var b,c,d,e={};for(b=0;b<a.length;b++){d=this.clone(a[b]);for(c in d)e[c]=d[c]}return e}};THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.matrixAutoUpdate=!1};THREE.Particle.prototype=new THREE.Object3D;
THREE.Particle.prototype.constructor=THREE.Particle;THREE.ParticleSystem=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];this.sortParticles=!1};THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;THREE.Line=function(a,b,c){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];this.type=c!=undefined?c:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;
THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;THREE.Mesh=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.materials=b&&b.length?b:[b];this.flipSided=!1;this.doubleSided=!1;this.overdraw=!1;if(this.geometry){this.geometry.boundingSphere||this.geometry.computeBoundingSphere();this.boundRadius=a.boundingSphere.radius}};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.Mesh.prototype.supr=THREE.Object3D.prototype;
THREE.Bone=function(a){THREE.Object3D.call(this);this.skin=a;this.skinMatrix=new THREE.Matrix4;this.hasNoneBoneChildren=!1};THREE.Bone.prototype=new THREE.Object3D;THREE.Bone.prototype.constructor=THREE.Bone;THREE.Bone.prototype.supr=THREE.Object3D.prototype;
THREE.Bone.prototype.update=function(a,b,c){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixNeedsUpdate){a?this.skinMatrix.multiply(a,this.matrix):this.skinMatrix.copy(this.matrix);this.matrixNeedsUpdate=!1;b=!0}var d,e=this.children.length;if(this.hasNoneBoneChildren){this.matrixWorld.multiply(this.skin.matrixWorld,this.skinMatrix);for(d=0;d<e;d++){a=this.children[d];a instanceof THREE.Bone?a.update(this.skinMatrix,b,c):a.update(this.matrixWorld,!0,c)}}else for(d=0;d<e;d++)this.children[d].update(this.skinMatrix,
b,c)};THREE.Bone.prototype.addChild=function(a){if(this.children.indexOf(a)===-1){a.parent!==undefined&&a.parent.removeChild(a);a.parent=this;this.children.push(a);if(!(a instanceof THREE.Bone))this.hasNoneBoneChildren=!0}};if(!window.Float32Array)window.Float32Array=Array;
THREE.SkinnedMesh=function(a,b){THREE.Mesh.call(this,a,b);this.identityMatrix=new THREE.Matrix4;this.bones=[];this.boneMatrices=[];var c,d,e,g,h,j;if(this.geometry.bones!==undefined){for(c=0;c<this.geometry.bones.length;c++){e=this.geometry.bones[c];g=e.pos;h=e.rotq;j=e.scl;d=this.addBone();d.name=e.name;d.position.set(g[0],g[1],g[2]);d.quaternion.set(h[0],h[1],h[2],h[3]);j!==undefined?d.scale.set(j[0],j[1],j[2]):d.scale.set(1,1,1)}for(c=0;c<this.bones.length;c++){e=this.geometry.bones[c];d=this.bones[c];
e.parent===-1?this.addChild(d):this.bones[e.parent].addChild(d)}this.boneMatrices=new Float32Array(16*this.bones.length);this.pose()}};THREE.SkinnedMesh.prototype=new THREE.Mesh;THREE.SkinnedMesh.prototype.constructor=THREE.SkinnedMesh;
THREE.SkinnedMesh.prototype.update=function(a,b,c){if(this.visible){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixNeedsUpdate=!1;b=!0}var d,e=this.children.length;for(d=0;d<e;d++){a=this.children[d];a instanceof THREE.Bone?a.update(this.identityMatrix,!1,c):a.update(this.matrixWorld,b,c)}}};
THREE.SkinnedMesh.prototype.addBone=function(a){a===undefined&&(a=new THREE.Bone(this));this.bones.push(a);return a};
THREE.SkinnedMesh.prototype.pose=function(){this.update(undefined,!0);for(var a,b=[],c=0;c<this.bones.length;c++){a=this.bones[c];b.push(THREE.Matrix4.makeInvert(a.skinMatrix));a.skinMatrix.flattenToArrayOffset(this.boneMatrices,c*16)}if(this.geometry.skinVerticesA===undefined){this.geometry.skinVerticesA=[];this.geometry.skinVerticesB=[];var d;for(a=0;a<this.geometry.skinIndices.length;a++){c=this.geometry.vertices[a].position;var e=this.geometry.skinIndices[a].x,g=this.geometry.skinIndices[a].y;
d=new THREE.Vector3(c.x,c.y,c.z);this.geometry.skinVerticesA.push(b[e].multiplyVector3(d));d=new THREE.Vector3(c.x,c.y,c.z);this.geometry.skinVerticesB.push(b[g].multiplyVector3(d));if(this.geometry.skinWeights[a].x+this.geometry.skinWeights[a].y!==1){c=(1-(this.geometry.skinWeights[a].x+this.geometry.skinWeights[a].y))*0.5;this.geometry.skinWeights[a].x+=c;this.geometry.skinWeights[a].y+=c}}}};
THREE.Ribbon=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];this.flipSided=!1;this.doubleSided=!1};THREE.Ribbon.prototype=new THREE.Object3D;THREE.Ribbon.prototype.constructor=THREE.Ribbon;
THREE.Sound=function(a,b,c,d){THREE.Object3D.call(this);this.isLoaded=!1;this.isAddedToDOM=!1;this.isPlaying=!1;this.duration=-1;this.radius=b!==undefined?Math.abs(b):100;this.volume=Math.min(1,Math.max(0,c!==undefined?c:1));this.domElement=document.createElement("audio");this.domElement.volume=0;this.domElement.pan=0;this.domElement.loop=d!==undefined?d:!0;this.sources=a instanceof Array?a:[a];var e;c=this.sources.length;for(a=0;a<c;a++){b=this.sources[a];b.toLowerCase();if(b.indexOf(".mp3")!==-1)e=
"audio/mpeg";else if(b.indexOf(".ogg")!==-1)e="audio/ogg";else b.indexOf(".wav")!==-1&&(e="audio/wav");if(this.domElement.canPlayType(e)){e=document.createElement("source");e.src=this.sources[a];this.domElement.THREESound=this;this.domElement.appendChild(e);this.domElement.addEventListener("canplay",this.onLoad,!0);this.domElement.load();break}}};THREE.Sound.prototype=new THREE.Object3D;THREE.Sound.prototype.constructor=THREE.Sound;THREE.Sound.prototype.supr=THREE.Object3D.prototype;
THREE.Sound.prototype.onLoad=function(){var a=this.THREESound;if(!a.isLoaded){this.removeEventListener("canplay",this.onLoad,!0);a.isLoaded=!0;a.duration=this.duration;a.isPlaying&&a.play()}};THREE.Sound.prototype.addToDOM=function(a){this.isAddedToDOM=!0;a.appendChild(this.domElement)};THREE.Sound.prototype.play=function(a){this.isPlaying=!0;if(this.isLoaded){this.domElement.play();if(a)this.domElement.currentTime=a%this.duration}};THREE.Sound.prototype.pause=function(){this.isPlaying=!1;this.domElement.pause()};
THREE.Sound.prototype.stop=function(){this.isPlaying=!1;this.domElement.pause();this.domElement.currentTime=0};THREE.Sound.prototype.calculateVolumeAndPan=function(a){a=a.length();this.domElement.volume=a<=this.radius?this.volume*(1-a/this.radius):0};
THREE.Sound.prototype.update=function(a,b,c){if(this.matrixAutoUpdate){this.matrix.setPosition(this.position);b=!0}if(b||this.matrixNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixNeedsUpdate=!1;b=!0}var d=this.children.length;for(a=0;a<d;a++)this.children[a].update(this.matrixWorld,b,c)};THREE.LOD=function(){THREE.Object3D.call(this);this.LODs=[]};THREE.LOD.prototype=new THREE.Object3D;THREE.LOD.prototype.constructor=THREE.LOD;
THREE.LOD.prototype.supr=THREE.Object3D.prototype;THREE.LOD.prototype.add=function(a,b){b===undefined&&(b=0);b=Math.abs(b);for(var c=0;c<this.LODs.length;c++)if(b<this.LODs[c].visibleAtDistance)break;this.LODs.splice(c,0,{visibleAtDistance:b,object3D:a});this.addChild(a)};
THREE.LOD.prototype.update=function(a,b,c){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixNeedsUpdate=!1;b=!0}if(this.LODs.length>1){a=c.matrixWorldInverse;a=-(a.n31*this.position.x+a.n32*this.position.y+a.n33*this.position.z+a.n34);this.LODs[0].object3D.visible=!0;for(var d=1;d<this.LODs.length;d++)if(a>=this.LODs[d].visibleAtDistance){this.LODs[d-1].object3D.visible=!1;this.LODs[d].object3D.visible=
!0}else break;for(;d<this.LODs.length;d++)this.LODs[d].object3D.visible=!1}for(a=0;a<this.children.length;a++)this.children[a].update(this.matrixWorld,b,c)};THREE.Scene=function(){THREE.Object3D.call(this);this.matrixAutoUpdate=!1;this.fog=null;this.objects=[];this.lights=[];this.sounds=[];this.__objectsAdded=[];this.__objectsRemoved=[]};THREE.Scene.prototype=new THREE.Object3D;THREE.Scene.prototype.constructor=THREE.Scene;THREE.Scene.prototype.supr=THREE.Object3D.prototype;
THREE.Scene.prototype.addChild=function(a){this.supr.addChild.call(this,a);this.addChildRecurse(a)};THREE.Scene.prototype.addChildRecurse=function(a){if(a instanceof THREE.Light)this.lights.indexOf(a)===-1&&this.lights.push(a);else if(a instanceof THREE.Sound)this.sounds.indexOf(a)===-1&&this.sounds.push(a);else if(!(a instanceof THREE.Camera||a instanceof THREE.Bone)&&this.objects.indexOf(a)===-1){this.objects.push(a);this.__objectsAdded.push(a)}for(var b=0;b<a.children.length;b++)this.addChildRecurse(a.children[b])};
THREE.Scene.prototype.removeChild=function(a){this.supr.removeChild.call(this,a);this.removeChildRecurse(a)};THREE.Scene.prototype.removeChildRecurse=function(a){if(a instanceof THREE.Light){var b=this.lights.indexOf(a);b!==-1&&this.lights.splice(b,1)}else if(a instanceof THREE.Sound){b=this.sounds.indexOf(a);b!==-1&&this.sounds.splice(b,1)}else if(!(a instanceof THREE.Camera)){b=this.objects.indexOf(a);if(b!==-1){this.objects.splice(b,1);this.__objectsRemoved.push(a)}}for(b=0;b<a.children.length;b++)this.removeChildRecurse(a.children[b])};
THREE.Scene.prototype.addObject=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeObject=THREE.Scene.prototype.removeChild;THREE.Scene.prototype.addLight=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeLight=THREE.Scene.prototype.removeChild;THREE.Fog=function(a,b,c){this.color=new THREE.Color(a);this.near=b||1;this.far=c||1E3};THREE.FogExp2=function(a,b){this.color=new THREE.Color(a);this.density=b||2.5E-4};
THREE.Projector=function(){function a(N,O){return O.z-N.z}function b(N,O){var U=0,Q=1,Z=N.z+N.w,ca=O.z+O.w,L=-N.z+N.w,W=-O.z+O.w;if(Z>=0&&ca>=0&&L>=0&&W>=0)return!0;else if(Z<0&&ca<0||L<0&&W<0)return!1;else{if(Z<0)U=Math.max(U,Z/(Z-ca));else ca<0&&(Q=Math.min(Q,Z/(Z-ca)));if(L<0)U=Math.max(U,L/(L-W));else W<0&&(Q=Math.min(Q,L/(L-W)));if(Q<U)return!1;else{N.lerpSelf(O,U);O.lerpSelf(N,1-Q);return!0}}}var c,d,e=[],g,h,j,k=[],m,p,y=[],t,q,z=[],C=new THREE.Vector4,F=new THREE.Vector4,v=new THREE.Matrix4,
G=new THREE.Matrix4,w=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],K=new THREE.Vector4,J=new THREE.Vector4,f;this.projectObjects=function(N,O,U){O=[];var Q,Z,ca;d=0;Z=N.objects;N=0;for(Q=Z.length;N<Q;N++){ca=Z[N];var L;if(!(L=!ca.visible))if(L=ca instanceof THREE.Mesh){a:{L=void 0;for(var W=ca.matrixWorld,ma=-ca.geometry.boundingSphere.radius*Math.max(ca.scale.x,Math.max(ca.scale.y,ca.scale.z)),ba=0;ba<6;ba++){L=w[ba].x*W.n14+w[ba].y*
W.n24+w[ba].z*W.n34+w[ba].w;if(L<=ma){L=!1;break a}}L=!0}L=!L}if(!L){c=e[d]=e[d]||new THREE.RenderableObject;C.copy(ca.position);v.multiplyVector3(C);c.object=ca;c.z=C.z;O.push(c);d++}}U&&O.sort(a);return O};this.projectScene=function(N,O,U){var Q=[],Z=O.near,ca=O.far,L,W,ma,ba,na,ga,ia,ra,wa,l,x,B,n,o,E,D;j=p=q=0;O.matrixAutoUpdate&&O.update();v.multiply(O.projectionMatrix,O.matrixWorldInverse);w[0].set(v.n41-v.n11,v.n42-v.n12,v.n43-v.n13,v.n44-v.n14);w[1].set(v.n41+v.n11,v.n42+v.n12,v.n43+v.n13,
v.n44+v.n14);w[2].set(v.n41+v.n21,v.n42+v.n22,v.n43+v.n23,v.n44+v.n24);w[3].set(v.n41-v.n21,v.n42-v.n22,v.n43-v.n23,v.n44-v.n24);w[4].set(v.n41-v.n31,v.n42-v.n32,v.n43-v.n33,v.n44-v.n34);w[5].set(v.n41+v.n31,v.n42+v.n32,v.n43+v.n33,v.n44+v.n34);for(L=0;L<6;L++){ga=w[L];ga.divideScalar(Math.sqrt(ga.x*ga.x+ga.y*ga.y+ga.z*ga.z))}N.update(undefined,!1,O);ga=this.projectObjects(N,O,!0);N=0;for(L=ga.length;N<L;N++){ia=ga[N].object;if(ia.visible){ra=ia.matrixWorld;x=ia.matrixRotationWorld;wa=ia.materials;
l=ia.overdraw;if(ia instanceof THREE.Mesh){B=ia.geometry;n=B.vertices;W=0;for(ma=n.length;W<ma;W++){o=n[W];o.positionWorld.copy(o.position);ra.multiplyVector3(o.positionWorld);ba=o.positionScreen;ba.copy(o.positionWorld);v.multiplyVector4(ba);ba.x/=ba.w;ba.y/=ba.w;o.__visible=ba.z>Z&&ba.z<ca}B=B.faces;W=0;for(ma=B.length;W<ma;W++){o=B[W];if(o instanceof THREE.Face3){ba=n[o.a];na=n[o.b];E=n[o.c];if(ba.__visible&&na.__visible&&E.__visible&&(ia.doubleSided||ia.flipSided!=(E.positionScreen.x-ba.positionScreen.x)*
(na.positionScreen.y-ba.positionScreen.y)-(E.positionScreen.y-ba.positionScreen.y)*(na.positionScreen.x-ba.positionScreen.x)<0)){g=k[j]=k[j]||new THREE.RenderableFace3;g.v1.positionWorld.copy(ba.positionWorld);g.v2.positionWorld.copy(na.positionWorld);g.v3.positionWorld.copy(E.positionWorld);g.v1.positionScreen.copy(ba.positionScreen);g.v2.positionScreen.copy(na.positionScreen);g.v3.positionScreen.copy(E.positionScreen);g.normalWorld.copy(o.normal);x.multiplyVector3(g.normalWorld);g.centroidWorld.copy(o.centroid);
ra.multiplyVector3(g.centroidWorld);g.centroidScreen.copy(g.centroidWorld);v.multiplyVector3(g.centroidScreen);E=o.vertexNormals;f=g.vertexNormalsWorld;ba=0;for(na=E.length;ba<na;ba++){D=f[ba]=f[ba]||new THREE.Vector3;D.copy(E[ba]);x.multiplyVector3(D)}g.z=g.centroidScreen.z;g.meshMaterials=wa;g.faceMaterials=o.materials;g.overdraw=l;if(ia.geometry.uvs[W]){g.uvs[0]=ia.geometry.uvs[W][0];g.uvs[1]=ia.geometry.uvs[W][1];g.uvs[2]=ia.geometry.uvs[W][2]}Q.push(g);j++}}else if(o instanceof THREE.Face4){ba=
n[o.a];na=n[o.b];E=n[o.c];D=n[o.d];if(ba.__visible&&na.__visible&&E.__visible&&D.__visible&&(ia.doubleSided||ia.flipSided!=((D.positionScreen.x-ba.positionScreen.x)*(na.positionScreen.y-ba.positionScreen.y)-(D.positionScreen.y-ba.positionScreen.y)*(na.positionScreen.x-ba.positionScreen.x)<0||(na.positionScreen.x-E.positionScreen.x)*(D.positionScreen.y-E.positionScreen.y)-(na.positionScreen.y-E.positionScreen.y)*(D.positionScreen.x-E.positionScreen.x)<0))){g=k[j]=k[j]||new THREE.RenderableFace3;g.v1.positionWorld.copy(ba.positionWorld);
g.v2.positionWorld.copy(na.positionWorld);g.v3.positionWorld.copy(D.positionWorld);g.v1.positionScreen.copy(ba.positionScreen);g.v2.positionScreen.copy(na.positionScreen);g.v3.positionScreen.copy(D.positionScreen);g.normalWorld.copy(o.normal);x.multiplyVector3(g.normalWorld);g.centroidWorld.copy(o.centroid);ra.multiplyVector3(g.centroidWorld);g.centroidScreen.copy(g.centroidWorld);v.multiplyVector3(g.centroidScreen);g.z=g.centroidScreen.z;g.meshMaterials=wa;g.faceMaterials=o.materials;g.overdraw=
l;if(ia.geometry.uvs[W]){g.uvs[0]=ia.geometry.uvs[W][0];g.uvs[1]=ia.geometry.uvs[W][1];g.uvs[2]=ia.geometry.uvs[W][3]}Q.push(g);j++;h=k[j]=k[j]||new THREE.RenderableFace3;h.v1.positionWorld.copy(na.positionWorld);h.v2.positionWorld.copy(E.positionWorld);h.v3.positionWorld.copy(D.positionWorld);h.v1.positionScreen.copy(na.positionScreen);h.v2.positionScreen.copy(E.positionScreen);h.v3.positionScreen.copy(D.positionScreen);h.normalWorld.copy(g.normalWorld);h.centroidWorld.copy(g.centroidWorld);h.centroidScreen.copy(g.centroidScreen);
h.z=h.centroidScreen.z;h.meshMaterials=wa;h.faceMaterials=o.materials;h.overdraw=l;if(ia.geometry.uvs[W]){h.uvs[0]=ia.geometry.uvs[W][1];h.uvs[1]=ia.geometry.uvs[W][2];h.uvs[2]=ia.geometry.uvs[W][3]}Q.push(h);j++}}}}else if(ia instanceof THREE.Line){G.multiply(v,ra);n=ia.geometry.vertices;o=n[0];o.positionScreen.copy(o.position);G.multiplyVector4(o.positionScreen);W=1;for(ma=n.length;W<ma;W++){ba=n[W];ba.positionScreen.copy(ba.position);G.multiplyVector4(ba.positionScreen);na=n[W-1];K.copy(ba.positionScreen);
J.copy(na.positionScreen);if(b(K,J)){K.multiplyScalar(1/K.w);J.multiplyScalar(1/J.w);m=y[p]=y[p]||new THREE.RenderableLine;m.v1.positionScreen.copy(K);m.v2.positionScreen.copy(J);m.z=Math.max(K.z,J.z);m.materials=ia.materials;Q.push(m);p++}}}else if(ia instanceof THREE.Particle){F.set(ia.position.x,ia.position.y,ia.position.z,1);v.multiplyVector4(F);F.z/=F.w;if(F.z>0&&F.z<1){t=z[q]=z[q]||new THREE.RenderableParticle;t.x=F.x/F.w;t.y=F.y/F.w;t.z=F.z;t.rotation=ia.rotation.z;t.scale.x=ia.scale.x*Math.abs(t.x-
(F.x+O.projectionMatrix.n11)/(F.w+O.projectionMatrix.n14));t.scale.y=ia.scale.y*Math.abs(t.y-(F.y+O.projectionMatrix.n22)/(F.w+O.projectionMatrix.n24));t.materials=ia.materials;Q.push(t);q++}}}}U&&Q.sort(a);return Q};this.unprojectVector=function(N,O){var U=O.matrixWorld.clone();U.multiplySelf(THREE.Matrix4.makeInvert(O.projectionMatrix));U.multiplyVector3(N);return N}};
THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,c,d,e,g;this.domElement=document.createElement("div");this.setSize=function(h,j){c=h;d=j;e=c/2;g=d/2};this.render=function(h,j){var k,m,p,y,t,q,z,C;a=b.projectScene(h,j);k=0;for(m=a.length;k<m;k++){t=a[k];if(t instanceof THREE.RenderableParticle){z=t.x*e+e;C=t.y*g+g;p=0;for(y=t.material.length;p<y;p++){q=t.material[p];if(q instanceof THREE.ParticleDOMMaterial){q=q.domElement;q.style.left=z+"px";q.style.top=C+"px"}}}}}};
THREE.CanvasRenderer=function(){function a(pa){if(t!=pa)m.globalAlpha=t=pa}function b(pa){if(q!=pa){switch(pa){case THREE.NormalBlending:m.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:m.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:m.globalCompositeOperation="darker"}q=pa}}var c=null,d=new THREE.Projector,e=document.createElement("canvas"),g,h,j,k,m=e.getContext("2d"),p=new THREE.Color(0),y=0,t=1,q=0,z=null,C=null,F=1,v,G,w,K,J,f,N,O,U,Q=new THREE.Color,
Z=new THREE.Color,ca=new THREE.Color,L=new THREE.Color,W=new THREE.Color,ma,ba,na,ga,ia,ra,wa,l,x,B=new THREE.Rectangle,n=new THREE.Rectangle,o=new THREE.Rectangle,E=!1,D=new THREE.Color,I=new THREE.Color,S=new THREE.Color,u=new THREE.Color,A=Math.PI*2,H=new THREE.Vector3,T,Y,ha,da,ka,Ca,P=16;T=document.createElement("canvas");T.width=T.height=2;Y=T.getContext("2d");Y.fillStyle="rgba(0,0,0,1)";Y.fillRect(0,0,2,2);ha=Y.getImageData(0,0,2,2);da=ha.data;ka=document.createElement("canvas");ka.width=ka.height=
P;Ca=ka.getContext("2d");Ca.translate(-P/2,-P/2);Ca.scale(P,P);P--;this.domElement=e;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setSize=function(pa,xa){g=pa;h=xa;j=g/2;k=h/2;e.width=g;e.height=h;B.set(-j,-k,j,k);t=1;q=0;C=z=null;F=1};this.setClearColor=function(pa,xa){p=pa;y=xa};this.setClearColorHex=function(pa,xa){p.setHex(pa);y=xa};this.clear=function(){m.setTransform(1,0,0,-1,j,k);if(!n.isEmpty()){n.inflate(1);n.minSelf(B);if(p.hex==0&&y==0)m.clearRect(n.getX(),n.getY(),n.getWidth(),
n.getHeight());else{b(THREE.NormalBlending);a(1);m.fillStyle="rgba("+Math.floor(p.r*255)+","+Math.floor(p.g*255)+","+Math.floor(p.b*255)+","+y+")";m.fillRect(n.getX(),n.getY(),n.getWidth(),n.getHeight())}n.empty()}};this.render=function(pa,xa){function Ia(R){var fa,ja,V,ea=R.lights;I.setRGB(0,0,0);S.setRGB(0,0,0);u.setRGB(0,0,0);R=0;for(fa=ea.length;R<fa;R++){ja=ea[R];V=ja.color;if(ja instanceof THREE.AmbientLight){I.r+=V.r;I.g+=V.g;I.b+=V.b}else if(ja instanceof THREE.DirectionalLight){S.r+=V.r;
S.g+=V.g;S.b+=V.b}else if(ja instanceof THREE.PointLight){u.r+=V.r;u.g+=V.g;u.b+=V.b}}}function X(R,fa,ja,V){var ea,qa,Da,Ea,ya=R.lights;R=0;for(ea=ya.length;R<ea;R++){qa=ya[R];Da=qa.color;Ea=qa.intensity;if(qa instanceof THREE.DirectionalLight){qa=ja.dot(qa.position)*Ea;if(qa>0){V.r+=Da.r*qa;V.g+=Da.g*qa;V.b+=Da.b*qa}}else if(qa instanceof THREE.PointLight){H.sub(qa.position,fa);H.normalize();qa=ja.dot(H)*Ea;if(qa>0){V.r+=Da.r*qa;V.g+=Da.g*qa;V.b+=Da.b*qa}}}}function $(R,fa,ja){if(ja.opacity!=0){a(ja.opacity);
b(ja.blending);var V,ea,qa,Da,Ea,ya;if(ja instanceof THREE.ParticleBasicMaterial){if(ja.map){Da=ja.map.image;Ea=Da.width>>1;ya=Da.height>>1;ea=fa.scale.x*j;qa=fa.scale.y*k;ja=ea*Ea;V=qa*ya;o.set(R.x-ja,R.y-V,R.x+ja,R.y+V);if(B.instersects(o)){m.save();m.translate(R.x,R.y);m.rotate(-fa.rotation);m.scale(ea,-qa);m.translate(-Ea,-ya);m.drawImage(Da,0,0);m.restore()}}}else if(ja instanceof THREE.ParticleCircleMaterial){if(E){D.r=I.r+S.r+u.r;D.g=I.g+S.g+u.g;D.b=I.b+S.b+u.b;Q.r=ja.color.r*D.r;Q.g=ja.color.g*
D.g;Q.b=ja.color.b*D.b;Q.updateStyleString()}else Q.__styleString=ja.color.__styleString;ja=fa.scale.x*j;V=fa.scale.y*k;o.set(R.x-ja,R.y-V,R.x+ja,R.y+V);if(B.instersects(o)){ea=Q.__styleString;if(C!=ea)m.fillStyle=C=ea;m.save();m.translate(R.x,R.y);m.rotate(-fa.rotation);m.scale(ja,V);m.beginPath();m.arc(0,0,1,0,A,!0);m.closePath();m.fill();m.restore()}}}}function aa(R,fa,ja,V){if(V.opacity!=0){a(V.opacity);b(V.blending);m.beginPath();m.moveTo(R.positionScreen.x,R.positionScreen.y);m.lineTo(fa.positionScreen.x,
fa.positionScreen.y);m.closePath();if(V instanceof THREE.LineBasicMaterial){Q.__styleString=V.color.__styleString;R=V.linewidth;if(F!=R)m.lineWidth=F=R;R=Q.__styleString;if(z!=R)m.strokeStyle=z=R;m.stroke();o.inflate(V.linewidth*2)}}}function ta(R,fa,ja,V,ea,qa){if(ea.opacity!=0){a(ea.opacity);b(ea.blending);K=R.positionScreen.x;J=R.positionScreen.y;f=fa.positionScreen.x;N=fa.positionScreen.y;O=ja.positionScreen.x;U=ja.positionScreen.y;m.beginPath();m.moveTo(K,J);m.lineTo(f,N);m.lineTo(O,U);m.lineTo(K,
J);m.closePath();if(ea instanceof THREE.MeshBasicMaterial)if(ea.map)ea.map.mapping instanceof THREE.UVMapping&&M(K,J,f,N,O,U,ea.map.image,V.uvs[0].u,V.uvs[0].v,V.uvs[1].u,V.uvs[1].v,V.uvs[2].u,V.uvs[2].v);else if(ea.envMap){if(ea.envMap.mapping instanceof THREE.SphericalReflectionMapping){R=xa.matrixWorldInverse;H.copy(V.vertexNormalsWorld[0]);ga=(H.x*R.n11+H.y*R.n12+H.z*R.n13)*0.5+0.5;ia=-(H.x*R.n21+H.y*R.n22+H.z*R.n23)*0.5+0.5;H.copy(V.vertexNormalsWorld[1]);ra=(H.x*R.n11+H.y*R.n12+H.z*R.n13)*0.5+
0.5;wa=-(H.x*R.n21+H.y*R.n22+H.z*R.n23)*0.5+0.5;H.copy(V.vertexNormalsWorld[2]);l=(H.x*R.n11+H.y*R.n12+H.z*R.n13)*0.5+0.5;x=-(H.x*R.n21+H.y*R.n22+H.z*R.n23)*0.5+0.5;M(K,J,f,N,O,U,ea.envMap.image,ga,ia,ra,wa,l,x)}}else ea.wireframe?Fa(ea.color.__styleString,ea.wireframeLinewidth):za(ea.color.__styleString);else if(ea instanceof THREE.MeshLambertMaterial){if(ea.map&&!ea.wireframe){ea.map.mapping instanceof THREE.UVMapping&&M(K,J,f,N,O,U,ea.map.image,V.uvs[0].u,V.uvs[0].v,V.uvs[1].u,V.uvs[1].v,V.uvs[2].u,
V.uvs[2].v);b(THREE.SubtractiveBlending)}if(E)if(!ea.wireframe&&ea.shading==THREE.SmoothShading&&V.vertexNormalsWorld.length==3){Z.r=ca.r=L.r=I.r;Z.g=ca.g=L.g=I.g;Z.b=ca.b=L.b=I.b;X(qa,V.v1.positionWorld,V.vertexNormalsWorld[0],Z);X(qa,V.v2.positionWorld,V.vertexNormalsWorld[1],ca);X(qa,V.v3.positionWorld,V.vertexNormalsWorld[2],L);W.r=(ca.r+L.r)*0.5;W.g=(ca.g+L.g)*0.5;W.b=(ca.b+L.b)*0.5;na=Aa(Z,ca,L,W);M(K,J,f,N,O,U,na,0,0,1,0,0,1)}else{D.r=I.r;D.g=I.g;D.b=I.b;X(qa,V.centroidWorld,V.normalWorld,
D);Q.r=ea.color.r*D.r;Q.g=ea.color.g*D.g;Q.b=ea.color.b*D.b;Q.updateStyleString();ea.wireframe?Fa(Q.__styleString,ea.wireframeLinewidth):za(Q.__styleString)}else ea.wireframe?Fa(ea.color.__styleString,ea.wireframeLinewidth):za(ea.color.__styleString)}else if(ea instanceof THREE.MeshDepthMaterial){ma=xa.near;ba=xa.far;Z.r=Z.g=Z.b=1-Pa(R.positionScreen.z,ma,ba);ca.r=ca.g=ca.b=1-Pa(fa.positionScreen.z,ma,ba);L.r=L.g=L.b=1-Pa(ja.positionScreen.z,ma,ba);W.r=(ca.r+L.r)*0.5;W.g=(ca.g+L.g)*0.5;W.b=(ca.b+
L.b)*0.5;na=Aa(Z,ca,L,W);M(K,J,f,N,O,U,na,0,0,1,0,0,1)}else if(ea instanceof THREE.MeshNormalMaterial){Q.r=Qa(V.normalWorld.x);Q.g=Qa(V.normalWorld.y);Q.b=Qa(V.normalWorld.z);Q.updateStyleString();ea.wireframe?Fa(Q.__styleString,ea.wireframeLinewidth):za(Q.__styleString)}}}function Fa(R,fa){if(z!=R)m.strokeStyle=z=R;if(F!=fa)m.lineWidth=F=fa;m.stroke();o.inflate(fa*2)}function za(R){if(C!=R)m.fillStyle=C=R;m.fill()}function M(R,fa,ja,V,ea,qa,Da,Ea,ya,Na,La,Oa,Sa){var Ga,Ja;Ga=Da.width-1;Ja=Da.height-
1;Ea*=Ga;ya*=Ja;Na*=Ga;La*=Ja;Oa*=Ga;Sa*=Ja;ja-=R;V-=fa;ea-=R;qa-=fa;Na-=Ea;La-=ya;Oa-=Ea;Sa-=ya;Ga=Na*Sa-Oa*La;if(Ga!=0){Ja=1/Ga;Ga=(Sa*ja-La*ea)*Ja;La=(Sa*V-La*qa)*Ja;ja=(Na*ea-Oa*ja)*Ja;V=(Na*qa-Oa*V)*Ja;R=R-Ga*Ea-ja*ya;fa=fa-La*Ea-V*ya;m.save();m.transform(Ga,La,ja,V,R,fa);m.clip();m.drawImage(Da,0,0);m.restore()}}function Aa(R,fa,ja,V){var ea=~~(R.r*255),qa=~~(R.g*255);R=~~(R.b*255);var Da=~~(fa.r*255),Ea=~~(fa.g*255);fa=~~(fa.b*255);var ya=~~(ja.r*255),Na=~~(ja.g*255);ja=~~(ja.b*255);var La=
~~(V.r*255),Oa=~~(V.g*255);V=~~(V.b*255);da[0]=ea<0?0:ea>255?255:ea;da[1]=qa<0?0:qa>255?255:qa;da[2]=R<0?0:R>255?255:R;da[4]=Da<0?0:Da>255?255:Da;da[5]=Ea<0?0:Ea>255?255:Ea;da[6]=fa<0?0:fa>255?255:fa;da[8]=ya<0?0:ya>255?255:ya;da[9]=Na<0?0:Na>255?255:Na;da[10]=ja<0?0:ja>255?255:ja;da[12]=La<0?0:La>255?255:La;da[13]=Oa<0?0:Oa>255?255:Oa;da[14]=V<0?0:V>255?255:V;Y.putImageData(ha,0,0);Ca.drawImage(T,0,0);return ka}function Pa(R,fa,ja){R=(R-fa)/(ja-fa);return R*R*(3-2*R)}function Qa(R){R=(R+1)*0.5;return R<
0?0:R>1?1:R}function Ka(R,fa){var ja=fa.x-R.x,V=fa.y-R.y,ea=1/Math.sqrt(ja*ja+V*V);ja*=ea;V*=ea;fa.x+=ja;fa.y+=V;R.x-=ja;R.y-=V}var ua,Ba,la,oa,sa,va,Ma,Ha;this.autoClear?this.clear():m.setTransform(1,0,0,-1,j,k);c=d.projectScene(pa,xa,this.sortElements);(E=pa.lights.length>0)&&Ia(pa);ua=0;for(Ba=c.length;ua<Ba;ua++){la=c[ua];o.empty();if(la instanceof THREE.RenderableParticle){v=la;v.x*=j;v.y*=k;oa=0;for(sa=la.materials.length;oa<sa;oa++)$(v,la,la.materials[oa],pa)}else if(la instanceof THREE.RenderableLine){v=
la.v1;G=la.v2;v.positionScreen.x*=j;v.positionScreen.y*=k;G.positionScreen.x*=j;G.positionScreen.y*=k;o.addPoint(v.positionScreen.x,v.positionScreen.y);o.addPoint(G.positionScreen.x,G.positionScreen.y);if(B.instersects(o)){oa=0;for(sa=la.materials.length;oa<sa;)aa(v,G,la,la.materials[oa++],pa)}}else if(la instanceof THREE.RenderableFace3){v=la.v1;G=la.v2;w=la.v3;v.positionScreen.x*=j;v.positionScreen.y*=k;G.positionScreen.x*=j;G.positionScreen.y*=k;w.positionScreen.x*=j;w.positionScreen.y*=k;if(la.overdraw){Ka(v.positionScreen,
G.positionScreen);Ka(G.positionScreen,w.positionScreen);Ka(w.positionScreen,v.positionScreen)}o.add3Points(v.positionScreen.x,v.positionScreen.y,G.positionScreen.x,G.positionScreen.y,w.positionScreen.x,w.positionScreen.y);if(B.instersects(o)){oa=0;for(sa=la.meshMaterials.length;oa<sa;){Ha=la.meshMaterials[oa++];if(Ha instanceof THREE.MeshFaceMaterial){va=0;for(Ma=la.faceMaterials.length;va<Ma;)(Ha=la.faceMaterials[va++])&&ta(v,G,w,la,Ha,pa)}else ta(v,G,w,la,Ha,pa)}}}n.addRectangle(o)}m.setTransform(1,
0,0,1,0,0)}};
THREE.SVGRenderer=function(){function a(ga,ia,ra){var wa,l,x,B;wa=0;for(l=ga.lights.length;wa<l;wa++){x=ga.lights[wa];if(x instanceof THREE.DirectionalLight){B=ia.normalWorld.dot(x.position)*x.intensity;if(B>0){ra.r+=x.color.r*B;ra.g+=x.color.g*B;ra.b+=x.color.b*B}}else if(x instanceof THREE.PointLight){U.sub(x.position,ia.centroidWorld);U.normalize();B=ia.normalWorld.dot(U)*x.intensity;if(B>0){ra.r+=x.color.r*B;ra.g+=x.color.g*B;ra.b+=x.color.b*B}}}}function b(ga,ia,ra,wa,l,x){L=d(W++);L.setAttribute("d",
"M "+ga.positionScreen.x+" "+ga.positionScreen.y+" L "+ia.positionScreen.x+" "+ia.positionScreen.y+" L "+ra.positionScreen.x+","+ra.positionScreen.y+"z");if(l instanceof THREE.MeshBasicMaterial)w.__styleString=l.color.__styleString;else if(l instanceof THREE.MeshLambertMaterial)if(G){K.r=J.r;K.g=J.g;K.b=J.b;a(x,wa,K);w.r=l.color.r*K.r;w.g=l.color.g*K.g;w.b=l.color.b*K.b;w.updateStyleString()}else w.__styleString=l.color.__styleString;else if(l instanceof THREE.MeshDepthMaterial){O=1-l.__2near/(l.__farPlusNear-
wa.z*l.__farMinusNear);w.setRGB(O,O,O)}else l instanceof THREE.MeshNormalMaterial&&w.setRGB(e(wa.normalWorld.x),e(wa.normalWorld.y),e(wa.normalWorld.z));l.wireframe?L.setAttribute("style","fill: none; stroke: "+w.__styleString+"; stroke-width: "+l.wireframeLinewidth+"; stroke-opacity: "+l.opacity+"; stroke-linecap: "+l.wireframeLinecap+"; stroke-linejoin: "+l.wireframeLinejoin):L.setAttribute("style","fill: "+w.__styleString+"; fill-opacity: "+l.opacity);j.appendChild(L)}function c(ga,ia,ra,wa,l,
x,B){L=d(W++);L.setAttribute("d","M "+ga.positionScreen.x+" "+ga.positionScreen.y+" L "+ia.positionScreen.x+" "+ia.positionScreen.y+" L "+ra.positionScreen.x+","+ra.positionScreen.y+" L "+wa.positionScreen.x+","+wa.positionScreen.y+"z");if(x instanceof THREE.MeshBasicMaterial)w.__styleString=x.color.__styleString;else if(x instanceof THREE.MeshLambertMaterial)if(G){K.r=J.r;K.g=J.g;K.b=J.b;a(B,l,K);w.r=x.color.r*K.r;w.g=x.color.g*K.g;w.b=x.color.b*K.b;w.updateStyleString()}else w.__styleString=x.color.__styleString;
else if(x instanceof THREE.MeshDepthMaterial){O=1-x.__2near/(x.__farPlusNear-l.z*x.__farMinusNear);w.setRGB(O,O,O)}else x instanceof THREE.MeshNormalMaterial&&w.setRGB(e(l.normalWorld.x),e(l.normalWorld.y),e(l.normalWorld.z));x.wireframe?L.setAttribute("style","fill: none; stroke: "+w.__styleString+"; stroke-width: "+x.wireframeLinewidth+"; stroke-opacity: "+x.opacity+"; stroke-linecap: "+x.wireframeLinecap+"; stroke-linejoin: "+x.wireframeLinejoin):L.setAttribute("style","fill: "+w.__styleString+
"; fill-opacity: "+x.opacity);j.appendChild(L)}function d(ga){if(Q[ga]==null){Q[ga]=document.createElementNS("http://www.w3.org/2000/svg","path");na==0&&Q[ga].setAttribute("shape-rendering","crispEdges")}return Q[ga]}function e(ga){return ga<0?Math.min((1+ga)*0.5,0.5):0.5+Math.min(ga*0.5,0.5)}var g=null,h=new THREE.Projector,j=document.createElementNS("http://www.w3.org/2000/svg","svg"),k,m,p,y,t,q,z,C,F=new THREE.Rectangle,v=new THREE.Rectangle,G=!1,w=new THREE.Color(16777215),K=new THREE.Color(16777215),
J=new THREE.Color(0),f=new THREE.Color(0),N=new THREE.Color(0),O,U=new THREE.Vector3,Q=[],Z=[],ca=[],L,W,ma,ba,na=1;this.domElement=j;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setQuality=function(ga){switch(ga){case "high":na=1;break;case "low":na=0}};this.setSize=function(ga,ia){k=ga;m=ia;p=k/2;y=m/2;j.setAttribute("viewBox",-p+" "+-y+" "+k+" "+m);j.setAttribute("width",k);j.setAttribute("height",m);F.set(-p,-y,p,y)};this.clear=function(){for(;j.childNodes.length>0;)j.removeChild(j.childNodes[0])};
this.render=function(ga,ia){var ra,wa,l,x,B,n,o,E;this.autoClear&&this.clear();g=h.projectScene(ga,ia,this.sortElements);ba=ma=W=0;if(G=ga.lights.length>0){o=ga.lights;J.setRGB(0,0,0);f.setRGB(0,0,0);N.setRGB(0,0,0);ra=0;for(wa=o.length;ra<wa;ra++){l=o[ra];x=l.color;if(l instanceof THREE.AmbientLight){J.r+=x.r;J.g+=x.g;J.b+=x.b}else if(l instanceof THREE.DirectionalLight){f.r+=x.r;f.g+=x.g;f.b+=x.b}else if(l instanceof THREE.PointLight){N.r+=x.r;N.g+=x.g;N.b+=x.b}}}ra=0;for(wa=g.length;ra<wa;ra++){o=
g[ra];v.empty();if(o instanceof THREE.RenderableParticle){t=o;t.x*=p;t.y*=-y;l=0;for(x=o.materials.length;l<x;l++)if(E=o.materials[l]){B=t;n=o;var D=ma++;if(Z[D]==null){Z[D]=document.createElementNS("http://www.w3.org/2000/svg","circle");na==0&&Z[D].setAttribute("shape-rendering","crispEdges")}L=Z[D];L.setAttribute("cx",B.x);L.setAttribute("cy",B.y);L.setAttribute("r",n.scale.x*p);if(E instanceof THREE.ParticleCircleMaterial){if(G){K.r=J.r+f.r+N.r;K.g=J.g+f.g+N.g;K.b=J.b+f.b+N.b;w.r=E.color.r*K.r;
w.g=E.color.g*K.g;w.b=E.color.b*K.b;w.updateStyleString()}else w=E.color;L.setAttribute("style","fill: "+w.__styleString)}j.appendChild(L)}}else if(o instanceof THREE.RenderableLine){t=o.v1;q=o.v2;t.positionScreen.x*=p;t.positionScreen.y*=-y;q.positionScreen.x*=p;q.positionScreen.y*=-y;v.addPoint(t.positionScreen.x,t.positionScreen.y);v.addPoint(q.positionScreen.x,q.positionScreen.y);if(F.instersects(v)){l=0;for(x=o.materials.length;l<x;)if(E=o.materials[l++]){B=t;n=q;D=ba++;if(ca[D]==null){ca[D]=
document.createElementNS("http://www.w3.org/2000/svg","line");na==0&&ca[D].setAttribute("shape-rendering","crispEdges")}L=ca[D];L.setAttribute("x1",B.positionScreen.x);L.setAttribute("y1",B.positionScreen.y);L.setAttribute("x2",n.positionScreen.x);L.setAttribute("y2",n.positionScreen.y);if(E instanceof THREE.LineBasicMaterial){w.__styleString=E.color.__styleString;L.setAttribute("style","fill: none; stroke: "+w.__styleString+"; stroke-width: "+E.linewidth+"; stroke-opacity: "+E.opacity+"; stroke-linecap: "+
E.linecap+"; stroke-linejoin: "+E.linejoin);j.appendChild(L)}}}}else if(o instanceof THREE.RenderableFace3){t=o.v1;q=o.v2;z=o.v3;t.positionScreen.x*=p;t.positionScreen.y*=-y;q.positionScreen.x*=p;q.positionScreen.y*=-y;z.positionScreen.x*=p;z.positionScreen.y*=-y;v.addPoint(t.positionScreen.x,t.positionScreen.y);v.addPoint(q.positionScreen.x,q.positionScreen.y);v.addPoint(z.positionScreen.x,z.positionScreen.y);if(F.instersects(v)){l=0;for(x=o.meshMaterials.length;l<x;){E=o.meshMaterials[l++];if(E instanceof
THREE.MeshFaceMaterial){B=0;for(n=o.faceMaterials.length;B<n;)(E=o.faceMaterials[B++])&&b(t,q,z,o,E,ga)}else E&&b(t,q,z,o,E,ga)}}}else if(o instanceof THREE.RenderableFace4){t=o.v1;q=o.v2;z=o.v3;C=o.v4;t.positionScreen.x*=p;t.positionScreen.y*=-y;q.positionScreen.x*=p;q.positionScreen.y*=-y;z.positionScreen.x*=p;z.positionScreen.y*=-y;C.positionScreen.x*=p;C.positionScreen.y*=-y;v.addPoint(t.positionScreen.x,t.positionScreen.y);v.addPoint(q.positionScreen.x,q.positionScreen.y);v.addPoint(z.positionScreen.x,
z.positionScreen.y);v.addPoint(C.positionScreen.x,C.positionScreen.y);if(F.instersects(v)){l=0;for(x=o.meshMaterials.length;l<x;){E=o.meshMaterials[l++];if(E instanceof THREE.MeshFaceMaterial){B=0;for(n=o.faceMaterials.length;B<n;)(E=o.faceMaterials[B++])&&c(t,q,z,C,o,E,ga)}else E&&c(t,q,z,C,o,E,ga)}}}}}};
THREE.WebGLRenderer=function(a){function b(l,x,B){var n,o,E,D=l.vertices,I=D.length,S=l.colors,u=S.length,A=l.__vertexArray,H=l.__colorArray,T=l.__sortArray,Y=l.__dirtyVertices,ha=l.__dirtyColors;if(B.sortParticles){ma.multiplySelf(B.matrixWorld);for(n=0;n<I;n++){o=D[n].position;ga.copy(o);ma.multiplyVector3(ga);T[n]=[ga.z,n]}T.sort(function(da,ka){return ka[0]-da[0]});for(n=0;n<I;n++){o=D[T[n][1]].position;E=n*3;A[E]=o.x;A[E+1]=o.y;A[E+2]=o.z}for(n=0;n<u;n++){E=n*3;color=S[T[n][1]];H[E]=color.r;
H[E+1]=color.g;H[E+2]=color.b}}else{if(Y)for(n=0;n<I;n++){o=D[n].position;E=n*3;A[E]=o.x;A[E+1]=o.y;A[E+2]=o.z}if(ha)for(n=0;n<u;n++){color=S[n];E=n*3;H[E]=color.r;H[E+1]=color.g;H[E+2]=color.b}}if(Y||B.sortParticles){f.bindBuffer(f.ARRAY_BUFFER,l.__webGLVertexBuffer);f.bufferData(f.ARRAY_BUFFER,A,x)}if(ha||B.sortParticles){f.bindBuffer(f.ARRAY_BUFFER,l.__webGLColorBuffer);f.bufferData(f.ARRAY_BUFFER,H,x)}}function c(l,x){l.fragmentShader=x.fragmentShader;l.vertexShader=x.vertexShader;l.uniforms=
Uniforms.clone(x.uniforms)}function d(l,x,B,n,o){n.program||U.initMaterial(n,x,B);var E=n.program,D=E.uniforms,I=n.uniforms;if(E!=N){f.useProgram(E);N=E;f.uniformMatrix4fv(D.projectionMatrix,!1,ba)}if(B&&(n instanceof THREE.MeshBasicMaterial||n instanceof THREE.MeshLambertMaterial||n instanceof THREE.MeshPhongMaterial||n instanceof THREE.LineBasicMaterial||n instanceof THREE.ParticleBasicMaterial)){I.fogColor.value.setHex(B.color.hex);if(B instanceof THREE.Fog){I.fogNear.value=B.near;I.fogFar.value=
B.far}else if(B instanceof THREE.FogExp2)I.fogDensity.value=B.density}if(n instanceof THREE.MeshPhongMaterial||n instanceof THREE.MeshLambertMaterial){var S,u,A=0,H=0,T=0,Y,ha,da,ka=U.lights,Ca=ka.directional.colors,P=ka.directional.positions,pa=ka.point.colors,xa=ka.point.positions,Ia=0,X=0;B=u=u=0;for(S=x.length;B<S;B++){u=x[B];Y=u.color;ha=u.position;da=u.intensity;if(u instanceof THREE.AmbientLight){A+=Y.r;H+=Y.g;T+=Y.b}else if(u instanceof THREE.DirectionalLight){u=Ia*3;Ca[u]=Y.r*da;Ca[u+1]=
Y.g*da;Ca[u+2]=Y.b*da;P[u]=ha.x;P[u+1]=ha.y;P[u+2]=ha.z;Ia+=1}else if(u instanceof THREE.PointLight){u=X*3;pa[u]=Y.r*da;pa[u+1]=Y.g*da;pa[u+2]=Y.b*da;xa[u]=ha.x;xa[u+1]=ha.y;xa[u+2]=ha.z;X+=1}}for(B=Ia*3;B<Ca.length;B++)Ca[B]=0;for(B=X*3;B<pa.length;B++)pa[B]=0;ka.point.length=X;ka.directional.length=Ia;ka.ambient[0]=A;ka.ambient[1]=H;ka.ambient[2]=T;x=U.lights;I.enableLighting.value=x.directional.length+x.point.length;I.ambientLightColor.value=x.ambient;I.directionalLightColor.value=x.directional.colors;
I.directionalLightDirection.value=x.directional.positions;I.pointLightColor.value=x.point.colors;I.pointLightPosition.value=x.point.positions}if(n instanceof THREE.MeshBasicMaterial||n instanceof THREE.MeshLambertMaterial||n instanceof THREE.MeshPhongMaterial){I.diffuse.value.setRGB(n.color.r*n.opacity,n.color.g*n.opacity,n.color.b*n.opacity);I.opacity.value=n.opacity;I.map.texture=n.map;I.lightMap.texture=n.lightMap;I.envMap.texture=n.envMap;I.reflectivity.value=n.reflectivity;I.refractionRatio.value=
n.refractionRatio;I.combine.value=n.combine;I.useRefract.value=n.envMap&&n.envMap.mapping instanceof THREE.CubeRefractionMapping}if(n instanceof THREE.LineBasicMaterial){I.diffuse.value.setRGB(n.color.r*n.opacity,n.color.g*n.opacity,n.color.b*n.opacity);I.opacity.value=n.opacity}else if(n instanceof THREE.ParticleBasicMaterial){I.psColor.value.setRGB(n.color.r*n.opacity,n.color.g*n.opacity,n.color.b*n.opacity);I.opacity.value=n.opacity;I.size.value=n.size;I.map.texture=n.map}else if(n instanceof THREE.MeshPhongMaterial){I.ambient.value.setRGB(n.ambient.r,
n.ambient.g,n.ambient.b);I.specular.value.setRGB(n.specular.r,n.specular.g,n.specular.b);I.shininess.value=n.shininess}else if(n instanceof THREE.MeshDepthMaterial){I.mNear.value=l.near;I.mFar.value=l.far;I.opacity.value=n.opacity}else if(n instanceof THREE.MeshNormalMaterial)I.opacity.value=n.opacity;for(var $ in I)if(A=E.uniforms[$]){B=I[$];S=B.type;x=B.value;if(S=="i")f.uniform1i(A,x);else if(S=="f")f.uniform1f(A,x);else if(S=="fv1")f.uniform1fv(A,x);else if(S=="fv")f.uniform3fv(A,x);else if(S==
"v2")f.uniform2f(A,x.x,x.y);else if(S=="v3")f.uniform3f(A,x.x,x.y,x.z);else if(S=="c")f.uniform3f(A,x.r,x.g,x.b);else if(S=="t"){f.uniform1i(A,x);if(B=B.texture)if(B.image instanceof Array&&B.image.length==6){if(B.image.length==6){if(B.needsUpdate){if(!B.image.__webGLTextureCube)B.image.__webGLTextureCube=f.createTexture();f.bindTexture(f.TEXTURE_CUBE_MAP,B.image.__webGLTextureCube);f.texParameteri(f.TEXTURE_CUBE_MAP,f.TEXTURE_WRAP_S,f.CLAMP_TO_EDGE);f.texParameteri(f.TEXTURE_CUBE_MAP,f.TEXTURE_WRAP_T,
f.CLAMP_TO_EDGE);f.texParameteri(f.TEXTURE_CUBE_MAP,f.TEXTURE_MAG_FILTER,f.LINEAR);f.texParameteri(f.TEXTURE_CUBE_MAP,f.TEXTURE_MIN_FILTER,f.LINEAR_MIPMAP_LINEAR);for(S=0;S<6;++S)f.texImage2D(f.TEXTURE_CUBE_MAP_POSITIVE_X+S,0,f.RGBA,f.RGBA,f.UNSIGNED_BYTE,B.image[S]);f.generateMipmap(f.TEXTURE_CUBE_MAP);f.bindTexture(f.TEXTURE_CUBE_MAP,null);B.needsUpdate=!1}f.activeTexture(f.TEXTURE0+x);f.bindTexture(f.TEXTURE_CUBE_MAP,B.image.__webGLTextureCube)}}else{if(B.needsUpdate){if(B.__wasSetOnce){f.bindTexture(f.TEXTURE_2D,
B.__webGLTexture);f.texSubImage2D(f.TEXTURE_2D,0,0,0,f.RGBA,f.UNSIGNED_BYTE,B.image);f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_S,K(B.wrapS));f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_T,K(B.wrapT));f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MAG_FILTER,K(B.magFilter));f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MIN_FILTER,K(B.minFilter));f.generateMipmap(f.TEXTURE_2D);f.bindTexture(f.TEXTURE_2D,null)}else{B.__webGLTexture=f.createTexture();f.bindTexture(f.TEXTURE_2D,B.__webGLTexture);f.texImage2D(f.TEXTURE_2D,
0,f.RGBA,f.RGBA,f.UNSIGNED_BYTE,B.image);f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_S,K(B.wrapS));f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_T,K(B.wrapT));f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MAG_FILTER,K(B.magFilter));f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MIN_FILTER,K(B.minFilter));f.generateMipmap(f.TEXTURE_2D);f.bindTexture(f.TEXTURE_2D,null);B.__wasSetOnce=!0}B.needsUpdate=!1}f.activeTexture(f.TEXTURE0+x);f.bindTexture(f.TEXTURE_2D,B.__webGLTexture)}}}f.uniformMatrix4fv(D.modelViewMatrix,
!1,o._modelViewMatrixArray);f.uniformMatrix3fv(D.normalMatrix,!1,o._normalMatrixArray);(n instanceof THREE.MeshShaderMaterial||n instanceof THREE.MeshPhongMaterial||n.envMap)&&f.uniform3f(D.cameraPosition,l.position.x,l.position.y,l.position.z);(n instanceof THREE.MeshShaderMaterial||n.envMap||n.skinning)&&f.uniformMatrix4fv(D.objectMatrix,!1,o._objectMatrixArray);(n instanceof THREE.MeshPhongMaterial||n instanceof THREE.MeshLambertMaterial||n instanceof THREE.MeshShaderMaterial||n.skinning)&&f.uniformMatrix4fv(D.viewMatrix,
!1,na);if(n.skinning){f.uniformMatrix4fv(D.cameraInverseMatrix,!1,na);f.uniformMatrix4fv(D.boneGlobalMatrices,!1,o.boneMatrices)}return E}function e(l,x,B,n,o,E){l=d(l,x,B,n,E).attributes;f.bindBuffer(f.ARRAY_BUFFER,o.__webGLVertexBuffer);f.vertexAttribPointer(l.position,3,f.FLOAT,!1,0,0);if(l.color>=0){f.bindBuffer(f.ARRAY_BUFFER,o.__webGLColorBuffer);f.vertexAttribPointer(l.color,3,f.FLOAT,!1,0,0)}if(l.normal>=0){f.bindBuffer(f.ARRAY_BUFFER,o.__webGLNormalBuffer);f.vertexAttribPointer(l.normal,
3,f.FLOAT,!1,0,0)}if(l.tangent>=0){f.bindBuffer(f.ARRAY_BUFFER,o.__webGLTangentBuffer);f.vertexAttribPointer(l.tangent,4,f.FLOAT,!1,0,0)}if(l.uv>=0)if(o.__webGLUVBuffer){f.bindBuffer(f.ARRAY_BUFFER,o.__webGLUVBuffer);f.vertexAttribPointer(l.uv,2,f.FLOAT,!1,0,0);f.enableVertexAttribArray(l.uv)}else f.disableVertexAttribArray(l.uv);if(l.uv2>=0)if(o.__webGLUV2Buffer){f.bindBuffer(f.ARRAY_BUFFER,o.__webGLUV2Buffer);f.vertexAttribPointer(l.uv2,2,f.FLOAT,!1,0,0);f.enableVertexAttribArray(l.uv2)}else f.disableVertexAttribArray(l.uv2);
if(n.skinning&&l.skinVertexA>=0&&l.skinVertexB>=0&&l.skinIndex>=0&&l.skinWeight>=0){f.bindBuffer(f.ARRAY_BUFFER,o.__webGLSkinVertexABuffer);f.vertexAttribPointer(l.skinVertexA,4,f.FLOAT,!1,0,0);f.bindBuffer(f.ARRAY_BUFFER,o.__webGLSkinVertexBBuffer);f.vertexAttribPointer(l.skinVertexB,4,f.FLOAT,!1,0,0);f.bindBuffer(f.ARRAY_BUFFER,o.__webGLSkinIndicesBuffer);f.vertexAttribPointer(l.skinIndex,4,f.FLOAT,!1,0,0);f.bindBuffer(f.ARRAY_BUFFER,o.__webGLSkinWeightsBuffer);f.vertexAttribPointer(l.skinWeight,
4,f.FLOAT,!1,0,0)}if(E instanceof THREE.Mesh)if(n.wireframe){f.lineWidth(n.wireframeLinewidth);f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,o.__webGLLineBuffer);f.drawElements(f.LINES,o.__webGLLineCount,f.UNSIGNED_SHORT,0)}else{f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,o.__webGLFaceBuffer);f.drawElements(f.TRIANGLES,o.__webGLFaceCount,f.UNSIGNED_SHORT,0)}else if(E instanceof THREE.Line){E=E.type==THREE.LineStrip?f.LINE_STRIP:f.LINES;f.lineWidth(n.linewidth);f.drawArrays(E,0,o.__webGLLineCount)}else if(E instanceof
THREE.ParticleSystem)f.drawArrays(f.POINTS,0,o.__webGLParticleCount);else E instanceof THREE.Ribbon&&f.drawArrays(f.TRIANGLE_STRIP,0,o.__webGLVertexCount)}function g(l,x){if(!l.__webGLVertexBuffer)l.__webGLVertexBuffer=f.createBuffer();if(!l.__webGLNormalBuffer)l.__webGLNormalBuffer=f.createBuffer();if(l.hasPos){f.bindBuffer(f.ARRAY_BUFFER,l.__webGLVertexBuffer);f.bufferData(f.ARRAY_BUFFER,l.positionArray,f.DYNAMIC_DRAW);f.enableVertexAttribArray(x.attributes.position);f.vertexAttribPointer(x.attributes.position,
3,f.FLOAT,!1,0,0)}if(l.hasNormal){f.bindBuffer(f.ARRAY_BUFFER,l.__webGLNormalBuffer);f.bufferData(f.ARRAY_BUFFER,l.normalArray,f.DYNAMIC_DRAW);f.enableVertexAttribArray(x.attributes.normal);f.vertexAttribPointer(x.attributes.normal,3,f.FLOAT,!1,0,0)}f.drawArrays(f.TRIANGLES,0,l.count);l.count=0}function h(l){if(Q!=l.doubleSided){l.doubleSided?f.disable(f.CULL_FACE):f.enable(f.CULL_FACE);Q=l.doubleSided}if(Z!=l.flipSided){l.flipSided?f.frontFace(f.CW):f.frontFace(f.CCW);Z=l.flipSided}}function j(l){if(L!=
l){l?f.enable(f.DEPTH_TEST):f.disable(f.DEPTH_TEST);L=l}}function k(l){W[0].set(l.n41-l.n11,l.n42-l.n12,l.n43-l.n13,l.n44-l.n14);W[1].set(l.n41+l.n11,l.n42+l.n12,l.n43+l.n13,l.n44+l.n14);W[2].set(l.n41+l.n21,l.n42+l.n22,l.n43+l.n23,l.n44+l.n24);W[3].set(l.n41-l.n21,l.n42-l.n22,l.n43-l.n23,l.n44-l.n24);W[4].set(l.n41-l.n31,l.n42-l.n32,l.n43-l.n33,l.n44-l.n34);W[5].set(l.n41+l.n31,l.n42+l.n32,l.n43+l.n33,l.n44+l.n34);var x;for(l=0;l<6;l++){x=W[l];x.divideScalar(Math.sqrt(x.x*x.x+x.y*x.y+x.z*x.z))}}
function m(l){for(var x=l.matrixWorld,B=-l.geometry.boundingSphere.radius*Math.max(l.scale.x,Math.max(l.scale.y,l.scale.z)),n=0;n<6;n++){l=W[n].x*x.n14+W[n].y*x.n24+W[n].z*x.n34+W[n].w;if(l<=B)return!1}return!0}function p(l,x){l.list[l.count]=x;l.count+=1}function y(l){var x,B,n=l.object,o=l.opaque,E=l.transparent;E.count=0;l=o.count=0;for(x=n.materials.length;l<x;l++){B=n.materials[l];B.opacity&&B.opacity<1||B.blending!=THREE.NormalBlending?p(E,B):p(o,B)}}function t(l){var x,B,n,o,E=l.object,D=l.buffer,
I=l.opaque,S=l.transparent;S.count=0;l=I.count=0;for(n=E.materials.length;l<n;l++){x=E.materials[l];if(x instanceof THREE.MeshFaceMaterial){x=0;for(B=D.materials.length;x<B;x++)(o=D.materials[x])&&(o.opacity&&o.opacity<1||o.blending!=THREE.NormalBlending?p(S,o):p(I,o))}else{o=x;o.opacity&&o.opacity<1||o.blending!=THREE.NormalBlending?p(S,o):p(I,o)}}}function q(l,x){return x.z-l.z}function z(l,x){l._modelViewMatrix.multiplyToArray(x.matrixWorldInverse,l.matrixWorld,l._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(l._modelViewMatrix).transposeIntoArray(l._normalMatrixArray)}
function C(l){function x(H){var T=[];B=0;for(n=H.length;B<n;B++)H[B]==undefined?T.push("undefined"):T.push(H[B].id);return T.join("_")}var B,n,o,E,D,I,S,u,A={};l.geometryGroups={};o=0;for(E=l.faces.length;o<E;o++){D=l.faces[o];I=D.materials;S=x(I);A[S]==undefined&&(A[S]={hash:S,counter:0});u=A[S].hash+"_"+A[S].counter;l.geometryGroups[u]==undefined&&(l.geometryGroups[u]={faces:[],materials:I,vertices:0});D=D instanceof THREE.Face3?3:4;if(l.geometryGroups[u].vertices+D>65535){A[S].counter+=1;u=A[S].hash+
"_"+A[S].counter;l.geometryGroups[u]==undefined&&(l.geometryGroups[u]={faces:[],materials:I,vertices:0})}l.geometryGroups[u].faces.push(o);l.geometryGroups[u].vertices+=D}}function F(l,x,B){l.push({buffer:x,object:B,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function v(l){if(l!=ca){switch(l){case THREE.AdditiveBlending:f.blendEquation(f.FUNC_ADD);f.blendFunc(f.ONE,f.ONE);break;case THREE.SubtractiveBlending:f.blendFunc(f.DST_COLOR,f.ZERO);break;case THREE.BillboardBlending:f.blendEquation(f.FUNC_ADD);
f.blendFunc(f.SRC_ALPHA,f.ONE_MINUS_SRC_ALPHA);break;case THREE.ReverseSubtractiveBlending:f.blendEquation(f.FUNC_REVERSE_SUBTRACT);f.blendFunc(f.ONE,f.ONE);break;default:f.blendEquation(f.FUNC_ADD);f.blendFunc(f.ONE,f.ONE_MINUS_SRC_ALPHA)}ca=l}}function G(l,x){if(l&&!l.__webGLFramebuffer){l.__webGLFramebuffer=f.createFramebuffer();l.__webGLRenderbuffer=f.createRenderbuffer();l.__webGLTexture=f.createTexture();f.bindRenderbuffer(f.RENDERBUFFER,l.__webGLRenderbuffer);f.renderbufferStorage(f.RENDERBUFFER,
f.DEPTH_COMPONENT16,l.width,l.height);f.bindTexture(f.TEXTURE_2D,l.__webGLTexture);f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_S,K(l.wrapS));f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_T,K(l.wrapT));f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MAG_FILTER,K(l.magFilter));f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MIN_FILTER,K(l.minFilter));f.texImage2D(f.TEXTURE_2D,0,K(l.format),l.width,l.height,0,K(l.format),K(l.type),null);f.bindFramebuffer(f.FRAMEBUFFER,l.__webGLFramebuffer);f.framebufferTexture2D(f.FRAMEBUFFER,
f.COLOR_ATTACHMENT0,f.TEXTURE_2D,l.__webGLTexture,0);f.framebufferRenderbuffer(f.FRAMEBUFFER,f.DEPTH_ATTACHMENT,f.RENDERBUFFER,l.__webGLRenderbuffer);f.bindTexture(f.TEXTURE_2D,null);f.bindRenderbuffer(f.RENDERBUFFER,null);f.bindFramebuffer(f.FRAMEBUFFER,null)}var B,n,o;if(l){B=l.__webGLFramebuffer;n=l.width;o=l.height}else{B=null;n=J.width;o=J.height}if(B!=O){f.bindFramebuffer(f.FRAMEBUFFER,B);f.viewport(0,0,n,o);x&&f.clear(f.COLOR_BUFFER_BIT|f.DEPTH_BUFFER_BIT);O=B}}function w(l,x){var B;if(l==
"fragment")B=f.createShader(f.FRAGMENT_SHADER);else l=="vertex"&&(B=f.createShader(f.VERTEX_SHADER));f.shaderSource(B,x);f.compileShader(B);if(!f.getShaderParameter(B,f.COMPILE_STATUS)){alert(f.getShaderInfoLog(B));return null}return B}function K(l){switch(l){case THREE.RepeatWrapping:return f.REPEAT;case THREE.ClampToEdgeWrapping:return f.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return f.MIRRORED_REPEAT;case THREE.NearestFilter:return f.NEAREST;case THREE.NearestMipMapNearestFilter:return f.NEAREST_MIPMAP_NEAREST;
case THREE.NearestMipMapLinearFilter:return f.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return f.LINEAR;case THREE.LinearMipMapNearestFilter:return f.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return f.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return f.BYTE;case THREE.UnsignedByteType:return f.UNSIGNED_BYTE;case THREE.ShortType:return f.SHORT;case THREE.UnsignedShortType:return f.UNSIGNED_SHORT;case THREE.IntType:return f.INT;case THREE.UnsignedShortType:return f.UNSIGNED_INT;case THREE.FloatType:return f.FLOAT;
case THREE.AlphaFormat:return f.ALPHA;case THREE.RGBFormat:return f.RGB;case THREE.RGBAFormat:return f.RGBA;case THREE.LuminanceFormat:return f.LUMINANCE;case THREE.LuminanceAlphaFormat:return f.LUMINANCE_ALPHA}return 0}var J=document.createElement("canvas"),f,N=null,O=null,U=this,Q=null,Z=null,ca=null,L=null,W=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],ma=new THREE.Matrix4,ba=new Float32Array(16),na=new Float32Array(16),ga=new THREE.Vector4,
ia=!0,ra=new THREE.Color(0),wa=0;if(a){if(a.antialias!==undefined)ia=a.antialias;a.clearColor!==undefined&&ra.setHex(a.clearColor);if(a.clearAlpha!==undefined)wa=a.clearAlpha}this.domElement=J;this.autoClear=!0;this.sortObjects=!1;(function(l,x,B){try{f=J.getContext("experimental-webgl",{antialias:l})}catch(n){console.log(n)}if(!f)throw"cannot create webgl context";f.clearColor(0,0,0,1);f.clearDepth(1);f.enable(f.DEPTH_TEST);f.depthFunc(f.LEQUAL);f.frontFace(f.CCW);f.cullFace(f.BACK);f.enable(f.CULL_FACE);
f.enable(f.BLEND);f.blendFunc(f.ONE,f.ONE_MINUS_SRC_ALPHA);f.clearColor(x.r,x.g,x.b,B);_cullEnabled=!0})(ia,ra,wa);this.context=f;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(l,x){J.width=l;J.height=x;f.viewport(0,0,J.width,J.height)};this.setClearColorHex=function(l,x){var B=new THREE.Color(l);f.clearColor(B.r,B.g,B.b,x)};this.setClearColor=function(l,x){f.clearColor(l.r,l.g,l.b,x)};this.clear=function(){f.clear(f.COLOR_BUFFER_BIT|
f.DEPTH_BUFFER_BIT)};this.initMaterial=function(l,x,B){var n,o;if(l instanceof THREE.MeshDepthMaterial)c(l,THREE.ShaderLib.depth);else if(l instanceof THREE.MeshNormalMaterial)c(l,THREE.ShaderLib.normal);else if(l instanceof THREE.MeshBasicMaterial)c(l,THREE.ShaderLib.basic);else if(l instanceof THREE.MeshLambertMaterial)c(l,THREE.ShaderLib.lambert);else if(l instanceof THREE.MeshPhongMaterial)c(l,THREE.ShaderLib.phong);else if(l instanceof THREE.LineBasicMaterial)c(l,THREE.ShaderLib.basic);else l instanceof
THREE.ParticleBasicMaterial&&c(l,THREE.ShaderLib.particle_basic);var E,D,I,S;o=I=S=0;for(E=x.length;o<E;o++){D=x[o];D instanceof THREE.DirectionalLight&&I++;D instanceof THREE.PointLight&&S++}if(S+I<=4)x=I;else{x=Math.ceil(4*I/(S+I));S=4-x}o={directional:x,point:S};S=l.fragmentShader;x=l.vertexShader;E={fog:B,map:l.map,envMap:l.envMap,lightMap:l.lightMap,vertexColors:l.vertexColors,skinning:l.skinning,maxDirLights:o.directional,maxPointLights:o.point};B=f.createProgram();o=["#ifdef GL_ES\nprecision highp float;\n#endif",
"#define MAX_DIR_LIGHTS "+E.maxDirLights,"#define MAX_POINT_LIGHTS "+E.maxPointLights,E.fog?"#define USE_FOG":"",E.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",E.map?"#define USE_MAP":"",E.envMap?"#define USE_ENVMAP":"",E.lightMap?"#define USE_LIGHTMAP":"",E.vertexColors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");E=[f.getParameter(f.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+E.maxDirLights,"#define MAX_POINT_LIGHTS "+
E.maxPointLights,E.map?"#define USE_MAP":"",E.envMap?"#define USE_ENVMAP":"",E.lightMap?"#define USE_LIGHTMAP":"",E.vertexColors?"#define USE_COLOR":"",E.skinning?"#define USE_SKINNING":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n"].join("\n");
f.attachShader(B,w("fragment",o+S));f.attachShader(B,w("vertex",E+x));f.linkProgram(B);f.getProgramParameter(B,f.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+f.getProgramParameter(B,f.VALIDATE_STATUS)+", gl error ["+f.getError()+"]");B.uniforms={};B.attributes={};l.program=B;B=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices"];for(n in l.uniforms)B.push(n);n=l.program;S=0;for(x=B.length;S<
x;S++){o=B[S];n.uniforms[o]=f.getUniformLocation(n,o)}n=l.program;B=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];S=0;for(x=B.length;S<x;S++){o=B[S];n.attributes[o]=f.getAttribLocation(n,o)}n=l.program.attributes;f.enableVertexAttribArray(n.position);n.color>=0&&f.enableVertexAttribArray(n.color);n.normal>=0&&f.enableVertexAttribArray(n.normal);n.tangent>=0&&f.enableVertexAttribArray(n.tangent);if(l.skinning&&n.skinVertexA>=0&&n.skinVertexB>=
0&&n.skinIndex>=0&&n.skinWeight>=0){f.enableVertexAttribArray(n.skinVertexA);f.enableVertexAttribArray(n.skinVertexB);f.enableVertexAttribArray(n.skinIndex);f.enableVertexAttribArray(n.skinWeight)}};this.render=function(l,x,B,n){var o,E,D,I,S,u,A,H,T=l.lights,Y=l.fog;x.matrixAutoUpdate&&x.update();x.matrixWorldInverse.flattenToArray(na);x.projectionMatrix.flattenToArray(ba);ma.multiply(x.projectionMatrix,x.matrixWorldInverse);k(ma);l.update(undefined,!1,x);this.initWebGLObjects(l,x);G(B,n!==undefined?
n:!0);this.autoClear&&this.clear();S=l.__webglObjects.length;for(n=0;n<S;n++){o=l.__webglObjects[n];A=o.object;if(A.visible)if(!(A instanceof THREE.Mesh)||m(A)){A.matrixWorld.flattenToArray(A._objectMatrixArray);z(A,x);t(o);o.render=!0;if(this.sortObjects){ga.copy(A.position);ma.multiplyVector3(ga);o.z=ga.z}}else o.render=!1;else o.render=!1}this.sortObjects&&l.__webglObjects.sort(q);u=l.__webglObjectsImmediate.length;for(n=0;n<u;n++){o=l.__webglObjectsImmediate[n];A=o.object;if(A.visible){A.matrixAutoUpdate&&
A.matrixWorld.flattenToArray(A._objectMatrixArray);z(A,x);y(o)}}v(THREE.NormalBlending);for(n=0;n<S;n++){o=l.__webglObjects[n];if(o.render){A=o.object;H=o.buffer;D=o.opaque;h(A);for(o=0;o<D.count;o++){I=D.list[o];j(I.depthTest);e(x,T,Y,I,H,A)}}}for(n=0;n<u;n++){o=l.__webglObjectsImmediate[n];A=o.object;if(A.visible){D=o.opaque;h(A);for(o=0;o<D.count;o++){I=D.list[o];j(I.depthTest);E=d(x,T,Y,I,A);A.render(function(ha){g(ha,E)})}}}for(n=0;n<S;n++){o=l.__webglObjects[n];if(o.render){A=o.object;H=o.buffer;
D=o.transparent;h(A);for(o=0;o<D.count;o++){I=D.list[o];v(I.blending);j(I.depthTest);e(x,T,Y,I,H,A)}}}for(n=0;n<u;n++){o=l.__webglObjectsImmediate[n];A=o.object;if(A.visible){D=o.transparent;h(A);for(o=0;o<D.count;o++){I=D.list[o];v(I.blending);j(I.depthTest);E=d(x,T,Y,I,A);A.render(function(ha){g(ha,E)})}}}if(B&&B.minFilter!==THREE.NearestFilter&&B.minFilter!==THREE.LinearFilter){f.bindTexture(f.TEXTURE_2D,B.__webGLTexture);f.generateMipmap(f.TEXTURE_2D);f.bindTexture(f.TEXTURE_2D,null)}};this.initWebGLObjects=
function(l){if(!l.__webglObjects){l.__webglObjects=[];l.__webglObjectsImmediate=[]}for(;l.__objectsAdded.length;){var x=l.__objectsAdded[0],B=l,n=void 0,o=void 0,E=void 0;if(x._modelViewMatrix==undefined){x._modelViewMatrix=new THREE.Matrix4;x._normalMatrixArray=new Float32Array(9);x._modelViewMatrixArray=new Float32Array(16);x._objectMatrixArray=new Float32Array(16);x.matrixWorld.flattenToArray(x._objectMatrixArray)}if(x instanceof THREE.Mesh){o=x.geometry;o.geometryGroups==undefined&&C(o);for(n in o.geometryGroups){E=
o.geometryGroups[n];if(!E.__webGLVertexBuffer){var D=E;D.__webGLVertexBuffer=f.createBuffer();D.__webGLNormalBuffer=f.createBuffer();D.__webGLTangentBuffer=f.createBuffer();D.__webGLColorBuffer=f.createBuffer();D.__webGLUVBuffer=f.createBuffer();D.__webGLUV2Buffer=f.createBuffer();D.__webGLSkinVertexABuffer=f.createBuffer();D.__webGLSkinVertexBBuffer=f.createBuffer();D.__webGLSkinIndicesBuffer=f.createBuffer();D.__webGLSkinWeightsBuffer=f.createBuffer();D.__webGLFaceBuffer=f.createBuffer();D.__webGLLineBuffer=
f.createBuffer();D=E;var I=x,S=void 0,u=void 0,A=0,H=0,T=0,Y=I.geometry.faces,ha=D.faces;S=0;for(u=ha.length;S<u;S++){fi=ha[S];face=Y[fi];if(face instanceof THREE.Face3){A+=3;H+=1;T+=3}else if(face instanceof THREE.Face4){A+=4;H+=2;T+=4}}D.__vertexArray=new Float32Array(A*3);D.__normalArray=new Float32Array(A*3);D.__tangentArray=new Float32Array(A*4);D.__colorArray=new Float32Array(A*3);D.__uvArray=new Float32Array(A*2);D.__uv2Array=new Float32Array(A*2);D.__skinVertexAArray=new Float32Array(A*4);
D.__skinVertexBArray=new Float32Array(A*4);D.__skinIndexArray=new Float32Array(A*4);D.__skinWeightArray=new Float32Array(A*4);D.__faceArray=new Uint16Array(H*3);D.__lineArray=new Uint16Array(T*2);u=S=D;A=void 0;Y=void 0;var da=void 0,ka=void 0;da=void 0;ha=!1;A=0;for(Y=I.materials.length;A<Y;A++){da=I.materials[A];if(da instanceof THREE.MeshFaceMaterial){da=0;for(ka=u.materials.length;da<ka;da++)if(u.materials[da]&&u.materials[da].shading!=undefined&&u.materials[da].shading==THREE.SmoothShading){ha=
!0;break}}else if(da&&da.shading!=undefined&&da.shading==THREE.SmoothShading){ha=!0;break}if(ha)break}S.__needsSmoothNormals=ha;D.__webGLFaceCount=H*3;D.__webGLLineCount=T*2;o.__dirtyVertices=!0;o.__dirtyElements=!0;o.__dirtyUvs=!0;o.__dirtyNormals=!0;o.__dirtyTangents=!0;o.__dirtyColors=!0}F(B.__webglObjects,E,x)}}else if(x instanceof THREE.Ribbon){o=x.geometry;if(!o.__webGLVertexBuffer){n=o;n.__webGLVertexBuffer=f.createBuffer();n.__webGLColorBuffer=f.createBuffer();n=o;E=n.vertices.length;n.__vertexArray=
new Float32Array(E*3);n.__colorArray=new Float32Array(E*3);n.__webGLVertexCount=E;o.__dirtyVertices=!0;o.__dirtyColors=!0}F(B.__webglObjects,o,x)}else if(x instanceof THREE.Line){o=x.geometry;if(!o.__webGLVertexBuffer){n=o;n.__webGLVertexBuffer=f.createBuffer();n.__webGLColorBuffer=f.createBuffer();n=o;E=n.vertices.length;n.__vertexArray=new Float32Array(E*3);n.__colorArray=new Float32Array(E*3);n.__webGLLineCount=E;o.__dirtyVertices=!0;o.__dirtyColors=!0}F(B.__webglObjects,o,x)}else if(x instanceof
THREE.ParticleSystem){o=x.geometry;if(!o.__webGLVertexBuffer){n=o;n.__webGLVertexBuffer=f.createBuffer();n.__webGLColorBuffer=f.createBuffer();n=o;E=n.vertices.length;n.__vertexArray=new Float32Array(E*3);n.__colorArray=new Float32Array(E*3);n.__sortArray=[];n.__webGLParticleCount=E;o.__dirtyVertices=!0;o.__dirtyColors=!0}F(B.__webglObjects,o,x)}else THREE.MarchingCubes!==undefined&&x instanceof THREE.MarchingCubes&&B.__webglObjectsImmediate.push({object:x,opaque:{list:[],count:0},transparent:{list:[],
count:0}});l.__objectsAdded.splice(0,1)}for(;l.__objectsRemoved.length;){x=l.__objectsRemoved[0];B=l;o=void 0;n=void 0;for(o=B.__webglObjects.length-1;o>=0;o--){n=B.__webglObjects[o].object;x==n&&B.__webglObjects.splice(o,1)}l.__objectsRemoved.splice(0,1)}x=0;for(B=l.__webglObjects.length;x<B;x++){n=l.__webglObjects[x].object;E=void 0;o=void 0;D=void 0;if(n instanceof THREE.Mesh){o=n.geometry;for(E in o.geometryGroups){D=o.geometryGroups[E];if(o.__dirtyVertices||o.__dirtyElements||o.__dirtyUvs||o.__dirtyNormals||
o.__dirtyColors||o.__dirtyTangents){H=f.DYNAMIC_DRAW;T=void 0;S=void 0;var Ca=void 0,P=void 0,pa=void 0,xa=void 0,Ia=void 0;Ca=void 0;var X=void 0,$=void 0,aa=void 0,ta=void 0;X=void 0;$=void 0;aa=void 0;P=void 0;X=void 0;$=void 0;aa=void 0;ta=void 0;X=void 0;$=void 0;aa=void 0;ta=void 0;X=void 0;$=void 0;aa=void 0;ta=void 0;X=void 0;$=void 0;aa=void 0;ta=void 0;X=void 0;$=void 0;aa=void 0;ta=void 0;P=void 0;xa=void 0;pa=void 0;Ia=void 0;var Fa=ka=da=ha=Y=A=I=u=0,za=0,M=0,Aa=D.__vertexArray,Pa=D.__uvArray,
Qa=D.__uv2Array,Ka=D.__normalArray,ua=D.__tangentArray,Ba=D.__colorArray,la=D.__skinVertexAArray,oa=D.__skinVertexBArray,sa=D.__skinIndexArray,va=D.__skinWeightArray,Ma=D.__faceArray,Ha=D.__lineArray,R=D.__needsSmoothNormals,fa=n.geometry,ja=fa.__dirtyVertices,V=fa.__dirtyElements,ea=fa.__dirtyUvs,qa=fa.__dirtyNormals,Da=fa.__dirtyTangents,Ea=fa.__dirtyColors,ya=fa.vertices,Na=D.faces,La=fa.faces,Oa=fa.uvs,Sa=fa.uvs2,Ga=fa.colors,Ja=fa.skinVerticesA,Ta=fa.skinVerticesB,Ua=fa.skinIndices,Ra=fa.skinWeights;
T=0;for(S=Na.length;T<S;T++){Ca=Na[T];P=La[Ca];Ia=Oa[Ca];Ca=Sa[Ca];pa=P.vertexNormals;xa=P.normal;if(P instanceof THREE.Face3){if(ja){X=ya[P.a].position;$=ya[P.b].position;aa=ya[P.c].position;Aa[I]=X.x;Aa[I+1]=X.y;Aa[I+2]=X.z;Aa[I+3]=$.x;Aa[I+4]=$.y;Aa[I+5]=$.z;Aa[I+6]=aa.x;Aa[I+7]=aa.y;Aa[I+8]=aa.z;I+=9}if(Ra.length){X=Ra[P.a];$=Ra[P.b];aa=Ra[P.c];va[M]=X.x;va[M+1]=X.y;va[M+2]=X.z;va[M+3]=X.w;va[M+4]=$.x;va[M+5]=$.y;va[M+6]=$.z;va[M+7]=$.w;va[M+8]=aa.x;va[M+9]=aa.y;va[M+10]=aa.z;va[M+11]=aa.w;X=
Ua[P.a];$=Ua[P.b];aa=Ua[P.c];sa[M]=X.x;sa[M+1]=X.y;sa[M+2]=X.z;sa[M+3]=X.w;sa[M+4]=$.x;sa[M+5]=$.y;sa[M+6]=$.z;sa[M+7]=$.w;sa[M+8]=aa.x;sa[M+9]=aa.y;sa[M+10]=aa.z;sa[M+11]=aa.w;X=Ja[P.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ma[ha]=u;Ma[ha+1]=u+1;Ma[ha+2]=u+
2;Ma[ha+3]=u;Ma[ha+4]=u+2;Ma[ha+5]=u+3;ha+=6;Ha[Fa]=u;Ha[Fa+1]=u+1;Ha[Fa+2]=u;Ha[Fa+3]=u+3;Ha[Fa+4]=u+1;Ha[Fa+5]=u+2;Ha[Fa+6]=u+2;Ha[Fa+7]=u+3;Fa+=8;u+=4}}}if(ja){f.bindBuffer(f.ARRAY_BUFFER,D.__webGLVertexBuffer);f.bufferData(f.ARRAY_BUFFER,Aa,H)}if(Ea&&Ga.length){f.bindBuffer(f.ARRAY_BUFFER,D.__webGLColorBuffer);f.bufferData(f.ARRAY_BUFFER,Ba,H)}if(qa){f.bindBuffer(f.ARRAY_BUFFER,D.__webGLNormalBuffer);f.bufferData(f.ARRAY_BUFFER,Ka,H)}if(Da&&fa.hasTangents){f.bindBuffer(f.ARRAY_BUFFER,D.__webGLTangentBuffer);
f.bufferData(f.ARRAY_BUFFER,ua,H)}if(ea&&A>0){f.bindBuffer(f.ARRAY_BUFFER,D.__webGLUVBuffer);f.bufferData(f.ARRAY_BUFFER,Pa,H)}if(ea&&Y>0){f.bindBuffer(f.ARRAY_BUFFER,D.__webGLUV2Buffer);f.bufferData(f.ARRAY_BUFFER,Qa,H)}if(V){f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,D.__webGLFaceBuffer);f.bufferData(f.ELEMENT_ARRAY_BUFFER,Ma,H);f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,D.__webGLLineBuffer);f.bufferData(f.ELEMENT_ARRAY_BUFFER,Ha,H)}if(M>0){f.bindBuffer(f.ARRAY_BUFFER,D.__webGLSkinVertexABuffer);f.bufferData(f.ARRAY_BUFFER,
la,H);f.bindBuffer(f.ARRAY_BUFFER,D.__webGLSkinVertexBBuffer);f.bufferData(f.ARRAY_BUFFER,oa,H);f.bindBuffer(f.ARRAY_BUFFER,D.__webGLSkinIndicesBuffer);f.bufferData(f.ARRAY_BUFFER,sa,H);f.bindBuffer(f.ARRAY_BUFFER,D.__webGLSkinWeightsBuffer);f.bufferData(f.ARRAY_BUFFER,va,H)}}}o.__dirtyVertices=!1;o.__dirtyElements=!1;o.__dirtyUvs=!1;o.__dirtyNormals=!1;o.__dirtyTangents=!1;o.__dirtyColors=!1}else if(n instanceof THREE.Ribbon){o=n.geometry;if(o.__dirtyVertices||o.__dirtyColors){n=o;E=f.DYNAMIC_DRAW;
u=void 0;u=void 0;I=void 0;D=void 0;A=n.vertices;H=n.colors;Y=A.length;T=H.length;ha=n.__vertexArray;S=n.__colorArray;da=n.__dirtyColors;if(n.__dirtyVertices){for(u=0;u<Y;u++){I=A[u].position;D=u*3;ha[D]=I.x;ha[D+1]=I.y;ha[D+2]=I.z}f.bindBuffer(f.ARRAY_BUFFER,n.__webGLVertexBuffer);f.bufferData(f.ARRAY_BUFFER,ha,E)}if(da){for(u=0;u<T;u++){color=H[u];D=u*3;S[D]=color.r;S[D+1]=color.g;S[D+2]=color.b}f.bindBuffer(f.ARRAY_BUFFER,n.__webGLColorBuffer);f.bufferData(f.ARRAY_BUFFER,S,E)}}o.__dirtyVertices=
!1;o.__dirtyColors=!1}else if(n instanceof THREE.Line){o=n.geometry;if(o.__dirtyVertices||o.__dirtyColors){n=o;E=f.DYNAMIC_DRAW;u=void 0;u=void 0;I=void 0;D=void 0;A=n.vertices;H=n.colors;Y=A.length;T=H.length;ha=n.__vertexArray;S=n.__colorArray;da=n.__dirtyColors;if(n.__dirtyVertices){for(u=0;u<Y;u++){I=A[u].position;D=u*3;ha[D]=I.x;ha[D+1]=I.y;ha[D+2]=I.z}f.bindBuffer(f.ARRAY_BUFFER,n.__webGLVertexBuffer);f.bufferData(f.ARRAY_BUFFER,ha,E)}if(da){for(u=0;u<T;u++){color=H[u];D=u*3;S[D]=color.r;S[D+
1]=color.g;S[D+2]=color.b}f.bindBuffer(f.ARRAY_BUFFER,n.__webGLColorBuffer);f.bufferData(f.ARRAY_BUFFER,S,E)}}o.__dirtyVertices=!1;o.__dirtyColors=!1}else if(n instanceof THREE.ParticleSystem){o=n.geometry;(o.__dirtyVertices||o.__dirtyColors||n.sortParticles)&&b(o,f.DYNAMIC_DRAW,n);o.__dirtyVertices=!1;o.__dirtyColors=!1}}};this.setFaceCulling=function(l,x){if(l){!x||x=="ccw"?f.frontFace(f.CCW):f.frontFace(f.CW);if(l=="back")f.cullFace(f.BACK);else l=="front"?f.cullFace(f.FRONT):f.cullFace(f.FRONT_AND_BACK);
f.enable(f.CULL_FACE)}else f.disable(f.CULL_FACE)};this.supportsVertexTextures=function(){return f.getParameter(f.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
THREE.Snippets={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube envMap;\nuniform int combine;\n#endif",
envmap_fragment:"#ifdef USE_ENVMAP\nvec4 cubeColor = textureCube( envMap, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = vec4( mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity ), opacity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refractionRatio;\nuniform bool useRefract;\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refractionRatio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif",
map_particle_pars_fragment:"#ifdef USE_MAP\nuniform sampler2D map;\n#endif",map_particle_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, gl_PointCoord );\n#endif",map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif",map_pars_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\n#endif",map_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\nuniform sampler2D lightMap;\n#endif",
lightmap_pars_vertex:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\n#endif",lightmap_fragment:"#ifdef USE_LIGHTMAP\ngl_FragColor = gl_FragColor * texture2D( lightMap, vUv2 );\n#endif",lightmap_vertex:"#ifdef USE_LIGHTMAP\nvUv2 = uv2;\n#endif",lights_pars_vertex:"uniform bool enableLighting;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\n#ifdef PHONG\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\n#endif",
lights_vertex:"if ( !enableLighting ) {\nvLightWeighting = vec3( 1.0 );\n} else {\nvLightWeighting = ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nfloat directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );\nvLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;\n}\n#endif\n#if MAX_POINT_LIGHTS > 0\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 pointLightVector = normalize( lPosition.xyz - mvPosition.xyz );\nfloat pointLightWeighting = max( dot( transformedNormal, pointLightVector ), 0.0 );\nvLightWeighting += pointLightColor[ i ] * pointLightWeighting;\n#ifdef PHONG\nvPointLightVector[ i ] = pointLightVector;\n#endif\n}\n#endif\n}",
lights_pars_fragment:"#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",lights_fragment:"vec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );\nvec4 mColor = vec4( diffuse, opacity );\nvec4 mSpecular = vec4( specular, opacity );\n#if MAX_POINT_LIGHTS > 0\nvec4 pointDiffuse = vec4( 0.0 );\nvec4 pointSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec3 pointVector = normalize( vPointLightVector[ i ] );\nvec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );\nfloat pointDotNormalHalf = dot( normal, pointHalfVector );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = 0.0;\nif ( pointDotNormalHalf >= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, shininess );\npointDiffuse += mColor * pointDiffuseWeight;\npointSpecular += mSpecular * pointSpecularWeight;\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec4 dirDiffuse = vec4( 0.0 );\nvec4 dirSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, shininess );\ndirDiffuse += mColor * dirDiffuseWeight;\ndirSpecular += mSpecular * dirSpecularWeight;\n}\n#endif\nvec4 totalLight = vec4( ambient, opacity );\n#if MAX_DIR_LIGHTS > 0\ntotalLight += dirDiffuse + dirSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalLight += pointDiffuse + pointSpecular;\n#endif\ngl_FragColor = gl_FragColor * totalLight;",
color_pars_fragment:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_fragment:"#ifdef USE_COLOR\ngl_FragColor = gl_FragColor * vec4( vColor, opacity );\n#endif",color_pars_vertex:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\nvColor = color;\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\nuniform mat4 boneGlobalMatrices[20];\n#endif",skinning_vertex:"#ifdef USE_SKINNING\ngl_Position = ( boneGlobalMatrices[ int( skinIndex.x ) ] * skinVertexA ) * skinWeight.x;\ngl_Position += ( boneGlobalMatrices[ int( skinIndex.y ) ] * skinVertexB ) * skinWeight.y;\ngl_Position = projectionMatrix * viewMatrix * objectMatrix * gl_Position;\n#else\ngl_Position = projectionMatrix * mvPosition;\n#endif"};
THREE.UniformsLib={common:{diffuse:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},map:{type:"t",value:0,texture:null},lightMap:{type:"t",value:2,texture:null},envMap:{type:"t",value:1,texture:null},useRefract:{type:"i",value:0},reflectivity:{type:"f",value:1},refractionRatio:{type:"f",value:0.98},combine:{type:"i",value:0},fogDensity:{type:"f",value:2.5E-4},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)}},lights:{enableLighting:{type:"i",
value:1},ambientLightColor:{type:"fv",value:[]},directionalLightDirection:{type:"fv",value:[]},directionalLightColor:{type:"fv",value:[]},pointLightPosition:{type:"fv",value:[]},pointLightColor:{type:"fv",value:[]}},particle:{psColor:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},size:{type:"f",value:1},map:{type:"t",value:0,texture:null},fogDensity:{type:"f",value:2.5E-4},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)}}};
THREE.ShaderLib={depth:{uniforms:{mNear:{type:"f",value:1},mFar:{type:"f",value:2E3},opacity:{type:"f",value:1}},fragmentShader:"uniform float mNear;\nuniform float mFar;\nuniform float opacity;\nvoid main() {\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat color = 1.0 - smoothstep( mNear, mFar, depth );\ngl_FragColor = vec4( vec3( color ), opacity );\n}",vertexShader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}"},normal:{uniforms:{opacity:{type:"f",
value:1}},fragmentShader:"uniform float opacity;\nvarying vec3 vNormal;\nvoid main() {\ngl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, opacity );\n}",vertexShader:"varying vec3 vNormal;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalize( normalMatrix * normal );\ngl_Position = projectionMatrix * mvPosition;\n}"},basic:{uniforms:THREE.UniformsLib.common,fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;",THREE.Snippets.color_pars_fragment,
THREE.Snippets.map_pars_fragment,THREE.Snippets.lightmap_pars_fragment,THREE.Snippets.envmap_pars_fragment,THREE.Snippets.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( diffuse, opacity );",THREE.Snippets.map_fragment,THREE.Snippets.lightmap_fragment,THREE.Snippets.color_fragment,THREE.Snippets.envmap_fragment,THREE.Snippets.fog_fragment,"}"].join("\n"),vertexShader:[THREE.Snippets.map_pars_vertex,THREE.Snippets.lightmap_pars_vertex,THREE.Snippets.envmap_pars_vertex,THREE.Snippets.color_pars_vertex,
THREE.Snippets.skinning_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.Snippets.map_vertex,THREE.Snippets.lightmap_vertex,THREE.Snippets.envmap_vertex,THREE.Snippets.color_vertex,THREE.Snippets.skinning_vertex,"}"].join("\n")},lambert:{uniforms:Uniforms.merge([THREE.UniformsLib.common,THREE.UniformsLib.lights]),fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;\nvarying vec3 vLightWeighting;",THREE.Snippets.color_pars_fragment,THREE.Snippets.map_pars_fragment,
THREE.Snippets.lightmap_pars_fragment,THREE.Snippets.envmap_pars_fragment,THREE.Snippets.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( diffuse, opacity );\ngl_FragColor = gl_FragColor * vec4( vLightWeighting, 1.0 );",THREE.Snippets.map_fragment,THREE.Snippets.lightmap_fragment,THREE.Snippets.color_fragment,THREE.Snippets.envmap_fragment,THREE.Snippets.fog_fragment,"}"].join("\n"),vertexShader:["varying vec3 vLightWeighting;",THREE.Snippets.map_pars_vertex,THREE.Snippets.lightmap_pars_vertex,
THREE.Snippets.envmap_pars_vertex,THREE.Snippets.lights_pars_vertex,THREE.Snippets.color_pars_vertex,THREE.Snippets.skinning_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.Snippets.map_vertex,THREE.Snippets.lightmap_vertex,THREE.Snippets.envmap_vertex,THREE.Snippets.color_vertex,"vec3 transformedNormal = normalize( normalMatrix * normal );",THREE.Snippets.lights_vertex,THREE.Snippets.skinning_vertex,"}"].join("\n")},phong:{uniforms:Uniforms.merge([THREE.UniformsLib.common,
THREE.UniformsLib.lights,{ambient:{type:"c",value:new THREE.Color(328965)},specular:{type:"c",value:new THREE.Color(1118481)},shininess:{type:"f",value:30}}]),fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;\nuniform vec3 ambient;\nuniform vec3 specular;\nuniform float shininess;\nvarying vec3 vLightWeighting;",THREE.Snippets.color_pars_fragment,THREE.Snippets.map_pars_fragment,THREE.Snippets.lightmap_pars_fragment,THREE.Snippets.envmap_pars_fragment,THREE.Snippets.fog_pars_fragment,
THREE.Snippets.lights_pars_fragment,"void main() {\ngl_FragColor = vec4( vLightWeighting, 1.0 );",THREE.Snippets.lights_fragment,THREE.Snippets.map_fragment,THREE.Snippets.lightmap_fragment,THREE.Snippets.color_fragment,THREE.Snippets.envmap_fragment,THREE.Snippets.fog_fragment,"}"].join("\n"),vertexShader:["#define PHONG\nvarying vec3 vLightWeighting;\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",THREE.Snippets.map_pars_vertex,THREE.Snippets.lightmap_pars_vertex,THREE.Snippets.envmap_pars_vertex,
THREE.Snippets.lights_pars_vertex,THREE.Snippets.color_pars_vertex,THREE.Snippets.skinning_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.Snippets.map_vertex,THREE.Snippets.lightmap_vertex,THREE.Snippets.envmap_vertex,THREE.Snippets.color_vertex,"#ifndef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\n#endif\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 transformedNormal = normalize( normalMatrix * normal );\nvNormal = transformedNormal;",
THREE.Snippets.lights_vertex,THREE.Snippets.skinning_vertex,"}"].join("\n")},particle_basic:{uniforms:THREE.UniformsLib.particle,fragmentShader:["uniform vec3 psColor;\nuniform float opacity;",THREE.Snippets.color_pars_fragment,THREE.Snippets.map_particle_pars_fragment,THREE.Snippets.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( psColor, opacity );",THREE.Snippets.map_particle_fragment,THREE.Snippets.color_fragment,THREE.Snippets.fog_fragment,"}"].join("\n"),vertexShader:["uniform float size;",
THREE.Snippets.color_pars_vertex,"void main() {",THREE.Snippets.color_vertex,"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\ngl_Position = projectionMatrix * mvPosition;\ngl_PointSize = size;\n}"].join("\n")}};
THREE.SoundRenderer=function(){this.volume=1;this.domElement=document.createElement("div");this.domElement.id="THREESound";this.cameraPosition=new THREE.Vector3;this.soundPosition=new THREE.Vector3;this.render=function(a,b,c){c&&a.update(undefined,!1,b);c=a.sounds;var d,e=c.length;for(d=0;d<e;d++){a=c[d];this.soundPosition.set(a.matrixWorld.n14,a.matrixWorld.n24,a.matrixWorld.n34);this.soundPosition.subSelf(b.position);if(a.isPlaying&&a.isLoaded){a.isAddedToDOM||a.addToDOM(this.domElement);a.calculateVolumeAndPan(this.soundPosition)}}}};
THREE.RenderableObject=function(){this.z=this.object=null};THREE.RenderableFace3=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.v3=new THREE.Vertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[];this.faceMaterials=this.meshMaterials=null;this.overdraw=!1;this.uvs=[null,null,null]};
THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.materials=null};THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.materials=null};
var GeometryUtils={merge:function(a,b){var c=b instanceof THREE.Mesh,d=a.vertices.length,e=c?b.geometry:b,g=a.vertices,h=e.vertices,j=a.faces,k=e.faces,m=a.uvs;e=e.uvs;c&&b.matrixAutoUpdate&&b.updateMatrix();for(var p=0,y=h.length;p<y;p++){var t=new THREE.Vertex(h[p].position.clone());c&&b.matrix.multiplyVector3(t.position);g.push(t)}p=0;for(y=k.length;p<y;p++){h=k[p];var q,z=h.vertexNormals;if(h instanceof THREE.Face3)q=new THREE.Face3(h.a+d,h.b+d,h.c+d);else h instanceof THREE.Face4&&(q=new THREE.Face4(h.a+
d,h.b+d,h.c+d,h.d+d));q.centroid.copy(h.centroid);q.normal.copy(h.normal);c=0;for(g=z.length;c<g;c++){t=z[c];q.vertexNormals.push(t.clone())}q.materials=h.materials.slice();j.push(q)}p=0;for(y=e.length;p<y;p++){d=e[p];j=[];c=0;for(g=d.length;c<g;c++)j.push(new THREE.UV(d[c].u,d[c].v));m.push(j)}}},ImageUtils={loadTexture:function(a,b,c){var d=new Image,e=new THREE.Texture(d,b);d.onload=function(){e.needsUpdate=!0;c&&c(this)};d.src=a;return e},loadTextureCube:function(a,b,c){var d,e=[],g=new THREE.Texture(e,
b);b=e.loadCount=0;for(d=a.length;b<d;++b){e[b]=new Image;e[b].onload=function(){e.loadCount+=1;if(e.loadCount==6)g.needsUpdate=!0;c&&c(this)};e[b].src=a[b]}return g}},SceneUtils={loadScene:function(a,b,c,d){a=new Worker(a);a.postMessage(0);a.onmessage=function(e){function g(){for(p in N.objects)if(!L.objects[p]){C=N.objects[p];if(w=L.geometries[C.geometry]){f=[];for(i=0;i<C.materials.length;i++)f[i]=L.materials[C.materials[i]];F=C.position;r=C.rotation;s=C.scale;object=new THREE.Mesh(w,f);object.position.set(F[0],
F[1],F[2]);object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=C.visible;L.scene.addObject(object);L.objects[p]=object}}}function h(W){return function(ma){L.geometries[W]=ma;g();U-=1;j()}}function j(){d({total_models:Z,total_textures:ca,loaded_models:Z-U,loaded_textures:ca-Q},L);U==0&&Q==0&&c(L)}var k,m,p,y,t,q,z,C,F,v,G,w,K,J,f,N,O,U,Q,Z,ca,L;N=e.data;O=new THREE.Loader;Q=U=0;L={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},
fogs:{}};e=function(){Q-=1;j()};for(t in N.cameras){v=N.cameras[t];if(v.type=="perspective")K=new THREE.Camera(v.fov,v.aspect,v.near,v.far);else if(v.type=="ortho"){K=new THREE.Camera;K.projectionMatrix=THREE.Matrix4.makeOrtho(v.left,v.right,v.top,v.bottom,v.near,v.far)}F=v.position;v=v.target;K.position.set(F[0],F[1],F[2]);K.target.position.set(v[0],v[1],v[2]);L.cameras[t]=K}for(y in N.lights){t=N.lights[y];if(t.type=="directional"){F=t.direction;light=new THREE.DirectionalLight;light.position.set(F[0],
F[1],F[2]);light.position.normalize()}else if(t.type=="point"){F=t.position;light=new THREE.PointLight;light.position.set(F[0],F[1],F[2])}v=t.color;i=t.intensity||1;light.color.setRGB(v[0]*i,v[1]*i,v[2]*i);L.scene.addLight(light);L.lights[y]=light}for(q in N.fogs){y=N.fogs[q];if(y.type=="linear")J=new THREE.Fog(0,y.near,y.far);else y.type=="exp2"&&(J=new THREE.FogExp2(0,y.density));v=y.color;J.color.setRGB(v[0],v[1],v[2]);L.fogs[q]=J}if(L.cameras&&N.defaults.camera)L.currentCamera=L.cameras[N.defaults.camera];
if(L.fogs&&N.defaults.fog)L.scene.fog=L.fogs[N.defaults.fog];v=N.defaults.bgcolor;L.bgColor=new THREE.Color;L.bgColor.setRGB(v[0],v[1],v[2]);L.bgColorAlpha=N.defaults.bgalpha;for(k in N.geometries){q=N.geometries[k];if(q.type=="bin_mesh"||q.type=="ascii_mesh")U+=1}Z=U;for(k in N.geometries){q=N.geometries[k];if(q.type=="cube"){w=new Cube(q.width,q.height,q.depth,q.segmentsWidth,q.segmentsHeight,null,q.flipped,q.sides);L.geometries[k]=w}else if(q.type=="plane"){w=new Plane(q.width,q.height,q.segmentsWidth,
q.segmentsHeight);L.geometries[k]=w}else if(q.type=="sphere"){w=new Sphere(q.radius,q.segmentsWidth,q.segmentsHeight);L.geometries[k]=w}else if(q.type=="cylinder"){w=new Cylinder(q.numSegs,q.topRad,q.botRad,q.height,q.topOffset,q.botOffset);L.geometries[k]=w}else if(q.type=="torus"){w=new Torus(q.radius,q.tube,q.segmentsR,q.segmentsT);L.geometries[k]=w}else if(q.type=="icosahedron"){w=new Icosahedron(q.subdivisions);L.geometries[k]=w}else if(q.type=="bin_mesh")O.loadBinary({model:q.url,callback:h(k)});
else q.type=="ascii_mesh"&&O.loadAscii({model:q.url,callback:h(k)})}for(z in N.textures){k=N.textures[z];Q+=k.url instanceof Array?k.url.length:1}ca=Q;for(z in N.textures){k=N.textures[z];if(k.mapping!=undefined&&THREE[k.mapping]!=undefined)k.mapping=new THREE[k.mapping];if(k.url instanceof Array)q=ImageUtils.loadTextureCube(k.url,k.mapping,e);else{q=ImageUtils.loadTexture(k.url,k.mapping,e);if(THREE[k.minFilter]!=undefined)q.minFilter=THREE[k.minFilter];if(THREE[k.magFilter]!=undefined)q.magFilter=
THREE[k.magFilter]}L.textures[z]=q}for(m in N.materials){z=N.materials[m];for(G in z.parameters)if(G=="envMap"||G=="map"||G=="lightMap")z.parameters[G]=L.textures[z.parameters[G]];else if(G=="shading")z.parameters[G]=z.parameters[G]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(G=="blending")z.parameters[G]=THREE[z.parameters[G]]?THREE[z.parameters[G]]:THREE.NormalBlending;else G=="combine"&&(z.parameters[G]=z.parameters[G]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation);z=new THREE[z.type](z.parameters);
L.materials[m]=z}g();b(L)}},addMesh:function(a,b,c,d,e,g,h,j,k,m){b=new THREE.Mesh(b,m);b.scale.x=b.scale.y=b.scale.z=c;b.position.x=d;b.position.y=e;b.position.z=g;b.rotation.x=h;b.rotation.y=j;b.rotation.z=k;a.addObject(b);return b},addPanoramaCubeWebGL:function(a,b,c){var d=ShaderUtils.lib.cube;d.uniforms.tCube.texture=c;c=new THREE.MeshShaderMaterial({fragmentShader:d.fragmentShader,vertexShader:d.vertexShader,uniforms:d.uniforms});b=new THREE.Mesh(new Cube(b,b,b,1,1,1,null,!0),c);a.addObject(b);
return b},addPanoramaCube:function(a,b,c){var d=[];d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[0])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[1])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[2])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[3])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[4])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[5])}));b=new THREE.Mesh(new Cube(b,b,b,1,1,d,!0),new THREE.MeshFaceMaterial);
a.addObject(b);return b},addPanoramaCubePlanes:function(a,b,c){var d=b/2;b=new Plane(b,b);var e=Math.PI,g=Math.PI/2;SceneUtils.addMesh(a,b,1,0,0,-d,0,0,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[5])}));SceneUtils.addMesh(a,b,1,-d,0,0,0,g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[0])}));SceneUtils.addMesh(a,b,1,d,0,0,0,-g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[1])}));SceneUtils.addMesh(a,b,1,0,d,0,g,0,e,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[2])}));
SceneUtils.addMesh(a,b,1,0,-d,0,-g,0,e,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[3])}))}},ShaderUtils={lib:{fresnel:{uniforms:{mRefractionRatio:{type:"f",value:1.02},mFresnelBias:{type:"f",value:0.1},mFresnelPower:{type:"f",value:2},mFresnelScale:{type:"f",value:1},tCube:{type:"t",value:1,texture:null}},fragmentShader:"uniform samplerCube tCube;\nvarying vec3 vReflect;\nvarying vec3 vRefract[3];\nvarying float vReflectionFactor;\nvoid main() {\nvec4 reflectedColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\nvec4 refractedColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nrefractedColor.r = textureCube( tCube, vec3( -vRefract[0].x, vRefract[0].yz ) ).r;\nrefractedColor.g = textureCube( tCube, vec3( -vRefract[1].x, vRefract[1].yz ) ).g;\nrefractedColor.b = textureCube( tCube, vec3( -vRefract[2].x, vRefract[2].yz ) ).b;\nrefractedColor.a = 1.0;\ngl_FragColor = mix( refractedColor, reflectedColor, clamp( vReflectionFactor, 0.0, 1.0 ) );\n}",
vertexShader:"uniform float mRefractionRatio;\nuniform float mFresnelBias;\nuniform float mFresnelScale;\nuniform float mFresnelPower;\nvarying vec3 vReflect;\nvarying vec3 vRefract[3];\nvarying float vReflectionFactor;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = normalize ( mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal );\nvec3 I = mPosition.xyz - cameraPosition;\nvReflect = reflect( I, nWorld );\nvRefract[0] = refract( normalize( I ), nWorld, mRefractionRatio );\nvRefract[1] = refract( normalize( I ), nWorld, mRefractionRatio * 0.99 );\nvRefract[2] = refract( normalize( I ), nWorld, mRefractionRatio * 0.98 );\nvReflectionFactor = mFresnelBias + mFresnelScale * pow( 1.0 + dot( normalize( I ), nWorld ), mFresnelPower );\ngl_Position = projectionMatrix * mvPosition;\n}"},
normal:{uniforms:{enableAO:{type:"i",value:0},enableDiffuse:{type:"i",value:0},tDiffuse:{type:"t",value:0,texture:null},tNormal:{type:"t",value:2,texture:null},tAO:{type:"t",value:3,texture:null},uNormalScale:{type:"f",value:1},tDisplacement:{type:"t",value:4,texture:null},uDisplacementBias:{type:"f",value:-0.5},uDisplacementScale:{type:"f",value:2.5},uPointLightPos:{type:"v3",value:new THREE.Vector3},uPointLightColor:{type:"c",value:new THREE.Color(15658734)},uDirLightPos:{type:"v3",value:new THREE.Vector3},
uDirLightColor:{type:"c",value:new THREE.Color(15658734)},uAmbientLightColor:{type:"c",value:new THREE.Color(328965)},uDiffuseColor:{type:"c",value:new THREE.Color(15658734)},uSpecularColor:{type:"c",value:new THREE.Color(1118481)},uAmbientColor:{type:"c",value:new THREE.Color(328965)},uShininess:{type:"f",value:30}},fragmentShader:"uniform vec3 uDirLightPos;\nuniform vec3 uAmbientLightColor;\nuniform vec3 uDirLightColor;\nuniform vec3 uPointLightColor;\nuniform vec3 uAmbientColor;\nuniform vec3 uDiffuseColor;\nuniform vec3 uSpecularColor;\nuniform float uShininess;\nuniform bool enableDiffuse;\nuniform bool enableAO;\nuniform sampler2D tDiffuse;\nuniform sampler2D tNormal;\nuniform sampler2D tAO;\nuniform float uNormalScale;\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vPointLightVector;\nvarying vec3 vViewPosition;\nvoid main() {\nvec3 diffuseTex = vec3( 1.0, 1.0, 1.0 );\nvec3 aoTex = vec3( 1.0, 1.0, 1.0 );\nvec3 normalTex = texture2D( tNormal, vUv ).xyz * 2.0 - 1.0;\nnormalTex.xy *= uNormalScale;\nnormalTex = normalize( normalTex );\nif( enableDiffuse )\ndiffuseTex = texture2D( tDiffuse, vUv ).xyz;\nif( enableAO )\naoTex = texture2D( tAO, vUv ).xyz;\nmat3 tsb = mat3( vTangent, vBinormal, vNormal );\nvec3 finalNormal = tsb * normalTex;\nvec3 normal = normalize( finalNormal );\nvec3 viewPosition = normalize( vViewPosition );\nvec4 pointDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 pointSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec3 pointVector = normalize( vPointLightVector );\nvec3 pointHalfVector = normalize( vPointLightVector + vViewPosition );\nfloat pointDotNormalHalf = dot( normal, pointHalfVector );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = 0.0;\nif ( pointDotNormalHalf >= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, uShininess );\npointDiffuse += vec4( uDiffuseColor, 1.0 ) * pointDiffuseWeight;\npointSpecular += vec4( uSpecularColor, 1.0 ) * pointSpecularWeight;\nvec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 lDirection = viewMatrix * vec4( uDirLightPos, 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, uShininess );\ndirDiffuse += vec4( uDiffuseColor, 1.0 ) * dirDiffuseWeight;\ndirSpecular += vec4( uSpecularColor, 1.0 ) * dirSpecularWeight;\nvec4 totalLight = vec4( uAmbientLightColor * uAmbientColor, 1.0 );\ntotalLight += vec4( uDirLightColor, 1.0 ) * ( dirDiffuse + dirSpecular );\ntotalLight += vec4( uPointLightColor, 1.0 ) * ( pointDiffuse + pointSpecular );\ngl_FragColor = vec4( totalLight.xyz * aoTex * diffuseTex, 1.0 );\n}",
vertexShader:"attribute vec4 tangent;\nuniform vec3 uPointLightPos;\n#ifdef VERTEX_TEXTURES\nuniform sampler2D tDisplacement;\nuniform float uDisplacementScale;\nuniform float uDisplacementBias;\n#endif\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vPointLightVector;\nvarying vec3 vViewPosition;\nvoid main() {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalize( normalMatrix * normal );\nvTangent = normalize( normalMatrix * tangent.xyz );\nvBinormal = cross( vNormal, vTangent ) * tangent.w;\nvBinormal = normalize( vBinormal );\nvUv = uv;\nvec4 lPosition = viewMatrix * vec4( uPointLightPos, 1.0 );\nvPointLightVector = normalize( lPosition.xyz - mvPosition.xyz );\n#ifdef VERTEX_TEXTURES\nvec3 dv = texture2D( tDisplacement, uv ).xyz;\nfloat df = uDisplacementScale * dv.x + uDisplacementBias;\nvec4 displacedPosition = vec4( vNormal.xyz * df, 0.0 ) + mvPosition;\ngl_Position = projectionMatrix * displacedPosition;\n#else\ngl_Position = projectionMatrix * mvPosition;\n#endif\n}"},
cube:{uniforms:{tCube:{type:"t",value:1,texture:null}},vertexShader:"varying vec3 vViewPosition;\nvoid main() {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"uniform samplerCube tCube;\nvarying vec3 vViewPosition;\nvoid main() {\nvec3 wPos = cameraPosition - vViewPosition;\ngl_FragColor = textureCube( tCube, vec3( - wPos.x, wPos.yz ) );\n}"},convolution:{uniforms:{tDiffuse:{type:"t",
value:0,texture:null},uImageIncrement:{type:"v2",value:new THREE.Vector2(0.001953125,0)},cKernel:{type:"fv1",value:[]}},vertexShader:"varying vec2 vUv;\nuniform vec2 uImageIncrement;\nvoid main(void) {\nvUv = uv - ((KERNEL_SIZE - 1.0) / 2.0) * uImageIncrement;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform vec2 uImageIncrement;\nuniform float cKernel[KERNEL_SIZE];\nvoid main(void) {\nvec2 imageCoord = vUv;\nvec4 sum = vec4( 0.0, 0.0, 0.0, 0.0 );\nfor( int i=0; i<KERNEL_SIZE; ++i ) {\nsum += texture2D( tDiffuse, imageCoord ) * cKernel[i];\nimageCoord += uImageIncrement;\n}\ngl_FragColor = sum;\n}"},
film:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},time:{type:"f",value:0},nIntensity:{type:"f",value:0.5},sIntensity:{type:"f",value:0.05},sCount:{type:"f",value:4096},grayscale:{type:"i",value:1}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float time;\nuniform bool grayscale;\nuniform float nIntensity;\nuniform float sIntensity;\nuniform float sCount;\nvoid main() {\nvec4 cTextureScreen = texture2D( tDiffuse, vUv );\nfloat x = vUv.x * vUv.y * time * 1000.0;\nx = mod( x, 13.0 ) * mod( x, 123.0 );\nfloat dx = mod( x, 0.01 );\nvec3 cResult = cTextureScreen.rgb + cTextureScreen.rgb * clamp( 0.1 + dx * 100.0, 0.0, 1.0 );\nvec2 sc = vec2( sin( vUv.y * sCount ), cos( vUv.y * sCount ) );\ncResult += cTextureScreen.rgb * vec3( sc.x, sc.y, sc.x ) * sIntensity;\ncResult = cTextureScreen.rgb + clamp( nIntensity, 0.0,1.0 ) * ( cResult - cTextureScreen.rgb );\nif( grayscale ) {\ncResult = vec3( cResult.r * 0.3 + cResult.g * 0.59 + cResult.b * 0.11 );\n}\ngl_FragColor = vec4( cResult, cTextureScreen.a );\n}"},
screen:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},opacity:{type:"f",value:1}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float opacity;\nvoid main() {\nvec4 texel = texture2D( tDiffuse, vUv );\ngl_FragColor = opacity * texel;\n}"},basic:{uniforms:{},vertexShader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",
fragmentShader:"void main() {\ngl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );\n}"}},buildKernel:function(a){var b,c,d,e,g=2*Math.ceil(a*3)+1;g>25&&(g=25);e=(g-1)*0.5;c=Array(g);for(b=d=0;b<g;++b){c[b]=Math.exp(-((b-e)*(b-e))/(2*a*a));d+=c[b]}for(b=0;b<g;++b)c[b]/=d;return c}},Cube=function(a,b,c,d,e,g,h,j,k){function m(F,v,G,w,K,J,f,N){var O,U,Q=d||1,Z=e||1,ca=K/2,L=J/2,W=p.vertices.length;if(F=="x"&&v=="y"||F=="y"&&v=="x")O="z";else if(F=="x"&&v=="z"||F=="z"&&v=="x"){O="y";Z=g||1}else if(F=="z"&&v==
"y"||F=="y"&&v=="z"){O="x";Q=g||1}var ma=Q+1,ba=Z+1;K/=Q;var na=J/Z;for(U=0;U<ba;U++)for(J=0;J<ma;J++){var ga=new THREE.Vector3;ga[F]=(J*K-ca)*G;ga[v]=(U*na-L)*w;ga[O]=f;p.vertices.push(new THREE.Vertex(ga))}for(U=0;U<Z;U++)for(J=0;J<Q;J++){p.faces.push(new THREE.Face4(J+ma*U+W,J+ma*(U+1)+W,J+1+ma*(U+1)+W,J+1+ma*U+W,null,N));p.uvs.push([new THREE.UV(J/Q,U/Z),new THREE.UV(J/Q,(U+1)/Z),new THREE.UV((J+1)/Q,(U+1)/Z),new THREE.UV((J+1)/Q,U/Z)])}}THREE.Geometry.call(this);var p=this,y=a/2,t=b/2,q=c/2;
j=j?-1:1;if(h!==undefined)if(h instanceof Array)this.materials=h;else{this.materials=[];for(var z=0;z<6;z++)this.materials.push([h])}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(k!=undefined)for(var C in k)this.sides[C]!=undefined&&(this.sides[C]=k[C]);this.sides.px&&m("z","y",1*j,-1,c,b,-y,this.materials[0]);this.sides.nx&&m("z","y",-1*j,-1,c,b,y,this.materials[1]);this.sides.py&&m("x","z",1*j,1,a,c,t,this.materials[2]);this.sides.ny&&m("x","z",1*j,-1,a,c,-t,this.materials[3]);
this.sides.pz&&m("x","y",1*j,-1,a,b,q,this.materials[4]);this.sides.nz&&m("x","y",-1*j,-1,a,b,-q,this.materials[5]);(function(){for(var F=[],v=[],G=0,w=p.vertices.length;G<w;G++){for(var K=p.vertices[G],J=!1,f=0,N=F.length;f<N;f++){var O=F[f];if(K.position.x==O.position.x&&K.position.y==O.position.y&&K.position.z==O.position.z){v[G]=f;J=!0;break}}if(!J){v[G]=F.length;F.push(new THREE.Vertex(K.position.clone()))}}G=0;for(w=p.faces.length;G<w;G++){K=p.faces[G];K.a=v[K.a];K.b=v[K.b];K.c=v[K.c];K.d=v[K.d]}p.vertices=
F})();this.computeCentroids();this.computeFaceNormals()};Cube.prototype=new THREE.Geometry;Cube.prototype.constructor=Cube;
var Cylinder=function(a,b,c,d,e){function g(m,p,y){h.vertices.push(new THREE.Vertex(new THREE.Vector3(m,p,y)))}THREE.Geometry.call(this);var h=this,j=Math.PI,k;for(k=0;k<a;k++)g(Math.sin(2*j*k/a)*b,Math.cos(2*j*k/a)*b,0);for(k=0;k<a;k++)g(Math.sin(2*j*k/a)*c,Math.cos(2*j*k/a)*c,d);for(k=0;k<a;k++)h.faces.push(new THREE.Face4(k,k+a,a+(k+1)%a,(k+1)%a));if(c!=0){g(0,0,-e);for(k=a;k<a+a/2;k++)h.faces.push(new THREE.Face4(2*a,(2*k-2*a)%a,(2*k-2*a+1)%a,(2*k-2*a+2)%a))}if(b!=0){g(0,0,d+e);for(k=a+a/2;k<
2*a;k++)h.faces.push(new THREE.Face4((2*k-2*a+2)%a+a,(2*k-2*a+1)%a+a,(2*k-2*a)%a+a,2*a+1))}this.computeCentroids();this.computeFaceNormals()};Cylinder.prototype=new THREE.Geometry;Cylinder.prototype.constructor=Cylinder;
var Plane=function(a,b,c,d){THREE.Geometry.call(this);var e,g=a/2,h=b/2;c=c||1;d=d||1;var j=c+1,k=d+1;a/=c;var m=b/d;for(e=0;e<k;e++)for(b=0;b<j;b++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(b*a-g,-(e*m-h),0)));for(e=0;e<d;e++)for(b=0;b<c;b++){this.faces.push(new THREE.Face4(b+j*e,b+j*(e+1),b+1+j*(e+1),b+1+j*e));this.uvs.push([new THREE.UV(b/c,e/d),new THREE.UV(b/c,(e+1)/d),new THREE.UV((b+1)/c,(e+1)/d),new THREE.UV((b+1)/c,e/d)])}this.computeCentroids();this.computeFaceNormals()};
Plane.prototype=new THREE.Geometry;Plane.prototype.constructor=Plane;
var Sphere=function(a,b,c){THREE.Geometry.call(this);var d,e=Math.PI,g=Math.max(3,b||8),h=Math.max(2,c||6);b=[];for(c=0;c<h+1;c++){d=c/h;var j=a*Math.cos(d*e),k=a*Math.sin(d*e),m=[],p=0;for(d=0;d<g;d++){var y=2*d/g,t=k*Math.sin(y*e);y=k*Math.cos(y*e);(c==0||c==h)&&d>0||(p=this.vertices.push(new THREE.Vertex(new THREE.Vector3(y,j,t)))-1);m.push(p)}b.push(m)}var q,z,C;e=b.length;for(c=0;c<e;c++){g=b[c].length;if(c>0)for(d=0;d<g;d++){m=d==g-1;h=b[c][m?0:d+1];j=b[c][m?g-1:d];k=b[c-1][m?g-1:d];m=b[c-1][m?
0:d+1];t=c/(e-1);q=(c-1)/(e-1);z=(d+1)/g;y=d/g;p=new THREE.UV(1-z,t);t=new THREE.UV(1-y,t);y=new THREE.UV(1-y,q);var F=new THREE.UV(1-z,q);if(c<b.length-1){q=this.vertices[h].position.clone();z=this.vertices[j].position.clone();C=this.vertices[k].position.clone();q.normalize();z.normalize();C.normalize();this.faces.push(new THREE.Face3(h,j,k,[new THREE.Vector3(q.x,q.y,q.z),new THREE.Vector3(z.x,z.y,z.z),new THREE.Vector3(C.x,C.y,C.z)]));this.uvs.push([p,t,y])}if(c>1){q=this.vertices[h].position.clone();
z=this.vertices[k].position.clone();C=this.vertices[m].position.clone();q.normalize();z.normalize();C.normalize();this.faces.push(new THREE.Face3(h,k,m,[new THREE.Vector3(q.x,q.y,q.z),new THREE.Vector3(z.x,z.y,z.z),new THREE.Vector3(C.x,C.y,C.z)]));this.uvs.push([p,y,F])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;
var Torus=function(a,b,c,d){this.radius=a||100;this.tube=b||40;this.segmentsR=c||8;this.segmentsT=d||6;a=[];THREE.Geometry.call(this);for(b=0;b<=this.segmentsR;++b)for(c=0;c<=this.segmentsT;++c){d=c/this.segmentsT*2*Math.PI;var e=b/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(e))*Math.cos(d),(this.radius+this.tube*Math.cos(e))*Math.sin(d),this.tube*Math.sin(e))));a.push([c/this.segmentsT,1-b/this.segmentsR])}for(b=1;b<=this.segmentsR;++b)for(c=
1;c<=this.segmentsT;++c){d=(this.segmentsT+1)*b+c;e=(this.segmentsT+1)*b+c-1;var g=(this.segmentsT+1)*(b-1)+c-1,h=(this.segmentsT+1)*(b-1)+c;this.faces.push(new THREE.Face4(d,e,g,h));this.uvs.push([new THREE.UV(a[d][0],a[d][1]),new THREE.UV(a[e][0],a[e][1]),new THREE.UV(a[g][0],a[g][1]),new THREE.UV(a[h][0],a[h][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus;
var Icosahedron=function(a){function b(y,t,q){var z=Math.sqrt(y*y+t*t+q*q);return e.vertices.push(new THREE.Vertex(new THREE.Vector3(y/z,t/z,q/z)))-1}function c(y,t,q,z){z.faces.push(new THREE.Face3(y,t,q))}function d(y,t){var q=e.vertices[y].position,z=e.vertices[t].position;return b((q.x+z.x)/2,(q.y+z.y)/2,(q.z+z.z)/2)}var e=this,g=new THREE.Geometry,h;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;b(-1,a,0);b(1,a,0);b(-1,-a,0);b(1,-a,0);b(0,-1,a);b(0,1,a);b(0,-1,-a);b(0,
1,-a);b(a,0,-1);b(a,0,1);b(-a,0,-1);b(-a,0,1);c(0,11,5,g);c(0,5,1,g);c(0,1,7,g);c(0,7,10,g);c(0,10,11,g);c(1,5,9,g);c(5,11,4,g);c(11,10,2,g);c(10,7,6,g);c(7,1,8,g);c(3,9,4,g);c(3,4,2,g);c(3,2,6,g);c(3,6,8,g);c(3,8,9,g);c(4,9,5,g);c(2,4,11,g);c(6,2,10,g);c(8,6,7,g);c(9,8,1,g);for(a=0;a<this.subdivisions;a++){h=new THREE.Geometry;for(var j in g.faces){var k=d(g.faces[j].a,g.faces[j].b),m=d(g.faces[j].b,g.faces[j].c),p=d(g.faces[j].c,g.faces[j].a);c(g.faces[j].a,k,p,h);c(g.faces[j].b,m,k,h);c(g.faces[j].c,
p,m,h);c(k,m,p,h)}g.faces=h.faces}e.faces=g.faces;delete g;delete h;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};Icosahedron.prototype=new THREE.Geometry;Icosahedron.prototype.constructor=Icosahedron;
function LathedObject(a,b,c){THREE.Geometry.call(this);this.nsteps=b||12;this.latheAngle=c||2*Math.PI;b=this.latheAngle/this.nsteps;for(var d=[],e=[],g=[],h=[],j=0;j<a.length;j++){this.vertices.push(new THREE.Vertex(a[j]));e[j]=this.vertices.length-1;d[j]=new THREE.Vector3(a[j].x,a[j].y,a[j].z)}for(var k=THREE.Matrix4.rotationZMatrix(this.stepSize),m=0;m<=this.latheAngle+0.001;m+=this.stepSize){for(j=0;j<d.length;j++)if(m<c){d[j]=k.multiplyVector3(d[j].clone());this.vertices.push(new THREE.Vertex(d[j]));
g[j]=this.vertices.length-1}else g=h;m==0&&(h=e);for(j=0;j<e.length-1;j++){this.faces.push(new THREE.Face4(g[j],g[j+1],e[j+1],e[j]));this.uvs.push([new THREE.UV(m/c,j/a.length),new THREE.UV(m/c,(j+1)/a.length),new THREE.UV((m-b)/c,(j+1)/a.length),new THREE.UV((m-b)/c,j/a.length)])}e=g;g=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()}LathedObject.prototype=new THREE.Geometry;LathedObject.prototype.constructor=LathedObject;
if(!window.Int32Array){window.Int32Array=Array;window.Float32Array=Array}
THREE.MarchingCubes=function(a,b){THREE.Object3D.call(this);this.materials=b instanceof Array?b:[b];this.init=function(c){this.isolation=80;this.size=c;this.size2=this.size*this.size;this.size3=this.size2*this.size;this.halfsize=this.size/2;this.delta=2/this.size;this.yd=this.size;this.zd=this.size2;this.field=new Float32Array(this.size3);this.normal_cache=new Float32Array(this.size3*3);this.vlist=new Float32Array(36);this.nlist=new Float32Array(36);this.firstDraw=!0;this.maxCount=4096;this.count=
0;this.hasPos=!1;this.hasNormal=!1;this.positionArray=new Float32Array(this.maxCount*3);this.normalArray=new Float32Array(this.maxCount*3)};this.lerp=function(c,d,e){return c+(d-c)*e};this.VIntX=function(c,d,e,g,h,j,k,m,p,y){h=(h-p)/(y-p);p=this.normal_cache;d[g]=j+h*this.delta;d[g+1]=k;d[g+2]=m;e[g]=this.lerp(p[c],p[c+3],h);e[g+1]=this.lerp(p[c+1],p[c+4],h);e[g+2]=this.lerp(p[c+2],p[c+5],h)};this.VIntY=function(c,d,e,g,h,j,k,m,p,y){h=(h-p)/(y-p);p=this.normal_cache;d[g]=j;d[g+1]=k+h*this.delta;d[g+
2]=m;d=c+this.yd*3;e[g]=this.lerp(p[c],p[d],h);e[g+1]=this.lerp(p[c+1],p[d+1],h);e[g+2]=this.lerp(p[c+2],p[d+2],h)};this.VIntZ=function(c,d,e,g,h,j,k,m,p,y){h=(h-p)/(y-p);p=this.normal_cache;d[g]=j;d[g+1]=k;d[g+2]=m+h*this.delta;d=c+this.zd*3;e[g]=this.lerp(p[c],p[d],h);e[g+1]=this.lerp(p[c+1],p[d+1],h);e[g+2]=this.lerp(p[c+2],p[d+2],h)};this.compNorm=function(c){var d=c*3;if(this.normal_cache[d]==0){this.normal_cache[d]=this.field[c-1]-this.field[c+1];this.normal_cache[d+1]=this.field[c-this.yd]-
this.field[c+this.yd];this.normal_cache[d+2]=this.field[c-this.zd]-this.field[c+this.zd]}};this.polygonize=function(c,d,e,g,h,j){var k=g+1,m=g+this.yd,p=g+this.zd,y=k+this.yd,t=k+this.zd,q=g+this.yd+this.zd,z=k+this.yd+this.zd,C=0,F=this.field[g],v=this.field[k],G=this.field[m],w=this.field[y],K=this.field[p],J=this.field[t],f=this.field[q],N=this.field[z];F<h&&(C|=1);v<h&&(C|=2);G<h&&(C|=8);w<h&&(C|=4);K<h&&(C|=16);J<h&&(C|=32);f<h&&(C|=128);N<h&&(C|=64);var O=THREE.edgeTable[C];if(O==0)return 0;
var U=this.delta,Q=c+U,Z=d+U;U=e+U;if(O&1){this.compNorm(g);this.compNorm(k);this.VIntX(g*3,this.vlist,this.nlist,0,h,c,d,e,F,v)}if(O&2){this.compNorm(k);this.compNorm(y);this.VIntY(k*3,this.vlist,this.nlist,3,h,Q,d,e,v,w)}if(O&4){this.compNorm(m);this.compNorm(y);this.VIntX(m*3,this.vlist,this.nlist,6,h,c,Z,e,G,w)}if(O&8){this.compNorm(g);this.compNorm(m);this.VIntY(g*3,this.vlist,this.nlist,9,h,c,d,e,F,G)}if(O&16){this.compNorm(p);this.compNorm(t);this.VIntX(p*3,this.vlist,this.nlist,12,h,c,d,U,
K,J)}if(O&32){this.compNorm(t);this.compNorm(z);this.VIntY(t*3,this.vlist,this.nlist,15,h,Q,d,U,J,N)}if(O&64){this.compNorm(q);this.compNorm(z);this.VIntX(q*3,this.vlist,this.nlist,18,h,c,Z,U,f,N)}if(O&128){this.compNorm(p);this.compNorm(q);this.VIntY(p*3,this.vlist,this.nlist,21,h,c,d,U,K,f)}if(O&256){this.compNorm(g);this.compNorm(p);this.VIntZ(g*3,this.vlist,this.nlist,24,h,c,d,e,F,K)}if(O&512){this.compNorm(k);this.compNorm(t);this.VIntZ(k*3,this.vlist,this.nlist,27,h,Q,d,e,v,J)}if(O&1024){this.compNorm(y);
this.compNorm(z);this.VIntZ(y*3,this.vlist,this.nlist,30,h,Q,Z,e,w,N)}if(O&2048){this.compNorm(m);this.compNorm(q);this.VIntZ(m*3,this.vlist,this.nlist,33,h,c,Z,e,G,f)}C<<=4;for(h=g=0;THREE.triTable[C+h]!=-1;){c=C+h;d=c+1;e=c+2;this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[c],3*THREE.triTable[d],3*THREE.triTable[e],j);h+=3;g++}return g};this.posnormtriv=function(c,d,e,g,h,j){var k=this.count*3;this.positionArray[k]=c[e];this.positionArray[k+1]=c[e+1];this.positionArray[k+2]=c[e+2];this.positionArray[k+
3]=c[g];this.positionArray[k+4]=c[g+1];this.positionArray[k+5]=c[g+2];this.positionArray[k+6]=c[h];this.positionArray[k+7]=c[h+1];this.positionArray[k+8]=c[h+2];this.normalArray[k]=d[e];this.normalArray[k+1]=d[e+1];this.normalArray[k+2]=d[e+2];this.normalArray[k+3]=d[g];this.normalArray[k+4]=d[g+1];this.normalArray[k+5]=d[g+2];this.normalArray[k+6]=d[h];this.normalArray[k+7]=d[h+1];this.normalArray[k+8]=d[h+2];this.hasPos=!0;this.hasNormal=!0;this.count+=3;this.count>=this.maxCount-3&&j(this)};this.begin=
function(){this.count=0;this.hasPos=!1;this.hasNormal=!1};this.end=function(c){if(this.count!=0){for(var d=this.count*3;d<this.positionArray.length;d++)this.positionArray[d]=0;c(this)}};this.addBall=function(c,d,e,g,h){var j=this.size*Math.sqrt(g/h),k=e*this.size,m=d*this.size,p=c*this.size,y=Math.floor(k-j);y<1&&(y=1);k=Math.floor(k+j);k>this.size-1&&(k=this.size-1);var t=Math.floor(m-j);t<1&&(t=1);m=Math.floor(m+j);m>this.size-1&&(m=this.size-1);var q=Math.floor(p-j);q<1&&(q=1);j=Math.floor(p+j);
j>this.size-1&&(j=this.size-1);for(var z,C,F,v,G,w;y<k;y++){p=this.size2*y;C=y/this.size-e;G=C*C;for(C=t;C<m;C++){F=p+this.size*C;z=C/this.size-d;w=z*z;for(z=q;z<j;z++){v=z/this.size-c;v=g/(1.0E-6+v*v+w+G)-h;v>0&&(this.field[F+z]+=v)}}}};this.addPlaneX=function(c,d){var e,g,h,j,k,m=this.size,p=this.yd,y=this.zd,t=this.field,q=m*Math.sqrt(c/d);q>m&&(q=m);for(e=0;e<q;e++){g=e/m;g*=g;j=c/(1.0E-4+g)-d;if(j>0)for(g=0;g<m;g++){k=e+g*p;for(h=0;h<m;h++)t[y*h+k]+=j}}};this.addPlaneY=function(c,d){var e,g,
h,j,k,m,p=this.size,y=this.yd,t=this.zd,q=this.field,z=p*Math.sqrt(c/d);z>p&&(z=p);for(g=0;g<z;g++){e=g/p;e*=e;j=c/(1.0E-4+e)-d;if(j>0){k=g*y;for(e=0;e<p;e++){m=k+e;for(h=0;h<p;h++)q[t*h+m]+=j}}}};this.addPlaneZ=function(c,d){var e,g,h,j,k,m;size=this.size;yd=this.yd;zd=this.zd;field=this.field;dist=size*Math.sqrt(c/d);dist>size&&(dist=size);for(h=0;h<dist;h++){e=h/size;e*=e;j=c/(1.0E-4+e)-d;if(j>0){k=zd*h;for(g=0;g<size;g++){m=k+g*yd;for(e=0;e<size;e++)field[m+e]+=j}}}};this.reset=function(){var c;
for(c=0;c<this.size3;c++){this.normal_cache[c*3]=0;this.field[c]=0}};this.render=function(c){this.begin();var d,e,g,h,j,k,m,p,y,t=this.size-2;for(h=1;h<t;h++){y=this.size2*h;m=(h-this.halfsize)/this.halfsize;for(g=1;g<t;g++){p=y+this.size*g;k=(g-this.halfsize)/this.halfsize;for(e=1;e<t;e++){j=(e-this.halfsize)/this.halfsize;d=p+e;this.polygonize(j,k,m,d,this.isolation,c)}}}this.end(c)};this.generateGeometry=function(){var c=0,d=new THREE.Geometry;this.render(function(e){var g,h,j,k,m,p,y,t;for(g=
0;g<e.count;g++){m=g*3;y=m+1;t=m+2;h=e.positionArray[m];j=e.positionArray[y];k=e.positionArray[t];p=new THREE.Vector3(h,j,k);h=e.normalArray[m];j=e.normalArray[y];k=e.normalArray[t];m=new THREE.Vector3(h,j,k);m.normalize();m=new THREE.Vertex(p,m);d.vertices.push(m)}nfaces=e.count/3;for(g=0;g<nfaces;g++){m=(c+g)*3;y=m+1;t=m+2;p=d.vertices[m].normal;h=d.vertices[y].normal;j=d.vertices[t].normal;m=new THREE.Face3(m,y,t,[p,h,j]);d.faces.push(m)}c+=nfaces;e.count=0});return d};this.init(a)};
THREE.MarchingCubes.prototype=new THREE.Object3D;THREE.MarchingCubes.prototype.constructor=THREE.MarchingCubes;
THREE.edgeTable=new Int32Array([0,265,515,778,1030,1295,1541,1804,2060,2309,2575,2822,3082,3331,3593,3840,400,153,915,666,1430,1183,1941,1692,2460,2197,2975,2710,3482,3219,3993,3728,560,825,51,314,1590,1855,1077,1340,2620,2869,2111,2358,3642,3891,3129,3376,928,681,419,170,1958,1711,1445,1196,2988,2725,2479,2214,4010,3747,3497,3232,1120,1385,1635,1898,102,367,613,876,3180,3429,3695,3942,2154,2403,2665,2912,1520,1273,2035,1786,502,255,1013,764,3580,3317,4095,3830,2554,2291,3065,2800,1616,1881,1107,
1370,598,863,85,348,3676,3925,3167,3414,2650,2899,2137,2384,1984,1737,1475,1226,966,719,453,204,4044,3781,3535,3270,3018,2755,2505,2240,2240,2505,2755,3018,3270,3535,3781,4044,204,453,719,966,1226,1475,1737,1984,2384,2137,2899,2650,3414,3167,3925,3676,348,85,863,598,1370,1107,1881,1616,2800,3065,2291,2554,3830,4095,3317,3580,764,1013,255,502,1786,2035,1273,1520,2912,2665,2403,2154,3942,3695,3429,3180,876,613,367,102,1898,1635,1385,1120,3232,3497,3747,4010,2214,2479,2725,2988,1196,1445,1711,1958,170,
419,681,928,3376,3129,3891,3642,2358,2111,2869,2620,1340,1077,1855,1590,314,51,825,560,3728,3993,3219,3482,2710,2975,2197,2460,1692,1941,1183,1430,666,915,153,400,3840,3593,3331,3082,2822,2575,2309,2060,1804,1541,1295,1030,778,515,265,0]);
THREE.triTable=new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-1,-1,-1,-1,3,0,9,3,9,11,11,9,10,-1,-1,-1,-1,-1,-1,-1,0,1,10,0,10,8,8,10,11,-1,-1,-1,-1,-1,-1,-1,3,1,10,11,3,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,11,1,11,9,9,11,8,-1,-1,-1,-1,-1,-1,-1,3,0,9,3,9,11,1,2,9,2,11,9,-1,-1,-1,-1,0,2,11,8,0,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,2,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,8,2,8,10,10,8,9,-1,-1,-1,-1,-1,-1,-1,9,10,2,0,9,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,8,2,8,10,0,1,8,1,10,8,-1,-1,-1,-1,1,10,
2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,3,8,9,1,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,9,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,3,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1]);THREE.Loader=function(a){this.statusDomElement=(this.showStatus=a)?this.addStatusElement():null};
THREE.Loader.prototype={addStatusElement:function(){var a=document.createElement("div");a.style.fontSize="0.8em";a.style.textAlign="left";a.style.background="#b00";a.style.color="#fff";a.style.width="140px";a.style.padding="0.25em 0.25em 0.25em 0.5em";a.style.position="absolute";a.style.right="0px";a.style.top="0px";a.style.zIndex=1E3;a.innerHTML="Loading ...";return a},updateProgress:function(a){var b="Loaded ";b+=a.total?(100*a.loaded/a.total).toFixed(0)+"%":(a.loaded/1E3).toFixed(2)+" KB";this.statusDomElement.innerHTML=
b},loadAsciiOld:function(a,b){var c=document.createElement("script");c.type="text/javascript";c.onload=b;c.src=a;document.getElementsByTagName("head")[0].appendChild(c)},loadAscii:function(a){var b=a.model,c=a.callback,d=a.texture_path?a.texture_path:THREE.Loader.prototype.extractUrlbase(b);a=(new Date).getTime();b=new Worker(b);b.onmessage=function(e){THREE.Loader.prototype.createModel(e.data,c,d)};b.postMessage(a)},loadBinary:function(a){var b=a.model,c=a.callback,d=a.texture_path?a.texture_path:
THREE.Loader.prototype.extractUrlbase(b),e=a.bin_path?a.bin_path:THREE.Loader.prototype.extractUrlbase(b);a=(new Date).getTime();b=new Worker(b);var g=this.showProgress?THREE.Loader.prototype.updateProgress:null;b.onmessage=function(h){THREE.Loader.prototype.loadAjaxBuffers(h.data.buffers,h.data.materials,c,e,d,g)};b.onerror=function(h){alert("worker.onerror: "+h.message+"\n"+h.data);h.preventDefault()};b.postMessage(a)},loadAjaxBuffers:function(a,b,c,d,e,g){var h=new XMLHttpRequest,j=d+"/"+a,k=0;
h.onreadystatechange=function(){if(h.readyState==4)h.status==200||h.status==0?THREE.Loader.prototype.createBinModel(h.responseText,c,e,b):alert("Couldn't load ["+j+"] ["+h.status+"]");else if(h.readyState==3){if(g){k==0&&(k=h.getResponseHeader("Content-Length"));g({total:k,loaded:h.responseText.length})}}else h.readyState==2&&(k=h.getResponseHeader("Content-Length"))};h.open("GET",j,!0);h.overrideMimeType("text/plain; charset=x-user-defined");h.setRequestHeader("Content-Type","text/plain");h.send(null)},
createBinModel:function(a,b,c,d){var e=function(g){function h(u,A){var H=p(u,A),T=p(u,A+1),Y=p(u,A+2),ha=p(u,A+3),da=(ha<<1&255|Y>>7)-127;H|=(Y&127)<<16|T<<8;if(H==0&&da==-127)return 0;return(1-2*(ha>>7))*(1+H*Math.pow(2,-23))*Math.pow(2,da)}function j(u,A){var H=p(u,A),T=p(u,A+1),Y=p(u,A+2);return(p(u,A+3)<<24)+(Y<<16)+(T<<8)+H}function k(u,A){var H=p(u,A);return(p(u,A+1)<<8)+H}function m(u,A){var H=p(u,A);return H>127?H-256:H}function p(u,A){return u.charCodeAt(A)&255}function y(u){var A,H,T;A=
j(a,u);H=j(a,u+f);T=j(a,u+N);u=k(a,u+O);THREE.Loader.prototype.f3(v,A,H,T,u)}function t(u){var A,H,T,Y,ha,da;A=j(a,u);H=j(a,u+f);T=j(a,u+N);Y=k(a,u+O);ha=j(a,u+U);da=j(a,u+Q);u=j(a,u+Z);THREE.Loader.prototype.f3n(v,K,A,H,T,Y,ha,da,u)}function q(u){var A,H,T,Y;A=j(a,u);H=j(a,u+ca);T=j(a,u+L);Y=j(a,u+W);u=k(a,u+ma);THREE.Loader.prototype.f4(v,A,H,T,Y,u)}function z(u){var A,H,T,Y,ha,da,ka,Ca;A=j(a,u);H=j(a,u+ca);T=j(a,u+L);Y=j(a,u+W);ha=k(a,u+ma);da=j(a,u+ba);ka=j(a,u+na);Ca=j(a,u+ga);u=j(a,u+ia);THREE.Loader.prototype.f4n(v,
K,A,H,T,Y,ha,da,ka,Ca,u)}function C(u){var A,H;A=j(a,u);H=j(a,u+ra);u=j(a,u+wa);THREE.Loader.prototype.uv3(v.uvs,J[A*2],J[A*2+1],J[H*2],J[H*2+1],J[u*2],J[u*2+1])}function F(u){var A,H,T;A=j(a,u);H=j(a,u+l);T=j(a,u+x);u=j(a,u+B);THREE.Loader.prototype.uv4(v.uvs,J[A*2],J[A*2+1],J[H*2],J[H*2+1],J[T*2],J[T*2+1],J[u*2],J[u*2+1])}var v=this,G=0,w,K=[],J=[],f,N,O,U,Q,Z,ca,L,W,ma,ba,na,ga,ia,ra,wa,l,x,B,n,o,E,D,I,S;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(v,d,g);w={signature:a.substr(G,
8),header_bytes:p(a,G+8),vertex_coordinate_bytes:p(a,G+9),normal_coordinate_bytes:p(a,G+10),uv_coordinate_bytes:p(a,G+11),vertex_index_bytes:p(a,G+12),normal_index_bytes:p(a,G+13),uv_index_bytes:p(a,G+14),material_index_bytes:p(a,G+15),nvertices:j(a,G+16),nnormals:j(a,G+16+4),nuvs:j(a,G+16+8),ntri_flat:j(a,G+16+12),ntri_smooth:j(a,G+16+16),ntri_flat_uv:j(a,G+16+20),ntri_smooth_uv:j(a,G+16+24),nquad_flat:j(a,G+16+28),nquad_smooth:j(a,G+16+32),nquad_flat_uv:j(a,G+16+36),nquad_smooth_uv:j(a,G+16+40)};
G+=w.header_bytes;f=w.vertex_index_bytes;N=w.vertex_index_bytes*2;O=w.vertex_index_bytes*3;U=w.vertex_index_bytes*3+w.material_index_bytes;Q=w.vertex_index_bytes*3+w.material_index_bytes+w.normal_index_bytes;Z=w.vertex_index_bytes*3+w.material_index_bytes+w.normal_index_bytes*2;ca=w.vertex_index_bytes;L=w.vertex_index_bytes*2;W=w.vertex_index_bytes*3;ma=w.vertex_index_bytes*4;ba=w.vertex_index_bytes*4+w.material_index_bytes;na=w.vertex_index_bytes*4+w.material_index_bytes+w.normal_index_bytes;ga=
w.vertex_index_bytes*4+w.material_index_bytes+w.normal_index_bytes*2;ia=w.vertex_index_bytes*4+w.material_index_bytes+w.normal_index_bytes*3;ra=w.uv_index_bytes;wa=w.uv_index_bytes*2;l=w.uv_index_bytes;x=w.uv_index_bytes*2;B=w.uv_index_bytes*3;g=w.vertex_index_bytes*3+w.material_index_bytes;S=w.vertex_index_bytes*4+w.material_index_bytes;n=w.ntri_flat*g;o=w.ntri_smooth*(g+w.normal_index_bytes*3);E=w.ntri_flat_uv*(g+w.uv_index_bytes*3);D=w.ntri_smooth_uv*(g+w.normal_index_bytes*3+w.uv_index_bytes*
3);I=w.nquad_flat*S;g=w.nquad_smooth*(S+w.normal_index_bytes*4);S=w.nquad_flat_uv*(S+w.uv_index_bytes*4);G+=function(u){for(var A,H,T,Y=w.vertex_coordinate_bytes*3,ha=u+w.nvertices*Y;u<ha;u+=Y){A=h(a,u);H=h(a,u+w.vertex_coordinate_bytes);T=h(a,u+w.vertex_coordinate_bytes*2);THREE.Loader.prototype.v(v,A,H,T)}return w.nvertices*Y}(G);G+=function(u){for(var A,H,T,Y=w.normal_coordinate_bytes*3,ha=u+w.nnormals*Y;u<ha;u+=Y){A=m(a,u);H=m(a,u+w.normal_coordinate_bytes);T=m(a,u+w.normal_coordinate_bytes*2);
K.push(A/127,H/127,T/127)}return w.nnormals*Y}(G);G+=function(u){for(var A,H,T=w.uv_coordinate_bytes*2,Y=u+w.nuvs*T;u<Y;u+=T){A=h(a,u);H=h(a,u+w.uv_coordinate_bytes);J.push(A,H)}return w.nuvs*T}(G);n=G+n;o=n+o;E=o+E;D=E+D;I=D+I;g=I+g;S=g+S;(function(u){var A,H=w.vertex_index_bytes*3+w.material_index_bytes,T=H+w.uv_index_bytes*3,Y=u+w.ntri_flat_uv*T;for(A=u;A<Y;A+=T){y(A);C(A+H)}return Y-u})(o);(function(u){var A,H=w.vertex_index_bytes*3+w.material_index_bytes+w.normal_index_bytes*3,T=H+w.uv_index_bytes*
3,Y=u+w.ntri_smooth_uv*T;for(A=u;A<Y;A+=T){t(A);C(A+H)}return Y-u})(E);(function(u){var A,H=w.vertex_index_bytes*4+w.material_index_bytes,T=H+w.uv_index_bytes*4,Y=u+w.nquad_flat_uv*T;for(A=u;A<Y;A+=T){q(A);F(A+H)}return Y-u})(g);(function(u){var A,H=w.vertex_index_bytes*4+w.material_index_bytes+w.normal_index_bytes*4,T=H+w.uv_index_bytes*4,Y=u+w.nquad_smooth_uv*T;for(A=u;A<Y;A+=T){z(A);F(A+H)}return Y-u})(S);(function(u){var A,H=w.vertex_index_bytes*3+w.material_index_bytes,T=u+w.ntri_flat*H;for(A=
u;A<T;A+=H)y(A);return T-u})(G);(function(u){var A,H=w.vertex_index_bytes*3+w.material_index_bytes+w.normal_index_bytes*3,T=u+w.ntri_smooth*H;for(A=u;A<T;A+=H)t(A);return T-u})(n);(function(u){var A,H=w.vertex_index_bytes*4+w.material_index_bytes,T=u+w.nquad_flat*H;for(A=u;A<T;A+=H)q(A);return T-u})(D);(function(u){var A,H=w.vertex_index_bytes*4+w.material_index_bytes+w.normal_index_bytes*4,T=u+w.nquad_smooth*H;for(A=u;A<T;A+=H)z(A);return T-u})(I);this.computeCentroids();this.computeFaceNormals()};
e.prototype=new THREE.Geometry;e.prototype.constructor=e;b(new e(c))},createModel:function(a,b,c){var d=function(e){var g=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(g,a.materials,e);(function(){var h,j,k,m,p;h=0;for(j=a.vertices.length;h<j;h+=3){k=a.vertices[h];m=a.vertices[h+1];p=a.vertices[h+2];THREE.Loader.prototype.v(g,k,m,p)}if(a.colors){h=0;for(j=a.colors.length;h<j;h+=3){k=a.colors[h];m=a.colors[h+1];p=a.colors[h+2];THREE.Loader.prototype.vc(g,k,m,p)}}})();(function(){function h(z,
C){THREE.Loader.prototype.f3(g,z[C],z[C+1],z[C+2],z[C+3])}function j(z,C){THREE.Loader.prototype.f3n(g,a.normals,z[C],z[C+1],z[C+2],z[C+3],z[C+4],z[C+5],z[C+6])}function k(z,C){THREE.Loader.prototype.f4(g,z[C],z[C+1],z[C+2],z[C+3],z[C+4])}function m(z,C){THREE.Loader.prototype.f4n(g,a.normals,z[C],z[C+1],z[C+2],z[C+3],z[C+4],z[C+5],z[C+6],z[C+7],z[C+8])}function p(z,C){var F,v,G,w,K,J,f,N,O;F=z[C];v=z[C+1];G=z[C+2];w=a.uvs[F*2];f=a.uvs[F*2+1];K=a.uvs[v*2];N=a.uvs[v*2+1];J=a.uvs[G*2];O=a.uvs[G*2+1];
THREE.Loader.prototype.uv3(g.uvs,w,f,K,N,J,O);if(a.uvs2&&a.uvs2.length){w=a.uvs2[F*2];f=a.uvs2[F*2+1];K=a.uvs2[v*2];N=a.uvs2[v*2+1];J=a.uvs2[G*2];O=a.uvs2[G*2+1];THREE.Loader.prototype.uv3(g.uvs2,w,1-f,K,1-N,J,1-O)}}function y(z,C){var F,v,G,w,K,J,f,N,O,U,Q,Z;F=z[C];v=z[C+1];G=z[C+2];w=z[C+3];K=a.uvs[F*2];O=a.uvs[F*2+1];J=a.uvs[v*2];U=a.uvs[v*2+1];f=a.uvs[G*2];Q=a.uvs[G*2+1];N=a.uvs[w*2];Z=a.uvs[w*2+1];THREE.Loader.prototype.uv4(g.uvs,K,O,J,U,f,Q,N,Z);if(a.uvs2){K=a.uvs2[F*2];O=a.uvs2[F*2+1];J=a.uvs2[v*
2];U=a.uvs2[v*2+1];f=a.uvs2[G*2];Q=a.uvs2[G*2+1];N=a.uvs2[w*2];Z=a.uvs2[w*2+1];THREE.Loader.prototype.uv4(g.uvs2,K,1-O,J,1-U,f,1-Q,N,1-Z)}}var t,q;t=0;for(q=a.trianglesUvs.length;t<q;t+=7){h(a.trianglesUvs,t);p(a.trianglesUvs,t+4)}t=0;for(q=a.trianglesNormalsUvs.length;t<q;t+=10){j(a.trianglesNormalsUvs,t);p(a.trianglesNormalsUvs,t+7)}t=0;for(q=a.quadsUvs.length;t<q;t+=9){k(a.quadsUvs,t);y(a.quadsUvs,t+5)}t=0;for(q=a.quadsNormalsUvs.length;t<q;t+=13){m(a.quadsNormalsUvs,t);y(a.quadsNormalsUvs,t+9)}t=
0;for(q=a.triangles.length;t<q;t+=4)h(a.triangles,t);t=0;for(q=a.trianglesNormals.length;t<q;t+=7)j(a.trianglesNormals,t);t=0;for(q=a.quads.length;t<q;t+=5)k(a.quads,t);t=0;for(q=a.quadsNormals.length;t<q;t+=9)m(a.quadsNormals,t)})();(function(){var h,j,k,m;if(a.skinWeights){h=0;for(j=a.skinWeights.length;h<j;h+=2){k=a.skinWeights[h];m=a.skinWeights[h+1];THREE.Loader.prototype.sw(g,k,m,0,0)}}if(a.skinIndices){h=0;for(j=a.skinIndices.length;h<j;h+=2){k=a.skinIndices[h];m=a.skinIndices[h+1];THREE.Loader.prototype.si(g,
k,m,0,0)}}THREE.Loader.prototype.bones(g,a.bones);THREE.Loader.prototype.animation(g,a.animation)})();this.computeCentroids();this.computeFaceNormals()};d.prototype=new THREE.Geometry;d.prototype.constructor=d;b(new d(c))},bones:function(a,b){a.bones=b},animation:function(a,b){a.animation=b},si:function(a,b,c,d,e){a.skinIndices.push(new THREE.Vector4(b,c,d,e))},sw:function(a,b,c,d,e){a.skinWeights.push(new THREE.Vector4(b,c,d,e))},v:function(a,b,c,d){a.vertices.push(new THREE.Vertex(new THREE.Vector3(b,
c,d)))},vc:function(a,b,c,d){var e=new THREE.Color(16777215);e.setRGB(b,c,d);a.colors.push(e)},f3:function(a,b,c,d,e){a.faces.push(new THREE.Face3(b,c,d,null,a.materials[e]))},f4:function(a,b,c,d,e,g){a.faces.push(new THREE.Face4(b,c,d,e,null,a.materials[g]))},f3n:function(a,b,c,d,e,g,h,j,k){g=a.materials[g];var m=b[j*3],p=b[j*3+1];j=b[j*3+2];var y=b[k*3],t=b[k*3+1];k=b[k*3+2];a.faces.push(new THREE.Face3(c,d,e,[new THREE.Vector3(b[h*3],b[h*3+1],b[h*3+2]),new THREE.Vector3(m,p,j),new THREE.Vector3(y,
t,k)],g))},f4n:function(a,b,c,d,e,g,h,j,k,m,p){h=a.materials[h];var y=b[k*3],t=b[k*3+1];k=b[k*3+2];var q=b[m*3],z=b[m*3+1];m=b[m*3+2];var C=b[p*3],F=b[p*3+1];p=b[p*3+2];a.faces.push(new THREE.Face4(c,d,e,g,[new THREE.Vector3(b[j*3],b[j*3+1],b[j*3+2]),new THREE.Vector3(y,t,k),new THREE.Vector3(q,z,m),new THREE.Vector3(C,F,p)],h))},uv3:function(a,b,c,d,e,g,h){var j=[];j.push(new THREE.UV(b,c));j.push(new THREE.UV(d,e));j.push(new THREE.UV(g,h));a.push(j)},uv4:function(a,b,c,d,e,g,h,j,k){var m=[];m.push(new THREE.UV(b,
c));m.push(new THREE.UV(d,e));m.push(new THREE.UV(g,h));m.push(new THREE.UV(j,k));a.push(m)},init_materials:function(a,b,c){a.materials=[];for(var d=0;d<b.length;++d)a.materials[d]=[THREE.Loader.prototype.createMaterial(b[d],c)]},createMaterial:function(a,b){function c(j){j=Math.log(j)/Math.LN2;return Math.floor(j)==j}function d(j,k){var m=new Image;m.onload=function(){if(!c(this.width)||!c(this.height)){var p=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),y=Math.pow(2,Math.round(Math.log(this.height)/
Math.LN2));j.image.width=p;j.image.height=y;j.image.getContext("2d").drawImage(this,0,0,p,y)}else j.image=this;j.needsUpdate=!0};m.src=k}var e,g,h;e="MeshLambertMaterial";g={color:15658734,opacity:1,map:null,lightMap:null,vertexColors:a.vertexColors};a.shading&&a.shading=="Phong"&&(e="MeshPhongMaterial");if(a.mapDiffuse&&b){h=document.createElement("canvas");g.map=new THREE.Texture(h);d(g.map,b+"/"+a.mapDiffuse)}else if(a.colorDiffuse){h=(a.colorDiffuse[0]*255<<16)+(a.colorDiffuse[1]*255<<8)+a.colorDiffuse[2]*
255;g.color=h;g.opacity=a.transparency}else if(a.DbgColor)g.color=a.DbgColor;if(a.mapLightmap&&b){h=document.createElement("canvas");g.lightMap=new THREE.Texture(h);d(g.lightMap,b+"/"+a.mapLightmap)}return new THREE[e](g)},extractUrlbase:function(a){a=a.split("/");a.pop();return a.join("/")}};