UNPKG

three

Version:

JavaScript 3D library

98 lines 631 kB
// threejs.org/license (function(k,Ea){"object"===typeof exports&&"undefined"!==typeof module?Ea(exports):"function"===typeof define&&define.amd?define(["exports"],Ea):(k=k||self,Ea(k.THREE={}))})(this,function(k){function Ea(){}function u(a,b){void 0===a&&(a=0);void 0===b&&(b=0);this.x=a;this.y=b}function qa(){this.elements=[1,0,0,0,1,0,0,0,1];0<arguments.length&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}function V(a,b,c,d,e,f,g,h,l,n){Object.defineProperty(this,"id", {value:ej++});this.uuid=P.generateUUID();this.name="";this.image=void 0!==a?a:V.DEFAULT_IMAGE;this.mipmaps=[];this.mapping=void 0!==b?b:V.DEFAULT_MAPPING;this.wrapS=void 0!==c?c:1001;this.wrapT=void 0!==d?d:1001;this.magFilter=void 0!==e?e:1006;this.minFilter=void 0!==f?f:1008;this.anisotropy=void 0!==l?l:1;this.format=void 0!==g?g:1023;this.internalFormat=null;this.type=void 0!==h?h:1009;this.offset=new u(0,0);this.repeat=new u(1,1);this.center=new u(0,0);this.rotation=0;this.matrixAutoUpdate=!0; this.matrix=new qa;this.generateMipmaps=!0;this.premultiplyAlpha=!1;this.flipY=!0;this.unpackAlignment=4;this.encoding=void 0!==n?n:3E3;this.version=0;this.onUpdate=null}function S(a,b,c,d){void 0===a&&(a=0);void 0===b&&(b=0);void 0===c&&(c=0);void 0===d&&(d=1);this.x=a;this.y=b;this.z=c;this.w=d}function Ga(a,b,c){this.width=a;this.height=b;this.scissor=new S(0,0,a,b);this.scissorTest=!1;this.viewport=new S(0,0,a,b);c=c||{};this.texture=new V(void 0,c.mapping,c.wrapS,c.wrapT,c.magFilter,c.minFilter, c.format,c.type,c.anisotropy,c.encoding);this.texture.image={};this.texture.image.width=a;this.texture.image.height=b;this.texture.generateMipmaps=void 0!==c.generateMipmaps?c.generateMipmaps:!1;this.texture.minFilter=void 0!==c.minFilter?c.minFilter:1006;this.depthBuffer=void 0!==c.depthBuffer?c.depthBuffer:!0;this.stencilBuffer=void 0!==c.stencilBuffer?c.stencilBuffer:!0;this.depthTexture=void 0!==c.depthTexture?c.depthTexture:null}function ag(a,b,c){Ga.call(this,a,b,c);this.samples=4}function Y(a, b,c,d){void 0===a&&(a=0);void 0===b&&(b=0);void 0===c&&(c=0);void 0===d&&(d=1);this._x=a;this._y=b;this._z=c;this._w=d}function m(a,b,c){void 0===a&&(a=0);void 0===b&&(b=0);void 0===c&&(c=0);this.x=a;this.y=b;this.z=c}function U(){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];0<arguments.length&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}function Vb(a,b,c,d){void 0===a&&(a=0);void 0===b&&(b=0);void 0===c&&(c=0);void 0===d&&(d=Vb.DefaultOrder); this._x=a;this._y=b;this._z=c;this._order=d}function He(){this.mask=1}function C(){Object.defineProperty(this,"id",{value:fj++});this.uuid=P.generateUUID();this.name="";this.type="Object3D";this.parent=null;this.children=[];this.up=C.DefaultUp.clone();var a=new m,b=new Vb,c=new Y,d=new m(1,1,1);b._onChange(function(){c.setFromEuler(b,!1)});c._onChange(function(){b.setFromQuaternion(c,void 0,!1)});Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:a},rotation:{configurable:!0, enumerable:!0,value:b},quaternion:{configurable:!0,enumerable:!0,value:c},scale:{configurable:!0,enumerable:!0,value:d},modelViewMatrix:{value:new U},normalMatrix:{value:new qa}});this.matrix=new U;this.matrixWorld=new U;this.matrixAutoUpdate=C.DefaultMatrixAutoUpdate;this.matrixWorldNeedsUpdate=!1;this.layers=new He;this.visible=!0;this.receiveShadow=this.castShadow=!1;this.frustumCulled=!0;this.renderOrder=0;this.userData={}}function Ad(){C.call(this);this.type="Scene";this.overrideMaterial=this.fog= this.environment=this.background=null;this.autoUpdate=!0;"undefined"!==typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}function Sa(a,b){this.min=void 0!==a?a:new m(Infinity,Infinity,Infinity);this.max=void 0!==b?b:new m(-Infinity,-Infinity,-Infinity)}function bg(a,b,c,d,e){for(var f=0,g=a.length-3;f<=g;f+=3){Wb.fromArray(a,f);var h=e.x*Math.abs(Wb.x)+e.y*Math.abs(Wb.y)+e.z*Math.abs(Wb.z),l=b.dot(Wb),n=c.dot(Wb),q=d.dot(Wb);if(Math.max(-Math.max(l, n,q),Math.min(l,n,q))>h)return!1}return!0}function cb(a,b){this.center=void 0!==a?a:new m;this.radius=void 0!==b?b:-1}function Xb(a,b){this.origin=void 0!==a?a:new m;this.direction=void 0!==b?b:new m(0,0,-1)}function Ta(a,b){this.normal=void 0!==a?a:new m(1,0,0);this.constant=void 0!==b?b:0}function ba(a,b,c){this.a=void 0!==a?a:new m;this.b=void 0!==b?b:new m;this.c=void 0!==c?c:new m}function H(a,b,c){return void 0===b&&void 0===c?this.set(a):this.setRGB(a,b,c)}function cg(a,b,c){0>c&&(c+=1);1< c&&--c;return c<1/6?a+6*(b-a)*c:.5>c?b:c<2/3?a+6*(b-a)*(2/3-c):a}function dg(a){return.04045>a?.0773993808*a:Math.pow(.9478672986*a+.0521327014,2.4)}function eg(a){return.0031308>a?12.92*a:1.055*Math.pow(a,.41666)-.055}function Cc(a,b,c,d,e,f){this.a=a;this.b=b;this.c=c;this.normal=d&&d.isVector3?d:new m;this.vertexNormals=Array.isArray(d)?d:[];this.color=e&&e.isColor?e:new H;this.vertexColors=Array.isArray(e)?e:[];this.materialIndex=void 0!==f?f:0}function L(){Object.defineProperty(this,"id",{value:gj++}); this.uuid=P.generateUUID();this.name="";this.type="Material";this.fog=!0;this.blending=1;this.side=0;this.vertexColors=this.flatShading=!1;this.opacity=1;this.transparent=!1;this.blendSrc=204;this.blendDst=205;this.blendEquation=100;this.blendEquationAlpha=this.blendDstAlpha=this.blendSrcAlpha=null;this.depthFunc=3;this.depthWrite=this.depthTest=!0;this.stencilWriteMask=255;this.stencilFunc=519;this.stencilRef=0;this.stencilFuncMask=255;this.stencilZPass=this.stencilZFail=this.stencilFail=7680;this.stencilWrite= !1;this.clippingPlanes=null;this.clipShadows=this.clipIntersection=!1;this.shadowSide=null;this.colorWrite=!0;this.precision=null;this.polygonOffset=!1;this.polygonOffsetUnits=this.polygonOffsetFactor=0;this.dithering=!1;this.alphaTest=0;this.premultipliedAlpha=!1;this.toneMapped=this.visible=!0;this.userData={};this.version=0}function Na(a){L.call(this);this.type="MeshBasicMaterial";this.color=new H(16777215);this.lightMap=this.map=null;this.lightMapIntensity=1;this.aoMap=null;this.aoMapIntensity= 1;this.envMap=this.alphaMap=this.specularMap=null;this.combine=0;this.reflectivity=1;this.refractionRatio=.98;this.wireframe=!1;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.morphTargets=this.skinning=!1;this.setValues(a)}function J(a,b,c){if(Array.isArray(a))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.name="";this.array=a;this.itemSize=b;this.count=void 0!==a?a.length/b:0;this.normalized=!0===c;this.usage=35044;this.updateRange= {offset:0,count:-1};this.version=0}function Bd(a,b,c){J.call(this,new Int8Array(a),b,c)}function Cd(a,b,c){J.call(this,new Uint8Array(a),b,c)}function Dd(a,b,c){J.call(this,new Uint8ClampedArray(a),b,c)}function Ed(a,b,c){J.call(this,new Int16Array(a),b,c)}function Yb(a,b,c){J.call(this,new Uint16Array(a),b,c)}function Fd(a,b,c){J.call(this,new Int32Array(a),b,c)}function Zb(a,b,c){J.call(this,new Uint32Array(a),b,c)}function A(a,b,c){J.call(this,new Float32Array(a),b,c)}function Gd(a,b,c){J.call(this, new Float64Array(a),b,c)}function th(){this.vertices=[];this.normals=[];this.colors=[];this.uvs=[];this.uvs2=[];this.groups=[];this.morphTargets={};this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.groupsNeedUpdate=this.uvsNeedUpdate=this.colorsNeedUpdate=this.normalsNeedUpdate=this.verticesNeedUpdate=!1}function uh(a){if(0===a.length)return-Infinity;for(var b=a[0],c=1,d=a.length;c<d;++c)a[c]>b&&(b=a[c]);return b}function E(){Object.defineProperty(this,"id",{value:hj+= 2});this.uuid=P.generateUUID();this.name="";this.type="BufferGeometry";this.index=null;this.attributes={};this.morphAttributes={};this.morphTargetsRelative=!1;this.groups=[];this.boundingSphere=this.boundingBox=null;this.drawRange={start:0,count:Infinity};this.userData={}}function T(a,b){C.call(this);this.type="Mesh";this.geometry=void 0!==a?a:new E;this.material=void 0!==b?b:new Na;this.updateMorphTargets()}function vh(a,b,c,d,e,f,g,h){if(null===(1===b.side?d.intersectTriangle(g,f,e,!0,h):d.intersectTriangle(e, f,g,2!==b.side,h)))return null;Ie.copy(h);Ie.applyMatrix4(a.matrixWorld);b=c.ray.origin.distanceTo(Ie);return b<c.near||b>c.far?null:{distance:b,point:Ie.clone(),object:a}}function Je(a,b,c,d,e,f,g,h,l,n,q,p){yb.fromBufferAttribute(e,n);zb.fromBufferAttribute(e,q);Ab.fromBufferAttribute(e,p);e=a.morphTargetInfluences;if(b.morphTargets&&f&&e){Ke.set(0,0,0);Le.set(0,0,0);Me.set(0,0,0);for(var z=0,k=f.length;z<k;z++){var t=e[z],v=f[z];0!==t&&(fg.fromBufferAttribute(v,n),gg.fromBufferAttribute(v,q),hg.fromBufferAttribute(v, p),g?(Ke.addScaledVector(fg,t),Le.addScaledVector(gg,t),Me.addScaledVector(hg,t)):(Ke.addScaledVector(fg.sub(yb),t),Le.addScaledVector(gg.sub(zb),t),Me.addScaledVector(hg.sub(Ab),t)))}yb.add(Ke);zb.add(Le);Ab.add(Me)}a.isSkinnedMesh&&(a.boneTransform(n,yb),a.boneTransform(q,zb),a.boneTransform(p,Ab));if(a=vh(a,b,c,d,yb,zb,Ab,Hd))h&&(Dc.fromBufferAttribute(h,n),Ec.fromBufferAttribute(h,q),Fc.fromBufferAttribute(h,p),a.uv=ba.getUV(Hd,yb,zb,Ab,Dc,Ec,Fc,new u)),l&&(Dc.fromBufferAttribute(l,n),Ec.fromBufferAttribute(l, q),Fc.fromBufferAttribute(l,p),a.uv2=ba.getUV(Hd,yb,zb,Ab,Dc,Ec,Fc,new u)),h=new Cc(n,q,p),ba.getNormal(yb,zb,Ab,h.normal),a.face=h;return a}function F(){Object.defineProperty(this,"id",{value:ij+=2});this.uuid=P.generateUUID();this.name="";this.type="Geometry";this.vertices=[];this.colors=[];this.faces=[];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphNormals=[];this.skinWeights=[];this.skinIndices=[];this.lineDistances=[];this.boundingSphere=this.boundingBox=null;this.groupsNeedUpdate=this.lineDistancesNeedUpdate= this.colorsNeedUpdate=this.normalsNeedUpdate=this.uvsNeedUpdate=this.verticesNeedUpdate=this.elementsNeedUpdate=!1}function Gc(a,b,c,d,e,f){F.call(this);this.type="BoxGeometry";this.parameters={width:a,height:b,depth:c,widthSegments:d,heightSegments:e,depthSegments:f};this.fromBufferGeometry(new Bb(a,b,c,d,e,f));this.mergeVertices()}function Bb(a,b,c,d,e,f){function g(a,b,c,d,e,f,g,r,y,I,jj){var t=f/y,v=g/I,x=f/2,w=g/2,Q=r/2;g=y+1;for(var B=I+1,N=f=0,ca=new m,u=0;u<B;u++)for(var C=u*v-w,A=0;A<g;A++)ca[a]= (A*t-x)*d,ca[b]=C*e,ca[c]=Q,n.push(ca.x,ca.y,ca.z),ca[a]=0,ca[b]=0,ca[c]=0<r?1:-1,q.push(ca.x,ca.y,ca.z),p.push(A/y),p.push(1-u/I),f+=1;for(a=0;a<I;a++)for(b=0;b<y;b++)c=z+b+g*(a+1),d=z+(b+1)+g*(a+1),e=z+(b+1)+g*a,l.push(z+b+g*a,c,e),l.push(c,d,e),N+=6;h.addGroup(k,N,jj);k+=N;z+=f}void 0===a&&(a=1);void 0===b&&(b=1);void 0===c&&(c=1);void 0===d&&(d=1);void 0===e&&(e=1);void 0===f&&(f=1);E.call(this);this.type="BoxBufferGeometry";this.parameters={width:a,height:b,depth:c,widthSegments:d,heightSegments:e, depthSegments:f};var h=this;d=Math.floor(d);e=Math.floor(e);f=Math.floor(f);var l=[],n=[],q=[],p=[],z=0,k=0;g("z","y","x",-1,-1,c,b,a,f,e,0);g("z","y","x",1,-1,c,b,-a,f,e,1);g("x","z","y",1,1,a,c,b,d,f,2);g("x","z","y",1,-1,a,c,-b,d,f,3);g("x","y","z",1,-1,a,b,c,d,e,4);g("x","y","z",-1,-1,a,b,-c,d,e,5);this.setIndex(l);this.setAttribute("position",new A(n,3));this.setAttribute("normal",new A(q,3));this.setAttribute("uv",new A(p,2))}function Hc(a){var b={},c;for(c in a){b[c]={};for(var d in a[c]){var e= a[c][d];e&&(e.isColor||e.isMatrix3||e.isMatrix4||e.isVector2||e.isVector3||e.isVector4||e.isTexture)?b[c][d]=e.clone():Array.isArray(e)?b[c][d]=e.slice():b[c][d]=e}}return b}function Aa(a){for(var b={},c=0;c<a.length;c++){var d=Hc(a[c]),e;for(e in d)b[e]=d[e]}return b}function ra(a){L.call(this);this.type="ShaderMaterial";this.defines={};this.uniforms={};this.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}";this.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}"; this.linewidth=1;this.wireframe=!1;this.wireframeLinewidth=1;this.morphNormals=this.morphTargets=this.skinning=this.clipping=this.lights=this.fog=!1;this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1};this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]};this.index0AttributeName=void 0;this.uniformsNeedUpdate=!1;void 0!==a&&(void 0!==a.attributes&&console.error("THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead."),this.setValues(a))} function db(){C.call(this);this.type="Camera";this.matrixWorldInverse=new U;this.projectionMatrix=new U;this.projectionMatrixInverse=new U}function W(a,b,c,d){db.call(this);this.type="PerspectiveCamera";this.fov=void 0!==a?a:50;this.zoom=1;this.near=void 0!==c?c:.1;this.far=void 0!==d?d:2E3;this.focus=10;this.aspect=void 0!==b?b:1;this.view=null;this.filmGauge=35;this.filmOffset=0;this.updateProjectionMatrix()}function Ic(a,b,c){C.call(this);this.type="CubeCamera";if(!0!==c.isWebGLCubeRenderTarget)console.error("THREE.CubeCamera: The constructor now expects an instance of WebGLCubeRenderTarget as third parameter."); else{this.renderTarget=c;var d=new W(90,1,a,b);d.layers=this.layers;d.up.set(0,-1,0);d.lookAt(new m(1,0,0));this.add(d);var e=new W(90,1,a,b);e.layers=this.layers;e.up.set(0,-1,0);e.lookAt(new m(-1,0,0));this.add(e);var f=new W(90,1,a,b);f.layers=this.layers;f.up.set(0,0,1);f.lookAt(new m(0,1,0));this.add(f);var g=new W(90,1,a,b);g.layers=this.layers;g.up.set(0,0,-1);g.lookAt(new m(0,-1,0));this.add(g);var h=new W(90,1,a,b);h.layers=this.layers;h.up.set(0,-1,0);h.lookAt(new m(0,0,1));this.add(h); var l=new W(90,1,a,b);l.layers=this.layers;l.up.set(0,-1,0);l.lookAt(new m(0,0,-1));this.add(l);this.update=function(a,b){null===this.parent&&this.updateMatrixWorld();var n=a.xr.enabled,q=a.getRenderTarget();a.xr.enabled=!1;var k=c.texture.generateMipmaps;c.texture.generateMipmaps=!1;a.setRenderTarget(c,0);a.render(b,d);a.setRenderTarget(c,1);a.render(b,e);a.setRenderTarget(c,2);a.render(b,f);a.setRenderTarget(c,3);a.render(b,g);a.setRenderTarget(c,4);a.render(b,h);c.texture.generateMipmaps=k;a.setRenderTarget(c, 5);a.render(b,l);a.setRenderTarget(q);a.xr.enabled=n};this.clear=function(a,b,d,e){for(var f=a.getRenderTarget(),g=0;6>g;g++)a.setRenderTarget(c,g),a.clear(b,d,e);a.setRenderTarget(f)}}}function ac(a,b,c){Number.isInteger(b)&&(console.warn("THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )"),b=c);Ga.call(this,a,a,b)}function bc(a,b,c,d,e,f,g,h,l,n,q,p){V.call(this,null,f,g,h,l,n,d,e,q,p);this.image={data:a||null,width:b||1,height:c||1};this.magFilter= void 0!==l?l:1003;this.minFilter=void 0!==n?n:1003;this.flipY=this.generateMipmaps=!1;this.unpackAlignment=1;this.needsUpdate=!0}function Jc(a,b,c,d,e,f){this.planes=[void 0!==a?a:new Ta,void 0!==b?b:new Ta,void 0!==c?c:new Ta,void 0!==d?d:new Ta,void 0!==e?e:new Ta,void 0!==f?f:new Ta]}function wh(){function a(c,g){d(c,g);e=b.requestAnimationFrame(a)}var b=null,c=!1,d=null,e=null;return{start:function(){!0!==c&&null!==d&&(e=b.requestAnimationFrame(a),c=!0)},stop:function(){b.cancelAnimationFrame(e); c=!1},setAnimationLoop:function(a){d=a},setContext:function(a){b=a}}}function kj(a,b){function c(b,c){var d=b.array,e=b.usage,f=a.createBuffer();a.bindBuffer(c,f);a.bufferData(c,d,e);b.onUploadCallback();c=5126;d instanceof Float32Array?c=5126:d instanceof Float64Array?console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array."):d instanceof Uint16Array?c=5123:d instanceof Int16Array?c=5122:d instanceof Uint32Array?c=5125:d instanceof Int32Array?c=5124:d instanceof Int8Array? c=5120:d instanceof Uint8Array&&(c=5121);return{buffer:f,type:c,bytesPerElement:d.BYTES_PER_ELEMENT,version:b.version}}var d=b.isWebGL2,e=new WeakMap;return{get:function(a){a.isInterleavedBufferAttribute&&(a=a.data);return e.get(a)},remove:function(b){b.isInterleavedBufferAttribute&&(b=b.data);var c=e.get(b);c&&(a.deleteBuffer(c.buffer),e.delete(b))},update:function(b,g){b.isInterleavedBufferAttribute&&(b=b.data);var f=e.get(b);if(void 0===f)e.set(b,c(b,g));else if(f.version<b.version){var l=b.array, n=b.updateRange;a.bindBuffer(g,f.buffer);-1===n.count?a.bufferSubData(g,0,l):(d?a.bufferSubData(g,n.offset*l.BYTES_PER_ELEMENT,l,n.offset,n.count):a.bufferSubData(g,n.offset*l.BYTES_PER_ELEMENT,l.subarray(n.offset,n.offset+n.count)),n.count=-1);f.version=b.version}}}}function Id(a,b,c,d){F.call(this);this.type="PlaneGeometry";this.parameters={width:a,height:b,widthSegments:c,heightSegments:d};this.fromBufferGeometry(new cc(a,b,c,d));this.mergeVertices()}function cc(a,b,c,d){E.call(this);this.type= "PlaneBufferGeometry";this.parameters={width:a,height:b,widthSegments:c,heightSegments:d};a=a||1;b=b||1;var e=a/2,f=b/2;c=Math.floor(c)||1;d=Math.floor(d)||1;var g=c+1,h=d+1,l=a/c,n=b/d;b=[];a=[];for(var q=[],p=[],z=0;z<h;z++)for(var k=z*n-f,t=0;t<g;t++)a.push(t*l-e,-k,0),q.push(0,0,1),p.push(t/c),p.push(1-z/d);for(e=0;e<d;e++)for(f=0;f<c;f++)h=f+g*(e+1),l=f+1+g*(e+1),n=f+1+g*e,b.push(f+g*e,h,n),b.push(h,l,n);this.setIndex(b);this.setAttribute("position",new A(a,3));this.setAttribute("normal",new A(q, 3));this.setAttribute("uv",new A(p,2))}function lj(a,b,c,d){function e(a,c){b.buffers.color.setClear(a.r,a.g,a.b,c,d)}var f=new H(0),g=0,h,l,n=null,q=0,p=null;return{getClearColor:function(){return f},setClearColor:function(a,b){f.set(a);g=void 0!==b?b:1;e(f,g)},getClearAlpha:function(){return g},setClearAlpha:function(a){g=a;e(f,g)},render:function(b,d,t,k){d=!0===d.isScene?d.background:null;t=a.xr;(t=t.getSession&&t.getSession())&&"additive"===t.environmentBlendMode&&(d=null);null===d?e(f,g):d&& d.isColor&&(e(d,1),k=!0);(a.autoClear||k)&&a.clear(a.autoClearColor,a.autoClearDepth,a.autoClearStencil);if(d&&(d.isCubeTexture||d.isWebGLCubeRenderTarget||306===d.mapping)){void 0===l&&(l=new T(new Bb(1,1,1),new ra({name:"BackgroundCubeMaterial",uniforms:Hc(Ua.cube.uniforms),vertexShader:Ua.cube.vertexShader,fragmentShader:Ua.cube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(a,b,c){this.matrixWorld.copyPosition(c.matrixWorld)}, Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),c.update(l));k=d.isWebGLCubeRenderTarget?d.texture:d;l.material.uniforms.envMap.value=k;l.material.uniforms.flipEnvMap.value=k.isCubeTexture?-1:1;if(n!==d||q!==k.version||p!==a.toneMapping)l.material.needsUpdate=!0,n=d,q=k.version,p=a.toneMapping;b.unshift(l,l.geometry,l.material,0,0,null)}else if(d&&d.isTexture){void 0===h&&(h=new T(new cc(2,2),new ra({name:"BackgroundMaterial",uniforms:Hc(Ua.background.uniforms), vertexShader:Ua.background.vertexShader,fragmentShader:Ua.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1})),h.geometry.deleteAttribute("normal"),Object.defineProperty(h.material,"map",{get:function(){return this.uniforms.t2D.value}}),c.update(h));h.material.uniforms.t2D.value=d;!0===d.matrixAutoUpdate&&d.updateMatrix();h.material.uniforms.uvTransform.value.copy(d.matrix);if(n!==d||q!==d.version||p!==a.toneMapping)h.material.needsUpdate=!0,n=d,q=d.version,p=a.toneMapping;b.unshift(h, h.geometry,h.material,0,0,null)}}}}function mj(a,b,c,d){function e(b){return d.isWebGL2?a.bindVertexArray(b):t.bindVertexArrayOES(b)}function f(b){return d.isWebGL2?a.deleteVertexArray(b):t.deleteVertexArrayOES(b)}function g(a){for(var b=[],c=[],d=[],e=0;e<r;e++)b[e]=0,c[e]=0,d[e]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:b,enabledAttributes:c,attributeDivisors:d,object:a,attributes:{}}}function h(){for(var a=w.newAttributes,b=0,c=a.length;b<c;b++)a[b]=0}function l(a){n(a,0)} function n(c,e){var f=w.enabledAttributes,g=w.attributeDivisors;w.newAttributes[c]=1;0===f[c]&&(a.enableVertexAttribArray(c),f[c]=1);g[c]!==e&&((d.isWebGL2?a:b.get("ANGLE_instanced_arrays"))[d.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](c,e),g[c]=e)}function q(){for(var b=w.newAttributes,c=w.enabledAttributes,d=0,e=c.length;d<e;d++)c[d]!==b[d]&&(a.disableVertexAttribArray(d),c[d]=0)}function p(){k();w!==B&&(w=B,e(w.object))}function k(){B.geometry=null;B.program=null;B.wireframe=!1} var r=a.getParameter(34921),t=d.isWebGL2?null:b.get("OES_vertex_array_object"),v=d.isWebGL2||null!==t,m={},B=g(null),w=B;return{setup:function(f,p,k,z,r){var x=!1;if(v){x=!0===p.wireframe;var D=m[z.id];void 0===D&&(D={},m[z.id]=D);var y=D[k.id];void 0===y&&(y={},D[k.id]=y);D=y[x];void 0===D&&(D=g(d.isWebGL2?a.createVertexArray():t.createVertexArrayOES()),y[x]=D);x=D;w!==x&&(w=x,e(w.object));a:if(x=w.attributes,y=z.attributes,Object.keys(x).length!==Object.keys(y).length)x=!0;else{for(var B in y){D= x[B];var Q=y[B];if(D.attribute!==Q||D.data!==Q.data){x=!0;break a}}x=!1}if(x){B={};y=z.attributes;for(var ca in y)D=y[ca],Q={},Q.attribute=D,D.data&&(Q.data=D.data),B[ca]=Q;w.attributes=B}}else if(ca=!0===p.wireframe,w.geometry!==z.id||w.program!==k.id||w.wireframe!==ca)w.geometry=z.id,w.program=k.id,w.wireframe=ca,x=!0;!0===f.isInstancedMesh&&(x=!0);null!==r&&c.update(r,34963);if(x){if(!1!==d.isWebGL2||!f.isInstancedMesh&&!z.isInstancedBufferGeometry||null!==b.get("ANGLE_instanced_arrays")){h(); ca=z.attributes;k=k.getAttributes();p=p.defaultAttributeValues;for(var N in k)if(x=k[N],0<=x){var I=ca[N];if(void 0!==I){if(B=I.normalized,Q=I.itemSize,D=c.get(I),void 0!==D){var u=D.buffer;y=D.type;D=D.bytesPerElement;if(I.isInterleavedBufferAttribute){var A=I.data,C=A.stride;I=I.offset;A&&A.isInstancedInterleavedBuffer?(n(x,A.meshPerAttribute),void 0===z._maxInstanceCount&&(z._maxInstanceCount=A.meshPerAttribute*A.count)):l(x);a.bindBuffer(34962,u);C*=D;D*=I;!0!==d.isWebGL2||5124!==y&&5125!==y? a.vertexAttribPointer(x,Q,y,B,C,D):a.vertexAttribIPointer(x,Q,y,C,D)}else I.isInstancedBufferAttribute?(n(x,I.meshPerAttribute),void 0===z._maxInstanceCount&&(z._maxInstanceCount=I.meshPerAttribute*I.count)):l(x),a.bindBuffer(34962,u),D=Q,!0!==d.isWebGL2||5124!==y&&5125!==y?a.vertexAttribPointer(x,D,y,B,0,0):a.vertexAttribIPointer(x,D,y,0,0)}}else if("instanceMatrix"===N)y=c.get(f.instanceMatrix),void 0!==y&&(B=y.buffer,y=y.type,n(x+0,1),n(x+1,1),n(x+2,1),n(x+3,1),a.bindBuffer(34962,B),a.vertexAttribPointer(x+ 0,4,y,!1,64,0),a.vertexAttribPointer(x+1,4,y,!1,64,16),a.vertexAttribPointer(x+2,4,y,!1,64,32),a.vertexAttribPointer(x+3,4,y,!1,64,48));else if(void 0!==p&&(B=p[N],void 0!==B))switch(B.length){case 2:a.vertexAttrib2fv(x,B);break;case 3:a.vertexAttrib3fv(x,B);break;case 4:a.vertexAttrib4fv(x,B);break;default:a.vertexAttrib1fv(x,B)}}q()}null!==r&&a.bindBuffer(34963,c.get(r).buffer)}},reset:p,resetDefaultState:k,dispose:function(){p();for(var a in m){var b=m[a],c;for(c in b){var d=b[c],e;for(e in d)f(d[e].object), delete d[e];delete b[c]}delete m[a]}},releaseStatesOfGeometry:function(a){if(void 0!==m[a.id]){var b=m[a.id],c;for(c in b){var d=b[c],e;for(e in d)f(d[e].object),delete d[e];delete b[c]}delete m[a.id]}},releaseStatesOfProgram:function(a){for(var b in m){var c=m[b];if(void 0!==c[a.id]){var d=c[a.id],e;for(e in d)f(d[e].object),delete d[e];delete c[a.id]}}},initAttributes:h,enableAttribute:l,disableUnusedAttributes:q}}function nj(a,b,c,d){var e=d.isWebGL2,f;this.setMode=function(a){f=a};this.render= function(b,d){a.drawArrays(f,b,d);c.update(d,f,1)};this.renderInstances=function(d,h,l){if(0!==l){if(e){var g=a;var q="drawArraysInstanced"}else if(g=b.get("ANGLE_instanced_arrays"),q="drawArraysInstancedANGLE",null===g){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}g[q](f,d,h,l);c.update(h,f,l)}}}function oj(a,b,c){function d(b){if("highp"===b){if(0<a.getShaderPrecisionFormat(35633,36338).precision&& 0<a.getShaderPrecisionFormat(35632,36338).precision)return"highp";b="mediump"}return"mediump"===b&&0<a.getShaderPrecisionFormat(35633,36337).precision&&0<a.getShaderPrecisionFormat(35632,36337).precision?"mediump":"lowp"}var e,f="undefined"!==typeof WebGL2RenderingContext&&a instanceof WebGL2RenderingContext||"undefined"!==typeof WebGL2ComputeRenderingContext&&a instanceof WebGL2ComputeRenderingContext,g=void 0!==c.precision?c.precision:"highp",h=d(g);h!==g&&(console.warn("THREE.WebGLRenderer:",g, "not supported, using",h,"instead."),g=h);c=!0===c.logarithmicDepthBuffer;h=a.getParameter(34930);var l=a.getParameter(35660),n=a.getParameter(3379),q=a.getParameter(34076),p=a.getParameter(34921),k=a.getParameter(36347),r=a.getParameter(36348),t=a.getParameter(36349),v=0<l,m=f||!!b.get("OES_texture_float"),B=v&&m,w=f?a.getParameter(36183):0;return{isWebGL2:f,getMaxAnisotropy:function(){if(void 0!==e)return e;var c=b.get("EXT_texture_filter_anisotropic");return e=null!==c?a.getParameter(c.MAX_TEXTURE_MAX_ANISOTROPY_EXT): 0},getMaxPrecision:d,precision:g,logarithmicDepthBuffer:c,maxTextures:h,maxVertexTextures:l,maxTextureSize:n,maxCubemapSize:q,maxAttributes:p,maxVertexUniforms:k,maxVaryings:r,maxFragmentUniforms:t,vertexTextures:v,floatFragmentTextures:m,floatVertexTextures:B,maxSamples:w}}function pj(){function a(){n.value!==d&&(n.value=d,n.needsUpdate=0<e);c.numPlanes=e;c.numIntersection=0}function b(a,b,d,e){var f=null!==a?a.length:0,g=null;if(0!==f){g=n.value;if(!0!==e||null===g){e=d+4*f;b=b.matrixWorldInverse; l.getNormalMatrix(b);if(null===g||g.length<e)g=new Float32Array(e);for(e=0;e!==f;++e,d+=4)h.copy(a[e]).applyMatrix4(b,l),h.normal.toArray(g,d),g[d+3]=h.constant}n.value=g;n.needsUpdate=!0}c.numPlanes=f;c.numIntersection=0;return g}var c=this,d=null,e=0,f=!1,g=!1,h=new Ta,l=new qa,n={value:null,needsUpdate:!1};this.uniform=n;this.numIntersection=this.numPlanes=0;this.init=function(a,c,g){var h=0!==a.length||c||0!==e||f;f=c;d=b(a,g,0);e=a.length;return h};this.beginShadows=function(){g=!0;b(null)}; this.endShadows=function(){g=!1;a()};this.setState=function(c,h,l,k,t,v){if(!f||null===c||0===c.length||g&&!l)g?b(null):a();else{l=g?0:e;var q=4*l,p=t.clippingState||null;n.value=p;p=b(c,k,q,v);for(c=0;c!==q;++c)p[c]=d[c];t.clippingState=p;this.numIntersection=h?this.numPlanes:0;this.numPlanes+=l}}}function qj(a){var b={};return{has:function(c){if(void 0!==b[c])return b[c];switch(c){case "WEBGL_depth_texture":var d=a.getExtension("WEBGL_depth_texture")||a.getExtension("MOZ_WEBGL_depth_texture")|| a.getExtension("WEBKIT_WEBGL_depth_texture");break;case "EXT_texture_filter_anisotropic":d=a.getExtension("EXT_texture_filter_anisotropic")||a.getExtension("MOZ_EXT_texture_filter_anisotropic")||a.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case "WEBGL_compressed_texture_s3tc":d=a.getExtension("WEBGL_compressed_texture_s3tc")||a.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||a.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case "WEBGL_compressed_texture_pvrtc":d=a.getExtension("WEBGL_compressed_texture_pvrtc")|| a.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:d=a.getExtension(c)}b[c]=d;return!!d},get:function(a){this.has(a)||console.warn("THREE.WebGLRenderer: "+a+" extension not supported.");return b[a]}}}function rj(a,b,c,d){function e(a){a=a.target;var f=g.get(a);null!==f.index&&b.remove(f.index);for(var l in f.attributes)b.remove(f.attributes[l]);a.removeEventListener("dispose",e);g.delete(a);if(l=h.get(f))b.remove(l),h.delete(f);d.releaseStatesOfGeometry(a);!0===a.isInstancedBufferGeometry&& delete a._maxInstanceCount;c.memory.geometries--}function f(a){var c=[],d=a.index,e=a.attributes.position;if(null!==d){e=d.array;d=d.version;for(var f=0,g=e.length;f<g;f+=3){var l=e[f+0],k=e[f+1],m=e[f+2];c.push(l,k,k,m,m,l)}}else for(f=e.array,d=e.version,e=0,f=f.length/3-1;e<f;e+=3)g=e+0,l=e+1,k=e+2,c.push(g,l,l,k,k,g);c=new (65535<uh(c)?Zb:Yb)(c,1);c.version=d;(d=h.get(a))&&b.remove(d);h.set(a,c)}var g=new WeakMap,h=new WeakMap;return{get:function(a,b){var d=g.get(b);if(d)return d;b.addEventListener("dispose", e);b.isBufferGeometry?d=b:b.isGeometry&&(void 0===b._bufferGeometry&&(b._bufferGeometry=(new E).setFromObject(a)),d=b._bufferGeometry);g.set(b,d);c.memory.geometries++;return d},update:function(a){var c=a.attributes;for(e in c)b.update(c[e],34962);a=a.morphAttributes;for(var d in a){c=a[d];var e=0;for(var f=c.length;e<f;e++)b.update(c[e],34962)}},getWireframeAttribute:function(a){var b=h.get(a);if(b){var c=a.index;null!==c&&b.version<c.version&&f(a)}else f(a);return h.get(a)}}}function sj(a,b,c,d){var e= d.isWebGL2,f,g,h;this.setMode=function(a){f=a};this.setIndex=function(a){g=a.type;h=a.bytesPerElement};this.render=function(b,d){a.drawElements(f,d,g,b*h);c.update(d,f,1)};this.renderInstances=function(d,n,q){if(0!==q){if(e){var l=a;var k="drawElementsInstanced"}else if(l=b.get("ANGLE_instanced_arrays"),k="drawElementsInstancedANGLE",null===l){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}l[k](f, n,g,d*h,q);c.update(n,f,q)}}}function tj(a){var b={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:b,programs:null,autoReset:!0,reset:function(){b.frame++;b.calls=0;b.triangles=0;b.points=0;b.lines=0},update:function(a,d,e){b.calls++;switch(d){case 4:b.triangles+=a/3*e;break;case 1:b.lines+=a/2*e;break;case 3:b.lines+=e*(a-1);break;case 2:b.lines+=e*a;break;case 0:b.points+=e*a;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",d)}}}}function uj(a, b){return a[0]-b[0]}function vj(a,b){return Math.abs(b[1])-Math.abs(a[1])}function wj(a){for(var b={},c=new Float32Array(8),d=[],e=0;8>e;e++)d[e]=[e,0];return{update:function(e,g,h,l){var f=e.morphTargetInfluences;e=void 0===f?0:f.length;var q=b[g.id];if(void 0===q){q=[];for(var p=0;p<e;p++)q[p]=[p,0];b[g.id]=q}for(p=0;p<e;p++){var k=q[p];k[0]=p;k[1]=f[p]}q.sort(vj);for(f=0;8>f;f++)f<e&&q[f][1]?(d[f][0]=q[f][0],d[f][1]=q[f][1]):(d[f][0]=Number.MAX_SAFE_INTEGER,d[f][1]=0);d.sort(uj);e=h.morphTargets&& g.morphAttributes.position;h=h.morphNormals&&g.morphAttributes.normal;for(f=q=0;8>f;f++)k=d[f],p=k[0],k=k[1],p!==Number.MAX_SAFE_INTEGER&&k?(e&&g.getAttribute("morphTarget"+f)!==e[p]&&g.setAttribute("morphTarget"+f,e[p]),h&&g.getAttribute("morphNormal"+f)!==h[p]&&g.setAttribute("morphNormal"+f,h[p]),c[f]=k,q+=k):(e&&void 0!==g.getAttribute("morphTarget"+f)&&g.deleteAttribute("morphTarget"+f),h&&void 0!==g.getAttribute("morphNormal"+f)&&g.deleteAttribute("morphNormal"+f),c[f]=0);g=g.morphTargetsRelative? 1:1-q;l.getUniforms().setValue(a,"morphTargetBaseInfluence",g);l.getUniforms().setValue(a,"morphTargetInfluences",c)}}}function xj(a,b,c,d){var e=new WeakMap;return{update:function(a){var f=d.render.frame,h=a.geometry,l=b.get(a,h);e.get(l)!==f&&(h.isGeometry&&l.updateFromObject(a),b.update(l),e.set(l,f));a.isInstancedMesh&&c.update(a.instanceMatrix,34962);return l},dispose:function(){e=new WeakMap}}}function ob(a,b,c,d,e,f,g,h,l,n){a=void 0!==a?a:[];V.call(this,a,void 0!==b?b:301,c,d,e,f,void 0!== g?g:1022,h,l,n);this.flipY=!1}function Kc(a,b,c,d){V.call(this,null);this.image={data:a||null,width:b||1,height:c||1,depth:d||1};this.minFilter=this.magFilter=1003;this.wrapR=1001;this.flipY=this.generateMipmaps=!1;this.needsUpdate=!0}function Lc(a,b,c,d){V.call(this,null);this.image={data:a||null,width:b||1,height:c||1,depth:d||1};this.minFilter=this.magFilter=1003;this.wrapR=1001;this.flipY=this.generateMipmaps=!1;this.needsUpdate=!0}function Mc(a,b,c){var d=a[0];if(0>=d||0<d)return a;var e=b*c, f=xh[e];void 0===f&&(f=new Float32Array(e),xh[e]=f);if(0!==b)for(d.toArray(f,0),d=1,e=0;d!==b;++d)e+=c,a[d].toArray(f,e);return f}function Oa(a,b){if(a.length!==b.length)return!1;for(var c=0,d=a.length;c<d;c++)if(a[c]!==b[c])return!1;return!0}function Fa(a,b){for(var c=0,d=b.length;c<d;c++)a[c]=b[c]}function yh(a,b){var c=zh[b];void 0===c&&(c=new Int32Array(b),zh[b]=c);for(var d=0;d!==b;++d)c[d]=a.allocateTextureUnit();return c}function yj(a,b){var c=this.cache;c[0]!==b&&(a.uniform1f(this.addr,b), c[0]=b)}function zj(a,b){var c=this.cache;if(void 0!==b.x){if(c[0]!==b.x||c[1]!==b.y)a.uniform2f(this.addr,b.x,b.y),c[0]=b.x,c[1]=b.y}else Oa(c,b)||(a.uniform2fv(this.addr,b),Fa(c,b))}function Aj(a,b){var c=this.cache;if(void 0!==b.x){if(c[0]!==b.x||c[1]!==b.y||c[2]!==b.z)a.uniform3f(this.addr,b.x,b.y,b.z),c[0]=b.x,c[1]=b.y,c[2]=b.z}else if(void 0!==b.r){if(c[0]!==b.r||c[1]!==b.g||c[2]!==b.b)a.uniform3f(this.addr,b.r,b.g,b.b),c[0]=b.r,c[1]=b.g,c[2]=b.b}else Oa(c,b)||(a.uniform3fv(this.addr,b),Fa(c, b))}function Bj(a,b){var c=this.cache;if(void 0!==b.x){if(c[0]!==b.x||c[1]!==b.y||c[2]!==b.z||c[3]!==b.w)a.uniform4f(this.addr,b.x,b.y,b.z,b.w),c[0]=b.x,c[1]=b.y,c[2]=b.z,c[3]=b.w}else Oa(c,b)||(a.uniform4fv(this.addr,b),Fa(c,b))}function Cj(a,b){var c=this.cache,d=b.elements;void 0===d?Oa(c,b)||(a.uniformMatrix2fv(this.addr,!1,b),Fa(c,b)):Oa(c,d)||(Ah.set(d),a.uniformMatrix2fv(this.addr,!1,Ah),Fa(c,d))}function Dj(a,b){var c=this.cache,d=b.elements;void 0===d?Oa(c,b)||(a.uniformMatrix3fv(this.addr, !1,b),Fa(c,b)):Oa(c,d)||(Bh.set(d),a.uniformMatrix3fv(this.addr,!1,Bh),Fa(c,d))}function Ej(a,b){var c=this.cache,d=b.elements;void 0===d?Oa(c,b)||(a.uniformMatrix4fv(this.addr,!1,b),Fa(c,b)):Oa(c,d)||(Ch.set(d),a.uniformMatrix4fv(this.addr,!1,Ch),Fa(c,d))}function Fj(a,b,c){var d=this.cache,e=c.allocateTextureUnit();d[0]!==e&&(a.uniform1i(this.addr,e),d[0]=e);c.safeSetTexture2D(b||Dh,e)}function Gj(a,b,c){var d=this.cache,e=c.allocateTextureUnit();d[0]!==e&&(a.uniform1i(this.addr,e),d[0]=e);c.setTexture2DArray(b|| Hj,e)}function Ij(a,b,c){var d=this.cache,e=c.allocateTextureUnit();d[0]!==e&&(a.uniform1i(this.addr,e),d[0]=e);c.setTexture3D(b||Jj,e)}function Kj(a,b,c){var d=this.cache,e=c.allocateTextureUnit();d[0]!==e&&(a.uniform1i(this.addr,e),d[0]=e);c.safeSetTextureCube(b||Eh,e)}function Lj(a,b){var c=this.cache;c[0]!==b&&(a.uniform1i(this.addr,b),c[0]=b)}function Mj(a,b){var c=this.cache;Oa(c,b)||(a.uniform2iv(this.addr,b),Fa(c,b))}function Nj(a,b){var c=this.cache;Oa(c,b)||(a.uniform3iv(this.addr,b),Fa(c, b))}function Oj(a,b){var c=this.cache;Oa(c,b)||(a.uniform4iv(this.addr,b),Fa(c,b))}function Pj(a,b){var c=this.cache;c[0]!==b&&(a.uniform1ui(this.addr,b),c[0]=b)}function Qj(a){switch(a){case 5126:return yj;case 35664:return zj;case 35665:return Aj;case 35666:return Bj;case 35674:return Cj;case 35675:return Dj;case 35676:return Ej;case 5124:case 35670:return Lj;case 35667:case 35671:return Mj;case 35668:case 35672:return Nj;case 35669:case 35673:return Oj;case 5125:return Pj;case 35678:case 36198:case 36298:case 36306:case 35682:return Fj; case 35679:case 36299:case 36307:return Ij;case 35680:case 36300:case 36308:case 36293:return Kj;case 36289:case 36303:case 36311:case 36292:return Gj}}function Rj(a,b){a.uniform1fv(this.addr,b)}function Sj(a,b){a.uniform1iv(this.addr,b)}function Tj(a,b){a.uniform2iv(this.addr,b)}function Uj(a,b){a.uniform3iv(this.addr,b)}function Vj(a,b){a.uniform4iv(this.addr,b)}function Wj(a,b){b=Mc(b,this.size,2);a.uniform2fv(this.addr,b)}function Xj(a,b){b=Mc(b,this.size,3);a.uniform3fv(this.addr,b)}function Yj(a, b){b=Mc(b,this.size,4);a.uniform4fv(this.addr,b)}function Zj(a,b){b=Mc(b,this.size,4);a.uniformMatrix2fv(this.addr,!1,b)}function ak(a,b){b=Mc(b,this.size,9);a.uniformMatrix3fv(this.addr,!1,b)}function bk(a,b){b=Mc(b,this.size,16);a.uniformMatrix4fv(this.addr,!1,b)}function ck(a,b,c){var d=b.length,e=yh(c,d);a.uniform1iv(this.addr,e);for(a=0;a!==d;++a)c.safeSetTexture2D(b[a]||Dh,e[a])}function dk(a,b,c){var d=b.length,e=yh(c,d);a.uniform1iv(this.addr,e);for(a=0;a!==d;++a)c.safeSetTextureCube(b[a]|| Eh,e[a])}function ek(a){switch(a){case 5126:return Rj;case 35664:return Wj;case 35665:return Xj;case 35666:return Yj;case 35674:return Zj;case 35675:return ak;case 35676:return bk;case 5124:case 35670:return Sj;case 35667:case 35671:return Tj;case 35668:case 35672:return Uj;case 35669:case 35673:return Vj;case 35678:case 36198:case 36298:case 36306:case 35682:return ck;case 35680:case 36300:case 36308:case 36293:return dk}}function fk(a,b,c){this.id=a;this.addr=c;this.cache=[];this.setValue=Qj(b.type)} function Fh(a,b,c){this.id=a;this.addr=c;this.cache=[];this.size=b.size;this.setValue=ek(b.type)}function Gh(a){this.id=a;this.seq=[];this.map={}}function Cb(a,b){this.seq=[];this.map={};for(var c=a.getProgramParameter(b,35718),d=0;d<c;++d){var e=a.getActiveUniform(b,d),f=a.getUniformLocation(b,e.name),g=this,h=e.name,l=h.length;for(ig.lastIndex=0;;){var n=ig.exec(h),q=ig.lastIndex,p=n[1],k=n[3];"]"===n[2]&&(p|=0);if(void 0===k||"["===k&&q+2===l){h=g;e=void 0===k?new fk(p,e,f):new Fh(p,e,f);h.seq.push(e); h.map[e.id]=e;break}else k=g.map[p],void 0===k&&(k=new Gh(p),p=g,g=k,p.seq.push(g),p.map[g.id]=g),g=k}}}function Hh(a,b,c){b=a.createShader(b);a.shaderSource(b,c);a.compileShader(b);return b}function Ih(a){switch(a){case 3E3:return["Linear","( value )"];case 3001:return["sRGB","( value )"];case 3002:return["RGBE","( value )"];case 3004:return["RGBM","( value, 7.0 )"];case 3005:return["RGBM","( value, 16.0 )"];case 3006:return["RGBD","( value, 256.0 )"];case 3007:return["Gamma","( value, float( GAMMA_FACTOR ) )"]; case 3003:return["LogLuv","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported encoding:",a),["Linear","( value )"]}}function Jh(a,b,c){var d=a.getShaderParameter(b,35713),e=a.getShaderInfoLog(b).trim();if(d&&""===e)return"";a=a.getShaderSource(b).split("\n");for(b=0;b<a.length;b++)a[b]=b+1+": "+a[b];a=a.join("\n");return"THREE.WebGLShader: gl.getShaderInfoLog() "+c+"\n"+e+a}function Jd(a,b){b=Ih(b);return"vec4 "+a+"( vec4 value ) { return "+b[0]+"ToLinear"+b[1]+"; }"}function gk(a, b){b=Ih(b);return"vec4 "+a+"( vec4 value ) { return LinearTo"+b[0]+b[1]+"; }"}function hk(a,b){switch(b){case 1:b="Linear";break;case 2:b="Reinhard";break;case 3:b="OptimizedCineon";break;case 4:b="ACESFilmic";break;case 5:b="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",b),b="Linear"}return"vec3 "+a+"( vec3 color ) { return "+b+"ToneMapping( color ); }"}function ik(a){var b=[],c;for(c in a){var d=a[c];!1!==d&&b.push("#define "+c+" "+d)}return b.join("\n")}function Kd(a){return""!== a}function Kh(a,b){return a.replace(/NUM_DIR_LIGHTS/g,b.numDirLights).replace(/NUM_SPOT_LIGHTS/g,b.numSpotLights).replace(/NUM_RECT_AREA_LIGHTS/g,b.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,b.numPointLights).replace(/NUM_HEMI_LIGHTS/g,b.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,b.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS/g,b.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,b.numPointLightShadows)}function Lh(a,b){return a.replace(/NUM_CLIPPING_PLANES/g,b.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g, b.numClippingPlanes-b.numClipIntersection)}function jg(a,b){a=O[b];if(void 0===a)throw Error("Can not resolve #include <"+b+">");return a.replace(kg,jg)}function Mh(a,b,c,d){console.warn("WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead.");return lg(a,b,c,d)}function lg(a,b,c,d){a="";for(b=parseInt(b);b<parseInt(c);b++)a+=d.replace(/\[ i \]/g,"[ "+b+" ]").replace(/UNROLLED_LOOP_INDEX/g,b);return a}function Nh(a){var b="precision "+ a.precision+" float;\nprecision "+a.precision+" int;";"highp"===a.precision?b+="\n#define HIGH_PRECISION":"mediump"===a.precision?b+="\n#define MEDIUM_PRECISION":"lowp"===a.precision&&(b+="\n#define LOW_PRECISION");return b}function jk(a){var b="SHADOWMAP_TYPE_BASIC";1===a.shadowMapType?b="SHADOWMAP_TYPE_PCF":2===a.shadowMapType?b="SHADOWMAP_TYPE_PCF_SOFT":3===a.shadowMapType&&(b="SHADOWMAP_TYPE_VSM");return b}function kk(a){var b="ENVMAP_TYPE_CUBE";if(a.envMap)switch(a.envMapMode){case 301:case 302:b= "ENVMAP_TYPE_CUBE";break;case 306:case 307:b="ENVMAP_TYPE_CUBE_UV";break;case 303:case 304:b="ENVMAP_TYPE_EQUIREC"}return b}function lk(a){var b="ENVMAP_MODE_REFLECTION";if(a.envMap)switch(a.envMapMode){case 302:case 304:case 307:b="ENVMAP_MODE_REFRACTION"}return b}function mk(a){var b="ENVMAP_BLENDING_NONE";if(a.envMap)switch(a.combine){case 0:b="ENVMAP_BLENDING_MULTIPLY";break;case 1:b="ENVMAP_BLENDING_MIX";break;case 2:b="ENVMAP_BLENDING_ADD"}return b}function nk(a,b,c,d){var e=a.getContext(), f=c.defines,g=c.vertexShader,h=c.fragmentShader,l=jk(c),n=kk(c),q=lk(c),p=mk(c),k=0<a.gammaFactor?a.gammaFactor:1,r=c.isWebGL2?"":[c.extensionDerivatives||c.envMapCubeUV||c.bumpMap||c.tangentSpaceNormalMap||c.clearcoatNormalMap||c.flatShading||"physical"===c.shaderID?"#extension GL_OES_standard_derivatives : enable":"",(c.extensionFragDepth||c.logarithmicDepthBuffer)&&c.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",c.extensionDrawBuffers&&c.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require": "",(c.extensionShaderTextureLOD||c.envMap)&&c.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(Kd).join("\n"),t=ik(f),v=e.createProgram();c.isRawShaderMaterial?(f=[t].filter(Kd).join("\n"),0<f.length&&(f+="\n"),l=[r,t].filter(Kd).join("\n"),0<l.length&&(l+="\n")):(f=[Nh(c),"#define SHADER_NAME "+c.shaderName,t,c.instancing?"#define USE_INSTANCING":"",c.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+k,"#define MAX_BONES "+c.maxBones, c.useFog&&c.fog?"#define USE_FOG":"",c.useFog&&c.fogExp2?"#define FOG_EXP2":"",c.map?"#define USE_MAP":"",c.envMap?"#define USE_ENVMAP":"",c.envMap?"#define "+q:"",c.lightMap?"#define USE_LIGHTMAP":"",c.aoMap?"#define USE_AOMAP":"",c.emissiveMap?"#define USE_EMISSIVEMAP":"",c.bumpMap?"#define USE_BUMPMAP":"",c.normalMap?"#define USE_NORMALMAP":"",c.normalMap&&c.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",c.normalMap&&c.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",c.clearcoatMap? "#define USE_CLEARCOATMAP":"",c.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",c.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",c.displacementMap&&c.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",c.specularMap?"#define USE_SPECULARMAP":"",c.roughnessMap?"#define USE_ROUGHNESSMAP":"",c.metalnessMap?"#define USE_METALNESSMAP":"",c.alphaMap?"#define USE_ALPHAMAP":"",c.transmissionMap?"#define USE_TRANSMISSIONMAP":"",c.vertexTangents?"#define USE_TANGENT":"",c.vertexColors? "#define USE_COLOR":"",c.vertexUvs?"#define USE_UV":"",c.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",c.flatShading?"#define FLAT_SHADED":"",c.skinning?"#define USE_SKINNING":"",c.useVertexTexture?"#define BONE_TEXTURE":"",c.morphTargets?"#define USE_MORPHTARGETS":"",c.morphNormals&&!1===c.flatShading?"#define USE_MORPHNORMALS":"",c.doubleSided?"#define DOUBLE_SIDED":"",c.flipSided?"#define FLIP_SIDED":"",c.shadowMapEnabled?"#define USE_SHADOWMAP":"",c.shadowMapEnabled?"#define "+l:"",c.sizeAttenuation? "#define USE_SIZEATTENUATION":"",c.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",c.logarithmicDepthBuffer&&c.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","attribute vec3 position;","attribute vec3 normal;", "attribute vec2 uv;","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#ifdef USE_COLOR","\tattribute vec3 color;","#endif","#ifdef USE_MORPHTARGETS","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;", "\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(Kd).join("\n"),l=[r,Nh(c),"#define SHADER_NAME "+c.shaderName,t,c.alphaTest?"#define ALPHATEST "+c.alphaTest+(c.alphaTest%1?"":".0"):"","#define GAMMA_FACTOR "+k,c.useFog&&c.fog?"#define USE_FOG":"",c.useFog&&c.fogExp2?"#define FOG_EXP2":"",c.map?"#define USE_MAP":"",c.matcap? "#define USE_MATCAP":"",c.envMap?"#define USE_ENVMAP":"",c.envMap?"#define "+n:"",c.envMap?"#define "+q:"",c.envMap?"#define "+p:"",c.lightMap?"#define USE_LIGHTMAP":"",c.aoMap?"#define USE_AOMAP":"",c.emissiveMap?"#define USE_EMISSIVEMAP":"",c.bumpMap?"#define USE_BUMPMAP":"",c.normalMap?"#define USE_NORMALMAP":"",c.normalMap&&c.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",c.normalMap&&c.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",c.clearcoatMap?"#define USE_CLEARCOATMAP": "",c.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",c.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",c.specularMap?"#define USE_SPECULARMAP":"",c.roughnessMap?"#define USE_ROUGHNESSMAP":"",c.metalnessMap?"#define USE_METALNESSMAP":"",c.alphaMap?"#define USE_ALPHAMAP":"",c.sheen?"#define USE_SHEEN":"",c.transmissionMap?"#define USE_TRANSMISSIONMAP":"",c.vertexTangents?"#define USE_TANGENT":"",c.vertexColors?"#define USE_COLOR":"",c.vertexUvs?"#define USE_UV":"",c.uvsVertexOnly? "#define UVS_VERTEX_ONLY":"",c.gradientMap?"#define USE_GRADIENTMAP":"",c.flatShading?"#define FLAT_SHADED":"",c.doubleSided?"#define DOUBLE_SIDED":"",c.flipSided?"#define FLIP_SIDED":"",c.shadowMapEnabled?"#define USE_SHADOWMAP":"",c.shadowMapEnabled?"#define "+l:"",c.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",c.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",c.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",c.logarithmicDepthBuffer&&c.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT": "",(c.extensionShaderTextureLOD||c.envMap)&&c.rendererExtensionShaderTextureLod?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",0!==c.toneMapping?"#define TONE_MAPPING":"",0!==c.toneMapping?O.tonemapping_pars_fragment:"",0!==c.toneMapping?hk("toneMapping",c.toneMapping):"",c.dithering?"#define DITHERING":"",O.encodings_pars_fragment,c.map?Jd("mapTexelToLinear",c.mapEncoding):"",c.matcap?Jd("matcapTexelToLinear",c.matcapEncoding): "",c.envMap?Jd("envMapTexelToLinear",c.envMapEncoding):"",c.emissiveMap?Jd("emissiveMapTexelToLinear",c.emissiveMapEncoding):"",c.lightMap?Jd("lightMapTexelToLinear",c.lightMapEncoding):"",gk("linearToOutputTexel",c.outputEncoding),c.depthPacking?"#define DEPTH_PACKING "+c.depthPacking:"","\n"].filter(Kd).join("\n"));g=g.replace(kg,jg);g=Kh(g,c);g=Lh(g,c);h=h.replace(kg,jg);h=Kh(h,c);h=Lh(h,c);g=g.replace(Oh,lg).replace(Ph,Mh);h=h.replace(Oh,lg).replace(Ph,Mh);c.isWebGL2&&!c.isRawShaderMaterial&& (f="#version 300 es\n\n#define attribute in\n#define varying out\n#define texture2D texture\n"+f,l="#version 300 es\n\n#define varying in\nout highp vec4 pc_fragColor;\n#define gl_FragColor pc_fragColor\n#define gl_FragDepthEXT gl_FragDepth\n#define texture2D texture\n#define textureCube texture\n#define texture2DProj textureProj\n#define texture2DLodEXT textureLod\n#define texture2DProjLodEXT textureProjLod\n#define textureCubeLodEXT textureLod\n#define texture2DGradEXT textureGrad\n#define texture2DProjGradEXT textureProjGrad\n#define textureCubeGradEXT textureGrad\n"+ l);h=l+h;g=Hh(e,35633,f+g);h=Hh(e,35632,h);e.attachShader(v,g);e.attachShader(v,h);void 0!==c.index0AttributeName?e.bindAttribLocation(v,0,c.index0AttributeName):!0===c.morphTargets&&e.bindAttribLocation(v,0,"position");e.linkProgram(v);if(a.debug.checkShaderErrors){a=e.getProgramInfoLog(v).trim();n=e.getShaderInfoLog(g).trim();q=e.getShaderInfoLog(h).trim();k=p=!0;if(!1===e.getProgramParameter(v,35714))p=!1,r=Jh(e,g,"vertex"),t=Jh(e,h,"fragment"),console.error("THREE.WebGLProgram: shader error: ", e.getError(),"35715",e.getProgramParameter(v,35715),"gl.getProgramInfoLog",a,r,t);else if(""!==a)console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",a);else if(""===n||""===q)k=!1;k&&(this.diagnostics={runnable:p,programLog:a,vertexShader:{log:n,prefix:f},fragmentShader:{log:q,prefix:l}})}e.deleteShader(g);e.deleteShader(h);var m;this.getUniforms=function(){void 0===m&&(m=new Cb(e,v));return m};var B;this.getAttributes=function(){if(void 0===B){for(var a={},b=e.getProgramParameter(v,35721), c=0;c<b;c++){var d=e.getActiveAttrib(v,c).name;a[d]=e.getAttribLocation(v,d)}B=a}return B};this.destroy=function(){d.releaseStatesOfProgram(this);e.deleteProgram(v);this.program=void 0};this.name=c.shaderName;this.id=ok++;this.cacheKey=b;this.usedTimes=1;this.program=v;this.vertexShader=g;this.fragmentShader=h;return this}function pk(a,b,c,d){function e(a){if(a)a.isTexture?b=a.encoding:a.isWebGLRenderTarget&&(console.warn("THREE.WebGLPrograms.getTextureEncodingFromMap: don't use render targets as textures. Use their .texture property instead."), b=a.texture.encoding);else var b=3E3;return b}var f=[],g=c.isWebGL2,h=c.logarithmicDepthBuffer,l=c.floatVertexTextures,n=c.maxVertexUniforms,q=c.vertexTextures,p=c.precision,k={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed", PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"},r="precision isWebGL2 supportsVertexTextures outputEncoding instancing map mapEncoding matcap matcapEncoding envMap envMapMode envMapEncoding envMapCubeUV lightMap lightMapEncoding aoMap emissiveMap emissiveMapEncoding bumpMap normalMap objectSpaceNormalMap tangentSpaceNormalMap clearcoatMap clearcoatRoughnessMap clearcoatNormalMap displacementMap specularMap roughnessMap metalnessMap gradientMap alphaMap combine vertexColors vertexTangents vertexUvs uvsVertexOnly fog useFog fogExp2 flatShading sizeAttenuation logarithmicDepthBuffer skinning maxBones useVertexTexture morphTargets morphNormals maxMorphTar