openct-tasks/_common/modules/ext/zen3d/zen3d.min.js

2 lines
229 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// github.com/shawn0326/zen-3d
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).zen3d={})}(this,function(e){"use strict";var t,r,n,i,a=(r="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),n=new Array(36),function(){for(var e=0;e<36;e++)8===e||13===e||18===e||23===e?n[e]="-":14===e?n[e]="4":(i<=2&&(i=33554432+16777216*Math.random()|0),t=15&i,i>>=4,n[e]=r[19===e?3&t|8:t]);return n.join("")});function o(e){return 0==(e&e-1)&&0!==e}function s(e){return Math.pow(2,Math.round(Math.log(e)/Math.LN2))}function h(e){return e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,++e}function c(e){var t={};for(var r in e){var n=e[r];Array.isArray(n)?t[r]=n.slice():t[r]=n}return t}var u,l,d,p,f,_,m,v,g,M,E,S,x,y,w,T,b,A,N,P,L,R,C,O,F,U,I,D,B,z,V={MESH:"mesh",SKINNED_MESH:"skinned_mesh",LIGHT:"light",CAMERA:"camera",SCENE:"scene",GROUP:"group",CANVAS2D:"canvas2d"},G={AMBIENT:"ambient",DIRECT:"direct",POINT:"point",SPOT:"spot"},H={BASIC:"basic",LAMBERT:"lambert",PHONG:"phong",PBR:"pbr",PBR2:"pbr2",POINT:"point",LINE:"line",CANVAS2D:"canvas2d",SHADER:"shader",DEPTH:"depth",DISTANCE:"distance"},k={NORMAL:"normal",EXP2:"exp2"},j={NONE:"none",NORMAL:"normal",ADD:"add",CUSTOM:"custom"},X={ADD:32774,SUBTRACT:32778,REVERSE_SUBTRACT:32779},W={ZERO:i=0,ONE:1,SRC_COLOR:768,ONE_MINUS_SRC_COLOR:769,SRC_ALPHA:770,ONE_MINUS_SRC_ALPHA:771,DST_ALPHA:772,ONE_MINUS_DST_ALPHA:773,DST_COLOR:774,ONE_MINUS_DST_COLOR:775},Y={NONE:"none",FRONT:"front",BACK:"back",FRONT_AND_BACK:"front_and_back"},q={FRONT:"front",BACK:"back",DOUBLE:"double"},Z={SMOOTH_SHADING:"smooth_shading",FLAT_SHADING:"flat_shading"},K={TEXTURE_2D:3553,TEXTURE_CUBE_MAP:34067,TEXTURE_3D:32879},Q={DEPTH_COMPONENT:6402,DEPTH_STENCIL:34041,ALPHA:6406,RED:6403,RGB:6407,RGBA:6408,LUMINANCE:6409,LUMINANCE_ALPHA:6410,R8:33321,RGBA8:32856,RGBA16F:34842,RGBA32F:34836,DEPTH_COMPONENT16:33189,DEPTH_COMPONENT24:33190,DEPTH_COMPONENT32F:36012,DEPTH24_STENCIL8:35056,DEPTH32F_STENCIL8:36013},$={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,HALF_FLOAT:36193,UNSIGNED_INT_24_8:34042,UNSIGNED_SHORT_4_4_4_4:32819,UNSIGNED_SHORT_5_5_5_1:32820,UNSIGNED_SHORT_5_6_5:33635,FLOAT_32_UNSIGNED_INT_24_8_REV:36269},J={NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987},ee={REPEAT:10497,CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648},te={LEQUAL:515,GEQUAL:518,LESS:513,GREATER:516,EQUAL:514,NOTEQUAL:517,ALWAYS:519,NEVER:512},re={FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,INT_VEC2:35667,INT_VEC3:35668,INT_VEC4:35669,BOOL:35670,BOOL_VEC2:35671,BOOL_VEC3:35672,BOOL_VEC4:35673,FLOAT_MAT2:35674,FLOAT_MAT3:35675,FLOAT_MAT4:35676,SAMPLER_2D:35678,SAMPLER_2D_SHADOW:35682,SAMPLER_CUBE:35680,SAMPLER_CUBE_SHADOW:36293,SAMPLER_3D:35679,BYTE:65535,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126},ne={FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,FLOAT:5126,BYTE:65535,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},ie={HARD:"hard",POISSON_SOFT:"poisson_soft",PCF3_SOFT:"pcf3_soft",PCF5_SOFT:"pcf5_soft",PCSS16_SOFT:"pcss16_soft",PCSS32_SOFT:"pcss32_soft",PCSS64_SOFT:"pcss64_soft"},ae={LINEAR:"linear",SRGB:"sRGB",RGBE:"RGBE",RGBM7:"RGBM7",RGBM16:"RGBM16",RGBD:"RGBD",GAMMA:"Gamma"},se={MULTIPLY:"ENVMAP_BLENDING_MULTIPLY",MIX:"ENVMAP_BLENDING_MIX",ADD:"ENVMAP_BLENDING_ADD"},oe={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},he={NONE:0,RGB:1,RGBA:2},ce={COLOR_ATTACHMENT0:36064,COLOR_ATTACHMENT1:36065,COLOR_ATTACHMENT2:36066,COLOR_ATTACHMENT3:36067,COLOR_ATTACHMENT4:36068,COLOR_ATTACHMENT5:36069,COLOR_ATTACHMENT6:36070,COLOR_ATTACHMENT7:36071,COLOR_ATTACHMENT8:36072,COLOR_ATTACHMENT9:36073,COLOR_ATTACHMENT10:577040,COLOR_ATTACHMENT11:577041,COLOR_ATTACHMENT12:577042,COLOR_ATTACHMENT13:577043,COLOR_ATTACHMENT14:577044,COLOR_ATTACHMENT15:577045,DEPTH_ATTACHMENT:36096,STENCIL_ATTACHMENT:36128,DEPTH_STENCIL_ATTACHMENT:33306};function ue(){this.eventMap={}}function le(e,t,r){this.x=e||0,this.y=t||0,this.z=r||0}function de(e,t){this.origin=void 0!==e?e:new le,this.direction=void 0!==t?t:new le}function pe(e,t,r,n){this.ray=new de(e,t),this.near=r||0,this.far=n||1/0}function fe(e,t){return e.distance-t.distance}function _e(e,t,r,n){if(e.raycast(t,r),!0===n)for(var i=e.children,a=0,s=i.length;a<s;a++)_e(i[a],t,r,!0)}function me(){this.elements=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function ve(e,t,r,n){this._x=e||0,this._y=t||0,this._z=r||0,this._order=n||ve.DefaultOrder}function ge(e,t){this.x=e||0,this.y=t||0}function Me(e,t,r,n){this.x=e||0,this.y=t||0,this.z=r||0,this.w=void 0!==n?n:1}function Ee(){this.elements=new Float32Array([1,0,0,0,1,0,0,0,1])}function Se(e,t,r,n){this._x=e||0,this._y=t||0,this._z=r||0,this._w=void 0!==n?n:1}function xe(e,t){this.min=void 0!==e?e:new ge(1/0,1/0),this.max=void 0!==t?t:new ge(-1/0,-1/0)}function ye(e,t){this.min=void 0!==e?e:new le(1/0,1/0,1/0),this.max=void 0!==t?t:new le(-1/0,-1/0,-1/0)}function we(e,t){this.center=void 0!==e?e:new le,this.radius=void 0!==t?t:0}function Te(e,t){this.normal=void 0!==e?e:new le(1,0,0),this.constant=void 0!==t?t:0}function be(e,t,r,n,i,a){this.planes=[void 0!==e?e:new Te,void 0!==t?t:new Te,void 0!==r?r:new Te,void 0!==n?n:new Te,void 0!==i?i:new Te,void 0!==a?a:new Te]}function Ae(e,t,r){return this.r=0,this.g=0,void(this.b=0)===t&&void 0===r?this.setHex(e):this.setRGB(e,t,r)}function Ne(e,t,r){return r<0&&(r+=1),1<r&&--r,r<1/6?e+6*(t-e)*r:r<.5?t:r<2/3?e+6*(t-e)*(2/3-r):e}function Pe(e,t,r){this.a=void 0!==e?e:new le,this.b=void 0!==t?t:new le,this.c=void 0!==r?r:new le}function Le(e,t){this.posPoints=void 0,this.ctrlPoints=void 0,this.segCount=0,this.set(e,t)}function Re(e,t,r){this.radius=void 0!==e?e:1,this.phi=void 0!==t?t:0,this.theta=void 0!==r?r:0}function Ce(){ue.call(this),this.uuid=a(),this.textureType="",this.mipmaps=[],this.border=0,this.format=Q.RGBA,this.internalformat=null,this.type=$.UNSIGNED_BYTE,this.magFilter=J.LINEAR,this.minFilter=J.LINEAR_MIPMAP_LINEAR,this.wrapS=ee.CLAMP_TO_EDGE,this.wrapT=ee.CLAMP_TO_EDGE,this.anisotropy=1,this.compare=void 0,this.generateMipmaps=!0,this.encoding=ae.LINEAR,this.flipY=!0,this.version=0}function Oe(e,t,r){var n=this,i=!1,a=0,s=0,o=void 0;this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=r,this.itemStart=function(e){s++,!1===i&&void 0!==n.onStart&&n.onStart(e,a,s),i=!0},this.itemEnd=function(e){a++,void 0!==n.onProgress&&n.onProgress(e,a,s),a===s&&(i=!1,void 0!==n.onLoad&&n.onLoad())},this.itemError=function(e){void 0!==n.onError&&n.onError(e)},this.resolveURL=function(e){return o?o(e):e},this.setURLModifier=function(e){return o=e,this}}Object.assign(ue.prototype,{addEventListener:function(e,t,r){var n=this.eventMap[e];(n=n||(this.eventMap[e]=[])).push({listener:t,thisObject:r||this})},removeEventListener:function(e,t,r){var n=this.eventMap[e];if(n)for(var i=0,a=n.length;i<a;i++){var s=n[i];if(s.listener==t&&s.thisObject==(r||this)){n.splice(i,1);break}}},dispatchEvent:function(e){(e.target=this).notifyListener(e)},notifyListener:function(e){var t=this.eventMap[e.type];if(t)for(var r=0,n=t.length;r<n;r++){var i=t[r];i.listener.call(i.thisObject,e)}}}),Object.assign(le.prototype,{lerpVectors:function(e,t,r){return this.subVectors(t,e).multiplyScalar(r).add(e)},set:function(e,t,r){return this.x=e||0,this.y=t||0,this.z=r||0,this},min:function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this},max:function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this},getLength:function(){return Math.sqrt(this.getLengthSquared())},getLengthSquared:function(){return this.x*this.x+this.y*this.y+this.z*this.z},normalize:function(e){e=e||1;var t=this.getLength();if(0!=t){var r=e/t;return this.x*=r,this.y*=r,this.z*=r,this}},subtract:function(e,t){return(t=t||new le).set(this.x-e.x,this.y-e.y,this.z-e.z),t},multiply:function(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this},crossVectors:function(e,t){var r=e.x,n=e.y,i=e.z,a=t.x,s=t.y,o=t.z;return this.x=n*o-i*s,this.y=i*a-r*o,this.z=r*s-n*a,this},cross:function(e){var t=this.x,r=this.y,n=this.z;return this.x=r*e.z-n*e.y,this.y=n*e.x-t*e.z,this.z=t*e.y-r*e.x,this},dot:function(e){return this.x*e.x+this.y*e.y+this.z*e.z},applyQuaternion:function(e){var t=this.x,r=this.y,n=this.z,i=e._x,a=e._y,s=e._z,o=e._w,h=o*t+a*n-s*r,c=o*r+s*t-i*n,u=o*n+i*r-a*t,l=-i*t-a*r-s*n;return this.x=h*o+l*-i+c*-s-u*-a,this.y=c*o+l*-a+u*-i-h*-s,this.z=u*o+l*-s+h*-a-c*-i,this},applyMatrix4:function(e){var t=this.x,r=this.y,n=this.z,i=e.elements,a=1/(i[3]*t+i[7]*r+i[11]*n+i[15]);return this.x=(i[0]*t+i[4]*r+i[8]*n+i[12])*a,this.y=(i[1]*t+i[5]*r+i[9]*n+i[13])*a,this.z=(i[2]*t+i[6]*r+i[10]*n+i[14])*a,this},applyMatrix3:function(e){var t=this.x,r=this.y,n=this.z,i=e.elements;return this.x=i[0]*t+i[3]*r+i[6]*n,this.y=i[1]*t+i[4]*r+i[7]*n,this.z=i[2]*t+i[5]*r+i[8]*n,this},transformDirection:function(e){var t=this.x,r=this.y,n=this.z,i=e.elements;return this.x=i[0]*t+i[4]*r+i[8]*n,this.y=i[1]*t+i[5]*r+i[9]*n,this.z=i[2]*t+i[6]*r+i[10]*n,this.normalize()},setFromMatrixPosition:function(e){return this.setFromMatrixColumn(e,3)},setFromMatrixColumn:function(e,t){return this.fromArray(e.elements,4*t)},fromArray:function(e,t){return void 0===t&&(t=0),this.x=e[t],this.y=e[t+1],this.z=e[t+2],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e},copy:function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this},addScalar:function(e){return this.x+=e,this.y+=e,this.z+=e,this},add:function(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this},addScaledVector:function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this},sub:function(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this},multiplyScalar:function(e){return this.x*=e,this.y*=e,this.z*=e,this},distanceToSquared:function(e){var t=this.x-e.x,r=this.y-e.y,n=this.z-e.z;return t*t+r*r+n*n},distanceTo:function(e){return Math.sqrt(this.distanceToSquared(e))},setFromSpherical:function(e){var t=Math.sin(e.phi)*e.radius;return this.x=t*Math.sin(e.theta),this.y=Math.cos(e.phi)*e.radius,this.z=t*Math.cos(e.theta),this},project:function(e){return this.applyMatrix4(e.viewMatrix).applyMatrix4(e.projectionMatrix)},unproject:function(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.worldMatrix)},equals:function(e){return e.x===this.x&&e.y===this.y&&e.z===this.z},clone:function(){return new le(this.x,this.y,this.z)},applyProjection:function(e){console.error("zen3d.Vector3: .applyProjection has been removed. Use .applyMatrix4 instead.")}}),Object.assign(de.prototype,{set:function(e,t){this.origin.copy(e),this.direction.copy(t)},at:function(e,t){return(t||new le).copy(this.direction).multiplyScalar(e).add(this.origin)},intersectsSphere:(f=new le,function(e,t){f.subVectors(e.center,this.origin);var r=f.dot(this.direction),n=f.dot(f)-r*r,i=e.radius*e.radius;if(i<n)return null;var a=Math.sqrt(i-n),s=r-a,o=r+a;return s<0&&o<0?null:s<0?this.at(o,t):this.at(s,t)}),intersectsBox:function(e,t){var r,n,i,a,s,o,h=1/this.direction.x,c=1/this.direction.y,u=1/this.direction.z,l=this.origin;return n=0<=h?(r=(e.min.x-l.x)*h,(e.max.x-l.x)*h):(r=(e.max.x-l.x)*h,(e.min.x-l.x)*h),(a=0<=c?(i=(e.min.y-l.y)*c,(e.max.y-l.y)*c):(i=(e.max.y-l.y)*c,(e.min.y-l.y)*c))<r||n<i?null:((r<i||r!=r)&&(r=i),(a<n||n!=n)&&(n=a),(o=0<=u?(s=(e.min.z-l.z)*u,(e.max.z-l.z)*u):(s=(e.max.z-l.z)*u,(e.min.z-l.z)*u))<r||n<s?null:((r<s||r!=r)&&(r=s),(o<n||n!=n)&&(n=o),n<0?null:this.at(0<=r?r:n,t)))},intersectTriangle:(u=new le,l=new le,d=new le,p=new le,function(e,t,r,n,i){l.subVectors(t,e),d.subVectors(r,e),p.crossVectors(l,d);var a,s=this.direction.dot(p);if(0<s){if(n)return null;a=1}else{if(!(s<0))return null;a=-1,s=-s}u.subVectors(this.origin,e);var o=a*this.direction.dot(d.crossVectors(u,d));if(o<0)return null;var h=a*this.direction.dot(l.cross(u));if(h<0)return null;if(s<o+h)return null;var c=-a*u.dot(p);return c<0?null:this.at(c/s,i)}),copy:function(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this},applyMatrix4:function(e){return this.direction.add(this.origin).applyMatrix4(e),this.origin.applyMatrix4(e),this.direction.sub(this.origin),this.direction.normalize(),this}}),Object.assign(pe.prototype,{set:function(e,t){this.ray.set(e,t)},setFromCamera:function(e,t,r){"orthographic"==(r=r||"perspective")?(this.ray.origin.set(e.x,e.y,t.projectionMatrix.elements[14]).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.worldMatrix)):(this.ray.origin.setFromMatrixPosition(t.worldMatrix),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize())},intersectObject:function(e,t){var r=[];return _e(e,this,r,t),r.sort(fe),r},intersectObjects:function(e,t){var r=[];if(!1===Array.isArray(e))return console.warn("Raycaster.intersectObjects: objects is not an Array."),r;for(var n=0,i=e.length;n<i;n++)_e(e[n],this,r,t);return r.sort(fe),r}}),Object.assign(me.prototype,{identity:function(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this},set:function(e,t,r,n,i,a,s,o,h,c,u,l,d,p,f,_){var m=this.elements;return m[0]=e,m[4]=t,m[8]=r,m[12]=n,m[1]=i,m[5]=a,m[9]=s,m[13]=o,m[2]=h,m[6]=c,m[10]=u,m[14]=l,m[3]=d,m[7]=p,m[11]=f,m[15]=_,this},copy:function(e){return this.elements.set(e.elements),this},makeTranslation:function(e,t,r){return this.set(1,0,0,e,0,1,0,t,0,0,1,r,0,0,0,1),this},multiply:function(e){return this.multiplyMatrices(this,e)},premultiply:function(e){return this.multiplyMatrices(e,this)},multiplyMatrices:function(e,t){var r=e.elements,n=t.elements,i=this.elements,a=r[0],s=r[4],o=r[8],h=r[12],c=r[1],u=r[5],l=r[9],d=r[13],p=r[2],f=r[6],_=r[10],m=r[14],v=r[3],g=r[7],M=r[11],E=r[15],S=n[0],x=n[4],y=n[8],w=n[12],T=n[1],b=n[5],A=n[9],N=n[13],P=n[2],L=n[6],R=n[10],C=n[14],O=n[3],F=n[7],U=n[11],I=n[15];return i[0]=a*S+s*T+o*P+h*O,i[4]=a*x+s*b+o*L+h*F,i[8]=a*y+s*A+o*R+h*U,i[12]=a*w+s*N+o*C+h*I,i[1]=c*S+u*T+l*P+d*O,i[5]=c*x+u*b+l*L+d*F,i[9]=c*y+u*A+l*R+d*U,i[13]=c*w+u*N+l*C+d*I,i[2]=p*S+f*T+_*P+m*O,i[6]=p*x+f*b+_*L+m*F,i[10]=p*y+f*A+_*R+m*U,i[14]=p*w+f*N+_*C+m*I,i[3]=v*S+g*T+M*P+E*O,i[7]=v*x+g*b+M*L+E*F,i[11]=v*y+g*A+M*R+E*U,i[15]=v*w+g*N+M*C+E*I,this},transpose:function(){var e,t=this.elements;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this},inverse:function(){return this.getInverse(this)},getInverse:function(e){var t=this.elements,r=e.elements,n=r[0],i=r[1],a=r[2],s=r[3],o=r[4],h=r[5],c=r[6],u=r[7],l=r[8],d=r[9],p=r[10],f=r[11],_=r[12],m=r[13],v=r[14],g=r[15],M=d*v*u-m*p*u+m*c*f-h*v*f-d*c*g+h*p*g,E=_*p*u-l*v*u-_*c*f+o*v*f+l*c*g-o*p*g,S=l*m*u-_*d*u+_*h*f-o*m*f-l*h*g+o*d*g,x=_*d*c-l*m*c-_*h*p+o*m*p+l*h*v-o*d*v,y=n*M+i*E+a*S+s*x;if(0==y)return console.warn("can't invert matrix, determinant is 0"),this.identity();var w=1/y;return t[0]=M*w,t[1]=(m*p*s-d*v*s-m*a*f+i*v*f+d*a*g-i*p*g)*w,t[2]=(h*v*s-m*c*s+m*a*u-i*v*u-h*a*g+i*c*g)*w,t[3]=(d*c*s-h*p*s-d*a*u+i*p*u+h*a*f-i*c*f)*w,t[4]=E*w,t[5]=(l*v*s-_*p*s+_*a*f-n*v*f-l*a*g+n*p*g)*w,t[6]=(_*c*s-o*v*s-_*a*u+n*v*u+o*a*g-n*c*g)*w,t[7]=(o*p*s-l*c*s+l*a*u-n*p*u-o*a*f+n*c*f)*w,t[8]=S*w,t[9]=(_*d*s-l*m*s-_*i*f+n*m*f+l*i*g-n*d*g)*w,t[10]=(o*m*s-_*h*s+_*i*u-n*m*u-o*i*g+n*h*g)*w,t[11]=(l*h*s-o*d*s-l*i*u+n*d*u+o*i*f-n*h*f)*w,t[12]=x*w,t[13]=(l*m*a-_*d*a+_*i*p-n*m*p-l*i*v+n*d*v)*w,t[14]=(_*h*a-o*m*a-_*i*c+n*m*c+o*i*v-n*h*v)*w,t[15]=(o*d*a-l*h*a+l*i*c-n*d*c-o*i*p+n*h*p)*w,this},transform:(E=new me,function(e,t,r){var n=r.toMatrix4(E).elements,i=this.elements;return i[0]=n[0]*t.x,i[1]=n[1]*t.x,i[2]=n[2]*t.x,i[3]=0,i[4]=n[4]*t.y,i[5]=n[5]*t.y,i[6]=n[6]*t.y,i[7]=0,i[8]=n[8]*t.z,i[9]=n[9]*t.z,i[10]=n[10]*t.z,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}),makeRotationFromQuaternion:function(e){var t=this.elements,r=e.x,n=e.y,i=e.z,a=e.w,s=r+r,o=n+n,h=i+i,c=r*s,u=r*o,l=r*h,d=n*o,p=n*h,f=i*h,_=a*s,m=a*o,v=a*h;return t[0]=1-(d+f),t[4]=u-v,t[8]=l+m,t[1]=u+v,t[5]=1-(c+f),t[9]=p-_,t[2]=l-m,t[6]=p+_,t[10]=1-(c+d),t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this},lookAtRH:(v=new le,g=new le,M=new le,function(e,t,r){var n=this.elements;return M.subVectors(e,t),0===M.getLengthSquared()&&(M.z=1),M.normalize(),v.crossVectors(r,M),0===v.getLengthSquared()&&(1===Math.abs(r.z)?M.x+=1e-4:M.z+=1e-4,M.normalize(),v.crossVectors(r,M)),v.normalize(),g.crossVectors(M,v),n[0]=v.x,n[4]=g.x,n[8]=M.x,n[1]=v.y,n[5]=g.y,n[9]=M.y,n[2]=v.z,n[6]=g.z,n[10]=M.z,this}),decompose:(_=new le,m=new me,function(e,t,r){var n=this.elements,i=_.set(n[0],n[1],n[2]).getLength(),a=_.set(n[4],n[5],n[6]).getLength(),s=_.set(n[8],n[9],n[10]).getLength();this.determinant()<0&&(i=-i),e.x=n[12],e.y=n[13],e.z=n[14],m.elements.set(this.elements);var o=1/i,h=1/a,c=1/s;return m.elements[0]*=o,m.elements[1]*=o,m.elements[2]*=o,m.elements[4]*=h,m.elements[5]*=h,m.elements[6]*=h,m.elements[8]*=c,m.elements[9]*=c,m.elements[10]*=c,t.setFromRotationMatrix(m),r.x=i,r.y=a,r.z=s,this}),determinant:function(){var e=this.elements,t=e[0],r=e[4],n=e[8],i=e[12],a=e[1],s=e[5],o=e[9],h=e[13],c=e[2],u=e[6],l=e[10],d=e[14];return e[3]*(i*o*u-n*h*u-i*s*l+r*h*l+n*s*d-r*o*d)+e[7]*(t*o*d-t*h*l+i*a*l-n*a*d+n*h*c-i*o*c)+e[11]*(t*h*u-t*s*d-i*a*u+r*a*d+i*s*c-r*h*c)+e[15]*(-n*s*c-t*o*u+t*s*l+n*a*u-r*a*l+r*o*c)},fromArray:function(e,t){void 0===t&&(t=0);for(var r=0;r<16;r++)this.elements[r]=e[r+t];return this},getMaxScaleOnAxis:function(){var e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],r=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],n=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,r,n))},toArray:function(e,t){void 0===e&&(e=[]),void 0===t&&(t=0);var r=this.elements;return e[t]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3],e[t+4]=r[4],e[t+5]=r[5],e[t+6]=r[6],e[t+7]=r[7],e[t+8]=r[8],e[t+9]=r[9],e[t+10]=r[10],e[t+11]=r[11],e[t+12]=r[12],e[t+13]=r[13],e[t+14]=r[14],e[t+15]=r[15],e}}),ve.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"],ve.DefaultOrder="XYZ",Object.defineProperties(ve.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this.onChangeCallback()}},y:{get:function(){return this._y},set:function(e){this._y=e,this.onChangeCallback()}},z:{get:function(){return this._z},set:function(e){this._z=e,this.onChangeCallback()}},order:{get:function(){return this._order},set:function(e){this._order=e,this.onChangeCallback()}}}),Object.assign(ve.prototype,{copyFrom:function(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this.onChangeCallback(),this},set:function(e,t,r,n){return this._x=e||0,this._y=t||0,this._z=r||0,this._order=n||this._order,this.onChangeCallback(),this},setFromRotationMatrix:function(e,t,r){function n(e,t,r){return Math.max(t,Math.min(r,e))}var i=e.elements,a=i[0],s=i[4],o=i[8],h=i[1],c=i[5],u=i[9],l=i[2],d=i[6],p=i[10];return"XYZ"===(t=t||this._order)?(this._y=Math.asin(n(o,-1,1)),Math.abs(o)<.99999?(this._x=Math.atan2(-u,p),this._z=Math.atan2(-s,a)):(this._x=Math.atan2(d,c),this._z=0)):"YXZ"===t?(this._x=Math.asin(-n(u,-1,1)),Math.abs(u)<.99999?(this._y=Math.atan2(o,p),this._z=Math.atan2(h,c)):(this._y=Math.atan2(-l,a),this._z=0)):"ZXY"===t?(this._x=Math.asin(n(d,-1,1)),Math.abs(d)<.99999?(this._y=Math.atan2(-l,p),this._z=Math.atan2(-s,c)):(this._y=0,this._z=Math.atan2(h,a))):"ZYX"===t?(this._y=Math.asin(-n(l,-1,1)),Math.abs(l)<.99999?(this._x=Math.atan2(d,p),this._z=Math.atan2(h,a)):(this._x=0,this._z=Math.atan2(-s,c))):"YZX"===t?(this._z=Math.asin(n(h,-1,1)),Math.abs(h)<.99999?(this._x=Math.atan2(-u,c),this._y=Math.atan2(-l,a)):(this._x=0,this._y=Math.atan2(o,p))):"XZY"===t?(this._z=Math.asin(-n(s,-1,1)),Math.abs(s)<.99999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,a)):(this._x=Math.atan2(-u,p),this._y=0)):console.warn("given unsupported order: "+t),this._order=t,!1!==r&&this.onChangeCallback(),this},setFromQuaternion:(S=new me,function(e,t,r){return e.toMatrix4(S),this.setFromRotationMatrix(S,t,r)}),onChange:function(e){return this.onChangeCallback=e,this},onChangeCallback:function(){}}),Object.assign(ge.prototype,{set:function(e,t){return this.x=e||0,this.y=t||0,this},lerpVectors:function(e,t,r){return this.subVectors(t,e).multiplyScalar(r).add(e)},min:function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this},max:function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this},getLength:function(){return Math.sqrt(this.getLengthSquared())},getLengthSquared:function(){return this.x*this.x+this.y*this.y},normalize:function(e){e=e||1;var t=this.getLength();if(0!=t){var r=e/t;return this.x*=r,this.y*=r,this}},subtract:function(e,t){return(t=t||new ge).set(this.x-e.x,this.y-e.y),t},sub:function(e){return this.x-=e.x,this.y-=e.y,this},copy:function(e){return this.x=e.x,this.y=e.y,this},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this},multiplyScalar:function(e){return this.x*=e,this.y*=e,this},distanceToSquared:function(e){var t=this.x-e.x,r=this.y-e.y;return t*t+r*r},distanceTo:function(e){return Math.sqrt(this.distanceToSquared(e))},fromArray:function(e,t){return void 0===t&&(t=0),this.x=e[t],this.y=e[t+1],this},add:function(e){return this.x+=e.x,this.y+=e.y,this},angle:function(){var e=Math.atan2(this.y,this.x);return e<0&&(e+=2*Math.PI),e},clone:function(){return new ge(this.x,this.y)}}),Object.assign(Me.prototype,{lerpVectors:function(e,t,r){return this.subVectors(t,e).multiplyScalar(r).add(e)},set:function(e,t,r,n){return this.x=e||0,this.y=t||0,this.z=r||0,this.w=void 0!==n?n:1,this},normalize:function(){return this.multiplyScalar(1/(this.getLength()||1))},multiplyScalar:function(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this},getLengthSquared:function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},getLength:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},applyMatrix4:function(e){var t=this.x,r=this.y,n=this.z,i=this.w,a=e.elements;return this.x=a[0]*t+a[4]*r+a[8]*n+a[12]*i,this.y=a[1]*t+a[5]*r+a[9]*n+a[13]*i,this.z=a[2]*t+a[6]*r+a[10]*n+a[14]*i,this.w=a[3]*t+a[7]*r+a[11]*n+a[15]*i,this},equals:function(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w},add:function(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this},multiply:function(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this},multiplyScalar:function(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this},fromArray:function(e,t){return void 0===t&&(t=0),this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e},copy:function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=void 0!==e.w?e.w:1,this}}),Object.assign(Ee.prototype,{identity:function(){return this.set(1,0,0,0,1,0,0,0,1),this},inverse:function(){return this.getInverse(this)},getInverse:function(e){var t=e.elements,r=this.elements,n=t[0],i=t[1],a=t[2],s=t[3],o=t[4],h=t[5],c=t[6],u=t[7],l=t[8],d=l*o-h*u,p=h*c-l*s,f=u*s-o*c,_=n*d+i*p+a*f;if(0==_){return console.warn("zen3d.Matrix3: .getInverse() can't invert matrix, determinant is 0"),this.identity()}var m=1/_;return r[0]=d*m,r[1]=(a*u-l*i)*m,r[2]=(h*i-a*o)*m,r[3]=p*m,r[4]=(l*n-a*c)*m,r[5]=(a*s-h*n)*m,r[6]=f*m,r[7]=(i*c-u*n)*m,r[8]=(o*n-i*s)*m,this},transpose:function(){var e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this},set:function(e,t,r,n,i,a,s,o,h){var c=this.elements;return c[0]=e,c[3]=t,c[6]=r,c[1]=n,c[4]=i,c[7]=a,c[2]=s,c[5]=o,c[8]=h,this},copy:function(e){return this.elements.set(e.elements),this},multiply:function(e){return this.multiplyMatrices(this,e)},premultiply:function(e){return this.multiplyMatrices(e,this)},multiplyMatrices:function(e,t){var r=e.elements,n=t.elements,i=this.elements,a=r[0],s=r[3],o=r[6],h=r[1],c=r[4],u=r[7],l=r[2],d=r[5],p=r[8],f=n[0],_=n[3],m=n[6],v=n[1],g=n[4],M=n[7],E=n[2],S=n[5],x=n[8];return i[0]=a*f+s*v+o*E,i[3]=a*_+s*g+o*S,i[6]=a*m+s*M+o*x,i[1]=h*f+c*v+u*E,i[4]=h*_+c*g+u*S,i[7]=h*m+c*M+u*x,i[2]=l*f+d*v+p*E,i[5]=l*_+d*g+p*S,i[8]=l*m+d*M+p*x,this},transform:function(e,t,r,n,i,a,s){var o=this.elements,h=1,c=0;if(i%360){var u=i;h=Math.cos(u),c=Math.sin(u)}return o[0]=h*r,o[3]=-c*n,o[6]=e,o[1]=c*r,o[4]=h*n,o[7]=t,o[2]=0,o[5]=0,o[8]=1,(a||s)&&(o[6]-=a*o[0]+s*o[3],o[7]-=a*o[1]+s*o[4]),this},setUvTransform:function(e,t,r,n,i,a,s){var o=Math.cos(i),h=Math.sin(i);this.set(r*o,r*h,-r*(o*a+h*s)+a+e,-n*h,n*o,-n*(-h*a+o*s)+s+t,0,0,1)},setFromMatrix4:function(e){var t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}}),Object.defineProperties(Se.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this.onChangeCallback()}},y:{get:function(){return this._y},set:function(e){this._y=e,this.onChangeCallback()}},z:{get:function(){return this._z},set:function(e){this._z=e,this.onChangeCallback()}},w:{get:function(){return this._w},set:function(e){this._w=e,this.onChangeCallback()}}}),Object.assign(Se.prototype,{normalize:function(e){var t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this.onChangeCallback(),this},length:function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},lerpQuaternions:function(e,t,r){var n=e._w,i=e._x,a=e._y,s=e._z,o=t._w,h=t._x,c=t._y,u=t._z,l=n*o+i*h+a*c+s*u;l<0&&(l=-l,o=-o,h=-h,c=-c,u=-u),this._w=n+r*(o-n),this._x=i+r*(h-i),this._y=a+r*(c-a),this._z=s+r*(u-s);var d=1/Math.sqrt(this._w*this._w+this._x*this._x+this._y*this._y+this._z*this._z);return this._w*=d,this._x*=d,this._y*=d,this._z*=d,this.onChangeCallback(),this},slerpQuaternions:function(e,t,r){var n=e._w,i=e._x,a=e._y,s=e._z,o=t._w,h=t._x,c=t._y,u=t._z,l=n*o+i*h+a*c+s*u;if(l<0&&(l=-l,o=-o,h=-h,c=-c,u=-u),l<.95){var d=Math.acos(l),p=1/Math.sin(d),f=Math.sin(d*(1-r))*p,_=Math.sin(d*r)*p;this._w=n*f+o*_,this._x=i*f+h*_,this._y=a*f+c*_,this._z=s*f+u*_}else{this._w=n+r*(o-n),this._x=i+r*(h-i),this._y=a+r*(c-a),this._z=s+r*(u-s);var m=1/Math.sqrt(this._w*this._w+this._x*this._x+this._y*this._y+this._z*this._z);this._w*=m,this._x*=m,this._y*=m,this._z*=m}return this.onChangeCallback(),this},set:function(e,t,r,n){return this._x=e||0,this._y=t||0,this._z=r||0,this._w=void 0!==n?n:1,this.onChangeCallback(),this},copy:function(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=void 0!==e.w?e.w:1,this.onChangeCallback(),this},setFromEuler:function(e,t){var r=Math.cos(e._x/2),n=Math.cos(e._y/2),i=Math.cos(e._z/2),a=Math.sin(e._x/2),s=Math.sin(e._y/2),o=Math.sin(e._z/2),h=e._order;return"XYZ"===h?(this._x=a*n*i+r*s*o,this._y=r*s*i-a*n*o,this._z=r*n*o+a*s*i,this._w=r*n*i-a*s*o):"YXZ"===h?(this._x=a*n*i+r*s*o,this._y=r*s*i-a*n*o,this._z=r*n*o-a*s*i,this._w=r*n*i+a*s*o):"ZXY"===h?(this._x=a*n*i-r*s*o,this._y=r*s*i+a*n*o,this._z=r*n*o+a*s*i,this._w=r*n*i-a*s*o):"ZYX"===h?(this._x=a*n*i-r*s*o,this._y=r*s*i+a*n*o,this._z=r*n*o-a*s*i,this._w=r*n*i+a*s*o):"YZX"===h?(this._x=a*n*i+r*s*o,this._y=r*s*i+a*n*o,this._z=r*n*o-a*s*i,this._w=r*n*i-a*s*o):"XZY"===h&&(this._x=a*n*i-r*s*o,this._y=r*s*i-a*n*o,this._z=r*n*o+a*s*i,this._w=r*n*i+a*s*o),!1!==t&&this.onChangeCallback(),this},setFromRotationMatrix:function(e){var t,r=e.elements,n=r[0],i=r[4],a=r[8],s=r[1],o=r[5],h=r[9],c=r[2],u=r[6],l=r[10],d=n+o+l;return 0<d?(t=.5/Math.sqrt(d+1),this._w=.25/t,this._x=(u-h)*t,this._y=(a-c)*t,this._z=(s-i)*t):o<n&&l<n?(t=2*Math.sqrt(1+n-o-l),this._w=(u-h)/t,this._x=.25*t,this._y=(i+s)/t,this._z=(a+c)/t):l<o?(t=2*Math.sqrt(1+o-n-l),this._w=(a-c)/t,this._x=(i+s)/t,this._y=.25*t,this._z=(h+u)/t):(t=2*Math.sqrt(1+l-n-o),this._w=(s-i)/t,this._x=(a+c)/t,this._y=(h+u)/t,this._z=.25*t),this.onChangeCallback(),this},setFromUnitVectors:(y=new le,function(e,t){return void 0===y&&(y=new le),(x=e.dot(t)+1)<1e-6?(x=0,Math.abs(e.x)>Math.abs(e.z)?y.set(-e.y,e.x,0):y.set(0,-e.z,e.y)):y.crossVectors(e,t),this._x=y.x,this._y=y.y,this._z=y.z,this._w=x,this.normalize()}),multiply:function(e){return this.multiplyQuaternions(this,e)},premultiply:function(e){return this.multiplyQuaternions(e,this)},multiplyQuaternions:function(e,t){var r=e._x,n=e._y,i=e._z,a=e._w,s=t._x,o=t._y,h=t._z,c=t._w;return this._x=r*c+a*s+n*h-i*o,this._y=n*c+a*o+i*s-r*h,this._z=i*c+a*h+r*o-n*s,this._w=a*c-r*s-n*o-i*h,this.onChangeCallback(),this},toMatrix4:function(e){var t=(e=e||new me).elements,r=2*this._x*this._y,n=2*this._x*this._z,i=2*this._x*this._w,a=2*this._y*this._z,s=2*this._y*this._w,o=2*this._z*this._w,h=this._x*this._x,c=this._y*this._y,u=this._z*this._z,l=this._w*this._w;return t[0]=h-c-u+l,t[4]=r-o,t[8]=n+s,t[12]=0,t[1]=r+o,t[5]=c-h-u+l,t[9]=a-i,t[13]=0,t[2]=n-s,t[6]=a+i,t[10]=-h-c+u+l,t[14]=0,t[3]=0,t[7]=0,t[11]=0,t[15]=1,e},dot:function(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w},setFromAxisAngle:function(e,t){var r=t/2,n=Math.sin(r);return this._x=e.x*n,this._y=e.y*n,this._z=e.z*n,this._w=Math.cos(r),this.onChangeCallback(),this},fromArray:function(e,t){return void 0===t&&(t=0),this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this.onChangeCallback(),this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e},onChange:function(e){return this.onChangeCallback=e,this},onChangeCallback:function(){}}),Object.assign(Se,{slerpFlat:function(e,t,r,n,i,a,s){var o=r[n+0],h=r[n+1],c=r[n+2],u=r[n+3],l=i[a+0],d=i[a+1],p=i[a+2],f=i[a+3];if(u!==f||o!==l||h!==d||c!==p){var _=1-s,m=o*l+h*d+c*p+u*f,v=0<=m?1:-1,g=1-m*m;if(g>Number.EPSILON){var M=Math.sqrt(g),E=Math.atan2(M,m*v);_=Math.sin(_*E)/M,s=Math.sin(s*E)/M}var S=s*v;if(o=o*_+l*S,h=h*_+d*S,c=c*_+p*S,u=u*_+f*S,_===1-s){var x=1/Math.sqrt(o*o+h*h+c*c+u*u);o*=x,h*=x,c*=x,u*=x}}e[t]=o,e[t+1]=h,e[t+2]=c,e[t+3]=u}}),Object.assign(xe.prototype,{set:function(e,t,r,n){this.min.set(e,t),this.max.set(r,n)},copy:function(e){return this.min.copy(e.min),this.max.copy(e.max),this}}),Object.assign(ye.prototype,{set:function(e,t){this.min.copy(e),this.max.copy(t)},setFromPoints:function(e){this.makeEmpty();for(var t=0,r=e.length;t<r;t++)this.expandByPoint(e[t]);return 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},expandByPoint:function(e){return this.min.min(e),this.max.max(e),this},expandByScalar:function(e){return this.min.addScalar(-e),this.max.addScalar(e),this},expandByBox3:function(e){return this.min.min(e.min),this.max.max(e.max),this},setFromArray:function(e,t){for(var r=1/0,n=1/0,i=1/0,a=-1/0,s=-1/0,o=-1/0,h=void 0!==t?t:3,c=0,u=e.length;c<u;c+=h){var l=e[c],d=e[c+1],p=e[c+2];l<r&&(r=l),d<n&&(n=d),p<i&&(i=p),a<l&&(a=l),s<d&&(s=d),o<p&&(o=p)}return this.min.set(r,n,i),this.max.set(a,s,o),this},isEmpty:function(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z},equals:function(e){return e.min.equals(this.min)&&e.max.equals(this.max)},getCenter:function(e){var t=e||new le;return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)},applyMatrix4:(w=[new le,new le,new le,new le,new le,new le,new le,new le],function(e){return this.isEmpty()||(w[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),w[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),w[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),w[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),w[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),w[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),w[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),w[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(w)),this}),copy:function(e){return this.min.copy(e.min),this.max.copy(e.max),this}}),Object.assign(we.prototype,{set:function(e,t){return this.center.copy(e),this.radius=t,this},setFromArray:(T=new ye,b=new le,function(e,t){var r=void 0!==t?t:3,n=this.center;T.setFromArray(e,r).getCenter(n);for(var i=0,a=0,s=e.length;a<s;a+=r){var o=e[a],h=e[a+1],c=e[a+2];b.set(o,h,c),i=Math.max(i,n.distanceToSquared(b))}return this.radius=Math.sqrt(i),this}),applyMatrix4:function(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this},getBoundingBox:function(e){var t=e||new ye;return t.set(this.center,this.center),t.expandByScalar(this.radius),t},clone:function(){return(new we).copy(this)},copy:function(e){return this.center.copy(e.center),this.radius=e.radius,this}}),Object.assign(Te.prototype,{set:function(e,t){return this.normal.copy(e),this.constant=t,this},setComponents:function(e,t,r,n){return this.normal.set(e,t,r),this.constant=n,this},normalize:function(){var e=1/this.normal.getLength();return this.normal.multiplyScalar(e),this.constant*=e,this},distanceToPoint:function(e){return this.normal.dot(e)+this.constant},coplanarPoint:function(e){return(e||new le).copy(this.normal).multiplyScalar(-this.constant)},copy:function(e){return this.normal.copy(e.normal),this.constant=e.constant,this},applyMatrix4:(A=new le,N=new Ee,function(e,t){var r=t||N.setFromMatrix4(e).inverse().transpose(),n=this.coplanarPoint(A).applyMatrix4(e),i=this.normal.applyMatrix3(r).normalize();return this.constant=-n.dot(i),this})}),Object.assign(be.prototype,{set:function(e,t,r,n,i,a){var s=this.planes;return s[0].copy(e),s[1].copy(t),s[2].copy(r),s[3].copy(n),s[4].copy(i),s[5].copy(a),this},setFromMatrix:function(e){var t=this.planes,r=e.elements,n=r[0],i=r[1],a=r[2],s=r[3],o=r[4],h=r[5],c=r[6],u=r[7],l=r[8],d=r[9],p=r[10],f=r[11],_=r[12],m=r[13],v=r[14],g=r[15];return t[0].setComponents(s-n,u-o,f-l,g-_).normalize(),t[1].setComponents(s+n,u+o,f+l,g+_).normalize(),t[2].setComponents(s+i,u+h,f+d,g+m).normalize(),t[3].setComponents(s-i,u-h,f-d,g-m).normalize(),t[4].setComponents(s-a,u-c,f-p,g-v).normalize(),t[5].setComponents(s+a,u+c,f+p,g+v).normalize(),this},intersectsSphere:function(e){for(var t=this.planes,r=e.center,n=-e.radius,i=0;i<6;i++){if(t[i].distanceToPoint(r)<n)return!1}return!0},intersectsBox:(P=new le,L=new le,function(e){for(var t=this.planes,r=0;r<6;r++){var n=t[r];P.x=0<n.normal.x?e.min.x:e.max.x,L.x=0<n.normal.x?e.max.x:e.min.x,P.y=0<n.normal.y?e.min.y:e.max.y,L.y=0<n.normal.y?e.max.y:e.min.y,P.z=0<n.normal.z?e.min.z:e.max.z,L.z=0<n.normal.z?e.max.z:e.min.z;var i=n.distanceToPoint(P),a=n.distanceToPoint(L);if(i<0&&a<0)return!1}return!0}),clone:function(){return(new this.constructor).copy(this)},copy:function(e){for(var t=this.planes,r=0;r<6;r++)t[r].copy(e.planes[r]);return this}}),Object.assign(Ae.prototype,{lerpColors:function(e,t,r){this.r=r*(t.r-e.r)+e.r,this.g=r*(t.g-e.g)+e.g,this.b=r*(t.b-e.b)+e.b},lerp:function(e,t){this.lerpColors(this,e,t)},copy:function(e){return this.r=e.r,this.g=e.g,this.b=e.b,this},setHex:function(e){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,this},setRGB:function(e,t,r){return this.r=e,this.g=t,this.b=r,this},setHSL:function(e,t,r){var n;if(e=(e%(n=1)+n)%n,t=Math.max(0,Math.min(1,t)),r=Math.max(0,Math.min(1,r)),0===t)this.r=this.g=this.b=r;else{var i=r<=.5?r*(1+t):r+t-r*t,a=2*r-i;this.r=Ne(a,i,e+1/3),this.g=Ne(a,i,e),this.b=Ne(a,i,e-1/3)}return this},fromArray:function(e,t){return void 0===t&&(t=0),this.r=e[t],this.g=e[t+1],this.b=e[t+2],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}}),Object.assign(Pe.prototype,{set:function(e,t,r){return this.a.copy(e),this.b.copy(t),this.c.copy(r),this}}),Pe.normal=(R=new le,function(e,t,r,n){var i=n||new le;i.subVectors(r,t),R.subVectors(e,t),i.cross(R);var a=i.getLengthSquared();return 0<a?i.multiplyScalar(1/Math.sqrt(a)):i.set(0,0,0)}),Pe.barycoordFromPoint=(C=new le,O=new le,F=new le,function(e,t,r,n,i){C.subVectors(n,t),O.subVectors(r,t),F.subVectors(e,t);var a=C.dot(C),s=C.dot(O),o=C.dot(F),h=O.dot(O),c=O.dot(F),u=a*h-s*s,l=i||new le;if(0==u)return l.set(-2,-1,-1);var d=1/u,p=(h*o-s*c)*d,f=(a*c-s*o)*d;return l.set(1-p-f,f,p)}),Pe.containsPoint=(U=new le,function(e,t,r,n){var i=Pe.barycoordFromPoint(e,t,r,n,U);return 0<=i.x&&0<=i.y&&i.x+i.y<=1}),Object.assign(Le.prototype,{set:function(e,t){this.posPoints=e,this.ctrlPoints=t,e.length!==t.length&&console.warn("Curve: posPoints and ctrlPoints's length not equal!"),this.segCount=e.length-1},calc:(I=new ge,D=new ge,B=new ge,z=new ge,function(e){for(var t=0;t<this.segCount;t++)if(e>=this.posPoints[t].x&&e<=this.posPoints[t+1].x){I.copy(this.posPoints[t]),B.copy(this.posPoints[t+1]),D.copy(this.ctrlPoints[t]),z.copy(this.ctrlPoints[t+1]);break}return I||I.copy(this.posPoints[this.posPoints.length-1]),D||D.copy(this.ctrlPoints[this.ctrlPoints.length-1]),B.copy(B||I),z.copy(z||D),e=(e-I.x)/(B.x-I.x),this._cubic_bezier(I.y,D.y,z.y,B.y,e)}),averageXSampler:function(e){e<2&&console.warn("Curve: sampler num less than 2!");for(var t=[],r=this.posPoints[0].x,n=this.posPoints[this.posPoints.length-1].x,i=(n-r)/(e-1),a=0,s=0;s<e;s++)a=s===e-1?n:r+s*i,t.push(a,this.calc(a));return t},_cubic_bezier:function(e,t,r,n,i){return e=this._mix(e,t,i),t=this._mix(t,r,i),r=this._mix(r,n,i),e=this._mix(e,t,i),t=this._mix(t,r,i),e=this._mix(e,t,i)},_mix:function(e,t,r){return e*(1-r)+t*r}}),Object.assign(Re.prototype,{set:function(e,t,r){return this.radius=e,this.phi=t,this.theta=r,this},copy:function(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this},clone:function(){return(new this.constructor).copy(this)},makeSafe:function(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this},setFromVector3:function(e){return this.radius=e.getLength(),0===this.radius?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e.x,e.z),this.phi=Math.acos(Math.min(1,Math.max(-1,e.y/this.radius)))),this}}),Ce.prototype=Object.assign(Object.create(ue.prototype),{constructor:Ce,isTexture:!0,clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.textureType=e.textureType,this.border=e.border,this.format=e.format,this.type=e.type,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.anisotropy=e.anisotropy,this.generateMipmaps=e.generateMipmaps,this.encoding=e.encoding,this.flipY=e.flipY,this.version=e.version,this},dispose:function(){this.dispatchEvent({type:"dispose"}),this.version=0}});var Fe=new Oe;function Ue(e){this.crossOrigin=void 0,this.path=void 0,this.manager=void 0!==e?e:Fe}function Ie(e){this.path=void 0,this.responseType=void 0,this.withCredentials=void 0,this.mimeType=void 0,this.requestHeader=void 0,this.manager=void 0!==e?e:Fe}function De(e){this.manager=void 0!==e?e:Fe}function Be(e){this.manager=void 0!==e?e:Fe,this.type=zen3d.WEBGL_PIXEL_TYPE.UNSIGNED_BYTE}function ze(){Ce.call(this),this.textureType=K.TEXTURE_2D,this.image=null,this.offset=new ge,this.repeat=new ge(1,1),this.center=new ge,this.rotation=0,this.matrix=new Ee,this.matrixAutoUpdate=!0,this.useUVTransform=!0}function Ge(){Ce.call(this),this.textureType=K.TEXTURE_CUBE_MAP,this.images=[],this.flipY=!1}function He(){Ce.call(this),this.textureType=K.TEXTURE_3D,this.image={data:new Uint8Array(255,255,255,255,255,255,255,255),width:2,height:2,depth:2},this.format=Q.RED,this.internalformat=Q.R8,this.type=$.UNSIGNED_BYTE,this.flipY=!1}Object.assign(Ue.prototype,{load:function(t,e,r,n){void 0===t&&(t=""),void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);var i=this,a=document.createElementNS("http://www.w3.org/1999/xhtml","img");function s(){a.removeEventListener("load",s,!1),a.removeEventListener("error",o,!1),e&&e(this),i.manager.itemEnd(t)}function o(e){a.removeEventListener("load",s,!1),a.removeEventListener("error",o,!1),n&&n(e),i.manager.itemError(t),i.manager.itemEnd(t)}return a.addEventListener("load",s,!1),a.addEventListener("error",o,!1),"data:"!==t.substr(0,5)&&void 0!==this.crossOrigin&&(a.crossOrigin=this.crossOrigin),i.manager.itemStart(t),a.src=t,a},setCrossOrigin:function(e){return this.crossOrigin=e,this},setPath:function(e){return this.path=e,this}}),Object.assign(Ie.prototype,{load:function(r,n,t,i){void 0===r&&(r=""),null!=this.path&&(r=this.path+r),r=this.manager.resolveURL(r);var e,a=this,s=r.match(/^data:(.*?)(;base64)?,(.*)$/);if(s){var o=s[1],h=!!s[2],c=s[3];c=decodeURIComponent(c),h&&(c=atob(c));try{var u,l=(this.responseType||"").toLowerCase();switch(l){case"arraybuffer":case"blob":u=new ArrayBuffer(c.length);for(var d=new Uint8Array(u),p=0;p<c.length;p++)d[p]=c.charCodeAt(p);"blob"===l&&(u=new Blob([u],{type:o}));break;case"document":var f=new DOMParser;u=f.parseFromString(c,o);break;case"json":u=JSON.parse(c);break;default:u=c}setTimeout(function(){n&&n(u),a.manager.itemEnd(r)},0)}catch(e){setTimeout(function(){i&&i(e),a.manager.itemError(r),a.manager.itemEnd(r)},0)}}else{for(var _ in(e=new XMLHttpRequest).open("GET",r,!0),e.addEventListener("load",function(e){var t=this.response;200===this.status?n&&n(t):0===this.status?(console.warn("zen3d.FileLoader: HTTP Status 0 received."),n&&n(t)):(i&&i(e),a.manager.itemError(r)),a.manager.itemEnd(r)},!1),void 0!==t&&e.addEventListener("progress",function(e){t(e)},!1),void 0!==i&&e.addEventListener("error",function(e){i(e),a.manager.itemError(r),a.manager.itemEnd(r)},!1),void 0!==this.responseType&&(e.responseType=this.responseType),void 0!==this.withCredentials&&(e.withCredentials=this.withCredentials),e.overrideMimeType&&e.overrideMimeType(void 0!==this.mimeType?this.mimeType:"text/plain"),this.requestHeader)e.setRequestHeader(_,this.requestHeader[_]);e.send(null)}return a.manager.itemStart(r),e},setPath:function(e){return this.path=e,this},setResponseType:function(e){return this.responseType=e,this},setWithCredentials:function(e){return this.withCredentials=e,this},setMimeType:function(e){return this.mimeType=e,this},setRequestHeader:function(e){return this.requestHeader=e,this}}),Object.assign(De.prototype,{load:function(e,t,r,n){var i=this,a=new Ie(this.manager);a.setResponseType("arraybuffer"),a.load(e,function(e){void 0!==t&&t(i.parse(e))},r,n)},parse:function(e){e.length<19&&console.error("TGALoader.parse: Not enough data to contain header.");var t=new Uint8Array(e),r=0,_={id_length:t[r++],colormap_type:t[r++],image_type:t[r++],colormap_index:t[r++]|t[r++]<<8,colormap_length:t[r++]|t[r++]<<8,colormap_size:t[r++],origin:[t[r++]|t[r++]<<8,t[r++]|t[r++]<<8],width:t[r++]|t[r++]<<8,height:t[r++]|t[r++]<<8,pixel_size:t[r++],flags:t[r++]};!function(e){switch(e.image_type){case 1:case 9:(256<e.colormap_length||24!==e.colormap_size||1!==e.colormap_type)&&console.error("TGALoader.parse.tgaCheckHeader: Invalid type colormap data for indexed type");break;case 2:case 3:case 10:case 11:e.colormap_type&&console.error("TGALoader.parse.tgaCheckHeader: Invalid type colormap data for colormap type");break;case 0:console.error("TGALoader.parse.tgaCheckHeader: No data");default:console.error('TGALoader.parse.tgaCheckHeader: Invalid type " '+e.image_type+'"')}(e.width<=0||e.height<=0)&&console.error("TGALoader.parse.tgaCheckHeader: Invalid image size"),8!==e.pixel_size&&16!==e.pixel_size&&24!==e.pixel_size&&32!==e.pixel_size&&console.error('TGALoader.parse.tgaCheckHeader: Invalid pixel size "'+e.pixel_size+'"')}(_),_.id_length+r>e.length&&console.error("TGALoader.parse: No data"),r+=_.id_length;var n=!1,i=!1,l=!1;switch(_.image_type){case 9:i=n=!0;break;case 1:i=!0;break;case 10:n=!0;break;case 2:break;case 11:l=n=!0;break;case 3:l=!0}var a=document.createElement("canvas");a.width=_.width,a.height=_.height;var s=a.getContext("2d"),o=s.createImageData(_.width,_.height),h=function(e,t,r,n,i){var a,s,o,h;if(s=r.pixel_size>>3,o=r.width*r.height*s,t&&(h=i.subarray(n,n+=r.colormap_length*(r.colormap_size>>3))),e){var c,u,l;a=new Uint8Array(o);for(var d=0,p=new Uint8Array(s);d<o;)if(u=1+(127&(c=i[n++])),128&c){for(l=0;l<s;++l)p[l]=i[n++];for(l=0;l<u;++l)a.set(p,d+l*s);d+=s*u}else{for(u*=s,l=0;l<u;++l)a[d+l]=i[n++];d+=u}}else a=i.subarray(n,n+=t?r.width*r.height:o);return{pixel_data:a,palettes:h}}(n,i,_,r,t);return function(e,t,r,n,i){var a,s,o,h,c,u;switch((48&_.flags)>>4){default:case 2:c=t,s=a=0,h=o=1,u=r;break;case 0:a=0,c=t,s=r-(o=1),u=h=-1;break;case 3:a=t-1,c=o=-1,s=0,h=1,u=r;break;case 1:a=t-1,s=r-1,u=h=c=o=-1}if(l)switch(_.pixel_size){case 8:!function(e,t,r,n,i,a,s,o){var h,c,u,l=0,d=_.width;for(u=t;u!==n;u+=r)for(c=i;c!==s;c+=a,l++)h=o[l],e[4*(c+d*u)+0]=h,e[4*(c+d*u)+1]=h,e[4*(c+d*u)+2]=h,e[4*(c+d*u)+3]=255}(e,s,h,u,a,o,c,n);break;case 16:!function(e,t,r,n,i,a,s,o){var h,c,u=0,l=_.width;for(c=t;c!==n;c+=r)for(h=i;h!==s;h+=a,u+=2)e[4*(h+l*c)+0]=o[u+0],e[4*(h+l*c)+1]=o[u+0],e[4*(h+l*c)+2]=o[u+0],e[4*(h+l*c)+3]=o[u+1]}(e,s,h,u,a,o,c,n);break;default:console.error("TGALoader.parse.getTgaRGBA: not support this format")}else switch(_.pixel_size){case 8:!function(e,t,r,n,i,a,s,o,h){var c,u,l,d=h,p=0,f=_.width;for(l=t;l!==n;l+=r)for(u=i;u!==s;u+=a,p++)c=o[p],e[4*(u+f*l)+3]=255,e[4*(u+f*l)+2]=d[3*c+0],e[4*(u+f*l)+1]=d[3*c+1],e[4*(u+f*l)+0]=d[3*c+2]}(e,s,h,u,a,o,c,n,i);break;case 16:!function(e,t,r,n,i,a,s,o){var h,c,u,l=0,d=_.width;for(u=t;u!==n;u+=r)for(c=i;c!==s;c+=a,l+=2)h=o[l+0]+(o[l+1]<<8),e[4*(c+d*u)+0]=(31744&h)>>7,e[4*(c+d*u)+1]=(992&h)>>2,e[4*(c+d*u)+2]=(31&h)>>3,e[4*(c+d*u)+3]=32768&h?0:255}(e,s,h,u,a,o,c,n);break;case 24:!function(e,t,r,n,i,a,s,o){var h,c,u=0,l=_.width;for(c=t;c!==n;c+=r)for(h=i;h!==s;h+=a,u+=3)e[4*(h+l*c)+3]=255,e[4*(h+l*c)+2]=o[u+0],e[4*(h+l*c)+1]=o[u+1],e[4*(h+l*c)+0]=o[u+2]}(e,s,h,u,a,o,c,n);break;case 32:!function(e,t,r,n,i,a,s,o){var h,c,u=0,l=_.width;for(c=t;c!==n;c+=r)for(h=i;h!==s;h+=a,u+=4)e[4*(h+l*c)+2]=o[u+0],e[4*(h+l*c)+1]=o[u+1],e[4*(h+l*c)+0]=o[u+2],e[4*(h+l*c)+3]=o[u+3]}(e,s,h,u,a,o,c,n);break;default:console.error("TGALoader.parse.getTgaRGBA: not support this format")}}(o.data,_.width,_.height,h.pixel_data,h.palettes),s.putImageData(o,0,0),a}}),Object.assign(Be.prototype,{load:function(e,t,r,n){var i=this,a=new Ie(this.manager);a.setResponseType("arraybuffer"),a.load(e,function(e){void 0!==t&&t(i.parse(e))},r,n)},parse:function(e){function g(e,t){switch(e){case 1:console.error("zen3d.RGBELoader Read Error: "+(t||""));break;case 2:console.error("zen3d.RGBELoader Write Error: "+(t||""));break;case 3:console.error("zen3d.RGBELoader Bad File Format: "+(t||""));break;default:console.error("zen3d.RGBELoader: Error: "+(t||""))}return-1}function h(e,t,r){t=t||1024;for(var n=e.pos,i=-1,a=0,s="",o=String.fromCharCode.apply(null,new Uint16Array(e.subarray(n,n+128)));(i=o.indexOf("\n"))<0&&a<t&&n<e.byteLength;)s+=o,a+=o.length,n+=128,o+=String.fromCharCode.apply(null,new Uint16Array(e.subarray(n,n+128)));return-1<i&&(!1!==r&&(e.pos+=a+i+1),s+o.slice(0,i))}var t=new Uint8Array(e);t.pos=0;var r,n,i,a,s,o,c=function(e){var t,r,n=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,i=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,a=/^\s*FORMAT=(\S+)\s*$/,s=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,o={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};if(e.pos>=e.byteLength||!(t=h(e)))return g(1,"no header found");if(!(r=t.match(/^#\?(\S+)$/)))return g(3,"bad initial token");for(o.valid|=1,o.programtype=r[1],o.string+=t+"\n";!1!==(t=h(e));)if(o.string+=t+"\n","#"!==t.charAt(0)){if((r=t.match(n))&&(o.gamma=parseFloat(r[1],10)),(r=t.match(i))&&(o.exposure=parseFloat(r[1],10)),(r=t.match(a))&&(o.valid|=2,o.format=r[1]),(r=t.match(s))&&(o.valid|=4,o.height=parseInt(r[1],10),o.width=parseInt(r[2],10)),2&o.valid&&4&o.valid)break}else o.comments+=t+"\n";return 2&o.valid?4&o.valid?o:g(3,"missing image size specifier"):g(3,"missing format specifier")}(t);if(-1!==c){var u=c.width,l=c.height,d=function(e,t,r){var n,i,a,s,o,h,c,u,l,d,p,f,_,m=t,v=r;if(m<8||32767<m||2!==e[0]||2!==e[1]||128&e[2])return new Uint8Array(e);if(m!==(e[2]<<8|e[3]))return g(3,"wrong scanline width");if(!(n=new Uint8Array(4*t*r))||!n.length)return g(4,"unable to allocate buffer space");for(a=i=0,u=4*m,_=new Uint8Array(4),h=new Uint8Array(u);0<v&&a<e.byteLength;){if(a+4>e.byteLength)return g(1);if(_[0]=e[a++],_[1]=e[a++],_[2]=e[a++],_[3]=e[a++],2!=_[0]||2!=_[1]||(_[2]<<8|_[3])!=m)return g(3,"bad rgbe scanline format");for(c=0;c<u&&a<e.byteLength;){if((f=128<(s=e[a++]))&&(s-=128),0===s||u<c+s)return g(3,"bad scanline data");if(f)for(o=e[a++],l=0;l<s;l++)h[c++]=o;else h.set(e.subarray(a,a+s),c),c+=s,a+=s}for(d=m,l=0;l<d;l++)p=0,n[i]=h[l+p],p+=m,n[i+1]=h[l+p],p+=m,n[i+2]=h[l+p],p+=m,n[i+3]=h[l+p],i+=4;v--}return n}(t.subarray(t.pos),u,l);if(-1!==d){if(this.type===$.UNSIGNED_BYTE)var p=d,f=Q.RGBA,_=$.UNSIGNED_BYTE;else if(this.type===$.FLOAT){for(var m=d.length/4*3,v=new Float32Array(m),M=0;M<m;M++)i=v,a=3*M,0,s=(r=d)[(n=4*M)+3],o=Math.pow(2,s-128)/255,i[a+0]=r[n+0]*o,i[a+1]=r[n+1]*o,i[a+2]=r[n+2]*o;p=v,f=Q.RGB,_=$.FLOAT}else console.error("zen3d.RGBELoader: unsupported type: ",this.type);return{width:u,height:l,data:p,header:c.string,gamma:c.gamma,exposure:c.exposure,format:f,type:_}}}return null}}),ze.prototype=Object.assign(Object.create(Ce.prototype),{constructor:ze,copy:function(e){return Ce.prototype.copy.call(this,e),this.image=e.image,this.mipmaps=e.mipmaps.slice(0),this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this},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)}}),ze.fromImage=function(e){var t=new ze;return t.image=e,t.version++,t},ze.fromSrc=function(e){var t=new ze,r=0<e.search(/\.(jpg|jpeg)$/)||0===e.search(/^data\:image\/jpeg/),n=0<e.search(/\.(tga)$/)||0===e.search(/^data\:image\/tga/);0<e.search(/\.(hdr)$/)?(new Be).load(e,function(e){t.image={data:e.data,width:e.width,height:e.height},t.encoding=zen3d.TEXEL_ENCODING_TYPE.RGBE,t.type=e.type,t.format=e.format,t.version++,t.dispatchEvent({type:"onload"})}):(new(n?De:Ue)).load(e,function(e){t.format=r?Q.RGB:Q.RGBA,t.image=e,t.version++,t.dispatchEvent({type:"onload"})});return t},Ge.prototype=Object.assign(Object.create(Ce.prototype),{constructor:Ge,copy:function(e){return Ce.prototype.copy.call(this,e),this.images=e.images.slice(0),this}}),Ge.fromImage=function(e){for(var t=new Ge,r=t.images,n=0;n<6;n++)r[n]=e[n];return t.version++,t},Ge.fromSrc=function(r){var n,i=new Ge,a=i.images,e=r[0],s=0<e.search(/\.(jpg|jpeg)$/)||0===e.search(/^data\:image\/jpeg/),t=0<e.search(/\.(tga)$/)||0===e.search(/^data\:image\/tga/),o=0<e.search(/\.(hdr)$/);n=new(o?Be:t?De:Ue);var h=0;return function e(t){t&&(o?a.push({data:t.data,width:t.width,height:t.height}):a.push(t),h++),6<=h?function(e){e?(i.encoding=ae.RGBE,i.type=e.type,i.format=e.format):i.format=s?Q.RGB:Q.RGBA,i.version++,i.dispatchEvent({type:"onload"})}(o?t:void 0):n.load(r[h],e)}(),i},He.prototype=Object.assign(Object.create(Ce.prototype),{constructor:He});var ke,Ve,je,Xe,We,Ye=0;function qe(){Object.defineProperty(this,"id",{value:Ye++}),this.uuid=a(),this.name="",this.type="",this.position=new le,this.scale=new le(1,1,1),this.euler=new ve,this.quaternion=new Se;var e=this.euler,t=this.quaternion;e.onChange(function(){t.setFromEuler(e,!1)}),t.onChange(function(){e.setFromQuaternion(t,void 0,!1)}),this.matrix=new me,this.worldMatrix=new me,this.children=new Array,this.parent=null,this.castShadow=!1,this.receiveShadow=!1,this.shadowType=ie.PCF3_SOFT,this.frustumCulled=!0,this.visible=!0,this.renderOrder=0,this.userData={}}function Ze(){qe.call(this),this.type="bone",this.offsetMatrix=new me}function Ke(e){e=e||[],this.bones=e.slice(0),this.boneMatrices=new Float32Array(16*this.bones.length),this.boneTexture=void 0}function Qe(e,t,r,n,i){if(.5<=n)for(var a=0;a!==i;++a)e[t+a]=e[r+a]}function $e(e,t,r,n){Se.slerpFlat(e,t,e,t,e,r,n)}function Je(e,t,r,n,i){for(var a=1-n,s=0;s!==i;++s){var o=t+s;e[o]=e[o]*a+e[r+s]*n}}function et(e,t,r,n){this.target=null,this.property="",this.parseBinding(e,t),this.valueSize=n;var i,a=Float64Array;switch(r){case"quaternion":i=$e;break;case"string":case"bool":a=Array,i=Qe;break;default:i=Je}this.buffer=new a(3*n),this._mixBufferFunction=i,this.cumulativeWeight=0,this.referenceCount=0,this.useCount=0}function tt(){this._clips={},this._bindings={},this._activeClips={}}function rt(e,t,r,n,i){this.target=e,this.propertyPath=t,this.name=this.target.uuid+"."+t,this.times=r,this.values=n,this.valueSize=n.length/r.length,this.interpolant=void 0===i||i}function nt(e,t,r,n,i){rt.call(this,e,t,r,n,i)}function it(e,t,r,n,i){rt.call(this,e,t,r,n,i)}function at(e){this.name=e||"",this.tracks=[],this.loop=!0,this.startFrame=0,this.endFrame=0,this.frame=0}function st(e,t,r,n,i){rt.call(this,e,t,r,n,i)}function ot(e,t,r,n,i){rt.call(this,e,t,r,n,i)}function ht(e,t,r,n,i){rt.call(this,e,t,r,n,i)}function ct(e,t,r,n,i){rt.call(this,e,t,r,n,i)}function ut(e,t,r){this.array=e,this.size=t,this.count=void 0!==e?e.length/t:0,this.normalized=!0===r,this.dynamic=!1,this.updateRange={offset:0,count:-1},this.version=0}Object.assign(qe.prototype,{onBeforeRender:function(){},onAfterRender:function(){},add:function(e){this.children.push(e),e.parent=this},remove:function(e){var t=this.children.indexOf(e);-1!==t&&this.children.splice(t,1),e.parent=null},getObjectByName:function(e){return this.getObjectByProperty("name",e)},getObjectByProperty:function(e,t){if(this[e]===t)return this;for(var r=0,n=this.children.length;r<n;r++){var i=this.children[r].getObjectByProperty(e,t);if(void 0!==i)return i}},updateMatrix:function(){var e=this.matrix.transform(this.position,this.scale,this.quaternion);if(this.worldMatrix.copy(e),this.parent){var t=this.parent.worldMatrix;this.worldMatrix.premultiply(t)}for(var r=this.children,n=0,i=r.length;n<i;n++)r[n].updateMatrix()},getWorldDirection:(Ve=new le,je=new Se,Xe=new le,function(e){var t=e||new le;return this.worldMatrix.decompose(Ve,je,Xe),t.set(0,0,1).applyQuaternion(je),t}),lookAt:(ke=new me,function(e,t){ke.lookAtRH(e,this.position,t),this.quaternion.setFromRotationMatrix(ke)}),raycast:function(e,t){},traverse:function(e){e(this);for(var t=this.children,r=0,n=t.length;r<n;r++)t[r].traverse(e)},clone:function(e){return(new this.constructor).copy(this,e)},copy:function(e,t){if(void 0===t&&(t=!0),this.name=e.name,this.type=e.type,this.position.copy(e.position),this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.worldMatrix.copy(e.worldMatrix),this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.userData=JSON.parse(JSON.stringify(e.userData)),!0===t)for(var r=0;r<e.children.length;r++){var n=e.children[r];this.add(n.clone())}return this}}),(Ze.prototype=Object.create(qe.prototype)).constructor=Ze,Object.assign(Ke.prototype,{pose:function(){for(var e=0;e<this.bones.length;e++){(t=this.bones[e]).worldMatrix.getInverse(t.offsetMatrix)}for(e=0;e<this.bones.length;e++){var t;(t=this.bones[e]).parent&&"bone"==t.parent.type?(t.matrix.getInverse(t.parent.worldMatrix),t.matrix.multiply(t.worldMatrix)):t.matrix.copy(t.worldMatrix),t.matrix.decompose(t.position,t.quaternion,t.scale)}},updateBones:(We=new me,function(){for(var e=0;e<this.bones.length;e++){var t=this.bones[e];We.multiplyMatrices(t.worldMatrix,t.offsetMatrix),We.toArray(this.boneMatrices,16*e)}void 0!==this.boneTexture&&this.boneTexture.version++}),getBoneByName:function(e){for(var t=0,r=this.bones.length;t<r;t++){var n=this.bones[t];if(n.name===e)return n}}}),Object.assign(et.prototype,{parseBinding:function(e,t){if(1<(t=t.split(".")).length){for(var r=e[t[0]],n=1;n<t.length-1;n++)r=r[t[n]];this.property=t[t.length-1],this.target=r}else this.property=t[0],this.target=e},saveOriginalState:function(){var e=this.buffer,t=this.valueSize,r=2*t;1<this.valueSize?this.target[this.property].toArray?this.target[this.property].toArray(e,r):function(e,t,r,n){for(var i=0;i<n;i++)e[r+i]=t[i]}(e,this.target[this.property],r,this.valueSize):this.target[this.property]=e[r];for(var n=t,i=r;n!==i;++n)e[n]=e[r+n%t];this.cumulativeWeight=0},restoreOriginalState:function(){for(var e=this.buffer,t=this.valueSize,r=2*t,n=t,i=r;n!==i;++n)e[n]=e[r+n%t];this.apply()},accumulate:function(e){var t=this.buffer,r=this.valueSize,n=r,i=this.cumulativeWeight;if(0===i){for(var a=0;a!==r;++a)t[n+a]=t[a];i=e}else{var s=e/(i+=e);this._mixBufferFunction(t,n,0,s,r)}this.cumulativeWeight=i},apply:function(){var e=this.buffer,t=this.valueSize,r=this.cumulativeWeight;if(this.cumulativeWeight=0,r<1){var n=2*t;this._mixBufferFunction(e,t,n,1-r,t)}1<this.valueSize?this.target[this.property].fromArray?this.target[this.property].fromArray(e,t):function(e,t,r,n){for(var i=0;i<n;i++)e[i]=t[r+i]}(this.target[this.property],e,t,this.valueSize):this.target[this.property]=e[t]}}),Object.assign(tt.prototype,{add:function(e){if(void 0===this._clips[e.name]){for(var t=e.tracks,r=0;r<t.length;r++){var n,i=t[r],a=i.name;this._bindings[a]?n=this._bindings[a]:(n=new et(i.target,i.propertyPath,i.valueTypeName,i.valueSize),this._bindings[a]=n),n.referenceCount++}this._clips[e.name]=e}else console.warn("AnimationMixer.add: already has clip: "+e.name)},remove:function(e){if(this._clips[e.name]){for(var t=e.tracks,r=0;r<t.length;r++){var n=t[r].name,i=this._bindings[n];i&&i.referenceCount--,i.referenceCount<=0&&delete this._bindings[n]}delete this._clips[e.name]}else console.warn("AnimationMixer.remove: has no clip: "+e.name)},play:function(e,t){if(void 0===this._activeClips[e]){this._activeClips[e]=void 0===t?1:t;var r=this._clips[e];if(r){r.frame=0;for(var n=r.tracks,i=0;i<n.length;i++){var a=n[i].name,s=this._bindings[a];s&&0==s.useCount++&&s.saveOriginalState()}}else console.warn("AnimationMixer.stop: clip "+e+" is not found.")}else console.warn("AnimationMixer.play: clip "+e+" is playing.")},stop:function(e){if(void 0!==this._activeClips[e]){delete this._activeClips[e];var t=this._clips[e];if(t)for(var r=t.tracks,n=0;n<r.length;n++){var i=r[n].name,a=this._bindings[i];a&&0<a.useCount&&0==--a.useCount&&a.restoreOriginalState()}else console.warn("AnimationMixer.stop: clip "+e+" is not found.")}else console.warn("AnimationMixer.stop: clip "+e+" is not playing.")},update:function(e){for(var t in this._activeClips){var r=this._clips[t],n=this._activeClips[t];r.update(e,this._bindings,n)}for(var i in this._bindings)0<this._bindings[i].useCount&&this._bindings[i].apply()},setClipWeight:function(e,t){void 0!==this._activeClips[e]?this._activeClips[e]=t:console.warn("AnimationMixer.stop: clip "+e+" is not playing.")},getAllClipNames:function(){var e=[];for(var t in this._clips)e.push(t);return e}}),Object.assign(rt.prototype,{_getLastTimeIndex:function(e){var t,r=0,n=this.times.length;for(t=0;t<n;t++)e>=this.times[t]&&(r=t);return r},getValue:function(e,t){for(var r,n,i=this._getLastTimeIndex(e),a=this.times,s=this.values,o=this.valueSize,h=a[i],c=a[i+1],u=0;u<o;u++)if(r=s[i*o+u],n=s[(i+1)*o+u],this.interpolant)if(void 0!==r&&void 0!==n){var l=(e-h)/(c-h);t[u]=r*(1-l)+n*l}else t[u]=r;else t[u]=r}}),nt.prototype=Object.assign(Object.create(rt.prototype),{constructor:nt,valueTypeName:"bool",getValue:function(e,t){var r=this._getLastTimeIndex(e),n=this.times[r];t[0]=this.values[n]}}),it.prototype=Object.assign(Object.create(rt.prototype),{constructor:it,valueTypeName:"color"}),Object.assign(at.prototype,{update:function(e,t,r){this.frame+=e,this.frame>this.endFrame&&(this.loop?this.frame=this.startFrame:this.frame=this.endFrame);for(var n=0,i=this.tracks.length;n<i;n++){var a=this.tracks[n],s=t[a.name];a.getValue(this.frame,s.buffer),s.accumulate(r)}}}),st.prototype=Object.assign(Object.create(rt.prototype),{constructor:st,valueTypeName:"number"}),ot.prototype=Object.assign(Object.create(rt.prototype),{constructor:ot,valueTypeName:"quaternion",getValue:function(e,t){var r=this._getLastTimeIndex(e),n=this.times,i=this.values,a=n[r],s=n[r+1],o=0;if(this.interpolant)if(void 0!==s)Se.slerpFlat(t,0,i,4*r,i,4*(r+1),(e-a)/(s-a));else for(o=0;o<4;o++)t[o]=i[4*r+o];else for(o=0;o<4;o++)t[o]=i[4*r+o]}}),ht.prototype=Object.assign(Object.create(rt.prototype),{constructor:ht,valueTypeName:"string",getValue:function(e,t){var r=this._getLastTimeIndex(e),n=this.times[r];t[0]=this.values[n]}}),ct.prototype=Object.assign(Object.create(rt.prototype),{constructor:ct,valueTypeName:"vector"}),Object.assign(ut.prototype,{setArray:function(e){return this.count=void 0!==e?e.length/this.size:0,this.array=e,this},copy:function(e){return this.array=new e.array.constructor(e.array),this.size=e.size,this.count=e.count,this.normalized=e.normalized,this.dynamic=e.dynamic,this},clone:function(){return new this.constructor(this.array,this.size).copy(this)}});var lt=1;function dt(){ue.call(this),Object.defineProperty(this,"id",{value:lt++}),this.uuid=a(),this.attributes={},this.morphAttributes={},this.index=null,this.boundingBox=new ye,this.boundingSphere=new we,this.groups=[]}dt.prototype=Object.assign(Object.create(ue.prototype),{constructor:dt,addAttribute:function(e,t){this.attributes[e]=t},getAttribute:function(e){return this.attributes[e]},removeAttribute:function(e){delete this.attributes[e]},setIndex:function(e){Array.isArray(e)?this.index=new ut(new Uint16Array(e),1):this.index=e},addGroup:function(e,t,r){this.groups.push({start:e,count:t,materialIndex:void 0!==r?r:0})},clearGroups:function(){this.groups=[]},computeBoundingBox:function(){var e=this.attributes.a_Position||this.attributes.position;if(e.isInterleavedBufferAttribute){var t=e.data;this.boundingBox.setFromArray(t.array,t.stride)}else this.boundingBox.setFromArray(e.array,e.size)},computeBoundingSphere:function(){var e=this.attributes.a_Position||this.attributes.position;if(e.isInterleavedBufferAttribute){var t=e.data;this.boundingSphere.setFromArray(t.array,t.stride)}else this.boundingSphere.setFromArray(e.array,e.size)},dispose:function(){this.dispatchEvent({type:"dispose"})},copy:function(e){var t,r,n;this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;var i=e.index;null!==i&&this.setIndex(i.clone());var a=e.attributes;for(t in a){var s=a[t];this.addAttribute(t,s.clone())}var o=e.morphAttributes;for(t in o){var h=[],c=o[t];for(r=0,n=c.length;r<n;r++)h.push(c[r].clone());this.morphAttributes[t]=h}var u=e.groups;for(r=0,n=u.length;r<n;r++){var l=u[r];this.addGroup(l.start,l.count,l.materialIndex)}var d=e.boundingBox;null!==d&&(this.boundingBox=(new ye).copy(d));var p=e.boundingSphere;return null!==p&&(this.boundingSphere=(new we).copy(p)),this},clone:function(){return(new dt).copy(this)}});var pt=function(s){function e(e,t,r,n,i,a){s.call(this),this.buildGeometry(e,t,r,n,i,a)}return s&&(e.__proto__=s),((e.prototype=Object.create(s&&s.prototype)).constructor=e).prototype.buildGeometry=function(e,t,r,n,i,a){var P=this;e=e||1,t=t||1,r=r||1,n=Math.floor(n)||1,i=Math.floor(i)||1,a=Math.floor(a)||1;var L=[],R=[],C=[],O=[],F=0,U=0;function s(e,t,r,n,i,a,s,o,h,c,u){var l,d,p=a/h,f=s/c,_=a/2,m=s/2,v=o/2,g=h+1,M=c+1,E=0,S=0,x=new le;for(d=0;d<M;d++){var y=d*f-m;for(l=0;l<g;l++){var w=l*p-_;x[e]=w*n,x[t]=y*i,x[r]=v,R.push(x.x,x.y,x.z),x[e]=0,x[t]=0,x[r]=0<o?1:-1,C.push(x.x,x.y,x.z),O.push(l/h),O.push(1-d/c),E+=1}}for(d=0;d<c;d++)for(l=0;l<h;l++){var T=F+l+g*d,b=F+l+g*(d+1),A=F+(l+1)+g*(d+1),N=F+(l+1)+g*d;L.push(T,b,N),L.push(b,A,N),S+=6}P.addGroup(U,S,u),U+=S,F+=E}s("z","y","x",-1,-1,r,t,e,a,i,0),s("z","y","x",1,-1,r,t,-e,a,i,1),s("x","z","y",1,1,e,r,t,n,a,2),s("x","z","y",1,-1,e,r,-t,n,a,3),s("x","y","z",1,-1,e,t,r,n,i,4),s("x","y","z",-1,-1,e,t,-r,n,i,5),this.setIndex(L),this.addAttribute("a_Position",new ut(new Float32Array(R),3)),this.addAttribute("a_Normal",new ut(new Float32Array(C),3)),this.addAttribute("a_Uv",new ut(new Float32Array(O),2)),this.computeBoundingBox(),this.computeBoundingSphere()},e}(dt);function ft(e,t,r,n,i,a,s,o){dt.call(this),this.buildGeometry(e,t,r,n,i,a,s,o)}function _t(e,t,r,n){ut.call(this,e,t,r),this.meshPerAttribute=n||1}function mt(){dt.call(this),this.maxInstancedCount=void 0}function vt(e,t){this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.dynamic=!1,this.updateRange={offset:0,count:-1},this.version=0}function gt(e,t,r){vt.call(this,e,t),this.meshPerAttribute=r||1}function Mt(e,t,r,n){this.data=e,this.size=t,this.offset=r,this.normalized=!0===n}function Et(e,t,r,n){dt.call(this),this.buildGeometry(e,t,r,n)}function St(e,t,r,n,i,a,s){dt.call(this),this.buildGeometry(e,t,r,n,i,a,s)}function xt(e,t,r,n,i,a){dt.call(this),this.parameters={radius:e,tube:t,tubularSegments:r,radialSegments:n,p:i,q:a},e=e||1,t=t||.4,r=Math.floor(r)||64,n=Math.floor(n)||8,i=i||2,a=a||3;var s,o,h=[],c=[],u=[],l=[],d=new le,p=new le,f=new le,_=new le,m=new le,v=new le,g=new le;for(s=0;s<=r;++s){var M=s/r*i*Math.PI*2;for(A(M,i,a,e,f),A(.01+M,i,a,e,_),v.subVectors(_,f),g.addVectors(_,f),m.crossVectors(v,g),g.crossVectors(m,v),m.normalize(),g.normalize(),o=0;o<=n;++o){var E=o/n*Math.PI*2,S=-t*Math.cos(E),x=t*Math.sin(E);d.x=f.x+(S*g.x+x*m.x),d.y=f.y+(S*g.y+x*m.y),d.z=f.z+(S*g.z+x*m.z),c.push(d.x,d.y,d.z),p.subVectors(d,f).normalize(),u.push(p.x,p.y,p.z),l.push(s/r),l.push(o/n)}}for(o=1;o<=r;o++)for(s=1;s<=n;s++){var y=(n+1)*(o-1)+(s-1),w=(n+1)*o+(s-1),T=(n+1)*o+s,b=(n+1)*(o-1)+s;h.push(y,w,b),h.push(w,T,b)}function A(e,t,r,n,i){var a=Math.cos(e),s=Math.sin(e),o=r/t*e,h=Math.cos(o);i.x=n*(2+h)*.5*a,i.y=n*(2+h)*s*.5,i.z=n*Math.sin(o)*.5}this.setIndex(h),this.addAttribute("a_Position",new ut(new Float32Array(c),3)),this.addAttribute("a_Normal",new ut(new Float32Array(u),3)),this.addAttribute("a_Uv",new ut(new Float32Array(l),2)),this.computeBoundingBox(),this.computeBoundingSphere()}ft.prototype=Object.assign(Object.create(dt.prototype),{constructor:ft,buildGeometry:function(v,g,M,E,S,e,x,y){var w=this;v=void 0!==v?v:1,g=void 0!==g?g:1,M=M||1,E=Math.floor(E)||8,S=Math.floor(S)||1,e=void 0!==e&&e,x=void 0!==x?x:0,y=void 0!==y?y:2*Math.PI;var T=[],b=[],A=[],N=[],P=0,L=[],R=M/2,C=0;function t(e){var t,r,n,i=new ge,a=new le,s=0,o=!0===e?v:g,h=!0===e?1:-1;for(r=P,t=1;t<=E;t++)b.push(0,R*h,0),A.push(0,h,0),N.push(.5,.5),P++;for(n=P,t=0;t<=E;t++){var c=t/E*y+x,u=Math.cos(c),l=Math.sin(c);a.x=o*l,a.y=R*h,a.z=o*u,b.push(a.x,a.y,a.z),A.push(0,h,0),i.x=.5*u+.5,i.y=.5*l*h+.5,N.push(i.x,i.y),P++}for(t=0;t<E;t++){var d=r+t,p=n+t;!0===e?T.push(p,p+1,d):T.push(p+1,p,d),s+=3}w.addGroup(C,s,!0===e?1:2),C+=s}!function(){var e,t,r=new le,n=new le,i=0,a=(g-v)/M;for(t=0;t<=S;t++){var s=[],o=t/S,h=o*(g-v)+v;for(e=0;e<=E;e++){var c=e/E,u=c*y+x,l=Math.sin(u),d=Math.cos(u);n.x=h*l,n.y=-o*M+R,n.z=h*d,b.push(n.x,n.y,n.z),r.set(l,a,d).normalize(),A.push(r.x,r.y,r.z),N.push(c,1-o),s.push(P++)}L.push(s)}for(e=0;e<E;e++)for(t=0;t<S;t++){var p=L[t][e],f=L[t+1][e],_=L[t+1][e+1],m=L[t][e+1];T.push(p,f,m),T.push(f,_,m),i+=6}w.addGroup(C,i,0),C+=i}(),!1===e&&(0<v&&t(!0),0<g&&t(!1)),this.setIndex(T),this.addAttribute("a_Position",new ut(new Float32Array(b),3)),this.addAttribute("a_Normal",new ut(new Float32Array(A),3)),this.addAttribute("a_Uv",new ut(new Float32Array(N),2)),this.computeBoundingBox(),this.computeBoundingSphere()}}),_t.prototype=Object.assign(Object.create(ut.prototype),{constructor:_t,isInstancedBufferAttribute:!0,copy:function(e){return ut.prototype.copy.call(this,e),this.meshPerAttribute=e.meshPerAttribute,this}}),mt.prototype=Object.assign(Object.create(dt.prototype),{constructor:mt,isInstancedGeometry:!0}),Object.assign(vt.prototype,{setArray:function(e){this.count=void 0!==e?e.length/this.stride:0,this.array=e}}),gt.prototype=Object.assign(Object.create(vt.prototype),{constructor:gt,isInstancedInterleavedBuffer:!0}),Mt.prototype.isInterleavedBufferAttribute=!0,Object.defineProperties(Mt.prototype,{count:{get:function(){return this.data.count}},array:{get:function(){return this.data.array}}}),Et.prototype=Object.assign(Object.create(dt.prototype),{constructor:Et,buildGeometry:function(e,t,r,n){var i,a,s=(e=e||1)/2,o=(t=t||1)/2,h=Math.floor(r)||1,c=Math.floor(n)||1,u=h+1,l=c+1,d=e/h,p=t/c,f=[],_=[],m=[],v=[];for(a=0;a<l;a++){var g=a*p-o;for(i=0;i<u;i++){var M=i*d-s;_.push(M,0,g),m.push(0,1,0),v.push(i/h),v.push(1-a/c)}}for(a=0;a<c;a++)for(i=0;i<h;i++){var E=i+u*a,S=i+u*(a+1),x=i+1+u*(a+1),y=i+1+u*a;f.push(E,S,y),f.push(S,x,y)}this.setIndex(f),this.addAttribute("a_Position",new ut(new Float32Array(_),3)),this.addAttribute("a_Normal",new ut(new Float32Array(m),3)),this.addAttribute("a_Uv",new ut(new Float32Array(v),2)),this.computeBoundingBox(),this.computeBoundingSphere()}}),St.prototype=Object.assign(Object.create(dt.prototype),{constructor:St,buildGeometry:function(e,t,r,n,i,a,s){e=e||1,t=Math.max(3,Math.floor(t)||8),r=Math.max(2,Math.floor(r)||6),n=void 0!==n?n:0,i=void 0!==i?i:2*Math.PI;var o,h,c=(a=void 0!==a?a:0)+(s=void 0!==s?s:Math.PI),u=0,l=[],d=new le,p=new le,f=[],_=[],m=[],v=[];for(h=0;h<=r;h++){var g=[],M=h/r;for(o=0;o<=t;o++){var E=o/t;d.x=-e*Math.cos(n+E*i)*Math.sin(a+M*s),d.y=e*Math.cos(a+M*s),d.z=e*Math.sin(n+E*i)*Math.sin(a+M*s),_.push(d.x,d.y,d.z),p.set(d.x,d.y,d.z).normalize(),m.push(p.x,p.y,p.z),v.push(E,1-M),g.push(u++)}l.push(g)}for(h=0;h<r;h++)for(o=0;o<t;o++){var S=l[h][o+1],x=l[h][o],y=l[h+1][o],w=l[h+1][o+1];(0!==h||0<a)&&f.push(S,x,w),(h!==r-1||c<Math.PI)&&f.push(x,y,w)}this.setIndex(f),this.addAttribute("a_Position",new ut(new Float32Array(_),3)),this.addAttribute("a_Normal",new ut(new Float32Array(m),3)),this.addAttribute("a_Uv",new ut(new Float32Array(v),2)),this.computeBoundingBox(),this.computeBoundingSphere()}}),(xt.prototype=Object.create(dt.prototype)).constructor=xt;var yt=0;function wt(){ue.call(this),Object.defineProperty(this,"id",{value:yt++}),this.type="",this.uuid=a(),this.precision=null,this.opacity=1,this.transparent=!1,this.blending=j.NORMAL,this.blendSrc=W.SRC_ALPHA,this.blendDst=W.ONE_MINUS_SRC_ALPHA,this.blendEquation=X.ADD,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.premultipliedAlpha=!1,this.vertexColors=he.NONE,this.vertexTangents=!1,this.diffuse=new Ae(16777215),this.diffuseMap=null,this.diffuseMapCoord=0,this.normalMap=null,this.alphaMap=null,this.alphaMapCoord=0,this.aoMap=null,this.aoMapIntensity=1,this.aoMapCoord=0,this.bumpMap=null,this.bumpScale=1,this.envMap=null,this.envMapIntensity=1,this.envMapCombine=se.MULTIPLY,this.emissive=new Ae(0),this.emissiveMap=null,this.emissiveMapCoord=0,this.emissiveIntensity=1,this.depthFunc=te.LEQUAL,this.depthTest=!0,this.depthWrite=!0,this.colorWrite=!0,this.alphaTest=0,this.side=q.FRONT,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.shading=Z.SMOOTH_SHADING,this.dithering=!1,this.acceptLight=!1,this.drawMode=oe.TRIANGLES,this.needsUpdate=!0}function Tt(){wt.call(this),this.type=H.BASIC}function bt(){wt.call(this),this.type=H.LAMBERT,this.acceptLight=!0}function At(){wt.call(this),this.type=H.PHONG,this.shininess=30,this.specular=new Ae(1118481),this.specularMap=null,this.acceptLight=!0}function Nt(){wt.call(this),this.type=H.PBR,this.roughness=.5,this.metalness=.5,this.roughnessMap=null,this.metalnessMap=null,this.acceptLight=!0}function Pt(){wt.call(this),this.type=H.PBR2,this.specular=new Ae(1118481),this.glossiness=.5,this.specularMap=null,this.glossinessMap=null,this.acceptLight=!0}function Lt(){wt.call(this),this.type=H.POINT,this.size=1,this.sizeAttenuation=!0,this.drawMode=oe.POINTS}function Rt(){wt.call(this),this.type=H.LINE,this.lineWidth=1,this.drawMode=oe.LINES}function Ct(e){wt.call(this),this.type=H.SHADER,this.vertexShader=e.vertexShader||"",this.fragmentShader=e.fragmentShader||"",this.defines={},Object.assign(this.defines,e.defines),this.uniforms=c(e.uniforms)}function Ot(){wt.call(this),this.type=H.DEPTH,this.packToRGBA=!1}function Ft(){wt.call(this),this.type=H.DISTANCE}function Ut(n){var i=["","WEBKIT_","MOZ_"],a={};function e(e){if(a[e]||null===a[e])return a[e];var t=null;for(var r in i)if(t=n.getExtension(i[r]+e))break;return a[e]=t}var t=parseFloat(/^WebGL\ ([0-9])/.exec(n.getParameter(n.VERSION))[1]),r=e("EXT_texture_filter_anisotropic");return{version:t,maxPrecision:function(e,t){if("highp"===t){if(0<e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT).precision&&0<e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision)return"highp";t="mediump"}return"mediump"===t&&0<e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision&&0<e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision?"mediump":"lowp"}(n,"highp"),maxTextures:n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS),maxVertexTextures:n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS),maxTextureSize:n.getParameter(n.MAX_TEXTURE_SIZE),maxCubemapSize:n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE),maxVertexUniformVectors:n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS),lineWidthRange:n.getParameter(n.ALIASED_LINE_WIDTH_RANGE),anisotropyExt:r,maxAnisotropy:null!==r?n.getParameter(r.MAX_TEXTURE_MAX_ANISOTROPY_EXT):1,maxSamples:1<t?n.getParameter(n.MAX_SAMPLES):1,getExtension:e}}function It(e,t,r,n){var i=new Uint8Array(4),a=e.createTexture();e.bindTexture(t,a),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(var s=0;s<n;s++)e.texImage2D(r+s,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,i);return a}function Dt(a){var t=!1,s=new Me,r=null,o=new Me(0,0,0,0);return{setMask:function(e){r===e||t||(a.colorMask(e,e,e,e),r=e)},setLocked:function(e){t=e},setClear:function(e,t,r,n,i){!0===i&&(e*=n,t*=n,r*=n),s.set(e,t,r,n),!1===o.equals(s)&&(a.clearColor(e,t,r,n),o.copy(s))},getClear:function(){return o},reset:function(){t=!1,r=null,o.set(-1,0,0,0)}}}function Bt(t,r){var n=!1,i=null,a=null,s=null;return{setTest:function(e){e?r.enable(t.DEPTH_TEST):r.disable(t.DEPTH_TEST)},setMask:function(e){i===e||n||(t.depthMask(e),i=e)},setFunc:function(e){a!==e&&(t.depthFunc(e),a=e)},setLocked:function(e){n=e},setClear:function(e){s!==e&&(t.clearDepth(e),s=e)},reset:function(){n=!1,s=a=i=null}}}function zt(n,t){var r=!1,i=null,a=null,s=null,o=null,h=null,c=null,u=null,l=null;return{setTest:function(e){e?t.enable(n.STENCIL_TEST):t.disable(n.STENCIL_TEST)},setMask:function(e){i===e||r||(n.stencilMask(e),i=e)},setFunc:function(e,t,r){a===e&&s===t&&o===r||(n.stencilFunc(e,t,r),a=e,s=t,o=r)},setOp:function(e,t,r){h===e&&c===t&&u===r||(n.stencilOp(e,t,r),h=e,c=t,u=r)},setLocked:function(e){r=e},setClear:function(e){l!==e&&(n.clearStencil(e),l=e)},reset:function(){r=!1,l=u=c=h=o=s=a=i=null}}}function Gt(e,t){this.gl=e,this.capabilities=t,this.colorBuffer=new Dt(e),this.depthBuffer=new Bt(e,this),this.stencilBuffer=new zt(e,this),this.states={},this.currentBlending=null,this.currentBlendEquation=null,this.currentBlendSrc=null,this.currentBlendDst=null,this.currentBlendEquationAlpha=null,this.currentBlendSrcAlpha=null,this.currentBlendDstAlpha=null,this.currentPremultipliedAlpha=null,this.currentCullFace=null,this.currentViewport=new Me,this.currentTextureSlot=null,this.currentBoundTextures={},this.currentBoundBuffers={},this.emptyTextures={},this.emptyTextures[e.TEXTURE_2D]=It(e,e.TEXTURE_2D,e.TEXTURE_2D,1),this.emptyTextures[e.TEXTURE_CUBE_MAP]=It(e,e.TEXTURE_CUBE_MAP,e.TEXTURE_CUBE_MAP_POSITIVE_X,6),this.currentFlipSided=!1,this.currentLineWidth=null,this.currentPolygonOffsetFactor=null,this.currentPolygonOffsetUnits=null,this.currentProgram=null,this.currentRenderTarget=null,this.colorBuffer.setClear(0,0,0,1),this.depthBuffer.setClear(1),this.stencilBuffer.setClear(0),this.depthBuffer.setTest(!0),this.depthBuffer.setFunc(te.LEQUAL),this.setCullFace(Y.BACK),this.setFlipSided(!1)}function Ht(){this.properties=new WeakMap}function kt(e){return e.wrapS!==ee.CLAMP_TO_EDGE||e.wrapT!==ee.CLAMP_TO_EDGE||e.minFilter!==J.NEAREST&&e.minFilter!==J.LINEAR}function Vt(e){return e===J.NEAREST||e===J.NEAREST_MIPMAP_LINEAR||e===J.NEAREST_MIPMAP_NEAREST?J.NEAREST:J.LINEAR}function jt(e){return o(e.width)&&o(e.height)}function Xt(e){if(e instanceof HTMLImageElement||e instanceof HTMLCanvasElement){var t=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return t.width=s(e.width),t.height=s(e.height),t.getContext("2d").drawImage(e,0,0,t.width,t.height),console.warn("image is not power of two ("+e.width+"x"+e.height+"). Resized to "+t.width+"x"+t.height,e),t}return e}function Wt(e,t){if(e.width>t||e.height>t){var r=t/Math.max(e.width,e.height),n=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return n.width=Math.floor(e.width*r),n.height=Math.floor(e.height*r),n.getContext("2d").drawImage(e,0,0,e.width,e.height,0,0,n.width,n.height),console.warn("image is too big ("+e.width+"x"+e.height+"). Resized to "+n.width+"x"+n.height,e),n}return e}function Yt(e,t,r,n){this.gl=e,this.state=t,this.properties=r,this.capabilities=n}function qt(e,t,r,n){r.isInterleavedBufferAttribute&&(r=r.data);var i,a,s,o,h,c,u=t.get(r);void 0===u.buffer?function(e,t,r,n){var i=r.array,a=r.dynamic?e.DYNAMIC_DRAW:e.STATIC_DRAW,s=e.createBuffer();e.bindBuffer(n,s),e.bufferData(n,i,a);var o=e.FLOAT;i instanceof Float32Array?o=e.FLOAT:i instanceof Float64Array?console.warn("Unsupported data buffer format: Float64Array."):i instanceof Uint16Array?o=e.UNSIGNED_SHORT:i instanceof Int16Array?o=e.SHORT:i instanceof Uint32Array?o=e.UNSIGNED_INT:i instanceof Int32Array?o=e.INT:i instanceof Int8Array?o=e.BYTE:i instanceof Uint8Array&&(o=e.UNSIGNED_BYTE),t.buffer=s,t.type=o,t.bytesPerElement=i.BYTES_PER_ELEMENT,t.version=r.version}(e,u,r,n):u.version<r.version&&(i=e,a=u.buffer,o=n,h=(s=r).array,c=s.updateRange,i.bindBuffer(o,a),!1===s.dynamic?i.bufferData(o,h,i.STATIC_DRAW):-1===c.count?i.bufferSubData(o,0,h):0===c.count?console.error("updateBuffer: dynamic BufferAttribute marked as needsUpdate but updateRange.count is 0, ensure you are using set methods or updating manually."):(i.bufferSubData(o,c.offset*h.BYTES_PER_ELEMENT,h.subarray(c.offset,c.offset+c.count)),c.count=-1),u.version=r.version)}function Zt(e,t,r){r.isInterleavedBufferAttribute&&(r=r.data);var n=t.get(r);n.buffer&&e.deleteBuffer(n.buffer),t.delete(r)}function Kt(e,t,r,n){this.gl=e,this.state=t,this.properties=r,this.capabilities=n}wt.prototype=Object.assign(Object.create(ue.prototype),{constructor:wt,copy:function(e){return this.type=e.type,this.precision=e.precision,e.defines&&(this.defines=Object.assign({},e.defines)),this.opacity=e.opacity,this.transparent=e.transparent,this.premultipliedAlpha=e.premultipliedAlpha,this.vertexColors=e.vertexColors,this.diffuse.copy(e.diffuse),this.diffuseMap=e.diffuseMap,this.diffuseMapCoord=e.diffuseMapCoord,this.alphaMap=e.alphaMap,this.alphaMapCoord=e.alphaMapCoord,this.normalMap=e.normalMap,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.aoMapCoord=e.aoMapCoord,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.envMap=e.envMap,this.envMapIntensity=e.envMapIntensity,this.envMapCombine=e.envMapCombine,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveMapCoord=e.emissiveMapCoord,this.emissiveIntensity=e.emissiveIntensity,this.blending=e.blending,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.colorWrite=e.colorWrite,this.alphaTest=e.alphaTest,this.side=e.side,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.shading=e.shading,this.acceptLight=e.acceptLight,this.drawMode=e.drawMode,this},clone:function(){return(new this.constructor).copy(this)},dispose:function(){this.dispatchEvent({type:"dispose"})}}),(Tt.prototype=Object.create(wt.prototype)).constructor=Tt,(bt.prototype=Object.create(wt.prototype)).constructor=bt,At.prototype=Object.assign(Object.create(wt.prototype),{constructor:At,copy:function(e){return wt.prototype.copy.call(this,e),this.shininess=e.shininess,this.specular.copy(e.specular),this.specularMap=e.specularMap,this}}),Nt.prototype=Object.assign(Object.create(wt.prototype),{constructor:Nt,copy:function(e){return wt.prototype.copy.call(this,e),this.roughness=e.roughness,this.metalness=e.metalness,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this}}),Pt.prototype=Object.assign(Object.create(wt.prototype),{constructor:Pt,copy:function(e){return wt.prototype.copy.call(this,e),this.specular=e.specular,this.glossiness=e.glossiness,this.specularMap=e.specularMap,this.glossinessMap=e.glossinessMap,this}}),Lt.prototype=Object.assign(Object.create(wt.prototype),{constructor:Lt,copy:function(e){return wt.prototype.copy.call(this,e),this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this}}),Rt.prototype=Object.assign(Object.create(wt.prototype),{constructor:Rt,copy:function(e){return wt.prototype.copy.call(this,e),this.lineWidth=e.lineWidth,this}}),Ct.prototype=Object.assign(Object.create(wt.prototype),{constructor:Ct,copy:function(e){return wt.prototype.copy.call(this,e),this.vertexShader=e.vertexShader,this.fragmentShader=e.fragmentShader,this.uniforms=c(e.uniforms),this}}),(Ot.prototype=Object.create(wt.prototype)).constructor=Ot,(Ft.prototype=Object.create(wt.prototype)).constructor=Ft,Object.assign(Gt.prototype,{setBlend:function(e,t,r,n,i,a,s,o){var h=this.gl;e!==j.NONE?this.enable(h.BLEND):this.disable(h.BLEND),e!==j.CUSTOM?(e===this.currentBlending&&o===this.currentPremultipliedAlpha||(e===j.NORMAL&&(o?(h.blendEquationSeparate(h.FUNC_ADD,h.FUNC_ADD),h.blendFuncSeparate(h.ONE,h.ONE_MINUS_SRC_ALPHA,h.ONE,h.ONE_MINUS_SRC_ALPHA)):(h.blendEquationSeparate(h.FUNC_ADD,h.FUNC_ADD),h.blendFuncSeparate(h.SRC_ALPHA,h.ONE_MINUS_SRC_ALPHA,h.ONE,h.ONE_MINUS_SRC_ALPHA))),e===j.ADD&&(o?(h.blendEquationSeparate(h.FUNC_ADD,h.FUNC_ADD),h.blendFuncSeparate(h.ONE,h.ONE,h.ONE,h.ONE)):(h.blendEquation(h.FUNC_ADD),h.blendFunc(h.SRC_ALPHA,h.ONE)))),this.currentBlendEquation=null,this.currentBlendSrc=null,this.currentBlendDst=null,this.currentBlendEquationAlpha=null,this.currentBlendSrcAlpha=null,this.currentBlendDstAlpha=null):(i=i||t,a=a||r,s=s||n,t===this.currentBlendEquation&&i===this.currentBlendEquationAlpha||(h.blendEquationSeparate(t,i),this.currentBlendEquation=t,this.currentBlendEquationAlpha=i),r===this.currentBlendSrc&&n===this.currentBlendDst&&a===this.currentBlendSrcAlpha&&s===this.currentBlendDstAlpha||(h.blendFuncSeparate(r,n,a,s),this.currentBlendSrc=r,this.currentBlendDst=n,this.currentBlendSrcAlpha=a,this.currentBlendDstAlpha=s)),this.currentBlending=e,this.currentPremultipliedAlpha=o},setFlipSided:function(e){var t=this.gl;this.currentFlipSided!==e&&(e?t.frontFace(t.CW):t.frontFace(t.CCW),this.currentFlipSided=e)},setCullFace:function(e){var t=this.gl;e!==Y.NONE?(this.enable(t.CULL_FACE),e!==this.currentCullFace&&(e===Y.BACK?t.cullFace(t.BACK):e===Y.FRONT?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):this.disable(t.CULL_FACE),this.currentCullFace=e},viewport:function(e,t,r,n){var i=this.currentViewport;i.x===e&&i.y===t&&i.z===r&&i.w===n||(this.gl.viewport(e,t,r,n),i.set(e,t,r,n))},activeTexture:function(e){var t=this.gl;void 0===e&&(e=t.TEXTURE0+this.capabilities.maxTextures-1),this.currentTextureSlot!==e&&(t.activeTexture(e),this.currentTextureSlot=e)},bindTexture:function(e,t){var r=this.gl;null===this.currentTextureSlot&&this.activeTexture();var n=this.currentBoundTextures[this.currentTextureSlot];void 0===n&&(n={type:void 0,texture:void 0},this.currentBoundTextures[this.currentTextureSlot]=n),n.type===e&&n.texture===t||(r.bindTexture(e,t||this.emptyTextures[e]),n.type=e,n.texture=t)},bindBuffer:function(e,t){var r=this.gl;this.currentBoundBuffers[e]!==t&&(r.bindBuffer(e,t),this.currentBoundBuffers[e]=t)},enable:function(e){!0!==this.states[e]&&(this.gl.enable(e),this.states[e]=!0)},disable:function(e){!1!==this.states[e]&&(this.gl.disable(e),this.states[e]=!1)},setLineWidth:function(e){if(e!==this.currentLineWidth){var t=this.capabilities.lineWidthRange;t[0]<=e&&e<=t[1]?this.gl.lineWidth(e):console.warn("GL_ALIASED_LINE_WIDTH_RANGE is ["+t[0]+","+t[1]+"], but set to "+e+"."),this.currentLineWidth=e}},setPolygonOffset:function(e,t,r){var n=this.gl;e?(this.enable(n.POLYGON_OFFSET_FILL),this.currentPolygonOffsetFactor===t&&this.currentPolygonOffsetUnits===r||(n.polygonOffset(t,r),this.currentPolygonOffsetFactor=t,this.currentPolygonOffsetUnits=r)):this.disable(n.POLYGON_OFFSET_FILL)},setProgram:function(e){this.currentProgram!==e&&(this.gl.useProgram(e.program),this.currentProgram=e)}}),Object.assign(Ht.prototype,{get:function(e){var t=this.properties.get(e);return void 0===t&&(t={},this.properties.set(e,t)),t},delete:function(e){this.properties.delete(e)},clear:function(){this.properties=new WeakMap}}),Object.assign(Yt.prototype,{setTexture2D:function(e,t){var r=this.gl,n=this.state,i=this.capabilities;void 0!==t&&(t=r.TEXTURE0+t);var a=this.properties.get(e);if(!e.image||e.image.rtt&&void 0!==t||a.__version===e.version)return n.activeTexture(t),n.bindTexture(r.TEXTURE_2D,a.__webglTexture),a;void 0===a.__webglTexture&&(e.addEventListener("dispose",this.onTextureDispose,this),a.__webglTexture=r.createTexture()),n.activeTexture(t),n.bindTexture(r.TEXTURE_2D,a.__webglTexture);var s=e.image,o=s instanceof HTMLImageElement||s instanceof HTMLCanvasElement;o&&(s=Wt(s,i.maxTextureSize),kt(e)&&!1===jt(s)&&i.version<2&&(s=Xt(s)));var h=!jt(s)&&i.version<2;r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,e.flipY),this.setTextureParameters(e,h);var c,u=e.mipmaps,l=e.format,d=e.internalformat||e.format,p=e.type;if(i.version<2?(l!==d&&console.warn("texture format "+l+" not same as internalformat "+d+" in webgl 1.0."),p===$.HALF_FLOAT&&(i.getExtension("OES_texture_half_float")||console.warn("extension OES_texture_half_float is not support in webgl 1.0.")),p===$.FLOAT&&(i.getExtension("OES_texture_float")||console.warn("extension OES_texture_float is not support in webgl 1.0.")),l!==Q.DEPTH_COMPONENT&&l!==Q.DEPTH_STENCIL||i.getExtension("WEBGL_depth_texture")||console.warn("extension WEBGL_depth_texture is not support in webgl 1.0.")):p===$.HALF_FLOAT&&(p=5131),o)if(0<u.length&&!h){for(var f=0,_=u.length;f<_;f++)c=u[f],r.texImage2D(r.TEXTURE_2D,f,d,l,p,c);e.generateMipmaps=!1,a.__maxMipLevel=u.length-1}else r.texImage2D(r.TEXTURE_2D,0,d,l,p,s),a.__maxMipLevel=0;else if(0<u.length&&!h){for(f=0,_=u.length;f<_;f++)c=u[f],r.texImage2D(r.TEXTURE_2D,f,d,c.width,c.height,e.border,l,p,c.data);e.generateMipmaps=!1,a.__maxMipLevel=u.length-1}else r.texImage2D(r.TEXTURE_2D,0,d,s.width,s.height,e.border,l,p,s.data),a.__maxMipLevel=0;return e.generateMipmaps&&!h&&this.generateMipmap(r.TEXTURE_2D,e,s.width,s.height),a.__version=e.version,a},setTextureCube:function(e,t){var r=this.gl,n=this.state,i=this.capabilities;void 0!==t&&(t=r.TEXTURE0+t);var a=this.properties.get(e);if(6!==e.images.length||e.images[0].rtt&&void 0!==t||a.__version===e.version)return n.activeTexture(t),n.bindTexture(r.TEXTURE_CUBE_MAP,a.__webglTexture),a;void 0===a.__webglTexture&&(e.addEventListener("dispose",this.onTextureDispose,this),a.__webglTexture=r.createTexture()),n.activeTexture(t),n.bindTexture(r.TEXTURE_CUBE_MAP,a.__webglTexture);var s,o=[],h=e.mipmaps,c=e.format,u=e.internalformat||e.format,l=e.type;i.version<2?(c!==u&&console.warn("texture format "+c+" not same as internalformat "+u+" in webgl 1.0."),l===$.HALF_FLOAT&&(i.getExtension("OES_texture_half_float")||console.warn("extension OES_texture_half_float is not support in webgl 1.0.")),l===$.FLOAT&&(i.getExtension("OES_texture_float")||console.warn("extension OES_texture_float is not support in webgl 1.0.")),c!==Q.DEPTH_COMPONENT&&c!==Q.DEPTH_STENCIL||i.getExtension("WEBGL_depth_texture")||console.warn("extension WEBGL_depth_texture is not support in webgl 1.0.")):l===$.HALF_FLOAT&&(l=5131);for(var d=!1,p=0;p<6;p++){(_=(f=e.images[p])instanceof HTMLImageElement||f instanceof HTMLCanvasElement)&&(f=Wt(f,i.maxTextureSize),kt(e)&&!1===jt(f)&&i.version<2&&(f=Xt(f))),!jt(f)&&i.version<2&&(d=!0),(o[p]=f).__isElement=_}r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,e.flipY),this.setTextureParameters(e,d);for(p=0;p<6;p++){var f,_;if(_=(f=o[p]).__isElement)if(0<h.length&&!d){for(var m=0,v=h.length;m<v;m++)s=h[m][p],r.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+p,0,u,c,l,s);a.__maxMipLevel=h.length-1,e.generateMipmaps=!1}else r.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+p,0,u,c,l,f),a.__maxMipLevel=0;else if(0<h.length&&!d){for(m=0,v=h.length;m<v;m++)s=h[m][p],r.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+p,m,u,s.width,s.height,e.border,c,l,s.data);a.__maxMipLevel=h.length-1,e.generateMipmaps=!1}else r.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+p,0,u,f.width,f.height,e.border,c,l,f.data),a.__maxMipLevel=0}return e.generateMipmaps&&!d&&this.generateMipmap(r.TEXTURE_CUBE_MAP,e,f.width,f.height),a.__version=e.version,a},setTexture3D:function(e,t){var r=this.gl,n=this.state;if(!(this.capabilities.version<2)){void 0!==t&&(t=r.TEXTURE0+t);var i=this.properties.get(e);if(e.image&&i.__version!==e.version){void 0===i.__webglTexture&&(e.addEventListener("dispose",this.onTextureDispose,this),i.__webglTexture=r.createTexture()),n.activeTexture(t),n.bindTexture(r.TEXTURE_3D,i.__webglTexture);var a=e.image;r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,e.flipY),this.setTextureParameters(e,!1);var s=e.format,o=e.internalformat||e.format,h=e.type;return r.texImage3D(r.TEXTURE_3D,0,o,a.width,a.height,a.depth,e.border,s,h,a.data),e.generateMipmaps&&this.generateMipmap(r.TEXTURE_3D,e,a.width,a.height),i.__version=e.version,i}return n.activeTexture(t),n.bindTexture(r.TEXTURE_3D,i.__webglTexture),i}console.warn("Try to use Texture3D but browser not support WebGL2.0")},setTextureParameters:function(e,t){var r,n,i,a,s,o,h,c,u=this.gl,l=this.capabilities,d=e.textureType,p=(n=t,i=(r=e).wrapS,a=r.wrapT,s=r.magFilter,o=r.minFilter,h=r.anisotropy,c=r.compare,n&&(i=ee.CLAMP_TO_EDGE,a=ee.CLAMP_TO_EDGE,r.wrapS===ee.CLAMP_TO_EDGE&&r.wrapT===ee.CLAMP_TO_EDGE||console.warn("Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to zen3d.TEXTURE_WRAP.CLAMP_TO_EDGE.",r),s=Vt(r.magFilter),o=Vt(r.minFilter),(r.minFilter!==J.NEAREST&&r.minFilter!==J.LINEAR||r.magFilter!==J.NEAREST&&r.magFilter!==J.LINEAR)&&console.warn("Texture is not power of two. Texture.minFilter and Texture.magFilter should be set to zen3d.TEXTURE_FILTER.NEAREST or zen3d.TEXTURE_FILTER.LINEAR.",r)),[i,a,s,o,h,c]);u.texParameteri(d,u.TEXTURE_WRAP_S,p[0]),u.texParameteri(d,u.TEXTURE_WRAP_T,p[1]),u.texParameteri(d,u.TEXTURE_MAG_FILTER,p[2]),u.texParameteri(d,u.TEXTURE_MIN_FILTER,p[3]);var f=l.anisotropyExt;f&&u.texParameterf(d,f.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(p[4],l.maxAnisotropy)),2<=l.version&&(void 0!==p[5]?(u.texParameteri(d,u.TEXTURE_COMPARE_MODE,u.COMPARE_REF_TO_TEXTURE),u.texParameteri(d,u.TEXTURE_COMPARE_FUNC,p[5])):u.texParameteri(d,u.TEXTURE_COMPARE_MODE,u.NONE))},generateMipmap:function(e,t,r,n){this.gl.generateMipmap(e),this.properties.get(t).__maxMipLevel=Math.log(Math.max(r,n))*Math.LOG2E},onTextureDispose:function(e){var t=this.gl,r=e.target,n=this.properties.get(r);r.removeEventListener("dispose",this.onTextureDispose,this),n.__webglTexture&&t.deleteTexture(n.__webglTexture),this.properties.delete(r)}}),Object.assign(Kt.prototype,{setGeometry:function(e){var t=this.gl,r=this.properties,n=this.properties.get(e);for(var i in n.created||(e.addEventListener("dispose",this.onGeometryDispose,this),n.created=!0,n._vaos={}),null!==e.index&&qt(t,r,e.index,t.ELEMENT_ARRAY_BUFFER),e.attributes)qt(t,r,e.attributes[i],t.ARRAY_BUFFER);for(var i in e.morphAttributes)for(var a=e.morphAttributes[i],s=0,o=a.length;s<o;s++)qt(t,r,a[s],t.ARRAY_BUFFER);return n},onGeometryDispose:function(e){var t=this.gl,r=e.target,n=this.properties.get(r);for(var i in r.removeEventListener("dispose",this.onGeometryDispose,this),null!==r.index&&Zt(t,this.properties,r.index),r.attributes)Zt(t,this.properties,r.attributes[i]);for(var i in r.morphAttributes)for(var a=r.morphAttributes[i],s=0,o=a.length;s<o;s++)Zt(t,this.properties,a[s]);for(var h in n._vaos){var c=n[h];c&&(2<=this.capabilities.version?t.deleteVertexArray(c):t.deleteVertexArrayOES(c))}n._vaos={},n.created=!1,this.properties.delete(r)}});var Qt=new ze;Qt.image={data:new Uint8Array([1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1]),width:2,height:2},Qt.magFilter=J.NEAREST,Qt.minFilter=J.NEAREST,Qt.generateMipmaps=!1,Qt.version++;var $t=new ze;$t.image={data:null,width:2,height:2},$t.version++,$t.type=$.FLOAT_32_UNSIGNED_INT_24_8_REV,$t.format=Q.DEPTH_STENCIL,$t.internalformat=Q.DEPTH32F_STENCIL8,$t.magFilter=J.NEAREST,$t.minFilter=J.NEAREST,$t.compare=te.LESS,$t.generateMipmaps=!1,$t.version++;var Jt=new He,er=new Ge;function tr(){this.seq=[],this.map={}}function rr(e,t){if(e.length===t.length){for(var r=0,n=e.length;r<n;r++)if(e[r]!==t[r])return;return 1}}function nr(e,t){for(var r=0,n=t.length;r<n;r++)e[r]=t[r]}var ir=[];function ar(e,t){var r=ir[t];void 0===r&&(r=new Int32Array(t),ir[t]=r);for(var n=0;n!==t;++n)r[n]=e.allocTexUnit();return r}function sr(e,t){var a=e.gl,s=e.type,o=e.location,h=e.cache;switch(s){case re.FLOAT:e.setValue=function(e){h[0]!==e&&(a.uniform1f(o,e),h[0]=e)},e.set=t?function(e){rr(h,e)||(a.uniform1fv(o,e),nr(h,e))}:e.setValue;break;case re.SAMPLER_2D:case re.SAMPLER_2D_SHADOW:e.setValue=function(e,t){var r=t.allocTexUnit();t.texture.setTexture2D(e||(s===re.SAMPLER_2D_SHADOW?$t:Qt),r),h[0]!==r&&(a.uniform1i(o,r),h[0]=r)},e.set=t?function(e,t){for(var r=e.length,n=ar(t,r),i=0;i!==r;++i)t.texture.setTexture2D(e[i]||(s===re.SAMPLER_2D_SHADOW?$t:Qt),n[i]);rr(h,n)||(a.uniform1iv(o,n),nr(h,n))}:e.setValue;break;case re.SAMPLER_CUBE:case re.SAMPLER_CUBE_SHADOW:e.setValue=function(e,t){var r=t.allocTexUnit();t.texture.setTextureCube(e||er,r),h[0]!==r&&(a.uniform1i(o,r),h[0]=r)},e.set=t?function(e,t){for(var r=e.length,n=ar(t,r),i=0;i!==r;++i)t.texture.setTextureCube(e[i]||er,n[i]);rr(h,n)||(a.uniform1iv(o,n),nr(h,n))}:e.setValue;break;case re.SAMPLER_3D:e.setValue=function(e,t){var r=t.allocTexUnit();t.texture.setTexture3D(e||Jt,r),h[0]!==r&&(a.uniform1i(o,r),h[0]=r)},e.set=t?function(e,t){for(var r=e.length,n=ar(t,r),i=0;i!==r;++i)t.texture.setTexture3D(e[i]||Jt,n[i]);rr(h,n)||(a.uniform1iv(o,n),nr(h,n))}:e.setValue;break;case re.BOOL:case re.INT:e.setValue=function(e){h[0]!==e&&(a.uniform1i(o,e),h[0]=e)},e.set=t?function(e){rr(h,e)||(a.uniform1iv(o,e),nr(h,e))}:e.setValue;break;case re.FLOAT_VEC2:e.setValue=function(e,t){h[0]===e&&h[1]===t||(a.uniform2f(o,e,t),h[0]=e,h[1]=t)},e.set=function(e){rr(h,e)||(a.uniform2fv(o,e),nr(h,e))};break;case re.BOOL_VEC2:case re.INT_VEC2:e.setValue=function(e,t){h[0]===e&&h[1]===t||(a.uniform2i(o,e,t),h[0]=e,h[1]=t)},e.set=function(e){rr(h,e)||(a.uniform2iv(o,e),nr(h,e))};break;case re.FLOAT_VEC3:e.setValue=function(e,t,r){h[0]===e&&h[1]===t&&h[2]===r||(a.uniform3f(o,e,t,r),h[0]=e,h[1]=t,h[2]=r)},e.set=function(e){rr(h,e)||(a.uniform3fv(o,e),nr(h,e))};break;case re.BOOL_VEC3:case re.INT_VEC3:e.setValue=function(e,t,r){h[0]===e&&h[1]===t&&h[2]===r||(a.uniform3i(o,e,t,r),h[0]=e,h[1]=t,h[2]=r)},e.set=function(e){rr(h,e)||(a.uniform3iv(o,e),nr(h,e))};break;case re.FLOAT_VEC4:e.setValue=function(e,t,r,n){h[0]===e&&h[1]===t&&h[2]===r&&h[3]===n||(a.uniform4f(o,e,t,r,n),h[0]=e,h[1]=t,h[2]=r,h[3]=n)},e.set=function(e){rr(h,e)||(a.uniform4fv(o,e),nr(h,e))};break;case re.BOOL_VEC4:case re.INT_VEC4:e.setValue=function(e,t,r,n){h[0]===e&&h[1]===t&&h[2]===r&&h[3]===n||(a.uniform4i(o,e,t,r,n),h[0]=e,h[1]=t,h[2]=r,h[3]=n)},e.set=function(e){rr(h,e)||(a.uniform4iv(o,e),nr(h,e))};break;case re.FLOAT_MAT2:e.setValue=e.set=function(e){rr(h,e)||(a.uniformMatrix2fv(o,!1,e),nr(h,e))};break;case re.FLOAT_MAT3:e.setValue=e.set=function(e){rr(h,e)||(a.uniformMatrix3fv(o,!1,e),nr(h,e))};break;case re.FLOAT_MAT4:e.setValue=e.set=function(e){rr(h,e)||(a.uniformMatrix4fv(o,!1,e),nr(h,e))}}}function or(e,t,r,n){this.gl=e,this.id=t,this.type=r.type,this.location=n,this.setValue=void 0,this.set=void 0,this.cache=[],sr(this)}function hr(e,t,r,n){this.gl=e,this.id=t,this.type=r.type,this.size=r.size,this.location=n,this.setValue=void 0,this.set=void 0,this.cache=[],sr(this,!0)}function cr(e){this.id=e,tr.call(this)}cr.prototype.set=function(e,t){for(var r=this.seq,n=0,i=r.length;n!==i;++n){var a=r[n];a.set(e[a.id],t)}};var ur=/([\w\d_]+)(\])?(\[|\.)?/g;function lr(e,t){e.seq.push(t),e.map[t.id]=t}function dr(e,t,r,n){var i=t.name,a=i.length;for(ur.lastIndex=0;;){var s=ur.exec(i),o=ur.lastIndex,h=s[1],c="]"===s[2],u=s[3];if(c&&(h|=0),void 0===u||"["===u&&o+2===a){lr(n,new(void 0===u?or:hr)(e,h,t,r));break}var l=n.map[h];void 0===l&&lr(n,l=new cr(h)),n=l}}function pr(e,t){tr.call(this);for(var r=e.getProgramParameter(t,e.ACTIVE_UNIFORMS),n=0;n<r;++n){var i=e.getActiveUniform(t,n),a=e.getUniformLocation(t,i.name);dr(e,i,a,this)}}function fr(e,t,r){this.gl=e,this.name=r.name,this.type=r.type,this.size=r.size,this.location=e.getAttribLocation(t,this.name),this.count=0,this.initCount(e),this.format=e.FLOAT,this.initFormat(e)}function _r(e,t,r){var n=e.createShader(t);return e.shaderSource(n,r),e.compileShader(n),e.getShaderParameter(n,e.COMPILE_STATUS)||console.warn("shader not compiled!",e.getShaderInfoLog(n),function(e){for(var t=e.split("\n"),r=0;r<t.length;r++)t[r]=r+1+": "+t[r];return t.join("\n")}(r)),n}pr.prototype.set=function(e,t,r){var n=this.map[e];void 0!==n&&n.set(t,r)},pr.prototype.has=function(e){return!!this.map[e]},Object.assign(fr.prototype,{initCount:function(e){switch(this.type){case ne.FLOAT:case ne.BYTE:case ne.UNSIGNED_BYTE:case ne.UNSIGNED_SHORT:this.count=1;break;case ne.FLOAT_VEC2:this.count=2;break;case ne.FLOAT_VEC3:this.count=3;break;case ne.FLOAT_VEC4:this.count=4}},initFormat:function(e){switch(this.type){case ne.FLOAT:case ne.FLOAT_VEC2:case ne.FLOAT_VEC3:case ne.FLOAT_VEC4:this.format=e.FLOAT;break;case ne.UNSIGNED_BYTE:this.format=e.UNSIGNED_BYTE;break;case ne.UNSIGNED_SHORT:this.format=e.UNSIGNED_SHORT;break;case ne.BYTE:this.format=e.BYTE}}});var mr=0;function vr(e,t,r){this.id=mr++,this.usedTimes=1,this.code="",this.gl=e,this.vshaderSource=t,this.fshaderSource=r;var n,i,a,s,o=_r(e,e.VERTEX_SHADER,this.vshaderSource),h=_r(e,e.FRAGMENT_SHADER,this.fshaderSource);this.program=(i=o,a=h,s=(n=e).createProgram(),n.attachShader(s,i),n.attachShader(s,a),n.linkProgram(s),n.getProgramParameter(s,n.LINK_STATUS)||console.warn("program not linked!",n.getProgramInfoLog(s)),s),this.uniforms=new pr(e,this.program),this.attributes=function(e,t){for(var r={},n=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES),i=0;i<n;i++){var a=e.getActiveAttrib(t,i),s=a.name,o=new fr(e,t,a);r[s]=o}return r}(e,this.program),e.deleteShader(o),e.deleteShader(h)}vr.prototype.dispose=function(){this.gl.deleteProgram(this.program),this.program=void 0};var gr={alphaTest_frag:"#ifdef ALPHATEST\r\n\r\n\tif ( outColor.a < ALPHATEST ) {\r\n\t\tdiscard;\r\n\t} else {\r\n\t\t// Prevent alpha test edge gradient\r\n\t\toutColor.a = u_Opacity;\r\n\t}\r\n\r\n#endif",ambientlight_pars_frag:"uniform vec3 u_AmbientLightColor;",aoMap_pars_frag:"#ifdef USE_AOMAP\r\n\r\n\tuniform sampler2D aoMap;\r\n\tuniform float aoMapIntensity;\r\n\r\n#endif",begin_frag:"vec4 outColor = vec4(u_Color, u_Opacity);",begin_vert:"vec3 transformed = vec3(a_Position);\r\n#if defined(USE_NORMAL) || defined(USE_ENV_MAP)\r\n vec3 objectNormal = vec3(a_Normal);\r\n#endif\r\n#ifdef USE_TANGENT\r\n vec3 objectTangent = vec3(a_Tangent.xyz);\r\n#endif",bsdfs:'// diffuse just use lambert\r\n\r\nvec4 BRDF_Diffuse_Lambert(vec4 diffuseColor) {\r\n return RECIPROCAL_PI * diffuseColor;\r\n}\r\n\r\n// specular use Cook-Torrance microfacet model, http://ruh.li/GraphicsCookTorrance.html\r\n// About RECIPROCAL_PI: referenced by http://www.joshbarczak.com/blog/?p=272\r\n\r\nvec4 F_Schlick( const in vec4 specularColor, const in float dotLH ) {\r\n\t// Original approximation by Christophe Schlick \'94\r\n\tfloat fresnel = pow( 1.0 - dotLH, 5.0 );\r\n\r\n\t// Optimized variant (presented by Epic at SIGGRAPH \'13)\r\n\t// float fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\r\n\r\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\r\n}\r\n\r\n// use blinn phong instead of phong\r\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\r\n // ( shininess * 0.5 + 1.0 ), three.js do this, but why ???\r\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\r\n}\r\n\r\nfloat G_BlinnPhong_Implicit( ) {\r\n\t// geometry term is (n dot l)(n dot v) / 4(n dot l)(n dot v)\r\n\treturn 0.25;\r\n}\r\n\r\nvec4 BRDF_Specular_BlinnPhong(vec4 specularColor, vec3 N, vec3 L, vec3 V, float shininess) {\r\n vec3 H = normalize(L + V);\r\n\r\n float dotNH = saturate(dot(N, H));\r\n float dotLH = saturate(dot(L, H));\r\n\r\n vec4 F = F_Schlick(specularColor, dotLH);\r\n\r\n float G = G_BlinnPhong_Implicit( );\r\n\r\n float D = D_BlinnPhong(shininess, dotNH);\r\n\r\n return F * G * D;\r\n}\r\n\r\n// Microfacet Models for Refraction through Rough Surfaces - equation (33)\r\n// http://graphicrants.blogspot.com/2013/08/specular-brdf-reference.html\r\n// alpha is "roughness squared" in Disneys reparameterization\r\nfloat D_GGX( const in float alpha, const in float dotNH ) {\r\n\r\n\tfloat a2 = pow2( alpha );\r\n\r\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; // avoid alpha = 0 with dotNH = 1\r\n\r\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\r\n\r\n}\r\n\r\n// Microfacet Models for Refraction through Rough Surfaces - equation (34)\r\n// http://graphicrants.blogspot.com/2013/08/specular-brdf-reference.html\r\n// alpha is "roughness squared" in Disneys reparameterization\r\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\r\n\r\n\t// geometry term = G(l)⋅G(v) / 4(n⋅l)(n⋅v)\r\n\r\n\tfloat a2 = pow2( alpha );\r\n\r\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\r\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\r\n\r\n\treturn 1.0 / ( gl * gv );\r\n\r\n}\r\n\r\n// Moving Frostbite to Physically Based Rendering 2.0 - page 12, listing 2\r\n// http://www.frostbite.com/wp-content/uploads/2014/11/course_notes_moving_frostbite_to_pbr_v2.pdf\r\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\r\n\r\n\tfloat a2 = pow2( alpha );\r\n\r\n\t// dotNL and dotNV are explicitly swapped. This is not a mistake.\r\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\r\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\r\n\r\n\treturn 0.5 / max( gv + gl, EPSILON );\r\n}\r\n\r\n// GGX Distribution, Schlick Fresnel, GGX-Smith Visibility\r\nvec4 BRDF_Specular_GGX(vec4 specularColor, vec3 N, vec3 L, vec3 V, float roughness) {\r\n\r\n\tfloat alpha = pow2( roughness ); // UE4\'s roughness\r\n\r\n\tvec3 H = normalize(L + V);\r\n\r\n\tfloat dotNL = saturate( dot(N, L) );\r\n\tfloat dotNV = saturate( dot(N, V) );\r\n\tfloat dotNH = saturate( dot(N, H) );\r\n\tfloat dotLH = saturate( dot(L, H) );\r\n\r\n\tvec4 F = F_Schlick( specularColor, dotLH );\r\n\r\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\r\n\r\n\tfloat D = D_GGX( alpha, dotNH );\r\n\r\n\treturn F * G * D;\r\n\r\n}\r\n\r\n// ref: https://www.unrealengine.com/blog/physically-based-shading-on-mobile - environmentBRDF for GGX on mobile\r\nvec4 BRDF_Specular_GGX_Environment( const in vec3 N, const in vec3 V, const in vec4 specularColor, const in float roughness ) {\r\n\r\n\tfloat dotNV = saturate( dot( N, V ) );\r\n\r\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\r\n\r\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\r\n\r\n\tvec4 r = roughness * c0 + c1;\r\n\r\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\r\n\r\n\tvec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;\r\n\r\n\treturn specularColor * AB.x + AB.y;\r\n\r\n}\r\n\r\n// source: http://simonstechblog.blogspot.ca/2011/12/microfacet-brdf.html\r\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\r\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\r\n}\r\n\r\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\r\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\r\n}',bumpMap_pars_frag:"#ifdef USE_BUMPMAP\r\n\r\n\tuniform sampler2D bumpMap;\r\n\tuniform float bumpScale;\r\n\r\n\t// Derivative maps - bump mapping unparametrized surfaces by Morten Mikkelsen\r\n\t// http://mmikkelsen3d.blogspot.sk/2011/07/derivative-maps.html\r\n\r\n\t// Evaluate the derivative of the height w.r.t. screen-space using forward differencing (listing 2)\r\n\r\n\tvec2 dHdxy_fwd(vec2 uv) {\r\n\r\n\t\tvec2 dSTdx = dFdx( uv );\r\n\t\tvec2 dSTdy = dFdy( uv );\r\n\r\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, uv ).x;\r\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, uv + dSTdx ).x - Hll;\r\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, uv + dSTdy ).x - Hll;\r\n\r\n\t\treturn vec2( dBx, dBy );\r\n\r\n\t}\r\n\r\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy) {\r\n\r\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\r\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\r\n\t\tvec3 vN = surf_norm;\t\t// normalized\r\n\r\n\t\tvec3 R1 = cross( vSigmaY, vN );\r\n\t\tvec3 R2 = cross( vN, vSigmaX );\r\n\r\n\t\tfloat fDet = dot( vSigmaX, R1 );\r\n\r\n\t\tfDet *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\r\n\r\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\r\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\r\n\r\n\t}\r\n\r\n#endif\r\n",clippingPlanes_frag:"#if NUM_CLIPPING_PLANES > 0\r\n\r\n vec4 plane;\r\n\r\n #pragma unroll_loop\r\n for ( int i = 0; i < NUM_CLIPPING_PLANES; i ++ ) {\r\n\r\n plane = clippingPlanes[ i ];\r\n if ( dot( -v_modelPos, plane.xyz ) > plane.w ) discard;\r\n\r\n }\r\n\r\n#endif",clippingPlanes_pars_frag:"#if NUM_CLIPPING_PLANES > 0\r\n uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\r\n#endif",color_frag:"#ifdef USE_VCOLOR_RGB\r\n outColor.rgb *= v_Color;\r\n#endif\r\n#ifdef USE_VCOLOR_RGBA\r\n outColor *= v_Color;\r\n#endif",color_pars_frag:"#ifdef USE_VCOLOR_RGB\r\n varying vec3 v_Color;\r\n#endif\r\n#ifdef USE_VCOLOR_RGBA\r\n varying vec4 v_Color;\r\n#endif",color_pars_vert:"#ifdef USE_VCOLOR_RGB\r\n attribute vec3 a_Color;\r\n varying vec3 v_Color;\r\n#endif\r\n#ifdef USE_VCOLOR_RGBA\r\n attribute vec4 a_Color;\r\n varying vec4 v_Color;\r\n#endif",color_vert:"#if defined(USE_VCOLOR_RGB) || defined(USE_VCOLOR_RGBA)\r\n v_Color = a_Color;\r\n#endif",common_frag:"uniform mat4 u_View;\r\n\r\nuniform float u_Opacity;\r\nuniform vec3 u_Color;\r\n\r\nuniform vec3 u_CameraPosition;",common_vert:"attribute vec3 a_Position;\r\nattribute vec3 a_Normal;\r\n#ifdef USE_TANGENT\r\n\tattribute vec4 a_Tangent;\r\n#endif\r\n\r\n#include <transpose>\r\n#include <inverse>\r\n\r\nuniform mat4 u_Projection;\r\nuniform mat4 u_View;\r\nuniform mat4 u_Model;\r\n\r\nuniform vec3 u_CameraPosition;\r\n\r\n#ifdef USE_MORPHTARGETS\r\n\r\n attribute vec3 morphTarget0;\r\n attribute vec3 morphTarget1;\r\n attribute vec3 morphTarget2;\r\n attribute vec3 morphTarget3;\r\n\r\n #ifdef USE_MORPHNORMALS\r\n\r\n \tattribute vec3 morphNormal0;\r\n \tattribute vec3 morphNormal1;\r\n \tattribute vec3 morphNormal2;\r\n \tattribute vec3 morphNormal3;\r\n\r\n #else\r\n\r\n \tattribute vec3 morphTarget4;\r\n \tattribute vec3 morphTarget5;\r\n \tattribute vec3 morphTarget6;\r\n \tattribute vec3 morphTarget7;\r\n\r\n #endif\r\n\r\n#endif",diffuseMap_frag:"#ifdef USE_DIFFUSE_MAP\r\n #if (USE_DIFFUSE_MAP == 1)\r\n vec4 texelColor = texture2D( diffuseMap, v_Uv );\r\n #elif (USE_DIFFUSE_MAP == 2)\r\n vec4 texelColor = texture2D( diffuseMap, v_Uv2 );\r\n #else \r\n vec4 texelColor = texture2D( diffuseMap, v_Uv );\r\n #endif\r\n \r\n texelColor = mapTexelToLinear( texelColor );\r\n\r\n outColor *= texelColor;\r\n#endif",diffuseMap_pars_frag:"#ifdef USE_DIFFUSE_MAP\r\n uniform sampler2D diffuseMap;\r\n#endif",directlight_pars_frag:"struct DirectLight\r\n{\r\n vec3 direction;\r\n vec4 color;\r\n\r\n int shadow;\r\n float shadowBias;\r\n float shadowRadius;\r\n vec2 shadowMapSize;\r\n};\r\nuniform DirectLight u_Directional[NUM_DIR_LIGHTS];",emissiveMap_frag:"#ifdef USE_EMISSIVEMAP\r\n\r\n\t#if (USE_EMISSIVEMAP == 1)\r\n\t\tvec4 emissiveColor = texture2D(emissiveMap, v_Uv);\r\n\t#elif (USE_EMISSIVEMAP == 2)\r\n vec4 emissiveColor = texture2D(emissiveMap, v_Uv2);\r\n #else \r\n vec4 emissiveColor = texture2D(emissiveMap, v_Uv);\r\n #endif\r\n\r\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\r\n\r\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\r\n\r\n#endif",emissiveMap_pars_frag:"#ifdef USE_EMISSIVEMAP\r\n\r\n\tuniform sampler2D emissiveMap;\r\n\r\n#endif",encodings_frag:"gl_FragColor = linearToOutputTexel( gl_FragColor );",encodings_pars_frag:"// 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/\r\n\r\nvec4 LinearToLinear( in vec4 value ) {\r\n\treturn value;\r\n}\r\n\r\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\r\n\treturn vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );\r\n}\r\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\r\n\treturn vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );\r\n}\r\n\r\nvec4 sRGBToLinear( in vec4 value ) {\r\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );\r\n}\r\nvec4 LinearTosRGB( in vec4 value ) {\r\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );\r\n}\r\n\r\nvec4 RGBEToLinear( in vec4 value ) {\r\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\r\n}\r\nvec4 LinearToRGBE( in vec4 value ) {\r\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\r\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\r\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\r\n// return vec4( value.brg, ( 3.0 + 128.0 ) / 256.0 );\r\n}\r\n\r\n// reference: http://iwasbeingirony.blogspot.ca/2010/06/difference-between-rgbm-and-rgbd.html\r\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\r\n\treturn vec4( value.xyz * value.w * maxRange, 1.0 );\r\n}\r\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\r\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\r\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\r\n\tM = ceil( M * 255.0 ) / 255.0;\r\n\treturn vec4( value.rgb / ( M * maxRange ), M );\r\n}\r\n\r\n// reference: http://iwasbeingirony.blogspot.ca/2010/06/difference-between-rgbm-and-rgbd.html\r\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\r\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\r\n}\r\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\r\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\r\n\tfloat D = max( maxRange / maxRGB, 1.0 );\r\n\tD = min( floor( D ) / 255.0, 1.0 );\r\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\r\n}\r\n\r\n// LogLuv reference: http://graphicrants.blogspot.ca/2009/04/rgbm-color-encoding.html\r\n\r\n// M matrix, for encoding\r\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\r\nvec4 LinearToLogLuv( in vec4 value ) {\r\n\tvec3 Xp_Y_XYZp = value.rgb * cLogLuvM;\r\n\tXp_Y_XYZp = max(Xp_Y_XYZp, vec3(1e-6, 1e-6, 1e-6));\r\n\tvec4 vResult;\r\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\r\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\r\n\tvResult.w = fract(Le);\r\n\tvResult.z = (Le - (floor(vResult.w*255.0))/255.0)/255.0;\r\n\treturn vResult;\r\n}\r\n\r\n// Inverse M matrix, for decoding\r\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\r\nvec4 LogLuvToLinear( in vec4 value ) {\r\n\tfloat Le = value.z * 255.0 + value.w;\r\n\tvec3 Xp_Y_XYZp;\r\n\tXp_Y_XYZp.y = exp2((Le - 127.0) / 2.0);\r\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\r\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\r\n\tvec3 vRGB = Xp_Y_XYZp.rgb * cLogLuvInverseM;\r\n\treturn vec4( max(vRGB, 0.0), 1.0 );\r\n}\r\n",end_frag:"gl_FragColor = outColor;",envMap_frag:"#ifdef USE_ENV_MAP\r\n\r\n vec3 envDir;\r\n #if defined(USE_NORMAL_MAP) || defined(USE_BUMPMAP)\r\n envDir = reflect(normalize(v_worldPos - u_CameraPosition), N);\r\n #else\r\n envDir = v_EnvPos;\r\n #endif\r\n\r\n vec4 envColor = textureCube(envMap, envDir);\r\n\r\n envColor = envMapTexelToLinear( envColor );\r\n\r\n #ifdef ENVMAP_BLENDING_MULTIPLY\r\n\t\toutColor = mix(outColor, envColor * outColor, u_EnvMap_Intensity);\r\n\t#elif defined( ENVMAP_BLENDING_MIX )\r\n\t\toutColor = mix(outColor, envColor, u_EnvMap_Intensity);\r\n\t#elif defined( ENVMAP_BLENDING_ADD )\r\n\t\toutColor += envColor * u_EnvMap_Intensity;\r\n\t#endif\r\n#endif",envMap_pars_frag:"#ifdef USE_ENV_MAP\r\n #if defined(USE_NORMAL_MAP) || defined(USE_BUMPMAP)\r\n varying vec3 v_worldPos;\r\n #else\r\n varying vec3 v_EnvPos;\r\n #endif\r\n uniform samplerCube envMap;\r\n uniform float u_EnvMap_Intensity;\r\n uniform int maxMipLevel;\r\n#endif",envMap_pars_vert:"#ifdef USE_ENV_MAP\r\n #if defined(USE_NORMAL_MAP) || defined(USE_BUMPMAP)\r\n varying vec3 v_worldPos;\r\n #else\r\n varying vec3 v_EnvPos;\r\n #endif\r\n#endif",envMap_vert:"#ifdef USE_ENV_MAP\r\n #if defined(USE_NORMAL_MAP) || defined(USE_BUMPMAP)\r\n v_worldPos = (u_Model * vec4(transformed, 1.0)).xyz;\r\n #else\r\n v_EnvPos = reflect(normalize((u_Model * vec4(transformed, 1.0)).xyz - u_CameraPosition), (transposeMat4(inverseMat4(u_Model)) * vec4(objectNormal, 1.0)).xyz);\r\n #endif\r\n#endif",fog_frag:"#ifdef USE_FOG\r\n\r\n float depth = gl_FragCoord.z / gl_FragCoord.w;\r\n\r\n #ifdef USE_EXP2_FOG\r\n\r\n float fogFactor = whiteCompliment( exp2( - u_FogDensity * u_FogDensity * depth * depth * LOG2 ) );\r\n\r\n #else\r\n\r\n float fogFactor = smoothstep( u_FogNear, u_FogFar, depth );\r\n\r\n #endif\r\n\r\n gl_FragColor.rgb = mix( gl_FragColor.rgb, u_FogColor, fogFactor );\r\n\r\n#endif",fog_pars_frag:"#ifdef USE_FOG\r\n\r\n uniform vec3 u_FogColor;\r\n\r\n #ifdef USE_EXP2_FOG\r\n\r\n uniform float u_FogDensity;\r\n\r\n #else\r\n\r\n uniform float u_FogNear;\r\n uniform float u_FogFar;\r\n #endif\r\n\r\n#endif",inverse:"mat4 inverseMat4(mat4 m) {\r\n float\r\n a00 = m[0][0], a01 = m[0][1], a02 = m[0][2], a03 = m[0][3],\r\n a10 = m[1][0], a11 = m[1][1], a12 = m[1][2], a13 = m[1][3],\r\n a20 = m[2][0], a21 = m[2][1], a22 = m[2][2], a23 = m[2][3],\r\n a30 = m[3][0], a31 = m[3][1], a32 = m[3][2], a33 = m[3][3],\r\n b00 = a00 * a11 - a01 * a10,\r\n b01 = a00 * a12 - a02 * a10,\r\n b02 = a00 * a13 - a03 * a10,\r\n b03 = a01 * a12 - a02 * a11,\r\n b04 = a01 * a13 - a03 * a11,\r\n b05 = a02 * a13 - a03 * a12,\r\n b06 = a20 * a31 - a21 * a30,\r\n b07 = a20 * a32 - a22 * a30,\r\n b08 = a20 * a33 - a23 * a30,\r\n b09 = a21 * a32 - a22 * a31,\r\n b10 = a21 * a33 - a23 * a31,\r\n b11 = a22 * a33 - a23 * a32,\r\n det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\r\n return mat4(\r\n a11 * b11 - a12 * b10 + a13 * b09,\r\n a02 * b10 - a01 * b11 - a03 * b09,\r\n a31 * b05 - a32 * b04 + a33 * b03,\r\n a22 * b04 - a21 * b05 - a23 * b03,\r\n a12 * b08 - a10 * b11 - a13 * b07,\r\n a00 * b11 - a02 * b08 + a03 * b07,\r\n a32 * b02 - a30 * b05 - a33 * b01,\r\n a20 * b05 - a22 * b02 + a23 * b01,\r\n a10 * b10 - a11 * b08 + a13 * b06,\r\n a01 * b08 - a00 * b10 - a03 * b06,\r\n a30 * b04 - a31 * b02 + a33 * b00,\r\n a21 * b02 - a20 * b04 - a23 * b00,\r\n a11 * b07 - a10 * b09 - a12 * b06,\r\n a00 * b09 - a01 * b07 + a02 * b06,\r\n a31 * b01 - a30 * b03 - a32 * b00,\r\n a20 * b03 - a21 * b01 + a22 * b00) / det;\r\n}",light_frag:"#ifdef USE_LIGHT\r\n vec4 light;\r\n vec3 L;\r\n\r\n vec4 totalReflect = vec4(0., 0., 0., 0.); // direct light\r\n\r\n // https://computergraphics.stackexchange.com/questions/7503/what-is-the-difference-between-radiance-and-irradiance-in-brdf\r\n vec3 indirectIrradiance = vec3(0., 0., 0.); // for indirect diffuse\r\n vec3 indirectRadiance = vec3(0., 0., 0.); // for indirect specular\r\n\r\n #ifdef USE_PBR\r\n #ifdef USE_PBR2\r\n vec4 diffuseColor = outColor.xyzw;\r\n vec4 specularColor = vec4(specularFactor.rgb, 1.);\r\n\t\t\tfloat roughness = clamp(1.0 - glossinessFactor, 0.04, 1.0);\r\n #else\r\n vec4 diffuseColor = outColor.xyzw * (1.0 - metalnessFactor);\r\n vec4 specularColor = mix(vec4(0.04), outColor.xyzw, metalnessFactor);\r\n float roughness = clamp(roughnessFactor, 0.04, 1.0);\r\n #endif\r\n #else\r\n vec4 diffuseColor = outColor.xyzw;\r\n #ifdef USE_PHONG\r\n vec4 specularColor = vec4(u_SpecularColor, 1.);\r\n float shininess = u_Specular;\r\n #endif\r\n #endif\r\n\r\n #ifdef USE_AMBIENT_LIGHT\r\n indirectIrradiance += u_AmbientLightColor;\r\n #endif\r\n\r\n // TODO light map\r\n\r\n #ifdef USE_PBR\r\n #ifdef USE_ENV_MAP\r\n \t\tvec3 envDir;\r\n \t #if defined(USE_NORMAL_MAP) || defined(USE_BUMPMAP)\r\n \t envDir = reflect(normalize(v_worldPos - u_CameraPosition), N);\r\n \t #else\r\n \t envDir = v_EnvPos;\r\n \t #endif\r\n indirectIrradiance += getLightProbeIndirectIrradiance(maxMipLevel, envDir);\r\n indirectRadiance += getLightProbeIndirectRadiance(GGXRoughnessToBlinnExponent(roughness), maxMipLevel, envDir);\r\n \t#endif\r\n #endif\r\n\r\n #if (defined(USE_PHONG) || defined(USE_PBR))\r\n vec3 V = normalize( u_CameraPosition - v_modelPos );\r\n #endif\r\n\r\n float dotNL;\r\n vec4 irradiance;\r\n vec4 reflectLight;\r\n float dist;\r\n\r\n #if NUM_DIR_LIGHTS > 0\r\n\r\n #pragma unroll_loop\r\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\r\n L = -u_Directional[ i ].direction;\r\n light = u_Directional[ i ].color;\r\n L = normalize(L);\r\n\r\n dotNL = saturate( dot(N, L) );\r\n irradiance = light * dotNL;\r\n\r\n #if NUM_DIR_SHADOWS > 0\r\n #ifdef USE_PCSS_SOFT_SHADOW\r\n irradiance *= bool( u_Directional[ i ].shadow ) ? getShadowWithPCSS( directionalDepthMap[ i ], directionalShadowMap[ i ], vDirectionalShadowCoord[ i ], u_Directional[ i ].shadowBias, u_Directional[ i ].shadowRadius, u_Directional[ i ].shadowMapSize ) : 1.0;\r\n #else\r\n irradiance *= bool( u_Directional[ i ].shadow ) ? getShadow( directionalShadowMap[ i ], vDirectionalShadowCoord[ i ], u_Directional[ i ].shadowBias, u_Directional[ i ].shadowRadius, u_Directional[ i ].shadowMapSize ) : 1.0;\r\n #endif\r\n #endif\r\n\r\n // #ifndef USE_PBR\r\n // irradiance *= PI;\r\n // #endif\r\n\r\n reflectLight = irradiance * BRDF_Diffuse_Lambert(diffuseColor);\r\n\r\n #ifdef USE_PHONG\r\n reflectLight += irradiance * BRDF_Specular_BlinnPhong(specularColor, N, L, V, shininess) * specularStrength;\r\n #endif\r\n\r\n #ifdef USE_PBR\r\n reflectLight += irradiance * BRDF_Specular_GGX(specularColor, N, L, V, roughness);\r\n #endif\r\n\r\n totalReflect += reflectLight;\r\n }\r\n\r\n #endif\r\n\r\n #if NUM_POINT_LIGHTS > 0\r\n vec3 worldV;\r\n\r\n #pragma unroll_loop\r\n for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\r\n L = u_Point[ i ].position - v_modelPos;\r\n dist = pow(clamp(1. - length(L) / u_Point[ i ].distance, 0.0, 1.0), u_Point[ i ].decay);\r\n light = u_Point[ i ].color * dist;\r\n L = normalize(L);\r\n\r\n dotNL = saturate( dot(N, L) );\r\n irradiance = light * dotNL;\r\n\r\n // #ifndef USE_PBR\r\n // irradiance *= PI;\r\n // #endif\r\n\r\n #if NUM_POINT_SHADOWS > 0\r\n worldV = v_modelPos - u_Point[ i ].position;\r\n irradiance *= bool( u_Point[ i ].shadow ) ? getPointShadow( pointShadowMap[ i ], worldV, u_Point[ i ].shadowBias, u_Point[ i ].shadowRadius, u_Point[ i ].shadowMapSize, u_Point[ i ].shadowCameraNear, u_Point[ i ].shadowCameraFar ) : 1.0;\r\n #endif\r\n\r\n reflectLight = irradiance * BRDF_Diffuse_Lambert(diffuseColor);\r\n\r\n #ifdef USE_PHONG\r\n reflectLight += irradiance * BRDF_Specular_BlinnPhong(specularColor, N, L, V, shininess) * specularStrength;\r\n #endif\r\n\r\n #ifdef USE_PBR\r\n reflectLight += irradiance * BRDF_Specular_GGX(specularColor, N, L, V, roughness);\r\n #endif\r\n\r\n totalReflect += reflectLight;\r\n }\r\n\r\n #endif\r\n\r\n #if NUM_SPOT_LIGHTS > 0\r\n float lightDistance;\r\n float angleCos;\r\n float spotEffect;\r\n\r\n #pragma unroll_loop\r\n for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\r\n L = u_Spot[ i ].position - v_modelPos;\r\n lightDistance = length(L);\r\n L = normalize(L);\r\n angleCos = dot( L, -normalize(u_Spot[ i ].direction) );\r\n\r\n if( all( bvec2(angleCos > u_Spot[ i ].coneCos, lightDistance < u_Spot[ i ].distance) ) ) {\r\n\r\n spotEffect = smoothstep( u_Spot[ i ].coneCos, u_Spot[ i ].penumbraCos, angleCos );\r\n dist = pow(clamp(1. - lightDistance / u_Spot[ i ].distance, 0.0, 1.0), u_Spot[ i ].decay);\r\n light = u_Spot[ i ].color * dist * spotEffect;\r\n\r\n dotNL = saturate( dot(N, L) );\r\n irradiance = light * dotNL;\r\n\r\n // #ifndef USE_PBR\r\n // irradiance *= PI;\r\n // #endif\r\n\r\n #if NUM_SPOT_SHADOWS > 0\r\n #ifdef USE_PCSS_SOFT_SHADOW\r\n irradiance *= bool( u_Spot[ i ].shadow ) ? getShadowWithPCSS( spotDepthMap[ i ], spotShadowMap[ i ], vSpotShadowCoord[ i ], u_Spot[ i ].shadowBias, u_Spot[ i ].shadowRadius, u_Spot[ i ].shadowMapSize ) : 1.0;\r\n #else\r\n irradiance *= bool( u_Spot[ i ].shadow ) ? getShadow( spotShadowMap[ i ], vSpotShadowCoord[ i ], u_Spot[ i ].shadowBias, u_Spot[ i ].shadowRadius, u_Spot[ i ].shadowMapSize ) : 1.0;\r\n #endif\r\n #endif\r\n\r\n reflectLight = irradiance * BRDF_Diffuse_Lambert(diffuseColor);\r\n\r\n #ifdef USE_PHONG\r\n reflectLight += irradiance * BRDF_Specular_BlinnPhong(specularColor, N, L, V, shininess) * specularStrength;\r\n #endif\r\n\r\n #ifdef USE_PBR\r\n reflectLight += irradiance * BRDF_Specular_GGX(specularColor, N, L, V, roughness);\r\n #endif\r\n\r\n totalReflect += reflectLight;\r\n }\r\n\r\n }\r\n\r\n #endif\r\n\r\n vec3 indirectDiffuse = indirectIrradiance * BRDF_Diffuse_Lambert(diffuseColor).rgb;\r\n vec3 indirectSpecular = vec3(0., 0., 0.);\r\n\r\n #if defined( USE_ENV_MAP ) && defined( USE_PBR )\r\n indirectSpecular += indirectRadiance * BRDF_Specular_GGX_Environment(N, V, specularColor, roughness).rgb;\r\n #endif\r\n\r\n #ifdef USE_AOMAP\r\n\r\n // reads channel R, compatible with a combined OcclusionRoughnessMetallic (RGB) texture\r\n #if (USE_AOMAP == 1)\r\n \t float ambientOcclusion = ( texture2D( aoMap, v_Uv ).r - 1.0 ) * aoMapIntensity + 1.0;\r\n #elif (USE_AOMAP == 2)\r\n float ambientOcclusion = ( texture2D( aoMap, v_Uv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\r\n #else\r\n float ambientOcclusion = ( texture2D( aoMap, v_Uv ).r - 1.0 ) * aoMapIntensity + 1.0;\r\n #endif\r\n \t\r\n \tindirectDiffuse *= ambientOcclusion;\r\n\r\n \t#if defined( USE_ENV_MAP ) && defined( USE_PBR )\r\n\r\n \t\tfloat dotNV = saturate( dot( N, V ) );\r\n\r\n \t\tindirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, GGXRoughnessToBlinnExponent(roughness) );\r\n\r\n \t#endif\r\n\r\n #endif\r\n\r\n outColor.xyz = totalReflect.xyz + indirectDiffuse + indirectSpecular;\r\n#endif",light_pars_frag:"#ifdef USE_AMBIENT_LIGHT\r\n #include <ambientlight_pars_frag>\r\n#endif\r\n#if NUM_DIR_LIGHTS > 0\r\n #include <directlight_pars_frag>\r\n#endif\r\n#if NUM_POINT_LIGHTS > 0\r\n #include <pointlight_pars_frag>\r\n#endif\r\n#if NUM_SPOT_LIGHTS > 0\r\n #include <spotlight_pars_frag>\r\n#endif\r\n\r\n#if defined(USE_PBR) && defined(USE_ENV_MAP)\r\n\r\n vec3 getLightProbeIndirectIrradiance(const in int maxMIPLevel, const in vec3 envDir) {\r\n // TODO: replace with properly filtered cubemaps and access the irradiance LOD level, be it the last LOD level\r\n \t// of a specular cubemap, or just the default level of a specially created irradiance cubemap.\r\n\r\n \t#ifdef TEXTURE_LOD_EXT\r\n\r\n \t\tvec4 envMapColor = textureCubeLodEXT( envMap, envDir, float( maxMIPLevel ) );\r\n\r\n \t#else\r\n\r\n \t\t// force the bias high to get the last LOD level as it is the most blurred.\r\n \t\tvec4 envMapColor = textureCube( envMap, envDir, float( maxMIPLevel ) );\r\n\r\n \t#endif\r\n\r\n envMapColor = envMapTexelToLinear( envMapColor );\r\n\r\n return PI * envMapColor.rgb * u_EnvMap_Intensity;\r\n }\r\n\r\n // taken from here: http://casual-effects.blogspot.ca/2011/08/plausible-environment-lighting-in-two.html\r\n float getSpecularMIPLevel( const in float blinnShininessExponent, const in int maxMIPLevel ) {\r\n\r\n \t//float envMapWidth = pow( 2.0, maxMIPLevelScalar );\r\n \t//float desiredMIPLevel = log2( envMapWidth * sqrt( 3.0 ) ) - 0.5 * log2( pow2( blinnShininessExponent ) + 1.0 );\r\n\r\n \tfloat maxMIPLevelScalar = float( maxMIPLevel );\r\n \tfloat desiredMIPLevel = maxMIPLevelScalar - 0.79248 - 0.5 * log2( pow2( blinnShininessExponent ) + 1.0 );\r\n\r\n \t// clamp to allowable LOD ranges.\r\n \treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\r\n\r\n }\r\n\r\n vec3 getLightProbeIndirectRadiance(const in float blinnShininessExponent, const in int maxMIPLevel, const in vec3 envDir) {\r\n float specularMIPLevel = getSpecularMIPLevel( blinnShininessExponent, maxMIPLevel );\r\n\r\n #ifdef TEXTURE_LOD_EXT\r\n\r\n \t\tvec4 envMapColor = textureCubeLodEXT( envMap, envDir, specularMIPLevel );\r\n\r\n \t#else\r\n\r\n \t\tvec4 envMapColor = textureCube( envMap, envDir, specularMIPLevel );\r\n\r\n \t#endif\r\n\r\n envMapColor = envMapTexelToLinear( envMapColor );\r\n\r\n return envMapColor.rgb * u_EnvMap_Intensity;\r\n }\r\n\r\n // ref: https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf\r\n float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\r\n\r\n \treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\r\n\r\n }\r\n\r\n#endif",alphamap_pars_frag:"#ifdef USE_ALPHA_MAP\r\n\r\n\tuniform sampler2D alphaMap;\r\n\r\n#endif",alphamap_frag:"#ifdef USE_ALPHA_MAP\r\n\r\n\t#ifdef USE_ALPHA_MAP_UV_TRANSFORM\r\n\t\toutColor.a *= texture2D(alphaMap, vAlphaMapUV).g;\r\n\t#else\r\n\t\t#if (USE_ALPHA_MAP == 1)\r\n\t\t\toutColor.a *= texture2D(alphaMap, v_Uv).g;\r\n\t\t#elif (USE_ALPHA_MAP == 2)\r\n outColor.a *= texture2D(alphaMap, v_Uv2).g;\r\n\t\t#else\r\n outColor.a *= texture2D(alphaMap, v_Uv).g;\r\n #endif\r\n\t#endif\r\n\r\n#endif",normalMap_pars_frag:"#if !defined(USE_TANGENT) || defined(FLAT_SHADED)\r\n #include <tsn>\r\n#endif\r\nuniform sampler2D normalMap;",normal_frag:"#ifdef USE_NORMAL\r\n #ifdef FLAT_SHADED\r\n // Workaround for Adreno/Nexus5 not able able to do dFdx( Vec3 ) ...\r\n \tvec3 fdx = vec3( dFdx( v_modelPos.x ), dFdx( v_modelPos.y ), dFdx( v_modelPos.z ) );\r\n \tvec3 fdy = vec3( dFdy( v_modelPos.x ), dFdy( v_modelPos.y ), dFdy( v_modelPos.z ) );\r\n \tvec3 N = normalize( cross( fdx, fdy ) );\r\n #else\r\n vec3 N = normalize(v_Normal);\r\n #ifdef DOUBLE_SIDED\r\n N = N * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\r\n #endif \r\n #endif\r\n #ifdef USE_NORMAL_MAP\r\n vec3 mapN = texture2D(normalMap, v_Uv).rgb * 2.0 - 1.0;\r\n #if defined(USE_TANGENT) && !defined(FLAT_SHADED)\r\n vec3 tangent = normalize(v_Tangent);\r\n vec3 bitangent = normalize(v_Bitangent);\r\n #ifdef DOUBLE_SIDED\r\n tangent = tangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\r\n bitangent = bitangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\r\n #endif \r\n mat3 tspace = mat3(tangent, bitangent, N);\r\n #else\r\n // for now, uv coord is flip Y\r\n mat3 tspace = tsn(N, v_modelPos, vec2(v_Uv.x, 1.0 - v_Uv.y));\r\n mapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\r\n #endif\r\n N = normalize(tspace * mapN);\r\n #elif defined(USE_BUMPMAP)\r\n N = perturbNormalArb(v_modelPos, N, dHdxy_fwd(v_Uv));\r\n #endif\r\n#endif",normal_pars_frag:"#if defined(USE_NORMAL) && !defined(FLAT_SHADED)\r\n varying vec3 v_Normal;\r\n #ifdef USE_TANGENT\r\n varying vec3 v_Tangent;\r\n\t\tvarying vec3 v_Bitangent;\r\n #endif\r\n#endif",normal_pars_vert:"#if defined(USE_NORMAL) && !defined(FLAT_SHADED)\r\n varying vec3 v_Normal;\r\n #ifdef USE_TANGENT\r\n varying vec3 v_Tangent;\r\n\t\tvarying vec3 v_Bitangent;\r\n #endif\r\n#endif",normal_vert:"#if defined(USE_NORMAL) && !defined(FLAT_SHADED)\r\n v_Normal = (transposeMat4(inverseMat4(u_Model)) * vec4(objectNormal, 0.0)).xyz;\r\n\r\n #ifdef FLIP_SIDED\r\n \tv_Normal = - v_Normal;\r\n #endif\r\n\r\n #ifdef USE_TANGENT\r\n v_Tangent = (transposeMat4(inverseMat4(u_Model)) * vec4(objectTangent, 0.0)).xyz;\r\n\r\n #ifdef FLIP_SIDED\r\n v_Tangent = - v_Tangent;\r\n #endif\r\n\r\n v_Bitangent = normalize(cross(v_Normal, v_Tangent) * a_Tangent.w);\r\n #endif\r\n#endif\r\n",packing:"const float PackUpscale = 256. / 255.; // fraction -> 0..1 (including 1)\r\nconst float UnpackDownscale = 255. / 256.; // 0..1 -> fraction (excluding 1)\r\n\r\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\r\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\r\n\r\nconst float ShiftRight8 = 1. / 256.;\r\n\r\nvec4 packDepthToRGBA( const in float v ) {\r\n\r\n vec4 r = vec4( fract( v * PackFactors ), v );\r\n r.yzw -= r.xyz * ShiftRight8; // tidy overflow\r\n return r * PackUpscale;\r\n\r\n}\r\n\r\nfloat unpackRGBAToDepth( const in vec4 v ) {\r\n\r\n return dot( v, UnpackFactors );\r\n\r\n}",pointlight_pars_frag:"struct PointLight\r\n{\r\n vec3 position;\r\n vec4 color;\r\n float distance;\r\n float decay;\r\n\r\n int shadow;\r\n float shadowBias;\r\n float shadowRadius;\r\n vec2 shadowMapSize;\r\n\r\n float shadowCameraNear;\r\n float shadowCameraFar;\r\n};\r\nuniform PointLight u_Point[NUM_POINT_LIGHTS];",premultipliedAlpha_frag:"#ifdef USE_PREMULTIPLIED_ALPHA\r\n gl_FragColor.rgb = gl_FragColor.rgb * gl_FragColor.a;\r\n#endif",pvm_vert:"gl_Position = u_Projection * u_View * u_Model * vec4(transformed, 1.0);",dithering_frag:"#if defined( DITHERING )\r\n\r\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\r\n\r\n#endif",dithering_pars_frag:"#if defined( DITHERING )\r\n\r\n\t// based on http://loopit.dk/banding_in_games.pdf\r\n\tvec3 dithering( vec3 color ) {\r\n\t\t//Calculate grid position\r\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\r\n\r\n\t\t//Shift the individual colors differently, thus making it even harder to see the dithering pattern\r\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\r\n\r\n\t\t//modify shift acording to grid position.\r\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\r\n\r\n\t\t//shift the color by dither_shift\r\n\t\treturn color + dither_shift_RGB;\r\n\t}\r\n\r\n#endif",shadow:"\r\n#ifdef WEBGL2\r\n float computeShadow(sampler2DShadow shadowMap, vec3 shadowCoord) {\r\n return texture2D( shadowMap, shadowCoord );\r\n }\r\n#else\r\n float computeShadow(sampler2D shadowMap, vec3 shadowCoord) {\r\n return step( shadowCoord.z, unpackRGBAToDepth( texture2D( shadowMap, shadowCoord.xy ) ) );\r\n }\r\n#endif\r\n\r\nfloat computeShadowWithPoissonSampling( sampler2DShadow shadowMap, vec3 shadowCoord, float texelSize ) {\r\n vec3 poissonDisk[4];\r\n poissonDisk[0] = vec3(-0.94201624, -0.39906216, 0);\r\n poissonDisk[1] = vec3(0.94558609, -0.76890725, 0);\r\n poissonDisk[2] = vec3(-0.094184101, -0.92938870, 0);\r\n poissonDisk[3] = vec3(0.34495938, 0.29387760, 0);\r\n\r\n return computeShadow( shadowMap, shadowCoord + poissonDisk[0] * texelSize ) * 0.25 +\r\n computeShadow( shadowMap, shadowCoord + poissonDisk[1] * texelSize ) * 0.25 +\r\n computeShadow( shadowMap, shadowCoord + poissonDisk[2] * texelSize ) * 0.25 +\r\n computeShadow( shadowMap, shadowCoord + poissonDisk[3] * texelSize ) * 0.25;\r\n}\r\n\r\n// Shadow PCF kernel size 1 with a single tap (lowest quality)\r\nfloat computeShadowWithPCF1(sampler2DShadow shadowSampler, vec3 shadowCoord) {\r\n return computeShadow(shadowSampler, shadowCoord);\r\n}\r\n\r\n// Shadow PCF kernel 3*3 in only 4 taps (medium quality)\r\n// This uses a well distributed taps to allow a gaussian distribution covering a 3*3 kernel\r\n// https://mynameismjp.wordpress.com/2013/09/10/shadow-maps/\r\nfloat computeShadowWithPCF3(sampler2DShadow shadowSampler, vec3 shadowCoord, vec2 shadowMapSizeAndInverse) {\r\n vec2 uv = shadowCoord.xy * shadowMapSizeAndInverse.x;\t// uv in texel units\r\n uv += 0.5;\t\t\t\t\t\t\t\t\t\t\t// offset of half to be in the center of the texel\r\n vec2 st = fract(uv);\t\t\t\t\t\t\t\t// how far from the center\r\n vec2 base_uv = floor(uv) - 0.5;\t\t\t\t\t\t// texel coord\r\n base_uv *= shadowMapSizeAndInverse.y;\t\t\t\t// move back to uv coords\r\n\r\n // Equation resolved to fit in a 3*3 distribution like \r\n // 1 2 1\r\n // 2 4 2 \r\n // 1 2 1\r\n vec2 uvw0 = 3. - 2. * st;\r\n vec2 uvw1 = 1. + 2. * st;\r\n vec2 u = vec2((2. - st.x) / uvw0.x - 1., st.x / uvw1.x + 1.) * shadowMapSizeAndInverse.y;\r\n vec2 v = vec2((2. - st.y) / uvw0.y - 1., st.y / uvw1.y + 1.) * shadowMapSizeAndInverse.y;\r\n\r\n float shadow = 0.;\r\n shadow += uvw0.x * uvw0.y * computeShadow(shadowSampler, vec3(base_uv.xy + vec2(u[0], v[0]), shadowCoord.z));\r\n shadow += uvw1.x * uvw0.y * computeShadow(shadowSampler, vec3(base_uv.xy + vec2(u[1], v[0]), shadowCoord.z));\r\n shadow += uvw0.x * uvw1.y * computeShadow(shadowSampler, vec3(base_uv.xy + vec2(u[0], v[1]), shadowCoord.z));\r\n shadow += uvw1.x * uvw1.y * computeShadow(shadowSampler, vec3(base_uv.xy + vec2(u[1], v[1]), shadowCoord.z));\r\n shadow = shadow / 16.;\r\n\r\n return shadow;\r\n}\r\n\r\n// Shadow PCF kernel 5*5 in only 9 taps (high quality)\r\n// This uses a well distributed taps to allow a gaussian distribution covering a 5*5 kernel\r\n// https://mynameismjp.wordpress.com/2013/09/10/shadow-maps/\r\nfloat computeShadowWithPCF5(sampler2DShadow shadowSampler, vec3 shadowCoord, vec2 shadowMapSizeAndInverse) {\r\n\r\n vec2 uv = shadowCoord.xy * shadowMapSizeAndInverse.x;\t// uv in texel units\r\n uv += 0.5;\t\t\t\t\t\t\t\t\t\t\t// offset of half to be in the center of the texel\r\n vec2 st = fract(uv);\t\t\t\t\t\t\t\t// how far from the center\r\n vec2 base_uv = floor(uv) - 0.5;\t\t\t\t\t\t// texel coord\r\n base_uv *= shadowMapSizeAndInverse.y;\t\t\t\t// move back to uv coords\r\n\r\n // Equation resolved to fit in a 5*5 distribution like \r\n // 1 2 4 2 1\r\n vec2 uvw0 = 4. - 3. * st;\r\n vec2 uvw1 = vec2(7.);\r\n vec2 uvw2 = 1. + 3. * st;\r\n\r\n vec3 u = vec3((3. - 2. * st.x) / uvw0.x - 2., (3. + st.x) / uvw1.x, st.x / uvw2.x + 2.) * shadowMapSizeAndInverse.y;\r\n vec3 v = vec3((3. - 2. * st.y) / uvw0.y - 2., (3. + st.y) / uvw1.y, st.y / uvw2.y + 2.) * shadowMapSizeAndInverse.y;\r\n\r\n float shadow = 0.;\r\n shadow += uvw0.x * uvw0.y * computeShadow(shadowSampler, vec3(base_uv.xy + vec2(u[0], v[0]), shadowCoord.z));\r\n shadow += uvw1.x * uvw0.y * computeShadow(shadowSampler, vec3(base_uv.xy + vec2(u[1], v[0]), shadowCoord.z));\r\n shadow += uvw2.x * uvw0.y * computeShadow(shadowSampler, vec3(base_uv.xy + vec2(u[2], v[0]), shadowCoord.z));\r\n shadow += uvw0.x * uvw1.y * computeShadow(shadowSampler, vec3(base_uv.xy + vec2(u[0], v[1]), shadowCoord.z));\r\n shadow += uvw1.x * uvw1.y * computeShadow(shadowSampler, vec3(base_uv.xy + vec2(u[1], v[1]), shadowCoord.z));\r\n shadow += uvw2.x * uvw1.y * computeShadow(shadowSampler, vec3(base_uv.xy + vec2(u[2], v[1]), shadowCoord.z));\r\n shadow += uvw0.x * uvw2.y * computeShadow(shadowSampler, vec3(base_uv.xy + vec2(u[0], v[2]), shadowCoord.z));\r\n shadow += uvw1.x * uvw2.y * computeShadow(shadowSampler, vec3(base_uv.xy + vec2(u[1], v[2]), shadowCoord.z));\r\n shadow += uvw2.x * uvw2.y * computeShadow(shadowSampler, vec3(base_uv.xy + vec2(u[2], v[2]), shadowCoord.z));\r\n shadow = shadow / 144.;\r\n\r\n return shadow;\r\n}\r\n\r\nfloat getShadow( sampler2DShadow shadowMap, vec4 shadowCoord, float shadowBias, float shadowRadius, vec2 shadowMapSize ) {\r\n shadowCoord.xyz /= shadowCoord.w;\r\n\r\n shadowCoord.z += shadowBias;\r\n\r\n bvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\r\n bool inFrustum = all( inFrustumVec );\r\n\r\n bvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\r\n\r\n bool frustumTest = all( frustumTestVec );\r\n\r\n if ( frustumTest ) {\r\n #ifdef USE_HARD_SHADOW\r\n return computeShadow(shadowMap, shadowCoord.xyz);\r\n #else\r\n #ifdef USE_PCF3_SOFT_SHADOW\r\n vec2 shadowMapSizeAndInverse = vec2(shadowMapSize.x, 1. / shadowMapSize.x);\r\n return computeShadowWithPCF3(shadowMap, shadowCoord.xyz, shadowMapSizeAndInverse);\r\n #else\r\n #ifdef USE_PCF5_SOFT_SHADOW\r\n vec2 shadowMapSizeAndInverse = vec2(shadowMapSize.x, 1. / shadowMapSize.x);\r\n return computeShadowWithPCF5(shadowMap, shadowCoord.xyz, shadowMapSizeAndInverse);\r\n #else\r\n float texelSize = shadowRadius / shadowMapSize.x;\r\n return computeShadowWithPoissonSampling(shadowMap, shadowCoord.xyz, texelSize);\r\n #endif\r\n #endif\r\n #endif\r\n }\r\n\r\n return 1.0;\r\n\r\n}\r\n\r\nfloat textureCubeCompare( samplerCube depths, vec3 uv, float compare ) {\r\n\r\n return step( compare, unpackRGBAToDepth( textureCube( depths, uv ) ) );\r\n\r\n}\r\n\r\nfloat getPointShadow( samplerCube shadowMap, vec3 V, float shadowBias, float shadowRadius, vec2 shadowMapSize, float shadowCameraNear, float shadowCameraFar ) {\r\n\r\n // depth = normalized distance from light to fragment position\r\n float depth = ( length( V ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); // need to clamp?\r\n depth += shadowBias;\r\n\r\n #ifdef USE_HARD_SHADOW\r\n return textureCubeCompare( shadowMap, normalize(V), depth);\r\n #else\r\n float texelSize = shadowRadius / shadowMapSize.x;\r\n\r\n vec3 poissonDisk[4];\r\n poissonDisk[0] = vec3(-1.0, 1.0, -1.0);\r\n poissonDisk[1] = vec3(1.0, -1.0, -1.0);\r\n poissonDisk[2] = vec3(-1.0, -1.0, -1.0);\r\n poissonDisk[3] = vec3(1.0, -1.0, 1.0);\r\n\r\n return textureCubeCompare( shadowMap, normalize(V) + poissonDisk[0] * texelSize, depth ) * 0.25 +\r\n textureCubeCompare( shadowMap, normalize(V) + poissonDisk[1] * texelSize, depth ) * 0.25 +\r\n textureCubeCompare( shadowMap, normalize(V) + poissonDisk[2] * texelSize, depth ) * 0.25 +\r\n textureCubeCompare( shadowMap, normalize(V) + poissonDisk[3] * texelSize, depth ) * 0.25;\r\n #endif\r\n}\r\n\r\n#ifdef USE_PCSS_SOFT_SHADOW\r\n\r\n const vec3 PoissonSamplers32[64] = vec3[64](\r\n vec3(0.06407013, 0.05409927, 0.),\r\n vec3(0.7366577, 0.5789394, 0.),\r\n vec3(-0.6270542, -0.5320278, 0.),\r\n vec3(-0.4096107, 0.8411095, 0.),\r\n vec3(0.6849564, -0.4990818, 0.),\r\n vec3(-0.874181, -0.04579735, 0.),\r\n vec3(0.9989998, 0.0009880066, 0.),\r\n vec3(-0.004920578, -0.9151649, 0.),\r\n vec3(0.1805763, 0.9747483, 0.),\r\n vec3(-0.2138451, 0.2635818, 0.),\r\n vec3(0.109845, 0.3884785, 0.),\r\n vec3(0.06876755, -0.3581074, 0.),\r\n vec3(0.374073, -0.7661266, 0.),\r\n vec3(0.3079132, -0.1216763, 0.),\r\n vec3(-0.3794335, -0.8271583, 0.),\r\n vec3(-0.203878, -0.07715034, 0.),\r\n vec3(0.5912697, 0.1469799, 0.),\r\n vec3(-0.88069, 0.3031784, 0.),\r\n vec3(0.5040108, 0.8283722, 0.),\r\n vec3(-0.5844124, 0.5494877, 0.),\r\n vec3(0.6017799, -0.1726654, 0.),\r\n vec3(-0.5554981, 0.1559997, 0.),\r\n vec3(-0.3016369, -0.3900928, 0.),\r\n vec3(-0.5550632, -0.1723762, 0.),\r\n vec3(0.925029, 0.2995041, 0.),\r\n vec3(-0.2473137, 0.5538505, 0.),\r\n vec3(0.9183037, -0.2862392, 0.),\r\n vec3(0.2469421, 0.6718712, 0.),\r\n vec3(0.3916397, -0.4328209, 0.),\r\n vec3(-0.03576927, -0.6220032, 0.),\r\n vec3(-0.04661255, 0.7995201, 0.),\r\n vec3(0.4402924, 0.3640312, 0.),\r\n\r\n vec3(0., 0., 0.),\r\n vec3(0., 0., 0.),\r\n vec3(0., 0., 0.),\r\n vec3(0., 0., 0.),\r\n vec3(0., 0., 0.),\r\n vec3(0., 0., 0.),\r\n vec3(0., 0., 0.),\r\n vec3(0., 0., 0.),\r\n vec3(0., 0., 0.),\r\n vec3(0., 0., 0.),\r\n vec3(0., 0., 0.),\r\n vec3(0., 0., 0.),\r\n vec3(0., 0., 0.),\r\n vec3(0., 0., 0.),\r\n vec3(0., 0., 0.),\r\n vec3(0., 0., 0.),\r\n vec3(0., 0., 0.),\r\n vec3(0., 0., 0.),\r\n vec3(0., 0., 0.),\r\n vec3(0., 0., 0.),\r\n vec3(0., 0., 0.),\r\n vec3(0., 0., 0.),\r\n vec3(0., 0., 0.),\r\n vec3(0., 0., 0.),\r\n vec3(0., 0., 0.),\r\n vec3(0., 0., 0.),\r\n vec3(0., 0., 0.),\r\n vec3(0., 0., 0.),\r\n vec3(0., 0., 0.),\r\n vec3(0., 0., 0.),\r\n vec3(0., 0., 0.),\r\n vec3(0., 0., 0.)\r\n );\r\n\r\n const vec3 PoissonSamplers64[64] = vec3[64](\r\n vec3(-0.613392, 0.617481, 0.),\r\n vec3(0.170019, -0.040254, 0.),\r\n vec3(-0.299417, 0.791925, 0.),\r\n vec3(0.645680, 0.493210, 0.),\r\n vec3(-0.651784, 0.717887, 0.),\r\n vec3(0.421003, 0.027070, 0.),\r\n vec3(-0.817194, -0.271096, 0.),\r\n vec3(-0.705374, -0.668203, 0.),\r\n vec3(0.977050, -0.108615, 0.),\r\n vec3(0.063326, 0.142369, 0.),\r\n vec3(0.203528, 0.214331, 0.),\r\n vec3(-0.667531, 0.326090, 0.),\r\n vec3(-0.098422, -0.295755, 0.),\r\n vec3(-0.885922, 0.215369, 0.),\r\n vec3(0.566637, 0.605213, 0.),\r\n vec3(0.039766, -0.396100, 0.),\r\n vec3(0.751946, 0.453352, 0.),\r\n vec3(0.078707, -0.715323, 0.),\r\n vec3(-0.075838, -0.529344, 0.),\r\n vec3(0.724479, -0.580798, 0.),\r\n vec3(0.222999, -0.215125, 0.),\r\n vec3(-0.467574, -0.405438, 0.),\r\n vec3(-0.248268, -0.814753, 0.),\r\n vec3(0.354411, -0.887570, 0.),\r\n vec3(0.175817, 0.382366, 0.),\r\n vec3(0.487472, -0.063082, 0.),\r\n vec3(-0.084078, 0.898312, 0.),\r\n vec3(0.488876, -0.783441, 0.),\r\n vec3(0.470016, 0.217933, 0.),\r\n vec3(-0.696890, -0.549791, 0.),\r\n vec3(-0.149693, 0.605762, 0.),\r\n vec3(0.034211, 0.979980, 0.),\r\n vec3(0.503098, -0.308878, 0.),\r\n vec3(-0.016205, -0.872921, 0.),\r\n vec3(0.385784, -0.393902, 0.),\r\n vec3(-0.146886, -0.859249, 0.),\r\n vec3(0.643361, 0.164098, 0.),\r\n vec3(0.634388, -0.049471, 0.),\r\n vec3(-0.688894, 0.007843, 0.),\r\n vec3(0.464034, -0.188818, 0.),\r\n vec3(-0.440840, 0.137486, 0.),\r\n vec3(0.364483, 0.511704, 0.),\r\n vec3(0.034028, 0.325968, 0.),\r\n vec3(0.099094, -0.308023, 0.),\r\n vec3(0.693960, -0.366253, 0.),\r\n vec3(0.678884, -0.204688, 0.),\r\n vec3(0.001801, 0.780328, 0.),\r\n vec3(0.145177, -0.898984, 0.),\r\n vec3(0.062655, -0.611866, 0.),\r\n vec3(0.315226, -0.604297, 0.),\r\n vec3(-0.780145, 0.486251, 0.),\r\n vec3(-0.371868, 0.882138, 0.),\r\n vec3(0.200476, 0.494430, 0.),\r\n vec3(-0.494552, -0.711051, 0.),\r\n vec3(0.612476, 0.705252, 0.),\r\n vec3(-0.578845, -0.768792, 0.),\r\n vec3(-0.772454, -0.090976, 0.),\r\n vec3(0.504440, 0.372295, 0.),\r\n vec3(0.155736, 0.065157, 0.),\r\n vec3(0.391522, 0.849605, 0.),\r\n vec3(-0.620106, -0.328104, 0.),\r\n vec3(0.789239, -0.419965, 0.),\r\n vec3(-0.545396, 0.538133, 0.),\r\n vec3(-0.178564, -0.596057, 0.)\r\n );\r\n\r\n // https://stackoverflow.com/questions/4200224/random-noise-functions-for-glsl\r\n float getRand(vec2 seed) {\r\n return fract(sin(dot(seed.xy ,vec2(12.9898,78.233))) * 43758.5453);\r\n }\r\n\r\n // PCSS\r\n // This helps to achieve a contact hardening effect on the shadow\r\n // It uses 16 Taps for search and a 32 PCF taps in a randomly rotating poisson sampling disc.\r\n // This is heavily inspired from http://developer.download.nvidia.com/shaderlibrary/docs/shadow_PCSS.pdf\r\n // and http://developer.download.nvidia.com/whitepapers/2008/PCSS_Integration.pdf\r\n float computeShadowWithPCSS(sampler2D depthSampler, sampler2DShadow shadowSampler, vec3 shadowCoord, float shadowMapSizeInverse, float lightSizeUV, int searchTapCount, int pcfTapCount, vec3[64] poissonSamplers) {\r\n float depthMetric = shadowCoord.z;\r\n\r\n float blockerDepth = 0.0;\r\n float sumBlockerDepth = 0.0;\r\n float numBlocker = 0.0;\r\n for (int i = 0; i < searchTapCount; i ++) {\r\n blockerDepth = unpackRGBAToDepth( texture( depthSampler, shadowCoord.xy + (lightSizeUV * shadowMapSizeInverse * PoissonSamplers32[i].xy) ) );\r\n if (blockerDepth < depthMetric) {\r\n sumBlockerDepth += blockerDepth;\r\n numBlocker++;\r\n }\r\n }\r\n\r\n if (numBlocker < 1.0) {\r\n return 1.0;\r\n }\r\n float avgBlockerDepth = sumBlockerDepth / numBlocker;\r\n\r\n // Offset preventing aliasing on contact.\r\n float AAOffset = shadowMapSizeInverse * 10.;\r\n // Do not dividing by z despite being physically incorrect looks better due to the limited kernel size.\r\n // float penumbraRatio = (depthMetric - avgBlockerDepth) / avgBlockerDepth;\r\n float penumbraRatio = ((depthMetric - avgBlockerDepth) + AAOffset);\r\n float filterRadius = penumbraRatio * lightSizeUV * shadowMapSizeInverse;\r\n\r\n float random = getRand(shadowCoord.xy);//getRand(vPositionFromLight.xy);\r\n float rotationAngle = random * 3.1415926;\r\n vec2 rotationVector = vec2(cos(rotationAngle), sin(rotationAngle));\r\n\r\n float shadow = 0.;\r\n for (int i = 0; i < pcfTapCount; i++) {\r\n vec3 offset = poissonSamplers[i];\r\n // Rotated offset.\r\n offset = vec3(offset.x * rotationVector.x - offset.y * rotationVector.y, offset.y * rotationVector.x + offset.x * rotationVector.y, 0.);\r\n shadow += texture(shadowSampler, shadowCoord + offset * filterRadius);\r\n }\r\n shadow /= float(pcfTapCount);\r\n\r\n // Blocker distance falloff\r\n shadow = mix(shadow, 1., depthMetric - avgBlockerDepth);\r\n\r\n return shadow;\r\n }\r\n\r\n float getShadowWithPCSS( sampler2D depthSampler, sampler2DShadow shadowMap, vec4 shadowCoord, float shadowBias, float shadowRadius, vec2 shadowMapSize ) {\r\n\r\n shadowCoord.xyz /= shadowCoord.w;\r\n\r\n shadowCoord.z += shadowBias;\r\n\r\n bvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\r\n bool inFrustum = all( inFrustumVec );\r\n\r\n bvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\r\n\r\n bool frustumTest = all( frustumTestVec );\r\n\r\n if ( frustumTest ) {\r\n #ifdef USE_PCSS16_SOFT_SHADOW\r\n return computeShadowWithPCSS(depthSampler, shadowMap, shadowCoord.xyz, 1. / shadowMapSize.x, 0.1 * shadowMapSize.x, 16, 16, PoissonSamplers32);\r\n #else\r\n #ifdef USE_PCSS32_SOFT_SHADOW\r\n return computeShadowWithPCSS(depthSampler, shadowMap, shadowCoord.xyz, 1. / shadowMapSize.x, 0.1 * shadowMapSize.x, 16, 32, PoissonSamplers32);\r\n #else\r\n return computeShadowWithPCSS(depthSampler, shadowMap, shadowCoord.xyz, 1. / shadowMapSize.x, 0.1 * shadowMapSize.x, 32, 64, PoissonSamplers64);\r\n #endif\r\n #endif\r\n }\r\n\r\n return 1.0;\r\n\r\n }\r\n\r\n#endif",shadowMap_frag:"#ifdef USE_SHADOW\r\n // outColor *= getShadowMask();\r\n#endif",shadowMap_pars_frag:"#ifdef USE_SHADOW\r\n\r\n #if NUM_DIR_SHADOWS > 0\r\n\r\n uniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHTS ];\r\n varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\r\n\r\n #ifdef USE_PCSS_SOFT_SHADOW\r\n\r\n uniform sampler2D directionalDepthMap[ NUM_DIR_LIGHTS ];\r\n\r\n #endif\r\n\r\n #endif\r\n\r\n #if NUM_POINT_SHADOWS > 0\r\n\r\n uniform samplerCube pointShadowMap[ NUM_POINT_LIGHTS ];\r\n\r\n #endif\r\n\r\n #if NUM_SPOT_SHADOWS > 0\r\n\r\n uniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHTS ];\r\n varying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\r\n\r\n #ifdef USE_PCSS_SOFT_SHADOW\r\n\r\n uniform sampler2D spotDepthMap[ NUM_SPOT_LIGHTS ];\r\n\r\n #endif\r\n\r\n #endif\r\n\r\n #include <packing>\r\n #include <shadow>\r\n\r\n#endif",shadowMap_pars_vert:"#ifdef USE_SHADOW\r\n\r\n #if NUM_DIR_SHADOWS > 0\r\n\r\n uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHTS ];\r\n varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\r\n\r\n #endif\r\n\r\n #if NUM_POINT_SHADOWS > 0\r\n\r\n // nothing\r\n\r\n #endif\r\n\r\n #if NUM_SPOT_SHADOWS > 0\r\n\r\n uniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHTS ];\r\n varying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\r\n\r\n #endif\r\n\r\n#endif",shadowMap_vert:"#ifdef USE_SHADOW\r\n\r\n vec4 worldPosition = u_Model * vec4(transformed, 1.0);\r\n\r\n #if NUM_DIR_SHADOWS > 0\r\n\r\n #pragma unroll_loop\r\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\r\n\r\n vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\r\n\r\n }\r\n\r\n #endif\r\n\r\n #if NUM_POINT_SHADOWS > 0\r\n\r\n // nothing\r\n\r\n #endif\r\n\r\n #if NUM_SPOT_SHADOWS > 0\r\n\r\n #pragma unroll_loop\r\n for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\r\n\r\n vSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\r\n\r\n }\r\n\r\n #endif\r\n\r\n#endif",morphnormal_vert:"#ifdef USE_MORPHNORMALS\r\n\r\n\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\r\n\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\r\n\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\r\n\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\r\n\r\n#endif",morphtarget_pars_vert:"#ifdef USE_MORPHTARGETS\r\n\r\n\t#ifndef USE_MORPHNORMALS\r\n\r\n\tuniform float morphTargetInfluences[ 8 ];\r\n\r\n\t#else\r\n\r\n\tuniform float morphTargetInfluences[ 4 ];\r\n\r\n\t#endif\r\n\r\n#endif",morphtarget_vert:"#ifdef USE_MORPHTARGETS\r\n\r\n\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\r\n\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\r\n\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\r\n\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\r\n\r\n\t#ifndef USE_MORPHNORMALS\r\n\r\n transformed += morphTarget4 * morphTargetInfluences[ 4 ];\r\n transformed += morphTarget5 * morphTargetInfluences[ 5 ];\r\n transformed += morphTarget6 * morphTargetInfluences[ 6 ];\r\n transformed += morphTarget7 * morphTargetInfluences[ 7 ];\r\n\r\n\t#endif\r\n\r\n#endif",skinning_pars_vert:"#ifdef USE_SKINNING\r\n\r\n attribute vec4 skinIndex;\r\n\tattribute vec4 skinWeight;\r\n\r\n uniform mat4 bindMatrix;\r\n\tuniform mat4 bindMatrixInverse;\r\n\r\n #ifdef BONE_TEXTURE\r\n uniform sampler2D boneTexture;\r\n uniform int boneTextureSize;\r\n\r\n mat4 getBoneMatrix( const in float i ) {\r\n float j = i * 4.0;\r\n float x = mod( j, float( boneTextureSize ) );\r\n float y = floor( j / float( boneTextureSize ) );\r\n\r\n float dx = 1.0 / float( boneTextureSize );\r\n float dy = 1.0 / float( boneTextureSize );\r\n\r\n y = dy * ( y + 0.5 );\r\n\r\n vec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\r\n vec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\r\n vec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\r\n vec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\r\n\r\n mat4 bone = mat4( v1, v2, v3, v4 );\r\n\r\n return bone;\r\n }\r\n #else\r\n uniform mat4 boneMatrices[MAX_BONES];\r\n\r\n mat4 getBoneMatrix(const in float i) {\r\n mat4 bone = boneMatrices[int(i)];\r\n return bone;\r\n }\r\n #endif\r\n\r\n#endif",skinning_vert:"#ifdef USE_SKINNING\r\n\r\n mat4 boneMatX = getBoneMatrix( skinIndex.x );\r\n mat4 boneMatY = getBoneMatrix( skinIndex.y );\r\n mat4 boneMatZ = getBoneMatrix( skinIndex.z );\r\n mat4 boneMatW = getBoneMatrix( skinIndex.w );\r\n\r\n vec4 skinVertex = bindMatrix * vec4(transformed, 1.0);\r\n\r\n vec4 skinned = vec4( 0.0 );\r\n\tskinned += boneMatX * skinVertex * skinWeight.x;\r\n\tskinned += boneMatY * skinVertex * skinWeight.y;\r\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\r\n\tskinned += boneMatW * skinVertex * skinWeight.w;\r\n\tskinned = bindMatrixInverse * skinned;\r\n\r\n // override\r\n transformed = skinned.xyz / skinned.w;\r\n\r\n #if defined(USE_NORMAL) || defined(USE_ENV_MAP)\r\n mat4 skinMatrix = mat4( 0.0 );\r\n skinMatrix += skinWeight.x * boneMatX;\r\n skinMatrix += skinWeight.y * boneMatY;\r\n skinMatrix += skinWeight.z * boneMatZ;\r\n skinMatrix += skinWeight.w * boneMatW;\r\n skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\r\n\r\n // override\r\n objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\r\n #endif\r\n\r\n#endif",specularMap_frag:"float specularStrength;\r\n\r\n#ifdef USE_SPECULARMAP\r\n\r\n\tvec4 texelSpecular = texture2D( specularMap, v_Uv );\r\n\tspecularStrength = texelSpecular.r;\r\n\r\n#else\r\n\r\n\tspecularStrength = 1.0;\r\n\r\n#endif",specularMap_pars_frag:"#ifdef USE_SPECULARMAP\r\n\r\n\tuniform sampler2D specularMap;\r\n\r\n#endif",spotlight_pars_frag:"struct SpotLight\r\n{\r\n vec3 position;\r\n vec4 color;\r\n float distance;\r\n float decay;\r\n float coneCos;\r\n float penumbraCos;\r\n vec3 direction;\r\n\r\n int shadow;\r\n float shadowBias;\r\n float shadowRadius;\r\n vec2 shadowMapSize;\r\n};\r\nuniform SpotLight u_Spot[NUM_SPOT_LIGHTS];",transpose:"mat4 transposeMat4(mat4 inMatrix) {\r\n vec4 i0 = inMatrix[0];\r\n vec4 i1 = inMatrix[1];\r\n vec4 i2 = inMatrix[2];\r\n vec4 i3 = inMatrix[3];\r\n mat4 outMatrix = mat4(\r\n vec4(i0.x, i1.x, i2.x, i3.x),\r\n vec4(i0.y, i1.y, i2.y, i3.y),\r\n vec4(i0.z, i1.z, i2.z, i3.z),\r\n vec4(i0.w, i1.w, i2.w, i3.w)\r\n );\r\n return outMatrix;\r\n}",tsn:"// Per-Pixel Tangent Space Normal Mapping\r\n// http://hacksoflife.blogspot.ch/2009/11/per-pixel-tangent-space-normal-mapping.html\r\nmat3 tsn(vec3 N, vec3 V, vec2 uv) {\r\n // Workaround for Adreno/Nexus5 not able able to do dFdx( Vec3 ) ...\r\n vec3 q0 = vec3(dFdx(V.x), dFdx(V.y), dFdx(V.z));\r\n vec3 q1 = vec3(dFdy(V.x), dFdy(V.y), dFdy(V.z));\r\n vec2 st0 = dFdx( uv.st );\r\n vec2 st1 = dFdy( uv.st );\r\n\r\n float scale = sign( st1.t * st0.s - st0.t * st1.s );\r\n\r\n vec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );\r\n vec3 T = normalize( ( -q0 * st1.s + q1 * st0.s ) * scale );\r\n // vec3 N = normalize( N );\r\n\r\n mat3 tsn = mat3( S, T, N );\r\n return tsn;\r\n}",uv_pars_frag:"#if defined(USE_DIFFUSE_MAP) || defined(USE_ALPHA_MAP) || defined(USE_NORMAL_MAP) || defined(USE_BUMPMAP) || defined(USE_SPECULARMAP) || defined(USE_EMISSIVEMAP) || defined(USE_ROUGHNESSMAP) || defined(USE_METALNESSMAP) || defined(USE_GLOSSINESSMAP) || defined(USE_AOMAP)\r\n varying vec2 v_Uv;\r\n#endif\r\n\r\n#ifdef USE_UV2\r\n varying vec2 v_Uv2;\r\n#endif\r\n\r\n#ifdef USE_ALPHA_MAP_UV_TRANSFORM\r\n varying vec2 vAlphaMapUV;\r\n#endif ",uv_pars_vert:"#if defined(USE_DIFFUSE_MAP) || defined(USE_ALPHA_MAP) || defined(USE_NORMAL_MAP) || defined(USE_BUMPMAP) || defined(USE_SPECULARMAP) || defined(USE_EMISSIVEMAP) || defined(USE_ROUGHNESSMAP) || defined(USE_METALNESSMAP) || defined(USE_GLOSSINESSMAP) || defined(USE_AOMAP)\r\n attribute vec2 a_Uv;\r\n varying vec2 v_Uv;\r\n uniform mat3 uvTransform;\r\n#endif\r\n\r\n#ifdef USE_UV2\r\n attribute vec2 a_Uv2;\r\n varying vec2 v_Uv2;\r\n#endif\r\n\r\n#ifdef USE_ALPHA_MAP_UV_TRANSFORM\r\n varying vec2 vAlphaMapUV;\r\n uniform mat3 alphaMapUVTransform;\r\n#endif \r\n",uv_vert:"#if defined(USE_DIFFUSE_MAP) || defined(USE_ALPHA_MAP) || defined(USE_NORMAL_MAP) || defined(USE_BUMPMAP) || defined(USE_SPECULARMAP) || defined(USE_EMISSIVEMAP) || defined(USE_ROUGHNESSMAP) || defined(USE_METALNESSMAP) || defined(USE_GLOSSINESSMAP) || defined(USE_AOMAP)\r\n v_Uv = (uvTransform * vec3(a_Uv, 1.)).xy;\r\n#endif\r\n\r\n#ifdef USE_UV2\r\n v_Uv2 = a_Uv2;\r\n#endif\r\n\r\n#ifdef USE_ALPHA_MAP_UV_TRANSFORM\r\n #if (USE_ALPHA_MAP == 1)\r\n vAlphaMapUV = (alphaMapUVTransform * vec3(a_Uv, 1.)).xy;\r\n #elif (USE_ALPHA_MAP == 2)\r\n vAlphaMapUV = (alphaMapUVTransform * vec3(a_Uv2, 1.)).xy;\r\n #else\r\n vAlphaMapUV = (alphaMapUVTransform * vec3(a_Uv, 1.)).xy;\r\n #endif\r\n#endif ",viewModelPos_pars_frag:"#if (NUM_POINT_LIGHTS > 0) || (NUM_SPOT_LIGHTS > 0) || defined(USE_NORMAL_MAP) || defined(USE_BUMPMAP) || defined(FLAT_SHADED) || defined(USE_PHONG) || defined(USE_PBR) || (NUM_CLIPPING_PLANES > 0) \r\n varying vec3 v_modelPos;\r\n#endif",viewModelPos_pars_vert:"#if (NUM_POINT_LIGHTS > 0) || (NUM_SPOT_LIGHTS > 0) || defined(USE_NORMAL_MAP) || defined(USE_BUMPMAP) || defined(FLAT_SHADED) || defined(USE_PHONG) || defined(USE_PBR)|| (NUM_CLIPPING_PLANES > 0)\r\n varying vec3 v_modelPos;\r\n#endif",viewModelPos_vert:"#if (NUM_POINT_LIGHTS > 0) || (NUM_SPOT_LIGHTS > 0) || defined(USE_NORMAL_MAP) || defined(USE_BUMPMAP) || defined(FLAT_SHADED) || defined(USE_PHONG) || defined(USE_PBR) || (NUM_CLIPPING_PLANES > 0)\r\n v_modelPos = (u_Model * vec4(transformed, 1.0)).xyz;\r\n#endif"},Mr="#define USE_PBR\r\n\r\n#include <common_vert>\r\n#include <normal_pars_vert>\r\n#include <uv_pars_vert>\r\n#include <color_pars_vert>\r\n#include <viewModelPos_pars_vert>\r\n#include <envMap_pars_vert>\r\n#include <shadowMap_pars_vert>\r\n#include <morphtarget_pars_vert>\r\n#include <skinning_pars_vert>\r\nvoid main() {\r\n #include <begin_vert>\r\n #include <morphtarget_vert>\r\n #include <morphnormal_vert>\r\n #include <skinning_vert>\r\n #include <pvm_vert>\r\n #include <normal_vert>\r\n #include <uv_vert>\r\n #include <color_vert>\r\n #include <viewModelPos_vert>\r\n #include <envMap_vert>\r\n #include <shadowMap_vert>\r\n}",Er={basic_frag:"#include <common_frag>\r\n#include <uv_pars_frag>\r\n#include <color_pars_frag>\r\n#include <diffuseMap_pars_frag>\r\n#include <alphamap_pars_frag>\r\n#include <envMap_pars_frag>\r\n#include <aoMap_pars_frag>\r\n#include <fog_pars_frag>\r\nvoid main() {\r\n #include <begin_frag>\r\n #include <color_frag>\r\n #include <diffuseMap_frag>\r\n #include <alphamap_frag>\r\n #include <alphaTest_frag>\r\n #include <envMap_frag>\r\n #include <end_frag>\r\n #include <encodings_frag>\r\n #include <premultipliedAlpha_frag>\r\n #include <fog_frag>\r\n}",basic_vert:"#include <common_vert>\r\n#include <uv_pars_vert>\r\n#include <color_pars_vert>\r\n#include <envMap_pars_vert>\r\n#include <morphtarget_pars_vert>\r\n#include <skinning_pars_vert>\r\nvoid main() {\r\n #include <begin_vert>\r\n #include <morphtarget_vert>\r\n #include <skinning_vert>\r\n #include <pvm_vert>\r\n #include <uv_vert>\r\n #include <color_vert>\r\n #include <envMap_vert>\r\n}",canvas2d_frag:"#include <common_frag>\r\nvarying vec2 v_Uv;\r\nuniform sampler2D spriteTexture;\r\nvoid main() {\r\n #include <begin_frag>\r\n outColor *= texture2D(spriteTexture, v_Uv);\r\n #include <end_frag>\r\n #include <premultipliedAlpha_frag>\r\n}",canvas2d_vert:"#include <common_vert>\r\nattribute vec2 a_Uv;\r\nvarying vec2 v_Uv;\r\nvoid main() {\r\n #include <begin_vert>\r\n #include <pvm_vert>\r\n v_Uv = a_Uv;\r\n}",depth_frag:"#include <common_frag>\r\n#include <diffuseMap_pars_frag>\r\n\r\n#include <uv_pars_frag>\r\n\r\n#include <packing>\r\n\r\nvoid main() {\r\n #if defined(USE_DIFFUSE_MAP) && defined(ALPHATEST)\r\n vec4 texelColor = texture2D( diffuseMap, v_Uv );\r\n\r\n float alpha = texelColor.a * u_Opacity;\r\n if(alpha < ALPHATEST) discard;\r\n #endif\r\n \r\n #ifdef DEPTH_PACKING_RGBA\r\n gl_FragColor = packDepthToRGBA(gl_FragCoord.z);\r\n #else\r\n gl_FragColor = vec4( vec3( 1.0 - gl_FragCoord.z ), u_Opacity );\r\n #endif\r\n}",depth_vert:"#include <common_vert>\r\n#include <morphtarget_pars_vert>\r\n#include <skinning_pars_vert>\r\n#include <uv_pars_vert>\r\nvoid main() {\r\n #include <uv_vert>\r\n #include <begin_vert>\r\n #include <morphtarget_vert>\r\n #include <skinning_vert>\r\n #include <pvm_vert>\r\n}",distance_frag:"#include <common_frag>\r\nuniform float nearDistance;\r\nuniform float farDistance;\r\nvarying vec3 v_ModelPos;\r\n#include <packing>\r\nvoid main() {\r\n float dist = length( v_ModelPos - u_CameraPosition );\r\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\r\n\tdist = saturate( dist ); // clamp to [ 0, 1 ]\r\n\r\n gl_FragColor = packDepthToRGBA(dist);\r\n}",distance_vert:"#include <common_vert>\r\nvarying vec3 v_ModelPos;\r\n#include <morphtarget_pars_vert>\r\n#include <skinning_pars_vert>\r\nvoid main() {\r\n #include <begin_vert>\r\n #include <morphtarget_vert>\r\n #include <skinning_vert>\r\n #include <pvm_vert>\r\n v_ModelPos = (u_Model * vec4(transformed, 1.0)).xyz;\r\n}",lambert_frag:"#define USE_LAMBERT\r\n\r\n#include <common_frag>\r\n#include <dithering_pars_frag>\r\n\r\nuniform vec3 emissive;\r\n\r\n#include <uv_pars_frag>\r\n#include <color_pars_frag>\r\n#include <diffuseMap_pars_frag>\r\n#include <normalMap_pars_frag>\r\n#include <alphamap_pars_frag>\r\n#include <bumpMap_pars_frag>\r\n#include <light_pars_frag>\r\n#include <normal_pars_frag>\r\n#include <viewModelPos_pars_frag>\r\n#include <bsdfs>\r\n#include <envMap_pars_frag>\r\n#include <aoMap_pars_frag>\r\n#include <shadowMap_pars_frag>\r\n#include <fog_pars_frag>\r\n#include <emissiveMap_pars_frag>\r\n#include <clippingPlanes_pars_frag>\r\nvoid main() {\r\n #include <clippingPlanes_frag>\r\n #include <begin_frag>\r\n #include <color_frag>\r\n #include <diffuseMap_frag>\r\n #include <alphamap_frag>\r\n #include <alphaTest_frag>\r\n #include <normal_frag>\r\n #include <light_frag>\r\n #include <envMap_frag>\r\n #include <shadowMap_frag>\r\n\r\n vec3 totalEmissiveRadiance = emissive;\r\n #include <emissiveMap_frag>\r\n outColor += vec4(totalEmissiveRadiance.rgb, 0.0);\r\n\r\n #include <end_frag>\r\n #include <encodings_frag>\r\n #include <premultipliedAlpha_frag>\r\n #include <fog_frag>\r\n #include <dithering_frag>\r\n}",lambert_vert:"#define USE_LAMBERT\r\n\r\n#include <common_vert>\r\n#include <normal_pars_vert>\r\n#include <uv_pars_vert>\r\n#include <color_pars_vert>\r\n#include <viewModelPos_pars_vert>\r\n#include <envMap_pars_vert>\r\n#include <shadowMap_pars_vert>\r\n#include <morphtarget_pars_vert>\r\n#include <skinning_pars_vert>\r\nvoid main() {\r\n #include <begin_vert>\r\n #include <morphtarget_vert>\r\n #include <morphnormal_vert>\r\n #include <skinning_vert>\r\n #include <pvm_vert>\r\n #include <normal_vert>\r\n #include <uv_vert>\r\n #include <color_vert>\r\n #include <viewModelPos_vert>\r\n #include <envMap_vert>\r\n #include <shadowMap_vert>\r\n}",normaldepth_frag:"#include <common_frag>\r\n#include <diffuseMap_pars_frag>\r\n\r\n#include <uv_pars_frag>\r\n\r\n#define USE_NORMAL\r\n\r\n#include <packing>\r\n#include <normal_pars_frag>\r\n\r\nvoid main() {\r\n #if defined(USE_DIFFUSE_MAP) && defined(ALPHATEST)\r\n vec4 texelColor = texture2D( diffuseMap, v_Uv );\r\n\r\n float alpha = texelColor.a * u_Opacity;\r\n if(alpha < ALPHATEST) discard;\r\n #endif\r\n vec4 packedNormalDepth;\r\n packedNormalDepth.xyz = normalize(v_Normal) * 0.5 + 0.5;\r\n packedNormalDepth.w = gl_FragCoord.z;\r\n gl_FragColor = packedNormalDepth;\r\n}",normaldepth_vert:"#include <common_vert>\r\n\r\n#define USE_NORMAL\r\n\r\n#include <morphtarget_pars_vert>\r\n#include <skinning_pars_vert>\r\n#include <normal_pars_vert>\r\n#include <uv_pars_vert>\r\nvoid main() {\r\n #include <uv_vert>\r\n #include <begin_vert>\r\n #include <morphtarget_vert>\r\n #include <morphnormal_vert>\r\n #include <skinning_vert>\r\n #include <normal_vert>\r\n #include <pvm_vert>\r\n}",pbr_frag:"#define USE_PBR\r\n\r\n#include <common_frag>\r\n#include <dithering_pars_frag>\r\n\r\n// if no light> this will not active\r\nuniform float u_Metalness;\r\n#ifdef USE_METALNESSMAP\r\n\tuniform sampler2D metalnessMap;\r\n#endif\r\n\r\nuniform float u_Roughness;\r\n#ifdef USE_ROUGHNESSMAP\r\n\tuniform sampler2D roughnessMap;\r\n#endif\r\n\r\nuniform vec3 emissive;\r\n\r\n#include <uv_pars_frag>\r\n#include <color_pars_frag>\r\n#include <diffuseMap_pars_frag>\r\n#include <alphamap_pars_frag>\r\n#include <normalMap_pars_frag>\r\n#include <bumpMap_pars_frag>\r\n#include <envMap_pars_frag>\r\n#include <aoMap_pars_frag>\r\n#include <light_pars_frag>\r\n#include <normal_pars_frag>\r\n#include <viewModelPos_pars_frag>\r\n#include <bsdfs>\r\n#include <shadowMap_pars_frag>\r\n#include <fog_pars_frag>\r\n#include <emissiveMap_pars_frag>\r\n#include <clippingPlanes_pars_frag>\r\nvoid main() {\r\n #include <clippingPlanes_frag>\r\n #include <begin_frag>\r\n #include <color_frag>\r\n #include <diffuseMap_frag>\r\n #include <alphamap_frag>\r\n #include <alphaTest_frag>\r\n #include <normal_frag>\r\n\r\n float roughnessFactor = u_Roughness;\r\n #ifdef USE_ROUGHNESSMAP\r\n \tvec4 texelRoughness = texture2D( roughnessMap, v_Uv );\r\n \t// reads channel G, compatible with a combined OcclusionRoughnessMetallic (RGB) texture\r\n \troughnessFactor *= texelRoughness.g;\r\n #endif\r\n\r\n float metalnessFactor = u_Metalness;\r\n #ifdef USE_METALNESSMAP\r\n \tvec4 texelMetalness = texture2D( metalnessMap, v_Uv );\r\n \t// reads channel B, compatible with a combined OcclusionRoughnessMetallic (RGB) texture\r\n \tmetalnessFactor *= texelMetalness.b;\r\n #endif\r\n\r\n #include <light_frag>\r\n #include <shadowMap_frag>\r\n\r\n vec3 totalEmissiveRadiance = emissive;\r\n #include <emissiveMap_frag>\r\n outColor += vec4(totalEmissiveRadiance.rgb, 0.0);\r\n\r\n #include <end_frag>\r\n #include <encodings_frag>\r\n #include <premultipliedAlpha_frag>\r\n #include <fog_frag>\r\n #include <dithering_frag>\r\n}",pbr_vert:Mr,pbr2_frag:"#define USE_PBR\r\n#define USE_PBR2\r\n\r\n#include <common_frag>\r\n#include <dithering_pars_frag>\r\n\r\n// if no light> this will not active\r\nuniform vec3 u_SpecularColor;\r\n#ifdef USE_SPECULARMAP\r\n\tuniform sampler2D specularMap;\r\n#endif\r\n\r\nuniform float glossiness;\r\n#ifdef USE_GLOSSINESSMAP\r\n\tuniform sampler2D glossinessMap;\r\n#endif\r\n\r\nuniform vec3 emissive;\r\n\r\n#include <uv_pars_frag>\r\n#include <color_pars_frag>\r\n#include <diffuseMap_pars_frag>\r\n#include <alphamap_pars_frag>\r\n#include <normalMap_pars_frag>\r\n#include <bumpMap_pars_frag>\r\n#include <envMap_pars_frag>\r\n#include <aoMap_pars_frag>\r\n#include <light_pars_frag>\r\n#include <normal_pars_frag>\r\n#include <viewModelPos_pars_frag>\r\n#include <bsdfs>\r\n#include <shadowMap_pars_frag>\r\n#include <fog_pars_frag>\r\n#include <emissiveMap_pars_frag>\r\n#include <clippingPlanes_pars_frag>\r\nvoid main() {\r\n #include <clippingPlanes_frag>\r\n #include <begin_frag>\r\n #include <color_frag>\r\n #include <diffuseMap_frag>\r\n #include <alphamap_frag>\r\n #include <alphaTest_frag>\r\n #include <normal_frag>\r\n\r\n vec3 specularFactor = u_SpecularColor;\r\n #ifdef USE_SPECULARMAP\r\n vec4 texelSpecular = texture2D(specularMap, v_Uv);\r\n texelSpecular = sRGBToLinear(texelSpecular);\r\n // reads channel RGB, compatible with a glTF Specular-Glossiness (RGBA) texture\r\n specularFactor *= texelSpecular.rgb;\r\n #endif\r\n\r\n float glossinessFactor = glossiness;\r\n #ifdef USE_GLOSSINESSMAP\r\n vec4 texelGlossiness = texture2D(glossinessMap, v_Uv);\r\n // reads channel A, compatible with a glTF Specular-Glossiness (RGBA) texture\r\n glossinessFactor *= texelGlossiness.a;\r\n #endif\r\n\r\n #include <light_frag>\r\n #include <shadowMap_frag>\r\n\r\n vec3 totalEmissiveRadiance = emissive;\r\n #include <emissiveMap_frag>\r\n outColor += vec4(totalEmissiveRadiance.rgb, 0.0);\r\n\r\n #include <end_frag>\r\n #include <encodings_frag>\r\n #include <premultipliedAlpha_frag>\r\n #include <fog_frag>\r\n #include <dithering_frag>\r\n}",pbr2_vert:Mr,phong_frag:"#define USE_PHONG\r\n\r\n#include <common_frag>\r\n#include <dithering_pars_frag>\r\n\r\n// if no light> this will not active\r\nuniform float u_Specular;\r\nuniform vec3 u_SpecularColor;\r\n#include <specularMap_pars_frag>\r\n\r\nuniform vec3 emissive;\r\n\r\n#include <uv_pars_frag>\r\n#include <color_pars_frag>\r\n#include <diffuseMap_pars_frag>\r\n#include <alphamap_pars_frag>\r\n#include <normalMap_pars_frag>\r\n#include <bumpMap_pars_frag>\r\n#include <light_pars_frag>\r\n#include <normal_pars_frag>\r\n#include <viewModelPos_pars_frag>\r\n#include <bsdfs>\r\n#include <envMap_pars_frag>\r\n#include <aoMap_pars_frag>\r\n#include <shadowMap_pars_frag>\r\n#include <fog_pars_frag>\r\n#include <emissiveMap_pars_frag>\r\n#include <clippingPlanes_pars_frag>\r\nvoid main() {\r\n #include <clippingPlanes_frag>\r\n #include <begin_frag>\r\n #include <color_frag>\r\n #include <diffuseMap_frag>\r\n #include <alphamap_frag>\r\n #include <alphaTest_frag>\r\n #include <normal_frag>\r\n #include <specularMap_frag>\r\n #include <light_frag>\r\n #include <envMap_frag>\r\n #include <shadowMap_frag>\r\n\r\n vec3 totalEmissiveRadiance = emissive;\r\n #include <emissiveMap_frag>\r\n outColor += vec4(totalEmissiveRadiance.rgb, 0.0);\r\n\r\n #include <end_frag>\r\n #include <encodings_frag>\r\n #include <premultipliedAlpha_frag>\r\n #include <fog_frag>\r\n #include <dithering_frag>\r\n}",phong_vert:"#define USE_PHONG\r\n\r\n#include <common_vert>\r\n#include <normal_pars_vert>\r\n#include <uv_pars_vert>\r\n#include <color_pars_vert>\r\n#include <viewModelPos_pars_vert>\r\n#include <envMap_pars_vert>\r\n#include <shadowMap_pars_vert>\r\n#include <morphtarget_pars_vert>\r\n#include <skinning_pars_vert>\r\nvoid main() {\r\n #include <begin_vert>\r\n #include <morphtarget_vert>\r\n #include <morphnormal_vert>\r\n #include <skinning_vert>\r\n #include <pvm_vert>\r\n #include <normal_vert>\r\n #include <uv_vert>\r\n #include <color_vert>\r\n #include <viewModelPos_vert>\r\n #include <envMap_vert>\r\n #include <shadowMap_vert>\r\n}",point_frag:"#include <common_frag>\r\n#include <diffuseMap_pars_frag>\r\n#include <fog_pars_frag>\r\nvoid main() {\r\n #include <begin_frag>\r\n #ifdef USE_DIFFUSE_MAP\r\n outColor *= texture2D(diffuseMap, vec2(gl_PointCoord.x, 1.0 - gl_PointCoord.y));\r\n #endif\r\n #include <end_frag>\r\n #include <encodings_frag>\r\n #include <premultipliedAlpha_frag>\r\n #include <fog_frag>\r\n}",point_vert:"#include <common_vert>\r\nuniform float u_PointSize;\r\nuniform float u_PointScale;\r\nvoid main() {\r\n #include <begin_vert>\r\n #include <pvm_vert>\r\n vec4 mvPosition = u_View * u_Model * vec4(transformed, 1.0);\r\n #ifdef USE_SIZEATTENUATION\r\n gl_PointSize = u_PointSize * ( u_PointScale / - mvPosition.z );\r\n #else\r\n gl_PointSize = u_PointSize;\r\n #endif\r\n}"};function Sr(e){var t;return e?e.encoding&&(t=e.encoding):t=ae.LINEAR,t}function xr(e){switch(e){case ae.LINEAR:return["Linear","( value )"];case ae.SRGB:return["sRGB","( value )"];case ae.RGBE:return["RGBE","( value )"];case ae.RGBM7:return["RGBM","( value, 7.0 )"];case ae.RGBM16:return["RGBM","( value, 16.0 )"];case ae.RGBD:return["RGBD","( value, 256.0 )"];case ae.GAMMA:return["Gamma","( value, float( GAMMA_FACTOR ) )"];default:console.error("unsupported encoding: "+e)}}function yr(e,t){var r=xr(t);return"vec4 "+e+"( vec4 value ) { return "+r[0]+"ToLinear"+r[1]+"; }"}function wr(e,t,r){var n,i,a,s=["precision "+t.precision+" float;","precision "+t.precision+" int;","precision "+t.precision+" sampler2D;","#define SHADER_NAME "+t.materialType,r,2<=t.version?"#define WEBGL2":"",t.useRoughnessMap?"#define USE_ROUGHNESSMAP":"",t.useMetalnessMap?"#define USE_METALNESSMAP":"",t.useGlossinessMap?"#define USE_GLOSSINESSMAP":"",0<t.ambientLightNum?"#define USE_AMBIENT_LIGHT "+t.ambientLightNum:"",0<t.pointLightNum||0<t.directLightNum||0<t.ambientLightNum||0<t.spotLightNum?"#define USE_LIGHT":"",0<t.pointLightNum||0<t.directLightNum||0<t.spotLightNum?"#define USE_NORMAL":"",(0<t.pointLightNum||0<t.directLightNum||0<t.spotLightNum)&&t.useNormalMap?"#define USE_NORMAL_MAP":"",(0<t.pointLightNum||0<t.directLightNum||0<t.spotLightNum)&&t.useBumpMap?"#define USE_BUMPMAP":"",(0<t.pointLightNum||0<t.directLightNum||0<t.spotLightNum)&&t.useSpecularMap?"#define USE_SPECULARMAP":"",t.useEmissiveMap?"#define USE_EMISSIVEMAP "+t.useEmissiveMap:"",t.useShadow?"#define USE_SHADOW":"",t.flatShading?"#define FLAT_SHADED":"",t.flipSided?"#define FLIP_SIDED":"",t.useDiffuseMap?"#define USE_DIFFUSE_MAP "+t.useDiffuseMap:"",t.useAlphaMap?"#define USE_ALPHA_MAP "+t.useAlphaMap:"",t.useAlphaMapUVTransform?"#define USE_ALPHA_MAP_UV_TRANSFORM":"",t.useEnvMap?"#define USE_ENV_MAP":"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.useAOMap?"#define USE_AOMAP "+t.useAOMap:"",t.useVertexColors==he.RGB?"#define USE_VCOLOR_RGB":"",t.useVertexColors==he.RGBA?"#define USE_VCOLOR_RGBA":"",t.useVertexTangents?"#define USE_TANGENT":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&!1===t.flatShading?"#define USE_MORPHNORMALS":"",t.useSkinning?"#define USE_SKINNING":"",0<t.bonesNum?"#define MAX_BONES "+t.bonesNum:"",t.useVertexTexture?"#define BONE_TEXTURE":""].filter(br).join("\n"),o=[t.useStandardDerivatives&&t.version<2?"#extension GL_OES_standard_derivatives : enable":"",t.useShaderTextureLOD&&t.version<2?"#extension GL_EXT_shader_texture_lod : enable":"","precision "+t.precision+" float;","precision "+t.precision+" int;","precision "+t.precision+" sampler2D;",2<=t.version?"precision "+t.precision+" sampler2DShadow;":"",2<=t.version?"precision "+t.precision+" samplerCubeShadow;":"","#define SHADER_NAME "+t.materialType,"#define PI 3.14159265359","#define EPSILON 1e-6","float pow2( const in float x ) { return x*x; }","#define LOG2 1.442695","#define RECIPROCAL_PI 0.31830988618","#define saturate(a) clamp( a, 0.0, 1.0 )","#define whiteCompliment(a) ( 1.0 - saturate( a ) )","highp float rand( const in vec2 uv ) {","const highp float a = 12.9898, b = 78.233, c = 43758.5453;","highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );","return fract(sin(sn) * c);","}",r,2<=t.version?"#define WEBGL2":"",t.version<2?"#define sampler2DShadow sampler2D":"",t.useRoughnessMap?"#define USE_ROUGHNESSMAP":"",t.useMetalnessMap?"#define USE_METALNESSMAP":"",t.useGlossinessMap?"#define USE_GLOSSINESSMAP":"",0<t.ambientLightNum?"#define USE_AMBIENT_LIGHT "+t.ambientLightNum:"",0<t.pointLightNum||0<t.directLightNum||0<t.ambientLightNum||0<t.spotLightNum?"#define USE_LIGHT":"",0<t.pointLightNum||0<t.directLightNum||0<t.spotLightNum?"#define USE_NORMAL":"",(0<t.pointLightNum||0<t.directLightNum||0<t.spotLightNum)&&t.useNormalMap?"#define USE_NORMAL_MAP":"",(0<t.pointLightNum||0<t.directLightNum||0<t.spotLightNum)&&t.useBumpMap?"#define USE_BUMPMAP":"",(0<t.pointLightNum||0<t.directLightNum||0<t.spotLightNum)&&t.useSpecularMap?"#define USE_SPECULARMAP":"",t.useEmissiveMap?"#define USE_EMISSIVEMAP "+t.useEmissiveMap:"",t.useShadow?"#define USE_SHADOW":"",t.shadowType===ie.HARD?"#define USE_HARD_SHADOW":"",t.shadowType===ie.POISSON_SOFT?"#define USE_POISSON_SOFT_SHADOW":"",t.shadowType===ie.PCF3_SOFT?"#define USE_PCF3_SOFT_SHADOW":"",t.shadowType===ie.PCF5_SOFT?"#define USE_PCF5_SOFT_SHADOW":"",t.shadowType===ie.PCSS16_SOFT?"#define USE_PCSS16_SOFT_SHADOW":"",t.shadowType===ie.PCSS32_SOFT?"#define USE_PCSS32_SOFT_SHADOW":"",t.shadowType===ie.PCSS64_SOFT?"#define USE_PCSS64_SOFT_SHADOW":"",t.shadowType===ie.PCSS16_SOFT||t.shadowType===ie.PCSS32_SOFT||t.shadowType===ie.PCSS64_SOFT?"#define USE_PCSS_SOFT_SHADOW":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.useShaderTextureLOD?"#define TEXTURE_LOD_EXT":"",t.useDiffuseMap?"#define USE_DIFFUSE_MAP "+t.useDiffuseMap:"",t.useAlphaMap?"#define USE_ALPHA_MAP "+t.useAlphaMap:"",t.useAlphaMapUVTransform?"#define USE_ALPHA_MAP_UV_TRANSFORM":"",t.useEnvMap?"#define USE_ENV_MAP":"",t.useAOMap?"#define USE_AOMAP "+t.useAOMap:"",t.useVertexColors==he.RGB?"#define USE_VCOLOR_RGB":"",t.useVertexColors==he.RGBA?"#define USE_VCOLOR_RGBA":"",t.useVertexTangents?"#define USE_TANGENT":"",t.premultipliedAlpha?"#define USE_PREMULTIPLIED_ALPHA":"",t.fog?"#define USE_FOG":"",t.fogExp2?"#define USE_EXP2_FOG":"",t.alphaTest?"#define ALPHATEST "+t.alphaTest:"",t.useEnvMap?"#define "+t.envMapCombine:"","#define GAMMA_FACTOR "+t.gammaFactor,t.dithering?"#define DITHERING":"",t.diffuseMapEncoding||t.envMapEncoding||t.emissiveMapEncoding||t.outputEncoding?gr.encodings_pars_frag:"",t.diffuseMapEncoding?yr("mapTexelToLinear",t.diffuseMapEncoding):"",t.envMapEncoding?yr("envMapTexelToLinear",t.envMapEncoding):"",t.emissiveMapEncoding?yr("emissiveMapTexelToLinear",t.emissiveMapEncoding):"",t.outputEncoding?(n="linearToOutputTexel",i=t.outputEncoding,a=xr(i),"vec4 "+n+"( vec4 value ) { return LinearTo"+a[0]+a[1]+"; }"):"",t.packDepthToRGBA?"#define DEPTH_PACKING_RGBA":""].filter(br).join("\n"),h=Er[t.materialType+"_vert"]||t.vertexShader||Er.basic_vert,c=Er[t.materialType+"_frag"]||t.fragmentShader||Er.basic_frag,u=[s,h].join("\n"),l=[o,c].join("\n");if(u=Tr(u),l=Tr(l),u=Ar(u,t),l=Ar(l,t),u=Nr(u,t),l=Nr(l,t),u=Pr(u),l=Pr(l),1<t.version){l=l.replace("#extension GL_EXT_draw_buffers : require","");for(var d=0,p=[];-1<l.indexOf("gl_FragData["+d+"]");)l=l.replace("gl_FragData["+d+"]","pc_fragData"+d),p.push("layout(location = "+d+") out vec4 pc_fragData"+d+";"),d++;l=l.replace("#define whiteCompliment(a) ( 1.0 - saturate( a ) )","#define whiteCompliment(a) ( 1.0 - saturate( a ) )\n"+p.join("\n")+"\n"),u=["#version 300 es\n","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+u,l=["#version 300 es\n","#define varying in",-1<l.indexOf("layout")?"":"out highp vec4 pc_fragColor;","#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+l}return new vr(e,u,l)}var Tr=function(e){return e.replace(/#include +<([\w\d.]+)>/g,function(e,t){var r=gr[t];if(void 0===r)throw new Error("Can not resolve #include <"+t+">");return Tr(r)})};function br(e){return""!==e}function Ar(e,t){return e.replace(/NUM_DIR_LIGHTS/g,t.directLightNum).replace(/NUM_SPOT_LIGHTS/g,t.spotLightNum).replace(/NUM_POINT_LIGHTS/g,t.pointLightNum).replace(/NUM_DIR_SHADOWS/g,t.directShadowNum).replace(/NUM_SPOT_SHADOWS/g,t.spotShadowNum).replace(/NUM_POINT_SHADOWS/g,t.pointShadowNum)}function Nr(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes)}function Pr(e){return e.replace(/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,function(e,t,r,n){for(var i="",a=parseInt(t);a<parseInt(r);a++)i+=n.replace(/\[ i \]/g,"[ "+a+" ]");return i})}function Lr(f,_,m){var v=[];this.getProgram=function(e,t,r,n){t=t||r.material;for(var i,a=n&&t.acceptLight?n.lights:null,s=n?n.fog:null,o=n?n.clippingPlanes:null,h=function(e,t,r,n,i,a,s,o){var h={};h.materialType=n.type,t=t,h.version=t.version,h.precision=n.precision||t.maxPrecision,h.useStandardDerivatives=2<=t.version||!!t.getExtension("OES_standard_derivatives")||!!t.getExtension("GL_OES_standard_derivatives"),h.useShaderTextureLOD=2<=t.version||!!t.getExtension("EXT_shader_texture_lod"),h.useDiffuseMap=n.diffuseMap?n.diffuseMapCoord+1:0,h.useAlphaMap=n.alphaMap?n.alphaMapCoord+1:0,h.useAlphaMapUVTransform=!!n.alphaMap&&n.alphaMap.useUVTransform,h.useNormalMap=!!n.normalMap,h.useBumpMap=!!n.bumpMap,h.useSpecularMap=!!n.specularMap,h.useEnvMap=!!n.envMap,h.envMapCombine=n.envMapCombine,h.useEmissiveMap=n.emissiveMap?n.emissiveMapCoord+1:0,h.useRoughnessMap=!!n.roughnessMap,h.useMetalnessMap=!!n.metalnessMap,h.useGlossinessMap=!!n.glossinessMap,h.useAOMap=n.aoMap?n.aoMapCoord+1:0,h.ambientLightNum=a?a.ambientsNum:0,h.directLightNum=a?a.directsNum:0,h.pointLightNum=a?a.pointsNum:0,h.spotLightNum=a?a.spotsNum:0,h.directShadowNum=i.receiveShadow&&a?a.directShadowNum:0,h.pointShadowNum=i.receiveShadow&&a?a.pointShadowNum:0,h.spotShadowNum=i.receiveShadow&&a?a.spotShadowNum:0,h.useShadow=i.receiveShadow&&!!a&&0<a.shadowsNum,-1<i.shadowType.indexOf("pcss")&&t.version<2?(console.warn("WebGL 1.0 not support PCSS soft shadow, fallback to POISSON_SOFT"),h.shadowType=ie.POISSON_SOFT):h.shadowType=i.shadowType,h.dithering=n.dithering;var c=e.currentRenderTarget;h.gammaFactor=r.gammaFactor,h.outputEncoding=c.texture?Sr(c.texture):r.outputEncoding,h.diffuseMapEncoding=Sr(n.diffuseMap||n.cubeMap),h.envMapEncoding=Sr(n.envMap),h.emissiveMapEncoding=Sr(n.emissiveMap),h.alphaTest=n.alphaTest,h.premultipliedAlpha=n.premultipliedAlpha,h.useVertexColors=n.vertexColors,h.useVertexTangents=!!n.normalMap&&n.vertexTangents,h.numClippingPlanes=o?o.length:0,h.flatShading=n.shading===Z.FLAT_SHADING,h.fog=!!s,h.fogExp2=!!s&&s.fogType===k.EXP2,h.sizeAttenuation=n.sizeAttenuation,h.doubleSided=n.side===q.DOUBLE,h.flipSided=n.side===q.BACK,h.packDepthToRGBA=n.packToRGBA,h.morphTargets=!!i.morphTargetInfluences,h.morphNormals=!!i.morphTargetInfluences&&i.geometry.morphAttributes.normal;var u=i.type===V.SKINNED_MESH&&i.skeleton,l=t.maxVertexUniformVectors,d=0<t.maxVertexTextures&&(!!t.getExtension("OES_texture_float")||2<=t.version),p=0;return d?p=1024:l<16*(p=i.skeleton?i.skeleton.bones.length:0)&&(console.warn("Program: too many bones ("+p+"), current cpu only support "+Math.floor(l/16)+" bones!!"),p=Math.floor(l/16)),h.useSkinning=u,h.bonesNum=p,h.useVertexTexture=d,n.type===H.SHADER&&(h.vertexShader=n.vertexShader,h.fragmentShader=n.fragmentShader),h}(_,m,e,t,r,a,s,o),c=function(e,t){var r="";for(var n in e)r+=e[n]+"_";if(void 0!==t.defines)for(var i in t.defines)r+=i+"_"+t.defines[i]+"_";return r}(h,t),u=0,l=v.length;u<l;u++){var d=v[u];if(d.code===c){++(i=d).usedTimes;break}}if(void 0===i){var p="";void 0!==t.defines&&(p=function(e){var t=[];for(var r in e){var n=e[r];!1!==n&&t.push("#define "+r+" "+n)}return t.join("\n")}(t.defines)),(i=wr(f,h,p)).code=c,v.push(i)}return i},this.releaseProgram=function(e){if(0==--e.usedTimes){var t=v.indexOf(e);v[t]=v[v.length-1],v.pop(),e.dispose(f)}},this.programs=v}function Rr(e,t,r){this.gl=e,this.properties=t,this.capabilities=r}function Cr(e,t,r,n,i,a){this.gl=e,this.state=t,this.texture=r,this.renderBuffer=n,this.properties=i,this.capabilities=a}Object.assign(Rr.prototype,{setRenderBuffer:function(e){var t=this.gl,r=this.capabilities,n=this.properties.get(e);return void 0===n.__webglRenderbuffer?(e.addEventListener("dispose",this.onRenderBufferDispose,this),n.__webglRenderbuffer=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,n.__webglRenderbuffer),0<e.multipleSampling?(r.version<2&&console.error("render buffer multipleSampling is not support in webgl 1.0."),t.renderbufferStorageMultisample(t.RENDERBUFFER,Math.min(e.multipleSampling,r.maxSamples),e.format,e.width,e.height)):t.renderbufferStorage(t.RENDERBUFFER,e.format,e.width,e.height)):t.bindRenderbuffer(t.RENDERBUFFER,n.__webglRenderbuffer),n},onRenderBufferDispose:function(e){var t=this.gl,r=e.target,n=this.properties.get(r);n.__webglRenderbuffer&&t.deleteRenderbuffer(n.__webglRenderbuffer),this.properties.delete(r)}}),Object.assign(Cr.prototype,{setRenderTarget2D:function(e){var t=this.gl,r=this.state,n=this.texture,i=this.renderBuffer,a=this.capabilities,s=this.properties.get(e);if(void 0!==s.__webglFramebuffer)t.bindFramebuffer(t.FRAMEBUFFER,s.__webglFramebuffer);else{e.addEventListener("dispose",this.onRenderTargetDispose,this),s.__webglFramebuffer=t.createFramebuffer(),t.bindFramebuffer(t.FRAMEBUFFER,s.__webglFramebuffer);var o=[];for(var h in e._attachments)if((h=Number(h))!==ce.DEPTH_ATTACHMENT&&h!==ce.DEPTH_STENCIL_ATTACHMENT||a.version<2&&!a.getExtension("WEBGL_depth_texture")&&console.warn("extension WEBGL_depth_texture is not support in webgl 1.0."),(h<=36073&&36064<=h||h<=577045&&577040<=h)&&o.push(h),e._attachments[h].isTexture){var c=n.setTexture2D(e._attachments[h]);t.framebufferTexture2D(t.FRAMEBUFFER,h,t.TEXTURE_2D,c.__webglTexture,0),r.bindTexture(t.TEXTURE_2D,null)}else{var u=i.setRenderBuffer(e._attachments[h]);t.framebufferRenderbuffer(t.FRAMEBUFFER,h,t.RENDERBUFFER,u.__webglRenderbuffer),t.bindRenderbuffer(t.RENDERBUFFER,null)}1<o.length&&(2<=a.version?t.drawBuffers(o):a.getExtension("WEBGL_draw_buffers")&&a.getExtension("WEBGL_draw_buffers").drawBuffersWEBGL(o));var l=t.checkFramebufferStatus(t.FRAMEBUFFER);l!==t.FRAMEBUFFER_COMPLETE&&(l===t.FRAMEBUFFER_INCOMPLETE_ATTACHMENT?console.warn("framebuffer not complete: FRAMEBUFFER_INCOMPLETE_ATTACHMENT"):l===t.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT?console.warn("framebuffer not complete: FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT"):l===t.FRAMEBUFFER_INCOMPLETE_DIMENSIONS?console.warn("framebuffer not complete: FRAMEBUFFER_INCOMPLETE_DIMENSIONS"):l===t.FRAMEBUFFER_UNSUPPORTED?console.warn("framebuffer not complete: FRAMEBUFFER_UNSUPPORTED"):l===t.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE?console.warn("framebuffer not complete: FRAMEBUFFER_INCOMPLETE_MULTISAMPLE"):console.warn("framebuffer not complete."))}},setRenderTargetCube:function(e){var t=this.gl,r=this.state,n=this.texture,i=this.renderBuffer,a=this.capabilities,s=this.properties.get(e);if(void 0!==s.__webglFramebuffer){for(var o in t.bindFramebuffer(t.FRAMEBUFFER,s.__webglFramebuffer),e._attachments)if(e._attachments[o].isTexture){c=this.properties.get(e._attachments[o]);t.framebufferTexture2D(t.FRAMEBUFFER,o,t.TEXTURE_CUBE_MAP_POSITIVE_X+e.activeCubeFace,c.__webglTexture,0)}s.__currentActiveCubeFace=e.activeCubeFace}else{e.addEventListener("dispose",this.onRenderTargetDispose,this),s.__webglFramebuffer=t.createFramebuffer(),s.__currentActiveCubeFace=e.activeCubeFace,t.bindFramebuffer(t.FRAMEBUFFER,s.__webglFramebuffer);var h=[];for(var o in e._attachments)if((o=Number(o))!==ce.DEPTH_ATTACHMENT&&o!==ce.DEPTH_STENCIL_ATTACHMENT||a.version<2&&!a.getExtension("WEBGL_depth_texture")&&console.warn("extension WEBGL_depth_texture is not support in webgl 1.0."),(o<=36073&&36064<=o||o<=577045&&577040<=o)&&h.push(o),e._attachments[o].isTexture){var c=n.setTextureCube(e._attachments[o]);t.framebufferTexture2D(t.FRAMEBUFFER,o,t.TEXTURE_CUBE_MAP_POSITIVE_X+e.activeCubeFace,c.__webglTexture,0),r.bindTexture(t.TEXTURE_CUBE_MAP,null)}else{var u=i.setRenderBuffer(e._attachments[o]);t.framebufferRenderbuffer(t.FRAMEBUFFER,o,t.RENDERBUFFER,u.__webglRenderbuffer),t.bindRenderbuffer(t.RENDERBUFFER,null)}1<h.length&&(2<=a.version?t.drawBuffers(h):a.getExtension("WEBGL_draw_buffers")&&a.getExtension("WEBGL_draw_buffers").drawBuffersWEBGL(h));var l=t.checkFramebufferStatus(t.FRAMEBUFFER);l!==t.FRAMEBUFFER_COMPLETE&&(l===t.FRAMEBUFFER_INCOMPLETE_ATTACHMENT?console.warn("framebuffer not complete: FRAMEBUFFER_INCOMPLETE_ATTACHMENT"):l===t.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT?console.warn("framebuffer not complete: FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT"):l===t.FRAMEBUFFER_INCOMPLETE_DIMENSIONS?console.warn("framebuffer not complete: FRAMEBUFFER_INCOMPLETE_DIMENSIONS"):l===t.FRAMEBUFFER_UNSUPPORTED?console.warn("framebuffer not complete: FRAMEBUFFER_UNSUPPORTED"):l===t.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE?console.warn("framebuffer not complete: FRAMEBUFFER_INCOMPLETE_MULTISAMPLE"):console.warn("framebuffer not complete."))}},blitRenderTarget:function(e,t,r,n,i){var a=this.gl,s=this.properties,o=this.capabilities;if(o.version<2)console.warn("blitFramebuffer not support by WebGL"+o.version);else{var h=s.get(e).__webglFramebuffer,c=s.get(t).__webglFramebuffer;a.bindFramebuffer(a.READ_FRAMEBUFFER,h),a.bindFramebuffer(a.DRAW_FRAMEBUFFER,c);var u=0;void 0!==r&&!r||(u|=a.COLOR_BUFFER_BIT),void 0!==n&&!n||(u|=a.DEPTH_BUFFER_BIT),void 0!==i&&!i||(u|=a.STENCIL_BUFFER_BIT),a.blitFramebuffer(0,0,e.width,e.height,0,0,t.width,t.height,u,a.NEAREST)}},updateRenderTargetMipmap:function(e){var t,r=this.gl,n=this.state,i=e.texture;if(i.generateMipmaps&&(o((t=e).width)&&o(t.height))&&i.minFilter!==r.NEAREST&&i.minFilter!==r.LINEAR){var a=i.textureType,s=this.properties.get(i).__webglTexture;n.bindTexture(a,s),r.generateMipmap(a),n.bindTexture(a,null)}},onRenderTargetDispose:function(e){var t=this.gl,r=this.state,n=e.target,i=this.properties.get(n);for(var a in n.removeEventListener("dispose",this.onRenderTargetDispose,this),i.__webglFramebuffer&&t.deleteFramebuffer(i.__webglFramebuffer),n._attachments)n._attachments[a].dispose();this.properties.delete(n),r.currentRenderTarget===n&&(r.currentRenderTarget=null)},setRenderTarget:function(e){var t=this.gl,r=this.state;if(e.view)r.currentRenderTarget===e||(t.bindFramebuffer(t.FRAMEBUFFER,null),r.currentRenderTarget=e);else{var n=void 0!==e.activeCubeFace;if(r.currentRenderTarget!==e)n?this.setRenderTargetCube(e):this.setRenderTarget2D(e),r.currentRenderTarget=e;else if(n){var i=this.properties.get(e);if(i.__currentActiveCubeFace!==e.activeCubeFace){for(var a in e._attachments){var s=this.properties.get(e._attachments[a]);t.framebufferTexture2D(t.FRAMEBUFFER,a,t.TEXTURE_CUBE_MAP_POSITIVE_X+e.activeCubeFace,s.__webglTexture,0)}i.__currentActiveCubeFace=e.activeCubeFace}}}}});var Or=new le,Fr=new Me,Ur=new WeakMap,Ir=new Float32Array(8);function Dr(e){return e.material}function Br(e){return!0}function zr(){}var Gr,Hr,kr,Vr,jr,Xr,Wr,Yr=(Hr=new Te,function(e){(!Gr||Gr.length<4*e.length)&&(Gr=new Float32Array(4*e.length));for(var t=0;t<e.length;t++)Hr.copy(e[t]),Gr[4*t+0]=Hr.normal.x,Gr[4*t+1]=Hr.normal.y,Gr[4*t+2]=Hr.normal.z,Gr[4*t+3]=Hr.constant;return Gr});function qr(e){this.gl=e;var t=new Ht;this.properties=t;var r=new Ut(e),n=new Gt(e,this.capabilities=r),i=new Yt(e,this.state=n,t,r);this.texture=i;var a=new Rr(e,t,r);this.renderTarget=new Cr(e,n,i,a,t,r),this.geometry=new Kt(e,n,t,r),this.programs=new Lr(e,n,r),this._usedTextureUnits=0,this._currentGeometryProgram=""}function Zr(){qe.call(this),this.type=V.CAMERA,this.viewMatrix=new me,this.projectionMatrix=new me,this.projectionMatrixInverse=new me,this.frustum=new be,this.gammaFactor=2,this.outputEncoding=ae.LINEAR,this.rect=new Me(0,0,1,1),this.frustumCulled=!0}function Kr(e,t){ue.call(this),this.width=e,this.height=t}function Qr(e,t,r,n){ue.call(this),this.width=e,this.height=t,this.format=void 0!==r?r:Q.RGBA8,this.multipleSampling=void 0!==n?n:0}function $r(e,t){Kr.call(this,e,t),this._attachments={},this.attach(new Ge,ce.COLOR_ATTACHMENT0),this.attach(new Qr(e,t,Q.DEPTH_STENCIL),ce.DEPTH_STENCIL_ATTACHMENT),this.activeCubeFace=0}function Jr(e){this.camera=new Zr,this.targets=[new le(1,0,0),new le(-1,0,0),new le(0,1,0),new le(0,-1,0),new le(0,0,1),new le(0,0,-1)],this.ups=[new le(0,-1,0),new le(0,-1,0),new le(0,0,1),new le(0,0,-1),new le(0,-1,0),new le(0,-1,0)],this.camera.setPerspective(.5*Math.PI,1,1,1e3),this.position=new le,this.lookTarget=new le,this.renderTarget=e||new $r(512,512),this.renderTexture=this.renderTarget.texture,this.renderTexture.minFilter=J.LINEAR_MIPMAP_LINEAR}function en(){this.depthMaterial=new Ot,this.depthMaterial.packToRGBA=!0,this.distanceMaterial=new Ft,this.oldClearColor=new Me}Object.assign(qr.prototype,{clear:function(e,t,r){var n=this.gl,i=0;void 0!==e&&!e||(i|=n.COLOR_BUFFER_BIT),void 0!==t&&!t||(i|=n.DEPTH_BUFFER_BIT),void 0!==r&&!r||(i|=n.STENCIL_BUFFER_BIT),n.clear(i)},render:function(t,e,r){var n;n=(r=void 0===r||r)?t.updateRenderList(e):t.getRenderList(e),this.renderPass(n.opaque,e,{scene:t,getMaterial:function(e){return t.overrideMaterial||e.material}}),this.renderPass(n.transparent,e,{scene:t,getMaterial:function(e){return t.overrideMaterial||e.material}})},renderPass:function(e,t,r){r=r||{};for(var n=this.gl,i=this.state,a=this.capabilities.getExtension("OES_vertex_array_object"),s=r.getMaterial||Dr,o=r.beforeRender||zr,h=r.afterRender||zr,c=r.ifRender||Br,u=r.scene||{},l=i.currentRenderTarget,d=0,p=e.length;d<p;d++){var f=e[d];if(c(f)){var _=f.object,m=s.call(this,f),v=f.geometry,g=f.group;_.onBeforeRender(f,m),o.call(this,f,m);var M=this.properties.get(m);if(!1===m.needsUpdate)if(void 0===M.program)m.needsUpdate=!0;else if(M.fog!==u.fog)m.needsUpdate=!0;else if(u.clippingPlanes&&u.clippingPlanes.length!==M.numClippingPlanes)m.needsUpdate=!0;else if(t.outputEncoding!==M.outputEncoding||t.gammaFactor!==M.gammaFactor)m.needsUpdate=!0;else{var E=m.acceptLight&&!!u.lights&&0<u.lights.totalNum;E!==M.acceptLight?m.needsUpdate=!0:E&&(u.lights.hash.compare(M.lightsHash)&&_.receiveShadow===M.receiveShadow&&_.shadowType===M.shadowType||(m.needsUpdate=!0))}if(m.needsUpdate){void 0===M.program&&m.addEventListener("dispose",this.onMaterialDispose,this);var S=M.program;M.program=this.programs.getProgram(t,m,_,u),S&&this.programs.releaseProgram(S),M.fog=u.fog,u.lights?(M.acceptLight=m.acceptLight,M.lightsHash=u.lights.hash.copyTo(M.lightsHash),M.receiveShadow=_.receiveShadow,M.shadowType=_.shadowType):M.acceptLight=!1,M.numClippingPlanes=u.clippingPlanes?u.clippingPlanes.length:0,M.outputEncoding=t.outputEncoding,M.gammaFactor=t.gammaFactor,m.needsUpdate=!1}var x=M.program;i.setProgram(x);var y=this.geometry.setGeometry(v);if(_.morphTargetInfluences&&this.updateMorphtargets(_,v,x),_.morphTargetInfluences)this.setupVertexAttributes(x,v),this._currentGeometryProgram="";else if(2<=this.capabilities.version)y._vaos[x.id]?n.bindVertexArray(y._vaos[x.id]):(y._vaos[x.id]=n.createVertexArray(),n.bindVertexArray(y._vaos[x.id]),this.setupVertexAttributes(x,v));else if(a)y._vaos[x.id]?a.bindVertexArrayOES(y._vaos[x.id]):(y._vaos[x.id]=a.createVertexArrayOES(),a.bindVertexArrayOES(y._vaos[x.id]),this.setupVertexAttributes(x,v));else{var w=x.id+"_"+v.id;w!==this._currentGeometryProgram&&(this.setupVertexAttributes(x,v),this._currentGeometryProgram=w),this._currentGeometryProgram=w}for(var T=x.uniforms,b=0,A=T.seq.length;b<A;b++){var N=T.seq[b],P=N.id;if(m.uniforms&&void 0!==m.uniforms[P])N.set(m.uniforms[P],this);else switch(P){case"u_Projection":if(_.type===V.CANVAS2D&&_.isScreenCanvas)var L=_.orthoCamera.projectionMatrix.elements;else L=t.projectionMatrix.elements;N.set(L);break;case"u_View":if(_.type===V.CANVAS2D&&_.isScreenCanvas)var R=_.orthoCamera.viewMatrix.elements;else R=t.viewMatrix.elements;N.set(R);break;case"u_Model":var C=_.worldMatrix.elements;N.set(C);break;case"u_Color":var O=m.diffuse;N.setValue(O.r,O.g,O.b);break;case"u_Opacity":N.set(m.opacity);break;case"diffuseMap":N.set(m.diffuseMap,this);break;case"alphaMap":N.set(m.alphaMap,this);break;case"normalMap":N.set(m.normalMap,this);break;case"bumpMap":N.set(m.bumpMap,this);break;case"bumpScale":N.set(m.bumpScale);break;case"envMap":N.set(m.envMap,this);break;case"cubeMap":N.set(m.cubeMap,this);break;case"u_EnvMap_Intensity":N.set(m.envMapIntensity);break;case"maxMipLevel":N.set(this.properties.get(m.envMap).__maxMipLevel||0);break;case"u_Specular":N.set(m.shininess);break;case"u_SpecularColor":O=m.specular;N.setValue(O.r,O.g,O.b);break;case"specularMap":N.set(m.specularMap,this);break;case"aoMap":N.set(m.aoMap,this);break;case"aoMapIntensity":N.set(m.aoMapIntensity);break;case"u_Roughness":N.set(m.roughness);break;case"roughnessMap":N.set(m.roughnessMap,this);break;case"u_Metalness":N.set(m.metalness);break;case"metalnessMap":N.set(m.metalnessMap,this);break;case"glossiness":N.set(m.glossiness);break;case"glossinessMap":N.set(m.glossinessMap,this);break;case"emissive":O=m.emissive;var F=m.emissiveIntensity;N.setValue(O.r*F,O.g*F,O.b*F);break;case"emissiveMap":N.set(m.emissiveMap,this);break;case"u_CameraPosition":Or.setFromMatrixPosition(t.worldMatrix),N.setValue(Or.x,Or.y,Or.z);break;case"u_FogColor":O=u.fog.color;N.setValue(O.r,O.g,O.b);break;case"u_FogDensity":N.set(u.fog.density);break;case"u_FogNear":N.set(u.fog.near);break;case"u_FogFar":N.set(u.fog.far);break;case"u_PointSize":N.set(m.size);break;case"u_PointScale":var U=.5*l.height;N.set(U);break;case"dashSize":N.set(m.dashSize);break;case"totalSize":N.set(m.dashSize+m.gapSize);break;case"scale":N.set(m.scale);break;case"clippingPlanes":var I=Yr(u.clippingPlanes||[],t);N.set(I);break;case"uvTransform":var D;(D=m.diffuseMap||m.specularMap||m.normalMap||m.bumpMap||m.roughnessMap||m.metalnessMap||m.emissiveMap)&&(D.matrixAutoUpdate&&D.updateMatrix(),N.set(D.matrix.elements));break;case"alphaMapUVTransform":m.alphaMap.updateMatrix(),N.set(m.alphaMap.matrix.elements)}}_.type===V.SKINNED_MESH&&this.uploadSkeleton(T,_,x.program),m.acceptLight&&u.lights&&this.uploadLights(T,u.lights,_.receiveShadow,t);var B=_.worldMatrix.determinant()<0;this.setStates(m,B);var z=Fr.set(l.width,l.height,l.width,l.height).multiply(t.rect);if(z.z-=z.x,z.w-=z.y,z.x=Math.floor(z.x),z.y=Math.floor(z.y),z.z=Math.floor(z.z),z.w=Math.floor(z.w),_.type===V.CANVAS2D){_.isScreenCanvas&&(_.setRenderViewport(z.x,z.y,z.z,z.w),i.viewport(_.viewport.x,_.viewport.y,_.viewport.z,_.viewport.w));for(var G=0,H=0;H<_.drawArray.length;H++){var k=_.drawArray[H];T.set("spriteTexture",k.texture,this),n.drawElements(n.TRIANGLES,6*k.count,n.UNSIGNED_SHORT,2*G),G+=6*k.count,this._usedTextureUnits=0}}else i.viewport(z.x,z.y,z.z,z.w),this.draw(v,m,g);2<=this.capabilities.version?n.bindVertexArray(null):a&&a.bindVertexArrayOES(null),this._usedTextureUnits=0,i.depthBuffer.setTest(!0),i.depthBuffer.setMask(!0),i.colorBuffer.setMask(!0),h(this,f),_.onAfterRender(f)}}},setStates:function(e,t){var r=this.state;e.transparent?r.setBlend(e.blending,e.blendEquation,e.blendSrc,e.blendDst,e.blendEquationAlpha,e.blendSrcAlpha,e.blendDstAlpha,e.premultipliedAlpha):r.setBlend(j.NONE),r.depthBuffer.setFunc(e.depthFunc),r.depthBuffer.setTest(e.depthTest),r.depthBuffer.setMask(e.depthWrite),r.colorBuffer.setMask(e.colorWrite),r.setCullFace(e.side===q.DOUBLE?Y.NONE:Y.BACK);var n=e.side===q.BACK;t&&(n=!n),r.setFlipSided(n),void 0!==e.lineWidth&&r.setLineWidth(e.lineWidth),r.setPolygonOffset(e.polygonOffset,e.polygonOffsetFactor,e.polygonOffsetUnits)},draw:function(e,t,r){var n=this.gl,i=this.properties,a=this.capabilities,s=null!==e.index,o=0,h=s?e.index.count:e.getAttribute("a_Position").count,c=r?r.start:0,u=r?r.count:1/0;if(o=Math.max(o,c),h=Math.min(h,u),s){var l=i.get(e.index),d=l.bytesPerElement,p=l.type;p===n.UNSIGNED_INT&&a.version<2&&!a.getExtension("OES_element_index_uint")&&console.warn("draw elements type not support UNSIGNED_INT!"),e.isInstancedGeometry?0<e.maxInstancedCount&&(2<=a.version?n.drawElementsInstanced(t.drawMode,h,p,o*d,e.maxInstancedCount):a.getExtension("ANGLE_instanced_arrays")?a.getExtension("ANGLE_instanced_arrays").drawElementsInstancedANGLE(t.drawMode,h,p,o*d,e.maxInstancedCount):console.warn("no support instanced draw.")):n.drawElements(t.drawMode,h,p,o*d)}else e.isInstancedGeometry?0<e.maxInstancedCount&&(2<=a.version?n.drawArraysInstanced(t.drawMode,o,h,e.maxInstancedCount):a.getExtension("ANGLE_instanced_arrays")?a.getExtension("ANGLE_instanced_arrays").drawArraysInstancedANGLE(t.drawMode,o,h,e.maxInstancedCount):console.warn("no support instanced draw.")):n.drawArrays(t.drawMode,o,h)},uploadSkeleton:function(e,t,r){if(t.skeleton&&0<t.skeleton.bones.length){var n=t.skeleton,i=this.capabilities;if(n.updateBones(),0<i.maxVertexTextures&&(i.getExtension("OES_texture_float")||2<=i.version)){if(void 0===n.boneTexture){var a=Math.sqrt(4*n.bones.length);a=h(Math.ceil(a)),a=Math.max(4,a);var s=new Float32Array(a*a*4);s.set(n.boneMatrices);var o=new ze;o.image={data:s,width:a,height:a},2<=i.version&&(o.internalformat=Q.RGBA32F,o.format=Q.RGBA),o.type=$.FLOAT,o.magFilter=J.NEAREST,o.minFilter=J.NEAREST,o.generateMipmaps=!1,o.flipY=!1,n.boneMatrices=s,n.boneTexture=o}e.set("boneTexture",n.boneTexture,this),e.set("boneTextureSize",n.boneTexture.image.width)}else e.set("boneMatrices",n.boneMatrices);e.set("bindMatrix",t.bindMatrix.elements),e.set("bindMatrixInverse",t.bindMatrixInverse.elements)}},uploadLights:function(e,t,r,n){0<t.ambientsNum&&e.set("u_AmbientLightColor",t.ambient),0<t.directsNum&&(e.set("u_Directional",t.directional),e.has("directionalShadowMap")&&(2<=this.capabilities.version?e.set("directionalShadowMap",t.directionalShadowDepthMap,this):e.set("directionalShadowMap",t.directionalShadowMap,this),e.set("directionalShadowMatrix",t.directionalShadowMatrix)),e.has("directionalDepthMap")&&e.set("directionalDepthMap",t.directionalShadowMap,this)),0<t.pointsNum&&(e.set("u_Point",t.point),e.has("pointShadowMap")&&e.set("pointShadowMap",t.pointShadowMap,this)),0<t.spotsNum&&(e.set("u_Spot",t.spot),e.has("spotShadowMap")&&(2<=this.capabilities.version?e.set("spotShadowMap",t.spotShadowDepthMap,this):e.set("spotShadowMap",t.spotShadowMap,this),e.set("spotShadowMatrix",t.spotShadowMatrix)),e.has("spotDepthMap")&&e.set("spotDepthMap",t.spotShadowMap,this))},allocTexUnit:function(){var e=this._usedTextureUnits;return e>=this.capabilities.maxTextures&&console.warn("trying to use "+e+" texture units while this GPU supports only "+this.capabilities.maxTextures),this._usedTextureUnits+=1,e},updateMorphtargets:function(e,t,r){var n=e.morphTargetInfluences;Ur.has(t)||Ur.set(t,n.slice(0));for(var i=t.morphAttributes.position,a=t.morphAttributes.normal,s=Ur.get(t),o=0;o<s.length;o++){0!==(c=s[o])&&(i&&t.removeAttribute("morphTarget"+o),a&&t.removeAttribute("morphNormal"+o))}for(o=0;o<n.length;o++)s[o]=n[o];s.length=n.length;var h=0;for(o=0;o<s.length;o++){var c;0<(c=s[o])&&(i&&t.addAttribute("morphTarget"+h,i[o]),a&&t.addAttribute("morphNormal"+h,a[o]),Ir[h]=c,h++)}for(;h<8;h++)Ir[h]=0;r.uniforms.set("morphTargetInfluences",Ir)},setupVertexAttributes:function(e,t){var r=this.gl,n=e.attributes,i=this.properties,a=this.capabilities;for(var s in n){var o=n[s],h=t.getAttribute(s);if(h){var c,u=h.normalized,l=h.size;o.count!==l&&console.warn("WebGLCore: attribute "+s+" size not match! "+o.count+" : "+l);var d=(c=h.isInterleavedBufferAttribute?i.get(h.data):i.get(h)).buffer,p=c.type;o.format;var f=c.bytesPerElement;if(h.isInterleavedBufferAttribute){var _=h.data,m=_.stride,v=h.offset;r.enableVertexAttribArray(o.location),_&&_.isInstancedInterleavedBuffer&&(2<=a.version?r.vertexAttribDivisor(o.location,_.meshPerAttribute):a.getExtension("ANGLE_instanced_arrays")?a.getExtension("ANGLE_instanced_arrays").vertexAttribDivisorANGLE(o.location,_.meshPerAttribute):console.warn("vertexAttribDivisor not supported"),void 0===t.maxInstancedCount&&(t.maxInstancedCount=_.meshPerAttribute*_.count)),r.bindBuffer(r.ARRAY_BUFFER,d),r.vertexAttribPointer(o.location,o.count,p,u,f*m,f*v)}else r.enableVertexAttribArray(o.location),h&&h.isInstancedBufferAttribute&&(2<=a.version?r.vertexAttribDivisor(o.location,h.meshPerAttribute):a.getExtension("ANGLE_instanced_arrays")?a.getExtension("ANGLE_instanced_arrays").vertexAttribDivisorANGLE(o.location,h.meshPerAttribute):console.warn("vertexAttribDivisor not supported"),void 0===t.maxInstancedCount&&(t.maxInstancedCount=h.meshPerAttribute*h.count)),r.bindBuffer(r.ARRAY_BUFFER,d),r.vertexAttribPointer(o.location,o.count,p,u,0,0)}}if(t.index){var g=i.get(t.index);r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,g.buffer)}},onMaterialDispose:function(e){var t=e.target,r=this.properties.get(t);t.removeEventListener("dispose",this.onMaterialDispose,this);var n=r.program;void 0!==n&&this.programs.releaseProgram(n),this.properties.delete(t)}}),Zr.prototype=Object.assign(Object.create(qe.prototype),{constructor:Zr,lookAt:(Wr=new me,function(e,t){Wr.lookAtRH(this.position,e,t),this.quaternion.setFromRotationMatrix(Wr)}),setOrtho:function(e,t,r,n,i,a){this.projectionMatrix.set(2/(t-e),0,0,-(t+e)/(t-e),0,2/(n-r),0,-(n+r)/(n-r),0,0,-2/(a-i),-(a+i)/(a-i),0,0,0,1),this.projectionMatrixInverse.getInverse(this.projectionMatrix)},setPerspective:function(e,t,r,n){this.projectionMatrix.set(1/(t*Math.tan(e/2)),0,0,0,0,1/Math.tan(e/2),0,0,0,0,-(n+r)/(n-r),-2*n*r/(n-r),0,0,-1,0),this.projectionMatrixInverse.getInverse(this.projectionMatrix)},getWorldDirection:(Vr=new le,jr=new Se,Xr=new le,function(e){var t=e||new le;return this.worldMatrix.decompose(Vr,jr,Xr),t.set(0,0,-1).applyQuaternion(jr),t}),updateMatrix:(kr=new me,function(){qe.prototype.updateMatrix.call(this),this.viewMatrix.getInverse(this.worldMatrix),kr.multiplyMatrices(this.projectionMatrix,this.viewMatrix),this.frustum.setFromMatrix(kr)}),copy:function(e,t){return qe.prototype.copy.call(this,e,t),this.viewMatrix.copy(e.viewMatrix),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.frustum.copy(e.frustum),this.gammaFactor=e.gammaFactor,this.outputEncoding=e.outputEncoding,this.rect.copy(e.rect),this.frustumCulled=e.frustumCulled,this}}),Object.defineProperties(Zr.prototype,{gammaInput:{get:function(){return console.warn("zen3d.Camera: .gammaInput has been removed. Use texture.encoding instead."),!1},set:function(e){console.warn("zen3d.Camera: .gammaInput has been removed. Use texture.encoding instead.")}},gammaOutput:{get:function(){return console.warn("zen3d.Camera: .gammaOutput has been removed. Use .outputEncoding or renderTarget.texture.encoding instead."),this.outputEncoding==ae.GAMMA},set:function(e){console.warn("zen3d.Camera: .gammaOutput has been removed. Use .outputEncoding or renderTarget.texture.encoding instead."),this.outputEncoding=e?ae.GAMMA:ae.LINEAR}}}),Kr.prototype=Object.assign(Object.create(ue.prototype),{constructor:Kr,resize:function(e,t){return(this.width!==e||this.height!==t)&&(this.dispose(),this.width=e,this.height=t,!0)},dispose:function(){this.dispatchEvent({type:"dispose"})}}),Qr.prototype=Object.assign(Object.create(ue.prototype),{constructor:Qr,isRenderBuffer:!0,resize:function(e,t){return(this.width!==e||this.height!==t)&&(this.dispose(),this.width=e,this.height=t,!0)},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.format=e.format,this.multipleSampling=e.multipleSampling,this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),(($r.prototype=Object.create(Kr.prototype)).constructor=$r).prototype=Object.assign(Object.create(Kr.prototype),{constructor:$r,attach:function(e,t){if(e.isTexture){for(var r=!1,n=0;n<6;n++)e.images[n]&&e.images[n].rtt?e.images[n].width===this.width&&e.images[n].height===this.height||(e.images[n].width=this.width,e.images[n].height=this.height,r=!0):(e.images[n]={rtt:!0,data:null,width:this.width,height:this.height},r=!0);r&&e.version++}else e.resize(this.width,this.height);this._attachments[t||ce.COLOR_ATTACHMENT0]=e},detach:function(e){delete this._attachments[e||ce.COLOR_ATTACHMENT0]},resize:function(e,t){if(Kr.prototype.resize.call(this,e,t))for(var r in this._attachments){var n=this._attachments[r];if(n.isTexture){for(var i=0;i<6;i++)n.images[i]={rtt:!0,data:null,width:this.width,height:this.height};n.version++}else n.resize(e,t)}}}),Object.defineProperties($r.prototype,{texture:{set:function(e){e?e.isTexture&&this.attach(e,ce.COLOR_ATTACHMENT0):this.detach(ce.COLOR_ATTACHMENT0)},get:function(){var e=this._attachments[ce.COLOR_ATTACHMENT0];return e.isTexture?e:null}}}),Jr.prototype.render=function(e,t){this.camera.position.copy(this.position);for(var r=0;r<6;r++)this.lookTarget.set(this.targets[r].x+this.camera.position.x,this.targets[r].y+this.camera.position.y,this.targets[r].z+this.camera.position.z),this.camera.lookAt(this.lookTarget,this.ups[r]),this.camera.updateMatrix(),this.renderTarget.activeCubeFace=r,e.renderTarget.setRenderTarget(this.renderTarget),e.clear(!0,!0,!0),e.render(t,this.camera),e.renderTarget.updateRenderTargetMipmap(this.renderTarget)},en.prototype.render=function(e,t){var r=e.gl,n=e.state,i=n.states[r.STENCIL_TEST];i&&n.stencilBuffer.setTest(!1),this.oldClearColor.copy(n.colorBuffer.getClear()),n.colorBuffer.setClear(1,1,1,1);for(var a=t.lights.shadows,s=0;s<a.length;s++){var o=a[s],h=o.shadow,c=h.camera,u=h.renderTarget,l=o.lightType==G.POINT,d=l?6:1;2<=e.capabilities.version&&(l||h.depthMap||h._initDepthMap());for(var p=0;p<d;p++){l?(h.update(o,p),u.activeCubeFace=p):h.update(o);var f=t.updateRenderList(c);e.renderTarget.setRenderTarget(u),e.clear(!0,!0);var _=l?this.distanceMaterial:this.depthMaterial;_.uniforms=_.uniforms||{},_.uniforms.nearDistance=h.cameraNear,_.uniforms.farDistance=h.cameraFar,e.renderPass(f.opaque,c,{getMaterial:function(e){return _.side=e.material.side,_},ifRender:function(e){return e.object.castShadow}})}}i&&n.stencilBuffer.setTest(!0),n.colorBuffer.setClear(this.oldClearColor.x,this.oldClearColor.y,this.oldClearColor.z,this.oldClearColor.w)};var tn=new le,rn=new WeakMap;function nn(e){if(rn.has(e))return rn.get(e);var t;switch(e.lightType){case G.DIRECT:t={direction:new Float32Array(3),color:new Float32Array([0,0,0,1]),shadow:0,shadowBias:0,shadowRadius:1,shadowMapSize:new Float32Array(2)};break;case G.POINT:t={position:new Float32Array(3),color:new Float32Array([0,0,0,1]),distance:0,decay:0,shadow:0,shadowBias:0,shadowRadius:1,shadowMapSize:new Float32Array(2),shadowCameraNear:1,shadowCameraFar:1e3};break;case G.SPOT:t={position:new Float32Array(3),direction:new Float32Array(3),color:new Float32Array([0,0,0,1]),distance:0,coneCos:0,penumbraCos:0,decay:0,shadow:0,shadowBias:0,shadowRadius:1,shadowMapSize:new Float32Array(2)}}return rn.set(e,t),t}function an(){this._factor=new Uint16Array(4)}function sn(){this.ambient=new Float32Array([0,0,0]),this.directional=[],this.directionalShadowMap=[],this.directionalShadowDepthMap=[],this.directionalShadowMatrix=[],this.point=[],this.pointShadowMap=[],this.pointShadowMatrix=[],this.spot=[],this.spotShadowMap=[],this.spotShadowDepthMap=[],this.spotShadowMatrix=[],this.shadows=[],this.ambientsNum=0,this.directsNum=0,this.pointsNum=0,this.spotsNum=0,this.directShadowNum=0,this.pointShadowNum=0,this.spotShadowNum=0,this.shadowsNum=0,this.totalNum=0,this.hash=new an}Object.assign(an.prototype,{update:function(e){this._factor[0]=e.ambientsNum,this._factor[1]=e.directsNum,this._factor[2]=e.pointsNum,this._factor[3]=e.spotsNum},compare:function(e){return!!e&&!(this._factor[0]!==e[0]||this._factor[1]!==e[1]||this._factor[2]!==e[2]||this._factor[3]!==e[3])},copyTo:function(e){return(e=e||new Uint16Array(4)).set(this._factor),e}}),Object.assign(sn.prototype,{startCount:function(){for(var e=0;e<3;e++)this.ambient[e]=0;this.shadows.length=0,this.ambientsNum=0,this.directsNum=0,this.pointsNum=0,this.spotsNum=0,this.directShadowNum=0,this.pointShadowNum=0,this.spotShadowNum=0,this.shadowsNum=0,this.totalNum=0},add:function(e){e.lightType==G.AMBIENT?this._doAddAmbientLight(e):e.lightType==G.DIRECT?this._doAddDirectLight(e):e.lightType==G.POINT?this._doAddPointLight(e):e.lightType==G.SPOT&&this._doAddSpotLight(e),e.castShadow&&e.lightType!==G.AMBIENT&&(this.shadows.push(e),this.shadowsNum++),this.totalNum++},endCount:function(){this.hash.update(this)},_doAddAmbientLight:function(e){var t=e.intensity,r=e.color;this.ambient[0]+=r.r*t,this.ambient[1]+=r.g*t,this.ambient[2]+=r.b*t,this.ambientsNum++},_doAddDirectLight:function(e){var t=e.intensity,r=e.color,n=nn(e);n.color[0]=r.r*t,n.color[1]=r.g*t,n.color[2]=r.b*t;var i=tn;if(e.getWorldDirection(i),n.direction[0]=i.x,n.direction[1]=i.y,n.direction[2]=i.z,e.castShadow?(n.shadow=1,n.shadowBias=e.shadow.bias,n.shadowRadius=e.shadow.radius,n.shadowMapSize[0]=e.shadow.mapSize.x,n.shadowMapSize[1]=e.shadow.mapSize.y,this.directShadowNum++):n.shadow=0,e.castShadow){var a=16*(this.directsNum+1);if(this.directionalShadowMatrix.length<a){var s=this.directionalShadowMatrix;this.directionalShadowMatrix=new Float32Array(a),this.directionalShadowMatrix.set(s)}this.directionalShadowMatrix.set(e.shadow.matrix.elements,16*this.directsNum),this.directionalShadowMap[this.directsNum]=e.shadow.map,this.directionalShadowDepthMap[this.directsNum]=e.shadow.depthMap}this.directional[this.directsNum]=n,this.directsNum++},_doAddPointLight:function(e){var t=e.intensity,r=e.color,n=e.distance,i=e.decay,a=nn(e);a.color[0]=r.r*t,a.color[1]=r.g*t,a.color[2]=r.b*t,a.distance=n,a.decay=i;var s=tn.setFromMatrixPosition(e.worldMatrix);if(a.position[0]=s.x,a.position[1]=s.y,a.position[2]=s.z,e.castShadow?(a.shadow=1,a.shadowBias=e.shadow.bias,a.shadowRadius=e.shadow.radius,a.shadowMapSize[0]=e.shadow.mapSize.x,a.shadowMapSize[1]=e.shadow.mapSize.y,a.shadowCameraNear=e.shadow.cameraNear,a.shadowCameraFar=e.shadow.cameraFar,this.pointShadowNum++):a.shadow=0,e.castShadow){var o=16*(this.pointsNum+1);if(this.pointShadowMatrix.length<o){var h=this.pointShadowMatrix;this.pointShadowMatrix=new Float32Array(o),this.pointShadowMatrix.set(h)}this.pointShadowMatrix.set(e.shadow.matrix.elements,16*this.pointsNum),this.pointShadowMap[this.pointsNum]=e.shadow.map}this.point[this.pointsNum]=a,this.pointsNum++},_doAddSpotLight:function(e){var t=e.intensity,r=e.color,n=e.distance,i=e.decay,a=nn(e);a.color[0]=r.r*t,a.color[1]=r.g*t,a.color[2]=r.b*t,a.distance=n,a.decay=i;var s=tn.setFromMatrixPosition(e.worldMatrix);a.position[0]=s.x,a.position[1]=s.y,a.position[2]=s.z;var o=tn;e.getWorldDirection(tn),a.direction[0]=o.x,a.direction[1]=o.y,a.direction[2]=o.z;var h=Math.cos(e.angle),c=Math.cos(e.angle*(1-e.penumbra));if(a.coneCos=h,a.penumbraCos=c,e.castShadow?(a.shadow=1,a.shadowBias=e.shadow.bias,a.shadowRadius=e.shadow.radius,a.shadowMapSize[0]=e.shadow.mapSize.x,a.shadowMapSize[1]=e.shadow.mapSize.y,this.spotShadowNum++):a.shadow=0,e.castShadow){var u=16*(this.spotsNum+1);if(this.spotShadowMatrix.length<u){var l=this.spotShadowMatrix;this.spotShadowMatrix=new Float32Array(u),this.spotShadowMatrix.set(l)}this.spotShadowMatrix.set(e.shadow.matrix.elements,16*this.spotsNum),this.spotShadowMap[this.spotsNum]=e.shadow.map,this.spotShadowDepthMap[this.spotsNum]=e.shadow.depthMap}this.spot[this.spotsNum]=a,this.spotsNum++}});function on(e,t){return e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.material.id!==t.material.id?e.material.id-t.material.id:e.z!==t.z?e.z-t.z:e.id-t.id}function hn(e,t){return e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.material.id!==t.material.id?e.material.id-t.material.id:e.id-t.id}var cn,un,ln,dn,pn,fn,_n,mn,vn,gn,Mn,En,Sn,xn=new le,yn=new we;function wn(){var s=[],o=0,h=[],c=0,u=[],l=0;function d(e,t,r,n,i){var a=s[o];void 0===a?(a={object:e,geometry:t,material:r,z:n,renderOrder:e.renderOrder,group:i},s[o]=a):(a.object=e,a.geometry=t,a.material=r,a.z=n,a.renderOrder=e.renderOrder,a.group=i),r.transparent?(u[l]=a,l++):(h[c]=a,c++),o++}return{opaque:h,transparent:u,startCount:function(){l=c=o=0},add:function(e,t){if(e.frustumCulled&&t.frustumCulled&&(yn.copy(e.geometry.boundingSphere).applyMatrix4(e.worldMatrix),!t.frustum.intersectsSphere(yn)))return;if(xn.setFromMatrixPosition(e.worldMatrix),xn.project(t),Array.isArray(e.material))for(var r=e.geometry.groups,n=0;n<r.length;n++){var i=r[n],a=e.material[i.materialIndex];a&&d(e,e.geometry,a,xn.z,i)}else d(e,e.geometry,e.material,xn.z)},endCount:function(){h.length=c,u.length=l},sort:function(){h.sort(on),u.sort(hn)}}}function Tn(){qe.call(this),this.type=V.SCENE,this.overrideMaterial=null,this.fog=null,this.clippingPlanes=[],this.lights=new sn,this._renderListMap=new WeakMap}function bn(e,t){qe.call(this),this.geometry=e,this.material=t,this.morphTargetInfluences=null,this.type=V.MESH}function An(e,t,r,n,i,a,s){var o=e.material;if(null===(o.side===q.BACK?r.intersectTriangle(a,i,n,!0,s):r.intersectTriangle(n,i,a,o.side!==q.DOUBLE,s)))return null;Sn.copy(s),Sn.applyMatrix4(e.worldMatrix);var h=t.ray.origin.distanceTo(Sn);return h<t.near||h>t.far?null:{distance:h,point:Sn.clone(),object:e}}function Nn(e){var t=new Tn,r=this.camera=new Zr;r.frustumCulled=!1,r.position.set(0,1,0),r.lookAt(new le(0,0,0),new le(0,0,-1)),r.setOrtho(-1,1,-1,1,.1,2),t.add(r);var n=new Et(2,2,1,1),i=this.material=new Ct(e);this.uniforms=i.uniforms;var a=new bn(n,i);a.frustumCulled=!1,t.add(a),t.updateMatrix(),this.renderList=t.updateRenderList(r),this.renderConfig={}}function Pn(e){Kr.call(this,e.width,e.height),this.view=e}function Ln(e,t){var r={antialias:!0,alpha:!1,stencil:!0},n=e.getContext("webgl2",t||r)||e.getContext("webgl",t||r);this.glCore=new qr(n),console.info("ForwardRenderer use WebGL Version: "+this.glCore.capabilities.version),this.backRenderTarget=new Pn(e),this.shadowMapPass=new en,this.shadowAutoUpdate=!0,this.shadowNeedsUpdate=!1,this.matrixAutoUpdate=!0,this.lightsAutoupdate=!0,this.autoClear=!0}function Rn(e,t){Kr.call(this,e,t),this._attachments={},this.attach(new ze,ce.COLOR_ATTACHMENT0),this.attach(new Qr(e,t,Q.DEPTH_STENCIL),ce.DEPTH_STENCIL_ATTACHMENT)}function Cn(){qe.call(this),this.type=V.GROUP}function On(e,t){qe.call(this),this.type=V.LIGHT,this.lightType="",this.color=new Ae(void 0!==e?e:16777215),this.intensity=void 0!==t?t:1}function Fn(e,t){On.call(this,e,t),this.lightType=G.AMBIENT}function Un(){this.camera=new Zr,this.matrix=new me,this.bias=3e-4,this.radius=2,this.cameraNear=1,this.cameraFar=500,this.mapSize=new ge(512,512),this.renderTarget=null,this.map=null}function In(){Un.call(this),this.camera.frustumCulled=!1,this.renderTarget=new Rn(this.mapSize.x,this.mapSize.y);var e=this.renderTarget.texture;e.generateMipmaps=!1,e.minFilter=J.LINEAR,this.map=e,this.depthMap=null,this.windowSize=500,this._lookTarget=new le,this._up=new le(0,1,0)}function Dn(e,t){On.call(this,e,t),this.lightType=G.DIRECT,this.shadow=new In}function Bn(){Un.call(this),this.renderTarget=new $r(this.mapSize.x,this.mapSize.y);var e=this.renderTarget.texture;e.generateMipmaps=!1,e.minFilter=J.LINEAR,this.map=e,this._targets=[new le(1,0,0),new le(-1,0,0),new le(0,1,0),new le(0,-1,0),new le(0,0,1),new le(0,0,-1)],this._ups=[new le(0,-1,0),new le(0,-1,0),new le(0,0,1),new le(0,0,-1),new le(0,-1,0),new le(0,-1,0)],this._lookTarget=new le}function zn(e,t,r,n){On.call(this,e,t),this.lightType=G.POINT,this.decay=void 0!==n?n:1,this.distance=void 0!==r?r:200,this.shadow=new Bn}function Gn(){Un.call(this),this.renderTarget=new Rn(this.mapSize.x,this.mapSize.y);var e=this.renderTarget.texture;e.generateMipmaps=!1,e.minFilter=J.LINEAR,this.map=e,this.depthMap=null,this._lookTarget=new le,this._up=new le(0,1,0)}function Hn(e,t,r,n,i,a){On.call(this,e,t),this.lightType=G.SPOT,this.decay=void 0!==a?a:1,this.distance=void 0!==r?r:200,this.penumbra=void 0!==i?i:0,this.angle=void 0!==n?n:Math.PI/6,this.shadow=new Gn}function kn(e,t){bn.call(this,e,t),this.type=V.SKINNED_MESH,this.skeleton=void 0,this.bindMode="attached",this.bindMatrix=new me,this.bindMatrixInverse=new me}Tn.prototype=Object.assign(Object.create(qe.prototype),{constructor:Tn,updateRenderList:function(e){this._renderListMap.has(e)||this._renderListMap.set(e,new wn);var t=this._renderListMap.get(e);return t.startCount(),this._doUpdateRenderList(this,e,t),t.endCount(),t.sort(),t},getRenderList:function(e){return this._renderListMap.get(e)},updateLights:function(){var e=this.lights;return e.startCount(),this._doUpdateLights(this),e.endCount(),e},_doUpdateRenderList:function(e,t,r){if(e.visible&&(e.geometry&&e.material&&r.add(e,t),V.CANVAS2D!==e.type))for(var n=e.children,i=0,a=n.length;i<a;i++)this._doUpdateRenderList(n[i],t,r)},_doUpdateLights:function(e){if(e.visible&&(V.LIGHT===e.type&&this.lights.add(e),V.CANVAS2D!==e.type))for(var t=e.children,r=0,n=t.length;r<n;r++)this._doUpdateLights(t[r])}}),bn.prototype=Object.assign(Object.create(qe.prototype),{constructor:bn,raycast:(cn=new we,un=new ye,ln=new me,dn=new de,pn=new le,fn=new le,_n=new le,mn=new le,vn=new ge,gn=new ge,Mn=new ge,En=new le,Sn=new le,function(e,t){var r=this.geometry,n=this.worldMatrix;if(cn.copy(r.boundingSphere),cn.applyMatrix4(n),e.ray.intersectsSphere(cn)&&(un.copy(r.boundingBox),un.applyMatrix4(n),e.ray.intersectsBox(un))){ln.getInverse(n),dn.copy(e.ray).applyMatrix4(ln);for(var i,a,s,o,h,c,u=r.index.array,l=r.getAttribute("a_Position"),d=r.getAttribute("a_Uv"),p=0;p<u.length;p+=3){i=u[p],a=u[p+1],s=u[p+2],fn.fromArray(l.array,3*i),_n.fromArray(l.array,3*a),mn.fromArray(l.array,3*s);var f=An(this,e,dn,fn,_n,mn,En);f&&(vn.fromArray(d.array,2*i),gn.fromArray(d.array,2*a),Mn.fromArray(d.array,2*s),f.uv=(o=vn,h=gn,c=Mn,Pe.barycoordFromPoint(En,fn,_n,mn,pn),o.multiplyScalar(pn.x),h.multiplyScalar(pn.y),c.multiplyScalar(pn.z),o.add(h).add(c),o.clone()),f.face=[i,a,s],f.faceIndex=i,t.push(f))}}}),copy:function(e){return qe.prototype.copy.call(this,e),e.morphTargetInfluences&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),this},clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),Nn.prototype.render=function(e){e.renderPass(this.renderList.opaque,this.camera,this.renderConfig)},Pn.prototype=Object.assign(Object.create(Kr.prototype),{constructor:Pn,resize:function(e,t){this.view.width=e,this.view.height=t,this.width=e,this.height=t},dispose:function(){}}),Ln.prototype.render=function(e,t,r,n){this.matrixAutoUpdate&&e.updateMatrix(),this.lightsAutoupdate&&e.updateLights(),(this.shadowAutoUpdate||this.shadowNeedsUpdate)&&(this.shadowMapPass.render(this.glCore,e),this.shadowNeedsUpdate=!1),void 0===r&&(r=this.backRenderTarget),this.glCore.renderTarget.setRenderTarget(r),(this.autoClear||n)&&this.glCore.clear(!0,!0,!0),this.glCore.render(e,t),r.texture&&this.glCore.renderTarget.updateRenderTargetMipmap(r)},Rn.prototype=Object.assign(Object.create(Kr.prototype),{constructor:Rn,attach:function(e,t){e.isTexture?e.image&&e.image.rtt?e.image.width===this.width&&e.image.height===this.height||(e.version++,e.image.width=this.width,e.image.height=this.height):(e.version++,e.image={rtt:!0,data:null,width:this.width,height:this.height}):e.resize(this.width,this.height),this._attachments[t||ce.COLOR_ATTACHMENT0]=e},detach:function(e){delete this._attachments[e||ce.COLOR_ATTACHMENT0]},resize:function(e,t){var r=Kr.prototype.resize.call(this,e,t);if(r)for(var n in this._attachments){var i=this._attachments[n];i.isTexture?(i.image={rtt:!0,data:null,width:this.width,height:this.height},i.version++):i.resize(e,t)}return r}}),Object.defineProperties(Rn.prototype,{texture:{set:function(e){e?e.isTexture&&this.attach(e,ce.COLOR_ATTACHMENT0):this.detach(ce.COLOR_ATTACHMENT0)},get:function(){var e=this._attachments[ce.COLOR_ATTACHMENT0];return e.isTexture?e:null}}}),(Cn.prototype=Object.create(qe.prototype)).constructor=Cn,On.prototype=Object.assign(Object.create(qe.prototype),{constructor:On,copy:function(e){return qe.prototype.copy.call(this,e),this.type=e.type,this.lightType=e.lightType,this.color.copy(e.color),this.intensity=e.intensity,this}}),(Fn.prototype=Object.create(On.prototype)).constructor=Fn,Object.assign(Un.prototype,{update:function(e,t){},copy:function(e){return this.camera.copy(e.camera),this.matrix.copy(e.matrix),this.bias=e.bias,this.radius=e.radius,this.cameraNear=e.cameraNear,this.cameraFar=e.cameraFar,this.mapSize.copy(e.mapSize),this},clone:function(){return(new this.constructor).copy(this)}}),In.prototype=Object.assign(Object.create(Un.prototype),{constructor:In,update:function(e){this._updateCamera(e),this._updateMatrix(),this.mapSize.x===this.renderTarget.width&&this.mapSize.y===this.renderTarget.height||this.renderTarget.resize(this.mapSize.x,this.mapSize.y)},_updateCamera:function(e){var t=this.camera,r=this._lookTarget;e.getWorldDirection(this._lookTarget),t.position.setFromMatrixPosition(e.worldMatrix),r.set(r.x+t.position.x,r.y+t.position.y,r.z+t.position.z),t.lookAt(r,this._up),t.updateMatrix();var n=this.windowSize/2;t.setOrtho(-n,n,-n,n,this.cameraNear,this.cameraFar)},_updateMatrix:function(){var e=this.matrix,t=this.camera;e.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),e.multiply(t.projectionMatrix),e.multiply(t.viewMatrix)},copy:function(e){return Un.prototype.copy.call(this,e),this.windowSize=e.windowSize,this},_initDepthMap:function(){var e=new ze;e.type=$.FLOAT_32_UNSIGNED_INT_24_8_REV,e.format=Q.DEPTH_STENCIL,e.internalformat=Q.DEPTH32F_STENCIL8,e.magFilter=J.LINEAR,e.minFilter=J.LINEAR,e.compare=te.LESS,e.generateMipmaps=!1,this.renderTarget.attach(e,ce.DEPTH_STENCIL_ATTACHMENT),this.depthMap=e}}),Dn.prototype=Object.assign(Object.create(On.prototype),{constructor:Dn,copy:function(e){return On.prototype.copy.call(this,e),this.shadow.copy(e.shadow),this}}),Bn.prototype=Object.assign(Object.create(Un.prototype),{constructor:Bn,update:function(e,t){this._updateCamera(e,t),this._updateMatrix(),this.mapSize.x===this.renderTarget.width&&this.mapSize.y===this.renderTarget.height||this.renderTarget.resize(this.mapSize.x,this.mapSize.y)},_updateCamera:function(e,t){var r=this.camera,n=this._lookTarget,i=this._targets,a=this._ups;r.position.setFromMatrixPosition(e.worldMatrix),n.set(i[t].x+r.position.x,i[t].y+r.position.y,i[t].z+r.position.z),r.lookAt(n,a[t]),r.updateMatrix(),r.setPerspective(.5*Math.PI,1,this.cameraNear,this.cameraFar)},_updateMatrix:function(){var e=this.matrix,t=this.camera;e.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),e.multiply(t.projectionMatrix),e.multiply(t.viewMatrix)}}),zn.prototype=Object.assign(Object.create(On.prototype),{constructor:zn,copy:function(e){return On.prototype.copy.call(this,e),this.shadow.copy(e.shadow),this}}),Gn.prototype=Object.assign(Object.create(Un.prototype),{constructor:Gn,update:function(e){this._updateCamera(e),this._updateMatrix(),this.mapSize.x===this.renderTarget.width&&this.mapSize.y===this.renderTarget.height||this.renderTarget.resize(this.mapSize.x,this.mapSize.y)},_updateCamera:function(e){var t=this.camera,r=this._lookTarget;e.getWorldDirection(this._lookTarget),t.position.setFromMatrixPosition(e.worldMatrix),r.set(r.x+t.position.x,r.y+t.position.y,r.z+t.position.z),t.lookAt(r,this._up),t.updateMatrix(),t.setPerspective(2*e.angle,1,this.cameraNear,this.cameraFar)},_updateMatrix:function(){var e=this.matrix,t=this.camera;e.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),e.multiply(t.projectionMatrix),e.multiply(t.viewMatrix)},_initDepthMap:function(){var e=new ze;e.type=$.FLOAT_32_UNSIGNED_INT_24_8_REV,e.format=Q.DEPTH_STENCIL,e.internalformat=Q.DEPTH32F_STENCIL8,e.magFilter=J.LINEAR,e.minFilter=J.LINEAR,e.compare=te.LESS,e.generateMipmaps=!1,this.renderTarget.attach(e,ce.DEPTH_STENCIL_ATTACHMENT),this.depthMap=e}}),Hn.prototype=Object.assign(Object.create(On.prototype),{constructor:Hn,copy:function(e){return On.prototype.copy.call(this,e),this.shadow.copy(e.shadow),this}}),kn.prototype=Object.assign(Object.create(bn.prototype),{constructor:kn,bind:function(e,t){this.skeleton=e,void 0===t&&(this.updateMatrix(),t=this.worldMatrix),this.bindMatrix.copy(t),this.bindMatrixInverse.getInverse(t)},updateMatrix:function(){bn.prototype.updateMatrix.call(this),"attached"===this.bindMode?this.bindMatrixInverse.getInverse(this.worldMatrix):"detached"===this.bindMode?this.bindMatrixInverse.getInverse(this.bindMatrix):console.warn("zen3d.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)},clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),e.ATTACHMENT=ce,e.AmbientLight=Fn,e.AnimationMixer=tt,e.BLEND_EQUATION=X,e.BLEND_FACTOR=W,e.BLEND_TYPE=j,e.BasicMaterial=Tt,e.Bone=Ze,e.BooleanKeyframeTrack=nt,e.Box2=xe,e.Box3=ye,e.BufferAttribute=ut,e.CULL_FACE_TYPE=Y,e.Camera=Zr,e.Color3=Ae,e.ColorKeyframeTrack=it,e.CubeGeometry=pt,e.Curve=Le,e.CylinderGeometry=ft,e.DRAW_BUFFER={DRAW_BUFFER0:34853,DRAW_BUFFER1:34854,DRAW_BUFFER2:34855,DRAW_BUFFER3:34856,DRAW_BUFFER4:34857,DRAW_BUFFER5:34858,DRAW_BUFFER6:34859,DRAW_BUFFER7:34860,DRAW_BUFFER8:34861,DRAW_BUFFER9:34862,DRAW_BUFFER10:34863,DRAW_BUFFER11:34864,DRAW_BUFFER12:34865,DRAW_BUFFER13:34866,DRAW_BUFFER14:34867,DRAW_BUFFER15:34868},e.DRAW_MODE=oe,e.DRAW_SIDE=q,e.DefaultLoadingManager=Fe,e.DepthMaterial=Ot,e.DirectionalLight=Dn,e.DirectionalLightShadow=In,e.DistanceMaterial=Ft,e.ENVMAP_COMBINE_TYPE=se,e.EnvironmentMapPass=Jr,e.Euler=ve,e.EventDispatcher=ue,e.FOG_TYPE=k,e.FileLoader=Ie,e.Fog=function(e,t,r){this.fogType=k.NORMAL,this.color=new Ae(void 0!==e?e:0),this.near=void 0!==t?t:1,this.far=void 0!==r?r:1e3},e.FogExp2=function(e,t){this.fogType=k.EXP2,this.color=new Ae(void 0!==e?e:0),this.density=void 0!==t?t:25e-5},e.Frustum=be,e.Geometry=dt,e.Group=Cn,e.ImageLoader=Ue,e.InstancedBufferAttribute=_t,e.InstancedGeometry=mt,e.InstancedInterleavedBuffer=gt,e.InterleavedBuffer=vt,e.InterleavedBufferAttribute=Mt,e.KeyframeClip=at,e.KeyframeTrack=rt,e.LIGHT_TYPE=G,e.LambertMaterial=bt,e.Light=On,e.LightCache=sn,e.LightShadow=Un,e.LineMaterial=Rt,e.LoadingManager=Oe,e.MATERIAL_TYPE=H,e.Material=wt,e.Matrix3=Ee,e.Matrix4=me,e.Mesh=bn,e.NumberKeyframeTrack=st,e.OBJECT_TYPE=V,e.Object3D=qe,e.PBR2Material=Pt,e.PBRMaterial=Nt,e.PhongMaterial=At,e.Plane=Te,e.PlaneGeometry=Et,e.PointLight=zn,e.PointLightShadow=Bn,e.PointsMaterial=Lt,e.PropertyBindingMixer=et,e.Quaternion=Se,e.QuaternionKeyframeTrack=ot,e.RGBELoader=Be,e.Ray=de,e.Raycaster=pe,e.RenderBuffer=Qr,e.RenderList=wn,e.RenderTarget2D=Rn,e.RenderTargetBack=Pn,e.RenderTargetBase=Kr,e.RenderTargetCube=$r,e.Renderer=Ln,e.SHADING_TYPE=Z,e.SHADOW_TYPE=ie,e.Scene=Tn,e.ShaderChunk=gr,e.ShaderLib=Er,e.ShaderMaterial=Ct,e.ShaderPostPass=Nn,e.ShadowMapPass=en,e.Skeleton=Ke,e.SkinnedMesh=kn,e.Sphere=we,e.SphereGeometry=St,e.Spherical=Re,e.SpotLight=Hn,e.SpotLightShadow=Gn,e.StringKeyframeTrack=ht,e.TEXEL_ENCODING_TYPE=ae,e.TGALoader=De,e.Texture2D=ze,e.Texture3D=He,e.TextureBase=Ce,e.TextureCube=Ge,e.TorusKnotGeometry=xt,e.Triangle=Pe,e.VERTEX_COLOR=he,e.Vector2=ge,e.Vector3=le,e.Vector4=Me,e.VectorKeyframeTrack=ct,e.WEBGL_ATTRIBUTE_TYPE=ne,e.WEBGL_COMPARE_FUNC=te,e.WEBGL_PIXEL_FORMAT=Q,e.WEBGL_PIXEL_TYPE=$,e.WEBGL_TEXTURE_FILTER=J,e.WEBGL_TEXTURE_TYPE=K,e.WEBGL_TEXTURE_WRAP=ee,e.WEBGL_UNIFORM_TYPE=re,e.WebGLAttribute=fr,e.WebGLCapabilities=Ut,e.WebGLCore=qr,e.WebGLGeometry=Kt,e.WebGLProgram=vr,e.WebGLPrograms=Lr,e.WebGLProperties=Ht,e.WebGLState=Gt,e.WebGLTexture=Yt,e.WebGLUniforms=pr,e.cloneUniforms=c,e.generateUUID=a,e.isPowerOfTwo=o,e.nearestPowerOfTwo=s,e.nextPowerOfTwo=h,Object.defineProperty(e,"__esModule",{value:!0})});