@jake-niemiec/react-planner
Version:
react-planner is a React Component for plans design. Draw a 2D floorplan and navigate it in 3D mode.
1 lines • 719 kB
JavaScript
webpackJsonp([1],{0:function(t,e,n){"use strict";t.exports=n(185)},1:function(t,e,n){"use strict";function r(){}function i(t,e){this.x=t||0,this.y=e||0}function o(t,e,n,r,a,s,u,c,l,h){Object.defineProperty(this,"id",{value:Jo++}),this.uuid=Zo.generateUUID(),this.name="",this.image=void 0!==t?t:o.DEFAULT_IMAGE,this.mipmaps=[],this.mapping=void 0!==e?e:o.DEFAULT_MAPPING,this.wrapS=void 0!==n?n:Vi,this.wrapT=void 0!==r?r:Vi,this.magFilter=void 0!==a?a:Ki,this.minFilter=void 0!==s?s:Ji,this.anisotropy=void 0!==l?l:1,this.format=void 0!==u?u:po,this.type=void 0!==c?c:Qi,this.offset=new i(0,0),this.repeat=new i(1,1),this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=void 0!==h?h:Bo,this.version=0,this.onUpdate=null}function a(t,e,n,r){this.x=t||0,this.y=e||0,this.z=n||0,this.w=void 0!==r?r:1}function s(t,e,n){this.uuid=Zo.generateUUID(),this.width=t,this.height=e,this.scissor=new a(0,0,t,e),this.scissorTest=!1,this.viewport=new a(0,0,t,e),void 0===(n=n||{}).minFilter&&(n.minFilter=Ki),this.texture=new o(void 0,void 0,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.encoding),this.depthBuffer=void 0===n.depthBuffer||n.depthBuffer,this.stencilBuffer=void 0===n.stencilBuffer||n.stencilBuffer,this.depthTexture=void 0!==n.depthTexture?n.depthTexture:null}function u(t,e,n){s.call(this,t,e,n),this.activeCubeFace=0,this.activeMipMapLevel=0}function c(t,e,n,r){this._x=t||0,this._y=e||0,this._z=n||0,this._w=void 0!==r?r:1}function l(t,e,n){this.x=t||0,this.y=e||0,this.z=n||0}function h(){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}function p(t,e,n,r,i,a,s,u,c,l,h,p){o.call(this,null,a,s,u,c,l,r,i,h,p),this.image={data:t,width:e,height:n},this.magFilter=void 0!==c?c:qi,this.minFilter=void 0!==l?l:qi,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}function d(t,e,n,r,i,a,s,u,c,l){o.call(this,t=void 0!==t?t:[],e=void 0!==e?e:Ui,n,r,i,a,s,u,c,l),this.flipY=!1}function f(){this.seq=[],this.map={}}function m(t,e,n){var r=t[0];if(r<=0||r>0)return t;var i=e*n,o=ta[i];if(void 0===o&&(o=new Float32Array(i),ta[i]=o),0!==e){r.toArray(o,0);for(var a=1,s=0;a!==e;++a)s+=n,t[a].toArray(o,s)}return o}function v(t,e){var n=ea[e];void 0===n&&(n=new Int32Array(e),ea[e]=n);for(var r=0;r!==e;++r)n[r]=t.allocTextureUnit();return n}function g(t,e){t.uniform2iv(this.addr,e)}function y(t,e){t.uniform3iv(this.addr,e)}function _(t,e){t.uniform4iv(this.addr,e)}function b(t){this.id=t,f.call(this)}function x(t,e){t.seq.push(e),t.map[e.id]=e}function w(t,e,n){f.call(this),this.renderer=n;for(var r=t.getProgramParameter(e,t.ACTIVE_UNIFORMS),i=0;i<r;++i){var o=t.getActiveUniform(e,i),a=o.name;!function(t,e,n){var r=t.name,i=r.length;for(ia.lastIndex=0;;){var o=ia.exec(r),a=ia.lastIndex,s=o[1],u="]"===o[2],c=o[3];if(u&&(s|=0),void 0===c||"["===c&&a+2===i){x(n,void 0===c?new function(t,e,n){this.id=t,this.addr=n,this.setValue=function(t){switch(e.type){case 5126:return function(t,e){t.uniform1f(this.addr,e)};case 35664:return function(t,e){void 0===e.x?t.uniform2fv(this.addr,e):t.uniform2f(this.addr,e.x,e.y)};case 35665:return function(t,e){void 0!==e.x?t.uniform3f(this.addr,e.x,e.y,e.z):void 0!==e.r?t.uniform3f(this.addr,e.r,e.g,e.b):t.uniform3fv(this.addr,e)};case 35666:return function(t,e){void 0===e.x?t.uniform4fv(this.addr,e):t.uniform4f(this.addr,e.x,e.y,e.z,e.w)};case 35674:return function(t,e){t.uniformMatrix2fv(this.addr,!1,e.elements||e)};case 35675:return function(t,e){void 0===e.elements?t.uniformMatrix3fv(this.addr,!1,e):(ra.set(e.elements),t.uniformMatrix3fv(this.addr,!1,ra))};case 35676:return function(t,e){void 0===e.elements?t.uniformMatrix4fv(this.addr,!1,e):(na.set(e.elements),t.uniformMatrix4fv(this.addr,!1,na))};case 35678:case 36198:return function(t,e,n){var r=n.allocTextureUnit();t.uniform1i(this.addr,r),n.setTexture2D(e||Qo,r)};case 35680:return function(t,e,n){var r=n.allocTextureUnit();t.uniform1i(this.addr,r),n.setTextureCube(e||$o,r)};case 5124:case 35670:return function(t,e){t.uniform1i(this.addr,e)};case 35667:case 35671:return g;case 35668:case 35672:return y;case 35669:case 35673:return _}}()}(s,t,e):new function(t,e,n){this.id=t,this.addr=n,this.size=e.size,this.setValue=function(t){switch(e.type){case 5126:return function(t,e){t.uniform1fv(this.addr,e)};case 35664:return function(t,e){t.uniform2fv(this.addr,m(e,this.size,2))};case 35665:return function(t,e){t.uniform3fv(this.addr,m(e,this.size,3))};case 35666:return function(t,e){t.uniform4fv(this.addr,m(e,this.size,4))};case 35674:return function(t,e){t.uniformMatrix2fv(this.addr,!1,m(e,this.size,4))};case 35675:return function(t,e){t.uniformMatrix3fv(this.addr,!1,m(e,this.size,9))};case 35676:return function(t,e){t.uniformMatrix4fv(this.addr,!1,m(e,this.size,16))};case 35678:return function(t,e,n){var r=e.length,i=v(n,r);t.uniform1iv(this.addr,i);for(var o=0;o!==r;++o)n.setTexture2D(e[o]||Qo,i[o])};case 35680:return function(t,e,n){var r=e.length,i=v(n,r);t.uniform1iv(this.addr,i);for(var o=0;o!==r;++o)n.setTextureCube(e[o]||$o,i[o])};case 5124:case 35670:return function(t,e){t.uniform1iv(this.addr,e)};case 35667:case 35671:return g;case 35668:case 35672:return y;case 35669:case 35673:return _}}()}(s,t,e));break}var l=n.map[s];void 0===l&&x(n,l=new b(s)),n=l}}(o,t.getUniformLocation(e,a),this)}}function E(t,e,n){return void 0===e&&void 0===n?this.set(t):this.setRGB(t,e,n)}function M(t,e){this.min=void 0!==t?t:new i(1/0,1/0),this.max=void 0!==e?e:new i(-1/0,-1/0)}function T(t,e,n,r,i,a,s,u,c){o.call(this,t,e,n,r,i,a,s,u,c),this.needsUpdate=!0}function S(){Object.defineProperty(this,"id",{value:la++}),this.uuid=Zo.generateUUID(),this.name="",this.type="Material",this.fog=!0,this.lights=!0,this.blending=Qr,this.side=jr,this.flatShading=!1,this.vertexColors=Yr,this.opacity=1,this.transparent=!1,this.blendSrc=pi,this.blendDst=di,this.blendEquation=ri,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=wi,this.depthTest=!0,this.depthWrite=!0,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaTest=0,this.premultipliedAlpha=!1,this.overdraw=0,this.visible=!0,this.userData={},this.needsUpdate=!0}function C(t){S.call(this),this.type="ShaderMaterial",this.defines={},this.uniforms={},this.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",this.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}",this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]},this.index0AttributeName=void 0,void 0!==t&&(void 0!==t.attributes&&console.error("THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead."),this.setValues(t))}function A(t){S.call(this),this.type="MeshDepthMaterial",this.depthPacking=Yo,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.setValues(t)}function P(t){S.call(this),this.type="MeshDistanceMaterial",this.referencePosition=new l,this.nearDistance=1,this.farDistance=1e3,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.fog=!1,this.lights=!1,this.setValues(t)}function R(t,e){this.min=void 0!==t?t:new l(1/0,1/0,1/0),this.max=void 0!==e?e:new l(-1/0,-1/0,-1/0)}function L(t,e){this.center=void 0!==t?t:new l,this.radius=void 0!==e?e:0}function I(){this.elements=[1,0,0,0,1,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}function O(t,e){this.normal=void 0!==t?t:new l(1,0,0),this.constant=void 0!==e?e:0}function N(t,e,n,r,i,o){this.planes=[void 0!==t?t:new O,void 0!==e?e:new O,void 0!==n?n:new O,void 0!==r?r:new O,void 0!==i?i:new O,void 0!==o?o:new O]}function D(t,e,n){function r(e,n,r,i,o,a){var s=e.geometry,u=null,c=_,l=e.customDepthMaterial;if(r&&(c=b,l=e.customDistanceMaterial),l)u=l;else{var h=!1;n.morphTargets&&(s&&s.isBufferGeometry?h=s.morphAttributes&&s.morphAttributes.position&&s.morphAttributes.position.length>0:s&&s.isGeometry&&(h=s.morphTargets&&s.morphTargets.length>0)),e.isSkinnedMesh&&!1===n.skinning&&console.warn("THREE.WebGLShadowMap: THREE.SkinnedMesh with material.skinning set to false:",e);var p=e.isSkinnedMesh&&n.skinning,d=0;h&&(d|=v),p&&(d|=g),u=c[d]}if(t.localClippingEnabled&&!0===n.clipShadows&&0!==n.clippingPlanes.length){var f=u.uuid,m=n.uuid,y=x[f];void 0===y&&(y={},x[f]=y);var w=y[m];void 0===w&&(w=u.clone(),y[m]=w),u=w}u.visible=n.visible,u.wireframe=n.wireframe;var E=n.side;return I.renderSingleSided&&E==Wr&&(E=jr),I.renderReverseSided&&(E===jr?E=Vr:E===Vr&&(E=jr)),u.side=E,u.clipShadows=n.clipShadows,u.clippingPlanes=n.clippingPlanes,u.clipIntersection=n.clipIntersection,u.wireframeLinewidth=n.wireframeLinewidth,u.linewidth=n.linewidth,r&&u.isMeshDistanceMaterial&&(u.referencePosition.copy(i),u.nearDistance=o,u.farDistance=a),u}function o(n,i,a,s){if(!1!==n.visible){if(n.layers.test(i.layers)&&(n.isMesh||n.isLine||n.isPoints)&&n.castShadow&&(!n.frustumCulled||u.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(a.matrixWorldInverse,n.matrixWorld);var c=e.update(n),l=n.material;if(Array.isArray(l))for(var h=c.groups,p=0,d=h.length;p<d;p++){var f=h[p],v=l[f.materialIndex];if(v&&v.visible){g=r(n,v,s,m,a.near,a.far);t.renderBufferDirect(a,null,c,g,n,f)}}else if(l.visible){var g=r(n,l,s,m,a.near,a.far);t.renderBufferDirect(a,null,c,g,n,null)}}for(var y=n.children,_=0,b=y.length;_<b;_++)o(y[_],i,a,s)}}for(var u=new N,c=new h,p=new i,d=new i(n,n),f=new l,m=new l,v=1,g=2,y=1+(v|g),_=new Array(y),b=new Array(y),x={},w=[new l(1,0,0),new l(-1,0,0),new l(0,0,1),new l(0,0,-1),new l(0,1,0),new l(0,-1,0)],E=[new l(0,1,0),new l(0,1,0),new l(0,1,0),new l(0,1,0),new l(0,0,1),new l(0,0,-1)],M=[new a,new a,new a,new a,new a,new a],T=0;T!==y;++T){var S=0!=(T&v),C=0!=(T&g),R=new A({depthPacking:Ko,morphTargets:S,skinning:C});_[T]=R;var L=new P({morphTargets:S,skinning:C});b[T]=L}var I=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Hr,this.renderReverseSided=!0,this.renderSingleSided=!0,this.render=function(e,n,r){if(!1!==I.enabled&&(!1!==I.autoUpdate||!1!==I.needsUpdate)&&0!==e.length){var i=t.context,a=t.state;a.disable(i.BLEND),a.buffers.color.setClear(1,1,1,1),a.buffers.depth.setTest(!0),a.setScissorTest(!1);for(var l,h=0,v=e.length;h<v;h++){var g=e[h],y=g.shadow,_=g&&g.isPointLight;if(void 0!==y){var b=y.camera;if(p.copy(y.mapSize),p.min(d),_){var x=p.x,T=p.y;M[0].set(2*x,T,x,T),M[1].set(0,T,x,T),M[2].set(3*x,T,x,T),M[3].set(x,T,x,T),M[4].set(3*x,0,x,T),M[5].set(x,0,x,T),p.x*=4,p.y*=2}if(null===y.map){var S={minFilter:qi,magFilter:qi,format:po};y.map=new s(p.x,p.y,S),y.map.texture.name=g.name+".shadowMap",b.updateProjectionMatrix()}y.isSpotLightShadow&&y.update(g);var C=y.map,A=y.matrix;m.setFromMatrixPosition(g.matrixWorld),b.position.copy(m),_?(l=6,A.makeTranslation(-m.x,-m.y,-m.z)):(l=1,f.setFromMatrixPosition(g.target.matrixWorld),b.lookAt(f),b.updateMatrixWorld(),A.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),A.multiply(b.projectionMatrix),A.multiply(b.matrixWorldInverse)),t.setRenderTarget(C),t.clear();for(var P=0;P<l;P++){if(_){f.copy(b.position),f.add(w[P]),b.up.copy(E[P]),b.lookAt(f),b.updateMatrixWorld();var R=M[P];a.viewport(R)}c.multiplyMatrices(b.projectionMatrix,b.matrixWorldInverse),u.setFromMatrix(c),o(n,r,b,_)}}else console.warn("THREE.WebGLShadowMap:",g,"has no shadow.")}I.needsUpdate=!1}}}function U(t,e,n,r){this._x=t||0,this._y=e||0,this._z=n||0,this._order=r||U.DefaultOrder}function F(){this.mask=1}function k(){Object.defineProperty(this,"id",{value:ha++}),this.uuid=Zo.generateUUID(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=k.DefaultUp.clone();var t=new l,e=new U,n=new c,r=new l(1,1,1);e.onChange(function(){n.setFromEuler(e,!1)}),n.onChange(function(){e.setFromQuaternion(n,void 0,!1)}),Object.defineProperties(this,{position:{enumerable:!0,value:t},rotation:{enumerable:!0,value:e},quaternion:{enumerable:!0,value:n},scale:{enumerable:!0,value:r},modelViewMatrix:{value:new h},normalMatrix:{value:new I}}),this.matrix=new h,this.matrixWorld=new h,this.matrixAutoUpdate=k.DefaultMatrixAutoUpdate,this.matrixWorldNeedsUpdate=!1,this.layers=new F,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.userData={}}function z(){k.call(this),this.type="Camera",this.matrixWorldInverse=new h,this.projectionMatrix=new h}function B(t,e,n,r,i,o){z.call(this),this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=n,this.bottom=r,this.near=void 0!==i?i:.1,this.far=void 0!==o?o:2e3,this.updateProjectionMatrix()}function H(t,e,n,r){z.call(this),this.type="PerspectiveCamera",this.fov=void 0!==t?t:50,this.zoom=1,this.near=void 0!==n?n:.1,this.far=void 0!==r?r:2e3,this.focus=10,this.aspect=void 0!==e?e:1,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}function G(t,e,n,r,i,o){this.a=t,this.b=e,this.c=n,this.normal=r&&r.isVector3?r:new l,this.vertexNormals=Array.isArray(r)?r:[],this.color=i&&i.isColor?i:new E,this.vertexColors=Array.isArray(i)?i:[],this.materialIndex=void 0!==o?o:0}function j(){return pa++}function V(){Object.defineProperty(this,"id",{value:j()}),this.uuid=Zo.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}function W(t,e,n){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.uuid=Zo.generateUUID(),this.name="",this.array=t,this.itemSize=e,this.count=void 0!==t?t.length/e:0,this.normalized=!0===n,this.dynamic=!1,this.updateRange={offset:0,count:-1},this.onUploadCallback=function(){},this.version=0}function q(t,e){W.call(this,new Int8Array(t),e)}function X(t,e){W.call(this,new Uint8Array(t),e)}function Y(t,e){W.call(this,new Uint8ClampedArray(t),e)}function K(t,e){W.call(this,new Int16Array(t),e)}function Z(t,e){W.call(this,new Uint16Array(t),e)}function J(t,e){W.call(this,new Int32Array(t),e)}function Q(t,e){W.call(this,new Uint32Array(t),e)}function $(t,e){W.call(this,new Float32Array(t),e)}function tt(t,e){W.call(this,new Float64Array(t),e)}function et(){this.indices=[],this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}function nt(t){if(0===t.length)return-1/0;for(var e=t[0],n=1,r=t.length;n<r;++n)t[n]>e&&(e=t[n]);return e}function rt(){Object.defineProperty(this,"id",{value:j()}),this.uuid=Zo.generateUUID(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0}}function it(t,e,n,r,i,o){V.call(this),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:r,heightSegments:i,depthSegments:o},this.fromBufferGeometry(new ot(t,e,n,r,i,o)),this.mergeVertices()}function ot(t,e,n,r,i,o){function a(t,e,n,r,i,o,a,m,v,g,y){var _,b,x=o/v,w=a/g,E=o/2,M=a/2,T=m/2,S=v+1,C=g+1,A=0,P=0,R=new l;for(b=0;b<C;b++){var L=b*w-M;for(_=0;_<S;_++){var I=_*x-E;R[t]=I*r,R[e]=L*i,R[n]=T,c.push(R.x,R.y,R.z),R[t]=0,R[e]=0,R[n]=m>0?1:-1,h.push(R.x,R.y,R.z),p.push(_/v),p.push(1-b/g),A+=1}}for(b=0;b<g;b++)for(_=0;_<v;_++){var O=d+_+S*b,N=d+_+S*(b+1),D=d+(_+1)+S*(b+1),U=d+(_+1)+S*b;u.push(O,N,U),u.push(N,D,U),P+=6}s.addGroup(f,P,y),f+=P,d+=A}rt.call(this),this.type="BoxBufferGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:r,heightSegments:i,depthSegments:o};var s=this;r=Math.floor(r)||1,i=Math.floor(i)||1;var u=[],c=[],h=[],p=[],d=0,f=0;a("z","y","x",-1,-1,n,e,t,o=Math.floor(o)||1,i,0),a("z","y","x",1,-1,n,e,-t,o,i,1),a("x","z","y",1,1,t,n,e,r,o,2),a("x","z","y",1,-1,t,n,-e,r,o,3),a("x","y","z",1,-1,t,e,n,r,i,4),a("x","y","z",-1,-1,t,e,-n,r,i,5),this.setIndex(u),this.addAttribute("position",new $(c,3)),this.addAttribute("normal",new $(h,3)),this.addAttribute("uv",new $(p,2))}function at(t,e,n,r){V.call(this),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:n,heightSegments:r},this.fromBufferGeometry(new st(t,e,n,r)),this.mergeVertices()}function st(t,e,n,r){rt.call(this),this.type="PlaneBufferGeometry",this.parameters={width:t,height:e,widthSegments:n,heightSegments:r};var i,o,a=t/2,s=e/2,u=Math.floor(n)||1,c=Math.floor(r)||1,l=u+1,h=c+1,p=t/u,d=e/c,f=[],m=[],v=[],g=[];for(o=0;o<h;o++){var y=o*d-s;for(i=0;i<l;i++){var _=i*p-a;m.push(_,-y,0),v.push(0,0,1),g.push(i/u),g.push(1-o/c)}}for(o=0;o<c;o++)for(i=0;i<u;i++){var b=i+l*o,x=i+l*(o+1),w=i+1+l*(o+1),E=i+1+l*o;f.push(b,x,E),f.push(x,w,E)}this.setIndex(f),this.addAttribute("position",new $(m,3)),this.addAttribute("normal",new $(v,3)),this.addAttribute("uv",new $(g,2))}function ut(t){S.call(this),this.type="MeshBasicMaterial",this.color=new E(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Ci,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.lights=!1,this.setValues(t)}function ct(t,e){this.origin=void 0!==t?t:new l,this.direction=void 0!==e?e:new l}function lt(t,e){this.start=void 0!==t?t:new l,this.end=void 0!==e?e:new l}function ht(t,e,n){this.a=void 0!==t?t:new l,this.b=void 0!==e?e:new l,this.c=void 0!==n?n:new l}function pt(t,e){k.call(this),this.type="Mesh",this.geometry=void 0!==t?t:new rt,this.material=void 0!==e?e:new ut({color:16777215*Math.random()}),this.drawMode=Fo,this.updateMorphTargets()}function dt(t,e,n){var r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),!1===t.getShaderParameter(r,t.COMPILE_STATUS)&&console.error("THREE.WebGLShader: Shader couldn't compile."),""!==t.getShaderInfoLog(r)&&console.warn("THREE.WebGLShader: gl.getShaderInfoLog()",e===t.VERTEX_SHADER?"vertex":"fragment",t.getShaderInfoLog(r),function(t){for(var e=t.split("\n"),n=0;n<e.length;n++)e[n]=n+1+": "+e[n];return e.join("\n")}(n)),r}function ft(t){switch(t){case Bo:return["Linear","( value )"];case Ho:return["sRGB","( value )"];case jo:return["RGBE","( value )"];case Wo:return["RGBM","( value, 7.0 )"];case qo:return["RGBM","( value, 16.0 )"];case Xo:return["RGBD","( value, 256.0 )"];case Go:return["Gamma","( value, float( GAMMA_FACTOR ) )"];default:throw new Error("unsupported encoding: "+t)}}function mt(t,e){var n=ft(e);return"vec4 "+t+"( vec4 value ) { return "+n[0]+"ToLinear"+n[1]+"; }"}function vt(t){return""!==t}function gt(t,e){return t.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights)}function yt(t){return t.replace(/^[ \t]*#include +<([\w\d.]+)>/gm,function(t,e){var n=ua[e];if(void 0===n)throw new Error("Can not resolve #include <"+e+">");return yt(n)})}function _t(t){return t.replace(/for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,function(t,e,n,r){for(var i="",o=parseInt(e);o<parseInt(n);o++)i+=r.replace(/\[ i \]/g,"[ "+o+" ]");return i})}function bt(t){H.call(this),this.cameras=t||[]}function xt(t,e){return{convert:function(n){var r;if(n===ji)return t.REPEAT;if(n===Vi)return t.CLAMP_TO_EDGE;if(n===Wi)return t.MIRRORED_REPEAT;if(n===qi)return t.NEAREST;if(n===Xi)return t.NEAREST_MIPMAP_NEAREST;if(n===Yi)return t.NEAREST_MIPMAP_LINEAR;if(n===Ki)return t.LINEAR;if(n===Zi)return t.LINEAR_MIPMAP_NEAREST;if(n===Ji)return t.LINEAR_MIPMAP_LINEAR;if(n===Qi)return t.UNSIGNED_BYTE;if(n===ao)return t.UNSIGNED_SHORT_4_4_4_4;if(n===so)return t.UNSIGNED_SHORT_5_5_5_1;if(n===uo)return t.UNSIGNED_SHORT_5_6_5;if(n===$i)return t.BYTE;if(n===to)return t.SHORT;if(n===eo)return t.UNSIGNED_SHORT;if(n===no)return t.INT;if(n===ro)return t.UNSIGNED_INT;if(n===io)return t.FLOAT;if(n===oo&&null!==(r=e.get("OES_texture_half_float")))return r.HALF_FLOAT_OES;if(n===lo)return t.ALPHA;if(n===ho)return t.RGB;if(n===po)return t.RGBA;if(n===fo)return t.LUMINANCE;if(n===mo)return t.LUMINANCE_ALPHA;if(n===go)return t.DEPTH_COMPONENT;if(n===yo)return t.DEPTH_STENCIL;if(n===ri)return t.FUNC_ADD;if(n===ii)return t.FUNC_SUBTRACT;if(n===oi)return t.FUNC_REVERSE_SUBTRACT;if(n===ui)return t.ZERO;if(n===ci)return t.ONE;if(n===li)return t.SRC_COLOR;if(n===hi)return t.ONE_MINUS_SRC_COLOR;if(n===pi)return t.SRC_ALPHA;if(n===di)return t.ONE_MINUS_SRC_ALPHA;if(n===fi)return t.DST_ALPHA;if(n===mi)return t.ONE_MINUS_DST_ALPHA;if(n===vi)return t.DST_COLOR;if(n===gi)return t.ONE_MINUS_DST_COLOR;if(n===yi)return t.SRC_ALPHA_SATURATE;if((n===_o||n===bo||n===xo||n===wo)&&null!==(r=e.get("WEBGL_compressed_texture_s3tc"))){if(n===_o)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===bo)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===xo)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===wo)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}if((n===Eo||n===Mo||n===To||n===So)&&null!==(r=e.get("WEBGL_compressed_texture_pvrtc"))){if(n===Eo)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Mo)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===To)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===So)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(n===Co&&null!==(r=e.get("WEBGL_compressed_texture_etc1")))return r.COMPRESSED_RGB_ETC1_WEBGL;if((n===ai||n===si)&&null!==(r=e.get("EXT_blend_minmax"))){if(n===ai)return r.MIN_EXT;if(n===si)return r.MAX_EXT}return n===co&&null!==(r=e.get("WEBGL_depth_texture"))?r.UNSIGNED_INT_24_8_WEBGL:0}}}function wt(t){function e(){return null===Y?Et:1}function n(){(Ft=new function(t){var e={};return{get:function(n){if(void 0!==e[n])return e[n];var r;switch(n){case"WEBGL_depth_texture":r=t.getExtension("WEBGL_depth_texture")||t.getExtension("MOZ_WEBGL_depth_texture")||t.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":r=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":r=t.getExtension("WEBGL_compressed_texture_s3tc")||t.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":r=t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;case"WEBGL_compressed_texture_etc1":r=t.getExtension("WEBGL_compressed_texture_etc1");break;default:r=t.getExtension(n)}return null===r&&console.warn("THREE.WebGLRenderer: "+n+" extension not supported."),e[n]=r,r}}}(Dt)).get("WEBGL_depth_texture"),Ft.get("OES_texture_float"),Ft.get("OES_texture_float_linear"),Ft.get("OES_texture_half_float"),Ft.get("OES_texture_half_float_linear"),Ft.get("OES_standard_derivatives"),Ft.get("ANGLE_instanced_arrays"),Ft.get("OES_element_index_uint")&&(rt.MaxIndex=4294967296),te=new xt(Dt,Ft),kt=new function(t,e,n){function r(e){if("highp"===e){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";e="mediump"}return"mediump"===e&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}var i,o=void 0!==n.precision?n.precision:"highp",a=r(o);a!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",a,"instead."),o=a);var s=!0===n.logarithmicDepthBuffer&&!!e.get("EXT_frag_depth"),u=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),c=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),l=t.getParameter(t.MAX_TEXTURE_SIZE),h=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),p=t.getParameter(t.MAX_VERTEX_ATTRIBS),d=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),f=t.getParameter(t.MAX_VARYING_VECTORS),m=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),v=c>0,g=!!e.get("OES_texture_float");return{getMaxAnisotropy:function(){if(void 0!==i)return i;var n=e.get("EXT_texture_filter_anisotropic");return i=null!==n?t.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0},getMaxPrecision:r,precision:o,logarithmicDepthBuffer:s,maxTextures:u,maxVertexTextures:c,maxTextureSize:l,maxCubemapSize:h,maxAttributes:p,maxVertexUniforms:d,maxVaryings:f,maxFragmentUniforms:m,vertexTextures:v,floatFragmentTextures:g,floatVertexTextures:v&&g}}(Dt,Ft,t),(zt=new function(t,e,n){function r(e,n,r){var i=new Uint8Array(4),o=t.createTexture();t.bindTexture(e,o),t.texParameteri(e,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(e,t.TEXTURE_MAG_FILTER,t.NEAREST);for(var a=0;a<r;a++)t.texImage2D(n+a,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,i);return o}function i(e){!0!==_[e]&&(t.enable(e),_[e]=!0)}function o(e){!1!==_[e]&&(t.disable(e),_[e]=!1)}function s(e,r,a,s,u,c,l,h){if(e!==Jr?i(t.BLEND):o(t.BLEND),e!==ni){if(e!==w||h!==P)switch(e){case $r:h?(t.blendEquationSeparate(t.FUNC_ADD,t.FUNC_ADD),t.blendFuncSeparate(t.ONE,t.ONE,t.ONE,t.ONE)):(t.blendEquation(t.FUNC_ADD),t.blendFunc(t.SRC_ALPHA,t.ONE));break;case ti:h?(t.blendEquationSeparate(t.FUNC_ADD,t.FUNC_ADD),t.blendFuncSeparate(t.ZERO,t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ONE_MINUS_SRC_ALPHA)):(t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ZERO,t.ONE_MINUS_SRC_COLOR));break;case ei:h?(t.blendEquationSeparate(t.FUNC_ADD,t.FUNC_ADD),t.blendFuncSeparate(t.ZERO,t.SRC_COLOR,t.ZERO,t.SRC_ALPHA)):(t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ZERO,t.SRC_COLOR));break;default:h?(t.blendEquationSeparate(t.FUNC_ADD,t.FUNC_ADD),t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA)):(t.blendEquationSeparate(t.FUNC_ADD,t.FUNC_ADD),t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA))}E=null,M=null,T=null,S=null,C=null,A=null}else u=u||r,c=c||a,l=l||s,r===E&&u===S||(t.blendEquationSeparate(n.convert(r),n.convert(u)),E=r,S=u),a===M&&s===T&&c===C&&l===A||(t.blendFuncSeparate(n.convert(a),n.convert(s),n.convert(c),n.convert(l)),M=a,T=s,C=c,A=l);w=e,P=h}function u(e){R!==e&&(e?t.frontFace(t.CW):t.frontFace(t.CCW),R=e)}function c(e){e!==Nr?(i(t.CULL_FACE),e!==L&&(e===Dr?t.cullFace(t.BACK):e===Ur?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):o(t.CULL_FACE),L=e}function l(e,n,r){e?(i(t.POLYGON_OFFSET_FILL),O===n&&N===r||(t.polygonOffset(n,r),O=n,N=r)):o(t.POLYGON_OFFSET_FILL)}function h(e){void 0===e&&(e=t.TEXTURE0+D-1),k!==e&&(t.activeTexture(e),k=e)}var p=new function(){var e=!1,n=new a,r=null,i=new a(0,0,0,0);return{setMask:function(n){r===n||e||(t.colorMask(n,n,n,n),r=n)},setLocked:function(t){e=t},setClear:function(e,r,o,a,s){!0===s&&(e*=a,r*=a,o*=a),n.set(e,r,o,a),!1===i.equals(n)&&(t.clearColor(e,r,o,a),i.copy(n))},reset:function(){e=!1,r=null,i.set(-1,0,0,0)}}},d=new function(){var e=!1,n=null,r=null,a=null;return{setTest:function(e){e?i(t.DEPTH_TEST):o(t.DEPTH_TEST)},setMask:function(r){n===r||e||(t.depthMask(r),n=r)},setFunc:function(e){if(r!==e){if(e)switch(e){case _i:t.depthFunc(t.NEVER);break;case bi:t.depthFunc(t.ALWAYS);break;case xi:t.depthFunc(t.LESS);break;case wi:t.depthFunc(t.LEQUAL);break;case Ei:t.depthFunc(t.EQUAL);break;case Mi:t.depthFunc(t.GEQUAL);break;case Ti:t.depthFunc(t.GREATER);break;case Si:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}else t.depthFunc(t.LEQUAL);r=e}},setLocked:function(t){e=t},setClear:function(e){a!==e&&(t.clearDepth(e),a=e)},reset:function(){e=!1,n=null,r=null,a=null}}},f=new function(){var e=!1,n=null,r=null,a=null,s=null,u=null,c=null,l=null,h=null;return{setTest:function(e){e?i(t.STENCIL_TEST):o(t.STENCIL_TEST)},setMask:function(r){n===r||e||(t.stencilMask(r),n=r)},setFunc:function(e,n,i){r===e&&a===n&&s===i||(t.stencilFunc(e,n,i),r=e,a=n,s=i)},setOp:function(e,n,r){u===e&&c===n&&l===r||(t.stencilOp(e,n,r),u=e,c=n,l=r)},setLocked:function(t){e=t},setClear:function(e){h!==e&&(t.clearStencil(e),h=e)},reset:function(){e=!1,n=null,r=null,a=null,s=null,u=null,c=null,l=null,h=null}}},m=t.getParameter(t.MAX_VERTEX_ATTRIBS),v=new Uint8Array(m),g=new Uint8Array(m),y=new Uint8Array(m),_={},b=null,x=null,w=null,E=null,M=null,T=null,S=null,C=null,A=null,P=!1,R=null,L=null,I=null,O=null,N=null,D=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS),U=parseFloat(/^WebGL\ ([0-9])/.exec(t.getParameter(t.VERSION))[1]),F=parseFloat(U)>=1,k=null,z={},B=new a,H=new a,G={};return G[t.TEXTURE_2D]=r(t.TEXTURE_2D,t.TEXTURE_2D,1),G[t.TEXTURE_CUBE_MAP]=r(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),p.setClear(0,0,0,1),d.setClear(1),f.setClear(0),i(t.DEPTH_TEST),d.setFunc(wi),u(!1),c(Dr),i(t.CULL_FACE),i(t.BLEND),s(Qr),{buffers:{color:p,depth:d,stencil:f},initAttributes:function(){for(var t=0,e=v.length;t<e;t++)v[t]=0},enableAttribute:function(n){v[n]=1,0===g[n]&&(t.enableVertexAttribArray(n),g[n]=1),0!==y[n]&&(e.get("ANGLE_instanced_arrays").vertexAttribDivisorANGLE(n,0),y[n]=0)},enableAttributeAndDivisor:function(n,r){v[n]=1,0===g[n]&&(t.enableVertexAttribArray(n),g[n]=1),y[n]!==r&&(e.get("ANGLE_instanced_arrays").vertexAttribDivisorANGLE(n,r),y[n]=r)},disableUnusedAttributes:function(){for(var e=0,n=g.length;e!==n;++e)g[e]!==v[e]&&(t.disableVertexAttribArray(e),g[e]=0)},enable:i,disable:o,getCompressedTextureFormats:function(){if(null===b&&(b=[],e.get("WEBGL_compressed_texture_pvrtc")||e.get("WEBGL_compressed_texture_s3tc")||e.get("WEBGL_compressed_texture_etc1")))for(var n=t.getParameter(t.COMPRESSED_TEXTURE_FORMATS),r=0;r<n.length;r++)b.push(n[r]);return b},useProgram:function(e){return x!==e&&(t.useProgram(e),x=e,!0)},setBlending:s,setMaterial:function(e){e.side===Wr?o(t.CULL_FACE):i(t.CULL_FACE),u(e.side===Vr),!0===e.transparent?s(e.blending,e.blendEquation,e.blendSrc,e.blendDst,e.blendEquationAlpha,e.blendSrcAlpha,e.blendDstAlpha,e.premultipliedAlpha):s(Jr),d.setFunc(e.depthFunc),d.setTest(e.depthTest),d.setMask(e.depthWrite),p.setMask(e.colorWrite),l(e.polygonOffset,e.polygonOffsetFactor,e.polygonOffsetUnits)},setFlipSided:u,setCullFace:c,setLineWidth:function(e){e!==I&&(F&&t.lineWidth(e),I=e)},setPolygonOffset:l,setScissorTest:function(e){e?i(t.SCISSOR_TEST):o(t.SCISSOR_TEST)},activeTexture:h,bindTexture:function(e,n){null===k&&h();var r=z[k];void 0===r&&(r={type:void 0,texture:void 0},z[k]=r),r.type===e&&r.texture===n||(t.bindTexture(e,n||G[e]),r.type=e,r.texture=n)},compressedTexImage2D:function(){try{t.compressedTexImage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texImage2D:function(){try{t.texImage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},scissor:function(e){!1===B.equals(e)&&(t.scissor(e.x,e.y,e.z,e.w),B.copy(e))},viewport:function(e){!1===H.equals(e)&&(t.viewport(e.x,e.y,e.z,e.w),H.copy(e))},reset:function(){for(var e=0;e<g.length;e++)1===g[e]&&(t.disableVertexAttribArray(e),g[e]=0);_={},b=null,k=null,z={},x=null,w=null,R=null,L=null,p.reset(),d.reset(),f.reset()}}}(Dt,Ft,te)).scissor(at.copy(Tt).multiplyScalar(Et)),zt.viewport(it.copy(Mt).multiplyScalar(Et)),Bt=new function(){var t={};return{get:function(e){var n=e.uuid,r=t[n];return void 0===r&&(r={},t[n]=r),r},remove:function(e){delete t[e.uuid]},clear:function(){t={}}}},Ht=new function(t,e,n,r,i,o,a){function s(t,e){if(t.width>e||t.height>e){var n=e/Math.max(t.width,t.height),r=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return r.width=Math.floor(t.width*n),r.height=Math.floor(t.height*n),r.getContext("2d").drawImage(t,0,0,t.width,t.height,0,0,r.width,r.height),console.warn("THREE.WebGLRenderer: image is too big ("+t.width+"x"+t.height+"). Resized to "+r.width+"x"+r.height,t),r}return t}function u(t){return Zo.isPowerOfTwo(t.width)&&Zo.isPowerOfTwo(t.height)}function c(t,e){return t.generateMipmaps&&e&&t.minFilter!==qi&&t.minFilter!==Ki}function l(e){return e===qi||e===Xi||e===Yi?t.NEAREST:t.LINEAR}function h(e){var n=e.target;n.removeEventListener("dispose",h),function(e){var n=r.get(e);if(e.image&&n.__image__webglTextureCube)t.deleteTexture(n.__image__webglTextureCube);else{if(void 0===n.__webglInit)return;t.deleteTexture(n.__webglTexture)}r.remove(e)}(n),a.textures--}function p(e){var n=e.target;n.removeEventListener("dispose",p),function(e){var n=r.get(e),i=r.get(e.texture);if(e){if(void 0!==i.__webglTexture&&t.deleteTexture(i.__webglTexture),e.depthTexture&&e.depthTexture.dispose(),e.isWebGLRenderTargetCube)for(var o=0;o<6;o++)t.deleteFramebuffer(n.__webglFramebuffer[o]),n.__webglDepthbuffer&&t.deleteRenderbuffer(n.__webglDepthbuffer[o]);else t.deleteFramebuffer(n.__webglFramebuffer),n.__webglDepthbuffer&&t.deleteRenderbuffer(n.__webglDepthbuffer);r.remove(e.texture),r.remove(e)}}(n),a.textures--}function d(e,l){var p=r.get(e);if(e.version>0&&p.__version!==e.version){var d=e.image;if(void 0===d)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined",e);else{if(!1!==d.complete)return void function(e,r,l){void 0===e.__webglInit&&(e.__webglInit=!0,r.addEventListener("dispose",h),e.__webglTexture=t.createTexture(),a.textures++),n.activeTexture(t.TEXTURE0+l),n.bindTexture(t.TEXTURE_2D,e.__webglTexture),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,r.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,r.unpackAlignment);var p=s(r.image,i.maxTextureSize);(function(t){return t.wrapS!==Vi||t.wrapT!==Vi||t.minFilter!==qi&&t.minFilter!==Ki})(r)&&!1===u(p)&&(p=function(t){if(t instanceof HTMLImageElement||t instanceof HTMLCanvasElement){var e=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return e.width=Zo.nearestPowerOfTwo(t.width),e.height=Zo.nearestPowerOfTwo(t.height),e.getContext("2d").drawImage(t,0,0,e.width,e.height),console.warn("THREE.WebGLRenderer: image is not power of two ("+t.width+"x"+t.height+"). Resized to "+e.width+"x"+e.height,t),e}return t}(p));var d=u(p),m=o.convert(r.format),v=o.convert(r.type);f(t.TEXTURE_2D,r,d);var y,_=r.mipmaps;if(r.isDepthTexture){var b=t.DEPTH_COMPONENT;if(r.type===io){if(!g)throw new Error("Float Depth Texture only supported in WebGL2.0");b=t.DEPTH_COMPONENT32F}else g&&(b=t.DEPTH_COMPONENT16);r.format===go&&b===t.DEPTH_COMPONENT&&r.type!==eo&&r.type!==ro&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),r.type=eo,v=o.convert(r.type)),r.format===yo&&(b=t.DEPTH_STENCIL,r.type!==co&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),r.type=co,v=o.convert(r.type))),n.texImage2D(t.TEXTURE_2D,0,b,p.width,p.height,0,m,v,null)}else if(r.isDataTexture)if(_.length>0&&d){for(var x=0,w=_.length;x<w;x++)y=_[x],n.texImage2D(t.TEXTURE_2D,x,m,y.width,y.height,0,m,v,y.data);r.generateMipmaps=!1}else n.texImage2D(t.TEXTURE_2D,0,m,p.width,p.height,0,m,v,p.data);else if(r.isCompressedTexture)for(var x=0,w=_.length;x<w;x++)y=_[x],r.format!==po&&r.format!==ho?n.getCompressedTextureFormats().indexOf(m)>-1?n.compressedTexImage2D(t.TEXTURE_2D,x,m,y.width,y.height,0,y.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):n.texImage2D(t.TEXTURE_2D,x,m,y.width,y.height,0,m,v,y.data);else if(_.length>0&&d){for(var x=0,w=_.length;x<w;x++)y=_[x],n.texImage2D(t.TEXTURE_2D,x,m,m,v,y);r.generateMipmaps=!1}else n.texImage2D(t.TEXTURE_2D,0,m,m,v,p);c(r,d)&&t.generateMipmap(t.TEXTURE_2D),e.__version=r.version,r.onUpdate&&r.onUpdate(r)}(p,e,l);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete",e)}}n.activeTexture(t.TEXTURE0+l),n.bindTexture(t.TEXTURE_2D,p.__webglTexture)}function f(n,a,s){var u;if(s?(t.texParameteri(n,t.TEXTURE_WRAP_S,o.convert(a.wrapS)),t.texParameteri(n,t.TEXTURE_WRAP_T,o.convert(a.wrapT)),t.texParameteri(n,t.TEXTURE_MAG_FILTER,o.convert(a.magFilter)),t.texParameteri(n,t.TEXTURE_MIN_FILTER,o.convert(a.minFilter))):(t.texParameteri(n,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(n,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),a.wrapS===Vi&&a.wrapT===Vi||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping.",a),t.texParameteri(n,t.TEXTURE_MAG_FILTER,l(a.magFilter)),t.texParameteri(n,t.TEXTURE_MIN_FILTER,l(a.minFilter)),a.minFilter!==qi&&a.minFilter!==Ki&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.",a)),u=e.get("EXT_texture_filter_anisotropic")){if(a.type===io&&null===e.get("OES_texture_float_linear"))return;if(a.type===oo&&null===e.get("OES_texture_half_float_linear"))return;(a.anisotropy>1||r.get(a).__currentAnisotropy)&&(t.texParameterf(n,u.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,i.getMaxAnisotropy())),r.get(a).__currentAnisotropy=a.anisotropy)}}function m(e,i,a,s){var u=o.convert(i.texture.format),c=o.convert(i.texture.type);n.texImage2D(s,0,u,i.width,i.height,0,u,c,null),t.bindFramebuffer(t.FRAMEBUFFER,e),t.framebufferTexture2D(t.FRAMEBUFFER,a,s,r.get(i.texture).__webglTexture,0),t.bindFramebuffer(t.FRAMEBUFFER,null)}function v(e,n){t.bindRenderbuffer(t.RENDERBUFFER,e),n.depthBuffer&&!n.stencilBuffer?(t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_COMPONENT16,n.width,n.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,e)):n.depthBuffer&&n.stencilBuffer?(t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,n.width,n.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,e)):t.renderbufferStorage(t.RENDERBUFFER,t.RGBA4,n.width,n.height),t.bindRenderbuffer(t.RENDERBUFFER,null)}var g="undefined"!=typeof WebGL2RenderingContext&&t instanceof WebGL2RenderingContext;this.setTexture2D=d,this.setTextureCube=function(e,l){var p=r.get(e);if(6===e.image.length)if(e.version>0&&p.__version!==e.version){p.__image__webglTextureCube||(e.addEventListener("dispose",h),p.__image__webglTextureCube=t.createTexture(),a.textures++),n.activeTexture(t.TEXTURE0+l),n.bindTexture(t.TEXTURE_CUBE_MAP,p.__image__webglTextureCube),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,e.flipY);for(var d=e&&e.isCompressedTexture,m=e.image[0]&&e.image[0].isDataTexture,v=[],g=0;g<6;g++)v[g]=d||m?m?e.image[g].image:e.image[g]:s(e.image[g],i.maxCubemapSize);var y=u(v[0]),_=o.convert(e.format),b=o.convert(e.type);for(f(t.TEXTURE_CUBE_MAP,e,y),g=0;g<6;g++)if(d)for(var x,w=v[g].mipmaps,E=0,M=w.length;E<M;E++)x=w[E],e.format!==po&&e.format!==ho?n.getCompressedTextureFormats().indexOf(_)>-1?n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+g,E,_,x.width,x.height,0,x.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+g,E,_,x.width,x.height,0,_,b,x.data);else m?n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+g,0,_,v[g].width,v[g].height,0,_,b,v[g].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+g,0,_,_,b,v[g]);c(e,y)&&t.generateMipmap(t.TEXTURE_CUBE_MAP),p.__version=e.version,e.onUpdate&&e.onUpdate(e)}else n.activeTexture(t.TEXTURE0+l),n.bindTexture(t.TEXTURE_CUBE_MAP,p.__image__webglTextureCube)},this.setTextureCubeDynamic=function(e,i){n.activeTexture(t.TEXTURE0+i),n.bindTexture(t.TEXTURE_CUBE_MAP,r.get(e).__webglTexture)},this.setupRenderTarget=function(e){var i=r.get(e),o=r.get(e.texture);e.addEventListener("dispose",p),o.__webglTexture=t.createTexture(),a.textures++;var s=!0===e.isWebGLRenderTargetCube,l=u(e);if(s)for(i.__webglFramebuffer=[],h=0;h<6;h++)i.__webglFramebuffer[h]=t.createFramebuffer();else i.__webglFramebuffer=t.createFramebuffer();if(s){n.bindTexture(t.TEXTURE_CUBE_MAP,o.__webglTexture),f(t.TEXTURE_CUBE_MAP,e.texture,l);for(var h=0;h<6;h++)m(i.__webglFramebuffer[h],e,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+h);c(e.texture,l)&&t.generateMipmap(t.TEXTURE_CUBE_MAP),n.bindTexture(t.TEXTURE_CUBE_MAP,null)}else n.bindTexture(t.TEXTURE_2D,o.__webglTexture),f(t.TEXTURE_2D,e.texture,l),m(i.__webglFramebuffer,e,t.COLOR_ATTACHMENT0,t.TEXTURE_2D),c(e.texture,l)&&t.generateMipmap(t.TEXTURE_2D),n.bindTexture(t.TEXTURE_2D,null);e.depthBuffer&&function(e){var n=r.get(e),i=!0===e.isWebGLRenderTargetCube;if(e.depthTexture){if(i)throw new Error("target.depthTexture not supported in Cube render targets");!function(e,n){if(n&&n.isWebGLRenderTargetCube)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(t.FRAMEBUFFER,e),!n.depthTexture||!n.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");r.get(n.depthTexture).__webglTexture&&n.depthTexture.image.width===n.width&&n.depthTexture.image.height===n.height||(n.depthTexture.image.width=n.width,n.depthTexture.image.height=n.height,n.depthTexture.needsUpdate=!0),d(n.depthTexture,0);var i=r.get(n.depthTexture).__webglTexture;if(n.depthTexture.format===go)t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,i,0);else{if(n.depthTexture.format!==yo)throw new Error("Unknown depthTexture format");t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,i,0)}}(n.__webglFramebuffer,e)}else if(i){n.__webglDepthbuffer=[];for(var o=0;o<6;o++)t.bindFramebuffer(t.FRAMEBUFFER,n.__webglFramebuffer[o]),n.__webglDepthbuffer[o]=t.createRenderbuffer(),v(n.__webglDepthbuffer[o],e)}else t.bindFramebuffer(t.FRAMEBUFFER,n.__webglFramebuffer),n.__webglDepthbuffer=t.createRenderbuffer(),v(n.__webglDepthbuffer,e);t.bindFramebuffer(t.FRAMEBUFFER,null)}(e)},this.updateRenderTargetMipmap=function(e){var i=e.texture;if(c(i,u(e))){var o=e.isWebGLRenderTargetCube?t.TEXTURE_CUBE_MAP:t.TEXTURE_2D,a=r.get(i).__webglTexture;n.bindTexture(o,a),t.generateMipmap(o),n.bindTexture(o,null)}}}(Dt,Ft,zt,Bt,kt,te,Ot),Gt=new function(t){var e={};return{get:function(t){return t.isInterleavedBufferAttribute&&(t=t.data),e[t.uuid]},remove:function(n){n.isInterleavedBufferAttribute&&(n=n.data);var r=e[n.uuid];r&&(t.deleteBuffer(r.buffer),delete e[n.uuid])},update:function(n,r){n.isInterleavedBufferAttribute&&(n=n.data);var i=e[n.uuid];void 0===i?e[n.uuid]=function(e,n){var r=e.array,i=e.dynamic?t.DYNAMIC_DRAW:t.STATIC_DRAW,o=t.createBuffer();t.bindBuffer(n,o),t.bufferData(n,r,i),e.onUploadCallback();var a=t.FLOAT;return r instanceof Float32Array?a=t.FLOAT:r instanceof Float64Array?console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array."):r instanceof Uint16Array?a=t.UNSIGNED_SHORT:r instanceof Int16Array?a=t.SHORT:r instanceof Uint32Array?a=t.UNSIGNED_INT:r instanceof Int32Array?a=t.INT:r instanceof Int8Array?a=t.BYTE:r instanceof Uint8Array&&(a=t.UNSIGNED_BYTE),{buffer:o,type:a,bytesPerElement:r.BYTES_PER_ELEMENT,version:e.version}}(n,r):i.version<n.version&&(function(e,n,r){var i=n.array,o=n.updateRange;t.bindBuffer(r,e),!1===n.dynamic?t.bufferData(r,i,t.STATIC_DRAW):-1===o.count?t.bufferSubData(r,0,i):0===o.count?console.error("THREE.WebGLObjects.updateBuffer: dynamic THREE.BufferAttribute marked as needsUpdate but updateRange.count is 0, ensure you are using set methods or updating manually."):(t.bufferSubData(r,o.offset*i.BYTES_PER_ELEMENT,i.subarray(o.offset,o.offset+o.count)),o.count=-1)}(i.buffer,n,r),i.version=n.version)}}}(Dt),jt=new function(t,e,n){function r(t){var a=t.target,s=i[a.id];null!==s.index&&e.remove(s.index);for(var u in s.attributes)e.remove(s.attributes[u]);a.removeEventListener("dispose",r),delete i[a.id];var c=o[a.id];c&&(e.remove(c),delete o[a.id]),(c=o[s.id])&&(e.remove(c),delete o[s.id]),n.geometries--}var i={},o={};return{get:function(t,e){var o=i[e.id];return o||(e.addEventListener("dispose",r),e.isBufferGeometry?o=e:e.isGeometry&&(void 0===e._bufferGeometry&&(e._bufferGeometry=(new rt).setFromObject(t)),o=e._bufferGeometry),i[e.id]=o,n.geometries++,o)},update:function(n){var r=n.index,i=n.attributes;null!==r&&e.update(r,t.ELEMENT_ARRAY_BUFFER);for(var o in i)e.update(i[o],t.ARRAY_BUFFER);var a=n.morphAttributes;for(var o in a)for(var s=a[o],u=0,c=s.length;u<c;u++)e.update(s[u],t.ARRAY_BUFFER)},getWireframeAttribute:function(n){var r=o[n.id];if(r)return r;var i=[],a=n.index,s=n.attributes;if(null!==a)for(var u=0,c=(d=a.array).length;u<c;u+=3){var l=d[u+0],h=d[u+1],p=d[u+2];i.push(l,h,h,p,p,l)}else for(var d=s.position.array,u=0,c=d.length/3-1;u<c;u+=3){var l=u+0,h=u+1,p=u+2;i.push(l,h,h,p,p,l)}return r=new(nt(i)>65535?Q:Z)(i,1),e.update(r,t.ELEMENT_ARRAY_BUFFER),o[n.id]=r,r}}}(Dt,Gt,Ot),Vt=new function(t,e){var n={};return{update:function(r){var i=e.frame,o=r.geometry,a=t.get(r,o);return n[a.id]!==i&&(o.isGeometry&&a.updateFromObject(r),t.update(a),n[a.id]=i),a},clear:function(){n={}}}}(jt,Nt),Kt=new function(t){var e={},n=new Float32Array(8);return{update:function(r,i,o,a){var s=r.morphTargetInfluences,u=s.length,c=e[i.id];if(void 0===c){for(c=[],p=0;p<u;p++)c[p]=[p,0];e[i.id]=c}for(var l=o.morphTargets&&i.morphAttributes.position,h=o.morphNormals&&i.morphAttributes.normal,p=0;p<u;p++)0!==(d=c[p])[1]&&(l&&i.removeAttribute("morphTarget"+p),h&&i.removeAttribute("morphNormal"+p));for(p=0;p<u;p++)(d=c[p])[0]=p,d[1]=s[p];for(c.sort(function(t,e){return Math.abs(e[1])-Math.abs(t[1])}),p=0;p<8;p++){var d=c[p];if(d){var f=d[0],m=d[1];if(m){l&&i.addAttribute("morphTarget"+p,l[f]),h&&i.addAttribute("morphNormal"+p,h[f]),n[p]=m;continue}}n[p]=0}a.getUniforms().setValue(t,"morphTargetInfluences",n)}}}(Dt),qt=new function(t,e,n){function r(t,e){var n;return t?t.isTexture?n=t.encoding:t.isWebGLRenderTarget&&(console.warn("THREE.WebGLPrograms.getTextureEncodingFromMap: don't use render targets as textures. Use their .texture property instead."),n=t.texture.encoding):n=Bo,n===Bo&&e&&(n=Go),n}var i=[],o={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"phong",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow"},a=["precision","supportsVertexTextures","map","mapEncoding","envMap","envMapMode","envMapEncoding","lightMap","aoMap","emissiveMap","emissiveMapEncoding","bumpMap","normalMap","displacementMap","specularMap","roughnessMap","metalnessMap","gradientMap","alphaMap","combine","vertexColors","fog","useFog","fogExp","flatShading","sizeAttenuation","logarithmicDepthBuffer","skinning","maxBones","useVertexTexture","morphTargets","morphNormals","maxMorphTargets","maxMorphNormals","premultipliedAlpha","numDirLights","numPointLights","numSpotLights","numHemiLights","numRectAreaLights","shadowMapEnabled","shadowMapType","toneMapping","physicallyCorrectLights","alphaTest","doubleSided","flipSided","numClippingPlanes","numClipIntersection","depthPacking","dithering"];this.getParameters=function(e,i,a,s,u,c,l){var h=o[e.type],p=l.isSkinnedMesh?function(t){var e=t.skeleton.bones;if(n.floatVertexTextures)return 1024;var r=n.maxVertexUniforms,i=Math.floor((r-20)/4),o=Math.min(i,e.length);return o<e.length?(console.warn("THREE.WebGLRenderer: Skeleton has "+e.length+" bones. This GPU supports "+o+"."),0):o}(l):0,d=n.precision;null!==e.precision&&(d=n.getMaxPrecision(e.precision))!==e.precision&&console.warn("THREE.WebGLProgram.getParameters:",e.precision,"not supported, using",d,"instead.");var f=t.getRenderTarget();return{shaderID:h,precision:d,supportsVertexTextures:n.vertexTextures,outputEncoding:r(f?f.texture:null,t.gammaOutput),map:!!e.map,mapEncoding:r(e.map,t.gammaInput),envMap:!!e.envMap,envMapMode:e.envMap&&e.envMap.mapping,envMapEncoding:r(e.envMap,t.gammaInput),envMapCubeUV:!!e.envMap&&(e.envMap.mapping===Hi||e.envMap.mapping===Gi),lightMap:!!e.lightMap,aoMap:!!e.aoMap,emissiveMap:!!e.emissiveMap,emissiveMapEncoding:r(e.emissiveMap,t.gammaInput),bumpMap:!!e.bumpMap,normalMap:!!e.normalMap,displacementMap:!!e.displacementMap,roughnessMap:!!e.roughnessMap,metalnessMap:!!e.metalnessMap,specularMap:!!e.specularMap,alphaMap:!!e.alphaMap,gradientMap:!!e.gradientMap,combine:e.combine,vertexColors:e.vertexColors,fog:!!s,useFog:e.fog,fogExp:s&&s.isFogExp2,flatShading:e.flatShading,sizeAttenuation:e.sizeAttenuation,logarithmicDepthBuffer:n.logarithmicDepthBuffer,skinning:e.skinning&&p>0,maxBones:p,useVertexTexture:n.floatVertexTextures,morphTargets:e.morphTargets,morphNormals:e.morphNormals,maxMorphTargets:t.maxMorphTargets,maxMorphNormals:t.maxMorphNormals,numDirLights:i.directional.length,numPointLights:i.point.length,numSpotLights:i.spot.length,numRectAreaLights:i.rectArea.length,numHemiLights:i.hemi.length,numClippingPlanes:u,numClipIntersection:c,dithering:e.dithering,shadowMapEnabled:t.shadowMap.enabled&&l.receiveShadow&&a.length>0,shadowMapType:t.shadowMap.type,toneMapping:t.toneMapping,physicallyCorrectLights:t.physicallyCorrectLights,premultipliedAlpha:e.premultipliedAlpha,alphaTest:e.alphaTest,doubleSided:e.side===Wr,flipSided