fengmap.plugin.markers.min.js
348.0 KB
/**Released Version v3.1.5,BUILD 69,Time 1706862862898. Fengmap Javascript SDK , see: https://www.fengmap.com for details**/
!function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.fengmap=n():t.fengmap=n()}(this,function(){return e=[function(U,F,t){"use strict";t.r(F);for(var t={NONE:0,EXTRUDE_MARKER:2,FM3DTILE_LAYER:4,IMAGE_MARKER:8,LOCATION_MARKER:16,POLYGON_MARKER:32,TEXT_MARKER:64,LINE_MARKER:128,LINE3D_MARKER:256,HEAT_MAP_MARKER:512,EXTENT:1024,EXTERNAL_MODEL:2048,MODEL:4096,FACILITY:8192,LABEL:16384,DYNAMIC_MODEL_MARKER:32768,DOM_MARKER:65536,SPHERE_MARKER:1<<17,EXTENT_LAYER:1<<20,EXTERNAL_MODEL_LAYER:1<<21,MODEL_LAYER:1<<22,FACILITY_LAYER:1<<23,LABEL_LAYER:1<<24,MARKER_GROUP:1<<25,FLOW_LINE_LAYER:1<<27,FLOW_LINE_MARKER:1<<27,FIRE_MARKER:1<<28,WALL_MARKER:1<<29,TUBE_MARKER:1<<30},H=(t.LAYER_NODE_TYPE=new Map,t.LAYER_NODE_TYPE.set(t.EXTENT_LAYER,t.EXTENT),t.LAYER_NODE_TYPE.set(t.EXTERNAL_MODEL_LAYER,t.EXTERNAL_MODEL),t.LAYER_NODE_TYPE.set(t.MODEL_LAYER,t.MODEL),t.LAYER_NODE_TYPE.set(t.FACILITY_LAYER,t.FACILITY),t.LAYER_NODE_TYPE.set(t.LABEL_LAYER,t.LABEL),t.LAYER_NODE_TYPE.set(t.DOM_MARKER,t.DOM_MARKER),t.LAYER_NODE_TYPE.set(t.DYNAMIC_MODEL_MARKER,t.DYNAMIC_MODEL_MARKER),t.LAYER_NODE_TYPE.set(t.EXTRUDE_MARKER,t.EXTRUDE_MARKER),t.LAYER_NODE_TYPE.set(t.HEAT_MAP_MARKER,t.HEAT_MAP_MARKER),t.LAYER_NODE_TYPE.set(t.LINE_MARKER,t.LINE_MARKER),t.LAYER_NODE_TYPE.set(t.LOCATION_MARKER,t.LOCATION_MARKER),t.LAYER_NODE_TYPE.set(t.POLYGON_MARKER,t.POLYGON_MARKER),t.LAYER_NODE_TYPE.set(t.TEXT_MARKER,t.TEXT_MARKER),t.LAYER_NODE_TYPE.set(t.IMAGE_MARKER,t.IMAGE_MARKER),t.LAYER_NODE_TYPE.set(t.FLOW_LINE_LAYER,t.FLOW_LINE_MARKER),t.LAYER_NODE_TYPE.set(t.FIRE_MARKER,t.FIRE_MARKER),t.LAYER_NODE_TYPE.set(t.WALL_MARKER,t.WALL_MARKER),t.LAYER_NODE_TYPE.set(t.TUBE_MARKER,t.TUBE_MARKER),t.LAYER_NODE_TYPE.set(t.LINE3D_MARKER,t.LINE3D_MARKER),t.LAYER_NODE_TYPE.set(t.SPHERE_MARKER,t.SPHERE_MARKER),t),r=[],j=0;j<256;j++)r[j]=(j<16?"0":"")+j.toString(16);var v={DEG2RAD:Math.PI/180,RAD2DEG:180/Math.PI,generateUUID:function(){var t=4294967295*Math.random()|0,n=4294967295*Math.random()|0,e=4294967295*Math.random()|0,i=4294967295*Math.random()|0;return(r[255&t]+r[t>>8&255]+r[t>>16&255]+r[t>>24&255]+"-"+r[255&n]+r[n>>8&255]+"-"+r[n>>16&15|64]+r[n>>24&255]+"-"+r[63&e|128]+r[e>>8&255]+"-"+r[e>>16&255]+r[e>>24&255]+r[255&i]+r[i>>8&255]+r[i>>16&255]+r[i>>24&255]).toUpperCase()},clamp:function(t,n,e){return Math.max(n,Math.min(e,t))},euclideanModulo:function(t,n){return(t%n+n)%n},mapLinear:function(t,n,e,i,r){return i+(t-n)*(r-i)/(e-n)},lerp:function(t,n,e){return(1-e)*t+e*n},smoothstep:function(t,n,e){return t<=n?0:e<=t?1:(t=(t-n)/(e-n))*t*(3-2*t)},smootherstep:function(t,n,e){return t<=n?0:e<=t?1:(t=(t-n)/(e-n))*t*t*(t*(6*t-15)+10)},randInt:function(t,n){return t+Math.floor(Math.random()*(n-t+1))},randFloat:function(t,n){return t+Math.random()*(n-t)},randFloatSpread:function(t){return t*(.5-Math.random())},degToRad:function(t){return t*v.DEG2RAD},radToDeg:function(t){return t*v.RAD2DEG},isPowerOfTwo:function(t){return 0==(t&t-1)&&0!==t},ceilPowerOfTwo:function(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))},floorPowerOfTwo:function(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))},setQuaternionFromProperEuler:function(t,n,e,i,r){var o=Math.cos,a=Math.sin,s=o(e/2),e=a(e/2),c=o((n+i)/2),h=a((n+i)/2),u=o((n-i)/2),l=a((n-i)/2),o=o((i-n)/2),a=a((i-n)/2);"XYX"===r?t.set(s*h,e*u,e*l,s*c):"YZY"===r?t.set(e*l,s*h,e*u,s*c):"ZXZ"===r?t.set(e*u,e*l,s*h,s*c):"XZX"===r?t.set(s*h,e*a,e*o,s*c):"YXY"===r?t.set(e*o,s*h,e*a,s*c):"ZYZ"===r?t.set(e*a,e*o,s*h,s*c):console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order.")}};function o(t,n,e,i){this.u=t||0,this.v=n||0,this._=e||0,this.M=void 0!==i?i:1}Object.assign(o,{slerp:function(t,n,e,i){return e.copy(t).slerp(n,i)},slerpFlat:function(t,n,e,i,r,o,a){var s,c,h,u=e[i+0],l=e[i+1],f=e[i+2],e=e[i+3],i=r[o+0],d=r[o+1],v=r[o+2],r=r[o+3];e===r&&u===i&&l===d&&f===v||(o=1-a,s=0<=(c=u*i+l*d+f*v+e*r)?1:-1,(h=1-c*c)>Number.EPSILON&&(h=Math.sqrt(h),c=Math.atan2(h,c*s),o=Math.sin(o*c)/h,a=Math.sin(a*c)/h),u=u*o+i*(c=a*s),l=l*o+d*c,f=f*o+v*c,e=e*o+r*c,o===1-a&&(u*=h=1/Math.sqrt(u*u+l*l+f*f+e*e),l*=h,f*=h,e*=h)),t[n]=u,t[n+1]=l,t[n+2]=f,t[n+3]=e}}),Object.defineProperties(o.prototype,{x:{get:function(){return this.u},set:function(t){this.u=t,this.S()}},y:{get:function(){return this.v},set:function(t){this.v=t,this.S()}},z:{get:function(){return this._},set:function(t){this._=t,this.S()}},w:{get:function(){return this.M},set:function(t){this.M=t,this.S()}}}),Object.assign(o.prototype,{isQuaternion:!0,set:function(t,n,e,i){return this.u=t,this.v=n,this._=e,this.M=i,this.S(),this},clone:function(){return new this.constructor(this.u,this.v,this._,this.M)},copy:function(t){return this.u=t.x,this.v=t.y,this._=t.z,this.M=t.w,this.S(),this},setFromEuler:function(t,n){var e,i,r,o,a,s,c;if(t&&t.isEuler)return a=t.u,s=t.v,e=t._,t=t.order,o=Math.cos,c=Math.sin,i=o(a/2),r=o(s/2),o=o(e/2),a=c(a/2),s=c(s/2),c=c(e/2),"XYZ"===t?(this.u=a*r*o+i*s*c,this.v=i*s*o-a*r*c,this._=i*r*c+a*s*o,this.M=i*r*o-a*s*c):"YXZ"===t?(this.u=a*r*o+i*s*c,this.v=i*s*o-a*r*c,this._=i*r*c-a*s*o,this.M=i*r*o+a*s*c):"ZXY"===t?(this.u=a*r*o-i*s*c,this.v=i*s*o+a*r*c,this._=i*r*c+a*s*o,this.M=i*r*o-a*s*c):"ZYX"===t?(this.u=a*r*o-i*s*c,this.v=i*s*o+a*r*c,this._=i*r*c-a*s*o,this.M=i*r*o+a*s*c):"YZX"===t?(this.u=a*r*o+i*s*c,this.v=i*s*o+a*r*c,this._=i*r*c-a*s*o,this.M=i*r*o-a*s*c):"XZY"===t&&(this.u=a*r*o-i*s*c,this.v=i*s*o-a*r*c,this._=i*r*c+a*s*o,this.M=i*r*o+a*s*c),!1!==n&&this.S(),this;throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.")},setFromAxisAngle:function(t,n){var n=n/2,e=Math.sin(n);return this.u=t.x*e,this.v=t.y*e,this._=t.z*e,this.M=Math.cos(n),this.S(),this},setFromRotationMatrix:function(t){var n,t=t.elements,e=t[0],i=t[4],r=t[8],o=t[1],a=t[5],s=t[9],c=t[2],h=t[6],t=t[10],u=e+a+t;return 0<u?(n=.5/Math.sqrt(u+1),this.M=.25/n,this.u=(h-s)*n,this.v=(r-c)*n,this._=(o-i)*n):a<e&&t<e?(n=2*Math.sqrt(1+e-a-t),this.M=(h-s)/n,this.u=.25*n,this.v=(i+o)/n,this._=(r+c)/n):t<a?(n=2*Math.sqrt(1+a-e-t),this.M=(r-c)/n,this.u=(i+o)/n,this.v=.25*n,this._=(s+h)/n):(n=2*Math.sqrt(1+t-e-a),this.M=(o-i)/n,this.u=(r+c)/n,this.v=(s+h)/n,this._=.25*n),this.S(),this},setFromUnitVectors:function(t,n){var e=t.dot(n)+1;return e<1e-6?(e=0,Math.abs(t.x)>Math.abs(t.z)?(this.u=-t.y,this.v=t.x,this._=0):(this.u=0,this.v=-t.z,this._=t.y)):(this.u=t.y*n.z-t.z*n.y,this.v=t.z*n.x-t.x*n.z,this._=t.x*n.y-t.y*n.x),this.M=e,this.normalize()},angleTo:function(t){return 2*Math.acos(Math.abs(v.clamp(this.dot(t),-1,1)))},rotateTowards:function(t,n){var e=this.angleTo(t);return 0!==e&&(n=Math.min(1,n/e),this.slerp(t,n)),this},inverse:function(){return this.conjugate()},conjugate:function(){return this.u*=-1,this.v*=-1,this._*=-1,this.S(),this},dot:function(t){return this.u*t.u+this.v*t.v+this._*t._+this.M*t.M},lengthSq:function(){return this.u*this.u+this.v*this.v+this._*this._+this.M*this.M},length:function(){return Math.sqrt(this.u*this.u+this.v*this.v+this._*this._+this.M*this.M)},normalize:function(){var t=this.length();return 0===t?(this.u=0,this.v=0,this._=0,this.M=1):(this.u=this.u*(t=1/t),this.v=this.v*t,this._=this._*t,this.M=this.M*t),this.S(),this},multiply:function(t,n){return void 0!==n?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(t,n)):this.multiplyQuaternions(this,t)},premultiply:function(t){return this.multiplyQuaternions(t,this)},multiplyQuaternions:function(t,n){var e=t.u,i=t.v,r=t._,t=t.M,o=n.u,a=n.v,s=n._,n=n.M;return this.u=e*n+t*o+i*s-r*a,this.v=i*n+t*a+r*o-e*s,this._=r*n+t*s+e*a-i*o,this.M=t*n-e*o-i*a-r*s,this.S(),this},slerp:function(t,n){if(0!==n){if(1===n)return this.copy(t);var e,i=this.u,r=this.v,o=this._,a=this.M,s=a*t.M+i*t.u+r*t.v+o*t._;s<0?(this.M=-t.M,this.u=-t.u,this.v=-t.v,this._=-t._,s=-s):this.copy(t),1<=s?(this.M=a,this.u=i,this.v=r,this._=o):((t=1-s*s)<=Number.EPSILON?(this.M=(e=1-n)*a+n*this.M,this.u=e*i+n*this.u,this.v=e*r+n*this.v,this._=e*o+n*this._,this.normalize()):(e=Math.sqrt(t),t=Math.atan2(e,s),s=Math.sin((1-n)*t)/e,n=Math.sin(n*t)/e,this.M=a*s+this.M*n,this.u=i*s+this.u*n,this.v=r*s+this.v*n,this._=o*s+this._*n),this.S())}return this},equals:function(t){return t.u===this.u&&t.v===this.v&&t._===this._&&t.M===this.M},fromArray:function(t,n){return this.u=t[n=void 0===n?0:n],this.v=t[n+1],this._=t[n+2],this.M=t[n+3],this.S(),this},toArray:function(t,n){return(t=void 0===t?[]:t)[n=void 0===n?0:n]=this.u,t[n+1]=this.v,t[n+2]=this._,t[n+3]=this.M,t},fromBufferAttribute:function(t,n){return this.u=t.getX(n),this.v=t.getY(n),this._=t.getZ(n),this.M=t.getW(n),this},L:function(t){return this.S=t,this},S:function(){}});var k=new E,G=new o;function E(t,n,e){this.x=t||0,this.y=n||0,this.z=e||0}function O(t,n){this.x=t||0,this.y=n||0}Object.assign(E.prototype,{isVector3:!0,set:function(t,n,e){return this.x=t,this.y=n,this.z=e,this},setScalar:function(t){return this.x=t,this.y=t,this.z=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setZ:function(t){return this.z=t,this},setComponent:function(t,n){switch(t){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y,this.z)},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},add:function(t,n){return void 0!==n?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,n)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this)},addScalar:function(t){return this.x+=t,this.y+=t,this.z+=t,this},addVectors:function(t,n){return this.x=t.x+n.x,this.y=t.y+n.y,this.z=t.z+n.z,this},addScaledVector:function(t,n){return this.x+=t.x*n,this.y+=t.y*n,this.z+=t.z*n,this},sub:function(t,n){return void 0!==n?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,n)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this)},subScalar:function(t){return this.x-=t,this.y-=t,this.z-=t,this},subVectors:function(t,n){return this.x=t.x-n.x,this.y=t.y-n.y,this.z=t.z-n.z,this},multiply:function(t,n){return void 0!==n?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(t,n)):(this.x*=t.x,this.y*=t.y,this.z*=t.z,this)},multiplyScalar:function(t){return this.x*=t,this.y*=t,this.z*=t,this},multiplyVectors:function(t,n){return this.x=t.x*n.x,this.y=t.y*n.y,this.z=t.z*n.z,this},applyEuler:function(t){return t&&t.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(G.setFromEuler(t))},applyAxisAngle:function(t,n){return this.applyQuaternion(G.setFromAxisAngle(t,n))},applyMatrix3:function(t){var n=this.x,e=this.y,i=this.z,t=t.elements;return this.x=t[0]*n+t[3]*e+t[6]*i,this.y=t[1]*n+t[4]*e+t[7]*i,this.z=t[2]*n+t[5]*e+t[8]*i,this},applyNormalMatrix:function(t){return this.applyMatrix3(t).normalize()},applyMatrix4:function(t){var n=this.x,e=this.y,i=this.z,t=t.elements,r=1/(t[3]*n+t[7]*e+t[11]*i+t[15]);return this.x=(t[0]*n+t[4]*e+t[8]*i+t[12])*r,this.y=(t[1]*n+t[5]*e+t[9]*i+t[13])*r,this.z=(t[2]*n+t[6]*e+t[10]*i+t[14])*r,this},applyQuaternion:function(t){var n=this.x,e=this.y,i=this.z,r=t.x,o=t.y,a=t.z,t=t.w,s=t*n+o*i-a*e,c=t*e+a*n-r*i,h=t*i+r*e-o*n,n=-r*n-o*e-a*i;return this.x=s*t+n*-r+c*-a-h*-o,this.y=c*t+n*-o+h*-r-s*-a,this.z=h*t+n*-a+s*-o-c*-r,this},project:function(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)},unproject:function(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)},transformDirection:function(t){var n=this.x,e=this.y,i=this.z,t=t.elements;return this.x=t[0]*n+t[4]*e+t[8]*i,this.y=t[1]*n+t[5]*e+t[9]*i,this.z=t[2]*n+t[6]*e+t[10]*i,this.normalize()},divide:function(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this},divideScalar:function(t){return this.multiplyScalar(1/t)},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this},clamp:function(t,n){return this.x=Math.max(t.x,Math.min(n.x,this.x)),this.y=Math.max(t.y,Math.min(n.y,this.y)),this.z=Math.max(t.z,Math.min(n.z,this.z)),this},clampScalar:function(t,n){return this.x=Math.max(t,Math.min(n,this.x)),this.y=Math.max(t,Math.min(n,this.y)),this.z=Math.max(t,Math.min(n,this.z)),this},clampLength:function(t,n){var e=this.length();return this.divideScalar(e||1).multiplyScalar(Math.max(t,Math.min(n,e)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length()||1)},setLength:function(t){return this.normalize().multiplyScalar(t)},lerp:function(t,n){return this.x+=(t.x-this.x)*n,this.y+=(t.y-this.y)*n,this.z+=(t.z-this.z)*n,this},lerpVectors:function(t,n,e){return this.subVectors(n,t).multiplyScalar(e).add(t)},cross:function(t,n){return void 0!==n?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(t,n)):this.crossVectors(this,t)},crossVectors:function(t,n){var e=t.x,i=t.y,t=t.z,r=n.x,o=n.y,n=n.z;return this.x=i*n-t*o,this.y=t*r-e*n,this.z=e*o-i*r,this},projectOnVector:function(t){var n=t.lengthSq();return 0===n?this.set(0,0,0):(n=t.dot(this)/n,this.copy(t).multiplyScalar(n))},projectOnPlane:function(t){return k.copy(this).projectOnVector(t),this.sub(k)},reflect:function(t){return this.sub(k.copy(t).multiplyScalar(2*this.dot(t)))},angleTo:function(t){var n=Math.sqrt(this.lengthSq()*t.lengthSq());return 0===n?Math.PI/2:(t=this.dot(t)/n,Math.acos(v.clamp(t,-1,1)))},distanceTo:function(t){return Math.sqrt(this.distanceToSquared(t))},distanceToSquared:function(t){var n=this.x-t.x,e=this.y-t.y,t=this.z-t.z;return n*n+e*e+t*t},manhattanDistanceTo:function(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)},setFromSpherical:function(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)},setFromSphericalCoords:function(t,n,e){var i=Math.sin(n)*t;return this.x=i*Math.sin(e),this.y=Math.cos(n)*t,this.z=i*Math.cos(e),this},setFromCylindrical:function(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)},setFromCylindricalCoords:function(t,n,e){return this.x=t*Math.sin(n),this.y=e,this.z=t*Math.cos(n),this},setFromMatrixPosition:function(t){t=t.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this},setFromMatrixScale:function(t){var n=this.setFromMatrixColumn(t,0).length(),e=this.setFromMatrixColumn(t,1).length(),t=this.setFromMatrixColumn(t,2).length();return this.x=n,this.y=e,this.z=t,this},setFromMatrixColumn:function(t,n){return this.fromArray(t.elements,4*n)},setFromMatrix3Column:function(t,n){return this.fromArray(t.elements,3*n)},equals:function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z},fromArray:function(t,n){return this.x=t[n=void 0===n?0:n],this.y=t[n+1],this.z=t[n+2],this},toArray:function(t,n){return(t=void 0===t?[]:t)[n=void 0===n?0:n]=this.x,t[n+1]=this.y,t[n+2]=this.z,t},fromBufferAttribute:function(t,n,e){return void 0!==e&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(n),this.y=t.getY(n),this.z=t.getZ(n),this}}),Object.defineProperties(O.prototype,{width:{get:function(){return this.x},set:function(t){this.x=t}},height:{get:function(){return this.y},set:function(t){this.y=t}}}),Object.assign(O.prototype,{isVector2:!0,set:function(t,n){return this.x=t,this.y=n,this},setScalar:function(t){return this.x=t,this.y=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setComponent:function(t,n){switch(t){case 0:this.x=n;break;case 1:this.y=n;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(t){return this.x=t.x,this.y=t.y,this},add:function(t,n){return void 0!==n?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,n)):(this.x+=t.x,this.y+=t.y,this)},addScalar:function(t){return this.x+=t,this.y+=t,this},addVectors:function(t,n){return this.x=t.x+n.x,this.y=t.y+n.y,this},addScaledVector:function(t,n){return this.x+=t.x*n,this.y+=t.y*n,this},sub:function(t,n){return void 0!==n?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,n)):(this.x-=t.x,this.y-=t.y,this)},subScalar:function(t){return this.x-=t,this.y-=t,this},subVectors:function(t,n){return this.x=t.x-n.x,this.y=t.y-n.y,this},multiply:function(t){return this.x*=t.x,this.y*=t.y,this},multiplyScalar:function(t){return this.x*=t,this.y*=t,this},divide:function(t){return this.x/=t.x,this.y/=t.y,this},divideScalar:function(t){return this.multiplyScalar(1/t)},applyMatrix3:function(t){var n=this.x,e=this.y,t=t.elements;return this.x=t[0]*n+t[3]*e+t[6],this.y=t[1]*n+t[4]*e+t[7],this},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this},clamp:function(t,n){return this.x=Math.max(t.x,Math.min(n.x,this.x)),this.y=Math.max(t.y,Math.min(n.y,this.y)),this},clampScalar:function(t,n){return this.x=Math.max(t,Math.min(n,this.x)),this.y=Math.max(t,Math.min(n,this.y)),this},clampLength:function(t,n){var e=this.length();return this.divideScalar(e||1).multiplyScalar(Math.max(t,Math.min(n,e)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this},negate:function(){return this.x=-this.x,this.y=-this.y,this},dot:function(t){return this.x*t.x+this.y*t.y},cross:function(t){return this.x*t.y-this.y*t.x},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)},normalize:function(){return this.divideScalar(this.length()||1)},angle:function(){return Math.atan2(-this.y,-this.x)+Math.PI},distanceTo:function(t){return Math.sqrt(this.distanceToSquared(t))},distanceToSquared:function(t){var n=this.x-t.x,t=this.y-t.y;return n*n+t*t},manhattanDistanceTo:function(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)},setLength:function(t){return this.normalize().multiplyScalar(t)},lerp:function(t,n){return this.x+=(t.x-this.x)*n,this.y+=(t.y-this.y)*n,this},lerpVectors:function(t,n,e){return this.subVectors(n,t).multiplyScalar(e).add(t)},equals:function(t){return t.x===this.x&&t.y===this.y},fromArray:function(t,n){return this.x=t[n=void 0===n?0:n],this.y=t[n+1],this},toArray:function(t,n){return(t=void 0===t?[]:t)[n=void 0===n?0:n]=this.x,t[n+1]=this.y,t},fromBufferAttribute:function(t,n,e){return void 0!==e&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(n),this.y=t.getY(n),this},rotateAround:function(t,n){var e=Math.cos(n),n=Math.sin(n),i=this.x-t.x,r=this.y-t.y;return this.x=i*e-r*n+t.x,this.y=i*n+r*e+t.y,this}});var n=[new E,new E,new E,new E,new E,new E,new E,new E],z=new E,B=new tt,V=new E,W=new E,X=new E,Y=new E,Z=new E,q=new E,K=new E,Q=new E,J=new E,$=new E;function tt(t,n){this.min=void 0!==t?t:new E(1/0,1/0,1/0),this.max=void 0!==n?n:new E(-1/0,-1/0,-1/0)}function nt(t,n,e,i,r){for(var o=0,a=t.length-3;o<=a;o+=3){$.fromArray(t,o);var s=r.x*Math.abs($.x)+r.y*Math.abs($.y)+r.z*Math.abs($.z),c=n.dot($),h=e.dot($),u=i.dot($);if(Math.max(-Math.max(c,h,u),Math.min(c,h,u))>s)return!1}return!0}Object.assign(tt.prototype,{isBox3:!0,set:function(t,n){return this.min.copy(t),this.max.copy(n),this},setFromArray:function(t){for(var n=1/0,e=1/0,i=1/0,r=-1/0,o=-1/0,a=-1/0,s=0,c=t.length;s<c;s+=3){var h=t[s],u=t[s+1],l=t[s+2];h<n&&(n=h),u<e&&(e=u),l<i&&(i=l),r<h&&(r=h),o<u&&(o=u),a<l&&(a=l)}return this.min.set(n,e,i),this.max.set(r,o,a),this},setFromBufferAttribute:function(t){for(var n=1/0,e=1/0,i=1/0,r=-1/0,o=-1/0,a=-1/0,s=0,c=t.count;s<c;s++){var h=t.getX(s),u=t.getY(s),l=t.getZ(s);h<n&&(n=h),u<e&&(e=u),l<i&&(i=l),r<h&&(r=h),o<u&&(o=u),a<l&&(a=l)}return this.min.set(n,e,i),this.max.set(r,o,a),this},setFromPoints:function(t){this.makeEmpty();for(var n=0,e=t.length;n<e;n++)this.expandByPoint(t[n]);return this},setFromCenterAndSize:function(t,n){n=z.copy(n).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this},setFromObject:function(t){return this.makeEmpty(),this.expandByObject(t)},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.min.copy(t.min),this.max.copy(t.max),this},makeEmpty:function(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this},isEmpty:function(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z},getCenter:function(t){return void 0===t&&(console.warn("THREE.Box3: .getCenter() target is now required"),t=new E),this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)},getSize:function(t){return void 0===t&&(console.warn("THREE.Box3: .getSize() target is now required"),t=new E),this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)},expandByPoint:function(t){return this.min.min(t),this.max.max(t),this},expandByVector:function(t){return this.min.sub(t),this.max.add(t),this},expandByScalar:function(t){return this.min.addScalar(-t),this.max.addScalar(t),this},expandByObject:function(t){t.updateWorldMatrix(!1,!1);for(var n=t.geometry,e=(void 0!==n&&(null===n.boundingBox&&n.computeBoundingBox(),B.copy(n.boundingBox),B.applyMatrix4(t.matrixWorld),this.union(B)),t.children),i=0,r=e.length;i<r;i++)this.expandByObject(e[i]);return this},containsPoint:function(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y||t.z<this.min.z||t.z>this.max.z)},containsBox:function(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z},getParameter:function(t,n){return void 0===n&&(console.warn("THREE.Box3: .getParameter() target is now required"),n=new E),n.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))},intersectsBox:function(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y||t.max.z<this.min.z||t.min.z>this.max.z)},intersectsSphere:function(t){return this.clampPoint(t.center,z),z.distanceToSquared(t.center)<=t.radius*t.radius},intersectsPlane:function(t){var n,e=0<t.normal.x?(n=t.normal.x*this.min.x,t.normal.x*this.max.x):(n=t.normal.x*this.max.x,t.normal.x*this.min.x);return 0<t.normal.y?(n+=t.normal.y*this.min.y,e+=t.normal.y*this.max.y):(n+=t.normal.y*this.max.y,e+=t.normal.y*this.min.y),0<t.normal.z?(n+=t.normal.z*this.min.z,e+=t.normal.z*this.max.z):(n+=t.normal.z*this.max.z,e+=t.normal.z*this.min.z),n<=-t.constant&&e>=-t.constant},intersectsTriangle:function(t){return!this.isEmpty()&&(this.getCenter(K),Q.subVectors(this.max,K),V.subVectors(t.a,K),W.subVectors(t.b,K),X.subVectors(t.c,K),Y.subVectors(W,V),Z.subVectors(X,W),q.subVectors(V,X),!!nt([0,-Y.z,Y.y,0,-Z.z,Z.y,0,-q.z,q.y,Y.z,0,-Y.x,Z.z,0,-Z.x,q.z,0,-q.x,-Y.y,Y.x,0,-Z.y,Z.x,0,-q.y,q.x,0],V,W,X,Q))&&!!nt([1,0,0,0,1,0,0,0,1],V,W,X,Q)&&(J.crossVectors(Y,Z),nt([J.x,J.y,J.z],V,W,X,Q))},clampPoint:function(t,n){return void 0===n&&(console.warn("THREE.Box3: .clampPoint() target is now required"),n=new E),n.copy(t).clamp(this.min,this.max)},distanceToPoint:function(t){return z.copy(t).clamp(this.min,this.max).sub(t).length()},getBoundingSphere:function(t){return void 0===t&&console.error("THREE.Box3: .getBoundingSphere() target is now required"),this.getCenter(t.center),t.radius=.5*this.getSize(z).length(),t},intersect:function(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this},union:function(t){return this.min.min(t.min),this.max.max(t.max),this},applyMatrix4:function(t){return this.isEmpty()||(n[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),n[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),n[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),n[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),n[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),n[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),n[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),n[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(n)),this},translate:function(t){return this.min.add(t),this.max.add(t),this},equals:function(t){return t.min.equals(this.min)&&t.max.equals(this.max)}});var et=new tt;function it(t,n){this.center=void 0!==t?t:new E,this.radius=void 0!==n?n:0}Object.assign(it.prototype,{set:function(t,n){return this.center.copy(t),this.radius=n,this},setFromPoints:function(t,n){for(var e=this.center,i=(void 0!==n?e.copy(n):et.setFromPoints(t).getCenter(e),0),r=0,o=t.length;r<o;r++)i=Math.max(i,e.distanceToSquared(t[r]));return this.radius=Math.sqrt(i),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.center.copy(t.center),this.radius=t.radius,this},empty:function(){return this.radius<=0},containsPoint:function(t){return t.distanceToSquared(this.center)<=this.radius*this.radius},distanceToPoint:function(t){return t.distanceTo(this.center)-this.radius},intersectsSphere:function(t){var n=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=n*n},intersectsBox:function(t){return t.intersectsSphere(this)},intersectsPlane:function(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius},clampPoint:function(t,n){var e=this.center.distanceToSquared(t);return void 0===n&&(console.warn("THREE.Sphere: .clampPoint() target is now required"),n=new E),n.copy(t),e>this.radius*this.radius&&(n.sub(this.center).normalize(),n.multiplyScalar(this.radius).add(this.center)),n},getBoundingBox:function(t){return void 0===t&&(console.warn("THREE.Sphere: .getBoundingBox() target is now required"),t=new tt),t.set(this.center,this.center),t.expandByScalar(this.radius),t},applyMatrix4:function(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this},translate:function(t){return this.center.add(t),this},equals:function(t){return t.center.equals(this.center)&&t.radius===this.radius}});var a=new E,rt=new E,ot=new E,at=new E,st=new E,ct=new E,ht=new E;function ut(t,n){this.origin=void 0!==t?t:new E,this.direction=void 0!==n?n:new E(0,0,-1)}Object.assign(ut.prototype,{set:function(t,n){return this.origin.copy(t),this.direction.copy(n),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this},at:function(t,n){return void 0===n&&(console.warn("THREE.Ray: .at() target is now required"),n=new E),n.copy(this.direction).multiplyScalar(t).add(this.origin)},lookAt:function(t){return this.direction.copy(t).sub(this.origin).normalize(),this},recast:function(t){return this.origin.copy(this.at(t,a)),this},closestPointToPoint:function(t,n){void 0===n&&(console.warn("THREE.Ray: .closestPointToPoint() target is now required"),n=new E),n.subVectors(t,this.origin);t=n.dot(this.direction);return t<0?n.copy(this.origin):n.copy(this.direction).multiplyScalar(t).add(this.origin)},distanceToPoint:function(t){return Math.sqrt(this.distanceSqToPoint(t))},distanceSqToPoint:function(t){var n=a.subVectors(t,this.origin).dot(this.direction);return(n<0?this.origin:(a.copy(this.direction).multiplyScalar(n).add(this.origin),a)).distanceToSquared(t)},distanceSqToSegment:function(t,n,e,i){rt.copy(t).add(n).multiplyScalar(.5),ot.copy(n).sub(t).normalize(),at.copy(this.origin).sub(rt);var r,o,a,t=.5*t.distanceTo(n),n=-this.direction.dot(ot),s=at.dot(this.direction),c=-at.dot(ot),h=at.lengthSq(),u=Math.abs(1-n*n);return u=0<u?(o=n*s-c,a=t*u,0<=(r=n*c-s)?-a<=o?o<=a?(r*=u=1/u)*(r+n*(o*=u)+2*s)+o*(n*r+o+2*c)+h:(o=t,-(r=Math.max(0,-(n*o+s)))*r+o*(o+2*c)+h):(o=-t,-(r=Math.max(0,-(n*o+s)))*r+o*(o+2*c)+h):o<=-a?-(r=Math.max(0,-(-n*t+s)))*r+(o=0<r?-t:Math.min(Math.max(-t,-c),t))*(o+2*c)+h:o<=a?(r=0,(o=Math.min(Math.max(-t,-c),t))*(o+2*c)+h):-(r=Math.max(0,-(n*t+s)))*r+(o=0<r?t:Math.min(Math.max(-t,-c),t))*(o+2*c)+h):(o=0<n?-t:t,-(r=Math.max(0,-(n*o+s)))*r+o*(o+2*c)+h),e&&e.copy(this.direction).multiplyScalar(r).add(this.origin),i&&i.copy(ot).multiplyScalar(o).add(rt),u},intersectSphere:function(t,n){a.subVectors(t.center,this.origin);var e=a.dot(this.direction),i=a.dot(a)-e*e,t=t.radius*t.radius;return t<i||(i=e+(t=Math.sqrt(t-i)),(e=e-t)<0&&i<0)?null:e<0?this.at(i,n):this.at(e,n)},intersectsSphere:function(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius},distanceToPlane:function(t){var n=t.normal.dot(this.direction);return 0===n?0===t.distanceToPoint(this.origin)?0:null:0<=(t=-(this.origin.dot(t.normal)+t.constant)/n)?t:null},intersectPlane:function(t,n){t=this.distanceToPlane(t);return null===t?null:this.at(t,n)},intersectsPlane:function(t){var n=t.distanceToPoint(this.origin);return 0===n||t.normal.dot(this.direction)*n<0},intersectBox:function(t,n){var e,i,r,o=1/this.direction.x,a=1/this.direction.y,s=1/this.direction.z,c=this.origin,o=0<=o?(e=(t.min.x-c.x)*o,(t.max.x-c.x)*o):(e=(t.max.x-c.x)*o,(t.min.x-c.x)*o),a=0<=a?(r=(t.min.y-c.y)*a,(t.max.y-c.y)*a):(r=(t.max.y-c.y)*a,(t.min.y-c.y)*a);return a<e||o<r||((e<r||e!=e)&&(e=r),(a<o||o!=o)&&(o=a),(r=0<=s?(i=(t.min.z-c.z)*s,(t.max.z-c.z)*s):(i=(t.max.z-c.z)*s,(t.min.z-c.z)*s))<e)||o<i||((e<i||e!=e)&&(e=i),(o=r<o||o!=o?r:o)<0)?null:this.at(0<=e?e:o,n)},intersectsBox:function(t){return null!==this.intersectBox(t,a)},intersectTriangle:function(t,n,e,i,r){st.subVectors(n,t),ct.subVectors(e,t),ht.crossVectors(st,ct);var o,n=this.direction.dot(ht);if(0<n){if(i)return null;o=1}else{if(!(n<0))return null;o=-1,n=-n}at.subVectors(this.origin,t);e=o*this.direction.dot(ct.crossVectors(at,ct));return e<0||(i=o*this.direction.dot(st.cross(at)))<0||n<e+i||(t=-o*at.dot(ht))<0?null:this.at(t/n,r)},applyMatrix4:function(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this},equals:function(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}});var lt=new E,c=new _,ft=new E(0,0,0),dt=new E(1,1,1),vt=new E,pt=new E,s=new E;function _(){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0<arguments.length&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}function mt(){}Object.assign(_.prototype,{isMatrix4:!0,set:function(t,n,e,i,r,o,a,s,c,h,u,l,f,d,v,p){var m=this.elements;return m[0]=t,m[4]=n,m[8]=e,m[12]=i,m[1]=r,m[5]=o,m[9]=a,m[13]=s,m[2]=c,m[6]=h,m[10]=u,m[14]=l,m[3]=f,m[7]=d,m[11]=v,m[15]=p,this},identity:function(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this},clone:function(){return(new _).fromArray(this.elements)},copy:function(t){var n=this.elements,t=t.elements;return n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[3],n[4]=t[4],n[5]=t[5],n[6]=t[6],n[7]=t[7],n[8]=t[8],n[9]=t[9],n[10]=t[10],n[11]=t[11],n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15],this},copyPosition:function(t){var n=this.elements,t=t.elements;return n[12]=t[12],n[13]=t[13],n[14]=t[14],this},extractBasis:function(t,n,e){return t.setFromMatrixColumn(this,0),n.setFromMatrixColumn(this,1),e.setFromMatrixColumn(this,2),this},makeBasis:function(t,n,e){return this.set(t.x,n.x,e.x,0,t.y,n.y,e.y,0,t.z,n.z,e.z,0,0,0,0,1),this},extractRotation:function(t){var n=this.elements,e=t.elements,i=1/lt.setFromMatrixColumn(t,0).length(),r=1/lt.setFromMatrixColumn(t,1).length(),t=1/lt.setFromMatrixColumn(t,2).length();return n[0]=e[0]*i,n[1]=e[1]*i,n[2]=e[2]*i,n[3]=0,n[4]=e[4]*r,n[5]=e[5]*r,n[6]=e[6]*r,n[7]=0,n[8]=e[8]*t,n[9]=e[9]*t,n[10]=e[10]*t,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this},makeRotationFromEuler:function(t){t&&t.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");var n,e,i,r,o,a,s,c,h,u,l,f,d=this.elements,v=t.x,p=t.y,m=t.z,g=Math.cos(v),v=Math.sin(v),_=Math.cos(p),p=Math.sin(p),b=Math.cos(m),m=Math.sin(m);return"XYZ"===t.order?(o=g*b,a=g*m,s=v*b,c=v*m,d[0]=_*b,d[4]=-_*m,d[8]=p,d[1]=a+s*p,d[5]=o-c*p,d[9]=-v*_,d[2]=c-o*p,d[6]=s+a*p,d[10]=g*_):"YXZ"===t.order?(e=_*m,i=p*b,d[0]=(n=_*b)+(r=p*m)*v,d[4]=i*v-e,d[8]=g*p,d[1]=g*m,d[5]=g*b,d[9]=-v,d[2]=e*v-i,d[6]=r+n*v,d[10]=g*_):"ZXY"===t.order?(e=_*m,i=p*b,d[0]=(n=_*b)-(r=p*m)*v,d[4]=-g*m,d[8]=i+e*v,d[1]=e+i*v,d[5]=g*b,d[9]=r-n*v,d[2]=-g*p,d[6]=v,d[10]=g*_):"ZYX"===t.order?(o=g*b,a=g*m,s=v*b,c=v*m,d[0]=_*b,d[4]=s*p-a,d[8]=o*p+c,d[1]=_*m,d[5]=c*p+o,d[9]=a*p-s,d[2]=-p,d[6]=v*_,d[10]=g*_):"YZX"===t.order?(h=g*_,u=g*p,l=v*_,f=v*p,d[0]=_*b,d[4]=f-h*m,d[8]=l*m+u,d[1]=m,d[5]=g*b,d[9]=-v*b,d[2]=-p*b,d[6]=u*m+l,d[10]=h-f*m):"XZY"===t.order&&(h=g*_,u=g*p,l=v*_,f=v*p,d[0]=_*b,d[4]=-m,d[8]=p*b,d[1]=h*m+f,d[5]=g*b,d[9]=u*m-l,d[2]=l*m-u,d[6]=v*b,d[10]=f*m+h),d[3]=0,d[7]=0,d[11]=0,d[12]=0,d[13]=0,d[14]=0,d[15]=1,this},makeRotationFromQuaternion:function(t){return this.compose(ft,t,dt)},lookAt:function(t,n,e){var i=this.elements;return s.subVectors(t,n),0===s.lengthSq()&&(s.z=1),s.normalize(),vt.crossVectors(e,s),0===vt.lengthSq()&&(1===Math.abs(e.z)?s.x+=1e-4:s.z+=1e-4,s.normalize(),vt.crossVectors(e,s)),vt.normalize(),pt.crossVectors(s,vt),i[0]=vt.x,i[4]=pt.x,i[8]=s.x,i[1]=vt.y,i[5]=pt.y,i[9]=s.y,i[2]=vt.z,i[6]=pt.z,i[10]=s.z,this},multiply:function(t,n){return void 0!==n?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(t,n)):this.multiplyMatrices(this,t)},premultiply:function(t){return this.multiplyMatrices(t,this)},multiplyMatrices:function(t,n){var t=t.elements,n=n.elements,e=this.elements,i=t[0],r=t[4],o=t[8],a=t[12],s=t[1],c=t[5],h=t[9],u=t[13],l=t[2],f=t[6],d=t[10],v=t[14],p=t[3],m=t[7],g=t[11],t=t[15],_=n[0],b=n[4],y=n[8],w=n[12],x=n[1],M=n[5],S=n[9],L=n[13],E=n[2],T=n[6],C=n[10],D=n[14],P=n[3],A=n[7],R=n[11],n=n[15];return e[0]=i*_+r*x+o*E+a*P,e[4]=i*b+r*M+o*T+a*A,e[8]=i*y+r*S+o*C+a*R,e[12]=i*w+r*L+o*D+a*n,e[1]=s*_+c*x+h*E+u*P,e[5]=s*b+c*M+h*T+u*A,e[9]=s*y+c*S+h*C+u*R,e[13]=s*w+c*L+h*D+u*n,e[2]=l*_+f*x+d*E+v*P,e[6]=l*b+f*M+d*T+v*A,e[10]=l*y+f*S+d*C+v*R,e[14]=l*w+f*L+d*D+v*n,e[3]=p*_+m*x+g*E+t*P,e[7]=p*b+m*M+g*T+t*A,e[11]=p*y+m*S+g*C+t*R,e[15]=p*w+m*L+g*D+t*n,this},multiplyScalar:function(t){var n=this.elements;return n[0]*=t,n[4]*=t,n[8]*=t,n[12]*=t,n[1]*=t,n[5]*=t,n[9]*=t,n[13]*=t,n[2]*=t,n[6]*=t,n[10]*=t,n[14]*=t,n[3]*=t,n[7]*=t,n[11]*=t,n[15]*=t,this},determinant:function(){var t=this.elements,n=t[0],e=t[4],i=t[8],r=t[12],o=t[1],a=t[5],s=t[9],c=t[13],h=t[2],u=t[6],l=t[10],f=t[14];return t[3]*(+r*s*u-i*c*u-r*a*l+e*c*l+i*a*f-e*s*f)+t[7]*(+n*s*f-n*c*l+r*o*l-i*o*f+i*c*h-r*s*h)+t[11]*(+n*c*u-n*a*f-r*o*u+e*o*f+r*a*h-e*c*h)+t[15]*(-i*a*h-n*s*u+n*a*l+i*o*u-e*o*l+e*s*h)},transpose:function(){var t=this.elements,n=t[1];return t[1]=t[4],t[4]=n,n=t[2],t[2]=t[8],t[8]=n,n=t[6],t[6]=t[9],t[9]=n,n=t[3],t[3]=t[12],t[12]=n,n=t[7],t[7]=t[13],t[13]=n,n=t[11],t[11]=t[14],t[14]=n,this},setPosition:function(t,n,e){var i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=n,i[14]=e),this},getInverse:function(t,n){void 0!==n&&console.warn("THREE.Matrix4: .getInverse() can no longer be configured to throw on degenerate.");var n=this.elements,t=t.elements,e=t[0],i=t[1],r=t[2],o=t[3],a=t[4],s=t[5],c=t[6],h=t[7],u=t[8],l=t[9],f=t[10],d=t[11],v=t[12],p=t[13],m=t[14],t=t[15],g=l*m*h-p*f*h+p*c*d-s*m*d-l*c*t+s*f*t,_=v*f*h-u*m*h-v*c*d+a*m*d+u*c*t-a*f*t,b=u*p*h-v*l*h+v*s*d-a*p*d-u*s*t+a*l*t,y=v*l*c-u*p*c-v*s*f+a*p*f+u*s*m-a*l*m,w=e*g+i*_+r*b+o*y;return 0==w?this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0):(n[0]=g*(g=1/w),n[1]=(p*f*o-l*m*o-p*r*d+i*m*d+l*r*t-i*f*t)*g,n[2]=(s*m*o-p*c*o+p*r*h-i*m*h-s*r*t+i*c*t)*g,n[3]=(l*c*o-s*f*o-l*r*h+i*f*h+s*r*d-i*c*d)*g,n[4]=_*g,n[5]=(u*m*o-v*f*o+v*r*d-e*m*d-u*r*t+e*f*t)*g,n[6]=(v*c*o-a*m*o-v*r*h+e*m*h+a*r*t-e*c*t)*g,n[7]=(a*f*o-u*c*o+u*r*h-e*f*h-a*r*d+e*c*d)*g,n[8]=b*g,n[9]=(v*l*o-u*p*o-v*i*d+e*p*d+u*i*t-e*l*t)*g,n[10]=(a*p*o-v*s*o+v*i*h-e*p*h-a*i*t+e*s*t)*g,n[11]=(u*s*o-a*l*o-u*i*h+e*l*h+a*i*d-e*s*d)*g,n[12]=y*g,n[13]=(u*p*r-v*l*r+v*i*f-e*p*f-u*i*m+e*l*m)*g,n[14]=(v*s*r-a*p*r-v*i*c+e*p*c+a*i*m-e*s*m)*g,n[15]=(a*l*r-u*s*r+u*i*c-e*l*c-a*i*f+e*s*f)*g,this)},invert:function(){var t=this.elements,n=t[0],e=t[1],i=t[2],r=t[3],o=t[4],a=t[5],s=t[6],c=t[7],h=t[8],u=t[9],l=t[10],f=t[11],d=t[12],v=t[13],p=t[14],m=t[15],g=u*p*c-v*l*c+v*s*f-a*p*f-u*s*m+a*l*m,_=d*l*c-h*p*c-d*s*f+o*p*f+h*s*m-o*l*m,b=h*v*c-d*u*c+d*a*f-o*v*f-h*a*m+o*u*m,y=d*u*s-h*v*s-d*a*l+o*v*l+h*a*p-o*u*p,w=n*g+e*_+i*b+r*y;return 0==w?this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0):(t[0]=g*(g=1/w),t[1]=(v*l*r-u*p*r-v*i*f+e*p*f+u*i*m-e*l*m)*g,t[2]=(a*p*r-v*s*r+v*i*c-e*p*c-a*i*m+e*s*m)*g,t[3]=(u*s*r-a*l*r-u*i*c+e*l*c+a*i*f-e*s*f)*g,t[4]=_*g,t[5]=(h*p*r-d*l*r+d*i*f-n*p*f-h*i*m+n*l*m)*g,t[6]=(d*s*r-o*p*r-d*i*c+n*p*c+o*i*m-n*s*m)*g,t[7]=(o*l*r-h*s*r+h*i*c-n*l*c-o*i*f+n*s*f)*g,t[8]=b*g,t[9]=(d*u*r-h*v*r-d*e*f+n*v*f+h*e*m-n*u*m)*g,t[10]=(o*v*r-d*a*r+d*e*c-n*v*c-o*e*m+n*a*m)*g,t[11]=(h*a*r-o*u*r-h*e*c+n*u*c+o*e*f-n*a*f)*g,t[12]=y*g,t[13]=(h*v*i-d*u*i+d*e*l-n*v*l-h*e*p+n*u*p)*g,t[14]=(d*a*i-o*v*i-d*e*s+n*v*s+o*e*p-n*a*p)*g,t[15]=(o*u*i-h*a*i+h*e*s-n*u*s-o*e*l+n*a*l)*g,this)},scale:function(t){var n=this.elements,e=t.x,i=t.y,t=t.z;return n[0]*=e,n[4]*=i,n[8]*=t,n[1]*=e,n[5]*=i,n[9]*=t,n[2]*=e,n[6]*=i,n[10]*=t,n[3]*=e,n[7]*=i,n[11]*=t,this},getMaxScaleOnAxis:function(){var t=this.elements,n=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],e=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],t=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(n,e,t))},makeTranslation:function(t,n,e){return this.set(1,0,0,t,0,1,0,n,0,0,1,e,0,0,0,1),this},makeRotationX:function(t){var n=Math.cos(t),t=Math.sin(t);return this.set(1,0,0,0,0,n,-t,0,0,t,n,0,0,0,0,1),this},makeRotationY:function(t){var n=Math.cos(t),t=Math.sin(t);return this.set(n,0,t,0,0,1,0,0,-t,0,n,0,0,0,0,1),this},makeRotationZ:function(t){var n=Math.cos(t),t=Math.sin(t);return this.set(n,-t,0,0,t,n,0,0,0,0,1,0,0,0,0,1),this},makeRotationAxis:function(t,n){var e=Math.cos(n),n=Math.sin(n),i=1-e,r=t.x,o=t.y,t=t.z,a=i*r,s=i*o;return this.set(a*r+e,a*o-n*t,a*t+n*o,0,a*o+n*t,s*o+e,s*t-n*r,0,a*t-n*o,s*t+n*r,i*t*t+e,0,0,0,0,1),this},makeScale:function(t,n,e){return this.set(t,0,0,0,0,n,0,0,0,0,e,0,0,0,0,1),this},makeShear:function(t,n,e){return this.set(1,n,e,0,t,1,e,0,t,n,1,0,0,0,0,1),this},compose:function(t,n,e){var i=this.elements,r=n.u,o=n.v,a=n._,n=n.M,s=r+r,c=o+o,h=a+a,u=r*s,l=r*c,r=r*h,f=o*c,o=o*h,a=a*h,s=n*s,c=n*c,n=n*h,h=e.x,d=e.y,e=e.z;return i[0]=(1-(f+a))*h,i[1]=(l+n)*h,i[2]=(r-c)*h,i[3]=0,i[4]=(l-n)*d,i[5]=(1-(u+a))*d,i[6]=(o+s)*d,i[7]=0,i[8]=(r+c)*e,i[9]=(o-s)*e,i[10]=(1-(u+f))*e,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this},decompose:function(t,n,e){var i=this.elements,r=lt.set(i[0],i[1],i[2]).length(),o=lt.set(i[4],i[5],i[6]).length(),a=lt.set(i[8],i[9],i[10]).length(),t=(this.determinant()<0&&(r=-r),t.x=i[12],t.y=i[13],t.z=i[14],c.copy(this),1/r),i=1/o,s=1/a;return c.elements[0]*=t,c.elements[1]*=t,c.elements[2]*=t,c.elements[4]*=i,c.elements[5]*=i,c.elements[6]*=i,c.elements[8]*=s,c.elements[9]*=s,c.elements[10]*=s,n.setFromRotationMatrix(c),e.x=r,e.y=o,e.z=a,this},makePerspective:function(t,n,e,i,r,o){void 0===o&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");var a=this.elements,s=2*r/(e-i),c=(n+t)/(n-t),e=(e+i)/(e-i),i=-(o+r)/(o-r),o=-2*o*r/(o-r);return a[0]=2*r/(n-t),a[4]=0,a[8]=c,a[12]=0,a[1]=0,a[5]=s,a[9]=e,a[13]=0,a[2]=0,a[6]=0,a[10]=i,a[14]=o,a[3]=0,a[7]=0,a[11]=-1,a[15]=0,this},makeOrthographic:function(t,n,e,i,r,o){var a=this.elements,s=1/(n-t),c=1/(e-i),h=1/(o-r),n=(n+t)*s,t=(e+i)*c,e=(o+r)*h;return a[0]=2*s,a[4]=0,a[8]=0,a[12]=-n,a[1]=0,a[5]=2*c,a[9]=0,a[13]=-t,a[2]=0,a[6]=0,a[10]=-2*h,a[14]=-e,a[3]=0,a[7]=0,a[11]=0,a[15]=1,this},equals:function(t){for(var n=this.elements,e=t.elements,i=0;i<16;i++)if(n[i]!==e[i])return!1;return!0},fromArray:function(t,n){void 0===n&&(n=0);for(var e=0;e<16;e++)this.elements[e]=t[e+n];return this},toArray:function(t,n){var e=this.elements;return(t=void 0===t?[]:t)[n=void 0===n?0:n]=e[0],t[n+1]=e[1],t[n+2]=e[2],t[n+3]=e[3],t[n+4]=e[4],t[n+5]=e[5],t[n+6]=e[6],t[n+7]=e[7],t[n+8]=e[8],t[n+9]=e[9],t[n+10]=e[10],t[n+11]=e[11],t[n+12]=e[12],t[n+13]=e[13],t[n+14]=e[14],t[n+15]=e[15],t}}),Object.assign(mt.prototype,{addEventListener:function(t,n){void 0===this.T&&(this.T={});var e=this.T;void 0===e[t]&&(e[t]=[]),-1===e[t].indexOf(n)&&e[t].push(n)},hasEventListener:function(t,n){var e;return void 0!==this.T&&void 0!==(e=this.T)[t]&&-1!==e[t].indexOf(n)},removeEventListener:function(t,n){var e;void 0!==this.T&&void 0!==(t=this.T[t])&&-1!==(e=t.indexOf(n))&&t.splice(e,1)},dispatchEvent:function(t){if(void 0!==this.T){var n=this.T[t.type];if(void 0!==n){t.target=this;for(var e=n.slice(0),i=0,r=e.length;i<r;i++)e[i].call(this,t)}}}});var gt=new _,_t=new o;function bt(t,n,e,i){this.u=t||0,this.v=n||0,this._=e||0,this.C=i||bt.DefaultOrder}function yt(){this.mask=1}function u(){this.elements=[1,0,0,0,1,0,0,0,1],0<arguments.length&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}bt.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"],bt.DefaultOrder="XYZ",Object.defineProperties(bt.prototype,{x:{get:function(){return this.u},set:function(t){this.u=t,this.S()}},y:{get:function(){return this.v},set:function(t){this.v=t,this.S()}},z:{get:function(){return this._},set:function(t){this._=t,this.S()}},order:{get:function(){return this.C},set:function(t){this.C=t,this.S()}}}),Object.assign(bt.prototype,{isEuler:!0,set:function(t,n,e,i){return this.u=t,this.v=n,this._=e,this.C=i||this.C,this.S(),this},clone:function(){return new this.constructor(this.u,this.v,this._,this.C)},copy:function(t){return this.u=t.u,this.v=t.v,this._=t._,this.C=t.C,this.S(),this},setFromRotationMatrix:function(t,n,e){var i=v.clamp,t=t.elements,r=t[0],o=t[4],a=t[8],s=t[1],c=t[5],h=t[9],u=t[2],l=t[6],t=t[10];return"XYZ"===(n=n||this.C)?(this.v=Math.asin(i(a,-1,1)),Math.abs(a)<.9999999?(this.u=Math.atan2(-h,t),this._=Math.atan2(-o,r)):(this.u=Math.atan2(l,c),this._=0)):"YXZ"===n?(this.u=Math.asin(-i(h,-1,1)),Math.abs(h)<.9999999?(this.v=Math.atan2(a,t),this._=Math.atan2(s,c)):(this.v=Math.atan2(-u,r),this._=0)):"ZXY"===n?(this.u=Math.asin(i(l,-1,1)),Math.abs(l)<.9999999?(this.v=Math.atan2(-u,t),this._=Math.atan2(-o,c)):(this.v=0,this._=Math.atan2(s,r))):"ZYX"===n?(this.v=Math.asin(-i(u,-1,1)),Math.abs(u)<.9999999?(this.u=Math.atan2(l,t),this._=Math.atan2(s,r)):(this.u=0,this._=Math.atan2(-o,c))):"YZX"===n?(this._=Math.asin(i(s,-1,1)),Math.abs(s)<.9999999?(this.u=Math.atan2(-h,c),this.v=Math.atan2(-u,r)):(this.u=0,this.v=Math.atan2(a,t))):"XZY"===n?(this._=Math.asin(-i(o,-1,1)),Math.abs(o)<.9999999?(this.u=Math.atan2(l,c),this.v=Math.atan2(a,r)):(this.u=Math.atan2(-h,t),this.v=0)):console.warn("THREE.Euler: .setFromRotationMatrix() given unsupported order: "+n),this.C=n,!1!==e&&this.S(),this},setFromQuaternion:function(t,n,e){return gt.makeRotationFromQuaternion(t),this.setFromRotationMatrix(gt,n,e)},setFromVector3:function(t,n){return this.set(t.x,t.y,t.z,n||this.C)},reorder:function(t){return _t.setFromEuler(this),this.setFromQuaternion(_t,t)},equals:function(t){return t.u===this.u&&t.v===this.v&&t._===this._&&t.C===this.C},fromArray:function(t){return this.u=t[0],this.v=t[1],this._=t[2],void 0!==t[3]&&(this.C=t[3]),this.S(),this},toArray:function(t,n){return(t=void 0===t?[]:t)[n=void 0===n?0:n]=this.u,t[n+1]=this.v,t[n+2]=this._,t[n+3]=this.C,t},toVector3:function(t){return t?t.set(this.u,this.v,this._):new E(this.u,this.v,this._)},L:function(t){return this.S=t,this},S:function(){}}),Object.assign(yt.prototype,{set:function(t){this.mask=1<<t|0},enable:function(t){this.mask|=1<<t|0},enableAll:function(){this.mask=-1},toggle:function(t){this.mask^=1<<t|0},disable:function(t){this.mask&=~(1<<t|0)},disableAll:function(){this.mask=0},test:function(t){return 0!=(this.mask&t.mask)}}),Object.assign(u.prototype,{isMatrix3:!0,set:function(t,n,e,i,r,o,a,s,c){var h=this.elements;return h[0]=t,h[1]=i,h[2]=a,h[3]=n,h[4]=r,h[5]=s,h[6]=e,h[7]=o,h[8]=c,this},identity:function(){return this.set(1,0,0,0,1,0,0,0,1),this},clone:function(){return(new this.constructor).fromArray(this.elements)},copy:function(t){var n=this.elements,t=t.elements;return n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[3],n[4]=t[4],n[5]=t[5],n[6]=t[6],n[7]=t[7],n[8]=t[8],this},extractBasis:function(t,n,e){return t.setFromMatrix3Column(this,0),n.setFromMatrix3Column(this,1),e.setFromMatrix3Column(this,2),this},setFromMatrix4:function(t){t=t.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this},multiply:function(t){return this.multiplyMatrices(this,t)},premultiply:function(t){return this.multiplyMatrices(t,this)},multiplyMatrices:function(t,n){var t=t.elements,n=n.elements,e=this.elements,i=t[0],r=t[3],o=t[6],a=t[1],s=t[4],c=t[7],h=t[2],u=t[5],t=t[8],l=n[0],f=n[3],d=n[6],v=n[1],p=n[4],m=n[7],g=n[2],_=n[5],n=n[8];return e[0]=i*l+r*v+o*g,e[3]=i*f+r*p+o*_,e[6]=i*d+r*m+o*n,e[1]=a*l+s*v+c*g,e[4]=a*f+s*p+c*_,e[7]=a*d+s*m+c*n,e[2]=h*l+u*v+t*g,e[5]=h*f+u*p+t*_,e[8]=h*d+u*m+t*n,this},multiplyScalar:function(t){var n=this.elements;return n[0]*=t,n[3]*=t,n[6]*=t,n[1]*=t,n[4]*=t,n[7]*=t,n[2]*=t,n[5]*=t,n[8]*=t,this},determinant:function(){var t=this.elements,n=t[0],e=t[1],i=t[2],r=t[3],o=t[4],a=t[5],s=t[6],c=t[7],t=t[8];return n*o*t-n*a*c-e*r*t+e*a*s+i*r*c-i*o*s},getInverse:function(t,n){void 0!==n&&console.warn("THREE.Matrix3: .getInverse() can no longer be configured to throw on degenerate.");var n=t.elements,t=this.elements,e=n[0],i=n[1],r=n[2],o=n[3],a=n[4],s=n[5],c=n[6],h=n[7],n=n[8],u=n*a-s*h,l=s*c-n*o,f=h*o-a*c,d=e*u+i*l+r*f;return 0==d?this.set(0,0,0,0,0,0,0,0,0):(t[0]=u*(u=1/d),t[1]=(r*h-n*i)*u,t[2]=(s*i-r*a)*u,t[3]=l*u,t[4]=(n*e-r*c)*u,t[5]=(r*o-s*e)*u,t[6]=f*u,t[7]=(i*c-h*e)*u,t[8]=(a*e-i*o)*u,this)},transpose:function(){var t=this.elements,n=t[1];return t[1]=t[3],t[3]=n,n=t[2],t[2]=t[6],t[6]=n,n=t[5],t[5]=t[7],t[7]=n,this},getNormalMatrix:function(t){return this.setFromMatrix4(t).getInverse(this).transpose()},transposeIntoArray:function(t){var n=this.elements;return t[0]=n[0],t[1]=n[3],t[2]=n[6],t[3]=n[1],t[4]=n[4],t[5]=n[7],t[6]=n[2],t[7]=n[5],t[8]=n[8],this},setUvTransform:function(t,n,e,i,r,o,a){var s=Math.cos(r),r=Math.sin(r);this.set(e*s,e*r,-e*(s*o+r*a)+o+t,-i*r,i*s,-i*(-r*o+s*a)+a+n,0,0,1)},scale:function(t,n){var e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=n,e[4]*=n,e[7]*=n,this},rotate:function(t){var n=Math.cos(t),t=Math.sin(t),e=this.elements,i=e[0],r=e[3],o=e[6],a=e[1],s=e[4],c=e[7];return e[0]=n*i+t*a,e[3]=n*r+t*s,e[6]=n*o+t*c,e[1]=-t*i+n*a,e[4]=-t*r+n*s,e[7]=-t*o+n*c,this},translate:function(t,n){var e=this.elements;return e[0]+=t*e[2],e[3]+=t*e[5],e[6]+=t*e[8],e[1]+=n*e[2],e[4]+=n*e[5],e[7]+=n*e[8],this},equals:function(t){for(var n=this.elements,e=t.elements,i=0;i<9;i++)if(n[i]!==e[i])return!1;return!0},fromArray:function(t,n){void 0===n&&(n=0);for(var e=0;e<9;e++)this.elements[e]=t[e+n];return this},toArray:function(t,n){var e=this.elements;return(t=void 0===t?[]:t)[n=void 0===n?0:n]=e[0],t[n+1]=e[1],t[n+2]=e[2],t[n+3]=e[3],t[n+4]=e[4],t[n+5]=e[5],t[n+6]=e[6],t[n+7]=e[7],t[n+8]=e[8],t}});var wt=0,xt=new E,Mt=new o,i=new _,St=new E,Lt=new E,Et=new E,Tt=new o,Ct=new E(1,0,0),Dt=new E(0,1,0),Pt=new E(0,0,1),At={type:"added"},Rt={type:"removed"};function h(){Object.defineProperty(this,"id",{value:wt++}),this.uuid=v.generateUUID(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=h.DefaultUp.clone();var t=new E,n=new bt,e=new o,i=new E(1,1,1);n.L(function(){e.setFromEuler(n,!1)}),e.L(function(){n.setFromQuaternion(e,void 0,!1)}),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:e},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new _},normalMatrix:{value:new u}}),this.matrix=new _,this.matrixWorld=new _,this.matrixAutoUpdate=h.DefaultMatrixAutoUpdate,this.matrixWorldNeedsUpdate=!1,this.layers=new yt,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.userData={}}h.DefaultUp=new E(0,1,0),h.DefaultMatrixAutoUpdate=!0,h.prototype=Object.assign(Object.create(mt.prototype),{constructor:h,isObject3D:!0,onBeforeRender:function(){},onAfterRender:function(){},applyMatrix4:function(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)},applyQuaternion:function(t){return this.quaternion.premultiply(t),this},setRotationFromAxisAngle:function(t,n){this.quaternion.setFromAxisAngle(t,n)},setRotationFromEuler:function(t){this.quaternion.setFromEuler(t,!0)},setRotationFromMatrix:function(t){this.quaternion.setFromRotationMatrix(t)},setRotationFromQuaternion:function(t){this.quaternion.copy(t)},rotateOnAxis:function(t,n){return Mt.setFromAxisAngle(t,n),this.quaternion.multiply(Mt),this},rotateOnWorldAxis:function(t,n){return Mt.setFromAxisAngle(t,n),this.quaternion.premultiply(Mt),this},rotateX:function(t){return this.rotateOnAxis(Ct,t)},rotateY:function(t){return this.rotateOnAxis(Dt,t)},rotateZ:function(t){return this.rotateOnAxis(Pt,t)},translateOnAxis:function(t,n){return xt.copy(t).applyQuaternion(this.quaternion),this.position.add(xt.multiplyScalar(n)),this},translateX:function(t){return this.translateOnAxis(Ct,t)},translateY:function(t){return this.translateOnAxis(Dt,t)},translateZ:function(t){return this.translateOnAxis(Pt,t)},localToWorld:function(t){return t.applyMatrix4(this.matrixWorld)},worldToLocal:function(t){return t.applyMatrix4(i.getInverse(this.matrixWorld))},lookAt:function(t,n,e){t.isVector3?St.copy(t):St.set(t,n,e);t=this.parent;this.updateWorldMatrix(!0,!1),Lt.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?i.lookAt(Lt,St,this.up):i.lookAt(St,Lt,this.up),this.quaternion.setFromRotationMatrix(i),t&&(i.extractRotation(t.matrixWorld),Mt.setFromRotationMatrix(i),this.quaternion.premultiply(Mt.inverse()))},add:function(t){if(1<arguments.length)for(var n=0;n<arguments.length;n++)this.add(arguments[n]);else t===this?console.error("THREE.Object3D.add: object can't be added as a child of itself.",t):t&&t.isObject3D?(null!==t.parent&&t.parent.remove(t),(t.parent=this).children.push(t),t.dispatchEvent(At)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t);return this},remove:function(t){if(1<arguments.length)for(var n=0;n<arguments.length;n++)this.remove(arguments[n]);else{var e=this.children.indexOf(t);-1!==e&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(Rt))}return this},attach:function(t){return this.updateWorldMatrix(!0,!1),i.getInverse(this.matrixWorld),null!==t.parent&&(t.parent.updateWorldMatrix(!0,!1),i.multiply(t.parent.matrixWorld)),t.applyMatrix4(i),t.updateWorldMatrix(!1,!1),this.add(t),this},getObjectById:function(t){return this.getObjectByProperty("id",t)},getObjectByName:function(t){return this.getObjectByProperty("name",t)},getObjectByProperty:function(t,n){if(this[t]===n)return this;for(var e=0,i=this.children.length;e<i;e++){var r=this.children[e].getObjectByProperty(t,n);if(void 0!==r)return r}},getWorldPosition:function(t){return void 0===t&&(console.warn("THREE.Object3D: .getWorldPosition() target is now required"),t=new E),this.updateMatrixWorld(!0),t.setFromMatrixPosition(this.matrixWorld)},getWorldQuaternion:function(t){return void 0===t&&(console.warn("THREE.Object3D: .getWorldQuaternion() target is now required"),t=new o),this.updateMatrixWorld(!0),this.matrixWorld.decompose(Lt,t,Et),t},getWorldScale:function(t){return void 0===t&&(console.warn("THREE.Object3D: .getWorldScale() target is now required"),t=new E),this.updateMatrixWorld(!0),this.matrixWorld.decompose(Lt,Tt,t),t},getWorldDirection:function(t){void 0===t&&(console.warn("THREE.Object3D: .getWorldDirection() target is now required"),t=new E),this.updateMatrixWorld(!0);var n=this.matrixWorld.elements;return t.set(n[8],n[9],n[10]).normalize()},raycast:function(){},traverse:function(t){t(this);for(var n=this.children,e=0,i=n.length;e<i;e++)n[e].traverse(t)},traverseVisible:function(t){if(!1!==this.visible){t(this);for(var n=this.children,e=0,i=n.length;e<i;e++)n[e].traverseVisible(t)}},traverseAncestors:function(t){var n=this.parent;null!==n&&(t(n),n.traverseAncestors(t))},updateMatrix:function(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0},updateMatrixWorld:function(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),t=!(this.matrixWorldNeedsUpdate=!1));for(var n=this.children,e=0,i=n.length;e<i;e++)n[e].updateMatrixWorld(t)},updateWorldMatrix:function(t,n){var e=this.parent;if(!0===t&&null!==e&&e.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),!0===n)for(var i=this.children,r=0,o=i.length;r<o;r++)i[r].updateWorldMatrix(!1,!0)},clone:function(t){return(new this.constructor).copy(this,t)},copy:function(t,n){if(void 0===n&&(n=!0),this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),!0===n)for(var e=0;e<t.children.length;e++){var i=t.children[e];this.add(i.clone())}return this}});var Nt=new E,Ot=new E,It=new u;function Ut(t,n){this.normal=void 0!==t?t:new E(1,0,0),this.constant=void 0!==n?n:0}Object.assign(Ut.prototype,{isPlane:!0,set:function(t,n){return this.normal.copy(t),this.constant=n,this},setComponents:function(t,n,e,i){return this.normal.set(t,n,e),this.constant=i,this},setFromNormalAndCoplanarPoint:function(t,n){return this.normal.copy(t),this.constant=-n.dot(this.normal),this},setFromCoplanarPoints:function(t,n,e){e=Nt.subVectors(e,n).cross(Ot.subVectors(t,n)).normalize();return this.setFromNormalAndCoplanarPoint(e,t),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.normal.copy(t.normal),this.constant=t.constant,this},normalize:function(){var t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this},negate:function(){return this.constant*=-1,this.normal.negate(),this},distanceToPoint:function(t){return this.normal.dot(t)+this.constant},distanceToSphere:function(t){return this.distanceToPoint(t.center)-t.radius},projectPoint:function(t,n){return void 0===n&&(console.warn("THREE.Plane: .projectPoint() target is now required"),n=new E),n.copy(this.normal).multiplyScalar(-this.distanceToPoint(t)).add(t)},intersectLine:function(t,n){void 0===n&&(console.warn("THREE.Plane: .intersectLine() target is now required"),n=new E);var e=t.delta(Nt),i=this.normal.dot(e);return 0===i?0===this.distanceToPoint(t.start)?n.copy(t.start):void 0:(i=-(t.start.dot(this.normal)+this.constant)/i)<0||1<i?void 0:n.copy(e).multiplyScalar(i).add(t.start)},intersectsLine:function(t){var n=this.distanceToPoint(t.start),t=this.distanceToPoint(t.end);return n<0&&0<t||t<0&&0<n},intersectsBox:function(t){return t.intersectsPlane(this)},intersectsSphere:function(t){return t.intersectsPlane(this)},coplanarPoint:function(t){return void 0===t&&(console.warn("THREE.Plane: .coplanarPoint() target is now required"),t=new E),t.copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(t,n){n=n||It.getNormalMatrix(t),t=this.coplanarPoint(Nt).applyMatrix4(t),n=this.normal.applyMatrix3(n).normalize();return this.constant=-t.dot(n),this},translate:function(t){return this.constant-=t.dot(this.normal),this},equals:function(t){return t.normal.equals(this.normal)&&t.constant===this.constant}});var l=new E,f=new E,Ft=new E,d=new E,Ht=new E,jt=new E,kt=new E,Gt=new E,zt=new E,Bt=new E;function I(t,n,e){this.a=void 0!==t?t:new E,this.b=void 0!==n?n:new E,this.c=void 0!==e?e:new E}Object.assign(I,{getNormal:function(t,n,e,i){void 0===i&&(console.warn("THREE.Triangle: .getNormal() target is now required"),i=new E),i.subVectors(e,n),l.subVectors(t,n),i.cross(l);e=i.lengthSq();return 0<e?i.multiplyScalar(1/Math.sqrt(e)):i.set(0,0,0)},getBarycoord:function(t,n,e,i,r){l.subVectors(i,n),f.subVectors(e,n),Ft.subVectors(t,n);var i=l.dot(l),e=l.dot(f),t=l.dot(Ft),n=f.dot(f),o=f.dot(Ft),a=i*n-e*e;return void 0===r&&(console.warn("THREE.Triangle: .getBarycoord() target is now required"),r=new E),0==a?r.set(-2,-1,-1):r.set(1-(n=(n*t-e*o)*(r=1/a))-(a=(i*o-e*t)*r),a,n)},containsPoint:function(t,n,e,i){return I.getBarycoord(t,n,e,i,d),0<=d.x&&0<=d.y&&d.x+d.y<=1},getUV:function(t,n,e,i,r,o,a,s){return this.getBarycoord(t,n,e,i,d),s.set(0,0),s.addScaledVector(r,d.x),s.addScaledVector(o,d.y),s.addScaledVector(a,d.z),s},isFrontFacing:function(t,n,e,i){return l.subVectors(e,n),f.subVectors(t,n),l.cross(f).dot(i)<0}}),Object.assign(I.prototype,{set:function(t,n,e){return this.a.copy(t),this.b.copy(n),this.c.copy(e),this},setFromPointsAndIndices:function(t,n,e,i){return this.a.copy(t[n]),this.b.copy(t[e]),this.c.copy(t[i]),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this},getArea:function(){return l.subVectors(this.c,this.b),f.subVectors(this.a,this.b),.5*l.cross(f).length()},getMidpoint:function(t){return void 0===t&&(console.warn("THREE.Triangle: .getMidpoint() target is now required"),t=new E),t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},getNormal:function(t){return I.getNormal(this.a,this.b,this.c,t)},getPlane:function(t){return void 0===t&&(console.warn("THREE.Triangle: .getPlane() target is now required"),t=new Ut),t.setFromCoplanarPoints(this.a,this.b,this.c)},getBarycoord:function(t,n){return I.getBarycoord(t,this.a,this.b,this.c,n)},getUV:function(t,n,e,i,r){return I.getUV(t,this.a,this.b,this.c,n,e,i,r)},containsPoint:function(t){return I.containsPoint(t,this.a,this.b,this.c)},isFrontFacing:function(t){return I.isFrontFacing(this.a,this.b,this.c,t)},intersectsBox:function(t){return t.intersectsTriangle(this)},closestPointToPoint:function(t,n){void 0===n&&(console.warn("THREE.Triangle: .closestPointToPoint() target is now required"),n=new E);var e=this.a,i=this.b,r=this.c,o=(Ht.subVectors(i,e),jt.subVectors(r,e),Gt.subVectors(t,e),Ht.dot(Gt)),a=jt.dot(Gt);if(o<=0&&a<=0)return n.copy(e);zt.subVectors(t,i);var s=Ht.dot(zt),c=jt.dot(zt);if(0<=s&&c<=s)return n.copy(i);var h=o*c-s*a;if(h<=0&&0<=o&&s<=0)return u=o/(o-s),n.copy(e).addScaledVector(Ht,u);Bt.subVectors(t,r);var u,l,t=Ht.dot(Bt),f=jt.dot(Bt);return 0<=f&&t<=f?n.copy(r):(o=t*a-o*f)<=0&&0<=a&&f<=0?(l=a/(a-f),n.copy(e).addScaledVector(jt,l)):(a=s*f-t*c)<=0&&0<=c-s&&0<=t-f?(kt.subVectors(r,i),l=(c-s)/(c-s+(t-f)),n.copy(i).addScaledVector(kt,l)):(u=o*(r=1/(a+o+h)),l=h*r,n.copy(e).addScaledVector(Ht,u).addScaledVector(jt,l))},equals:function(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}});var Vt={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},p={h:0,s:0,l:0},Wt={h:0,s:0,l:0};function m(t,n,e){return void 0===n&&void 0===e?this.set(t):this.setRGB(t,n,e)}function Xt(t,n,e){return e<0&&(e+=1),1<e&&--e,e<1/6?t+6*(n-t)*e:e<.5?n:e<2/3?t+6*(n-t)*(2/3-e):t}function Yt(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function Zt(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}function qt(t,n,e,i,r,o){this.a=t,this.b=n,this.c=e,this.normal=i&&i.isVector3?i:new E,this.vertexNormals=Array.isArray(i)?i:[],this.color=r&&r.isColor?r:new m,this.vertexColors=Array.isArray(r)?r:[],this.materialIndex=void 0!==o?o:0}Object.assign(m.prototype,{isColor:!0,r:1,g:1,b:1,set:function(t){return t&&t.isColor?this.copy(t):"number"==typeof t?this.setHex(t):"string"==typeof t&&this.setStyle(t),this},setScalar:function(t){return this.r=t,this.g=t,this.b=t,this},setHex:function(t){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,this},setRGB:function(t,n,e){return this.r=t,this.g=n,this.b=e,this},setHSL:function(t,n,e){return t=v.euclideanModulo(t,1),n=v.clamp(n,0,1),e=v.clamp(e,0,1),0===n?this.r=this.g=this.b=e:(this.r=Xt(n=2*e-(e=e<=.5?e*(1+n):e+n-e*n),e,t+1/3),this.g=Xt(n,e,t),this.b=Xt(n,e,t-1/3)),this},setStyle:function(n){function t(t){void 0!==t&&parseFloat(t)<1&&console.warn("THREE.Color: Alpha component of "+n+" will be ignored.")}if(c=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(n)){var e,i,r,o,a=c[1],s=c[2];switch(a){case"rgb":case"rgba":if(e=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(s))return this.r=Math.min(255,parseInt(e[1],10))/255,this.g=Math.min(255,parseInt(e[2],10))/255,this.b=Math.min(255,parseInt(e[3],10))/255,t(e[5]),this;if(e=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(s))return this.r=Math.min(100,parseInt(e[1],10))/100,this.g=Math.min(100,parseInt(e[2],10))/100,this.b=Math.min(100,parseInt(e[3],10))/100,t(e[5]),this;break;case"hsl":case"hsla":if(e=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(s))return i=parseFloat(e[1])/360,r=parseInt(e[2],10)/100,o=parseInt(e[3],10)/100,t(e[5]),this.setHSL(i,r,o)}}else if(c=/^\#([A-Fa-f0-9]+)$/.exec(n)){var a=c[1],c=a.length;if(3===c)return this.r=parseInt(a.charAt(0)+a.charAt(0),16)/255,this.g=parseInt(a.charAt(1)+a.charAt(1),16)/255,this.b=parseInt(a.charAt(2)+a.charAt(2),16)/255,this;if(6===c)return this.r=parseInt(a.charAt(0)+a.charAt(1),16)/255,this.g=parseInt(a.charAt(2)+a.charAt(3),16)/255,this.b=parseInt(a.charAt(4)+a.charAt(5),16)/255,this}return n&&0<n.length?this.setColorName(n):this},setColorName:function(t){var n=Vt[t];return void 0!==n?this.setHex(n):console.warn("THREE.Color: Unknown color "+t),this},clone:function(){return new this.constructor(this.r,this.g,this.b)},copy:function(t){return this.r=t.r,this.g=t.g,this.b=t.b,this},copyGammaToLinear:function(t,n){return void 0===n&&(n=2),this.r=Math.pow(t.r,n),this.g=Math.pow(t.g,n),this.b=Math.pow(t.b,n),this},copyLinearToGamma:function(t,n){n=0<(n=void 0===n?2:n)?1/n:1;return this.r=Math.pow(t.r,n),this.g=Math.pow(t.g,n),this.b=Math.pow(t.b,n),this},convertGammaToLinear:function(t){return this.copyGammaToLinear(this,t),this},convertLinearToGamma:function(t){return this.copyLinearToGamma(this,t),this},copySRGBToLinear:function(t){return this.r=Yt(t.r),this.g=Yt(t.g),this.b=Yt(t.b),this},copyLinearToSRGB:function(t){return this.r=Zt(t.r),this.g=Zt(t.g),this.b=Zt(t.b),this},convertSRGBToLinear:function(){return this.copySRGBToLinear(this),this},convertLinearToSRGB:function(){return this.copyLinearToSRGB(this),this},getHex:function(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0},getHexString:function(){return("000000"+this.getHex().toString(16)).slice(-6)},getHSL:function(t){void 0===t&&(console.warn("THREE.Color: .getHSL() target is now required"),t={h:0,s:0,l:0});var n,e=this.r,i=this.g,r=this.b,o=Math.max(e,i,r),a=Math.min(e,i,r),s=(a+o)/2;if(a===o)h=n=0;else{var c=o-a,h=s<=.5?c/(o+a):c/(2-o-a);switch(o){case e:n=(i-r)/c+(i<r?6:0);break;case i:n=(r-e)/c+2;break;case r:n=(e-i)/c+4}n/=6}return t.h=n,t.s=h,t.l=s,t},getStyle:function(){return"rgb("+(255*this.r|0)+","+(255*this.g|0)+","+(255*this.b|0)+")"},offsetHSL:function(t,n,e){return this.getHSL(p),p.h+=t,p.s+=n,p.l+=e,this.setHSL(p.h,p.s,p.l),this},add:function(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this},addColors:function(t,n){return this.r=t.r+n.r,this.g=t.g+n.g,this.b=t.b+n.b,this},addScalar:function(t){return this.r+=t,this.g+=t,this.b+=t,this},sub:function(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this},multiply:function(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this},multiplyScalar:function(t){return this.r*=t,this.g*=t,this.b*=t,this},lerp:function(t,n){return this.r+=(t.r-this.r)*n,this.g+=(t.g-this.g)*n,this.b+=(t.b-this.b)*n,this},lerpHSL:function(t,n){this.getHSL(p),t.getHSL(Wt);var t=v.lerp(p.h,Wt.h,n),e=v.lerp(p.s,Wt.s,n),n=v.lerp(p.l,Wt.l,n);return this.setHSL(t,e,n),this},equals:function(t){return t.r===this.r&&t.g===this.g&&t.b===this.b},fromArray:function(t,n){return this.r=t[n=void 0===n?0:n],this.g=t[n+1],this.b=t[n+2],this},toArray:function(t,n){return(t=void 0===t?[]:t)[n=void 0===n?0:n]=this.r,t[n+1]=this.g,t[n+2]=this.b,t}}),m.NAMES=Vt,Object.assign(qt.prototype,{clone:function(){return(new this.constructor).copy(this)},copy:function(t){this.a=t.a,this.b=t.b,this.c=t.c,this.normal.copy(t.normal),this.color.copy(t.color),this.materialIndex=t.materialIndex;for(var n=0,e=t.vertexNormals.length;n<e;n++)this.vertexNormals[n]=t.vertexNormals[n].clone();for(n=0,e=t.vertexColors.length;n<e;n++)this.vertexColors[n]=t.vertexColors[n].clone();return this}});var Kt=1,Qt=2,Jt=0;function e(){Object.defineProperty(this,"id",{value:Jt++}),this.uuid=v.generateUUID(),this.name="",this.type="Material",this.fog=!0,this.blending=1,this.side=0,this.flatShading=!1,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=7680,this.stencilZFail=7680,this.stencilZPass=7680,this.stencilWrite=!1,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.toneMapped=!0,this.userData={},this.version=0}function g(t){e.call(this),this.type="MeshBasicMaterial",this.color=new m(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=0,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.setValues(t)}function $t(t,n,e,i){this.x=t||0,this.y=n||0,this.z=e||0,this.w=void 0!==i?i:1}e.prototype=Object.assign(Object.create(mt.prototype),{constructor:e,isMaterial:!0,onBeforeCompile:function(){},setValues:function(t){if(void 0!==t)for(var n in t){var e,i=t[n];void 0===i?console.warn("THREE.Material: '"+n+"' parameter is undefined."):"shading"===n?(console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=1===i):void 0===(e=this[n])?console.warn("THREE."+this.type+": '"+n+"' is not a property of this material."):e&&e.isColor?e.set(i):e&&e.isVector3&&i&&i.isVector3?e.copy(i):this[n]=i}},clone:function(){return(new this.constructor).copy(this)},copy:function(t){this.name=t.name,this.fog=t.fog,this.blending=t.blending,this.side=t.side,this.flatShading=t.flatShading,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;var n=t.clippingPlanes,e=null;if(null!==n)for(var i=n.length,e=new Array(i),r=0;r!==i;++r)e[r]=n[r].clone();return this.clippingPlanes=e,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.premultipliedAlpha=t.premultipliedAlpha,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),Object.defineProperty(e.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),((g.prototype=Object.create(e.prototype)).constructor=g).prototype.isMeshBasicMaterial=!0,g.prototype.copy=function(t){return e.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this},Object.defineProperties($t.prototype,{width:{get:function(){return this.z},set:function(t){this.z=t}},height:{get:function(){return this.w},set:function(t){this.w=t}}}),Object.assign($t.prototype,{isVector4:!0,set:function(t,n,e,i){return this.x=t,this.y=n,this.z=e,this.w=i,this},setScalar:function(t){return this.x=t,this.y=t,this.z=t,this.w=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setZ:function(t){return this.z=t,this},setW:function(t){return this.w=t,this},setComponent:function(t,n){switch(t){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;case 3:this.w=n;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y,this.z,this.w)},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this},add:function(t,n){return void 0!==n?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,n)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this)},addScalar:function(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this},addVectors:function(t,n){return this.x=t.x+n.x,this.y=t.y+n.y,this.z=t.z+n.z,this.w=t.w+n.w,this},addScaledVector:function(t,n){return this.x+=t.x*n,this.y+=t.y*n,this.z+=t.z*n,this.w+=t.w*n,this},sub:function(t,n){return void 0!==n?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,n)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this)},subScalar:function(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this},subVectors:function(t,n){return this.x=t.x-n.x,this.y=t.y-n.y,this.z=t.z-n.z,this.w=t.w-n.w,this},multiplyScalar:function(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},applyMatrix4:function(t){var n=this.x,e=this.y,i=this.z,r=this.w,t=t.elements;return this.x=t[0]*n+t[4]*e+t[8]*i+t[12]*r,this.y=t[1]*n+t[5]*e+t[9]*i+t[13]*r,this.z=t[2]*n+t[6]*e+t[10]*i+t[14]*r,this.w=t[3]*n+t[7]*e+t[11]*i+t[15]*r,this},divideScalar:function(t){return this.multiplyScalar(1/t)},setAxisAngleFromQuaternion:function(t){this.w=2*Math.acos(t.w);var n=Math.sqrt(1-t.w*t.w);return n<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/n,this.y=t.y/n,this.z=t.z/n),this},setAxisAngleFromRotationMatrix:function(t){var n,e,i,r,o,a,s,c,h,u,t=t.elements,l=t[0],f=t[4],d=t[8],v=t[1],p=t[5],m=t[9],g=t[2],_=t[6],t=t[10];return Math.abs(f-v)<.01&&Math.abs(d-g)<.01&&Math.abs(m-_)<.01?Math.abs(f+v)<.1&&Math.abs(d+g)<.1&&Math.abs(m+_)<.1&&Math.abs(l+p+t-3)<.1?this.set(1,0,0,0):(r=Math.PI,a=(t+1)/2,s=(f+v)/4,c=(d+g)/4,h=(m+_)/4,(o=(p+1)/2)<(u=(l+1)/2)&&a<u?i=u<.01?(n=0,e=.707106781):(e=s/(n=Math.sqrt(u)),c/n):a<o?i=o<.01?(e=0,n=.707106781):(n=s/(e=Math.sqrt(o)),h/e):a<.01?(e=n=.707106781,i=0):(n=c/(i=Math.sqrt(a)),e=h/i),this.set(n,e,i,r)):(u=Math.sqrt((_-m)*(_-m)+(d-g)*(d-g)+(v-f)*(v-f)),Math.abs(u)<.001&&(u=1),this.x=(_-m)/u,this.y=(d-g)/u,this.z=(v-f)/u,this.w=Math.acos((l+p+t-1)/2)),this},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this},clamp:function(t,n){return this.x=Math.max(t.x,Math.min(n.x,this.x)),this.y=Math.max(t.y,Math.min(n.y,this.y)),this.z=Math.max(t.z,Math.min(n.z,this.z)),this.w=Math.max(t.w,Math.min(n.w,this.w)),this},clampScalar:function(t,n){return this.x=Math.max(t,Math.min(n,this.x)),this.y=Math.max(t,Math.min(n,this.y)),this.z=Math.max(t,Math.min(n,this.z)),this.w=Math.max(t,Math.min(n,this.w)),this},clampLength:function(t,n){var e=this.length();return this.divideScalar(e||1).multiplyScalar(Math.max(t,Math.min(n,e)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)},normalize:function(){return this.divideScalar(this.length()||1)},setLength:function(t){return this.normalize().multiplyScalar(t)},lerp:function(t,n){return this.x+=(t.x-this.x)*n,this.y+=(t.y-this.y)*n,this.z+=(t.z-this.z)*n,this.w+=(t.w-this.w)*n,this},lerpVectors:function(t,n,e){return this.subVectors(n,t).multiplyScalar(e).add(t)},equals:function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w},fromArray:function(t,n){return this.x=t[n=void 0===n?0:n],this.y=t[n+1],this.z=t[n+2],this.w=t[n+3],this},toArray:function(t,n){return(t=void 0===t?[]:t)[n=void 0===n?0:n]=this.x,t[n+1]=this.y,t[n+2]=this.z,t[n+3]=this.w,t},fromBufferAttribute:function(t,n,e){return void 0!==e&&console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(n),this.y=t.getY(n),this.z=t.getZ(n),this.w=t.getW(n),this}});var b=new E;function y(t,n,e){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.name="",this.array=t,this.itemSize=n,this.count=void 0!==t?t.length/n:0,this.normalized=!0===e,this.usage=35044,this.updateRange={offset:0,count:-1},this.version=0}function tn(t,n,e){y.call(this,new Int8Array(t),n,e)}function nn(t,n,e){y.call(this,new Uint8Array(t),n,e)}function en(t,n,e){y.call(this,new Uint8ClampedArray(t),n,e)}function rn(t,n,e){y.call(this,new Int16Array(t),n,e)}function on(t,n,e){y.call(this,new Uint16Array(t),n,e)}function an(t,n,e){y.call(this,new Int32Array(t),n,e)}function sn(t,n,e){y.call(this,new Uint32Array(t),n,e)}function T(t,n,e){y.call(this,new Float32Array(t),n,e)}function cn(t,n,e){y.call(this,new Float64Array(t),n,e)}function hn(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}Object.defineProperty(y.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.assign(y.prototype,{isBufferAttribute:!0,onUploadCallback:function(){},setUsage:function(t){return this.usage=t,this},copy:function(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this},copyAt:function(t,n,e){t*=this.itemSize,e*=n.itemSize;for(var i=0,r=this.itemSize;i<r;i++)this.array[t+i]=n.array[e+i];return this},copyArray:function(t){return this.array.set(t),this},copyColorsArray:function(t){for(var n=this.array,e=0,i=0,r=t.length;i<r;i++){var o=t[i];void 0===o&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",i),o=new m),n[e++]=o.r,n[e++]=o.g,n[e++]=o.b}return this},copyVector2sArray:function(t){for(var n=this.array,e=0,i=0,r=t.length;i<r;i++){var o=t[i];void 0===o&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",i),o=new O),n[e++]=o.x,n[e++]=o.y}return this},copyVector3sArray:function(t){for(var n=this.array,e=0,i=0,r=t.length;i<r;i++){var o=t[i];void 0===o&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",i),o=new E),n[e++]=o.x,n[e++]=o.y,n[e++]=o.z}return this},copyVector4sArray:function(t){for(var n=this.array,e=0,i=0,r=t.length;i<r;i++){var o=t[i];void 0===o&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",i),o=new $t),n[e++]=o.x,n[e++]=o.y,n[e++]=o.z,n[e++]=o.w}return this},applyMatrix3:function(t){for(var n=0,e=this.count;n<e;n++)b.x=this.getX(n),b.y=this.getY(n),b.z=this.getZ(n),b.applyMatrix3(t),this.setXYZ(n,b.x,b.y,b.z);return this},applyMatrix4:function(t){for(var n=0,e=this.count;n<e;n++)b.x=this.getX(n),b.y=this.getY(n),b.z=this.getZ(n),b.applyMatrix4(t),this.setXYZ(n,b.x,b.y,b.z);return this},applyNormalMatrix:function(t){for(var n=0,e=this.count;n<e;n++)b.x=this.getX(n),b.y=this.getY(n),b.z=this.getZ(n),b.applyNormalMatrix(t),this.setXYZ(n,b.x,b.y,b.z);return this},transformDirection:function(t){for(var n=0,e=this.count;n<e;n++)b.x=this.getX(n),b.y=this.getY(n),b.z=this.getZ(n),b.transformDirection(t),this.setXYZ(n,b.x,b.y,b.z);return this},set:function(t,n){return this.array.set(t,n=void 0===n?0:n),this},getX:function(t){return this.array[t*this.itemSize]},setX:function(t,n){return this.array[t*this.itemSize]=n,this},getY:function(t){return this.array[t*this.itemSize+1]},setY:function(t,n){return this.array[t*this.itemSize+1]=n,this},getZ:function(t){return this.array[t*this.itemSize+2]},setZ:function(t,n){return this.array[t*this.itemSize+2]=n,this},getW:function(t){return this.array[t*this.itemSize+3]},setW:function(t,n){return this.array[t*this.itemSize+3]=n,this},setXY:function(t,n,e){return t*=this.itemSize,this.array[t+0]=n,this.array[t+1]=e,this},setXYZ:function(t,n,e,i){return t*=this.itemSize,this.array[t+0]=n,this.array[t+1]=e,this.array[t+2]=i,this},setXYZW:function(t,n,e,i,r){return t*=this.itemSize,this.array[t+0]=n,this.array[t+1]=e,this.array[t+2]=i,this.array[t+3]=r,this},onUpload:function(t){return this.onUploadCallback=t,this},clone:function(){return new this.constructor(this.array,this.itemSize).copy(this)}}),(tn.prototype=Object.create(y.prototype)).constructor=tn,(nn.prototype=Object.create(y.prototype)).constructor=nn,(en.prototype=Object.create(y.prototype)).constructor=en,(rn.prototype=Object.create(y.prototype)).constructor=rn,on.prototype=Object.create(y.prototype),on.prototype.constructor=on,(an.prototype=Object.create(y.prototype)).constructor=an,sn.prototype=Object.create(y.prototype),sn.prototype.constructor=sn,(T.prototype=Object.create(y.prototype)).constructor=T,(cn.prototype=Object.create(y.prototype)).constructor=cn,Object.assign(hn.prototype,{computeGroups:function(t){for(var n,e=[],i=void 0,r=t.faces,o=0;o<r.length;o++){var a=r[o];a.materialIndex!==i&&(i=a.materialIndex,void 0!==n&&(n.count=3*o-n.start,e.push(n)),n={start:3*o,materialIndex:i})}void 0!==n&&(n.count=3*o-n.start,e.push(n)),this.groups=e},fromGeometry:function(t){var n=t.faces,e=t.vertices,i=t.faceVertexUvs,r=i[0]&&0<i[0].length,o=i[1]&&0<i[1].length,a=t.morphTargets,s=a.length;if(0<s){for(var c=[],h=0;h<s;h++)c[h]={name:a[h].name,data:[]};this.morphTargets.position=c}var u=t.morphNormals,l=u.length;if(0<l){for(var f=[],h=0;h<l;h++)f[h]={name:u[h].name,data:[]};this.morphTargets.normal=f}var d=t.skinIndices,v=t.skinWeights,p=d.length===e.length,m=v.length===e.length;0<e.length&&0===n.length&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(h=0;h<n.length;h++){var g,_=n[h],b=(this.vertices.push(e[_.a],e[_.b],e[_.c]),_.vertexNormals),b=(3===b.length?this.normals.push(b[0],b[1],b[2]):(b=_.normal,this.normals.push(b,b,b)),_.vertexColors);3===b.length?this.colors.push(b[0],b[1],b[2]):(b=_.color,this.colors.push(b,b,b)),!0===r&&(void 0!==(g=i[0][h])?this.uvs.push(g[0],g[1],g[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",h),this.uvs.push(new O,new O,new O))),!0===o&&(void 0!==(g=i[1][h])?this.uvs2.push(g[0],g[1],g[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",h),this.uvs2.push(new O,new O,new O)));for(var y=0;y<s;y++){var w=a[y].vertices;c[y].data.push(w[_.a],w[_.b],w[_.c])}for(y=0;y<l;y++){var x=u[y].vertexNormals[h];f[y].data.push(x.a,x.b,x.c)}p&&this.skinIndices.push(d[_.a],d[_.b],d[_.c]),m&&this.skinWeights.push(v[_.a],v[_.b],v[_.c])}return this.computeGroups(t),this.verticesNeedUpdate=t.verticesNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),this}});var un=1,w=new _,ln=new h,fn=new E,x=new tt,dn=new tt,M=new E;function C(){Object.defineProperty(this,"id",{value:un+=2}),this.uuid=v.generateUUID(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}C.prototype=Object.assign(Object.create(mt.prototype),{constructor:C,isBufferGeometry:!0,getIndex:function(){return this.index},setIndex:function(t){Array.isArray(t)?this.index=new(65535<function(t){if(0===t.length)return-1/0;for(var n=t[0],e=1,i=t.length;e<i;++e)t[e]>n&&(n=t[e]);return n}(t)?sn:on)(t,1):this.index=t},getAttribute:function(t){return this.attributes[t]},setAttribute:function(t,n){return this.attributes[t]=n,this},deleteAttribute:function(t){return delete this.attributes[t],this},addGroup:function(t,n,e){this.groups.push({start:t,count:n,materialIndex:void 0!==e?e:0})},clearGroups:function(){this.groups=[]},setDrawRange:function(t,n){this.drawRange.start=t,this.drawRange.count=n},applyMatrix4:function(t){var n=this.attributes.position,n=(void 0!==n&&(n.applyMatrix4(t),n.needsUpdate=!0),this.attributes.normal),e=(void 0!==n&&(e=(new u).getNormalMatrix(t),n.applyNormalMatrix(e),n.needsUpdate=!0),this.attributes.tangent);return void 0!==e&&(e.transformDirection(t),e.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this},rotateX:function(t){return w.makeRotationX(t),this.applyMatrix4(w),this},rotateY:function(t){return w.makeRotationY(t),this.applyMatrix4(w),this},rotateZ:function(t){return w.makeRotationZ(t),this.applyMatrix4(w),this},translate:function(t,n,e){return w.makeTranslation(t,n,e),this.applyMatrix4(w),this},scale:function(t,n,e){return w.makeScale(t,n,e),this.applyMatrix4(w),this},lookAt:function(t){return ln.lookAt(t),ln.updateMatrix(),this.applyMatrix4(ln.matrix),this},center:function(){return this.computeBoundingBox(),this.boundingBox.getCenter(fn).negate(),this.translate(fn.x,fn.y,fn.z),this},setFromObject:function(t){var n,e,i=t.geometry;return t.isPoints||t.isLine?(e=new T(3*i.vertices.length,3),n=new T(3*i.colors.length,3),this.setAttribute("position",e.copyVector3sArray(i.vertices)),this.setAttribute("color",n.copyColorsArray(i.colors)),i.lineDistances&&i.lineDistances.length===i.vertices.length&&(e=new T(i.lineDistances.length,1),this.setAttribute("lineDistance",e.copyArray(i.lineDistances))),null!==i.boundingSphere&&(this.boundingSphere=i.boundingSphere.clone()),null!==i.boundingBox&&(this.boundingBox=i.boundingBox.clone())):t.isMesh&&i&&i.isGeometry&&this.fromGeometry(i),this},setFromPoints:function(t){for(var n=[],e=0,i=t.length;e<i;e++){var r=t[e];n.push(r.x,r.y,r.z||0)}return this.setAttribute("position",new T(n,3)),this},updateFromObject:function(t){var n,e=t.geometry;if(t.isMesh){var i=e.D;if(!0===e.elementsNeedUpdate&&(i=void 0,e.elementsNeedUpdate=!1),void 0===i)return this.fromGeometry(e);i.verticesNeedUpdate=e.verticesNeedUpdate,i.normalsNeedUpdate=e.normalsNeedUpdate,i.colorsNeedUpdate=e.colorsNeedUpdate,i.uvsNeedUpdate=e.uvsNeedUpdate,i.groupsNeedUpdate=e.groupsNeedUpdate,e.verticesNeedUpdate=!1,e.normalsNeedUpdate=!1,e.colorsNeedUpdate=!1,e.uvsNeedUpdate=!1,e.groupsNeedUpdate=!1,e=i}return!0===e.verticesNeedUpdate&&(void 0!==(n=this.attributes.position)&&(n.copyVector3sArray(e.vertices),n.needsUpdate=!0),e.verticesNeedUpdate=!1),!0===e.normalsNeedUpdate&&(void 0!==(n=this.attributes.normal)&&(n.copyVector3sArray(e.normals),n.needsUpdate=!0),e.normalsNeedUpdate=!1),!0===e.colorsNeedUpdate&&(void 0!==(n=this.attributes.color)&&(n.copyColorsArray(e.colors),n.needsUpdate=!0),e.colorsNeedUpdate=!1),e.uvsNeedUpdate&&(void 0!==(n=this.attributes.uv)&&(n.copyVector2sArray(e.uvs),n.needsUpdate=!0),e.uvsNeedUpdate=!1),e.lineDistancesNeedUpdate&&(void 0!==(n=this.attributes.lineDistance)&&(n.copyArray(e.lineDistances),n.needsUpdate=!0),e.lineDistancesNeedUpdate=!1),e.groupsNeedUpdate&&(e.computeGroups(t.geometry),this.groups=e.groups,e.groupsNeedUpdate=!1),this},fromGeometry:function(t){return t.D=(new hn).fromGeometry(t),this.fromDirectGeometry(t.D)},fromDirectGeometry:function(t){var n,e=new Float32Array(3*t.vertices.length);for(n in this.setAttribute("position",new y(e,3).copyVector3sArray(t.vertices)),0<t.normals.length&&(e=new Float32Array(3*t.normals.length),this.setAttribute("normal",new y(e,3).copyVector3sArray(t.normals))),0<t.colors.length&&(e=new Float32Array(3*t.colors.length),this.setAttribute("color",new y(e,3).copyColorsArray(t.colors))),0<t.uvs.length&&(e=new Float32Array(2*t.uvs.length),this.setAttribute("uv",new y(e,2).copyVector2sArray(t.uvs))),0<t.uvs2.length&&(e=new Float32Array(2*t.uvs2.length),this.setAttribute("uv2",new y(e,2).copyVector2sArray(t.uvs2))),this.groups=t.groups,t.morphTargets){for(var i=[],r=t.morphTargets[n],o=0,a=r.length;o<a;o++){var s=r[o],c=new T(3*s.data.length,3);c.name=s.name,i.push(c.copyVector3sArray(s.data))}this.morphAttributes[n]=i}return 0<t.skinIndices.length&&(e=new T(4*t.skinIndices.length,4),this.setAttribute("skinIndex",e.copyVector4sArray(t.skinIndices))),0<t.skinWeights.length&&(e=new T(4*t.skinWeights.length,4),this.setAttribute("skinWeight",e.copyVector4sArray(t.skinWeights))),null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),this},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new tt);var t=this.attributes.position,n=this.morphAttributes.position;if(void 0!==t){if(this.boundingBox.setFromBufferAttribute(t),n)for(var e=0,i=n.length;e<i;e++){var r=n[e];x.setFromBufferAttribute(r),this.morphTargetsRelative?(M.addVectors(this.boundingBox.min,x.min),this.boundingBox.expandByPoint(M),M.addVectors(this.boundingBox.max,x.max),this.boundingBox.expandByPoint(M)):(this.boundingBox.expandByPoint(x.min),this.boundingBox.expandByPoint(x.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox: Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)},computeBoundingSphere:function(){null===this.boundingSphere&&(this.boundingSphere=new it);var t=this.attributes.position,n=this.morphAttributes.position;if(t){var e=this.boundingSphere.center;if(x.setFromBufferAttribute(t),n)for(var i=0,r=n.length;i<r;i++){var o=n[i];dn.setFromBufferAttribute(o),this.morphTargetsRelative?(M.addVectors(x.min,dn.min),x.expandByPoint(M),M.addVectors(x.max,dn.max),x.expandByPoint(M)):(x.expandByPoint(dn.min),x.expandByPoint(dn.max))}x.getCenter(e);for(var a=0,i=0,r=t.count;i<r;i++)M.fromBufferAttribute(t,i),a=Math.max(a,e.distanceToSquared(M));if(n)for(i=0,r=n.length;i<r;i++)for(var o=n[i],s=this.morphTargetsRelative,c=0,h=o.count;c<h;c++)M.fromBufferAttribute(o,c),s&&(fn.fromBufferAttribute(t,c),M.add(fn)),a=Math.max(a,e.distanceToSquared(M));this.boundingSphere.radius=Math.sqrt(a),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}},computeFaceNormals:function(){},computeVertexNormals:function(){var t=this.index,n=this.attributes;if(n.position){var e=n.position.array;if(void 0===n.normal)this.setAttribute("normal",new y(new Float32Array(e.length),3));else for(var i=n.normal.array,r=0,o=i.length;r<o;r++)i[r]=0;var a,s,c,h=n.normal.array,u=new E,l=new E,f=new E,d=new E,v=new E;if(t)for(var p=t.array,r=0,o=t.count;r<o;r+=3)a=3*p[r+0],s=3*p[r+1],c=3*p[r+2],u.fromArray(e,a),l.fromArray(e,s),f.fromArray(e,c),d.subVectors(f,l),v.subVectors(u,l),d.cross(v),h[a]+=d.x,h[1+a]+=d.y,h[2+a]+=d.z,h[s]+=d.x,h[1+s]+=d.y,h[2+s]+=d.z,h[c]+=d.x,h[1+c]+=d.y,h[2+c]+=d.z;else for(r=0,o=e.length;r<o;r+=9)u.fromArray(e,r),l.fromArray(e,r+3),f.fromArray(e,r+6),d.subVectors(f,l),v.subVectors(u,l),d.cross(v),h[r]=d.x,h[r+1]=d.y,h[r+2]=d.z,h[r+3]=d.x,h[r+4]=d.y,h[r+5]=d.z,h[r+6]=d.x,h[r+7]=d.y,h[r+8]=d.z;this.normalizeNormals(),n.normal.needsUpdate=!0}},normalizeNormals:function(){for(var t=this.attributes.normal,n=0,e=t.count;n<e;n++)M.x=t.getX(n),M.y=t.getY(n),M.z=t.getZ(n),M.normalize(),t.setXYZ(n,M.x,M.y,M.z)},dispose:function(){this.dispatchEvent({type:"dispose"})}});var vn=new _,pn=new ut,mn=new it,gn=new E,_n=new E,bn=new E,yn=new E,wn=new E,xn=new E,Mn=new E,Sn=new E,Ln=new E,En=new O,Tn=new O,Cn=new O,Dn=new E,Pn=new E;function An(t,n){h.call(this),this.type="Mesh",this.geometry=void 0!==t?t:new C,this.material=void 0!==n?n:new g,this.updateMorphTargets()}function Rn(t,n,e,i,r,o,a,s){i=n.side===Kt?i.intersectTriangle(a,o,r,!0,s):i.intersectTriangle(r,o,a,n.side!==Qt,s);if(null===i)return null;Pn.copy(s),Pn.applyMatrix4(t.matrixWorld);r=e.ray.origin.distanceTo(Pn);return r<e.near||r>e.far?null:{distance:r,point:Pn.clone(),object:t}}function Nn(t,n,e,i,r,o,a,s,c,h,u,l){gn.fromBufferAttribute(r,h),_n.fromBufferAttribute(r,u),bn.fromBufferAttribute(r,l);var f=t.morphTargetInfluences;if(n.morphTargets&&o&&f){Mn.set(0,0,0),Sn.set(0,0,0),Ln.set(0,0,0);for(var d=0,v=o.length;d<v;d++){var p=f[d],m=o[d];0!==p&&(yn.fromBufferAttribute(m,h),wn.fromBufferAttribute(m,u),xn.fromBufferAttribute(m,l),a?(Mn.addScaledVector(yn,p),Sn.addScaledVector(wn,p),Ln.addScaledVector(xn,p)):(Mn.addScaledVector(yn.sub(gn),p),Sn.addScaledVector(wn.sub(_n),p),Ln.addScaledVector(xn.sub(bn),p)))}gn.add(Mn),_n.add(Sn),bn.add(Ln)}r=Rn(t,n,e,i,gn,_n,bn,Dn);return r&&(s&&(En.fromBufferAttribute(s,h),Tn.fromBufferAttribute(s,u),Cn.fromBufferAttribute(s,l),r.uv=I.getUV(Dn,gn,_n,bn,En,Tn,Cn,new O)),c&&(En.fromBufferAttribute(c,h),Tn.fromBufferAttribute(c,u),Cn.fromBufferAttribute(c,l),r.uv2=I.getUV(Dn,gn,_n,bn,En,Tn,Cn,new O)),t=new qt(h,u,l),I.getNormal(gn,_n,bn,t.normal),r.face=t),r}function S(){this.type="Curve",this.arcLengthDivisions=200}function On(t,n){S.call(this),this.type="LineCurve3",this.v1=t||new E,this.v2=n||new E}function In(t,n,e,i,r,o,a,s){S.call(this),this.type="EllipseCurve",this.aX=t||0,this.aY=n||0,this.xRadius=e||1,this.yRadius=i||1,this.aStartAngle=r||0,this.aEndAngle=o||2*Math.PI,this.aClockwise=a||!1,this.aRotation=s||0}function Un(t,n,e,i,r,o){In.call(this,t,n,e,e,i,r,o),this.type="ArcCurve"}function Fn(){var r=0,o=0,a=0,s=0;function c(t,n,e,i){a=-3*(r=t)+3*n-2*(o=e)-i,s=2*t-2*n+e+i}return{initCatmullRom:function(t,n,e,i,r){c(n,e,r*(e-t),r*(i-n))},initNonuniformCatmullRom:function(t,n,e,i,r,o,a){t=(n-t)/r-(e-t)/(r+o)+(e-n)/o,r=(e-n)/o-(i-n)/(o+a)+(i-e)/a;c(n,e,t*=o,r*=o)},calc:function(t){var n=t*t;return r+o*t+a*n+s*(n*t)}}}An.prototype=Object.assign(Object.create(h.prototype),{constructor:An,isMesh:!0,copy:function(t){return h.prototype.copy.call(this,t),void 0!==t.morphTargetInfluences&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),void 0!==t.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this},updateMorphTargets:function(){var t,n,e,i=this.geometry;if(i.isBufferGeometry){var r=i.morphAttributes,o=Object.keys(r);if(0<o.length){var a=r[o[0]];if(void 0!==a)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},t=0,n=a.length;t<n;t++)e=a[t].name||String(t),this.morphTargetInfluences.push(0),this.morphTargetDictionary[e]=t}}else{r=i.morphTargets;void 0!==r&&0<r.length&&console.error("THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}},raycast:function(t,n){var e=this.geometry,i=this.material,r=this.matrixWorld;if(void 0!==i&&(null===e.boundingSphere&&e.computeBoundingSphere(),mn.copy(e.boundingSphere),mn.applyMatrix4(r),!1!==t.ray.intersectsSphere(mn)&&(vn.getInverse(r),pn.copy(t.ray).applyMatrix4(vn),null===e.boundingBox||!1!==pn.intersectsBox(e.boundingBox))))if(e.isBufferGeometry){var o,a,s,c,h,u,l,f,d,v=e.index,p=e.attributes.position,m=e.morphAttributes.position,g=e.morphTargetsRelative,_=e.attributes.uv,b=e.attributes.uv2,y=e.groups,w=e.drawRange;if(null!==v)if(Array.isArray(i))for(c=0,u=y.length;c<u;c++)for(d=i[(f=y[c]).materialIndex],h=Math.max(f.start,w.start),l=Math.min(f.start+f.count,w.start+w.count);h<l;h+=3)o=v.getX(h),a=v.getX(h+1),s=v.getX(h+2),(A=Nn(this,d,t,pn,p,m,g,_,b,o,a,s))&&(A.faceIndex=Math.floor(h/3),A.face.materialIndex=f.materialIndex,n.push(A));else for(c=Math.max(0,w.start),u=Math.min(v.count,w.start+w.count);c<u;c+=3)o=v.getX(c),a=v.getX(c+1),s=v.getX(c+2),(A=Nn(this,i,t,pn,p,m,g,_,b,o,a,s))&&(A.faceIndex=Math.floor(c/3),n.push(A));else if(void 0!==p)if(Array.isArray(i))for(c=0,u=y.length;c<u;c++)for(d=i[(f=y[c]).materialIndex],h=Math.max(f.start,w.start),l=Math.min(f.start+f.count,w.start+w.count);h<l;h+=3)(A=Nn(this,d,t,pn,p,m,g,_,b,o=h,a=h+1,s=h+2))&&(A.faceIndex=Math.floor(h/3),A.face.materialIndex=f.materialIndex,n.push(A));else for(c=Math.max(0,w.start),u=Math.min(p.count,w.start+w.count);c<u;c+=3)(A=Nn(this,i,t,pn,p,m,g,_,b,o=c,a=c+1,s=c+2))&&(A.faceIndex=Math.floor(c/3),n.push(A))}else if(e.isGeometry){var x,M=Array.isArray(i),S=e.vertices,L=e.faces,r=e.faceVertexUvs[0];0<r.length&&(x=r);for(var E=0,T=L.length;E<T;E++){var C,D,P,A,R=L[E],N=M?i[R.materialIndex]:i;void 0!==N&&(C=S[R.a],D=S[R.b],P=S[R.c],A=Rn(this,N,t,pn,C,D,P,Dn))&&(x&&x[E]&&(N=x[E],En.copy(N[0]),Tn.copy(N[1]),Cn.copy(N[2]),A.uv=I.getUV(Dn,C,D,P,En,Tn,Cn,new O)),A.face=R,A.faceIndex=E,n.push(A))}}},clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),Object.assign(S.prototype,{getPoint:function(){return console.warn("THREE.Curve: .getPoint() not implemented."),null},getPointAt:function(t,n){t=this.getUtoTmapping(t);return this.getPoint(t,n)},getPoints:function(t){void 0===t&&(t=5);for(var n=[],e=0;e<=t;e++)n.push(this.getPoint(e/t));return n},getSpacedPoints:function(t){void 0===t&&(t=5);for(var n=[],e=0;e<=t;e++)n.push(this.getPointAt(e/t));return n},getLength:function(){var t=this.getLengths();return t[t.length-1]},getLengths:function(t){if(void 0===t&&(t=this.arcLengthDivisions),this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var n,e,i=[],r=this.getPoint(0),o=0;for(i.push(0),e=1;e<=t;e++)o+=(n=this.getPoint(e/t)).distanceTo(r),i.push(o),r=n;return this.cacheArcLengths=i},updateArcLengths:function(){this.needsUpdate=!0,this.getLengths()},getUtoTmapping:function(t,n){for(var e,i=this.getLengths(),r=0,o=i.length,a=n||t*i[o-1],s=0,c=o-1;s<=c;)if((e=i[r=Math.floor(s+(c-s)/2)]-a)<0)s=r+1;else{if(!(0<e)){c=r;break}c=r-1}return i[r=c]===a?r/(o-1):(r+(a-(n=i[r]))/(i[r+1]-n))/(o-1)},getTangent:function(t){var n=t-1e-4,t=t+1e-4,n=(1<t&&(t=1),this.getPoint(n=n<0?0:n));return this.getPoint(t).clone().sub(n).normalize()},getTangentAt:function(t){t=this.getUtoTmapping(t);return this.getTangent(t)},computeFrenetFrames:function(t,n){for(var e,i=new E,r=[],o=[],a=[],s=new E,c=new _,h=0;h<=t;h++)r[h]=this.getTangentAt(h/t),r[h].normalize();o[0]=new E,a[0]=new E;var u=Number.MAX_VALUE,l=Math.abs(r[0].x),f=Math.abs(r[0].y),d=Math.abs(r[0].z);for(l<=u&&(u=l,i.set(1,0,0)),f<=u&&(u=f,i.set(0,1,0)),d<=u&&i.set(0,0,1),s.crossVectors(r[0],i).normalize(),o[0].crossVectors(r[0],s),a[0].crossVectors(r[0],o[0]),h=1;h<=t;h++)o[h]=o[h-1].clone(),a[h]=a[h-1].clone(),s.crossVectors(r[h-1],r[h]),s.length()>Number.EPSILON&&(s.normalize(),e=Math.acos(v.clamp(r[h-1].dot(r[h]),-1,1)),o[h].applyMatrix4(c.makeRotationAxis(s,e))),a[h].crossVectors(r[h],o[h]);if(!0===n)for(e=Math.acos(v.clamp(o[0].dot(o[t]),-1,1)),e/=t,0<r[0].dot(s.crossVectors(o[0],o[t]))&&(e=-e),h=1;h<=t;h++)o[h].applyMatrix4(c.makeRotationAxis(r[h],e*h)),a[h].crossVectors(r[h],o[h]);return{tangents:r,normals:o,binormals:a}},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}}),((On.prototype=Object.create(S.prototype)).constructor=On).prototype.isLineCurve3=!0,On.prototype.getPoint=function(t,n){n=n||new E;return 1===t?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n},On.prototype.getPointAt=function(t,n){return this.getPoint(t,n)},On.prototype.copy=function(t){return S.prototype.copy.call(this,t),this.v1.copy(t.v1),this.v2.copy(t.v2),this},((In.prototype=Object.create(S.prototype)).constructor=In).prototype.isEllipseCurve=!0,In.prototype.getPoint=function(t,n){for(var n=n||new O,e=2*Math.PI,i=this.aEndAngle-this.aStartAngle,r=Math.abs(i)<Number.EPSILON;i<0;)i+=e;for(;e<i;)i-=e;i<Number.EPSILON&&(i=r?0:e),!0!==this.aClockwise||r||(i===e?i=-e:i-=e);var o,a,s,c,r=this.aStartAngle+t*i,t=this.aX+this.xRadius*Math.cos(r),r=this.aY+this.yRadius*Math.sin(r);return 0!==this.aRotation&&(o=Math.cos(this.aRotation),a=Math.sin(this.aRotation),t=(s=t-this.aX)*o-(c=r-this.aY)*a+this.aX,r=s*a+c*o+this.aY),n.set(t,r)},In.prototype.copy=function(t){return S.prototype.copy.call(this,t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this},((Un.prototype=Object.create(In.prototype)).constructor=Un).prototype.isArcCurve=!0;var Hn=new E,jn=new Fn,kn=new Fn,Gn=new Fn;function zn(t,n,e,i){S.call(this),this.type="CatmullRomCurve3",this.points=t||[],this.closed=n||!1,this.curveType=e||"centripetal",this.tension=i||.5}function Bn(t,n,e,i,r){var n=.5*(i-n),r=.5*(r-e),o=t*t;return(2*e-2*i+n+r)*(t*o)+(-3*e+3*i-2*n-r)*o+n*t+e}function Vn(t,n,e,i){return(r=1-(r=t))*r*n+2*(1-t)*t*e+t*t*i;var r}function Wn(t,n,e,i,r){return(o=1-(o=t))*o*o*n+3*(o=1-t)*o*t*e+3*(1-t)*t*t*i+t*t*t*r;var o}function Xn(t,n,e,i){S.call(this),this.type="CubicBezierCurve",this.v0=t||new O,this.v1=n||new O,this.v2=e||new O,this.v3=i||new O}function Yn(t,n,e,i){S.call(this),this.type="CubicBezierCurve3",this.v0=t||new E,this.v1=n||new E,this.v2=e||new E,this.v3=i||new E}function Zn(t,n){S.call(this),this.type="LineCurve",this.v1=t||new O,this.v2=n||new O}function qn(t,n,e){S.call(this),this.type="QuadraticBezierCurve",this.v0=t||new O,this.v1=n||new O,this.v2=e||new O}function Kn(t){S.call(this),this.type="SplineCurve",this.points=t||[]}function Qn(){S.call(this),this.type="CurvePath",this.curves=[],this.autoClose=!1}((zn.prototype=Object.create(S.prototype)).constructor=zn).prototype.isCatmullRomCurve3=!0,zn.prototype.getPoint=function(t,n){var e,i,r,o,n=n||new E,a=this.points,s=a.length,t=(s-(this.closed?0:1))*t,c=Math.floor(t),t=t-c;return this.closed?c+=0<c?0:(Math.floor(Math.abs(c)/s)+1)*s:0===t&&c===s-1&&(c=s-2,t=1),e=this.closed||0<c?a[(c-1)%s]:(Hn.subVectors(a[0],a[1]).add(a[0]),Hn),i=a[c%s],r=a[(c+1)%s],c=this.closed||c+2<s?a[(c+2)%s]:(Hn.subVectors(a[s-1],a[s-2]).add(a[s-1]),Hn),"centripetal"===this.curveType||"chordal"===this.curveType?(a="chordal"===this.curveType?.5:.25,s=Math.pow(e.distanceToSquared(i),a),(o=Math.pow(i.distanceToSquared(r),a))<1e-4&&(o=1),s<1e-4&&(s=o),(a=Math.pow(r.distanceToSquared(c),a))<1e-4&&(a=o),jn.initNonuniformCatmullRom(e.x,i.x,r.x,c.x,s,o,a),kn.initNonuniformCatmullRom(e.y,i.y,r.y,c.y,s,o,a),Gn.initNonuniformCatmullRom(e.z,i.z,r.z,c.z,s,o,a)):"catmullrom"===this.curveType&&(jn.initCatmullRom(e.x,i.x,r.x,c.x,this.tension),kn.initCatmullRom(e.y,i.y,r.y,c.y,this.tension),Gn.initCatmullRom(e.z,i.z,r.z,c.z,this.tension)),n.set(jn.calc(t),kn.calc(t),Gn.calc(t)),n},zn.prototype.copy=function(t){S.prototype.copy.call(this,t),this.points=[];for(var n=0,e=t.points.length;n<e;n++){var i=t.points[n];this.points.push(i.clone())}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this},((Xn.prototype=Object.create(S.prototype)).constructor=Xn).prototype.isCubicBezierCurve=!0,Xn.prototype.getPoint=function(t,n){var n=n||new O,e=this.v0,i=this.v1,r=this.v2,o=this.v3;return n.set(Wn(t,e.x,i.x,r.x,o.x),Wn(t,e.y,i.y,r.y,o.y)),n},Xn.prototype.copy=function(t){return S.prototype.copy.call(this,t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this},((Yn.prototype=Object.create(S.prototype)).constructor=Yn).prototype.isCubicBezierCurve3=!0,Yn.prototype.getPoint=function(t,n){var n=n||new E,e=this.v0,i=this.v1,r=this.v2,o=this.v3;return n.set(Wn(t,e.x,i.x,r.x,o.x),Wn(t,e.y,i.y,r.y,o.y),Wn(t,e.z,i.z,r.z,o.z)),n},Yn.prototype.copy=function(t){return S.prototype.copy.call(this,t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this},((Zn.prototype=Object.create(S.prototype)).constructor=Zn).prototype.isLineCurve=!0,Zn.prototype.getPoint=function(t,n){n=n||new O;return 1===t?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n},Zn.prototype.getPointAt=function(t,n){return this.getPoint(t,n)},Zn.prototype.getTangent=function(){return this.v2.clone().sub(this.v1).normalize()},Zn.prototype.copy=function(t){return S.prototype.copy.call(this,t),this.v1.copy(t.v1),this.v2.copy(t.v2),this},((qn.prototype=Object.create(S.prototype)).constructor=qn).prototype.isQuadraticBezierCurve=!0,qn.prototype.getPoint=function(t,n){var n=n||new O,e=this.v0,i=this.v1,r=this.v2;return n.set(Vn(t,e.x,i.x,r.x),Vn(t,e.y,i.y,r.y)),n},qn.prototype.copy=function(t){return S.prototype.copy.call(this,t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this},((Kn.prototype=Object.create(S.prototype)).constructor=Kn).prototype.isSplineCurve=!0,Kn.prototype.getPoint=function(t,n){var n=n||new O,e=this.points,t=(e.length-1)*t,i=Math.floor(t),t=t-i,r=e[0===i?i:i-1],o=e[i],a=e[i>e.length-2?e.length-1:i+1],e=e[i>e.length-3?e.length-1:i+2];return n.set(Bn(t,r.x,o.x,a.x,e.x),Bn(t,r.y,o.y,a.y,e.y)),n},Kn.prototype.copy=function(t){S.prototype.copy.call(this,t),this.points=[];for(var n=0,e=t.points.length;n<e;n++){var i=t.points[n];this.points.push(i.clone())}return this},Qn.prototype=Object.assign(Object.create(S.prototype),{constructor:Qn,add:function(t){this.curves.push(t)},closePath:function(){var t=this.curves[0].getPoint(0),n=this.curves[this.curves.length-1].getPoint(1);t.equals(n)||this.curves.push(new Zn(n,t))},getPoint:function(t){for(var n,e,i,r=t*this.getLength(),o=this.getCurveLengths(),a=0;a<o.length;){if(o[a]>=r)return n=o[a]-r,i=(e=this.curves[a]).getLength(),e.getPointAt(0===i?0:1-n/i);a++}return null},getLength:function(){var t=this.getCurveLengths();return t[t.length-1]},updateArcLengths:function(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()},getCurveLengths:function(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;for(var t=[],n=0,e=0,i=this.curves.length;e<i;e++)n+=this.curves[e].getLength(),t.push(n);return this.cacheLengths=t},getSpacedPoints:function(t){void 0===t&&(t=40);for(var n=[],e=0;e<=t;e++)n.push(this.getPoint(e/t));return this.autoClose&&n.push(n[0]),n},getPoints:function(t){t=t||12;for(var n,e=[],i=0,r=this.curves;i<r.length;i++)for(var o=r[i],a=o&&o.isEllipseCurve?2*t:o&&(o.isLineCurve||o.isLineCurve3)?1:o&&o.isSplineCurve?t*o.points.length:t,s=o.getPoints(a),c=0;c<s.length;c++){var h=s[c];n&&n.equals(h)||(e.push(h),n=h)}return this.autoClose&&1<e.length&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e},copy:function(t){S.prototype.copy.call(this,t),this.curves=[];for(var n=0,e=t.curves.length;n<e;n++){var i=t.curves[n];this.curves.push(i.clone())}return this.autoClose=t.autoClose,this}});var Jn=0,L=new _,$n=new h,te=new E;function ne(){Object.defineProperty(this,"id",{value:Jn+=2}),this.uuid=v.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}function ee(t,n,e,i,r,o){ne.call(this),this.type="TubeGeometry",this.parameters={path:t,tubularSegments:n,radius:e,radialSegments:i,closed:r},void 0!==o&&console.warn("THREE.TubeGeometry: taper has been removed.");o=new ie(t,n,e,i,r);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals,this.fromBufferGeometry(o),this.mergeVertices()}function ie(o,a,s,c,t){C.call(this),this.type="TubeBufferGeometry",this.parameters={path:o,tubularSegments:a,radius:s,radialSegments:c,closed:t},a=a||64,s=s||1,c=c||8,t=t||!1;var n,h,u=o.computeFrenetFrames(a,t),l=(this.tangents=u.tangents,this.normals=u.normals,this.binormals=u.binormals,new E),f=new E,e=new O,d=new E,v=[],p=[],i=[],r=[];for(n=0;n<a;n++)y(n);for(y(!1===t?a:0),n=0;n<=a;n++)for(h=0;h<=c;h++)e.x=n/a,e.y=h/c,i.push(e.x,e.y);for(h=1;h<=a;h++)for(n=1;n<=c;n++){var m=(c+1)*(h-1)+(n-1),g=(c+1)*h+(n-1),_=(c+1)*h+n,b=(c+1)*(h-1)+n;r.push(m,g,b),r.push(g,_,b)}function y(t){d=o.getPointAt(t/a,d);var n=u.normals[t],e=u.binormals[t];for(h=0;h<=c;h++){var i=h/c*Math.PI*2,r=Math.sin(i),i=-Math.cos(i);f.x=i*n.x+r*e.x,f.y=i*n.y+r*e.y,f.z=i*n.z+r*e.z,f.normalize(),p.push(f.x,f.y,f.z),l.x=d.x+s*f.x,l.y=d.y+s*f.y,l.z=d.z+s*f.z,v.push(l.x,l.y,l.z)}}this.setIndex(r),this.setAttribute("position",new T(v,3)),this.setAttribute("normal",new T(p,3)),this.setAttribute("uv",new T(i,2))}ne.prototype=Object.assign(Object.create(mt.prototype),{constructor:ne,isGeometry:!0,applyMatrix4:function(t){for(var n=(new u).getNormalMatrix(t),e=0,i=this.vertices.length;e<i;e++)this.vertices[e].applyMatrix4(t);for(e=0,i=this.faces.length;e<i;e++){var r=this.faces[e];r.normal.applyMatrix3(n).normalize();for(var o=0,a=r.vertexNormals.length;o<a;o++)r.vertexNormals[o].applyMatrix3(n).normalize()}return null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this},rotateX:function(t){return L.makeRotationX(t),this.applyMatrix4(L),this},rotateY:function(t){return L.makeRotationY(t),this.applyMatrix4(L),this},rotateZ:function(t){return L.makeRotationZ(t),this.applyMatrix4(L),this},translate:function(t,n,e){return L.makeTranslation(t,n,e),this.applyMatrix4(L),this},scale:function(t,n,e){return L.makeScale(t,n,e),this.applyMatrix4(L),this},lookAt:function(t){return $n.lookAt(t),$n.updateMatrix(),this.applyMatrix4($n.matrix),this},fromBufferGeometry:function(t){var o=this,n=null!==t.index?t.index.array:void 0,e=t.attributes;if(void 0===e.position)console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion.");else{var i=e.position.array,a=void 0!==e.normal?e.normal.array:void 0,s=void 0!==e.color?e.color.array:void 0,c=void 0!==e.uv?e.uv.array:void 0,h=void 0!==e.uv2?e.uv2.array:void 0;void 0!==h&&(this.faceVertexUvs[1]=[]);for(var r=0;r<i.length;r+=3)o.vertices.push((new E).fromArray(i,r)),void 0!==s&&o.colors.push((new m).fromArray(s,r));var u=t.groups;if(0<u.length)for(r=0;r<u.length;r++)for(var l=u[r],f=l.start,d=f,v=f+l.count;d<v;d+=3)void 0!==n?p(n[d],n[d+1],n[d+2],l.materialIndex):p(d,d+1,d+2,l.materialIndex);else if(void 0!==n)for(r=0;r<n.length;r+=3)p(n[r],n[r+1],n[r+2]);else for(r=0;r<i.length/3;r+=3)p(r,r+1,r+2);this.computeFaceNormals(),null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone())}return this;function p(t,n,e,i){var r=void 0===s?[]:[o.colors[t].clone(),o.colors[n].clone(),o.colors[e].clone()],r=new qt(t,n,e,void 0===a?[]:[(new E).fromArray(a,3*t),(new E).fromArray(a,3*n),(new E).fromArray(a,3*e)],r,i);o.faces.push(r),void 0!==c&&o.faceVertexUvs[0].push([(new O).fromArray(c,2*t),(new O).fromArray(c,2*n),(new O).fromArray(c,2*e)]),void 0!==h&&o.faceVertexUvs[1].push([(new O).fromArray(h,2*t),(new O).fromArray(h,2*n),(new O).fromArray(h,2*e)])}},center:function(){return this.computeBoundingBox(),this.boundingBox.getCenter(te).negate(),this.translate(te.x,te.y,te.z),this},normalize:function(){this.computeBoundingSphere();var t=this.boundingSphere.center,n=this.boundingSphere.radius,n=0===n?1:1/n,e=new _;return e.set(n,0,0,-n*t.x,0,n,0,-n*t.y,0,0,n,-n*t.z,0,0,0,1),this.applyMatrix4(e),this},computeFaceNormals:function(){for(var t=new E,n=new E,e=0,i=this.faces.length;e<i;e++){var r=this.faces[e],o=this.vertices[r.a],a=this.vertices[r.b],s=this.vertices[r.c];t.subVectors(s,a),n.subVectors(o,a),t.cross(n),t.normalize(),r.normal.copy(t)}},computeVertexNormals:function(t){var n,e,i;for(void 0===t&&(t=!0),i=new Array(this.vertices.length),n=0,e=this.vertices.length;n<e;n++)i[n]=new E;if(t)for(var r,o,a,s=new E,c=new E,h=0,u=this.faces.length;h<u;h++)l=this.faces[h],r=this.vertices[l.a],o=this.vertices[l.b],a=this.vertices[l.c],s.subVectors(a,o),c.subVectors(r,o),s.cross(c),i[l.a].add(s),i[l.b].add(s),i[l.c].add(s);else for(this.computeFaceNormals(),h=0,u=this.faces.length;h<u;h++)i[(l=this.faces[h]).a].add(l.normal),i[l.b].add(l.normal),i[l.c].add(l.normal);for(n=0,e=this.vertices.length;n<e;n++)i[n].normalize();for(h=0,u=this.faces.length;h<u;h++){var l,f=(l=this.faces[h]).vertexNormals;3===f.length?(f[0].copy(i[l.a]),f[1].copy(i[l.b]),f[2].copy(i[l.c])):(f[0]=i[l.a].clone(),f[1]=i[l.b].clone(),f[2]=i[l.c].clone())}0<this.faces.length&&(this.normalsNeedUpdate=!0)},computeFlatVertexNormals:function(){var t,n;for(this.computeFaceNormals(),t=0,n=this.faces.length;t<n;t++){var e,i=(e=this.faces[t]).vertexNormals;3===i.length?(i[0].copy(e.normal),i[1].copy(e.normal),i[2].copy(e.normal)):(i[0]=e.normal.clone(),i[1]=e.normal.clone(),i[2]=e.normal.clone())}0<this.faces.length&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){var t,n,e;for(a=0,s=this.faces.length;a<s;a++)for((e=this.faces[a]).P?e.P.copy(e.normal):e.P=e.normal.clone(),e.A||(e.A=[]),t=0,n=e.vertexNormals.length;t<n;t++)e.A[t]?e.A[t].copy(e.vertexNormals[t]):e.A[t]=e.vertexNormals[t].clone();var i=new ne;for(i.faces=this.faces,t=0,n=this.morphTargets.length;t<n;t++){if(!this.morphNormals[t]){this.morphNormals[t]={},this.morphNormals[t].faceNormals=[],this.morphNormals[t].vertexNormals=[];for(var r=this.morphNormals[t].faceNormals,o=this.morphNormals[t].vertexNormals,a=0,s=this.faces.length;a<s;a++)c=new E,h={a:new E,b:new E,c:new E},r.push(c),o.push(h)}var c,h,u=this.morphNormals[t];for(i.vertices=this.morphTargets[t].vertices,i.computeFaceNormals(),i.computeVertexNormals(),a=0,s=this.faces.length;a<s;a++)e=this.faces[a],c=u.faceNormals[a],h=u.vertexNormals[a],c.copy(e.normal),h.a.copy(e.vertexNormals[0]),h.b.copy(e.vertexNormals[1]),h.c.copy(e.vertexNormals[2])}for(a=0,s=this.faces.length;a<s;a++)(e=this.faces[a]).normal=e.P,e.vertexNormals=e.A},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new tt),this.boundingBox.setFromPoints(this.vertices)},computeBoundingSphere:function(){null===this.boundingSphere&&(this.boundingSphere=new it),this.boundingSphere.setFromPoints(this.vertices)},mergeVertices:function(){for(var t,n,e,i,r={},o=[],a=[],s=Math.pow(10,4),c=0,h=this.vertices.length;c<h;c++)t=this.vertices[c],void 0===r[t=Math.round(t.x*s)+"_"+Math.round(t.y*s)+"_"+Math.round(t.z*s)]?(r[t]=c,o.push(this.vertices[c]),a[c]=o.length-1):a[c]=a[r[t]];var u=[];for(c=0,h=this.faces.length;c<h;c++){(n=this.faces[c]).a=a[n.a],n.b=a[n.b],n.c=a[n.c];for(var l=[n.a,n.b,n.c],f=0;f<3;f++)if(l[f]===l[(f+1)%3]){u.push(c);break}}for(c=u.length-1;0<=c;c--){var d=u[c];for(this.faces.splice(d,1),e=0,i=this.faceVertexUvs.length;e<i;e++)this.faceVertexUvs[e].splice(d,1)}var v=this.vertices.length-o.length;return this.vertices=o,v},setFromPoints:function(t){this.vertices=[];for(var n=0,e=t.length;n<e;n++){var i=t[n];this.vertices.push(new E(i.x,i.y,i.z||0))}return this},sortFacesByMaterialIndex:function(){for(var t=this.faces,n=t.length,e=0;e<n;e++)t[e].R=e;t.sort(function(t,n){return t.materialIndex-n.materialIndex});var i,r,o=this.faceVertexUvs[0],a=this.faceVertexUvs[1];o&&o.length===n&&(i=[]),a&&a.length===n&&(r=[]);for(e=0;e<n;e++){var s=t[e].R;i&&i.push(o[s]),r&&r.push(a[s])}i&&(this.faceVertexUvs[0]=i),r&&(this.faceVertexUvs[1]=r)},dispose:function(){this.dispatchEvent({type:"dispose"})}}),(ee.prototype=Object.create(ne.prototype)).constructor=ee,(ie.prototype=Object.create(C.prototype)).constructor=ie;var re=0;function D(t,n,e,i,r,o,a,s,c,h){Object.defineProperty(this,"id",{value:re++}),this.uuid=v.generateUUID(),this.name="",this.image=void 0!==t?t:D.DEFAULT_IMAGE,this.mipmaps=[],this.mapping=void 0!==n?n:D.DEFAULT_MAPPING,this.wrapS=void 0!==e?e:1001,this.wrapT=void 0!==i?i:1001,this.magFilter=void 0!==r?r:1006,this.minFilter=void 0!==o?o:1008,this.anisotropy=void 0!==c?c:1,this.format=void 0!==a?a:1023,this.internalFormat=null,this.type=void 0!==s?s:1009,this.offset=new O(0,0),this.repeat=new O(1,1),this.center=new O(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new u,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=void 0!==h?h:3e3,this.version=0,this.onUpdate=null}function oe(t,n,e,i,r,o,a,s,c){D.call(this,t,n,e,i,r,o,a,s,c),this.needsUpdate=!0}function ae(t){e.call(this),this.type="MeshPhongMaterial",this.color=new m(16777215),this.specular=new m(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new m(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new O(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function se(t){return(se="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function ce(t,n){for(var e=0;e<n.length;e++){var i=n[e];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,function(t){t=function(t,n){if("object"!=se(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0===e)return("string"===n?String:Number)(t);e=e.call(t,n||"default");if("object"!=se(e))return e;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"==se(t)?t:String(t)}(i.key),i)}}function he(t,n,e){return n&&ce(t.prototype,n),e&&ce(t,e),Object.defineProperty(t,"prototype",{writable:!1}),t}D.DEFAULT_IMAGE=void 0,D.DEFAULT_MAPPING=300,D.prototype=Object.assign(Object.create(mt.prototype),{constructor:D,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(t){return this.name=t.name,this.image=t.image,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.encoding=t.encoding,this},dispose:function(){this.dispatchEvent({type:"dispose"})},transformUv:function(t){if(300===this.mapping){if(t.applyMatrix3(this.matrix),t.x<0||1<t.x)switch(this.wrapS){case 1e3:t.x=t.x-Math.floor(t.x);break;case 1001:t.x=t.x<0?0:1;break;case 1002:1===Math.abs(Math.floor(t.x)%2)?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x)}if(t.y<0||1<t.y)switch(this.wrapT){case 1e3:t.y=t.y-Math.floor(t.y);break;case 1001:t.y=t.y<0?0:1;break;case 1002:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}this.flipY&&(t.y=1-t.y)}return t}}),Object.defineProperty(D.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),((oe.prototype=Object.create(D.prototype)).constructor=oe).prototype.isCanvasTexture=!0,((ae.prototype=Object.create(e.prototype)).constructor=ae).prototype.isMeshPhongMaterial=!0,ae.prototype.copy=function(t){return e.prototype.copy.call(this,t),this.color.copy(t.color),this.specular.copy(t.specular),this.shininess=t.shininess,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this};var t=he(function t(n,e){if(!(this instanceof t))throw new TypeError("Cannot call a class as a function");this.N=n.points,this.O=n.color,this.I=n.opacity,void 0===this.I&&(this.I=1),this.U=n.radius,this.F=n.height,void 0===this.F&&(this.F=0),this.H=null,this.j=n.url,this.k=null,this.G=null,this.B=n.count,this.V=new fengmap.FMBound,this.W=e}),ue=(Object.assign(t.prototype,{X:function(){var t=this.k;if(!t)return!1;t.enableUpdateRender()},Y:function(t,n){var e=new Image;e.crossOrigin="Anonymous",e.onload=function(){var t=document.createElement("canvas");t.width=512,t.height=512,t.getContext("2d").drawImage(e,0,0,512,512),n&&n(t,e.width,e.height)},e.src=t},Z:function(t,n,e,i){for(var r=0,o=0;o<i.length-1;o++){var a=i[o],s=i[o+1];r+=Math.sqrt((a.x-s.x)*(a.x-s.x)+(a.y-s.y)*(a.y-s.y))}return t*=e/n,Math.floor(r/t)},q:function(t,n,e){var i=this.k;if(!i)return!1;for(var r=[],o=0;o<t.length;o++){var a=new E(t[o].x-i.x,t[o].z+n/2+e,-t[o].y+i.y);r.push(a)}return r},K:function(t,n){t=new oe(t);return t.repeat.set(n,1),t.wrapS=t.wrapT=1e3,t},J:function(t,n){return new g({color:new m(t),opacity:n,transparent:!0})},$:function(t,n,e,i,r,o){var a=this,s=null,s=t.type===fengmap.FMType.TUBE_MARKER?new ae({color:new m(e),opacity:i,side:Qt,transparent:!0}):this.J(e,i),c=(void 0!==r&&(s.visible=!1),new An(n,s));return c.mapNode=t,void 0!==r&&this.Y(r,function(t){t=a.K(t,o);c.material.map=t,c.material.color=null,c.material.needsUpdate=!0,c.material.visible=!0,a.X()}),c},tt:function(t){t=new oe(t);t.repeat.set(this.B,1),t.wrapS=t.wrapT=1e3,this.H.material.color=null,this.H.material.map=t,this.H.material.needsUpdate=!0,this.H.material.visible=!0,this.X()}}),t);function le(t){return(le="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function fe(t,n){for(var e=0;e<n.length;e++){var i=n[e];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,function(t){t=function(t,n){if("object"!=le(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0===e)return("string"===n?String:Number)(t);e=e.call(t,n||"default");if("object"!=le(e))return e;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"==le(t)?t:String(t)}(i.key),i)}}function de(t,n,e){n=pe(n);var i=t,n=ve()?Reflect.construct(n,e||[],pe(t).constructor):n.apply(t,e);if(n&&("object"===le(n)||"function"==typeof n))return n;if(void 0!==n)throw new TypeError("Derived constructors may only return object or undefined");t=i;if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}function ve(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(ve=function(){return!!t})()}function pe(t){return(pe=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function me(t,n){return(me=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t})(t,n)}var t=function(){var t,n,e=r,i=ue;if("function"!=typeof i&&null!==i)throw new TypeError("Super expression must either be null or a function");function r(t,n){if(this instanceof r)return(n=de(this,r,[t,n])).nt=t.extrudeHeight,void 0===n.nt&&(n.nt=1),n.H=null,n.et=90,n.it=null,n.rt=!1,n.ot=!1,n.st=null,n;throw new TypeError("Cannot call a class as a function")}return e.prototype=Object.create(i&&i.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),i&&me(e,i),e=r,t&&fe(e.prototype,t),n&&fe(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}(),ge=(Object.assign(t.prototype,{ct:function(){for(var i=this,t=new Qn,n=this.q(this.N,this.nt,this.F),e=0;e<n.length-1;e++){n[e].x===n[e+1].x&&(n[e+1].x=n[e+1].x+.01),n[e].z===n[e+1].z&&(n[e+1].z=n[e+1].z+.01);var r=new On(n[e],n[e+1]);t.curves.push(r)}var o=new ie(t,this.et*(n.length-1),this.nt/2,2),a=this.J(this.O,this.I);return void 0!==this.j&&(a.visible=!1),this.H=new An(o,a),this.H.mapNode=this.W,void 0!==this.j?this.Y(this.j,function(t,n,e){void 0===i.B&&(i.B=i.Z(n,e,i.nt,i.N)),i.ht(t)}):this.X(),!0},ht:function(t){var n=this.ut(t),e=document.createElement("canvas"),i=(e.width=512,e.height=1024,e.getContext("2d")),t=(i.drawImage(t,0,0,512,512),i.drawImage(n,0,512,512,512),this.K(this.lt(e),this.B));this.H.material.color=null,this.H.material.map=t,this.H.material.needsUpdate=!0,this.H.material.visible=!0,this.X()},lt:function(t){var n=document.createElement("canvas"),e=(n.width=t.width,n.height=t.height,n.getContext("2d"));return e.translate(n.width,0),e.scale(-1,1),e.drawImage(t,0,0,n.width,n.height),n},ut:function(t){var n=document.createElement("canvas"),e=(n.width=512,n.height=512,n.getContext("2d"));return e.translate(256,256),e.rotate(Math.PI),e.drawImage(t,-256,-256),this.lt(n)}}),t);function _e(t){return(_e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function be(t,n){for(var e=0;e<n.length;e++){var i=n[e];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,Le(i.key),i)}}function ye(t,n,e){n=Ce(n);var i=t,n=we()?Reflect.construct(n,e||[],Ce(t).constructor):n.apply(t,e);if(n&&("object"===_e(n)||"function"==typeof n))return n;if(void 0!==n)throw new TypeError("Derived constructors may only return object or undefined");return xe(i)}function we(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(we=function(){return!!t})()}function xe(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function Me(t,n,e,i){return(Me="undefined"!=typeof Reflect&&Reflect.set?Reflect.set:function(t,n,e,i){var r,t=Te(t,n);if(t){if((r=Object.getOwnPropertyDescriptor(t,n)).set)return r.set.call(i,e),!0;if(!r.writable)return!1}if(r=Object.getOwnPropertyDescriptor(i,n)){if(!r.writable)return!1;r.value=e,Object.defineProperty(i,n,r)}else t=i,r=e,!((i=Le(i=n))in t?Object.defineProperty(t,i,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[i]=r);return!0})(t,n,e,i)}function Se(t,n,e,i,r){if(!Me(t,n,e,i||t)&&r)throw new TypeError("failed to set property")}function Le(t){t=function(t,n){if("object"!=_e(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0===e)return("string"===n?String:Number)(t);e=e.call(t,n||"default");if("object"!=_e(e))return e;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"==_e(t)?t:String(t)}function Ee(){return(Ee="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,n,e){var i=Te(t,n);if(i)return(i=Object.getOwnPropertyDescriptor(i,n)).get?i.get.call(arguments.length<3?t:e):i.value}).apply(this,arguments)}function Te(t,n){for(;!Object.prototype.hasOwnProperty.call(t,n)&&null!==(t=Ce(t)););return t}function Ce(t){return(Ce=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function De(t,n){return(De=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t})(t,n)}var Pe=function(t){var n,e=i;if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");function i(t){if(this instanceof i)return(t=ye(this,i,[t])).tool=null,t.update=t.update.bind(xe(t)),t.resize=t.resize.bind(xe(t)),t;throw new TypeError("Cannot call a class as a function")}return e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&De(e,t),e=i,(t=[{key:"count",get:function(){return this.tool.B},set:function(t){this.tool.B=t,this.type!==fengmap.FMType.LINE3D_MARKER?this.tool.H.material.map&&(this.tool.H.material.map.repeat.set(this.tool.B,1),this.tool.H.material.needsUpdate=!0):this.tool.H.material.map&&(this.tool.ft=!1,this.tool.H.material.repeat=new O(this.tool.B,1)),this.tool.X()}},{key:"opacity",get:function(){return this.tool.I},set:function(t){this.tool.I=t,this.tool.H&&(this.tool.H.material.opacity=this.tool.I,this.tool.X())}},{key:"points",get:function(){return this.tool.N},set:function(t){this.tool.N=t,this.reCreateObject()}},{key:"color",get:function(){return this.tool.O},set:function(t){this.tool.O=t,this.tool.H.material.color=new m(t),this.tool.X()}},{key:"bound",get:function(){return!0===Ee(Ce(i.prototype),"needUpdateBound",this)&&(this.tool.V.reset(),this.tool.V.expandByCoords(this.tool.N),Se(Ce(i.prototype),"needUpdateBound",!1,this,!0)),this.tool.V.clone()}},{key:"x",get:function(){return this.bound.center.x}},{key:"y",get:function(){return this.bound.center.y}},{key:"url",get:function(){return this.tool.j},set:function(t){var n=this;this.tool.j=t,"ShaderMaterial"===this.tool.H.material.type?this.tool.it.getMaterial(this,function(t){n.tool.H.material.dispose(),n.tool.H.material=t}):this.tool.j&&this.tool.Y(this.tool.j,function(t){n.type!==fengmap.FMType.WALL_MARKER?n.tool.tt(t):n.tool.ht(t)})}},{key:"radius",get:function(){return this.tool.U},set:function(t){this.tool.U=t,this.reCreateObject(),this.updateLineMaterial(),this.tool.X()}},{key:"height",get:function(){return this.tool.F},set:function(t){this.tool.F=t,this.reCreateObject(),this.updateLineMaterial(),this.tool.X()}},{key:"visible",get:function(){return Ee(Ce(i.prototype),"visible",this)},set:function(t){Se(Ce(i.prototype),"visible",t,this,!0),this.tool.H&&(this.tool.H.visible=t),this.tool.X()}},{key:"addTo",value:function(t){this.isInit=!0,Ee(Ce(i.prototype),"addTo",this).call(this,t),this.tool.k=t.parent.parent,this.tool.G=t,this.tool.ct(),this.parent.scene.add(this.tool.H)}},{key:"remove",value:function(){var t,n=this.tool.k;n&&((t=this.tool.H.parent)&&t.remove(this.tool.H),this.parent&&this.parent.remove(this),n)&&(n.enableUpdateRender(),this.tool.rt&&n.off("update",this.update),this.type===fengmap.FMType.LINE3D_MARKER)&&n.off("resize",this.resize)}},{key:"getRenderNode",value:function(){return this.tool.H}},{key:"update",value:function(){var t,n,e=this;this.type!==fengmap.FMType.SPHERE_MARKER?null!==this.tool.it&&(this.type===fengmap.FMType.LINE3D_MARKER?void 0!==this.tool.B&&(t=this.tool.it.speed/this.tool.B,(n=this.tool.H.material.offset).x=n.x+t/1e3,this.tool.H.material.offset=n,this.tool.X()):("ShaderMaterial"!==this.tool.H.material.type&&this.tool.it.getMaterial(this,function(t){e.tool.H.material.dispose(),e.tool.H.material=t}),this.tool.H.material.uniforms&&(this.tool.it.update(this),this.tool.X()))):null!==this.tool.dt&&("ShaderMaterial"!==this.tool.H.material.type&&this.tool.dt.getMaterial(this,function(t){e.tool.H.material.dispose(),e.tool.H.material=t}),this.tool.H.material.uniforms)&&(this.tool.dt.update(this.tool.H),this.tool.X())}},{key:"resize",value:function(){var t=window.innerWidth,n=window.innerHeight,e=this.tool.k;e&&(t=e.getContainer().clientWidth,n=e.getContainer().clientHeight),this.tool.H.material.resolution=new O(t,n),this.tool.X()}},{key:"addEffect",value:function(t,n,e){var i=this,r=this.tool.k;r&&"FMFlowEffect"===t.type&&(void 0===this.tool.j?console.error("没有图片不能加特效"):this.type!==fengmap.FMType.LINE3D_MARKER?(this.tool.it=t,this.tool.it.getMaterial(this,function(t){i.tool.rt||(i.tool.H.material.dispose(),i.tool.H.material=t,i.tool.ot=!0,r.on("update",i.update),i.tool.rt=!0)})):(void 0!==e&&(this.tool.H.material.isbackground=!0,this.tool.H.material.bgcolor=new m(e)),void 0!==n&&(this.tool.H.material.luminance=n),this.tool.vt=e,this.tool.gt=n,this.tool.it=t,this.tool.rt=!0,r.on("update",this.update)))}},{key:"removeEffect",value:function(t){var n=this;"FMFlowEffect"===t.type&&(this.tool.it=null),this.tool.rt=!1,null===this.tool.it&&(t=this.tool.k)&&(t.off("update",this._t),this.tool.H.material.dispose(),this.type===fengmap.FMType.TUBE_MARKER?(t=new ae({color:new m(this.tool.O),opacity:this.tool.I,side:Qt,transparent:!0}),this.tool.H.material=t,void 0!==this.tool.j&&this.tool.Y(this.tool.j,function(t){t=new oe(t);t.repeat.set(n.tool.B,1),n.tool.H.material.color=null,t.wrapS=t.wrapT=1e3,n.tool.H.material.map=t,n.tool.H.material.needsUpdate=!0,n.tool.X()}),this.tool.X()):this.type===fengmap.FMType.WALL_MARKER?(t=new g({color:new m(this.tool.O),opacity:this.tool.I,transparent:!0}),this.tool.H.material=t,void 0!==this.tool.j&&this.tool.Y(this.tool.j,function(t){n.tool.ht(t)}),this.tool.X()):(this.tool.H.material.offset=new O(1,1),this.tool.H.material.isbackground=!1,this.tool.H.material.luminance=1))}},{key:"reCreateObject",value:function(){var t=this.tool.H.parent;t.remove(this.tool.H),this.tool.H.geometry.dispose(),this.tool.H.material.dispose(),this.tool.ct(),t.add(this.tool.H),this.tool.X()}},{key:"updateLineMaterial",value:function(){this.type===fengmap.FMType.LINE3D_MARKER&&(void 0!==this.tool.vt&&(this.tool.H.material.isbackground=!0,this.tool.H.material.bgcolor=new m(this.tool.vt)),void 0!==this.tool.gt)&&(this.tool.H.material.luminance=this.tool.gt)}}])&&be(e.prototype,t),n&&be(e,n),Object.defineProperty(e,"prototype",{writable:!1}),i}(fengmap.FMMarker);function Ae(t){return(Ae="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Re(t,n){for(var e=0;e<n.length;e++){var i=n[e];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,function(t){t=function(t,n){if("object"!=Ae(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0===e)return("string"===n?String:Number)(t);e=e.call(t,n||"default");if("object"!=Ae(e))return e;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"==Ae(t)?t:String(t)}(i.key),i)}}function Ne(t,n,e){n=He(n);var i=t,n=Oe()?Reflect.construct(n,e||[],He(t).constructor):n.apply(t,e);if(n&&("object"===Ae(n)||"function"==typeof n))return n;if(void 0!==n)throw new TypeError("Derived constructors may only return object or undefined");return Ie(i)}function Oe(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(Oe=function(){return!!t})()}function Ie(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function Ue(t,n){return(Ue=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t})(t,n)}function Fe(){return(Fe="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,n,e){var i=function(t,n){for(;!Object.prototype.hasOwnProperty.call(t,n)&&null!==(t=He(t)););return t}(t,n);if(i)return(i=Object.getOwnPropertyDescriptor(i,n)).get?i.get.call(arguments.length<3?t:e):i.value}).apply(this,arguments)}function He(t){return(He=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}t=function(){var t,n=i,e=Pe;if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");function i(t){var n,e;if(this instanceof i)return Fe((n=Ie(e=Ne(this,i,[t])),He(i.prototype)),"setType",n).call(n,H.WALL_MARKER),e.tool=new ge(t,Ie(e)),e;throw new TypeError("Cannot call a class as a function")}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),Object.defineProperty(n,"prototype",{writable:!1}),e&&Ue(n,e),n=i,(e=[{key:"extrudeHeight",get:function(){return this.tool.nt},set:function(t){this.tool.nt=t,this.reCreateObject()}},{key:"radius",get:function(){return null},set:function(t){}}])&&Re(n.prototype,e),t&&Re(n,t),Object.defineProperty(n,"prototype",{writable:!1}),i}();function je(o,a,s,c,t){C.call(this),this.type="TubeBufferGeometry",this.parameters={path:o,tubularSegments:a,radius:s,radialSegments:c,closed:t},a=a||64,s=s||1,c=c||8,t=t||!1;var n,h,u=o.computeFrenetFrames(a,t),l=(this.tangents=u.tangents,this.normals=u.normals,this.binormals=u.binormals,new E),f=new E,e=new O,d=new E,v=[],p=[],i=[],r=[];for(n=0;n<a;n++)y(n);for(y(!1===t?a:0),n=0;n<=a;n++)for(h=0;h<=c;h++)e.x=n/a,e.y=h/c,i.push(e.x,e.y);for(h=1;h<=a;h++)for(n=1;n<=c;n++){var m=(c+1)*(h-1)+(n-1),g=(c+1)*h+(n-1),_=(c+1)*h+n,b=(c+1)*(h-1)+n;r.push(m,g,b),r.push(g,_,b)}function y(t){d=o.getPointAt(t/a,d);var n=u.normals[t],e=u.binormals[t];for(h=0;h<=c;h++){var i=h/c*Math.PI*2,r=(4===c&&(i=h*Math.PI/2+Math.PI/4),Math.sin(i)),i=-Math.cos(i);f.x=i*n.x+r*e.x,f.y=i*n.y+r*e.y,f.z=i*n.z+r*e.z,f.normalize(),p.push(f.x,f.y,f.z),l.x=d.x+s*f.x,l.y=d.y+s*f.y,l.z=d.z+s*f.z,v.push(l.x,l.y,l.z)}}this.setIndex(r),this.setAttribute("position",new T(v,3)),this.setAttribute("normal",new T(p,3)),this.setAttribute("uv",new T(i,2))}function ke(t){return(ke="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Ge(t,n){for(var e=0;e<n.length;e++){var i=n[e];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,function(t){t=function(t,n){if("object"!=ke(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0===e)return("string"===n?String:Number)(t);e=e.call(t,n||"default");if("object"!=ke(e))return e;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"==ke(t)?t:String(t)}(i.key),i)}}function ze(t,n,e){n=Ve(n);var i=t,n=Be()?Reflect.construct(n,e||[],Ve(t).constructor):n.apply(t,e);if(n&&("object"===ke(n)||"function"==typeof n))return n;if(void 0!==n)throw new TypeError("Derived constructors may only return object or undefined");t=i;if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}function Be(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(Be=function(){return!!t})()}function Ve(t){return(Ve=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function We(t,n){return(We=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t})(t,n)}(je.prototype=Object.create(C.prototype)).constructor=je;var Xe=function(){var t,n,e=r,i=ue;if("function"!=typeof i&&null!==i)throw new TypeError("Super expression must either be null or a function");function r(t,n){if(this instanceof r)return void 0===(n=ze(this,r,[t,n])).U&&(n.U=2),n.bt=t.tubularSegments,void 0===n.bt&&(n.bt=64),n.yt=t.radialSegments,void 0===n.yt&&(n.yt=8),void 0===n.B&&(n.B=1),n.H=null,n.it=null,n.st=null,n.rt=!1,n.ot=!1,n;throw new TypeError("Cannot call a class as a function")}return e.prototype=Object.create(i&&i.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),i&&We(e,i),e=r,t&&Ge(e.prototype,t),n&&Ge(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}(),Ye=(Object.assign(Xe.prototype,{ct:function(){for(var t=new Qn,n=this.q(this.N,2*this.U,this.F),e=0;e<n.length-1;e++){var i=new On(n[e],n[e+1]);t.curves.push(i)}var r=new je(t,this.bt,this.U,this.yt,!1);return this.H=this.$(this.W,r,this.O,this.I,this.j,this.B),this.X(),!0}}),Xe);function Ze(t){return(Ze="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function qe(t,n){for(var e=0;e<n.length;e++){var i=n[e];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,function(t){t=function(t,n){if("object"!=Ze(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0===e)return("string"===n?String:Number)(t);e=e.call(t,n||"default");if("object"!=Ze(e))return e;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"==Ze(t)?t:String(t)}(i.key),i)}}function Ke(t,n,e){n=ni(n);var i=t,n=Qe()?Reflect.construct(n,e||[],ni(t).constructor):n.apply(t,e);if(n&&("object"===Ze(n)||"function"==typeof n))return n;if(void 0!==n)throw new TypeError("Derived constructors may only return object or undefined");return Je(i)}function Qe(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(Qe=function(){return!!t})()}function Je(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function $e(t,n){return($e=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t})(t,n)}function ti(){return(ti="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,n,e){var i=function(t,n){for(;!Object.prototype.hasOwnProperty.call(t,n)&&null!==(t=ni(t)););return t}(t,n);if(i)return(i=Object.getOwnPropertyDescriptor(i,n)).get?i.get.call(arguments.length<3?t:e):i.value}).apply(this,arguments)}function ni(t){return(ni=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}Xe=function(){var t,n=i,e=Pe;if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");function i(t){var n,e;if(this instanceof i)return ti((n=Je(e=Ke(this,i,[t])),ni(i.prototype)),"setType",n).call(n,H.TUBE_MARKER),e.tool=new Ye(t,Je(e)),e;throw new TypeError("Cannot call a class as a function")}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),Object.defineProperty(n,"prototype",{writable:!1}),e&&$e(n,e),n=i,(e=[{key:"tubularSegments",get:function(){return this.tool.bt},set:function(t){this.tool.bt=t,this.reCreateObject()}},{key:"radialSegments",get:function(){return this.tool.yt},set:function(t){this.tool.yt=t,this.reCreateObject()}}])&&qe(n.prototype,e),t&&qe(n,t),Object.defineProperty(n,"prototype",{writable:!1}),i}();function ei(t){e.call(this),this.type="LineBasicMaterial",this.color=new m(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.setValues(t)}((ei.prototype=Object.create(e.prototype)).constructor=ei).prototype.isLineBasicMaterial=!0,ei.prototype.copy=function(t){return e.prototype.copy.call(this,t),this.color.copy(t.color),this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this};var ii=new E,ri=new E,oi=new _,ai=new ut,si=new it;function ci(t,n,e){1===e&&console.error("THREE.Line: parameter THREE.LinePieces no longer supported. Use THREE.LineSegments instead."),h.call(this),this.type="Line",this.geometry=void 0!==t?t:new C,this.material=void 0!==n?n:new ei}ci.prototype=Object.assign(Object.create(h.prototype),{constructor:ci,isLine:!0,computeLineDistances:function(){var t=this.geometry;if(t.isBufferGeometry)if(null===t.index){for(var n=t.attributes.position,e=[0],i=1,r=n.count;i<r;i++)ii.fromBufferAttribute(n,i-1),ri.fromBufferAttribute(n,i),e[i]=e[i-1],e[i]+=ii.distanceTo(ri);t.setAttribute("lineDistance",new T(e,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else if(t.isGeometry){var o=t.vertices;(e=t.lineDistances)[0]=0;for(i=1,r=o.length;i<r;i++)e[i]=e[i-1],e[i]+=o[i-1].distanceTo(o[i])}return this},raycast:function(t,n){var e=this.geometry,i=this.matrixWorld,r=t.params.Line.threshold;if(null===e.boundingSphere&&e.computeBoundingSphere(),si.copy(e.boundingSphere),si.applyMatrix4(i),si.radius+=r,!1!==t.ray.intersectsSphere(si)){oi.getInverse(i),ai.copy(t.ray).applyMatrix4(oi);var i=r/((this.scale.x+this.scale.y+this.scale.z)/3),o=i*i,a=new E,s=new E,c=new E,h=new E,u=this&&this.isLineSegments?2:1;if(e.isBufferGeometry){var r=e.index,l=e.attributes.position.array;if(null!==r)for(var f=r.array,d=0,v=f.length-1;d<v;d+=u){var p=f[d],m=f[d+1];a.fromArray(l,3*p),s.fromArray(l,3*m),o<ai.distanceSqToSegment(a,s,h,c)||(h.applyMatrix4(this.matrixWorld),(g=t.ray.origin.distanceTo(h))<t.near)||g>t.far||n.push({distance:g,point:c.clone().applyMatrix4(this.matrixWorld),index:d,face:null,faceIndex:null,object:this})}else for(d=0,v=l.length/3-1;d<v;d+=u)a.fromArray(l,3*d),s.fromArray(l,3*d+3),o<ai.distanceSqToSegment(a,s,h,c)||(h.applyMatrix4(this.matrixWorld),(g=t.ray.origin.distanceTo(h))<t.near)||g>t.far||n.push({distance:g,point:c.clone().applyMatrix4(this.matrixWorld),index:d,face:null,faceIndex:null,object:this})}else if(e.isGeometry)for(var g,_=e.vertices,b=_.length,d=0;d<b-1;d+=u)o<ai.distanceSqToSegment(_[d],_[d+1],h,c)||(h.applyMatrix4(this.matrixWorld),(g=t.ray.origin.distanceTo(h))<t.near)||g>t.far||n.push({distance:g,point:c.clone().applyMatrix4(this.matrixWorld),index:d,face:null,faceIndex:null,object:this})}},clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}});var hi=new E,ui=new E;function li(t,n){ci.call(this,t,n),this.type="LineSegments"}li.prototype=Object.assign(Object.create(ci.prototype),{constructor:li,isLineSegments:!0,computeLineDistances:function(){var t=this.geometry;if(t.isBufferGeometry)if(null===t.index){for(var n=t.attributes.position,e=[],i=0,r=n.count;i<r;i+=2)hi.fromBufferAttribute(n,i),ui.fromBufferAttribute(n,i+1),e[i]=0===i?0:e[i-1],e[i+1]=e[i]+hi.distanceTo(ui);t.setAttribute("lineDistance",new T(e,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else if(t.isGeometry)for(var o=t.vertices,e=t.lineDistances,i=0,r=o.length;i<r;i+=2)hi.copy(o[i]),ui.copy(o[i+1]),e[i]=0===i?0:e[i-1],e[i+1]=e[i]+hi.distanceTo(ui);return this}});var P={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( STANDARD )\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\n#ifdef USE_TANGENT\n\n\tvec3 objectTangent = vec3( tangent.xyz );\n\n#endif\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\nvec3 F_Schlick_RoughnessDependent( const in vec3 F0, const in float dotNV, const in float roughness ) {\n\n\t// See F_Schlick\n\tfloat fresnel = exp2( ( -5.55473 * dotNV - 6.98316 ) * dotNV );\n\tvec3 Fr = max( vec3( 1.0 - roughness ), F0 ) - F0;\n\n\treturn Fr * fresnel + F0;\n\n}\n\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’s 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)⋅G(v) / 4(n⋅l)(n⋅v)\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’s 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 vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\n\tfloat alpha = pow2( roughness ); // UE4\'s roughness\n\n\tvec3 halfDir = normalize( incidentLight.direction + viewDir );\n\n\tfloat dotNL = saturate( dot( normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( 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 vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\n\treturn specularColor * brdf.x + brdf.y;\n\n} // validated\n\n// Fdez-Agüera\'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_RoughnessDependent( specularColor, dotNV, roughness );\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\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\n#if defined( USE_SHEEN )\n\n// https://github.com/google/filament/blob/master/shaders/src/brdf.fs#L94\nfloat D_Charlie(float roughness, float NoH) {\n\t// Estevez and Kulla 2017, "Production Friendly Microfacet Sheen BRDF"\n\tfloat invAlpha = 1.0 / roughness;\n\tfloat cos2h = NoH * NoH;\n\tfloat sin2h = max(1.0 - cos2h, 0.0078125); // 2^(-14/2), so sin2h^2 > 0 in fp16\n\treturn (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI);\n}\n\n// https://github.com/google/filament/blob/master/shaders/src/brdf.fs#L136\nfloat V_Neubelt(float NoV, float NoL) {\n\t// Neubelt and Pettineo 2013, "Crafting a Next-gen Material Pipeline for The Order: 1886"\n\treturn saturate(1.0 / (4.0 * (NoL + NoV - NoL * NoV)));\n}\n\nvec3 BRDF_Specular_Sheen( const in float roughness, const in vec3 L, const in GeometricContext geometry, vec3 specularColor ) {\n\n\tvec3 N = geometry.normal;\n\tvec3 V = geometry.viewDir;\n\n\tvec3 H = normalize( V + L );\n\tfloat dotNH = saturate( dot( N, H ) );\n\n\treturn specularColor * D_Charlie( roughness, dotNH ) * V_Neubelt( dot(N, V), dot(N, L) );\n\n}\n\n#endif\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_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\n\t}\n\t#pragma unroll_loop_end\n\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\n\t\tbool clipped = true;\n\n\t\t#pragma unroll_loop_start\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( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\n\t\t}\n\t\t#pragma unroll_loop_end\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\tvarying vec3 vClipPosition;\n\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n\n#endif\n",clipping_planes_pars_vertex:"\n#if NUM_CLIPPING_PLANES > 0\n\n\tvarying vec3 vClipPosition;\n\n#endif\n",clipping_planes_vertex:"\n#if NUM_CLIPPING_PLANES > 0\n\n\tvClipPosition = - mvPosition.xyz;\n\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#ifndef saturate\n// <tonemapping_pars_fragment> may have defined saturate() already\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement(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\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat max3( vec3 v ) { return max( max( v.x, v.y ), v.z ); }\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\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#ifdef CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\n\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n}\n\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t// dir can be either a direction vector or a normal vector\n\t// upper-left 3x3 of matrix is assumed to be orthogonal\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\nbool isPerspectiveMatrix( mat4 m ) {\n\n return m[ 2 ][ 3 ] == - 1.0;\n\n}\n",cube_uv_reflection_fragment:"\n#ifdef ENVMAP_TYPE_CUBE_UV\n\n#define cubeUV_maxMipLevel 8.0\n#define cubeUV_minMipLevel 4.0\n#define cubeUV_maxTileSize 256.0\n#define cubeUV_minTileSize 16.0\n\n// These shader functions convert between the UV coordinates of a single face of\n// a cubemap, the 0-5 integer index of a cube face, and the direction vector for\n// sampling a textureCube (not generally normalized).\n\nfloat getFace(vec3 direction) {\n vec3 absDirection = abs(direction);\n float face = -1.0;\n if (absDirection.x > absDirection.z) {\n if (absDirection.x > absDirection.y)\n face = direction.x > 0.0 ? 0.0 : 3.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n } else {\n if (absDirection.z > absDirection.y)\n face = direction.z > 0.0 ? 2.0 : 5.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n }\n return face;\n}\n\nvec2 getUV(vec3 direction, float face) {\n vec2 uv;\n if (face == 0.0) {\n uv = vec2(-direction.z, direction.y) / abs(direction.x);\n } else if (face == 1.0) {\n uv = vec2(direction.x, -direction.z) / abs(direction.y);\n } else if (face == 2.0) {\n uv = direction.xy / abs(direction.z);\n } else if (face == 3.0) {\n uv = vec2(direction.z, direction.y) / abs(direction.x);\n } else if (face == 4.0) {\n uv = direction.xz / abs(direction.y);\n } else {\n uv = vec2(-direction.x, direction.y) / abs(direction.z);\n }\n return 0.5 * (uv + 1.0);\n}\n\nvec3 bilinearCubeUV(sampler2D envMap, vec3 direction, float mipInt) {\n float face = getFace(direction);\n float filterInt = max(cubeUV_minMipLevel - mipInt, 0.0);\n mipInt = max(mipInt, cubeUV_minMipLevel);\n float faceSize = exp2(mipInt);\n\n float texelSize = 1.0 / (3.0 * cubeUV_maxTileSize);\n\n vec2 uv = getUV(direction, face) * (faceSize - 1.0);\n vec2 f = fract(uv);\n uv += 0.5 - f;\n if (face > 2.0) {\n uv.y += faceSize;\n face -= 3.0;\n }\n uv.x += face * faceSize;\n if(mipInt < cubeUV_maxMipLevel){\n uv.y += 2.0 * cubeUV_maxTileSize;\n }\n uv.y += filterInt * 2.0 * cubeUV_minTileSize;\n uv.x += 3.0 * max(0.0, cubeUV_maxTileSize - 2.0 * faceSize);\n uv *= texelSize;\n\n vec3 tl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n uv.x += texelSize;\n vec3 tr = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n uv.y += texelSize;\n vec3 br = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n uv.x -= texelSize;\n vec3 bl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n vec3 tm = mix(tl, tr, f.x);\n vec3 bm = mix(bl, br, f.x);\n return mix(tm, bm, f.y);\n}\n\n// These defines must match with PMREMGenerator\n\n#define r0 1.0\n#define v0 0.339\n#define m0 -2.0\n#define r1 0.8\n#define v1 0.276\n#define m1 -1.0\n#define r4 0.4\n#define v4 0.046\n#define m4 2.0\n#define r5 0.305\n#define v5 0.016\n#define m5 3.0\n#define r6 0.21\n#define v6 0.0038\n#define m6 4.0\n\nfloat roughnessToMip(float roughness) {\n float mip = 0.0;\n if (roughness >= r1) {\n mip = (r0 - roughness) * (m1 - m0) / (r0 - r1) + m0;\n } else if (roughness >= r4) {\n mip = (r1 - roughness) * (m4 - m1) / (r1 - r4) + m1;\n } else if (roughness >= r5) {\n mip = (r4 - roughness) * (m5 - m4) / (r4 - r5) + m4;\n } else if (roughness >= r6) {\n mip = (r5 - roughness) * (m6 - m5) / (r5 - r6) + m5;\n } else {\n mip = -2.0 * log2(1.16 * roughness);// 1.16 = 1.79^0.25\n }\n return mip;\n}\n\nvec4 textureCubeUV(sampler2D envMap, vec3 sampleDir, float roughness) {\n float mip = clamp(roughnessToMip(roughness), m0, cubeUV_maxMipLevel);\n float mipF = fract(mip);\n float mipInt = floor(mip);\n\n vec3 color0 = bilinearCubeUV(envMap, sampleDir, mipInt);\n if (mipF == 0.0) {\n return vec4(color0, 1.0);\n } else {\n vec3 color1 = bilinearCubeUV(envMap, sampleDir, mipInt + 1.0);\n return vec4(mix(color0, color1, mipF), 1.0);\n }\n}\n#endif\n",defaultnormal_vertex:"\nvec3 transformedNormal = objectNormal;\n\n#ifdef USE_INSTANCING\n\n\t// this is in lieu of a per-instance normal-matrix\n\t// shear transforms in the instance matrix are not supported\n\n\tmat3 m = mat3( instanceMatrix );\n\n\ttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n\n\ttransformedNormal = m * transformedNormal;\n\n#endif\n\ntransformedNormal = normalMatrix * transformedNormal;\n\n#ifdef FLIP_SIDED\n\n\ttransformedNormal = - transformedNormal;\n\n#endif\n\n#ifdef USE_TANGENT\n\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\n\t#ifdef FLIP_SIDED\n\n\t\ttransformedTangent = - transformedTangent;\n\n\t#endif\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, vUv ).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:"\ngl_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\t// NOTE: The implementation with min causes the shader to not compile on\n\t// a common Alcatel A502DL in Chrome 78/Android 8.1. Some research suggests \n\t// that the chipset is Mediatek MT6739 w/ IMG PowerVR GE8100 GPU.\n\t// D = min( floor( D ) / 255.0, 1.0 );\n\tD = clamp( floor( D ) / 255.0, 0.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#ifdef ENV_WORLDPOS\n\n\t\tvec3 cameraToFrag;\n\t\t\n\t\tif ( isOrthographic ) {\n\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\n\t\t} else {\n\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\n\t\t}\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( cameraToFrag, worldNormal );\n\n\t\t#else\n\n\t\t\tvec3 reflectVec = refract( cameraToFrag, 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_CUBE_UV )\n\n\t\tvec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );\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\t#ifndef ENVMAP_TYPE_CUBE_UV\n\n\t\tenvColor = envMapTexelToLinear( envColor );\n\n\t#endif\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_common_pars_fragment:"\n#ifdef USE_ENVMAP\n\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform int maxMipLevel;\n\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif\n",envmap_pars_fragment:"\n#ifdef USE_ENVMAP\n\n\tuniform float reflectivity;\n\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\n\t\t#define ENV_WORLDPOS\n\n\t#endif\n\n\t#ifdef ENV_WORLDPOS\n\n\t\tvarying vec3 vWorldPosition;\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\n\t\t#define ENV_WORLDPOS\n\n\t#endif\n\n\t#ifdef ENV_WORLDPOS\n\t\t\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 )\n\n\t#ifdef ENVMAP_MODE_REFRACTION\n\t\tuniform float refractionRatio;\n\t#endif\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\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 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// Trowbridge-Reitz distribution to Mip level, following the logic of http://casual-effects.blogspot.ca/2011/08/plausible-environment-lighting-in-two.html\n\tfloat getSpecularMIPLevel( const in float roughness, const in int maxMIPLevel ) {\n\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\n\t\tfloat sigma = PI * roughness * roughness / ( 1.0 + roughness );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar + log2( sigma );\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 vec3 viewDir, const in vec3 normal, const in float roughness, const in int maxMIPLevel ) {\n\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\n\t\t vec3 reflectVec = reflect( -viewDir, normal );\n\n\t\t // Mixing the reflection with the normal is more accurate and keeps rough objects from gathering light from behind their tangent plane.\n\t\t reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\n\t\t#else\n\n\t\t vec3 reflectVec = refract( -viewDir, normal, refractionRatio );\n\n\t\t#endif\n\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( roughness, 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\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\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#ifdef ENV_WORLDPOS\n\n\t\tvWorldPosition = worldPosition.xyz;\n\n\t#else\n\n\t\tvec3 cameraToVertex;\n\n\t\tif ( isOrthographic ) { \n\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\n\t\t} else {\n\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\n\t\t}\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 = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth );\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\n#ifdef USE_GRADIENTMAP\n\n\tuniform sampler2D gradientMap;\n\n#endif\n\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\n\t// dotNL will be from -1.0 to 1.0\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\n\t#ifdef USE_GRADIENTMAP\n\n\t\treturn texture2D( gradientMap, coord ).rgb;\n\n\t#else\n\n\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\n\t#endif\n\n}\n\n",lightmap_fragment:"\n#ifdef USE_LIGHTMAP\n\n\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\treflectedLight.indirectDiffuse += PI * lightMapTexelToLinear( lightMapTexel ).rgb * 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 = ( isOrthographic ) ? vec3( 0, 0, 1 ) : 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_start\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\t#pragma unroll_loop_end\n\n#endif\n\n#if NUM_SPOT_LIGHTS > 0\n\n\t#pragma unroll_loop_start\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\t#pragma unroll_loop_end\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_start\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\t#pragma unroll_loop_end\n\n#endif\n\n#if NUM_HEMI_LIGHTS > 0\n\n\t#pragma unroll_loop_start\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\t#pragma unroll_loop_end\n\n#endif\n",lights_pars_begin:"\nuniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\n\n// get the irradiance (radiance convolved with cosine lobe) at the point 'normal' on the unit sphere\n// source: https://graphics.stanford.edu/papers/envmap/envmap.pdf\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\n\t// normal is assumed to have unit length\n\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\n\t// band 0\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\n\t// band 1\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\n\t// band 2\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\n\treturn result;\n\n}\n\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in GeometricContext geometry ) {\n\n\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\n\treturn irradiance;\n\n}\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\t};\n\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\n\t#endif\n\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\t};\n\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\n\t#endif\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\t};\n\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\n\t#endif\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_toon_fragment:"\nToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;\n",lights_toon_pars_fragment:"\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n#endif\n\n\nstruct ToonMaterial {\n\n\tvec3\tdiffuseColor;\n\tvec3\tspecularColor;\n\tfloat\tspecularShininess;\n\tfloat\tspecularStrength;\n\n};\n\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\n\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\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_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial 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_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon\n\n#define Material_LightProbeLOD( material )\t(0)\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\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\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\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 );\n\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\n\nmaterial.specularRoughness = max( roughnessFactor, 0.0525 );// 0.0525 corresponds to the base mip of a 256 cubemap.\nmaterial.specularRoughness += geometryRoughness;\nmaterial.specularRoughness = min( material.specularRoughness, 1.0 );\n\n#ifdef REFLECTIVITY\n\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n\n#else\n\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n\n#endif\n\n#ifdef CLEARCOAT\n\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\n\t#ifdef USE_CLEARCOATMAP\n\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vUv ).x;\n\n\t#endif\n\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y;\n\n\t#endif\n\n\tmaterial.clearcoat = saturate( material.clearcoat ); // Burley clearcoat model\n\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n\n#endif\n\n#ifdef USE_SHEEN\n\n\tmaterial.sheenColor = sheen;\n\n#endif\n",lights_physical_pars_fragment:"\nstruct PhysicalMaterial {\n\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n\n#ifdef CLEARCOAT\n\tfloat clearcoat;\n\tfloat clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tvec3 sheenColor;\n#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#ifdef CLEARCOAT\n\n\t\tfloat ccDotNL = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\n\t\tvec3 ccIrradiance = ccDotNL * directLight.color;\n\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\n\t\t\tccIrradiance *= PI; // punctual light\n\n\t\t#endif\n\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\n\t\treflectedLight.directSpecular += ccIrradiance * material.clearcoat * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\n\t#else\n\n\t\tfloat clearcoatDHR = 0.0;\n\n\t#endif\n\n\t#ifdef USE_SHEEN\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_Sheen(\n\t\t\tmaterial.specularRoughness,\n\t\t\tdirectLight.direction,\n\t\t\tgeometry,\n\t\t\tmaterial.sheenColor\n\t\t);\n\t#else\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness);\n\t#endif\n\n\treflectedLight.directDiffuse += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\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#ifdef CLEARCOAT\n\n\t\tfloat ccDotNV = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\n\t\treflectedLight.indirectSpecular += clearcoatRadiance * material.clearcoat * BRDF_Specular_GGX_Environment( geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\n\t\tfloat ccDotNL = ccDotNV;\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\n\t#else\n\n\t\tfloat clearcoatDHR = 0.0;\n\n\t#endif\n\n\tfloat clearcoatInv = 1.0 - clearcoatDHR;\n\n\t// Both indirect specular and indirect diffuse light accumulate here\n\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\n\tBRDF_Specular_Multiscattering_Environment( geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering );\n\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n\n\treflectedLight.indirectSpecular += clearcoatInv * radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n\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// 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 = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n\n#ifdef CLEARCOAT\n\n\tgeometry.clearcoatNormal = clearcoatNormal;\n\n#endif\n\nIncidentLight directLight;\n\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\n\t#pragma unroll_loop_start\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#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\n\tSpotLight spotLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\n\t#pragma unroll_loop_start\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#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\n\t#pragma unroll_loop_start\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#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\n\t}\n\t#pragma unroll_loop_end\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_start\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\t#pragma unroll_loop_end\n\n#endif\n\n#if defined( RE_IndirectDiffuse )\n\n\tvec3 iblIrradiance = vec3( 0.0 );\n\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry );\n\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\n\t\t#pragma unroll_loop_start\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\t\t#pragma unroll_loop_end\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\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\tvec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * 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( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\n\t\tiblIrradiance += 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.viewDir, geometry.normal, material.specularRoughness, maxMipLevel );\n\n\t#ifdef CLEARCOAT\n\n\t\tclearcoatRadiance += getLightProbeIndirectRadiance( /*specularLightProbe,*/ geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness, maxMipLevel );\n\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, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n\n#endif\n",logdepthbuf_fragment:"\n#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\n\t// Doing a strict comparison with == 1.0 can cause noise artifacts\n\t// on some platforms. See issue #17623.\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : 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\tvarying float vIsPerspective;\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\t\tvarying float vIsPerspective;\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\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\n\t#else\n\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\n\t\t\tgl_Position.z *= gl_Position.w;\n\n\t\t}\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_fragment_1:"\n#ifdef USE_MAP\n\n\tvec4 texelColor = texture2D( map, vUv );\n\n\ttexelColor = mapTexelToLinear( texelColor );\n\t\n\tif(mapMixColor){\n\t diffuseColor = texelColor*texelColor.a + diffuseColor*(1.0-texelColor.a);\n\t}else {\n\t diffuseColor *= texelColor;\n\t}\n\n#endif\n",map_pars_fragment:"\n#ifdef USE_MAP\n\n\tuniform sampler2D map;\n\n#endif\n",map_particle_fragment:"\n#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\n\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\n#endif\n\n#ifdef USE_MAP\n\n\tvec4 mapTexel = texture2D( map, uv );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n\n#endif\n\n#ifdef USE_ALPHAMAP\n\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n\n#endif\n",map_particle_pars_fragment:"\n#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\n\tuniform mat3 uvTransform;\n\n#endif\n\n#ifdef USE_MAP\n\n\tuniform sampler2D map;\n\n#endif\n\n#ifdef USE_ALPHAMAP\n\n\tuniform sampler2D alphaMap;\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\t// morphTargetBaseInfluence is set based on BufferGeometry.morphTargetsRelative value:\n\t// When morphTargetsRelative is false, this is set to 1 - sum(influences); this results in normal = sum((target - base) * influence)\n\t// When morphTargetsRelative is true, this is set to 1; as a result, all morph targets are simply added to the base after weighting\n\tobjectNormal *= morphTargetBaseInfluence;\n\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n\n#endif\n",morphtarget_pars_vertex:"\n#ifdef USE_MORPHTARGETS\n\n\tuniform float morphTargetBaseInfluence;\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\t// morphTargetBaseInfluence is set based on BufferGeometry.morphTargetsRelative value:\n\t// When morphTargetsRelative is false, this is set to 1 - sum(influences); this results in position = sum((target - base) * influence)\n\t// When morphTargetsRelative is true, this is set to 1; as a result, all morph targets are simply added to the base after weighting\n\ttransformed *= morphTargetBaseInfluence;\n\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\n\t#ifndef USE_MORPHNORMALS\n\n\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\ttransformed += morphTarget7 * 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\t#ifdef USE_TANGENT\n\n\t\tvec3 tangent = normalize( vTangent );\n\t\tvec3 bitangent = normalize( vBitangent );\n\n\t\t#ifdef DOUBLE_SIDED\n\n\t\t\ttangent = tangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t\tbitangent = bitangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\n\t\t#endif\n\n\t\t#if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )\n\n\t\t\tmat3 vTBN = mat3( tangent, bitangent, normal );\n\n\t\t#endif\n\n\t#endif\n\n#endif\n\n// non perturbed normal for clearcoat among others\n\nvec3 geometryNormal = normal;\n\n",normal_fragment_maps:"\n\n#ifdef OBJECTSPACE_NORMALMAP\n\n\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0; // overrides both flatShading and attribute normals\n\n\t#ifdef FLIP_SIDED\n\n\t\tnormal = - normal;\n\n\t#endif\n\n\t#ifdef DOUBLE_SIDED\n\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\n\t#endif\n\n\tnormal = normalize( normalMatrix * normal );\n\n#elif defined( TANGENTSPACE_NORMALMAP )\n\n\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\n\t#ifdef USE_TANGENT\n\n\t\tnormal = normalize( vTBN * mapN );\n\n\t#else\n\n\t\tnormal = perturbNormal2Arb( -vViewPosition, normal, mapN );\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#endif\n\n#ifdef OBJECTSPACE_NORMALMAP\n\n\tuniform mat3 normalMatrix;\n\n#endif\n\n#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\n\n\t// Per-Pixel Tangent Space Normal Mapping\n\t// http://hacksoflife.blogspot.ch/2009/11/per-pixel-tangent-space-normal-mapping.html\n\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN ) {\n\n\t\t// Workaround for Adreno 3XX dFd*( vec3 ) bug. See #9988\n\n\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\n\t\tfloat scale = sign( st1.t * st0.s - st0.t * st1.s ); // we do not care about the magnitude\n\n\t\tvec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );\n\t\tvec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );\n\t\tvec3 N = normalize( surf_norm );\n\n\t\tmat3 tsn = mat3( S, T, N );\n\n\t\tmapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\n\t\treturn normalize( tsn * mapN );\n\n\t}\n\n#endif\n",clearcoat_normal_fragment_begin:"\n#ifdef CLEARCOAT\n\n\tvec3 clearcoatNormal = geometryNormal;\n\n#endif\n",clearcoat_normal_fragment_maps:"\n#ifdef USE_CLEARCOAT_NORMALMAP\n\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\n\t#ifdef USE_TANGENT\n\n\t\tclearcoatNormal = normalize( vTBN * clearcoatMapN );\n\n\t#else\n\n\t\tclearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN );\n\n\t#endif\n\n#endif\n",clearcoat_pars_fragment:"\n\n#ifdef USE_CLEARCOATMAP\n\n\tuniform sampler2D clearcoatMap;\n\n#endif\n\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\n\tuniform sampler2D clearcoatRoughnessMap;\n\n#endif\n\n#ifdef USE_CLEARCOAT_NORMALMAP\n\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\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\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ));\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w);\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\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 = vec4( transformed, 1.0 );\n\n#ifdef USE_INSTANCING\n\n\tmvPosition = instanceMatrix * mvPosition;\n\n#endif\n\nmvPosition = modelViewMatrix * mvPosition;\n\ngl_Position = projectionMatrix * mvPosition;\n",dithering_fragment:"\n#ifdef DITHERING\n\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n\n#endif\n",dithering_pars_fragment:"\n#ifdef 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_LIGHT_SHADOWS > 0\n\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\n\t#endif\n\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\n\t#endif\n\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\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\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\n\t}\n\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\n\t\tfloat occlusion = 1.0;\n\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\n\t\tfloat hard_shadow = step( compare , distribution.x ); // Hard Shadow\n\n\t\tif (hard_shadow != 1.0 ) {\n\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance ); // Chebeyshevs inequality\n\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); // 0.3 reduces light bleed\n\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\n\t\t}\n\t\treturn occlusion;\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\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\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( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), 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( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), 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 / 17.0 );\n\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), \n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\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 ) || defined( SHADOWMAP_TYPE_VSM )\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_LIGHT_SHADOWS > 0\n\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\n\t#endif\n\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\n\t#endif\n\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\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_LIGHT_SHADOWS > 0\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\n\n\t}\n\t#pragma unroll_loop_end\n\n\t#endif\n\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\n\n\t}\n\t#pragma unroll_loop_end\n\n\t#endif\n\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;\n\n\t}\n\t#pragma unroll_loop_end\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_LIGHT_SHADOWS > 0\n\n\tDirectionalLightShadow directionalLight;\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\n\t}\n\t#pragma unroll_loop_end\n\n\t#endif\n\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\n\tSpotLightShadow spotLight;\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\n\t}\n\t#pragma unroll_loop_end\n\n\t#endif\n\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\n\tPointLightShadow pointLight;\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\n\t}\n\t#pragma unroll_loop_end\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 highp 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\t#ifdef USE_TANGENT\n\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\n\t#endif\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\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n\n#endif\n",tonemapping_pars_fragment:"\n#ifndef saturate\n// <common> may have defined saturate() already\n#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_UV ) && ! defined( UVS_VERTEX_ONLY ) )\n\n\tvarying vec2 vUv;\n\n#endif\n",uv_pars_vertex:"\n#ifdef USE_UV\n\n\t#ifdef UVS_VERTEX_ONLY\n\n\t\tvec2 vUv;\n\n\t#else\n\n\t\tvarying vec2 vUv;\n\n\t#endif\n\n\tuniform mat3 uvTransform;\n\n#endif\n",uv_vertex:"\n#ifdef USE_UV\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\tuniform mat3 uv2Transform;\n\n#endif\n",uv2_vertex:"\n#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\n\tvUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;\n\n#endif\n",worldpos_vertex:"\n#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )\n\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\n\t#ifdef USE_INSTANCING\n\n\t\tworldPosition = instanceMatrix * worldPosition;\n\n\t#endif\n\n\tworldPosition = modelMatrix * worldPosition;\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:"\n\n#include <envmap_common_pars_fragment>\nuniform float opacity;\n\nvarying vec3 vWorldDirection;\n\n#include <cube_uv_reflection_fragment>\n\nvoid main() {\n\n\tvec3 vReflect = vWorldDirection;\n\t#include <envmap_fragment>\n\n\tgl_FragColor = envColor;\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\nvarying vec2 vHighPrecisionZW;\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// Higher precision equivalent of gl_FragCoord.z. This assumes depthRange has been left to its default values.\n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\n\t#if DEPTH_PACKING == 3200\n\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\n\t#elif DEPTH_PACKING == 3201\n\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\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\n// This is used for computing an equivalent of gl_FragCoord.z that is as high precision as possible.\n// Some platforms compute gl_FragCoord at a lower precision which makes the manually computed value better for\n// depth-based postprocessing effects. Reproduced on iPad with A10 processor / iPadOS 13.3.1.\nvarying vec2 vHighPrecisionZW;\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\tvHighPrecisionZW = gl_Position.zw;\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 <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_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\tvLineDistance = scale * lineDistance;\n\n\t#include <color_vertex>\n\t#include <begin_vertex>\n\t#include <project_vertex>\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_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <cube_uv_reflection_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\t\n\t\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\treflectedLight.indirectDiffuse += lightMapTexelToLinear( lightMapTexel ).rgb * 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 <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_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_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <cube_uv_reflection_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 <color_pars_fragment>\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 <color_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 <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_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 <color_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\t#include <color_vertex>\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",meshtoon_frag:"\n#define TOON\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 <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <lights_toon_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_toon_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",meshtoon_vert:"\n#define TOON\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",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_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <cube_uv_reflection_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 STANDARD\n\n#ifdef PHYSICAL\n\t#define REFLECTIVITY\n\t#define CLEARCOAT\n\t#define TRANSPARENCY\n#endif\n\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n\n#ifdef TRANSPARENCY\n\tuniform float transparency;\n#endif\n\n#ifdef REFLECTIVITY\n\tuniform float reflectivity;\n#endif\n\n#ifdef CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n\n#ifdef USE_SHEEN\n\tuniform vec3 sheen;\n#endif\n\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n\t#ifdef USE_TANGENT\n\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\n\t#endif\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_common_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 <clearcoat_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 <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_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\t// this is a stub for the transparency model\n\t#ifdef TRANSPARENCY\n\t\tdiffuseColor.a *= saturate( 1. - transparency + linearToRelativeLuminance( reflectedLight.directSpecular + reflectedLight.indirectSpecular ) );\n\t#endif\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 STANDARD\n\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n\t#ifdef USE_TANGENT\n\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\n\t#endif\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\t#ifdef USE_TANGENT\n\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\n\t#endif\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( TANGENTSPACE_NORMALMAP )\n\n\tvarying vec3 vViewPosition;\n\n#endif\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n\t#ifdef USE_TANGENT\n\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\n\t#endif\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#include <clipping_planes_pars_fragment>\n\nvoid main() {\n\n\t#include <clipping_planes_fragment>\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( TANGENTSPACE_NORMALMAP )\n\n\tvarying vec3 vViewPosition;\n\n#endif\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n\t#ifdef USE_TANGENT\n\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\n\t#endif\n\n#endif\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 <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#ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED\n\n\tvNormal = normalize( transformedNormal );\n\n\t#ifdef USE_TANGENT\n\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\n\t#endif\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#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_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 <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_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 = isPerspectiveMatrix( projectionMatrix );\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 <tonemapping_fragment>\n\t#include <encodings_fragment>\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 <alphamap_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 <alphamap_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 = isPerspectiveMatrix( projectionMatrix );\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"};function fi(t){var n,e={};for(n in t)for(var i in e[n]={},t[n]){var r=t[n][i];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture)?e[n][i]=r.clone():Array.isArray(r)?e[n][i]=r.slice():e[n][i]=r}return e}function di(t){e.call(this),this.type="ShaderMaterial",this.defines={},this.uniforms={},this.vertexShader="\nvoid main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}\n",this.fragmentShader="\nvoid main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}\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!==t&&(void 0!==t.attributes&&console.error("THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead."),this.setValues(t))}((di.prototype=Object.create(e.prototype)).constructor=di).prototype.isShaderMaterial=!0,di.prototype.copy=function(t){return e.prototype.copy.call(this,t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=fi(t.uniforms),this.defines=Object.assign({},t.defines),this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.lights=t.lights,this.clipping=t.clipping,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this.extensions=t.extensions,this};var vi={common:{diffuse:{value:new m(15658734)},opacity:{value:1},map:{value:null},uvTransform:{value:new u},uv2Transform:{value:new u},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 O(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 m(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{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 m(15658734)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},uvTransform:{value:new u}},sprite:{diffuse:{value:new m(15658734)},opacity:{value:1},center:{value:new O(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},uvTransform:{value:new u}}};function pi(t){return(pi="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function mi(t,n){for(var e=0;e<n.length;e++){var i=n[e];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,function(t){t=function(t,n){if("object"!=pi(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0===e)return("string"===n?String:Number)(t);e=e.call(t,n||"default");if("object"!=pi(e))return e;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"==pi(t)?t:String(t)}(i.key),i)}}function gi(t,n,e){return n&&mi(t.prototype,n),e&&mi(t,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function _i(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}function bi(t,n,e){n=wi(n);var i=t,n=yi()?Reflect.construct(n,e||[],wi(t).constructor):n.apply(t,e);if(n&&("object"===pi(n)||"function"==typeof n))return n;if(void 0!==n)throw new TypeError("Derived constructors may only return object or undefined");return xi(i)}function yi(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(yi=function(){return!!t})()}function wi(t){return(wi=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function xi(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function Mi(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(n&&n.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),n&&Si(t,n)}function Si(t,n){return(Si=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t})(t,n)}var Li=function(){function n(){var t;return _i(this,n),(t=bi(this,n)).isMeshLine=!0,t.type="MeshLine",t.positions=[],t.previous=[],t.next=[],t.side=[],t.width=[],t.indices_array=[],t.uvs=[],t.counters=[],t.N=[],t.wt=null,t.widthCallback=null,t.matrixWorld=new _,Object.defineProperties(xi(t),{geometry:{enumerable:!0,get:function(){return this}},geom:{enumerable:!0,get:function(){return this.wt},set:function(t){this.setGeometry(t,this.widthCallback)}},points:{enumerable:!0,get:function(){return this.N},set:function(t){this.setPoints(t,this.widthCallback)}}}),t}return Mi(n,C),gi(n)}();function Ei(t,n,e,i,r){var o;if(t=t.subarray||t.slice?t:t.buffer,e=e.subarray||e.slice?e:e.buffer,t=n?t.subarray?t.subarray(n,r&&n+r):t.slice(n,r&&n+r):t,e.set)e.set(t,i);else for(o=0;o<t.length;o++)e[o+i]=t[o]}Li.prototype.setMatrixWorld=function(t){this.matrixWorld=t},Li.prototype.setGeometry=function(t,n){this.xt=t,this.setPoints(t.getAttribute("position").array,n)},Li.prototype.setPoints=function(t,n){if(t instanceof Float32Array||t instanceof Array){if(this.N=t,this.widthCallback=n,this.positions=[],this.counters=[],t.length&&t[0]instanceof E)for(var e=0;e<t.length;e++){var i=t[e],r=e/t.length;this.positions.push(i.x,i.y,i.z),this.positions.push(i.x,i.y,i.z),this.counters.push(r),this.counters.push(r)}else for(e=0;e<t.length;e+=3){r=e/t.length;this.positions.push(t[e],t[e+1],t[e+2]),this.positions.push(t[e],t[e+1],t[e+2]),this.counters.push(r),this.counters.push(r)}this.process()}else console.error("ERROR: The BufferArray of points is not instancied correctly.")},Li.prototype.raycast=function(t,n){var e=new _,i=new ut,r=new it,o=new E,a=this.geometry;if(a.boundingSphere||a.computeBoundingSphere(),r.copy(a.boundingSphere),r.applyMatrix4(this.matrixWorld),!1!==t.ray.intersectSphere(r,o)){e.copy(this.matrixWorld).invert(),i.copy(t.ray).applyMatrix4(e);var s=new E,c=new E,h=new E,u=this instanceof li?2:1,r=a.index,e=a.attributes;if(null!==r)for(var l=r.array,f=e.position.array,d=e.width.array,v=0,p=l.length-1;v<p;v+=u){var m=l[v],g=l[v+1],m=(s.fromArray(f,3*m),c.fromArray(f,3*g),void 0!==d[Math.floor(v/3)]?d[Math.floor(v/3)]:1),g=t.params.Line.threshold+this.material.lineWidth*m/2;g*g<i.distanceSqToSegment(s,c,o,h)||(o.applyMatrix4(this.matrixWorld),(m=t.ray.origin.distanceTo(o))<t.near)||m>t.far||(n.push({distance:m,point:h.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this}),v=p)}}},Li.prototype.compareV3=function(t,n){t*=6,n*=6;return this.positions[t]===this.positions[n]&&this.positions[1+t]===this.positions[1+n]&&this.positions[2+t]===this.positions[2+n]},Li.prototype.copyV3=function(t){t*=6;return[this.positions[t],this.positions[1+t],this.positions[2+t]]},Li.prototype.process=function(){var t,n=this.positions.length/6;this.previous=[],this.next=[],this.side=[],this.width=[],this.indices_array=[],this.uvs=[],t=this.compareV3(0,n-1)?this.copyV3(n-2):this.copyV3(0),this.previous.push(t[0],t[1],t[2]),this.previous.push(t[0],t[1],t[2]);for(var e,i=0;i<n;i++)this.side.push(1),this.side.push(-1),e=this.widthCallback?this.widthCallback(i/(n-1)):1,this.width.push(e),this.width.push(e),this.uvs.push(i/(n-1),0),this.uvs.push(i/(n-1),1),i<n-1&&(t=this.copyV3(i),this.previous.push(t[0],t[1],t[2]),this.previous.push(t[0],t[1],t[2]),this.indices_array.push(e=2*i,1+e,2+e),this.indices_array.push(2+e,1+e,3+e)),0<i&&(t=this.copyV3(i),this.next.push(t[0],t[1],t[2]),this.next.push(t[0],t[1],t[2]));t=this.compareV3(n-1,0)?this.copyV3(1):this.copyV3(n-1),this.next.push(t[0],t[1],t[2]),this.next.push(t[0],t[1],t[2]),this.Mt&&this.Mt.position.count===this.positions.length?(this.Mt.position.copyArray(new Float32Array(this.positions)),this.Mt.position.needsUpdate=!0,this.Mt.previous.copyArray(new Float32Array(this.previous)),this.Mt.previous.needsUpdate=!0,this.Mt.next.copyArray(new Float32Array(this.next)),this.Mt.next.needsUpdate=!0,this.Mt.side.copyArray(new Float32Array(this.side)),this.Mt.side.needsUpdate=!0,this.Mt.width.copyArray(new Float32Array(this.width)),this.Mt.width.needsUpdate=!0,this.Mt.uv.copyArray(new Float32Array(this.uvs)),this.Mt.uv.needsUpdate=!0,this.Mt.index.copyArray(new Uint16Array(this.indices_array)),this.Mt.index.needsUpdate=!0):this.Mt={position:new y(new Float32Array(this.positions),3),previous:new y(new Float32Array(this.previous),3),next:new y(new Float32Array(this.next),3),side:new y(new Float32Array(this.side),1),width:new y(new Float32Array(this.width),1),uv:new y(new Float32Array(this.uvs),2),index:new y(new Uint16Array(this.indices_array),1),counters:new y(new Float32Array(this.counters),1)},this.setAttribute("position",this.Mt.position),this.setAttribute("previous",this.Mt.previous),this.setAttribute("next",this.Mt.next),this.setAttribute("side",this.Mt.side),this.setAttribute("width",this.Mt.width),this.setAttribute("uv",this.Mt.uv),this.setAttribute("counters",this.Mt.counters),this.setIndex(this.Mt.index),this.computeBoundingSphere(),this.computeBoundingBox()},Li.prototype.advance=function(t){var n=this.Mt.position.array,e=this.Mt.previous.array,i=this.Mt.next.array,r=n.length;Ei(n,0,e,0,r),Ei(n,6,n,0,r-6),n[r-6]=t.x,n[r-5]=t.y,n[r-4]=t.z,n[r-3]=t.x,n[r-2]=t.y,n[r-1]=t.z,Ei(n,6,i,0,r-6),i[r-6]=t.x,i[r-5]=t.y,i[r-4]=t.z,i[r-3]=t.x,i[r-2]=t.y,i[r-1]=t.z,this.Mt.position.needsUpdate=!0,this.Mt.previous.needsUpdate=!0,this.Mt.next.needsUpdate=!0},P.meshline_vert=["",P.common,P.logdepthbuf_pars_vertex,P.fog_pars_vertex,"","attribute vec3 previous;","attribute vec3 next;","attribute float side;","attribute float width;","attribute float counters;","","uniform vec2 resolution;","uniform float lineWidth;","uniform vec3 color;","uniform float opacity;","uniform float sizeAttenuation;","uniform vec2 offset;","","varying vec2 vUV;","varying vec4 vColor;","varying float vCounters;","","vec2 fix( vec4 i, float aspect ) {",""," vec2 res = i.xy / i.w;"," res.x *= aspect;","\t vCounters = counters;"," return res;","","}","","void main() {",""," float aspect = resolution.x / resolution.y;",""," vColor = vec4( color, opacity );"," vUV = uv + offset;",""," mat4 m = projectionMatrix * modelViewMatrix;"," vec4 finalPosition = m * vec4( position, 1.0 );"," vec4 prevPos = m * vec4( previous, 1.0 );"," vec4 nextPos = m * vec4( next, 1.0 );",""," vec2 currentP = fix( finalPosition, aspect );"," vec2 prevP = fix( prevPos, aspect );"," vec2 nextP = fix( nextPos, aspect );",""," float w = lineWidth * width;",""," vec2 dir;"," if( nextP == currentP ) dir = normalize( currentP - prevP );"," else if( prevP == currentP ) dir = normalize( nextP - currentP );"," else {"," vec2 dir1 = normalize( currentP - prevP );"," vec2 dir2 = normalize( nextP - currentP );"," dir = normalize( dir1 + dir2 );",""," vec2 perp = vec2( -dir1.y, dir1.x );"," vec2 miter = vec2( -dir.y, dir.x );"," //w = clamp( w / dot( miter, perp ), 0., 4. * lineWidth * width );",""," }",""," //vec2 normal = ( cross( vec3( dir, 0. ), vec3( 0., 0., 1. ) ) ).xy;"," vec4 normal = vec4( -dir.y, dir.x, 0., 1. );"," normal.xy *= .5 * w;"," normal *= projectionMatrix;"," if( sizeAttenuation == 0. ) {"," normal.xy *= finalPosition.w;"," normal.xy /= ( vec4( resolution, 0., 1. ) * projectionMatrix ).xy;"," }",""," finalPosition.xy += normal.xy * side;",""," gl_Position = finalPosition;","",P.logdepthbuf_vertex,P.fog_vertex&&" vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",P.fog_vertex,"}"].join("\n"),P.meshline_frag=["",P.fog_pars_fragment,P.logdepthbuf_pars_fragment,"","uniform sampler2D map;","uniform sampler2D alphaMap;","uniform float useMap;","uniform float useAlphaMap;","uniform float useDash;","uniform float dashArray;","uniform float dashOffset;","uniform float dashRatio;","uniform float visibility;","uniform float alphaTest;","uniform vec2 repeat;","uniform float luminance;","uniform bool isbackground;","uniform vec3 bgcolor;","","varying vec2 vUV;","varying vec4 vColor;","varying float vCounters;","","void main() {","",P.logdepthbuf_fragment,""," vec4 c = vColor;"," if( useMap == 1. ) {","\t \tc = texture2D( map, vUV * repeat );","\t } else {"," c = vColor;","\t }","\t c.r = c.r * c.a * luminance;"," c.g = c.g * c.a * luminance;"," c.b = c.b * c.a * luminance;"," if(isbackground){","\t\tc=vec4(vec3(mix(c,vec4(bgcolor,1.0),1.0-c.a)),1.0);"," }","\t c.a = c.a * vColor.a;"," if( useAlphaMap == 1. ) c.a *= texture2D( alphaMap, vUV * repeat ).a;"," if( c.a < alphaTest ) discard;"," if( useDash == 1. ){"," c.a *= ceil(mod(vCounters + dashOffset, dashArray) - (dashArray * dashRatio));"," }"," gl_FragColor = c;"," gl_FragColor.a *= step(vCounters, visibility);","",P.fog_fragment,"}"].join("\n");var Ti=function(){function e(t){var n;return _i(this,e),(n=bi(this,e,[{uniforms:Object.assign({},vi.fog,{lineWidth:{value:1},map:{value:null},useMap:{value:0},alphaMap:{value:null},useAlphaMap:{value:0},color:{value:new m(16777215)},opacity:{value:1},resolution:{value:new O(1,1)},sizeAttenuation:{value:1},dashArray:{value:0},dashOffset:{value:0},dashRatio:{value:.5},useDash:{value:0},visibility:{value:1},alphaTest:{value:0},repeat:{value:new O(1,1)},offset:{value:new O(1,1)},luminance:{value:1},isbackground:{value:!1},bgcolor:{value:new m(16777215)}}),vertexShader:P.meshline_vert,fragmentShader:P.meshline_frag}])).isMeshLineMaterial=!0,n.type="MeshLineMaterial",Object.defineProperties(xi(n),{lineWidth:{enumerable:!0,get:function(){return this.uniforms.lineWidth.value},set:function(t){this.uniforms.lineWidth.value=t}},map:{enumerable:!0,get:function(){return this.uniforms.map.value},set:function(t){this.uniforms.map.value=t}},useMap:{enumerable:!0,get:function(){return this.uniforms.useMap.value},set:function(t){this.uniforms.useMap.value=t}},alphaMap:{enumerable:!0,get:function(){return this.uniforms.alphaMap.value},set:function(t){this.uniforms.alphaMap.value=t}},useAlphaMap:{enumerable:!0,get:function(){return this.uniforms.useAlphaMap.value},set:function(t){this.uniforms.useAlphaMap.value=t}},color:{enumerable:!0,get:function(){return this.uniforms.color.value},set:function(t){this.uniforms.color.value=t}},opacity:{enumerable:!0,get:function(){return this.uniforms.opacity.value},set:function(t){this.uniforms.opacity.value=t}},resolution:{enumerable:!0,get:function(){return this.uniforms.resolution.value},set:function(t){this.uniforms.resolution.value.copy(t)}},sizeAttenuation:{enumerable:!0,get:function(){return this.uniforms.sizeAttenuation.value},set:function(t){this.uniforms.sizeAttenuation.value=t}},dashArray:{enumerable:!0,get:function(){return this.uniforms.dashArray.value},set:function(t){this.uniforms.dashArray.value=t,this.useDash=0!==t?1:0}},dashOffset:{enumerable:!0,get:function(){return this.uniforms.dashOffset.value},set:function(t){this.uniforms.dashOffset.value=t}},dashRatio:{enumerable:!0,get:function(){return this.uniforms.dashRatio.value},set:function(t){this.uniforms.dashRatio.value=t}},useDash:{enumerable:!0,get:function(){return this.uniforms.useDash.value},set:function(t){this.uniforms.useDash.value=t}},visibility:{enumerable:!0,get:function(){return this.uniforms.visibility.value},set:function(t){this.uniforms.visibility.value=t}},alphaTest:{enumerable:!0,get:function(){return this.uniforms.alphaTest.value},set:function(t){this.uniforms.alphaTest.value=t}},repeat:{enumerable:!0,get:function(){return this.uniforms.repeat.value},set:function(t){this.uniforms.repeat.value.copy(t)}},offset:{enumerable:!0,get:function(){return this.uniforms.offset.value},set:function(t){this.uniforms.offset.value.copy(t)}},luminance:{enumerable:!0,get:function(){return this.uniforms.luminance.value},set:function(t){this.uniforms.luminance.value=t}},isbackground:{enumerable:!0,get:function(){return this.uniforms.isbackground.value},set:function(t){this.uniforms.isbackground.value=t}},bgcolor:{enumerable:!0,get:function(){return this.uniforms.bgcolor.value},set:function(t){this.uniforms.bgcolor.value=t}}}),n.setValues(t),n}return Mi(e,di),gi(e)}();function Ci(t){return(Ci="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Di(t,n){for(var e=0;e<n.length;e++){var i=n[e];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,function(t){t=function(t,n){if("object"!=Ci(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0===e)return("string"===n?String:Number)(t);e=e.call(t,n||"default");if("object"!=Ci(e))return e;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"==Ci(t)?t:String(t)}(i.key),i)}}function Pi(t,n,e){n=Ri(n);var i=t,n=Ai()?Reflect.construct(n,e||[],Ri(t).constructor):n.apply(t,e);if(n&&("object"===Ci(n)||"function"==typeof n))return n;if(void 0!==n)throw new TypeError("Derived constructors may only return object or undefined");t=i;if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}function Ai(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(Ai=function(){return!!t})()}function Ri(t){return(Ri=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function Ni(t,n){return(Ni=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t})(t,n)}Ti.prototype.copy=function(t){return di.prototype.copy.call(this,t),this.lineWidth=t.lineWidth,this.map=t.map,this.useMap=t.useMap,this.alphaMap=t.alphaMap,this.useAlphaMap=t.useAlphaMap,this.color.copy(t.color),this.opacity=t.opacity,this.resolution.copy(t.resolution),this.sizeAttenuation=t.sizeAttenuation,this.dashArray.copy(t.dashArray),this.dashOffset.copy(t.dashOffset),this.dashRatio.copy(t.dashRatio),this.useDash=t.useDash,this.visibility=t.visibility,this.alphaTest=t.alphaTest,this.repeat.copy(t.repeat),this};var Oi=function(){var t,n,e=r,i=ue;if("function"!=typeof i&&null!==i)throw new TypeError("Super expression must either be null or a function");function r(t,n){if(this instanceof r)return void 0===(n=Pi(this,r,[t,n])).U&&(n.U=1),n.St=t.isFlat,void 0===n.St&&(n.St=!1),n.Lt=t.isBezier,n.H=null,n.et=t.smoothparam,void 0===n.et&&(n.et=35),n.it=null,n.st=null,n.rt=!1,n.ot=!1,n.B=t.count,n.Et=!1,void 0===n.B&&(n.ft=!0,n.Lt||(n.Et=!0)),n.Tt=t.sizeAttenuation,void 0!==n.Tt&&n.Tt?n.Tt=1:n.Tt=0,n.Ct=t.depth,void 0===n.Ct&&(n.Ct=!0),n.Dt=null,n.vt=void 0,n.gt=void 0,n;throw new TypeError("Cannot call a class as a function")}return e.prototype=Object.create(i&&i.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),i&&Ni(e,i),e=r,t&&Di(e.prototype,t),n&&Di(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}(),Ii=(Object.assign(Oi.prototype,{ct:function(){var r=this,t=this.q(this.N,0,this.F),n=new Qn;if(this.Lt)n=new Yn(t[0],t[1],t[2],t[3]);else for(var e=0;e<t.length-1;e++){var i=new On(t[e],t[e+1]);n.curves.push(i)}var o=window.innerWidth,a=window.innerHeight,s=this.k,s=(s&&(o=s.getContainer().clientWidth,a=s.getContainer().clientHeight,s.on("resize",this.W.resize)),new Ti({useMap:0,color:new m(this.O),opacity:this.I,resolution:new O(o,a),sizeAttenuation:this.Tt,lineWidth:2*this.U,transparent:!0,depthTest:this.Ct})),o=(s.polygonOffset=!0,s.polygonOffsetFactor=-1,s.polygonOffsetUnits=-4,void 0!==this.j&&(s.visible=!1),new Li);return this.Et?o.setPoints(this.Pt(t,n)):o.setPoints(n.getPoints(this.et)),this.H=new An(o.geometry,s),this.H.mapNode=this.W,void 0!==this.j&&this.Y(this.j,function(t,n,e){r.ft&&(1===r.Tt?r.B=r.Z(n,e,2*r.U,r.N):(i=r.At(),r.Dt={width:n,height:e},r.B=r.Z(n,e,2*r.U*i,r.N)));var i,n=r.K(t,1);n.wrapS=n.wrapT=1e3,r.H.material.color=new m("#FFFFFF"),r.H.material.useMap=1,r.H.material.map=n,r.H.material.repeat=new O(r.B,1),r.H.material.visible=!0,r.X()}),this.X(),!0},Pt:function(t,n){for(var e=[],i=new E,r=t.length*this.et,o=0;o<r;o++)i=n.getPointAt(o/r,i),e.push(i);return e},At:function(){var t={x:document.body.clientWidth/2,y:document.body.clientHeight/2,z:this.G.height,buildingID:this.G.parent.buildingID},n={x:t.x+1,y:t.y,z:this.G.height,buildingID:this.G.parent.buildingID},t=fengmap.FMUtil.coordsScreenToMap(this.k,t),n=fengmap.FMUtil.coordsScreenToMap(this.k,n);return Math.sqrt((t.x-n.x)*(t.x-n.x)+(t.y-n.y)*(t.y-n.y))}}),Oi);function Ui(t){return(Ui="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Fi(t,n){for(var e=0;e<n.length;e++){var i=n[e];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,function(t){t=function(t,n){if("object"!=Ui(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0===e)return("string"===n?String:Number)(t);e=e.call(t,n||"default");if("object"!=Ui(e))return e;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"==Ui(t)?t:String(t)}(i.key),i)}}function Hi(t,n,e){n=Bi(n);var i=t,n=ji()?Reflect.construct(n,e||[],Bi(t).constructor):n.apply(t,e);if(n&&("object"===Ui(n)||"function"==typeof n))return n;if(void 0!==n)throw new TypeError("Derived constructors may only return object or undefined");return ki(i)}function ji(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(ji=function(){return!!t})()}function ki(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function Gi(t,n){return(Gi=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t})(t,n)}function zi(){return(zi="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,n,e){var i=function(t,n){for(;!Object.prototype.hasOwnProperty.call(t,n)&&null!==(t=Bi(t)););return t}(t,n);if(i)return(i=Object.getOwnPropertyDescriptor(i,n)).get?i.get.call(arguments.length<3?t:e):i.value}).apply(this,arguments)}function Bi(t){return(Bi=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}Oi=function(){var t,n=i,e=Pe;if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");function i(t){var n,e;if(this instanceof i)return zi((n=ki(e=Hi(this,i,[t])),Bi(i.prototype)),"setType",n).call(n,H.LINE3D_MARKER),e.tool=new Ii(t,ki(e)),e.updateZoom=e.updateZoom.bind(ki(e)),e;throw new TypeError("Cannot call a class as a function")}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),Object.defineProperty(n,"prototype",{writable:!1}),e&&Gi(n,e),n=i,(e=[{key:"url",get:function(){return this.tool.j},set:function(t){var r=this;this.tool.j=t,void 0!==this.tool.j&&this.tool.Y(this.tool.j,function(t,n,e){r.tool.ft&&(1===r.tool.Tt?r.tool.B=r.tool.Z(n,e,2*r.tool.U,r.tool.N):(i=r.tool.At(),r.tool.Dt={width:n,height:e},r.tool.B=r.tool.Z(n,e,2*r.tool.U*i,r.tool.N)));var i,n=new oe(t);n.wrapS=n.wrapT=1e3,r.tool.H.material.color=new m("#FFFFFF"),r.tool.H.material.useMap=1,r.tool.H.material.map=n,r.tool.H.material.repeat=new O(r.tool.B,1),r.tool.X()})}},{key:"isBezier",get:function(){return this.tool.Lt},set:function(t){t&&4!==this.tool.N.length?console.error("贝塞尔需要四个坐标点"):(this.tool.Lt=t,this.reCreateObject())}},{key:"sizeAttenuation",get:function(){return 0!==this.tool.Tt},set:function(t){this.tool.Tt=t?1:0,this.tool.H.material.sizeAttenuation=this.tool.Tt,this.tool.X()}},{key:"depth",get:function(){return this.tool.Ct},set:function(t){this.tool.Ct=t,this.tool.H.material.depthTest=this.tool.Ct,this.tool.X()}},{key:"addTo",value:function(t){zi(Bi(i.prototype),"addTo",this).call(this,t),this.tool.k.on("zoom",this.updateZoom)}},{key:"remove",value:function(){zi(Bi(i.prototype),"remove",this).call(this),this.tool.k.off("zoom",this.updateZoom)}},{key:"updateZoom",value:function(){var t;void 0!==this.tool.B&&0===this.tool.Tt&&this.tool.ft&&(t=this.tool.At(),1<=(t=this.tool.Z(this.tool.Dt.width,this.tool.Dt.height,2*this.tool.U*t,this.tool.N)))&&(this.tool.B=t,this.tool.H.material.repeat=new O(this.tool.B,1))}}])&&Fi(n.prototype,e),t&&Fi(n,t),Object.defineProperty(n,"prototype",{writable:!1}),i}();function Vi(t,n,e,i,r,o,a){ne.call(this),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:n,heightSegments:e,phiStart:i,phiLength:r,thetaStart:o,thetaLength:a},this.fromBufferGeometry(new Wi(t,n,e,i,r,o,a)),this.mergeVertices()}function Wi(t,n,e,i,r,o,a){C.call(this),this.type="SphereBufferGeometry",this.parameters={radius:t,widthSegments:n,heightSegments:e,phiStart:i,phiLength:r,thetaStart:o,thetaLength:a},t=t||1,n=Math.max(3,Math.floor(n)||8),e=Math.max(2,Math.floor(e)||6),i=void 0!==i?i:0,r=void 0!==r?r:2*Math.PI,o=void 0!==o?o:0,a=void 0!==a?a:Math.PI;for(var s,c=Math.min(o+a,Math.PI),h=0,u=[],l=new E,f=new E,d=[],v=[],p=[],m=[],g=0;g<=e;g++){var _=[],b=g/e,y=0;for(0==g&&0==o?y=.5/n:g==e&&c==Math.PI&&(y=-.5/n),s=0;s<=n;s++){var w=s/n;l.x=-t*Math.cos(i+w*r)*Math.sin(o+b*a),l.y=t*Math.cos(o+b*a),l.z=t*Math.sin(i+w*r)*Math.sin(o+b*a),v.push(l.x,l.y,l.z),f.copy(l).normalize(),p.push(f.x,f.y,f.z),m.push(w+y,1-b),_.push(h++)}u.push(_)}for(g=0;g<e;g++)for(s=0;s<n;s++){var x=u[g][s+1],M=u[g][s],S=u[g+1][s],L=u[g+1][s+1];(0!==g||0<o)&&d.push(x,M,L),(g!==e-1||c<Math.PI)&&d.push(M,S,L)}this.setIndex(d),this.setAttribute("position",new T(v,3)),this.setAttribute("normal",new T(p,3)),this.setAttribute("uv",new T(m,2))}function Xi(t){return(Xi="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Yi(t,n){for(var e=0;e<n.length;e++){var i=n[e];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,function(t){t=function(t,n){if("object"!=Xi(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0===e)return("string"===n?String:Number)(t);e=e.call(t,n||"default");if("object"!=Xi(e))return e;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"==Xi(t)?t:String(t)}(i.key),i)}}function Zi(t,n,e){n=Ki(n);var i=t,n=qi()?Reflect.construct(n,e||[],Ki(t).constructor):n.apply(t,e);if(n&&("object"===Xi(n)||"function"==typeof n))return n;if(void 0!==n)throw new TypeError("Derived constructors may only return object or undefined");t=i;if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}function qi(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(qi=function(){return!!t})()}function Ki(t){return(Ki=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function Qi(t,n){return(Qi=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t})(t,n)}(Vi.prototype=Object.create(ne.prototype)).constructor=Vi,(Wi.prototype=Object.create(C.prototype)).constructor=Wi;var Ji=function(){var t,n,e=r,i=ue;if("function"!=typeof i&&null!==i)throw new TypeError("Super expression must either be null or a function");function r(t,n){if(this instanceof r)return(n=Zi(this,r,[t,n])).B=1,n.Rt=t.isHemiSphere,void 0===n.Rt&&(n.Rt=!0),n.u=t.x,n.v=t.y,n.O=t.color,void 0===n.I&&(n.I=.5),void 0===n.U&&(n.U=8),n.N=[{x:n.u+n.U,y:n.v},{x:n.u-n.U,y:n.v},{x:n.u,y:n.v+n.U},{x:n.u,y:n.v-n.U}],n.Nt=null,n.dt=null,n.rt=!1,n.Ot=!1,n;throw new TypeError("Cannot call a class as a function")}return e.prototype=Object.create(i&&i.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),i&&Qi(e,i),e=r,t&&Yi(e.prototype,t),n&&Yi(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}(),$i=(Object.assign(Ji.prototype,{ct:function(){var t=null,t=this.Rt?new Vi(this.U,32,16,0,2*Math.PI,0,Math.PI/2):new Vi(this.U,32,16,0,2*Math.PI,0,Math.PI);return this.H=this.$(this.W,t,this.O,this.I,this.j,1),this.X(),this.It(),!0},It:function(){var t=this.k;if(!t)return!1;this.Rt?this.H.position.set(this.u-t.x,this.F,-this.v+t.y):this.H.position.set(this.u-t.x,this.F+this.U,-this.v+t.y)}}),Ji);function tr(t){return(tr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function nr(t,n){for(var e=0;e<n.length;e++){var i=n[e];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,function(t){t=function(t,n){if("object"!=tr(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0===e)return("string"===n?String:Number)(t);e=e.call(t,n||"default");if("object"!=tr(e))return e;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"==tr(t)?t:String(t)}(i.key),i)}}function er(t,n,e){n=sr(n);var i=t,n=ir()?Reflect.construct(n,e||[],sr(t).constructor):n.apply(t,e);if(n&&("object"===tr(n)||"function"==typeof n))return n;if(void 0!==n)throw new TypeError("Derived constructors may only return object or undefined");return rr(i)}function ir(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(ir=function(){return!!t})()}function rr(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function or(t,n){return(or=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t})(t,n)}function ar(){return(ar="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,n,e){var i=function(t,n){for(;!Object.prototype.hasOwnProperty.call(t,n)&&null!==(t=sr(t)););return t}(t,n);if(i)return(i=Object.getOwnPropertyDescriptor(i,n)).get?i.get.call(arguments.length<3?t:e):i.value}).apply(this,arguments)}function sr(t){return(sr=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}Ji=function(){var t,n=i,e=Pe;if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");function i(t){var n,e;if(this instanceof i)return ar((n=rr(e=er(this,i,[t])),sr(i.prototype)),"setType",n).call(n,H.SPHERE_MARKER),e.tool=new $i(t,rr(e)),e;throw new TypeError("Cannot call a class as a function")}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),Object.defineProperty(n,"prototype",{writable:!1}),e&&or(n,e),n=i,(e=[{key:"points",get:function(){return this.tool.N},set:function(t){}},{key:"count",get:function(){return 1},set:function(t){}},{key:"color",get:function(){return this.tool.O},set:function(t){this.tool.O=t,"ShaderMaterial"===this.tool.H.material.type?(this.tool.H.material.uniforms.color.value=new m(t),this.tool.H.material.uniforms.iscolor.value=!0):this.tool.H.material.color=new m(t),this.tool.X()}},{key:"height",get:function(){return this.tool.F},set:function(t){this.tool.F=t,this.tool.It(),this.tool.X()}},{key:"radius",get:function(){return this.tool.U},set:function(t){this.tool.U=t,this.reCreateObject()}},{key:"x",get:function(){return this.tool.u},set:function(t){this.tool.u=t,this.tool.It(),this.tool.X()}},{key:"y",get:function(){return this.tool.v},set:function(t){this.tool.v=t,this.tool.It(),this.tool.X()}},{key:"isHemiSphere",get:function(){return this.tool.Rt},set:function(t){this.tool.Rt=t,this.reCreateObject()}},{key:"addEffect",value:function(t){var n,e=this;"FMDiffusion"!==t.type?console.error("半圆覆盖物只能添加扩散效果"):(n=this.tool.k)&&(this.tool.dt=t,this.tool.dt.getMaterial(this,function(t){e.tool.rt||(e.tool.H.material.dispose(),e.tool.H.material=t,e.tool.Ot=!0,n.on("update",e.update),e.tool.rt=!0)}))}},{key:"removeEffect",value:function(){var n=this,t=(this.tool.dt=null,this.tool.k);t&&(t.off("update",this.update),t=new g({color:new m(this.tool.O),opacity:this.tool.I,transparent:!0}),void 0!==this.tool.j&&(t.visible=!1),this.tool.H.material=t,this.tool.H.scale.set(1,1,1),void 0!==this.tool.j&&this.tool.Y(this.tool.j,function(t){n.tool.tt(t)}),this.tool.rt=!1,this.tool.X())}}])&&nr(n.prototype,e),t&&nr(n,t),Object.defineProperty(n,"prototype",{writable:!1}),i}();function cr(t,n){this.array=t,this.stride=n,this.count=void 0!==t?t.length/n:0,this.usage=35044,this.updateRange={offset:0,count:-1},this.version=0}Object.defineProperty(cr.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.assign(cr.prototype,{isInterleavedBuffer:!0,onUploadCallback:function(){},setUsage:function(t){return this.usage=t,this},copy:function(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this},copyAt:function(t,n,e){t*=this.stride,e*=n.stride;for(var i=0,r=this.stride;i<r;i++)this.array[t+i]=n.array[e+i];return this},set:function(t,n){return this.array.set(t,n=void 0===n?0:n),this},clone:function(){return(new this.constructor).copy(this)},onUpload:function(t){return this.onUploadCallback=t,this}});var hr,ur=new E;function lr(t,n,e,i){this.data=t,this.itemSize=n,this.offset=e,this.normalized=!0===i}function fr(t){e.call(this),this.type="SpriteMaterial",this.color=new m(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.setValues(t)}Object.defineProperties(lr.prototype,{count:{get:function(){return this.data.count}},array:{get:function(){return this.data.array}}}),Object.assign(lr.prototype,{isInterleavedBufferAttribute:!0,applyMatrix4:function(t){for(var n=0,e=this.data.count;n<e;n++)ur.x=this.getX(n),ur.y=this.getY(n),ur.z=this.getZ(n),ur.applyMatrix4(t),this.setXYZ(n,ur.x,ur.y,ur.z);return this},setX:function(t,n){return this.data.array[t*this.data.stride+this.offset]=n,this},setY:function(t,n){return this.data.array[t*this.data.stride+this.offset+1]=n,this},setZ:function(t,n){return this.data.array[t*this.data.stride+this.offset+2]=n,this},setW:function(t,n){return this.data.array[t*this.data.stride+this.offset+3]=n,this},getX:function(t){return this.data.array[t*this.data.stride+this.offset]},getY:function(t){return this.data.array[t*this.data.stride+this.offset+1]},getZ:function(t){return this.data.array[t*this.data.stride+this.offset+2]},getW:function(t){return this.data.array[t*this.data.stride+this.offset+3]},setXY:function(t,n,e){return t=t*this.data.stride+this.offset,this.data.array[t+0]=n,this.data.array[t+1]=e,this},setXYZ:function(t,n,e,i){return t=t*this.data.stride+this.offset,this.data.array[t+0]=n,this.data.array[t+1]=e,this.data.array[t+2]=i,this},setXYZW:function(t,n,e,i,r){return t=t*this.data.stride+this.offset,this.data.array[t+0]=n,this.data.array[t+1]=e,this.data.array[t+2]=i,this.data.array[t+3]=r,this}}),((fr.prototype=Object.create(e.prototype)).constructor=fr).prototype.isSpriteMaterial=!0,fr.prototype.copy=function(t){return e.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.rotation=t.rotation,this.sizeAttenuation=t.sizeAttenuation,this};var dr=new E,vr=new E,pr=new E,mr=new O,gr=new O,_r=new _,br=new E,yr=new E,wr=new E,xr=new O,Mr=new O,Sr=new O;function Lr(t){var n;h.call(this),this.type="Sprite",void 0===hr&&(hr=new C,n=new cr(new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),5),hr.setIndex([0,1,2,0,2,3]),hr.setAttribute("position",new lr(n,3,0,!1)),hr.setAttribute("uv",new lr(n,2,3,!1))),this.geometry=hr,this.material=void 0!==t?t:new fr,this.center=new O(.5,.5)}function Er(t,n,e,i,r,o){mr.subVectors(t,e).addScalar(.5).multiply(i),void 0!==r?(gr.x=o*mr.x-r*mr.y,gr.y=r*mr.x+o*mr.y):gr.copy(mr),t.copy(n),t.x+=gr.x,t.y+=gr.y,t.applyMatrix4(_r)}function Tr(t,n,e,i){C.call(this),this.type="PlaneBufferGeometry",this.parameters={width:t,height:n,widthSegments:e,heightSegments:i};for(var r=(t=t||1)/2,o=(n=n||1)/2,a=Math.floor(e)||1,s=Math.floor(i)||1,c=a+1,h=s+1,u=t/a,l=n/s,f=[],d=[],v=[],p=[],m=0;m<h;m++)for(var g=m*l-o,_=0;_<c;_++)d.push(_*u-r,-g,0),v.push(0,0,1),p.push(_/a),p.push(1-m/s);for(m=0;m<s;m++)for(_=0;_<a;_++){var b=_+c*(m+1),y=_+1+c*(m+1),w=_+1+c*m;f.push(_+c*m,b,w),f.push(b,y,w)}this.setIndex(f),this.setAttribute("position",new T(d,3)),this.setAttribute("normal",new T(v,3)),this.setAttribute("uv",new T(p,2))}function Cr(t){return(Cr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Dr(t,n){for(var e=0;e<n.length;e++){var i=n[e];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,function(t){t=function(t,n){if("object"!=Cr(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0===e)return("string"===n?String:Number)(t);e=e.call(t,n||"default");if("object"!=Cr(e))return e;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"==Cr(t)?t:String(t)}(i.key),i)}}function Pr(t,n,e){n=Rr(n);var i=t,n=Ar()?Reflect.construct(n,e||[],Rr(t).constructor):n.apply(t,e);if(n&&("object"===Cr(n)||"function"==typeof n))return n;if(void 0!==n)throw new TypeError("Derived constructors may only return object or undefined");t=i;if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}function Ar(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(Ar=function(){return!!t})()}function Rr(t){return(Rr=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function Nr(t,n){return(Nr=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t})(t,n)}Lr.prototype=Object.assign(Object.create(h.prototype),{constructor:Lr,isSprite:!0,raycast:function(t,n){null===t.camera&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),vr.setFromMatrixScale(this.matrixWorld),_r.copy(t.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(t.camera.matrixWorldInverse,this.matrixWorld),pr.setFromMatrixPosition(this.modelViewMatrix),t.camera.isPerspectiveCamera&&!1===this.material.sizeAttenuation&&vr.multiplyScalar(-pr.z);var e,i,r=this.material.rotation,r=(0!==r&&(i=Math.cos(r),e=Math.sin(r)),this.center);Er(br.set(-.5,-.5,0),pr,r,vr,e,i),Er(yr.set(.5,-.5,0),pr,r,vr,e,i),Er(wr.set(.5,.5,0),pr,r,vr,e,i),xr.set(0,0),Mr.set(1,0),Sr.set(1,1),null===t.ray.intersectTriangle(br,yr,wr,!1,dr)&&(Er(yr.set(-.5,.5,0),pr,r,vr,e,i),Mr.set(0,1),null===t.ray.intersectTriangle(br,wr,yr,!1,dr))||(r=t.ray.origin.distanceTo(dr))<t.near||r>t.far||n.push({distance:r,point:dr.clone(),uv:I.getUV(dr,br,yr,wr,xr,Mr,Sr,new O),face:null,object:this})},clone:function(){return new this.constructor(this.material).copy(this)},copy:function(t){return h.prototype.copy.call(this,t),void 0!==t.center&&this.center.copy(t.center),this}}),(Tr.prototype=Object.create(C.prototype)).constructor=Tr;var Or=function(){var t,n,e=r,i=C;if("function"!=typeof i&&null!==i)throw new TypeError("Super expression must either be null or a function");function r(){var t,n;if(this instanceof r)return t=Pr(this,r),n=new cr(new Float32Array([-.5,0,-.5,0,0,.5,0,-.5,1,0,.5,0,.5,1,1,-.5,0,.5,0,1]),5),t.setIndex([0,1,2,0,2,3]),t.setAttribute("position",new lr(n,3,0,!1)),t.setAttribute("uv",new lr(n,2,3,!1)),t;throw new TypeError("Cannot call a class as a function")}return e.prototype=Object.create(i&&i.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),i&&Nr(e,i),e=r,t&&Dr(e.prototype,t),n&&Dr(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}(),A={RIGHT:2,LEFT:4,BOTTOM:8,TOP:16,RIGHT_BOTTOM:32,LEFT_BOTTOM:64,RIGHT_TOP:128,LEFT_TOP:256,CENTER:512},Ir=(Object.freeze(A),A),A={BROWSER:0,WX:1},Ur=(Object.freeze(A),A),Fr={document:"undefined"!=typeof document?document:{},window:"undefined"!=typeof window?window:{},environment:Ur.BROWSER,XMLHttpRequest:"undefined"!=typeof XMLHttpRequest?XMLHttpRequest:{}};function Hr(t){return(Hr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function jr(t,n){for(var e=0;e<n.length;e++){var i=n[e];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,function(t){t=function(t,n){if("object"!=Hr(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0===e)return("string"===n?String:Number)(t);e=e.call(t,n||"default");if("object"!=Hr(e))return e;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"==Hr(t)?t:String(t)}(i.key),i)}}var kr=function(){function t(){if(!(this instanceof t))throw new TypeError("Cannot call a class as a function")}var n,e,i;return n=t,i=[{key:"convertPointCoordsByCenter",value:function(t,n){return t.x=t.x-n.x,t.y=t.y-n.y,void 0!==t.z&&void 0!==n.z&&(t.z=t.z-n.z),t}},{key:"convertPointsCoordsByCenter",value:function(t,n){for(var e=0;e<t.length;e++)this.convertPointCoordsByCenter(t[e],n);return t}},{key:"getMapScaleInfo",value:function(){var t,n;return Fr.environment===Ur.WX?96/2.54:(window.screen.deviceXDPI?t=window.screen.deviceXDPI:((n=document.createElement("DIV")).style.cssText="width:1in;height:1in;position:absolute;left:0px;top:0px;z-index:99;visibility:hidden",document.body.appendChild(n),t=parseInt(n.offsetWidth),n.parentNode.removeChild(n)),t/2.54)}},{key:"getCenterByAnchor",value:function(t){var n=new O(.5,.5);switch(t){case Ir.LEFT:n.setX(0);break;case Ir.RIGHT:n.setX(1);break;case Ir.TOP:n.setY(1);break;case Ir.BOTTOM:n.setY(0);break;case Ir.LEFT_TOP:n.set(0,1);break;case Ir.RIGHT_TOP:n.set(1,1);break;case Ir.LEFT_BOTTOM:n.set(0,0);break;case Ir.RIGHT_BOTTOM:n.set(1,0)}return n}},{key:"uniqWithArrayOne",value:function(t){var n=[];return t.forEach(function(t){n.includes(t)||n.push(t)}),n}},{key:"uniqWithArrayTwo",value:function(t){if(t.length<1)return[];t=JSON.parse(JSON.stringify(t));for(var n=[],e=0;e<t.length;e++){var i=(i=this.uniqWithArrayOne(t[e])).filter(function(t){return!n.includes(t)});t[e]=i,n=n.concat(i)}return t.filter(function(t){return 0<t.length})}}],(e=null)&&jr(n.prototype,e),i&&jr(n,i),Object.defineProperty(n,"prototype",{writable:!1}),t}(),A={FOV:35,CAMERA_NEAR:1,CAMERA_FAR:1e5,ZOOM_UPPER_BOUND:30,TILT_UPPER_BOUND:90,THOUSAND:1e3,DEG2RAD:.0174532,RAD2DEG:57.2957795,DRAW_TIME:500,EPS:.001},Gr=(Object.freeze(A),A);function zr(t){return(zr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Br(t,n){for(var e=0;e<n.length;e++){var i=n[e];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,function(t){t=function(t,n){if("object"!=zr(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0===e)return("string"===n?String:Number)(t);e=e.call(t,n||"default");if("object"!=zr(e))return e;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"==zr(t)?t:String(t)}(i.key),i)}}var Vr=function(){function e(t,n){if(!(this instanceof e))throw new TypeError("Cannot call a class as a function");this.W=t,this.Ut=n,this.Ft=void 0!==n.depth&&n.depth}var t,n,i;return t=e,(n=[{key:"createFlatMesh",value:function(t){var n=new g,n=new An(new Or,n);return n.rotation.set(0,-Math.PI,-Math.PI,"XYZ"),n.updateMatrixWorld(!0),n.renderOrder=1,n.position.x=t.position.x,n.position.y=t.position.y,n.position.z=t.position.z,n.mapNode=this.W,n}},{key:"createRectMesh",value:function(t){var n=this.Ut.rectangle,e=new g,n=new An(new Tr(n.size.x,n.size.y),e);return n.mapNode=this.W,n.rotation.x=-Math.PI/2,n.position.x=t.position.x,n.position.y=t.position.y,n.position.z=t.position.z,n}},{key:"editFlatMaterial",value:function(n,e){var i=this,o=this;n.depthTest=!1,n.depthWrite=!1,n.transparent=!0,void 0!==this.Ut.opacity?n.opacity=this.Ut.opacity:n.opacity=1,n.side=Qt,this.editMaterial(n),this.createCanvas(function(t){i.editTexture(t,n),n.depthTest=i.Ft,n.depthWrite=i.Ft,"rectangle"===i.W.renderType&&(n.polygonOffset=!0,n.polygonOffsetFactor=-1,n.polygonOffsetUnits=-4,t=function(t){var n=o.Ut.rectangle,e=n.size.x,i=n.size.y;{var r;e<i?(i=e*(t.height/t.width))>n.size.y&&(r=n.size.y/i,i=n.size.y,e*=r):(e=i*(t.width/t.height))>n.size.x&&(r=n.size.x/e,e=n.size.x,i*=r)}return{x:e/n.size.x,y:i/n.size.y}}(t),i.W.myrenderNode.scale.x=t.x,i.W.myrenderNode.scale.y=t.y,i.W.myrenderNode.scaleinfo=t),e&&e(n)})}},{key:"createSprite",value:function(t){var n=new Lr(new fr);return n.position.x=t.position.x,n.position.y=t.position.y,n.position.z=t.position.z,n.mapNode=this.W,n}},{key:"editMaterial",value:function(t){t.sizeAttenuation=!1,t.depthTest=!1,t.depthWrite=!1,t.transparent=!0,void 0!==this.Ut.opacity?t.opacity=this.Ut.opacity:t.opacity=1,t.side=Qt}},{key:"editTexture",value:function(t,n){var e=new oe(t);e.minFilter=1006,e.generateMipmaps=!1,n.map=e,n.userData.scaleRatio=t.height/t.width,n.userData.mspriteScale=t.spriteScale}},{key:"myUpdateMaterial",value:function(n){var e=this,i=new fr,r=(i.sizeAttenuation=!1,this.editMaterial(i),this.W.getRenderNode());!n&&r.parent&&r.parent.remove(r),this.createCanvas(function(t){e.editTexture(t,i),"image"!==e.Ut.layout.style&&"text"!==e.Ut.layout.style&&(i.userData.style=e.Ut.layout.style,i.userData.itHeightRatio=t.itHeightRatio),i.depthTest=e.Ft,i.depthWrite=e.Ft,r.material.map&&r.material.map.dispose(),r.material.dispose(),r.material=i,e.W.updateSize(),setTimeout(function(){n||(e.W.parent.scene.add(r),e.W.collision=e.Ut.collision),e.W.map.enableUpdateRender()},0)})}},{key:"createCanvas",value:function(t){"image"===this.Ut.layout.style?this.createImageCanvas(t):"text"===this.Ut.layout.style?this.createTextCanvas(t):this.createImageTextCanvas(t),"billboard"!==this.W.renderType||"image"!==this.Ut.layout.style&&"text"!==this.Ut.layout.style||(t=kr.getCenterByAnchor(this.W.myanchor.anchor),this.W.getRenderNode().center.set(t.x,t.y))}},{key:"getCenterByAnchor",value:function(t,n,e){var i,r;if("flat"!==this.W.renderType&&"rectangle"!==this.W.renderType)return i=n.width/e.width,n=n.height/e.height,r=t.width/e.width,t=t.height/e.height,"image"===this.W.myanchor.baseon?o(this.W.myanchor.anchor,i,n):"text"===this.W.myanchor.baseon?o(this.W.myanchor.anchor,r,t):kr.getCenterByAnchor(this.W.myanchor.anchor);function o(t,n,e){var i=new O(n/2,e/2);switch(t){case fengmap.FMMarkerAnchor.LEFT:i.setX(0);break;case fengmap.FMMarkerAnchor.RIGHT:i.setX(n);break;case fengmap.FMMarkerAnchor.TOP:i.setY(e);break;case fengmap.FMMarkerAnchor.BOTTOM:i.setY(0);break;case fengmap.FMMarkerAnchor.LEFT_TOP:i.set(0,e);break;case fengmap.FMMarkerAnchor.RIGHT_TOP:i.set(n,e);break;case fengmap.FMMarkerAnchor.LEFT_BOTTOM:i.set(0,0);break;case fengmap.FMMarkerAnchor.RIGHT_BOTTOM:i.set(n,0)}return i}}},{key:"createImageTextCanvas",value:function(i){var r=this;this.createImageCanvas(function(t){var n=r.createTextCanvas(),e=null;(e="limage-rtext"===r.Ut.layout.style||"ltext-rimage"===r.Ut.layout.style?r.leftRight(n,t):"timage-btext"===r.Ut.layout.style||"ttext-bimage"===r.Ut.layout.style?r.topBottom(n,t):r.overlayText(n,t)).itHeightRatio=t.height/n.height,e.itWidthRatio=t.width/n.width,i&&i(e)})}},{key:"overlayText",value:function(t,n){var e=this.Ut.layout.align,i=t.width,r=(i<n.width&&(i=n.width),t.height),o=(r<n.height&&(r=n.height),document.createElement("canvas")),a=(o.width=i,o.height=r,o.getContext("2d")),s=0,c=0,h=0,u=0,e=("center"===(e=void 0===e||e.indexOf("-")<0?"center-center":e).split("-")[0]?(c=r/2-t.height/2,u=r/2-n.height/2):"bottom"===e.split("-")[0]&&(c=r-t.height,u=r-n.height),"right"===e.split("-")[1]?(s=i-t.width,h=i-n.width):"center"===e.split("-")[1]&&(s=i/2-t.width/2,h=i/2-n.width/2),this.getCenterByAnchor(t,n,o));return e&&("all"!==this.W.myanchor.baseon&&("image"===this.W.myanchor.baseon?(e.x=e.x+h/i,e.y=e.y+u/r):(e.x=e.x+s/i,e.y=e.y+c/r)),this.W.getRenderNode().center.set(e.x,e.y)),a.drawImage(n,h,u,n.width,n.height),a.drawImage(t,s,c,t.width,t.height),o.spriteScale=r/t.rowHeight,o}},{key:"topBottom",value:function(t,n){var e=n.height+t.height,i=n.width,r=(i<t.width&&(i=t.width),document.createElement("canvas")),o=(r.width=i,r.height=e,r.getContext("2d")),a=this.Ut.layout.align,s=this.Ut.layout.style,c=0,h=0,s=("timage-btext"===s?h=n.height:"ttext-bimage"===s&&(c=t.height),0),u=0,a=(t.width>n.width?s=(t.width-n.width)/2:t.width<n.width&&(u=(n.width-t.width)/2),"left"===(a=void 0===a||"left"!==a&&"center"!==a&&"right"!==a?"center":a)?u=s=0:"right"===a&&(t.width>n.width?(s=t.width-n.width,u=0):t.width<n.width&&(u=n.width-t.width,s=0)),this.getCenterByAnchor(t,n,r));return a&&("all"!==this.W.myanchor.baseon&&("image"===this.W.myanchor.baseon?(a.x=a.x+s/i,a.y=a.y+h/e):(a.x=a.x+u/i,a.y=a.y+c/e)),this.W.getRenderNode().center.set(a.x,a.y)),o.drawImage(n,s,c,n.width,n.height),o.drawImage(t,u,h,t.width,t.height),r.spriteScale=e/t.rowHeight,r}},{key:"leftRight",value:function(t,n){var e=n.width+t.width,i=n.height,r=(i<t.height&&(i=t.height),document.createElement("canvas")),o=(r.width=e,r.height=i,r.getContext("2d")),a=this.Ut.layout.align,s=this.Ut.layout.style,c=0,h=0,a=("center"===(a=void 0===a||"top"!==a&&"center"!==a&&"bottom"!==a?"top":a)?n.height>t.height?(c=0,h=(n.height-t.height)/2):n.height<t.height&&(c=(t.height-n.height)/2,h=0):"bottom"===a&&(n.height>t.height?(c=0,h=n.height-t.height):n.height<t.height&&(c=t.height-n.height,h=0)),0),u=0,s=("limage-rtext"===s?u=n.width:"ltext-rimage"===s&&(a=t.width),this.getCenterByAnchor(t,n,r));return s&&("all"!==this.W.myanchor.baseon&&("image"===this.W.myanchor.baseon?(s.x=s.x+a/e,s.y=s.y+c/i):(s.x=s.x+u/e,s.y=s.y+h/i)),this.W.getRenderNode().center.set(s.x,s.y)),o.drawImage(n,a,c,n.width,n.height),o.drawImage(t,u,h,t.width,t.height),r.spriteScale=i/t.rowHeight,r}},{key:"createImageCanvas",value:function(t){var n,e=this,i=document.createElement("canvas"),r=(i.width=this.W.imagesize[0],i.height=this.W.imagesize[1],i.spriteScale=1,i.getContext("2d"));this.W.url?((n=new Image).crossOrigin="Anonymous",n.onload=function(){r.drawImage(n,0,0,e.W.imagesize[0],e.W.imagesize[1]),t&&t(i)},n.src=this.W.url):t&&t(i)}},{key:"createTextCanvas",value:function(t){var n=this.getTextInfo(),e=this.getCanvasInfo(n),i=document.createElement("canvas"),r=(i.width=e.width,i.height=e.height,i.getContext("2d")),r=(this.drawText(r,n,e),this.drawPlate(i,e,n)),o=1;if((1<n.length||"text"!==this.Ut.layout.style)&&(o=i.height/e.rowHeight),r.spriteScale=o,r.rowHeight=e.rowHeight,this.W.size=e.size,!t)return r;t(r)}},{key:"drawPlate",value:function(t,n,e){var i,r,o,a,s,c=this.Ut.text.padding,h=(void 0===c&&(c=[0,0,0,0]),this.Ut.text.plateColor),u=this.Ut.text.plateStrokeColor,l=this.Ut.text.plateStrokeWidth,f=this.Ut.text.plateOpacity,d=this.Ut.text.plateStrokeRadius;return void 0!==u&&void 0===l&&(l=1),void 0===f&&(f=1),void 0===d&&(d=0),void 0===h&&void 0===u?t:(void(r=0)!==u?r=4*l:l=0,(i=document.createElement("canvas")).width=n.width+2*(c[1]+c[3])+r,i.height=n.height+2*(c[0]+c[2])+r,r=i.getContext("2d"),void 0!==h&&(0===d?r.rect(0,0,i.width,i.height):(a=i.width,0,(o=i.height)<2*(s=a<2*(s=d)?a/2:s)&&(s=o/2),r.beginPath(),r.moveTo(0+s,0),r.arcTo(0+a,0,0+a,0+o,s),r.arcTo(0+a,0+o,0,0+o,s),r.arcTo(0,0+o,0,0,s),r.arcTo(0,0,0+a,0,s)),r.fillStyle=v(h,f),r.fill()),void 0!==u&&(r.lineWidth=l,0===d?r.rect(0,0,i.width,i.height):(o=i.width,0,(a=i.height)<2*(s=o<2*(s=d)?o/2:s)&&(s=a/2),r.beginPath(),r.moveTo(0+s,0),r.arcTo(0+o,0,0+o,0+a,s),r.arcTo(0+o,0+a,0,0+a,s),r.arcTo(0,0+a,0,0,s),r.arcTo(0,0,0+o,0,s)),r.strokeStyle=v(u,f),r.stroke()),r.drawImage(t,2*(c[3]+l),2*(c[0]+l),t.width,t.height),1<e.length?n.size=n.size+(c[0]+c[2]+2*l)/e.length:n.size=n.size+(c[0]+c[2]+l)/e.length,i);function v(t,n){return t=t||"#ededed","rgba("+parseInt("0x"+t.slice(1,3))+","+parseInt("0x"+t.slice(3,5))+","+parseInt("0x"+t.slice(5,7))+","+(n||"1")+")"}}},{key:"drawText",value:function(s,t,n){if(s.textBaseline="Alphabetic",1===t.length){var e=t[0],i=2*e.fontSize*1.2;h(e,2,n,n.height/2+i/3)}else for(var r=0,o=0;o<t.length;o++){var a=t[o],c=2*a.fontSize*1.2;0===o?r+=c:r=r+c+2*a.lineSpacing,h(a,2,n,r)}function h(t,n,e,i){var r=t.text,o=t.fontSize*n*1.2,a=o+"px "+t.fontFamily,o=(void 0!==t.fontWeight&&(a=t.fontWeight+" "+o+"px "+t.fontFamily),s.font=a,1);void 0!==t.strokeColor?(s.strokeStyle=t.strokeColor,void 0===t.strokeWidth||isNaN(""+t.strokeWidth)||(o=parseFloat(""+t.strokeWidth)),s.lineWidth=2*n*o):o=0,s.fillStyle=t.fillColor,t.textAlign===fengmap.FMTextAlign.Left?(s.textAlign="left",0!==o&&s.strokeText(r,0,i),s.fillText(r,0,i)):t.textAlign===fengmap.FMTextAlign.Right?(s.textAlign="right",0!==o&&s.strokeText(r,e.width,i),s.fillText(r,e.width,i)):(s.textAlign="center",0!==o&&s.strokeText(r,e.width/2,i),s.fillText(r,e.width/2,i))}}},{key:"getCanvasInfo",value:function(t){for(var n=document.createElement("canvas").getContext("2d"),e=(n.textBaseline="Alphabetic",null),i=0,r=null,o=0,a=0,s=0;s<t.length;s++){var c=2*t[s].fontSize*1.2,h=((null===r||r<t[s].fontSize)&&(r=t[s].fontSize),c+"px "+t[s].fontFamily);void 0!==t[s].fontWeight&&(h=t[s].fontWeight+" "+c+"px "+t[s].fontFamily),n.font=h;var h=n.measureText(t[s].text).width,u=c+2*t[s].lineSpacing,o=o+c+2*t[s].lineSpacing;a+=t[s].lineSpacing,i+=u,(null===e||e<h)&&(e=h)}var l=r,f=(1<t.length&&(l+=a/t.length),this.Ut.text.padding),d=this.Ut.text.plateStrokeColor,v=this.Ut.text.plateStrokeWidth;return{width:e,height:i,fontHeight:i,size:l,rowHeight:(o+2*((f=void 0===f?[0,0,0,0]:f)[0]+f[2])+2*(v=void 0===(v=void 0!==d&&void 0===v?1:v)?0:v)*2)/t.length}}},{key:"getTextInfo",value:function(){var t=this.W.map,n=this.Ut.text.content,e=n.lineSpacing,i=((e=void 0===e?2:e)<2&&(e=2),n.textAlign),r=(void 0===i&&(i=fengmap.FMTextAlign.Center),n.fontSize),o=(void 0===r&&(r=20),n.fontWeight),a=n.fontFamily,s=(void 0===a&&(a=t.getMapOptions().fontFamily),n.fillColor),c=(void 0===s&&(s="#000000"),n.strokeColor),h=n.strokeWidth,u=(void 0!==c&&void 0===h&&(h=1),n.text),l=[];if("string"==typeof u)if(u.indexOf("%rn%")<0)l.push({textAlign:i,fontSize:r,fontWeight:o,fontFamily:a,fillColor:s,strokeColor:c,strokeWidth:h,lineSpacing:0,text:u});else for(var f=u.split("%rn%"),d=0;d<f.length;d++)l.push({textAlign:i,fontSize:r,fontWeight:o,fontFamily:a,fillColor:s,strokeColor:c,strokeWidth:h,lineSpacing:e,text:f[d]});else for(var v=0;v<u.length;v++){var p=u[v];void 0===p.textAlign&&(p.textAlign=i),void 0===p.fontSize&&(p.fontSize=r),void 0===p.fontWeight&&(p.fontWeight=o),void 0===p.fontFamily&&(p.fontFamily=a),void 0===p.fillColor&&(p.fillColor=s),void 0===p.strokeColor&&(p.strokeColor=c),void 0===p.strokeWidth&&(p.strokeWidth=h),void 0===p.lineSpacing&&(p.lineSpacing=e),l.push(p)}return l}},{key:"getLocationScale",value:function(t,n){var e;return this.W.map.camera.isPerspectiveCamera?(e=new _,t.updateMatrixWorld(),this.W.map.camera.updateMatrixWorld(),e.multiplyMatrices(this.W.map.camera.matrixWorldInverse,t.matrixWorld),t=(new E).applyMatrix4(e),this.getScale(n)*Math.abs(t.z)):this.getScale(n)}},{key:"getScale",value:function(t){var n=0,n=this.W.map.camera.isPerspectiveCamera?t/(this.W.map.getRenderManager().renderer.domElement.clientHeight/(2*Math.tan(this.W.map.camera.fov*Gr.DEG2RAD/2))):t*Math.abs(this.W.map.camera.top-this.W.map.camera.bottom)/this.W.map.camera.zoom/this.W.map.getRenderManager().renderer.domElement.clientHeight;return n=isNaN(n)?1:n}}])&&Br(t.prototype,n),i&&Br(t,i),Object.defineProperty(t,"prototype",{writable:!1}),e}(),Wr={BILLBOARD:1,FLAT:2,FIX_FLAT:3};function Xr(t){return(Xr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Yr(t,n){for(var e=0;e<n.length;e++){var i=n[e];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,function(t){t=function(t,n){if("object"!=Xr(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0===e)return("string"===n?String:Number)(t);e=e.call(t,n||"default");if("object"!=Xr(e))return e;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"==Xr(t)?t:String(t)}(i.key),i)}}var Zr=function(){function t(){if(!(this instanceof t))throw new TypeError("Cannot call a class as a function")}var n,e,i;return n=t,i=[{key:"round",value:function(t){return 0<t.toFixed(2)?Math.ceil(t.toFixed(2)):Math.floor(t.toFixed(2))}},{key:"generateUUID",value:function(){for(var t=[],n=0;n<256;n++)t[n]=(n<16?"0":"")+n.toString(16);var e=4294967295*Math.random()|0,i=4294967295*Math.random()|0,r=4294967295*Math.random()|0,o=4294967295*Math.random()|0,e=t[255&e]+t[e>>8&255]+t[e>>16&255]+t[e>>24&255]+"-"+t[255&i]+t[i>>8&255]+"-"+t[i>>16&15|64]+t[i>>24&255]+"-"+t[63&r|128]+t[r>>8&255]+"-"+t[r>>16&255]+t[r>>24&255]+t[255&o]+t[o>>8&255]+t[o>>16&255]+t[o>>24&255];return t.length=0,e.toUpperCase()}},{key:"findNearNthPowerOfTwo",value:function(t){t-=1;return(t=(t=(t=(t=(t|=t>>1)|t>>2)|t>>4)|t>>8)|t>>16)<0?1:1+t}},{key:"rgbToArray",value:function(t){var n=new m;return n.setStyle(t),[n.r,n.g,n.b]}},{key:"toRgba",value:function(t){var n;return void 0===t?t:"number"!=typeof t?3<=(n=t.split(",")).length?"rgba("+parseInt(n[0])+","+parseInt(n[1])+","+parseInt(n[2])+",1)":t:"rgba("+parseInt(255*new m(t).r)+","+parseInt(255*new m(t).g)+","+parseInt(255*new m(t).b)+",1)"}},{key:"toColor",value:function(t){var n;return"number"==typeof t?t:3<=(n=t.split(",")).length?parseInt(n[0])<<16|parseInt(n[1])<<8|parseInt(n[2]):(console.error("color format error",t),0)}},{key:"cov",value:function(t){for(var n=[],e=[0,0],i=[],r=0;r<t.length;r++)e[0]+=t[r].x,e[1]+=t[r].y;e[0]=e[0]/t.length,e[1]=e[1]/t.length;for(var o=0;o<t.length;o++)i.push([t[o].x-e[0],t[o].y-e[1]]);for(var a=[],s=0;s<i[0].length;s++){for(var c=[],h=0;h<i.length;h++)c.push(i[h][s]);a.push(c)}for(var u=0;u<a.length;u++){for(var l=[],f=0;f<i[0].length;f++){for(var d=0,v=0;v<a[u].length;v++)d+=a[u][v]*i[v][f];d/=t.length-1,l.push(d)}n.push(l)}return n}},{key:"eig",value:function(t){var n=(t[0][0]+t[1][1])/2,e=t[0][0]*t[1][1]-t[1][0]*t[0][1],i=n+Math.sqrt(n*n-e),n=n-Math.sqrt(n*n-e);return 0==t[0][1]&&0==t[1][0]?{eigValue:[i,n],eigVect:[[1,0],[0,1]]}:(e=(i-t[0][0])/t[0][1],t=(n-t[0][0])/t[0][1],{eigValue:[i,n],eigVect:[[1/Math.sqrt(1+e*e),e/Math.sqrt(1+e*e)],[1/Math.sqrt(1+t*t),t/Math.sqrt(1+t*t)]]})}}],(e=null)&&Yr(n.prototype,e),i&&Yr(n,i),Object.defineProperty(n,"prototype",{writable:!1}),t}();function qr(t){return(qr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Kr(t,n){for(var e=0;e<n.length;e++){var i=n[e];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,function(t){t=function(t,n){if("object"!=qr(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0===e)return("string"===n?String:Number)(t);e=e.call(t,n||"default");if("object"!=qr(e))return e;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"==qr(t)?t:String(t)}(i.key),i)}}var A=function(){function n(t){if(!(this instanceof n))throw new TypeError("Cannot call a class as a function");this.Ht=(t=t||{}).src,this.jt=t.dest,this.W=null,this.kt=[],this.Gt=0,this.zt=0,this.Bt=0,this.Vt=Gr.THOUSAND,this.Wt=!1,this.Xt=!1,this.Yt=!0,this._t=null,this.Zt=null,this.qt=Zr.generateUUID()}var t,e,i;return t=n,(e=[{key:"play",value:function(){return this.Kt()}},{key:"pause",value:function(){return this.Xt=!0,this}},{key:"resume",value:function(){return this.Xt=!1,this.Gt+=this.Bt,this.Bt=0,this}},{key:"stop",value:function(){return this.Yt=!0,this}},{key:"finish",value:function(){return this.Yt=!0,this.Zt&&this.Zt(),this.kt=[],this}}])&&Kr(t.prototype,e),i&&Kr(t,i),Object.defineProperty(t,"prototype",{writable:!1}),n}(),Qr=(Object.assign(A.prototype,{Qt:function(){for(var t in this)this[""+t]=null,delete this[""+t]},Jt:function(t){return this.Ht=t,this},$t:function(t){return this.jt=t,this},tn:function(t){return this.Vt=t*Gr.THOUSAND,this},nn:function(t){return this.zt=t*Gr.THOUSAND,this},en:function(t){return this._t=t,this},rn:function(t){return this.Zt=t,this},on:function(t){return this.Wt=t,this},Kt:function(){return this.Yt=!1,this.W&&(this.Gt=this.W.an),this},sn:function(){var t=new this.constructor({src:this.Ht,dest:this.jt});return t.Gt=this.Gt,t.zt=this.zt,t.Vt=this.Vt,t.Wt=this.Wt,t._t=this._t,t.Zt=this.Zt,t},cn:function(){var t=this.jt.concat(),n=this.Ht.concat();return this.Ht=t,this.jt=n,this}}),A);function Jr(t){return(Jr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function $r(t,n){for(var e=0;e<n.length;e++){var i=n[e];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,function(t){t=function(t,n){if("object"!=Jr(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0===e)return("string"===n?String:Number)(t);e=e.call(t,n||"default");if("object"!=Jr(e))return e;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"==Jr(t)?t:String(t)}(i.key),i)}}function to(t,n,e){return n&&$r(t.prototype,n),e&&$r(t,e),Object.defineProperty(t,"prototype",{writable:!1}),t}var A=to(function t(){if(!(this instanceof t))throw new TypeError("Cannot call a class as a function");this.hn=new Map,this.un=[],this.an=(new Date).getTime(),this.ln=new Map,this.fn=null,this.dn=this.dn.bind(this),this.vn=0,this.pn()}),no=(Object.assign(A.prototype,{mn:function(t){if(Array.isArray(t)){this.hn.set(t[0].qt,t[0]),t[0].W=this;for(var n=1;n<t.length;n++)t[n].Gt=t[n-1].Gt+t[n-1].Vt,t[n].zt=t[n-1].zt+t[n-1].Vt,this.hn.set(t[n].qt,t[n]),t[n].W=this}else this.hn.has(t.qt)||(this.hn.set(t.qt,t),t.W=this,t.Gt=this.an)},gn:function(t){if(Array.isArray(t))for(var n=0;n<t.length;n++)this.hn.delete(t[n].qt);else this.hn.delete(t.qt)},_n:function(t){this.un.push(t)},bn:function(t){t=this.un.indexOf(t);-1<t&&this.un.splice(t,1)},yn:function(t){this.ln.set(t.qt=Zr.generateUUID(),t)},wn:function(t){this.ln.delete(t.qt)},_t:function(t,n,e){for(var i=[],r=[],o=0;o<t.Ht.length;o++)void 0===t.kt[o]&&(t.kt[o]=0),1<=n?(i.push(t.jt[o]),r.push(t.jt[o]-t.Ht[o]-t.kt[o])):(i.push((t.jt[o]-t.Ht[o])*n+t.Ht[o]),r.push((t.jt[o]-t.Ht[o])*e),t.kt[o]+=(t.jt[o]-t.Ht[o])*e);t._t({destination:i,delta:r}),r.length=i.length=0},pn:function(){var i=this,r=(this.vn=Fr.window.requestAnimationFrame(this.pn.bind(this)),(new Date).getTime()),o=r-this.an;this.ln.forEach(function(t){return t(o)});for(var t=0;t<this.un.length;t++)this.un[t].update(o/1e3);this.hn.forEach(function(t){var n,e;t.Yt||(t.Xt?t.Bt+=o:(n=(r-t.Gt)/t.Vt,e=o/t.Vt,i._t(t,n,e),n=r-t.Gt-t.zt,t.Vt<=n&&(t.kt=[],t.Wt?(t.Gt=r,t.Zt&&t.Zt()):(e=t.Yt,t.Yt=!0,!e&&t.Zt&&t.Zt()))))}),this.an=r,this.fn&&0===this.hn.size&&this.dn()},Qt:function(t){this.fn=t},dn:function(){this.vn&&(Fr.window.cancelAnimationFrame(this.vn),this.vn=0),this.hn.forEach(function(t){t.Qt()}),this.hn.clear(),this.un=[],this.ln.clear(),this.fn&&this.fn({name:"Animator"})}}),A);function eo(t){return(eo="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function io(t,n){for(var e=0;e<n.length;e++){var i=n[e];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,ho(i.key),i)}}function ro(t,n,e){n=N(n);var i=t,n=oo()?Reflect.construct(n,e||[],N(t).constructor):n.apply(t,e);if(n&&("object"===eo(n)||"function"==typeof n))return n;if(void 0!==n)throw new TypeError("Derived constructors may only return object or undefined");return ao(i)}function oo(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(oo=function(){return!!t})()}function ao(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function so(t,n,e,i){return(so="undefined"!=typeof Reflect&&Reflect.set?Reflect.set:function(t,n,e,i){var r,t=lo(t,n);if(t){if((r=Object.getOwnPropertyDescriptor(t,n)).set)return r.set.call(i,e),!0;if(!r.writable)return!1}if(r=Object.getOwnPropertyDescriptor(i,n)){if(!r.writable)return!1;r.value=e,Object.defineProperty(i,n,r)}else t=i,r=e,!((i=ho(i=n))in t?Object.defineProperty(t,i,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[i]=r);return!0})(t,n,e,i)}function co(t,n,e,i,r){if(!so(t,n,e,i||t)&&r)throw new TypeError("failed to set property")}function ho(t){t=function(t,n){if("object"!=eo(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0===e)return("string"===n?String:Number)(t);e=e.call(t,n||"default");if("object"!=eo(e))return e;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"==eo(t)?t:String(t)}function uo(t,n){return(uo=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t})(t,n)}function R(){return(R="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,n,e){var i=lo(t,n);if(i)return(i=Object.getOwnPropertyDescriptor(i,n)).get?i.get.call(arguments.length<3?t:e):i.value}).apply(this,arguments)}function lo(t,n){for(;!Object.prototype.hasOwnProperty.call(t,n)&&null!==(t=N(t)););return t}function N(t){return(N=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var fo,vo={FMWallMarker:t,FMTubeMarker:Xe,FMSphereMarker:Ji,FMLine3dMarker:Oi,FMCompositeMarker:function(t){var n,e=i;if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");function i(t){var n;if(!(this instanceof i))throw new TypeError("Cannot call a class as a function");void 0===t.anchor&&(t.anchor={baseon:"all",anchor:fengmap.FMMarkerAnchor.CENTER}),"image"!==t.layout.style&&"text"!==t.layout.style||(t.anchor.baseon="all"),void 0===t.collision&&(t.collision=!0),void 0===t.render||""+t.render!="flat"&&""+t.render!="rectangle"&&""+t.render!=""+Wr.FLAT&&""+t.render!=""+Wr.FIX_FLAT||(t.collision=!1);var e={text:"",x:t.x,y:t.y,height:t.height,collision:!1};return""+t.render!="rectangle"&&""+t.render!=""+Wr.FIX_FLAT||void 0===t.rectangle||(e.x=t.rectangle.center.x,e.y=t.rectangle.center.y),"all"===t.anchor.baseon&&(e.anchor=t.anchor.anchor),(n=ro(this,i,[e])).myanchor=t.anchor,n.map=null,n.markerOptions=t,n.tool=new Vr(ao(n),t),n.mydepth=void 0!==t.depth&&t.depth,n.url=null,n.imagesize=[32,32],n.renderType=t.render,n.myrenderNode=null,void 0===n.renderType?n.renderType="billboard":""+n.renderType==""+Wr.FLAT?n.renderType="flat":""+n.renderType==""+Wr.FIX_FLAT?n.renderType="rectangle":""+n.renderType==""+Wr.BILLBOARD&&(n.renderType="billboard"),t.image&&(n.url=t.image.url,t.image.size)&&(n.imagesize=t.image.size),n.rotateAnimation=null,n.animator=new no,n.myUpdateSize=n.myUpdateSize.bind(ao(n)),n.zoomUpdate=n.zoomUpdate.bind(ao(n)),"billboard"===n.renderType?R((e=ao(n),N(i.prototype)),"setInitWriteRenderNodeFunction",e).call(e,function(t){return n.tool.createSprite(t)}):"flat"===n.renderType?R((t=ao(n),N(i.prototype)),"setInitWriteRenderNodeFunction",t).call(t,function(t){return n.myrenderNode=n.tool.createFlatMesh(t),n.myrenderNode}):"rectangle"===n.renderType&&R((e=ao(n),N(i.prototype)),"setInitWriteRenderNodeFunction",e).call(e,function(t){return n.myrenderNode=n.tool.createRectMesh(t),n.myrenderNode}),n}return e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&uo(e,t),e=i,(t=[{key:"addTo",value:function(t){R(N(i.prototype),"addTo",this).call(this,t),this.map=t.parent.parent,this.size=this.imagesize[1],this.map.on("zoom",this.zoomUpdate),"billboard"===this.renderType?this.tool.myUpdateMaterial():this.myInit()}},{key:"stop",value:function(){R(N(i.prototype),"stop",this).call(this),this.rotateAnimation&&(this.animator.gn(this.rotateAnimation),this.rotateAnimation=null)}},{key:"remove",value:function(){R(N(i.prototype),"remove",this).call(this),this.map.off("zoom",this.zoomUpdate),"flat"===this.renderType&&this.myrenderNode&&this.myrenderNode.parent&&(this.rotateAnimation&&(this.animator.gn(this.rotateAnimation),this.rotateAnimation=null),this.myrenderNode.parent.remove(this.myrenderNode),this.myrenderNode=null,this.map.off("zoom",this.myUpdateSize),this.map.off("resize",this.myUpdateSize),this.map.off("viewChanged",this.myUpdateSize))}},{key:"setText",value:function(t){this.markerOptions.text.content.text=t}},{key:"getText",value:function(){return this.markerOptions.text.content.text}},{key:"setImage",value:function(t,n){this.url=t,this.imagesize=n,this.size=this.imagesize[1]}},{key:"getImage",value:function(){return{url:this.url,size:this.imagesize}}},{key:"update",value:function(n){var e,i=this;"billboard"===this.renderType?this.tool.myUpdateMaterial(!0):(e=new g,this.tool.editFlatMaterial(e,function(){var t=i.myrenderNode;t.material.map&&t.material.map.dispose(),t.material.dispose(),t.material=e,"flat"===i.renderType&&i.myUpdateSize(),i.map.enableUpdateRender(),n&&n()}))}},{key:"moveTo",value:function(t){R(N(i.prototype),"moveTo",this).call(this,t)}},{key:"rotateTo",value:function(t){var n,e,i,r,o,a=this;"billboard"!==this.renderType&&(n=this.map,e=t.duration||.5,i=this.myrenderNode.rotation.y,r=t.heading%360*Gr.DEG2RAD,o=0,o=i+(o=(r="flat"===this.renderType?-Math.PI+r:r)-i!=0?Math.sin(r-i)/Math.abs(Math.sin(r-i))*Math.acos(Math.cos(r-i)):o),t.animate?(this.rotateAnimation?(this.rotateAnimation.Jt([i]),this.rotateAnimation.$t([r])):this.rotateAnimation=new Qr({src:[i],dest:[o]}),this.rotateAnimation.tn(e).en(function(t){a.myrenderNode&&("flat"===a.renderType?a.myrenderNode.rotation.y=t.destination[0]:a.myrenderNode.rotation.z=t.destination[0],n.enableUpdateRender())}).rn(function(){a.animator.gn(a.rotateAnimation),a.rotateAnimation=null,n.enableUpdateRender(),t.finish&&t.finish()}),this.animator.mn(this.rotateAnimation.Kt())):this.myrenderNode&&("flat"===this.renderType?this.myrenderNode.rotation.y=o:this.myrenderNode.rotation.z=o,n.enableUpdateRender()))}},{key:"visible",get:function(){return R(N(i.prototype),"visible",this)},set:function(t){co(N(i.prototype),"visible",t,this,!0)}},{key:"plateColor",get:function(){return this.markerOptions.text.plateColor},set:function(t){this.markerOptions.text.plateColor=t}},{key:"plateStrokeColor",get:function(){return this.markerOptions.text.plateStrokeColor},set:function(t){this.markerOptions.text.plateStrokeColor=t}},{key:"plateOpacity",get:function(){return this.markerOptions.text.plateOpacity},set:function(t){this.markerOptions.text.plateOpacity=t}},{key:"plateStrokeRadius",get:function(){return this.markerOptions.text.plateStrokeRadius},set:function(t){this.markerOptions.text.plateStrokeRadius=t}},{key:"height",get:function(){return R(N(i.prototype),"height",this)},set:function(t){co(N(i.prototype),"height",t,this,!0),this.map.enableUpdateRender()}},{key:"x",get:function(){return R(N(i.prototype),"x",this)}},{key:"y",get:function(){return R(N(i.prototype),"y",this)}},{key:"zoomRange",get:function(){var t=this.markerOptions.zoomRange;return t=void 0===t?[16,23]:t},set:function(t){this.markerOptions.zoomRange=t,this.zoomUpdate()}},{key:"opacity",get:function(){var t=this.markerOptions.opacity;return void 0===t?1:t},set:function(t){this.markerOptions.opacity=t}},{key:"level",get:function(){return R(N(i.prototype),"level",this)}},{key:"text",get:function(){return"image"!==this.markerOptions.layout.style?this.getText():" "}},{key:"type",get:function(){return R(N(i.prototype),"type",this)}},{key:"myInit",value:function(){var t=this;this.update(function(){"flat"===t.renderType&&(t.map.on("zoom",t.myUpdateSize),t.map.on("resize",t.myUpdateSize),t.map.on("viewChanged",t.myUpdateSize),t.map.enableUpdateRender())})}},{key:"myUpdateSize",value:function(){var t,n,e=this.map;e&&(n=this.myrenderNode.position,t=!1,(isNaN(n.x)||isNaN(n.y)||isNaN(n.z)||"number"!=typeof n.x||"number"!=typeof n.y||"number"!=typeof n.z)&&(t=!0),"flat"!==this.renderType||t||(n=this.tool.getLocationScale(this.myrenderNode,this.size),this.myrenderNode.scale.set(n,n,n),this.myrenderNode.scale.multiplyScalar(this.myrenderNode.material.userData.mspriteScale),this.myrenderNode.scale.setX(this.myrenderNode.scale.x/this.myrenderNode.material.userData.scaleRatio),e.enableUpdateRender()))}},{key:"zoomUpdate",value:function(){var t=this.markerOptions.zoomRange,n=(void 0===t&&(t=[16,23]),this.getRenderNode()),e=("flat"===this.renderType&&(n=this.myrenderNode),this.map.getZoom());!(e<t[0]||e>t[1])&&this.visible?n.visible=!0:n.visible=!1}},{key:"dispose",value:function(){this.remove()}},{key:"getAnchor",value:function(){var t="billboard"===this.renderType?{x:this.getRenderNode().center.x,y:this.getRenderNode().center.y}:{x:.5,y:.5};return t}},{key:"getScreenSize",value:function(){var t,n;return"billboard"===this.renderType?{width:(t=this.size*this.getRenderNode().material.userData.mspriteScale*1.1)/this.getRenderNode().material.userData.scaleRatio,height:t}:(t=this.markerOptions.layout.style,n=this.myrenderNode.material.map.image,"image"===t?{width:n.width,height:n.height}:{width:n.width/2,height:n.height/2})}}])&&io(e.prototype,t),n&&io(e,n),Object.defineProperty(e,"prototype",{writable:!1}),i}(fengmap.FMTextMarker),FMMarkerRenderMode:Wr};for(fo in vo)window.fengmap[fo]=vo[fo];F.default=fengmap}],i={},r.m=e,r.c=i,r.d=function(t,n,e){r.o(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:e})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"xn",{value:!0})},r.t=function(n,t){if(1&t&&(n=r(n)),8&t)return n;if(4&t&&"object"==typeof n&&n&&n.xn)return n;var e=Object.create(null);if(r.r(e),Object.defineProperty(e,"default",{enumerable:!0,value:n}),2&t&&"string"!=typeof n)for(var i in n)r.d(e,i,function(t){return n[t]}.bind(null,i));return e},r.n=function(t){var n=t&&t.xn?function(){return t.default}:function(){return t};return r.d(n,"a",n),n},r.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},r.p="",r(r.s=0).default;function r(t){var n;return(i[t]||(n=i[t]={i:t,l:!1,exports:{}},e[t].call(n.exports,n,n.exports,r),n.l=!0,n)).exports}var e,i});