forked from WeBankFinTech/Visualis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
12.6a5e154d006bd4d2684b.chunk.js
1 lines (1 loc) · 262 KB
/
12.6a5e154d006bd4d2684b.chunk.js
1
(window.webpackJsonp=window.webpackJsonp||[]).push([[12,29],{"39c741a38b7f6fbfdd92":function(e,t,n){"use strict";n.d(t,"a",function(){return s});var i=n("550464552fd011906622"),r=n("cb92241db9e33ee3542f"),a=n("d1886278d8ad2602c715"),o=0;function s(){Object.defineProperty(this,"id",{value:o++}),this.uuid=a.a.generateUUID(),this.name="",this.type="Material",this.fog=!0,this.lights=!0,this.blending=r.fb,this.side=r.D,this.flatShading=!1,this.vertexColors=r.db,this.opacity=1,this.transparent=!1,this.blendSrc=r.ac,this.blendDst=r.lb,this.blendEquation=r.b,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=r.K,this.depthTest=!0,this.depthWrite=!0,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaTest=0,this.premultipliedAlpha=!1,this.visible=!0,this.userData={},this.needsUpdate=!0}s.prototype=Object.assign(Object.create(i.a.prototype),{constructor:s,isMaterial:!0,onBeforeCompile:function(){},setValues:function(e){if(void 0!==e)for(var t in e){var n=e[t];if(void 0!==n)if("shading"!==t){var i=this[t];void 0!==i?i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n:console.warn("THREE."+this.type+": '"+t+"' is not a property of this material.")}else console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=n===r.B;else console.warn("THREE.Material: '"+t+"' parameter is undefined.")}},toJSON:function(e){var t=void 0===e||"string"===typeof e;t&&(e={textures:{},images:{}});var n={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};function i(e){var t=[];for(var n in e){var i=e[n];delete i.metadata,t.push(i)}return t}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),void 0!==this.roughness&&(n.roughness=this.roughness),void 0!==this.metalness&&(n.metalness=this.metalness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),1!==this.emissiveIntensity&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),void 0!==this.shininess&&(n.shininess=this.shininess),void 0!==this.clearCoat&&(n.clearCoat=this.clearCoat),void 0!==this.clearCoatRoughness&&(n.clearCoatRoughness=this.clearCoatRoughness),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,n.reflectivity=this.reflectivity,void 0!==this.combine&&(n.combine=this.combine),void 0!==this.envMapIntensity&&(n.envMapIntensity=this.envMapIntensity)),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),void 0!==this.size&&(n.size=this.size),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==r.fb&&(n.blending=this.blending),!0===this.flatShading&&(n.flatShading=this.flatShading),this.side!==r.D&&(n.side=this.side),this.vertexColors!==r.db&&(n.vertexColors=this.vertexColors),this.opacity<1&&(n.opacity=this.opacity),!0===this.transparent&&(n.transparent=this.transparent),n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,0!==this.rotation&&(n.rotation=this.rotation),!0===this.polygonOffset&&(n.polygonOffset=!0),0!==this.polygonOffsetFactor&&(n.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(n.polygonOffsetUnits=this.polygonOffsetUnits),1!==this.linewidth&&(n.linewidth=this.linewidth),void 0!==this.dashSize&&(n.dashSize=this.dashSize),void 0!==this.gapSize&&(n.gapSize=this.gapSize),void 0!==this.scale&&(n.scale=this.scale),!0===this.dithering&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(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),!0===this.morphTargets&&(n.morphTargets=!0),!0===this.skinning&&(n.skinning=!0),!1===this.visible&&(n.visible=!1),"{}"!==JSON.stringify(this.userData)&&(n.userData=this.userData),t){var a=i(e.textures),o=i(e.images);a.length>0&&(n.textures=a),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.visible=e.visible,this.userData=JSON.parse(JSON.stringify(e.userData)),this.clipShadows=e.clipShadows,this.clipIntersection=e.clipIntersection;var t=e.clippingPlanes,n=null;if(null!==t){var i=t.length;n=new Array(i);for(var r=0;r!==i;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.shadowSide=e.shadowSide,this},dispose:function(){this.dispatchEvent({type:"dispose"})}})},"8908bd2155cefaf0af9d":function(e,t,n){"use strict";n.r(t);var i=n("a4f0ef367f0a790cdce8"),r=n("3fcced0dfecbf072faf3"),a=n("b82d2ea0c8dcd2b25103");function o(){r.a.call(this),this.type="Camera",this.matrixWorldInverse=new i.a,this.projectionMatrix=new i.a,this.projectionMatrixInverse=new i.a}o.prototype=Object.assign(Object.create(r.a.prototype),{constructor:o,isCamera:!0,copy:function(e,t){return r.a.prototype.copy.call(this,e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this},getWorldDirection:function(e){void 0===e&&(console.warn("THREE.Camera: .getWorldDirection() target is now required"),e=new a.a),this.updateMatrixWorld(!0);var t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()},updateMatrixWorld:function(e){r.a.prototype.updateMatrixWorld.call(this,e),this.matrixWorldInverse.getInverse(this.matrixWorld)},clone:function(){return(new this.constructor).copy(this)}});var s=n("d1886278d8ad2602c715");function l(e,t,n,i){o.call(this),this.type="PerspectiveCamera",this.fov=void 0!==e?e:50,this.zoom=1,this.near=void 0!==n?n:.1,this.far=void 0!==i?i:2e3,this.focus=10,this.aspect=void 0!==t?t:1,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}n.d(t,"PerspectiveCamera",function(){return l}),l.prototype=Object.assign(Object.create(o.prototype),{constructor:l,isPerspectiveCamera:!0,copy:function(e,t){return o.prototype.copy.call(this,e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=null===e.view?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this},setFocalLength:function(e){var t=.5*this.getFilmHeight()/e;this.fov=2*s.a.RAD2DEG*Math.atan(t),this.updateProjectionMatrix()},getFocalLength:function(){var e=Math.tan(.5*s.a.DEG2RAD*this.fov);return.5*this.getFilmHeight()/e},getEffectiveFOV:function(){return 2*s.a.RAD2DEG*Math.atan(Math.tan(.5*s.a.DEG2RAD*this.fov)/this.zoom)},getFilmWidth:function(){return this.filmGauge*Math.min(this.aspect,1)},getFilmHeight:function(){return this.filmGauge/Math.max(this.aspect,1)},setViewOffset:function(e,t,n,i,r,a){this.aspect=e/t,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()},clearViewOffset:function(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()},updateProjectionMatrix:function(){var e=this.near,t=e*Math.tan(.5*s.a.DEG2RAD*this.fov)/this.zoom,n=2*t,i=this.aspect*n,r=-.5*i,a=this.view;if(null!==this.view&&this.view.enabled){var o=a.fullWidth,l=a.fullHeight;r+=a.offsetX*i/o,t-=a.offsetY*n/l,i*=a.width/o,n*=a.height/l}var c=this.filmOffset;0!==c&&(r+=e*c/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,t,t-n,e,this.far),this.projectionMatrixInverse.getInverse(this.projectionMatrix)},toJSON:function(e){var t=r.a.prototype.toJSON.call(this,e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,null!==this.view&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}})},"9493e9352520294a389f":function(e,t,n){"use strict";n.d(t,"a",function(){return c});var i,r,a,o,s,l=n("b82d2ea0c8dcd2b25103");function c(e,t){this.origin=void 0!==e?e:new l.a,this.direction=void 0!==t?t:new l.a}Object.assign(c.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 l.a),t.copy(this.direction).multiplyScalar(e).add(this.origin)},lookAt:function(e){return this.direction.copy(e).sub(this.origin).normalize(),this},recast:(s=new l.a,function(e){return this.origin.copy(this.at(e,s)),this}),closestPointToPoint:function(e,t){void 0===t&&(console.warn("THREE.Ray: .closestPointToPoint() target is now required"),t=new l.a),t.subVectors(e,this.origin);var n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.direction).multiplyScalar(n).add(this.origin)},distanceToPoint:function(e){return Math.sqrt(this.distanceSqToPoint(e))},distanceSqToPoint:function(){var e=new l.a;return function(t){var n=e.subVectors(t,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(t):(e.copy(this.direction).multiplyScalar(n).add(this.origin),e.distanceToSquared(t))}}(),distanceSqToSegment:(r=new l.a,a=new l.a,o=new l.a,function(e,t,n,i){r.copy(e).add(t).multiplyScalar(.5),a.copy(t).sub(e).normalize(),o.copy(this.origin).sub(r);var s,l,c,d,u=.5*e.distanceTo(t),f=-this.direction.dot(a),p=o.dot(this.direction),h=-o.dot(a),m=o.lengthSq(),g=Math.abs(1-f*f);if(g>0)if(l=f*p-h,d=u*g,(s=f*h-p)>=0)if(l>=-d)if(l<=d){var v=1/g;c=(s*=v)*(s+f*(l*=v)+2*p)+l*(f*s+l+2*h)+m}else l=u,c=-(s=Math.max(0,-(f*l+p)))*s+l*(l+2*h)+m;else l=-u,c=-(s=Math.max(0,-(f*l+p)))*s+l*(l+2*h)+m;else l<=-d?c=-(s=Math.max(0,-(-f*u+p)))*s+(l=s>0?-u:Math.min(Math.max(-u,-h),u))*(l+2*h)+m:l<=d?(s=0,c=(l=Math.min(Math.max(-u,-h),u))*(l+2*h)+m):c=-(s=Math.max(0,-(f*u+p)))*s+(l=s>0?u:Math.min(Math.max(-u,-h),u))*(l+2*h)+m;else l=f>0?-u:u,c=-(s=Math.max(0,-(f*l+p)))*s+l*(l+2*h)+m;return n&&n.copy(this.direction).multiplyScalar(s).add(this.origin),i&&i.copy(a).multiplyScalar(l).add(r),c}),intersectSphere:function(){var e=new l.a;return function(t,n){e.subVectors(t.center,this.origin);var i=e.dot(this.direction),r=e.dot(e)-i*i,a=t.radius*t.radius;if(r>a)return null;var o=Math.sqrt(a-r),s=i-o,l=i+o;return s<0&&l<0?null:s<0?this.at(l,n):this.at(s,n)}}(),intersectsSphere:function(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius},distanceToPlane:function(e){var t=e.normal.dot(this.direction);if(0===t)return 0===e.distanceToPoint(this.origin)?0:null;var n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null},intersectPlane:function(e,t){var n=this.distanceToPlane(e);return null===n?null:this.at(n,t)},intersectsPlane:function(e){var t=e.distanceToPoint(this.origin);return 0===t||e.normal.dot(this.direction)*t<0},intersectBox:function(e,t){var n,i,r,a,o,s,l=1/this.direction.x,c=1/this.direction.y,d=1/this.direction.z,u=this.origin;return l>=0?(n=(e.min.x-u.x)*l,i=(e.max.x-u.x)*l):(n=(e.max.x-u.x)*l,i=(e.min.x-u.x)*l),c>=0?(r=(e.min.y-u.y)*c,a=(e.max.y-u.y)*c):(r=(e.max.y-u.y)*c,a=(e.min.y-u.y)*c),n>a||r>i?null:((r>n||n!==n)&&(n=r),(a<i||i!==i)&&(i=a),d>=0?(o=(e.min.z-u.z)*d,s=(e.max.z-u.z)*d):(o=(e.max.z-u.z)*d,s=(e.min.z-u.z)*d),n>s||o>i?null:((o>n||n!==n)&&(n=o),(s<i||i!==i)&&(i=s),i<0?null:this.at(n>=0?n:i,t)))},intersectsBox:(i=new l.a,function(e){return null!==this.intersectBox(e,i)}),intersectTriangle:function(){var e=new l.a,t=new l.a,n=new l.a,i=new l.a;return function(r,a,o,s,l){t.subVectors(a,r),n.subVectors(o,r),i.crossVectors(t,n);var c,d=this.direction.dot(i);if(d>0){if(s)return null;c=1}else{if(!(d<0))return null;c=-1,d=-d}e.subVectors(this.origin,r);var u=c*this.direction.dot(n.crossVectors(e,n));if(u<0)return null;var f=c*this.direction.dot(t.cross(e));if(f<0)return null;if(u+f>d)return null;var p=-c*e.dot(i);return p<0?null:this.at(p/d,l)}}(),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)}})},a9d74ad8a46048b4091b:function(e,t,n){"use strict";function i(e){var t={};for(var n in e)for(var i in t[n]={},e[n]){var r=e[n][i];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture)?t[n][i]=r.clone():Array.isArray(r)?t[n][i]=r.slice():t[n][i]=r}return t}function r(e){for(var t={},n=0;n<e.length;n++){var r=i(e[n]);for(var a in r)t[a]=r[a]}return t}n.d(t,"a",function(){return i}),n.d(t,"b",function(){return r})},b4419cc2aab9d79ef113:function(e,t,n){"use strict";n.r(t),n.d(t,"ShaderMaterial",function(){return a});var i=n("39c741a38b7f6fbfdd92"),r=n("a9d74ad8a46048b4091b");function a(e){i.a.call(this),this.type="ShaderMaterial",this.defines={},this.uniforms={},this.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",this.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}",this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,void 0!==e&&(void 0!==e.attributes&&console.error("THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead."),this.setValues(e))}a.prototype=Object.create(i.a.prototype),a.prototype.constructor=a,a.prototype.isShaderMaterial=!0,a.prototype.copy=function(e){return i.a.prototype.copy.call(this,e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Object(r.a)(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},a.prototype.toJSON=function(e){var t=i.a.prototype.toJSON.call(this,e);for(var n in t.uniforms={},this.uniforms){var r=this.uniforms[n].value;r&&r.isTexture?t.uniforms[n]={type:"t",value:r.toJSON(e).uuid}:r&&r.isColor?t.uniforms[n]={type:"c",value:r.getHex()}:r&&r.isVector2?t.uniforms[n]={type:"v2",value:r.toArray()}:r&&r.isVector3?t.uniforms[n]={type:"v3",value:r.toArray()}:r&&r.isVector4?t.uniforms[n]={type:"v4",value:r.toArray()}:r&&r.isMatrix3?t.uniforms[n]={type:"m3",value:r.toArray()}:r&&r.isMatrix4?t.uniforms[n]={type:"m4",value:r.toArray()}:t.uniforms[n]={value:r}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader;var a={};for(var o in this.extensions)!0===this.extensions[o]&&(a[o]=!0);return Object.keys(a).length>0&&(t.extensions=a),t}},f2390b5c77fe596cd8a0:function(e,t,n){"use strict";n.r(t);var i,r=n("cb92241db9e33ee3542f"),a=n("d1886278d8ad2602c715"),o=n("550464552fd011906622"),s=n("022920c09d348f259d0d"),l=n("9fdadb962569641cba1f"),c=function(e){var t;if("undefined"==typeof HTMLCanvasElement)return e.src;if(e instanceof HTMLCanvasElement)t=e;else{void 0===i&&(i=document.createElementNS("http://www.w3.org/1999/xhtml","canvas")),i.width=e.width,i.height=e.height;var n=i.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=i}return t.width>2048||t.height>2048?t.toDataURL("image/jpeg",.6):t.toDataURL("image/png")},d=0;function u(e,t,n,i,o,c,f,p,h,m){Object.defineProperty(this,"id",{value:d++}),this.uuid=a.a.generateUUID(),this.name="",this.image=void 0!==e?e:u.DEFAULT_IMAGE,this.mipmaps=[],this.mapping=void 0!==t?t:u.DEFAULT_MAPPING,this.wrapS=void 0!==n?n:r.k,this.wrapT=void 0!==i?i:r.k,this.magFilter=void 0!==o?o:r.M,this.minFilter=void 0!==c?c:r.N,this.anisotropy=void 0!==h?h:1,this.format=void 0!==f?f:r.rb,this.type=void 0!==p?p:r.kc,this.offset=new s.a(0,0),this.repeat=new s.a(1,1),this.center=new s.a(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new l.a,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=void 0!==m?m:r.L,this.version=0,this.onUpdate=null}function f(e,t,n,i,a,o,s,l,c,d,f,p){u.call(this,null,o,s,l,c,d,i,a,f,p),this.image={data:e,width:t,height:n},this.magFilter=void 0!==c?c:r.Y,this.minFilter=void 0!==d?d:r.Y,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}u.DEFAULT_IMAGE=void 0,u.DEFAULT_MAPPING=r.ic,u.prototype=Object.assign(Object.create(o.a.prototype),{constructor:u,isTexture:!0,updateMatrix:function(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.name=e.name,this.image=e.image,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.encoding=e.encoding,this},toJSON:function(e){var t=void 0===e||"string"===typeof e;if(!t&&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,type:this.type,encoding:this.encoding,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(void 0!==this.image){var i=this.image;if(void 0===i.uuid&&(i.uuid=a.a.generateUUID()),!t&&void 0===e.images[i.uuid]){var r;if(Array.isArray(i)){r=[];for(var o=0,s=i.length;o<s;o++)r.push(c(i[o]))}else r=c(i);e.images[i.uuid]={uuid:i.uuid,url:r}}n.image=i.uuid}return t||(e.textures[this.uuid]=n),n},dispose:function(){this.dispatchEvent({type:"dispose"})},transformUv:function(e){if(this.mapping!==r.ic)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case r.Wb:e.x=e.x-Math.floor(e.x);break;case r.k:e.x=e.x<0?0:1;break;case r.U: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 r.Wb:e.y=e.y-Math.floor(e.y);break;case r.k:e.y=e.y<0?0:1;break;case r.U:1===Math.abs(Math.floor(e.y)%2)?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y)}return this.flipY&&(e.y=1-e.y),e}}),Object.defineProperty(u.prototype,"needsUpdate",{set:function(e){!0===e&&this.version++}}),f.prototype=Object.create(u.prototype),f.prototype.constructor=f,f.prototype.isDataTexture=!0;var p,h,m,g,v=n("b82d2ea0c8dcd2b25103"),_=n("0427f930b2f19a25b61d");function x(e,t){this.normal=void 0!==e?e:new v.a(1,0,0),this.constant=void 0!==t?t:0}function b(e,t,n,i,r,a){this.planes=[void 0!==e?e:new x,void 0!==t?t:new x,void 0!==n?n:new x,void 0!==i?i:new x,void 0!==r?r:new x,void 0!==a?a:new x]}Object.assign(x.prototype,{set:function(e,t){return this.normal.copy(e),this.constant=t,this},setComponents:function(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this},setFromNormalAndCoplanarPoint:function(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this},setFromCoplanarPoints:(p=new v.a,h=new v.a,function(e,t,n){var i=p.subVectors(n,t).cross(h.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),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 v.a),t.copy(this.normal).multiplyScalar(-this.distanceToPoint(e)).add(e)},intersectLine:function(){var e=new v.a;return function(t,n){void 0===n&&(console.warn("THREE.Plane: .intersectLine() target is now required"),n=new v.a);var i=t.delta(e),r=this.normal.dot(i);if(0===r)return 0===this.distanceToPoint(t.start)?n.copy(t.start):void 0;var a=-(t.start.dot(this.normal)+this.constant)/r;return a<0||a>1?void 0:n.copy(i).multiplyScalar(a).add(t.start)}}(),intersectsLine:function(e){var t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<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 v.a),e.copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(){var e=new v.a,t=new l.a;return function(n,i){var r=i||t.getNormalMatrix(n),a=this.coplanarPoint(e).applyMatrix4(n),o=this.normal.applyMatrix3(r).normalize();return this.constant=-a.dot(o),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(b.prototype,{set:function(e,t,n,i,r,a){var o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(i),o[4].copy(r),o[5].copy(a),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){for(var t=this.planes,n=0;n<6;n++)t[n].copy(e.planes[n]);return this},setFromMatrix:function(e){var t=this.planes,n=e.elements,i=n[0],r=n[1],a=n[2],o=n[3],s=n[4],l=n[5],c=n[6],d=n[7],u=n[8],f=n[9],p=n[10],h=n[11],m=n[12],g=n[13],v=n[14],_=n[15];return t[0].setComponents(o-i,d-s,h-u,_-m).normalize(),t[1].setComponents(o+i,d+s,h+u,_+m).normalize(),t[2].setComponents(o+r,d+l,h+f,_+g).normalize(),t[3].setComponents(o-r,d-l,h-f,_-g).normalize(),t[4].setComponents(o-a,d-c,h-p,_-v).normalize(),t[5].setComponents(o+a,d+c,h+p,_+v).normalize(),this},intersectsObject:(g=new _.a,function(e){var t=e.geometry;return null===t.boundingSphere&&t.computeBoundingSphere(),g.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(g)}),intersectsSprite:function(){var e=new _.a;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,n=e.center,i=-e.radius,r=0;r<6;r++){if(t[r].distanceToPoint(n)<i)return!1}return!0},intersectsBox:(m=new v.a,function(e){for(var t=this.planes,n=0;n<6;n++){var i=t[n];if(m.x=i.normal.x>0?e.max.x:e.min.x,m.y=i.normal.y>0?e.max.y:e.min.y,m.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(m)<0)return!1}return!0}),containsPoint:function(e){for(var t=this.planes,n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}});var M=n("a4f0ef367f0a790cdce8"),E={alphamap_fragment:"\n#ifdef USE_ALPHAMAP\n\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n\n#endif\n",alphamap_pars_fragment:"\n#ifdef USE_ALPHAMAP\n\n\tuniform sampler2D alphaMap;\n\n#endif\n",alphatest_fragment:"\n#ifdef ALPHATEST\n\n\tif ( diffuseColor.a < ALPHATEST ) discard;\n\n#endif\n",aomap_fragment:"\n#ifdef USE_AOMAP\n\n\t// reads channel R, compatible with a combined OcclusionRoughnessMetallic (RGB) texture\n\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\n\t#if defined( USE_ENVMAP ) && defined( PHYSICAL )\n\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );\n\n\t#endif\n\n#endif\n",aomap_pars_fragment:"\n#ifdef USE_AOMAP\n\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n\n#endif\n",begin_vertex:"\nvec3 transformed = vec3( position );\n",beginnormal_vertex:"\nvec3 objectNormal = vec3( normal );\n",bsdfs:'\n\n// Analytical approximation of the DFG LUT, one half of the\n// split-sum approximation used in indirect specular lighting.\n// via \'environmentBRDF\' from "Physically Based Shading on Mobile"\n// https://www.unrealengine.com/blog/physically-based-shading-on-mobile - environmentBRDF for GGX on mobile\nvec2 integrateSpecularBRDF( const in float dotNV, const in float roughness ) {\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\n\tvec4 r = roughness * c0 + c1;\n\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\n\treturn vec2( -1.04, 1.04 ) * a004 + r.zw;\n\n}\n\nfloat punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\n\t// based upon Frostbite 3 Moving to Physically-based Rendering\n\t// page 32, equation 26: E[window1]\n\t// https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf\n\t// this is intended to be used on spot and point lights who are represented as luminous intensity\n\t// but who must be converted to luminous irradiance for surface lighting calculation\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\n\tif( cutoffDistance > 0.0 ) {\n\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\n\t}\n\n\treturn distanceFalloff;\n\n#else\n\n\tif( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\n\t}\n\n\treturn 1.0;\n\n#endif\n\n}\n\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\n\treturn RECIPROCAL_PI * diffuseColor;\n\n} // validated\n\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\n\t// Original approximation by Christophe Schlick \'94\n\t// float fresnel = pow( 1.0 - dotLH, 5.0 );\n\n\t// Optimized variant (presented by Epic at SIGGRAPH \'13)\n\t// https://cdn2.unrealengine.com/Resources/files/2013SiggraphPresentationsNotes-26915738.pdf\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n\n} // validated\n\n// Microfacet Models for Refraction through Rough Surfaces - equation (34)\n// http://graphicrants.blogspot.com/2013/08/specular-brdf-reference.html\n// alpha is "roughness squared" in Disney\u2019s reparameterization\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\n\t// geometry term (normalized) = G(l)\u22c5G(v) / 4(n\u22c5l)(n\u22c5v)\n\t// also see #12151\n\n\tfloat a2 = pow2( alpha );\n\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\n\treturn 1.0 / ( gl * gv );\n\n} // validated\n\n// Moving Frostbite to Physically Based Rendering 3.0 - page 12, listing 2\n// https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\n\tfloat a2 = pow2( alpha );\n\n\t// dotNL and dotNV are explicitly swapped. This is not a mistake.\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\n\treturn 0.5 / max( gv + gl, EPSILON );\n\n}\n\n// Microfacet Models for Refraction through Rough Surfaces - equation (33)\n// http://graphicrants.blogspot.com/2013/08/specular-brdf-reference.html\n// alpha is "roughness squared" in Disney\u2019s reparameterization\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\n\tfloat a2 = pow2( alpha );\n\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; // avoid alpha = 0 with dotNH = 1\n\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n\n}\n\n// GGX Distribution, Schlick Fresnel, GGX-Smith Visibility\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\n\tfloat alpha = pow2( roughness ); // UE4\'s roughness\n\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\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\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\n\tfloat D = D_GGX( alpha, dotNH );\n\n\treturn F * ( G * D );\n\n} // validated\n\n// Rect Area Light\n\n// Real-Time Polygonal-Light Shading with Linearly Transformed Cosines\n// by Eric Heitz, Jonathan Dupuy, Stephen Hill and David Neubelt\n// code: https://github.com/selfshadow/ltc_code/\n\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\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\n\tfloat dotNV = saturate( dot( N, V ) );\n\n\t// texture parameterized by sqrt( GGX alpha ) and sqrt( 1 - cos( theta ) )\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\n\treturn uv;\n\n}\n\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\n\t// Real-Time Area Lighting: a Journey from Research to Production (p.102)\n\t// An approximation of the form factor of a horizon-clipped rectangle.\n\n\tfloat l = length( f );\n\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n\n}\n\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\n\tfloat x = dot( v1, v2 );\n\n\tfloat y = abs( x );\n\n\t// rational polynomial approximation to theta / sin( theta ) / 2PI\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\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\n\treturn cross( v1, v2 ) * theta_sintheta;\n\n}\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\n\t// bail if point is on back side of plane of light\n\t// assumes ccw winding order of light vertices\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\n\t// construct orthonormal basis around N\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 ); // negated from paper; possibly due to a different handedness of world coordinate system\n\n\t// compute transform\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\n\t// transform rect\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\n\t// project rect onto sphere\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\n\t// calculate vector form factor\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\n\t// adjust for horizon clipping\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\n/*\n\t// alternate method of adjusting for horizon clipping (see referece)\n\t// refactoring required\n\tfloat len = length( vectorFormFactor );\n\tfloat z = vectorFormFactor.z / len;\n\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\n\t// tabulated horizon-clipped sphere, apparently...\n\tvec2 uv = vec2( z * 0.5 + 0.5, len );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\n\tfloat scale = texture2D( ltc_2, uv ).w;\n\n\tfloat result = len * scale;\n*/\n\n\treturn vec3( result );\n\n}\n\n// End Rect Area Light\n\n// ref: https://www.unrealengine.com/blog/physically-based-shading-on-mobile - environmentBRDF for GGX on mobile\nvec3 BRDF_Specular_GGX_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\n\treturn specularColor * brdf.x + brdf.y;\n\n} // validated\n\n// Fdez-Ag\xfcera\'s "Multiple-Scattering Microfacet Model for Real-Time Image Based Lighting"\n// Approximates multiscattering in order to preserve energy.\n// http://www.jcgt.org/published/0008/01/03/\nvoid BRDF_Specular_Multiscattering_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\n\tvec3 F = F_Schlick( specularColor, dotNV );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\tvec3 FssEss = F * brdf.x + brdf.y;\n\n\tfloat Ess = brdf.x + brdf.y;\n\tfloat Ems = 1.0 - Ess;\n\n\t// Paper incorrect indicates coefficient is PI/21, and will\n\t// be corrected to 1/21 in future updates.\n\tvec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619; // 1/21\n\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n\n}\n\nfloat G_BlinnPhong_Implicit( /* const in float dotNL, const in float dotNV */ ) {\n\n\t// geometry term is (n dot l)(n dot v) / 4(n dot l)(n dot v)\n\treturn 0.25;\n\n}\n\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n\n}\n\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\n\t//float dotNL = saturate( dot( geometry.normal, incidentLight.direction ) );\n\t//float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\n\tfloat G = G_BlinnPhong_Implicit( /* dotNL, dotNV */ );\n\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\n\treturn F * ( G * D );\n\n} // validated\n\n// source: http://simonstechblog.blogspot.ca/2011/12/microfacet-brdf.html\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\n\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n',bumpmap_pars_fragment:"\n#ifdef USE_BUMPMAP\n\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\n\t// Bump Mapping Unparametrized Surfaces on the GPU by Morten S. Mikkelsen\n\t// http://api.unrealengine.com/attachments/Engine/Rendering/LightingAndShadows/BumpMappingWithoutTangentSpace/mm_sfgrad_bump.pdf\n\n\t// Evaluate the derivative of the height w.r.t. screen-space using forward differencing (listing 2)\n\n\tvec2 dHdxy_fwd() {\n\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\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\n\t\treturn vec2( dBx, dBy );\n\n\t}\n\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n\n\t\t// Workaround for Adreno 3XX dFd*( vec3 ) bug. See #9988\n\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;\t\t// normalized\n\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\n\t\tfloat fDet = dot( vSigmaX, R1 );\n\n\t\tfDet *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\n\t}\n\n#endif\n",clipping_planes_fragment:"\n#if NUM_CLIPPING_PLANES > 0\n\n\tvec4 plane;\n\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vViewPosition, plane.xyz ) > plane.w ) discard;\n\n\t}\n\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\n\t\tbool clipped = true;\n\n\t\t#pragma unroll_loop\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vViewPosition, plane.xyz ) > plane.w ) && clipped;\n\n\t\t}\n\n\t\tif ( clipped ) discard;\n\n\t#endif\n\n#endif\n",clipping_planes_pars_fragment:"\n#if NUM_CLIPPING_PLANES > 0\n\n\t#if ! defined( PHYSICAL ) && ! defined( PHONG ) && ! defined( MATCAP )\n\t\tvarying vec3 vViewPosition;\n\t#endif\n\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n\n#endif\n",clipping_planes_pars_vertex:"\n#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG ) && ! defined( MATCAP )\n\tvarying vec3 vViewPosition;\n#endif\n",clipping_planes_vertex:"\n#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG ) && ! defined( MATCAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n",color_fragment:"\n#ifdef USE_COLOR\n\n\tdiffuseColor.rgb *= vColor;\n\n#endif\n",color_pars_fragment:"\n#ifdef USE_COLOR\n\n\tvarying vec3 vColor;\n\n#endif\n",color_pars_vertex:"\n#ifdef USE_COLOR\n\n\tvarying vec3 vColor;\n\n#endif\n",color_vertex:"\n#ifdef USE_COLOR\n\n\tvColor.xyz = color.xyz;\n\n#endif\n",common:"\n#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\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#define whiteCompliment(a) ( 1.0 - saturate( a ) )\n\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 ) ); }\n// expects values in the range of [0,1]x[0,1], returns values in the [0,1] range.\n// do not collapse into a single function per: http://byteblacksmith.com/improvements-to-the-canonical-one-liner-glsl-rand-for-opengl-es-2-0/\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}\n\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\n\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\n\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n};\n\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n}\n\n// http://en.wikibooks.org/wiki/GLSL_Programming/Applying_Matrix_Transformations\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n\n}\n\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\n\treturn - distance * planeNormal + point;\n\n}\n\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n\n}\n\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n\n}\n\nmat3 transposeMat3( const in mat3 m ) {\n\n\tmat3 tmp;\n\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\n\treturn tmp;\n\n}\n\n// https://en.wikipedia.org/wiki/Relative_luminance\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\n\treturn dot( weights, color.rgb );\n\n}\n",cube_uv_reflection_fragment:"\n#ifdef ENVMAP_TYPE_CUBE_UV\n\n#define cubeUV_textureSize (1024.0)\n\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))\n\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\t// Clamp the value to the max mip level counts. hard coded to 6 mips\n\td = clamp(d, 1.0, cubeUV_rangeClamp);\n\tfloat mipLevel = 0.5 * log2(d);\n\treturn vec2(floor(mipLevel), fract(mipLevel));\n}\n\n#define cubeUV_maxLods2 (log2(cubeUV_textureSize*0.25) - 2.0)\n#define cubeUV_rcpTextureSize (1.0 / cubeUV_textureSize)\n\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\n\tvec2 exp2_packed = exp2( vec2( roughnessLevel, mipLevel ) );\n\tvec2 rcp_exp2_packed = vec2( 1.0 ) / exp2_packed;\n\t// float powScale = exp2(roughnessLevel + mipLevel);\n\tfloat powScale = exp2_packed.x * exp2_packed.y;\n\t// float scale = 1.0 / exp2(roughnessLevel + 2.0 + mipLevel);\n\tfloat scale = rcp_exp2_packed.x * rcp_exp2_packed.y * 0.25;\n\t// float mipOffset = 0.75*(1.0 - 1.0/exp2(mipLevel))/exp2(roughnessLevel);\n\tfloat mipOffset = 0.75*(1.0 - rcp_exp2_packed.y) * rcp_exp2_packed.x;\n\n\tbool bRes = mipLevel == 0.0;\n\tscale = bRes && (scale < a) ? a : scale;\n\n\tvec3 r;\n\tvec2 offset;\n\tint face = getFaceFromDirection(direction);\n\n\tfloat rcpPowScale = 1.0 / powScale;\n\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\n#define cubeUV_maxLods3 (log2(cubeUV_textureSize*0.25) - 3.0)\n\nvec4 textureCubeUV( sampler2D envMap, 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\n\t// round to nearest mipmap if we are not interpolating.\n\tlevel0 += min( floor( s + 0.5 ), 5.0 );\n\n\t// Tri linear interpolation.\n\tvec2 uv_10 = getCubeUV(reflectedDirection, r1, level0);\n\tvec4 color10 = envMapTexelToLinear(texture2D(envMap, uv_10));\n\n\tvec2 uv_20 = getCubeUV(reflectedDirection, r2, level0);\n\tvec4 color20 = envMapTexelToLinear(texture2D(envMap, uv_20));\n\n\tvec4 result = mix(color10, color20, t);\n\n\treturn vec4(result.rgb, 1.0);\n}\n\n#endif\n",defaultnormal_vertex:"\nvec3 transformedNormal = normalMatrix * objectNormal;\n\n#ifdef FLIP_SIDED\n\n\ttransformedNormal = - transformedNormal;\n\n#endif\n",displacementmap_pars_vertex:"\n#ifdef USE_DISPLACEMENTMAP\n\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n\n#endif\n",displacementmap_vertex:"\n#ifdef USE_DISPLACEMENTMAP\n\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, uv ).x * displacementScale + displacementBias );\n\n#endif\n",emissivemap_fragment:"\n#ifdef USE_EMISSIVEMAP\n\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n\n#endif\n",emissivemap_pars_fragment:"\n#ifdef USE_EMISSIVEMAP\n\n\tuniform sampler2D emissiveMap;\n\n#endif\n",encodings_fragment:"\n gl_FragColor = linearToOutputTexel( gl_FragColor );\n",encodings_pars_fragment:"\n// For a discussion of what this is, please read this: http://lousodrome.net/blog/light/2013/05/26/gamma-correct-and-hdr-rendering-in-a-32-bits-buffer/\n\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\n\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );\n}\n\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );\n}\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.a );\n}\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.a );\n}\n\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\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// return vec4( value.brg, ( 3.0 + 128.0 ) / 256.0 );\n}\n\n// reference: http://iwasbeingirony.blogspot.ca/2010/06/difference-between-rgbm-and-rgbd.html\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * value.a * maxRange, 1.0 );\n}\n\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, 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}\n\n// reference: http://iwasbeingirony.blogspot.ca/2010/06/difference-between-rgbm-and-rgbd.html\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\n\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, 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}\n\n// LogLuv reference: http://graphicrants.blogspot.ca/2009/04/rgbm-color-encoding.html\n\n// M matrix, for encoding\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 = cLogLuvM * value.rgb;\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}\n\n// Inverse M matrix, for decoding\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 = cLogLuvInverseM * Xp_Y_XYZp.rgb;\n\treturn vec4( max( vRGB, 0.0 ), 1.0 );\n}\n",envmap_fragment:"\n#ifdef USE_ENVMAP\n\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\n\t\tvec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );\n\n\t\t// Transforming Normal Vectors with the Inverse Transformation\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\n\t\t\tvec3 reflectVec = reflect( cameraToVertex, worldNormal );\n\n\t\t#else\n\n\t\t\tvec3 reflectVec = refract( cameraToVertex, worldNormal, refractionRatio );\n\n\t\t#endif\n\n\t#else\n\n\t\tvec3 reflectVec = vReflect;\n\n\t#endif\n\n\t#ifdef ENVMAP_TYPE_CUBE\n\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\n\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\n\t\tvec2 sampleUV;\n\n\t\treflectVec = normalize( reflectVec );\n\n\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\n\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\n\t\tvec4 envColor = texture2D( envMap, sampleUV );\n\n\t#elif defined( ENVMAP_TYPE_SPHERE )\n\n\t\treflectVec = normalize( reflectVec );\n\n\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) );\n\n\t\tvec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );\n\n\t#else\n\n\t\tvec4 envColor = vec4( 0.0 );\n\n\t#endif\n\n\tenvColor = envMapTexelToLinear( envColor );\n\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\n\t#endif\n\n#endif\n",envmap_pars_fragment:"\n#if defined( USE_ENVMAP ) || defined( PHYSICAL )\n\tuniform float reflectivity;\n\tuniform float envMapIntensity;\n#endif\n\n#ifdef USE_ENVMAP\n\n\t#if ! defined( PHYSICAL ) && ( defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) )\n\t\tvarying vec3 vWorldPosition;\n\t#endif\n\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\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\n#endif\n",envmap_pars_vertex:"\n#ifdef USE_ENVMAP\n\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvarying vec3 vWorldPosition;\n\n\t#else\n\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\n\t#endif\n\n#endif\n",envmap_physical_pars_fragment:"\n#if defined( USE_ENVMAP ) && defined( PHYSICAL )\n\n\tvec3 getLightProbeIndirectIrradiance( /*const in SpecularLightProbe specularLightProbe,*/ const in GeometricContext geometry, const in int maxMIPLevel ) {\n\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\n\t\t\t// TODO: replace with properly filtered cubemaps and access the irradiance LOD level, be it the last LOD level\n\t\t\t// of a specular cubemap, or just the default level of a specially created irradiance cubemap.\n\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\n\t\t\t#else\n\n\t\t\t\t// force the bias high to get the last LOD level as it is the most blurred.\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\n\t\t\t#endif\n\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, queryVec, 1.0 );\n\n\t\t#else\n\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\n\t\t#endif\n\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\n\t}\n\n\t// taken from here: http://casual-effects.blogspot.ca/2011/08/plausible-environment-lighting-in-two.html\n\tfloat getSpecularMIPLevel( const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\n\t\t//float envMapWidth = pow( 2.0, maxMIPLevelScalar );\n\t\t//float desiredMIPLevel = log2( envMapWidth * sqrt( 3.0 ) ) - 0.5 * log2( pow2( blinnShininessExponent ) + 1.0 );\n\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar + 0.79248 - 0.5 * log2( pow2( blinnShininessExponent ) + 1.0 );\n\n\t\t// clamp to allowable LOD ranges.\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\n\t}\n\n\tvec3 getLightProbeIndirectRadiance( /*const in SpecularLightProbe specularLightProbe,*/ const in GeometricContext geometry, const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\n\t\t\tvec3 reflectVec = reflect( -geometry.viewDir, geometry.normal );\n\n\t\t#else\n\n\t\t\tvec3 reflectVec = refract( -geometry.viewDir, geometry.normal, refractionRatio );\n\n\t\t#endif\n\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( blinnShininessExponent, maxMIPLevel );\n\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\n\t\t\t#else\n\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\n\t\t\t#endif\n\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, queryReflectVec, BlinnExponentToGGXRoughness(blinnShininessExponent ));\n\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\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\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n\n\t\t\t#else\n\n\t\t\t\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n\n\t\t\t#endif\n\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\n\t\t#elif defined( ENVMAP_TYPE_SPHERE )\n\n\t\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0,0.0,1.0 ) );\n\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\n\t\t\t#else\n\n\t\t\t\tvec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\n\t\t\t#endif\n\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\n\t\t#endif\n\n\t\treturn envMapColor.rgb * envMapIntensity;\n\n\t}\n\n#endif\n",envmap_vertex:"\n#ifdef USE_ENVMAP\n\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\n\t\tvWorldPosition = worldPosition.xyz;\n\n\t#else\n\n\t\tvec3 cameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\n\t\t#else\n\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\n\t\t#endif\n\n\t#endif\n\n#endif\n",fog_vertex:"\n#ifdef USE_FOG\n\n\tfogDepth = -mvPosition.z;\n\n#endif\n",fog_pars_vertex:"\n#ifdef USE_FOG\n\n\tvarying float fogDepth;\n\n#endif\n",fog_fragment:"\n#ifdef USE_FOG\n\n\t#ifdef FOG_EXP2\n\n\t\tfloat fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * fogDepth * fogDepth * LOG2 ) );\n\n\t#else\n\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n\n\t#endif\n\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n\n#endif\n",fog_pars_fragment:"\n#ifdef USE_FOG\n\n\tuniform vec3 fogColor;\n\tvarying float fogDepth;\n\n\t#ifdef FOG_EXP2\n\n\t\tuniform float fogDensity;\n\n\t#else\n\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\n\t#endif\n\n#endif\n",gradientmap_pars_fragment:"\n#ifdef TOON\n\n\tuniform sampler2D gradientMap;\n\n\tvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\n\t\t// dotNL will be from -1.0 to 1.0\n\t\tfloat dotNL = dot( normal, lightDirection );\n\t\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\n\t\t#ifdef USE_GRADIENTMAP\n\n\t\t\treturn texture2D( gradientMap, coord ).rgb;\n\n\t\t#else\n\n\t\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\n\t\t#endif\n\n\n\t}\n\n#endif\n",lightmap_fragment:"\n#ifdef USE_LIGHTMAP\n\n\treflectedLight.indirectDiffuse += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity; // factor of PI should not be present; included here to prevent breakage\n\n#endif\n",lightmap_pars_fragment:"\n#ifdef USE_LIGHTMAP\n\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n\n#endif\n",lights_lambert_vertex:"\nvec3 diffuse = vec3( 1.0 );\n\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = normalize( -mvPosition.xyz );\n\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\n\nvLightFront = vec3( 0.0 );\nvIndirectFront = vec3( 0.0 );\n\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n\tvIndirectBack = vec3( 0.0 );\n#endif\n\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\n\n#if NUM_POINT_LIGHTS > 0\n\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\n\t\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\n\t\t#ifdef DOUBLE_SIDED\n\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\n\t\t#endif\n\n\t}\n\n#endif\n\n#if NUM_SPOT_LIGHTS > 0\n\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\n\t\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\n\t\t#ifdef DOUBLE_SIDED\n\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\n\t\t#endif\n\t}\n\n#endif\n\n/*\n#if NUM_RECT_AREA_LIGHTS > 0\n\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\n\t\t// TODO (abelnation): implement\n\n\t}\n\n#endif\n*/\n\n#if NUM_DIR_LIGHTS > 0\n\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\n\t\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\n\t\t#ifdef DOUBLE_SIDED\n\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\n\t\t#endif\n\n\t}\n\n#endif\n\n#if NUM_HEMI_LIGHTS > 0\n\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\n\t\tvIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\n\t\t#ifdef DOUBLE_SIDED\n\n\t\t\tvIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\n\t\t#endif\n\n\t}\n\n#endif\n",lights_pars_begin:"\nuniform vec3 ambientLightColor;\n\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\n\tvec3 irradiance = ambientLightColor;\n\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\n\t\tirradiance *= PI;\n\n\t#endif\n\n\treturn irradiance;\n\n}\n\n#if NUM_DIR_LIGHTS > 0\n\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\n\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\n\t\tdirectLight.color = directionalLight.color;\n\t\tdirectLight.direction = directionalLight.direction;\n\t\tdirectLight.visible = true;\n\n\t}\n\n#endif\n\n\n#if NUM_POINT_LIGHTS > 0\n\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\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\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\n\t// directLight is an out parameter as having it as a return value caused compiler errors on some devices\n\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\n\t\tfloat lightDistance = length( lVector );\n\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\n\t}\n\n#endif\n\n\n#if NUM_SPOT_LIGHTS > 0\n\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\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\n\t// directLight is an out parameter as having it as a return value caused compiler errors on some devices\n\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\n\n\t\tif ( angleCos > spotLight.coneCos ) {\n\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\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\n\t\t} else {\n\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\n\t\t}\n\t}\n\n#endif\n\n\n#if NUM_RECT_AREA_LIGHTS > 0\n\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\n\t// Pre-computed values of LinearTransformedCosine approximation of BRDF\n\t// BRDF approximation Texture is 64x64\n\tuniform sampler2D ltc_1; // RGBA Float\n\tuniform sampler2D ltc_2; // RGBA Float\n\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n\n#endif\n\n\n#if NUM_HEMI_LIGHTS > 0\n\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\n\t\t\tirradiance *= PI;\n\n\t\t#endif\n\n\t\treturn irradiance;\n\n\t}\n\n#endif\n",lights_phong_fragment:"\nBlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;\n",lights_phong_pars_fragment:"\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n#endif\n\n\nstruct BlinnPhongMaterial {\n\n\tvec3\tdiffuseColor;\n\tvec3\tspecularColor;\n\tfloat\tspecularShininess;\n\tfloat\tspecularStrength;\n\n};\n\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\n\t#ifdef TOON\n\n\t\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\n\t#else\n\n\t\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\t\tvec3 irradiance = dotNL * directLight.color;\n\n\t#endif\n\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\n\t\tirradiance *= PI; // punctual light\n\n\t#endif\n\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n\n}\n\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\n}\n\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n\n#define Material_LightProbeLOD( material )\t(0)\n",lights_physical_fragment:"\nPhysicalMaterial 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 ); // Burley clearcoat model\n\tmaterial.clearCoatRoughness = clamp( clearCoatRoughness, 0.04, 1.0 );\n#endif\n",lights_physical_pars_fragment:"\nstruct PhysicalMaterial {\n\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n\n\t#ifndef STANDARD\n\t\tfloat clearCoat;\n\t\tfloat clearCoatRoughness;\n\t#endif\n\n};\n\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\n\n// Clear coat directional hemishperical reflectance (this approximation should be improved)\nfloat clearCoatDHRApprox( const in float roughness, const in float dotNL ) {\n\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n\n}\n\n#if NUM_RECT_AREA_LIGHTS > 0\n\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\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\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight; // counterclockwise; light shines in local neg z direction\n\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\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\n\t\t// LTC Fresnel Approximation by Stephen Hill\n\t\t// http://blog.selfshadow.com/publications/s2016-advances/s2016_ltc_fresnel.pdf\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\n\t}\n\n#endif\n\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\n\tvec3 irradiance = dotNL * directLight.color;\n\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\n\t\tirradiance *= PI; // punctual light\n\n\t#endif\n\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\n\treflectedLight.directSpecular += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry, material.specularColor, material.specularRoughness );\n\n\treflectedLight.directDiffuse += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\n\t#ifndef STANDARD\n\n\t\treflectedLight.directSpecular += irradiance * material.clearCoat * BRDF_Specular_GGX( directLight, geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\n\t#endif\n\n}\n\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\n\t// Defer to the IndirectSpecular function to compute\n\t// the indirectDiffuse if energy preservation is enabled.\n\t#ifndef ENVMAP_TYPE_CUBE_UV\n\n\t\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\n\t#endif\n\n}\n\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearCoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\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\n\tfloat clearCoatInv = 1.0 - clearCoatDHR;\n\n\t// Both indirect specular and diffuse light accumulate here\n\t// if energy preservation enabled, and PMREM provided.\n\t#if defined( ENVMAP_TYPE_CUBE_UV )\n\n\t\tvec3 singleScattering = vec3( 0.0 );\n\t\tvec3 multiScattering = vec3( 0.0 );\n\t\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\n\t\tBRDF_Specular_Multiscattering_Environment( geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering );\n\n\t\t// The multiscattering paper uses the below formula for calculating diffuse \n\t\t// for dielectrics, but this is already handled when initially computing the \n\t\t// specular and diffuse color, so we can just use the diffuseColor directly.\n\t\t//vec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n\t\tvec3 diffuse = material.diffuseColor;\n\n\t\treflectedLight.indirectSpecular += clearCoatInv * radiance * singleScattering;\n\t\treflectedLight.indirectDiffuse += multiScattering * cosineWeightedIrradiance;\n\t\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n\n\t#else\n\n\t\treflectedLight.indirectSpecular += clearCoatInv * radiance * BRDF_Specular_GGX_Environment( geometry, material.specularColor, material.specularRoughness );\n\n\t#endif\n\n\t#ifndef STANDARD\n\n\t\treflectedLight.indirectSpecular += clearCoatRadiance * material.clearCoat * BRDF_Specular_GGX_Environment( geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\n\t#endif\n}\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\n#define Material_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.specularRoughness )\n#define Material_ClearCoat_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.clearCoatRoughness )\n\n// ref: https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n\n}\n",lights_fragment_begin:"\n/**\n * This is a template that can be used to light a material, it uses pluggable\n * RenderEquations (RE)for specific lighting scenarios.\n *\n * Instructions for use:\n * - Ensure that both RE_Direct, RE_IndirectDiffuse and RE_IndirectSpecular are defined\n * - If you have defined an RE_IndirectSpecular, you need to also provide a Material_LightProbeLOD. <---- ???\n * - Create a material parameter that is to be passed as the third parameter to your lighting functions.\n *\n * TODO:\n * - Add area light support.\n * - Add sphere light support.\n * - Add diffuse light probe (irradiance cubemap) support.\n */\n\nGeometricContext geometry;\n\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = normalize( vViewPosition );\n\nIncidentLight directLight;\n\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\n\tPointLight pointLight;\n\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\n\t\tpointLight = pointLights[ i ];\n\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\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\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\n\t}\n\n#endif\n\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\n\tSpotLight spotLight;\n\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\n\t\tspotLight = spotLights[ i ];\n\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\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\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\n\t}\n\n#endif\n\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\n\tDirectionalLight directionalLight;\n\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\n\t\tdirectionalLight = directionalLights[ i ];\n\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\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\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\n\t}\n\n#endif\n\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\n\tRectAreaLight rectAreaLight;\n\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\n\t}\n\n#endif\n\n#if defined( RE_IndirectDiffuse )\n\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\n\t\t#pragma unroll_loop\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\n\t\t}\n\n\t#endif\n\n#endif\n\n#if defined( RE_IndirectSpecular )\n\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearCoatRadiance = vec3( 0.0 );\n\n#endif\n",lights_fragment_maps:"\n#if defined( RE_IndirectDiffuse )\n\n\t#ifdef USE_LIGHTMAP\n\n\t\tvec3 lightMapIrradiance = texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\n\t\t\tlightMapIrradiance *= PI; // factor of PI should not be present; included here to prevent breakage\n\n\t\t#endif\n\n\t\tirradiance += lightMapIrradiance;\n\n\t#endif\n\n\t#if defined( USE_ENVMAP ) && defined( PHYSICAL ) && defined( ENVMAP_TYPE_CUBE_UV )\n\n\t\tirradiance += getLightProbeIndirectIrradiance( /*lightProbe,*/ geometry, maxMipLevel );\n\n\t#endif\n\n#endif\n\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\n\tradiance += getLightProbeIndirectRadiance( /*specularLightProbe,*/ geometry, Material_BlinnShininessExponent( material ), maxMipLevel );\n\n\t#ifndef STANDARD\n\t\tclearCoatRadiance += getLightProbeIndirectRadiance( /*specularLightProbe,*/ geometry, Material_ClearCoat_BlinnShininessExponent( material ), maxMipLevel );\n\t#endif\n\n#endif\n",lights_fragment_end:"\n#if defined( RE_IndirectDiffuse )\n\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n\n#endif\n\n#if defined( RE_IndirectSpecular )\n\n\tRE_IndirectSpecular( radiance, irradiance, clearCoatRadiance, geometry, material, reflectedLight );\n\n#endif\n",logdepthbuf_fragment:"\n#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\n\tgl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;\n\n#endif\n",logdepthbuf_pars_fragment:"\n#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\n#endif\n",logdepthbuf_pars_vertex:"\n#ifdef USE_LOGDEPTHBUF\n\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\n\t\tvarying float vFragDepth;\n\n\t#else\n\n\t\tuniform float logDepthBufFC;\n\n\t#endif\n\n#endif\n",logdepthbuf_vertex:"\n#ifdef USE_LOGDEPTHBUF\n\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\n\t#else\n\n\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\n\t\tgl_Position.z *= gl_Position.w;\n\n\t#endif\n\n#endif\n",map_fragment:"\n#ifdef USE_MAP\n\n\tvec4 texelColor = texture2D( map, vUv );\n\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n\n#endif\n",map_pars_fragment:"\n#ifdef USE_MAP\n\n\tuniform sampler2D map;\n\n#endif\n",map_particle_fragment:"\n#ifdef USE_MAP\n\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\n#endif\n",map_particle_pars_fragment:"\n#ifdef USE_MAP\n\n\tuniform mat3 uvTransform;\n\tuniform sampler2D map;\n\n#endif\n",metalnessmap_fragment:"\nfloat metalnessFactor = metalness;\n\n#ifdef USE_METALNESSMAP\n\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\n\t// reads channel B, compatible with a combined OcclusionRoughnessMetallic (RGB) texture\n\tmetalnessFactor *= texelMetalness.b;\n\n#endif\n",metalnessmap_pars_fragment:"\n#ifdef USE_METALNESSMAP\n\n\tuniform sampler2D metalnessMap;\n\n#endif\n",morphnormal_vertex:"\n#ifdef USE_MORPHNORMALS\n\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\n#endif\n",morphtarget_pars_vertex:"\n#ifdef USE_MORPHTARGETS\n\n\t#ifndef USE_MORPHNORMALS\n\n\tuniform float morphTargetInfluences[ 8 ];\n\n\t#else\n\n\tuniform float morphTargetInfluences[ 4 ];\n\n\t#endif\n\n#endif\n",morphtarget_vertex:"\n#ifdef USE_MORPHTARGETS\n\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\n\t#ifndef USE_MORPHNORMALS\n\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\n\t#endif\n\n#endif\n",normal_fragment_begin:"\n#ifdef FLAT_SHADED\n\n\t// Workaround for Adreno/Nexus5 not able able to do dFdx( vViewPosition ) ...\n\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\n#else\n\n\tvec3 normal = normalize( vNormal );\n\n\t#ifdef DOUBLE_SIDED\n\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\n\t#endif\n\n#endif\n",normal_fragment_maps:"\n#ifdef USE_NORMALMAP\n\n\t#ifdef OBJECTSPACE_NORMALMAP\n\n\t\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0; // overrides both flatShading and attribute normals\n\n\t\t#ifdef FLIP_SIDED\n\n\t\t\tnormal = - normal;\n\n\t\t#endif\n\n\t\t#ifdef DOUBLE_SIDED\n\n\t\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\n\t\t#endif\n\n\t\tnormal = normalize( normalMatrix * normal );\n\n\t#else // tangent-space normal map\n\n\t\tnormal = perturbNormal2Arb( -vViewPosition, normal );\n\n\t#endif\n\n#elif defined( USE_BUMPMAP )\n\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n\n#endif\n",normalmap_pars_fragment:"\n#ifdef USE_NORMALMAP\n\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n\n\t#ifdef OBJECTSPACE_NORMALMAP\n\n\t\tuniform mat3 normalMatrix;\n\n\t#else\n\n\t\t// Per-Pixel Tangent Space Normal Mapping\n\t\t// http://hacksoflife.blogspot.ch/2009/11/per-pixel-tangent-space-normal-mapping.html\n\n\t\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm ) {\n\n\t\t\t// Workaround for Adreno 3XX dFd*( vec3 ) bug. See #9988\n\n\t\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\t\tvec2 st0 = dFdx( vUv.st );\n\t\t\tvec2 st1 = dFdy( vUv.st );\n\n\t\t\tfloat scale = sign( st1.t * st0.s - st0.t * st1.s ); // we do not care about the magnitude\n\n\t\t\tvec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );\n\t\t\tvec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );\n\t\t\tvec3 N = normalize( surf_norm );\n\t\t\tmat3 tsn = mat3( S, T, N );\n\n\t\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\n\t\t\tmapN.xy *= normalScale;\n\t\t\tmapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\n\t\t\treturn normalize( tsn * mapN );\n\n\t\t}\n\n\t#endif\n\n#endif\n",packing:"\nvec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\n\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\n\nconst float PackUpscale = 256. / 255.; // fraction -> 0..1 (including 1)\nconst float UnpackDownscale = 255. / 256.; // 0..1 -> fraction (excluding 1)\n\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\n\nconst float ShiftRight8 = 1. / 256.;\n\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8; // tidy overflow\n\treturn r * PackUpscale;\n}\n\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\n\n// NOTE: viewZ/eyeZ is < 0 when in front of the camera per OpenGL conventions\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}\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",premultiplied_alpha_fragment:"\n#ifdef PREMULTIPLIED_ALPHA\n\n\t// Get get normal blending with premultipled, use with CustomBlending, OneFactor, OneMinusSrcAlphaFactor, AddEquation.\n\tgl_FragColor.rgb *= gl_FragColor.a;\n\n#endif\n",project_vertex:"\nvec4 mvPosition = modelViewMatrix * vec4( transformed, 1.0 );\n\ngl_Position = projectionMatrix * mvPosition;\n",dithering_fragment:"\n#if defined( DITHERING )\n\n gl_FragColor.rgb = dithering( gl_FragColor.rgb );\n\n#endif\n",dithering_pars_fragment:"\n#if defined( DITHERING )\n\n\t// based on https://www.shadertoy.com/view/MslGR8\n\tvec3 dithering( vec3 color ) {\n\t\t//Calculate grid position\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\n\t\t//Shift the individual colors differently, thus making it even harder to see the dithering pattern\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\n\t\t//modify shift acording to grid position.\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\n\t\t//shift the color by dither_shift\n\t\treturn color + dither_shift_RGB;\n\t}\n\n#endif\n",roughnessmap_fragment:"\nfloat roughnessFactor = roughness;\n\n#ifdef USE_ROUGHNESSMAP\n\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\n\t// reads channel G, compatible with a combined OcclusionRoughnessMetallic (RGB) texture\n\troughnessFactor *= texelRoughness.g;\n\n#endif\n",roughnessmap_pars_fragment:"\n#ifdef USE_ROUGHNESSMAP\n\n\tuniform sampler2D roughnessMap;\n\n#endif\n",shadowmap_pars_fragment:"\n#ifdef USE_SHADOWMAP\n\n\t#if NUM_DIR_LIGHTS > 0\n\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\n\t#endif\n\n\t#if NUM_SPOT_LIGHTS > 0\n\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\n\t#endif\n\n\t#if NUM_POINT_LIGHTS > 0\n\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n\n\t#endif\n\n\t/*\n\t#if NUM_RECT_AREA_LIGHTS > 0\n\n\t\t// TODO (abelnation): create uniforms for area light shadows\n\n\t#endif\n\t*/\n\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\n\t}\n\n\tfloat texture2DShadowLerp( sampler2D depths, vec2 size, vec2 uv, float compare ) {\n\n\t\tconst vec2 offset = vec2( 0.0, 1.0 );\n\n\t\tvec2 texelSize = vec2( 1.0 ) / size;\n\t\tvec2 centroidUV = floor( uv * size + 0.5 ) / size;\n\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\n\t\tvec2 f = fract( uv * size + 0.5 );\n\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\n\t\treturn c;\n\n\t}\n\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\n\t\tfloat shadow = 1.0;\n\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\n\t\t// if ( something && something ) breaks ATI OpenGL shader compiler\n\t\t// if ( all( something, something ) ) using this instead\n\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\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\n\t\tbool frustumTest = all( frustumTestVec );\n\n\t\tif ( frustumTest ) {\n\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\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\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\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\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\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\n\t\t#else // no percentage-closer filtering:\n\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\n\t\t#endif\n\n\t\t}\n\n\t\treturn shadow;\n\n\t}\n\n\t// cubeToUV() maps a 3D direction vector suitable for cube texture mapping to a 2D\n\t// vector suitable for 2D texture mapping. This code uses the following layout for the\n\t// 2D texture:\n\t//\n\t// xzXZ\n\t// y Y\n\t//\n\t// Y - Positive y direction\n\t// y - Negative y direction\n\t// X - Positive x direction\n\t// x - Negative x direction\n\t// Z - Positive z direction\n\t// z - Negative z direction\n\t//\n\t// Source and test bed:\n\t// https://gist.github.com/tschw/da10c43c467ce8afd0c4\n\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\n\t\t// Number of texels to avoid at the edge of each square\n\n\t\tvec3 absV = abs( v );\n\n\t\t// Intersect unit cube\n\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\n\t\t// Apply scale to avoid seams\n\n\t\t// two texels less per square (one texel will do for NEAREST)\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\n\t\t// Unwrap\n\n\t\t// space: -1 ... 1 range for each square\n\t\t//\n\t\t// #X##\t\tdim := ( 4 , 2 )\n\t\t// # #\t\tcenter := ( 1 , 1 )\n\n\t\tvec2 planar = v.xy;\n\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\n\t\tif ( absV.z >= almostOne ) {\n\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\n\t\t} else if ( absV.x >= almostOne ) {\n\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\n\t\t} else if ( absV.y >= almostOne ) {\n\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\n\t\t}\n\n\t\t// Transform to UV space\n\n\t\t// scale := 0.5 / dim\n\t\t// translate := ( center + 0.5 ) / dim\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\n\t}\n\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\n\t\t// for point lights, the uniform @vShadowCoord is re-purposed to hold\n\t\t// the vector from the light to the world-space position of the fragment.\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\n\t\t// dp = normalized distance from light to fragment position\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); // need to clamp?\n\t\tdp += shadowBias;\n\n\t\t// bd3D = base direction 3D\n\t\tvec3 bd3D = normalize( lightToPosition );\n\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT )\n\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\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\n\t\t#else // no percentage-closer filtering\n\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\n\t\t#endif\n\n\t}\n\n#endif\n",shadowmap_pars_vertex:"\n#ifdef USE_SHADOWMAP\n\n\t#if NUM_DIR_LIGHTS > 0\n\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\n\t#endif\n\n\t#if NUM_SPOT_LIGHTS > 0\n\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\n\t#endif\n\n\t#if NUM_POINT_LIGHTS > 0\n\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n\n\t#endif\n\n\t/*\n\t#if NUM_RECT_AREA_LIGHTS > 0\n\n\t\t// TODO (abelnation): uniforms for area light shadows\n\n\t#endif\n\t*/\n\n#endif\n",shadowmap_vertex:"\n#ifdef USE_SHADOWMAP\n\n\t#if NUM_DIR_LIGHTS > 0\n\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\n\n\t}\n\n\t#endif\n\n\t#if NUM_SPOT_LIGHTS > 0\n\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\n\n\t}\n\n\t#endif\n\n\t#if NUM_POINT_LIGHTS > 0\n\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;\n\n\t}\n\n\t#endif\n\n\t/*\n\t#if NUM_RECT_AREA_LIGHTS > 0\n\n\t\t// TODO (abelnation): update vAreaShadowCoord with area light info\n\n\t#endif\n\t*/\n\n#endif\n",shadowmask_pars_fragment:"\nfloat getShadowMask() {\n\n\tfloat shadow = 1.0;\n\n\t#ifdef USE_SHADOWMAP\n\n\t#if NUM_DIR_LIGHTS > 0\n\n\tDirectionalLight directionalLight;\n\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\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\n\t}\n\n\t#endif\n\n\t#if NUM_SPOT_LIGHTS > 0\n\n\tSpotLight spotLight;\n\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\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\n\t}\n\n\t#endif\n\n\t#if NUM_POINT_LIGHTS > 0\n\n\tPointLight pointLight;\n\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\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\n\t}\n\n\t#endif\n\n\t/*\n\t#if NUM_RECT_AREA_LIGHTS > 0\n\n\t\t// TODO (abelnation): update shadow for Area light\n\n\t#endif\n\t*/\n\n\t#endif\n\n\treturn shadow;\n\n}\n",skinbase_vertex:"\n#ifdef USE_SKINNING\n\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\n#endif\n",skinning_pars_vertex:"\n#ifdef USE_SKINNING\n\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\n\t#ifdef BONE_TEXTURE\n\n\t\tuniform sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\n\t\tmat4 getBoneMatrix( const in float i ) {\n\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\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\n\t\t\ty = dy * ( y + 0.5 );\n\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\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\n\t\t\treturn bone;\n\n\t\t}\n\n\t#else\n\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\n\t\tmat4 getBoneMatrix( const in float i ) {\n\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\n\t\t}\n\n\t#endif\n\n#endif\n",skinning_vertex:"\n#ifdef USE_SKINNING\n\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\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\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n\n#endif\n",skinnormal_vertex:"\n#ifdef USE_SKINNING\n\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\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\n#endif\n",specularmap_fragment:"\nfloat specularStrength;\n\n#ifdef USE_SPECULARMAP\n\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n\n#else\n\n\tspecularStrength = 1.0;\n\n#endif\n",specularmap_pars_fragment:"\n#ifdef USE_SPECULARMAP\n\n\tuniform sampler2D specularMap;\n\n#endif\n",tonemapping_fragment:"\n#if defined( TONE_MAPPING )\n\n gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n\n#endif\n",tonemapping_pars_fragment:"\n#ifndef saturate\n\t#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\n\nuniform float toneMappingExposure;\nuniform float toneMappingWhitePoint;\n\n// exposure only\nvec3 LinearToneMapping( vec3 color ) {\n\n\treturn toneMappingExposure * color;\n\n}\n\n// source: https://www.cs.utah.edu/~reinhard/cdrom/\nvec3 ReinhardToneMapping( vec3 color ) {\n\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n\n}\n\n// source: http://filmicgames.com/archives/75\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\n\t// John Hable's filmic operator from Uncharted 2 video game\n\tcolor *= toneMappingExposure;\n\treturn saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\n\n}\n\n// source: http://filmicgames.com/archives/75\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\n\t// optimized filmic operator by Jim Hejl and Richard Burgess-Dawson\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}\n\n// source: https://knarkowicz.wordpress.com/2016/01/06/aces-filmic-tone-mapping-curve/\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\n\tcolor *= toneMappingExposure;\n\treturn saturate( ( color * ( 2.51 * color + 0.03 ) ) / ( color * ( 2.43 * color + 0.59 ) + 0.14 ) );\n\n}\n",uv_pars_fragment:"\n#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\n\tvarying vec2 vUv;\n\n#endif\n",uv_pars_vertex:"\n#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\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n\n#endif\n",uv_vertex:"\n#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\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\n#endif\n",uv2_pars_fragment:"\n#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\n\tvarying vec2 vUv2;\n\n#endif\n",uv2_pars_vertex:"\n#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n\n#endif\n",uv2_vertex:"\n#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\n\tvUv2 = uv2;\n\n#endif\n",worldpos_vertex:"\n#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )\n\n\tvec4 worldPosition = modelMatrix * vec4( transformed, 1.0 );\n\n#endif\n",background_frag:"\nuniform sampler2D t2D;\n\nvarying vec2 vUv;\n\nvoid main() {\n\n\tvec4 texColor = texture2D( t2D, vUv );\n\n\tgl_FragColor = mapTexelToLinear( texColor );\n\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\n}\n",background_vert:"\nvarying vec2 vUv;\nuniform mat3 uvTransform;\n\nvoid main() {\n\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n\n}\n",cube_frag:"\nuniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\n\nvarying vec3 vWorldDirection;\n\nvoid main() {\n\n\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\n\tgl_FragColor = mapTexelToLinear( texColor );\n\tgl_FragColor.a *= opacity;\n\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\n}\n",cube_vert:"\nvarying vec3 vWorldDirection;\n\n#include <common>\n\nvoid main() {\n\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\n\tgl_Position.z = gl_Position.w; // set z to camera.far\n\n}\n",depth_frag:"\n#if DEPTH_PACKING == 3200\n\n\tuniform float opacity;\n\n#endif\n\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\n\nvoid main() {\n\n\t#include <clipping_planes_fragment>\n\n\tvec4 diffuseColor = vec4( 1.0 );\n\n\t#if DEPTH_PACKING == 3200\n\n\t\tdiffuseColor.a = opacity;\n\n\t#endif\n\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\n\t#include <logdepthbuf_fragment>\n\n\t#if DEPTH_PACKING == 3200\n\n\t\tgl_FragColor = vec4( vec3( 1.0 - gl_FragCoord.z ), opacity );\n\n\t#elif DEPTH_PACKING == 3201\n\n\t\tgl_FragColor = packDepthToRGBA( gl_FragCoord.z );\n\n\t#endif\n\n}\n",depth_vert:"\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n\nvoid main() {\n\n\t#include <uv_vertex>\n\n\t#include <skinbase_vertex>\n\n\t#ifdef USE_DISPLACEMENTMAP\n\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\n\t#endif\n\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\n}\n",distanceRGBA_frag:"\n#define DISTANCE\n\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <clipping_planes_pars_fragment>\n\nvoid main () {\n\n\t#include <clipping_planes_fragment>\n\n\tvec4 diffuseColor = vec4( 1.0 );\n\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist ); // clamp to [ 0, 1 ]\n\n\tgl_FragColor = packDepthToRGBA( dist );\n\n}\n",distanceRGBA_vert:"\n#define DISTANCE\n\nvarying vec3 vWorldPosition;\n\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\n\nvoid main() {\n\n\t#include <uv_vertex>\n\n\t#include <skinbase_vertex>\n\n\t#ifdef USE_DISPLACEMENTMAP\n\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\n\t#endif\n\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\n\tvWorldPosition = worldPosition.xyz;\n\n}\n",equirect_frag:"\nuniform sampler2D tEquirect;\n\nvarying vec3 vWorldDirection;\n\n#include <common>\n\nvoid main() {\n\n\tvec3 direction = normalize( vWorldDirection );\n\n\tvec2 sampleUV;\n\n\tsampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\n\tsampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;\n\n\tvec4 texColor = texture2D( tEquirect, sampleUV );\n\n\tgl_FragColor = mapTexelToLinear( texColor );\n\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\n}\n",equirect_vert:"\nvarying vec3 vWorldDirection;\n\n#include <common>\n\nvoid main() {\n\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\n}\n",linedashed_frag:"\nuniform vec3 diffuse;\nuniform float opacity;\n\nuniform float dashSize;\nuniform float totalSize;\n\nvarying float vLineDistance;\n\n#include <common>\n#include <color_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\n\nvoid main() {\n\n\t#include <clipping_planes_fragment>\n\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\n\t\tdiscard;\n\n\t}\n\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\n\t#include <logdepthbuf_fragment>\n\t#include <color_fragment>\n\n\toutgoingLight = diffuseColor.rgb; // simple shader\n\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\n\t#include <premultiplied_alpha_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\n}\n",linedashed_vert:"\nuniform float scale;\nattribute float lineDistance;\n\nvarying float vLineDistance;\n\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n\nvoid main() {\n\n\t#include <color_vertex>\n\n\tvLineDistance = scale * lineDistance;\n\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;\n\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n\n}\n",meshbasic_frag:"\nuniform vec3 diffuse;\nuniform float opacity;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n#endif\n\n#include <common>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\n\nvoid main() {\n\n\t#include <clipping_planes_fragment>\n\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\n\t// accumulation (baked indirect lighting only)\n\t#ifdef USE_LIGHTMAP\n\n\t\treflectedLight.indirectDiffuse += texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\n\t#else\n\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\n\t#endif\n\n\t// modulation\n\t#include <aomap_fragment>\n\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\n\t#include <envmap_fragment>\n\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\n\t#include <premultiplied_alpha_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\n}\n",meshbasic_vert:"\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n\nvoid main() {\n\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <skinbase_vertex>\n\n\t#ifdef USE_ENVMAP\n\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\n\t#endif\n\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n\n}\n",meshlambert_frag:"\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n\n\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <fog_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\n\nvoid main() {\n\n\t#include <clipping_planes_fragment>\n\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\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <emissivemap_fragment>\n\n\t// accumulation\n\treflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );\n\n\t#ifdef DOUBLE_SIDED\n\n\t\treflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;\n\n\t#else\n\n\t\treflectedLight.indirectDiffuse += vIndirectFront;\n\n\t#endif\n\n\t#include <lightmap_fragment>\n\n\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\n\t#ifdef DOUBLE_SIDED\n\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\n\t#else\n\n\t\treflectedLight.directDiffuse = vLightFront;\n\n\t#endif\n\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n\n\t// modulation\n\t#include <aomap_fragment>\n\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\n\t#include <envmap_fragment>\n\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}\n",meshlambert_vert:"\n#define LAMBERT\n\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n\nvoid main() {\n\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <lights_lambert_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}\n",meshmatcap_frag:"\n#define MATCAP\n\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\n\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n#endif\n\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n\n#include <fog_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\n\nvoid main() {\n\n\t#include <clipping_planes_fragment>\n\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; // 0.495 to remove artifacts caused by undersized matcap disks\n\n\t#ifdef USE_MATCAP\n\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t\tmatcapColor = matcapTexelToLinear( matcapColor );\n\n\t#else\n\n\t\tvec4 matcapColor = vec4( 1.0 );\n\n\t#endif\n\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\n\t#include <premultiplied_alpha_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\n}\n",meshmatcap_vert:"\n#define MATCAP\n\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n#endif\n\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n\nvoid main() {\n\n\t#include <uv_vertex>\n\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\n\t#ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED\n\n\t\tvNormal = normalize( transformedNormal );\n\n\t#endif\n\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n\n\tvViewPosition = - mvPosition.xyz;\n\n}\n",meshphong_frag:"\n#define PHONG\n\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\n\nvoid main() {\n\n\t#include <clipping_planes_fragment>\n\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\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\n\t// accumulation\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\n\t// modulation\n\t#include <aomap_fragment>\n\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\n\t#include <envmap_fragment>\n\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n\n}\n",meshphong_vert:"\n#define PHONG\n\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n#endif\n\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n\nvoid main() {\n\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\n#ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED\n\n\tvNormal = normalize( transformedNormal );\n\n#endif\n\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\n\tvViewPosition = - mvPosition.xyz;\n\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n\n}\n",meshphysical_frag:"\n#define PHYSICAL\n\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n\n#ifndef STANDARD\n\tuniform float clearCoat;\n\tuniform float clearCoatRoughness;\n#endif\n\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n#endif\n\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <bsdfs>\n#include <cube_uv_reflection_fragment>\n#include <envmap_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <lights_physical_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\n\nvoid main() {\n\n\t#include <clipping_planes_fragment>\n\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\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\n\t// accumulation\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\n\t// modulation\n\t#include <aomap_fragment>\n\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n\n}\n",meshphysical_vert:"\n#define PHYSICAL\n\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n#endif\n\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n\nvoid main() {\n\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\n#ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED\n\n\tvNormal = normalize( transformedNormal );\n\n#endif\n\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\n\tvViewPosition = - mvPosition.xyz;\n\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n\n}\n",normal_frag:"\n#define NORMAL\n\nuniform float opacity;\n\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || ( defined( USE_NORMALMAP ) && ! defined( OBJECTSPACE_NORMALMAP ) )\n\n\tvarying vec3 vViewPosition;\n\n#endif\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n#endif\n\n#include <packing>\n#include <uv_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n\nvoid main() {\n\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n\n}\n",normal_vert:"\n#define NORMAL\n\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || ( defined( USE_NORMALMAP ) && ! defined( OBJECTSPACE_NORMALMAP ) )\n\n\tvarying vec3 vViewPosition;\n\n#endif\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n#endif\n\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n\nvoid main() {\n\n\t#include <uv_vertex>\n\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\n#ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED\n\n\tvNormal = normalize( transformedNormal );\n\n#endif\n\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || ( defined( USE_NORMALMAP ) && ! defined( OBJECTSPACE_NORMALMAP ) )\n\n\tvViewPosition = - mvPosition.xyz;\n\n#endif\n\n}\n",points_frag:"\nuniform vec3 diffuse;\nuniform float opacity;\n\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\n\nvoid main() {\n\n\t#include <clipping_planes_fragment>\n\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\n\toutgoingLight = diffuseColor.rgb;\n\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\n\t#include <premultiplied_alpha_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\n}\n",points_vert:"\nuniform float size;\nuniform float scale;\n\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n\nvoid main() {\n\n\t#include <color_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\n\tgl_PointSize = size;\n\n\t#ifdef USE_SIZEATTENUATION\n\n\t\tbool isPerspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 );\n\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\n\t#endif\n\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <fog_vertex>\n\n}\n",shadow_frag:"\nuniform vec3 color;\nuniform float opacity;\n\n#include <common>\n#include <packing>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\n\nvoid main() {\n\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\n\t#include <fog_fragment>\n\n}\n",shadow_vert:"\n#include <fog_pars_vertex>\n#include <shadowmap_pars_vertex>\n\nvoid main() {\n\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n\n}\n",sprite_frag:"\nuniform vec3 diffuse;\nuniform float opacity;\n\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\n\nvoid main() {\n\n\t#include <clipping_planes_fragment>\n\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphatest_fragment>\n\n\toutgoingLight = diffuseColor.rgb;\n\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\n}\n",sprite_vert:"\nuniform float rotation;\nuniform vec2 center;\n\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n\nvoid main() {\n\n\t#include <uv_vertex>\n\n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\n\t#ifndef USE_SIZEATTENUATION\n\n\t\tbool isPerspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 );\n\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\n\t#endif\n\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\n\tmvPosition.xy += rotatedPosition;\n\n\tgl_Position = projectionMatrix * mvPosition;\n\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n\n}\n"},T=n("a9d74ad8a46048b4091b"),S=n("a1aefa272411e80f6961"),L={common:{diffuse:{value:new S.Color(15658734)},opacity:{value:1},map:{value:null},uvTransform:{value:new l.a},alphaMap:{value:null}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},refractionRatio:{value:.98},maxMipLevel:{value:0}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new s.a(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new S.Color(16777215)}},lights:{ambientLightColor:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{},shadow:{},shadowBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{},shadow:{},shadowBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{},shadow:{},shadowBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}}},points:{diffuse:{value:new S.Color(15658734)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},uvTransform:{value:new l.a}},sprite:{diffuse:{value:new S.Color(15658734)},opacity:{value:1},center:{value:new s.a(.5,.5)},rotation:{value:0},map:{value:null},uvTransform:{value:new l.a}}},y={basic:{uniforms:Object(T.b)([L.common,L.specularmap,L.envmap,L.aomap,L.lightmap,L.fog]),vertexShader:E.meshbasic_vert,fragmentShader:E.meshbasic_frag},lambert:{uniforms:Object(T.b)([L.common,L.specularmap,L.envmap,L.aomap,L.lightmap,L.emissivemap,L.fog,L.lights,{emissive:{value:new S.Color(0)}}]),vertexShader:E.meshlambert_vert,fragmentShader:E.meshlambert_frag},phong:{uniforms:Object(T.b)([L.common,L.specularmap,L.envmap,L.aomap,L.lightmap,L.emissivemap,L.bumpmap,L.normalmap,L.displacementmap,L.gradientmap,L.fog,L.lights,{emissive:{value:new S.Color(0)},specular:{value:new S.Color(1118481)},shininess:{value:30}}]),vertexShader:E.meshphong_vert,fragmentShader:E.meshphong_frag},standard:{uniforms:Object(T.b)([L.common,L.envmap,L.aomap,L.lightmap,L.emissivemap,L.bumpmap,L.normalmap,L.displacementmap,L.roughnessmap,L.metalnessmap,L.fog,L.lights,{emissive:{value:new S.Color(0)},roughness:{value:.5},metalness:{value:.5},envMapIntensity:{value:1}}]),vertexShader:E.meshphysical_vert,fragmentShader:E.meshphysical_frag},matcap:{uniforms:Object(T.b)([L.common,L.bumpmap,L.normalmap,L.displacementmap,L.fog,{matcap:{value:null}}]),vertexShader:E.meshmatcap_vert,fragmentShader:E.meshmatcap_frag},points:{uniforms:Object(T.b)([L.points,L.fog]),vertexShader:E.points_vert,fragmentShader:E.points_frag},dashed:{uniforms:Object(T.b)([L.common,L.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:E.linedashed_vert,fragmentShader:E.linedashed_frag},depth:{uniforms:Object(T.b)([L.common,L.displacementmap]),vertexShader:E.depth_vert,fragmentShader:E.depth_frag},normal:{uniforms:Object(T.b)([L.common,L.bumpmap,L.normalmap,L.displacementmap,{opacity:{value:1}}]),vertexShader:E.normal_vert,fragmentShader:E.normal_frag},sprite:{uniforms:Object(T.b)([L.sprite,L.fog]),vertexShader:E.sprite_vert,fragmentShader:E.sprite_frag},background:{uniforms:{uvTransform:{value:new l.a},t2D:{value:null}},vertexShader:E.background_vert,fragmentShader:E.background_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:E.cube_vert,fragmentShader:E.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:E.equirect_vert,fragmentShader:E.equirect_frag},distanceRGBA:{uniforms:Object(T.b)([L.common,L.displacementmap,{referencePosition:{value:new v.a},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:E.distanceRGBA_vert,fragmentShader:E.distanceRGBA_frag},shadow:{uniforms:Object(T.b)([L.lights,L.fog,{color:{value:new S.Color(0)},opacity:{value:1}}]),vertexShader:E.shadow_vert,fragmentShader:E.shadow_frag}};y.physical={uniforms:Object(T.b)([y.standard.uniforms,{clearCoat:{value:0},clearCoatRoughness:{value:0}}]),vertexShader:E.meshphysical_vert,fragmentShader:E.meshphysical_frag};var w=n("8c2c34e61acc0ecbc2d2");function A(){var e=null,t=!1,n=null;function i(r,a){!1!==t&&(n(r,a),e.requestAnimationFrame(i))}return{start:function(){!0!==t&&null!==n&&(e.requestAnimationFrame(i),t=!0)},stop:function(){t=!1},setAnimationLoop:function(e){n=e},setContext:function(t){e=t}}}function R(e){var t=new WeakMap;return{get:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),t.get(e)},remove:function(n){n.isInterleavedBufferAttribute&&(n=n.data);var i=t.get(n);i&&(e.deleteBuffer(i.buffer),t.delete(n))},update:function(n,i){n.isInterleavedBufferAttribute&&(n=n.data);var r=t.get(n);void 0===r?t.set(n,function(t,n){var i=t.array,r=t.dynamic?e.DYNAMIC_DRAW:e.STATIC_DRAW,a=e.createBuffer();e.bindBuffer(n,a),e.bufferData(n,i,r),t.onUploadCallback();var o=e.FLOAT;return i instanceof Float32Array?o=e.FLOAT:i instanceof Float64Array?console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array."):i instanceof Uint16Array?o=e.UNSIGNED_SHORT:i instanceof Int16Array?o=e.SHORT:i instanceof Uint32Array?o=e.UNSIGNED_INT:i instanceof Int32Array?o=e.INT:i instanceof Int8Array?o=e.BYTE:i instanceof Uint8Array&&(o=e.UNSIGNED_BYTE),{buffer:a,type:o,bytesPerElement:i.BYTES_PER_ELEMENT,version:t.version}}(n,i)):r.version<n.version&&(function(t,n,i){var r=n.array,a=n.updateRange;e.bindBuffer(i,t),!1===n.dynamic?e.bufferData(i,r,e.STATIC_DRAW):-1===a.count?e.bufferSubData(i,0,r):0===a.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(i,a.offset*r.BYTES_PER_ELEMENT,r.subarray(a.offset,a.offset+a.count)),a.count=-1)}(r.buffer,n,i),r.version=n.version)}}}function P(e,t,n,i,r,a){this.a=e,this.b=t,this.c=n,this.normal=i&&i.isVector3?i:new v.a,this.vertexNormals=Array.isArray(i)?i:[],this.color=r&&r.isColor?r:new S.Color,this.vertexColors=Array.isArray(r)?r:[],this.materialIndex=void 0!==a?a:0}Object.assign(P.prototype,{clone:function(){return(new this.constructor).copy(this)},copy:function(e){this.a=e.a,this.b=e.b,this.c=e.c,this.normal.copy(e.normal),this.color.copy(e.color),this.materialIndex=e.materialIndex;for(var t=0,n=e.vertexNormals.length;t<n;t++)this.vertexNormals[t]=e.vertexNormals[t].clone();for(t=0,n=e.vertexColors.length;t<n;t++)this.vertexColors[t]=e.vertexColors[t].clone();return this}});var C,D,I,N=n("e8e740b3fab0642e6a30"),U=n("3fcced0dfecbf072faf3"),F=0;function O(){Object.defineProperty(this,"id",{value:F+=2}),this.uuid=a.a.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}O.prototype=Object.assign(Object.create(o.a.prototype),{constructor:O,isGeometry:!0,applyMatrix:function(e){for(var t=(new l.a).getNormalMatrix(e),n=0,i=this.vertices.length;n<i;n++){this.vertices[n].applyMatrix4(e)}for(n=0,i=this.faces.length;n<i;n++){var r=this.faces[n];r.normal.applyMatrix3(t).normalize();for(var a=0,o=r.vertexNormals.length;a<o;a++)r.vertexNormals[a].applyMatrix3(t).normalize()}return null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this},rotateX:(I=new M.a,function(e){return I.makeRotationX(e),this.applyMatrix(I),this}),rotateY:function(){var e=new M.a;return function(t){return e.makeRotationY(t),this.applyMatrix(e),this}}(),rotateZ:function(){var e=new M.a;return function(t){return e.makeRotationZ(t),this.applyMatrix(e),this}}(),translate:function(){var e=new M.a;return function(t,n,i){return e.makeTranslation(t,n,i),this.applyMatrix(e),this}}(),scale:function(){var e=new M.a;return function(t,n,i){return e.makeScale(t,n,i),this.applyMatrix(e),this}}(),lookAt:(D=new U.a,function(e){D.lookAt(e),D.updateMatrix(),this.applyMatrix(D.matrix)}),fromBufferGeometry:function(e){var t=this,n=null!==e.index?e.index.array:void 0,i=e.attributes,r=i.position.array,a=void 0!==i.normal?i.normal.array:void 0,o=void 0!==i.color?i.color.array:void 0,l=void 0!==i.uv?i.uv.array:void 0,c=void 0!==i.uv2?i.uv2.array:void 0;void 0!==c&&(this.faceVertexUvs[1]=[]);for(var d=0,u=0;d<r.length;d+=3,u+=2)t.vertices.push((new v.a).fromArray(r,d)),void 0!==o&&t.colors.push((new S.Color).fromArray(o,d));function f(e,n,i,r){var d=void 0===o?[]:[t.colors[e].clone(),t.colors[n].clone(),t.colors[i].clone()],u=new P(e,n,i,void 0===a?[]:[(new v.a).fromArray(a,3*e),(new v.a).fromArray(a,3*n),(new v.a).fromArray(a,3*i)],d,r);t.faces.push(u),void 0!==l&&t.faceVertexUvs[0].push([(new s.a).fromArray(l,2*e),(new s.a).fromArray(l,2*n),(new s.a).fromArray(l,2*i)]),void 0!==c&&t.faceVertexUvs[1].push([(new s.a).fromArray(c,2*e),(new s.a).fromArray(c,2*n),(new s.a).fromArray(c,2*i)])}var p=e.groups;if(p.length>0)for(d=0;d<p.length;d++)for(var h=p[d],m=h.start,g=(u=m,m+h.count);u<g;u+=3)void 0!==n?f(n[u],n[u+1],n[u+2],h.materialIndex):f(u,u+1,u+2,h.materialIndex);else if(void 0!==n)for(d=0;d<n.length;d+=3)f(n[d],n[d+1],n[d+2]);else for(d=0;d<r.length/3;d+=3)f(d,d+1,d+2);return this.computeFaceNormals(),null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone()),null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),this},center:(C=new v.a,function(){return this.computeBoundingBox(),this.boundingBox.getCenter(C).negate(),this.translate(C.x,C.y,C.z),this}),normalize:function(){this.computeBoundingSphere();var e=this.boundingSphere.center,t=this.boundingSphere.radius,n=0===t?1:1/t,i=new M.a;return i.set(n,0,0,-n*e.x,0,n,0,-n*e.y,0,0,n,-n*e.z,0,0,0,1),this.applyMatrix(i),this},computeFaceNormals:function(){for(var e=new v.a,t=new v.a,n=0,i=this.faces.length;n<i;n++){var r=this.faces[n],a=this.vertices[r.a],o=this.vertices[r.b],s=this.vertices[r.c];e.subVectors(s,o),t.subVectors(a,o),e.cross(t),e.normalize(),r.normal.copy(e)}},computeVertexNormals:function(e){var t,n,i,r,a,o;for(void 0===e&&(e=!0),o=new Array(this.vertices.length),t=0,n=this.vertices.length;t<n;t++)o[t]=new v.a;if(e){var s,l,c,d=new v.a,u=new v.a;for(i=0,r=this.faces.length;i<r;i++)a=this.faces[i],s=this.vertices[a.a],l=this.vertices[a.b],c=this.vertices[a.c],d.subVectors(c,l),u.subVectors(s,l),d.cross(u),o[a.a].add(d),o[a.b].add(d),o[a.c].add(d)}else for(this.computeFaceNormals(),i=0,r=this.faces.length;i<r;i++)o[(a=this.faces[i]).a].add(a.normal),o[a.b].add(a.normal),o[a.c].add(a.normal);for(t=0,n=this.vertices.length;t<n;t++)o[t].normalize();for(i=0,r=this.faces.length;i<r;i++){var f=(a=this.faces[i]).vertexNormals;3===f.length?(f[0].copy(o[a.a]),f[1].copy(o[a.b]),f[2].copy(o[a.c])):(f[0]=o[a.a].clone(),f[1]=o[a.b].clone(),f[2]=o[a.c].clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)},computeFlatVertexNormals:function(){var e,t,n;for(this.computeFaceNormals(),e=0,t=this.faces.length;e<t;e++){var i=(n=this.faces[e]).vertexNormals;3===i.length?(i[0].copy(n.normal),i[1].copy(n.normal),i[2].copy(n.normal)):(i[0]=n.normal.clone(),i[1]=n.normal.clone(),i[2]=n.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){var e,t,n,i,r;for(n=0,i=this.faces.length;n<i;n++)for((r=this.faces[n]).__originalFaceNormal?r.__originalFaceNormal.copy(r.normal):r.__originalFaceNormal=r.normal.clone(),r.__originalVertexNormals||(r.__originalVertexNormals=[]),e=0,t=r.vertexNormals.length;e<t;e++)r.__originalVertexNormals[e]?r.__originalVertexNormals[e].copy(r.vertexNormals[e]):r.__originalVertexNormals[e]=r.vertexNormals[e].clone();var a=new O;for(a.faces=this.faces,e=0,t=this.morphTargets.length;e<t;e++){if(!this.morphNormals[e]){this.morphNormals[e]={},this.morphNormals[e].faceNormals=[],this.morphNormals[e].vertexNormals=[];var o=this.morphNormals[e].faceNormals,s=this.morphNormals[e].vertexNormals;for(n=0,i=this.faces.length;n<i;n++)l=new v.a,c={a:new v.a,b:new v.a,c:new v.a},o.push(l),s.push(c)}var l,c,d=this.morphNormals[e];for(a.vertices=this.morphTargets[e].vertices,a.computeFaceNormals(),a.computeVertexNormals(),n=0,i=this.faces.length;n<i;n++)r=this.faces[n],l=d.faceNormals[n],c=d.vertexNormals[n],l.copy(r.normal),c.a.copy(r.vertexNormals[0]),c.b.copy(r.vertexNormals[1]),c.c.copy(r.vertexNormals[2])}for(n=0,i=this.faces.length;n<i;n++)(r=this.faces[n]).normal=r.__originalFaceNormal,r.vertexNormals=r.__originalVertexNormals},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new N.a),this.boundingBox.setFromPoints(this.vertices)},computeBoundingSphere:function(){null===this.boundingSphere&&(this.boundingSphere=new _.a),this.boundingSphere.setFromPoints(this.vertices)},merge:function(e,t,n){if(e&&e.isGeometry){var i,r=this.vertices.length,a=this.vertices,o=e.vertices,s=this.faces,c=e.faces,d=this.faceVertexUvs[0],u=e.faceVertexUvs[0],f=this.colors,p=e.colors;void 0===n&&(n=0),void 0!==t&&(i=(new l.a).getNormalMatrix(t));for(var h=0,m=o.length;h<m;h++){var g=o[h].clone();void 0!==t&&g.applyMatrix4(t),a.push(g)}for(h=0,m=p.length;h<m;h++)f.push(p[h].clone());for(h=0,m=c.length;h<m;h++){var v,_,x,b=c[h],M=b.vertexNormals,E=b.vertexColors;(v=new P(b.a+r,b.b+r,b.c+r)).normal.copy(b.normal),void 0!==i&&v.normal.applyMatrix3(i).normalize();for(var T=0,S=M.length;T<S;T++)_=M[T].clone(),void 0!==i&&_.applyMatrix3(i).normalize(),v.vertexNormals.push(_);v.color.copy(b.color);for(T=0,S=E.length;T<S;T++)x=E[T],v.vertexColors.push(x.clone());v.materialIndex=b.materialIndex+n,s.push(v)}for(h=0,m=u.length;h<m;h++){var L=u[h],y=[];if(void 0!==L){for(T=0,S=L.length;T<S;T++)y.push(L[T].clone());d.push(y)}}}else console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",e)},mergeMesh:function(e){e&&e.isMesh?(e.matrixAutoUpdate&&e.updateMatrix(),this.merge(e.geometry,e.matrix)):console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",e)},mergeVertices:function(){var e,t,n,i,r,a,o,s,l={},c=[],d=[],u=Math.pow(10,4);for(n=0,i=this.vertices.length;n<i;n++)e=this.vertices[n],void 0===l[t=Math.round(e.x*u)+"_"+Math.round(e.y*u)+"_"+Math.round(e.z*u)]?(l[t]=n,c.push(this.vertices[n]),d[n]=c.length-1):d[n]=d[l[t]];var f=[];for(n=0,i=this.faces.length;n<i;n++){(r=this.faces[n]).a=d[r.a],r.b=d[r.b],r.c=d[r.c],a=[r.a,r.b,r.c];for(var p=0;p<3;p++)if(a[p]===a[(p+1)%3]){f.push(n);break}}for(n=f.length-1;n>=0;n--){var h=f[n];for(this.faces.splice(h,1),o=0,s=this.faceVertexUvs.length;o<s;o++)this.faceVertexUvs[o].splice(h,1)}var m=this.vertices.length-c.length;return this.vertices=c,m},setFromPoints:function(e){this.vertices=[];for(var t=0,n=e.length;t<n;t++){var i=e[t];this.vertices.push(new v.a(i.x,i.y,i.z||0))}return this},sortFacesByMaterialIndex:function(){for(var e=this.faces,t=e.length,n=0;n<t;n++)e[n]._id=n;e.sort(function(e,t){return e.materialIndex-t.materialIndex});var i,r,a=this.faceVertexUvs[0],o=this.faceVertexUvs[1];a&&a.length===t&&(i=[]),o&&o.length===t&&(r=[]);for(n=0;n<t;n++){var s=e[n]._id;i&&i.push(a[s]),r&&r.push(o[s])}i&&(this.faceVertexUvs[0]=i),r&&(this.faceVertexUvs[1]=r)},toJSON:function(){var e={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,""!==this.name&&(e.name=this.name),void 0!==this.parameters){var t=this.parameters;for(var n in t)void 0!==t[n]&&(e[n]=t[n]);return e}for(var i=[],r=0;r<this.vertices.length;r++){var a=this.vertices[r];i.push(a.x,a.y,a.z)}var o=[],s=[],l={},c=[],d={},u=[],f={};for(r=0;r<this.faces.length;r++){var p=this.faces[r],h=void 0!==this.faceVertexUvs[0][r],m=p.normal.length()>0,g=p.vertexNormals.length>0,v=1!==p.color.r||1!==p.color.g||1!==p.color.b,_=p.vertexColors.length>0,x=0;if(x=T(x,0,0),x=T(x,1,!0),x=T(x,2,!1),x=T(x,3,h),x=T(x,4,m),x=T(x,5,g),x=T(x,6,v),x=T(x,7,_),o.push(x),o.push(p.a,p.b,p.c),o.push(p.materialIndex),h){var b=this.faceVertexUvs[0][r];o.push(y(b[0]),y(b[1]),y(b[2]))}if(m&&o.push(S(p.normal)),g){var M=p.vertexNormals;o.push(S(M[0]),S(M[1]),S(M[2]))}if(v&&o.push(L(p.color)),_){var E=p.vertexColors;o.push(L(E[0]),L(E[1]),L(E[2]))}}function T(e,t,n){return n?e|1<<t:e&~(1<<t)}function S(e){var t=e.x.toString()+e.y.toString()+e.z.toString();return void 0!==l[t]?l[t]:(l[t]=s.length/3,s.push(e.x,e.y,e.z),l[t])}function L(e){var t=e.r.toString()+e.g.toString()+e.b.toString();return void 0!==d[t]?d[t]:(d[t]=c.length,c.push(e.getHex()),d[t])}function y(e){var t=e.x.toString()+e.y.toString();return void 0!==f[t]?f[t]:(f[t]=u.length/2,u.push(e.x,e.y),f[t])}return e.data={},e.data.vertices=i,e.data.normals=s,c.length>0&&(e.data.colors=c),u.length>0&&(e.data.uvs=[u]),e.data.faces=o,e},clone:function(){return(new O).copy(this)},copy:function(e){var t,n,i,r,a,o;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,n=s.length;t<n;t++)this.vertices.push(s[t].clone());var l=e.colors;for(t=0,n=l.length;t<n;t++)this.colors.push(l[t].clone());var c=e.faces;for(t=0,n=c.length;t<n;t++)this.faces.push(c[t].clone());for(t=0,n=e.faceVertexUvs.length;t<n;t++){var d=e.faceVertexUvs[t];for(void 0===this.faceVertexUvs[t]&&(this.faceVertexUvs[t]=[]),i=0,r=d.length;i<r;i++){var u=d[i],f=[];for(a=0,o=u.length;a<o;a++){var p=u[a];f.push(p.clone())}this.faceVertexUvs[t].push(f)}}var h=e.morphTargets;for(t=0,n=h.length;t<n;t++){var m={};if(m.name=h[t].name,void 0!==h[t].vertices)for(m.vertices=[],i=0,r=h[t].vertices.length;i<r;i++)m.vertices.push(h[t].vertices[i].clone());if(void 0!==h[t].normals)for(m.normals=[],i=0,r=h[t].normals.length;i<r;i++)m.normals.push(h[t].normals[i].clone());this.morphTargets.push(m)}var g=e.morphNormals;for(t=0,n=g.length;t<n;t++){var v={};if(void 0!==g[t].vertexNormals)for(v.vertexNormals=[],i=0,r=g[t].vertexNormals.length;i<r;i++){var _=g[t].vertexNormals[i],x={};x.a=_.a.clone(),x.b=_.b.clone(),x.c=_.c.clone(),v.vertexNormals.push(x)}if(void 0!==g[t].faceNormals)for(v.faceNormals=[],i=0,r=g[t].faceNormals.length;i<r;i++)v.faceNormals.push(g[t].faceNormals[i].clone());this.morphNormals.push(v)}var b=e.skinWeights;for(t=0,n=b.length;t<n;t++)this.skinWeights.push(b[t].clone());var M=e.skinIndices;for(t=0,n=M.length;t<n;t++)this.skinIndices.push(M[t].clone());var E=e.lineDistances;for(t=0,n=E.length;t<n;t++)this.lineDistances.push(E[t]);var T=e.boundingBox;null!==T&&(this.boundingBox=T.clone());var S=e.boundingSphere;return null!==S&&(this.boundingSphere=S.clone()),this.elementsNeedUpdate=e.elementsNeedUpdate,this.verticesNeedUpdate=e.verticesNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.lineDistancesNeedUpdate=e.lineDistancesNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,this},dispose:function(){this.dispatchEvent({type:"dispose"})}});var G=n("4f02046caaa3f6d5dbf3"),B=n("9d3ccbbdd0ff23bbfd32");function H(e,t,n,i,r,a){O.call(this),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:r,depthSegments:a},this.fromBufferGeometry(new V(e,t,n,i,r,a)),this.mergeVertices()}function V(e,t,n,i,r,a){G.BufferGeometry.call(this),this.type="BoxBufferGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:r,depthSegments:a};var o=this;e=e||1,t=t||1,n=n||1,i=Math.floor(i)||1,r=Math.floor(r)||1,a=Math.floor(a)||1;var s=[],l=[],c=[],d=[],u=0,f=0;function p(e,t,n,i,r,a,p,h,m,g,_){var x,b,M=a/m,E=p/g,T=a/2,S=p/2,L=h/2,y=m+1,w=g+1,A=0,R=0,P=new v.a;for(b=0;b<w;b++){var C=b*E-S;for(x=0;x<y;x++){var D=x*M-T;P[e]=D*i,P[t]=C*r,P[n]=L,l.push(P.x,P.y,P.z),P[e]=0,P[t]=0,P[n]=h>0?1:-1,c.push(P.x,P.y,P.z),d.push(x/m),d.push(1-b/g),A+=1}}for(b=0;b<g;b++)for(x=0;x<m;x++){var I=u+x+y*b,N=u+x+y*(b+1),U=u+(x+1)+y*(b+1),F=u+(x+1)+y*b;s.push(I,N,F),s.push(N,U,F),R+=6}o.addGroup(f,R,_),f+=R,u+=A}p("z","y","x",-1,-1,n,t,e,a,r,0),p("z","y","x",1,-1,n,t,-e,a,r,1),p("x","z","y",1,1,e,n,t,i,a,2),p("x","z","y",1,-1,e,n,-t,i,a,3),p("x","y","z",1,-1,e,t,n,i,r,4),p("x","y","z",-1,-1,e,t,-n,i,r,5),this.setIndex(s),this.addAttribute("position",new B.Float32BufferAttribute(l,3)),this.addAttribute("normal",new B.Float32BufferAttribute(c,3)),this.addAttribute("uv",new B.Float32BufferAttribute(d,2))}function z(e,t,n,i){O.call(this),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i},this.fromBufferGeometry(new W(e,t,n,i)),this.mergeVertices()}function W(e,t,n,i){G.BufferGeometry.call(this),this.type="PlaneBufferGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};var r,a,o=(e=e||1)/2,s=(t=t||1)/2,l=Math.floor(n)||1,c=Math.floor(i)||1,d=l+1,u=c+1,f=e/l,p=t/c,h=[],m=[],g=[],v=[];for(a=0;a<u;a++){var _=a*p-s;for(r=0;r<d;r++){var x=r*f-o;m.push(x,-_,0),g.push(0,0,1),v.push(r/l),v.push(1-a/c)}}for(a=0;a<c;a++)for(r=0;r<l;r++){var b=r+d*a,M=r+d*(a+1),E=r+1+d*(a+1),T=r+1+d*a;h.push(b,M,T),h.push(M,E,T)}this.setIndex(h),this.addAttribute("position",new B.Float32BufferAttribute(m,3)),this.addAttribute("normal",new B.Float32BufferAttribute(g,3)),this.addAttribute("uv",new B.Float32BufferAttribute(v,2))}H.prototype=Object.create(O.prototype),H.prototype.constructor=H,V.prototype=Object.create(G.BufferGeometry.prototype),V.prototype.constructor=V,z.prototype=Object.create(O.prototype),z.prototype.constructor=z,W.prototype=Object.create(G.BufferGeometry.prototype),W.prototype.constructor=W;var k,X,j,Y,q,Z,J,K,Q=n("b4419cc2aab9d79ef113"),$=n("9493e9352520294a389f");function ee(e,t,n){this.a=void 0!==e?e:new v.a,this.b=void 0!==t?t:new v.a,this.c=void 0!==n?n:new v.a}Object.assign(ee,{getNormal:(X=new v.a,function(e,t,n,i){void 0===i&&(console.warn("THREE.Triangle: .getNormal() target is now required"),i=new v.a),i.subVectors(n,t),X.subVectors(e,t),i.cross(X);var r=i.lengthSq();return r>0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}),getBarycoord:function(){var e=new v.a,t=new v.a,n=new v.a;return function(i,r,a,o,s){e.subVectors(o,r),t.subVectors(a,r),n.subVectors(i,r);var l=e.dot(e),c=e.dot(t),d=e.dot(n),u=t.dot(t),f=t.dot(n),p=l*u-c*c;if(void 0===s&&(console.warn("THREE.Triangle: .getBarycoord() target is now required"),s=new v.a),0===p)return s.set(-2,-1,-1);var h=1/p,m=(u*d-c*f)*h,g=(l*f-c*d)*h;return s.set(1-m-g,g,m)}}(),containsPoint:function(){var e=new v.a;return function(t,n,i,r){return ee.getBarycoord(t,n,i,r,e),e.x>=0&&e.y>=0&&e.x+e.y<=1}}(),getUV:(k=new v.a,function(e,t,n,i,r,a,o,s){return this.getBarycoord(e,t,n,i,k),s.set(0,0),s.addScaledVector(r,k.x),s.addScaledVector(a,k.y),s.addScaledVector(o,k.z),s})}),Object.assign(ee.prototype,{set:function(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this},setFromPointsAndIndices:function(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),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 v.a,t=new v.a;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 v.a),e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},getNormal:function(e){return ee.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 v.a),e.setFromCoplanarPoints(this.a,this.b,this.c)},getBarycoord:function(e,t){return ee.getBarycoord(e,this.a,this.b,this.c,t)},containsPoint:function(e){return ee.containsPoint(e,this.a,this.b,this.c)},getUV:function(e,t,n,i,r){return ee.getUV(e,this.a,this.b,this.c,t,n,i,r)},intersectsBox:function(e){return e.intersectsTriangle(this)},closestPointToPoint:(j=new v.a,Y=new v.a,q=new v.a,Z=new v.a,J=new v.a,K=new v.a,function(e,t){void 0===t&&(console.warn("THREE.Triangle: .closestPointToPoint() target is now required"),t=new v.a);var n,i,r=this.a,a=this.b,o=this.c;j.subVectors(a,r),Y.subVectors(o,r),Z.subVectors(e,r);var s=j.dot(Z),l=Y.dot(Z);if(s<=0&&l<=0)return t.copy(r);J.subVectors(e,a);var c=j.dot(J),d=Y.dot(J);if(c>=0&&d<=c)return t.copy(a);var u=s*d-c*l;if(u<=0&&s>=0&&c<=0)return n=s/(s-c),t.copy(r).addScaledVector(j,n);K.subVectors(e,o);var f=j.dot(K),p=Y.dot(K);if(p>=0&&f<=p)return t.copy(o);var h=f*l-s*p;if(h<=0&&l>=0&&p<=0)return i=l/(l-p),t.copy(r).addScaledVector(Y,i);var m=c*p-f*d;if(m<=0&&d-c>=0&&f-p>=0)return q.subVectors(o,a),i=(d-c)/(d-c+(f-p)),t.copy(a).addScaledVector(q,i);var g=1/(m+h+u);return n=h*g,i=u*g,t.copy(r).addScaledVector(j,n).addScaledVector(Y,i)}),equals:function(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}});var te=n("39c741a38b7f6fbfdd92");function ne(e){te.a.call(this),this.type="MeshBasicMaterial",this.color=new S.Color(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=r.X,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.lights=!1,this.setValues(e)}function ie(e,t){U.a.call(this),this.type="Mesh",this.geometry=void 0!==e?e:new G.BufferGeometry,this.material=void 0!==t?t:new ne({color:16777215*Math.random()}),this.drawMode=r.hc,this.updateMorphTargets()}function re(e,t,n,i){var a,o,s=new S.Color(0),l=0,c=null,d=0;function u(e,n){t.buffers.color.setClear(e.r,e.g,e.b,n,i)}return{getClearColor:function(){return s},setClearColor:function(e,t){s.set(e),u(s,l=void 0!==t?t:1)},getClearAlpha:function(){return l},setClearAlpha:function(e){u(s,l=e)},render:function(t,i,f,p){var h=i.background;if(null===h?(u(s,l),c=null,d=0):h&&h.isColor&&(u(h,1),p=!0,c=null,d=0),(e.autoClear||p)&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),h&&(h.isCubeTexture||h.isWebGLRenderTargetCube)){void 0===o&&((o=new ie(new V(1,1,1),new Q.ShaderMaterial({type:"BackgroundCubeMaterial",uniforms:Object(T.a)(y.cube.uniforms),vertexShader:y.cube.vertexShader,fragmentShader:y.cube.fragmentShader,side:r.g,depthTest:!1,depthWrite:!1,fog:!1}))).geometry.removeAttribute("normal"),o.geometry.removeAttribute("uv"),o.onBeforeRender=function(e,t,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(o.material,"map",{get:function(){return this.uniforms.tCube.value}}),n.update(o));var m=h.isWebGLRenderTargetCube?h.texture:h;o.material.uniforms.tCube.value=m,o.material.uniforms.tFlip.value=h.isWebGLRenderTargetCube?1:-1,c===h&&d===m.version||(o.material.needsUpdate=!0,c=h,d=m.version),t.unshift(o,o.geometry,o.material,0,0,null)}else h&&h.isTexture&&(void 0===a&&((a=new ie(new W(2,2),new Q.ShaderMaterial({type:"BackgroundMaterial",uniforms:Object(T.a)(y.background.uniforms),vertexShader:y.background.vertexShader,fragmentShader:y.background.fragmentShader,side:r.D,depthTest:!1,depthWrite:!1,fog:!1}))).geometry.removeAttribute("normal"),Object.defineProperty(a.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(a)),a.material.uniforms.t2D.value=h,!0===h.matrixAutoUpdate&&h.updateMatrix(),a.material.uniforms.uvTransform.value.copy(h.matrix),c===h&&d===h.version||(a.material.needsUpdate=!0,c=h,d=h.version),t.unshift(a,a.geometry,a.material,0,0,null))}}}function ae(e,t,n,i){var r;this.setMode=function(e){r=e},this.render=function(t,i){e.drawArrays(r,t,i),n.update(i,r)},this.renderInstances=function(a,o,s){var l;if(i.isWebGL2)l=e;else if(null===(l=t.get("ANGLE_instanced_arrays")))return void console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");l[i.isWebGL2?"drawArraysInstanced":"drawArraysInstancedANGLE"](r,o,s,a.maxInstancedCount),n.update(s,r,a.maxInstancedCount)}}function oe(e,t,n){var i;function r(t){if("highp"===t){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT).precision>0&&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 a="undefined"!==typeof WebGL2RenderingContext&&e instanceof WebGL2RenderingContext,o=void 0!==n.precision?n.precision:"highp",s=r(o);s!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",s,"instead."),o=s);var l=!0===n.logarithmicDepthBuffer,c=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),d=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),u=e.getParameter(e.MAX_TEXTURE_SIZE),f=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),p=e.getParameter(e.MAX_VERTEX_ATTRIBS),h=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),m=e.getParameter(e.MAX_VARYING_VECTORS),g=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),v=d>0,_=a||!!t.get("OES_texture_float");return{isWebGL2:a,getMaxAnisotropy:function(){if(void 0!==i)return i;var n=t.get("EXT_texture_filter_anisotropic");return i=null!==n?e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0},getMaxPrecision:r,precision:o,logarithmicDepthBuffer:l,maxTextures:c,maxVertexTextures:d,maxTextureSize:u,maxCubemapSize:f,maxAttributes:p,maxVertexUniforms:h,maxVaryings:m,maxFragmentUniforms:g,vertexTextures:v,floatFragmentTextures:_,floatVertexTextures:v&&_,maxSamples:a?e.getParameter(e.MAX_SAMPLES):0}}function se(){var e=this,t=null,n=0,i=!1,r=!1,a=new x,o=new l.a,s={value:null,needsUpdate:!1};function c(){s.value!==t&&(s.value=t,s.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function d(t,n,i,r){var l=null!==t?t.length:0,c=null;if(0!==l){if(c=s.value,!0!==r||null===c){var d=i+4*l,u=n.matrixWorldInverse;o.getNormalMatrix(u),(null===c||c.length<d)&&(c=new Float32Array(d));for(var f=0,p=i;f!==l;++f,p+=4)a.copy(t[f]).applyMatrix4(u,o),a.normal.toArray(c,p),c[p+3]=a.constant}s.value=c,s.needsUpdate=!0}return e.numPlanes=l,c}this.uniform=s,this.numPlanes=0,this.numIntersection=0,this.init=function(e,r,a){var o=0!==e.length||r||0!==n||i;return i=r,t=d(e,a,0),n=e.length,o},this.beginShadows=function(){r=!0,d(null)},this.endShadows=function(){r=!1,c()},this.setState=function(e,a,o,l,u,f){if(!i||null===e||0===e.length||r&&!o)r?d(null):c();else{var p=r?0:n,h=4*p,m=u.clippingState||null;s.value=m,m=d(e,l,h,f);for(var g=0;g!==h;++g)m[g]=t[g];u.clippingState=m,this.numIntersection=a?this.numPlanes:0,this.numPlanes+=p}}}function le(e){var t={};return{get:function(n){if(void 0!==t[n])return t[n];var i;switch(n){case"WEBGL_depth_texture":i=e.getExtension("WEBGL_depth_texture")||e.getExtension("MOZ_WEBGL_depth_texture")||e.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":i=e.getExtension("WEBGL_compressed_texture_s3tc")||e.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":i=e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=e.getExtension(n)}return null===i&&console.warn("THREE.WebGLRenderer: "+n+" extension not supported."),t[n]=i,i}}}ne.prototype=Object.create(te.a.prototype),ne.prototype.constructor=ne,ne.prototype.isMeshBasicMaterial=!0,ne.prototype.copy=function(e){return te.a.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},ie.prototype=Object.assign(Object.create(U.a.prototype),{constructor:ie,isMesh:!0,setDrawMode:function(e){this.drawMode=e},copy:function(e){return U.a.prototype.copy.call(this,e),this.drawMode=e.drawMode,void 0!==e.morphTargetInfluences&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),void 0!==e.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this},updateMorphTargets:function(){var e,t,n,i=this.geometry;if(i.isBufferGeometry){var r=i.morphAttributes,a=Object.keys(r);if(a.length>0){var o=r[a[0]];if(void 0!==o)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},e=0,t=o.length;e<t;e++)n=o[e].name||String(e),this.morphTargetInfluences.push(0),this.morphTargetDictionary[n]=e}}else{var s=i.morphTargets;void 0!==s&&s.length>0&&console.error("THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}},raycast:function(){var e=new M.a,t=new $.a,n=new _.a,i=new v.a,a=new v.a,o=new v.a,l=new v.a,c=new v.a,d=new v.a,u=new s.a,f=new s.a,p=new s.a,h=new v.a,m=new v.a;function g(e,t,n,i,a,o,s,l){if(null===(t.side===r.g?i.intersectTriangle(s,o,a,!0,l):i.intersectTriangle(a,o,s,t.side!==r.v,l)))return null;m.copy(l),m.applyMatrix4(e.matrixWorld);var c=n.ray.origin.distanceTo(m);return c<n.near||c>n.far?null:{distance:c,point:m.clone(),object:e}}function x(e,t,n,r,l,c,d,m,v){i.fromBufferAttribute(l,d),a.fromBufferAttribute(l,m),o.fromBufferAttribute(l,v);var _=g(e,t,n,r,i,a,o,h);if(_){c&&(u.fromBufferAttribute(c,d),f.fromBufferAttribute(c,m),p.fromBufferAttribute(c,v),_.uv=ee.getUV(h,i,a,o,u,f,p,new s.a));var x=new P(d,m,v);ee.getNormal(i,a,o,x.normal),_.face=x}return _}return function(r,m){var v,_=this.geometry,b=this.material,M=this.matrixWorld;if(void 0!==b&&(null===_.boundingSphere&&_.computeBoundingSphere(),n.copy(_.boundingSphere),n.applyMatrix4(M),!1!==r.ray.intersectsSphere(n)&&(e.getInverse(M),t.copy(r.ray).applyMatrix4(e),null===_.boundingBox||!1!==t.intersectsBox(_.boundingBox))))if(_.isBufferGeometry){var E,T,S,L,y,w,A,R,P,C=_.index,D=_.attributes.position,I=_.attributes.uv,N=_.groups,U=_.drawRange;if(null!==C)if(Array.isArray(b))for(L=0,w=N.length;L<w;L++)for(P=b[(R=N[L]).materialIndex],y=Math.max(R.start,U.start),A=Math.min(R.start+R.count,U.start+U.count);y<A;y+=3)E=C.getX(y),T=C.getX(y+1),S=C.getX(y+2),(v=x(this,P,r,t,D,I,E,T,S))&&(v.faceIndex=Math.floor(y/3),v.face.materialIndex=R.materialIndex,m.push(v));else for(L=Math.max(0,U.start),w=Math.min(C.count,U.start+U.count);L<w;L+=3)E=C.getX(L),T=C.getX(L+1),S=C.getX(L+2),(v=x(this,b,r,t,D,I,E,T,S))&&(v.faceIndex=Math.floor(L/3),m.push(v));else if(void 0!==D)if(Array.isArray(b))for(L=0,w=N.length;L<w;L++)for(P=b[(R=N[L]).materialIndex],y=Math.max(R.start,U.start),A=Math.min(R.start+R.count,U.start+U.count);y<A;y+=3)(v=x(this,P,r,t,D,I,E=y,T=y+1,S=y+2))&&(v.faceIndex=Math.floor(y/3),v.face.materialIndex=R.materialIndex,m.push(v));else for(L=Math.max(0,U.start),w=Math.min(D.count,U.start+U.count);L<w;L+=3)(v=x(this,b,r,t,D,I,E=L,T=L+1,S=L+2))&&(v.faceIndex=Math.floor(L/3),m.push(v))}else if(_.isGeometry){var F,O,G,B,H=Array.isArray(b),V=_.vertices,z=_.faces,W=_.faceVertexUvs[0];W.length>0&&(B=W);for(var k=0,X=z.length;k<X;k++){var j=z[k],Y=H?b[j.materialIndex]:b;if(void 0!==Y){if(F=V[j.a],O=V[j.b],G=V[j.c],!0===Y.morphTargets){var q=_.morphTargets,Z=this.morphTargetInfluences;i.set(0,0,0),a.set(0,0,0),o.set(0,0,0);for(var J=0,K=q.length;J<K;J++){var Q=Z[J];if(0!==Q){var $=q[J].vertices;i.addScaledVector(l.subVectors($[j.a],F),Q),a.addScaledVector(c.subVectors($[j.b],O),Q),o.addScaledVector(d.subVectors($[j.c],G),Q)}}i.add(F),a.add(O),o.add(G),F=i,O=a,G=o}if(v=g(this,Y,r,t,F,O,G,h)){if(B&&B[k]){var te=B[k];u.copy(te[0]),f.copy(te[1]),p.copy(te[2]),v.uv=ee.getUV(h,F,O,G,u,f,p,new s.a)}v.face=j,v.faceIndex=k,m.push(v)}}}}}}(),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}});var ce=n("431d73f7466491f671ed");function de(e,t,n){var i={},r={};function a(e){var o=e.target,s=i[o.id];for(var l in null!==s.index&&t.remove(s.index),s.attributes)t.remove(s.attributes[l]);o.removeEventListener("dispose",a),delete i[o.id];var c=r[s.id];c&&(t.remove(c),delete r[s.id]),n.memory.geometries--}return{get:function(e,t){var r=i[t.id];return r||(t.addEventListener("dispose",a),t.isBufferGeometry?r=t:t.isGeometry&&(void 0===t._bufferGeometry&&(t._bufferGeometry=(new G.BufferGeometry).setFromObject(e)),r=t._bufferGeometry),i[t.id]=r,n.memory.geometries++,r)},update:function(n){var i=n.index,r=n.attributes;for(var a in null!==i&&t.update(i,e.ELEMENT_ARRAY_BUFFER),r)t.update(r[a],e.ARRAY_BUFFER);var o=n.morphAttributes;for(var a in o)for(var s=o[a],l=0,c=s.length;l<c;l++)t.update(s[l],e.ARRAY_BUFFER)},getWireframeAttribute:function(n){var i=r[n.id];if(i)return i;var a,o=[],s=n.index,l=n.attributes;if(null!==s)for(var c=0,d=(a=s.array).length;c<d;c+=3){var u=a[c+0],f=a[c+1],p=a[c+2];o.push(u,f,f,p,p,u)}else for(c=0,d=(a=l.position.array).length/3-1;c<d;c+=3)u=c+0,f=c+1,p=c+2,o.push(u,f,f,p,p,u);return i=new(Object(ce.a)(o)>65535?B.Uint32BufferAttribute:B.Uint16BufferAttribute)(o,1),t.update(i,e.ELEMENT_ARRAY_BUFFER),r[n.id]=i,i}}}function ue(e,t,n,i){var r,a,o;this.setMode=function(e){r=e},this.setIndex=function(e){a=e.type,o=e.bytesPerElement},this.render=function(t,i){e.drawElements(r,i,a,t*o),n.update(i,r)},this.renderInstances=function(s,l,c){var d;if(i.isWebGL2)d=e;else if(null===(d=t.get("ANGLE_instanced_arrays")))return void console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");d[i.isWebGL2?"drawElementsInstanced":"drawElementsInstancedANGLE"](r,c,a,l*o,s.maxInstancedCount),n.update(c,r,s.maxInstancedCount)}}function fe(e){var t={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:t,programs:null,autoReset:!0,reset:function(){t.frame++,t.calls=0,t.triangles=0,t.points=0,t.lines=0},update:function(n,i,r){switch(r=r||1,t.calls++,i){case e.TRIANGLES:t.triangles+=r*(n/3);break;case e.TRIANGLE_STRIP:case e.TRIANGLE_FAN:t.triangles+=r*(n-2);break;case e.LINES:t.lines+=r*(n/2);break;case e.LINE_STRIP:t.lines+=r*(n-1);break;case e.LINE_LOOP:t.lines+=r*n;break;case e.POINTS:t.points+=r*n;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",i)}}}}function pe(e,t){return Math.abs(t[1])-Math.abs(e[1])}function he(e){var t={},n=new Float32Array(8);return{update:function(i,r,a,o){var s=i.morphTargetInfluences,l=s.length,c=t[r.id];if(void 0===c){c=[];for(var d=0;d<l;d++)c[d]=[d,0];t[r.id]=c}var u=a.morphTargets&&r.morphAttributes.position,f=a.morphNormals&&r.morphAttributes.normal;for(d=0;d<l;d++)0!==(p=c[d])[1]&&(u&&r.removeAttribute("morphTarget"+d),f&&r.removeAttribute("morphNormal"+d));for(d=0;d<l;d++)(p=c[d])[0]=d,p[1]=s[d];for(c.sort(pe),d=0;d<8;d++){var p;if(p=c[d]){var h=p[0],m=p[1];if(m){u&&r.addAttribute("morphTarget"+d,u[h]),f&&r.addAttribute("morphNormal"+d,f[h]),n[d]=m;continue}}n[d]=0}o.getUniforms().setValue(e,"morphTargetInfluences",n)}}}function me(e,t){var n={};return{update:function(i){var r=t.render.frame,a=i.geometry,o=e.get(i,a);return n[o.id]!==r&&(a.isGeometry&&o.updateFromObject(i),e.update(o),n[o.id]=r),o},dispose:function(){n={}}}}function ge(e,t,n,i,a,o,s,l,c,d){e=void 0!==e?e:[],t=void 0!==t?t:r.l,u.call(this,e,t,n,i,a,o,s,l,c,d),this.flipY=!1}function ve(e,t,n,i){u.call(this,null),this.image={data:e,width:t,height:n,depth:i},this.magFilter=r.Y,this.minFilter=r.Y,this.generateMipmaps=!1,this.flipY=!1}ge.prototype=Object.create(u.prototype),ge.prototype.constructor=ge,ge.prototype.isCubeTexture=!0,Object.defineProperty(ge.prototype,"images",{get:function(){return this.image},set:function(e){this.image=e}}),ve.prototype=Object.create(u.prototype),ve.prototype.constructor=ve,ve.prototype.isDataTexture3D=!0;var _e=new u,xe=new ve,be=new ge;function Me(){this.seq=[],this.map={}}var Ee=[],Te=[],Se=new Float32Array(16),Le=new Float32Array(9),ye=new Float32Array(4);function we(e,t,n){var i=e[0];if(i<=0||i>0)return e;var r=t*n,a=Ee[r];if(void 0===a&&(a=new Float32Array(r),Ee[r]=a),0!==t){i.toArray(a,0);for(var o=1,s=0;o!==t;++o)s+=n,e[o].toArray(a,s)}return a}function Ae(e,t){if(e.length!==t.length)return!1;for(var n=0,i=e.length;n<i;n++)if(e[n]!==t[n])return!1;return!0}function Re(e,t){for(var n=0,i=t.length;n<i;n++)e[n]=t[n]}function Pe(e,t){var n=Te[t];void 0===n&&(n=new Int32Array(t),Te[t]=n);for(var i=0;i!==t;++i)n[i]=e.allocTextureUnit();return n}function Ce(e,t){var n=this.cache;n[0]!==t&&(e.uniform1f(this.addr,t),n[0]=t)}function De(e,t){var n=this.cache;n[0]!==t&&(e.uniform1i(this.addr,t),n[0]=t)}function Ie(e,t){var n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y||(e.uniform2f(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(Ae(n,t))return;e.uniform2fv(this.addr,t),Re(n,t)}}function Ne(e,t){var n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z||(e.uniform3f(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else if(void 0!==t.r)n[0]===t.r&&n[1]===t.g&&n[2]===t.b||(e.uniform3f(this.addr,t.r,t.g,t.b),n[0]=t.r,n[1]=t.g,n[2]=t.b);else{if(Ae(n,t))return;e.uniform3fv(this.addr,t),Re(n,t)}}function Ue(e,t){var n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z&&n[3]===t.w||(e.uniform4f(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(Ae(n,t))return;e.uniform4fv(this.addr,t),Re(n,t)}}function Fe(e,t){var n=this.cache,i=t.elements;if(void 0===i){if(Ae(n,t))return;e.uniformMatrix2fv(this.addr,!1,t),Re(n,t)}else{if(Ae(n,i))return;ye.set(i),e.uniformMatrix2fv(this.addr,!1,ye),Re(n,i)}}function Oe(e,t){var n=this.cache,i=t.elements;if(void 0===i){if(Ae(n,t))return;e.uniformMatrix3fv(this.addr,!1,t),Re(n,t)}else{if(Ae(n,i))return;Le.set(i),e.uniformMatrix3fv(this.addr,!1,Le),Re(n,i)}}function Ge(e,t){var n=this.cache,i=t.elements;if(void 0===i){if(Ae(n,t))return;e.uniformMatrix4fv(this.addr,!1,t),Re(n,t)}else{if(Ae(n,i))return;Se.set(i),e.uniformMatrix4fv(this.addr,!1,Se),Re(n,i)}}function Be(e,t,n){var i=this.cache,r=n.allocTextureUnit();i[0]!==r&&(e.uniform1i(this.addr,r),i[0]=r),n.setTexture2D(t||_e,r)}function He(e,t,n){var i=this.cache,r=n.allocTextureUnit();i[0]!==r&&(e.uniform1i(this.addr,r),i[0]=r),n.setTexture3D(t||xe,r)}function Ve(e,t,n){var i=this.cache,r=n.allocTextureUnit();i[0]!==r&&(e.uniform1i(this.addr,r),i[0]=r),n.setTextureCube(t||be,r)}function ze(e,t){var n=this.cache;Ae(n,t)||(e.uniform2iv(this.addr,t),Re(n,t))}function We(e,t){var n=this.cache;Ae(n,t)||(e.uniform3iv(this.addr,t),Re(n,t))}function ke(e,t){var n=this.cache;Ae(n,t)||(e.uniform4iv(this.addr,t),Re(n,t))}function Xe(e,t){var n=this.cache;Ae(n,t)||(e.uniform1fv(this.addr,t),Re(n,t))}function je(e,t){var n=this.cache;Ae(n,t)||(e.uniform1iv(this.addr,t),Re(n,t))}function Ye(e,t){var n=this.cache,i=we(t,this.size,2);Ae(n,i)||(e.uniform2fv(this.addr,i),this.updateCache(i))}function qe(e,t){var n=this.cache,i=we(t,this.size,3);Ae(n,i)||(e.uniform3fv(this.addr,i),this.updateCache(i))}function Ze(e,t){var n=this.cache,i=we(t,this.size,4);Ae(n,i)||(e.uniform4fv(this.addr,i),this.updateCache(i))}function Je(e,t){var n=this.cache,i=we(t,this.size,4);Ae(n,i)||(e.uniformMatrix2fv(this.addr,!1,i),this.updateCache(i))}function Ke(e,t){var n=this.cache,i=we(t,this.size,9);Ae(n,i)||(e.uniformMatrix3fv(this.addr,!1,i),this.updateCache(i))}function Qe(e,t){var n=this.cache,i=we(t,this.size,16);Ae(n,i)||(e.uniformMatrix4fv(this.addr,!1,i),this.updateCache(i))}function $e(e,t,n){var i=this.cache,r=t.length,a=Pe(n,r);!1===Ae(i,a)&&(e.uniform1iv(this.addr,a),Re(i,a));for(var o=0;o!==r;++o)n.setTexture2D(t[o]||_e,a[o])}function et(e,t,n){var i=this.cache,r=t.length,a=Pe(n,r);!1===Ae(i,a)&&(e.uniform1iv(this.addr,a),Re(i,a));for(var o=0;o!==r;++o)n.setTextureCube(t[o]||be,a[o])}function tt(e,t,n){this.id=e,this.addr=n,this.cache=[],this.setValue=function(e){switch(e){case 5126:return Ce;case 35664:return Ie;case 35665:return Ne;case 35666:return Ue;case 35674:return Fe;case 35675:return Oe;case 35676:return Ge;case 35678:case 36198:return Be;case 35679:return He;case 35680:return Ve;case 5124:case 35670:return De;case 35667:case 35671:return ze;case 35668:case 35672:return We;case 35669:case 35673:return ke}}(t.type)}function nt(e,t,n){this.id=e,this.addr=n,this.cache=[],this.size=t.size,this.setValue=function(e){switch(e){case 5126:return Xe;case 35664:return Ye;case 35665:return qe;case 35666:return Ze;case 35674:return Je;case 35675:return Ke;case 35676:return Qe;case 35678:return $e;case 35680:return et;case 5124:case 35670:return je;case 35667:case 35671:return ze;case 35668:case 35672:return We;case 35669:case 35673:return ke}}(t.type)}function it(e){this.id=e,Me.call(this)}nt.prototype.updateCache=function(e){var t=this.cache;e instanceof Float32Array&&t.length!==e.length&&(this.cache=new Float32Array(e.length)),Re(t,e)},it.prototype.setValue=function(e,t,n){for(var i=this.seq,r=0,a=i.length;r!==a;++r){var o=i[r];o.setValue(e,t[o.id],n)}};var rt=/([\w\d_]+)(\])?(\[|\.)?/g;function at(e,t){e.seq.push(t),e.map[t.id]=t}function ot(e,t,n){var i=e.name,r=i.length;for(rt.lastIndex=0;;){var a=rt.exec(i),o=rt.lastIndex,s=a[1],l="]"===a[2],c=a[3];if(l&&(s|=0),void 0===c||"["===c&&o+2===r){at(n,void 0===c?new tt(s,e,t):new nt(s,e,t));break}var d=n.map[s];void 0===d&&at(n,d=new it(s)),n=d}}function st(e,t,n){Me.call(this),this.renderer=n;for(var i=e.getProgramParameter(t,e.ACTIVE_UNIFORMS),r=0;r<i;++r){var a=e.getActiveUniform(t,r);ot(a,e.getUniformLocation(t,a.name),this)}}function lt(e,t,n){var i=e.createShader(t);return e.shaderSource(i,n),e.compileShader(i),!1===e.getShaderParameter(i,e.COMPILE_STATUS)&&console.error("THREE.WebGLShader: Shader couldn't compile."),""!==e.getShaderInfoLog(i)&&console.warn("THREE.WebGLShader: gl.getShaderInfoLog()",t===e.VERTEX_SHADER?"vertex":"fragment",e.getShaderInfoLog(i),function(e){for(var t=e.split("\n"),n=0;n<t.length;n++)t[n]=n+1+": "+t[n];return t.join("\n")}(n)),i}st.prototype.setValue=function(e,t,n){var i=this.map[t];void 0!==i&&i.setValue(e,n,this.renderer)},st.prototype.setOptional=function(e,t,n){var i=t[n];void 0!==i&&this.setValue(e,n,i)},st.upload=function(e,t,n,i){for(var r=0,a=t.length;r!==a;++r){var o=t[r],s=n[o.id];!1!==s.needsUpdate&&o.setValue(e,s.value,i)}},st.seqWithValue=function(e,t){for(var n=[],i=0,r=e.length;i!==r;++i){var a=e[i];a.id in t&&n.push(a)}return n};var ct=0;function dt(e){switch(e){case r.L:return["Linear","( value )"];case r.sc:return["sRGB","( value )"];case r.Mb:return["RGBE","( value )"];case r.Pb:return["RGBM","( value, 7.0 )"];case r.Ob:return["RGBM","( value, 16.0 )"];case r.Lb:return["RGBD","( value, 256.0 )"];case r.E:return["Gamma","( value, float( GAMMA_FACTOR ) )"];default:throw new Error("unsupported encoding: "+e)}}function ut(e,t){var n=dt(t);return"vec4 "+e+"( vec4 value ) { return "+n[0]+"ToLinear"+n[1]+"; }"}function ft(e,t){var n;switch(t){case r.P:n="Linear";break;case r.Vb:n="Reinhard";break;case r.jc:n="Uncharted2";break;case r.j:n="OptimizedCineon";break;case r.a:n="ACESFilmic";break;default:throw new Error("unsupported toneMapping: "+t)}return"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function pt(e){return""!==e}function ht(e,t){return e.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights)}function mt(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}function gt(e){return e.replace(/^[ \t]*#include +<([\w\d.\/]+)>/gm,function(e,t){var n=E[t];if(void 0===n)throw new Error("Can not resolve #include <"+t+">");return gt(n)})}function vt(e){return e.replace(/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,function(e,t,n,i){for(var r="",a=parseInt(t);a<parseInt(n);a++)r+=i.replace(/\[ i \]/g,"[ "+a+" ]");return r})}function _t(e,t,n,i,a,o,s){var l=e.context,c=i.defines,d=a.vertexShader,u=a.fragmentShader,f="SHADOWMAP_TYPE_BASIC";o.shadowMapType===r.nb?f="SHADOWMAP_TYPE_PCF":o.shadowMapType===r.ob&&(f="SHADOWMAP_TYPE_PCF_SOFT");var p="ENVMAP_TYPE_CUBE",h="ENVMAP_MODE_REFLECTION",m="ENVMAP_BLENDING_MULTIPLY";if(o.envMap){switch(i.envMap.mapping){case r.l:case r.m:p="ENVMAP_TYPE_CUBE";break;case r.n:case r.o:p="ENVMAP_TYPE_CUBE_UV";break;case r.z:case r.A:p="ENVMAP_TYPE_EQUIREC";break;case r.Zb:p="ENVMAP_TYPE_SPHERE"}switch(i.envMap.mapping){case r.m:case r.A:h="ENVMAP_MODE_REFRACTION"}switch(i.combine){case r.X:m="ENVMAP_BLENDING_MULTIPLY";break;case r.V:m="ENVMAP_BLENDING_MIX";break;case r.c:m="ENVMAP_BLENDING_ADD"}}var g,v,_,x,b,M=e.gammaFactor>0?e.gammaFactor:1,T=s.isWebGL2?"":function(e,t,n){return[(e=e||{}).derivatives||t.envMapCubeUV||t.bumpMap||t.normalMap&&!t.objectSpaceNormalMap||t.flatShading?"#extension GL_OES_standard_derivatives : enable":"",(e.fragDepth||t.logarithmicDepthBuffer)&&n.get("EXT_frag_depth")?"#extension GL_EXT_frag_depth : enable":"",e.drawBuffers&&n.get("WEBGL_draw_buffers")?"#extension GL_EXT_draw_buffers : require":"",(e.shaderTextureLOD||t.envMap)&&n.get("EXT_shader_texture_lod")?"#extension GL_EXT_shader_texture_lod : enable":""].filter(pt).join("\n")}(i.extensions,o,t),S=function(e){var t=[];for(var n in e){var i=e[n];!1!==i&&t.push("#define "+n+" "+i)}return t.join("\n")}(c),L=l.createProgram();if(i.isRawShaderMaterial?((g=[S].filter(pt).join("\n")).length>0&&(g+="\n"),(v=[T,S].filter(pt).join("\n")).length>0&&(v+="\n")):(g=["precision "+o.precision+" float;","precision "+o.precision+" int;","#define SHADER_NAME "+a.name,S,o.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+M,"#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 "+h:"",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.normalMap&&o.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",o.displacementMap&&o.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",o.specularMap?"#define USE_SPECULARMAP":"",o.roughnessMap?"#define USE_ROUGHNESSMAP":"",o.metalnessMap?"#define USE_METALNESSMAP":"",o.alphaMap?"#define USE_ALPHAMAP":"",o.vertexColors?"#define USE_COLOR":"",o.flatShading?"#define FLAT_SHADED":"",o.skinning?"#define USE_SKINNING":"",o.useVertexTexture?"#define BONE_TEXTURE":"",o.morphTargets?"#define USE_MORPHTARGETS":"",o.morphNormals&&!1===o.flatShading?"#define USE_MORPHNORMALS":"",o.doubleSided?"#define DOUBLE_SIDED":"",o.flipSided?"#define FLIP_SIDED":"",o.shadowMapEnabled?"#define USE_SHADOWMAP":"",o.shadowMapEnabled?"#define "+f:"",o.sizeAttenuation?"#define USE_SIZEATTENUATION":"",o.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",o.logarithmicDepthBuffer&&(s.isWebGL2||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(pt).join("\n"),v=[T,"precision "+o.precision+" float;","precision "+o.precision+" int;","#define SHADER_NAME "+a.name,S,o.alphaTest?"#define ALPHATEST "+o.alphaTest+(o.alphaTest%1?"":".0"):"","#define GAMMA_FACTOR "+M,o.useFog&&o.fog?"#define USE_FOG":"",o.useFog&&o.fogExp?"#define FOG_EXP2":"",o.map?"#define USE_MAP":"",o.matcap?"#define USE_MATCAP":"",o.envMap?"#define USE_ENVMAP":"",o.envMap?"#define "+p:"",o.envMap?"#define "+h:"",o.envMap?"#define "+m:"",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.normalMap&&o.objectSpaceNormalMap?"#define OBJECTSPACE_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 "+f:"",o.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",o.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",o.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",o.logarithmicDepthBuffer&&(s.isWebGL2||t.get("EXT_frag_depth"))?"#define USE_LOGDEPTHBUF_EXT":"",o.envMap&&(s.isWebGL2||t.get("EXT_shader_texture_lod"))?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;",o.toneMapping!==r.eb?"#define TONE_MAPPING":"",o.toneMapping!==r.eb?E.tonemapping_pars_fragment:"",o.toneMapping!==r.eb?ft("toneMapping",o.toneMapping):"",o.dithering?"#define DITHERING":"",o.outputEncoding||o.mapEncoding||o.matcapEncoding||o.envMapEncoding||o.emissiveMapEncoding?E.encodings_pars_fragment:"",o.mapEncoding?ut("mapTexelToLinear",o.mapEncoding):"",o.matcapEncoding?ut("matcapTexelToLinear",o.matcapEncoding):"",o.envMapEncoding?ut("envMapTexelToLinear",o.envMapEncoding):"",o.emissiveMapEncoding?ut("emissiveMapTexelToLinear",o.emissiveMapEncoding):"",o.outputEncoding?(_="linearToOutputTexel",x=o.outputEncoding,b=dt(x),"vec4 "+_+"( vec4 value ) { return LinearTo"+b[0]+b[1]+"; }"):"",o.depthPacking?"#define DEPTH_PACKING "+i.depthPacking:"","\n"].filter(pt).join("\n")),d=mt(d=ht(d=gt(d),o),o),u=mt(u=ht(u=gt(u),o),o),d=vt(d),u=vt(u),s.isWebGL2&&!i.isRawShaderMaterial){var y=!1,w=/^\s*#version\s+300\s+es\s*\n/;i.isShaderMaterial&&null!==d.match(w)&&null!==u.match(w)&&(y=!0,d=d.replace(w,""),u=u.replace(w,"")),g=["#version 300 es\n","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+g,v=["#version 300 es\n","#define varying in",y?"":"out highp vec4 pc_fragColor;",y?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+v}var A=g+d,R=v+u,P=lt(l,l.VERTEX_SHADER,A),C=lt(l,l.FRAGMENT_SHADER,R);l.attachShader(L,P),l.attachShader(L,C),void 0!==i.index0AttributeName?l.bindAttribLocation(L,0,i.index0AttributeName):!0===o.morphTargets&&l.bindAttribLocation(L,0,"position"),l.linkProgram(L);var D,I,N=l.getProgramInfoLog(L).trim(),U=l.getShaderInfoLog(P).trim(),F=l.getShaderInfoLog(C).trim(),O=!0,G=!0;return!1===l.getProgramParameter(L,l.LINK_STATUS)?(O=!1,console.error("THREE.WebGLProgram: shader error: ",l.getError(),"gl.VALIDATE_STATUS",l.getProgramParameter(L,l.VALIDATE_STATUS),"gl.getProgramInfoLog",N,U,F)):""!==N?console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",N):""!==U&&""!==F||(G=!1),G&&(this.diagnostics={runnable:O,material:i,programLog:N,vertexShader:{log:U,prefix:g},fragmentShader:{log:F,prefix:v}}),l.deleteShader(P),l.deleteShader(C),this.getUniforms=function(){return void 0===D&&(D=new st(l,L,e)),D},this.getAttributes=function(){return void 0===I&&(I=function(e,t){for(var n={},i=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES),r=0;r<i;r++){var a=e.getActiveAttrib(t,r).name;n[a]=e.getAttribLocation(t,a)}return n}(l,L)),I},this.destroy=function(){l.deleteProgram(L),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=a.name,this.id=ct++,this.code=n,this.usedTimes=1,this.program=L,this.vertexShader=P,this.fragmentShader=C,this}function xt(e,t,n){var i=[],a={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"phong",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"},o=["precision","supportsVertexTextures","map","mapEncoding","matcap","matcapEncoding","envMap","envMapMode","envMapEncoding","lightMap","aoMap","emissiveMap","emissiveMapEncoding","bumpMap","normalMap","objectSpaceNormalMap","displacementMap","specularMap","roughnessMap","metalnessMap","gradientMap","alphaMap","combine","vertexColors","fog","useFog","fogExp","flatShading","sizeAttenuation","logarithmicDepthBuffer","skinning","maxBones","useVertexTexture","morphTargets","morphNormals","maxMorphTargets","maxMorphNormals","premultipliedAlpha","numDirLights","numPointLights","numSpotLights","numHemiLights","numRectAreaLights","shadowMapEnabled","shadowMapType","toneMapping","physicallyCorrectLights","alphaTest","doubleSided","flipSided","numClippingPlanes","numClipIntersection","depthPacking","dithering"];function s(e,t){var n;return e?e.isTexture?n=e.encoding:e.isWebGLRenderTarget&&(console.warn("THREE.WebGLPrograms.getTextureEncodingFromMap: don't use render targets as textures. Use their .texture property instead."),n=e.texture.encoding):n=r.L,n===r.L&&t&&(n=r.E),n}this.getParameters=function(t,i,o,l,c,d,u){var f=a[t.type],p=u.isSkinnedMesh?function(e){var t=e.skeleton.bones;if(n.floatVertexTextures)return 1024;var i=n.maxVertexUniforms,r=Math.floor((i-20)/4),a=Math.min(r,t.length);return a<t.length?(console.warn("THREE.WebGLRenderer: Skeleton has "+t.length+" bones. This GPU supports "+a+"."),0):a}(u):0,h=n.precision;null!==t.precision&&(h=n.getMaxPrecision(t.precision))!==t.precision&&console.warn("THREE.WebGLProgram.getParameters:",t.precision,"not supported, using",h,"instead.");var m=e.getRenderTarget();return{shaderID:f,precision:h,supportsVertexTextures:n.vertexTextures,outputEncoding:s(m?m.texture:null,e.gammaOutput),map:!!t.map,mapEncoding:s(t.map,e.gammaInput),matcap:!!t.matcap,matcapEncoding:s(t.matcap,e.gammaInput),envMap:!!t.envMap,envMapMode:t.envMap&&t.envMap.mapping,envMapEncoding:s(t.envMap,e.gammaInput),envMapCubeUV:!!t.envMap&&(t.envMap.mapping===r.n||t.envMap.mapping===r.o),lightMap:!!t.lightMap,aoMap:!!t.aoMap,emissiveMap:!!t.emissiveMap,emissiveMapEncoding:s(t.emissiveMap,e.gammaInput),bumpMap:!!t.bumpMap,normalMap:!!t.normalMap,objectSpaceNormalMap:t.normalMapType===r.hb,displacementMap:!!t.displacementMap,roughnessMap:!!t.roughnessMap,metalnessMap:!!t.metalnessMap,specularMap:!!t.specularMap,alphaMap:!!t.alphaMap,gradientMap:!!t.gradientMap,combine:t.combine,vertexColors:t.vertexColors,fog:!!l,useFog:t.fog,fogExp:l&&l.isFogExp2,flatShading:t.flatShading,sizeAttenuation:t.sizeAttenuation,logarithmicDepthBuffer:n.logarithmicDepthBuffer,skinning:t.skinning&&p>0,maxBones:p,useVertexTexture:n.floatVertexTextures,morphTargets:t.morphTargets,morphNormals:t.morphNormals,maxMorphTargets:e.maxMorphTargets,maxMorphNormals:e.maxMorphNormals,numDirLights:i.directional.length,numPointLights:i.point.length,numSpotLights:i.spot.length,numRectAreaLights:i.rectArea.length,numHemiLights:i.hemi.length,numClippingPlanes:c,numClipIntersection:d,dithering:t.dithering,shadowMapEnabled:e.shadowMap.enabled&&u.receiveShadow&&o.length>0,shadowMapType:e.shadowMap.type,toneMapping:e.toneMapping,physicallyCorrectLights:e.physicallyCorrectLights,premultipliedAlpha:t.premultipliedAlpha,alphaTest:t.alphaTest,doubleSided:t.side===r.v,flipSided:t.side===r.g,depthPacking:void 0!==t.depthPacking&&t.depthPacking}},this.getProgramCode=function(t,n){var i=[];if(n.shaderID?i.push(n.shaderID):(i.push(t.fragmentShader),i.push(t.vertexShader)),void 0!==t.defines)for(var r in t.defines)i.push(r),i.push(t.defines[r]);for(var a=0;a<o.length;a++)i.push(n[o[a]]);return i.push(t.onBeforeCompile.toString()),i.push(e.gammaOutput),i.push(e.gammaFactor),i.join()},this.acquireProgram=function(r,a,o,s){for(var l,c=0,d=i.length;c<d;c++){var u=i[c];if(u.code===s){++(l=u).usedTimes;break}}return void 0===l&&(l=new _t(e,t,s,r,a,o,n),i.push(l)),l},this.releaseProgram=function(e){if(0===--e.usedTimes){var t=i.indexOf(e);i[t]=i[i.length-1],i.pop(),e.destroy()}},this.programs=i}function bt(){var e=new WeakMap;return{get:function(t){var n=e.get(t);return void 0===n&&(n={},e.set(t,n)),n},remove:function(t){e.delete(t)},update:function(t,n,i){e.get(t)[n]=i},dispose:function(){e=new WeakMap}}}function Mt(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.program&&t.program&&e.program!==t.program?e.program.id-t.program.id:e.material.id!==t.material.id?e.material.id-t.material.id:e.z!==t.z?e.z-t.z:e.id-t.id}function Et(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id-t.id}function Tt(){var e=[],t=0,n=[],i=[];function r(n,i,r,a,o,s){var l=e[t];return void 0===l?(l={id:n.id,object:n,geometry:i,material:r,program:r.program,groupOrder:a,renderOrder:n.renderOrder,z:o,group:s},e[t]=l):(l.id=n.id,l.object=n,l.geometry=i,l.material=r,l.program=r.program,l.groupOrder=a,l.renderOrder=n.renderOrder,l.z=o,l.group=s),t++,l}return{opaque:n,transparent:i,init:function(){t=0,n.length=0,i.length=0},push:function(e,t,a,o,s,l){var c=r(e,t,a,o,s,l);(!0===a.transparent?i:n).push(c)},unshift:function(e,t,a,o,s,l){var c=r(e,t,a,o,s,l);(!0===a.transparent?i:n).unshift(c)},sort:function(){n.length>1&&n.sort(Mt),i.length>1&&i.sort(Et)}}}function St(){var e={};function t(n){var i=n.target;i.removeEventListener("dispose",t),delete e[i.id]}return{get:function(n,i){var r,a=e[n.id];return void 0===a?(r=new Tt,e[n.id]={},e[n.id][i.id]=r,n.addEventListener("dispose",t)):void 0===(r=a[i.id])&&(r=new Tt,a[i.id]=r),r},dispose:function(){e={}}}}function Lt(){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 v.a,color:new S.Color,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new s.a};break;case"SpotLight":n={position:new v.a,direction:new v.a,color:new S.Color,distance:0,coneCos:0,penumbraCos:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new s.a};break;case"PointLight":n={position:new v.a,color:new S.Color,distance:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new s.a,shadowCameraNear:1,shadowCameraFar:1e3};break;case"HemisphereLight":n={direction:new v.a,skyColor:new S.Color,groundColor:new S.Color};break;case"RectAreaLight":n={color:new S.Color,position:new v.a,halfWidth:new v.a,halfHeight:new v.a}}return e[t.id]=n,n}}}var yt=0;function wt(){var e=new Lt,t={id:yt++,hash:{stateID:-1,directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,shadowsLength:-1},ambient:[0,0,0],directional:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],point:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[]},n=new v.a,i=new M.a,r=new M.a;return{setup:function(a,o,s){for(var l=0,c=0,d=0,u=0,f=0,p=0,h=0,m=0,g=s.matrixWorldInverse,v=0,_=a.length;v<_;v++){var x=a[v],b=x.color,M=x.intensity,E=x.distance,T=x.shadow&&x.shadow.map?x.shadow.map.texture:null;if(x.isAmbientLight)l+=b.r*M,c+=b.g*M,d+=b.b*M;else if(x.isDirectionalLight){if((L=e.get(x)).color.copy(x.color).multiplyScalar(x.intensity),L.direction.setFromMatrixPosition(x.matrixWorld),n.setFromMatrixPosition(x.target.matrixWorld),L.direction.sub(n),L.direction.transformDirection(g),L.shadow=x.castShadow,x.castShadow){var S=x.shadow;L.shadowBias=S.bias,L.shadowRadius=S.radius,L.shadowMapSize=S.mapSize}t.directionalShadowMap[u]=T,t.directionalShadowMatrix[u]=x.shadow.matrix,t.directional[u]=L,u++}else if(x.isSpotLight)(L=e.get(x)).position.setFromMatrixPosition(x.matrixWorld),L.position.applyMatrix4(g),L.color.copy(b).multiplyScalar(M),L.distance=E,L.direction.setFromMatrixPosition(x.matrixWorld),n.setFromMatrixPosition(x.target.matrixWorld),L.direction.sub(n),L.direction.transformDirection(g),L.coneCos=Math.cos(x.angle),L.penumbraCos=Math.cos(x.angle*(1-x.penumbra)),L.decay=x.decay,L.shadow=x.castShadow,x.castShadow&&(S=x.shadow,L.shadowBias=S.bias,L.shadowRadius=S.radius,L.shadowMapSize=S.mapSize),t.spotShadowMap[p]=T,t.spotShadowMatrix[p]=x.shadow.matrix,t.spot[p]=L,p++;else if(x.isRectAreaLight)(L=e.get(x)).color.copy(b).multiplyScalar(M),L.position.setFromMatrixPosition(x.matrixWorld),L.position.applyMatrix4(g),r.identity(),i.copy(x.matrixWorld),i.premultiply(g),r.extractRotation(i),L.halfWidth.set(.5*x.width,0,0),L.halfHeight.set(0,.5*x.height,0),L.halfWidth.applyMatrix4(r),L.halfHeight.applyMatrix4(r),t.rectArea[h]=L,h++;else if(x.isPointLight)(L=e.get(x)).position.setFromMatrixPosition(x.matrixWorld),L.position.applyMatrix4(g),L.color.copy(x.color).multiplyScalar(x.intensity),L.distance=x.distance,L.decay=x.decay,L.shadow=x.castShadow,x.castShadow&&(S=x.shadow,L.shadowBias=S.bias,L.shadowRadius=S.radius,L.shadowMapSize=S.mapSize,L.shadowCameraNear=S.camera.near,L.shadowCameraFar=S.camera.far),t.pointShadowMap[f]=T,t.pointShadowMatrix[f]=x.shadow.matrix,t.point[f]=L,f++;else if(x.isHemisphereLight){var L;(L=e.get(x)).direction.setFromMatrixPosition(x.matrixWorld),L.direction.transformDirection(g),L.direction.normalize(),L.skyColor.copy(x.color).multiplyScalar(M),L.groundColor.copy(x.groundColor).multiplyScalar(M),t.hemi[m]=L,m++}}t.ambient[0]=l,t.ambient[1]=c,t.ambient[2]=d,t.directional.length=u,t.spot.length=p,t.rectArea.length=h,t.point.length=f,t.hemi.length=m,t.hash.stateID=t.id,t.hash.directionalLength=u,t.hash.pointLength=f,t.hash.spotLength=p,t.hash.rectAreaLength=h,t.hash.hemiLength=m,t.hash.shadowsLength=o.length},state:t}}function At(){var e=new wt,t=[],n=[];return{init:function(){t.length=0,n.length=0},state:{lightsArray:t,shadowsArray:n,lights:e},setupLights:function(i){e.setup(t,n,i)},pushLight:function(e){t.push(e)},pushShadow:function(e){n.push(e)}}}function Rt(){var e={};function t(n){var i=n.target;i.removeEventListener("dispose",t),delete e[i.id]}return{get:function(n,i){var r;return void 0===e[n.id]?(r=new At,e[n.id]={},e[n.id][i.id]=r,n.addEventListener("dispose",t)):void 0===e[n.id][i.id]?(r=new At,e[n.id][i.id]=r):r=e[n.id][i.id],r},dispose:function(){e={}}}}function Pt(e,t,n){this.width=e,this.height=t,this.scissor=new w.a(0,0,e,t),this.scissorTest=!1,this.viewport=new w.a(0,0,e,t),n=n||{},this.texture=new u(void 0,void 0,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.encoding),this.texture.generateMipmaps=void 0!==n.generateMipmaps&&n.generateMipmaps,this.texture.minFilter=void 0!==n.minFilter?n.minFilter:r.M,this.depthBuffer=void 0===n.depthBuffer||n.depthBuffer,this.stencilBuffer=void 0===n.stencilBuffer||n.stencilBuffer,this.depthTexture=void 0!==n.depthTexture?n.depthTexture:null}function Ct(e){te.a.call(this),this.type="MeshDepthMaterial",this.depthPacking=r.h,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.setValues(e)}function Dt(e){te.a.call(this),this.type="MeshDistanceMaterial",this.referencePosition=new v.a,this.nearDistance=1,this.farDistance=1e3,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.fog=!1,this.lights=!1,this.setValues(e)}function It(e,t,n){for(var i=new b,a=new M.a,o=new s.a,l=new s.a(n,n),c=new v.a,d=new v.a,u=1,f=2,p=1+(u|f),h=new Array(p),m=new Array(p),g={},_={0:r.g,1:r.D,2:r.v},x=[new v.a(1,0,0),new v.a(-1,0,0),new v.a(0,0,1),new v.a(0,0,-1),new v.a(0,1,0),new v.a(0,-1,0)],E=[new v.a(0,1,0),new v.a(0,1,0),new v.a(0,1,0),new v.a(0,1,0),new v.a(0,0,1),new v.a(0,0,-1)],T=[new w.a,new w.a,new w.a,new w.a,new w.a,new w.a],S=0;S!==p;++S){var L=0!==(S&u),y=0!==(S&f),A=new Ct({depthPacking:r.qb,morphTargets:L,skinning:y});h[S]=A;var R=new Dt({morphTargets:L,skinning:y});m[S]=R}var P=this;function C(t,n,i,r,a,o){var s=t.geometry,l=null,c=h,d=t.customDepthMaterial;if(i&&(c=m,d=t.customDistanceMaterial),d)l=d;else{var p=!1;n.morphTargets&&(s&&s.isBufferGeometry?p=s.morphAttributes&&s.morphAttributes.position&&s.morphAttributes.position.length>0:s&&s.isGeometry&&(p=s.morphTargets&&s.morphTargets.length>0)),t.isSkinnedMesh&&!1===n.skinning&&console.warn("THREE.WebGLShadowMap: THREE.SkinnedMesh with material.skinning set to false:",t);var v=t.isSkinnedMesh&&n.skinning,x=0;p&&(x|=u),v&&(x|=f),l=c[x]}if(e.localClippingEnabled&&!0===n.clipShadows&&0!==n.clippingPlanes.length){var b=l.uuid,M=n.uuid,E=g[b];void 0===E&&(E={},g[b]=E);var T=E[M];void 0===T&&(T=l.clone(),E[M]=T),l=T}return l.visible=n.visible,l.wireframe=n.wireframe,l.side=null!=n.shadowSide?n.shadowSide:_[n.side],l.clipShadows=n.clipShadows,l.clippingPlanes=n.clippingPlanes,l.clipIntersection=n.clipIntersection,l.wireframeLinewidth=n.wireframeLinewidth,l.linewidth=n.linewidth,i&&l.isMeshDistanceMaterial&&(l.referencePosition.copy(r),l.nearDistance=a,l.farDistance=o),l}function D(n,r,a,o){if(!1!==n.visible){if(n.layers.test(r.layers)&&(n.isMesh||n.isLine||n.isPoints)&&n.castShadow&&(!n.frustumCulled||i.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(a.matrixWorldInverse,n.matrixWorld);var s=t.update(n),l=n.material;if(Array.isArray(l))for(var c=s.groups,u=0,f=c.length;u<f;u++){var p=c[u],h=l[p.materialIndex];if(h&&h.visible){var m=C(n,h,o,d,a.near,a.far);e.renderBufferDirect(a,null,s,m,n,p)}}else if(l.visible){m=C(n,l,o,d,a.near,a.far);e.renderBufferDirect(a,null,s,m,n,null)}}for(var g=n.children,v=0,_=g.length;v<_;v++)D(g[v],r,a,o)}}this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=r.nb,this.render=function(t,n,s){if(!1!==P.enabled&&(!1!==P.autoUpdate||!1!==P.needsUpdate)&&0!==t.length){var u,f=e.state;f.setBlending(r.cb),f.buffers.color.setClear(1,1,1,1),f.buffers.depth.setTest(!0),f.setScissorTest(!1);for(var p=0,h=t.length;p<h;p++){var m=t[p],g=m.shadow,v=m&&m.isPointLight;if(void 0!==g){var _=g.camera;if(o.copy(g.mapSize),o.min(l),v){var b=o.x,M=o.y;T[0].set(2*b,M,b,M),T[1].set(0,M,b,M),T[2].set(3*b,M,b,M),T[3].set(b,M,b,M),T[4].set(3*b,0,b,M),T[5].set(b,0,b,M),o.x*=4,o.y*=2}if(null===g.map){var S={minFilter:r.Y,magFilter:r.Y,format:r.rb};g.map=new Pt(o.x,o.y,S),g.map.texture.name=m.name+".shadowMap",_.updateProjectionMatrix()}g.isSpotLightShadow&&g.update(m);var L=g.map,y=g.matrix;d.setFromMatrixPosition(m.matrixWorld),_.position.copy(d),v?(u=6,y.makeTranslation(-d.x,-d.y,-d.z)):(u=1,c.setFromMatrixPosition(m.target.matrixWorld),_.lookAt(c),_.updateMatrixWorld(),y.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),y.multiply(_.projectionMatrix),y.multiply(_.matrixWorldInverse)),e.setRenderTarget(L),e.clear();for(var w=0;w<u;w++){if(v){c.copy(_.position),c.add(x[w]),_.up.copy(E[w]),_.lookAt(c),_.updateMatrixWorld();var A=T[w];f.viewport(A)}a.multiplyMatrices(_.projectionMatrix,_.matrixWorldInverse),i.setFromMatrix(a),D(n,s,_,v)}}else console.warn("THREE.WebGLShadowMap:",m,"has no shadow.")}P.needsUpdate=!1}}}function Nt(e,t,n,i){var a=new function(){var t=!1,n=new w.a,i=null,r=new w.a(0,0,0,0);return{setMask:function(n){i===n||t||(e.colorMask(n,n,n,n),i=n)},setLocked:function(e){t=e},setClear:function(t,i,a,o,s){!0===s&&(t*=o,i*=o,a*=o),n.set(t,i,a,o),!1===r.equals(n)&&(e.clearColor(t,i,a,o),r.copy(n))},reset:function(){t=!1,i=null,r.set(-1,0,0,0)}}},o=new function(){var t=!1,n=null,i=null,a=null;return{setTest:function(t){t?V(e.DEPTH_TEST):z(e.DEPTH_TEST)},setMask:function(i){n===i||t||(e.depthMask(i),n=i)},setFunc:function(t){if(i!==t){if(t)switch(t){case r.bb:e.depthFunc(e.NEVER);break;case r.f:e.depthFunc(e.ALWAYS);break;case r.J:e.depthFunc(e.LESS);break;case r.K:e.depthFunc(e.LEQUAL);break;case r.y:e.depthFunc(e.EQUAL);break;case r.G:e.depthFunc(e.GEQUAL);break;case r.F:e.depthFunc(e.GREATER);break;case r.gb:e.depthFunc(e.NOTEQUAL);break;default:e.depthFunc(e.LEQUAL)}else e.depthFunc(e.LEQUAL);i=t}},setLocked:function(e){t=e},setClear:function(t){a!==t&&(e.clearDepth(t),a=t)},reset:function(){t=!1,n=null,i=null,a=null}}},s=new function(){var t=!1,n=null,i=null,r=null,a=null,o=null,s=null,l=null,c=null;return{setTest:function(t){t?V(e.STENCIL_TEST):z(e.STENCIL_TEST)},setMask:function(i){n===i||t||(e.stencilMask(i),n=i)},setFunc:function(t,n,o){i===t&&r===n&&a===o||(e.stencilFunc(t,n,o),i=t,r=n,a=o)},setOp:function(t,n,i){o===t&&s===n&&l===i||(e.stencilOp(t,n,i),o=t,s=n,l=i)},setLocked:function(e){t=e},setClear:function(t){c!==t&&(e.clearStencil(t),c=t)},reset:function(){t=!1,n=null,i=null,r=null,a=null,o=null,s=null,l=null,c=null}}},l=e.getParameter(e.MAX_VERTEX_ATTRIBS),c=new Uint8Array(l),d=new Uint8Array(l),u=new Uint8Array(l),f={},p=null,h=null,m=null,g=null,v=null,_=null,x=null,b=null,M=null,E=null,T=!1,S=null,L=null,y=null,A=null,R=null,P=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS),C=!1,D=0,I=e.getParameter(e.VERSION);-1!==I.indexOf("WebGL")?(D=parseFloat(/^WebGL\ ([0-9])/.exec(I)[1]),C=D>=1):-1!==I.indexOf("OpenGL ES")&&(D=parseFloat(/^OpenGL\ ES\ ([0-9])/.exec(I)[1]),C=D>=2);var N=null,U={},F=new w.a,O=new w.a;function G(t,n,i){var r=new Uint8Array(4),a=e.createTexture();e.bindTexture(t,a),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(var o=0;o<i;o++)e.texImage2D(n+o,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,r);return a}var B={};function H(n,r){(c[n]=1,0===d[n]&&(e.enableVertexAttribArray(n),d[n]=1),u[n]!==r)&&((i.isWebGL2?e:t.get("ANGLE_instanced_arrays"))[i.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](n,r),u[n]=r)}function V(t){!0!==f[t]&&(e.enable(t),f[t]=!0)}function z(t){!1!==f[t]&&(e.disable(t),f[t]=!1)}function W(t,i,a,o,s,l,c,d){if(t!==r.cb){if(m||(V(e.BLEND),m=!0),t===r.s)s=s||i,l=l||a,c=c||o,i===v&&s===b||(e.blendEquationSeparate(n.convert(i),n.convert(s)),v=i,b=s),a===_&&o===x&&l===M&&c===E||(e.blendFuncSeparate(n.convert(a),n.convert(o),n.convert(l),n.convert(c)),_=a,x=o,M=l,E=c),g=t,T=null;else if(t!==g||d!==T){if(v===r.b&&b===r.b||(e.blendEquation(e.FUNC_ADD),v=r.b,b=r.b),d)switch(t){case r.fb:e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case r.d:e.blendFunc(e.ONE,e.ONE);break;case r.ec:e.blendFuncSeparate(e.ZERO,e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ONE_MINUS_SRC_ALPHA);break;case r.W:e.blendFuncSeparate(e.ZERO,e.SRC_COLOR,e.ZERO,e.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",t)}else switch(t){case r.fb:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case r.d:e.blendFunc(e.SRC_ALPHA,e.ONE);break;case r.ec:e.blendFunc(e.ZERO,e.ONE_MINUS_SRC_COLOR);break;case r.W:e.blendFunc(e.ZERO,e.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",t)}_=null,x=null,M=null,E=null,g=t,T=d}}else m&&(z(e.BLEND),m=!1)}function k(t){S!==t&&(t?e.frontFace(e.CW):e.frontFace(e.CCW),S=t)}function X(t){t!==r.r?(V(e.CULL_FACE),t!==L&&(t===r.p?e.cullFace(e.BACK):t===r.q?e.cullFace(e.FRONT):e.cullFace(e.FRONT_AND_BACK))):z(e.CULL_FACE),L=t}function j(t,n,i){t?(V(e.POLYGON_OFFSET_FILL),A===n&&R===i||(e.polygonOffset(n,i),A=n,R=i)):z(e.POLYGON_OFFSET_FILL)}function Y(t){void 0===t&&(t=e.TEXTURE0+P-1),N!==t&&(e.activeTexture(t),N=t)}return B[e.TEXTURE_2D]=G(e.TEXTURE_2D,e.TEXTURE_2D,1),B[e.TEXTURE_CUBE_MAP]=G(e.TEXTURE_CUBE_MAP,e.TEXTURE_CUBE_MAP_POSITIVE_X,6),a.setClear(0,0,0,1),o.setClear(1),s.setClear(0),V(e.DEPTH_TEST),o.setFunc(r.K),k(!1),X(r.p),V(e.CULL_FACE),W(r.cb),{buffers:{color:a,depth:o,stencil:s},initAttributes:function(){for(var e=0,t=c.length;e<t;e++)c[e]=0},enableAttribute:function(e){H(e,0)},enableAttributeAndDivisor:H,disableUnusedAttributes:function(){for(var t=0,n=d.length;t!==n;++t)d[t]!==c[t]&&(e.disableVertexAttribArray(t),d[t]=0)},enable:V,disable:z,getCompressedTextureFormats:function(){if(null===p&&(p=[],t.get("WEBGL_compressed_texture_pvrtc")||t.get("WEBGL_compressed_texture_s3tc")||t.get("WEBGL_compressed_texture_etc1")||t.get("WEBGL_compressed_texture_astc")))for(var n=e.getParameter(e.COMPRESSED_TEXTURE_FORMATS),i=0;i<n.length;i++)p.push(n[i]);return p},useProgram:function(t){return h!==t&&(e.useProgram(t),h=t,!0)},setBlending:W,setMaterial:function(t,n){t.side===r.v?z(e.CULL_FACE):V(e.CULL_FACE);var i=t.side===r.g;n&&(i=!i),k(i),t.blending===r.fb&&!1===t.transparent?W(r.cb):W(t.blending,t.blendEquation,t.blendSrc,t.blendDst,t.blendEquationAlpha,t.blendSrcAlpha,t.blendDstAlpha,t.premultipliedAlpha),o.setFunc(t.depthFunc),o.setTest(t.depthTest),o.setMask(t.depthWrite),a.setMask(t.colorWrite),j(t.polygonOffset,t.polygonOffsetFactor,t.polygonOffsetUnits)},setFlipSided:k,setCullFace:X,setLineWidth:function(t){t!==y&&(C&&e.lineWidth(t),y=t)},setPolygonOffset:j,setScissorTest:function(t){t?V(e.SCISSOR_TEST):z(e.SCISSOR_TEST)},activeTexture:Y,bindTexture:function(t,n){null===N&&Y();var i=U[N];void 0===i&&(i={type:void 0,texture:void 0},U[N]=i),i.type===t&&i.texture===n||(e.bindTexture(t,n||B[t]),i.type=t,i.texture=n)},compressedTexImage2D:function(){try{e.compressedTexImage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texImage2D:function(){try{e.texImage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texImage3D:function(){try{e.texImage3D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},scissor:function(t){!1===F.equals(t)&&(e.scissor(t.x,t.y,t.z,t.w),F.copy(t))},viewport:function(t){!1===O.equals(t)&&(e.viewport(t.x,t.y,t.z,t.w),O.copy(t))},reset:function(){for(var t=0;t<d.length;t++)1===d[t]&&(e.disableVertexAttribArray(t),d[t]=0);f={},p=null,N=null,U={},h=null,g=null,S=null,L=null,a.reset(),o.reset(),s.reset()}}}function Ut(e,t,n,i,o,s,l){var c,d={};function u(e,t,n,i){var r=1;if((e.width>i||e.height>i)&&(r=i/Math.max(e.width,e.height)),r<1||!0===t){if(e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof ImageBitmap){void 0===c&&(c=document.createElementNS("http://www.w3.org/1999/xhtml","canvas"));var o=n?document.createElementNS("http://www.w3.org/1999/xhtml","canvas"):c,s=t?a.a.floorPowerOfTwo:Math.floor;return o.width=s(r*e.width),o.height=s(r*e.height),o.getContext("2d").drawImage(e,0,0,o.width,o.height),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+e.width+"x"+e.height+") to ("+o.width+"x"+o.height+")."),o}return"data"in e&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+e.width+"x"+e.height+")."),e}return e}function f(e){return a.a.isPowerOfTwo(e.width)&&a.a.isPowerOfTwo(e.height)}function p(e,t){return e.generateMipmaps&&t&&e.minFilter!==r.Y&&e.minFilter!==r.M}function h(t,n,r,a){e.generateMipmap(t),i.get(n).__maxMipLevel=Math.log(Math.max(r,a))*Math.LOG2E}function m(n,i){if(!o.isWebGL2)return n;var r=n;return n===e.RED&&(i===e.FLOAT&&(r=e.R32F),i===e.HALF_FLOAT&&(r=e.R16F),i===e.UNSIGNED_BYTE&&(r=e.R8)),n===e.RGB&&(i===e.FLOAT&&(r=e.RGB32F),i===e.HALF_FLOAT&&(r=e.RGB16F),i===e.UNSIGNED_BYTE&&(r=e.RGB8)),n===e.RGBA&&(i===e.FLOAT&&(r=e.RGBA32F),i===e.HALF_FLOAT&&(r=e.RGBA16F),i===e.UNSIGNED_BYTE&&(r=e.RGBA8)),r===e.R16F||r===e.R32F||r===e.RGBA16F||r===e.RGBA32F?t.get("EXT_color_buffer_float"):r!==e.RGB16F&&r!==e.RGB32F||console.warn("THREE.WebGLRenderer: Floating point textures with RGB format not supported. Please use RGBA instead."),r}function g(t){return t===r.Y||t===r.ab||t===r.Z?e.NEAREST:e.LINEAR}function v(t){var n=t.target;n.removeEventListener("dispose",v),function(t){var n=i.get(t);if(t.image&&n.__image__webglTextureCube)e.deleteTexture(n.__image__webglTextureCube);else{if(void 0===n.__webglInit)return;e.deleteTexture(n.__webglTexture)}i.remove(t)}(n),n.isVideoTexture&&delete d[n.id],l.memory.textures--}function _(t){var n=t.target;n.removeEventListener("dispose",_),function(t){var n=i.get(t),r=i.get(t.texture);if(!t)return;void 0!==r.__webglTexture&&e.deleteTexture(r.__webglTexture);t.depthTexture&&t.depthTexture.dispose();if(t.isWebGLRenderTargetCube)for(var a=0;a<6;a++)e.deleteFramebuffer(n.__webglFramebuffer[a]),n.__webglDepthbuffer&&e.deleteRenderbuffer(n.__webglDepthbuffer[a]);else e.deleteFramebuffer(n.__webglFramebuffer),n.__webglDepthbuffer&&e.deleteRenderbuffer(n.__webglDepthbuffer);i.remove(t.texture),i.remove(t)}(n),l.memory.textures--}function x(t,r){var a=i.get(t);if(t.isVideoTexture&&function(e){var t=e.id,n=l.render.frame;d[t]!==n&&(d[t]=n,e.update())}(t),t.version>0&&a.__version!==t.version){var o=t.image;if(void 0===o)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");else{if(!1!==o.complete)return void M(a,t,r);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}n.activeTexture(e.TEXTURE0+r),n.bindTexture(e.TEXTURE_2D,a.__webglTexture)}function b(n,a,l){var c;if(l?(e.texParameteri(n,e.TEXTURE_WRAP_S,s.convert(a.wrapS)),e.texParameteri(n,e.TEXTURE_WRAP_T,s.convert(a.wrapT)),e.texParameteri(n,e.TEXTURE_MAG_FILTER,s.convert(a.magFilter)),e.texParameteri(n,e.TEXTURE_MIN_FILTER,s.convert(a.minFilter))):(e.texParameteri(n,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(n,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),a.wrapS===r.k&&a.wrapT===r.k||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),e.texParameteri(n,e.TEXTURE_MAG_FILTER,g(a.magFilter)),e.texParameteri(n,e.TEXTURE_MIN_FILTER,g(a.minFilter)),a.minFilter!==r.Y&&a.minFilter!==r.M&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),c=t.get("EXT_texture_filter_anisotropic")){if(a.type===r.C&&null===t.get("OES_texture_float_linear"))return;if(a.type===r.H&&null===(o.isWebGL2||t.get("OES_texture_half_float_linear")))return;(a.anisotropy>1||i.get(a).__currentAnisotropy)&&(e.texParameterf(n,c.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,o.getMaxAnisotropy())),i.get(a).__currentAnisotropy=a.anisotropy)}}function M(t,i,a){var c;c=i.isDataTexture3D?e.TEXTURE_3D:e.TEXTURE_2D,void 0===t.__webglInit&&(t.__webglInit=!0,i.addEventListener("dispose",v),t.__webglTexture=e.createTexture(),l.memory.textures++),n.activeTexture(e.TEXTURE0+a),n.bindTexture(c,t.__webglTexture),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,i.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,i.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,i.unpackAlignment);var d=function(e){return!o.isWebGL2&&(e.wrapS!==r.k||e.wrapT!==r.k||e.minFilter!==r.Y&&e.minFilter!==r.M)}(i)&&!1===f(i.image),g=u(i.image,d,!1,o.maxTextureSize),_=f(g)||o.isWebGL2,x=s.convert(i.format),M=s.convert(i.type),E=m(x,M);b(c,i,_);var T,S=i.mipmaps;if(i.isDepthTexture){if(E=e.DEPTH_COMPONENT,i.type===r.C){if(!o.isWebGL2)throw new Error("Float Depth Texture only supported in WebGL2.0");E=e.DEPTH_COMPONENT32F}else o.isWebGL2&&(E=e.DEPTH_COMPONENT16);i.format===r.t&&E===e.DEPTH_COMPONENT&&i.type!==r.qc&&i.type!==r.mc&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),i.type=r.qc,M=s.convert(i.type)),i.format===r.u&&(E=e.DEPTH_STENCIL,i.type!==r.lc&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),i.type=r.lc,M=s.convert(i.type))),n.texImage2D(e.TEXTURE_2D,0,E,g.width,g.height,0,x,M,null)}else if(i.isDataTexture)if(S.length>0&&_){for(var L=0,y=S.length;L<y;L++)T=S[L],n.texImage2D(e.TEXTURE_2D,L,E,T.width,T.height,0,x,M,T.data);i.generateMipmaps=!1,t.__maxMipLevel=S.length-1}else n.texImage2D(e.TEXTURE_2D,0,E,g.width,g.height,0,x,M,g.data),t.__maxMipLevel=0;else if(i.isCompressedTexture){for(L=0,y=S.length;L<y;L++)T=S[L],i.format!==r.rb&&i.format!==r.Nb?n.getCompressedTextureFormats().indexOf(x)>-1?n.compressedTexImage2D(e.TEXTURE_2D,L,E,T.width,T.height,0,T.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):n.texImage2D(e.TEXTURE_2D,L,E,T.width,T.height,0,x,M,T.data);t.__maxMipLevel=S.length-1}else if(i.isDataTexture3D)n.texImage3D(e.TEXTURE_3D,0,E,g.width,g.height,g.depth,0,x,M,g.data),t.__maxMipLevel=0;else if(S.length>0&&_){for(L=0,y=S.length;L<y;L++)T=S[L],n.texImage2D(e.TEXTURE_2D,L,E,x,M,T);i.generateMipmaps=!1,t.__maxMipLevel=S.length-1}else n.texImage2D(e.TEXTURE_2D,0,E,x,M,g),t.__maxMipLevel=0;p(i,_)&&h(e.TEXTURE_2D,i,g.width,g.height),t.__version=i.version,i.onUpdate&&i.onUpdate(i)}function E(t,r,a,o){var l=s.convert(r.texture.format),c=s.convert(r.texture.type),d=m(l,c);n.texImage2D(o,0,d,r.width,r.height,0,l,c,null),e.bindFramebuffer(e.FRAMEBUFFER,t),e.framebufferTexture2D(e.FRAMEBUFFER,a,o,i.get(r.texture).__webglTexture,0),e.bindFramebuffer(e.FRAMEBUFFER,null)}function T(t,n,i){if(e.bindRenderbuffer(e.RENDERBUFFER,t),n.depthBuffer&&!n.stencilBuffer){if(i){var r=L(n);e.renderbufferStorageMultisample(e.RENDERBUFFER,r,e.DEPTH_COMPONENT16,n.width,n.height)}else e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_COMPONENT16,n.width,n.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,t)}else if(n.depthBuffer&&n.stencilBuffer){if(i){r=L(n);e.renderbufferStorageMultisample(e.RENDERBUFFER,r,e.DEPTH_STENCIL,n.width,n.height)}else e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_STENCIL,n.width,n.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,t)}else{var a=m(s.convert(n.texture.format),s.convert(n.texture.type));if(i){r=L(n);e.renderbufferStorageMultisample(e.RENDERBUFFER,r,a,n.width,n.height)}else e.renderbufferStorage(e.RENDERBUFFER,a,n.width,n.height)}e.bindRenderbuffer(e.RENDERBUFFER,null)}function S(t){var n=i.get(t),a=!0===t.isWebGLRenderTargetCube;if(t.depthTexture){if(a)throw new Error("target.depthTexture not supported in Cube render targets");!function(t,n){if(n&&n.isWebGLRenderTargetCube)throw new Error("Depth Texture with cube render targets is not supported");if(e.bindFramebuffer(e.FRAMEBUFFER,t),!n.depthTexture||!n.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");i.get(n.depthTexture).__webglTexture&&n.depthTexture.image.width===n.width&&n.depthTexture.image.height===n.height||(n.depthTexture.image.width=n.width,n.depthTexture.image.height=n.height,n.depthTexture.needsUpdate=!0),x(n.depthTexture,0);var a=i.get(n.depthTexture).__webglTexture;if(n.depthTexture.format===r.t)e.framebufferTexture2D(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.TEXTURE_2D,a,0);else{if(n.depthTexture.format!==r.u)throw new Error("Unknown depthTexture format");e.framebufferTexture2D(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.TEXTURE_2D,a,0)}}(n.__webglFramebuffer,t)}else if(a){n.__webglDepthbuffer=[];for(var o=0;o<6;o++)e.bindFramebuffer(e.FRAMEBUFFER,n.__webglFramebuffer[o]),n.__webglDepthbuffer[o]=e.createRenderbuffer(),T(n.__webglDepthbuffer[o],t)}else e.bindFramebuffer(e.FRAMEBUFFER,n.__webglFramebuffer),n.__webglDepthbuffer=e.createRenderbuffer(),T(n.__webglDepthbuffer,t);e.bindFramebuffer(e.FRAMEBUFFER,null)}function L(e){return o.isWebGL2&&e.isWebGLMultisampleRenderTarget?Math.min(o.maxSamples,e.samples):0}this.setTexture2D=x,this.setTexture3D=function(t,r){var a=i.get(t);t.version>0&&a.__version!==t.version?M(a,t,r):(n.activeTexture(e.TEXTURE0+r),n.bindTexture(e.TEXTURE_3D,a.__webglTexture))},this.setTextureCube=function(t,a){var c=i.get(t);if(6===t.image.length)if(t.version>0&&c.__version!==t.version){c.__image__webglTextureCube||(t.addEventListener("dispose",v),c.__image__webglTextureCube=e.createTexture(),l.memory.textures++),n.activeTexture(e.TEXTURE0+a),n.bindTexture(e.TEXTURE_CUBE_MAP,c.__image__webglTextureCube),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,t.flipY);for(var d=t&&t.isCompressedTexture,g=t.image[0]&&t.image[0].isDataTexture,_=[],x=0;x<6;x++)_[x]=d||g?g?t.image[x].image:t.image[x]:u(t.image[x],!1,!0,o.maxCubemapSize);var M=_[0],E=f(M)||o.isWebGL2,T=s.convert(t.format),S=s.convert(t.type),L=m(T,S);for(b(e.TEXTURE_CUBE_MAP,t,E),x=0;x<6;x++)if(d)for(var y,w=_[x].mipmaps,A=0,R=w.length;A<R;A++)y=w[A],t.format!==r.rb&&t.format!==r.Nb?n.getCompressedTextureFormats().indexOf(T)>-1?n.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+x,A,L,y.width,y.height,0,y.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+x,A,L,y.width,y.height,0,T,S,y.data);else g?n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+x,0,L,_[x].width,_[x].height,0,T,S,_[x].data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+x,0,L,T,S,_[x]);c.__maxMipLevel=d?w.length-1:0,p(t,E)&&h(e.TEXTURE_CUBE_MAP,t,M.width,M.height),c.__version=t.version,t.onUpdate&&t.onUpdate(t)}else n.activeTexture(e.TEXTURE0+a),n.bindTexture(e.TEXTURE_CUBE_MAP,c.__image__webglTextureCube)},this.setTextureCubeDynamic=function(t,r){n.activeTexture(e.TEXTURE0+r),n.bindTexture(e.TEXTURE_CUBE_MAP,i.get(t).__webglTexture)},this.setupRenderTarget=function(t){var r=i.get(t),a=i.get(t.texture);t.addEventListener("dispose",_),a.__webglTexture=e.createTexture(),l.memory.textures++;var c=!0===t.isWebGLRenderTargetCube,d=!0===t.isWebGLMultisampleRenderTarget,u=f(t)||o.isWebGL2;if(c){r.__webglFramebuffer=[];for(var g=0;g<6;g++)r.__webglFramebuffer[g]=e.createFramebuffer()}else if(r.__webglFramebuffer=e.createFramebuffer(),d)if(o.isWebGL2){r.__webglMultisampledFramebuffer=e.createFramebuffer(),r.__webglColorRenderbuffer=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,r.__webglColorRenderbuffer);var v=m(s.convert(t.texture.format),s.convert(t.texture.type)),x=L(t);e.renderbufferStorageMultisample(e.RENDERBUFFER,x,v,t.width,t.height),e.bindFramebuffer(e.FRAMEBUFFER,r.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,r.__webglColorRenderbuffer),e.bindRenderbuffer(e.RENDERBUFFER,null),t.depthBuffer&&(r.__webglDepthRenderbuffer=e.createRenderbuffer(),T(r.__webglDepthRenderbuffer,t,!0)),e.bindFramebuffer(e.FRAMEBUFFER,null)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.");if(c){for(n.bindTexture(e.TEXTURE_CUBE_MAP,a.__webglTexture),b(e.TEXTURE_CUBE_MAP,t.texture,u),g=0;g<6;g++)E(r.__webglFramebuffer[g],t,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+g);p(t.texture,u)&&h(e.TEXTURE_CUBE_MAP,t.texture,t.width,t.height),n.bindTexture(e.TEXTURE_CUBE_MAP,null)}else n.bindTexture(e.TEXTURE_2D,a.__webglTexture),b(e.TEXTURE_2D,t.texture,u),E(r.__webglFramebuffer,t,e.COLOR_ATTACHMENT0,e.TEXTURE_2D),p(t.texture,u)&&h(e.TEXTURE_2D,t.texture,t.width,t.height),n.bindTexture(e.TEXTURE_2D,null);t.depthBuffer&&S(t)},this.updateRenderTargetMipmap=function(t){var r=t.texture;if(p(r,f(t)||o.isWebGL2)){var a=t.isWebGLRenderTargetCube?e.TEXTURE_CUBE_MAP:e.TEXTURE_2D,s=i.get(r).__webglTexture;n.bindTexture(a,s),h(a,r,t.width,t.height),n.bindTexture(a,null)}},this.updateMultisampleRenderTarget=function(t){if(t.isWebGLMultisampleRenderTarget)if(o.isWebGL2){var n=i.get(t);e.bindFramebuffer(e.READ_FRAMEBUFFER,n.__webglMultisampledFramebuffer),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,n.__webglFramebuffer);var r=t.width,a=t.height,s=e.COLOR_BUFFER_BIT;t.depthBuffer&&(s|=e.DEPTH_BUFFER_BIT),t.stencilBuffer&&(s|=e.STENCIL_BUFFER_BIT),e.blitFramebuffer(0,0,r,a,0,0,r,a,s,e.NEAREST)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.")}}function Ft(e,t,n){return{convert:function(i){var a;if(i===r.Wb)return e.REPEAT;if(i===r.k)return e.CLAMP_TO_EDGE;if(i===r.U)return e.MIRRORED_REPEAT;if(i===r.Y)return e.NEAREST;if(i===r.ab)return e.NEAREST_MIPMAP_NEAREST;if(i===r.Z)return e.NEAREST_MIPMAP_LINEAR;if(i===r.M)return e.LINEAR;if(i===r.O)return e.LINEAR_MIPMAP_NEAREST;if(i===r.N)return e.LINEAR_MIPMAP_LINEAR;if(i===r.kc)return e.UNSIGNED_BYTE;if(i===r.nc)return e.UNSIGNED_SHORT_4_4_4_4;if(i===r.oc)return e.UNSIGNED_SHORT_5_5_5_1;if(i===r.pc)return e.UNSIGNED_SHORT_5_6_5;if(i===r.i)return e.BYTE;if(i===r.Yb)return e.SHORT;if(i===r.qc)return e.UNSIGNED_SHORT;if(i===r.I)return e.INT;if(i===r.mc)return e.UNSIGNED_INT;if(i===r.C)return e.FLOAT;if(i===r.H){if(n.isWebGL2)return e.HALF_FLOAT;if(null!==(a=t.get("OES_texture_half_float")))return a.HALF_FLOAT_OES}if(i===r.e)return e.ALPHA;if(i===r.Nb)return e.RGB;if(i===r.rb)return e.RGBA;if(i===r.R)return e.LUMINANCE;if(i===r.Q)return e.LUMINANCE_ALPHA;if(i===r.t)return e.DEPTH_COMPONENT;if(i===r.u)return e.DEPTH_STENCIL;if(i===r.Ub)return e.RED;if(i===r.b)return e.FUNC_ADD;if(i===r.dc)return e.FUNC_SUBTRACT;if(i===r.Xb)return e.FUNC_REVERSE_SUBTRACT;if(i===r.rc)return e.ZERO;if(i===r.ib)return e.ONE;if(i===r.cc)return e.SRC_COLOR;if(i===r.mb)return e.ONE_MINUS_SRC_COLOR;if(i===r.ac)return e.SRC_ALPHA;if(i===r.lb)return e.ONE_MINUS_SRC_ALPHA;if(i===r.w)return e.DST_ALPHA;if(i===r.jb)return e.ONE_MINUS_DST_ALPHA;if(i===r.x)return e.DST_COLOR;if(i===r.kb)return e.ONE_MINUS_DST_COLOR;if(i===r.bc)return e.SRC_ALPHA_SATURATE;if((i===r.Tb||i===r.Ib||i===r.Jb||i===r.Kb)&&null!==(a=t.get("WEBGL_compressed_texture_s3tc"))){if(i===r.Tb)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===r.Ib)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===r.Jb)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===r.Kb)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}if((i===r.Sb||i===r.Rb||i===r.Hb||i===r.Gb)&&null!==(a=t.get("WEBGL_compressed_texture_pvrtc"))){if(i===r.Sb)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===r.Rb)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===r.Hb)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===r.Gb)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(i===r.Qb&&null!==(a=t.get("WEBGL_compressed_texture_etc1")))return a.COMPRESSED_RGB_ETC1_WEBGL;if((i===r.yb||i===r.zb||i===r.Ab||i===r.Bb||i===r.Cb||i===r.Db||i===r.Eb||i===r.Fb||i===r.tb||i===r.ub||i===r.vb||i===r.sb||i===r.wb||i===r.xb)&&null!==(a=t.get("WEBGL_compressed_texture_astc")))return i;if(i===r.T||i===r.S){if(n.isWebGL2){if(i===r.T)return e.MIN;if(i===r.S)return e.MAX}if(null!==(a=t.get("EXT_blend_minmax"))){if(i===r.T)return a.MIN_EXT;if(i===r.S)return a.MAX_EXT}}if(i===r.lc){if(n.isWebGL2)return e.UNSIGNED_INT_24_8;if(null!==(a=t.get("WEBGL_depth_texture")))return a.UNSIGNED_INT_24_8_WEBGL}return 0}}}function Ot(){U.a.call(this),this.type="Group"}Pt.prototype=Object.assign(Object.create(o.a.prototype),{constructor:Pt,isWebGLRenderTarget:!0,setSize:function(e,t){this.width===e&&this.height===t||(this.width=e,this.height=t,this.dispose()),this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.width=e.width,this.height=e.height,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.depthTexture=e.depthTexture,this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),Ct.prototype=Object.create(te.a.prototype),Ct.prototype.constructor=Ct,Ct.prototype.isMeshDepthMaterial=!0,Ct.prototype.copy=function(e){return te.a.prototype.copy.call(this,e),this.depthPacking=e.depthPacking,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this},Dt.prototype=Object.create(te.a.prototype),Dt.prototype.constructor=Dt,Dt.prototype.isMeshDistanceMaterial=!0,Dt.prototype.copy=function(e){return te.a.prototype.copy.call(this,e),this.referencePosition.copy(e.referencePosition),this.nearDistance=e.nearDistance,this.farDistance=e.farDistance,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this},Ot.prototype=Object.assign(Object.create(U.a.prototype),{constructor:Ot,isGroup:!0});var Gt=n("87e9a120487aa43be2b2"),Bt=n("8908bd2155cefaf0af9d");function Ht(e){Bt.PerspectiveCamera.call(this),this.cameras=e||[]}Ht.prototype=Object.assign(Object.create(Bt.PerspectiveCamera.prototype),{constructor:Ht,isArrayCamera:!0});var Vt=new v.a,zt=new v.a;function Wt(e,t,n){Vt.setFromMatrixPosition(t.matrixWorld),zt.setFromMatrixPosition(n.matrixWorld);var i=Vt.distanceTo(zt),r=t.projectionMatrix.elements,a=n.projectionMatrix.elements,o=r[14]/(r[10]-1),s=r[14]/(r[10]+1),l=(r[9]+1)/r[5],c=(r[9]-1)/r[5],d=(r[8]-1)/r[0],u=(a[8]+1)/a[0],f=o*d,p=o*u,h=i/(-d+u),m=h*-d;t.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(m),e.translateZ(h),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.getInverse(e.matrixWorld);var g=o+h,v=s+h,_=f-m,x=p+(i-m),b=l*s/v*g,M=c*s/v*g;e.projectionMatrix.makePerspective(_,x,b,M,g,v)}function kt(e){var t=this,n=null,i=null,r=null,a=[],o=new M.a,s=new M.a,l=1,c="stage";"undefined"!==typeof window&&"VRFrameData"in window&&(i=new window.VRFrameData,window.addEventListener("vrdisplaypresentchange",b,!1));var d=new M.a,u=new Gt.a,f=new v.a,p=new Bt.PerspectiveCamera;p.bounds=new w.a(0,0,.5,1),p.layers.enable(1);var h=new Bt.PerspectiveCamera;h.bounds=new w.a(.5,0,.5,1),h.layers.enable(2);var m,g,_=new Ht([p,h]);function x(){return null!==n&&!0===n.isPresenting}function b(){if(x()){var i=n.getEyeParameters("left"),r=i.renderWidth*l,a=i.renderHeight*l;g=e.getPixelRatio(),m=e.getSize(),e.setDrawingBufferSize(2*r,a,1),S.start()}else t.enabled&&e.setDrawingBufferSize(m.width,m.height,g),S.stop()}_.layers.enable(1),_.layers.enable(2);var E=[];function T(e){for(var t=navigator.getGamepads&&navigator.getGamepads(),n=0,i=0,r=t.length;n<r;n++){var a=t[n];if(a&&("Daydream Controller"===a.id||"Gear VR Controller"===a.id||"Oculus Go Controller"===a.id||"OpenVR Gamepad"===a.id||a.id.startsWith("Oculus Touch")||a.id.startsWith("Spatial Controller"))){if(i===e)return a;i++}}}this.enabled=!1,this.getController=function(e){var t=a[e];return void 0===t&&((t=new Ot).matrixAutoUpdate=!1,t.visible=!1,a[e]=t),t},this.getDevice=function(){return n},this.setDevice=function(e){void 0!==e&&(n=e),S.setContext(e)},this.setFramebufferScaleFactor=function(e){l=e},this.setFrameOfReferenceType=function(e){c=e},this.setPoseTarget=function(e){void 0!==e&&(r=e)},this.getCamera=function(e){var t="stage"===c?1.6:0;if(null===n)return e.position.set(0,t,0),e;if(n.depthNear=e.near,n.depthFar=e.far,n.getFrameData(i),"stage"===c){var l=n.stageParameters;l?o.fromArray(l.sittingToStandingTransform):o.makeTranslation(0,t,0)}var m=i.pose,g=null!==r?r:e;if(g.matrix.copy(o),g.matrix.decompose(g.position,g.quaternion,g.scale),null!==m.orientation&&(u.fromArray(m.orientation),g.quaternion.multiply(u)),null!==m.position&&(u.setFromRotationMatrix(o),f.fromArray(m.position),f.applyQuaternion(u),g.position.add(f)),g.updateMatrixWorld(),!1===n.isPresenting)return e;p.near=e.near,h.near=e.near,p.far=e.far,h.far=e.far,p.matrixWorldInverse.fromArray(i.leftViewMatrix),h.matrixWorldInverse.fromArray(i.rightViewMatrix),s.getInverse(o),"stage"===c&&(p.matrixWorldInverse.multiply(s),h.matrixWorldInverse.multiply(s));var v=g.parent;null!==v&&(d.getInverse(v.matrixWorld),p.matrixWorldInverse.multiply(d),h.matrixWorldInverse.multiply(d)),p.matrixWorld.getInverse(p.matrixWorldInverse),h.matrixWorld.getInverse(h.matrixWorldInverse),p.projectionMatrix.fromArray(i.leftProjectionMatrix),h.projectionMatrix.fromArray(i.rightProjectionMatrix),Wt(_,p,h);var x=n.getLayers();if(x.length){var b=x[0];null!==b.leftBounds&&4===b.leftBounds.length&&p.bounds.fromArray(b.leftBounds),null!==b.rightBounds&&4===b.rightBounds.length&&h.bounds.fromArray(b.rightBounds)}return function(){for(var e=0;e<a.length;e++){var t=a[e],n=T(e);if(void 0!==n&&void 0!==n.pose){if(null===n.pose)return;var i=n.pose;!1===i.hasPosition&&t.position.set(.2,-.6,-.05),null!==i.position&&t.position.fromArray(i.position),null!==i.orientation&&t.quaternion.fromArray(i.orientation),t.matrix.compose(t.position,t.quaternion,t.scale),t.matrix.premultiply(o),t.matrix.decompose(t.position,t.quaternion,t.scale),t.matrixWorldNeedsUpdate=!0,t.visible=!0;var r="Daydream Controller"===n.id?0:1;E[e]!==n.buttons[r].pressed&&(E[e]=n.buttons[r].pressed,!0===E[e]?t.dispatchEvent({type:"selectstart"}):(t.dispatchEvent({type:"selectend"}),t.dispatchEvent({type:"select"})))}else t.visible=!1}}(),_},this.getStandingMatrix=function(){return o},this.isPresenting=x;var S=new A;this.setAnimationLoop=function(e){S.setAnimationLoop(e)},this.submitFrame=function(){x()&&n.submitFrame()},this.dispose=function(){"undefined"!==typeof window&&window.removeEventListener("vrdisplaypresentchange",b)}}function Xt(e){var t=e.context,n=null,i=null,r=1,a=null,o="stage",s=null,l=[],c=[];function d(){return null!==i&&null!==a}var u=new Bt.PerspectiveCamera;u.layers.enable(1),u.viewport=new w.a;var f=new Bt.PerspectiveCamera;f.layers.enable(2),f.viewport=new w.a;var p=new Ht([u,f]);function h(e){var t=l[c.indexOf(e.inputSource)];t&&t.dispatchEvent({type:e.type})}function m(){e.setFramebuffer(null),_.stop()}function g(e,t){null===t?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.getInverse(e.matrixWorld)}p.layers.enable(1),p.layers.enable(2),this.enabled=!1,this.getController=function(e){var t=l[e];return void 0===t&&((t=new Ot).matrixAutoUpdate=!1,t.visible=!1,l[e]=t),t},this.getDevice=function(){return n},this.setDevice=function(e){void 0!==e&&(n=e),e instanceof XRDevice&&t.setCompatibleXRDevice(e)},this.setFramebufferScaleFactor=function(e){r=e},this.setFrameOfReferenceType=function(e){o=e},this.setSession=function(n){null!==(i=n)&&(i.addEventListener("select",h),i.addEventListener("selectstart",h),i.addEventListener("selectend",h),i.addEventListener("end",m),i.baseLayer=new XRWebGLLayer(i,t,{framebufferScaleFactor:r}),i.requestFrameOfReference(o).then(function(t){a=t,e.setFramebuffer(i.baseLayer.framebuffer),_.setContext(i),_.start()}),c=i.getInputSources(),i.addEventListener("inputsourceschange",function(){c=i.getInputSources(),console.log(c);for(var e=0;e<l.length;e++){l[e].userData.inputSource=c[e]}}))},this.getCamera=function(e){if(d()){var t=e.parent,n=p.cameras;g(p,t);for(var i=0;i<n.length;i++)g(n[i],t);e.matrixWorld.copy(p.matrixWorld);for(var r=e.children,a=(i=0,r.length);i<a;i++)r[i].updateMatrixWorld(!0);return Wt(p,u,f),p}return e},this.isPresenting=d;var v=null;var _=new A;_.setAnimationLoop(function(e,t){if(null!==(s=t.getDevicePose(a)))for(var n=i.baseLayer,r=t.views,o=0;o<r.length;o++){var d=r[o],u=n.getViewport(d),f=s.getViewMatrix(d),h=p.cameras[o];h.matrix.fromArray(f).getInverse(h.matrix),h.projectionMatrix.fromArray(d.projectionMatrix),h.viewport.set(u.x,u.y,u.width,u.height),0===o&&p.matrix.copy(h.matrix)}for(o=0;o<l.length;o++){var m=l[o],g=c[o];if(g){var _=t.getInputPose(g,a);if(null!==_){"targetRay"in _?m.matrix.elements=_.targetRay.transformMatrix:"pointerMatrix"in _&&(m.matrix.elements=_.pointerMatrix),m.matrix.decompose(m.position,m.rotation,m.scale),m.visible=!0;continue}}m.visible=!1}v&&v(e)}),this.setAnimationLoop=function(e){v=e},this.dispose=function(){},this.getStandingMatrix=function(){return console.warn("THREE.WebXRManager: getStandingMatrix() is no longer needed."),new THREE.Matrix4},this.submitFrame=function(){}}function jt(e){console.log("THREE.WebGLRenderer",r.pb);var t=void 0!==(e=e||{}).canvas?e.canvas:document.createElementNS("http://www.w3.org/1999/xhtml","canvas"),n=void 0!==e.context?e.context:null,i=void 0!==e.alpha&&e.alpha,o=void 0===e.depth||e.depth,s=void 0===e.stencil||e.stencil,l=void 0!==e.antialias&&e.antialias,c=void 0===e.premultipliedAlpha||e.premultipliedAlpha,d=void 0!==e.preserveDrawingBuffer&&e.preserveDrawingBuffer,u=void 0!==e.powerPreference?e.powerPreference:"default",p=null,h=null;this.domElement=t,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=r.P,this.toneMappingExposure=1,this.toneMappingWhitePoint=1,this.maxMorphTargets=8,this.maxMorphNormals=4;var m,g,_,x,E,S,P,C,D,I,N,U,F,O,G,B,H,V,z=this,W=!1,k=null,X=null,j=null,Y=-1,q={geometry:null,program:null,wireframe:!1},Z=null,J=null,K=new w.a,Q=new w.a,$=null,ee=0,te=t.width,ne=t.height,ie=1,ce=new w.a(0,0,te,ne),pe=new w.a(0,0,te,ne),ge=!1,ve=new b,_e=new se,xe=!1,be=!1,Me=new M.a,Ee=new v.a;function Te(){return null===X?ie:1}try{var Se={alpha:i,depth:o,stencil:s,antialias:l,premultipliedAlpha:c,preserveDrawingBuffer:d,powerPreference:u};if(t.addEventListener("webglcontextlost",Ae,!1),t.addEventListener("webglcontextrestored",Re,!1),null===(m=n||t.getContext("webgl",Se)||t.getContext("experimental-webgl",Se)))throw null!==t.getContext("webgl")?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.");void 0===m.getShaderPrecisionFormat&&(m.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(e){console.error("THREE.WebGLRenderer: "+e.message)}function Le(){g=new le(m),(_=new oe(m,g,e)).isWebGL2||(g.get("WEBGL_depth_texture"),g.get("OES_texture_float"),g.get("OES_texture_half_float"),g.get("OES_texture_half_float_linear"),g.get("OES_standard_derivatives"),g.get("OES_element_index_uint"),g.get("ANGLE_instanced_arrays")),g.get("OES_texture_float_linear"),V=new Ft(m,g,_),(x=new Nt(m,g,V,_)).scissor(Q.copy(pe).multiplyScalar(ie)),x.viewport(K.copy(ce).multiplyScalar(ie)),E=new fe(m),S=new bt,P=new Ut(m,g,x,S,_,V,E),C=new R(m),D=new de(m,C,E),I=new me(D,E),G=new he(m),N=new xt(z,g,_),U=new St,F=new Rt,O=new re(z,x,I,c),B=new ae(m,g,E,_),H=new ue(m,g,E,_),E.programs=N.programs,z.context=m,z.capabilities=_,z.extensions=g,z.properties=S,z.renderLists=U,z.state=x,z.info=E}Le();var ye=null;"undefined"!==typeof navigator&&(ye="xr"in navigator?new Xt(z):new kt(z)),this.vr=ye;var we=new It(z,I,_.maxTextureSize);function Ae(e){e.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),W=!0}function Re(){console.log("THREE.WebGLRenderer: Context Restored."),W=!1,Le()}function Pe(e){var t=e.target;t.removeEventListener("dispose",Pe),function(e){Ce(e),S.remove(e)}(t)}function Ce(e){var t=S.get(e).program;e.program=void 0,void 0!==t&&N.releaseProgram(t)}this.shadowMap=we,this.getContext=function(){return m},this.getContextAttributes=function(){return m.getContextAttributes()},this.forceContextLoss=function(){var e=g.get("WEBGL_lose_context");e&&e.loseContext()},this.forceContextRestore=function(){var e=g.get("WEBGL_lose_context");e&&e.restoreContext()},this.getPixelRatio=function(){return ie},this.setPixelRatio=function(e){void 0!==e&&(ie=e,this.setSize(te,ne,!1))},this.getSize=function(){return{width:te,height:ne}},this.setSize=function(e,n,i){ye.isPresenting()?console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."):(te=e,ne=n,t.width=e*ie,t.height=n*ie,!1!==i&&(t.style.width=e+"px",t.style.height=n+"px"),this.setViewport(0,0,e,n))},this.getDrawingBufferSize=function(){return{width:te*ie,height:ne*ie}},this.setDrawingBufferSize=function(e,n,i){te=e,ne=n,ie=i,t.width=e*i,t.height=n*i,this.setViewport(0,0,e,n)},this.getCurrentViewport=function(){return K},this.setViewport=function(e,t,n,i){ce.set(e,ne-t-i,n,i),x.viewport(K.copy(ce).multiplyScalar(ie))},this.setScissor=function(e,t,n,i){pe.set(e,ne-t-i,n,i),x.scissor(Q.copy(pe).multiplyScalar(ie))},this.setScissorTest=function(e){x.setScissorTest(ge=e)},this.getClearColor=function(){return O.getClearColor()},this.setClearColor=function(){O.setClearColor.apply(O,arguments)},this.getClearAlpha=function(){return O.getClearAlpha()},this.setClearAlpha=function(){O.setClearAlpha.apply(O,arguments)},this.clear=function(e,t,n){var i=0;(void 0===e||e)&&(i|=m.COLOR_BUFFER_BIT),(void 0===t||t)&&(i|=m.DEPTH_BUFFER_BIT),(void 0===n||n)&&(i|=m.STENCIL_BUFFER_BIT),m.clear(i)},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.dispose=function(){t.removeEventListener("webglcontextlost",Ae,!1),t.removeEventListener("webglcontextrestored",Re,!1),U.dispose(),F.dispose(),S.dispose(),I.dispose(),ye.dispose(),Ne.stop()},this.renderBufferImmediate=function(e,t){x.initAttributes();var n=S.get(e);e.hasPositions&&!n.position&&(n.position=m.createBuffer()),e.hasNormals&&!n.normal&&(n.normal=m.createBuffer()),e.hasUvs&&!n.uv&&(n.uv=m.createBuffer()),e.hasColors&&!n.color&&(n.color=m.createBuffer());var i=t.getAttributes();e.hasPositions&&(m.bindBuffer(m.ARRAY_BUFFER,n.position),m.bufferData(m.ARRAY_BUFFER,e.positionArray,m.DYNAMIC_DRAW),x.enableAttribute(i.position),m.vertexAttribPointer(i.position,3,m.FLOAT,!1,0,0)),e.hasNormals&&(m.bindBuffer(m.ARRAY_BUFFER,n.normal),m.bufferData(m.ARRAY_BUFFER,e.normalArray,m.DYNAMIC_DRAW),x.enableAttribute(i.normal),m.vertexAttribPointer(i.normal,3,m.FLOAT,!1,0,0)),e.hasUvs&&(m.bindBuffer(m.ARRAY_BUFFER,n.uv),m.bufferData(m.ARRAY_BUFFER,e.uvArray,m.DYNAMIC_DRAW),x.enableAttribute(i.uv),m.vertexAttribPointer(i.uv,2,m.FLOAT,!1,0,0)),e.hasColors&&(m.bindBuffer(m.ARRAY_BUFFER,n.color),m.bufferData(m.ARRAY_BUFFER,e.colorArray,m.DYNAMIC_DRAW),x.enableAttribute(i.color),m.vertexAttribPointer(i.color,3,m.FLOAT,!1,0,0)),x.disableUnusedAttributes(),m.drawArrays(m.TRIANGLES,0,e.count),e.count=0},this.renderBufferDirect=function(e,t,n,i,a,o){var s=a.isMesh&&a.normalMatrix.determinant()<0;x.setMaterial(i,s);var l=Ge(e,t,i,a),c=!1;q.geometry===n.id&&q.program===l.id&&q.wireframe===(!0===i.wireframe)||(q.geometry=n.id,q.program=l.id,q.wireframe=!0===i.wireframe,c=!0),a.morphTargetInfluences&&(G.update(a,n,i,l),c=!0);var d,u=n.index,f=n.attributes.position,p=1;!0===i.wireframe&&(u=D.getWireframeAttribute(n),p=2);var h=B;null!==u&&(d=C.get(u),(h=H).setIndex(d)),c&&(!function(e,t,n){if(n&&n.isInstancedBufferGeometry&!_.isWebGL2&&null===g.get("ANGLE_instanced_arrays"))return void console.error("THREE.WebGLRenderer.setupVertexAttributes: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");x.initAttributes();var i=n.attributes,r=t.getAttributes(),a=e.defaultAttributeValues;for(var o in r){var s=r[o];if(s>=0){var l=i[o];if(void 0!==l){var c=l.normalized,d=l.itemSize,u=C.get(l);if(void 0===u)continue;var f=u.buffer,p=u.type,h=u.bytesPerElement;if(l.isInterleavedBufferAttribute){var v=l.data,b=v.stride,M=l.offset;v&&v.isInstancedInterleavedBuffer?(x.enableAttributeAndDivisor(s,v.meshPerAttribute),void 0===n.maxInstancedCount&&(n.maxInstancedCount=v.meshPerAttribute*v.count)):x.enableAttribute(s),m.bindBuffer(m.ARRAY_BUFFER,f),m.vertexAttribPointer(s,d,p,c,b*h,M*h)}else l.isInstancedBufferAttribute?(x.enableAttributeAndDivisor(s,l.meshPerAttribute),void 0===n.maxInstancedCount&&(n.maxInstancedCount=l.meshPerAttribute*l.count)):x.enableAttribute(s),m.bindBuffer(m.ARRAY_BUFFER,f),m.vertexAttribPointer(s,d,p,c,0,0)}else if(void 0!==a){var E=a[o];if(void 0!==E)switch(E.length){case 2:m.vertexAttrib2fv(s,E);break;case 3:m.vertexAttrib3fv(s,E);break;case 4:m.vertexAttrib4fv(s,E);break;default:m.vertexAttrib1fv(s,E)}}}}x.disableUnusedAttributes()}(i,l,n),null!==u&&m.bindBuffer(m.ELEMENT_ARRAY_BUFFER,d.buffer));var v=1/0;null!==u?v=u.count:void 0!==f&&(v=f.count);var b=n.drawRange.start*p,M=n.drawRange.count*p,E=null!==o?o.start*p:0,T=null!==o?o.count*p:1/0,S=Math.max(b,E),L=Math.min(v,b+M,E+T)-1,y=Math.max(0,L-S+1);if(0!==y){if(a.isMesh)if(!0===i.wireframe)x.setLineWidth(i.wireframeLinewidth*Te()),h.setMode(m.LINES);else switch(a.drawMode){case r.hc:h.setMode(m.TRIANGLES);break;case r.gc:h.setMode(m.TRIANGLE_STRIP);break;case r.fc:h.setMode(m.TRIANGLE_FAN)}else if(a.isLine){var w=i.linewidth;void 0===w&&(w=1),x.setLineWidth(w*Te()),a.isLineSegments?h.setMode(m.LINES):a.isLineLoop?h.setMode(m.LINE_LOOP):h.setMode(m.LINE_STRIP)}else a.isPoints?h.setMode(m.POINTS):a.isSprite&&h.setMode(m.TRIANGLES);n&&n.isInstancedBufferGeometry?n.maxInstancedCount>0&&h.renderInstances(n,S,y):h.render(S,y)}},this.compile=function(e,t){(h=F.get(e,t)).init(),e.traverse(function(e){e.isLight&&(h.pushLight(e),e.castShadow&&h.pushShadow(e))}),h.setupLights(t),e.traverse(function(t){if(t.material)if(Array.isArray(t.material))for(var n=0;n<t.material.length;n++)Oe(t.material[n],e.fog,t);else Oe(t.material,e.fog,t)})};var De=null;var Ie,Ne=new A;function Ue(e,t,n,i){for(var r=0,a=e.length;r<a;r++){var o=e[r],s=o.object,l=o.geometry,c=void 0===i?o.material:i,d=o.group;if(n.isArrayCamera){J=n;for(var u=n.cameras,f=0,p=u.length;f<p;f++){var m=u[f];if(s.layers.test(m.layers)){if("viewport"in m)x.viewport(K.copy(m.viewport));else{var g=m.bounds,v=g.x*te,_=g.y*ne,b=g.z*te,M=g.w*ne;x.viewport(K.set(v,_,b,M).multiplyScalar(ie))}h.setupLights(m),Fe(s,t,m,l,c,d)}}}else J=null,Fe(s,t,n,l,c,d)}}function Fe(e,t,n,i,r,a){if(e.onBeforeRender(z,t,n,i,r,a),h=F.get(t,J||n),e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix),e.isImmediateRenderObject){x.setMaterial(r);var o=Ge(n,t.fog,r,e);q.geometry=null,q.program=null,q.wireframe=!1,function(e,t){e.render(function(e){z.renderBufferImmediate(e,t)})}(e,o)}else z.renderBufferDirect(n,t.fog,i,r,e,a);e.onAfterRender(z,t,n,i,r,a),h=F.get(t,J||n)}function Oe(e,t,n){var i=S.get(e),r=h.state.lights,a=h.state.shadowsArray,o=i.lightsHash,s=r.state.hash,l=N.getParameters(e,r.state,a,t,_e.numPlanes,_e.numIntersection,n),c=N.getProgramCode(e,l),d=i.program,u=!0;if(void 0===d)e.addEventListener("dispose",Pe);else if(d.code!==c)Ce(e);else if(o.stateID!==s.stateID||o.directionalLength!==s.directionalLength||o.pointLength!==s.pointLength||o.spotLength!==s.spotLength||o.rectAreaLength!==s.rectAreaLength||o.hemiLength!==s.hemiLength||o.shadowsLength!==s.shadowsLength)o.stateID=s.stateID,o.directionalLength=s.directionalLength,o.pointLength=s.pointLength,o.spotLength=s.spotLength,o.rectAreaLength=s.rectAreaLength,o.hemiLength=s.hemiLength,o.shadowsLength=s.shadowsLength,u=!1;else{if(void 0!==l.shaderID)return;u=!1}if(u){if(l.shaderID){var f=y[l.shaderID];i.shader={name:e.type,uniforms:Object(T.a)(f.uniforms),vertexShader:f.vertexShader,fragmentShader:f.fragmentShader}}else i.shader={name:e.type,uniforms:e.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader};e.onBeforeCompile(i.shader,z),c=N.getProgramCode(e,l),d=N.acquireProgram(e,i.shader,l,c),i.program=d,e.program=d}var p=d.getAttributes();if(e.morphTargets){e.numSupportedMorphTargets=0;for(var m=0;m<z.maxMorphTargets;m++)p["morphTarget"+m]>=0&&e.numSupportedMorphTargets++}if(e.morphNormals){e.numSupportedMorphNormals=0;for(m=0;m<z.maxMorphNormals;m++)p["morphNormal"+m]>=0&&e.numSupportedMorphNormals++}var g=i.shader.uniforms;(e.isShaderMaterial||e.isRawShaderMaterial)&&!0!==e.clipping||(i.numClippingPlanes=_e.numPlanes,i.numIntersection=_e.numIntersection,g.clippingPlanes=_e.uniform),i.fog=t,void 0===o&&(i.lightsHash=o={}),o.stateID=s.stateID,o.directionalLength=s.directionalLength,o.pointLength=s.pointLength,o.spotLength=s.spotLength,o.rectAreaLength=s.rectAreaLength,o.hemiLength=s.hemiLength,o.shadowsLength=s.shadowsLength,e.lights&&(g.ambientLightColor.value=r.state.ambient,g.directionalLights.value=r.state.directional,g.spotLights.value=r.state.spot,g.rectAreaLights.value=r.state.rectArea,g.pointLights.value=r.state.point,g.hemisphereLights.value=r.state.hemi,g.directionalShadowMap.value=r.state.directionalShadowMap,g.directionalShadowMatrix.value=r.state.directionalShadowMatrix,g.spotShadowMap.value=r.state.spotShadowMap,g.spotShadowMatrix.value=r.state.spotShadowMatrix,g.pointShadowMap.value=r.state.pointShadowMap,g.pointShadowMatrix.value=r.state.pointShadowMatrix);var v=i.program.getUniforms(),_=st.seqWithValue(v.seq,g);i.uniformsList=_}function Ge(e,t,n,i){ee=0;var o=S.get(n),s=h.state.lights,l=o.lightsHash,c=s.state.hash;if(xe&&(be||e!==Z)){var d=e===Z&&n.id===Y;_e.setState(n.clippingPlanes,n.clipIntersection,n.clipShadows,e,o,d)}!1===n.needsUpdate&&(void 0===o.program?n.needsUpdate=!0:n.fog&&o.fog!==t?n.needsUpdate=!0:(!n.lights||l.stateID===c.stateID&&l.directionalLength===c.directionalLength&&l.pointLength===c.pointLength&&l.spotLength===c.spotLength&&l.rectAreaLength===c.rectAreaLength&&l.hemiLength===c.hemiLength&&l.shadowsLength===c.shadowsLength)&&(void 0===o.numClippingPlanes||o.numClippingPlanes===_e.numPlanes&&o.numIntersection===_e.numIntersection)||(n.needsUpdate=!0)),n.needsUpdate&&(Oe(n,t,i),n.needsUpdate=!1);var u,p,g=!1,v=!1,b=!1,M=o.program,E=M.getUniforms(),T=o.shader.uniforms;if(x.useProgram(M.program)&&(g=!0,v=!0,b=!0),n.id!==Y&&(Y=n.id,v=!0),g||Z!==e){if(E.setValue(m,"projectionMatrix",e.projectionMatrix),_.logarithmicDepthBuffer&&E.setValue(m,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),Z!==e&&(Z=e,v=!0,b=!0),n.isShaderMaterial||n.isMeshPhongMaterial||n.isMeshStandardMaterial||n.envMap){var y=E.map.cameraPosition;void 0!==y&&y.setValue(m,Ee.setFromMatrixPosition(e.matrixWorld))}(n.isMeshPhongMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial||n.skinning)&&E.setValue(m,"viewMatrix",e.matrixWorldInverse)}if(n.skinning){E.setOptional(m,i,"bindMatrix"),E.setOptional(m,i,"bindMatrixInverse");var w=i.skeleton;if(w){var A=w.bones;if(_.floatVertexTextures){if(void 0===w.boneTexture){var R=Math.sqrt(4*A.length);R=a.a.ceilPowerOfTwo(R),R=Math.max(R,4);var P=new Float32Array(R*R*4);P.set(w.boneMatrices);var C=new f(P,R,R,r.rb,r.C);C.needsUpdate=!0,w.boneMatrices=P,w.boneTexture=C,w.boneTextureSize=R}E.setValue(m,"boneTexture",w.boneTexture),E.setValue(m,"boneTextureSize",w.boneTextureSize)}else E.setOptional(m,w,"boneMatrices")}}return v&&(E.setValue(m,"toneMappingExposure",z.toneMappingExposure),E.setValue(m,"toneMappingWhitePoint",z.toneMappingWhitePoint),n.lights&&(p=b,(u=T).ambientLightColor.needsUpdate=p,u.directionalLights.needsUpdate=p,u.pointLights.needsUpdate=p,u.spotLights.needsUpdate=p,u.rectAreaLights.needsUpdate=p,u.hemisphereLights.needsUpdate=p),t&&n.fog&&function(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)}(T,t),n.isMeshBasicMaterial?Be(T,n):n.isMeshLambertMaterial?(Be(T,n),function(e,t){t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap)}(T,n)):n.isMeshPhongMaterial?(Be(T,n),n.isMeshToonMaterial?function(e,t){He(e,t),t.gradientMap&&(e.gradientMap.value=t.gradientMap)}(T,n):He(T,n)):n.isMeshStandardMaterial?(Be(T,n),n.isMeshPhysicalMaterial?function(e,t){Ve(e,t),e.reflectivity.value=t.reflectivity,e.clearCoat.value=t.clearCoat,e.clearCoatRoughness.value=t.clearCoatRoughness}(T,n):Ve(T,n)):n.isMeshMatcapMaterial?(Be(T,n),function(e,t){t.matcap&&(e.matcap.value=t.matcap);t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,t.side===r.g&&(e.bumpScale.value*=-1));t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),t.side===r.g&&e.normalScale.value.negate());t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}(T,n)):n.isMeshDepthMaterial?(Be(T,n),function(e,t){t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}(T,n)):n.isMeshDistanceMaterial?(Be(T,n),function(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}(T,n)):n.isMeshNormalMaterial?(Be(T,n),function(e,t){t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,t.side===r.g&&(e.bumpScale.value*=-1));t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),t.side===r.g&&e.normalScale.value.negate());t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}(T,n)):n.isLineBasicMaterial?(function(e,t){e.diffuse.value=t.color,e.opacity.value=t.opacity}(T,n),n.isLineDashedMaterial&&function(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}(T,n)):n.isPointsMaterial?function(e,t){e.diffuse.value=t.color,e.opacity.value=t.opacity,e.size.value=t.size*ie,e.scale.value=.5*ne,e.map.value=t.map,null!==t.map&&(!0===t.map.matrixAutoUpdate&&t.map.updateMatrix(),e.uvTransform.value.copy(t.map.matrix))}(T,n):n.isSpriteMaterial?function(e,t){e.diffuse.value=t.color,e.opacity.value=t.opacity,e.rotation.value=t.rotation,e.map.value=t.map,null!==t.map&&(!0===t.map.matrixAutoUpdate&&t.map.updateMatrix(),e.uvTransform.value.copy(t.map.matrix))}(T,n):n.isShadowMaterial&&(T.color.value=n.color,T.opacity.value=n.opacity),void 0!==T.ltc_1&&(T.ltc_1.value=L.LTC_1),void 0!==T.ltc_2&&(T.ltc_2.value=L.LTC_2),st.upload(m,o.uniformsList,T,z)),n.isShaderMaterial&&!0===n.uniformsNeedUpdate&&(st.upload(m,o.uniformsList,T,z),n.uniformsNeedUpdate=!1),n.isSpriteMaterial&&E.setValue(m,"center",i.center),E.setValue(m,"modelViewMatrix",i.modelViewMatrix),E.setValue(m,"normalMatrix",i.normalMatrix),E.setValue(m,"modelMatrix",i.matrixWorld),M}function Be(e,t){var n;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.isCubeTexture?-1:1,e.reflectivity.value=t.reflectivity,e.refractionRatio.value=t.refractionRatio,e.maxMipLevel.value=S.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),t.map?n=t.map:t.specularMap?n=t.specularMap:t.displacementMap?n=t.displacementMap:t.normalMap?n=t.normalMap:t.bumpMap?n=t.bumpMap:t.roughnessMap?n=t.roughnessMap:t.metalnessMap?n=t.metalnessMap:t.alphaMap?n=t.alphaMap:t.emissiveMap&&(n=t.emissiveMap),void 0!==n&&(n.isWebGLRenderTarget&&(n=n.texture),!0===n.matrixAutoUpdate&&n.updateMatrix(),e.uvTransform.value.copy(n.matrix))}function He(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.side===r.g&&(e.bumpScale.value*=-1)),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),t.side===r.g&&e.normalScale.value.negate()),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}function Ve(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.side===r.g&&(e.bumpScale.value*=-1)),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),t.side===r.g&&e.normalScale.value.negate()),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias),t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)}Ne.setAnimationLoop(function(e){ye.isPresenting()||De&&De(e)}),"undefined"!==typeof window&&Ne.setContext(window),this.setAnimationLoop=function(e){De=e,ye.setAnimationLoop(e),Ne.start()},this.render=function(e,t,n,i){if(t&&t.isCamera){if(!W){q.geometry=null,q.program=null,q.wireframe=!1,Y=-1,Z=null,!0===e.autoUpdate&&e.updateMatrixWorld(),null===t.parent&&t.updateMatrixWorld(),ye.enabled&&(t=ye.getCamera(t)),(h=F.get(e,t)).init(),e.onBeforeRender(z,e,t,n),Me.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),ve.setFromMatrix(Me),be=this.localClippingEnabled,xe=_e.init(this.clippingPlanes,be,t),(p=U.get(e,t)).init(),function e(t,n,i,r){if(!1===t.visible)return;var a=t.layers.test(n.layers);if(a)if(t.isGroup)i=t.renderOrder;else if(t.isLight)h.pushLight(t),t.castShadow&&h.pushShadow(t);else if(t.isSprite){if(!t.frustumCulled||ve.intersectsSprite(t)){r&&Ee.setFromMatrixPosition(t.matrixWorld).applyMatrix4(Me);var o=I.update(t),s=t.material;p.push(t,o,s,i,Ee.z,null)}}else if(t.isImmediateRenderObject)r&&Ee.setFromMatrixPosition(t.matrixWorld).applyMatrix4(Me),p.push(t,null,t.material,i,Ee.z,null);else if((t.isMesh||t.isLine||t.isPoints)&&(t.isSkinnedMesh&&t.skeleton.update(),!t.frustumCulled||ve.intersectsObject(t))){r&&Ee.setFromMatrixPosition(t.matrixWorld).applyMatrix4(Me);var o=I.update(t),s=t.material;if(Array.isArray(s))for(var l=o.groups,c=0,d=l.length;c<d;c++){var u=l[c],f=s[u.materialIndex];f&&f.visible&&p.push(t,o,f,i,Ee.z,u)}else s.visible&&p.push(t,o,s,i,Ee.z,null)}var m=t.children;for(var c=0,d=m.length;c<d;c++)e(m[c],n,i,r)}(e,t,0,z.sortObjects),!0===z.sortObjects&&p.sort(),xe&&_e.beginShadows();var r=h.state.shadowsArray;we.render(r,e,t),h.setupLights(t),xe&&_e.endShadows(),this.info.autoReset&&this.info.reset(),void 0===n&&(n=null),this.setRenderTarget(n),O.render(p,e,t,i);var a=p.opaque,o=p.transparent;if(e.overrideMaterial){var s=e.overrideMaterial;a.length&&Ue(a,e,t,s),o.length&&Ue(o,e,t,s)}else a.length&&Ue(a,e,t),o.length&&Ue(o,e,t);n&&(P.updateRenderTargetMipmap(n),P.updateMultisampleRenderTarget(n)),x.buffers.depth.setTest(!0),x.buffers.depth.setMask(!0),x.buffers.color.setMask(!0),x.setPolygonOffset(!1),e.onAfterRender(z,e,t),ye.enabled&&ye.submitFrame(),p=null,h=null}}else console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.")},this.allocTextureUnit=function(){var e=ee;return e>=_.maxTextures&&console.warn("THREE.WebGLRenderer: Trying to use "+e+" texture units while this GPU supports only "+_.maxTextures),ee+=1,e},this.setTexture2D=(Ie=!1,function(e,t){e&&e.isWebGLRenderTarget&&(Ie||(console.warn("THREE.WebGLRenderer.setTexture2D: don't use render targets as textures. Use their .texture property instead."),Ie=!0),e=e.texture),P.setTexture2D(e,t)}),this.setTexture3D=function(e,t){P.setTexture3D(e,t)},this.setTexture=function(){var e=!1;return function(t,n){e||(console.warn("THREE.WebGLRenderer: .setTexture is deprecated, use setTexture2D instead."),e=!0),P.setTexture2D(t,n)}}(),this.setTextureCube=function(){var e=!1;return function(t,n){t&&t.isWebGLRenderTargetCube&&(e||(console.warn("THREE.WebGLRenderer.setTextureCube: don't use cube render targets as textures. Use their .texture property instead."),e=!0),t=t.texture),t&&t.isCubeTexture||Array.isArray(t.image)&&6===t.image.length?P.setTextureCube(t,n):P.setTextureCubeDynamic(t,n)}}(),this.setFramebuffer=function(e){k=e},this.getRenderTarget=function(){return X},this.setRenderTarget=function(e){X=e,e&&void 0===S.get(e).__webglFramebuffer&&P.setupRenderTarget(e);var t=k,n=!1;if(e){var i=S.get(e).__webglFramebuffer;e.isWebGLRenderTargetCube?(t=i[e.activeCubeFace],n=!0):t=e.isWebGLMultisampleRenderTarget?S.get(e).__webglMultisampledFramebuffer:i,K.copy(e.viewport),Q.copy(e.scissor),$=e.scissorTest}else K.copy(ce).multiplyScalar(ie),Q.copy(pe).multiplyScalar(ie),$=ge;if(j!==t&&(m.bindFramebuffer(m.FRAMEBUFFER,t),j=t),x.viewport(K),x.scissor(Q),x.setScissorTest($),n){var r=S.get(e.texture);m.framebufferTexture2D(m.FRAMEBUFFER,m.COLOR_ATTACHMENT0,m.TEXTURE_CUBE_MAP_POSITIVE_X+e.activeCubeFace,r.__webglTexture,e.activeMipMapLevel)}},this.readRenderTargetPixels=function(e,t,n,i,a,o){if(e&&e.isWebGLRenderTarget){var s=S.get(e).__webglFramebuffer;if(s){var l=!1;s!==j&&(m.bindFramebuffer(m.FRAMEBUFFER,s),l=!0);try{var c=e.texture,d=c.format,u=c.type;if(d!==r.rb&&V.convert(d)!==m.getParameter(m.IMPLEMENTATION_COLOR_READ_FORMAT))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(u!==r.kc&&V.convert(u)!==m.getParameter(m.IMPLEMENTATION_COLOR_READ_TYPE)&&(u!==r.C||!(_.isWebGL2||g.get("OES_texture_float")||g.get("WEBGL_color_buffer_float")))&&(u!==r.H||(_.isWebGL2?!g.get("EXT_color_buffer_float"):!g.get("EXT_color_buffer_half_float"))))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");m.checkFramebufferStatus(m.FRAMEBUFFER)===m.FRAMEBUFFER_COMPLETE?t>=0&&t<=e.width-i&&n>=0&&n<=e.height-a&&m.readPixels(t,n,i,a,V.convert(d),V.convert(u),o):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{l&&m.bindFramebuffer(m.FRAMEBUFFER,j)}}}else console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.")},this.copyFramebufferToTexture=function(e,t,n){var i=t.image.width,r=t.image.height,a=V.convert(t.format);this.setTexture2D(t,0),m.copyTexImage2D(m.TEXTURE_2D,n||0,a,e.x,e.y,i,r,0)},this.copyTextureToTexture=function(e,t,n,i){var r=t.image.width,a=t.image.height,o=V.convert(n.format),s=V.convert(n.type);this.setTexture2D(n,0),t.isDataTexture?m.texSubImage2D(m.TEXTURE_2D,i||0,e.x,e.y,r,a,o,s,t.image.data):m.texSubImage2D(m.TEXTURE_2D,i||0,e.x,e.y,o,s,t.image)}}n.d(t,"WebGLRenderer",function(){return jt})}}]);