!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.THREE={})}(this,function(e){"use strict";function t(){}function r(e,t){this.x=e||0,this.y=t||0}function n(){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 i(e,t,r,n){this._x=e||0,this._y=t||0,this._z=r||0,this._w=void 0!==n?n:1}function o(e,t,r){this.x=e||0,this.y=t||0,this.z=r||0}function a(){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 s(e,t,n,i,o,c,h,l,u,p){Object.defineProperty(this,"id",{value:Ac++}),this.uuid=Sc.generateUUID(),this.name="",this.image=void 0!==e?e:s.DEFAULT_IMAGE,this.mipmaps=[],this.mapping=void 0!==t?t:s.DEFAULT_MAPPING,this.wrapS=void 0!==n?n:ss,this.wrapT=void 0!==i?i:ss,this.magFilter=void 0!==o?o:ps,this.minFilter=void 0!==c?c:fs,this.anisotropy=void 0!==u?u:1,this.format=void 0!==h?h:Ls,this.type=void 0!==l?l:ms,this.offset=new r(0,0),this.repeat=new r(1,1),this.center=new r(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new a,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=void 0!==p?p:vc,this.version=0,this.onUpdate=null}function c(e,t,r,n){this.x=e||0,this.y=t||0,this.z=r||0,this.w=void 0!==n?n:1}function h(e,t,r){this.width=e,this.height=t,this.scissor=new c(0,0,e,t),this.scissorTest=!1,this.viewport=new c(0,0,e,t),r=r||{},void 0===r.minFilter&&(r.minFilter=ps),this.texture=new s((void 0),(void 0),r.wrapS,r.wrapT,r.magFilter,r.minFilter,r.format,r.type,r.anisotropy,r.encoding),this.depthBuffer=void 0===r.depthBuffer||r.depthBuffer,this.stencilBuffer=void 0===r.stencilBuffer||r.stencilBuffer,this.depthTexture=void 0!==r.depthTexture?r.depthTexture:null}function l(e,t,r){h.call(this,e,t,r),this.activeCubeFace=0,this.activeMipMapLevel=0}function u(e,t,r,n,i,o,a,c,h,l,u,p){s.call(this,null,o,a,c,h,l,n,i,u,p),this.image={data:e,width:t,height:r},this.magFilter=void 0!==h?h:hs,this.minFilter=void 0!==l?l:hs,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}function p(e,t){this.min=void 0!==e?e:new o((+(1/0)),(+(1/0)),(+(1/0))),this.max=void 0!==t?t:new o((-(1/0)),(-(1/0)),(-(1/0)))}function d(e,t){this.center=void 0!==e?e:new o,this.radius=void 0!==t?t:0}function f(e,t){this.normal=void 0!==e?e:new o(1,0,0),this.constant=void 0!==t?t:0}function m(e,t,r,n,i,o){this.planes=[void 0!==e?e:new f,void 0!==t?t:new f,void 0!==r?r:new f,void 0!==n?n:new f,void 0!==i?i:new f,void 0!==o?o:new f]}function v(e,t,r){return void 0===t&&void 0===r?this.set(e):this.setRGB(e,t,r)}function g(e){function t(t,r){var n=t.array,i=t.dynamic?e.DYNAMIC_DRAW:e.STATIC_DRAW,o=e.createBuffer();e.bindBuffer(r,o),e.bufferData(r,n,i),t.onUploadCallback();var a=e.FLOAT;return n instanceof Float32Array?a=e.FLOAT:n instanceof Float64Array?console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array."):n instanceof Uint16Array?a=e.UNSIGNED_SHORT:n instanceof Int16Array?a=e.SHORT:n instanceof Uint32Array?a=e.UNSIGNED_INT:n instanceof Int32Array?a=e.INT:n instanceof Int8Array?a=e.BYTE:n instanceof Uint8Array&&(a=e.UNSIGNED_BYTE),{buffer:o,type:a,bytesPerElement:n.BYTES_PER_ELEMENT,version:t.version}}function r(t,r,n){var i=r.array,o=r.updateRange;e.bindBuffer(n,t),r.dynamic===!1?e.bufferData(n,i,e.STATIC_DRAW):o.count===-1?e.bufferSubData(n,0,i):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."):(e.bufferSubData(n,o.offset*i.BYTES_PER_ELEMENT,i.subarray(o.offset,o.offset+o.count)),o.count=-1)}function n(e){return e.isInterleavedBufferAttribute&&(e=e.data),a.get(e)}function i(t){t.isInterleavedBufferAttribute&&(t=t.data);var r=a.get(t);r&&(e.deleteBuffer(r.buffer),a["delete"](t))}function o(e,n){e.isInterleavedBufferAttribute&&(e=e.data);var i=a.get(e);void 0===i?a.set(e,t(e,n)):i.versiont&&(t=e[r]);return t}function B(){Object.defineProperty(this,"id",{value:Fl+=2}),this.uuid=Sc.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 H(e,t,r,n,i,o){M.call(this),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:r,widthSegments:n,heightSegments:i,depthSegments:o},this.fromBufferGeometry(new z(e,t,r,n,i,o)),this.mergeVertices()}function z(e,t,r,n,i,a){function s(e,t,r,n,i,a,s,m,v,g,y){var x,b,w=a/v,_=s/g,E=a/2,M=s/2,T=m/2,S=v+1,A=g+1,R=0,L=0,P=new o;for(b=0;b0?1:-1,u.push(P.x,P.y,P.z),p.push(x/v),p.push(1-b/g),R+=1}}for(b=0;b0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";t="mediump"}return"mediump"===t&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}var o,a=void 0!==r.precision?r.precision:"highp",s=i(a);s!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",s,"instead."),a=s);var c=r.logarithmicDepthBuffer===!0,h=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),l=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),u=e.getParameter(e.MAX_TEXTURE_SIZE),p=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),d=e.getParameter(e.MAX_VERTEX_ATTRIBS),f=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),m=e.getParameter(e.MAX_VARYING_VECTORS),v=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),g=l>0,y=!!t.get("OES_texture_float"),x=g&&y;return{getMaxAnisotropy:n,getMaxPrecision:i,precision:a,logarithmicDepthBuffer:c,maxTextures:h,maxVertexTextures:l,maxTextureSize:u,maxCubemapSize:p,maxAttributes:d,maxVertexUniforms:f,maxVaryings:m,maxFragmentUniforms:v,vertexTextures:g,floatFragmentTextures:y,floatVertexTextures:x}}function K(){function e(){l.value!==n&&(l.value=n,l.needsUpdate=i>0),r.numPlanes=i,r.numIntersection=0}function t(e,t,n,i){var o=null!==e?e.length:0,a=null;if(0!==o){if(a=l.value,i!==!0||null===a){var s=n+4*o,u=t.matrixWorldInverse;h.getNormalMatrix(u),(null===a||a.length65535?O:P)(i,1),t.update(n,e.ELEMENT_ARRAY_BUFFER),c[r.id]=n,n}var s={},c={};return{get:i,update:o,getWireframeAttribute:a}}function te(e,t,r){function n(e){s=e}function i(e){c=e.type,h=e.bytesPerElement}function o(t,n){e.drawElements(s,n,c,t*h),r.update(n,s)}function a(e,n,i){var o=t.get("ANGLE_instanced_arrays");return null===o?void console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays."):(o.drawElementsInstancedANGLE(s,i,c,n*h,e.maxInstancedCount),void r.update(i,s,e.maxInstancedCount))}var s,c,h;this.setMode=n,this.setIndex=i,this.render=o,this.renderInstances=a}function re(e){function t(t,r,n){switch(n=n||1,i.calls++,r){case e.TRIANGLES:i.triangles+=n*(t/3);break;case e.TRIANGLE_STRIP:case e.TRIANGLE_FAN:i.triangles+=n*(t-2);break;case e.LINES:i.lines+=n*(t/2);break;case e.LINE_STRIP:i.lines+=n*(t-1);break;case e.LINE_LOOP:i.lines+=n*t;break;case e.POINTS:i.points+=n*t;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",r)}}function r(){i.frame++,i.calls=0,i.triangles=0,i.points=0,i.lines=0}var n={geometries:0,textures:0},i={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:n,render:i,programs:null,autoReset:!0,reset:r,update:t}}function ne(e,t){return Math.abs(t[1])-Math.abs(e[1])}function ie(e){function t(t,i,o,a){var s=t.morphTargetInfluences,c=s.length,h=r[i.id];if(void 0===h){h=[];for(var l=0;l0)return e;var i=t*r,o=kl[i];if(void 0===o&&(o=new Float32Array(i),kl[i]=o),0!==t){n.toArray(o,0);for(var a=1,s=0;a!==t;++a)s+=r,e[a].toArray(o,s)}return o}function he(e,t){var r=Wl[t];void 0===r&&(r=new Int32Array(t),Wl[t]=r);for(var n=0;n!==t;++n)r[n]=e.allocTextureUnit();return r}function le(e,t){e.uniform1f(this.addr,t)}function ue(e,t){e.uniform1i(this.addr,t)}function pe(e,t){void 0===t.x?e.uniform2fv(this.addr,t):e.uniform2f(this.addr,t.x,t.y)}function de(e,t){void 0!==t.x?e.uniform3f(this.addr,t.x,t.y,t.z):void 0!==t.r?e.uniform3f(this.addr,t.r,t.g,t.b):e.uniform3fv(this.addr,t)}function fe(e,t){void 0===t.x?e.uniform4fv(this.addr,t):e.uniform4f(this.addr,t.x,t.y,t.z,t.w)}function me(e,t){e.uniformMatrix2fv(this.addr,!1,t.elements||t)}function ve(e,t){void 0===t.elements?e.uniformMatrix3fv(this.addr,!1,t):(ql.set(t.elements),e.uniformMatrix3fv(this.addr,!1,ql))}function ge(e,t){void 0===t.elements?e.uniformMatrix4fv(this.addr,!1,t):(Xl.set(t.elements),e.uniformMatrix4fv(this.addr,!1,Xl))}function ye(e,t,r){var n=r.allocTextureUnit();e.uniform1i(this.addr,n),r.setTexture2D(t||Vl,n)}function xe(e,t,r){var n=r.allocTextureUnit();e.uniform1i(this.addr,n),r.setTextureCube(t||jl,n)}function be(e,t){e.uniform2iv(this.addr,t)}function we(e,t){e.uniform3iv(this.addr,t)}function _e(e,t){e.uniform4iv(this.addr,t)}function Ee(e){switch(e){case 5126:return le;case 35664:return pe;case 35665:return de;case 35666:return fe;case 35674:return me;case 35675:return ve;case 35676:return ge;case 35678:case 36198:return ye;case 35680:return xe;case 5124:case 35670:return ue;case 35667:case 35671:return be;case 35668:case 35672:return we;case 35669:case 35673:return _e}}function Me(e,t){e.uniform1fv(this.addr,t)}function Te(e,t){e.uniform1iv(this.addr,t)}function Se(e,t){e.uniform2fv(this.addr,ce(t,this.size,2))}function Ae(e,t){e.uniform3fv(this.addr,ce(t,this.size,3))}function Re(e,t){e.uniform4fv(this.addr,ce(t,this.size,4))}function Le(e,t){e.uniformMatrix2fv(this.addr,!1,ce(t,this.size,4))}function Pe(e,t){e.uniformMatrix3fv(this.addr,!1,ce(t,this.size,9))}function Ce(e,t){e.uniformMatrix4fv(this.addr,!1,ce(t,this.size,16))}function Oe(e,t,r){var n=t.length,i=he(r,n);e.uniform1iv(this.addr,i);for(var o=0;o!==n;++o)r.setTexture2D(t[o]||Vl,i[o])}function Ie(e,t,r){var n=t.length,i=he(r,n);e.uniform1iv(this.addr,i);for(var o=0;o!==n;++o)r.setTextureCube(t[o]||jl,i[o])}function Ne(e){switch(e){case 5126:return Me;case 35664:return Se;case 35665:return Ae;case 35666:return Re;case 35674:return Le;case 35675:return Pe;case 35676:return Ce;case 35678:return Oe;case 35680:return Ie;case 5124:case 35670:return Te;case 35667:case 35671:return be;case 35668:case 35672:return we;case 35669:case 35673:return _e}}function De(e,t,r){this.id=e,this.addr=r,this.setValue=Ee(t.type)}function Ue(e,t,r){this.id=e,this.addr=r,this.size=t.size,this.setValue=Ne(t.type)}function Be(e){this.id=e,se.call(this)}function He(e,t){e.seq.push(t),e.map[t.id]=t}function ze(e,t,r){var n=e.name,i=n.length;for(Yl.lastIndex=0;;){var o=Yl.exec(n),a=Yl.lastIndex,s=o[1],c="]"===o[2],h=o[3];if(c&&(s=0|s),void 0===h||"["===h&&a+2===i){He(r,void 0===h?new De(s,e,t):new Ue(s,e,t));break}var l=r.map,u=l[s];void 0===u&&(u=new Be(s),He(r,u)),r=u}}function Fe(e,t,r){se.call(this),this.renderer=r;for(var n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS),i=0;i");return $e(r)}var r=/^[ \t]*#include +<([\w\d.]+)>/gm;return e.replace(r,t)}function et(e){function t(e,t,r,n){for(var i="",o=parseInt(t);o0?e.gammaFactor:1,g=qe(n.extensions,o,t),y=Ye(s),x=a.createProgram();n.isRawShaderMaterial?(f=[y].filter(Je).join("\n"),f.length>0&&(f+="\n"),m=[g,y].filter(Je).join("\n"),m.length>0&&(m+="\n")):(f=["precision "+o.precision+" float;","precision "+o.precision+" int;","#define SHADER_NAME "+i.name,y,o.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+v,"#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&&o.flatShading===!1?"#define USE_MORPHNORMALS":"",o.doubleSided?"#define DOUBLE_SIDED":"",o.flipSided?"#define FLIP_SIDED":"",o.shadowMapEnabled?"#define USE_SHADOWMAP":"",o.shadowMapEnabled?"#define "+l:"",o.sizeAttenuation?"#define USE_SIZEATTENUATION":"",o.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",o.logarithmicDepthBuffer&&t.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(Je).join("\n"),m=[g,"precision "+o.precision+" float;","precision "+o.precision+" int;","#define SHADER_NAME "+i.name,y,o.alphaTest?"#define ALPHATEST "+o.alphaTest:"","#define GAMMA_FACTOR "+v,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":"",o.shadowMapEnabled?"#define USE_SHADOWMAP":"",o.shadowMapEnabled?"#define "+l:"",o.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",o.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",o.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",o.logarithmicDepthBuffer&&t.get("EXT_frag_depth")?"#define USE_LOGDEPTHBUF_EXT":"",o.envMap&&t.get("EXT_shader_texture_lod")?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;",o.toneMapping!==qa?"#define TONE_MAPPING":"",o.toneMapping!==qa?Il.tonemapping_pars_fragment:"",o.toneMapping!==qa?Xe("toneMapping",o.toneMapping):"",o.dithering?"#define DITHERING":"",o.outputEncoding||o.mapEncoding||o.envMapEncoding||o.emissiveMapEncoding?Il.encodings_pars_fragment:"",o.mapEncoding?ke("mapTexelToLinear",o.mapEncoding):"",o.envMapEncoding?ke("envMapTexelToLinear",o.envMapEncoding):"",o.emissiveMapEncoding?ke("emissiveMapTexelToLinear",o.emissiveMapEncoding):"",o.outputEncoding?We("linearToOutputTexel",o.outputEncoding):"",o.depthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(Je).join("\n")), c=$e(c),c=Qe(c,o),c=Ke(c,o),h=$e(h),h=Qe(h,o),h=Ke(h,o),c=et(c),h=et(h);var b=f+c,w=m+h,_=Ve(a,a.VERTEX_SHADER,b),E=Ve(a,a.FRAGMENT_SHADER,w);a.attachShader(x,_),a.attachShader(x,E),void 0!==n.index0AttributeName?a.bindAttribLocation(x,0,n.index0AttributeName):o.morphTargets===!0&&a.bindAttribLocation(x,0,"position"),a.linkProgram(x);var M=a.getProgramInfoLog(x).trim(),T=a.getShaderInfoLog(_).trim(),S=a.getShaderInfoLog(E).trim(),A=!0,R=!0;a.getProgramParameter(x,a.LINK_STATUS)===!1?(A=!1,console.error("THREE.WebGLProgram: shader error: ",a.getError(),"gl.VALIDATE_STATUS",a.getProgramParameter(x,a.VALIDATE_STATUS),"gl.getProgramInfoLog",M,T,S)):""!==M?console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",M):""!==T&&""!==S||(R=!1),R&&(this.diagnostics={runnable:A,material:n,programLog:M,vertexShader:{log:T,prefix:f},fragmentShader:{log:S,prefix:m}}),a.deleteShader(_),a.deleteShader(E);var L;this.getUniforms=function(){return void 0===L&&(L=new Fe(a,x,e)),L};var P;return this.getAttributes=function(){return void 0===P&&(P=Ze(a,x)),P},this.destroy=function(){a.deleteProgram(x),this.program=void 0},Object.defineProperties(this,{uniforms:{get:function(){return console.warn("THREE.WebGLProgram: .uniforms is now .getUniforms()."),this.getUniforms()}},attributes:{get:function(){return console.warn("THREE.WebGLProgram: .attributes is now .getAttributes()."),this.getAttributes()}}}),this.name=i.name,this.id=Zl++,this.code=r,this.usedTimes=1,this.program=x,this.vertexShader=_,this.fragmentShader=E,this}function rt(e,t,r){function n(e){var t=e.skeleton,n=t.bones;if(r.floatVertexTextures)return 1024;var i=r.maxVertexUniforms,o=Math.floor((i-20)/4),a=Math.min(o,n.length);return a0,maxBones:d,useVertexTexture:r.floatVertexTextures,morphTargets:t.morphTargets,morphNormals:t.morphNormals,maxMorphTargets:e.maxMorphTargets,maxMorphNormals:e.maxMorphNormals,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numClippingPlanes:h,numClipIntersection:l,dithering:t.dithering,shadowMapEnabled:e.shadowMap.enabled&&u.receiveShadow&&s.length>0,shadowMapType:e.shadowMap.type,toneMapping:e.toneMapping,physicallyCorrectLights:e.physicallyCorrectLights,premultipliedAlpha:t.premultipliedAlpha,alphaTest:t.alphaTest,doubleSided:t.side===ca,flipSided:t.side===sa,depthPacking:void 0!==t.depthPacking&&t.depthPacking};return v},this.getProgramCode=function(t,r){var n=[];if(r.shaderID?n.push(r.shaderID):(n.push(t.fragmentShader),n.push(t.vertexShader)),void 0!==t.defines)for(var i in t.defines)n.push(i),n.push(t.defines[i]);for(var o=0;o1&&o.sort(it),a.length>1&&a.sort(ot)}var n=[],i=0,o=[],a=[];return{opaque:o,transparent:a,init:e,push:t,sort:r}}function st(){function e(e,t){var n=e.id+","+t.id,i=r[n];return void 0===i&&(i=new at,r[n]=i),i}function t(){r={}}var r={};return{get:e,dispose:t}}function ct(){var e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];var n;switch(t.type){case"DirectionalLight":n={direction:new o,color:new v,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new r};break;case"SpotLight":n={position:new o,direction:new o,color:new v,distance:0,coneCos:0,penumbraCos:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new r};break;case"PointLight":n={position:new o,color:new v,distance:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new r,shadowCameraNear:1,shadowCameraFar:1e3};break;case"HemisphereLight":n={direction:new o,skyColor:new v,groundColor:new v};break;case"RectAreaLight":n={color:new v,position:new o,halfWidth:new o,halfHeight:new o}}return e[t.id]=n,n}}}function ht(){function e(e,n,o){for(var c=0,h=0,l=0,u=0,p=0,d=0,f=0,m=0,v=o.matrixWorldInverse,g=0,y=e.length;g0:s&&s.isGeometry&&(u=s.morphTargets&&s.morphTargets.length>0)),t.isSkinnedMesh&&r.skinning===!1&&console.warn("THREE.WebGLShadowMap: THREE.SkinnedMesh with material.skinning set to false:",t);var p=t.isSkinnedMesh&&r.skinning,d=0;u&&(d|=g),p&&(d|=y),c=h[d]}if(e.localClippingEnabled&&r.clipShadows===!0&&0!==r.clippingPlanes.length){var f=c.uuid,m=r.uuid,v=_[f];void 0===v&&(v={},_[f]=v);var x=v[m];void 0===x&&(x=c.clone(),v[m]=x),c=x}return c.visible=r.visible,c.wireframe=r.wireframe,c.side=null!=r.shadowSide?r.shadowSide:E[r.side],c.clipShadows=r.clipShadows,c.clippingPlanes=r.clippingPlanes,c.clipIntersection=r.clipIntersection,c.wireframeLinewidth=r.wireframeLinewidth,c.linewidth=r.linewidth,n&&c.isMeshDistanceMaterial&&(c.referencePosition.copy(i),c.nearDistance=o,c.farDistance=a),c}function s(r,n,i,o){if(r.visible!==!1){var c=r.layers.test(n.layers);if(c&&(r.isMesh||r.isLine||r.isPoints)&&r.castShadow&&(!r.frustumCulled||l.intersectsObject(r))){r.modelViewMatrix.multiplyMatrices(i.matrixWorldInverse,r.matrixWorld);var h=t.update(r),u=r.material;if(Array.isArray(u))for(var p=h.groups,d=0,f=p.length;d 0 ) {","\t\tfloat fogFactor = 0.0;","\t\tif ( fogType == 1 ) {","\t\t\tfogFactor = smoothstep( fogNear, fogFar, fogDepth );","\t\t} else {","\t\t\tconst float LOG2 = 1.442695;","\t\t\tfogFactor = exp2( - fogDensity * fogDensity * fogDepth * fogDepth * LOG2 );","\t\t\tfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );","\t\t}","\t\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );","\t}","}"].join("\n")),t.compileShader(r),t.compileShader(n),t.attachShader(e,r),t.attachShader(e,n),t.linkProgram(e),e}function h(e,t){return e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:t.id-e.id}var l,u,p,d,f,m,v=new o,g=new i,y=new o;this.render=function(i,o,a){if(0!==i.length){void 0===p&&s(),r.useProgram(p),r.initAttributes(),r.enableAttribute(d.position),r.enableAttribute(d.uv),r.disableUnusedAttributes(),r.disable(t.CULL_FACE),r.enable(t.BLEND),t.bindBuffer(t.ARRAY_BUFFER,l),t.vertexAttribPointer(d.position,2,t.FLOAT,!1,16,0),t.vertexAttribPointer(d.uv,2,t.FLOAT,!1,16,8),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,u),t.uniformMatrix4fv(f.projectionMatrix,!1,a.projectionMatrix.elements),r.activeTexture(t.TEXTURE0),t.uniform1i(f.map,0);var c=0,x=0,b=o.fog;b?(t.uniform3f(f.fogColor,b.color.r,b.color.g,b.color.b),b.isFog?(t.uniform1f(f.fogNear,b.near),t.uniform1f(f.fogFar,b.far),t.uniform1i(f.fogType,1),c=1,x=1):b.isFogExp2&&(t.uniform1f(f.fogDensity,b.density),t.uniform1i(f.fogType,2),c=2,x=2)):(t.uniform1i(f.fogType,0),c=0,x=0);for(var w=0,_=i.length;w<_;w++){var E=i[w];E.modelViewMatrix.multiplyMatrices(a.matrixWorldInverse,E.matrixWorld),E.z=-E.modelViewMatrix.elements[14]}i.sort(h);for(var M=[],T=[],w=0,_=i.length;w<_;w++){var E=i[w],S=E.material;if(S.visible!==!1){E.onBeforeRender(e,o,a,void 0,S,void 0),t.uniform1f(f.alphaTest,S.alphaTest),t.uniformMatrix4fv(f.modelViewMatrix,!1,E.modelViewMatrix.elements),E.matrixWorld.decompose(v,g,y),M[0]=y.x,M[1]=y.y,T[0]=E.center.x-.5,T[1]=E.center.y-.5;var A=0;o.fog&&S.fog&&(A=x),c!==A&&(t.uniform1i(f.fogType,A),c=A),null!==S.map?(t.uniform2f(f.uvOffset,S.map.offset.x,S.map.offset.y),t.uniform2f(f.uvScale,S.map.repeat.x,S.map.repeat.y)):(t.uniform2f(f.uvOffset,0,0),t.uniform2f(f.uvScale,1,1)),t.uniform1f(f.opacity,S.opacity),t.uniform3f(f.color,S.color.r,S.color.g,S.color.b),t.uniform1f(f.rotation,S.rotation),t.uniform2fv(f.center,T),t.uniform2fv(f.scale,M),r.setBlending(S.blending,S.blendEquation,S.blendSrc,S.blendDst,S.blendEquationAlpha,S.blendSrcAlpha,S.blendDstAlpha,S.premultipliedAlpha),r.buffers.depth.setTest(S.depthTest),r.buffers.depth.setMask(S.depthWrite),r.buffers.color.setMask(S.colorWrite),n.setTexture2D(S.map||m,0),t.drawElements(t.TRIANGLES,6,t.UNSIGNED_SHORT,0),E.onAfterRender(e,o,a,void 0,S,void 0)}}r.enable(t.CULL_FACE),r.reset()}}}function gt(e,t,r){function n(){var t=!1,r=new c,n=null,i=new c(0,0,0,0);return{setMask:function(r){n===r||t||(e.colorMask(r,r,r,r),n=r)},setLocked:function(e){t=e},setClear:function(t,n,o,a,s){s===!0&&(t*=a,n*=a,o*=a),r.set(t,n,o,a),i.equals(r)===!1&&(e.clearColor(t,n,o,a),i.copy(r))},reset:function(){t=!1,n=null,i.set(-1,0,0,0)}}}function i(){var t=!1,r=null,n=null,i=null;return{setTest:function(t){t?p(e.DEPTH_TEST):d(e.DEPTH_TEST)},setMask:function(n){r===n||t||(e.depthMask(n),r=n)},setFunc:function(t){if(n!==t){if(t)switch(t){case Ua:e.depthFunc(e.NEVER);break;case Ba:e.depthFunc(e.ALWAYS);break;case Ha:e.depthFunc(e.LESS);break;case za:e.depthFunc(e.LEQUAL);break;case Fa:e.depthFunc(e.EQUAL);break;case Ga:e.depthFunc(e.GEQUAL);break;case Va:e.depthFunc(e.GREATER);break;case ja:e.depthFunc(e.NOTEQUAL);break;default:e.depthFunc(e.LEQUAL)}else e.depthFunc(e.LEQUAL);n=t}},setLocked:function(e){t=e},setClear:function(t){i!==t&&(e.clearDepth(t),i=t)},reset:function(){t=!1,r=null,n=null,i=null}}}function o(){var t=!1,r=null,n=null,i=null,o=null,a=null,s=null,c=null,h=null;return{setTest:function(t){t?p(e.STENCIL_TEST):d(e.STENCIL_TEST)},setMask:function(n){r===n||t||(e.stencilMask(n),r=n)},setFunc:function(t,r,a){n===t&&i===r&&o===a||(e.stencilFunc(t,r,a),n=t,i=r,o=a)},setOp:function(t,r,n){a===t&&s===r&&c===n||(e.stencilOp(t,r,n),a=t,s=r,c=n)},setLocked:function(e){t=e},setClear:function(t){h!==t&&(e.clearStencil(t),h=t)},reset:function(){t=!1,r=null,n=null,i=null,o=null,a=null,s=null,c=null,h=null}}}function a(t,r,n){var i=new Uint8Array(4),o=e.createTexture();e.bindTexture(t,o),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(var a=0;a=1):re.indexOf("OpenGL ES")!==-1&&(te=parseFloat(/^OpenGL\ ES\ ([0-9])/.exec(re)[1]),ee=te>=2);var ne=null,ie={},oe=new c,ae=new c,se={};return se[e.TEXTURE_2D]=a(e.TEXTURE_2D,e.TEXTURE_2D,1),se[e.TEXTURE_CUBE_MAP]=a(e.TEXTURE_CUBE_MAP,e.TEXTURE_CUBE_MAP_POSITIVE_X,6),P.setClear(0,0,0,1),C.setClear(1),O.setClear(0),p(e.DEPTH_TEST),C.setFunc(za),y(!1),x(Ko),p(e.CULL_FACE),p(e.BLEND),v(ma),{buffers:{color:P,depth:C,stencil:O},initAttributes:s,enableAttribute:h,enableAttributeAndDivisor:l,disableUnusedAttributes:u,enable:p,disable:d,getCompressedTextureFormats:f,useProgram:m,setBlending:v,setMaterial:g,setFlipSided:y,setCullFace:x,setLineWidth:b,setPolygonOffset:w,setScissorTest:_,activeTexture:E,bindTexture:M,compressedTexImage2D:T,texImage2D:S,scissor:A,viewport:R,reset:L}}function yt(e,t,r,n,i,o,a){function s(e,t){if(e.width>t||e.height>t){if("data"in e)return void console.warn("THREE.WebGLRenderer: image in DataTexture is too big ("+e.width+"x"+e.height+").");var r=t/Math.max(e.width,e.height),n=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");n.width=Math.floor(e.width*r),n.height=Math.floor(e.height*r);var i=n.getContext("2d");return i.drawImage(e,0,0,e.width,e.height,0,0,n.width,n.height),console.warn("THREE.WebGLRenderer: image is too big ("+e.width+"x"+e.height+"). Resized to "+n.width+"x"+n.height,e),n}return e}function c(e){return Sc.isPowerOfTwo(e.width)&&Sc.isPowerOfTwo(e.height)}function h(e){if(e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof ImageBitmap){void 0===P&&(P=document.createElementNS("http://www.w3.org/1999/xhtml","canvas")),P.width=Sc.floorPowerOfTwo(e.width),P.height=Sc.floorPowerOfTwo(e.height);var t=P.getContext("2d");return t.drawImage(e,0,0,P.width,P.height),console.warn("THREE.WebGLRenderer: image is not power of two ("+e.width+"x"+e.height+"). Resized to "+P.width+"x"+P.height,e),P}return e}function l(e){return e.wrapS!==ss||e.wrapT!==ss||e.minFilter!==hs&&e.minFilter!==ps}function u(e,t){return e.generateMipmaps&&t&&e.minFilter!==hs&&e.minFilter!==ps}function p(t,r,i,o){e.generateMipmap(t);var a=n.get(r);a.__maxMipLevel=Math.log(Math.max(i,o))*Math.LOG2E}function d(t){return t===hs||t===ls||t===us?e.NEAREST:e.LINEAR}function f(e){var t=e.target;t.removeEventListener("dispose",f),v(t),t.isVideoTexture&&delete O[t.id],a.memory.textures--}function m(e){var t=e.target;t.removeEventListener("dispose",m),g(t),a.memory.textures--}function v(t){var r=n.get(t);if(t.image&&r.__image__webglTextureCube)e.deleteTexture(r.__image__webglTextureCube);else{if(void 0===r.__webglInit)return;e.deleteTexture(r.__webglTexture)}n.remove(t)}function g(t){var r=n.get(t),i=n.get(t.texture);if(t){if(void 0!==i.__webglTexture&&e.deleteTexture(i.__webglTexture),t.depthTexture&&t.depthTexture.dispose(),t.isWebGLRenderTargetCube)for(var o=0;o<6;o++)e.deleteFramebuffer(r.__webglFramebuffer[o]),r.__webglDepthbuffer&&e.deleteRenderbuffer(r.__webglDepthbuffer[o]);else e.deleteFramebuffer(r.__webglFramebuffer),r.__webglDepthbuffer&&e.deleteRenderbuffer(r.__webglDepthbuffer);n.remove(t.texture),n.remove(t)}}function y(t,i){var o=n.get(t);if(t.isVideoTexture&&L(t),t.version>0&&o.__version!==t.version){var a=t.image;if(void 0===a)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined",t);else{if(a.complete!==!1)return void _(o,t,i);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete",t)}}r.activeTexture(e.TEXTURE0+i),r.bindTexture(e.TEXTURE_2D,o.__webglTexture)}function x(t,h){var l=n.get(t);if(6===t.image.length)if(t.version>0&&l.__version!==t.version){l.__image__webglTextureCube||(t.addEventListener("dispose",f),l.__image__webglTextureCube=e.createTexture(),a.memory.textures++),r.activeTexture(e.TEXTURE0+h),r.bindTexture(e.TEXTURE_CUBE_MAP,l.__image__webglTextureCube),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,t.flipY);for(var d=t&&t.isCompressedTexture,m=t.image[0]&&t.image[0].isDataTexture,v=[],g=0;g<6;g++)d||m?v[g]=m?t.image[g].image:t.image[g]:v[g]=s(t.image[g],i.maxCubemapSize);var y=v[0],x=c(y),b=o.convert(t.format),_=o.convert(t.type);w(e.TEXTURE_CUBE_MAP,t,x);for(var g=0;g<6;g++)if(d)for(var E,M=v[g].mipmaps,T=0,S=M.length;T-1?r.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+g,T,b,E.width,E.height,0,E.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):r.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+g,T,b,E.width,E.height,0,b,_,E.data);else m?r.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+g,0,b,v[g].width,v[g].height,0,b,_,v[g].data):r.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+g,0,b,b,_,v[g]);d?l.__maxMipLevel=M.length-1:l.__maxMipLevel=0,u(t,x)&&p(e.TEXTURE_CUBE_MAP,t,y.width,y.height),l.__version=t.version,t.onUpdate&&t.onUpdate(t)}else r.activeTexture(e.TEXTURE0+h),r.bindTexture(e.TEXTURE_CUBE_MAP,l.__image__webglTextureCube); }function b(t,i){r.activeTexture(e.TEXTURE0+i),r.bindTexture(e.TEXTURE_CUBE_MAP,n.get(t).__webglTexture)}function w(r,a,s){var c;if(s?(e.texParameteri(r,e.TEXTURE_WRAP_S,o.convert(a.wrapS)),e.texParameteri(r,e.TEXTURE_WRAP_T,o.convert(a.wrapT)),e.texParameteri(r,e.TEXTURE_MAG_FILTER,o.convert(a.magFilter)),e.texParameteri(r,e.TEXTURE_MIN_FILTER,o.convert(a.minFilter))):(e.texParameteri(r,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(r,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),a.wrapS===ss&&a.wrapT===ss||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping.",a),e.texParameteri(r,e.TEXTURE_MAG_FILTER,d(a.magFilter)),e.texParameteri(r,e.TEXTURE_MIN_FILTER,d(a.minFilter)),a.minFilter!==hs&&a.minFilter!==ps&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.",a)),c=t.get("EXT_texture_filter_anisotropic")){if(a.type===ws&&null===t.get("OES_texture_float_linear"))return;if(a.type===_s&&null===t.get("OES_texture_half_float_linear"))return;(a.anisotropy>1||n.get(a).__currentAnisotropy)&&(e.texParameterf(r,c.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,i.getMaxAnisotropy())),n.get(a).__currentAnisotropy=a.anisotropy)}}function _(t,n,d){void 0===t.__webglInit&&(t.__webglInit=!0,n.addEventListener("dispose",f),t.__webglTexture=e.createTexture(),a.memory.textures++),r.activeTexture(e.TEXTURE0+d),r.bindTexture(e.TEXTURE_2D,t.__webglTexture),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,n.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,n.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,n.unpackAlignment);var m=s(n.image,i.maxTextureSize);l(n)&&c(m)===!1&&(m=h(m));var v=c(m),g=o.convert(n.format),y=o.convert(n.type);w(e.TEXTURE_2D,n,v);var x,b=n.mipmaps;if(n.isDepthTexture){var _=e.DEPTH_COMPONENT;if(n.type===ws){if(!C)throw new Error("Float Depth Texture only supported in WebGL2.0");_=e.DEPTH_COMPONENT32F}else C&&(_=e.DEPTH_COMPONENT16);n.format===Is&&_===e.DEPTH_COMPONENT&&n.type!==ys&&n.type!==bs&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),n.type=ys,y=o.convert(n.type)),n.format===Ns&&(_=e.DEPTH_STENCIL,n.type!==Ss&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),n.type=Ss,y=o.convert(n.type))),r.texImage2D(e.TEXTURE_2D,0,_,m.width,m.height,0,g,y,null)}else if(n.isDataTexture)if(b.length>0&&v){for(var E=0,M=b.length;E-1?r.compressedTexImage2D(e.TEXTURE_2D,E,g,x.width,x.height,0,x.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):r.texImage2D(e.TEXTURE_2D,E,g,x.width,x.height,0,g,y,x.data);t.__maxMipLevel=b.length-1}else if(b.length>0&&v){for(var E=0,M=b.length;E=0){var c=n[a];if(void 0!==c){var h=c.normalized,l=c.itemSize,u=Ge.get(c);if(void 0===u)continue;var p=u.buffer,d=u.type,f=u.bytesPerElement;if(c.isInterleavedBufferAttribute){var m=c.data,v=m.stride,g=c.offset;m&&m.isInstancedInterleavedBuffer?(Ue.enableAttributeAndDivisor(s,m.meshPerAttribute),void 0===r.maxInstancedCount&&(r.maxInstancedCount=m.meshPerAttribute*m.count)):Ue.enableAttribute(s),se.bindBuffer(se.ARRAY_BUFFER,p),se.vertexAttribPointer(s,l,d,h,v*f,g*f)}else c.isInstancedBufferAttribute?(Ue.enableAttributeAndDivisor(s,c.meshPerAttribute),void 0===r.maxInstancedCount&&(r.maxInstancedCount=c.meshPerAttribute*c.count)):Ue.enableAttribute(s),se.bindBuffer(se.ARRAY_BUFFER,p),se.vertexAttribPointer(s,l,d,h,0,0)}else if(void 0!==o){var y=o[a];if(void 0!==y)switch(y.length){case 2:se.vertexAttrib2fv(s,y);break;case 3:se.vertexAttrib3fv(s,y);break;case 4:se.vertexAttrib4fv(s,y);break;default:se.vertexAttrib1fv(s,y)}}}}Ue.disableUnusedAttributes()}function f(){tt||(y(),tt=!0)}function v(){tt=!1}function y(){var e=$e.getDevice();e&&e.isPresenting?e.requestAnimationFrame(x):window.requestAnimationFrame(x)}function x(e){tt!==!1&&(it(e),y())}function b(e,t,r){if(e.visible!==!1){var n=e.layers.test(t.layers);if(n)if(e.isLight)ae.pushLight(e),e.castShadow&&ae.pushShadow(e);else if(e.isSprite)e.frustumCulled&&!Se.intersectsSprite(e)||ae.pushSprite(e);else if(e.isImmediateRenderObject)r&&Ce.setFromMatrixPosition(e.matrixWorld).applyMatrix4(Pe),ne.push(e,null,e.material,Ce.z,null);else if((e.isMesh||e.isLine||e.isPoints)&&(e.isSkinnedMesh&&e.skeleton.update(),!e.frustumCulled||Se.intersectsObject(e))){r&&Ce.setFromMatrixPosition(e.matrixWorld).applyMatrix4(Pe);var i=je.update(e),o=e.material;if(Array.isArray(o))for(var a=i.groups,s=0,c=a.length;s=0&&e.numSupportedMorphTargets++}if(e.morphNormals){e.numSupportedMorphNormals=0;for(var f=0;f=0&&e.numSupportedMorphNormals++}var m=n.shader.uniforms;(e.isShaderMaterial||e.isRawShaderMaterial)&&e.clipping!==!0||(n.numClippingPlanes=Ae.numPlanes,n.numIntersection=Ae.numIntersection,m.clippingPlanes=Ae.uniform),n.fog=t,n.lightsHash=i.state.hash,e.lights&&(m.ambientLightColor.value=i.state.ambient,m.directionalLights.value=i.state.directional,m.spotLights.value=i.state.spot,m.rectAreaLights.value=i.state.rectArea,m.pointLights.value=i.state.point,m.hemisphereLights.value=i.state.hemi,m.directionalShadowMap.value=i.state.directionalShadowMap,m.directionalShadowMatrix.value=i.state.directionalShadowMatrix,m.spotShadowMap.value=i.state.spotShadowMap,m.spotShadowMatrix.value=i.state.spotShadowMatrix,m.pointShadowMap.value=i.state.pointShadowMap,m.pointShadowMatrix.value=i.state.pointShadowMatrix);var v=n.program.getUniforms(),g=Fe.seqWithValue(v.seq,m);n.uniformsList=g}function M(e,t,r,n){xe=0;var i=He.get(r),o=ae.state.lights;if(Re&&(Le||e!==fe)){var a=e===fe&&r.id===pe;Ae.setState(r.clippingPlanes,r.clipIntersection,r.clipShadows,e,i,a)}r.needsUpdate===!1&&(void 0===i.program?r.needsUpdate=!0:r.fog&&i.fog!==t?r.needsUpdate=!0:r.lights&&i.lightsHash!==o.state.hash?r.needsUpdate=!0:void 0===i.numClippingPlanes||i.numClippingPlanes===Ae.numPlanes&&i.numIntersection===Ae.numIntersection||(r.needsUpdate=!0)),r.needsUpdate&&(E(r,t,n),r.needsUpdate=!1);var s=!1,c=!1,h=!1,l=i.program,p=l.getUniforms(),d=i.shader.uniforms;if(Ue.useProgram(l.program)&&(s=!0,c=!0,h=!0),r.id!==pe&&(pe=r.id,c=!0),s||e!==fe){if(p.setValue(se,"projectionMatrix",e.projectionMatrix),De.logarithmicDepthBuffer&&p.setValue(se,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),fe!==(me||e)&&(fe=me||e,c=!0,h=!0),r.isShaderMaterial||r.isMeshPhongMaterial||r.isMeshStandardMaterial||r.envMap){var f=p.map.cameraPosition;void 0!==f&&f.setValue(se,Ce.setFromMatrixPosition(e.matrixWorld))}(r.isMeshPhongMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial||r.skinning)&&p.setValue(se,"viewMatrix",e.matrixWorldInverse)}if(r.skinning){p.setOptional(se,n,"bindMatrix"),p.setOptional(se,n,"bindMatrixInverse");var m=n.skeleton;if(m){var v=m.bones;if(De.floatVertexTextures){if(void 0===m.boneTexture){var g=Math.sqrt(4*v.length);g=Sc.ceilPowerOfTwo(g),g=Math.max(g,4);var y=new Float32Array(g*g*4);y.set(m.boneMatrices);var x=new u(y,g,g,Ls,ws);x.needsUpdate=!0,m.boneMatrices=y,m.boneTexture=x,m.boneTextureSize=g}p.setValue(se,"boneTexture",m.boneTexture),p.setValue(se,"boneTextureSize",m.boneTextureSize)}else p.setOptional(se,m,"boneMatrices")}}return c&&(p.setValue(se,"toneMappingExposure",ce.toneMappingExposure),p.setValue(se,"toneMappingWhitePoint",ce.toneMappingWhitePoint),r.lights&&H(d,h),t&&r.fog&&L(d,t),r.isMeshBasicMaterial?T(d,r):r.isMeshLambertMaterial?(T(d,r),P(d,r)):r.isMeshPhongMaterial?(T(d,r),r.isMeshToonMaterial?O(d,r):C(d,r)):r.isMeshStandardMaterial?(T(d,r),r.isMeshPhysicalMaterial?N(d,r):I(d,r)):r.isMeshDepthMaterial?(T(d,r),D(d,r)):r.isMeshDistanceMaterial?(T(d,r),U(d,r)):r.isMeshNormalMaterial?(T(d,r),B(d,r)):r.isLineBasicMaterial?(S(d,r),r.isLineDashedMaterial&&A(d,r)):r.isPointsMaterial?R(d,r):r.isShadowMaterial&&(d.color.value=r.color,d.opacity.value=r.opacity),void 0!==d.ltc_1&&(d.ltc_1.value=Ul.LTC_1),void 0!==d.ltc_2&&(d.ltc_2.value=Ul.LTC_2),Fe.upload(se,i.uniformsList,d,ce)),r.isShaderMaterial&&r.uniformsNeedUpdate===!0&&(Fe.upload(se,i.uniformsList,d,ce),r.uniformsNeedUpdate=!1),p.setValue(se,"modelViewMatrix",n.modelViewMatrix),p.setValue(se,"normalMatrix",n.normalMatrix),p.setValue(se,"modelMatrix",n.matrixWorld),l}function T(e,t){e.opacity.value=t.opacity,t.color&&(e.diffuse.value=t.color),t.emissive&&e.emissive.value.copy(t.emissive).multiplyScalar(t.emissiveIntensity),t.map&&(e.map.value=t.map),t.alphaMap&&(e.alphaMap.value=t.alphaMap),t.specularMap&&(e.specularMap.value=t.specularMap),t.envMap&&(e.envMap.value=t.envMap,e.flipEnvMap.value=t.envMap&&t.envMap.isCubeTexture?-1:1,e.reflectivity.value=t.reflectivity,e.refractionRatio.value=t.refractionRatio,e.maxMipLevel.value=He.get(t.envMap).__maxMipLevel),t.lightMap&&(e.lightMap.value=t.lightMap,e.lightMapIntensity.value=t.lightMapIntensity),t.aoMap&&(e.aoMap.value=t.aoMap,e.aoMapIntensity.value=t.aoMapIntensity);var r;t.map?r=t.map:t.specularMap?r=t.specularMap:t.displacementMap?r=t.displacementMap:t.normalMap?r=t.normalMap:t.bumpMap?r=t.bumpMap:t.roughnessMap?r=t.roughnessMap:t.metalnessMap?r=t.metalnessMap:t.alphaMap?r=t.alphaMap:t.emissiveMap&&(r=t.emissiveMap),void 0!==r&&(r.isWebGLRenderTarget&&(r=r.texture),r.matrixAutoUpdate===!0&&r.updateMatrix(),e.uvTransform.value.copy(r.matrix))}function S(e,t){e.diffuse.value=t.color,e.opacity.value=t.opacity}function A(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}function R(e,t){e.diffuse.value=t.color,e.opacity.value=t.opacity,e.size.value=t.size*_e,e.scale.value=.5*we,e.map.value=t.map,null!==t.map&&(t.map.matrixAutoUpdate===!0&&t.map.updateMatrix(),e.uvTransform.value.copy(t.map.matrix))}function L(e,t){e.fogColor.value=t.color,t.isFog?(e.fogNear.value=t.near,e.fogFar.value=t.far):t.isFogExp2&&(e.fogDensity.value=t.density)}function P(e,t){t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap)}function C(e,t){e.specular.value=t.specular,e.shininess.value=Math.max(t.shininess,1e-4),t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap),t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale)),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}function O(e,t){C(e,t),t.gradientMap&&(e.gradientMap.value=t.gradientMap)}function I(e,t){e.roughness.value=t.roughness,e.metalness.value=t.metalness,t.roughnessMap&&(e.roughnessMap.value=t.roughnessMap),t.metalnessMap&&(e.metalnessMap.value=t.metalnessMap),t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap),t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale)),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias),t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)}function N(e,t){e.clearCoat.value=t.clearCoat,e.clearCoatRoughness.value=t.clearCoatRoughness,I(e,t)}function D(e,t){t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}function U(e,t){t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias),e.referencePosition.value.copy(t.referencePosition),e.nearDistance.value=t.nearDistance,e.farDistance.value=t.farDistance}function B(e,t){t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale)),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}function H(e,t){e.ambientLightColor.needsUpdate=t,e.directionalLights.needsUpdate=t,e.pointLights.needsUpdate=t,e.spotLights.needsUpdate=t,e.rectAreaLights.needsUpdate=t,e.hemisphereLights.needsUpdate=t}function z(){var e=xe;return e>=De.maxTextures&&console.warn("THREE.WebGLRenderer: Trying to use "+e+" texture units while this GPU supports only "+De.maxTextures),xe+=1,e}console.log("THREE.WebGLRenderer",Zo),e=e||{};var F=void 0!==e.canvas?e.canvas:document.createElementNS("http://www.w3.org/1999/xhtml","canvas"),G=void 0!==e.context?e.context:null,V=void 0!==e.alpha&&e.alpha,j=void 0===e.depth||e.depth,k=void 0===e.stencil||e.stencil,W=void 0!==e.antialias&&e.antialias,X=void 0===e.premultipliedAlpha||e.premultipliedAlpha,q=void 0!==e.preserveDrawingBuffer&&e.preserveDrawingBuffer,Y=void 0!==e.powerPreference?e.powerPreference:"default",ne=null,ae=null;this.domElement=F,this.context=null,this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.gammaFactor=2,this.gammaInput=!1,this.gammaOutput=!1,this.physicallyCorrectLights=!1,this.toneMapping=Ya,this.toneMappingExposure=1,this.toneMappingWhitePoint=1,this.maxMorphTargets=8,this.maxMorphNormals=4;var se,ce=this,he=!1,le=null,ue=null,pe=-1,de="",fe=null,me=null,ve=new c,ge=new c,ye=null,xe=0,be=F.width,we=F.height,_e=1,Ee=new c(0,0,be,we),Me=new c(0,0,be,we),Te=!1,Se=new m,Ae=new K,Re=!1,Le=!1,Pe=new n,Ce=new o;try{var Oe={alpha:V,depth:j,stencil:k,antialias:W,premultipliedAlpha:X,preserveDrawingBuffer:q,powerPreference:Y};if(F.addEventListener("webglcontextlost",i,!1),F.addEventListener("webglcontextrestored",a,!1),se=G||F.getContext("webgl",Oe)||F.getContext("experimental-webgl",Oe),null===se)throw null!==F.getContext("webgl")?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.");void 0===se.getShaderPrecisionFormat&&(se.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(Ie){console.error("THREE.WebGLRenderer: "+Ie.message)}var Ne,De,Ue,Be,He,ze,Ge,Ve,je,ke,We,Xe,qe,Ye,Ze,Je,Qe,Ke;r();var $e=new _t(ce);this.vr=$e;var et=new ft(ce,je,De.maxTextureSize);this.shadowMap=et,this.getContext=function(){return se},this.getContextAttributes=function(){return se.getContextAttributes()},this.forceContextLoss=function(){var e=Ne.get("WEBGL_lose_context");e&&e.loseContext()},this.forceContextRestore=function(){var e=Ne.get("WEBGL_lose_context");e&&e.restoreContext()},this.getPixelRatio=function(){return _e},this.setPixelRatio=function(e){void 0!==e&&(_e=e,this.setSize(be,we,!1))},this.getSize=function(){return{width:be,height:we}},this.setSize=function(e,t,r){var n=$e.getDevice();return n&&n.isPresenting?void console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."):(be=e,we=t,F.width=e*_e,F.height=t*_e,r!==!1&&(F.style.width=e+"px",F.style.height=t+"px"),void this.setViewport(0,0,e,t))},this.getDrawingBufferSize=function(){return{width:be*_e,height:we*_e}},this.setDrawingBufferSize=function(e,t,r){be=e,we=t,_e=r,F.width=e*r,F.height=t*r,this.setViewport(0,0,e,t)},this.getCurrentViewport=function(){return ve},this.setViewport=function(e,t,r,n){Ee.set(e,we-t-n,r,n),Ue.viewport(ve.copy(Ee).multiplyScalar(_e))},this.setScissor=function(e,t,r,n){Me.set(e,we-t-n,r,n),Ue.scissor(ge.copy(Me).multiplyScalar(_e))},this.setScissorTest=function(e){Ue.setScissorTest(Te=e)},this.getClearColor=function(){return qe.getClearColor()},this.setClearColor=function(){qe.setClearColor.apply(qe,arguments)},this.getClearAlpha=function(){return qe.getClearAlpha()},this.setClearAlpha=function(){qe.setClearAlpha.apply(qe,arguments)},this.clear=function(e,t,r){var n=0;(void 0===e||e)&&(n|=se.COLOR_BUFFER_BIT),(void 0===t||t)&&(n|=se.DEPTH_BUFFER_BIT),(void 0===r||r)&&(n|=se.STENCIL_BUFFER_BIT),se.clear(n)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.clearTarget=function(e,t,r,n){this.setRenderTarget(e),this.clear(t,r,n)},this.dispose=function(){F.removeEventListener("webglcontextlost",i,!1),F.removeEventListener("webglcontextrestored",a,!1),We.dispose(),Xe.dispose(),He.dispose(),je.dispose(),$e.dispose(),v()},this.renderBufferImmediate=function(e,t,r){Ue.initAttributes();var n=He.get(e);e.hasPositions&&!n.position&&(n.position=se.createBuffer()),e.hasNormals&&!n.normal&&(n.normal=se.createBuffer()),e.hasUvs&&!n.uv&&(n.uv=se.createBuffer()),e.hasColors&&!n.color&&(n.color=se.createBuffer());var i=t.getAttributes();if(e.hasPositions&&(se.bindBuffer(se.ARRAY_BUFFER,n.position),se.bufferData(se.ARRAY_BUFFER,e.positionArray,se.DYNAMIC_DRAW),Ue.enableAttribute(i.position),se.vertexAttribPointer(i.position,3,se.FLOAT,!1,0,0)),e.hasNormals){if(se.bindBuffer(se.ARRAY_BUFFER,n.normal),!r.isMeshPhongMaterial&&!r.isMeshStandardMaterial&&!r.isMeshNormalMaterial&&r.flatShading===!0)for(var o=0,a=3*e.count;o0&&v.renderInstances(n,_,T):v.render(_,T); }},this.compile=function(e,t){ae=Xe.get(e,t),ae.init(),e.traverse(function(e){e.isLight&&(ae.pushLight(e),e.castShadow&&ae.pushShadow(e))}),ae.setupLights(t),e.traverse(function(t){if(t.material)if(Array.isArray(t.material))for(var r=0;r=0&&t<=e.width-n&&r>=0&&r<=e.height-i&&se.readPixels(t,r,n,i,Ke.convert(h),Ke.convert(l),o):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{s&&se.bindFramebuffer(se.FRAMEBUFFER,ue)}}},this.copyFramebufferToTexture=function(e,t,r){var n=t.image.width,i=t.image.height,o=Ke.convert(t.format);this.setTexture2D(t,0),se.copyTexImage2D(se.TEXTURE_2D,r||0,o,e.x,e.y,n,i,0)},this.copyTextureToTexture=function(e,t,r,n){var i=t.image.width,o=t.image.height,a=Ke.convert(r.format),s=Ke.convert(r.type),c=t.isDataTexture?t.image.data:t.image;this.setTexture2D(r,0),se.texSubImage2D(se.TEXTURE_2D,n||0,e.x,e.y,i,o,a,s,c)}}function Mt(e,t){this.name="",this.color=new v(e),this.density=void 0!==t?t:25e-5}function Tt(e,t,r){this.name="",this.color=new v(e),this.near=void 0!==t?t:1,this.far=void 0!==r?r:1e3}function St(){b.call(this),this.type="Scene",this.background=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0}function At(e){V.call(this),this.type="SpriteMaterial",this.color=new v(16777215),this.map=null,this.rotation=0,this.fog=!1,this.lights=!1,this.setValues(e)}function Rt(e){b.call(this),this.type="Sprite",this.material=void 0!==e?e:new At,this.center=new r(.5,.5)}function Lt(){b.call(this),this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}})}function Pt(e,t){if(e=e||[],this.bones=e.slice(0),this.boneMatrices=new Float32Array(16*this.bones.length),void 0===t)this.calculateInverses();else if(this.bones.length===t.length)this.boneInverses=t.slice(0);else{console.warn("THREE.Skeleton boneInverses is the wrong length."),this.boneInverses=[];for(var r=0,i=this.bones.length;r=0?(e(y-l,g,d),f.subVectors(p,d)):(e(y+l,g,d),f.subVectors(d,p)),g-l>=0?(e(y,g-l,d),m.subVectors(p,d)):(e(y,g+l,d),m.subVectors(d,p)),u.crossVectors(f,m).normalize(),c.push(u.x,u.y,u.z),h.push(y,g)}}for(n=0;n.9&&o<.1&&(t<.2&&(y[e+0]+=1),r<.2&&(y[e+2]+=1),n<.2&&(y[e+4]+=1))}}function u(e){g.push(e.x,e.y,e.z)}function p(t,r){var n=3*t;r.x=e[n+0],r.y=e[n+1],r.z=e[n+2]}function d(){for(var e=new o,t=new o,n=new o,i=new o,a=new r,s=new r,c=new r,h=0,l=0;h0)for(o=t;o=t;o-=n)a=Or(o,e[o],e[o+1],a);return a&&Sr(a,a.next)&&(Ir(a),a=a.next),a}function hr(e,t){if(!e)return e;t||(t=e);var r,n=e;do if(r=!1,n.steiner||!Sr(n,n.next)&&0!==Tr(n.prev,n,n.next))n=n.next;else{if(Ir(n),n=t=n.prev,n===n.next)break;r=!0}while(r||n!==t);return t}function lr(e,t,r,n,i,o,a){if(e){!a&&o&&xr(e,n,i,o);for(var s,c,h=e;e.prev!==e.next;)if(s=e.prev,c=e.next,o?pr(e,n,i,o):ur(e))t.push(s.i/r),t.push(e.i/r),t.push(c.i/r),Ir(e),e=c.next,h=c.next;else if(e=c,e===h){a?1===a?(e=dr(e,t,r),lr(e,t,r,n,i,o,2)):2===a&&fr(e,t,r,n,i,o):lr(hr(e),t,r,n,i,o,1);break}}}function ur(e){var t=e.prev,r=e,n=e.next;if(Tr(t,r,n)>=0)return!1;for(var i=e.next.next;i!==e.prev;){if(Er(t.x,t.y,r.x,r.y,n.x,n.y,i.x,i.y)&&Tr(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function pr(e,t,r,n){var i=e.prev,o=e,a=e.next;if(Tr(i,o,a)>=0)return!1;for(var s=i.xo.x?i.x>a.x?i.x:a.x:o.x>a.x?o.x:a.x,l=i.y>o.y?i.y>a.y?i.y:a.y:o.y>a.y?o.y:a.y,u=wr(s,c,t,r,n),p=wr(h,l,t,r,n),d=e.nextZ;d&&d.z<=p;){if(d!==e.prev&&d!==e.next&&Er(i.x,i.y,o.x,o.y,a.x,a.y,d.x,d.y)&&Tr(d.prev,d,d.next)>=0)return!1;d=d.nextZ}for(d=e.prevZ;d&&d.z>=u;){if(d!==e.prev&&d!==e.next&&Er(i.x,i.y,o.x,o.y,a.x,a.y,d.x,d.y)&&Tr(d.prev,d,d.next)>=0)return!1;d=d.prevZ}return!0}function dr(e,t,r){var n=e;do{var i=n.prev,o=n.next.next;!Sr(i,o)&&Ar(i,n,n.next,o)&&Lr(i,o)&&Lr(o,i)&&(t.push(i.i/r),t.push(n.i/r),t.push(o.i/r),Ir(n),Ir(n.next),n=e=o),n=n.next}while(n!==e);return n}function fr(e,t,r,n,i,o){var a=e;do{for(var s=a.next.next;s!==a.prev;){if(a.i!==s.i&&Mr(a,s)){var c=Cr(a,s);return a=hr(a,a.next),c=hr(c,c.next),lr(a,t,r,n,i,o),void lr(c,t,r,n,i,o)}s=s.next}a=a.next}while(a!==e)}function mr(e,t,r,n){var i,o,a,s,c,h=[];for(i=0,o=t.length;i=n.next.y&&n.next.y!==n.y){var s=n.x+(o-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(s<=i&&s>a){if(a=s,s===i){if(o===n.y)return n;if(o===n.next.y)return n.next}r=n.x=n.x&&n.x>=l&&i!==n.x&&Er(or.x)&&Lr(n,e)&&(r=n,p=c)),n=n.next;return r}function xr(e,t,r,n){var i=e;do null===i.z&&(i.z=wr(i.x,i.y,t,r,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,br(i)}function br(e){var t,r,n,i,o,a,s,c,h=1;do{for(r=e,e=null,o=null,a=0;r;){for(a++,n=r,s=0,t=0;t0||c>0&&n;)0!==s&&(0===c||!n||r.z<=n.z)?(i=r,r=r.nextZ,s--):(i=n,n=n.nextZ,c--),o?o.nextZ=i:e=i,i.prevZ=o,o=i;r=n}o.nextZ=null,h*=2}while(a>1);return e}function wr(e,t,r,n,i){return e=32767*(e-r)*i,t=32767*(t-n)*i,e=16711935&(e|e<<8),e=252645135&(e|e<<4),e=858993459&(e|e<<2),e=1431655765&(e|e<<1),t=16711935&(t|t<<8),t=252645135&(t|t<<4),t=858993459&(t|t<<2),t=1431655765&(t|t<<1),e|t<<1}function _r(e){var t=e,r=e;do t.x=0&&(e-a)*(n-s)-(r-a)*(t-s)>=0&&(r-a)*(o-s)-(i-a)*(n-s)>=0}function Mr(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!Rr(e,t)&&Lr(e,t)&&Lr(t,e)&&Pr(e,t)}function Tr(e,t,r){return(t.y-e.y)*(r.x-t.x)-(t.x-e.x)*(r.y-t.y)}function Sr(e,t){return e.x===t.x&&e.y===t.y}function Ar(e,t,r,n){return!!(Sr(e,t)&&Sr(r,n)||Sr(e,n)&&Sr(r,t))||Tr(e,t,r)>0!=Tr(e,t,n)>0&&Tr(r,n,e)>0!=Tr(r,n,t)>0}function Rr(e,t){var r=e;do{if(r.i!==e.i&&r.next.i!==e.i&&r.i!==t.i&&r.next.i!==t.i&&Ar(r,r.next,e,t))return!0;r=r.next}while(r!==e);return!1}function Lr(e,t){return Tr(e.prev,e,e.next)<0?Tr(e,t,e.next)>=0&&Tr(e,e.prev,t)>=0:Tr(e,t,e.prev)<0||Tr(e,e.next,t)<0}function Pr(e,t){var r=e,n=!1,i=(e.x+t.x)/2,o=(e.y+t.y)/2;do r.y>o!=r.next.y>o&&r.next.y!==r.y&&i<(r.next.x-r.x)*(o-r.y)/(r.next.y-r.y)+r.x&&(n=!n),r=r.next;while(r!==e);return n}function Cr(e,t){var r=new Nr(e.i,e.x,e.y),n=new Nr(t.i,t.x,t.y),i=e.next,o=t.prev;return e.next=t,t.prev=e,r.next=i,i.prev=r,n.next=r,r.prev=n,o.next=n,n.prev=o,n}function Or(e,t,r,n){var i=new Nr(e,t,r);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function Ir(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function Nr(e,t,r){this.i=e,this.x=t,this.y=r,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Dr(e,t,r,n){for(var i=0,o=t,a=r-n;o2&&e[t-1].equals(e[0])&&e.pop()}function Br(e,t){for(var r=0;rNumber.EPSILON){var d=Math.sqrt(u),f=Math.sqrt(h*h+l*l),m=t.x-c/d,v=t.y+s/d,g=n.x-l/f,y=n.y+h/f,x=((g-m)*l-(y-v)*h)/(s*l-c*h);i=m+s*x-e.x,o=v+c*x-e.y;var b=i*i+o*o;if(b<=2)return new r(i,o);a=Math.sqrt(b/2)}else{var w=!1;s>Number.EPSILON?h>Number.EPSILON&&(w=!0):s<-Number.EPSILON?h<-Number.EPSILON&&(w=!0):Math.sign(c)===Math.sign(l)&&(w=!0),w?(i=-c,o=s,a=Math.sqrt(u)):(i=s,o=c,a=Math.sqrt(u/2))}return new r(i/a,o/a)}function h(){var e=a.length/3;if(S){var t=0,r=Y*t;for(Q=0;Q=0;){r=Q,n=Q-1,n<0&&(n=e.length-1);var i=0,o=M+2*L;for(i=0;i=0;V--){for(k=V/L,W=A*Math.cos(k*Math.PI/2),j=R*Math.sin(k*Math.PI/2),Q=0,K=G.length;Q0)&&m.push(_,E,T),(h!==r-1||l0&&u(!0),t>0&&u(!1)),this.setIndex(d),this.addAttribute("position",new I(f,3)),this.addAttribute("normal",new I(m,3)),this.addAttribute("uv",new I(v,2))}function en(e,t,r,n,i,o,a){Kr.call(this,0,e,t,r,n,i,o,a),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:r,heightSegments:n,openEnded:i,thetaStart:o,thetaLength:a}}function tn(e,t,r,n,i,o,a){$r.call(this,0,e,t,r,n,i,o,a),this.type="ConeBufferGeometry",this.parameters={radius:e,height:t,radialSegments:r,heightSegments:n,openEnded:i,thetaStart:o,thetaLength:a}}function rn(e,t,r,n){M.call(this),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:r,thetaLength:n},this.fromBufferGeometry(new nn(e,t,r,n)),this.mergeVertices()}function nn(e,t,n,i){B.call(this),this.type="CircleBufferGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:i},e=e||1,t=void 0!==t?Math.max(3,t):8,n=void 0!==n?n:0,i=void 0!==i?i:2*Math.PI;var a,s,c=[],h=[],l=[],u=[],p=new o,d=new r;for(h.push(0,0,0),l.push(0,0,1),u.push(.5,.5),s=0,a=3;s<=t;s++,a+=3){var f=n+s/t*i;p.x=e*Math.cos(f),p.y=e*Math.sin(f),h.push(p.x,p.y,p.z),l.push(0,0,1),d.x=(h[a]/e+1)/2,d.y=(h[a+1]/e+1)/2,u.push(d.x,d.y)}for(a=1;a<=t;a++)c.push(a,a+1,0);this.setIndex(c),this.addAttribute("position",new I(h,3)),this.addAttribute("normal",new I(l,3)),this.addAttribute("uv",new I(u,2))}function on(e){V.call(this),this.type="ShadowMaterial",this.color=new v(0),this.transparent=!0,this.setValues(e)}function an(e){k.call(this,e),this.type="RawShaderMaterial"}function sn(e){V.call(this),this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new v(16777215),this.roughness=.5,this.metalness=.5,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new v(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalScale=new r(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}function cn(e){sn.call(this),this.defines={PHYSICAL:""},this.type="MeshPhysicalMaterial",this.reflectivity=.5,this.clearCoat=0,this.clearCoatRoughness=0,this.setValues(e)}function hn(e){V.call(this),this.type="MeshPhongMaterial",this.color=new v(16777215),this.specular=new v(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new v(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalScale=new r(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=ka,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.morphNormals=!1,this.setValues(e)}function ln(e){hn.call(this),this.defines={TOON:""},this.type="MeshToonMaterial",this.gradientMap=null,this.setValues(e)}function un(e){V.call(this),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalScale=new r(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}function pn(e){V.call(this),this.type="MeshLambertMaterial",this.color=new v(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new v(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=ka,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.morphNormals=!1,this.setValues(e)}function dn(e){It.call(this),this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}function fn(e,t,r){var n=this,i=!1,o=0,a=0,s=void 0;this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=r,this.itemStart=function(e){a++,i===!1&&void 0!==n.onStart&&n.onStart(e,o,a),i=!0},this.itemEnd=function(e){o++,void 0!==n.onProgress&&n.onProgress(e,o,a),o===a&&(i=!1,void 0!==n.onLoad&&n.onLoad())},this.itemError=function(e){void 0!==n.onError&&n.onError(e)},this.resolveURL=function(e){return s?s(e):e},this.setURLModifier=function(e){return s=e,this}}function mn(e){this.manager=void 0!==e?e:nu}function vn(e){this.manager=void 0!==e?e:nu,this._parser=null}function gn(e){this.manager=void 0!==e?e:nu,this._parser=null}function yn(e){this.manager=void 0!==e?e:nu}function xn(e){this.manager=void 0!==e?e:nu}function bn(e){this.manager=void 0!==e?e:nu}function wn(){this.type="Curve",this.arcLengthDivisions=200}function _n(e,t,r,n,i,o,a,s){wn.call(this),this.type="EllipseCurve",this.aX=e||0,this.aY=t||0,this.xRadius=r||1,this.yRadius=n||1,this.aStartAngle=i||0,this.aEndAngle=o||2*Math.PI,this.aClockwise=a||!1,this.aRotation=s||0}function En(e,t,r,n,i,o){_n.call(this,e,t,r,r,n,i,o),this.type="ArcCurve"}function Mn(){function e(e,o,a,s){t=e,r=a,n=-3*e+3*o-2*a-s,i=2*e-2*o+a+s}var t=0,r=0,n=0,i=0;return{initCatmullRom:function(t,r,n,i,o){e(r,n,o*(n-t),o*(i-r))},initNonuniformCatmullRom:function(t,r,n,i,o,a,s){var c=(r-t)/o-(n-t)/(o+a)+(n-r)/a,h=(n-r)/a-(i-r)/(a+s)+(i-n)/s;c*=a,h*=a,e(r,n,c,h)},calc:function(e){var o=e*e,a=o*e;return t+r*e+n*o+i*a}}}function Tn(e,t,r,n){wn.call(this),this.type="CatmullRomCurve3",this.points=e||[],this.closed=t||!1,this.curveType=r||"centripetal",this.tension=n||.5}function Sn(e,t,r,n,i){var o=.5*(n-t),a=.5*(i-r),s=e*e,c=e*s;return(2*r-2*n+o+a)*c+(-3*r+3*n-2*o-a)*s+o*e+r}function An(e,t){var r=1-e;return r*r*t}function Rn(e,t){return 2*(1-e)*e*t}function Ln(e,t){return e*e*t}function Pn(e,t,r,n){return An(e,t)+Rn(e,r)+Ln(e,n)}function Cn(e,t){var r=1-e;return r*r*r*t}function On(e,t){var r=1-e;return 3*r*r*e*t}function In(e,t){return 3*(1-e)*e*e*t}function Nn(e,t){return e*e*e*t}function Dn(e,t,r,n,i){return Cn(e,t)+On(e,r)+In(e,n)+Nn(e,i)}function Un(e,t,n,i){wn.call(this),this.type="CubicBezierCurve",this.v0=e||new r,this.v1=t||new r,this.v2=n||new r,this.v3=i||new r}function Bn(e,t,r,n){wn.call(this),this.type="CubicBezierCurve3",this.v0=e||new o,this.v1=t||new o,this.v2=r||new o,this.v3=n||new o}function Hn(e,t){wn.call(this),this.type="LineCurve",this.v1=e||new r,this.v2=t||new r}function zn(e,t){wn.call(this),this.type="LineCurve3",this.v1=e||new o,this.v2=t||new o}function Fn(e,t,n){wn.call(this),this.type="QuadraticBezierCurve",this.v0=e||new r,this.v1=t||new r,this.v2=n||new r}function Gn(e,t,r){wn.call(this),this.type="QuadraticBezierCurve3",this.v0=e||new o,this.v1=t||new o,this.v2=r||new o}function Vn(e){wn.call(this),this.type="SplineCurve",this.points=e||[]}function jn(){wn.call(this),this.type="CurvePath",this.curves=[],this.autoClose=!1}function kn(e){jn.call(this),this.type="Path",this.currentPoint=new r,e&&this.setFromPoints(e)}function Wn(e){kn.call(this,e),this.uuid=Sc.generateUUID(),this.type="Shape",this.holes=[]}function Xn(e,t){b.call(this),this.type="Light",this.color=new v(e),this.intensity=void 0!==t?t:1,this.receiveShadow=void 0}function qn(e,t,r){Xn.call(this,e,r),this.type="HemisphereLight",this.castShadow=void 0,this.position.copy(b.DefaultUp),this.updateMatrix(),this.groundColor=new v(t)}function Yn(e){this.camera=e,this.bias=0,this.radius=1,this.mapSize=new r(512,512),this.map=null,this.matrix=new n}function Zn(){Yn.call(this,new bt(50,1,.5,500))}function Jn(e,t,r,n,i,o){Xn.call(this,e,t),this.type="SpotLight",this.position.copy(b.DefaultUp),this.updateMatrix(),this.target=new b,Object.defineProperty(this,"power",{get:function(){return this.intensity*Math.PI},set:function(e){this.intensity=e/Math.PI}}),this.distance=void 0!==r?r:0,this.angle=void 0!==n?n:Math.PI/3,this.penumbra=void 0!==i?i:0,this.decay=void 0!==o?o:1,this.shadow=new Zn}function Qn(e,t,r,n){Xn.call(this,e,t),this.type="PointLight",Object.defineProperty(this,"power",{get:function(){return 4*this.intensity*Math.PI},set:function(e){this.intensity=e/(4*Math.PI)}}),this.distance=void 0!==r?r:0,this.decay=void 0!==n?n:1,this.shadow=new Yn(new bt(90,1,.5,500))}function Kn(){Yn.call(this,new _((-5),5,5,(-5),.5,500))}function $n(e,t){Xn.call(this,e,t),this.type="DirectionalLight",this.position.copy(b.DefaultUp),this.updateMatrix(),this.target=new b,this.shadow=new Kn}function ei(e,t){Xn.call(this,e,t),this.type="AmbientLight",this.castShadow=void 0}function ti(e,t,r,n){Xn.call(this,e,t),this.type="RectAreaLight",this.width=void 0!==r?r:10,this.height=void 0!==n?n:10}function ri(e,t,r,n){pi.call(this,e,t,r,n)}function ni(e,t,r){pi.call(this,e,t,r)}function ii(e,t,r,n){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=void 0!==n?n:new t.constructor(r),this.sampleValues=t,this.valueSize=r}function oi(e,t,r,n){ii.call(this,e,t,r,n)}function ai(e,t,r,n){pi.call(this,e,t,r,n)}function si(e,t,r,n){pi.call(this,e,t,r,n)}function ci(e,t,r,n){pi.call(this,e,t,r,n)}function hi(e,t,r,n){ii.call(this,e,t,r,n),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0}function li(e,t,r,n){ii.call(this,e,t,r,n)}function ui(e,t,r,n){ii.call(this,e,t,r,n)}function pi(e,t,r,n){if(void 0===e)throw new Error("THREE.KeyframeTrack: track name is undefined");if(void 0===t||0===t.length)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=lu.convertArray(t,this.TimeBufferType),this.values=lu.convertArray(r,this.ValueBufferType),this.setInterpolation(n||this.DefaultInterpolation),this.validate(),this.optimize()}function di(e,t,r,n){pi.call(this,e,t,r,n)}function fi(e,t,r){this.name=e,this.tracks=r,this.duration=void 0!==t?t:-1,this.uuid=Sc.generateUUID(),this.duration<0&&this.resetDuration(),this.optimize()}function mi(e){this.manager=void 0!==e?e:nu,this.textures={}}function vi(e){this.manager=void 0!==e?e:nu}function gi(){}function yi(e){"boolean"==typeof e&&(console.warn("THREE.JSONLoader: showStatus parameter has been removed from constructor."),e=void 0),this.manager=void 0!==e?e:nu,this.withCredentials=!1}function xi(e){this.manager=void 0!==e?e:nu,this.texturePath=""}function bi(e){"undefined"==typeof createImageBitmap&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),"undefined"==typeof fetch&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.manager=void 0!==e?e:nu,this.options=void 0}function wi(){this.type="ShapePath",this.color=new v,this.subPaths=[],this.currentPath=null}function _i(e){this.type="Font",this.data=e}function Ei(e,t,r,n){for(var i=String(e).split(""),o=t/n.resolution,a=(n.boundingBox.yMax-n.boundingBox.yMin+n.underlineThickness)*o,s=[],c=0,h=0,l=0;l0?1:+e}),"name"in Function.prototype==!1&&Object.defineProperty(Function.prototype,"name",{get:function(){return this.toString().match(/^\s*function\s*([^\(\s]*)/)[1]}}),void 0===Object.assign&&!function(){ Object.assign=function(e){if(void 0===e||null===e)throw new TypeError("Cannot convert undefined or null to object");for(var t=Object(e),r=1;r>8&255]+e[t>>16&255]+e[t>>24&255]+"-"+e[255&r]+e[r>>8&255]+"-"+e[r>>16&15|64]+e[r>>24&255]+"-"+e[63&n|128]+e[n>>8&255]+"-"+e[n>>16&255]+e[n>>24&255]+e[255&i]+e[i>>8&255]+e[i>>16&255]+e[i>>24&255];return o.toUpperCase()}}(),clamp:function(e,t,r){return Math.max(t,Math.min(r,e))},euclideanModulo:function(e,t){return(e%t+t)%t},mapLinear:function(e,t,r,n,i){return n+(e-t)*(i-n)/(r-t)},lerp:function(e,t,r){return(1-r)*e+r*t},smoothstep:function(e,t,r){return e<=t?0:e>=r?1:(e=(e-t)/(r-t),e*e*(3-2*e))},smootherstep:function(e,t,r){return e<=t?0:e>=r?1:(e=(e-t)/(r-t),e*e*e*(e*(6*e-15)+10))},randInt:function(e,t){return e+Math.floor(Math.random()*(t-e+1))},randFloat:function(e,t){return e+Math.random()*(t-e)},randFloatSpread:function(e){return e*(.5-Math.random())},degToRad:function(e){return e*Sc.DEG2RAD},radToDeg:function(e){return e*Sc.RAD2DEG},isPowerOfTwo:function(e){return 0===(e&e-1)&&0!==e},ceilPowerOfTwo:function(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))},floorPowerOfTwo:function(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}};Object.defineProperties(r.prototype,{width:{get:function(){return this.x},set:function(e){this.x=e}},height:{get:function(){return this.y},set:function(e){this.y=e}}}),Object.assign(r.prototype,{isVector2:!0,set:function(e,t){return this.x=e,this.y=t,this},setScalar:function(e){return this.x=e,this.y=e,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setComponent:function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(e){return this.x=e.x,this.y=e.y,this},add:function(e,t){return void 0!==t?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this)},addScalar:function(e){return this.x+=e,this.y+=e,this},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this},addScaledVector:function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this},sub:function(e,t){return void 0!==t?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this)},subScalar:function(e){return this.x-=e,this.y-=e,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this},multiply:function(e){return this.x*=e.x,this.y*=e.y,this},multiplyScalar:function(e){return this.x*=e,this.y*=e,this},divide:function(e){return this.x/=e.x,this.y/=e.y,this},divideScalar:function(e){return this.multiplyScalar(1/e)},applyMatrix3:function(e){var t=this.x,r=this.y,n=e.elements;return this.x=n[0]*t+n[3]*r+n[6],this.y=n[1]*t+n[4]*r+n[7],this},min:function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this},max:function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this},clamp:function(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this},clampScalar:function(){var e=new r,t=new r;return function(r,n){return e.set(r,r),t.set(n,n),this.clamp(e,t)}}(),clampLength:function(e,t){var r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(t,r)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this},negate:function(){return this.x=-this.x,this.y=-this.y,this},dot:function(e){return this.x*e.x+this.y*e.y},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)},normalize:function(){return this.divideScalar(this.length()||1)},angle:function(){var e=Math.atan2(this.y,this.x);return e<0&&(e+=2*Math.PI),e},distanceTo:function(e){return Math.sqrt(this.distanceToSquared(e))},distanceToSquared:function(e){var t=this.x-e.x,r=this.y-e.y;return t*t+r*r},manhattanDistanceTo:function(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)},setLength:function(e){return this.normalize().multiplyScalar(e)},lerp:function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this},lerpVectors:function(e,t,r){return this.subVectors(t,e).multiplyScalar(r).add(e)},equals:function(e){return e.x===this.x&&e.y===this.y},fromArray:function(e,t){return void 0===t&&(t=0),this.x=e[t],this.y=e[t+1],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e},fromBufferAttribute:function(e,t,r){return void 0!==r&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this},rotateAround:function(e,t){var r=Math.cos(t),n=Math.sin(t),i=this.x-e.x,o=this.y-e.y;return this.x=i*r-o*n+e.x,this.y=i*n+o*r+e.y,this}}),Object.assign(n.prototype,{isMatrix4:!0,set:function(e,t,r,n,i,o,a,s,c,h,l,u,p,d,f,m){var v=this.elements;return v[0]=e,v[4]=t,v[8]=r,v[12]=n,v[1]=i,v[5]=o,v[9]=a,v[13]=s,v[2]=c,v[6]=h,v[10]=l,v[14]=u,v[3]=p,v[7]=d,v[11]=f,v[15]=m,this},identity:function(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this},clone:function(){return(new n).fromArray(this.elements)},copy:function(e){var t=this.elements,r=e.elements;return t[0]=r[0],t[1]=r[1],t[2]=r[2],t[3]=r[3],t[4]=r[4],t[5]=r[5],t[6]=r[6],t[7]=r[7],t[8]=r[8],t[9]=r[9],t[10]=r[10],t[11]=r[11],t[12]=r[12],t[13]=r[13],t[14]=r[14],t[15]=r[15],this},copyPosition:function(e){var t=this.elements,r=e.elements;return t[12]=r[12],t[13]=r[13],t[14]=r[14],this},extractBasis:function(e,t,r){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this},makeBasis:function(e,t,r){return this.set(e.x,t.x,r.x,0,e.y,t.y,r.y,0,e.z,t.z,r.z,0,0,0,0,1),this},extractRotation:function(){var e=new o;return function(t){var r=this.elements,n=t.elements,i=1/e.setFromMatrixColumn(t,0).length(),o=1/e.setFromMatrixColumn(t,1).length(),a=1/e.setFromMatrixColumn(t,2).length();return r[0]=n[0]*i,r[1]=n[1]*i,r[2]=n[2]*i,r[4]=n[4]*o,r[5]=n[5]*o,r[6]=n[6]*o,r[8]=n[8]*a,r[9]=n[9]*a,r[10]=n[10]*a,this}}(),makeRotationFromEuler:function(e){e&&e.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");var t=this.elements,r=e.x,n=e.y,i=e.z,o=Math.cos(r),a=Math.sin(r),s=Math.cos(n),c=Math.sin(n),h=Math.cos(i),l=Math.sin(i);if("XYZ"===e.order){var u=o*h,p=o*l,d=a*h,f=a*l;t[0]=s*h,t[4]=-s*l,t[8]=c,t[1]=p+d*c,t[5]=u-f*c,t[9]=-a*s,t[2]=f-u*c,t[6]=d+p*c,t[10]=o*s}else if("YXZ"===e.order){var m=s*h,v=s*l,g=c*h,y=c*l;t[0]=m+y*a,t[4]=g*a-v,t[8]=o*c,t[1]=o*l,t[5]=o*h,t[9]=-a,t[2]=v*a-g,t[6]=y+m*a,t[10]=o*s}else if("ZXY"===e.order){var m=s*h,v=s*l,g=c*h,y=c*l;t[0]=m-y*a,t[4]=-o*l,t[8]=g+v*a,t[1]=v+g*a,t[5]=o*h,t[9]=y-m*a,t[2]=-o*c,t[6]=a,t[10]=o*s}else if("ZYX"===e.order){var u=o*h,p=o*l,d=a*h,f=a*l;t[0]=s*h,t[4]=d*c-p,t[8]=u*c+f,t[1]=s*l,t[5]=f*c+u,t[9]=p*c-d,t[2]=-c,t[6]=a*s,t[10]=o*s}else if("YZX"===e.order){var x=o*s,b=o*c,w=a*s,_=a*c;t[0]=s*h,t[4]=_-x*l,t[8]=w*l+b,t[1]=l,t[5]=o*h,t[9]=-a*h,t[2]=-c*h,t[6]=b*l+w,t[10]=x-_*l}else if("XZY"===e.order){var x=o*s,b=o*c,w=a*s,_=a*c;t[0]=s*h,t[4]=-l,t[8]=c*h,t[1]=x*l+_,t[5]=o*h,t[9]=b*l-w,t[2]=w*l-b,t[6]=a*h,t[10]=_*l+x}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this},makeRotationFromQuaternion:function(e){var t=this.elements,r=e._x,n=e._y,i=e._z,o=e._w,a=r+r,s=n+n,c=i+i,h=r*a,l=r*s,u=r*c,p=n*s,d=n*c,f=i*c,m=o*a,v=o*s,g=o*c;return t[0]=1-(p+f),t[4]=l-g,t[8]=u+v,t[1]=l+g,t[5]=1-(h+f),t[9]=d-m,t[2]=u-v,t[6]=d+m,t[10]=1-(h+p),t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this},lookAt:function(){var e=new o,t=new o,r=new o;return function(n,i,o){var a=this.elements;return r.subVectors(n,i),0===r.lengthSq()&&(r.z=1),r.normalize(),e.crossVectors(o,r),0===e.lengthSq()&&(1===Math.abs(o.z)?r.x+=1e-4:r.z+=1e-4,r.normalize(),e.crossVectors(o,r)),e.normalize(),t.crossVectors(r,e),a[0]=e.x,a[4]=t.x,a[8]=r.x,a[1]=e.y,a[5]=t.y,a[9]=r.y,a[2]=e.z,a[6]=t.z,a[10]=r.z,this}}(),multiply:function(e,t){return void 0!==t?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(e,t)):this.multiplyMatrices(this,e)},premultiply:function(e){return this.multiplyMatrices(e,this)},multiplyMatrices:function(e,t){var r=e.elements,n=t.elements,i=this.elements,o=r[0],a=r[4],s=r[8],c=r[12],h=r[1],l=r[5],u=r[9],p=r[13],d=r[2],f=r[6],m=r[10],v=r[14],g=r[3],y=r[7],x=r[11],b=r[15],w=n[0],_=n[4],E=n[8],M=n[12],T=n[1],S=n[5],A=n[9],R=n[13],L=n[2],P=n[6],C=n[10],O=n[14],I=n[3],N=n[7],D=n[11],U=n[15];return i[0]=o*w+a*T+s*L+c*I,i[4]=o*_+a*S+s*P+c*N,i[8]=o*E+a*A+s*C+c*D,i[12]=o*M+a*R+s*O+c*U,i[1]=h*w+l*T+u*L+p*I,i[5]=h*_+l*S+u*P+p*N,i[9]=h*E+l*A+u*C+p*D,i[13]=h*M+l*R+u*O+p*U,i[2]=d*w+f*T+m*L+v*I,i[6]=d*_+f*S+m*P+v*N,i[10]=d*E+f*A+m*C+v*D,i[14]=d*M+f*R+m*O+v*U,i[3]=g*w+y*T+x*L+b*I,i[7]=g*_+y*S+x*P+b*N,i[11]=g*E+y*A+x*C+b*D,i[15]=g*M+y*R+x*O+b*U,this},multiplyScalar:function(e){var t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this},applyToBufferAttribute:function(){var e=new o;return function(t){for(var r=0,n=t.count;r=0?1:-1,y=1-v*v;if(y>Number.EPSILON){var x=Math.sqrt(y),b=Math.atan2(x,v*g);m=Math.sin(m*b)/x,a=Math.sin(a*b)/x}var w=a*g;if(s=s*m+u*w,c=c*m+p*w,h=h*m+d*w,l=l*m+f*w,m===1-a){var _=1/Math.sqrt(s*s+c*c+h*h+l*l);s*=_,c*=_,h*=_,l*=_}}e[t]=s,e[t+1]=c,e[t+2]=h,e[t+3]=l}}),Object.defineProperties(i.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this.onChangeCallback()}},y:{get:function(){return this._y},set:function(e){this._y=e,this.onChangeCallback()}},z:{get:function(){return this._z},set:function(e){this._z=e,this.onChangeCallback()}},w:{get:function(){return this._w},set:function(e){this._w=e,this.onChangeCallback()}}}),Object.assign(i.prototype,{set:function(e,t,r,n){return this._x=e,this._y=t,this._z=r,this._w=n,this.onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._w)},copy:function(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this.onChangeCallback(),this},setFromEuler:function(e,t){if(!e||!e.isEuler)throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");var r=e._x,n=e._y,i=e._z,o=e.order,a=Math.cos,s=Math.sin,c=a(r/2),h=a(n/2),l=a(i/2),u=s(r/2),p=s(n/2),d=s(i/2);return"XYZ"===o?(this._x=u*h*l+c*p*d,this._y=c*p*l-u*h*d,this._z=c*h*d+u*p*l,this._w=c*h*l-u*p*d):"YXZ"===o?(this._x=u*h*l+c*p*d,this._y=c*p*l-u*h*d,this._z=c*h*d-u*p*l,this._w=c*h*l+u*p*d):"ZXY"===o?(this._x=u*h*l-c*p*d,this._y=c*p*l+u*h*d,this._z=c*h*d+u*p*l,this._w=c*h*l-u*p*d):"ZYX"===o?(this._x=u*h*l-c*p*d,this._y=c*p*l+u*h*d,this._z=c*h*d-u*p*l,this._w=c*h*l+u*p*d):"YZX"===o?(this._x=u*h*l+c*p*d,this._y=c*p*l+u*h*d,this._z=c*h*d-u*p*l,this._w=c*h*l-u*p*d):"XZY"===o&&(this._x=u*h*l-c*p*d,this._y=c*p*l-u*h*d,this._z=c*h*d+u*p*l,this._w=c*h*l+u*p*d),t!==!1&&this.onChangeCallback(),this},setFromAxisAngle:function(e,t){var r=t/2,n=Math.sin(r);return this._x=e.x*n,this._y=e.y*n,this._z=e.z*n,this._w=Math.cos(r),this.onChangeCallback(),this},setFromRotationMatrix:function(e){var t,r=e.elements,n=r[0],i=r[4],o=r[8],a=r[1],s=r[5],c=r[9],h=r[2],l=r[6],u=r[10],p=n+s+u;return p>0?(t=.5/Math.sqrt(p+1),this._w=.25/t,this._x=(l-c)*t,this._y=(o-h)*t,this._z=(a-i)*t):n>s&&n>u?(t=2*Math.sqrt(1+n-s-u),this._w=(l-c)/t,this._x=.25*t,this._y=(i+a)/t,this._z=(o+h)/t):s>u?(t=2*Math.sqrt(1+s-n-u),this._w=(o-h)/t,this._x=(i+a)/t,this._y=.25*t,this._z=(c+l)/t):(t=2*Math.sqrt(1+u-n-s),this._w=(a-i)/t,this._x=(o+h)/t,this._y=(c+l)/t,this._z=.25*t),this.onChangeCallback(),this},setFromUnitVectors:function(){var e,t=new o,r=1e-6;return function(n,i){return void 0===t&&(t=new o),e=n.dot(i)+1,eMath.abs(n.z)?t.set(-n.y,n.x,0):t.set(0,-n.z,n.y)):t.crossVectors(n,i),this._x=t.x,this._y=t.y,this._z=t.z,this._w=e,this.normalize()}}(),inverse:function(){return this.conjugate()},conjugate:function(){return this._x*=-1,this._y*=-1,this._z*=-1,this.onChangeCallback(),this},dot:function(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w},lengthSq:function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},length:function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},normalize:function(){var e=this.length();return 0===e?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this.onChangeCallback(),this},multiply:function(e,t){return void 0!==t?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(e,t)):this.multiplyQuaternions(this,e)},premultiply:function(e){return this.multiplyQuaternions(e,this)},multiplyQuaternions:function(e,t){var r=e._x,n=e._y,i=e._z,o=e._w,a=t._x,s=t._y,c=t._z,h=t._w;return this._x=r*h+o*a+n*c-i*s,this._y=n*h+o*s+i*a-r*c,this._z=i*h+o*c+r*s-n*a,this._w=o*h-r*a-n*s-i*c,this.onChangeCallback(),this},slerp:function(e,t){if(0===t)return this;if(1===t)return this.copy(e);var r=this._x,n=this._y,i=this._z,o=this._w,a=o*e._w+r*e._x+n*e._y+i*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=o,this._x=r,this._y=n,this._z=i,this;var s=Math.sqrt(1-a*a);if(Math.abs(s)<.001)return this._w=.5*(o+this._w),this._x=.5*(r+this._x),this._y=.5*(n+this._y),this._z=.5*(i+this._z),this;var c=Math.atan2(s,a),h=Math.sin((1-t)*c)/s,l=Math.sin(t*c)/s;return this._w=o*h+this._w*l,this._x=r*h+this._x*l,this._y=n*h+this._y*l,this._z=i*h+this._z*l,this.onChangeCallback(),this},equals:function(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w},fromArray:function(e,t){return void 0===t&&(t=0),this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this.onChangeCallback(),this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e},onChange:function(e){return this.onChangeCallback=e,this},onChangeCallback:function(){}}),Object.assign(o.prototype,{isVector3:!0,set:function(e,t,r){return this.x=e,this.y=t,this.z=r,this},setScalar:function(e){return this.x=e,this.y=e,this.z=e,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setZ:function(e){return this.z=e,this},setComponent:function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}},clone:function(){return new this.constructor(this.x,this.y,this.z)},copy:function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this},add:function(e,t){return void 0!==t?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this)},addScalar:function(e){return this.x+=e,this.y+=e,this.z+=e,this},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this},addScaledVector:function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this},sub:function(e,t){return void 0!==t?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this)},subScalar:function(e){return this.x-=e,this.y-=e,this.z-=e,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this},multiply:function(e,t){return void 0!==t?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(e,t)):(this.x*=e.x,this.y*=e.y,this.z*=e.z,this)},multiplyScalar:function(e){return this.x*=e,this.y*=e,this.z*=e,this},multiplyVectors:function(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this},applyEuler:function(){var e=new i;return function(t){return t&&t.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(e.setFromEuler(t))}}(),applyAxisAngle:function(){var e=new i;return function(t,r){return this.applyQuaternion(e.setFromAxisAngle(t,r))}}(),applyMatrix3:function(e){var t=this.x,r=this.y,n=this.z,i=e.elements;return this.x=i[0]*t+i[3]*r+i[6]*n,this.y=i[1]*t+i[4]*r+i[7]*n,this.z=i[2]*t+i[5]*r+i[8]*n,this},applyMatrix4:function(e){var t=this.x,r=this.y,n=this.z,i=e.elements,o=1/(i[3]*t+i[7]*r+i[11]*n+i[15]);return this.x=(i[0]*t+i[4]*r+i[8]*n+i[12])*o,this.y=(i[1]*t+i[5]*r+i[9]*n+i[13])*o,this.z=(i[2]*t+i[6]*r+i[10]*n+i[14])*o,this},applyQuaternion:function(e){var t=this.x,r=this.y,n=this.z,i=e.x,o=e.y,a=e.z,s=e.w,c=s*t+o*n-a*r,h=s*r+a*t-i*n,l=s*n+i*r-o*t,u=-i*t-o*r-a*n;return this.x=c*s+u*-i+h*-a-l*-o,this.y=h*s+u*-o+l*-i-c*-a,this.z=l*s+u*-a+c*-o-h*-i,this},project:function(){var e=new n;return function(t){return e.multiplyMatrices(t.projectionMatrix,e.getInverse(t.matrixWorld)),this.applyMatrix4(e)}}(),unproject:function(){var e=new n;return function(t){return e.multiplyMatrices(t.matrixWorld,e.getInverse(t.projectionMatrix)),this.applyMatrix4(e)}}(),transformDirection:function(e){var t=this.x,r=this.y,n=this.z,i=e.elements;return this.x=i[0]*t+i[4]*r+i[8]*n,this.y=i[1]*t+i[5]*r+i[9]*n,this.z=i[2]*t+i[6]*r+i[10]*n,this.normalize()},divide:function(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this},divideScalar:function(e){return this.multiplyScalar(1/e)},min:function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this},max:function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this},clamp:function(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this},clampScalar:function(){var e=new o,t=new o;return function(r,n){return e.set(r,r,r),t.set(n,n,n),this.clamp(e,t)}}(),clampLength:function(e,t){var r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(t,r)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},dot:function(e){return this.x*e.x+this.y*e.y+this.z*e.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length()||1)},setLength:function(e){return this.normalize().multiplyScalar(e)},lerp:function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this},lerpVectors:function(e,t,r){return this.subVectors(t,e).multiplyScalar(r).add(e)},cross:function(e,t){return void 0!==t?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(e,t)):this.crossVectors(this,e)},crossVectors:function(e,t){var r=e.x,n=e.y,i=e.z,o=t.x,a=t.y,s=t.z;return this.x=n*s-i*a,this.y=i*o-r*s,this.z=r*a-n*o,this},projectOnVector:function(e){var t=e.dot(this)/e.lengthSq();return this.copy(e).multiplyScalar(t)},projectOnPlane:function(){var e=new o;return function(t){return e.copy(this).projectOnVector(t),this.sub(e)}}(),reflect:function(){var e=new o;return function(t){return this.sub(e.copy(t).multiplyScalar(2*this.dot(t)))}}(),angleTo:function(e){var t=this.dot(e)/Math.sqrt(this.lengthSq()*e.lengthSq());return Math.acos(Sc.clamp(t,-1,1))},distanceTo:function(e){return Math.sqrt(this.distanceToSquared(e))},distanceToSquared:function(e){var t=this.x-e.x,r=this.y-e.y,n=this.z-e.z;return t*t+r*r+n*n},manhattanDistanceTo:function(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)},setFromSpherical:function(e){var t=Math.sin(e.phi)*e.radius;return this.x=t*Math.sin(e.theta),this.y=Math.cos(e.phi)*e.radius,this.z=t*Math.cos(e.theta),this},setFromCylindrical:function(e){return this.x=e.radius*Math.sin(e.theta),this.y=e.y,this.z=e.radius*Math.cos(e.theta),this},setFromMatrixPosition:function(e){var t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this},setFromMatrixScale:function(e){var t=this.setFromMatrixColumn(e,0).length(),r=this.setFromMatrixColumn(e,1).length(),n=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=r,this.z=n,this},setFromMatrixColumn:function(e,t){return this.fromArray(e.elements,4*t)},equals:function(e){return e.x===this.x&&e.y===this.y&&e.z===this.z},fromArray:function(e,t){return void 0===t&&(t=0),this.x=e[t],this.y=e[t+1],this.z=e[t+2],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e},fromBufferAttribute:function(e,t,r){return void 0!==r&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}}),Object.assign(a.prototype,{isMatrix3:!0,set:function(e,t,r,n,i,o,a,s,c){var h=this.elements;return h[0]=e,h[1]=n,h[2]=a,h[3]=t,h[4]=i,h[5]=s,h[6]=r,h[7]=o,h[8]=c,this},identity:function(){return this.set(1,0,0,0,1,0,0,0,1),this},clone:function(){return(new this.constructor).fromArray(this.elements)},copy:function(e){var t=this.elements,r=e.elements;return t[0]=r[0],t[1]=r[1],t[2]=r[2],t[3]=r[3],t[4]=r[4],t[5]=r[5],t[6]=r[6],t[7]=r[7],t[8]=r[8],this},setFromMatrix4:function(e){var t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this},applyToBufferAttribute:function(){var e=new o;return function(t){for(var r=0,n=t.count;r2048||t.height>2048?t.toDataURL("image/jpeg",.6):t.toDataURL("image/png")}var r=void 0===e||"string"==typeof e;if(!r&&void 0!==e.textures[this.uuid])return e.textures[this.uuid];var n={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY};if(void 0!==this.image){var i=this.image;void 0===i.uuid&&(i.uuid=Sc.generateUUID()),r||void 0!==e.images[i.uuid]||(e.images[i.uuid]={uuid:i.uuid,url:t(i)}),n.image=i.uuid}return r||(e.textures[this.uuid]=n),n},dispose:function(){this.dispatchEvent({type:"dispose"})},transformUv:function(e){if(this.mapping===Ka){if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case as:e.x=e.x-Math.floor(e.x);break;case ss:e.x=e.x<0?0:1;break;case cs:1===Math.abs(Math.floor(e.x)%2)?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case as:e.y=e.y-Math.floor(e.y);break;case ss:e.y=e.y<0?0:1;break;case cs:1===Math.abs(Math.floor(e.y)%2)?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y)}this.flipY&&(e.y=1-e.y)}}}),Object.defineProperty(s.prototype,"needsUpdate",{set:function(e){e===!0&&this.version++}}),Object.assign(c.prototype,{isVector4:!0,set:function(e,t,r,n){return this.x=e,this.y=t,this.z=r,this.w=n,this},setScalar:function(e){return this.x=e,this.y=e,this.z=e,this.w=e,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setZ:function(e){return this.z=e,this},setW:function(e){return this.w=e,this},setComponent:function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}},clone:function(){return new this.constructor(this.x,this.y,this.z,this.w)},copy:function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=void 0!==e.w?e.w:1,this},add:function(e,t){return void 0!==t?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this)},addScalar:function(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this},addScaledVector:function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this},sub:function(e,t){return void 0!==t?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this)},subScalar:function(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this},multiplyScalar:function(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this},applyMatrix4:function(e){var t=this.x,r=this.y,n=this.z,i=this.w,o=e.elements;return this.x=o[0]*t+o[4]*r+o[8]*n+o[12]*i,this.y=o[1]*t+o[5]*r+o[9]*n+o[13]*i,this.z=o[2]*t+o[6]*r+o[10]*n+o[14]*i,this.w=o[3]*t+o[7]*r+o[11]*n+o[15]*i,this},divideScalar:function(e){return this.multiplyScalar(1/e)},setAxisAngleFromQuaternion:function(e){this.w=2*Math.acos(e.w);var t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this},setAxisAngleFromRotationMatrix:function(e){var t,r,n,i,o=.01,a=.1,s=e.elements,c=s[0],h=s[4],l=s[8],u=s[1],p=s[5],d=s[9],f=s[2],m=s[6],v=s[10];if(Math.abs(h-u)y&&g>x?gx?yi&&(i=h),l>o&&(o=l),u>a&&(a=u)}return this.min.set(t,r,n),this.max.set(i,o,a),this},setFromBufferAttribute:function(e){for(var t=+(1/0),r=+(1/0),n=+(1/0),i=-(1/0),o=-(1/0),a=-(1/0),s=0,c=e.count;si&&(i=h),l>o&&(o=l),u>a&&(a=u)}return this.min.set(t,r,n),this.max.set(i,o,a),this},setFromPoints:function(e){this.makeEmpty();for(var t=0,r=e.length;tthis.max.x||e.ythis.max.y||e.zthis.max.z)},containsBox:function(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z},getParameter:function(e,t){return void 0===t&&(console.warn("THREE.Box3: .getParameter() target is now required"),t=new o),t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))},intersectsBox:function(e){return!(e.max.xthis.max.x||e.max.ythis.max.y||e.max.zthis.max.z)},intersectsSphere:function(){var e=new o;return function(t){return this.clampPoint(t.center,e),e.distanceToSquared(t.center)<=t.radius*t.radius}}(),intersectsPlane:function(e){var t,r;return e.normal.x>0?(t=e.normal.x*this.min.x,r=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,r=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,r+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,r+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,r+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,r+=e.normal.z*this.min.z),t<=e.constant&&r>=e.constant},intersectsTriangle:function(){function e(e){var i,o;for(i=0,o=e.length-3;i<=o;i+=3){c.fromArray(e,i);var a=l.x*Math.abs(c.x)+l.y*Math.abs(c.y)+l.z*Math.abs(c.z),s=t.dot(c),h=r.dot(c),u=n.dot(c);if(Math.max(-Math.max(s,h,u),Math.min(s,h,u))>a)return!1}return!0}var t=new o,r=new o,n=new o,i=new o,a=new o,s=new o,c=new o,h=new o,l=new o,u=new o;return function(o){if(this.isEmpty())return!1;this.getCenter(h),l.subVectors(this.max,h),t.subVectors(o.a,h),r.subVectors(o.b,h),n.subVectors(o.c,h),i.subVectors(r,t),a.subVectors(n,r),s.subVectors(t,n);var c=[0,-i.z,i.y,0,-a.z,a.y,0,-s.z,s.y,i.z,0,-i.x,a.z,0,-a.x,s.z,0,-s.x,-i.y,i.x,0,-a.y,a.x,0,-s.y,s.x,0];return!!e(c)&&(c=[1,0,0,0,1,0,0,0,1],!!e(c)&&(u.crossVectors(i,a),c=[u.x,u.y,u.z],e(c)))}}(),clampPoint:function(e,t){return void 0===t&&(console.warn("THREE.Box3: .clampPoint() target is now required"),t=new o),t.copy(e).clamp(this.min,this.max)},distanceToPoint:function(){var e=new o;return function(t){var r=e.copy(t).clamp(this.min,this.max);return r.sub(t).length()}}(),getBoundingSphere:function(){var e=new o;return function(t){return void 0===t&&(console.warn("THREE.Box3: .getBoundingSphere() target is now required"),t=new d),this.getCenter(t.center),t.radius=.5*this.getSize(e).length(),t}}(),intersect:function(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this},union:function(e){return this.min.min(e.min),this.max.max(e.max),this},applyMatrix4:function(){var e=[new o,new o,new o,new o,new o,new o,new o,new o];return function(t){return this.isEmpty()?this:(e[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),e[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),e[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),e[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),e[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),e[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),e[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),e[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(e),this)}}(),translate:function(e){return this.min.add(e),this.max.add(e),this},equals:function(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}),Object.assign(d.prototype,{set:function(e,t){return this.center.copy(e),this.radius=t,this},setFromPoints:function(){var e=new p;return function(t,r){var n=this.center;void 0!==r?n.copy(r):e.setFromPoints(t).getCenter(n);for(var i=0,o=0,a=t.length;othis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t},getBoundingBox:function(e){return void 0===e&&(console.warn("THREE.Sphere: .getBoundingBox() target is now required"),e=new p),e.set(this.center,this.center),e.expandByScalar(this.radius),e},applyMatrix4:function(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this},translate:function(e){return this.center.add(e),this},equals:function(e){return e.center.equals(this.center)&&e.radius===this.radius}}),Object.assign(f.prototype,{set:function(e,t){return this.normal.copy(e),this.constant=t,this},setComponents:function(e,t,r,n){return this.normal.set(e,t,r),this.constant=n,this},setFromNormalAndCoplanarPoint:function(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this},setFromCoplanarPoints:function(){var e=new o,t=new o;return function(r,n,i){var o=e.subVectors(i,n).cross(t.subVectors(r,n)).normalize();return this.setFromNormalAndCoplanarPoint(o,r),this}}(),clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.normal.copy(e.normal),this.constant=e.constant,this},normalize:function(){var e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this},negate:function(){return this.constant*=-1,this.normal.negate(),this},distanceToPoint:function(e){return this.normal.dot(e)+this.constant},distanceToSphere:function(e){return this.distanceToPoint(e.center)-e.radius},projectPoint:function(e,t){return void 0===t&&(console.warn("THREE.Plane: .projectPoint() target is now required"),t=new o),t.copy(this.normal).multiplyScalar(-this.distanceToPoint(e)).add(e)},intersectLine:function(){var e=new o;return function(t,r){void 0===r&&(console.warn("THREE.Plane: .intersectLine() target is now required"),r=new o);var n=t.delta(e),i=this.normal.dot(n);if(0!==i){var a=-(t.start.dot(this.normal)+this.constant)/i;if(!(a<0||a>1))return r.copy(n).multiplyScalar(a).add(t.start)}else if(0===this.distanceToPoint(t.start))return r.copy(t.start)}}(),intersectsLine:function(e){var t=this.distanceToPoint(e.start),r=this.distanceToPoint(e.end);return t<0&&r>0||r<0&&t>0},intersectsBox:function(e){return e.intersectsPlane(this)},intersectsSphere:function(e){return e.intersectsPlane(this)},coplanarPoint:function(e){return void 0===e&&(console.warn("THREE.Plane: .coplanarPoint() target is now required"),e=new o),e.copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(){var e=new o,t=new a;return function(r,n){var i=n||t.getNormalMatrix(r),o=this.coplanarPoint(e).applyMatrix4(r),a=this.normal.applyMatrix3(i).normalize();return this.constant=-o.dot(a),this}}(),translate:function(e){return this.constant-=e.dot(this.normal),this},equals:function(e){return e.normal.equals(this.normal)&&e.constant===this.constant}}),Object.assign(m.prototype,{set:function(e,t,r,n,i,o){var a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(r),a[3].copy(n),a[4].copy(i),a[5].copy(o),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){for(var t=this.planes,r=0;r<6;r++)t[r].copy(e.planes[r]);return this},setFromMatrix:function(e){var t=this.planes,r=e.elements,n=r[0],i=r[1],o=r[2],a=r[3],s=r[4],c=r[5],h=r[6],l=r[7],u=r[8],p=r[9],d=r[10],f=r[11],m=r[12],v=r[13],g=r[14],y=r[15];return t[0].setComponents(a-n,l-s,f-u,y-m).normalize(),t[1].setComponents(a+n,l+s,f+u,y+m).normalize(),t[2].setComponents(a+i,l+c,f+p,y+v).normalize(),t[3].setComponents(a-i,l-c,f-p,y-v).normalize(),t[4].setComponents(a-o,l-h,f-d,y-g).normalize(),t[5].setComponents(a+o,l+h,f+d,y+g).normalize(),this},intersectsObject:function(){var e=new d;return function(t){var r=t.geometry;return null===r.boundingSphere&&r.computeBoundingSphere(),e.copy(r.boundingSphere).applyMatrix4(t.matrixWorld),this.intersectsSphere(e)}}(),intersectsSprite:function(){var e=new d;return function(t){return e.center.set(0,0,0),e.radius=.7071067811865476,e.applyMatrix4(t.matrixWorld),this.intersectsSphere(e)}}(),intersectsSphere:function(e){for(var t=this.planes,r=e.center,n=-e.radius,i=0;i<6;i++){var o=t[i].distanceToPoint(r);if(o0?r.min.x:r.max.x,t.x=o.normal.x>0?r.max.x:r.min.x,e.y=o.normal.y>0?r.min.y:r.max.y,t.y=o.normal.y>0?r.max.y:r.min.y,e.z=o.normal.z>0?r.min.z:r.max.z,t.z=o.normal.z>0?r.max.z:r.min.z;var a=o.distanceToPoint(e),s=o.distanceToPoint(t);if(a<0&&s<0)return!1}return!0}}(),containsPoint:function(e){for(var t=this.planes,r=0;r<6;r++)if(t[r].distanceToPoint(e)<0)return!1;return!0}});var Rc="#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif\n",Lc="#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif\n",Pc="#ifdef ALPHATEST\n\tif ( diffuseColor.a < ALPHATEST ) discard;\n#endif\n",Cc="#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_ENVMAP ) && defined( PHYSICAL )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );\n\t#endif\n#endif\n",Oc="#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",Ic="\nvec3 transformed = vec3( position );\n",Nc="\nvec3 objectNormal = vec3( normal );\n",Dc="float punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\tif( decayExponent > 0.0 ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tfloat maxDistanceCutoffFactor = pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\treturn distanceFalloff * maxDistanceCutoffFactor;\n#else\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n#endif\n\t}\n\treturn 1.0;\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNL = saturate( dot( geometry.normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\nvec3 BRDF_Specular_GGX_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;\n\treturn specularColor * AB.x + AB.y;\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n",Uc="#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 );\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif\n",Bc="#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vViewPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vViewPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\tif ( clipped ) discard;\n\t#endif\n#endif\n",Hc="#if NUM_CLIPPING_PLANES > 0\n\t#if ! defined( PHYSICAL ) && ! defined( PHONG )\n\t\tvarying vec3 vViewPosition;\n\t#endif\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif\n",zc="#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n\tvarying vec3 vViewPosition;\n#endif\n",Fc="#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n",Gc="#ifdef USE_COLOR\n\tdiffuseColor.rgb *= vColor;\n#endif",Vc="#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif\n",jc="#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif",kc="#ifdef USE_COLOR\n\tvColor.xyz = color.xyz;\n#endif",Wc="#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI_HALF 1.5707963267949\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#define whiteCompliment(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}\n",Xc="#ifdef ENVMAP_TYPE_CUBE_UV\n#define cubeUV_textureSize (1024.0)\nint getFaceFromDirection(vec3 direction) {\n\tvec3 absDirection = abs(direction);\n\tint face = -1;\n\tif( absDirection.x > absDirection.z ) {\n\t\tif(absDirection.x > absDirection.y )\n\t\t\tface = direction.x > 0.0 ? 0 : 3;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\telse {\n\t\tif(absDirection.z > absDirection.y )\n\t\t\tface = direction.z > 0.0 ? 2 : 5;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\treturn face;\n}\n#define cubeUV_maxLods1 (log2(cubeUV_textureSize*0.25) - 1.0)\n#define cubeUV_rangeClamp (exp2((6.0 - 1.0) * 2.0))\nvec2 MipLevelInfo( vec3 vec, float roughnessLevel, float roughness ) {\n\tfloat scale = exp2(cubeUV_maxLods1 - roughnessLevel);\n\tfloat dxRoughness = dFdx(roughness);\n\tfloat dyRoughness = dFdy(roughness);\n\tvec3 dx = dFdx( vec * scale * dxRoughness );\n\tvec3 dy = dFdy( vec * scale * dyRoughness );\n\tfloat d = max( dot( dx, dx ), dot( dy, dy ) );\n\td = clamp(d, 1.0, cubeUV_rangeClamp);\n\tfloat mipLevel = 0.5 * log2(d);\n\treturn vec2(floor(mipLevel), fract(mipLevel));\n}\n#define cubeUV_maxLods2 (log2(cubeUV_textureSize*0.25) - 2.0)\n#define cubeUV_rcpTextureSize (1.0 / cubeUV_textureSize)\nvec2 getCubeUV(vec3 direction, float roughnessLevel, float mipLevel) {\n\tmipLevel = roughnessLevel > cubeUV_maxLods2 - 3.0 ? 0.0 : mipLevel;\n\tfloat a = 16.0 * cubeUV_rcpTextureSize;\n\tvec2 exp2_packed = exp2( vec2( roughnessLevel, mipLevel ) );\n\tvec2 rcp_exp2_packed = vec2( 1.0 ) / exp2_packed;\n\tfloat powScale = exp2_packed.x * exp2_packed.y;\n\tfloat scale = rcp_exp2_packed.x * rcp_exp2_packed.y * 0.25;\n\tfloat mipOffset = 0.75*(1.0 - rcp_exp2_packed.y) * rcp_exp2_packed.x;\n\tbool bRes = mipLevel == 0.0;\n\tscale = bRes && (scale < a) ? a : scale;\n\tvec3 r;\n\tvec2 offset;\n\tint face = getFaceFromDirection(direction);\n\tfloat rcpPowScale = 1.0 / powScale;\n\tif( face == 0) {\n\t\tr = vec3(direction.x, -direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 1) {\n\t\tr = vec3(direction.y, direction.x, direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 2) {\n\t\tr = vec3(direction.z, direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 3) {\n\t\tr = vec3(direction.x, direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse if( face == 4) {\n\t\tr = vec3(direction.y, direction.x, -direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse {\n\t\tr = vec3(direction.z, -direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\tr = normalize(r);\n\tfloat texelOffset = 0.5 * cubeUV_rcpTextureSize;\n\tvec2 s = ( r.yz / abs( r.x ) + vec2( 1.0 ) ) * 0.5;\n\tvec2 base = offset + vec2( texelOffset );\n\treturn base + s * ( scale - 2.0 * texelOffset );\n}\n#define cubeUV_maxLods3 (log2(cubeUV_textureSize*0.25) - 3.0)\nvec4 textureCubeUV(vec3 reflectedDirection, float roughness ) {\n\tfloat roughnessVal = roughness* cubeUV_maxLods3;\n\tfloat r1 = floor(roughnessVal);\n\tfloat r2 = r1 + 1.0;\n\tfloat t = fract(roughnessVal);\n\tvec2 mipInfo = MipLevelInfo(reflectedDirection, r1, roughness);\n\tfloat s = mipInfo.y;\n\tfloat level0 = mipInfo.x;\n\tfloat level1 = level0 + 1.0;\n\tlevel1 = level1 > 5.0 ? 5.0 : level1;\n\tlevel0 += min( floor( s + 0.5 ), 5.0 );\n\tvec2 uv_10 = getCubeUV(reflectedDirection, r1, level0);\n\tvec4 color10 = envMapTexelToLinear(texture2D(envMap, uv_10));\n\tvec2 uv_20 = getCubeUV(reflectedDirection, r2, level0);\n\tvec4 color20 = envMapTexelToLinear(texture2D(envMap, uv_20));\n\tvec4 result = mix(color10, color20, t);\n\treturn vec4(result.rgb, 1.0);\n}\n#endif\n",qc="vec3 transformedNormal = normalMatrix * objectNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n",Yc="#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif\n",Zc="#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, uv ).x * displacementScale + displacementBias );\n#endif\n",Jc="#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif\n",Qc="#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif\n",Kc=" gl_FragColor = linearToOutputTexel( gl_FragColor );\n",$c="\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.xyz * value.w * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = min( floor( D ) / 255.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = value.rgb * cLogLuvM;\n\tXp_Y_XYZp = max(Xp_Y_XYZp, vec3(1e-6, 1e-6, 1e-6));\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract(Le);\n\tvResult.z = (Le - (floor(vResult.w*255.0))/255.0)/255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2((Le - 127.0) / 2.0);\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = Xp_Y_XYZp.rgb * cLogLuvInverseM;\n\treturn vec4( max(vRGB, 0.0), 1.0 );\n}\n",eh="#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\tvec2 sampleUV;\n\t\treflectVec = normalize( reflectVec );\n\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\tvec4 envColor = texture2D( envMap, sampleUV );\n\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\treflectVec = normalize( reflectVec );\n\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) );\n\t\tvec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\tenvColor = envMapTexelToLinear( envColor );\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif\n",th="#if defined( USE_ENVMAP ) || defined( PHYSICAL )\n\tuniform float reflectivity;\n\tuniform float envMapIntensity;\n#endif\n#ifdef USE_ENVMAP\n\t#if ! defined( PHYSICAL ) && ( defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) )\n\t\tvarying vec3 vWorldPosition;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\tuniform float flipEnvMap;\n\tuniform int maxMipLevel;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( PHYSICAL )\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif\n",rh="#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif\n",nh="#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif\n",ih="\n#ifdef USE_FOG\nfogDepth = -mvPosition.z;\n#endif",oh="#ifdef USE_FOG\n varying float fogDepth;\n#endif\n",ah="#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * fogDepth * fogDepth * LOG2 ) );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif\n",sh="#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float fogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif\n",ch="#ifdef TOON\n\tuniform sampler2D gradientMap;\n\tvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\t\tfloat dotNL = dot( normal, lightDirection );\n\t\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t\t#ifdef USE_GRADIENTMAP\n\t\t\treturn texture2D( gradientMap, coord ).rgb;\n\t\t#else\n\t\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t\t#endif\n\t}\n#endif\n",hh="#ifdef USE_LIGHTMAP\n\treflectedLight.indirectDiffuse += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n#endif\n",lh="#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",uh="vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\n#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvLightFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n#endif\n",ph="uniform vec3 ambientLightColor;\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tdirectLight.color = directionalLight.color;\n\t\tdirectLight.direction = directionalLight.direction;\n\t\tdirectLight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t\tfloat shadowCameraNear;\n\t\tfloat shadowCameraFar;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tdirectLight.color = pointLight.color;\n\t\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n\t\tdirectLight.visible = ( directLight.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\n\t\tif ( angleCos > spotLight.coneCos ) {\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\t\tdirectLight.color = spotLight.color;\n\t\t\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tirradiance *= PI;\n\t\t#endif\n\t\treturn irradiance;\n\t}\n#endif\n",dh="#if defined( USE_ENVMAP ) && defined( PHYSICAL )\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( queryVec, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar + 0.79248 - 0.5 * log2( pow2( blinnShininessExponent ) + 1.0 );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in GeometricContext geometry, const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( -geometry.viewDir, geometry.normal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( -geometry.viewDir, geometry.normal, refractionRatio );\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( blinnShininessExponent, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\tvec4 envMapColor = textureCubeUV(queryReflectVec, BlinnExponentToGGXRoughness(blinnShininessExponent));\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\t\tvec2 sampleUV;\n\t\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0,0.0,1.0 ) );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#endif\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\n#endif\n",fh="BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;\n",mh="varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\n\tvec3\tdiffuseColor;\n\tvec3\tspecularColor;\n\tfloat\tspecularShininess;\n\tfloat\tspecularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\t#ifdef TOON\n\t\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\t#else\n\t\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\t\tvec3 irradiance = dotNL * directLight.color;\n\t#endif\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)\n",vh="PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );\n#ifdef STANDARD\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.clearCoat = saturate( clearCoat );\tmaterial.clearCoatRoughness = clamp( clearCoatRoughness, 0.04, 1.0 );\n#endif\n",gh="struct PhysicalMaterial {\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n\t#ifndef STANDARD\n\t\tfloat clearCoat;\n\t\tfloat clearCoatRoughness;\n\t#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearCoatDHRApprox( const in float roughness, const in float dotNL ) {\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.specularRoughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos - halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos + halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos + halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos - halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\t#ifndef STANDARD\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.directSpecular += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry, material.specularColor, material.specularRoughness );\n\treflectedLight.directDiffuse += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\t#ifndef STANDARD\n\t\treflectedLight.directSpecular += irradiance * material.clearCoat * BRDF_Specular_GGX( directLight, geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 clearCoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t#ifndef STANDARD\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\tfloat dotNL = dotNV;\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.indirectSpecular += ( 1.0 - clearCoatDHR ) * radiance * BRDF_Specular_GGX_Environment( geometry, material.specularColor, material.specularRoughness );\n\t#ifndef STANDARD\n\t\treflectedLight.indirectSpecular += clearCoatRadiance * material.clearCoat * BRDF_Specular_GGX_Environment( geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\n#define Material_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.specularRoughness )\n#define Material_ClearCoat_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.clearCoatRoughness )\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}\n",yh="\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = normalize( vViewPosition );\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( pointLight.shadow, directLight.visible ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( spotLight.shadow, directLight.visible ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( directionalLight.shadow, directLight.visible ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearCoatRadiance = vec3( 0.0 );\n#endif\n",xh="#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec3 lightMapIrradiance = texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( PHYSICAL ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tirradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getLightProbeIndirectRadiance( geometry, Material_BlinnShininessExponent( material ), maxMipLevel );\n\t#ifndef STANDARD\n\t\tclearCoatRadiance += getLightProbeIndirectRadiance( geometry, Material_ClearCoat_BlinnShininessExponent( material ), maxMipLevel );\n\t#endif\n#endif\n",bh="#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, clearCoatRadiance, geometry, material, reflectedLight );\n#endif\n",wh="#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",_h="#ifdef USE_LOGDEPTHBUF\n\tuniform float logDepthBufFC;\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#endif\n#endif\n",Eh="#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#endif\n\tuniform float logDepthBufFC;\n#endif",Mh="#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t#else\n\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\tgl_Position.z *= gl_Position.w;\n\t#endif\n#endif\n",Th="#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif\n",Sh="#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n",Ah="#ifdef USE_MAP\n\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\tvec4 mapTexel = texture2D( map, uv );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n",Rh="#ifdef USE_MAP\n\tuniform mat3 uvTransform;\n\tuniform sampler2D map;\n#endif\n",Lh="float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif\n",Ph="#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",Ch="#ifdef USE_MORPHNORMALS\n\tobjectNormal += ( morphNormal0 - normal ) * morphTargetInfluences[ 0 ];\n\tobjectNormal += ( morphNormal1 - normal ) * morphTargetInfluences[ 1 ];\n\tobjectNormal += ( morphNormal2 - normal ) * morphTargetInfluences[ 2 ];\n\tobjectNormal += ( morphNormal3 - normal ) * morphTargetInfluences[ 3 ];\n#endif\n",Oh="#ifdef USE_MORPHTARGETS\n\t#ifndef USE_MORPHNORMALS\n\tuniform float morphTargetInfluences[ 8 ];\n\t#else\n\tuniform float morphTargetInfluences[ 4 ];\n\t#endif\n#endif",Ih="#ifdef USE_MORPHTARGETS\n\ttransformed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\n\ttransformed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\n\ttransformed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\n\ttransformed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\n\t#ifndef USE_MORPHNORMALS\n\ttransformed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\n\ttransformed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\n\ttransformed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\n\ttransformed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\n\t#endif\n#endif\n",Nh="#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n#endif\n",Dh="#ifdef USE_NORMALMAP\n\tnormal = perturbNormal2Arb( -vViewPosition, normal );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n#endif\n",Uh="#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm ) {\n\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tfloat scale = sign( st1.t * st0.s - st0.t * st1.s );\t\tscale *= float( gl_FrontFacing ) * 2.0 - 1.0;\n\t\tvec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );\n\t\tvec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );\n\t\tvec3 N = normalize( surf_norm );\n\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\tmapN.xy = normalScale * mapN.xy;\n\t\tmat3 tsn = mat3( S, T, N );\n\t\treturn normalize( tsn * mapN );\n\t}\n#endif\n",Bh="vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn (( near + viewZ ) * far ) / (( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}\n",Hh="#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif\n",zh="vec4 mvPosition = modelViewMatrix * vec4( transformed, 1.0 );\ngl_Position = projectionMatrix * mvPosition;\n",Fh="#if defined( DITHERING )\n gl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif\n",Gh="#if defined( DITHERING )\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif\n",Vh="float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif\n",jh="#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",kh="#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tfloat texture2DShadowLerp( sampler2D depths, vec2 size, vec2 uv, float compare ) {\n\t\tconst vec2 offset = vec2( 0.0, 1.0 );\n\t\tvec2 texelSize = vec2( 1.0 ) / size;\n\t\tvec2 centroidUV = floor( uv * size + 0.5 ) / size;\n\t\tfloat lb = texture2DCompare( depths, centroidUV + texelSize * offset.xx, compare );\n\t\tfloat lt = texture2DCompare( depths, centroidUV + texelSize * offset.xy, compare );\n\t\tfloat rb = texture2DCompare( depths, centroidUV + texelSize * offset.yx, compare );\n\t\tfloat rt = texture2DCompare( depths, centroidUV + texelSize * offset.yy, compare );\n\t\tvec2 f = fract( uv * size + 0.5 );\n\t\tfloat a = mix( lb, lt, f.y );\n\t\tfloat b = mix( rb, rt, f.y );\n\t\tfloat c = mix( a, b, f.x );\n\t\treturn c;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tshadow = (\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif\n",Wh="#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n\t#endif\n#endif\n",Xh="#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n#endif\n",qh="float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\tDirectionalLight directionalLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tshadow *= bool( directionalLight.shadow ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\tSpotLight spotLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tshadow *= bool( spotLight.shadow ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\tPointLight pointLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tshadow *= bool( pointLight.shadow ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#endif\n\t#endif\n\treturn shadow;\n}\n",Yh="#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",Zh="#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif\n",Jh="#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif\n",Qh="#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n#endif\n",Kh="float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",$h="#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",el="#if defined( TONE_MAPPING )\n gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif\n",tl="#ifndef saturate\n\t#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nuniform float toneMappingWhitePoint;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\n#define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) )\nvec3 Uncharted2ToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\n",rl="#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n#endif",nl="#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\n",il="#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif",ol="#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif",al="#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n#endif",sl="#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = uv2;\n#endif",cl="#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )\n\tvec4 worldPosition = modelMatrix * vec4( transformed, 1.0 );\n#endif\n",hl="uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldPosition;\nvoid main() {\n\tgl_FragColor = textureCube( tCube, vec3( tFlip * vWorldPosition.x, vWorldPosition.yz ) );\n\tgl_FragColor.a *= opacity;\n}\n",ll="varying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}\n",ul="#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - gl_FragCoord.z ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( gl_FragCoord.z );\n\t#endif\n}\n",pl="#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",dl="#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#include \n\t#include \n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}\n",fl="#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition.xyz;\n}\n",ml="uniform sampler2D tEquirect;\nvarying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldPosition );\n\tvec2 sampleUV;\n\tsampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\tsampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n}\n",vl="varying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}\n",gl="uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",yl="uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvLineDistance = scale * lineDistance;\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}\n",xl="uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\treflectedLight.indirectDiffuse += texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",bl="#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef USE_ENVMAP\n\t#include \n\t#include \n\t#include \n\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",wl="uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\treflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );\n\t#include \n\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",_l="#define LAMBERT\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",El="#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",Ml="#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",Tl="#define PHYSICAL\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifndef STANDARD\n\tuniform float clearCoat;\n\tuniform float clearCoatRoughness;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",Sl="#define PHYSICAL\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}\n",Al="#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}\n",Rl="#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}\n",Ll="uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",Pl="uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#ifdef USE_SIZEATTENUATION\n\t\tgl_PointSize = size * ( scale / - mvPosition.z );\n\t#else\n\t\tgl_PointSize = size;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",Cl="uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include \n}\n",Ol="#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",Il={ alphamap_fragment:Rc,alphamap_pars_fragment:Lc,alphatest_fragment:Pc,aomap_fragment:Cc,aomap_pars_fragment:Oc,begin_vertex:Ic,beginnormal_vertex:Nc,bsdfs:Dc,bumpmap_pars_fragment:Uc,clipping_planes_fragment:Bc,clipping_planes_pars_fragment:Hc,clipping_planes_pars_vertex:zc,clipping_planes_vertex:Fc,color_fragment:Gc,color_pars_fragment:Vc,color_pars_vertex:jc,color_vertex:kc,common:Wc,cube_uv_reflection_fragment:Xc,defaultnormal_vertex:qc,displacementmap_pars_vertex:Yc,displacementmap_vertex:Zc,emissivemap_fragment:Jc,emissivemap_pars_fragment:Qc,encodings_fragment:Kc,encodings_pars_fragment:$c,envmap_fragment:eh,envmap_pars_fragment:th,envmap_pars_vertex:rh,envmap_vertex:nh,fog_vertex:ih,fog_pars_vertex:oh,fog_fragment:ah,fog_pars_fragment:sh,gradientmap_pars_fragment:ch,lightmap_fragment:hh,lightmap_pars_fragment:lh,lights_lambert_vertex:uh,lights_pars_begin:ph,lights_pars_maps:dh,lights_phong_fragment:fh,lights_phong_pars_fragment:mh,lights_physical_fragment:vh,lights_physical_pars_fragment:gh,lights_fragment_begin:yh,lights_fragment_maps:xh,lights_fragment_end:bh,logdepthbuf_fragment:wh,logdepthbuf_pars_fragment:_h,logdepthbuf_pars_vertex:Eh,logdepthbuf_vertex:Mh,map_fragment:Th,map_pars_fragment:Sh,map_particle_fragment:Ah,map_particle_pars_fragment:Rh,metalnessmap_fragment:Lh,metalnessmap_pars_fragment:Ph,morphnormal_vertex:Ch,morphtarget_pars_vertex:Oh,morphtarget_vertex:Ih,normal_fragment_begin:Nh,normal_fragment_maps:Dh,normalmap_pars_fragment:Uh,packing:Bh,premultiplied_alpha_fragment:Hh,project_vertex:zh,dithering_fragment:Fh,dithering_pars_fragment:Gh,roughnessmap_fragment:Vh,roughnessmap_pars_fragment:jh,shadowmap_pars_fragment:kh,shadowmap_pars_vertex:Wh,shadowmap_vertex:Xh,shadowmask_pars_fragment:qh,skinbase_vertex:Yh,skinning_pars_vertex:Zh,skinning_vertex:Jh,skinnormal_vertex:Qh,specularmap_fragment:Kh,specularmap_pars_fragment:$h,tonemapping_fragment:el,tonemapping_pars_fragment:tl,uv_pars_fragment:rl,uv_pars_vertex:nl,uv_vertex:il,uv2_pars_fragment:ol,uv2_pars_vertex:al,uv2_vertex:sl,worldpos_vertex:cl,cube_frag:hl,cube_vert:ll,depth_frag:ul,depth_vert:pl,distanceRGBA_frag:dl,distanceRGBA_vert:fl,equirect_frag:ml,equirect_vert:vl,linedashed_frag:gl,linedashed_vert:yl,meshbasic_frag:xl,meshbasic_vert:bl,meshlambert_frag:wl,meshlambert_vert:_l,meshphong_frag:El,meshphong_vert:Ml,meshphysical_frag:Tl,meshphysical_vert:Sl,normal_frag:Al,normal_vert:Rl,points_frag:Ll,points_vert:Pl,shadow_frag:Cl,shadow_vert:Ol},Nl={merge:function(e){for(var t={},r=0;r>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,this},setRGB:function(e,t,r){return this.r=e,this.g=t,this.b=r,this},setHSL:function(){function e(e,t,r){return r<0&&(r+=1),r>1&&(r-=1),r<1/6?e+6*(t-e)*r:r<.5?t:r<2/3?e+6*(t-e)*(2/3-r):e}return function(t,r,n){if(t=Sc.euclideanModulo(t,1),r=Sc.clamp(r,0,1),n=Sc.clamp(n,0,1),0===r)this.r=this.g=this.b=n;else{var i=n<=.5?n*(1+r):n+r-n*r,o=2*n-i;this.r=e(o,i,t+1/3),this.g=e(o,i,t),this.b=e(o,i,t-1/3)}return this}}(),setStyle:function(e){function t(t){void 0!==t&&parseFloat(t)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}var r;if(r=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(e)){var n,i=r[1],o=r[2];switch(i){case"rgb":case"rgba":if(n=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o))return this.r=Math.min(255,parseInt(n[1],10))/255,this.g=Math.min(255,parseInt(n[2],10))/255,this.b=Math.min(255,parseInt(n[3],10))/255,t(n[5]),this;if(n=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o))return this.r=Math.min(100,parseInt(n[1],10))/100,this.g=Math.min(100,parseInt(n[2],10))/100,this.b=Math.min(100,parseInt(n[3],10))/100,t(n[5]),this;break;case"hsl":case"hsla":if(n=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o)){var a=parseFloat(n[1])/360,s=parseInt(n[2],10)/100,c=parseInt(n[3],10)/100;return t(n[5]),this.setHSL(a,s,c)}}}else if(r=/^\#([A-Fa-f0-9]+)$/.exec(e)){var h=r[1],l=h.length;if(3===l)return this.r=parseInt(h.charAt(0)+h.charAt(0),16)/255,this.g=parseInt(h.charAt(1)+h.charAt(1),16)/255,this.b=parseInt(h.charAt(2)+h.charAt(2),16)/255,this;if(6===l)return this.r=parseInt(h.charAt(0)+h.charAt(1),16)/255,this.g=parseInt(h.charAt(2)+h.charAt(3),16)/255,this.b=parseInt(h.charAt(4)+h.charAt(5),16)/255,this}if(e&&e.length>0){var h=Dl[e];void 0!==h?this.setHex(h):console.warn("THREE.Color: Unknown color "+e)}return this},clone:function(){return new this.constructor(this.r,this.g,this.b)},copy:function(e){return this.r=e.r,this.g=e.g,this.b=e.b,this},copyGammaToLinear:function(e,t){return void 0===t&&(t=2),this.r=Math.pow(e.r,t),this.g=Math.pow(e.g,t),this.b=Math.pow(e.b,t),this},copyLinearToGamma:function(e,t){void 0===t&&(t=2);var r=t>0?1/t:1;return this.r=Math.pow(e.r,r),this.g=Math.pow(e.g,r),this.b=Math.pow(e.b,r),this},convertGammaToLinear:function(){var e=this.r,t=this.g,r=this.b;return this.r=e*e,this.g=t*t,this.b=r*r,this},convertLinearToGamma:function(){return this.r=Math.sqrt(this.r),this.g=Math.sqrt(this.g),this.b=Math.sqrt(this.b),this},getHex:function(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0},getHexString:function(){return("000000"+this.getHex().toString(16)).slice(-6)},getHSL:function(e){void 0===e&&(console.warn("THREE.Color: .getHSL() target is now required"),e={h:0,s:0,l:0});var t,r,n=this.r,i=this.g,o=this.b,a=Math.max(n,i,o),s=Math.min(n,i,o),c=(s+a)/2;if(s===a)t=0,r=0;else{var h=a-s;switch(r=c<=.5?h/(a+s):h/(2-a-s),a){case n:t=(i-o)/h+(i1){for(var t=0;t1){for(var t=0;t0){o.children=[];for(var c=0;c0&&(i.geometries=p),d.length>0&&(i.materials=d),f.length>0&&(i.textures=f),m.length>0&&(i.images=m),s.length>0&&(i.shapes=s)}return i.object=o,i},clone:function(e){return(new this.constructor).copy(this,e)},copy:function(e,t){if(void 0===t&&(t=!0),this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(var r=0;r0)for(var m=0;m0&&(this.normalsNeedUpdate=!0)},computeFlatVertexNormals:function(){var e,t,r;for(this.computeFaceNormals(),e=0,t=this.faces.length;e0&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){var e,t,r,n,i;for(r=0,n=this.faces.length;r=0;r--){var m=d[r];for(this.faces.splice(m,1),a=0,s=this.faceVertexUvs.length;a0,_=g.vertexNormals.length>0,E=1!==g.color.r||1!==g.color.g||1!==g.color.b,M=g.vertexColors.length>0,T=0;if(T=e(T,0,0),T=e(T,1,y),T=e(T,2,x),T=e(T,3,b),T=e(T,4,w),T=e(T,5,_),T=e(T,6,E),T=e(T,7,M),l.push(T),l.push(g.a,g.b,g.c),l.push(g.materialIndex),b){var S=this.faceVertexUvs[0][c];l.push(n(S[0]),n(S[1]),n(S[2]))}if(w&&l.push(t(g.normal)),_){var A=g.vertexNormals;l.push(t(A[0]),t(A[1]),t(A[2]))}if(E&&l.push(r(g.color)),M){var R=g.vertexColors;l.push(r(R[0]),r(R[1]),r(R[2]))}}return i.data={},i.data.vertices=s,i.data.normals=u,d.length>0&&(i.data.colors=d),m.length>0&&(i.data.uvs=[m]),i.data.faces=l,i},clone:function(){return(new M).copy(this)},copy:function(e){var t,r,n,i,o,a;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.name=e.name;var s=e.vertices;for(t=0,r=s.length;t0,s=o[1]&&o[1].length>0,c=e.morphTargets,h=c.length;if(h>0){t=[];for(var l=0;l0){u=[];for(var l=0;l65535?O:P)(e,1):this.index=e},addAttribute:function(e,t){return t&&t.isBufferAttribute||t&&t.isInterleavedBufferAttribute?"index"===e?(console.warn("THREE.BufferGeometry.addAttribute: Use .setIndex() for index attribute."),void this.setIndex(t)):(this.attributes[e]=t,this):(console.warn("THREE.BufferGeometry: .addAttribute() now expects ( name, attribute )."),void this.addAttribute(e,new T(arguments[1],arguments[2])))},getAttribute:function(e){return this.attributes[e]},removeAttribute:function(e){return delete this.attributes[e],this},addGroup:function(e,t,r){this.groups.push({start:e,count:t,materialIndex:void 0!==r?r:0})},clearGroups:function(){this.groups=[]},setDrawRange:function(e,t){this.drawRange.start=e,this.drawRange.count=t},applyMatrix:function(e){var t=this.attributes.position;void 0!==t&&(e.applyToBufferAttribute(t),t.needsUpdate=!0);var r=this.attributes.normal;if(void 0!==r){var n=(new a).getNormalMatrix(e);n.applyToBufferAttribute(r),r.needsUpdate=!0}return null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this},rotateX:function(){var e=new n;return function(t){return e.makeRotationX(t),this.applyMatrix(e),this}}(),rotateY:function(){var e=new n;return function(t){return e.makeRotationY(t),this.applyMatrix(e),this}}(),rotateZ:function(){var e=new n;return function(t){return e.makeRotationZ(t),this.applyMatrix(e),this}}(),translate:function(){var e=new n;return function(t,r,n){return e.makeTranslation(t,r,n),this.applyMatrix(e),this}}(),scale:function(){var e=new n;return function(t,r,n){return e.makeScale(t,r,n),this.applyMatrix(e),this}}(),lookAt:function(){var e=new b;return function(t){e.lookAt(t),e.updateMatrix(),this.applyMatrix(e.matrix)}}(),center:function(){var e=new o;return function(){return this.computeBoundingBox(),this.boundingBox.getCenter(e).negate(),this.translate(e.x,e.y,e.z),this}}(),setFromObject:function(e){var t=e.geometry;if(e.isPoints||e.isLine){var r=new I(3*t.vertices.length,3),n=new I(3*t.colors.length,3);if(this.addAttribute("position",r.copyVector3sArray(t.vertices)),this.addAttribute("color",n.copyColorsArray(t.colors)),t.lineDistances&&t.lineDistances.length===t.vertices.length){var i=new I(t.lineDistances.length,1);this.addAttribute("lineDistance",i.copyArray(t.lineDistances))}null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone())}else e.isMesh&&t&&t.isGeometry&&this.fromGeometry(t);return this},setFromPoints:function(e){for(var t=[],r=0,n=e.length;r0){var r=new Float32Array(3*e.normals.length);this.addAttribute("normal",new T(r,3).copyVector3sArray(e.normals))}if(e.colors.length>0){var n=new Float32Array(3*e.colors.length);this.addAttribute("color",new T(n,3).copyColorsArray(e.colors))}if(e.uvs.length>0){var i=new Float32Array(2*e.uvs.length);this.addAttribute("uv",new T(i,2).copyVector2sArray(e.uvs))}if(e.uvs2.length>0){var o=new Float32Array(2*e.uvs2.length);this.addAttribute("uv2",new T(o,2).copyVector2sArray(e.uvs2))}this.groups=e.groups;for(var a in e.morphTargets){for(var s=[],c=e.morphTargets[a],h=0,l=c.length;h0){var d=new I(4*e.skinIndices.length,4);this.addAttribute("skinIndex",d.copyVector4sArray(e.skinIndices))}if(e.skinWeights.length>0){var f=new I(4*e.skinWeights.length,4);this.addAttribute("skinWeight",f.copyVector4sArray(e.skinWeights))}return null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone()),this},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new p);var e=this.attributes.position;void 0!==e?this.boundingBox.setFromBufferAttribute(e):this.boundingBox.makeEmpty(),(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox: Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)},computeBoundingSphere:function(){var e=new p,t=new o;return function(){null===this.boundingSphere&&(this.boundingSphere=new d);var r=this.attributes.position;if(r){var n=this.boundingSphere.center;e.setFromBufferAttribute(r),e.getCenter(n);for(var i=0,o=0,a=r.count;o0&&(e.data.groups=JSON.parse(JSON.stringify(s)));var c=this.boundingSphere;return null!==c&&(e.data.boundingSphere={center:c.center.toArray(),radius:c.radius}),e},clone:function(){return(new B).copy(this)},copy:function(e){var t,r,n;this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.name=e.name;var i=e.index;null!==i&&this.setIndex(i.clone());var o=e.attributes;for(t in o){var a=o[t];this.addAttribute(t,a.clone())}var s=e.morphAttributes;for(t in s){var c=[],h=s[t];for(r=0,n=h.length;r0&&(n.alphaTest=this.alphaTest),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=this.premultipliedAlpha),this.wireframe===!0&&(n.wireframe=this.wireframe),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),this.morphTargets===!0&&(n.morphTargets=!0),this.skinning===!0&&(n.skinning=!0),this.visible===!1&&(n.visible=!1),"{}"!==JSON.stringify(this.userData)&&(n.userData=this.userData),r){var i=t(e.textures),o=t(e.images);i.length>0&&(n.textures=i),o.length>0&&(n.images=o)}return n},clone:function(){return(new this.constructor).copy(this)},copy:function(e){this.name=e.name,this.fog=e.fog,this.lights=e.lights,this.blending=e.blending,this.side=e.side,this.flatShading=e.flatShading,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.premultipliedAlpha=e.premultipliedAlpha,this.overdraw=e.overdraw,this.visible=e.visible,this.userData=JSON.parse(JSON.stringify(e.userData)),this.clipShadows=e.clipShadows,this.clipIntersection=e.clipIntersection;var t=e.clippingPlanes,r=null;if(null!==t){var n=t.length;r=new Array(n);for(var i=0;i!==n;++i)r[i]=t[i].clone()}return this.clippingPlanes=r,this.shadowSide=e.shadowSide,this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),j.prototype=Object.create(V.prototype),j.prototype.constructor=j,j.prototype.isMeshBasicMaterial=!0,j.prototype.copy=function(e){return V.prototype.copy.call(this,e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this},k.prototype=Object.create(V.prototype),k.prototype.constructor=k,k.prototype.isShaderMaterial=!0,k.prototype.copy=function(e){return V.prototype.copy.call(this,e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Nl.clone(e.uniforms),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.lights=e.lights,this.clipping=e.clipping,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this.extensions=e.extensions,this},k.prototype.toJSON=function(e){var t=V.prototype.toJSON.call(this,e);return t.uniforms=this.uniforms,t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t},Object.assign(W.prototype,{set:function(e,t){return this.origin.copy(e),this.direction.copy(t),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this},at:function(e,t){return void 0===t&&(console.warn("THREE.Ray: .at() target is now required"),t=new o),t.copy(this.direction).multiplyScalar(e).add(this.origin)},lookAt:function(e){return this.direction.copy(e).sub(this.origin).normalize(),this},recast:function(){var e=new o;return function(t){return this.origin.copy(this.at(t,e)),this}}(),closestPointToPoint:function(e,t){void 0===t&&(console.warn("THREE.Ray: .closestPointToPoint() target is now required"),t=new o),t.subVectors(e,this.origin);var r=t.dot(this.direction);return r<0?t.copy(this.origin):t.copy(this.direction).multiplyScalar(r).add(this.origin)},distanceToPoint:function(e){return Math.sqrt(this.distanceSqToPoint(e))},distanceSqToPoint:function(){var e=new o;return function(t){var r=e.subVectors(t,this.origin).dot(this.direction);return r<0?this.origin.distanceToSquared(t):(e.copy(this.direction).multiplyScalar(r).add(this.origin),e.distanceToSquared(t))}}(),distanceSqToSegment:function(){var e=new o,t=new o,r=new o;return function(n,i,o,a){e.copy(n).add(i).multiplyScalar(.5),t.copy(i).sub(n).normalize(),r.copy(this.origin).sub(e);var s,c,h,l,u=.5*n.distanceTo(i),p=-this.direction.dot(t),d=r.dot(this.direction),f=-r.dot(t),m=r.lengthSq(),v=Math.abs(1-p*p);if(v>0)if(s=p*f-d,c=p*d-f,l=u*v,s>=0)if(c>=-l)if(c<=l){var g=1/v;s*=g,c*=g,h=s*(s+p*c+2*d)+c*(p*s+c+2*f)+m}else c=u,s=Math.max(0,-(p*c+d)),h=-s*s+c*(c+2*f)+m;else c=-u,s=Math.max(0,-(p*c+d)),h=-s*s+c*(c+2*f)+m;else c<=-l?(s=Math.max(0,-(-p*u+d)),c=s>0?-u:Math.min(Math.max(-u,-f),u),h=-s*s+c*(c+2*f)+m):c<=l?(s=0,c=Math.min(Math.max(-u,-f),u),h=c*(c+2*f)+m):(s=Math.max(0,-(p*u+d)),c=s>0?u:Math.min(Math.max(-u,-f),u), h=-s*s+c*(c+2*f)+m);else c=p>0?-u:u,s=Math.max(0,-(p*c+d)),h=-s*s+c*(c+2*f)+m;return o&&o.copy(this.direction).multiplyScalar(s).add(this.origin),a&&a.copy(t).multiplyScalar(c).add(e),h}}(),intersectSphere:function(){var e=new o;return function(t,r){e.subVectors(t.center,this.origin);var n=e.dot(this.direction),i=e.dot(e)-n*n,o=t.radius*t.radius;if(i>o)return null;var a=Math.sqrt(o-i),s=n-a,c=n+a;return s<0&&c<0?null:s<0?this.at(c,r):this.at(s,r)}}(),intersectsSphere:function(e){return this.distanceToPoint(e.center)<=e.radius},distanceToPlane:function(e){var t=e.normal.dot(this.direction);if(0===t)return 0===e.distanceToPoint(this.origin)?0:null;var r=-(this.origin.dot(e.normal)+e.constant)/t;return r>=0?r:null},intersectPlane:function(e,t){var r=this.distanceToPlane(e);return null===r?null:this.at(r,t)},intersectsPlane:function(e){var t=e.distanceToPoint(this.origin);if(0===t)return!0;var r=e.normal.dot(this.direction);return r*t<0},intersectBox:function(e,t){var r,n,i,o,a,s,c=1/this.direction.x,h=1/this.direction.y,l=1/this.direction.z,u=this.origin;return c>=0?(r=(e.min.x-u.x)*c,n=(e.max.x-u.x)*c):(r=(e.max.x-u.x)*c,n=(e.min.x-u.x)*c),h>=0?(i=(e.min.y-u.y)*h,o=(e.max.y-u.y)*h):(i=(e.max.y-u.y)*h,o=(e.min.y-u.y)*h),r>o||i>n?null:((i>r||r!==r)&&(r=i),(o=0?(a=(e.min.z-u.z)*l,s=(e.max.z-u.z)*l):(a=(e.max.z-u.z)*l,s=(e.min.z-u.z)*l),r>s||a>n?null:((a>r||r!==r)&&(r=a),(s=0?r:n,t)))},intersectsBox:function(){var e=new o;return function(t){return null!==this.intersectBox(t,e)}}(),intersectTriangle:function(){var e=new o,t=new o,r=new o,n=new o;return function(i,o,a,s,c){t.subVectors(o,i),r.subVectors(a,i),n.crossVectors(t,r);var h,l=this.direction.dot(n);if(l>0){if(s)return null;h=1}else{if(!(l<0))return null;h=-1,l=-l}e.subVectors(this.origin,i);var u=h*this.direction.dot(r.crossVectors(e,r));if(u<0)return null;var p=h*this.direction.dot(t.cross(e));if(p<0)return null;if(u+p>l)return null;var d=-h*e.dot(n);return d<0?null:this.at(d/l,c)}}(),applyMatrix4:function(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this},equals:function(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}}),Object.assign(X.prototype,{set:function(e,t){return this.start.copy(e),this.end.copy(t),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.start.copy(e.start),this.end.copy(e.end),this},getCenter:function(e){return void 0===e&&(console.warn("THREE.Line3: .getCenter() target is now required"),e=new o),e.addVectors(this.start,this.end).multiplyScalar(.5)},delta:function(e){return void 0===e&&(console.warn("THREE.Line3: .delta() target is now required"),e=new o),e.subVectors(this.end,this.start)},distanceSq:function(){return this.start.distanceToSquared(this.end)},distance:function(){return this.start.distanceTo(this.end)},at:function(e,t){return void 0===t&&(console.warn("THREE.Line3: .at() target is now required"),t=new o),this.delta(t).multiplyScalar(e).add(this.start)},closestPointToPointParameter:function(){var e=new o,t=new o;return function(r,n){e.subVectors(r,this.start),t.subVectors(this.end,this.start);var i=t.dot(t),o=t.dot(e),a=o/i;return n&&(a=Sc.clamp(a,0,1)),a}}(),closestPointToPoint:function(e,t,r){var n=this.closestPointToPointParameter(e,t);return void 0===r&&(console.warn("THREE.Line3: .closestPointToPoint() target is now required"),r=new o),this.delta(r).multiplyScalar(n).add(this.start)},applyMatrix4:function(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this},equals:function(e){return e.start.equals(this.start)&&e.end.equals(this.end)}}),Object.assign(q,{getNormal:function(){var e=new o;return function(t,r,n,i){void 0===i&&(console.warn("THREE.Triangle: .getNormal() target is now required"),i=new o),i.subVectors(n,r),e.subVectors(t,r),i.cross(e);var a=i.lengthSq();return a>0?i.multiplyScalar(1/Math.sqrt(a)):i.set(0,0,0)}}(),getBarycoord:function(){var e=new o,t=new o,r=new o;return function(n,i,a,s,c){e.subVectors(s,i),t.subVectors(a,i),r.subVectors(n,i);var h=e.dot(e),l=e.dot(t),u=e.dot(r),p=t.dot(t),d=t.dot(r),f=h*p-l*l;if(void 0===c&&(console.warn("THREE.Triangle: .getBarycoord() target is now required"),c=new o),0===f)return c.set(-2,-1,-1);var m=1/f,v=(p*u-l*d)*m,g=(h*d-l*u)*m;return c.set(1-v-g,g,v)}}(),containsPoint:function(){var e=new o;return function(t,r,n,i){return q.getBarycoord(t,r,n,i,e),e.x>=0&&e.y>=0&&e.x+e.y<=1}}()}),Object.assign(q.prototype,{set:function(e,t,r){return this.a.copy(e),this.b.copy(t),this.c.copy(r),this},setFromPointsAndIndices:function(e,t,r,n){return this.a.copy(e[t]),this.b.copy(e[r]),this.c.copy(e[n]),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this},getArea:function(){var e=new o,t=new o;return function(){return e.subVectors(this.c,this.b),t.subVectors(this.a,this.b),.5*e.cross(t).length()}}(),getMidpoint:function(e){return void 0===e&&(console.warn("THREE.Triangle: .getMidpoint() target is now required"),e=new o),e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},getNormal:function(e){return q.getNormal(this.a,this.b,this.c,e)},getPlane:function(e){return void 0===e&&(console.warn("THREE.Triangle: .getPlane() target is now required"),e=new o),e.setFromCoplanarPoints(this.a,this.b,this.c)},getBarycoord:function(e,t){return q.getBarycoord(e,this.a,this.b,this.c,t)},containsPoint:function(e){return q.containsPoint(e,this.a,this.b,this.c)},intersectsBox:function(e){return e.intersectsTriangle(this)},closestPointToPoint:function(){var e=new f,t=[new X,new X,new X],r=new o,n=new o;return function(i,a){void 0===a&&(console.warn("THREE.Triangle: .closestPointToPoint() target is now required"),a=new o);var s=1/0;if(e.setFromCoplanarPoints(this.a,this.b,this.c),e.projectPoint(i,r),this.containsPoint(r)===!0)a.copy(r);else{t[0].set(this.a,this.b),t[1].set(this.b,this.c),t[2].set(this.c,this.a);for(var c=0;c0){var a=i[o[0]];if(void 0!==a)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},e=0,t=a.length;e0)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},e=0,t=s.length;er.far?null:{distance:h,point:w.clone(),object:e}}function i(r,n,i,o,a,s,c,p){h.fromBufferAttribute(o,s),l.fromBufferAttribute(o,c),u.fromBufferAttribute(o,p);var d=t(r,r.material,n,i,h,l,u,b);if(d){a&&(v.fromBufferAttribute(a,s),g.fromBufferAttribute(a,c),y.fromBufferAttribute(a,p),d.uv=e(b,h,l,u,v,g,y));var f=new E(s,c,p);q.getNormal(h,l,u,f.normal),d.face=f,d.faceIndex=s}return d}var a=new n,s=new W,c=new d,h=new o,l=new o,u=new o,p=new o,f=new o,m=new o,v=new r,g=new r,y=new r,x=new o,b=new o,w=new o;return function(r,n){var o=this.geometry,d=this.material,x=this.matrixWorld;if(void 0!==d&&(null===o.boundingSphere&&o.computeBoundingSphere(),c.copy(o.boundingSphere),c.applyMatrix4(x),r.ray.intersectsSphere(c)!==!1&&(a.getInverse(x),s.copy(r.ray).applyMatrix4(a),null===o.boundingBox||s.intersectsBox(o.boundingBox)!==!1))){var w;if(o.isBufferGeometry){var _,E,M,T,S,A=o.index,R=o.attributes.position,L=o.attributes.uv;if(null!==A)for(T=0,S=A.count;T0&&(I=B);for(var H=0,z=U.length;Ho)){var a=n.ray.origin.distanceTo(e);an.far||i.push({distance:a,point:e.clone(),face:null,object:this})}}}(),clone:function(){return new this.constructor(this.material).copy(this)},copy:function(e){return b.prototype.copy.call(this,e),void 0!==e.center&&this.center.copy(e.center),this}}),Lt.prototype=Object.assign(Object.create(b.prototype),{constructor:Lt,copy:function(e){b.prototype.copy.call(this,e,!1);for(var t=e.levels,r=0,n=t.length;r1){e.setFromMatrixPosition(r.matrixWorld),t.setFromMatrixPosition(this.matrixWorld);var i=e.distanceTo(t);n[0].object.visible=!0;for(var o=1,a=n.length;o=n[o].distance;o++)n[o-1].object.visible=!1,n[o].object.visible=!0;for(;os)){d.applyMatrix4(this.matrixWorld);var M=n.ray.origin.distanceTo(d);Mn.far||i.push({distance:M,point:p.clone().applyMatrix4(this.matrixWorld),index:x,face:null,faceIndex:null,object:this})}}else for(var x=0,b=g.length/3-1;xs)){d.applyMatrix4(this.matrixWorld);var M=n.ray.origin.distanceTo(d);Mn.far||i.push({distance:M,point:p.clone().applyMatrix4(this.matrixWorld),index:x,face:null,faceIndex:null,object:this})}}}else if(c.isGeometry)for(var T=c.vertices,S=T.length,x=0;xs)){d.applyMatrix4(this.matrixWorld);var M=n.ray.origin.distanceTo(d);Mn.far||i.push({distance:M,point:p.clone().applyMatrix4(this.matrixWorld),index:x,face:null,faceIndex:null,object:this})}}}}}(),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),Dt.prototype=Object.assign(Object.create(Nt.prototype),{constructor:Dt,isLineSegments:!0,computeLineDistances:function(){var e=new o,t=new o;return function(){var r=this.geometry;if(r.isBufferGeometry)if(null===r.index){for(var n=r.attributes.position,i=[],o=0,a=n.count;on.far)return;i.push({distance:a,distanceToRay:Math.sqrt(o),point:f.clone(),index:r,face:null,object:s})}}var s=this,c=this.geometry,h=this.matrixWorld,l=n.params.Points.threshold;if(null===c.boundingSphere&&c.computeBoundingSphere(),r.copy(c.boundingSphere),r.applyMatrix4(h),r.radius+=l,n.ray.intersectsSphere(r)!==!1){e.getInverse(h),t.copy(n.ray).applyMatrix4(e);var u=l/((this.scale.x+this.scale.y+this.scale.z)/3),p=u*u,d=new o,f=new o;if(c.isBufferGeometry){var m=c.index,v=c.attributes,g=v.position.array;if(null!==m)for(var y=m.array,x=0,b=y.length;x=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}),Gt.prototype=Object.create(s.prototype),Gt.prototype.constructor=Gt,Gt.prototype.isCompressedTexture=!0,Vt.prototype=Object.create(s.prototype),Vt.prototype.constructor=Vt,Vt.prototype.isDepthTexture=!0,jt.prototype=Object.create(B.prototype),jt.prototype.constructor=jt,kt.prototype=Object.create(M.prototype),kt.prototype.constructor=kt,Wt.prototype=Object.create(B.prototype),Wt.prototype.constructor=Wt,Xt.prototype=Object.create(M.prototype),Xt.prototype.constructor=Xt,qt.prototype=Object.create(B.prototype),qt.prototype.constructor=qt,Yt.prototype=Object.create(M.prototype),Yt.prototype.constructor=Yt,Zt.prototype=Object.create(qt.prototype),Zt.prototype.constructor=Zt,Jt.prototype=Object.create(M.prototype),Jt.prototype.constructor=Jt,Qt.prototype=Object.create(qt.prototype),Qt.prototype.constructor=Qt,Kt.prototype=Object.create(M.prototype),Kt.prototype.constructor=Kt,$t.prototype=Object.create(qt.prototype),$t.prototype.constructor=$t,er.prototype=Object.create(M.prototype),er.prototype.constructor=er,tr.prototype=Object.create(qt.prototype),tr.prototype.constructor=tr,rr.prototype=Object.create(M.prototype),rr.prototype.constructor=rr,nr.prototype=Object.create(B.prototype),nr.prototype.constructor=nr,ir.prototype=Object.create(M.prototype),ir.prototype.constructor=ir,or.prototype=Object.create(B.prototype),or.prototype.constructor=or,ar.prototype=Object.create(M.prototype),ar.prototype.constructor=ar,sr.prototype=Object.create(B.prototype),sr.prototype.constructor=sr;var Ql={triangulate:function(e,t,r){r=r||2;var n=t&&t.length,i=n?t[0]*r:e.length,o=cr(e,0,i,r,!0),a=[];if(!o)return a;var s,c,h,l,u,p,d;if(n&&(o=mr(e,t,o,r)),e.length>80*r){s=h=e[0],c=l=e[1];for(var f=r;fh&&(h=u),p>l&&(l=p);d=Math.max(h-s,l-c),d=0!==d?1/d:0}return lr(o,a,r,s,c,d),a}},Kl={area:function(e){for(var t=e.length,r=0,n=t-1,i=0;i0||0===e.search(/^data\:image\/jpeg/);i.format=n?Rs:Ls,i.needsUpdate=!0,void 0!==t&&t(i)},r,n),i},setCrossOrigin:function(e){return this.crossOrigin=e,this},setPath:function(e){return this.path=e,this}}),Object.assign(wn.prototype,{getPoint:function(){return console.warn("THREE.Curve: .getPoint() not implemented."),null},getPointAt:function(e,t){var r=this.getUtoTmapping(e);return this.getPoint(r,t)},getPoints:function(e){void 0===e&&(e=5);for(var t=[],r=0;r<=e;r++)t.push(this.getPoint(r/e));return t},getSpacedPoints:function(e){void 0===e&&(e=5);for(var t=[],r=0;r<=e;r++)t.push(this.getPointAt(r/e));return t},getLength:function(){var e=this.getLengths();return e[e.length-1]},getLengths:function(e){if(void 0===e&&(e=this.arcLengthDivisions),this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var t,r,n=[],i=this.getPoint(0),o=0;for(n.push(0),r=1;r<=e;r++)t=this.getPoint(r/e),o+=t.distanceTo(i),n.push(o),i=t;return this.cacheArcLengths=n,n},updateArcLengths:function(){this.needsUpdate=!0,this.getLengths()},getUtoTmapping:function(e,t){var r,n=this.getLengths(),i=0,o=n.length;r=t?t:e*n[o-1];for(var a,s=0,c=o-1;s<=c;)if(i=Math.floor(s+(c-s)/2),a=n[i]-r,a<0)s=i+1;else{if(!(a>0)){c=i;break}c=i-1}if(i=c,n[i]===r)return i/(o-1);var h=n[i],l=n[i+1],u=l-h,p=(r-h)/u,d=(i+p)/(o-1);return d},getTangent:function(e){var t=1e-4,r=e-t,n=e+t;r<0&&(r=0),n>1&&(n=1);var i=this.getPoint(r),o=this.getPoint(n),a=o.clone().sub(i);return a.normalize()},getTangentAt:function(e){var t=this.getUtoTmapping(e);return this.getTangent(t)},computeFrenetFrames:function(e,t){var r,i,a,s=new o,c=[],h=[],l=[],u=new o,p=new n;for(r=0;r<=e;r++)i=r/e,c[r]=this.getTangentAt(i),c[r].normalize();h[0]=new o,l[0]=new o;var d=Number.MAX_VALUE,f=Math.abs(c[0].x),m=Math.abs(c[0].y),v=Math.abs(c[0].z);for(f<=d&&(d=f,s.set(1,0,0)),m<=d&&(d=m,s.set(0,1,0)),v<=d&&s.set(0,0,1),u.crossVectors(c[0],s).normalize(),h[0].crossVectors(c[0],u),l[0].crossVectors(c[0],h[0]),r=1;r<=e;r++)h[r]=h[r-1].clone(),l[r]=l[r-1].clone(),u.crossVectors(c[r-1],c[r]),u.length()>Number.EPSILON&&(u.normalize(),a=Math.acos(Sc.clamp(c[r-1].dot(c[r]),-1,1)),h[r].applyMatrix4(p.makeRotationAxis(u,a))),l[r].crossVectors(c[r],h[r]);if(t===!0)for(a=Math.acos(Sc.clamp(h[0].dot(h[e]),-1,1)),a/=e,c[0].dot(u.crossVectors(h[0],h[e]))>0&&(a=-a),r=1;r<=e;r++)h[r].applyMatrix4(p.makeRotationAxis(c[r],a*r)),l[r].crossVectors(c[r],h[r]);return{tangents:c,normals:h,binormals:l}},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.arcLengthDivisions=e.arcLengthDivisions,this},toJSON:function(){var e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e},fromJSON:function(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}),_n.prototype=Object.create(wn.prototype),_n.prototype.constructor=_n,_n.prototype.isEllipseCurve=!0,_n.prototype.getPoint=function(e,t){for(var n=t||new r,i=2*Math.PI,o=this.aEndAngle-this.aStartAngle,a=Math.abs(o)i;)o-=i;o0?0:(Math.floor(Math.abs(s)/i)+1)*i:0===c&&s===i-1&&(s=i-2,c=1);var h,l,u,p;if(this.closed||s>0?h=n[(s-1)%i]:(ou.subVectors(n[0],n[1]).add(n[0]),h=ou),l=n[s%i],u=n[(s+1)%i],this.closed||s+2i.length-2?i.length-1:a+1],u=i[a>i.length-3?i.length-1:a+2];return n.set(Sn(s,c.x,h.x,l.x,u.x),Sn(s,c.y,h.y,l.y,u.y)),n},Vn.prototype.copy=function(e){wn.prototype.copy.call(this,e),this.points=[];for(var t=0,r=e.points.length;t=t){var i=r[n]-t,o=this.curves[n],a=o.getLength(),s=0===a?0:1-i/a;return o.getPointAt(s)}n++}return null},getLength:function(){var e=this.getCurveLengths();return e[e.length-1]},updateArcLengths:function(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()},getCurveLengths:function(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;for(var e=[],t=0,r=0,n=this.curves.length;r1&&!r[r.length-1].equals(r[0])&&r.push(r[0]),r},copy:function(e){wn.prototype.copy.call(this,e),this.curves=[];for(var t=0,r=e.curves.length;t0){var h=c.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(c);var l=c.getPoint(1);this.currentPoint.copy(l)},copy:function(e){return jn.prototype.copy.call(this,e),this.currentPoint.copy(e.currentPoint),this},toJSON:function(){var e=jn.prototype.toJSON.call(this);return e.currentPoint=this.currentPoint.toArray(),e},fromJSON:function(e){return jn.prototype.fromJSON.call(this,e),this.currentPoint.fromArray(e.currentPoint),this}}),Wn.prototype=Object.assign(Object.create(kn.prototype),{constructor:Wn,getPointsHoles:function(e){for(var t=[],r=0,n=this.holes.length;r=i)break e;var s=t[1];e=i)break t}o=r,r=0}}for(;r>>1;et;)--o;if(++o,0!==i||o!==n){i>=o&&(o=Math.max(o,1),i=o-1);var a=this.getValueSize();this.times=lu.arraySlice(r,i,o),this.values=lu.arraySlice(this.values,i*a,o*a)}return this},validate:function(){var e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);var r=this.times,n=this.values,i=r.length;0===i&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);for(var o=null,a=0;a!==i;a++){var s=r[a];if("number"==typeof s&&isNaN(s)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,s),e=!1;break}if(null!==o&&o>s){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,s,o),e=!1;break}o=s}if(void 0!==n&&lu.isTypedArray(n))for(var a=0,c=n.length;a!==c;++a){var h=n[a];if(isNaN(h)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,h),e=!1;break}}return e},optimize:function(){for(var e=this.times,t=this.values,r=this.getValueSize(),n=this.getInterpolation()===hc,i=1,o=e.length-1,a=1;a0){e[i]=e[o];for(var m=o*r,v=i*r,d=0;d!==r;++d)t[v+d]=t[m+d];++i}return i!==e.length&&(this.times=lu.arraySlice(e,0,i),this.values=lu.arraySlice(t,0,i*r)),this}}),di.prototype=Object.assign(Object.create(pi.prototype),{constructor:di,ValueTypeName:"vector"}),Object.assign(fi,{parse:function(e){for(var t=[],r=e.tracks,n=1/(e.fps||1),i=0,o=r.length;i!==o;++i)t.push(pi.parse(r[i]).scale(n));return new fi(e.name,e.duration,t)},toJSON:function(e){for(var t=[],r=e.tracks,n={name:e.name,duration:e.duration,tracks:t},i=0,o=r.length;i!==o;++i)t.push(pi.toJSON(r[i]));return n},CreateFromMorphTargetSequence:function(e,t,r,n){for(var i=t.length,o=[],a=0;a1){var h=c[1],l=n[h];l||(n[h]=l=[]),l.push(s)}}var u=[];for(var h in n)u.push(fi.CreateFromMorphTargetSequence(h,n[h],t,r));return u},parseAnimation:function(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;for(var r=function(e,t,r,n,i){if(0!==r.length){var o=[],a=[];lu.flattenJSON(r,o,a,n),0!==o.length&&i.push(new e(t,o,a))}},n=[],i=e.name||"default",o=e.length||-1,a=e.fps||30,s=e.hierarchy||[],c=0;c1?e.skinWeights[n+1]:0,s=r>2?e.skinWeights[n+2]:0,h=r>3?e.skinWeights[n+3]:0;t.skinWeights.push(new c(o,a,s,h))}if(e.skinIndices)for(var n=0,i=e.skinIndices.length;n1?e.skinIndices[n+1]:0,p=r>2?e.skinIndices[n+2]:0,d=r>3?e.skinIndices[n+3]:0;t.skinIndices.push(new c(l,u,p,d))}t.bones=e.bones,t.bones&&t.bones.length>0&&(t.skinWeights.length!==t.skinIndices.length||t.skinIndices.length!==t.vertices.length)&&console.warn("When skinning, number of vertices ("+t.vertices.length+"), skinIndices ("+t.skinIndices.length+"), and skinWeights ("+t.skinWeights.length+") should match.")}function n(e,t){var r=e.scale;if(void 0!==e.morphTargets)for(var n=0,i=e.morphTargets.length;n0){console.warn('THREE.JSONLoader: "morphColors" no longer supported. Using them as face colors.');for(var u=t.faces,p=e.morphColors[0].colors,n=0,i=u.length;n0&&(t.animations=r)}return function(r,o){void 0!==r.data&&(r=r.data),void 0!==r.scale?r.scale=1/r.scale:r.scale=1;var a=new M;if(e(r,a),t(r,a),n(r,a),i(r,a),a.computeFaceNormals(),a.computeBoundingSphere(),void 0===r.materials||0===r.materials.length)return{geometry:a};var s=gi.prototype.initMaterials(r.materials,o,this.crossOrigin);return{geometry:a,materials:s}}}()}),Object.assign(xi.prototype,{load:function(e,t,r,n){""===this.texturePath&&(this.texturePath=e.substring(0,e.lastIndexOf("/")+1));var i=this,o=new mn(i.manager);o.load(e,function(r){var o=null;try{o=JSON.parse(r)}catch(a){return void 0!==n&&n(a),void console.error("THREE:ObjectLoader: Can't parse "+e+".",a.message)}var s=o.metadata;return void 0===s||void 0===s.type||"geometry"===s.type.toLowerCase()?void console.error("THREE.ObjectLoader: Can't load "+e+". Use THREE.JSONLoader instead."):void i.parse(o,t)},r,n)},setTexturePath:function(e){this.texturePath=e},setCrossOrigin:function(e){this.crossOrigin=e},parse:function(e,t){var r=this.parseShape(e.shapes),n=this.parseGeometries(e.geometries,r),i=this.parseImages(e.images,function(){void 0!==t&&t(s)}),o=this.parseTextures(e.textures,i),a=this.parseMaterials(e.materials,o),s=this.parseObject(e.object,n,a);return e.animations&&(s.animations=this.parseAnimations(e.animations)),void 0!==e.images&&0!==e.images.length||void 0!==t&&t(s),s},parseShape:function(e){var t={};if(void 0!==e)for(var r=0,n=e.length;r0){var o=new fn(t),a=new yn(o);a.setCrossOrigin(this.crossOrigin);for(var s=0,c=e.length;s0?new Ot(a,s):new Y(a,s);break;case"LOD":o=new Lt;break;case"Line":o=new Nt(n(e.geometry),i(e.material),e.mode);break;case"LineLoop":o=new Ut(n(e.geometry),i(e.material));break;case"LineSegments":o=new Dt(n(e.geometry),i(e.material));break;case"PointCloud":case"Points":o=new Ht(n(e.geometry),i(e.material));break;case"Sprite":o=new Rt(i(e.material));break;case"Group":o=new zt;break;default:o=new b}if(o.uuid=e.uuid,void 0!==e.name&&(o.name=e.name),void 0!==e.matrix?(o.matrix.fromArray(e.matrix),void 0!==e.matrixAutoUpdate&&(o.matrixAutoUpdate=e.matrixAutoUpdate),o.matrixAutoUpdate&&o.matrix.decompose(o.position,o.quaternion,o.scale)):(void 0!==e.position&&o.position.fromArray(e.position),void 0!==e.rotation&&o.rotation.fromArray(e.rotation),void 0!==e.quaternion&&o.quaternion.fromArray(e.quaternion),void 0!==e.scale&&o.scale.fromArray(e.scale)),void 0!==e.castShadow&&(o.castShadow=e.castShadow),void 0!==e.receiveShadow&&(o.receiveShadow=e.receiveShadow),e.shadow&&(void 0!==e.shadow.bias&&(o.shadow.bias=e.shadow.bias),void 0!==e.shadow.radius&&(o.shadow.radius=e.shadow.radius),void 0!==e.shadow.mapSize&&o.shadow.mapSize.fromArray(e.shadow.mapSize),void 0!==e.shadow.camera&&(o.shadow.camera=this.parseObject(e.shadow.camera))),void 0!==e.visible&&(o.visible=e.visible),void 0!==e.frustumCulled&&(o.frustumCulled=e.frustumCulled),void 0!==e.renderOrder&&(o.renderOrder=e.renderOrder),void 0!==e.userData&&(o.userData=e.userData),void 0!==e.children)for(var c=e.children,h=0;hNumber.EPSILON){if(h<0&&(a=t[o],c=-c,s=t[i],h=-h),e.ys.y)continue;if(e.y===a.y){if(e.x===a.x)return!0}else{var l=h*(e.x-a.x)-c*(e.y-a.y);if(0===l)return!0;if(l<0)continue;n=!n}}else{if(e.y!==a.y)continue;if(s.x<=e.x&&e.x<=a.x||a.x<=e.x&&e.x<=s.x)return!0}}return n}var i=Kl.isClockWise,o=this.subPaths;if(0===o.length)return[];if(t===!0)return r(o);var a,s,c,h=[];if(1===o.length)return s=o[0],c=new Wn,c.curves=s.curves,h.push(c),h;var l=!i(o[0].getPoints());l=e?!l:l;var u,p=[],d=[],f=[],m=0; d[m]=void 0,f[m]=[];for(var v=0,g=o.length;v1){for(var y=!1,x=[],b=0,w=d.length;b0&&(y||(f=p))}for(var A,v=0,R=d.length;v0){this.source.connect(this.filters[0]);for(var e=1,t=this.filters.length;e0){this.source.disconnect(this.filters[0]);for(var e=1,t=this.filters.length;e=.5)for(var o=0;o!==i;++o)e[t+o]=e[r+o]},_slerp:function(e,t,r,n){i.slerpFlat(e,t,e,t,e,r,n)},_lerp:function(e,t,r,n,i){for(var o=1-n,a=0;a!==i;++a){var s=t+a;e[s]=e[s]*o+e[r+a]*n}}});var yu="\\[\\]\\.:\\/";Object.assign(Ni.prototype,{getValue:function(e,t){this.bind();var r=this._targetGroup.nCachedObjects_,n=this._bindings[r];void 0!==n&&n.getValue(e,t)},setValue:function(e,t){for(var r=this._bindings,n=this._targetGroup.nCachedObjects_,i=r.length;n!==i;++n)r[n].setValue(e,t)},bind:function(){for(var e=this._bindings,t=this._targetGroup.nCachedObjects_,r=e.length;t!==r;++t)e[t].bind()},unbind:function(){for(var e=this._bindings,t=this._targetGroup.nCachedObjects_,r=e.length;t!==r;++t)e[t].unbind()}}),Object.assign(Di,{Composite:Ni,create:function(e,t,r){return e&&e.isAnimationObjectGroup?new Di.Composite(e,t,r):new Di(e,t,r)},sanitizeNodeName:function(){var e=new RegExp("["+yu+"]","g");return function(t){return t.replace(/\s/g,"_").replace(e,"")}}(),parseTrackName:function(){var e="[^"+yu+"]",t="[^"+yu.replace("\\.","")+"]",r=/((?:WC+[\/:])*)/.source.replace("WC",e),n=/(WCOD+)?/.source.replace("WCOD",t),i=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",e),o=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",e),a=new RegExp("^"+r+n+i+o+"$"),s=["material","materials","bones"];return function(e){var t=a.exec(e);if(!t)throw new Error("PropertyBinding: Cannot parse trackName: "+e);var r={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},n=r.nodeName&&r.nodeName.lastIndexOf(".");if(void 0!==n&&n!==-1){var i=r.nodeName.substring(n+1);s.indexOf(i)!==-1&&(r.nodeName=r.nodeName.substring(0,n),r.objectName=i)}if(null===r.propertyName||0===r.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return r}}(),findNode:function(e,t){if(!t||""===t||"root"===t||"."===t||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){var r=e.skeleton.getBoneByName(t);if(void 0!==r)return r}if(e.children){var n=function(e){for(var r=0;r=t){var l=t++,u=e[l];r[u.uuid]=h,e[h]=u,r[c]=l,e[l]=s;for(var p=0,d=i;p!==d;++p){var f=n[p],m=f[l],v=f[h];f[h]=m,f[l]=v}}}this.nCachedObjects_=t},uncache:function(){for(var e=this._objects,t=e.length,r=this.nCachedObjects_,n=this._indicesByUUID,i=this._bindings,o=i.length,a=0,s=arguments.length;a!==s;++a){var c=arguments[a],h=c.uuid,l=n[h];if(void 0!==l)if(delete n[h],l0)for(var c=this._interpolants,h=this._propertyBindings,l=0,u=c.length;l!==u;++l)c[l].evaluate(a),h[l].accumulate(n,s)},_updateWeight:function(e){var t=0;if(this.enabled){t=this.weight;var r=this._weightInterpolant;if(null!==r){var n=r.evaluate(e)[0];t*=n,e>r.parameterPositions[1]&&(this.stopFading(),0===n&&(this.enabled=!1))}}return this._effectiveWeight=t,t},_updateTimeScale:function(e){var t=0;if(!this.paused){t=this.timeScale;var r=this._timeScaleInterpolant;if(null!==r){var n=r.evaluate(e)[0];t*=n,e>r.parameterPositions[1]&&(this.stopWarping(),0===t?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t},_updateTime:function(e){var t=this.time+e;if(0===e)return t;var r=this._clip.duration,n=this.loop,i=this._loopCount;if(n===ic){i===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(t>=r)t=r;else{if(!(t<0))break e;t=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{var o=n===ac;if(i===-1&&(e>=0?(i=0,this._setEndings(!0,0===this.repetitions,o)):this._setEndings(0===this.repetitions,!0,o)),t>=r||t<0){var a=Math.floor(t/r);t-=r*a,i+=Math.abs(a);var s=this.repetitions-i;if(s<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,t=e>0?r:0,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(1===s){var c=e<0;this._setEndings(c,!c,o)}else this._setEndings(!1,!1,o);this._loopCount=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}if(o&&1===(1&i))return this.time=t,r-t}return this.time=t,t},_setEndings:function(e,t,r){var n=this._interpolantSettings;r?(n.endingStart=uc,n.endingEnd=uc):(e?n.endingStart=this.zeroSlopeAtStart?uc:lc:n.endingStart=pc,t?n.endingEnd=this.zeroSlopeAtEnd?uc:lc:n.endingEnd=pc)},_scheduleFading:function(e,t,r){var n=this._mixer,i=n.time,o=this._weightInterpolant;null===o&&(o=n._lendControlInterpolant(),this._weightInterpolant=o);var a=o.parameterPositions,s=o.sampleValues;return a[0]=i,s[0]=t,a[1]=i+e,s[1]=r,this}}),Hi.prototype=Object.assign(Object.create(t.prototype),{constructor:Hi,_bindAction:function(e,t){var r=e._localRoot||this._root,n=e._clip.tracks,i=n.length,o=e._propertyBindings,a=e._interpolants,s=r.uuid,c=this._bindingsByRootAndName,h=c[s];void 0===h&&(h={},c[s]=h);for(var l=0;l!==i;++l){var u=n[l],p=u.name,d=h[p];if(void 0!==d)o[l]=d;else{if(d=o[l],void 0!==d){null===d._cacheIndex&&(++d.referenceCount,this._addInactiveBinding(d,s,p));continue}var f=t&&t._propertyBindings[l].binding.parsedPath;d=new Ii(Di.create(r,p,f),u.ValueTypeName,u.getValueSize()),++d.referenceCount,this._addInactiveBinding(d,s,p),o[l]=d}a[l].resultBuffer=d.buffer}},_activateAction:function(e){if(!this._isActiveAction(e)){if(null===e._cacheIndex){var t=(e._localRoot||this._root).uuid,r=e._clip.uuid,n=this._actionsByClip[r];this._bindAction(e,n&&n.knownActions[0]),this._addInactiveAction(e,r,t)}for(var i=e._propertyBindings,o=0,a=i.length;o!==a;++o){var s=i[o];0===s.useCount++&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}},_deactivateAction:function(e){if(this._isActiveAction(e)){for(var t=e._propertyBindings,r=0,n=t.length;r!==n;++r){var i=t[r];0===--i.useCount&&(i.restoreOriginalState(),this._takeBackBinding(i))}this._takeBackAction(e)}},_initMemoryManager:function(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;var e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}},_isActiveAction:function(e){var t=e._cacheIndex;return null!==t&&tthis.max.x||e.ythis.max.y)},containsBox:function(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y},getParameter:function(e,t){return void 0===t&&(console.warn("THREE.Box2: .getParameter() target is now required"),t=new r),t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))},intersectsBox:function(e){return!(e.max.xthis.max.x||e.max.ythis.max.y)},clampPoint:function(e,t){return void 0===t&&(console.warn("THREE.Box2: .clampPoint() target is now required"),t=new r),t.copy(e).clamp(this.min,this.max)},distanceToPoint:function(){var e=new r;return function(t){var r=e.copy(t).clamp(this.min,this.max);return r.sub(t).length()}}(),intersect:function(e){return this.min.max(e.min),this.max.min(e.max),this},union:function(e){return this.min.min(e.min),this.max.max(e.max),this},translate:function(e){return this.min.add(e),this.max.add(e),this},equals:function(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}),Ki.prototype=Object.create(b.prototype),Ki.prototype.constructor=Ki,Ki.prototype.isImmediateRenderObject=!0,$i.prototype=Object.create(Dt.prototype),$i.prototype.constructor=$i,$i.prototype.update=function(){var e=new o,t=new o,r=new a;return function(){var n=["a","b","c"];this.object.updateMatrixWorld(!0),r.getNormalMatrix(this.object.matrixWorld);var i=this.object.matrixWorld,o=this.geometry.attributes.position,a=this.object.geometry;if(a&&a.isGeometry)for(var s=a.vertices,c=a.faces,h=0,l=0,u=c.length;l.99999?this.quaternion.set(0,0,0,1):r.y<-.99999?this.quaternion.set(1,0,0,0):(t.set(r.z,0,-r.x).normalize(),e=Math.acos(r.y),this.quaternion.setFromAxisAngle(t,e))}}(),mo.prototype.setLength=function(e,t,r){void 0===t&&(t=.2*e),void 0===r&&(r=.2*t),this.line.scale.set(1,Math.max(0,e-t),1),this.line.updateMatrix(),this.cone.scale.set(r,t,r),this.cone.position.y=e,this.cone.updateMatrix()},mo.prototype.setColor=function(e){this.line.material.color.copy(e),this.cone.material.color.copy(e)},vo.prototype=Object.create(Dt.prototype),vo.prototype.constructor=vo;var wu=0,_u=1;wn.create=function(e,t){return console.log("THREE.Curve.create() has been deprecated"),e.prototype=Object.create(wn.prototype),e.prototype.constructor=e,e.prototype.getPoint=t,e},Object.assign(jn.prototype,{createPointsGeometry:function(e){console.warn("THREE.CurvePath: .createPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");var t=this.getPoints(e);return this.createGeometry(t)},createSpacedPointsGeometry:function(e){console.warn("THREE.CurvePath: .createSpacedPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");var t=this.getSpacedPoints(e);return this.createGeometry(t)},createGeometry:function(e){console.warn("THREE.CurvePath: .createGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");for(var t=new M,r=0,n=e.length;r0?a(n()):$.y<0&&s(n()),Q.copy(K),I.update()}function d(e){Z.set(e.clientX,e.clientY),J.subVectors(Z,Y),re(J.x,J.y),Y.copy(Z),I.update()}function f(e){}function m(e){e.deltaY<0?s(n()):e.deltaY>0&&a(n()),I.update()}function v(e){switch(e.keyCode){case I.keys.UP:re(0,I.keyPanSpeed),I.update();break;case I.keys.BOTTOM:re(0,-I.keyPanSpeed),I.update();break;case I.keys.LEFT:re(I.keyPanSpeed,0),I.update();break;case I.keys.RIGHT:re(-I.keyPanSpeed,0),I.update()}}function g(e){W.set(e.touches[0].pageX,e.touches[0].pageY)}function y(e){var t=e.touches[0].pageX-e.touches[1].pageX,r=e.touches[0].pageY-e.touches[1].pageY,n=Math.sqrt(t*t+r*r);Q.set(0,n)}function x(e){Y.set(e.touches[0].pageX,e.touches[0].pageY)}function b(e){X.set(e.touches[0].pageX,e.touches[0].pageY),q.subVectors(X,W);var t=I.domElement===document?I.domElement.body:I.domElement;i(2*Math.PI*q.x/t.clientWidth*I.rotateSpeed),o(2*Math.PI*q.y/t.clientHeight*I.rotateSpeed),W.copy(X),I.update()}function w(e){var t=e.touches[0].pageX-e.touches[1].pageX,r=e.touches[0].pageY-e.touches[1].pageY,i=Math.sqrt(t*t+r*r);K.set(0,i),$.subVectors(K,Q),$.y>0?s(n()):$.y<0&&a(n()),Q.copy(K),I.update()}function _(e){Z.set(e.touches[0].pageX,e.touches[0].pageY),J.subVectors(Z,Y),re(J.x,J.y),Y.copy(Z),I.update()}function E(e){}function M(e){if(I.enabled!==!1){switch(e.preventDefault(),e.button){case I.mouseButtons.ORBIT:if(I.enableRotate===!1)return;c(e),H=B.ROTATE;break;case I.mouseButtons.ZOOM:if(I.enableZoom===!1)return;h(e),H=B.DOLLY;break;case I.mouseButtons.PAN:if(I.enablePan===!1)return;l(e),H=B.PAN}H!==B.NONE&&(document.addEventListener("mousemove",T,!1),document.addEventListener("mouseup",S,!1),I.dispatchEvent(D))}}function T(e){if(I.enabled!==!1)switch(e.preventDefault(),H){case B.ROTATE:if(I.enableRotate===!1)return;u(e);break;case B.DOLLY:if(I.enableZoom===!1)return;p(e);break;case B.PAN:if(I.enablePan===!1)return;d(e)}}function S(e){I.enabled!==!1&&(f(e),document.removeEventListener("mousemove",T,!1),document.removeEventListener("mouseup",S,!1),I.dispatchEvent(U),H=B.NONE)}function A(e){I.enabled===!1||I.enableZoom===!1||H!==B.NONE&&H!==B.ROTATE||(e.preventDefault(),e.stopPropagation(),m(e),I.dispatchEvent(D),I.dispatchEvent(U))}function R(e){I.enabled!==!1&&I.enableKeys!==!1&&I.enablePan!==!1&&v(e)}function L(e){if(I.enabled!==!1){switch(e.touches.length){case 1:if(I.enableRotate===!1)return;g(e),H=B.TOUCH_ROTATE;break;case 2:if(I.enableZoom===!1)return;y(e),H=B.TOUCH_DOLLY;break;case 3:if(I.enablePan===!1)return;x(e),H=B.TOUCH_PAN;break;default:H=B.NONE}H!==B.NONE&&I.dispatchEvent(D)}}function P(e){if(I.enabled!==!1)switch(e.preventDefault(),e.stopPropagation(),e.touches.length){case 1:if(I.enableRotate===!1)return;if(H!==B.TOUCH_ROTATE)return;b(e);break;case 2:if(I.enableZoom===!1)return;if(H!==B.TOUCH_DOLLY)return;w(e);break;case 3:if(I.enablePan===!1)return;if(H!==B.TOUCH_PAN)return;_(e);break;default:H=B.NONE}}function C(e){I.enabled!==!1&&(E(e),I.dispatchEvent(U),H=B.NONE)}function O(e){I.enabled!==!1&&e.preventDefault()}this.object=e,this.domElement=void 0!==t?t:document,this.enabled=!0,this.target=new THREE.Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-(1/0),this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.25,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.keyPanSpeed=7,this.autoRotate=!1,this.autoRotateSpeed=2,this.enableKeys=!0,this.keys={LEFT:37,UP:38,RIGHT:39,BOTTOM:40},this.mouseButtons={ORBIT:THREE.MOUSE.LEFT,ZOOM:THREE.MOUSE.MIDDLE,PAN:THREE.MOUSE.RIGHT},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.getPolarAngle=function(){return F.phi},this.getAzimuthalAngle=function(){return F.theta},this.saveState=function(){I.target0.copy(I.target),I.position0.copy(I.object.position),I.zoom0=I.object.zoom},this.reset=function(){I.target.copy(I.target0),I.object.position.copy(I.position0),I.object.zoom=I.zoom0,I.object.updateProjectionMatrix(),I.dispatchEvent(N),I.update(),H=B.NONE},this.update=function(){var t=new THREE.Vector3,n=(new THREE.Quaternion).setFromUnitVectors(e.up,new THREE.Vector3(0,1,0)),o=n.clone().inverse(),a=new THREE.Vector3,s=new THREE.Quaternion;return function(){var e=I.object.position;return t.copy(e).sub(I.target),t.applyQuaternion(n),F.setFromVector3(t),I.autoRotate&&H===B.NONE&&i(r()),F.theta+=G.theta,F.phi+=G.phi,F.theta=Math.max(I.minAzimuthAngle,Math.min(I.maxAzimuthAngle,F.theta)),F.phi=Math.max(I.minPolarAngle,Math.min(I.maxPolarAngle,F.phi)),F.makeSafe(),F.radius*=V,F.radius=Math.max(I.minDistance,Math.min(I.maxDistance,F.radius)),I.target.add(j),t.setFromSpherical(F),t.applyQuaternion(o),e.copy(I.target).add(t),I.object.lookAt(I.target),I.enableDamping===!0?(G.theta*=1-I.dampingFactor,G.phi*=1-I.dampingFactor):G.set(0,0,0),V=1,j.set(0,0,0),!!(k||a.distanceToSquared(I.object.position)>z||8*(1-s.dot(I.object.quaternion))>z)&&(I.dispatchEvent(N),a.copy(I.object.position),s.copy(I.object.quaternion),k=!1,!0)}}(),this.dispose=function(){I.domElement.removeEventListener("contextmenu",O,!1),I.domElement.removeEventListener("mousedown",M,!1),I.domElement.removeEventListener("wheel",A,!1),I.domElement.removeEventListener("touchstart",L,!1),I.domElement.removeEventListener("touchend",C,!1),I.domElement.removeEventListener("touchmove",P,!1),document.removeEventListener("mousemove",T,!1),document.removeEventListener("mouseup",S,!1),window.removeEventListener("keydown",R,!1)};var I=this,N={type:"change"},D={type:"start"},U={type:"end"},B={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_DOLLY:4,TOUCH_PAN:5},H=B.NONE,z=1e-6,F=new THREE.Spherical,G=new THREE.Spherical,V=1,j=new THREE.Vector3,k=!1,W=new THREE.Vector2,X=new THREE.Vector2,q=new THREE.Vector2,Y=new THREE.Vector2,Z=new THREE.Vector2,J=new THREE.Vector2,Q=new THREE.Vector2,K=new THREE.Vector2,$=new THREE.Vector2,ee=function(){var e=new THREE.Vector3;return function(t,r){e.setFromMatrixColumn(r,0),e.multiplyScalar(-t),j.add(e)}}(),te=function(){var e=new THREE.Vector3;return function(t,r){e.setFromMatrixColumn(r,1),e.multiplyScalar(t),j.add(e)}}(),re=function(){var e=new THREE.Vector3;return function(t,r){var n=I.domElement===document?I.domElement.body:I.domElement;if(I.object instanceof THREE.PerspectiveCamera){var i=I.object.position;e.copy(i).sub(I.target);var o=e.length();o*=Math.tan(I.object.fov/2*Math.PI/180),ee(2*t*o/n.clientHeight,I.object.matrix),te(2*r*o/n.clientHeight,I.object.matrix)}else I.object instanceof THREE.OrthographicCamera?(ee(t*(I.object.right-I.object.left)/I.object.zoom/n.clientWidth,I.object.matrix),te(r*(I.object.top-I.object.bottom)/I.object.zoom/n.clientHeight,I.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),I.enablePan=!1)}}();I.domElement.addEventListener("contextmenu",O,!1),I.domElement.addEventListener("mousedown",M,!1),I.domElement.addEventListener("wheel",A,!1),I.domElement.addEventListener("touchstart",L,!1),I.domElement.addEventListener("touchend",C,!1),I.domElement.addEventListener("touchmove",P,!1),window.addEventListener("keydown",R,!1),this.update()},THREE.OrbitControls.prototype=Object.create(THREE.EventDispatcher.prototype),THREE.OrbitControls.prototype.constructor=THREE.OrbitControls,Object.defineProperties(THREE.OrbitControls.prototype,{center:{get:function(){return console.warn("THREE.OrbitControls: .center has been renamed to .target"),this.target}},noZoom:{get:function(){return console.warn("THREE.OrbitControls: .noZoom has been deprecated. Use .enableZoom instead."),!this.enableZoom},set:function(e){console.warn("THREE.OrbitControls: .noZoom has been deprecated. Use .enableZoom instead."),this.enableZoom=!e}},noRotate:{get:function(){return console.warn("THREE.OrbitControls: .noRotate has been deprecated. Use .enableRotate instead."),!this.enableRotate},set:function(e){console.warn("THREE.OrbitControls: .noRotate has been deprecated. Use .enableRotate instead."),this.enableRotate=!e}},noPan:{get:function(){return console.warn("THREE.OrbitControls: .noPan has been deprecated. Use .enablePan instead."),!this.enablePan},set:function(e){console.warn("THREE.OrbitControls: .noPan has been deprecated. Use .enablePan instead."),this.enablePan=!e}},noKeys:{get:function(){return console.warn("THREE.OrbitControls: .noKeys has been deprecated. Use .enableKeys instead."),!this.enableKeys},set:function(e){console.warn("THREE.OrbitControls: .noKeys has been deprecated. Use .enableKeys instead."),this.enableKeys=!e}},staticMoving:{get:function(){return console.warn("THREE.OrbitControls: .staticMoving has been deprecated. Use .enableDamping instead."),!this.enableDamping},set:function(e){console.warn("THREE.OrbitControls: .staticMoving has been deprecated. Use .enableDamping instead."),this.enableDamping=!e}},dynamicDampingFactor:{get:function(){return console.warn("THREE.OrbitControls: .dynamicDampingFactor has been renamed. Use .dampingFactor instead."),this.dampingFactor},set:function(e){console.warn("THREE.OrbitControls: .dynamicDampingFactor has been renamed. Use .dampingFactor instead."),this.dampingFactor=e}}}),THREE.RenderableObject=function(){this.id=0,this.object=null,this.z=0,this.renderOrder=0},THREE.RenderableFace=function(){this.id=0,this.v1=new THREE.RenderableVertex,this.v2=new THREE.RenderableVertex,this.v3=new THREE.RenderableVertex,this.normalModel=new THREE.Vector3,this.vertexNormalsModel=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3],this.vertexNormalsLength=0,this.color=new THREE.Color,this.material=null,this.uvs=[new THREE.Vector2,new THREE.Vector2,new THREE.Vector2],this.z=0,this.renderOrder=0},THREE.RenderableVertex=function(){this.position=new THREE.Vector3,this.positionWorld=new THREE.Vector3,this.positionScreen=new THREE.Vector4,this.visible=!0},THREE.RenderableVertex.prototype.copy=function(e){this.positionWorld.copy(e.positionWorld),this.positionScreen.copy(e.positionScreen)},THREE.RenderableLine=function(){this.id=0,this.v1=new THREE.RenderableVertex,this.v2=new THREE.RenderableVertex,this.vertexColors=[new THREE.Color,new THREE.Color],this.material=null,this.z=0,this.renderOrder=0},THREE.RenderableSprite=function(){this.id=0,this.object=null,this.x=0,this.y=0,this.z=0,this.rotation=0,this.scale=new THREE.Vector2,this.material=null,this.renderOrder=0},THREE.Projector=function(){function e(r){if(r.visible!==!1){if(r instanceof THREE.Light)C.lights.push(r);else if(r instanceof THREE.Mesh||r instanceof THREE.Line||r instanceof THREE.Points){if(r.material.visible===!1)return;if(r.frustumCulled===!0&&G.intersectsObject(r)===!1)return;t(r)}else if(r instanceof THREE.Sprite){if(r.material.visible===!1)return;if(r.frustumCulled===!0&&G.intersectsSprite(r)===!1)return;t(r)}for(var n=r.children,i=0,o=n.length;i=-1&&e.z<=1&&(y=s(),y.id=t.id,y.x=e.x*n,y.y=e.y*n,y.z=e.z,y.renderOrder=t.renderOrder,y.object=t,y.rotation=t.rotation,y.scale.x=t.scale.x*Math.abs(y.x-(e.x+r.projectionMatrix.elements[0])/(e.w+r.projectionMatrix.elements[12])),y.scale.y=t.scale.y*Math.abs(y.y-(e.y+r.projectionMatrix.elements[5])/(e.w+r.projectionMatrix.elements[13])),y.material=t.material,C.elements.push(y))}function n(){if(u===_){var e=new THREE.RenderableObject;return w.push(e),_++,u++,e}return w[u++]}function i(){if(d===M){var e=new THREE.RenderableVertex;return E.push(e),M++,d++,e}return E[d++]}function o(){if(m===S){var e=new THREE.RenderableFace;return T.push(e),S++,m++,e}return T[m++]}function a(){if(g===R){var e=new THREE.RenderableLine;return A.push(e),R++,g++,e}return A[g++]}function s(){if(x===P){var e=new THREE.RenderableSprite;return L.push(e),P++,x++,e}return L[x++]}function c(e,t){return e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id!==t.id?e.id-t.id:0}function h(e,t){var r=0,n=1,i=e.z+e.w,o=t.z+t.w,a=-e.z+e.w,s=-t.z+t.w;return i>=0&&o>=0&&a>=0&&s>=0||!(i<0&&o<0||a<0&&s<0)&&(i<0?r=Math.max(r,i/(i-o)):o<0&&(n=Math.min(n,i/(i-o))),a<0?r=Math.max(r,a/(a-s)):s<0&&(n=Math.min(n,a/(a-s))),!(n=-1&&n.x<=1&&n.y>=-1&&n.y<=1&&n.z>=-1&&n.z<=1}function r(e,r,n){p=i(),p.position.set(e,r,n),t(p)}function n(e,t,r){g.push(e,t,r)}function s(e,t,r){y.push(e,t,r)}function c(e,t){x.push(e,t)}function l(e,t,r){return e.visible===!0||t.visible===!0||r.visible===!0||(U[0]=e.positionScreen,U[1]=t.positionScreen,U[2]=r.positionScreen,N.intersectsBox(D.setFromPoints(U)))}function u(e,t,r){return(r.positionScreen.x-e.positionScreen.x)*(t.positionScreen.y-e.positionScreen.y)-(r.positionScreen.y-e.positionScreen.y)*(t.positionScreen.x-e.positionScreen.x)<0}function d(e,t){var r=E[e],n=E[t];r.positionScreen.copy(r.position).applyMatrix4(z),n.positionScreen.copy(n.position).applyMatrix4(z),h(r.positionScreen,n.positionScreen)===!0&&(r.positionScreen.multiplyScalar(1/r.positionScreen.w),n.positionScreen.multiplyScalar(1/n.positionScreen.w),v=a(),v.id=w.id,v.v1.copy(r),v.v2.copy(n),v.z=Math.max(r.positionScreen.z,n.positionScreen.z),v.renderOrder=w.renderOrder,v.material=w.material,w.material.vertexColors===THREE.VertexColors&&(v.vertexColors[0].fromArray(y,3*e), v.vertexColors[1].fromArray(y,3*t)),C.elements.push(v))}function m(e,t,r){var n=E[e],i=E[t],a=E[r];if(l(n,i,a)!==!1&&(_.side===THREE.DoubleSide||u(n,i,a)===!0)){f=o(),f.id=w.id,f.v1.copy(n),f.v2.copy(i),f.v3.copy(a),f.z=(n.positionScreen.z+i.positionScreen.z+a.positionScreen.z)/3,f.renderOrder=w.renderOrder,f.normalModel.fromArray(g,3*e),f.normalModel.applyMatrix3(M).normalize();for(var s=0;s<3;s++){var c=f.vertexNormalsModel[s];c.fromArray(g,3*arguments[s]),c.applyMatrix3(M).normalize();var h=f.uvs[s];h.fromArray(x,2*arguments[s])}f.vertexNormalsLength=3,f.material=w.material,C.elements.push(f)}}var g=[],y=[],x=[],w=null,_=null,M=new THREE.Matrix3;return{setObject:e,projectVertex:t,checkTriangleVisibility:l,checkBackfaceCulling:u,pushVertex:r,pushNormal:n,pushColor:s,pushUv:c,pushLine:d,pushTriangle:m}},W=new k;this.projectScene=function(t,n,s,l){m=0,g=0,x=0,C.elements.length=0,t.autoUpdate===!0&&t.updateMatrixWorld(),null===n.parent&&n.updateMatrixWorld(),B.copy(n.matrixWorldInverse),H.multiplyMatrices(n.projectionMatrix,B),G.setFromMatrix(H),u=0,C.objects.length=0,C.lights.length=0,e(t),s===!0&&C.objects.sort(c);for(var p=C.objects,y=0,w=p.length;y0)for(var U=0;U0||(pe=E[d-2],V.copy(ue.positionScreen),j.copy(pe.positionScreen),h(V,j)===!0&&(V.multiplyScalar(1/V.w),j.multiplyScalar(1/j.w),v=a(),v.id=_.id,v.v1.positionScreen.copy(V),v.v2.positionScreen.copy(j),v.z=Math.max(V.z,j.z),v.renderOrder=_.renderOrder,v.material=_.material,_.material.vertexColors===THREE.VertexColors&&(v.vertexColors[0].copy(_.geometry.colors[Q]),v.vertexColors[1].copy(_.geometry.colors[Q-1])),C.elements.push(v)))}}else if(_ instanceof THREE.Points){if(z.multiplyMatrices(H,b),M instanceof THREE.Geometry)for(var X=_.geometry.vertices,Q=0,K=X.length;Q","vec2 rand( const vec2 coord ) {","vec2 noise;","if ( useNoise ) {","float nx = dot ( coord, vec2( 12.9898, 78.233 ) );","float ny = dot ( coord, vec2( 12.9898, 78.233 ) * 2.0 );","noise = clamp( fract ( 43758.5453 * sin( vec2( nx, ny ) ) ), 0.0, 1.0 );","} else {","float ff = fract( 1.0 - coord.s * ( size.x / 2.0 ) );","float gg = fract( coord.t * ( size.y / 2.0 ) );","noise = vec2( 0.25, 0.75 ) * vec2( ff ) + vec2( 0.75, 0.25 ) * gg;","}","return ( noise * 2.0 - 1.0 ) * noiseAmount;","}","float readDepth( const in vec2 coord ) {","float cameraFarPlusNear = cameraFar + cameraNear;","float cameraFarMinusNear = cameraFar - cameraNear;","float cameraCoef = 2.0 * cameraNear;","#ifdef USE_LOGDEPTHBUF","float logz = unpackRGBAToDepth( texture2D( tDepth, coord ) );","float w = pow(2.0, (logz / logDepthBufFC)) - 1.0;","float z = (logz / w) + 1.0;","#else","float z = unpackRGBAToDepth( texture2D( tDepth, coord ) );","#endif","return cameraCoef / ( cameraFarPlusNear - z * cameraFarMinusNear );","}","float compareDepths( const in float depth1, const in float depth2, inout int far ) {","float garea = 8.0;","float diff = ( depth1 - depth2 ) * 100.0;","if ( diff < gDisplace ) {","garea = diffArea;","} else {","far = 1;","}","float dd = diff - gDisplace;","float gauss = pow( EULER, -2.0 * ( dd * dd ) / ( garea * garea ) );","return gauss;","}","float calcAO( float depth, float dw, float dh ) {","vec2 vv = vec2( dw, dh );","vec2 coord1 = vUv + radius * vv;","vec2 coord2 = vUv - radius * vv;","float temp1 = 0.0;","float temp2 = 0.0;","int far = 0;","temp1 = compareDepths( depth, readDepth( coord1 ), far );","if ( far > 0 ) {","temp2 = compareDepths( readDepth( coord2 ), depth, far );","temp1 += ( 1.0 - temp1 ) * temp2;","}","return temp1;","}","void main() {","vec2 noise = rand( vUv );","float depth = readDepth( vUv );","float tt = clamp( depth, aoClamp, 1.0 );","float w = ( 1.0 / size.x ) / tt + ( noise.x * ( 1.0 - noise.x ) );","float h = ( 1.0 / size.y ) / tt + ( noise.y * ( 1.0 - noise.y ) );","float ao = 0.0;","float dz = 1.0 / float( samples );","float l = 0.0;","float z = 1.0 - dz / 2.0;","for ( int i = 0; i <= samples; i ++ ) {","float r = sqrt( 1.0 - z );","float pw = cos( l ) * r;","float ph = sin( l ) * r;","ao += calcAO( depth, pw * w, ph * h );","z = z - dz;","l = l + DL;","}","ao /= float( samples );","ao = 1.0 - ao;","vec3 color = texture2D( tDiffuse, vUv ).rgb;","vec3 lumcoeff = vec3( 0.299, 0.587, 0.114 );","float lum = dot( color.rgb, lumcoeff );","vec3 luminance = vec3( lum );","vec3 final = vec3( color * mix( vec3( ao ), vec3( 1.0 ), luminance * lumInfluence ) );","if ( onlyAO ) {","final = vec3( mix( vec3( ao ), vec3( 1.0 ), luminance * lumInfluence ) );","}","gl_FragColor = vec4( final, 1.0 );","}"].join("\n")},THREE.CopyShader={uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform float opacity;","uniform sampler2D tDiffuse;","varying vec2 vUv;","void main() {","vec4 texel = texture2D( tDiffuse, vUv );","gl_FragColor = opacity * texel;","}"].join("\n")},THREE.EffectComposer=function(e,t){if(this.renderer=e,void 0===t){var r={minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,format:THREE.RGBAFormat,stencilBuffer:!1},n=e.getDrawingBufferSize();t=new THREE.WebGLRenderTarget(n.width,n.height,r),t.texture.name="EffectComposer.rt1"}this.renderTarget1=t,this.renderTarget2=t.clone(),this.renderTarget2.texture.name="EffectComposer.rt2",this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.passes=[],void 0===THREE.CopyShader&&console.error("THREE.EffectComposer relies on THREE.CopyShader"),void 0===THREE.ShaderPass&&console.error("THREE.EffectComposer relies on THREE.ShaderPass"),this.copyPass=new THREE.ShaderPass(THREE.CopyShader)},Object.assign(THREE.EffectComposer.prototype,{swapBuffers:function(){var e=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=e},addPass:function(e){this.passes.push(e);var t=this.renderer.getDrawingBufferSize();e.setSize(t.width,t.height)},insertPass:function(e,t){this.passes.splice(t,0,e)},render:function(e){var t,r,n=!1,i=this.passes.length;for(r=0;r