ami.js
Version:
<p align="center"> <img src="https://cloud.githubusercontent.com/assets/214063/23213764/78ade038-f90c-11e6-8208-4fcade5f3832.png" width="60%"> </p>
1 lines • 1.17 MB
JavaScript
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("AMI",[],e):"object"==typeof exports?exports.AMI=e():t.AMI=e()}(this,function(){return function(t){function e(i){if(n[i])return n[i].exports;var r=n[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,e),r.l=!0,r.exports}var n={};return e.m=t,e.c=n,e.d=function(t,n,i){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:i})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=83)}([function(t,e,n){"use strict";function i(){}function r(t,e){this.x=t||0,this.y=e||0}function o(t,e,n,i,a,s,l,c,h,u){Object.defineProperty(this,"id",{value:Ra++}),this.uuid=La.generateUUID(),this.name="",this.image=void 0!==t?t:o.DEFAULT_IMAGE,this.mipmaps=[],this.mapping=void 0!==e?e:o.DEFAULT_MAPPING,this.wrapS=void 0!==n?n:Oo,this.wrapT=void 0!==i?i:Oo,this.magFilter=void 0!==a?a:zo,this.minFilter=void 0!==s?s:jo,this.anisotropy=void 0!==h?h:1,this.format=void 0!==l?l:ia,this.type=void 0!==c?c:Ho,this.offset=new r(0,0),this.repeat=new r(1,1),this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=void 0!==u?u:xa,this.version=0,this.onUpdate=null}function a(t,e,n,i){this.x=t||0,this.y=e||0,this.z=n||0,this.w=void 0!==i?i:1}function s(t,e,n){this.uuid=La.generateUUID(),this.width=t,this.height=e,this.scissor=new a(0,0,t,e),this.scissorTest=!1,this.viewport=new a(0,0,t,e),void 0===(n=n||{}).minFilter&&(n.minFilter=zo),this.texture=new o(void 0,void 0,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.encoding),this.depthBuffer=void 0===n.depthBuffer||n.depthBuffer,this.stencilBuffer=void 0===n.stencilBuffer||n.stencilBuffer,this.depthTexture=void 0!==n.depthTexture?n.depthTexture:null}function l(t,e,n){s.call(this,t,e,n),this.activeCubeFace=0,this.activeMipMapLevel=0}function c(t,e,n,i){this._x=t||0,this._y=e||0,this._z=n||0,this._w=void 0!==i?i:1}function h(t,e,n){this.x=t||0,this.y=e||0,this.z=n||0}function u(){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}function p(t,e,n,i,r,a,s,l,c,h,u,p){o.call(this,null,a,s,l,c,h,i,r,u,p),this.image={data:t,width:e,height:n},this.magFilter=void 0!==c?c:Uo,this.minFilter=void 0!==h?h:Uo,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}function d(t,e,n,i,r,a,s,l,c,h){t=void 0!==t?t:[],e=void 0!==e?e:Ao,o.call(this,t,e,n,i,r,a,s,l,c,h),this.flipY=!1}function f(){this.seq=[],this.map={}}function m(t,e,n){var i=t[0];if(i<=0||i>0)return t;var r=e*n,o=Oa[r];if(void 0===o&&(o=new Float32Array(r),Oa[r]=o),0!==e){i.toArray(o,0);for(var a=1,s=0;a!==e;++a)s+=n,t[a].toArray(o,s)}return o}function _(t,e){var n=Fa[e];void 0===n&&(n=new Int32Array(e),Fa[e]=n);for(var i=0;i!==e;++i)n[i]=t.allocTextureUnit();return n}function g(t,e){t.uniform1f(this.addr,e)}function y(t,e){t.uniform1i(this.addr,e)}function v(t,e){void 0===e.x?t.uniform2fv(this.addr,e):t.uniform2f(this.addr,e.x,e.y)}function b(t,e){void 0!==e.x?t.uniform3f(this.addr,e.x,e.y,e.z):void 0!==e.r?t.uniform3f(this.addr,e.r,e.g,e.b):t.uniform3fv(this.addr,e)}function w(t,e){void 0===e.x?t.uniform4fv(this.addr,e):t.uniform4f(this.addr,e.x,e.y,e.z,e.w)}function x(t,e){t.uniformMatrix2fv(this.addr,!1,e.elements||e)}function S(t,e){void 0===e.elements?t.uniformMatrix3fv(this.addr,!1,e):(Na.set(e.elements),t.uniformMatrix3fv(this.addr,!1,Na))}function E(t,e){void 0===e.elements?t.uniformMatrix4fv(this.addr,!1,e):(Ua.set(e.elements),t.uniformMatrix4fv(this.addr,!1,Ua))}function M(t,e,n){var i=n.allocTextureUnit();t.uniform1i(this.addr,i),n.setTexture2D(e||ka,i)}function T(t,e,n){var i=n.allocTextureUnit();t.uniform1i(this.addr,i),n.setTextureCube(e||Da,i)}function A(t,e){t.uniform2iv(this.addr,e)}function P(t,e){t.uniform3iv(this.addr,e)}function I(t,e){t.uniform4iv(this.addr,e)}function C(t){switch(t){case 5126:return g;case 35664:return v;case 35665:return b;case 35666:return w;case 35674:return x;case 35675:return S;case 35676:return E;case 35678:case 36198:return M;case 35680:return T;case 5124:case 35670:return y;case 35667:case 35671:return A;case 35668:case 35672:return P;case 35669:case 35673:return I}}function L(t,e){t.uniform1fv(this.addr,e)}function R(t,e){t.uniform1iv(this.addr,e)}function k(t,e){t.uniform2fv(this.addr,m(e,this.size,2))}function D(t,e){t.uniform3fv(this.addr,m(e,this.size,3))}function O(t,e){t.uniform4fv(this.addr,m(e,this.size,4))}function F(t,e){t.uniformMatrix2fv(this.addr,!1,m(e,this.size,4))}function U(t,e){t.uniformMatrix3fv(this.addr,!1,m(e,this.size,9))}function N(t,e){t.uniformMatrix4fv(this.addr,!1,m(e,this.size,16))}function B(t,e,n){var i=e.length,r=_(n,i);t.uniform1iv(this.addr,r);for(var o=0;o!==i;++o)n.setTexture2D(e[o]||ka,r[o])}function z(t,e,n){var i=e.length,r=_(n,i);t.uniform1iv(this.addr,r);for(var o=0;o!==i;++o)n.setTextureCube(e[o]||Da,r[o])}function G(t){switch(t){case 5126:return L;case 35664:return k;case 35665:return D;case 35666:return O;case 35674:return F;case 35675:return U;case 35676:return N;case 35678:return B;case 35680:return z;case 5124:case 35670:return R;case 35667:case 35671:return A;case 35668:case 35672:return P;case 35669:case 35673:return I}}function j(t,e,n){this.id=t,this.addr=n,this.setValue=C(e.type)}function H(t,e,n){this.id=t,this.addr=n,this.size=e.size,this.setValue=G(e.type)}function V(t){this.id=t,f.call(this)}function W(t,e){t.seq.push(e),t.map[e.id]=e}function q(t,e,n){var i=t.name,r=i.length;for(Ba.lastIndex=0;;){var o=Ba.exec(i),a=Ba.lastIndex,s=o[1],l="]"===o[2],c=o[3];if(l&&(s|=0),void 0===c||"["===c&&a+2===r){W(n,void 0===c?new j(s,t,e):new H(s,t,e));break}var h=n.map[s];void 0===h&&W(n,h=new V(s)),n=h}}function X(t,e,n){f.call(this),this.renderer=n;for(var i=t.getProgramParameter(e,t.ACTIVE_UNIFORMS),r=0;r<i;++r){var o=t.getActiveUniform(e,r),a=o.name;q(o,t.getUniformLocation(e,a),this)}}function Y(t,e,n){return void 0===e&&void 0===n?this.set(t):this.setRGB(t,e,n)}function Z(t,e){this.min=void 0!==t?t:new r(1/0,1/0),this.max=void 0!==e?e:new r(-1/0,-1/0)}function J(t,e,n,i,o){function a(){var t=new Float32Array([-1,-1,0,0,1,-1,1,0,1,1,1,1,-1,1,0,1]),i=new Uint16Array([0,1,2,0,2,3]);l=e.createBuffer(),c=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,l),e.bufferData(e.ARRAY_BUFFER,t,e.STATIC_DRAW),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,c),e.bufferData(e.ELEMENT_ARRAY_BUFFER,i,e.STATIC_DRAW),m=e.createTexture(),_=e.createTexture(),n.bindTexture(e.TEXTURE_2D,m),e.texImage2D(e.TEXTURE_2D,0,e.RGB,16,16,0,e.RGB,e.UNSIGNED_BYTE,null),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),n.bindTexture(e.TEXTURE_2D,_),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,16,16,0,e.RGBA,e.UNSIGNED_BYTE,null),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),u={vertexShader:["uniform lowp int renderType;","uniform vec3 screenPosition;","uniform vec2 scale;","uniform float rotation;","uniform sampler2D occlusionMap;","attribute vec2 position;","attribute vec2 uv;","varying vec2 vUV;","varying float vVisibility;","void main() {","vUV = uv;","vec2 pos = position;","if ( renderType == 2 ) {","vec4 visibility = texture2D( occlusionMap, vec2( 0.1, 0.1 ) );","visibility += texture2D( occlusionMap, vec2( 0.5, 0.1 ) );","visibility += texture2D( occlusionMap, vec2( 0.9, 0.1 ) );","visibility += texture2D( occlusionMap, vec2( 0.9, 0.5 ) );","visibility += texture2D( occlusionMap, vec2( 0.9, 0.9 ) );","visibility += texture2D( occlusionMap, vec2( 0.5, 0.9 ) );","visibility += texture2D( occlusionMap, vec2( 0.1, 0.9 ) );","visibility += texture2D( occlusionMap, vec2( 0.1, 0.5 ) );","visibility += texture2D( occlusionMap, vec2( 0.5, 0.5 ) );","vVisibility = visibility.r / 9.0;","vVisibility *= 1.0 - visibility.g / 9.0;","vVisibility *= visibility.b / 9.0;","vVisibility *= 1.0 - visibility.a / 9.0;","pos.x = cos( rotation ) * position.x - sin( rotation ) * position.y;","pos.y = sin( rotation ) * position.x + cos( rotation ) * position.y;","}","gl_Position = vec4( ( pos * scale + screenPosition.xy ).xy, screenPosition.z, 1.0 );","}"].join("\n"),fragmentShader:["uniform lowp int renderType;","uniform sampler2D map;","uniform float opacity;","uniform vec3 color;","varying vec2 vUV;","varying float vVisibility;","void main() {","if ( renderType == 0 ) {","gl_FragColor = vec4( 1.0, 0.0, 1.0, 0.0 );","} else if ( renderType == 1 ) {","gl_FragColor = texture2D( map, vUV );","} else {","vec4 texture = texture2D( map, vUV );","texture.a *= opacity * vVisibility;","gl_FragColor = texture;","gl_FragColor.rgb *= color;","}","}"].join("\n")},p=s(u),d={vertex:e.getAttribLocation(p,"position"),uv:e.getAttribLocation(p,"uv")},f={renderType:e.getUniformLocation(p,"renderType"),map:e.getUniformLocation(p,"map"),occlusionMap:e.getUniformLocation(p,"occlusionMap"),opacity:e.getUniformLocation(p,"opacity"),color:e.getUniformLocation(p,"color"),scale:e.getUniformLocation(p,"scale"),rotation:e.getUniformLocation(p,"rotation"),screenPosition:e.getUniformLocation(p,"screenPosition")}}function s(t){var n=e.createProgram(),i=e.createShader(e.FRAGMENT_SHADER),r=e.createShader(e.VERTEX_SHADER),a="precision "+o.precision+" float;\n";return e.shaderSource(i,a+t.fragmentShader),e.shaderSource(r,a+t.vertexShader),e.compileShader(i),e.compileShader(r),e.attachShader(n,i),e.attachShader(n,r),e.linkProgram(n),n}var l,c,u,p,d,f,m,_;this.render=function(t,o,s,u){if(0!==t.length){var g=new h,y=u.w/u.z,v=.5*u.z,b=.5*u.w,w=16/u.w,x=new r(w*y,w),S=new h(1,1,0),E=new r(1,1),M=new Z;M.min.set(u.x,u.y),M.max.set(u.x+(u.z-16),u.y+(u.w-16)),void 0===p&&a(),n.useProgram(p),n.initAttributes(),n.enableAttribute(d.vertex),n.enableAttribute(d.uv),n.disableUnusedAttributes(),e.uniform1i(f.occlusionMap,0),e.uniform1i(f.map,1),e.bindBuffer(e.ARRAY_BUFFER,l),e.vertexAttribPointer(d.vertex,2,e.FLOAT,!1,16,0),e.vertexAttribPointer(d.uv,2,e.FLOAT,!1,16,8),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,c),n.disable(e.CULL_FACE),n.buffers.depth.setMask(!1);for(var T=0,A=t.length;T<A;T++){w=16/u.w,x.set(w*y,w);var P=t[T];if(g.set(P.matrixWorld.elements[12],P.matrixWorld.elements[13],P.matrixWorld.elements[14]),g.applyMatrix4(s.matrixWorldInverse),g.applyMatrix4(s.projectionMatrix),S.copy(g),E.x=u.x+S.x*v+v-8,E.y=u.y+S.y*b+b-8,!0===M.containsPoint(E)){n.activeTexture(e.TEXTURE0),n.bindTexture(e.TEXTURE_2D,null),n.activeTexture(e.TEXTURE1),n.bindTexture(e.TEXTURE_2D,m),e.copyTexImage2D(e.TEXTURE_2D,0,e.RGB,E.x,E.y,16,16,0),e.uniform1i(f.renderType,0),e.uniform2f(f.scale,x.x,x.y),e.uniform3f(f.screenPosition,S.x,S.y,S.z),n.disable(e.BLEND),n.enable(e.DEPTH_TEST),e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0),n.activeTexture(e.TEXTURE0),n.bindTexture(e.TEXTURE_2D,_),e.copyTexImage2D(e.TEXTURE_2D,0,e.RGBA,E.x,E.y,16,16,0),e.uniform1i(f.renderType,1),n.disable(e.DEPTH_TEST),n.activeTexture(e.TEXTURE1),n.bindTexture(e.TEXTURE_2D,m),e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0),P.positionScreen.copy(S),P.customUpdateCallback?P.customUpdateCallback(P):P.updateLensFlares(),e.uniform1i(f.renderType,2),n.enable(e.BLEND);for(var I=0,C=P.lensFlares.length;I<C;I++){var L=P.lensFlares[I];L.opacity>.001&&L.scale>.001&&(S.x=L.x,S.y=L.y,S.z=L.z,w=L.size*L.scale/u.w,x.x=w*y,x.y=w,e.uniform3f(f.screenPosition,S.x,S.y,S.z),e.uniform2f(f.scale,x.x,x.y),e.uniform1f(f.rotation,L.rotation),e.uniform1f(f.opacity,L.opacity),e.uniform3f(f.color,L.color.r,L.color.g,L.color.b),n.setBlending(L.blending,L.blendEquation,L.blendSrc,L.blendDst),i.setTexture2D(L.texture,1),e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0))}}}n.enable(e.CULL_FACE),n.enable(e.DEPTH_TEST),n.buffers.depth.setMask(!0),n.reset()}}}function K(t,e,n,i,r,a,s,l,c){o.call(this,t,e,n,i,r,a,s,l,c),this.needsUpdate=!0}function Q(t,e,n,i,r){function o(){var t=new Float32Array([-.5,-.5,0,0,.5,-.5,1,0,.5,.5,1,1,-.5,.5,0,1]),n=new Uint16Array([0,1,2,0,2,3]);l=e.createBuffer(),u=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,l),e.bufferData(e.ARRAY_BUFFER,t,e.STATIC_DRAW),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,u),e.bufferData(e.ELEMENT_ARRAY_BUFFER,n,e.STATIC_DRAW),p=a(),d={position:e.getAttribLocation(p,"position"),uv:e.getAttribLocation(p,"uv")},f={uvOffset:e.getUniformLocation(p,"uvOffset"),uvScale:e.getUniformLocation(p,"uvScale"),rotation:e.getUniformLocation(p,"rotation"),scale:e.getUniformLocation(p,"scale"),color:e.getUniformLocation(p,"color"),map:e.getUniformLocation(p,"map"),opacity:e.getUniformLocation(p,"opacity"),modelViewMatrix:e.getUniformLocation(p,"modelViewMatrix"),projectionMatrix:e.getUniformLocation(p,"projectionMatrix"),fogType:e.getUniformLocation(p,"fogType"),fogDensity:e.getUniformLocation(p,"fogDensity"),fogNear:e.getUniformLocation(p,"fogNear"),fogFar:e.getUniformLocation(p,"fogFar"),fogColor:e.getUniformLocation(p,"fogColor"),alphaTest:e.getUniformLocation(p,"alphaTest")};var i=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");i.width=8,i.height=8;var r=i.getContext("2d");r.fillStyle="white",r.fillRect(0,0,8,8),m=new K(i)}function a(){var t=e.createProgram(),n=e.createShader(e.VERTEX_SHADER),i=e.createShader(e.FRAGMENT_SHADER);return e.shaderSource(n,["precision "+r.precision+" float;","#define SHADER_NAME SpriteMaterial","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform float rotation;","uniform vec2 scale;","uniform vec2 uvOffset;","uniform vec2 uvScale;","attribute vec2 position;","attribute vec2 uv;","varying vec2 vUV;","void main() {","vUV = uvOffset + uv * uvScale;","vec2 alignedPosition = position * scale;","vec2 rotatedPosition;","rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;","rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;","vec4 finalPosition;","finalPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );","finalPosition.xy += rotatedPosition;","finalPosition = projectionMatrix * finalPosition;","gl_Position = finalPosition;","}"].join("\n")),e.shaderSource(i,["precision "+r.precision+" float;","#define SHADER_NAME SpriteMaterial","uniform vec3 color;","uniform sampler2D map;","uniform float opacity;","uniform int fogType;","uniform vec3 fogColor;","uniform float fogDensity;","uniform float fogNear;","uniform float fogFar;","uniform float alphaTest;","varying vec2 vUV;","void main() {","vec4 texture = texture2D( map, vUV );","if ( texture.a < alphaTest ) discard;","gl_FragColor = vec4( color * texture.xyz, texture.a * opacity );","if ( fogType > 0 ) {","float depth = gl_FragCoord.z / gl_FragCoord.w;","float fogFactor = 0.0;","if ( fogType == 1 ) {","fogFactor = smoothstep( fogNear, fogFar, depth );","} else {","const float LOG2 = 1.442695;","fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );","fogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );","}","gl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );","}","}"].join("\n")),e.compileShader(n),e.compileShader(i),e.attachShader(t,n),e.attachShader(t,i),e.linkProgram(t),t}function s(t,e){return t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:e.id-t.id}var l,u,p,d,f,m,_=new h,g=new c,y=new h;this.render=function(r,a,c){if(0!==r.length){void 0===p&&o(),n.useProgram(p),n.initAttributes(),n.enableAttribute(d.position),n.enableAttribute(d.uv),n.disableUnusedAttributes(),n.disable(e.CULL_FACE),n.enable(e.BLEND),e.bindBuffer(e.ARRAY_BUFFER,l),e.vertexAttribPointer(d.position,2,e.FLOAT,!1,16,0),e.vertexAttribPointer(d.uv,2,e.FLOAT,!1,16,8),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,u),e.uniformMatrix4fv(f.projectionMatrix,!1,c.projectionMatrix.elements),n.activeTexture(e.TEXTURE0),e.uniform1i(f.map,0);var h=0,v=0,b=a.fog;b?(e.uniform3f(f.fogColor,b.color.r,b.color.g,b.color.b),b.isFog?(e.uniform1f(f.fogNear,b.near),e.uniform1f(f.fogFar,b.far),e.uniform1i(f.fogType,1),h=1,v=1):b.isFogExp2&&(e.uniform1f(f.fogDensity,b.density),e.uniform1i(f.fogType,2),h=2,v=2)):(e.uniform1i(f.fogType,0),h=0,v=0);for(var w=0,x=r.length;w<x;w++)(E=r[w]).modelViewMatrix.multiplyMatrices(c.matrixWorldInverse,E.matrixWorld),E.z=-E.modelViewMatrix.elements[14];r.sort(s);for(var S=[],w=0,x=r.length;w<x;w++){var E=r[w],M=E.material;if(!1!==M.visible){E.onBeforeRender(t,a,c,void 0,M,void 0),e.uniform1f(f.alphaTest,M.alphaTest),e.uniformMatrix4fv(f.modelViewMatrix,!1,E.modelViewMatrix.elements),E.matrixWorld.decompose(_,g,y),S[0]=y.x,S[1]=y.y;var T=0;a.fog&&M.fog&&(T=v),h!==T&&(e.uniform1i(f.fogType,T),h=T),null!==M.map?(e.uniform2f(f.uvOffset,M.map.offset.x,M.map.offset.y),e.uniform2f(f.uvScale,M.map.repeat.x,M.map.repeat.y)):(e.uniform2f(f.uvOffset,0,0),e.uniform2f(f.uvScale,1,1)),e.uniform1f(f.opacity,M.opacity),e.uniform3f(f.color,M.color.r,M.color.g,M.color.b),e.uniform1f(f.rotation,M.rotation),e.uniform2fv(f.scale,S),n.setBlending(M.blending,M.blendEquation,M.blendSrc,M.blendDst,M.blendEquationAlpha,M.blendSrcAlpha,M.blendDstAlpha,M.premultipliedAlpha),n.buffers.depth.setTest(M.depthTest),n.buffers.depth.setMask(M.depthWrite),i.setTexture2D(M.map||m,0),e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0),E.onAfterRender(t,a,c,void 0,M,void 0)}}n.enable(e.CULL_FACE),n.reset()}}}function $(){Object.defineProperty(this,"id",{value:Wa++}),this.uuid=La.generateUUID(),this.name="",this.type="Material",this.fog=!0,this.lights=!0,this.blending=Hr,this.side=Fr,this.flatShading=!1,this.vertexColors=Br,this.opacity=1,this.transparent=!1,this.blendSrc=io,this.blendDst=ro,this.blendEquation=Yr,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=fo,this.depthTest=!0,this.depthWrite=!0,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaTest=0,this.premultipliedAlpha=!1,this.overdraw=0,this.visible=!0,this.userData={},this.needsUpdate=!0}function tt(t){$.call(this),this.type="ShaderMaterial",this.defines={},this.uniforms={},this.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",this.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}",this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]},this.index0AttributeName=void 0,void 0!==t&&(void 0!==t.attributes&&console.error("THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead."),this.setValues(t))}function et(t){$.call(this),this.type="MeshDepthMaterial",this.depthPacking=Ia,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.setValues(t)}function nt(t){$.call(this),this.type="MeshDistanceMaterial",this.referencePosition=new h,this.nearDistance=1,this.farDistance=1e3,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.fog=!1,this.lights=!1,this.setValues(t)}function it(t,e){this.min=void 0!==t?t:new h(1/0,1/0,1/0),this.max=void 0!==e?e:new h(-1/0,-1/0,-1/0)}function rt(t,e){this.center=void 0!==t?t:new h,this.radius=void 0!==e?e:0}function ot(){this.elements=[1,0,0,0,1,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}function at(t,e){this.normal=void 0!==t?t:new h(1,0,0),this.constant=void 0!==e?e:0}function st(t,e,n,i,r,o){this.planes=[void 0!==t?t:new at,void 0!==e?e:new at,void 0!==n?n:new at,void 0!==i?i:new at,void 0!==r?r:new at,void 0!==o?o:new at]}function lt(t,e,n){function i(e,n,i,r,o,a){var s=e.geometry,l=null,c=v,h=e.customDepthMaterial;if(i&&(c=b,h=e.customDistanceMaterial),h)l=h;else{var u=!1;n.morphTargets&&(s&&s.isBufferGeometry?u=s.morphAttributes&&s.morphAttributes.position&&s.morphAttributes.position.length>0:s&&s.isGeometry&&(u=s.morphTargets&&s.morphTargets.length>0)),e.isSkinnedMesh&&!1===n.skinning&&console.warn("THREE.WebGLShadowMap: THREE.SkinnedMesh with material.skinning set to false:",e);var p=e.isSkinnedMesh&&n.skinning,d=0;u&&(d|=_),p&&(d|=g),l=c[d]}if(t.localClippingEnabled&&!0===n.clipShadows&&0!==n.clippingPlanes.length){var f=l.uuid,m=n.uuid,y=w[f];void 0===y&&(y={},w[f]=y);var x=y[m];void 0===x&&(x=l.clone(),y[m]=x),l=x}l.visible=n.visible,l.wireframe=n.wireframe;var S=n.side;return C.renderSingleSided&&S==Nr&&(S=Fr),C.renderReverseSided&&(S===Fr?S=Ur:S===Ur&&(S=Fr)),l.side=S,l.clipShadows=n.clipShadows,l.clippingPlanes=n.clippingPlanes,l.clipIntersection=n.clipIntersection,l.wireframeLinewidth=n.wireframeLinewidth,l.linewidth=n.linewidth,i&&l.isMeshDistanceMaterial&&(l.referencePosition.copy(r),l.nearDistance=o,l.farDistance=a),l}function o(n,r,a,s){if(!1!==n.visible){if(n.layers.test(r.layers)&&(n.isMesh||n.isLine||n.isPoints)&&n.castShadow&&(!n.frustumCulled||l.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(a.matrixWorldInverse,n.matrixWorld);var c=e.update(n),h=n.material;if(Array.isArray(h))for(var u=c.groups,p=0,d=u.length;p<d;p++){var f=u[p],_=h[f.materialIndex];if(_&&_.visible){g=i(n,_,s,m,a.near,a.far);t.renderBufferDirect(a,null,c,g,n,f)}}else if(h.visible){var g=i(n,h,s,m,a.near,a.far);t.renderBufferDirect(a,null,c,g,n,null)}}for(var y=n.children,v=0,b=y.length;v<b;v++)o(y[v],r,a,s)}}for(var l=new st,c=new u,p=new r,d=new r(n,n),f=new h,m=new h,_=1,g=2,y=1+(_|g),v=new Array(y),b=new Array(y),w={},x=[new h(1,0,0),new h(-1,0,0),new h(0,0,1),new h(0,0,-1),new h(0,1,0),new h(0,-1,0)],S=[new h(0,1,0),new h(0,1,0),new h(0,1,0),new h(0,1,0),new h(0,0,1),new h(0,0,-1)],E=[new a,new a,new a,new a,new a,new a],M=0;M!==y;++M){var T=0!=(M&_),A=0!=(M&g),P=new et({depthPacking:Ca,morphTargets:T,skinning:A});v[M]=P;var I=new nt({morphTargets:T,skinning:A});b[M]=I}var C=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Dr,this.renderReverseSided=!0,this.renderSingleSided=!0,this.render=function(e,n,i){if(!1!==C.enabled&&(!1!==C.autoUpdate||!1!==C.needsUpdate)&&0!==e.length){var r=t.context,a=t.state;a.disable(r.BLEND),a.buffers.color.setClear(1,1,1,1),a.buffers.depth.setTest(!0),a.setScissorTest(!1);for(var h,u=0,_=e.length;u<_;u++){var g=e[u],y=g.shadow,v=g&&g.isPointLight;if(void 0!==y){var b=y.camera;if(p.copy(y.mapSize),p.min(d),v){var w=p.x,M=p.y;E[0].set(2*w,M,w,M),E[1].set(0,M,w,M),E[2].set(3*w,M,w,M),E[3].set(w,M,w,M),E[4].set(3*w,0,w,M),E[5].set(w,0,w,M),p.x*=4,p.y*=2}if(null===y.map){var T={minFilter:Uo,magFilter:Uo,format:ia};y.map=new s(p.x,p.y,T),y.map.texture.name=g.name+".shadowMap",b.updateProjectionMatrix()}y.isSpotLightShadow&&y.update(g);var A=y.map,P=y.matrix;m.setFromMatrixPosition(g.matrixWorld),b.position.copy(m),v?(h=6,P.makeTranslation(-m.x,-m.y,-m.z)):(h=1,f.setFromMatrixPosition(g.target.matrixWorld),b.lookAt(f),b.updateMatrixWorld(),P.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),P.multiply(b.projectionMatrix),P.multiply(b.matrixWorldInverse)),t.setRenderTarget(A),t.clear();for(var I=0;I<h;I++){if(v){f.copy(b.position),f.add(x[I]),b.up.copy(S[I]),b.lookAt(f),b.updateMatrixWorld();var L=E[I];a.viewport(L)}c.multiplyMatrices(b.projectionMatrix,b.matrixWorldInverse),l.setFromMatrix(c),o(n,i,b,v)}}else console.warn("THREE.WebGLShadowMap:",g,"has no shadow.")}C.needsUpdate=!1}}}function ct(t){function e(e,n){var i=e.array,r=e.dynamic?t.DYNAMIC_DRAW:t.STATIC_DRAW,o=t.createBuffer();t.bindBuffer(n,o),t.bufferData(n,i,r),e.onUploadCallback();var a=t.FLOAT;return i instanceof Float32Array?a=t.FLOAT:i instanceof Float64Array?console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array."):i instanceof Uint16Array?a=t.UNSIGNED_SHORT:i instanceof Int16Array?a=t.SHORT:i instanceof Uint32Array?a=t.UNSIGNED_INT:i instanceof Int32Array?a=t.INT:i instanceof Int8Array?a=t.BYTE:i instanceof Uint8Array&&(a=t.UNSIGNED_BYTE),{buffer:o,type:a,bytesPerElement:i.BYTES_PER_ELEMENT,version:e.version}}function n(e,n,i){var r=n.array,o=n.updateRange;t.bindBuffer(i,e),!1===n.dynamic?t.bufferData(i,r,t.STATIC_DRAW):-1===o.count?t.bufferSubData(i,0,r):0===o.count?console.error("THREE.WebGLObjects.updateBuffer: dynamic THREE.BufferAttribute marked as needsUpdate but updateRange.count is 0, ensure you are using set methods or updating manually."):(t.bufferSubData(i,o.offset*r.BYTES_PER_ELEMENT,r.subarray(o.offset,o.offset+o.count)),o.count=-1)}var i={};return{get:function(t){return t.isInterleavedBufferAttribute&&(t=t.data),i[t.uuid]},remove:function(e){e.isInterleavedBufferAttribute&&(e=e.data);var n=i[e.uuid];n&&(t.deleteBuffer(n.buffer),delete i[e.uuid])},update:function(t,r){t.isInterleavedBufferAttribute&&(t=t.data);var o=i[t.uuid];void 0===o?i[t.uuid]=e(t,r):o.version<t.version&&(n(o.buffer,t,r),o.version=t.version)}}}function ht(t,e,n,i){this._x=t||0,this._y=e||0,this._z=n||0,this._order=i||ht.DefaultOrder}function ut(){this.mask=1}function pt(){Object.defineProperty(this,"id",{value:qa++}),this.uuid=La.generateUUID(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=pt.DefaultUp.clone();var t=new h,e=new ht,n=new c,i=new h(1,1,1);e.onChange(function(){n.setFromEuler(e,!1)}),n.onChange(function(){e.setFromQuaternion(n,void 0,!1)}),Object.defineProperties(this,{position:{enumerable:!0,value:t},rotation:{enumerable:!0,value:e},quaternion:{enumerable:!0,value:n},scale:{enumerable:!0,value:i},modelViewMatrix:{value:new u},normalMatrix:{value:new ot}}),this.matrix=new u,this.matrixWorld=new u,this.matrixAutoUpdate=pt.DefaultMatrixAutoUpdate,this.matrixWorldNeedsUpdate=!1,this.layers=new ut,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.userData={}}function dt(){pt.call(this),this.type="Camera",this.matrixWorldInverse=new u,this.projectionMatrix=new u}function ft(t,e,n,i,r,o){dt.call(this),this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=n,this.bottom=i,this.near=void 0!==r?r:.1,this.far=void 0!==o?o:2e3,this.updateProjectionMatrix()}function mt(t,e,n,i){dt.call(this),this.type="PerspectiveCamera",this.fov=void 0!==t?t:50,this.zoom=1,this.near=void 0!==n?n:.1,this.far=void 0!==i?i:2e3,this.focus=10,this.aspect=void 0!==e?e:1,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}function _t(t,e,n,i,r,o){this.a=t,this.b=e,this.c=n,this.normal=i&&i.isVector3?i:new h,this.vertexNormals=Array.isArray(i)?i:[],this.color=r&&r.isColor?r:new Y,this.vertexColors=Array.isArray(r)?r:[],this.materialIndex=void 0!==o?o:0}function gt(){return Xa++}function yt(){Object.defineProperty(this,"id",{value:gt()}),this.uuid=La.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}function vt(t,e,n){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.uuid=La.generateUUID(),this.name="",this.array=t,this.itemSize=e,this.count=void 0!==t?t.length/e:0,this.normalized=!0===n,this.dynamic=!1,this.updateRange={offset:0,count:-1},this.onUploadCallback=function(){},this.version=0}function bt(t,e){vt.call(this,new Int8Array(t),e)}function wt(t,e){vt.call(this,new Uint8Array(t),e)}function xt(t,e){vt.call(this,new Uint8ClampedArray(t),e)}function St(t,e){vt.call(this,new Int16Array(t),e)}function Et(t,e){vt.call(this,new Uint16Array(t),e)}function Mt(t,e){vt.call(this,new Int32Array(t),e)}function Tt(t,e){vt.call(this,new Uint32Array(t),e)}function At(t,e){vt.call(this,new Float32Array(t),e)}function Pt(t,e){vt.call(this,new Float64Array(t),e)}function It(){this.indices=[],this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}function Ct(t){if(0===t.length)return-1/0;for(var e=t[0],n=1,i=t.length;n<i;++n)t[n]>e&&(e=t[n]);return e}function Lt(){Object.defineProperty(this,"id",{value:gt()}),this.uuid=La.generateUUID(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0}}function Rt(t,e,n,i,r,o){yt.call(this),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:i,heightSegments:r,depthSegments:o},this.fromBufferGeometry(new kt(t,e,n,i,r,o)),this.mergeVertices()}function kt(t,e,n,i,r,o){function a(t,e,n,i,r,o,a,m,_,g,y){var v,b,w=o/_,x=a/g,S=o/2,E=a/2,M=m/2,T=_+1,A=g+1,P=0,I=0,C=new h;for(b=0;b<A;b++){var L=b*x-E;for(v=0;v<T;v++){var R=v*w-S;C[t]=R*i,C[e]=L*r,C[n]=M,c.push(C.x,C.y,C.z),C[t]=0,C[e]=0,C[n]=m>0?1:-1,u.push(C.x,C.y,C.z),p.push(v/_),p.push(1-b/g),P+=1}}for(b=0;b<g;b++)for(v=0;v<_;v++){var k=d+v+T*b,D=d+v+T*(b+1),O=d+(v+1)+T*(b+1),F=d+(v+1)+T*b;l.push(k,D,F),l.push(D,O,F),I+=6}s.addGroup(f,I,y),f+=I,d+=P}Lt.call(this),this.type="BoxBufferGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:i,heightSegments:r,depthSegments:o};var s=this;i=Math.floor(i)||1,r=Math.floor(r)||1;var l=[],c=[],u=[],p=[],d=0,f=0;a("z","y","x",-1,-1,n,e,t,o=Math.floor(o)||1,r,0),a("z","y","x",1,-1,n,e,-t,o,r,1),a("x","z","y",1,1,t,n,e,i,o,2),a("x","z","y",1,-1,t,n,-e,i,o,3),a("x","y","z",1,-1,t,e,n,i,r,4),a("x","y","z",-1,-1,t,e,-n,i,r,5),this.setIndex(l),this.addAttribute("position",new At(c,3)),this.addAttribute("normal",new At(u,3)),this.addAttribute("uv",new At(p,2))}function Dt(t,e,n,i){yt.call(this),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:n,heightSegments:i},this.fromBufferGeometry(new Ot(t,e,n,i)),this.mergeVertices()}function Ot(t,e,n,i){Lt.call(this),this.type="PlaneBufferGeometry",this.parameters={width:t,height:e,widthSegments:n,heightSegments:i};var r,o,a=t/2,s=e/2,l=Math.floor(n)||1,c=Math.floor(i)||1,h=l+1,u=c+1,p=t/l,d=e/c,f=[],m=[],_=[],g=[];for(o=0;o<u;o++){var y=o*d-s;for(r=0;r<h;r++){var v=r*p-a;m.push(v,-y,0),_.push(0,0,1),g.push(r/l),g.push(1-o/c)}}for(o=0;o<c;o++)for(r=0;r<l;r++){var b=r+h*o,w=r+h*(o+1),x=r+1+h*(o+1),S=r+1+h*o;f.push(b,w,S),f.push(w,x,S)}this.setIndex(f),this.addAttribute("position",new At(m,3)),this.addAttribute("normal",new At(_,3)),this.addAttribute("uv",new At(g,2))}function Ft(t){$.call(this),this.type="MeshBasicMaterial",this.color=new Y(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=vo,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.lights=!1,this.setValues(t)}function Ut(t,e){this.origin=void 0!==t?t:new h,this.direction=void 0!==e?e:new h}function Nt(t,e){this.start=void 0!==t?t:new h,this.end=void 0!==e?e:new h}function Bt(t,e,n){this.a=void 0!==t?t:new h,this.b=void 0!==e?e:new h,this.c=void 0!==n?n:new h}function zt(t,e){pt.call(this),this.type="Mesh",this.geometry=void 0!==t?t:new Lt,this.material=void 0!==e?e:new Ft({color:16777215*Math.random()}),this.drawMode=va,this.updateMorphTargets()}function Gt(t,e,n,i){function r(t,n){e.buffers.color.setClear(t.r,t.g,t.b,n,i)}var o,a,s,l=new Y(0),c=0;return{getClearColor:function(){return l},setClearColor:function(t,e){l.set(t),r(l,c=void 0!==e?e:1)},getClearAlpha:function(){return c},setClearAlpha:function(t){r(l,c=t)},render:function(e,i,h,u){var p=i.background;null===p?r(l,c):p&&p.isColor&&(r(p,1),u=!0),(t.autoClear||u)&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),p&&p.isCubeTexture?(void 0===s&&((s=new zt(new kt(1,1,1),new tt({uniforms:Va.cube.uniforms,vertexShader:Va.cube.vertexShader,fragmentShader:Va.cube.fragmentShader,side:Ur,depthTest:!0,depthWrite:!1,polygonOffset:!0,fog:!1}))).geometry.removeAttribute("normal"),s.geometry.removeAttribute("uv"),s.onBeforeRender=function(t,e,n){var i=n.far;this.matrixWorld.makeScale(i,i,i),this.matrixWorld.copyPosition(n.matrixWorld),this.material.polygonOffsetUnits=10*i},n.update(s.geometry)),s.material.uniforms.tCube.value=p,e.push(s,s.geometry,s.material,0,null)):p&&p.isTexture&&(void 0===o&&(o=new ft(-1,1,1,-1,0,1),a=new zt(new Ot(2,2),new Ft({depthTest:!1,depthWrite:!1,fog:!1})),n.update(a.geometry)),a.material.map=p,t.renderBufferDirect(o,null,a.geometry,a.material,a,null))}}}function jt(t,e){return t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.program&&e.program&&t.program!==e.program?t.program.id-e.program.id:t.material.id!==e.material.id?t.material.id-e.material.id:t.z!==e.z?t.z-e.z:t.id-e.id}function Ht(t,e){return t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:t.id-e.id}function Vt(){var t=[],e=0,n=[],i=[];return{opaque:n,transparent:i,init:function(){e=0,n.length=0,i.length=0},push:function(r,o,a,s,l){var c=t[e];void 0===c?(c={id:r.id,object:r,geometry:o,material:a,program:a.program,renderOrder:r.renderOrder,z:s,group:l},t[e]=c):(c.id=r.id,c.object=r,c.geometry=o,c.material=a,c.program=a.program,c.renderOrder=r.renderOrder,c.z=s,c.group=l),(!0===a.transparent?i:n).push(c),e++},sort:function(){n.length>1&&n.sort(jt),i.length>1&&i.sort(Ht)}}}function Wt(){var t={};return{get:function(e,n){var i=e.id+","+n.id,r=t[i];return void 0===r&&(r=new Vt,t[i]=r),r},dispose:function(){t={}}}}function qt(t,e){return Math.abs(e[1])-Math.abs(t[1])}function Xt(t){var e={},n=new Float32Array(8);return{update:function(i,r,o,a){var s=i.morphTargetInfluences,l=s.length,c=e[r.id];if(void 0===c){for(c=[],p=0;p<l;p++)c[p]=[p,0];e[r.id]=c}for(var h=o.morphTargets&&r.morphAttributes.position,u=o.morphNormals&&r.morphAttributes.normal,p=0;p<l;p++)0!==(d=c[p])[1]&&(h&&r.removeAttribute("morphTarget"+p),u&&r.removeAttribute("morphNormal"+p));for(p=0;p<l;p++)(d=c[p])[0]=p,d[1]=s[p];c.sort(qt);for(p=0;p<8;p++){var d=c[p];if(d){var f=d[0],m=d[1];if(m){h&&r.addAttribute("morphTarget"+p,h[f]),u&&r.addAttribute("morphNormal"+p,u[f]),n[p]=m;continue}}n[p]=0}a.getUniforms().setValue(t,"morphTargetInfluences",n)}}}function Yt(t,e,n){var i,r,o;this.setMode=function(t){i=t},this.setIndex=function(t){r=t.type,o=t.bytesPerElement},this.render=function(e,a){t.drawElements(i,a,r,e*o),n.calls++,n.vertices+=a,i===t.TRIANGLES?n.faces+=a/3:i===t.POINTS&&(n.points+=a)},this.renderInstances=function(a,s,l){var c=e.get("ANGLE_instanced_arrays");null!==c?(c.drawElementsInstancedANGLE(i,l,r,s*o,a.maxInstancedCount),n.calls++,n.vertices+=l*a.maxInstancedCount,i===t.TRIANGLES?n.faces+=a.maxInstancedCount*l/3:i===t.POINTS&&(n.points+=a.maxInstancedCount*l)):console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.")}}function Zt(t,e,n){var i;this.setMode=function(t){i=t},this.render=function(e,r){t.drawArrays(i,e,r),n.calls++,n.vertices+=r,i===t.TRIANGLES?n.faces+=r/3:i===t.POINTS&&(n.points+=r)},this.renderInstances=function(r,o,a){var s=e.get("ANGLE_instanced_arrays");if(null!==s){var l=r.attributes.position;l.isInterleavedBufferAttribute?(a=l.data.count,s.drawArraysInstancedANGLE(i,0,a,r.maxInstancedCount)):s.drawArraysInstancedANGLE(i,o,a,r.maxInstancedCount),n.calls++,n.vertices+=a*r.maxInstancedCount,i===t.TRIANGLES?n.faces+=r.maxInstancedCount*a/3:i===t.POINTS&&(n.points+=r.maxInstancedCount*a)}else console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.")}}function Jt(t,e,n){function i(t){var a=t.target,s=r[a.id];null!==s.index&&e.remove(s.index);for(var l in s.attributes)e.remove(s.attributes[l]);a.removeEventListener("dispose",i),delete r[a.id];var c=o[a.id];c&&(e.remove(c),delete o[a.id]),(c=o[s.id])&&(e.remove(c),delete o[s.id]),n.geometries--}var r={},o={};return{get:function(t,e){var o=r[e.id];return o||(e.addEventListener("dispose",i),e.isBufferGeometry?o=e:e.isGeometry&&(void 0===e._bufferGeometry&&(e._bufferGeometry=(new Lt).setFromObject(t)),o=e._bufferGeometry),r[e.id]=o,n.geometries++,o)},update:function(n){var i=n.index,r=n.attributes;null!==i&&e.update(i,t.ELEMENT_ARRAY_BUFFER);for(var o in r)e.update(r[o],t.ARRAY_BUFFER);var a=n.morphAttributes;for(var o in a)for(var s=a[o],l=0,c=s.length;l<c;l++)e.update(s[l],t.ARRAY_BUFFER)},getWireframeAttribute:function(n){var i=o[n.id];if(i)return i;var r=[],a=n.index,s=n.attributes;if(null!==a)for(var l=0,c=(d=a.array).length;l<c;l+=3){var h=d[l+0],u=d[l+1],p=d[l+2];r.push(h,u,u,p,p,h)}else for(var d=s.position.array,l=0,c=d.length/3-1;l<c;l+=3){var h=l+0,u=l+1,p=l+2;r.push(h,u,u,p,p,h)}return i=new(Ct(r)>65535?Tt:Et)(r,1),e.update(i,t.ELEMENT_ARRAY_BUFFER),o[n.id]=i,i}}}function Kt(){var t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];var n;switch(e.type){case"DirectionalLight":n={direction:new h,color:new Y,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new r};break;case"SpotLight":n={position:new h,direction:new h,color:new Y,distance:0,coneCos:0,penumbraCos:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new r};break;case"PointLight":n={position:new h,color:new Y,distance:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new r,shadowCameraNear:1,shadowCameraFar:1e3};break;case"HemisphereLight":n={direction:new h,skyColor:new Y,groundColor:new Y};break;case"RectAreaLight":n={color:new Y,position:new h,halfWidth:new h,halfHeight:new h}}return t[e.id]=n,n}}}function Qt(){var t=new Kt,e={hash:"",ambient:[0,0,0],directional:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],point:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[]},n=new h,i=new u,r=new u;return{setup:function(o,a,s){for(var l=0,c=0,h=0,u=0,p=0,d=0,f=0,m=0,_=s.matrixWorldInverse,g=0,y=o.length;g<y;g++){var v=o[g],b=v.color,w=v.intensity,x=v.distance,S=v.shadow&&v.shadow.map?v.shadow.map.texture:null;if(v.isAmbientLight)l+=b.r*w,c+=b.g*w,h+=b.b*w;else if(v.isDirectionalLight)(M=t.get(v)).color.copy(v.color).multiplyScalar(v.intensity),M.direction.setFromMatrixPosition(v.matrixWorld),n.setFromMatrixPosition(v.target.matrixWorld),M.direction.sub(n),M.direction.transformDirection(_),M.shadow=v.castShadow,v.castShadow&&(E=v.shadow,M.shadowBias=E.bias,M.shadowRadius=E.radius,M.shadowMapSize=E.mapSize),e.directionalShadowMap[u]=S,e.directionalShadowMatrix[u]=v.shadow.matrix,e.directional[u]=M,u++;else if(v.isSpotLight)(M=t.get(v)).position.setFromMatrixPosition(v.matrixWorld),M.position.applyMatrix4(_),M.color.copy(b).multiplyScalar(w),M.distance=x,M.direction.setFromMatrixPosition(v.matrixWorld),n.setFromMatrixPosition(v.target.matrixWorld),M.direction.sub(n),M.direction.transformDirection(_),M.coneCos=Math.cos(v.angle),M.penumbraCos=Math.cos(v.angle*(1-v.penumbra)),M.decay=0===v.distance?0:v.decay,M.shadow=v.castShadow,v.castShadow&&(E=v.shadow,M.shadowBias=E.bias,M.shadowRadius=E.radius,M.shadowMapSize=E.mapSize),e.spotShadowMap[d]=S,e.spotShadowMatrix[d]=v.shadow.matrix,e.spot[d]=M,d++;else if(v.isRectAreaLight)(M=t.get(v)).color.copy(b).multiplyScalar(w/(v.width*v.height)),M.position.setFromMatrixPosition(v.matrixWorld),M.position.applyMatrix4(_),r.identity(),i.copy(v.matrixWorld),i.premultiply(_),r.extractRotation(i),M.halfWidth.set(.5*v.width,0,0),M.halfHeight.set(0,.5*v.height,0),M.halfWidth.applyMatrix4(r),M.halfHeight.applyMatrix4(r),e.rectArea[f]=M,f++;else if(v.isPointLight){if((M=t.get(v)).position.setFromMatrixPosition(v.matrixWorld),M.position.applyMatrix4(_),M.color.copy(v.color).multiplyScalar(v.intensity),M.distance=v.distance,M.decay=0===v.distance?0:v.decay,M.shadow=v.castShadow,v.castShadow){var E=v.shadow;M.shadowBias=E.bias,M.shadowRadius=E.radius,M.shadowMapSize=E.mapSize,M.shadowCameraNear=E.camera.near,M.shadowCameraFar=E.camera.far}e.pointShadowMap[p]=S,e.pointShadowMatrix[p]=v.shadow.matrix,e.point[p]=M,p++}else if(v.isHemisphereLight){var M=t.get(v);M.direction.setFromMatrixPosition(v.matrixWorld),M.direction.transformDirection(_),M.direction.normalize(),M.skyColor.copy(v.color).multiplyScalar(w),M.groundColor.copy(v.groundColor).multiplyScalar(w),e.hemi[m]=M,m++}}e.ambient[0]=l,e.ambient[1]=c,e.ambient[2]=h,e.directional.length=u,e.spot.length=d,e.rectArea.length=f,e.point.length=p,e.hemi.length=m,e.hash=u+","+p+","+d+","+f+","+m+","+a.length},state:e}}function $t(t,e){var n={};return{update:function(i){var r=e.frame,o=i.geometry,a=t.get(i,o);return n[a.id]!==r&&(o.isGeometry&&a.updateFromObject(i),t.update(a),n[a.id]=r),a},clear:function(){n={}}}}function te(t){for(var e=t.split("\n"),n=0;n<e.length;n++)e[n]=n+1+": "+e[n];return e.join("\n")}function ee(t,e,n){var i=t.createShader(e);return t.shaderSource(i,n),t.compileShader(i),!1===t.getShaderParameter(i,t.COMPILE_STATUS)&&console.error("THREE.WebGLShader: Shader couldn't compile."),""!==t.getShaderInfoLog(i)&&console.warn("THREE.WebGLShader: gl.getShaderInfoLog()",e===t.VERTEX_SHADER?"vertex":"fragment",t.getShaderInfoLog(i),te(n)),i}function ne(t){switch(t){case xa:return["Linear","( value )"];case Sa:return["sRGB","( value )"];case Ma:return["RGBE","( value )"];case Ta:return["RGBM","( value, 7.0 )"];case Aa:return["RGBM","( value, 16.0 )"];case Pa:return["RGBD","( value, 256.0 )"];case Ea:return["Gamma","( value, float( GAMMA_FACTOR ) )"];default:throw new Error("unsupported encoding: "+t)}}function ie(t,e){var n=ne(e);return"vec4 "+t+"( vec4 value ) { return "+n[0]+"ToLinear"+n[1]+"; }"}function re(t,e){var n=ne(e);return"vec4 "+t+"( vec4 value ) { return LinearTo"+n[0]+n[1]+"; }"}function oe(t,e){var n;switch(e){case So:n="Linear";break;case Eo:n="Reinhard";break;case Mo:n="Uncharted2";break;case To:n="OptimizedCineon";break;default:throw new Error("unsupported toneMapping: "+e)}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function ae(t,e,n){return[(t=t||{}).derivatives||e.envMapCubeUV||e.bumpMap||e.normalMap||e.flatShading?"#extension GL_OES_standard_derivatives : enable":"",(t.fragDepth||e.logarithmicDepthBuffer)&&n.get("EXT_frag_depth")?"#extension GL_EXT_frag_depth : enable":"",t.drawBuffers&&n.get("WEBGL_draw_buffers")?"#extension GL_EXT_draw_buffers : require":"",(t.shaderTextureLOD||e.envMap)&&n.get("EXT_shader_texture_lod")?"#extension GL_EXT_shader_texture_lod : enable":""].filter(ce).join("\n")}function se(t){var e=[];for(var n in t){var i=t[n];!1!==i&&e.push("#define "+n+" "+i)}return e.join("\n")}function le(t,e,n){for(var i={},r=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES),o=0;o<r;o++){var a=t.getActiveAttrib(e,o).name;i[a]=t.getAttribLocation(e,a)}return i}function ce(t){return""!==t}function he(t,e){return t.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights)}function ue(t){var e=/^[ \t]*#include +<([\w\d.]+)>/gm;return t.replace(e,function(t,e){var n=Ha[e];if(void 0===n)throw new Error("Can not resolve #include <"+e+">");return ue(n)})}function pe(t){var e=/for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g;return t.replace(e,function(t,e,n,i){for(var r="",o=parseInt(e);o<parseInt(n);o++)r+=i.replace(/\[ i \]/g,"[ "+o+" ]");return r})}function de(t,e,n,i,r,o){var a=t.context,s=i.defines,l=r.vertexShader,c=r.fragmentShader,h="SHADOWMAP_TYPE_BASIC";o.shadowMapType===Dr?h="SHADOWMAP_TYPE_PCF":o.shadowMapType===Or&&(h="SHADOWMAP_TYPE_PCF_SOFT");var u="ENVMAP_TYPE_CUBE",p="ENVMAP_MODE_REFLECTION",d="ENVMAP_BLENDING_MULTIPLY";if(o.envMap){switch(i.envMap.mapping){case Ao:case Po:u="ENVMAP_TYPE_CUBE";break;case Ro:case ko:u="ENVMAP_TYPE_CUBE_UV";break;case Io:case Co:u="ENVMAP_TYPE_EQUIREC";break;case Lo:u="ENVMAP_TYPE_SPHERE"}switch(i.envMap.mapping){case Po:case Co:p="ENVMAP_MODE_REFRACTION"}switch(i.combine){case vo:d="ENVMAP_BLENDING_MULTIPLY";break;case bo:d="ENVMAP_BLENDING_MIX";break;case wo:d="ENVMAP_BLENDING_ADD"}}var f,m,_=t.gammaFactor>0?t.gammaFactor:1,g=ae(i.extensions,o,e),y=se(s),v=a.createProgram();i.isRawShaderMaterial?(f=[y,"\n"].filter(ce).join("\n"),m=[g,y,"\n"].filter(ce).join("\n")):(f=["precision "+o.precision+" float;","precision "+o.precision+" int;","#define SHADER_NAME "+r.name,y,o.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+_,"#define MAX_BONES "+o.maxBones,o.useFog&&o.fog?"#define USE_FOG":"",o.useFog&&o.fogExp?"#define FOG_EXP2":"",o.map?"#define USE_MAP":"",o.envMap?"#define USE_ENVMAP":"",o.envMap?"#define "+p:"",o.lightMap?"#define USE_LIGHTMAP":"",o.aoMap?"#define USE_AOMAP":"",o.emissiveMap?"#define USE_EMISSIVEMAP":"",o.bumpMap?"#define USE_BUMPMAP":"",o.normalMap?"#define USE_NORMALMAP":"",o.displacementMap&&o.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",o.specularMap?"#define USE_SPECULARMAP":"",o.roughnessMap?"#define USE_ROUGHNESSMAP":"",o.metalnessMap?"#define USE_METALNESSMAP":"",o.alphaMap?"#define USE_ALPHAMAP":"",o.vertexColors?"#define USE_COLOR":"",o.flatShading?"#define FLAT_SHADED":"",o.skinning?"#define USE_SKINNING":"",o.useVertexTexture?"#define BONE_TEXTURE":"",o.morphTargets?"#define USE_MORPHTARGETS":"",o.morphNormals&&!1===o.flatShading?"#define USE_MORPHNORMALS":"",o.doubleSided?"#define DOUBLE_SIDED":"",o.flipSided?"#define FLIP_SIDED":"","#define NUM_CLIPPING_PLANES "+o.numClippingPlanes,o.shadowMapEnabled?"#define USE_SHADOWMAP":"",o.shadowMapEnabled?"#define "+h:"",o.sizeAttenuation?"#define USE_SIZEATTENUATION":"",o.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",o.logarithmicDepthBuffer&&e.get("EXT_frag_depth")?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_COLOR","\tattribute vec3 color;","#endif","#ifdef USE_MORPHTARGETS","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(ce).join("\n"),m=[g,"precision "+o.precision+" float;","precision "+o.precision+" int;","#define SHADER_NAME "+r.name,y,o.alphaTest?"#define ALPHATEST "+o.alphaTest:"","#define GAMMA_FACTOR "+_,o.useFog&&o.fog?"#define USE_FOG":"",o.useFog&&o.fogExp?"#define FOG_EXP2":"",o.map?"#define USE_MAP":"",o.envMap?"#define USE_ENVMAP":"",o.envMap?"#define "+u:"",o.envMap?"#define "+p:"",o.envMap?"#define "+d:"",o.lightMap?"#define USE_LIGHTMAP":"",o.aoMap?"#define USE_AOMAP":"",o.emissiveMap?"#define USE_EMISSIVEMAP":"",o.bumpMap?"#define USE_BUMPMAP":"",o.normalMap?"#define USE_NORMALMAP":"",o.specularMap?"#define USE_SPECULARMAP":"",o.roughnessMap?"#define USE_ROUGHNESSMAP":"",o.metalnessMap?"#define USE_METALNESSMAP":"",o.alphaMap?"#define USE_ALPHAMAP":"",o.vertexColors?"#define USE_COLOR":"",o.gradientMap?"#define USE_GRADIENTMAP":"",o.flatShading?"#define FLAT_SHADED":"",o.doubleSided?"#define DOUBLE_SIDED":"",o.flipSided?"#define FLIP_SIDED":"","#define NUM_CLIPPING_PLANES "+o.numClippingPlanes,"#define UNION_CLIPPING_PLANES "+(o.numClippingPlanes-o.numClipIntersection),o.shadowMapEnabled?"#define USE_SHADOWMAP":"",o.shadowMapEnabled?"#define "+h:"",o.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",o.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",o.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",o.logarithmicDepthBuffer&&e.get("EXT_frag_depth")?"#define USE_LOGDEPTHBUF_EXT":"",o.envMap&&e.get("EXT_shader_texture_lod")?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;",o.toneMapping!==xo?"#define TONE_MAPPING":"",o.toneMapping!==xo?Ha.tonemapping_pars_fragment:"",o.toneMapping!==xo?oe("toneMapping",o.toneMapping):"",o.dithering?"#define DITHERING":"",o.outputEncoding||o.mapEncoding||o.envMapEncoding||o.emissiveMapEncoding?Ha.encodings_pars_fragment:"",o.mapEncoding?ie("mapTexelToLinear",o.mapEncoding):"",o.envMapEncoding?ie("envMapTexelToLinear",o.envMapEncoding):"",o.emissiveMapEncoding?ie("emissiveMapTexelToLinear",o.emissiveMapEncoding):"",o.outputEncoding?re("linearToOutputTexel",o.outputEncoding):"",o.depthPacking?"#define DEPTH_PACKING "+i.depthPacking:"","\n"].filter(ce).join("\n")),l=he(l=ue(l),o),c=h