/** * created by yuanweihai on 2017/6/20. */ !function(a,b){"object"==typeof exports&&"undefined"!=typeof module?b(exports):"function"==typeof define&&define.amd?define(["exports"],b):b(a.three=a.three||{})}(this,function(a){"use strict";function b(){}function ub(a,b){this.x=a||0,this.y=b||0}function wb(a,b,c,d,e,f,g,h,i,j){object.defineproperty(this,"id",{value:vb++}),this.uuid=tb.generateuuid(),this.name="",this.image=void 0!==a?a:wb.default_image,this.mipmaps=[],this.mapping=void 0!==b?b:wb.default_mapping,this.wraps=void 0!==c?c:oa,this.wrapt=void 0!==d?d:oa,this.magfilter=void 0!==e?e:ta,this.minfilter=void 0!==f?f:va,this.anisotropy=void 0!==i?i:1,this.format=void 0!==g?g:ka,this.type=void 0!==h?h:wa,this.offset=new ub(0,0),this.repeat=new ub(1,1),this.generatemipmaps=!0,this.premultiplyalpha=!1,this.flipy=!0,this.unpackalignment=4,this.encoding=void 0!==j?j:jb,this.version=0,this.onupdate=null}function xb(a,b,c,d){this.x=a||0,this.y=b||0,this.z=c||0,this.w=void 0!==d?d:1}function yb(a,b,c){this.uuid=tb.generateuuid(),this.width=a,this.height=b,this.scissor=new xb(0,0,a,b),this.scissortest=!1,this.viewport=new xb(0,0,a,b),c=c||{},void 0===c.minfilter&&(c.minfilter=ta),this.texture=new wb(void 0,void 0,c.wraps,c.wrapt,c.magfilter,c.minfilter,c.format,c.type,c.anisotropy,c.encoding),this.depthbuffer=void 0===c.depthbuffer||c.depthbuffer,this.stencilbuffer=void 0===c.stencilbuffer||c.stencilbuffer,this.depthtexture=void 0!==c.depthtexture?c.depthtexture:null}function zb(a,b,c){yb.call(this,a,b,c),this.activecubeface=0,this.activemipmaplevel=0}function ab(a,b,c,d){this._x=a||0,this._y=b||0,this._z=c||0,this._w=void 0!==d?d:1}function bb(a,b,c){this.x=a||0,this.y=b||0,this.z=c||0}function cb(){this.elements=new float32array([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 db(a,b,c,d,e,f,g,h,i,j){a=void 0!==a?a:[],b=void 0!==b?b:ga,wb.call(this,a,b,c,d,e,f,g,h,i,j),this.flipy=!1}function gb(){this.seq=[],this.map={}}function jb(a,b,c){var d=a[0];if(d<=0||d>0)return a;var e=b*c,f=hb[e];if(void 0===f&&(f=new float32array(e),hb[e]=f),0!==b){d.toarray(f,0);for(var g=1,h=0;g!==b;++g)h+=c,a[g].toarray(f,h)}return f}function kb(a,b){var c=ib[b];void 0===c&&(c=new int32array(b),ib[b]=c);for(var d=0;d!==b;++d)c[d]=a.alloctextureunit();return c}function lb(a,b){a.uniform1f(this.addr,b)}function mb(a,b){a.uniform1i(this.addr,b)}function nb(a,b){void 0===b.x?a.uniform2fv(this.addr,b):a.uniform2f(this.addr,b.x,b.y)}function ob(a,b){void 0!==b.x?a.uniform3f(this.addr,b.x,b.y,b.z):void 0!==b.r?a.uniform3f(this.addr,b.r,b.g,b.b):a.uniform3fv(this.addr,b)}function pb(a,b){void 0===b.x?a.uniform4fv(this.addr,b):a.uniform4f(this.addr,b.x,b.y,b.z,b.w)}function qb(a,b){a.uniformmatrix2fv(this.addr,!1,b.elements||b)}function rb(a,b){a.uniformmatrix3fv(this.addr,!1,b.elements||b)}function sb(a,b){a.uniformmatrix4fv(this.addr,!1,b.elements||b)}function tb(a,b,c){var d=c.alloctextureunit();a.uniform1i(this.addr,d),c.settexture2d(b||eb,d)}function ub(a,b,c){var d=c.alloctextureunit();a.uniform1i(this.addr,d),c.settexturecube(b||fb,d)}function vb(a,b){a.uniform2iv(this.addr,b)}function wb(a,b){a.uniform3iv(this.addr,b)}function xb(a,b){a.uniform4iv(this.addr,b)}function yb(a){switch(a){case 5126:return lb;case 35664:return nb;case 35665:return ob;case 35666:return pb;case 35674:return qb;case 35675:return rb;case 35676:return sb;case 35678:return tb;case 35680:return ub;case 5124:case 35670:return mb;case 35667:case 35671:return vb;case 35668:case 35672:return wb;case 35669:case 35673:return xb}}function zb(a,b){a.uniform1fv(this.addr,b)}function $b(a,b){a.uniform1iv(this.addr,b)}function _b(a,b){a.uniform2fv(this.addr,jb(b,this.size,2))}function ac(a,b){a.uniform3fv(this.addr,jb(b,this.size,3))}function bc(a,b){a.uniform4fv(this.addr,jb(b,this.size,4))}function cc(a,b){a.uniformmatrix2fv(this.addr,!1,jb(b,this.size,4))}function dc(a,b){a.uniformmatrix3fv(this.addr,!1,jb(b,this.size,9))}function ec(a,b){a.uniformmatrix4fv(this.addr,!1,jb(b,this.size,16))}function fc(a,b,c){var d=b.length,e=kb(c,d);a.uniform1iv(this.addr,e);for(var f=0;f!==d;++f)c.settexture2d(b[f]||eb,e[f])}function gc(a,b,c){var d=b.length,e=kb(c,d);a.uniform1iv(this.addr,e);for(var f=0;f!==d;++f)c.settexturecube(b[f]||fb,e[f])}function hc(a){switch(a){case 5126:return zb;case 35664:return _b;case 35665:return ac;case 35666:return bc;case 35674:return cc;case 35675:return dc;case 35676:return ec;case 35678:return fc;case 35680:return gc;case 5124:case 35670:return $b;case 35667:case 35671:return vb;case 35668:case 35672:return wb;case 35669:case 35673:return xb}}function ic(a,b,c){this.id=a,this.addr=c,this.setvalue=yb(b.type)}function jc(a,b,c){this.id=a,this.addr=c,this.size=b.size,this.setvalue=hc(b.type)}function kc(a){this.id=a,gb.call(this)}function mc(a,b){a.seq.push(b),a.map[b.id]=b}function nc(a,b,c){var d=a.name,e=d.length;for(lc.lastindex=0;;){var f=lc.exec(d),g=lc.lastindex,h=f[1],i="]"===f[2],j=f[3];if(i&&(h|=0),void 0===j||"["===j&&g+2===e){mc(c,void 0===j?new ic(h,a,b):new jc(h,a,b));break}var k=c.map,l=k[h];void 0===l&&(l=new kc(h),mc(c,l)),c=l}}function oc(a,b,c){gb.call(this),this.renderer=c;for(var d=a.getprogramparameter(b,a.active_uniforms),e=0;e.001&&d.scale>.001&&(v.x=d.x,v.y=d.y,v.z=d.z,t=d.size*d.scale/o.w,u.x=t*q,u.y=t,c.uniform3f(j.screenposition,v.x,v.y,v.z),c.uniform2f(j.scale,u.x,u.y),c.uniform1f(j.rotation,d.rotation),c.uniform1f(j.opacity,d.opacity),c.uniform3f(j.color,d.color.r,d.color.g,d.color.b),d.setblending(d.blending,d.blendequation,d.blendsrc,d.blenddst),a.settexture2d(d.texture,1),c.drawelements(c.triangles,6,c.unsigned_short,0))}}}d.enable(c.cull_face),d.enable(c.depth_test),d.setdepthwrite(!0),a.resetglstate()}}}function ye(a,b){function n(){var a=new float32array([-.5,-.5,0,0,.5,-.5,1,0,.5,.5,1,1,-.5,.5,0,1]),b=new uint16array([0,1,2,0,2,3]);e=c.createbuffer(),f=c.createbuffer(),c.bindbuffer(c.array_buffer,e),c.bufferdata(c.array_buffer,a,c.static_draw),c.bindbuffer(c.element_array_buffer,f),c.bufferdata(c.element_array_buffer,b,c.static_draw),g=o(),h={position:c.getattriblocation(g,"position"),uv:c.getattriblocation(g,"uv")},i={uvoffset:c.getuniformlocation(g,"uvoffset"),uvscale:c.getuniformlocation(g,"uvscale"),rotation:c.getuniformlocation(g,"rotation"),scale:c.getuniformlocation(g,"scale"),color:c.getuniformlocation(g,"color"),map:c.getuniformlocation(g,"map"),opacity:c.getuniformlocation(g,"opacity"),modelviewmatrix:c.getuniformlocation(g,"modelviewmatrix"),projectionmatrix:c.getuniformlocation(g,"projectionmatrix"),fogtype:c.getuniformlocation(g,"fogtype"),fogdensity:c.getuniformlocation(g,"fogdensity"),fognear:c.getuniformlocation(g,"fognear"),fogfar:c.getuniformlocation(g,"fogfar"),fogcolor:c.getuniformlocation(g,"fogcolor"),alphatest:c.getuniformlocation(g,"alphatest")};var d=document.createelementns("http://www.w3.org/1999/xhtml","canvas");d.width=8,d.height=8;var k=d.getcontext("2d");k.fillstyle="white",k.fillrect(0,0,8,8),j=new wb(d),j.needsupdate=!0}function o(){var b=c.createprogram(),d=c.createshader(c.vertex_shader),e=c.createshader(c.fragment_shader);return c.shadersource(d,["precision "+a.getprecision()+" float;","uniform mat4 modelviewmatrix;","uniform mat4 projectionmatrix;","uniform float rotation;","uniform vec2 scale;","uniform vec2 uvoffset;","uniform vec2 uvscale;","attribute vec2 position;","attribute vec2 uv;","varying vec2 vuv;","void main() {","vuv = uvoffset + uv * uvscale;","vec2 alignedposition = position * scale;","vec2 rotatedposition;","rotatedposition.x = cos( rotation ) * alignedposition.x - sin( rotation ) * alignedposition.y;","rotatedposition.y = sin( rotation ) * alignedposition.x + cos( rotation ) * alignedposition.y;","vec4 finalposition;","finalposition = modelviewmatrix * vec4( 0.0, 0.0, 0.0, 1.0 );","finalposition.xy += rotatedposition;","finalposition = projectionmatrix * finalposition;","gl_position = finalposition;","}"].join("\n")),c.shadersource(e,["precision "+a.getprecision()+" float;","uniform vec3 color;","uniform sampler2d map;","uniform float opacity;","uniform int fogtype;","uniform vec3 fogcolor;","uniform float fogdensity;","uniform float fognear;","uniform float fogfar;","uniform float alphatest;","varying vec2 vuv;","void main() {","vec4 texture = texture2d( map, vuv );","if ( texture.a < alphatest ) discard;","gl_fragcolor = vec4( color * texture.xyz, texture.a * opacity );","if ( fogtype > 0 ) {","float depth = gl_fragcoord.z / gl_fragcoord.w;","float fogfactor = 0.0;","if ( fogtype == 1 ) {","fogfactor = smoothstep( fognear, fogfar, depth );","} else {","const float log2 = 1.442695;","fogfactor = exp2( - fogdensity * fogdensity * depth * depth * log2 );","fogfactor = 1.0 - clamp( fogfactor, 0.0, 1.0 );","}","gl_fragcolor = mix( gl_fragcolor, vec4( fogcolor, gl_fragcolor.w ), fogfactor );","}","}"].join("\n")),c.compileshader(d),c.compileshader(e),c.attachshader(b,d),c.attachshader(b,e),c.linkprogram(b),b}function p(a,b){return a.renderorder!==b.renderorder?a.renderorder-b.renderorder:a.z!==b.z?b.z-a.z:b.id-a.id}var e,f,g,h,i,j,c=a.context,d=a.state,k=new bb,l=new ab,m=new bb;this.render=function(o,q){if(0!==b.length){void 0===g&&n(),c.useprogram(g),d.initattributes(),d.enableattribute(h.position),d.enableattribute(h.uv),d.disableunusedattributes(),d.disable(c.cull_face),d.enable(c.blend),c.bindbuffer(c.array_buffer,e),c.vertexattribpointer(h.position,2,c.float,!1,16,0),c.vertexattribpointer(h.uv,2,c.float,!1,16,8),c.bindbuffer(c.element_array_buffer,f),c.uniformmatrix4fv(i.projectionmatrix,!1,q.projectionmatrix.elements),d.activetexture(c.texture0),c.uniform1i(i.map,0);var r=0,s=0,t=o.fog;t?(c.uniform3f(i.fogcolor,t.color.r,t.color.g,t.color.b),t.isfog?(c.uniform1f(i.fognear,t.near),c.uniform1f(i.fogfar,t.far),c.uniform1i(i.fogtype,1),r=1,s=1):t.isfogexp2&&(c.uniform1f(i.fogdensity,t.density),c.uniform1i(i.fogtype,2),r=2,s=2)):(c.uniform1i(i.fogtype,0),r=0,s=0);for(var u=0,v=b.length;u0&&console.error("three.matrix3: the constructor no longer reads arguments. use .set() instead.")}function ge(a,b){this.normal=void 0!==a?a:new bb(1,0,0),this.constant=void 0!==b?b:0}function he(a,b,c,d,e,f){this.planes=[void 0!==a?a:new ge,void 0!==b?b:new ge,void 0!==c?c:new ge,void 0!==d?d:new ge,void 0!==e?e:new ge,void 0!==f?f:new ge]}function ie(a,b,c,d){function k(b,c,d,e){var f=b.geometry,g=null,h=v,i=b.customdepthmaterial;if(d&&(h=w,i=b.customdistancematerial),i)g=i;else{var j=!1;c.morphtargets&&(f&&f.isbuffergeometry?j=f.morphattributes&&f.morphattributes.position&&f.morphattributes.position.length>0:f&&f.isgeometry&&(j=f.morphtargets&&f.morphtargets.length>0));var k=b.isskinnedmesh&&c.skinning,l=0;j&&(l|=s),k&&(l|=t),g=h[l]}if(a.localclippingenabled&&c.clipshadows===!0&&0!==c.clippingplanes.length){var m=g.uuid,q=c.uuid,r=x[m];void 0===r&&(r={},x[m]=r);var u=r[q];void 0===u&&(u=g.clone(),r[q]=u),g=u}g.visible=c.visible,g.wireframe=c.wireframe;var y=c.side;return j.rendersinglesided&&y==p&&(y=n),j.renderreversesided&&(y===n?y=o:y===o&&(y=n)),g.side=y,g.clipshadows=c.clipshadows,g.clippingplanes=c.clippingplanes,g.wireframelinewidth=c.wireframelinewidth,g.linewidth=c.linewidth,d&&void 0!==g.uniforms.lightpos&&g.uniforms.lightpos.value.copy(e),g}function l(a,b,c){if(a.visible!==!1){var d=0!==(a.layers.mask&b.layers.mask);if(d&&(a.ismesh||a.isline||a.ispoints)&&a.castshadow&&(a.frustumculled===!1||g.intersectsobject(a)===!0)){var e=a.material;e.visible===!0&&(a.modelviewmatrix.multiplymatrices(c.matrixworldinverse,a.matrixworld),r.push(a))}for(var f=a.children,h=0,i=f.length;hc&&(c=a[b]);return c}function df(){return cf++}function ef(){object.defineproperty(this,"id",{value:df()}),this.uuid=tb.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 ff(){object.defineproperty(this,"id",{value:df()}),this.uuid=tb.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 gf(a,b){ne.call(this),this.type="mesh",this.geometry=void 0!==a?a:new ff,this.material=void 0!==b?b:new re({color:16777215*math.random()}),this.drawmode=gb,this.updatemorphtargets()}function hf(a,b,c,d,e,f){ef.call(this),this.type="boxgeometry",this.parameters={width:a,height:b,depth:c,widthsegments:d,heightsegments:e,depthsegments:f},this.frombuffergeometry(new jf(a,b,c,d,e,f)),this.mergevertices()}function jf(a,b,c,d,e,f){function n(a,b,c,d,e,f,n,o,p,q,r){var b,c,s=f/p,t=n/q,u=f/2,v=n/2,w=o/2,x=p+1,y=q+1,z=0,a=0,d=new bb;for(c=0;c0?1:-1,j.push(d.x,d.y,d.z),k.push(b/p),k.push(1-c/q),z+=1}}for(c=0;c");return ef(c)}var b=/#include +<([\w\d.]+)>/g;return a.replace(b,c)}function ff(a){function c(a,b,c,d){for(var e="",f=parseint(b);f0?a.gammafactor:1,q=zf(f,d,a.extensions),r=af(g),s=e.createprogram();c.israwshadermaterial?(t=[r,"\n"].filter(cf).join("\n"),u=[q,r,"\n"].filter(cf).join("\n")):(t=["precision "+d.precision+" float;","precision "+d.precision+" int;","#define shader_name "+c.__webglshader.name,r,d.supportsvertextextures?"#define vertex_textures":"","#define gamma_factor "+p,"#define max_bones "+d.maxbones,d.usefog&&d.fog?"#define use_fog":"",d.usefog&&d.fogexp?"#define fog_exp2":"",d.map?"#define use_map":"",d.envmap?"#define use_envmap":"",d.envmap?"#define "+n:"",d.lightmap?"#define use_lightmap":"",d.aomap?"#define use_aomap":"",d.emissivemap?"#define use_emissivemap":"",d.bumpmap?"#define use_bumpmap":"",d.normalmap?"#define use_normalmap":"",d.displacementmap&&d.supportsvertextextures?"#define use_displacementmap":"",d.specularmap?"#define use_specularmap":"",d.roughnessmap?"#define use_roughnessmap":"",d.metalnessmap?"#define use_metalnessmap":"",d.alphamap?"#define use_alphamap":"",d.vertexcolors?"#define use_color":"",d.flatshading?"#define flat_shaded":"",d.skinning?"#define use_skinning":"",d.usevertextexture?"#define bone_texture":"",d.morphtargets?"#define use_morphtargets":"",d.morphnormals&&d.flatshading===!1?"#define use_morphnormals":"",d.doublesided?"#define double_sided":"",d.flipsided?"#define flip_sided":"","#define num_clipping_planes "+d.numclippingplanes,d.shadowmapenabled?"#define use_shadowmap":"",d.shadowmapenabled?"#define "+j:"",d.sizeattenuation?"#define use_sizeattenuation":"",d.logarithmicdepthbuffer?"#define use_logdepthbuf":"",d.logarithmicdepthbuffer&&a.extensions.get("ext_frag_depth")?"#define use_logdepthbuf_ext":"","uniform mat4 modelmatrix;","uniform mat4 modelviewmatrix;","uniform mat4 projectionmatrix;","uniform mat4 viewmatrix;","uniform mat3 normalmatrix;","uniform vec3 cameraposition;","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef use_color","\tattribute vec3 color;","#endif","#ifdef use_morphtargets","\tattribute vec3 morphtarget0;","\tattribute vec3 morphtarget1;","\tattribute vec3 morphtarget2;","\tattribute vec3 morphtarget3;","\t#ifdef use_morphnormals","\t\tattribute vec3 morphnormal0;","\t\tattribute vec3 morphnormal1;","\t\tattribute vec3 morphnormal2;","\t\tattribute vec3 morphnormal3;","\t#else","\t\tattribute vec3 morphtarget4;","\t\tattribute vec3 morphtarget5;","\t\tattribute vec3 morphtarget6;","\t\tattribute vec3 morphtarget7;","\t#endif","#endif","#ifdef use_skinning","\tattribute vec4 skinindex;","\tattribute vec4 skinweight;","#endif","\n"].filter(cf).join("\n"),u=[q,"precision "+d.precision+" float;","precision "+d.precision+" int;","#define shader_name "+c.__webglshader.name,r,d.alphatest?"#define alphatest "+d.alphatest:"","#define gamma_factor "+p,d.usefog&&d.fog?"#define use_fog":"",d.usefog&&d.fogexp?"#define fog_exp2":"",d.map?"#define use_map":"",d.envmap?"#define use_envmap":"",d.envmap?"#define "+k:"",d.envmap?"#define "+n:"",d.envmap?"#define "+o:"",d.lightmap?"#define use_lightmap":"",d.aomap?"#define use_aomap":"",d.emissivemap?"#define use_emissivemap":"",d.bumpmap?"#define use_bumpmap":"",d.normalmap?"#define use_normalmap":"",d.specularmap?"#define use_specularmap":"",d.roughnessmap?"#define use_roughnessmap":"",d.metalnessmap?"#define use_metalnessmap":"",d.alphamap?"#define use_alphamap":"",d.vertexcolors?"#define use_color":"",d.gradientmap?"#define use_gradientmap":"",d.flatshading?"#define flat_shaded":"",d.doublesided?"#define double_sided":"",d.flipsided?"#define flip_sided":"","#define num_clipping_planes "+d.numclippingplanes,"#define union_clipping_planes "+(d.numclippingplanes-d.numclipintersection),d.shadowmapenabled?"#define use_shadowmap":"",d.shadowmapenabled?"#define "+j:"",d.premultipliedalpha?"#define premultiplied_alpha":"",d.physicallycorrectlights?"#define physically_correct_lights":"",d.logarithmicdepthbuffer?"#define use_logdepthbuf":"",d.logarithmicdepthbuffer&&a.extensions.get("ext_frag_depth")?"#define use_logdepthbuf_ext":"",d.envmap&&a.extensions.get("ext_shader_texture_lod")?"#define texture_lod_ext":"","uniform mat4 viewmatrix;","uniform vec3 cameraposition;",d.tonemapping!==aa?"#define tone_mapping":"",d.tonemapping!==aa?qe.tonemapping_pars_fragment:"",d.tonemapping!==aa?yf("tonemapping",d.tonemapping):"",d.outputencoding||d.mapencoding||d.envmapencoding||d.emissivemapencoding?qe.encodings_pars_fragment:"",d.mapencoding?wf("maptexeltolinear",d.mapencoding):"",d.envmapencoding?wf("envmaptexeltolinear",d.envmapencoding):"",d.emissivemapencoding?wf("emissivemaptexeltolinear",d.emissivemapencoding):"",d.outputencoding?xf("lineartooutputtexel",d.outputencoding):"",d.depthpacking?"#define depth_packing "+c.depthpacking:"","\n"].filter(cf).join("\n")),h=ef(h,d),h=df(h,d),i=ef(i,d),i=df(i,d),c.isshadermaterial||(h=ff(h),i=ff(i));var v=t+h,w=u+i,x=tf(e,e.vertex_shader,v),y=tf(e,e.fragment_shader,w);e.attachshader(s,x),e.attachshader(s,y),void 0!==c.index0attributename?e.bindattriblocation(s,0,c.index0attributename):d.morphtargets===!0&&e.bindattriblocation(s,0,"position"),e.linkprogram(s);var z=e.getprograminfolog(s),a=e.getshaderinfolog(x),b=e.getshaderinfolog(y),c=!0,d=!0;e.getprogramparameter(s,e.link_status)===!1?(c=!1,console.error("three.webglprogram: shader error: ",e.geterror(),"gl.validate_status",e.getprogramparameter(s,e.validate_status),"gl.getprograminfolog",z,a,b)):""!==z?console.warn("three.webglprogram: gl.getprograminfolog()",z):""!==a&&""!==b||(d=!1),d&&(this.diagnostics={runnable:c,material:c,programlog:z,vertexshader:{log:a,prefix:t},fragmentshader:{log:b,prefix:u}}),e.deleteshader(x),e.deleteshader(y);var e;this.getuniforms=function(){return void 0===e&&(e=new oc(e,s,a)),e};var f;return this.getattributes=function(){return void 0===f&&(f=bf(e,s)),f},this.destroy=function(){e.deleteprogram(s),this.program=void 0},object.defineproperties(this,{uniforms:{get:function(){return console.warn("three.webglprogram: .uniforms is now .getuniforms()."),this.getuniforms()}},attributes:{get:function(){return console.warn("three.webglprogram: .attributes is now .getattributes()."),this.getattributes()}}}),this.id=uf++,this.code=b,this.usedtimes=1,this.program=s,this.vertexshader=x,this.fragmentshader=y,this}function hf(a,b){function f(a){if(b.floatvertextextures&&a&&a.skeleton&&a.skeleton.usevertextexture)return 1024;var c=b.maxvertexuniforms,d=math.floor((c-20)/4),e=d;return void 0!==a&&a&&a.isskinnedmesh&&(e=math.min(a.skeleton.bones.length,e),e0,shadowmaptype:a.shadowmap.type,tonemapping:a.tonemapping,physicallycorrectlights:a.physicallycorrectlights,premultipliedalpha:c.premultipliedalpha,alphatest:c.alphatest,doublesided:c.side===p,flipsided:c.side===o,depthpacking:void 0!==c.depthpacking&&c.depthpacking};return s},this.getprogramcode=function(a,b){var c=[];if(b.shaderid?c.push(b.shaderid):(c.push(a.fragmentshader),c.push(a.vertexshader)),void 0!==a.defines)for(var d in a.defines)c.push(d),c.push(a.defines[d]);for(var f=0;f65535?ze:xe)(e,1);return f(o,a.element_array_buffer),d.wireframe=o,o}var d=new if(a,b,c);return{getattributebuffer:i,getattributeproperties:j,getwireframeattribute:k,update:e}}function kf(a,b,c,d,e,f,g){function j(a,b){if(a.width>b||a.height>b){var c=b/math.max(a.width,a.height),d=document.createelementns("http://www.w3.org/1999/xhtml","canvas");d.width=math.floor(a.width*c),d.height=math.floor(a.height*c);var e=d.getcontext("2d");return e.drawimage(a,0,0,a.width,a.height,0,0,d.width,d.height),console.warn("three.webglrenderer: image is too big ("+a.width+"x"+a.height+"). resized to "+d.width+"x"+d.height,a),d}return a}function k(a){return tb.ispoweroftwo(a.width)&&tb.ispoweroftwo(a.height)}function l(a){if(a instanceof htmlimageelement||a instanceof htmlcanvaselement){var b=document.createelementns("http://www.w3.org/1999/xhtml","canvas");b.width=tb.nearestpoweroftwo(a.width),b.height=tb.nearestpoweroftwo(a.height);var c=b.getcontext("2d");return c.drawimage(a,0,0,b.width,b.height),console.warn("three.webglrenderer: image is not power of two ("+a.width+"x"+a.height+"). resized to "+b.width+"x"+b.height,a),b}return a}function m(a){return a.wraps!==oa||a.wrapt!==oa||a.minfilter!==qa&&a.minfilter!==ta}function n(b){return b===qa||b===ra||b===sa?a.nearest:a.linear}function o(a){var b=a.target;b.removeeventlistener("dispose",o),q(b),h.textures--}function p(a){var b=a.target;b.removeeventlistener("dispose",p),r(b),h.textures--}function q(b){var c=d.get(b);if(b.image&&c.__image__webgltexturecube)a.deletetexture(c.__image__webgltexturecube);else{if(void 0===c.__webglinit)return;a.deletetexture(c.__webgltexture)}d.delete(b)}function r(b){var c=d.get(b),e=d.get(b.texture);if(b){if(void 0!==e.__webgltexture&&a.deletetexture(e.__webgltexture),b.depthtexture&&b.depthtexture.dispose(),b.iswebglrendertargetcube)for(var f=0;f<6;f++)a.deleteframebuffer(c.__webglframebuffer[f]),c.__webgldepthbuffer&&a.deleterenderbuffer(c.__webgldepthbuffer[f]);else a.deleteframebuffer(c.__webglframebuffer),c.__webgldepthbuffer&&a.deleterenderbuffer(c.__webgldepthbuffer);d.delete(b.texture),d.delete(b)}}function s(b,e){var f=d.get(b);if(b.version>0&&f.__version!==b.version){var g=b.image;if(void 0===g)console.warn("three.webglrenderer: texture marked for update but image is undefined",b);else{if(g.complete!==!1)return void w(f,b,e);console.warn("three.webglrenderer: texture marked for update but image is incomplete",b)}}c.activetexture(a.texture0+e),c.bindtexture(a.texture_2d,f.__webgltexture)}function t(b,g){var i=d.get(b);if(6===b.image.length)if(b.version>0&&i.__version!==b.version){i.__image__webgltexturecube||(b.addeventlistener("dispose",o),i.__image__webgltexturecube=a.createtexture(),h.textures++),c.activetexture(a.texture0+g),c.bindtexture(a.texture_cube_map,i.__image__webgltexturecube),a.pixelstorei(a.unpack_flip_y_webgl,b.flipy);for(var l=b&&b.iscompressedtexture,m=b.image[0]&&b.image[0].isdatatexture,n=[],p=0;p<6;p++)l||m?n[p]=m?b.image[p].image:b.image[p]:n[p]=j(b.image[p],e.maxcubemapsize);var q=n[0],r=k(q),s=f(b.format),t=f(b.type);v(a.texture_cube_map,b,r);for(var p=0;p<6;p++)if(l)for(var u,w=n[p].mipmaps,x=0,y=w.length;x-1?c.compressedteximage2d(a.texture_cube_map_positive_x+p,x,s,u.width,u.height,0,u.data):console.warn("three.webglrenderer: attempt to load unsupported compressed texture format in .settexturecube()"):c.teximage2d(a.texture_cube_map_positive_x+p,x,s,u.width,u.height,0,s,t,u.data);else m?c.teximage2d(a.texture_cube_map_positive_x+p,0,s,n[p].width,n[p].height,0,s,t,n[p].data):c.teximage2d(a.texture_cube_map_positive_x+p,0,s,s,t,n[p]);b.generatemipmaps&&r&&a.generatemipmap(a.texture_cube_map),i.__version=b.version,b.onupdate&&b.onupdate(b)}else c.activetexture(a.texture0+g),c.bindtexture(a.texture_cube_map,i.__image__webgltexturecube)}function u(b,e){c.activetexture(a.texture0+e),c.bindtexture(a.texture_cube_map,d.get(b).__webgltexture)}function v(c,g,h){var i;if(h?(a.texparameteri(c,a.texture_wrap_s,f(g.wraps)),a.texparameteri(c,a.texture_wrap_t,f(g.wrapt)),a.texparameteri(c,a.texture_mag_filter,f(g.magfilter)),a.texparameteri(c,a.texture_min_filter,f(g.minfilter))):(a.texparameteri(c,a.texture_wrap_s,a.clamp_to_edge),a.texparameteri(c,a.texture_wrap_t,a.clamp_to_edge),g.wraps===oa&&g.wrapt===oa||console.warn("three.webglrenderer: texture is not power of two. texture.wraps and texture.wrapt should be set to three.clamptoedgewrapping.",g),a.texparameteri(c,a.texture_mag_filter,n(g.magfilter)),a.texparameteri(c,a.texture_min_filter,n(g.minfilter)),g.minfilter!==qa&&g.minfilter!==ta&&console.warn("three.webglrenderer: texture is not power of two. texture.minfilter should be set to three.nearestfilter or three.linearfilter.",g)),i=b.get("ext_texture_filter_anisotropic")){if(g.type===ca&&null===b.get("oes_texture_float_linear"))return;if(g.type===da&&null===b.get("oes_texture_half_float_linear"))return;(g.anisotropy>1||d.get(g).__currentanisotropy)&&(a.texparameterf(c,i.texture_max_anisotropy_ext,math.min(g.anisotropy,e.getmaxanisotropy())),d.get(g).__currentanisotropy=g.anisotropy)}}function w(b,d,g){void 0===b.__webglinit&&(b.__webglinit=!0,d.addeventlistener("dispose",o),b.__webgltexture=a.createtexture(),h.textures++),c.activetexture(a.texture0+g),c.bindtexture(a.texture_2d,b.__webgltexture),a.pixelstorei(a.unpack_flip_y_webgl,d.flipy),a.pixelstorei(a.unpack_premultiply_alpha_webgl,d.premultiplyalpha),a.pixelstorei(a.unpack_alignment,d.unpackalignment);var n=j(d.image,e.maxtexturesize);m(d)&&k(n)===!1&&(n=l(n));var p=k(n),q=f(d.format),r=f(d.type);v(a.texture_2d,d,p);var s,t=d.mipmaps;if(d.isdepthtexture){var u=a.depth_component;if(d.type===ca){if(!i)throw new error("float depth texture only supported in webgl2.0");u=a.depth_component32f}else i&&(u=a.depth_component16);d.format===oa&&u===a.depth_component&&d.type!==za&&d.type!==ba&&(console.warn("three.webglrenderer: use unsignedshorttype or unsignedinttype for depthformat depthtexture."),d.type=za,r=f(d.type)),d.format===pa&&(u=a.depth_stencil,d.type!==ha&&(console.warn("three.webglrenderer: use unsignedint248type for depthstencilformat depthtexture."),d.type=ha,r=f(d.type))),c.teximage2d(a.texture_2d,0,u,n.width,n.height,0,q,r,null)}else if(d.isdatatexture)if(t.length>0&&p){for(var w=0,x=t.length;w-1?c.compressedteximage2d(a.texture_2d,w,q,s.width,s.height,0,s.data):console.warn("three.webglrenderer: attempt to load unsupported compressed texture format in .uploadtexture()"):c.teximage2d(a.texture_2d,w,q,s.width,s.height,0,q,r,s.data);else if(t.length>0&&p){for(var w=0,x=t.length;w=1,p=null,q={},z=new xb,$=new xb,aa={};return aa[a.texture_2d]=_(a.texture_2d,a.texture_2d,1),aa[a.texture_cube_map]=_(a.texture_cube_map,a.texture_cube_map_positive_x,6),{buffers:{color:j,depth:k,stencil:l},init:ba,initattributes:ca,enableattribute:da,enableattributeanddivisor:ea,disableunusedattributes:fa,enable:ga,disable:ha,getcompressedtextureformats:ia,setblending:ja,setcolorwrite:ka,setdepthtest:la,setdepthwrite:ma,setdepthfunc:na,setstenciltest:oa,setstencilwrite:pa,setstencilfunc:qa,setstencilop:ra,setflipsided:sa,setcullface:ta,setlinewidth:ua,setpolygonoffset:va,getscissortest:wa,setscissortest:xa,activetexture:ya,bindtexture:za,compressedteximage2d:aa,teximage2d:ba,scissor:ca,viewport:da,reset:ea}}function nf(a,b,c){function e(){if(void 0!==d)return d;var c=b.get("ext_texture_filter_anisotropic");return d=null!==c?a.getparameter(c.max_texture_max_anisotropy_ext):0}function f(b){if("highp"===b){if(a.getshaderprecisionformat(a.vertex_shader,a.high_float).precision>0&&a.getshaderprecisionformat(a.fragment_shader,a.high_float).precision>0)return"highp";b="mediump"}return"mediump"===b&&a.getshaderprecisionformat(a.vertex_shader,a.medium_float).precision>0&&a.getshaderprecisionformat(a.fragment_shader,a.medium_float).precision>0?"mediump":"lowp"}var d,g=void 0!==c.precision?c.precision:"highp",h=f(g);h!==g&&(console.warn("three.webglrenderer:",g,"not supported, using",h,"instead."),g=h);var i=c.logarithmicdepthbuffer===!0&&!!b.get("ext_frag_depth"),j=a.getparameter(a.max_texture_image_units),k=a.getparameter(a.max_vertex_texture_image_units),l=a.getparameter(a.max_texture_size),m=a.getparameter(a.max_cube_map_texture_size),n=a.getparameter(a.max_vertex_attribs),o=a.getparameter(a.max_vertex_uniform_vectors),p=a.getparameter(a.max_varying_vectors),q=a.getparameter(a.max_fragment_uniform_vectors),r=k>0,s=!!b.get("oes_texture_float"),t=r&&s;return{getmaxanisotropy:e,getmaxprecision:f,precision:g,logarithmicdepthbuffer:i,maxtextures:j,maxvertextextures:k,maxtexturesize:l,maxcubemapsize:m,maxattributes:n,maxvertexuniforms:o,maxvaryings:p,maxfragmentuniforms:q,vertextextures:r,floatfragmenttextures:s,floatvertextextures:t}}function of(a){var b={};return{get:function(c){if(void 0!==b[c])return b[c];var d;switch(c){case"webgl_depth_texture":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;case"webgl_compressed_texture_etc1":d=a.getextension("webgl_compressed_texture_etc1");break;default:d=a.getextension(c)}return null===d&&console.warn("three.webglrenderer: "+c+" extension not supported."),b[c]=d,d}}}function pf(){function i(){h.value!==b&&(h.value=b,h.needsupdate=c>0),a.numplanes=c,a.numintersection=0}function j(b,c,d,e){var i=null!==b?b.length:0,j=null;if(0!==i){if(j=h.value,e!==!0||null===j){var k=d+4*i,l=c.matrixworldinverse;g.getnormalmatrix(l),(null===j||j.length=0){var k=f[i];if(void 0!==k){var l=k.normalized,m=k.itemsize,n=kb.getattributeproperties(k),o=n.__webglbuffer,p=n.type,q=n.bytesperelement;if(k.isinterleavedbufferattribute){var r=k.data,s=r.stride,t=k.offset;r&&r.isinstancedinterleavedbuffer?(eb.enableattributeanddivisor(j,r.meshperattribute,e),void 0===c.maxinstancedcount&&(c.maxinstancedcount=r.meshperattribute*r.count)):eb.enableattribute(j),ab.bindbuffer(ab.array_buffer,o),ab.vertexattribpointer(j,m,p,l,s*q,(d*s+t)*q)}else k.isinstancedbufferattribute?(eb.enableattributeanddivisor(j,k.meshperattribute,e),void 0===c.maxinstancedcount&&(c.maxinstancedcount=k.meshperattribute*k.count)):eb.enableattribute(j),ab.bindbuffer(ab.array_buffer,o),ab.vertexattribpointer(j,m,p,l,0,d*m*q)}else if(void 0!==h){var u=h[i];if(void 0!==u)switch(u.length){case 2:ab.vertexattrib2fv(j,u);break;case 3:ab.vertexattrib3fv(j,u);break;case 4:ab.vertexattrib4fv(j,u);break;default:ab.vertexattrib1fv(j,u)}}}}eb.disableunusedattributes()}function hb(a,b){return math.abs(b[0])-math.abs(a[0])}function ib(a,b){return a.object.renderorder!==b.object.renderorder?a.object.renderorder-b.object.renderorder:a.material.program&&b.material.program&&a.material.program!==b.material.program?a.material.program.id-b.material.program.id:a.material.id!==b.material.id?a.material.id-b.material.id:a.z!==b.z?a.z-b.z:a.id-b.id}function jb(a,b){return a.object.renderorder!==b.object.renderorder?a.object.renderorder-b.object.renderorder:a.z!==b.z?b.z-a.z:a.id-b.id}function kb(a,b,c,d,e){var f,g;c.transparent?(f=r,g=++t):(f=m,g=++n);var h=f[g];void 0!==h?(h.id=a.id,h.object=a,h.geometry=b,h.material=c,h.z=ma.z,h.group=e):(h={id:a.id,object:a,geometry:b,material:c,z:ma.z,group:e},f.push(h))}function lb(a){var b=a.geometry;return null===b.boundingsphere&&b.computeboundingsphere(),ka.copy(b.boundingsphere).applymatrix4(a.matrixworld),nb(ka)}function mb(a){return ka.center.set(0,0,0),ka.radius=.7071067811865476,ka.applymatrix4(a.matrixworld),nb(ka)}function nb(a){if(!ga.intersectssphere(a))return!1;var b=ha.numplanes;if(0===b)return!0;var c=y.clippingplanes,d=a.center,e=-a.radius,f=0;do if(c[f].distancetopoint(d)=0&&a.numsupportedmorphtargets++}if(a.morphnormals){a.numsupportedmorphnormals=0;for(var k=0;k=0&&a.numsupportedmorphnormals++}var l=d.__webglshader.uniforms;(a.isshadermaterial||a.israwshadermaterial)&&a.clipping!==!0||(d.numclippingplanes=ha.numplanes,d.numintersection=ha.numintersection,l.clippingplanes=ha.uniform),d.fog=b,d.lightshash=$a.hash,a.lights&&(l.ambientlightcolor.value=$a.ambient,l.directionallights.value=$a.directional,l.spotlights.value=$a.spot,l.rectarealights.value=$a.rectarea,l.pointlights.value=$a.point,l.hemispherelights.value=$a.hemi,l.directionalshadowmap.value=$a.directionalshadowmap,l.directionalshadowmatrix.value=$a.directionalshadowmatrix,l.spotshadowmap.value=$a.spotshadowmap,l.spotshadowmatrix.value=$a.spotshadowmatrix,l.pointshadowmap.value=$a.pointshadowmap,l.pointshadowmatrix.value=$a.pointshadowmatrix);var m=d.program.getuniforms(),n=oc.seqwithvalue(m.seq,l);d.uniformslist=n}function rb(a){a.side===p?eb.disable(ab.cull_face):eb.enable(ab.cull_face),eb.setflipsided(a.side===o),a.transparent===!0?eb.setblending(a.blending,a.blendequation,a.blendsrc,a.blenddst,a.blendequationalpha,a.blendsrcalpha,a.blenddstalpha,a.premultipliedalpha):eb.setblending(v),eb.setdepthfunc(a.depthfunc),eb.setdepthtest(a.depthtest),eb.setdepthwrite(a.depthwrite),eb.setcolorwrite(a.colorwrite),eb.setpolygonoffset(a.polygonoffset,a.polygonoffsetfactor,a.polygonoffsetunits)}function sb(a,b,c,d){y=0;var e=fb.get(c);if(ia&&(ja||a!==u)){var f=a===u&&c.id===s;ha.setstate(c.clippingplanes,c.clipintersection,c.clipshadows,a,e,f)}c.needsupdate===!1&&(void 0===e.program?c.needsupdate=!0:c.fog&&e.fog!==b?c.needsupdate=!0:c.lights&&e.lightshash!==$a.hash?c.needsupdate=!0:void 0===e.numclippingplanes||e.numclippingplanes===ha.numplanes&&e.numintersection===ha.numintersection||(c.needsupdate=!0)),c.needsupdate&&(qb(c,b,d),c.needsupdate=!1);var g=!1,h=!1,i=!1,j=e.program,k=j.getuniforms(),l=e.__webglshader.uniforms;if(j.id!==z&&(ab.useprogram(j.program),z=j.id,g=!0,h=!0,i=!0),c.id!==s&&(s=c.id,h=!0),g||a!==u){if(k.set(ab,a,"projectionmatrix"),db.logarithmicdepthbuffer&&k.setvalue(ab,"logdepthbuffc",2/(math.log(a.far+1)/math.ln2)),a!==u&&(u=a,h=!0,i=!0),c.isshadermaterial||c.ismeshphongmaterial||c.ismeshstandardmaterial||c.envmap){var m=k.map.cameraposition;void 0!==m&&m.setvalue(ab,ma.setfrommatrixposition(a.matrixworld))}(c.ismeshphongmaterial||c.ismeshlambertmaterial||c.ismeshbasicmaterial||c.ismeshstandardmaterial||c.isshadermaterial||c.skinning)&&k.setvalue(ab,"viewmatrix",a.matrixworldinverse),k.set(ab,y,"tonemappingexposure"),k.set(ab,y,"tonemappingwhitepoint")}if(c.skinning){k.setoptional(ab,d,"bindmatrix"),k.setoptional(ab,d,"bindmatrixinverse");var n=d.skeleton;n&&(db.floatvertextextures&&n.usevertextexture?(k.set(ab,n,"bonetexture"),k.set(ab,n,"bonetexturewidth"),k.set(ab,n,"bonetextureheight")):k.setoptional(ab,n,"bonematrices"))}return h&&(c.lights&&cc(l,i),b&&c.fog&&xb(l,b),(c.ismeshbasicmaterial||c.ismeshlambertmaterial||c.ismeshphongmaterial||c.ismeshstandardmaterial||c.ismeshnormalmaterial||c.ismeshdepthmaterial)&&tb(l,c),c.islinebasicmaterial?ub(l,c):c.islinedashedmaterial?(ub(l,c),vb(l,c)):c.ispointsmaterial?wb(l,c):c.ismeshlambertmaterial?yb(l,c):c.ismeshtoonmaterial?$b(l,c):c.ismeshphongmaterial?zb(l,c):c.ismeshphysicalmaterial?ac(l,c):c.ismeshstandardmaterial?_b(l,c):c.ismeshdepthmaterial?c.displacementmap&&(l.displacementmap.value=c.displacementmap,l.displacementscale.value=c.displacementscale,l.displacementbias.value=c.displacementbias):c.ismeshnormalmaterial&&bc(l,c),void 0!==l.ltcmat&&(l.ltcmat.value=three.uniformslib.ltc_mat_texture),void 0!==l.ltcmag&&(l.ltcmag.value=three.uniformslib.ltc_mag_texture),oc.upload(ab,e.uniformslist,l,y)),k.set(ab,d,"modelviewmatrix"),k.set(ab,d,"normalmatrix"),k.setvalue(ab,"modelmatrix",d.matrixworld),j}function tb(a,b){a.opacity.value=b.opacity,a.diffuse.value=b.color,b.emissive&&a.emissive.value.copy(b.emissive).multiplyscalar(b.emissiveintensity),a.map.value=b.map,a.specularmap.value=b.specularmap,a.alphamap.value=b.alphamap,b.lightmap&&(a.lightmap.value=b.lightmap,a.lightmapintensity.value=b.lightmapintensity),b.aomap&&(a.aomap.value=b.aomap,a.aomapintensity.value=b.aomapintensity);var c;if(b.map?c=b.map:b.specularmap?c=b.specularmap:b.displacementmap?c=b.displacementmap:b.normalmap?c=b.normalmap:b.bumpmap?c=b.bumpmap:b.roughnessmap?c=b.roughnessmap:b.metalnessmap?c=b.metalnessmap:b.alphamap?c=b.alphamap:b.emissivemap&&(c=b.emissivemap),void 0!==c){c.iswebglrendertarget&&(c=c.texture);var d=c.offset,e=c.repeat;a.offsetrepeat.value.set(d.x,d.y,e.x,e.y)}a.envmap.value=b.envmap,a.flipenvmap.value=b.envmap&&b.envmap.iscubetexture?-1:1,a.reflectivity.value=b.reflectivity,a.refractionratio.value=b.refractionratio}function ub(a,b){a.diffuse.value=b.color,a.opacity.value=b.opacity}function vb(a,b){a.dashsize.value=b.dashsize,a.totalsize.value=b.dashsize+b.gapsize,a.scale.value=b.scale}function wb(a,b){if(a.diffuse.value=b.color,a.opacity.value=b.opacity,a.size.value=b.size*ca,a.scale.value=.5*aa,a.map.value=b.map,null!==b.map){var c=b.map.offset,d=b.map.repeat;a.offsetrepeat.value.set(c.x,c.y,d.x,d.y)}}function xb(a,b){a.fogcolor.value=b.color,b.isfog?(a.fognear.value=b.near,a.fogfar.value=b.far):b.isfogexp2&&(a.fogdensity.value=b.density)}function yb(a,b){b.emissivemap&&(a.emissivemap.value=b.emissivemap)}function zb(a,b){a.specular.value=b.specular,a.shininess.value=math.max(b.shininess,1e-4),b.emissivemap&&(a.emissivemap.value=b.emissivemap),b.bumpmap&&(a.bumpmap.value=b.bumpmap,a.bumpscale.value=b.bumpscale),b.normalmap&&(a.normalmap.value=b.normalmap,a.normalscale.value.copy(b.normalscale)),b.displacementmap&&(a.displacementmap.value=b.displacementmap,a.displacementscale.value=b.displacementscale,a.displacementbias.value=b.displacementbias)}function $b(a,b){zb(a,b),b.gradientmap&&(a.gradientmap.value=b.gradientmap)}function _b(a,b){a.roughness.value=b.roughness,a.metalness.value=b.metalness,b.roughnessmap&&(a.roughnessmap.value=b.roughnessmap),b.metalnessmap&&(a.metalnessmap.value=b.metalnessmap),b.emissivemap&&(a.emissivemap.value=b.emissivemap),b.bumpmap&&(a.bumpmap.value=b.bumpmap,a.bumpscale.value=b.bumpscale),b.normalmap&&(a.normalmap.value=b.normalmap,a.normalscale.value.copy(b.normalscale)),b.displacementmap&&(a.displacementmap.value=b.displacementmap,a.displacementscale.value=b.displacementscale,a.displacementbias.value=b.displacementbias),b.envmap&&(a.envmapintensity.value=b.envmapintensity)}function ac(a,b){a.clearcoat.value=b.clearcoat,a.clearcoatroughness.value=b.clearcoatroughness,_b(a,b)}function bc(a,b){b.bumpmap&&(a.bumpmap.value=b.bumpmap,a.bumpscale.value=b.bumpscale),b.normalmap&&(a.normalmap.value=b.normalmap,a.normalscale.value.copy(b.normalscale)),b.displacementmap&&(a.displacementmap.value=b.displacementmap,a.displacementscale.value=b.displacementscale,a.displacementbias.value=b.displacementbias)}function cc(a,b){a.ambientlightcolor.needsupdate=b,a.directionallights.needsupdate=b,a.pointlights.needsupdate=b,a.spotlights.needsupdate=b,a.rectarealights.needsupdate=b,a.hemispherelights.needsupdate=b}function dc(a){for(var b=0,c=0,d=a.length;c=db.maxtextures&&console.warn("webglrenderer: trying to use "+a+" texture units while this gpu supports only "+db.maxtextures),y+=1,a}function gc(a){var b;if(a===na)return ab.repeat;if(a===oa)return ab.clamp_to_edge;if(a===pa)return ab.mirrored_repeat;if(a===qa)return ab.nearest;if(a===ra)return ab.nearest_mipmap_nearest;if(a===sa)return ab.nearest_mipmap_linear;if(a===ta)return ab.linear;if(a===ua)return ab.linear_mipmap_nearest;if(a===va)return ab.linear_mipmap_linear;if(a===wa)return ab.unsigned_byte;if(a===ea)return ab.unsigned_short_4_4_4_4;if(a===fa)return ab.unsigned_short_5_5_5_1;if(a===ga)return ab.unsigned_short_5_6_5;if(a===xa)return ab.byte;if(a===ya)return ab.short;if(a===za)return ab.unsigned_short;if(a===aa)return ab.int;if(a===ba)return ab.unsigned_int;if(a===ca)return ab.float;if(a===da&&(b=cb.get("oes_texture_half_float"),null!==b))return b.half_float_oes;if(a===ia)return ab.alpha;if(a===ja)return ab.rgb;if(a===ka)return ab.rgba;if(a===la)return ab.luminance;if(a===ma)return ab.luminance_alpha;if(a===oa)return ab.depth_component;if(a===pa)return ab.depth_stencil;if(a===b)return ab.func_add;if(a===c)return ab.func_subtract;if(a===d)return ab.func_reverse_subtract;if(a===g)return ab.zero;if(a===h)return ab.one;if(a===i)return ab.src_color;if(a===j)return ab.one_minus_src_color;if(a===k)return ab.src_alpha;if(a===l)return ab.one_minus_src_alpha;if(a===m)return ab.dst_alpha;if(a===n)return ab.one_minus_dst_alpha;if(a===o)return ab.dst_color;if(a===p)return ab.one_minus_dst_color;if(a===q)return ab.src_alpha_saturate;if((a===qa||a===ra||a===sa||a===ta)&&(b=cb.get("webgl_compressed_texture_s3tc"),null!==b)){if(a===qa)return b.compressed_rgb_s3tc_dxt1_ext;if(a===ra)return b.compressed_rgba_s3tc_dxt1_ext;if(a===sa)return b.compressed_rgba_s3tc_dxt3_ext;if(a===ta)return b.compressed_rgba_s3tc_dxt5_ext}if((a===ua||a===va||a===wa||a===xa)&&(b=cb.get("webgl_compressed_texture_pvrtc"),null!==b)){if(a===ua)return b.compressed_rgb_pvrtc_4bppv1_img;if(a===va)return b.compressed_rgb_pvrtc_2bppv1_img;if(a===wa)return b.compressed_rgba_pvrtc_4bppv1_img;if(a===xa)return b.compressed_rgba_pvrtc_2bppv1_img}if(a===ya&&(b=cb.get("webgl_compressed_texture_etc1"),null!==b))return b.compressed_rgb_etc1_webgl;if((a===e||a===f)&&(b=cb.get("ext_blend_minmax"),null!==b)){if(a===e)return b.min_ext;if(a===f)return b.max_ext}return a===ha&&(b=cb.get("webgl_depth_texture"),null!==b)?b.unsigned_int_24_8_webgl:0}console.log("three.webglrenderer",c),a=a||{};var b=void 0!==a.canvas?a.canvas:document.createelementns("http://www.w3.org/1999/xhtml","canvas"),d=void 0!==a.context?a.context:null,e=void 0!==a.alpha&&a.alpha,f=void 0===a.depth||a.depth,g=void 0===a.stencil||a.stencil,h=void 0!==a.antialias&&a.antialias,j=void 0===a.premultipliedalpha||a.premultipliedalpha,k=void 0!==a.preservedrawingbuffer&&a.preservedrawingbuffer,l=[],m=[],n=-1,r=[],t=-1,u=new float32array(8),w=[],x=[];this.domelement=b,this.context=null,this.autoclear=!0,this.autoclearcolor=!0,this.autocleardepth=!0,this.autoclearstencil=!0,this.sortobjects=!0,this.clippingplanes=[],this.localclippingenabled=!1,this.gammafactor=2,this.gammainput=!1,this.gammaoutput=!1,this.physicallycorrectlights=!1,this.tonemapping=ba,this.tonemappingexposure=1,this.tonemappingwhitepoint=1,this.maxmorphtargets=8,this.maxmorphnormals=4;var y=this,z=null,a=null,r=null,s=-1,t="",u=null,v=new xb,w=null,x=new xb,y=0,z=new re(0),$=0,_=b.width,aa=b.height,ca=1,da=new xb(0,0,_,aa),ea=!1,fa=new xb(0,0,_,aa),ga=new he,ha=new pf,ia=!1,ja=!1,ka=new ee,la=new cb,ma=new bb,na=new cb,za=new cb,$a={hash:"",ambient:[0,0,0],directional:[],directionalshadowmap:[],directionalshadowmatrix:[],spot:[],spotshadowmap:[],spotshadowmatrix:[],rectarea:[],point:[],pointshadowmap:[],pointshadowmatrix:[],hemi:[],shadows:[]},_a={calls:0,vertices:0,faces:0,points:0};this.info={render:_a,memory:{geometries:0,textures:0},programs:null};var ab;try{var bb={alpha:e,depth:f,stencil:g,antialias:h,premultipliedalpha:j,preservedrawingbuffer:k};if(ab=d||b.getcontext("webgl",bb)||b.getcontext("experimental-webgl",bb),null===ab)throw null!==b.getcontext("webgl")?"error creating webgl context with your selected attributes.":"error creating webgl context.";void 0===ab.getshaderprecisionformat&&(ab.getshaderprecisionformat=function(){return{rangemin:1,rangemax:1,precision:1}}),b.addeventlistener("webglcontextlost",ab,!1)}catch(a){console.error("three.webglrenderer: "+a)}var cb=new of(ab);cb.get("webgl_depth_texture"),cb.get("oes_texture_float"),cb.get("oes_texture_float_linear"),cb.get("oes_texture_half_float"),cb.get("oes_texture_half_float_linear"),cb.get("oes_standard_derivatives"),cb.get("angle_instanced_arrays"),cb.get("oes_element_index_uint")&&(ff.maxindex=4294967296);var db=new nf(ab,cb,a),eb=new mf(ab,cb,gc),fb=new lf,jb=new kf(ab,cb,eb,fb,db,gc,this.info),kb=new jf(ab,fb,this.info),lb=new hf(this,db),mb=new rf;this.info.programs=lb.programs;var pb,qb,rb,sb,nb=new qf(ab,cb,_a),ob=new pf(ab,cb,_a);ub(),this.context=ab,this.capabilities=db,this.extensions=cb,this.properties=fb,this.state=eb;var wb=new ie(this,$a,kb,db);this.shadowmap=wb;var yb=new ye(this,w),zb=new xe(this,x);this.getcontext=function(){return ab},this.getcontextattributes=function(){return ab.getcontextattributes()},this.forcecontextloss=function(){cb.get("webgl_lose_context").losecontext()},this.getmaxanisotropy=function(){return db.getmaxanisotropy()},this.getprecision=function(){return db.precision},this.getpixelratio=function(){return ca},this.setpixelratio=function(a){void 0!==a&&(ca=a,this.setsize(fa.z,fa.w,!1))},this.getsize=function(){return{width:_,height:aa}},this.setsize=function(a,c,d){_=a,aa=c,b.width=a*ca,b.height=c*ca,d!==!1&&(b.style.width=a+"px",b.style.height=c+"px"),this.setviewport(0,0,a,c)},this.setviewport=function(a,b,c,d){eb.viewport(fa.set(a,b,c,d))},this.setscissor=function(a,b,c,d){eb.scissor(da.set(a,b,c,d))},this.setscissortest=function(a){eb.setscissortest(ea=a)},this.getclearcolor=function(){return z},this.setclearcolor=function(a,b){z.set(a),$=void 0!==b?b:1,eb.buffers.color.setclear(z.r,z.g,z.b,$,j)},this.getclearalpha=function(){return $},this.setclearalpha=function(a){$=a,eb.buffers.color.setclear(z.r,z.g,z.b,$,j)},this.clear=function(a,b,c){var d=0;(void 0===a||a)&&(d|=ab.color_buffer_bit),(void 0===b||b)&&(d|=ab.depth_buffer_bit),(void 0===c||c)&&(d|=ab.stencil_buffer_bit),ab.clear(d)},this.clearcolor=function(){this.clear(!0,!1,!1)},this.cleardepth=function(){this.clear(!1,!0,!1)},this.clearstencil=function(){this.clear(!1,!1,!0)},this.cleartarget=function(a,b,c,d){this.setrendertarget(a),this.clear(b,c,d)},this.resetglstate=vb,this.dispose=function(){r=[],t=-1,m=[],n=-1,b.removeeventlistener("webglcontextlost",ab,!1)},this.renderbufferimmediate=function(a,b,c){eb.initattributes();var d=fb.get(a);a.haspositions&&!d.position&&(d.position=ab.createbuffer()),a.hasnormals&&!d.normal&&(d.normal=ab.createbuffer()),a.hasuvs&&!d.uv&&(d.uv=ab.createbuffer()),a.hascolors&&!d.color&&(d.color=ab.createbuffer());var e=b.getattributes();if(a.haspositions&&(ab.bindbuffer(ab.array_buffer,d.position),ab.bufferdata(ab.array_buffer,a.positionarray,ab.dynamic_draw),eb.enableattribute(e.position),ab.vertexattribpointer(e.position,3,ab.float,!1,0,0)),a.hasnormals){if(ab.bindbuffer(ab.array_buffer,d.normal),!c.ismeshphongmaterial&&!c.ismeshstandardmaterial&&!c.ismeshnormalmaterial&&c.shading===q)for(var f=0,g=3*a.count;f8&&(k.length=8);for(var o=c.morphattributes,l=0,m=k.length;l0&&t.renderinstances(c,a,c):t.render(a,c)}},this.render=function(a,b,c,d){if(void 0!==b&&b.iscamera!==!0)return void console.error("three.webglrenderer.render: camera is not an instance of three.camera.");t="",s=-1,u=null,a.autoupdate===!0&&a.updatematrixworld(),null===b.parent&&b.updatematrixworld(),b.matrixworldinverse.getinverse(b.matrixworld),la.multiplymatrices(b.projectionmatrix,b.matrixworldinverse),ga.setfrommatrix(la),l.length=0,n=-1,t=-1,w.length=0,x.length=0,ja=this.localclippingenabled,ia=ha.init(this.clippingplanes,ja,b),ob(a,b),m.length=n+1,r.length=t+1,y.sortobjects===!0&&(m.sort(ib),r.sort(jb)),ia&&ha.beginshadows(),dc(l),wb.render(a,b),ec(l,b),ia&&ha.endshadows(),_a.calls=0,_a.vertices=0,_a.faces=0,_a.points=0,void 0===c&&(c=null),this.setrendertarget(c);var e=a.background;if(null===e?eb.buffers.color.setclear(z.r,z.g,z.b,$,j):e&&e.iscolor&&(eb.buffers.color.setclear(e.r,e.g,e.b,1,j),d=!0),(this.autoclear||d)&&this.clear(this.autoclearcolor,this.autocleardepth,this.autoclearstencil), e&&e.iscubetexture?(void 0===rb&&(rb=new nf,sb=new gf(new jf(5,5,5),new be({uniforms:ve.cube.uniforms,vertexshader:ve.cube.vertexshader,fragmentshader:ve.cube.fragmentshader,side:o,depthtest:!1,depthwrite:!1,fog:!1}))),rb.projectionmatrix.copy(b.projectionmatrix),rb.matrixworld.extractrotation(b.matrixworld),rb.matrixworldinverse.getinverse(rb.matrixworld),sb.material.uniforms.tcube.value=e,sb.modelviewmatrix.multiplymatrices(rb.matrixworldinverse,sb.matrixworld),kb.update(sb),y.renderbufferdirect(rb,null,sb.geometry,sb.material,sb,null)):e&&e.istexture&&(void 0===pb&&(pb=new of(-1,1,1,-1,0,1),qb=new gf(new lf(2,2),new re({depthtest:!1,depthwrite:!1,fog:!1}))),qb.material.map=e,kb.update(qb),y.renderbufferdirect(pb,null,qb.geometry,qb.material,qb,null)),a.overridematerial){var f=a.overridematerial;pb(m,a,b,f),pb(r,a,b,f)}else eb.setblending(v),pb(m,a,b),pb(r,a,b);yb.render(a,b),zb.render(a,b,x),c&&jb.updaterendertargetmipmap(c),eb.setdepthtest(!0),eb.setdepthwrite(!0),eb.setcolorwrite(!0)},this.setfaceculling=function(a,b){eb.setcullface(a),eb.setflipsided(b===i)},this.alloctextureunit=fc,this.settexture2d=function(){var a=!1;return function(c,d){c&&c.iswebglrendertarget&&(a||(console.warn("three.webglrenderer.settexture2d: don't use render targets as textures. use their .texture property instead."),a=!0),c=c.texture),jb.settexture2d(c,d)}}(),this.settexture=function(){var a=!1;return function(c,d){a||(console.warn("three.webglrenderer: .settexture is deprecated, use settexture2d instead."),a=!0),jb.settexture2d(c,d)}}(),this.settexturecube=function(){var a=!1;return function(c,d){c&&c.iswebglrendertargetcube&&(a||(console.warn("three.webglrenderer.settexturecube: don't use cube render targets as textures. use their .texture property instead."),a=!0),c=c.texture),c&&c.iscubetexture||array.isarray(c.image)&&6===c.image.length?jb.settexturecube(c,d):jb.settexturecubedynamic(c,d)}}(),this.getcurrentrendertarget=function(){return a},this.setrendertarget=function(a){a=a,a&&void 0===fb.get(a).__webglframebuffer&&jb.setuprendertarget(a);var c,b=a&&a.iswebglrendertargetcube;if(a){var d=fb.get(a);c=b?d.__webglframebuffer[a.activecubeface]:d.__webglframebuffer,v.copy(a.scissor),w=a.scissortest,x.copy(a.viewport)}else c=null,v.copy(da).multiplyscalar(ca),w=ea,x.copy(fa).multiplyscalar(ca);if(r!==c&&(ab.bindframebuffer(ab.framebuffer,c),r=c),eb.scissor(v),eb.setscissortest(w),eb.viewport(x),b){var e=fb.get(a.texture);ab.framebuffertexture2d(ab.framebuffer,ab.color_attachment0,ab.texture_cube_map_positive_x+a.activecubeface,e.__webgltexture,a.activemipmaplevel)}},this.readrendertargetpixels=function(a,b,c,d,e,f){if((a&&a.iswebglrendertarget)===!1)return void console.error("three.webglrenderer.readrendertargetpixels: rendertarget is not three.webglrendertarget.");var g=fb.get(a).__webglframebuffer;if(g){var h=!1;g!==r&&(ab.bindframebuffer(ab.framebuffer,g),h=!0);try{var i=a.texture,j=i.format,k=i.type;if(j!==ka&&gc(j)!==ab.getparameter(ab.implementation_color_read_format))return void console.error("three.webglrenderer.readrendertargetpixels: rendertarget is not in rgba or implementation defined format.");if(!(k===wa||gc(k)===ab.getparameter(ab.implementation_color_read_type)||k===ca&&(cb.get("oes_texture_float")||cb.get("webgl_color_buffer_float"))||k===da&&cb.get("ext_color_buffer_half_float")))return void console.error("three.webglrenderer.readrendertargetpixels: rendertarget is not in unsignedbytetype or implementation defined type.");ab.checkframebufferstatus(ab.framebuffer)===ab.framebuffer_complete?b>=0&&b<=a.width-d&&c>=0&&c<=a.height-e&&ab.readpixels(b,c,d,e,gc(j),gc(k),f):console.error("three.webglrenderer.readrendertargetpixels: readpixels from rendertarget failed. framebuffer not complete.")}finally{h&&ab.bindframebuffer(ab.framebuffer,r)}}}}function rf(a,b){this.name="",this.color=new re(a),this.density=void 0!==b?b:25e-5}function sf(a,b,c){this.name="",this.color=new re(a),this.near=void 0!==b?b:1,this.far=void 0!==c?c:1e3}function tf(){ne.call(this),this.type="scene",this.background=null,this.fog=null,this.overridematerial=null,this.autoupdate=!0}function uf(a,b,c,d,e){ne.call(this),this.lensflares=[],this.positionscreen=new bb,this.customupdatecallback=void 0,void 0!==a&&this.add(a,b,c,d,e)}function vf(a){ae.call(this),this.type="spritematerial",this.color=new re(16777215),this.map=null,this.rotation=0,this.fog=!1,this.lights=!1,this.setvalues(a)}function wf(a){ne.call(this),this.type="sprite",this.material=void 0!==a?a:new vf}function xf(){ne.call(this),this.type="lod",object.defineproperties(this,{levels:{enumerable:!0,value:[]}})}function yf(a,b,c){if(this.usevertextexture=void 0===c||c,this.identitymatrix=new cb,a=a||[],this.bones=a.slice(0),this.usevertextexture){var d=math.sqrt(4*this.bones.length);d=tb.nextpoweroftwo(math.ceil(d)),d=math.max(d,4),this.bonetexturewidth=d,this.bonetextureheight=d,this.bonematrices=new float32array(this.bonetexturewidth*this.bonetextureheight*4),this.bonetexture=new te(this.bonematrices,this.bonetexturewidth,this.bonetextureheight,ka,ca)}else this.bonematrices=new float32array(16*this.bones.length);if(void 0===b)this.calculateinverses();else if(this.bones.length===b.length)this.boneinverses=b.slice(0);else{console.warn("three.skeleton boninverses is the wrong length."),this.boneinverses=[];for(var e=0,f=this.bones.length;e=a.have_current_data&&(j.needsupdate=!0)}wb.call(this,a,b,c,d,e,f,g,h,i),this.generatemipmaps=!1;var j=this;k()}function gg(a,b,c,d,e,f,g,h,i,j,k,l){wb.call(this,null,f,g,h,i,j,d,e,k,l),this.image={width:b,height:c},this.mipmaps=a,this.flipy=!1,this.generatemipmaps=!1}function hg(a,b,c,d,e,f,g,h,i){wb.call(this,a,b,c,d,e,f,g,h,i),this.needsupdate=!0}function ig(a,b,c,d,e,f,g,h,i,j){if(j=void 0!==j?j:oa,j!==oa&&j!==pa)throw new error("depthtexture format must be either three.depthformat or three.depthstencilformat");void 0===c&&j===oa&&(c=za),void 0===c&&j===pa&&(c=ha),wb.call(this,null,d,e,f,g,h,j,c,i),this.image={width:a,height:b},this.magfilter=void 0!==g?g:qa,this.minfilter=void 0!==h?h:qa,this.flipy=!1,this.generatemipmaps=!1}function jg(a){function x(a,b){return a-b}ff.call(this),this.type="wireframegeometry";var c,d,e,f,g,j,k,m,b=[],h=[0,0],i={},l=["a","b","c"];if(a&&a.isgeometry){var n=a.faces;for(c=0,e=n.length;c.9&&g<.1&&(b<.2&&(f[a+0]+=1),c<.2&&(f[a+2]+=1),d<.2&&(f[a+4]+=1))}}function l(a){e.push(a.x,a.y,a.z)}function m(b,c){var d=3*b;c.x=a[d+0],c.y=a[d+1],c.z=a[d+2]}function n(){for(var a=new bb,b=new bb,c=new bb,d=new bb,g=new ub,h=new ub,i=new ub,j=0,k=0;j0)&&o.push(v,w,y),(j!==c-1||h0&&t(!0),b>0&&t(!1)),this.setindex(j),this.addattribute("position",new $e(k,3)),this.addattribute("normal",new $e(l,3)),this.addattribute("uv",new $e(m,2))}function qg(a,b,c,d,e,f,g){og.call(this,0,a,b,c,d,e,f,g),this.type="conegeometry",this.parameters={radius:a,height:b,radialsegments:c,heightsegments:d,openended:e,thetastart:f,thetalength:g}}function rg(a,b,c,d,e,f,g){pg.call(this,0,a,b,c,d,e,f,g),this.type="conebuffergeometry",this.parameters={radius:a,height:b,radialsegments:c,heightsegments:d,openended:e,thetastart:f,thetalength:g}}function sg(a,b,c,d){ef.call(this),this.type="circlegeometry",this.parameters={radius:a,segments:b,thetastart:c,thetalength:d},this.frombuffergeometry(new tg(a,b,c,d))}function tg(a,b,c,d){ff.call(this),this.type="circlebuffergeometry",this.parameters={radius:a,segments:b,thetastart:c,thetalength:d},a=a||50,b=void 0!==b?math.max(3,b):8,c=void 0!==c?c:0,d=void 0!==d?d:2*math.pi;var i,j,e=[],f=[],g=[],h=[],k=new bb,l=new ub;for(f.push(0,0,0),g.push(0,0,1),h.push(.5,.5),j=0,i=3;j<=b;j++,i+=3){var m=c+j/b*d;k.x=a*math.cos(m),k.y=a*math.sin(m),f.push(k.x,k.y,k.z),g.push(0,0,1),l.x=(f[i]/a+1)/2,l.y=(f[i+1]/a+1)/2,h.push(l.x,l.y)}for(i=1;i<=b;i++)e.push(i,i+1,0);this.setindex(e),this.addattribute("position",new $e(f,3)),this.addattribute("normal",new $e(g,3)),this.addattribute("uv",new $e(h,2))}function vg(){be.call(this,{uniforms:pc.merge([ue.lights,{opacity:{value:1}}]),vertexshader:qe.shadow_vert,fragmentshader:qe.shadow_frag}),this.lights=!0,this.transparent=!0,object.defineproperties(this,{opacity:{enumerable:!0,get:function(){return this.uniforms.opacity.value},set:function(a){this.uniforms.opacity.value=a}}})}function wg(a){be.call(this,a),this.type="rawshadermaterial"}function xg(a){this.uuid=tb.generateuuid(),this.type="multimaterial",this.materials=array.isarray(a)?a:[],this.visible=!0}function yg(a){ae.call(this),this.defines={standard:""},this.type="meshstandardmaterial",this.color=new re(16777215),this.roughness=.5,this.metalness=.5,this.map=null,this.lightmap=null,this.lightmapintensity=1,this.aomap=null,this.aomapintensity=1,this.emissive=new re(0),this.emissiveintensity=1,this.emissivemap=null,this.bumpmap=null,this.bumpscale=1,this.normalmap=null,this.normalscale=new ub(1,1),this.displacementmap=null,this.displacementscale=1,this.displacementbias=0,this.roughnessmap=null,this.metalnessmap=null,this.alphamap=null,this.envmap=null,this.envmapintensity=1,this.refractionratio=.98,this.wireframe=!1,this.wireframelinewidth=1,this.wireframelinecap="round",this.wireframelinejoin="round",this.skinning=!1,this.morphtargets=!1,this.morphnormals=!1,this.setvalues(a)}function zg(a){yg.call(this),this.defines={physical:""},this.type="meshphysicalmaterial",this.reflectivity=.5,this.clearcoat=0,this.clearcoatroughness=0,this.setvalues(a)}function $g(a){ae.call(this),this.type="meshphongmaterial",this.color=new re(16777215),this.specular=new re(1118481),this.shininess=30,this.map=null,this.lightmap=null,this.lightmapintensity=1,this.aomap=null,this.aomapintensity=1,this.emissive=new re(0),this.emissiveintensity=1,this.emissivemap=null,this.bumpmap=null,this.bumpscale=1,this.normalmap=null,this.normalscale=new ub(1,1),this.displacementmap=null,this.displacementscale=1,this.displacementbias=0,this.specularmap=null,this.alphamap=null,this.envmap=null,this.combine=z,this.reflectivity=1,this.refractionratio=.98,this.wireframe=!1,this.wireframelinewidth=1,this.wireframelinecap="round",this.wireframelinejoin="round",this.skinning=!1,this.morphtargets=!1,this.morphnormals=!1,this.setvalues(a)}function _g(a){$g.call(this),this.defines={toon:""},this.type="meshtoonmaterial",this.gradientmap=null,this.setvalues(a)}function ah(a){ae.call(this,a),this.type="meshnormalmaterial",this.bumpmap=null,this.bumpscale=1,this.normalmap=null,this.normalscale=new ub(1,1),this.displacementmap=null,this.displacementscale=1,this.displacementbias=0,this.wireframe=!1,this.wireframelinewidth=1,this.fog=!1,this.lights=!1,this.skinning=!1,this.morphtargets=!1,this.morphnormals=!1,this.setvalues(a)}function bh(a){ae.call(this),this.type="meshlambertmaterial",this.color=new re(16777215),this.map=null,this.lightmap=null,this.lightmapintensity=1,this.aomap=null,this.aomapintensity=1,this.emissive=new re(0),this.emissiveintensity=1,this.emissivemap=null,this.specularmap=null,this.alphamap=null,this.envmap=null,this.combine=z,this.reflectivity=1,this.refractionratio=.98,this.wireframe=!1,this.wireframelinewidth=1,this.wireframelinecap="round",this.wireframelinejoin="round",this.skinning=!1,this.morphtargets=!1,this.morphnormals=!1,this.setvalues(a)}function ch(a){ae.call(this),this.type="linedashedmaterial",this.color=new re(16777215),this.linewidth=1,this.scale=1,this.dashsize=3,this.gapsize=1,this.lights=!1,this.setvalues(a)}function fh(a,b,c){var d=this,e=!1,f=0,g=0;this.onstart=void 0,this.onload=a,this.onprogress=b,this.onerror=c,this.itemstart=function(a){g++,e===!1&&void 0!==d.onstart&&d.onstart(a,f,g),e=!0},this.itemend=function(a){f++,void 0!==d.onprogress&&d.onprogress(a,f,g),f===g&&(e=!1,void 0!==d.onload&&d.onload())},this.itemerror=function(a){void 0!==d.onerror&&d.onerror(a)}}function hh(a){this.manager=void 0!==a?a:gh}function ih(a){this.manager=void 0!==a?a:gh,this._parser=null}function jh(a){this.manager=void 0!==a?a:gh,this._parser=null}function kh(a){this.manager=void 0!==a?a:gh}function lh(a){this.manager=void 0!==a?a:gh}function mh(a){this.manager=void 0!==a?a:gh}function nh(a,b){ne.call(this),this.type="light",this.color=new re(a),this.intensity=void 0!==b?b:1,this.receiveshadow=void 0}function oh(a,b,c){nh.call(this,a,c),this.type="hemispherelight",this.castshadow=void 0,this.position.copy(ne.defaultup),this.updatematrix(),this.groundcolor=new re(b)}function ph(a){this.camera=a,this.bias=0,this.radius=1,this.mapsize=new ub(512,512),this.map=null,this.matrix=new cb}function qh(){ph.call(this,new nf(50,1,.5,500))}function rh(a,b,c,d,e,f){nh.call(this,a,b),this.type="spotlight",this.position.copy(ne.defaultup),this.updatematrix(),this.target=new ne,object.defineproperty(this,"power",{get:function(){return this.intensity*math.pi},set:function(a){this.intensity=a/math.pi}}),this.distance=void 0!==c?c:0,this.angle=void 0!==d?d:math.pi/3,this.penumbra=void 0!==e?e:0,this.decay=void 0!==f?f:1,this.shadow=new qh}function sh(a,b,c,d){nh.call(this,a,b),this.type="pointlight",object.defineproperty(this,"power",{get:function(){return 4*this.intensity*math.pi},set:function(a){this.intensity=a/(4*math.pi)}}),this.distance=void 0!==c?c:0,this.decay=void 0!==d?d:1,this.shadow=new ph(new nf(90,1,.5,500))}function th(){ph.call(this,new of(-5,5,5,-5,.5,500))}function uh(a,b){nh.call(this,a,b),this.type="directionallight",this.position.copy(ne.defaultup),this.updatematrix(),this.target=new ne,this.shadow=new th}function vh(a,b){nh.call(this,a,b),this.type="ambientlight",this.castshadow=void 0}function xh(a,b,c,d){this.parameterpositions=a,this._cachedindex=0,this.resultbuffer=void 0!==d?d:new b.constructor(c),this.samplevalues=b,this.valuesize=c}function yh(a,b,c,d){xh.call(this,a,b,c,d),this._weightprev=-0,this._offsetprev=-0,this._weightnext=-0,this._offsetnext=-0; }function zh(a,b,c,d){xh.call(this,a,b,c,d)}function ah(a,b,c,d){xh.call(this,a,b,c,d)}function ch(a,b,c,d){if(void 0===a)throw new error("track name is undefined");if(void 0===b||0===b.length)throw new error("no keyframes in track named "+a);this.name=a,this.times=wh.convertarray(b,this.timebuffertype),this.values=wh.convertarray(c,this.valuebuffertype),this.setinterpolation(d||this.defaultinterpolation),this.validate(),this.optimize()}function dh(a,b,c,d){ch.call(this,a,b,c,d)}function eh(a,b,c,d){xh.call(this,a,b,c,d)}function fh(a,b,c,d){ch.call(this,a,b,c,d)}function gh(a,b,c,d){ch.call(this,a,b,c,d)}function hh(a,b,c,d){ch.call(this,a,b,c,d)}function ih(a,b,c){ch.call(this,a,b,c)}function jh(a,b,c,d){ch.call(this,a,b,c,d)}function kh(a,b,c,d){ch.apply(this,arguments)}function lh(a,b,c){this.name=a,this.tracks=c,this.duration=void 0!==b?b:-1,this.uuid=tb.generateuuid(),this.duration<0&&this.resetduration(),this.optimize()}function mh(a){this.manager=void 0!==a?a:gh,this.textures={}}function nh(a){this.manager=void 0!==a?a:gh}function oh(){this.onloadstart=function(){},this.onloadprogress=function(){},this.onloadcomplete=function(){}}function ph(a){"boolean"==typeof a&&(console.warn("three.jsonloader: showstatus parameter has been removed from constructor."),a=void 0),this.manager=void 0!==a?a:gh,this.withcredentials=!1}function qh(a){this.manager=void 0!==a?a:gh,this.texturepath=""}function rh(a,b,c,d,e){var f=.5*(d-b),g=.5*(e-c),h=a*a,i=a*h;return(2*c-2*d+f+g)*i+(-3*c+3*d-2*f-g)*h+f*a+c}function sh(a,b){var c=1-a;return c*c*b}function th(a,b){return 2*(1-a)*a*b}function uh(a,b){return a*a*b}function vh(a,b,c,d){return sh(a,b)+th(a,c)+uh(a,d)}function wh(a,b){var c=1-a;return c*c*c*b}function xh(a,b){var c=1-a;return 3*c*c*a*b}function yh(a,b){return 3*(1-a)*a*a*b}function zh(a,b){return a*a*a*b}function $h(a,b,c,d,e){return wh(a,b)+xh(a,c)+yh(a,d)+zh(a,e)}function _h(){}function ai(a,b){this.v1=a,this.v2=b}function bi(){this.curves=[],this.autoclose=!1}function ci(a,b,c,d,e,f,g,h){this.ax=a,this.ay=b,this.xradius=c,this.yradius=d,this.astartangle=e,this.aendangle=f,this.aclockwise=g,this.arotation=h||0}function di(a){this.points=void 0===a?[]:a}function ei(a,b,c,d){this.v0=a,this.v1=b,this.v2=c,this.v3=d}function fi(a,b,c){this.v0=a,this.v1=b,this.v2=c}function hi(a){bi.call(this),this.currentpoint=new ub,a&&this.frompoints(a)}function ii(){hi.apply(this,arguments),this.holes=[]}function ji(){this.subpaths=[],this.currentpath=null}function ki(a){this.data=a}function li(a){this.manager=void 0!==a?a:gh}function oi(a){this.manager=void 0!==a?a:gh}function pi(a,b,c,d){nh.call(this,a,b),this.type="rectarealight",this.position.set(0,1,0),this.updatematrix(),this.width=void 0!==c?c:10,this.height=void 0!==d?d:10}function qi(){this.type="stereocamera",this.aspect=1,this.eyesep=.064,this.cameral=new nf,this.cameral.layers.enable(1),this.cameral.matrixautoupdate=!1,this.camerar=new nf,this.camerar.layers.enable(2),this.camerar.matrixautoupdate=!1}function ri(a,b,c){ne.call(this),this.type="cubecamera";var d=90,e=1,f=new nf(d,e,a,b);f.up.set(0,-1,0),f.lookat(new bb(1,0,0)),this.add(f);var g=new nf(d,e,a,b);g.up.set(0,-1,0),g.lookat(new bb(-1,0,0)),this.add(g);var h=new nf(d,e,a,b);h.up.set(0,0,1),h.lookat(new bb(0,1,0)),this.add(h);var i=new nf(d,e,a,b);i.up.set(0,0,-1),i.lookat(new bb(0,-1,0)),this.add(i);var j=new nf(d,e,a,b);j.up.set(0,-1,0),j.lookat(new bb(0,0,1)),this.add(j);var k=new nf(d,e,a,b);k.up.set(0,-1,0),k.lookat(new bb(0,0,-1)),this.add(k);var l={format:ja,magfilter:ta,minfilter:ta};this.rendertarget=new zb(c,c,l),this.updatecubemap=function(a,b){null===this.parent&&this.updatematrixworld();var c=this.rendertarget,d=c.texture.generatemipmaps;c.texture.generatemipmaps=!1,c.activecubeface=0,a.render(b,f,c),c.activecubeface=1,a.render(b,g,c),c.activecubeface=2,a.render(b,h,c),c.activecubeface=3,a.render(b,i,c),c.activecubeface=4,a.render(b,j,c),c.texture.generatemipmaps=d,c.activecubeface=5,a.render(b,k,c),a.setrendertarget(null)}}function si(){ne.call(this),this.type="audiolistener",this.context=ni.getcontext(),this.gain=this.context.creategain(),this.gain.connect(this.context.destination),this.filter=null}function ti(a){ne.call(this),this.type="audio",this.context=a.context,this.gain=this.context.creategain(),this.gain.connect(a.getinput()),this.autoplay=!1,this.buffer=null,this.loop=!1,this.starttime=0,this.playbackrate=1,this.isplaying=!1,this.hasplaybackcontrol=!0,this.sourcetype="empty",this.filters=[]}function ui(a){ti.call(this,a),this.panner=this.context.createpanner(),this.panner.connect(this.gain)}function vi(a,b){this.analyser=a.context.createanalyser(),this.analyser.fftsize=void 0!==b?b:2048,this.data=new uint8array(this.analyser.frequencybincount),a.getoutput().connect(this.analyser)}function wi(a,b,c){this.binding=a,this.valuesize=c;var e,d=float64array;switch(b){case"quaternion":e=this._slerp;break;case"string":case"bool":d=array,e=this._select;break;default:e=this._lerp}this.buffer=new d(4*c),this._mixbufferregion=e,this.cumulativeweight=0,this.usecount=0,this.referencecount=0}function xi(a,b,c){this.path=b,this.parsedpath=c||xi.parsetrackname(b),this.node=xi.findnode(a,this.parsedpath.nodename)||a,this.rootnode=a}function yi(a){this.uuid=tb.generateuuid(),this._objects=array.prototype.slice.call(arguments),this.ncachedobjects_=0;var b={};this._indicesbyuuid=b;for(var c=0,d=arguments.length;c!==d;++c)b[arguments[c].uuid]=c;this._paths=[],this._parsedpaths=[],this._bindings=[],this._bindingsindicesbypath={};var e=this;this.stats={objects:{get total(){return e._objects.length},get inuse(){return this.total-e.ncachedobjects_}},get bindingsperobject(){return e._bindings.length}}}function zi(a,b,c){this._mixer=a,this._clip=b,this._localroot=c||null;for(var d=b.tracks,e=d.length,f=new array(e),g={endingstart:db,endingend:db},h=0;h!==e;++h){var i=d[h].createinterpolant(null);f[h]=i,i.settings=g}this._interpolantsettings=g,this._interpolants=f,this._propertybindings=new array(e),this._cacheindex=null,this._byclipcacheindex=null,this._timescaleinterpolant=null,this._weightinterpolant=null,this.loop=$a,this._loopcount=-1,this._starttime=null,this.time=0,this.timescale=1,this._effectivetimescale=1,this.weight=1,this._effectiveweight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampwhenfinished=!1,this.zeroslopeatstart=!0,this.zeroslopeatend=!0}function ai(a){this._root=a,this._initmemorymanager(),this._accuindex=0,this.time=0,this.timescale=1}function bi(a){"string"==typeof a&&(console.warn("three.uniform: type parameter is no longer needed."),a=arguments[1]),this.value=a}function ci(){ff.call(this),this.type="instancedbuffergeometry",this.maxinstancedcount=void 0}function di(a,b,c,d){this.uuid=tb.generateuuid(),this.data=a,this.itemsize=b,this.offset=c,this.normalized=d===!0}function ei(a,b){this.uuid=tb.generateuuid(),this.array=a,this.stride=b,this.count=void 0!==a?a.length/b:0,this.dynamic=!1,this.updaterange={offset:0,count:-1},this.onuploadcallback=function(){},this.version=0}function fi(a,b,c){ei.call(this,a,b),this.meshperattribute=c||1}function gi(a,b,c){se.call(this,a,b),this.meshperattribute=c||1}function hi(a,b,c,d){this.ray=new je(a,b),this.near=c||0,this.far=d||1/0,this.params={mesh:{},line:{},lod:{},points:{threshold:1},sprite:{}},object.defineproperties(this.params,{pointcloud:{get:function(){return console.warn("three.raycaster: params.pointcloud has been renamed to params.points."),this.points}}})}function ii(a,b){return a.distance-b.distance}function ji(a,b,c,d){if(a.visible!==!1&&(a.raycast(b,c),d===!0))for(var e=a.children,f=0,g=e.length;f0?1:+a}),void 0===function.prototype.name&&object.defineproperty(function.prototype,"name",{get:function(){return this.tostring().match(/^\s*function\s*([^\(\s]*)/)[1]}}),void 0===object.assign&&!function(){object.assign=function(a){if(void 0===a||null===a)throw new typeerror("cannot convert undefined or null to object");for(var b=object(a),c=1;c>=4,b[f]=a[19===f?3&d|8:d]);return b.join("")}}(),clamp:function(a,b,c){return math.max(b,math.min(c,a))},euclideanmodulo:function(a,b){return(a%b+b)%b},maplinear:function(a,b,c,d,e){return d+(a-b)*(e-d)/(c-b)},lerp:function(a,b,c){return(1-c)*a+c*b},smoothstep:function(a,b,c){return a<=b?0:a>=c?1:(a=(a-b)/(c-b),a*a*(3-2*a))},smootherstep:function(a,b,c){return a<=b?0:a>=c?1:(a=(a-b)/(c-b),a*a*a*(a*(6*a-15)+10))},randint:function(a,b){return a+math.floor(math.random()*(b-a+1))},randfloat:function(a,b){return a+math.random()*(b-a)},randfloatspread:function(a){return a*(.5-math.random())},degtorad:function(a){return a*tb.deg2rad},radtodeg:function(a){return a*tb.rad2deg},ispoweroftwo:function(a){return 0===(a&a-1)&&0!==a},nearestpoweroftwo:function(a){return math.pow(2,math.round(math.log(a)/math.ln2))},nextpoweroftwo:function(a){return a--,a|=a>>1,a|=a>>2,a|=a>>4,a|=a>>8,a|=a>>16,a++,a}};ub.prototype={constructor:ub,isvector2:!0,get width(){return this.x},set width(a){this.x=a},get height(){return this.y},set height(a){this.y=a},set:function(a,b){return this.x=a,this.y=b,this},setscalar:function(a){return this.x=a,this.y=a,this},setx:function(a){return this.x=a,this},sety:function(a){return this.y=a,this},setcomponent:function(a,b){switch(a){case 0:this.x=b;break;case 1:this.y=b;break;default:throw new error("index is out of range: "+a)}return this},getcomponent:function(a){switch(a){case 0:return this.x;case 1:return this.y;default:throw new error("index is out of range: "+a)}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(a){return this.x=a.x,this.y=a.y,this},add:function(a,b){return void 0!==b?(console.warn("three.vector2: .add() now only accepts one argument. use .addvectors( a, b ) instead."),this.addvectors(a,b)):(this.x+=a.x,this.y+=a.y,this)},addscalar:function(a){return this.x+=a,this.y+=a,this},addvectors:function(a,b){return this.x=a.x+b.x,this.y=a.y+b.y,this},addscaledvector:function(a,b){return this.x+=a.x*b,this.y+=a.y*b,this},sub:function(a,b){return void 0!==b?(console.warn("three.vector2: .sub() now only accepts one argument. use .subvectors( a, b ) instead."),this.subvectors(a,b)):(this.x-=a.x,this.y-=a.y,this)},subscalar:function(a){return this.x-=a,this.y-=a,this},subvectors:function(a,b){return this.x=a.x-b.x,this.y=a.y-b.y,this},multiply:function(a){return this.x*=a.x,this.y*=a.y,this},multiplyscalar:function(a){return isfinite(a)?(this.x*=a,this.y*=a):(this.x=0,this.y=0),this},divide:function(a){return this.x/=a.x,this.y/=a.y,this},dividescalar:function(a){return this.multiplyscalar(1/a)},min:function(a){return this.x=math.min(this.x,a.x),this.y=math.min(this.y,a.y),this},max:function(a){return this.x=math.max(this.x,a.x),this.y=math.max(this.y,a.y),this},clamp:function(a,b){return this.x=math.max(a.x,math.min(b.x,this.x)),this.y=math.max(a.y,math.min(b.y,this.y)),this},clampscalar:function(){var a,b;return function(d,e){return void 0===a&&(a=new ub,b=new ub),a.set(d,d),b.set(e,e),this.clamp(a,b)}}(),clamplength:function(a,b){var c=this.length();return this.multiplyscalar(math.max(a,math.min(b,c))/c)},floor:function(){return this.x=math.floor(this.x),this.y=math.floor(this.y),this},ceil:function(){return this.x=math.ceil(this.x),this.y=math.ceil(this.y),this},round:function(){return this.x=math.round(this.x),this.y=math.round(this.y),this},roundtozero:function(){return this.x=this.x<0?math.ceil(this.x):math.floor(this.x),this.y=this.y<0?math.ceil(this.y):math.floor(this.y),this},negate:function(){return this.x=-this.x,this.y=-this.y,this},dot:function(a){return this.x*a.x+this.y*a.y},lengthsq:function(){return this.x*this.x+this.y*this.y},length:function(){return math.sqrt(this.x*this.x+this.y*this.y)},lengthmanhattan:function(){return math.abs(this.x)+math.abs(this.y)},normalize:function(){return this.dividescalar(this.length())},angle:function(){var a=math.atan2(this.y,this.x);return a<0&&(a+=2*math.pi),a},distanceto:function(a){return math.sqrt(this.distancetosquared(a))},distancetosquared:function(a){var b=this.x-a.x,c=this.y-a.y;return b*b+c*c},distancetomanhattan:function(a){return math.abs(this.x-a.x)+math.abs(this.y-a.y)},setlength:function(a){return this.multiplyscalar(a/this.length())},lerp:function(a,b){return this.x+=(a.x-this.x)*b,this.y+=(a.y-this.y)*b,this},lerpvectors:function(a,b,c){return this.subvectors(b,a).multiplyscalar(c).add(a)},equals:function(a){return a.x===this.x&&a.y===this.y},fromarray:function(a,b){return void 0===b&&(b=0),this.x=a[b],this.y=a[b+1],this},toarray:function(a,b){return void 0===a&&(a=[]),void 0===b&&(b=0),a[b]=this.x,a[b+1]=this.y,a},frombufferattribute:function(a,b,c){return void 0!==c&&console.warn("three.vector2: offset has been removed from .frombufferattribute()."),this.x=a.getx(b),this.y=a.gety(b),this},rotatearound:function(a,b){var c=math.cos(b),d=math.sin(b),e=this.x-a.x,f=this.y-a.y;return this.x=e*c-f*d+a.x,this.y=e*d+f*c+a.y,this}};var vb=0;wb.default_image=void 0,wb.default_mapping=fa,wb.prototype={constructor:wb,istexture:!0,set needsupdate(a){a===!0&&this.version++},clone:function(){return(new this.constructor).copy(this)},copy:function(a){return this.image=a.image,this.mipmaps=a.mipmaps.slice(0),this.mapping=a.mapping,this.wraps=a.wraps,this.wrapt=a.wrapt,this.magfilter=a.magfilter,this.minfilter=a.minfilter,this.anisotropy=a.anisotropy,this.format=a.format,this.type=a.type,this.offset.copy(a.offset),this.repeat.copy(a.repeat),this.generatemipmaps=a.generatemipmaps,this.premultiplyalpha=a.premultiplyalpha,this.flipy=a.flipy,this.unpackalignment=a.unpackalignment,this.encoding=a.encoding,this},tojson:function(a){function b(a){var b;return void 0!==a.todataurl?b=a:(b=document.createelementns("http://www.w3.org/1999/xhtml","canvas"),b.width=a.width,b.height=a.height,b.getcontext("2d").drawimage(a,0,0,a.width,a.height)),b.width>2048||b.height>2048?b.todataurl("image/jpeg",.6):b.todataurl("image/png")}if(void 0!==a.textures[this.uuid])return a.textures[this.uuid];var c={metadata:{version:4.4,type:"texture",generator:"texture.tojson"},uuid:this.uuid,name:this.name,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],wrap:[this.wraps,this.wrapt],minfilter:this.minfilter,magfilter:this.magfilter,anisotropy:this.anisotropy,flipy:this.flipy};if(void 0!==this.image){var d=this.image;void 0===d.uuid&&(d.uuid=tb.generateuuid()),void 0===a.images[d.uuid]&&(a.images[d.uuid]={uuid:d.uuid,url:b(d)}),c.image=d.uuid}return a.textures[this.uuid]=c,c},dispose:function(){this.dispatchevent({type:"dispose"})},transformuv:function(a){if(this.mapping===fa){if(a.multiply(this.repeat),a.add(this.offset),a.x<0||a.x>1)switch(this.wraps){case na:a.x=a.x-math.floor(a.x);break;case oa:a.x=a.x<0?0:1;break;case pa:1===math.abs(math.floor(a.x)%2)?a.x=math.ceil(a.x)-a.x:a.x=a.x-math.floor(a.x)}if(a.y<0||a.y>1)switch(this.wrapt){case na:a.y=a.y-math.floor(a.y);break;case oa:a.y=a.y<0?0:1;break;case pa:1===math.abs(math.floor(a.y)%2)?a.y=math.ceil(a.y)-a.y:a.y=a.y-math.floor(a.y)}this.flipy&&(a.y=1-a.y)}}},object.assign(wb.prototype,b.prototype),xb.prototype={constructor:xb,isvector4:!0,set:function(a,b,c,d){return this.x=a,this.y=b,this.z=c,this.w=d,this},setscalar:function(a){return this.x=a,this.y=a,this.z=a,this.w=a,this},setx:function(a){return this.x=a,this},sety:function(a){return this.y=a,this},setz:function(a){return this.z=a,this},setw:function(a){return this.w=a,this},setcomponent:function(a,b){switch(a){case 0:this.x=b;break;case 1:this.y=b;break;case 2:this.z=b;break;case 3:this.w=b;break;default:throw new error("index is out of range: "+a)}return this},getcomponent:function(a){switch(a){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new error("index is out of range: "+a)}},clone:function(){return new this.constructor(this.x,this.y,this.z,this.w)},copy:function(a){return this.x=a.x,this.y=a.y,this.z=a.z,this.w=void 0!==a.w?a.w:1,this},add:function(a,b){return void 0!==b?(console.warn("three.vector4: .add() now only accepts one argument. use .addvectors( a, b ) instead."),this.addvectors(a,b)):(this.x+=a.x,this.y+=a.y,this.z+=a.z,this.w+=a.w,this)},addscalar:function(a){return this.x+=a,this.y+=a,this.z+=a,this.w+=a,this},addvectors:function(a,b){return this.x=a.x+b.x,this.y=a.y+b.y,this.z=a.z+b.z,this.w=a.w+b.w,this},addscaledvector:function(a,b){return this.x+=a.x*b,this.y+=a.y*b,this.z+=a.z*b,this.w+=a.w*b,this},sub:function(a,b){return void 0!==b?(console.warn("three.vector4: .sub() now only accepts one argument. use .subvectors( a, b ) instead."),this.subvectors(a,b)):(this.x-=a.x,this.y-=a.y,this.z-=a.z,this.w-=a.w,this)},subscalar:function(a){return this.x-=a,this.y-=a,this.z-=a,this.w-=a,this},subvectors:function(a,b){return this.x=a.x-b.x,this.y=a.y-b.y,this.z=a.z-b.z,this.w=a.w-b.w,this},multiplyscalar:function(a){return isfinite(a)?(this.x*=a,this.y*=a,this.z*=a,this.w*=a):(this.x=0,this.y=0,this.z=0,this.w=0),this},applymatrix4:function(a){var b=this.x,c=this.y,d=this.z,e=this.w,f=a.elements;return this.x=f[0]*b+f[4]*c+f[8]*d+f[12]*e,this.y=f[1]*b+f[5]*c+f[9]*d+f[13]*e,this.z=f[2]*b+f[6]*c+f[10]*d+f[14]*e,this.w=f[3]*b+f[7]*c+f[11]*d+f[15]*e,this},dividescalar:function(a){return this.multiplyscalar(1/a)},setaxisanglefromquaternion:function(a){this.w=2*math.acos(a.w);var b=math.sqrt(1-a.w*a.w);return b<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=a.x/b,this.y=a.y/b,this.z=a.z/b),this},setaxisanglefromrotationmatrix:function(a){var b,c,d,e,f=.01,g=.1,h=a.elements,i=h[0],j=h[4],k=h[8],l=h[1],m=h[5],n=h[9],o=h[2],p=h[6],q=h[10];if(math.abs(j-l)s&&r>t?rt?s0?(m=.5/math.sqrt(l+1),this._w=.25/m,this._x=(j-h)*m,this._y=(e-i)*m,this._z=(f-d)*m):c>g&&c>k?(m=2*math.sqrt(1+c-g-k),this._w=(j-h)/m,this._x=.25*m,this._y=(d+f)/m,this._z=(e+i)/m):g>k?(m=2*math.sqrt(1+g-c-k),this._w=(e-i)/m,this._x=(d+f)/m,this._y=.25*m,this._z=(h+j)/m):(m=2*math.sqrt(1+k-c-g),this._w=(f-d)/m,this._x=(e+i)/m,this._y=(h+j)/m,this._z=.25*m),this.onchangecallback(),this},setfromunitvectors:function(){var a,b,c=1e-6;return function(e,f){return void 0===a&&(a=new bb),b=e.dot(f)+1,bmath.abs(e.z)?a.set(-e.y,e.x,0):a.set(0,-e.z,e.y)):a.crossvectors(e,f),this._x=a.x,this._y=a.y,this._z=a.z,this._w=b,this.normalize()}}(),inverse:function(){return this.conjugate().normalize()},conjugate:function(){return this._x*=-1,this._y*=-1,this._z*=-1,this.onchangecallback(),this},dot:function(a){return this._x*a._x+this._y*a._y+this._z*a._z+this._w*a._w},lengthsq:function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},length:function(){return math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},normalize:function(){var a=this.length();return 0===a?(this._x=0,this._y=0,this._z=0,this._w=1):(a=1/a,this._x=this._x*a,this._y=this._y*a,this._z=this._z*a,this._w=this._w*a),this.onchangecallback(),this},multiply:function(a,b){return void 0!==b?(console.warn("three.quaternion: .multiply() now only accepts one argument. use .multiplyquaternions( a, b ) instead."),this.multiplyquaternions(a,b)):this.multiplyquaternions(this,a)},premultiply:function(a){return this.multiplyquaternions(a,this)},multiplyquaternions:function(a,b){var c=a._x,d=a._y,e=a._z,f=a._w,g=b._x,h=b._y,i=b._z,j=b._w;return this._x=c*j+f*g+d*i-e*h,this._y=d*j+f*h+e*g-c*i,this._z=e*j+f*i+c*h-d*g,this._w=f*j-c*g-d*h-e*i,this.onchangecallback(),this},slerp:function(a,b){if(0===b)return this;if(1===b)return this.copy(a);var c=this._x,d=this._y,e=this._z,f=this._w,g=f*a._w+c*a._x+d*a._y+e*a._z;if(g<0?(this._w=-a._w,this._x=-a._x,this._y=-a._y,this._z=-a._z,g=-g):this.copy(a),g>=1)return this._w=f,this._x=c,this._y=d,this._z=e,this;var h=math.sqrt(1-g*g);if(math.abs(h)<.001)return this._w=.5*(f+this._w),this._x=.5*(c+this._x),this._y=.5*(d+this._y),this._z=.5*(e+this._z),this;var i=math.atan2(h,g),j=math.sin((1-b)*i)/h,k=math.sin(b*i)/h;return this._w=f*j+this._w*k,this._x=c*j+this._x*k,this._y=d*j+this._y*k,this._z=e*j+this._z*k,this.onchangecallback(),this},equals:function(a){return a._x===this._x&&a._y===this._y&&a._z===this._z&&a._w===this._w},fromarray:function(a,b){return void 0===b&&(b=0),this._x=a[b],this._y=a[b+1],this._z=a[b+2],this._w=a[b+3],this.onchangecallback(),this},toarray:function(a,b){return void 0===a&&(a=[]),void 0===b&&(b=0),a[b]=this._x,a[b+1]=this._y,a[b+2]=this._z,a[b+3]=this._w,a},onchange:function(a){return this.onchangecallback=a,this},onchangecallback:function(){}},object.assign(ab,{slerp:function(a,b,c,d){return c.copy(a).slerp(b,d)},slerpflat:function(a,b,c,d,e,f,g){var h=c[d+0],i=c[d+1],j=c[d+2],k=c[d+3],l=e[f+0],m=e[f+1],n=e[f+2],o=e[f+3];if(k!==o||h!==l||i!==m||j!==n){var p=1-g,q=h*l+i*m+j*n+k*o,r=q>=0?1:-1,s=1-q*q;if(s>number.epsilon){var t=math.sqrt(s),u=math.atan2(t,q*r);p=math.sin(p*u)/t,g=math.sin(g*u)/t}var v=g*r;if(h=h*p+l*v,i=i*p+m*v,j=j*p+n*v,k=k*p+o*v,p===1-g){var w=1/math.sqrt(h*h+i*i+j*j+k*k);h*=w,i*=w,j*=w,k*=w}}a[b]=h,a[b+1]=i,a[b+2]=j,a[b+3]=k}}),bb.prototype={constructor:bb,isvector3:!0,set:function(a,b,c){return this.x=a,this.y=b,this.z=c,this},setscalar:function(a){return this.x=a,this.y=a,this.z=a,this},setx:function(a){return this.x=a,this},sety:function(a){return this.y=a,this},setz:function(a){return this.z=a,this},setcomponent:function(a,b){switch(a){case 0:this.x=b;break;case 1:this.y=b;break;case 2:this.z=b;break;default:throw new error("index is out of range: "+a)}return this},getcomponent:function(a){switch(a){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new error("index is out of range: "+a)}},clone:function(){return new this.constructor(this.x,this.y,this.z)},copy:function(a){return this.x=a.x,this.y=a.y,this.z=a.z,this},add:function(a,b){return void 0!==b?(console.warn("three.vector3: .add() now only accepts one argument. use .addvectors( a, b ) instead."),this.addvectors(a,b)):(this.x+=a.x,this.y+=a.y,this.z+=a.z,this)},addscalar:function(a){return this.x+=a,this.y+=a,this.z+=a,this},addvectors:function(a,b){return this.x=a.x+b.x,this.y=a.y+b.y,this.z=a.z+b.z,this},addscaledvector:function(a,b){return this.x+=a.x*b,this.y+=a.y*b,this.z+=a.z*b,this},sub:function(a,b){return void 0!==b?(console.warn("three.vector3: .sub() now only accepts one argument. use .subvectors( a, b ) instead."),this.subvectors(a,b)):(this.x-=a.x,this.y-=a.y,this.z-=a.z,this)},subscalar:function(a){return this.x-=a,this.y-=a,this.z-=a,this},subvectors:function(a,b){return this.x=a.x-b.x,this.y=a.y-b.y,this.z=a.z-b.z,this},multiply:function(a,b){return void 0!==b?(console.warn("three.vector3: .multiply() now only accepts one argument. use .multiplyvectors( a, b ) instead."),this.multiplyvectors(a,b)):(this.x*=a.x,this.y*=a.y,this.z*=a.z,this)},multiplyscalar:function(a){return isfinite(a)?(this.x*=a,this.y*=a,this.z*=a):(this.x=0,this.y=0,this.z=0),this},multiplyvectors:function(a,b){return this.x=a.x*b.x,this.y=a.y*b.y,this.z=a.z*b.z,this},applyeuler:function(){var a;return function(c){return(c&&c.iseuler)===!1&&console.error("three.vector3: .applyeuler() now expects an euler rotation rather than a vector3 and order."),void 0===a&&(a=new ab),this.applyquaternion(a.setfromeuler(c))}}(),applyaxisangle:function(){var a;return function(c,d){return void 0===a&&(a=new ab),this.applyquaternion(a.setfromaxisangle(c,d))}}(),applymatrix3:function(a){var b=this.x,c=this.y,d=this.z,e=a.elements;return this.x=e[0]*b+e[3]*c+e[6]*d,this.y=e[1]*b+e[4]*c+e[7]*d,this.z=e[2]*b+e[5]*c+e[8]*d,this},applymatrix4:function(a){var b=this.x,c=this.y,d=this.z,e=a.elements;this.x=e[0]*b+e[4]*c+e[8]*d+e[12],this.y=e[1]*b+e[5]*c+e[9]*d+e[13],this.z=e[2]*b+e[6]*c+e[10]*d+e[14];var f=e[3]*b+e[7]*c+e[11]*d+e[15];return this.dividescalar(f)},applyquaternion:function(a){var b=this.x,c=this.y,d=this.z,e=a.x,f=a.y,g=a.z,h=a.w,i=h*b+f*d-g*c,j=h*c+g*b-e*d,k=h*d+e*c-f*b,l=-e*b-f*c-g*d;return this.x=i*h+l*-e+j*-g-k*-f,this.y=j*h+l*-f+k*-e-i*-g,this.z=k*h+l*-g+i*-f-j*-e,this},project:function(){var a;return function(c){return void 0===a&&(a=new cb),a.multiplymatrices(c.projectionmatrix,a.getinverse(c.matrixworld)),this.applymatrix4(a)}}(),unproject:function(){var a;return function(c){return void 0===a&&(a=new cb),a.multiplymatrices(c.matrixworld,a.getinverse(c.projectionmatrix)),this.applymatrix4(a)}}(),transformdirection:function(a){var b=this.x,c=this.y,d=this.z,e=a.elements;return this.x=e[0]*b+e[4]*c+e[8]*d,this.y=e[1]*b+e[5]*c+e[9]*d,this.z=e[2]*b+e[6]*c+e[10]*d,this.normalize()},divide:function(a){return this.x/=a.x,this.y/=a.y,this.z/=a.z,this},dividescalar:function(a){return this.multiplyscalar(1/a)},min:function(a){return this.x=math.min(this.x,a.x),this.y=math.min(this.y,a.y),this.z=math.min(this.z,a.z),this},max:function(a){return this.x=math.max(this.x,a.x),this.y=math.max(this.y,a.y),this.z=math.max(this.z,a.z),this},clamp:function(a,b){return this.x=math.max(a.x,math.min(b.x,this.x)),this.y=math.max(a.y,math.min(b.y,this.y)),this.z=math.max(a.z,math.min(b.z,this.z)),this},clampscalar:function(){var a,b;return function(d,e){return void 0===a&&(a=new bb,b=new bb),a.set(d,d,d),b.set(e,e,e),this.clamp(a,b)}}(),clamplength:function(a,b){var c=this.length();return this.multiplyscalar(math.max(a,math.min(b,c))/c)},floor:function(){return this.x=math.floor(this.x),this.y=math.floor(this.y),this.z=math.floor(this.z),this},ceil:function(){return this.x=math.ceil(this.x),this.y=math.ceil(this.y),this.z=math.ceil(this.z),this},round:function(){return this.x=math.round(this.x),this.y=math.round(this.y),this.z=math.round(this.z),this},roundtozero:function(){return this.x=this.x<0?math.ceil(this.x):math.floor(this.x),this.y=this.y<0?math.ceil(this.y):math.floor(this.y),this.z=this.z<0?math.ceil(this.z):math.floor(this.z),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},lengthsq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthmanhattan:function(){return math.abs(this.x)+math.abs(this.y)+math.abs(this.z)},normalize:function(){return this.dividescalar(this.length())},setlength:function(a){return this.multiplyscalar(a/this.length())},lerp:function(a,b){return this.x+=(a.x-this.x)*b,this.y+=(a.y-this.y)*b,this.z+=(a.z-this.z)*b,this},lerpvectors:function(a,b,c){return this.subvectors(b,a).multiplyscalar(c).add(a)},cross:function(a,b){if(void 0!==b)return console.warn("three.vector3: .cross() now only accepts one argument. use .crossvectors( a, b ) instead."),this.crossvectors(a,b);var c=this.x,d=this.y,e=this.z;return this.x=d*a.z-e*a.y,this.y=e*a.x-c*a.z,this.z=c*a.y-d*a.x,this},crossvectors:function(a,b){var c=a.x,d=a.y,e=a.z,f=b.x,g=b.y,h=b.z;return this.x=d*h-e*g,this.y=e*f-c*h,this.z=c*g-d*f,this},projectonvector:function(a){var b=a.dot(this)/a.lengthsq();return this.copy(a).multiplyscalar(b)},projectonplane:function(){var a;return function(c){return void 0===a&&(a=new bb),a.copy(this).projectonvector(c),this.sub(a)}}(),reflect:function(){var a;return function(c){return void 0===a&&(a=new bb),this.sub(a.copy(c).multiplyscalar(2*this.dot(c)))}}(),angleto:function(a){var b=this.dot(a)/math.sqrt(this.lengthsq()*a.lengthsq());return math.acos(tb.clamp(b,-1,1))},distanceto:function(a){return math.sqrt(this.distancetosquared(a))},distancetosquared:function(a){var b=this.x-a.x,c=this.y-a.y,d=this.z-a.z;return b*b+c*c+d*d},distancetomanhattan:function(a){return math.abs(this.x-a.x)+math.abs(this.y-a.y)+math.abs(this.z-a.z)},setfromspherical:function(a){var b=math.sin(a.phi)*a.radius;return this.x=b*math.sin(a.theta),this.y=math.cos(a.phi)*a.radius,this.z=b*math.cos(a.theta),this},setfromcylindrical:function(a){return this.x=a.radius*math.sin(a.theta),this.y=a.y,this.z=a.radius*math.cos(a.theta),this},setfrommatrixposition:function(a){return this.setfrommatrixcolumn(a,3)},setfrommatrixscale:function(a){var b=this.setfrommatrixcolumn(a,0).length(),c=this.setfrommatrixcolumn(a,1).length(),d=this.setfrommatrixcolumn(a,2).length();return this.x=b,this.y=c,this.z=d,this},setfrommatrixcolumn:function(a,b){if("number"==typeof a){console.warn("three.vector3: setfrommatrixcolumn now expects ( matrix, index ).");var c=a;a=b,b=c}return this.fromarray(a.elements,4*b)},equals:function(a){return a.x===this.x&&a.y===this.y&&a.z===this.z},fromarray:function(a,b){return void 0===b&&(b=0),this.x=a[b],this.y=a[b+1],this.z=a[b+2],this},toarray:function(a,b){return void 0===a&&(a=[]),void 0===b&&(b=0),a[b]=this.x,a[b+1]=this.y,a[b+2]=this.z,a},frombufferattribute:function(a,b,c){return void 0!==c&&console.warn("three.vector3: offset has been removed from .frombufferattribute()."),this.x=a.getx(b),this.y=a.gety(b),this.z=a.getz(b),this}},cb.prototype={constructor:cb,ismatrix4:!0,set:function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p){var q=this.elements;return q[0]=a,q[4]=b,q[8]=c,q[12]=d,q[1]=e,q[5]=f,q[9]=g,q[13]=h,q[2]=i,q[6]=j,q[10]=k,q[14]=l,q[3]=m,q[7]=n,q[11]=o,q[15]=p,this},identity:function(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this},clone:function(){return(new cb).fromarray(this.elements)},copy:function(a){return this.elements.set(a.elements),this},copyposition:function(a){var b=this.elements,c=a.elements;return b[12]=c[12],b[13]=c[13],b[14]=c[14],this},extractbasis:function(a,b,c){return a.setfrommatrixcolumn(this,0),b.setfrommatrixcolumn(this,1),c.setfrommatrixcolumn(this,2),this},makebasis:function(a,b,c){return this.set(a.x,b.x,c.x,0,a.y,b.y,c.y,0,a.z,b.z,c.z,0,0,0,0,1),this},extractrotation:function(){var a;return function(c){void 0===a&&(a=new bb);var d=this.elements,e=c.elements,f=1/a.setfrommatrixcolumn(c,0).length(),g=1/a.setfrommatrixcolumn(c,1).length(),h=1/a.setfrommatrixcolumn(c,2).length();return d[0]=e[0]*f,d[1]=e[1]*f,d[2]=e[2]*f,d[4]=e[4]*g,d[5]=e[5]*g,d[6]=e[6]*g,d[8]=e[8]*h,d[9]=e[9]*h,d[10]=e[10]*h,this}}(),makerotationfromeuler:function(a){(a&&a.iseuler)===!1&&console.error("three.matrix: .makerotationfromeuler() now expects a euler rotation rather than a vector3 and order.");var b=this.elements,c=a.x,d=a.y,e=a.z,f=math.cos(c),g=math.sin(c),h=math.cos(d),i=math.sin(d),j=math.cos(e),k=math.sin(e);if("xyz"===a.order){var l=f*j,m=f*k,n=g*j,o=g*k;b[0]=h*j,b[4]=-h*k,b[8]=i,b[1]=m+n*i,b[5]=l-o*i,b[9]=-g*h,b[2]=o-l*i,b[6]=n+m*i,b[10]=f*h}else if("yxz"===a.order){var p=h*j,q=h*k,r=i*j,s=i*k;b[0]=p+s*g,b[4]=r*g-q,b[8]=f*i,b[1]=f*k,b[5]=f*j,b[9]=-g,b[2]=q*g-r,b[6]=s+p*g,b[10]=f*h}else if("zxy"===a.order){var p=h*j,q=h*k,r=i*j,s=i*k;b[0]=p-s*g,b[4]=-f*k,b[8]=r+q*g,b[1]=q+r*g,b[5]=f*j,b[9]=s-p*g,b[2]=-f*i,b[6]=g,b[10]=f*h}else if("zyx"===a.order){var l=f*j,m=f*k,n=g*j,o=g*k;b[0]=h*j,b[4]=n*i-m,b[8]=l*i+o,b[1]=h*k,b[5]=o*i+l,b[9]=m*i-n,b[2]=-i,b[6]=g*h,b[10]=f*h}else if("yzx"===a.order){var t=f*h,u=f*i,v=g*h,w=g*i;b[0]=h*j,b[4]=w-t*k,b[8]=v*k+u,b[1]=k,b[5]=f*j,b[9]=-g*j,b[2]=-i*j,b[6]=u*k+v,b[10]=t-w*k}else if("xzy"===a.order){var t=f*h,u=f*i,v=g*h,w=g*i;b[0]=h*j,b[4]=-k,b[8]=i*j,b[1]=t*k+w,b[5]=f*j,b[9]=u*k-v,b[2]=v*k-u,b[6]=g*j,b[10]=w*k+t}return b[3]=0,b[7]=0,b[11]=0,b[12]=0,b[13]=0,b[14]=0,b[15]=1,this},makerotationfromquaternion:function(a){var b=this.elements,c=a.x,d=a.y,e=a.z,f=a.w,g=c+c,h=d+d,i=e+e,j=c*g,k=c*h,l=c*i,m=d*h,n=d*i,o=e*i,p=f*g,q=f*h,r=f*i;return b[0]=1-(m+o),b[4]=k-r,b[8]=l+q,b[1]=k+r,b[5]=1-(j+o),b[9]=n-p,b[2]=l-q,b[6]=n+p,b[10]=1-(j+m),b[3]=0,b[7]=0,b[11]=0,b[12]=0,b[13]=0,b[14]=0,b[15]=1,this},lookat:function(){var a,b,c;return function(e,f,g){void 0===a&&(a=new bb,b=new bb,c=new bb);var h=this.elements;return c.subvectors(e,f).normalize(),0===c.lengthsq()&&(c.z=1),a.crossvectors(g,c).normalize(),0===a.lengthsq()&&(c.z+=1e-4,a.crossvectors(g,c).normalize()),b.crossvectors(c,a),h[0]=a.x,h[4]=b.x,h[8]=c.x,h[1]=a.y,h[5]=b.y,h[9]=c.y,h[2]=a.z,h[6]=b.z,h[10]=c.z,this}}(),multiply:function(a,b){return void 0!==b?(console.warn("three.matrix4: .multiply() now only accepts one argument. use .multiplymatrices( a, b ) instead."),this.multiplymatrices(a,b)):this.multiplymatrices(this,a)},premultiply:function(a){return this.multiplymatrices(a,this)},multiplymatrices:function(a,b){var c=a.elements,d=b.elements,e=this.elements,f=c[0],g=c[4],h=c[8],i=c[12],j=c[1],k=c[5],l=c[9],m=c[13],n=c[2],o=c[6],p=c[10],q=c[14],r=c[3],s=c[7],t=c[11],u=c[15],v=d[0],w=d[4],x=d[8],y=d[12],z=d[1],a=d[5],b=d[9],c=d[13],d=d[2],e=d[6],f=d[10],g=d[14],h=d[3],i=d[7],j=d[11],k=d[15];return e[0]=f*v+g*z+h*d+i*h,e[4]=f*w+g*a+h*e+i*i,e[8]=f*x+g*b+h*f+i*j,e[12]=f*y+g*c+h*g+i*k,e[1]=j*v+k*z+l*d+m*h,e[5]=j*w+k*a+l*e+m*i,e[9]=j*x+k*b+l*f+m*j,e[13]=j*y+k*c+l*g+m*k,e[2]=n*v+o*z+p*d+q*h,e[6]=n*w+o*a+p*e+q*i,e[10]=n*x+o*b+p*f+q*j,e[14]=n*y+o*c+p*g+q*k,e[3]=r*v+s*z+t*d+u*h,e[7]=r*w+s*a+t*e+u*i,e[11]=r*x+s*b+t*f+u*j,e[15]=r*y+s*c+t*g+u*k,this},multiplytoarray:function(a,b,c){var d=this.elements;return this.multiplymatrices(a,b),c[0]=d[0],c[1]=d[1],c[2]=d[2],c[3]=d[3],c[4]=d[4],c[5]=d[5],c[6]=d[6],c[7]=d[7],c[8]=d[8],c[9]=d[9],c[10]=d[10],c[11]=d[11],c[12]=d[12],c[13]=d[13],c[14]=d[14],c[15]=d[15],this},multiplyscalar:function(a){var b=this.elements;return b[0]*=a,b[4]*=a,b[8]*=a,b[12]*=a,b[1]*=a,b[5]*=a,b[9]*=a,b[13]*=a,b[2]*=a,b[6]*=a,b[10]*=a,b[14]*=a,b[3]*=a,b[7]*=a,b[11]*=a,b[15]*=a,this},applytobufferattribute:function(){var a;return function(c){void 0===a&&(a=new bb);for(var d=0,e=c.count;d>16&255)/255,this.g=(a>>8&255)/255,this.b=(255&a)/255,this},setrgb:function(a,b,c){return this.r=a,this.g=b,this.b=c,this},sethsl:function(){function a(a,b,c){return c<0&&(c+=1),c>1&&(c-=1),c<1/6?a+6*(b-a)*c:c<.5?b:c<2/3?a+6*(b-a)*(2/3-c):a}return function(c,d,e){if(c=tb.euclideanmodulo(c,1),d=tb.clamp(d,0,1),e=tb.clamp(e,0,1),0===d)this.r=this.g=this.b=e;else{var f=e<=.5?e*(1+d):e+d-e*d,g=2*e-f;this.r=a(g,f,c+1/3),this.g=a(g,f,c),this.b=a(g,f,c-1/3)}return this}}(),setstyle:function(a){function b(b){void 0!==b&&parsefloat(b)<1&&console.warn("three.color: alpha component of "+a+" will be ignored.")}var c;if(c=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(a)){var d,e=c[1],f=c[2];switch(e){case"rgb":case"rgba":if(d=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(f))return this.r=math.min(255,parseint(d[1],10))/255,this.g=math.min(255,parseint(d[2],10))/255,this.b=math.min(255,parseint(d[3],10))/255,b(d[5]),this;if(d=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(f))return this.r=math.min(100,parseint(d[1],10))/100,this.g=math.min(100,parseint(d[2],10))/100,this.b=math.min(100,parseint(d[3],10))/100,b(d[5]),this;break;case"hsl":case"hsla":if(d=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(f)){var g=parsefloat(d[1])/360,h=parseint(d[2],10)/100,i=parseint(d[3],10)/100;return b(d[5]),this.sethsl(g,h,i)}}}else if(c=/^\#([a-fa-f0-9]+)$/.exec(a)){var j=c[1],k=j.length;if(3===k)return this.r=parseint(j.charat(0)+j.charat(0),16)/255,this.g=parseint(j.charat(1)+j.charat(1),16)/255,this.b=parseint(j.charat(2)+j.charat(2),16)/255,this;if(6===k)return this.r=parseint(j.charat(0)+j.charat(1),16)/255,this.g=parseint(j.charat(2)+j.charat(3),16)/255,this.b=parseint(j.charat(4)+j.charat(5),16)/255,this}if(a&&a.length>0){var j=se[a];void 0!==j?this.sethex(j):console.warn("three.color: unknown color "+a)}return this},clone:function(){return new this.constructor(this.r,this.g,this.b)},copy:function(a){return this.r=a.r,this.g=a.g,this.b=a.b,this},copygammatolinear:function(a,b){return void 0===b&&(b=2),this.r=math.pow(a.r,b),this.g=math.pow(a.g,b),this.b=math.pow(a.b,b),this},copylineartogamma:function(a,b){void 0===b&&(b=2);var c=b>0?1/b:1;return this.r=math.pow(a.r,c),this.g=math.pow(a.g,c),this.b=math.pow(a.b,c),this},convertgammatolinear:function(){var a=this.r,b=this.g,c=this.b;return this.r=a*a,this.g=b*b,this.b=c*c,this},convertlineartogamma:function(){return this.r=math.sqrt(this.r),this.g=math.sqrt(this.g),this.b=math.sqrt(this.b),this},gethex:function(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0},gethexstring:function(){return("000000"+this.gethex().tostring(16)).slice(-6)},gethsl:function(a){var h,i,b=a||{h:0,s:0,l:0},c=this.r,d=this.g,e=this.b,f=math.max(c,d,e),g=math.min(c,d,e),j=(g+f)/2;if(g===f)h=0,i=0;else{var k=f-g;switch(i=j<=.5?k/(f+g):k/(2-f-g),f){case c:h=(d-e)/k+(dthis.max.x||a.ythis.max.y)},containsbox:function(a){return this.min.x<=a.min.x&&a.max.x<=this.max.x&&this.min.y<=a.min.y&&a.max.y<=this.max.y},getparameter:function(a,b){var c=b||new ub;return c.set((a.x-this.min.x)/(this.max.x-this.min.x),(a.y-this.min.y)/(this.max.y-this.min.y))},intersectsbox:function(a){return!(a.max.xthis.max.x||a.max.ythis.max.y)},clamppoint:function(a,b){var c=b||new ub;return c.copy(a).clamp(this.min,this.max)},distancetopoint:function(){var a=new ub;return function(c){var d=a.copy(c).clamp(this.min,this.max);return d.sub(c).length()}}(),intersect:function(a){return this.min.max(a.min),this.max.min(a.max),this},union:function(a){return this.min.min(a.min),this.max.max(a.max),this},translate:function(a){return this.min.add(a),this.max.add(a),this},equals:function(a){return a.min.equals(this.min)&&a.max.equals(this.max)}};var ze=0;ae.prototype={constructor:ae,ismaterial:!0,get needsupdate(){return this._needsupdate},set needsupdate(a){a===!0&&this.update(),this._needsupdate=a},setvalues:function(a){if(void 0!==a)for(var b in a){var c=a[b];if(void 0!==c){var d=this[b];void 0!==d?d&&d.iscolor?d.set(c):d&&d.isvector3&&c&&c.isvector3?d.copy(c):"overdraw"===b?this[b]=number(c):this[b]=c:console.warn("three."+this.type+": '"+b+"' is not a property of this material.")}else console.warn("three.material: '"+b+"' parameter is undefined.")}},tojson:function(a){function d(a){var b=[];for(var c in a){var d=a[c];delete d.metadata,b.push(d)}return b}var b=void 0===a;b&&(a={textures:{},images:{}});var c={metadata:{version:4.4,type:"material",generator:"material.tojson"}};if(c.uuid=this.uuid,c.type=this.type,""!==this.name&&(c.name=this.name),this.color&&this.color.iscolor&&(c.color=this.color.gethex()),void 0!==this.roughness&&(c.roughness=this.roughness),void 0!==this.metalness&&(c.metalness=this.metalness),this.emissive&&this.emissive.iscolor&&(c.emissive=this.emissive.gethex()),this.specular&&this.specular.iscolor&&(c.specular=this.specular.gethex()),void 0!==this.shininess&&(c.shininess=this.shininess),void 0!==this.clearcoat&&(c.clearcoat=this.clearcoat),void 0!==this.clearcoatroughness&&(c.clearcoatroughness=this.clearcoatroughness),this.map&&this.map.istexture&&(c.map=this.map.tojson(a).uuid),this.alphamap&&this.alphamap.istexture&&(c.alphamap=this.alphamap.tojson(a).uuid),this.lightmap&&this.lightmap.istexture&&(c.lightmap=this.lightmap.tojson(a).uuid),this.bumpmap&&this.bumpmap.istexture&&(c.bumpmap=this.bumpmap.tojson(a).uuid,c.bumpscale=this.bumpscale),this.normalmap&&this.normalmap.istexture&&(c.normalmap=this.normalmap.tojson(a).uuid,c.normalscale=this.normalscale.toarray()),this.displacementmap&&this.displacementmap.istexture&&(c.displacementmap=this.displacementmap.tojson(a).uuid,c.displacementscale=this.displacementscale,c.displacementbias=this.displacementbias),this.roughnessmap&&this.roughnessmap.istexture&&(c.roughnessmap=this.roughnessmap.tojson(a).uuid),this.metalnessmap&&this.metalnessmap.istexture&&(c.metalnessmap=this.metalnessmap.tojson(a).uuid),this.emissivemap&&this.emissivemap.istexture&&(c.emissivemap=this.emissivemap.tojson(a).uuid),this.specularmap&&this.specularmap.istexture&&(c.specularmap=this.specularmap.tojson(a).uuid),this.envmap&&this.envmap.istexture&&(c.envmap=this.envmap.tojson(a).uuid,c.reflectivity=this.reflectivity),this.gradientmap&&this.gradientmap.istexture&&(c.gradientmap=this.gradientmap.tojson(a).uuid),void 0!==this.size&&(c.size=this.size),void 0!==this.sizeattenuation&&(c.sizeattenuation=this.sizeattenuation),this.blending!==w&&(c.blending=this.blending),this.shading!==r&&(c.shading=this.shading),this.side!==n&&(c.side=this.side),this.vertexcolors!==s&&(c.vertexcolors=this.vertexcolors),this.opacity<1&&(c.opacity=this.opacity),this.transparent===!0&&(c.transparent=this.transparent),c.depthfunc=this.depthfunc,c.depthtest=this.depthtest,c.depthwrite=this.depthwrite,this.alphatest>0&&(c.alphatest=this.alphatest),this.premultipliedalpha===!0&&(c.premultipliedalpha=this.premultipliedalpha),this.wireframe===!0&&(c.wireframe=this.wireframe),this.wireframelinewidth>1&&(c.wireframelinewidth=this.wireframelinewidth),"round"!==this.wireframelinecap&&(c.wireframelinecap=this.wireframelinecap),"round"!==this.wireframelinejoin&&(c.wireframelinejoin=this.wireframelinejoin),c.skinning=this.skinning,c.morphtargets=this.morphtargets,b){var e=d(a.textures),f=d(a.images);e.length>0&&(c.textures=e),f.length>0&&(c.images=f)}return c},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.name=a.name,this.fog=a.fog,this.lights=a.lights,this.blending=a.blending,this.side=a.side,this.shading=a.shading,this.vertexcolors=a.vertexcolors,this.opacity=a.opacity,this.transparent=a.transparent,this.blendsrc=a.blendsrc,this.blenddst=a.blenddst,this.blendequation=a.blendequation,this.blendsrcalpha=a.blendsrcalpha,this.blenddstalpha=a.blenddstalpha,this.blendequationalpha=a.blendequationalpha,this.depthfunc=a.depthfunc,this.depthtest=a.depthtest,this.depthwrite=a.depthwrite,this.colorwrite=a.colorwrite,this.precision=a.precision,this.polygonoffset=a.polygonoffset,this.polygonoffsetfactor=a.polygonoffsetfactor,this.polygonoffsetunits=a.polygonoffsetunits,this.alphatest=a.alphatest,this.premultipliedalpha=a.premultipliedalpha,this.overdraw=a.overdraw,this.visible=a.visible,this.clipshadows=a.clipshadows,this.clipintersection=a.clipintersection;var b=a.clippingplanes,c=null;if(null!==b){var d=b.length;c=new array(d);for(var e=0;e!==d;++e)c[e]=b[e].clone()}return this.clippingplanes=c,this},update:function(){this.dispatchevent({type:"update"})},dispose:function(){this.dispatchevent({type:"dispose"})}},object.assign(ae.prototype,b.prototype),be.prototype=object.create(ae.prototype),be.prototype.constructor=be,be.prototype.isshadermaterial=!0,be.prototype.copy=function(a){return ae.prototype.copy.call(this,a),this.fragmentshader=a.fragmentshader,this.vertexshader=a.vertexshader,this.uniforms=pc.clone(a.uniforms),this.defines=a.defines,this.wireframe=a.wireframe,this.wireframelinewidth=a.wireframelinewidth,this.lights=a.lights,this.clipping=a.clipping,this.skinning=a.skinning,this.morphtargets=a.morphtargets,this.morphnormals=a.morphnormals,this.extensions=a.extensions,this},be.prototype.tojson=function(a){var b=ae.prototype.tojson.call(this,a);return b.uniforms=this.uniforms,b.vertexshader=this.vertexshader,b.fragmentshader=this.fragmentshader,b},ce.prototype=object.create(ae.prototype),ce.prototype.constructor=ce,ce.prototype.ismeshdepthmaterial=!0,ce.prototype.copy=function(a){return ae.prototype.copy.call(this,a),this.depthpacking=a.depthpacking,this.skinning=a.skinning,this.morphtargets=a.morphtargets,this.map=a.map,this.alphamap=a.alphamap,this.displacementmap=a.displacementmap,this.displacementscale=a.displacementscale,this.displacementbias=a.displacementbias,this.wireframe=a.wireframe,this.wireframelinewidth=a.wireframelinewidth,this},de.prototype={constructor:de,isbox3:!0,set:function(a,b){return this.min.copy(a),this.max.copy(b),this},setfromarray:function(a){for(var b=+(1/0),c=+(1/0),d=+(1/0),e=-(1/0),f=-(1/0),g=-(1/0),h=0,i=a.length;he&&(e=j),k>f&&(f=k),l>g&&(g=l)}return this.min.set(b,c,d),this.max.set(e,f,g),this},setfrombufferattribute:function(a){for(var b=+(1/0),c=+(1/0),d=+(1/0),e=-(1/0),f=-(1/0),g=-(1/0),h=0,i=a.count;he&&(e=j),k>f&&(f=k),l>g&&(g=l)}return this.min.set(b,c,d),this.max.set(e,f,g),this},setfrompoints:function(a){this.makeempty();for(var b=0,c=a.length;bthis.max.x||a.ythis.max.y||a.zthis.max.z)},containsbox:function(a){return this.min.x<=a.min.x&&a.max.x<=this.max.x&&this.min.y<=a.min.y&&a.max.y<=this.max.y&&this.min.z<=a.min.z&&a.max.z<=this.max.z},getparameter:function(a,b){var c=b||new bb;return c.set((a.x-this.min.x)/(this.max.x-this.min.x),(a.y-this.min.y)/(this.max.y-this.min.y),(a.z-this.min.z)/(this.max.z-this.min.z))},intersectsbox:function(a){return!(a.max.xthis.max.x||a.max.ythis.max.y||a.max.zthis.max.z)},intersectssphere:function(){var a;return function(c){return void 0===a&&(a=new bb),this.clamppoint(c.center,a),a.distancetosquared(c.center)<=c.radius*c.radius}}(),intersectsplane:function(a){var b,c;return a.normal.x>0?(b=a.normal.x*this.min.x,c=a.normal.x*this.max.x):(b=a.normal.x*this.max.x,c=a.normal.x*this.min.x),a.normal.y>0?(b+=a.normal.y*this.min.y,c+=a.normal.y*this.max.y):(b+=a.normal.y*this.max.y,c+=a.normal.y*this.min.y),a.normal.z>0?(b+=a.normal.z*this.min.z,c+=a.normal.z*this.max.z):(b+=a.normal.z*this.max.z,c+=a.normal.z*this.min.z),b<=a.constant&&c>=a.constant},clamppoint:function(a,b){var c=b||new bb;return c.copy(a).clamp(this.min,this.max)},distancetopoint:function(){var a=new bb;return function(c){var d=a.copy(c).clamp(this.min,this.max);return d.sub(c).length()}}(),getboundingsphere:function(){var a=new bb;return function(c){var d=c||new ee;return this.getcenter(d.center),d.radius=.5*this.getsize(a).length(),d}}(),intersect:function(a){return this.min.max(a.min),this.max.min(a.max),this.isempty()&&this.makeempty(),this},union:function(a){return this.min.min(a.min),this.max.max(a.max),this},applymatrix4:function(){var a=[new bb,new bb,new bb,new bb,new bb,new bb,new bb,new bb];return function(c){return this.isempty()?this:(a[0].set(this.min.x,this.min.y,this.min.z).applymatrix4(c),a[1].set(this.min.x,this.min.y,this.max.z).applymatrix4(c),a[2].set(this.min.x,this.max.y,this.min.z).applymatrix4(c),a[3].set(this.min.x,this.max.y,this.max.z).applymatrix4(c),a[4].set(this.max.x,this.min.y,this.min.z).applymatrix4(c),a[5].set(this.max.x,this.min.y,this.max.z).applymatrix4(c),a[6].set(this.max.x,this.max.y,this.min.z).applymatrix4(c),a[7].set(this.max.x,this.max.y,this.max.z).applymatrix4(c),this.setfrompoints(a),this)}}(),translate:function(a){return this.min.add(a),this.max.add(a),this},equals:function(a){return a.min.equals(this.min)&&a.max.equals(this.max)}},ee.prototype={constructor:ee,set:function(a,b){return this.center.copy(a),this.radius=b,this},setfrompoints:function(){var a;return function(c,d){void 0===a&&(a=new de);var e=this.center;void 0!==d?e.copy(d):a.setfrompoints(c).getcenter(e);for(var f=0,g=0,h=c.length;gthis.radius*this.radius&&(d.sub(this.center).normalize(),d.multiplyscalar(this.radius).add(this.center)),d},getboundingbox:function(a){var b=a||new de;return b.set(this.center,this.center),b.expandbyscalar(this.radius),b},applymatrix4:function(a){return this.center.applymatrix4(a),this.radius=this.radius*a.getmaxscaleonaxis(),this},translate:function(a){return this.center.add(a),this},equals:function(a){return a.center.equals(this.center)&&a.radius===this.radius}},fe.prototype={constructor:fe,ismatrix3:!0,set:function(a,b,c,d,e,f,g,h,i){var j=this.elements;return j[0]=a,j[1]=d,j[2]=g,j[3]=b,j[4]=e,j[5]=h,j[6]=c,j[7]=f,j[8]=i,this},identity:function(){return this.set(1,0,0,0,1,0,0,0,1),this},clone:function(){return(new this.constructor).fromarray(this.elements)},copy:function(a){var b=a.elements;return this.set(b[0],b[3],b[6],b[1],b[4],b[7],b[2],b[5],b[8]),this},setfrommatrix4:function(a){var b=a.elements;return this.set(b[0],b[4],b[8],b[1],b[5],b[9],b[2],b[6],b[10]),this},applytobufferattribute:function(){var a;return function(c){void 0===a&&(a=new bb);for(var d=0,e=c.count;d1))return e.copy(f).multiplyscalar(h).add(c.start)}else if(0===this.distancetopoint(c.start))return e.copy(c.start)}}(),intersectsline:function(a){var b=this.distancetopoint(a.start),c=this.distancetopoint(a.end);return b<0&&c>0||c<0&&b>0},intersectsbox:function(a){return a.intersectsplane(this)},intersectssphere:function(a){return a.intersectsplane(this)},coplanarpoint:function(a){var b=a||new bb;return b.copy(this.normal).multiplyscalar(-this.constant)},applymatrix4:function(){var a=new bb,b=new fe;return function(d,e){var f=this.coplanarpoint(a).applymatrix4(d),g=e||b.getnormalmatrix(d),h=this.normal.applymatrix3(g).normalize();return this.constant=-f.dot(h), this}}(),translate:function(a){return this.constant=this.constant-a.dot(this.normal),this},equals:function(a){return a.normal.equals(this.normal)&&a.constant===this.constant}},he.prototype={constructor:he,set:function(a,b,c,d,e,f){var g=this.planes;return g[0].copy(a),g[1].copy(b),g[2].copy(c),g[3].copy(d),g[4].copy(e),g[5].copy(f),this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){for(var b=this.planes,c=0;c<6;c++)b[c].copy(a.planes[c]);return this},setfrommatrix:function(a){var b=this.planes,c=a.elements,d=c[0],e=c[1],f=c[2],g=c[3],h=c[4],i=c[5],j=c[6],k=c[7],l=c[8],m=c[9],n=c[10],o=c[11],p=c[12],q=c[13],r=c[14],s=c[15];return b[0].setcomponents(g-d,k-h,o-l,s-p).normalize(),b[1].setcomponents(g+d,k+h,o+l,s+p).normalize(),b[2].setcomponents(g+e,k+i,o+m,s+q).normalize(),b[3].setcomponents(g-e,k-i,o-m,s-q).normalize(),b[4].setcomponents(g-f,k-j,o-n,s-r).normalize(),b[5].setcomponents(g+f,k+j,o+n,s+r).normalize(),this},intersectsobject:function(){var a=new ee;return function(c){var d=c.geometry;return null===d.boundingsphere&&d.computeboundingsphere(),a.copy(d.boundingsphere).applymatrix4(c.matrixworld),this.intersectssphere(a)}}(),intersectssprite:function(){var a=new ee;return function(c){return a.center.set(0,0,0),a.radius=.7071067811865476,a.applymatrix4(c.matrixworld),this.intersectssphere(a)}}(),intersectssphere:function(a){for(var b=this.planes,c=a.center,d=-a.radius,e=0;e<6;e++){var f=b[e].distancetopoint(c);if(f0?d.min.x:d.max.x,b.x=g.normal.x>0?d.max.x:d.min.x,a.y=g.normal.y>0?d.min.y:d.max.y,b.y=g.normal.y>0?d.max.y:d.min.y,a.z=g.normal.z>0?d.min.z:d.max.z,b.z=g.normal.z>0?d.max.z:d.min.z;var h=g.distancetopoint(a),i=g.distancetopoint(b);if(h<0&&i<0)return!1}return!0}}(),containspoint:function(a){for(var b=this.planes,c=0;c<6;c++)if(b[c].distancetopoint(a)<0)return!1;return!0}},je.prototype={constructor:je,set:function(a,b){return this.origin.copy(a),this.direction.copy(b),this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){return this.origin.copy(a.origin),this.direction.copy(a.direction),this},at:function(a,b){var c=b||new bb;return c.copy(this.direction).multiplyscalar(a).add(this.origin)},lookat:function(a){return this.direction.copy(a).sub(this.origin).normalize(),this},recast:function(){var a=new bb;return function(c){return this.origin.copy(this.at(c,a)),this}}(),closestpointtopoint:function(a,b){var c=b||new bb;c.subvectors(a,this.origin);var d=c.dot(this.direction);return d<0?c.copy(this.origin):c.copy(this.direction).multiplyscalar(d).add(this.origin)},distancetopoint:function(a){return math.sqrt(this.distancesqtopoint(a))},distancesqtopoint:function(){var a=new bb;return function(c){var d=a.subvectors(c,this.origin).dot(this.direction);return d<0?this.origin.distancetosquared(c):(a.copy(this.direction).multiplyscalar(d).add(this.origin),a.distancetosquared(c))}}(),distancesqtosegment:function(){var a=new bb,b=new bb,c=new bb;return function(e,f,g,h){a.copy(e).add(f).multiplyscalar(.5),b.copy(f).sub(e).normalize(),c.copy(this.origin).sub(a);var o,p,q,r,i=.5*e.distanceto(f),j=-this.direction.dot(b),k=c.dot(this.direction),l=-c.dot(b),m=c.lengthsq(),n=math.abs(1-j*j);if(n>0)if(o=j*l-k,p=j*k-l,r=i*n,o>=0)if(p>=-r)if(p<=r){var s=1/n;o*=s,p*=s,q=o*(o+j*p+2*k)+p*(j*o+p+2*l)+m}else p=i,o=math.max(0,-(j*p+k)),q=-o*o+p*(p+2*l)+m;else p=-i,o=math.max(0,-(j*p+k)),q=-o*o+p*(p+2*l)+m;else p<=-r?(o=math.max(0,-(-j*i+k)),p=o>0?-i:math.min(math.max(-i,-l),i),q=-o*o+p*(p+2*l)+m):p<=r?(o=0,p=math.min(math.max(-i,-l),i),q=p*(p+2*l)+m):(o=math.max(0,-(j*i+k)),p=o>0?i:math.min(math.max(-i,-l),i),q=-o*o+p*(p+2*l)+m);else p=j>0?-i:i,o=math.max(0,-(j*p+k)),q=-o*o+p*(p+2*l)+m;return g&&g.copy(this.direction).multiplyscalar(o).add(this.origin),h&&h.copy(b).multiplyscalar(p).add(a),q}}(),intersectsphere:function(){var a=new bb;return function(c,d){a.subvectors(c.center,this.origin);var e=a.dot(this.direction),f=a.dot(a)-e*e,g=c.radius*c.radius;if(f>g)return null;var h=math.sqrt(g-f),i=e-h,j=e+h;return i<0&&j<0?null:i<0?this.at(j,d):this.at(i,d)}}(),intersectssphere:function(a){return this.distancetopoint(a.center)<=a.radius},distancetoplane:function(a){var b=a.normal.dot(this.direction);if(0===b)return 0===a.distancetopoint(this.origin)?0:null;var c=-(this.origin.dot(a.normal)+a.constant)/b;return c>=0?c:null},intersectplane:function(a,b){var c=this.distancetoplane(a);return null===c?null:this.at(c,b)},intersectsplane:function(a){var b=a.distancetopoint(this.origin);if(0===b)return!0;var c=a.normal.dot(this.direction);return c*b<0},intersectbox:function(a,b){var c,d,e,f,g,h,i=1/this.direction.x,j=1/this.direction.y,k=1/this.direction.z,l=this.origin;return i>=0?(c=(a.min.x-l.x)*i,d=(a.max.x-l.x)*i):(c=(a.max.x-l.x)*i,d=(a.min.x-l.x)*i),j>=0?(e=(a.min.y-l.y)*j,f=(a.max.y-l.y)*j):(e=(a.max.y-l.y)*j,f=(a.min.y-l.y)*j),c>f||e>d?null:((e>c||c!==c)&&(c=e),(f=0?(g=(a.min.z-l.z)*k,h=(a.max.z-l.z)*k):(g=(a.max.z-l.z)*k,h=(a.min.z-l.z)*k),c>h||g>d?null:((g>c||c!==c)&&(c=g),(h=0?c:d,b)))},intersectsbox:function(){var a=new bb;return function(c){return null!==this.intersectbox(c,a)}}(),intersecttriangle:function(){var a=new bb,b=new bb,c=new bb,d=new bb;return function(f,g,h,i,j){b.subvectors(g,f),c.subvectors(h,f),d.crossvectors(b,c);var l,k=this.direction.dot(d);if(k>0){if(i)return null;l=1}else{if(!(k<0))return null;l=-1,k=-k}a.subvectors(this.origin,f);var m=l*this.direction.dot(c.crossvectors(a,c));if(m<0)return null;var n=l*this.direction.dot(b.cross(a));if(n<0)return null;if(m+n>k)return null;var o=-l*a.dot(d);return o<0?null:this.at(o/k,j)}}(),applymatrix4:function(a){return this.direction.add(this.origin).applymatrix4(a),this.origin.applymatrix4(a),this.direction.sub(this.origin),this.direction.normalize(),this},equals:function(a){return a.origin.equals(this.origin)&&a.direction.equals(this.direction)}},ke.rotationorders=["xyz","yzx","zxy","xzy","yxz","zyx"],ke.defaultorder="xyz",ke.prototype={constructor:ke,iseuler:!0,get x(){return this._x},set x(a){this._x=a,this.onchangecallback()},get y(){return this._y},set y(a){this._y=a,this.onchangecallback()},get z(){return this._z},set z(a){this._z=a,this.onchangecallback()},get order(){return this._order},set order(a){this._order=a,this.onchangecallback()},set:function(a,b,c,d){return this._x=a,this._y=b,this._z=c,this._order=d||this._order,this.onchangecallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._order)},copy:function(a){return this._x=a._x,this._y=a._y,this._z=a._z,this._order=a._order,this.onchangecallback(),this},setfromrotationmatrix:function(a,b,c){var d=tb.clamp,e=a.elements,f=e[0],g=e[4],h=e[8],i=e[1],j=e[5],k=e[9],l=e[2],m=e[6],n=e[10];return b=b||this._order,"xyz"===b?(this._y=math.asin(d(h,-1,1)),math.abs(h)<.99999?(this._x=math.atan2(-k,n),this._z=math.atan2(-g,f)):(this._x=math.atan2(m,j),this._z=0)):"yxz"===b?(this._x=math.asin(-d(k,-1,1)),math.abs(k)<.99999?(this._y=math.atan2(h,n),this._z=math.atan2(i,j)):(this._y=math.atan2(-l,f),this._z=0)):"zxy"===b?(this._x=math.asin(d(m,-1,1)),math.abs(m)<.99999?(this._y=math.atan2(-l,n),this._z=math.atan2(-g,j)):(this._y=0,this._z=math.atan2(i,f))):"zyx"===b?(this._y=math.asin(-d(l,-1,1)),math.abs(l)<.99999?(this._x=math.atan2(m,n),this._z=math.atan2(i,f)):(this._x=0,this._z=math.atan2(-g,j))):"yzx"===b?(this._z=math.asin(d(i,-1,1)),math.abs(i)<.99999?(this._x=math.atan2(-k,j),this._y=math.atan2(-l,f)):(this._x=0,this._y=math.atan2(h,n))):"xzy"===b?(this._z=math.asin(-d(g,-1,1)),math.abs(g)<.99999?(this._x=math.atan2(m,j),this._y=math.atan2(h,f)):(this._x=math.atan2(-k,n),this._y=0)):console.warn("three.euler: .setfromrotationmatrix() given unsupported order: "+b),this._order=b,c!==!1&&this.onchangecallback(),this},setfromquaternion:function(){var a;return function(c,d,e){return void 0===a&&(a=new cb),a.makerotationfromquaternion(c),this.setfromrotationmatrix(a,d,e)}}(),setfromvector3:function(a,b){return this.set(a.x,a.y,a.z,b||this._order)},reorder:function(){var a=new ab;return function(c){return a.setfromeuler(this),this.setfromquaternion(a,c)}}(),equals:function(a){return a._x===this._x&&a._y===this._y&&a._z===this._z&&a._order===this._order},fromarray:function(a){return this._x=a[0],this._y=a[1],this._z=a[2],void 0!==a[3]&&(this._order=a[3]),this.onchangecallback(),this},toarray:function(a,b){return void 0===a&&(a=[]),void 0===b&&(b=0),a[b]=this._x,a[b+1]=this._y,a[b+2]=this._z,a[b+3]=this._order,a},tovector3:function(a){return a?a.set(this._x,this._y,this._z):new bb(this._x,this._y,this._z)},onchange:function(a){return this.onchangecallback=a,this},onchangecallback:function(){}},le.prototype={constructor:le,set:function(a){this.mask=1<1){for(var b=0;b1)for(var b=0;b0){d.children=[];for(var e=0;e0&&(c.geometries=f),g.length>0&&(c.materials=g),h.length>0&&(c.textures=h),i.length>0&&(c.images=i)}return c.object=d,c},clone:function(a){return(new this.constructor).copy(this,a)},copy:function(a,b){if(void 0===b&&(b=!0),this.name=a.name,this.up.copy(a.up),this.position.copy(a.position),this.quaternion.copy(a.quaternion),this.scale.copy(a.scale),this.matrix.copy(a.matrix),this.matrixworld.copy(a.matrixworld),this.matrixautoupdate=a.matrixautoupdate,this.matrixworldneedsupdate=a.matrixworldneedsupdate,this.layers.mask=a.layers.mask,this.visible=a.visible,this.castshadow=a.castshadow,this.receiveshadow=a.receiveshadow,this.frustumculled=a.frustumculled,this.renderorder=a.renderorder,this.userdata=json.parse(json.stringify(a.userdata)),b===!0)for(var c=0;c0?g.multiplyscalar(1/math.sqrt(h)):g.set(0,0,0)}}(),pe.barycoordfrompoint=function(){var a=new bb,b=new bb,c=new bb;return function(e,f,g,h,i){a.subvectors(h,f),b.subvectors(g,f),c.subvectors(e,f);var j=a.dot(a),k=a.dot(b),l=a.dot(c),m=b.dot(b),n=b.dot(c),o=j*m-k*k,p=i||new bb;if(0===o)return p.set(-2,-1,-1);var q=1/o,r=(m*l-k*n)*q,s=(j*n-k*l)*q;return p.set(1-r-s,s,r)}}(),pe.containspoint=function(){var a=new bb;return function(c,d,e,f){var g=pe.barycoordfrompoint(c,d,e,f,a);return g.x>=0&&g.y>=0&&g.x+g.y<=1}}(),pe.prototype={constructor:pe,set:function(a,b,c){return this.a.copy(a),this.b.copy(b),this.c.copy(c),this},setfrompointsandindices:function(a,b,c,d){return this.a.copy(a[b]),this.b.copy(a[c]),this.c.copy(a[d]),this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){return this.a.copy(a.a),this.b.copy(a.b),this.c.copy(a.c),this},area:function(){var a=new bb,b=new bb;return function(){return a.subvectors(this.c,this.b),b.subvectors(this.a,this.b),.5*a.cross(b).length()}}(),midpoint:function(a){var b=a||new bb;return b.addvectors(this.a,this.b).add(this.c).multiplyscalar(1/3)},normal:function(a){return pe.normal(this.a,this.b,this.c,a)},plane:function(a){var b=a||new ge;return b.setfromcoplanarpoints(this.a,this.b,this.c)},barycoordfrompoint:function(a,b){return pe.barycoordfrompoint(a,this.a,this.b,this.c,b)},containspoint:function(a){return pe.containspoint(a,this.a,this.b,this.c)},closestpointtopoint:function(){var a,b,c,d;return function(f,g){void 0===a&&(a=new ge,b=[new oe,new oe,new oe],c=new bb,d=new bb);var h=g||new bb,i=1/0;if(a.setfromcoplanarpoints(this.a,this.b,this.c),a.projectpoint(f,c),this.containspoint(c)===!0)h.copy(c);else{b[0].set(this.a,this.b),b[1].set(this.b,this.c),b[2].set(this.c,this.a);for(var j=0;j0,f=d[1]&&d[1].length>0,g=a.morphtargets,h=g.length;if(h>0){i=[];for(var j=0;j0){m=[];for(var j=0;j0)for(var m=0;m0&&(this.normalsneedupdate=!0)},computeflatvertexnormals:function(){var a,b,c;for(this.computefacenormals(),a=0,b=this.faces.length;a0&&(this.normalsneedupdate=!0)},computemorphnormals:function(){var a,b,c,d,e;for(c=0,d=this.faces.length;c0&&(a+=b[c].distanceto(b[c-1])),this.linedistances[c]=a},computeboundingbox:function(){null===this.boundingbox&&(this.boundingbox=new de),this.boundingbox.setfrompoints(this.vertices)},computeboundingsphere:function(){null===this.boundingsphere&&(this.boundingsphere=new ee),this.boundingsphere.setfrompoints(this.vertices)},merge:function(a,b,c){if((a&&a.isgeometry)===!1)return void console.error("three.geometry.merge(): geometry not an instance of three.geometry.",a);var d,e=this.vertices.length,f=this.vertices,g=a.vertices,h=this.faces,i=a.faces,j=this.facevertexuvs[0],k=a.facevertexuvs[0],l=this.colors,m=a.colors;void 0===c&&(c=0),void 0!==b&&(d=(new fe).getnormalmatrix(b));for(var n=0,o=g.length;n=0;h--){var p=n[h];for(this.faces.splice(p,1),l=0,m=this.facevertexuvs.length;l0,s=n.vertexnormals.length>0,t=1!==n.color.r||1!==n.color.g||1!==n.color.b,u=n.vertexcolors.length>0,v=0;if(v=z(v,0,0),v=z(v,1,o),v=z(v,2,p),v=z(v,3,q),v=z(v,4,r),v=z(v,5,s),v=z(v,6,t),v=z(v,7,u),g.push(v),g.push(n.a,n.b,n.c),g.push(n.materialindex),q){var w=this.facevertexuvs[0][e];g.push(c(w[0]),c(w[1]),c(w[2]))}if(r&&g.push(a(n.normal)),s){var x=n.vertexnormals;g.push(a(x[0]),a(x[1]),a(x[2]))}if(t&&g.push(b(n.color)),u){var y=n.vertexcolors;g.push(b(y[0]),b(y[1]),b(y[2]))}}return a.data={},a.data.vertices=d,a.data.normals=h,j.length>0&&(a.data.colors=j),l.length>0&&(a.data.uvs=[l]),a.data.faces=g,a},clone:function(){return(new ef).copy(this)},copy:function(a){var b,c,d,e,f,g;this.vertices=[],this.colors=[],this.faces=[],this.facevertexuvs=[[]],this.morphtargets=[],this.morphnormals=[],this.skinweights=[],this.skinindices=[],this.linedistances=[],this.boundingbox=null,this.boundingsphere=null,this.name=a.name;var h=a.vertices;for(b=0,c=h.length;b65535?ze:xe)(a,1):this.index=a},addattribute:function(a,b){return(b&&b.isbufferattribute)===!1&&(b&&b.isinterleavedbufferattribute)===!1?(console.warn("three.buffergeometry: .addattribute() now expects ( name, attribute )."),void this.addattribute(a,new se(arguments[1],arguments[2]))):"index"===a?(console.warn("three.buffergeometry.addattribute: use .setindex() for index attribute."),void this.setindex(b)):(this.attributes[a]=b,this)},getattribute:function(a){return this.attributes[a]},removeattribute:function(a){return delete this.attributes[a],this},addgroup:function(a,b,c){this.groups.push({start:a,count:b,materialindex:void 0!==c?c:0})},cleargroups:function(){this.groups=[]},setdrawrange:function(a,b){this.drawrange.start=a,this.drawrange.count=b},applymatrix:function(a){var b=this.attributes.position;void 0!==b&&(a.applytobufferattribute(b),b.needsupdate=!0);var c=this.attributes.normal;if(void 0!==c){var d=(new fe).getnormalmatrix(a);d.applytobufferattribute(c),c.needsupdate=!0}return null!==this.boundingbox&&this.computeboundingbox(),null!==this.boundingsphere&&this.computeboundingsphere(),this},rotatex:function(){var a;return function(c){return void 0===a&&(a=new cb),a.makerotationx(c),this.applymatrix(a),this}}(),rotatey:function(){var a;return function(c){return void 0===a&&(a=new cb),a.makerotationy(c),this.applymatrix(a),this}}(),rotatez:function(){var a;return function(c){return void 0===a&&(a=new cb),a.makerotationz(c),this.applymatrix(a),this}}(),translate:function(){var a;return function(c,d,e){return void 0===a&&(a=new cb),a.maketranslation(c,d,e),this.applymatrix(a),this}}(),scale:function(){var a;return function(c,d,e){return void 0===a&&(a=new cb),a.makescale(c,d,e),this.applymatrix(a),this}}(),lookat:function(){var a;return function(c){void 0===a&&(a=new ne),a.lookat(c),a.updatematrix(),this.applymatrix(a.matrix)}}(),center:function(){this.computeboundingbox();var a=this.boundingbox.getcenter().negate();return this.translate(a.x,a.y,a.z),a},setfromobject:function(a){var b=a.geometry;if(a.ispoints||a.isline){var c=new $e(3*b.vertices.length,3),d=new $e(3*b.colors.length,3);if(this.addattribute("position",c.copyvector3sarray(b.vertices)),this.addattribute("color",d.copycolorsarray(b.colors)),b.linedistances&&b.linedistances.length===b.vertices.length){var e=new $e(b.linedistances.length,1);this.addattribute("linedistance",e.copyarray(b.linedistances))}null!==b.boundingsphere&&(this.boundingsphere=b.boundingsphere.clone()),null!==b.boundingbox&&(this.boundingbox=b.boundingbox.clone())}else a.ismesh&&b&&b.isgeometry&&this.fromgeometry(b);return this},updatefromobject:function(a){var b=a.geometry;if(a.ismesh){var c=b.__directgeometry;if(b.elementsneedupdate===!0&&(c=void 0,b.elementsneedupdate=!1),void 0===c)return this.fromgeometry(b);c.verticesneedupdate=b.verticesneedupdate,c.normalsneedupdate=b.normalsneedupdate,c.colorsneedupdate=b.colorsneedupdate,c.uvsneedupdate=b.uvsneedupdate,c.groupsneedupdate=b.groupsneedupdate,b.verticesneedupdate=!1,b.normalsneedupdate=!1,b.colorsneedupdate=!1,b.uvsneedupdate=!1,b.groupsneedupdate=!1,b=c}var d;return b.verticesneedupdate===!0&&(d=this.attributes.position,void 0!==d&&(d.copyvector3sarray(b.vertices),d.needsupdate=!0),b.verticesneedupdate=!1),b.normalsneedupdate===!0&&(d=this.attributes.normal,void 0!==d&&(d.copyvector3sarray(b.normals),d.needsupdate=!0),b.normalsneedupdate=!1),b.colorsneedupdate===!0&&(d=this.attributes.color,void 0!==d&&(d.copycolorsarray(b.colors),d.needsupdate=!0),b.colorsneedupdate=!1),b.uvsneedupdate&&(d=this.attributes.uv,void 0!==d&&(d.copyvector2sarray(b.uvs),d.needsupdate=!0),b.uvsneedupdate=!1),b.linedistancesneedupdate&&(d=this.attributes.linedistance,void 0!==d&&(d.copyarray(b.linedistances),d.needsupdate=!0),b.linedistancesneedupdate=!1),b.groupsneedupdate&&(b.computegroups(a.geometry),this.groups=b.groups,b.groupsneedupdate=!1),this},fromgeometry:function(a){return a.__directgeometry=(new af).fromgeometry(a),this.fromdirectgeometry(a.__directgeometry)},fromdirectgeometry:function(a){var b=new float32array(3*a.vertices.length);if(this.addattribute("position",new se(b,3).copyvector3sarray(a.vertices)),a.normals.length>0){var c=new float32array(3*a.normals.length);this.addattribute("normal",new se(c,3).copyvector3sarray(a.normals))}if(a.colors.length>0){var d=new float32array(3*a.colors.length);this.addattribute("color",new se(d,3).copycolorsarray(a.colors))}if(a.uvs.length>0){var e=new float32array(2*a.uvs.length);this.addattribute("uv",new se(e,2).copyvector2sarray(a.uvs))}if(a.uvs2.length>0){var f=new float32array(2*a.uvs2.length);this.addattribute("uv2",new se(f,2).copyvector2sarray(a.uvs2))}if(a.indices.length>0){var g=bf(a.indices)>65535?uint32array:uint16array,h=new g(3*a.indices.length);this.setindex(new se(h,1).copyindicesarray(a.indices))}this.groups=a.groups;for(var i in a.morphtargets){for(var j=[],k=a.morphtargets[i],l=0,m=k.length;l0){var p=new $e(4*a.skinindices.length,4);this.addattribute("skinindex",p.copyvector4sarray(a.skinindices))}if(a.skinweights.length>0){var q=new $e(4*a.skinweights.length,4);this.addattribute("skinweight",q.copyvector4sarray(a.skinweights))}return null!==a.boundingsphere&&(this.boundingsphere=a.boundingsphere.clone()),null!==a.boundingbox&&(this.boundingbox=a.boundingbox.clone()),this},computeboundingbox:function(){null===this.boundingbox&&(this.boundingbox=new de);var a=this.attributes.position;void 0!==a?this.boundingbox.setfrombufferattribute(a):this.boundingbox.makeempty(),(isnan(this.boundingbox.min.x)||isnan(this.boundingbox.min.y)||isnan(this.boundingbox.min.z))&&console.error('three.buffergeometry.computeboundingbox: computed min/max have nan values. the "position" attribute is likely to have nan values.',this)},computeboundingsphere:function(){var a=new de,b=new bb;return function(){null===this.boundingsphere&&(this.boundingsphere=new ee);var d=this.attributes.position;if(d){var e=this.boundingsphere.center;a.setfrombufferattribute(d),a.getcenter(e);for(var f=0,g=0,h=d.count;g0&&(a.data.groups=json.parse(json.stringify(h)));var i=this.boundingsphere;return null!==i&&(a.data.boundingsphere={center:i.center.toarray(),radius:i.radius}),a},clone:function(){return(new ff).copy(this)},copy:function(a){var b,c,d;this.index=null,this.attributes={},this.morphattributes={},this.groups=[],this.boundingbox=null,this.boundingsphere=null,this.name=a.name;var e=a.index;null!==e&&this.setindex(e.clone());var f=a.attributes;for(b in f){var g=f[b];this.addattribute(b,g.clone())}var h=a.morphattributes;for(b in h){var i=[],j=h[b];for(c=0,d=j.length;c0){this.morphtargetinfluences=[],this.morphtargetdictionary={};for(var b=0,c=a.length;bb.far?null:{distance:j,point:q.clone(),object:a}}function t(a,b,c,g,h,i,m,o){d.frombufferattribute(g,i),e.frombufferattribute(g,m),f.frombufferattribute(g,o);var p=s(a,b,c,d,e,f,n);return p&&(h&&(j.frombufferattribute(h,i),k.frombufferattribute(h,m),l.frombufferattribute(h,o),p.uv=r(n,d,e,f,j,k,l)),p.face=new qe(i,m,o,pe.normal(d,e,f)),p.faceindex=i),p}var a=new cb,b=new je,c=new ee,d=new bb,e=new bb,f=new bb,g=new bb,h=new bb,i=new bb,j=new ub,k=new ub,l=new ub,m=new bb,n=new bb,q=new bb;return function(o,p){var q=this.geometry,u=this.material,v=this.matrixworld;if(void 0!==u&&(null===q.boundingsphere&&q.computeboundingsphere(),c.copy(q.boundingsphere),c.applymatrix4(v),o.ray.intersectssphere(c)!==!1&&(a.getinverse(v),b.copy(o.ray).applymatrix4(a),null===q.boundingbox||b.intersectsbox(q.boundingbox)!==!1))){var w;if(q.isbuffergeometry){var x,y,z,d,e,a=q.index,b=q.attributes.position,c=q.attributes.uv;if(null!==a)for(d=0,e=a.count;d0&&(m=n);for(var o=0,p=l.length;of||d.push({distance:math.sqrt(e),point:this.position,face:null,object:this})}}(),clone:function(){return new this.constructor(this.material).copy(this)}}),xf.prototype=object.assign(object.create(ne.prototype),{constructor:xf,copy:function(a){ne.prototype.copy.call(this,a,!1);for(var b=a.levels,c=0,d=b.length;c1){a.setfrommatrixposition(d.matrixworld),b.setfrommatrixposition(this.matrixworld);var f=a.distanceto(b);e[0].object.visible=!0;for(var g=1,h=e.length;g=e[g].distance;g++)e[g-1].object.visible=!1,e[g].object.visible=!0;for(;gh)){n.applymatrix4(this.matrixworld);var y=e.ray.origin.distanceto(n);ye.far||f.push({distance:y,point:m.clone().applymatrix4(this.matrixworld),index:t,face:null,faceindex:null,object:this})}}else for(var t=0,u=r.length/3-1;th)){n.applymatrix4(this.matrixworld);var y=e.ray.origin.distanceto(n);ye.far||f.push({distance:y,point:m.clone().applymatrix4(this.matrixworld),index:t,face:null,faceindex:null,object:this})}}}else if(i.isgeometry)for(var z=i.vertices,a=z.length,t=0;th)){n.applymatrix4(this.matrixworld);var y=e.ray.origin.distanceto(n);ye.far||f.push({distance:y,point:m.clone().applymatrix4(this.matrixworld),index:t,face:null,faceindex:null,object:this})}}}}}(),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),bg.prototype=object.assign(object.create(ag.prototype),{constructor:bg,islinesegments:!0}),cg.prototype=object.create(ae.prototype),cg.prototype.constructor=cg,cg.prototype.ispointsmaterial=!0,cg.prototype.copy=function(a){return ae.prototype.copy.call(this,a),this.color.copy(a.color),this.map=a.map,this.size=a.size,this.sizeattenuation=a.sizeattenuation,this},dg.prototype=object.assign(object.create(ne.prototype),{constructor:dg,ispoints:!0,raycast:function(){var a=new cb,b=new je,c=new ee;return function(e,f){function n(a,c){var d=b.distancesqtopoint(a);if(de.far)return;f.push({distance:j,distancetoray:math.sqrt(d),point:h.clone(),index:c,face:null,object:g})}}var g=this,h=this.geometry,i=this.matrixworld,j=e.params.points.threshold;if(null===h.boundingsphere&&h.computeboundingsphere(),c.copy(h.boundingsphere),c.applymatrix4(i),e.ray.intersectssphere(c)!==!1){a.getinverse(i),b.copy(e.ray).applymatrix4(a);var k=j/((this.scale.x+this.scale.y+this.scale.z)/3),l=k*k,m=new bb;if(h.isbuffergeometry){var o=h.index,p=h.attributes,q=p.position.array;if(null!==o)for(var r=o.array,s=0,t=r.length;s=-number.epsilon&&c>=-number.epsilon&&b>=-number.epsilon))return!1;return!0}return function(c,d){var e=c.length;if(e<3)return null;var i,j,k,f=[],g=[],h=[];if(cg.area(c)>0)for(j=0;j2;){if(m--<=0)return console.warn("three.shapeutils: unable to triangulate polygon! in triangulate()"),d?h:f;if(i=j,l<=i&&(i=0),j=i+1,l<=j&&(j=0),k=j+1,l<=k&&(k=0),a(c,i,j,k,l,g)){var n,o,p,q,r;for(n=g[i],o=g[j],p=g[k],f.push([c[n],c[o],c[p]]),h.push([g[i],g[j],g[k]]),q=j,r=j+1;r2&&a[b-1].equals(a[0])&&a.pop()}function d(a,b,c){return a.x!==b.x?a.xnumber.epsilon){var o;if(m>0){if(n<0||n>m)return[];if(o=j*k-i*l,o<0||o>m)return[]}else{if(n>0||n0||oz?[]:u===z?f?[]:[s]:v<=z?[s,t]:[s,x]}function f(a,b,c,d){var e=b.x-a.x,f=b.y-a.y,g=c.x-a.x,h=c.y-a.y,i=d.x-a.x,j=d.y-a.y,k=e*h-f*g,l=e*j-f*i;if(math.abs(k)>number.epsilon){var m=i*h-j*g;return k>0?l>=0&&m>=0:l>=0||m>=0}return l>0}function g(a,b){function g(a,b){var e=c.length-1,g=a-1;g<0&&(g=e);var h=a+1;h>e&&(h=0);var i=f(c[a],c[g],c[h],d[b]);if(!i)return!1;var j=d.length-1,k=b-1;k<0&&(k=j);var l=b+1;return l>j&&(l=0),i=f(d[b],d[k],d[l],c[a]),!!i}function h(a,b){var d,f,g;for(d=0;d0)return!0;return!1}function j(a,c){var d,f,g,h,j;for(d=0;d0)return!0;return!1}for(var d,k,l,m,n,o,p,r,s,t,u,c=a.concat(),i=[],q=[],v=0,w=b.length;v0;){if(y--,y<0){console.log("infinite loop! holes left:"+i.length+", probably hole outside shape!");break}for(l=x;l=0)break;q[p]=!0}if(k>=0)break}}return c}c(a),b.foreach(c);for(var h,i,j,k,l,m,n={},o=a.concat(),p=0,q=b.length;pnumber.epsilon){var m=math.sqrt(k),n=math.sqrt(i*i+j*j),o=b.x-h/m,p=b.y+g/m,q=c.x-j/n,r=c.y+i/n,s=((q-o)*j-(r-p)*i)/(g*j-h*i);d=o+g*s-a.x,e=p+h*s-a.y;var t=d*d+e*e;if(t<=2)return new ub(d,e);f=math.sqrt(t/2)}else{var u=!1;g>number.epsilon?i>number.epsilon&&(u=!0):g<-number.epsilon?i<-number.epsilon&&(u=!0):math.sign(h)===math.sign(j)&&(u=!0),u?(d=-h,e=g,f=math.sqrt(k)):(d=g,e=h,f=math.sqrt(k/2))}return new ub(d/f,e/f)}function v(){if(g){var a=0,b=i*a;for(n=0;n=0;){c=n,d=n-1,d<0&&(d=a.length-1);var e=0,g=i+2*f;for(e=0;e=0;d--){for(f=d/f,g=d*math.cos(f*math.pi/2),e=e*math.sin(f*math.pi/2),n=0,o=b.length;n0||0===a.search(/^data\:image\/jpeg/);e.format=d?ja:ka,e.image=c,e.needsupdate=!0,void 0!==b&&b(e)},c,d),e},setcrossorigin:function(a){return this.crossorigin=a,this},setpath:function(a){return this.path=a,this}}),nh.prototype=object.assign(object.create(ne.prototype),{constructor:nh,islight:!0,copy:function(a){return ne.prototype.copy.call(this,a),this.color.copy(a.color),this.intensity=a.intensity,this},tojson:function(a){var b=ne.prototype.tojson.call(this,a);return b.object.color=this.color.gethex(),b.object.intensity=this.intensity,void 0!==this.groundcolor&&(b.object.groundcolor=this.groundcolor.gethex()),void 0!==this.distance&&(b.object.distance=this.distance),void 0!==this.angle&&(b.object.angle=this.angle),void 0!==this.decay&&(b.object.decay=this.decay),void 0!==this.penumbra&&(b.object.penumbra=this.penumbra),void 0!==this.shadow&&(b.object.shadow=this.shadow.tojson()),b}}),oh.prototype=object.assign(object.create(nh.prototype),{constructor:oh,ishemispherelight:!0,copy:function(a){return nh.prototype.copy.call(this,a),this.groundcolor.copy(a.groundcolor),this}}),object.assign(ph.prototype,{copy:function(a){return this.camera=a.camera.clone(),this.bias=a.bias,this.radius=a.radius,this.mapsize.copy(a.mapsize),this},clone:function(){return(new this.constructor).copy(this)},tojson:function(){var a={};return 0!==this.bias&&(a.bias=this.bias),1!==this.radius&&(a.radius=this.radius),512===this.mapsize.x&&512===this.mapsize.y||(a.mapsize=this.mapsize.toarray()),a.camera=this.camera.tojson(!1).object,delete a.camera.matrix,a}}),qh.prototype=object.assign(object.create(ph.prototype),{constructor:qh,isspotlightshadow:!0,update:function(a){var b=2*tb.rad2deg*a.angle,c=this.mapsize.width/this.mapsize.height,d=a.distance||500,e=this.camera;b===e.fov&&c===e.aspect&&d===e.far||(e.fov=b,e.aspect=c,e.far=d,e.updateprojectionmatrix())}}),rh.prototype=object.assign(object.create(nh.prototype),{constructor:rh,isspotlight:!0,copy:function(a){return nh.prototype.copy.call(this,a),this.distance=a.distance,this.angle=a.angle,this.penumbra=a.penumbra,this.decay=a.decay,this.target=a.target.clone(),this.shadow=a.shadow.clone(),this}}),sh.prototype=object.assign(object.create(nh.prototype),{constructor:sh,ispointlight:!0,copy:function(a){return nh.prototype.copy.call(this,a),this.distance=a.distance,this.decay=a.decay,this.shadow=a.shadow.clone(),this}}),th.prototype=object.assign(object.create(ph.prototype),{constructor:th}),uh.prototype=object.assign(object.create(nh.prototype),{constructor:uh,isdirectionallight:!0,copy:function(a){return nh.prototype.copy.call(this,a),this.target=a.target.clone(),this.shadow=a.shadow.clone(),this}}),vh.prototype=object.assign(object.create(nh.prototype),{constructor:vh,isambientlight:!0});var wh={arrayslice:function(a,b,c){return wh.istypedarray(a)?new a.constructor(a.subarray(b,c)):a.slice(b,c)},convertarray:function(a,b,c){return!a||!c&&a.constructor===b?a:"number"==typeof b.bytes_per_element?new b(a):array.prototype.slice.call(a)},istypedarray:function(a){return arraybuffer.isview(a)&&!(a instanceof dataview)},getkeyframeorder:function(a){function b(b,c){return a[b]-a[c]}for(var c=a.length,d=new array(c),e=0;e!==c;++e)d[e]=e;return d.sort(b),d},sortedarray:function(a,b,c){for(var d=a.length,e=new a.constructor(d),f=0,g=0;g!==d;++f)for(var h=c[f]*b,i=0;i!==b;++i)e[g++]=a[h+i];return e},flattenjson:function(a,b,c,d){for(var e=1,f=a[0];void 0!==f&&void 0===f[d];)f=a[e++];if(void 0!==f){var g=f[d];if(void 0!==g)if(array.isarray(g)){do g=f[d],void 0!==g&&(b.push(f.time),c.push.apply(c,g)),f=a[e++];while(void 0!==f)}else if(void 0!==g.toarray){do g=f[d],void 0!==g&&(b.push(f.time),g.toarray(c,c.length)),f=a[e++];while(void 0!==f)}else do g=f[d],void 0!==g&&(b.push(f.time),c.push(g)),f=a[e++];while(void 0!==f)}}};xh.prototype={constructor:xh,evaluate:function(a){var b=this.parameterpositions,c=this._cachedindex,d=b[c],e=b[c-1];a:{b:{var f;c:{d:if(!(a=e)break a;var h=b[1];a=e)break b}f=c,c=0}}for(;c>>1;ab;)--f;if(++f,0!==e||f!==d){e>=f&&(f=math.max(f,1),e=f-1);var g=this.getvaluesize();this.times=wh.arrayslice(c,e,f),this.values=wh.arrayslice(this.values,e*g,f*g)}return this},validate:function(){var a=!0,b=this.getvaluesize();b-math.floor(b)!==0&&(console.error("invalid value size in track",this),a=!1);var c=this.times,d=this.values,e=c.length;0===e&&(console.error("track is empty",this),a=!1);for(var f=null,g=0;g!==e;g++){var h=c[g];if("number"==typeof h&&isnan(h)){console.error("time is not a valid number",this,g,h),a=!1;break}if(null!==f&&f>h){console.error("out of order keys",this,g,h,f),a=!1;break}f=h}if(void 0!==d&&wh.istypedarray(d))for(var g=0,i=d.length;g!==i;++g){var j=d[g];if(isnan(j)){console.error("value is not a valid number",this,g,j),a=!1;break}}return a},optimize:function(){for(var a=this.times,b=this.values,c=this.getvaluesize(),d=this.getinterpolation()===cb,e=1,f=a.length-1,g=1;g0){a[e]=a[f];for(var p=f*c,q=e*c,n=0;n!==c;++n)b[q+n]=b[p+n];++e}return e!==a.length&&(this.times=wh.arrayslice(a,0,e),this.values=wh.arrayslice(b,0,e*c)),this}},dh.prototype=object.assign(object.create(bh),{constructor:dh,valuetypename:"vector"}),eh.prototype=object.assign(object.create(xh.prototype),{constructor:eh,interpolate_:function(a,b,c,d){for(var e=this.resultbuffer,f=this.samplevalues,g=this.valuesize,h=a*g,i=(c-b)/(d-b),j=h+g;h!==j;h+=4)ab.slerpflat(e,0,f,h-g,f,h,i); return e}}),fh.prototype=object.assign(object.create(bh),{constructor:fh,valuetypename:"quaternion",defaultinterpolation:bb,interpolantfactorymethodlinear:function(a){return new eh(this.times,this.values,this.getvaluesize(),a)},interpolantfactorymethodsmooth:void 0}),gh.prototype=object.assign(object.create(bh),{constructor:gh,valuetypename:"number"}),hh.prototype=object.assign(object.create(bh),{constructor:hh,valuetypename:"string",valuebuffertype:array,defaultinterpolation:ab,interpolantfactorymethodlinear:void 0,interpolantfactorymethodsmooth:void 0}),ih.prototype=object.assign(object.create(bh),{constructor:ih,valuetypename:"bool",valuebuffertype:array,defaultinterpolation:ab,interpolantfactorymethodlinear:void 0,interpolantfactorymethodsmooth:void 0}),jh.prototype=object.assign(object.create(bh),{constructor:jh,valuetypename:"color"}),kh.prototype=bh,bh.constructor=kh,object.assign(kh,{parse:function(a){if(void 0===a.type)throw new error("track type undefined, can not parse");var b=kh._gettracktypeforvaluetypename(a.type);if(void 0===a.times){var c=[],d=[];wh.flattenjson(a.keys,c,d,"value"),a.times=c,a.values=d}return void 0!==b.parse?b.parse(a):new b(a.name,a.times,a.values,a.interpolation)},tojson:function(a){var c,b=a.constructor;if(void 0!==b.tojson)c=b.tojson(a);else{c={name:a.name,times:wh.convertarray(a.times,array),values:wh.convertarray(a.values,array)};var d=a.getinterpolation();d!==a.defaultinterpolation&&(c.interpolation=d)}return c.type=a.valuetypename,c},_gettracktypeforvaluetypename:function(a){switch(a.tolowercase()){case"scalar":case"double":case"float":case"number":case"integer":return gh;case"vector":case"vector2":case"vector3":case"vector4":return dh;case"color":return jh;case"quaternion":return fh;case"bool":case"boolean":return ih;case"string":return hh}throw new error("unsupported typename: "+a)}}),lh.prototype={constructor:lh,resetduration:function(){for(var a=this.tracks,b=0,c=0,d=a.length;c!==d;++c){var e=this.tracks[c];b=math.max(b,e.times[e.times.length-1])}this.duration=b},trim:function(){for(var a=0;a1){var j=i[1],k=d[j];k||(d[j]=k=[]),k.push(h)}}var l=[];for(var j in d)l.push(lh.createfrommorphtargetsequence(j,d[j],b,c));return l},parseanimation:function(a,b){if(!a)return console.error(" no animation in jsonloader data"),null;for(var c=function(a,b,c,d,e){if(0!==c.length){var f=[],g=[];wh.flattenjson(c,f,g,d),0!==f.length&&e.push(new a(b,f,g))}},d=[],e=a.name||"default",f=a.length||-1,g=a.fps||30,h=a.hierarchy||[],i=0;i1?a.skinweights[d+1]:0,h=b>2?a.skinweights[d+2]:0,i=b>3?a.skinweights[d+3]:0;c.skinweights.push(new xb(f,g,h,i))}if(a.skinindices)for(var d=0,e=a.skinindices.length;d1?a.skinindices[d+1]:0,l=b>2?a.skinindices[d+2]:0,m=b>3?a.skinindices[d+3]:0;c.skinindices.push(new xb(j,k,l,m))}c.bones=a.bones,c.bones&&c.bones.length>0&&(c.skinweights.length!==c.skinindices.length||c.skinindices.length!==c.vertices.length)&&console.warn("when skinning, number of vertices ("+c.vertices.length+"), skinindices ("+c.skinindices.length+"), and skinweights ("+c.skinweights.length+") should match.")}function g(b){if(void 0!==a.morphtargets)for(var d=0,e=a.morphtargets.length;d0){console.warn('three.jsonloader: "morphcolors" no longer supported. using them as face colors.');for(var k=c.faces,l=a.morphcolors[0].colors,d=0,e=k.length;d0&&(c.animations=b)}var c=new ef,d=void 0!==a.scale?1/a.scale:1;if(e(d),f(),g(d),h(),c.computefacenormals(),c.computeboundingsphere(),void 0===a.materials||0===a.materials.length)return{geometry:c};var i=oh.prototype.initmaterials(a.materials,b,this.crossorigin);return{geometry:c,materials:i}}}),object.assign(qh.prototype,{load:function(a,b,c,d){""===this.texturepath&&(this.texturepath=a.substring(0,a.lastindexof("/")+1));var e=this,f=new hh(e.manager);f.load(a,function(c){var f=null;try{f=json.parse(c)}catch(b){return void 0!==d&&d(b),void console.error("three:objectloader: can't parse "+a+".",b.message)}var g=f.metadata;return void 0===g||void 0===g.type||"geometry"===g.type.tolowercase()?void console.error("three.objectloader: can't load "+a+". use three.jsonloader instead."):void e.parse(f,b)},c,d)},settexturepath:function(a){this.texturepath=a},setcrossorigin:function(a){this.crossorigin=a},parse:function(a,b){var c=this.parsegeometries(a.geometries),d=this.parseimages(a.images,function(){void 0!==b&&b(g)}),e=this.parsetextures(a.textures,d),f=this.parsematerials(a.materials,e),g=this.parseobject(a.object,c,f);return a.animations&&(g.animations=this.parseanimations(a.animations)),void 0!==a.images&&0!==a.images.length||void 0!==b&&b(g),g},parsegeometries:function(a){var b={};if(void 0!==a)for(var c=new ph,d=new nh,e=0,f=a.length;e0){var f=new fh(b),g=new kh(f);g.setcrossorigin(this.crossorigin);for(var h=0,i=a.length;h0?new $f(i,j):new gf(i,j);break;case"lod":f=new xf;break;case"line":f=new ag(g(c.geometry),h(c.material),c.mode);break;case"linesegments":f=new bg(g(c.geometry),h(c.material));break;case"pointcloud":case"points":f=new dg(g(c.geometry),h(c.material));break;case"sprite":f=new wf(h(c.material));break;case"group":f=new eg;break;case"skinnedmesh":console.warn("three.objectloader.parseobject() does not support skinnedmesh type. instantiates object3d instead.");default:f=new ne}if(f.uuid=c.uuid,void 0!==c.name&&(f.name=c.name),void 0!==c.matrix?(a.fromarray(c.matrix),a.decompose(f.position,f.quaternion,f.scale)):(void 0!==c.position&&f.position.fromarray(c.position),void 0!==c.rotation&&f.rotation.fromarray(c.rotation),void 0!==c.quaternion&&f.quaternion.fromarray(c.quaternion),void 0!==c.scale&&f.scale.fromarray(c.scale)),void 0!==c.castshadow&&(f.castshadow=c.castshadow),void 0!==c.receiveshadow&&(f.receiveshadow=c.receiveshadow),c.shadow&&(void 0!==c.shadow.bias&&(f.shadow.bias=c.shadow.bias),void 0!==c.shadow.radius&&(f.shadow.radius=c.shadow.radius),void 0!==c.shadow.mapsize&&f.shadow.mapsize.fromarray(c.shadow.mapsize),void 0!==c.shadow.camera&&(f.shadow.camera=this.parseobject(c.shadow.camera))),void 0!==c.visible&&(f.visible=c.visible),void 0!==c.userdata&&(f.userdata=c.userdata),void 0!==c.children)for(var k in c.children)f.add(this.parseobject(c.children[k],d,e));if("lod"===c.type)for(var l=c.levels,m=0;m0)){h=d;break}h=d-1}if(d=h,c[d]===f){var j=d/(e-1);return j}var k=c[d],l=c[d+1],m=l-k,n=(f-k)/m,j=(d+n)/(e-1);return j},gettangent:function(a){var b=1e-4,c=a-b,d=a+b;c<0&&(c=0),d>1&&(d=1);var e=this.getpoint(c),f=this.getpoint(d),g=f.clone().sub(e);return g.normalize()},gettangentat:function(a){var b=this.getutotmapping(a);return this.gettangent(b)},computefrenetframes:function(a,b){var i,j,k,c=new bb,d=[],e=[],f=[],g=new bb,h=new cb;for(i=0;i<=a;i++)j=i/a,d[i]=this.gettangentat(j),d[i].normalize();e[0]=new bb,f[0]=new bb;var l=number.max_value,m=math.abs(d[0].x),n=math.abs(d[0].y),o=math.abs(d[0].z);for(m<=l&&(l=m,c.set(1,0,0)),n<=l&&(l=n,c.set(0,1,0)),o<=l&&c.set(0,0,1),g.crossvectors(d[0],c).normalize(),e[0].crossvectors(d[0],g),f[0].crossvectors(d[0],e[0]),i=1;i<=a;i++)e[i]=e[i-1].clone(),f[i]=f[i-1].clone(),g.crossvectors(d[i-1],d[i]),g.length()>number.epsilon&&(g.normalize(),k=math.acos(tb.clamp(d[i-1].dot(d[i]),-1,1)),e[i].applymatrix4(h.makerotationaxis(g,k))),f[i].crossvectors(d[i],e[i]);if(b===!0)for(k=math.acos(tb.clamp(e[0].dot(e[a]),-1,1)),k/=a,d[0].dot(g.crossvectors(e[0],e[a]))>0&&(k=-k),i=1;i<=a;i++)e[i].applymatrix4(h.makerotationaxis(d[i],k*i)),f[i].crossvectors(d[i],e[i]);return{tangents:d,normals:e,binormals:f}}},ai.prototype=object.create(_h.prototype),ai.prototype.constructor=ai,ai.prototype.islinecurve=!0,ai.prototype.getpoint=function(a){if(1===a)return this.v2.clone();var b=this.v2.clone().sub(this.v1);return b.multiplyscalar(a).add(this.v1),b},ai.prototype.getpointat=function(a){return this.getpoint(a)},ai.prototype.gettangent=function(a){var b=this.v2.clone().sub(this.v1);return b.normalize()},bi.prototype=object.assign(object.create(_h.prototype),{constructor:bi,add:function(a){this.curves.push(a)},closepath:function(){var a=this.curves[0].getpoint(0),b=this.curves[this.curves.length-1].getpoint(1);a.equals(b)||this.curves.push(new ai(b,a))},getpoint:function(a){for(var b=a*this.getlength(),c=this.getcurvelengths(),d=0;d=b){var e=c[d]-b,f=this.curves[d],g=f.getlength(),h=0===g?0:1-e/g;return f.getpointat(h)}d++}return null},getlength:function(){var a=this.getcurvelengths();return a[a.length-1]},updatearclengths:function(){this.needsupdate=!0,this.cachelengths=null,this.getlengths()},getcurvelengths:function(){if(this.cachelengths&&this.cachelengths.length===this.curves.length)return this.cachelengths;for(var a=[],b=0,c=0,d=this.curves.length;c1&&!b[b.length-1].equals(b[0])&&b.push(b[0]),b},createpointsgeometry:function(a){var b=this.getpoints(a);return this.creategeometry(b)},createspacedpointsgeometry:function(a){var b=this.getspacedpoints(a);return this.creategeometry(b)},creategeometry:function(a){for(var b=new ef,c=0,d=a.length;cb;)c-=b;cb.length-2?b.length-1:d+1],i=b[d>b.length-3?b.length-1:d+2];return new ub(rh(e,f.x,g.x,h.x,i.x),rh(e,f.y,g.y,h.y,i.y))},ei.prototype=object.create(_h.prototype),ei.prototype.constructor=ei,ei.prototype.getpoint=function(a){var b=this.v0,c=this.v1,d=this.v2,e=this.v3;return new ub($h(a,b.x,c.x,d.x,e.x),$h(a,b.y,c.y,d.y,e.y))},fi.prototype=object.create(_h.prototype),fi.prototype.constructor=fi,fi.prototype.getpoint=function(a){var b=this.v0,c=this.v1,d=this.v2;return new ub(vh(a,b.x,c.x,d.x),vh(a,b.y,c.y,d.y))};var gi=object.assign(object.create(bi.prototype),{frompoints:function(a){this.moveto(a[0].x,a[0].y);for(var b=1,c=a.length;b0){var j=i.getpoint(0);j.equals(this.currentpoint)||this.lineto(j.x,j.y)}this.curves.push(i);var k=i.getpoint(1);this.currentpoint.copy(k)}});hi.prototype=gi,gi.constructor=hi,ii.prototype=object.assign(object.create(gi),{constructor:ii,getpointsholes:function(a){for(var b=[],c=0,d=this.holes.length;cnumber.epsilon){if(j<0&&(g=b[f],i=-i,h=b[e],j=-j),a.yh.y)continue;if(a.y===g.y){if(a.x===g.x)return!0}else{var k=j*(a.x-g.x)-i*(a.y-g.y);if(0===k)return!0;if(k<0)continue;d=!d}}else{if(a.y!==g.y)continue;if(h.x<=a.x&&a.x<=g.x||g.x<=a.x&&a.x<=h.x)return!0}}return d}var e=cg.isclockwise,f=this.subpaths;if(0===f.length)return[];if(b===!0)return c(f);var g,h,i,j=[];if(1===f.length)return h=f[0],i=new ii,i.curves=h.curves,j.push(i),j;var k=!e(f[0].getpoints());k=a?!k:k;var p,l=[],m=[],n=[],o=0;m[o]=void 0,n[o]=[];for(var q=0,r=f.length;q1){for(var s=!1,t=[],u=0,v=m.length;u0&&(s||(n=l))}for(var b,q=0,c=m.length;q0){this.source.connect(this.filters[0]);for(var a=1,b=this.filters.length;a0){this.source.disconnect(this.filters[0]);for(var a=1,b=this.filters.length;a=.5)for(var f=0;f!==e;++f)a[b+f]=a[c+f]},_slerp:function(a,b,c,d,e){ab.slerpflat(a,b,a,b,a,c,d)},_lerp:function(a,b,c,d,e){for(var f=1-d,g=0;g!==e;++g){var h=b+g;a[h]=a[h]*f+a[c+g]*d}}},xi.prototype={constructor:xi,getvalue:function(b,c){this.bind(),this.getvalue(b,c)},setvalue:function(b,c){this.bind(),this.setvalue(b,c)},bind:function(){var a=this.node,b=this.parsedpath,c=b.objectname,d=b.propertyname,e=b.propertyindex;if(a||(a=xi.findnode(this.rootnode,b.nodename)||this.rootnode,this.node=a),this.getvalue=this._getvalue_unavailable,this.setvalue=this._setvalue_unavailable,!a)return void console.error(" trying to update node for track: "+this.path+" but it wasn't found.");if(c){var f=b.objectindex;switch(c){case"materials":if(!a.material)return void console.error(" can not bind to material as node does not have a material",this);if(!a.material.materials)return void console.error(" can not bind to material.materials as node.material does not have a materials array",this);a=a.material.materials;break;case"bones":if(!a.skeleton)return void console.error(" can not bind to bones as node does not have a skeleton",this);a=a.skeleton.bones;for(var g=0;g=c){var l=c++,m=b[l];d[m.uuid]=k,b[k]=m,d[j]=l,b[l]=i;for(var n=0,o=f;n!==o;++n){var p=e[n],q=p[l],r=p[k];p[k]=q,p[l]=r}}}this.ncachedobjects_=c},uncache:function(a){for(var b=this._objects,c=b.length,d=this.ncachedobjects_,e=this._indicesbyuuid,f=this._bindings,g=f.length,h=0,i=arguments.length;h!==i;++h){var j=arguments[h],k=j.uuid,l=e[k];if(void 0!==l)if(delete e[k],l0)for(var i=this._interpolants,j=this._propertybindings,k=0,l=i.length;k!==l;++k)i[k].evaluate(g),j[k].accumulate(d,h)},_updateweight:function(a){var b=0;if(this.enabled){b=this.weight;var c=this._weightinterpolant;if(null!==c){var d=c.evaluate(a)[0];b*=d,a>c.parameterpositions[1]&&(this.stopfading(),0===d&&(this.enabled=!1))}}return this._effectiveweight=b,b},_updatetimescale:function(a){var b=0;if(!this.paused){b=this.timescale;var c=this._timescaleinterpolant;if(null!==c){var d=c.evaluate(a)[0];b*=d,a>c.parameterpositions[1]&&(this.stopwarping(),0===b?this.paused=!0:this.timescale=b)}}return this._effectivetimescale=b,b},_updatetime:function(a){var b=this.time+a;if(0===a)return b;var c=this._clip.duration,d=this.loop,e=this._loopcount;if(d===za){e===-1&&(this._loopcount=0,this._setendings(!0,!0,!1));a:{if(b>=c)b=c;else{if(!(b<0))break a;b=0}this.clampwhenfinished?this.paused=!0:this.enabled=!1,this._mixer.dispatchevent({type:"finished",action:this,direction:a<0?-1:1})}}else{var f=d===_a;if(e===-1&&(a>=0?(e=0,this._setendings(!0,0===this.repetitions,f)):this._setendings(0===this.repetitions,!0,f)),b>=c||b<0){var g=math.floor(b/c);b-=c*g,e+=math.abs(g);var h=this.repetitions-e;if(h<0)this.clampwhenfinished?this.paused=!0:this.enabled=!1,b=a>0?c:0,this._mixer.dispatchevent({type:"finished",action:this,direction:a>0?1:-1});else{if(0===h){var i=a<0;this._setendings(i,!i,f)}else this._setendings(!1,!1,f);this._loopcount=e,this._mixer.dispatchevent({type:"loop",action:this,loopdelta:g})}}if(f&&1===(1&e))return this.time=b,c-b}return this.time=b,b},_setendings:function(a,b,c){var d=this._interpolantsettings;c?(d.endingstart=eb,d.endingend=eb):(a?d.endingstart=this.zeroslopeatstart?eb:db:d.endingstart=fb,b?d.endingend=this.zeroslopeatend?eb:db:d.endingend=fb)},_schedulefading:function(a,b,c){var d=this._mixer,e=d.time,f=this._weightinterpolant;null===f&&(f=d._lendcontrolinterpolant(),this._weightinterpolant=f);var g=f.parameterpositions,h=f.samplevalues;return g[0]=e,h[0]=b,g[1]=e+a,h[1]=c,this}},ai.prototype={constructor:ai,clipaction:function(a,b){var c=b||this._root,d=c.uuid,e="string"==typeof a?lh.findbyname(c,a):a,f=null!==e?e.uuid:a,g=this._actionsbyclip[f],h=null;if(void 0!==g){var i=g.actionbyroot[d];if(void 0!==i)return i;h=g.knownactions[0],null===e&&(e=h._clip)}if(null===e)return null;var j=new zi(this,e,b);return this._bindaction(j,h),this._addinactiveaction(j,f,d),j},existingaction:function(a,b){var c=b||this._root,d=c.uuid,e="string"==typeof a?lh.findbyname(c,a):a,f=e?e.uuid:a,g=this._actionsbyclip[f];return void 0!==g?g.actionbyroot[d]||null:null},stopallaction:function(){var a=this._actions,b=this._nactiveactions,c=this._bindings,d=this._nactivebindings;this._nactiveactions=0,this._nactivebindings=0;for(var e=0;e!==b;++e)a[e].reset();for(var e=0;e!==d;++e)c[e].usecount=0;return this},update:function(a){a*=this.timescale;for(var b=this._actions,c=this._nactiveactions,d=this.time+=a,e=math.sign(a),f=this._accuindex^=1,g=0;g!==c;++g){var h=b[g];h.enabled&&h._update(d,a,e,f)}for(var i=this._bindings,j=this._nactivebindings,g=0;g!==j;++g)i[g].apply(f);return this},getroot:function(){return this._root},uncacheclip:function(a){var b=this._actions,c=a.uuid,d=this._actionsbyclip,e=d[c];if(void 0!==e){for(var f=e.knownactions,g=0,h=f.length;g!==h;++g){var i=f[g];this._deactivateaction(i);var j=i._cacheindex,k=b[b.length-1];i._cacheindex=null,i._byclipcacheindex=null,k._cacheindex=j,b[j]=k,b.pop(),this._removeinactivebindingsforaction(i)}delete d[c]}},uncacheroot:function(a){var b=a.uuid,c=this._actionsbyclip;for(var d in c){var e=c[d].actionbyroot,f=e[b];void 0!==f&&(this._deactivateaction(f),this._removeinactiveaction(f))}var g=this._bindingsbyrootandname,h=g[b];if(void 0!==h)for(var i in h){var j=h[i];j.restoreoriginalstate(),this._removeinactivebinding(j)}},uncacheaction:function(a,b){var c=this.existingaction(a,b);null!==c&&(this._deactivateaction(c),this._removeinactiveaction(c))}},object.assign(ai.prototype,{_bindaction:function(a,b){var c=a._localroot||this._root,d=a._clip.tracks,e=d.length,f=a._propertybindings,g=a._interpolants,h=c.uuid,i=this._bindingsbyrootandname,j=i[h];void 0===j&&(j={},i[h]=j);for(var k=0;k!==e;++k){var l=d[k],m=l.name,n=j[m];if(void 0!==n)f[k]=n;else{if(n=f[k],void 0!==n){null===n._cacheindex&&(++n.referencecount,this._addinactivebinding(n,h,m));continue}var o=b&&b._propertybindings[k].binding.parsedpath;n=new wi(xi.create(c,m,o),l.valuetypename,l.getvaluesize()),++n.referencecount,this._addinactivebinding(n,h,m),f[k]=n}g[k].resultbuffer=n.buffer}},_activateaction:function(a){if(!this._isactiveaction(a)){if(null===a._cacheindex){var b=(a._localroot||this._root).uuid,c=a._clip.uuid,d=this._actionsbyclip[c];this._bindaction(a,d&&d.knownactions[0]),this._addinactiveaction(a,c,b)}for(var e=a._propertybindings,f=0,g=e.length;f!==g;++f){var h=e[f];0===h.usecount++&&(this._lendbinding(h),h.saveoriginalstate())}this._lendaction(a)}},_deactivateaction:function(a){if(this._isactiveaction(a)){for(var b=a._propertybindings,c=0,d=b.length;c!==d;++c){var e=b[c];0===--e.usecount&&(e.restoreoriginalstate(),this._takebackbinding(e))}this._takebackaction(a)}},_initmemorymanager:function(){this._actions=[],this._nactiveactions=0,this._actionsbyclip={},this._bindings=[],this._nactivebindings=0,this._bindingsbyrootandname={},this._controlinterpolants=[],this._nactivecontrolinterpolants=0;var a=this;this.stats={actions:{get total(){return a._actions.length},get inuse(){return a._nactiveactions}},bindings:{get total(){return a._bindings.length},get inuse(){return a._nactivebindings}},controlinterpolants:{get total(){return a._controlinterpolants.length},get inuse(){return a._nactivecontrolinterpolants}}}},_isactiveaction:function(a){var b=a._cacheindex;return null!==b&&b1){var j=i[1];d[j]||(d[j]={start:1/0,end:-(1/0)});var k=d[j];fk.end&&(k.end=f),c||(c=j)}}for(var j in d){var k=d[j];this.createanimation(j,k.start,k.end,a)}this.firstanimation=c},ni.prototype.setanimationdirectionforward=function(a){var b=this.animationsmap[a];b&&(b.direction=1,b.directionbackwards=!1)},ni.prototype.setanimationdirectionbackward=function(a){var b=this.animationsmap[a];b&&(b.direction=-1,b.directionbackwards=!0)},ni.prototype.setanimationfps=function(a,b){var c=this.animationsmap[a];c&&(c.fps=b,c.duration=(c.end-c.start)/c.fps)},ni.prototype.setanimationduration=function(a,b){var c=this.animationsmap[a];c&&(c.duration=b,c.fps=(c.end-c.start)/c.duration)},ni.prototype.setanimationweight=function(a,b){var c=this.animationsmap[a];c&&(c.weight=b)},ni.prototype.setanimationtime=function(a,b){var c=this.animationsmap[a];c&&(c.time=b)},ni.prototype.getanimationtime=function(a){var b=0,c=this.animationsmap[a];return c&&(b=c.time),b},ni.prototype.getanimationduration=function(a){var b=-1,c=this.animationsmap[a];return c&&(b=c.duration),b},ni.prototype.playanimation=function(a){var b=this.animationsmap[a];b?(b.time=0,b.active=!0):console.warn("three.morphblendmesh: animation["+a+"] undefined in .playanimation()")},ni.prototype.stopanimation=function(a){var b=this.animationsmap[a];b&&(b.active=!1)},ni.prototype.update=function(a){for(var b=0,c=this.animationslist.length;bd.duration||d.time<0)&&(d.direction*=-1,d.time>d.duration&&(d.time=d.duration,d.directionbackwards=!0),d.time<0&&(d.time=0,d.directionbackwards=!1)):(d.time=d.time%d.duration,d.time<0&&(d.time+=d.duration));var f=d.start+tb.clamp(math.floor(d.time/e),0,d.length-1),g=d.weight;f!==d.currentframe&&(this.morphtargetinfluences[d.lastframe]=0,this.morphtargetinfluences[d.currentframe]=1*g,this.morphtargetinfluences[f]=0,d.lastframe=d.currentframe,d.currentframe=f);var h=d.time%e/e;d.directionbackwards&&(h=1-h),d.currentframe!==d.lastframe?(this.morphtargetinfluences[d.currentframe]=h*g,this.morphtargetinfluences[d.lastframe]=(1-h)*g):this.morphtargetinfluences[d.currentframe]=g}}},oi.prototype=object.create(ne.prototype),oi.prototype.constructor=oi,oi.prototype.isimmediaterenderobject=!0,pi.prototype=object.create(bg.prototype),pi.prototype.constructor=pi,pi.prototype.update=function(){var a=new bb,b=new bb,c=new fe;return function(){var e=["a","b","c"];this.object.updatematrixworld(!0),c.getnormalmatrix(this.object.matrixworld);var f=this.object.matrixworld,g=this.geometry.attributes.position,h=this.object.geometry;if(h&&h.isgeometry)for(var i=h.vertices,j=h.faces,k=0,l=0,m=j.length;l.99999?this.quaternion.set(0,0,0,1):d.y<-.99999?this.quaternion.set(1,0,0,0):(a.set(d.z,0,-d.x).normalize(),b=math.acos(d.y),this.quaternion.setfromaxisangle(a,b))}}(),bj.prototype.setlength=function(a,b,c){void 0===b&&(b=.2*a),void 0===c&&(c=.2*b),this.line.scale.set(1,math.max(0,a-b),1),this.line.updatematrix(),this.cone.scale.set(c,b,c),this.cone.position.y=a,this.cone.updatematrix()},bj.prototype.setcolor=function(a){this.line.material.color.copy(a),this.cone.material.color.copy(a)},cj.prototype=object.create(bg.prototype),cj.prototype.constructor=cj;var ej=new bb,fj=new dj,gj=new dj,hj=new dj;ij.prototype=object.create(_h.prototype),ij.prototype.constructor=ij,ij.prototype.getpoint=function(a){var b=this.points,c=b.length;c<2&&console.log("duh, you need at least 2 points");var d=(c-(this.closed?0:1))*a,e=math.floor(d),f=d-e;this.closed?e+=e>0?0:(math.floor(math.abs(e)/b.length)+1)*b.length:0===f&&e===c-1&&(e=c-2,f=1);var g,h,i,j;if(this.closed||e>0?g=b[(e-1)%c]:(ej.subvectors(b[0],b[1]).add(b[0]),g=ej),h=b[e%c],i=b[(e+1)%c],this.closed||e+2=0&&f>=0&&g>=0&&h>=0||!(e<0&&f<0||g<0&&h<0)&&(e<0?c=math.max(c,e/(e-f)):f<0&&(d=math.min(d,e/(e-f))),g<0?c=math.max(c,g/(g-h)):h<0&&(d=math.min(d,g/(g-h))),!(d=-1&&d.x<=1&&d.y>=-1&&d.y<=1&&d.z>=-1&&d.z<=1}function k(a,b,c){e=m(),e.position.set(a,b,c),j(e)}function l(b,c,d){a.push(b,c,d)}function n(a,c){b.push(a,c)}function o(a,b,c){return a.visible===!0||b.visible===!0||c.visible===!0||(z[0]=a.positionscreen,z[1]=b.positionscreen,z[2]=c.positionscreen,x.intersectsbox(y.setfrompoints(z)))}function p(a,b,c){return(c.positionscreen.x-a.positionscreen.x)*(b.positionscreen.y-a.positionscreen.y)-(c.positionscreen.y-a.positionscreen.y)*(b.positionscreen.x-a.positionscreen.x)<0}function q(a,b){var d=g[a],e=g[b];m=o(),m.id=c.id,m.v1.copy(d),m.v2.copy(e),m.z=(d.positionscreen.z+e.positionscreen.z)/2,m.renderorder=c.renderorder,m.material=c.material,u.elements.push(m)}function r(e,h,j){var k=g[e],l=g[h],m=g[j];if(o(k,l,m)!==!1&&(d.side===three.doubleside||p(k,l,m)===!0)){i=n(),i.id=c.id,i.v1.copy(k),i.v2.copy(l),i.v3.copy(m),i.z=(k.positionscreen.z+l.positionscreen.z+m.positionscreen.z)/3,i.renderorder=c.renderorder,i.normalmodel.fromarray(a,3*e),i.normalmodel.applymatrix3(f).normalize();for(var n=0;n<3;n++){var q=i.vertexnormalsmodel[n];q.fromarray(a,3*arguments[n]),q.applymatrix3(f).normalize();var r=i.uvs[n];r.fromarray(b,2*arguments[n])}i.vertexnormalslength=3,i.material=c.material,u.elements.push(i)}}var a=[],b=[],c=null,d=null,f=new three.matrix3;return{setobject:h,projectvertex:j,checktrianglevisibility:o,checkbackfaceculling:p,pushvertex:k,pushnormal:l,pushuv:n,pushline:q,pushtriangle:r}},k=new j;this.projectscene=function(c,d,e,h){function k(b){a=l(),a.id=b.id,a.object=b,v.setfrommatrixposition(b.matrixworld),v.applymatrix4(c),a.z=v.z,a.renderorder=b.renderorder,u.objects.push(a)}j=0,n=0,r=0,u.elements.length=0,c.autoupdate===!0&&c.updatematrixworld(),null===d.parent&&d.updatematrixworld(),b.copy(d.matrixworldinverse.getinverse(d.matrixworld)),c.multiplymatrices(d.projectionmatrix,b),g.setfrommatrix(c),b=0,u.objects.length=0,u.lights.length=0,c.traversevisible(function(a){if(a instanceof three.light)u.lights.push(a);else if(a instanceof three.mesh||a instanceof three.line){if(a.material.visible===!1)return;if(a.frustumculled===!0&&g.intersectsobject(a)===!1)return;k(a)}else if(a instanceof three.sprite){if(a.material.visible===!1)return;if(a.frustumculled===!0&&g.intersectssprite(a)===!1)return;k(a)}}),e===!0&&u.objects.sort(q);for(var l=0,o=u.objects.length;l0)for(var u=0;u0||(pa=g[f-2],h.copy(oa.positionscreen),i.copy(pa.positionscreen),r(h,i)===!0&&(h.multiplyscalar(1/h.w),i.multiplyscalar(1/i.w),m=o(),m.id=p.id,m.v1.positionscreen.copy(h),m.v2.positionscreen.copy(i),m.z=math.max(h.z,i.z),m.renderorder=p.renderorder,m.material=p.material,p.material.vertexcolors===three.vertexcolors&&(m.vertexcolors[0].copy(p.geometry.colors[aa]),m.vertexcolors[1].copy(p.geometry.colors[aa-1])),u.elements.push(m)))}}else if(p instanceof three.sprite){w.set(d.elements[12],d.elements[13],d.elements[14],1),w.applymatrix4(c);var za=1/w.w;w.z*=za,w.z>=-1&&w.z<=1&&(q=p(),q.id=p.id,q.x=w.x*za,q.y=w.y*za,q.z=w.z,q.renderorder=p.renderorder,q.object=p,q.rotation=p.rotation,q.scale.x=p.scale.x*math.abs(q.x-(w.x+d.projectionmatrix.elements[0])/(w.w+d.projectionmatrix.elements[12])),q.scale.y=p.scale.y*math.abs(q.y-(w.y+d.projectionmatrix.elements[5])/(w.w+d.projectionmatrix.elements[13])),q.material=p.material,u.elements.push(q))}}return h===!0&&u.elements.sort(q),u}},three.spritecanvasmaterial=function(a){three.material.call(this),this.type="spritecanvasmaterial",this.color=new three.color(16777215),this.program=function(a,b){},this.setvalues(a)},three.spritecanvasmaterial.prototype=object.create(three.material.prototype),three.spritecanvasmaterial.prototype.constructor=three.spritecanvasmaterial,three.spritecanvasmaterial.prototype.clone=function(){var a=new three.spritecanvasmaterial;return a.copy(this),a.color.copy(this.color),a.program=this.program,a},three.canvasrenderer=function(a){function ta(){ma.setrgb(0,0,0),na.setrgb(0,0,0),oa.setrgb(0,0,0);for(var a=0,b=e.length;a0&&(ga(three.normalblending),fa(1),la("rgba("+math.floor(255*r.r)+","+math.floor(255*r.g)+","+math.floor(255*r.b)+","+s+")"),q.fillrect(0|ka.min.x,0|ka.max.y,ka.max.x-ka.min.x|0,ka.min.y-ka.max.y|0)),ka.makeempty())},this.clearcolor=function(){},this.cleardepth=function(){},this.clearstencil=function(){},this.render=function(a,g){if(g instanceof three.camera==!1)return void console.error("three.canvasrenderer.render: camera is not an instance of three.camera.");var p=a.background;p&&p.iscolor?(la("rgb("+math.floor(255*p.r)+","+math.floor(255*p.g)+","+math.floor(255*p.b)+")"),q.fillrect(0,0,h,i)):this.autoclear===!0&&this.clear(),b.info.render.vertices=0,b.info.render.faces=0,q.settransform(n/h,0,0,-o/i,l,i-m),q.translate(j,k),c=f.projectscene(a,g,this.sortobjects,this.sortelements),d=c.elements,e=c.lights,b=g,sa.getnormalmatrix(g.matrixworldinverse),ta();for(var r=0,s=d.length;r1)continue;if(d.positionscreen.z<-1||d.positionscreen.z>1)continue;if(e.positionscreen.z<-1||e.positionscreen.z>1)continue;c.positionscreen.x*=j,c.positionscreen.y*=k,d.positionscreen.x*=j,d.positionscreen.y*=k,e.positionscreen.x*=j,e.positionscreen.y*=k,u.overdraw>0&&(ea(c.positionscreen,d.positionscreen,u.overdraw),ea(d.positionscreen,e.positionscreen,u.overdraw),ea(e.positionscreen,c.positionscreen,u.overdraw)),la.setfrompoints([c.positionscreen,d.positionscreen,e.positionscreen]),ja.intersectsbox(la)===!0&&xa(c,d,e,0,1,2,t,u)}ka.union(la)}}q.settransform(1,0,0,1,0,0)}}; var separation = 100, amountx = 50, amounty = 50; var container; var camera, scene, renderer; var particles, particle, count = 0; var mousex = 0, mousey = 0; /*让canvas的宽高从父容器取到*/ var canvasbox = $('.canvas-box'); var canw = canvasbox.width(); var canh = canvasbox.height(); var windowhalfx = canw / 2; var windowhalfy = canh / 2; if($(window).width() > 800){ init(); animate(); } function init() { container = document.createelement('div'); canvasbox.append(container); camera = new three.perspectivecamera(100, window.innerwidth / window.innerheight, 1, 10000); camera.position.z = 1000; scene = new three.scene(); scene.background = new three.color(0xffffff); particles = new array(); var pi2 = math.pi * 2; var color = new three.color("rgb(183, 183, 183)"); //var color = new three.color("rgb(183, 183, 183)"); var material = new three.spritecanvasmaterial({ color: color, program: function(context) { context.beginpath(); context.arc(0, 0, 0.5, 0, pi2, true); context.fill(); } }); var i = 0; for (var ix = 0; ix < amountx; ix++) { for (var iy = 0; iy < amounty; iy++) { particle = particles[i++] = new three.sprite(material); particle.position.x = ix * separation - ((amountx * separation) / 2); particle.position.z = iy * separation - ((amounty * separation) / 2); scene.add(particle); } } renderer = new three.canvasrenderer(); renderer.setpixelratio(window.devicepixelratio); renderer.setsize(canw,canh); container.appendchild(renderer.domelement); document.addeventlistener('mousemove', ondocumentmousemove, false); //document.addeventlistener( 'touchstart', ondocumenttouchstart, false ); //document.addeventlistener( 'touchmove', ondocumenttouchmove, false ); // window.addeventlistener('resize', onwindowresize, false); } function onwindowresize() { windowhalfx = window.innerwidth / 2; windowhalfy = window.innerheight / 2; var canw = canvasbox.width(); var canh = canvasbox.height(); camera.aspect = canw / canh; camera.updateprojectionmatrix(); renderer.setsize(canw,canh); } // function ondocumentmousemove(event) { mousex = event.clientx - windowhalfx; mousey = event.clienty - windowhalfy; } function ondocumenttouchstart(event) { if (event.touches.length === 1) { event.preventdefault(); mousex = event.touches[0].pagex - windowhalfx; mousey = event.touches[0].pagey - windowhalfy; } } function ondocumenttouchmove(event) { if (event.touches.length === 1) { event.preventdefault(); mousex = event.touches[0].pagex - windowhalfx; mousey = event.touches[0].pagey - windowhalfy; } } // function animate() { requestanimationframe(animate); render(); } function render() { camera.position.x += (900 - camera.position.x) * .05; camera.position.y += (500 - camera.position.y) * .1; camera.lookat(scene.position); var i = 0; for (var ix = 0; ix < amountx; ix++) { for (var iy = 0; iy < amounty; iy++) { particle = particles[i++]; particle.position.y = (math.sin((ix + count) * 0.3) * 50) + (math.sin((iy + count) * 0.5) * 50); particle.scale.x = particle.scale.y = (math.sin((ix + count) * 0.3) + 1) * 4 + (math.sin((iy + count) * 0.5) + 1) * 4; } } renderer.render(scene, camera); count += 0.1; }