diff --git a/assets/index-MG_WyDfq.js b/assets/index-2eie-ZMi.js similarity index 96% rename from assets/index-MG_WyDfq.js rename to assets/index-2eie-ZMi.js index 59c0281..deb52fb 100644 --- a/assets/index-MG_WyDfq.js +++ b/assets/index-2eie-ZMi.js @@ -3434,7 +3434,7 @@ void main() { #include #include #include -}`,it={alphahash_fragment:kp,alphahash_pars_fragment:Hp,alphamap_fragment:Vp,alphamap_pars_fragment:Gp,alphatest_fragment:Wp,alphatest_pars_fragment:Xp,aomap_fragment:qp,aomap_pars_fragment:jp,batching_pars_vertex:Yp,batching_vertex:$p,begin_vertex:Kp,beginnormal_vertex:Zp,bsdfs:Jp,iridescence_fragment:Qp,bumpmap_pars_fragment:em,clipping_planes_fragment:tm,clipping_planes_pars_fragment:nm,clipping_planes_pars_vertex:im,clipping_planes_vertex:rm,color_fragment:sm,color_pars_fragment:om,color_pars_vertex:am,color_vertex:lm,common:cm,cube_uv_reflection_fragment:um,defaultnormal_vertex:hm,displacementmap_pars_vertex:fm,displacementmap_vertex:dm,emissivemap_fragment:pm,emissivemap_pars_fragment:mm,colorspace_fragment:_m,colorspace_pars_fragment:gm,envmap_fragment:vm,envmap_common_pars_fragment:xm,envmap_pars_fragment:ym,envmap_pars_vertex:bm,envmap_physical_pars_fragment:Im,envmap_vertex:Sm,fog_vertex:Em,fog_pars_vertex:wm,fog_fragment:Mm,fog_pars_fragment:Tm,gradientmap_pars_fragment:Am,lightmap_fragment:Rm,lightmap_pars_fragment:Lm,lights_lambert_fragment:Cm,lights_lambert_pars_fragment:Pm,lights_pars_begin:Dm,lights_toon_fragment:Nm,lights_toon_pars_fragment:Fm,lights_phong_fragment:Om,lights_phong_pars_fragment:Um,lights_physical_fragment:Bm,lights_physical_pars_fragment:zm,lights_fragment_begin:km,lights_fragment_maps:Hm,lights_fragment_end:Vm,logdepthbuf_fragment:Gm,logdepthbuf_pars_fragment:Wm,logdepthbuf_pars_vertex:Xm,logdepthbuf_vertex:qm,map_fragment:jm,map_pars_fragment:Ym,map_particle_fragment:$m,map_particle_pars_fragment:Km,metalnessmap_fragment:Zm,metalnessmap_pars_fragment:Jm,morphcolor_vertex:Qm,morphnormal_vertex:e_,morphtarget_pars_vertex:t_,morphtarget_vertex:n_,normal_fragment_begin:i_,normal_fragment_maps:r_,normal_pars_fragment:s_,normal_pars_vertex:o_,normal_vertex:a_,normalmap_pars_fragment:l_,clearcoat_normal_fragment_begin:c_,clearcoat_normal_fragment_maps:u_,clearcoat_pars_fragment:h_,iridescence_pars_fragment:f_,opaque_fragment:d_,packing:p_,premultiplied_alpha_fragment:m_,project_vertex:__,dithering_fragment:g_,dithering_pars_fragment:v_,roughnessmap_fragment:x_,roughnessmap_pars_fragment:y_,shadowmap_pars_fragment:b_,shadowmap_pars_vertex:S_,shadowmap_vertex:E_,shadowmask_pars_fragment:w_,skinbase_vertex:M_,skinning_pars_vertex:T_,skinning_vertex:A_,skinnormal_vertex:R_,specularmap_fragment:L_,specularmap_pars_fragment:C_,tonemapping_fragment:P_,tonemapping_pars_fragment:D_,transmission_fragment:I_,transmission_pars_fragment:N_,uv_pars_fragment:F_,uv_pars_vertex:O_,uv_vertex:U_,worldpos_vertex:B_,background_vert:z_,background_frag:k_,backgroundCube_vert:H_,backgroundCube_frag:V_,cube_vert:G_,cube_frag:W_,depth_vert:X_,depth_frag:q_,distanceRGBA_vert:j_,distanceRGBA_frag:Y_,equirect_vert:$_,equirect_frag:K_,linedashed_vert:Z_,linedashed_frag:J_,meshbasic_vert:Q_,meshbasic_frag:eg,meshlambert_vert:tg,meshlambert_frag:ng,meshmatcap_vert:ig,meshmatcap_frag:rg,meshnormal_vert:sg,meshnormal_frag:og,meshphong_vert:ag,meshphong_frag:lg,meshphysical_vert:cg,meshphysical_frag:ug,meshtoon_vert:hg,meshtoon_frag:fg,points_vert:dg,points_frag:pg,shadow_vert:mg,shadow_frag:_g,sprite_vert:gg,sprite_frag:vg},xe={common:{diffuse:{value:new tt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new st},alphaMap:{value:null},alphaMapTransform:{value:new st},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new st}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new st}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new st}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new st},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new st},normalScale:{value:new Ue(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new st},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new st}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new st}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new st}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new tt(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new tt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new st},alphaTest:{value:0},uvTransform:{value:new st}},sprite:{diffuse:{value:new tt(16777215)},opacity:{value:1},center:{value:new Ue(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new st},alphaMap:{value:null},alphaMapTransform:{value:new st},alphaTest:{value:0}}},ui={basic:{uniforms:mn([xe.common,xe.specularmap,xe.envmap,xe.aomap,xe.lightmap,xe.fog]),vertexShader:it.meshbasic_vert,fragmentShader:it.meshbasic_frag},lambert:{uniforms:mn([xe.common,xe.specularmap,xe.envmap,xe.aomap,xe.lightmap,xe.emissivemap,xe.bumpmap,xe.normalmap,xe.displacementmap,xe.fog,xe.lights,{emissive:{value:new tt(0)}}]),vertexShader:it.meshlambert_vert,fragmentShader:it.meshlambert_frag},phong:{uniforms:mn([xe.common,xe.specularmap,xe.envmap,xe.aomap,xe.lightmap,xe.emissivemap,xe.bumpmap,xe.normalmap,xe.displacementmap,xe.fog,xe.lights,{emissive:{value:new tt(0)},specular:{value:new tt(1118481)},shininess:{value:30}}]),vertexShader:it.meshphong_vert,fragmentShader:it.meshphong_frag},standard:{uniforms:mn([xe.common,xe.envmap,xe.aomap,xe.lightmap,xe.emissivemap,xe.bumpmap,xe.normalmap,xe.displacementmap,xe.roughnessmap,xe.metalnessmap,xe.fog,xe.lights,{emissive:{value:new tt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:it.meshphysical_vert,fragmentShader:it.meshphysical_frag},toon:{uniforms:mn([xe.common,xe.aomap,xe.lightmap,xe.emissivemap,xe.bumpmap,xe.normalmap,xe.displacementmap,xe.gradientmap,xe.fog,xe.lights,{emissive:{value:new tt(0)}}]),vertexShader:it.meshtoon_vert,fragmentShader:it.meshtoon_frag},matcap:{uniforms:mn([xe.common,xe.bumpmap,xe.normalmap,xe.displacementmap,xe.fog,{matcap:{value:null}}]),vertexShader:it.meshmatcap_vert,fragmentShader:it.meshmatcap_frag},points:{uniforms:mn([xe.points,xe.fog]),vertexShader:it.points_vert,fragmentShader:it.points_frag},dashed:{uniforms:mn([xe.common,xe.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:it.linedashed_vert,fragmentShader:it.linedashed_frag},depth:{uniforms:mn([xe.common,xe.displacementmap]),vertexShader:it.depth_vert,fragmentShader:it.depth_frag},normal:{uniforms:mn([xe.common,xe.bumpmap,xe.normalmap,xe.displacementmap,{opacity:{value:1}}]),vertexShader:it.meshnormal_vert,fragmentShader:it.meshnormal_frag},sprite:{uniforms:mn([xe.sprite,xe.fog]),vertexShader:it.sprite_vert,fragmentShader:it.sprite_frag},background:{uniforms:{uvTransform:{value:new st},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:it.background_vert,fragmentShader:it.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:it.backgroundCube_vert,fragmentShader:it.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:it.cube_vert,fragmentShader:it.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:it.equirect_vert,fragmentShader:it.equirect_frag},distanceRGBA:{uniforms:mn([xe.common,xe.displacementmap,{referencePosition:{value:new C},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:it.distanceRGBA_vert,fragmentShader:it.distanceRGBA_frag},shadow:{uniforms:mn([xe.lights,xe.fog,{color:{value:new tt(0)},opacity:{value:1}}]),vertexShader:it.shadow_vert,fragmentShader:it.shadow_frag}};ui.physical={uniforms:mn([ui.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new st},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new st},clearcoatNormalScale:{value:new Ue(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new st},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new st},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new st},sheen:{value:0},sheenColor:{value:new tt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new st},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new st},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new st},transmissionSamplerSize:{value:new Ue},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new st},attenuationDistance:{value:0},attenuationColor:{value:new tt(0)},specularColor:{value:new tt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new st},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new st},anisotropyVector:{value:new Ue},anisotropyMap:{value:null},anisotropyMapTransform:{value:new st}}]),vertexShader:it.meshphysical_vert,fragmentShader:it.meshphysical_frag};const Lo={r:0,b:0,g:0};function xg(r,e,t,n,i,s,o){const a=new tt(0);let l=s===!0?0:1,c,u,f=null,h=0,p=null;function _(m,d){let x=!1,v=d.isScene===!0?d.background:null;v&&v.isTexture&&(v=(d.backgroundBlurriness>0?t:e).get(v)),v===null?g(a,l):v&&v.isColor&&(g(v,1),x=!0);const y=r.xr.getEnvironmentBlendMode();y==="additive"?n.buffers.color.setClear(0,0,0,1,o):y==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,o),(r.autoClear||x)&&r.clear(r.autoClearColor,r.autoClearDepth,r.autoClearStencil),v&&(v.isCubeTexture||v.mapping===ga)?(u===void 0&&(u=new Mn(new so(1,1,1),new Ki({name:"BackgroundCubeMaterial",uniforms:ps(ui.backgroundCube.uniforms),vertexShader:ui.backgroundCube.vertexShader,fragmentShader:ui.backgroundCube.fragmentShader,side:xn,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(b,M,T){this.matrixWorld.copyPosition(T.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(u)),u.material.uniforms.envMap.value=v,u.material.uniforms.flipEnvMap.value=v.isCubeTexture&&v.isRenderTargetTexture===!1?-1:1,u.material.uniforms.backgroundBlurriness.value=d.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=d.backgroundIntensity,u.material.toneMapped=pt.getTransfer(v.colorSpace)!==At,(f!==v||h!==v.version||p!==r.toneMapping)&&(u.material.needsUpdate=!0,f=v,h=v.version,p=r.toneMapping),u.layers.enableAll(),m.unshift(u,u.geometry,u.material,0,0,null)):v&&v.isTexture&&(c===void 0&&(c=new Mn(new ic(2,2),new Ki({name:"BackgroundMaterial",uniforms:ps(ui.background.uniforms),vertexShader:ui.background.vertexShader,fragmentShader:ui.background.fragmentShader,side:ei,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(c)),c.material.uniforms.t2D.value=v,c.material.uniforms.backgroundIntensity.value=d.backgroundIntensity,c.material.toneMapped=pt.getTransfer(v.colorSpace)!==At,v.matrixAutoUpdate===!0&&v.updateMatrix(),c.material.uniforms.uvTransform.value.copy(v.matrix),(f!==v||h!==v.version||p!==r.toneMapping)&&(c.material.needsUpdate=!0,f=v,h=v.version,p=r.toneMapping),c.layers.enableAll(),m.unshift(c,c.geometry,c.material,0,0,null))}function g(m,d){m.getRGB(Lo,bf(r)),n.buffers.color.setClear(Lo.r,Lo.g,Lo.b,d,o)}return{getClearColor:function(){return a},setClearColor:function(m,d=1){a.set(m),l=d,g(a,l)},getClearAlpha:function(){return l},setClearAlpha:function(m){l=m,g(a,l)},render:_}}function yg(r,e,t,n){const i=r.getParameter(r.MAX_VERTEX_ATTRIBS),s=n.isWebGL2?null:e.get("OES_vertex_array_object"),o=n.isWebGL2||s!==null,a={},l=m(null);let c=l,u=!1;function f(D,V,Z,J,ce){let ie=!1;if(o){const se=g(J,Z,V);c!==se&&(c=se,p(c.object)),ie=d(D,J,Z,ce),ie&&x(D,J,Z,ce)}else{const se=V.wireframe===!0;(c.geometry!==J.id||c.program!==Z.id||c.wireframe!==se)&&(c.geometry=J.id,c.program=Z.id,c.wireframe=se,ie=!0)}ce!==null&&t.update(ce,r.ELEMENT_ARRAY_BUFFER),(ie||u)&&(u=!1,I(D,V,Z,J),ce!==null&&r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,t.get(ce).buffer))}function h(){return n.isWebGL2?r.createVertexArray():s.createVertexArrayOES()}function p(D){return n.isWebGL2?r.bindVertexArray(D):s.bindVertexArrayOES(D)}function _(D){return n.isWebGL2?r.deleteVertexArray(D):s.deleteVertexArrayOES(D)}function g(D,V,Z){const J=Z.wireframe===!0;let ce=a[D.id];ce===void 0&&(ce={},a[D.id]=ce);let ie=ce[V.id];ie===void 0&&(ie={},ce[V.id]=ie);let se=ie[J];return se===void 0&&(se=m(h()),ie[J]=se),se}function m(D){const V=[],Z=[],J=[];for(let ce=0;ce=0){const oe=ce[ve];let Se=ie[ve];if(Se===void 0&&(ve==="instanceMatrix"&&D.instanceMatrix&&(Se=D.instanceMatrix),ve==="instanceColor"&&D.instanceColor&&(Se=D.instanceColor)),oe===void 0||oe.attribute!==Se||Se&&oe.data!==Se.data)return!0;se++}return c.attributesNum!==se||c.index!==J}function x(D,V,Z,J){const ce={},ie=V.attributes;let se=0;const me=Z.getAttributes();for(const ve in me)if(me[ve].location>=0){let oe=ie[ve];oe===void 0&&(ve==="instanceMatrix"&&D.instanceMatrix&&(oe=D.instanceMatrix),ve==="instanceColor"&&D.instanceColor&&(oe=D.instanceColor));const Se={};Se.attribute=oe,oe&&oe.data&&(Se.data=oe.data),ce[ve]=Se,se++}c.attributes=ce,c.attributesNum=se,c.index=J}function v(){const D=c.newAttributes;for(let V=0,Z=D.length;V=0){let Q=ce[me];if(Q===void 0&&(me==="instanceMatrix"&&D.instanceMatrix&&(Q=D.instanceMatrix),me==="instanceColor"&&D.instanceColor&&(Q=D.instanceColor)),Q!==void 0){const oe=Q.normalized,Se=Q.itemSize,De=t.get(Q);if(De===void 0)continue;const _e=De.buffer,qe=De.type,We=De.bytesPerElement,Fe=n.isWebGL2===!0&&(qe===r.INT||qe===r.UNSIGNED_INT||Q.gpuType===Ws);if(Q.isInterleavedBufferAttribute){const Ye=Q.data,X=Ye.stride,Lt=Q.offset;if(Ye.isInstancedInterleavedBuffer){for(let Le=0;Le0&&r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT).precision>0)return"highp";T="mediump"}return T==="mediump"&&r.getShaderPrecisionFormat(r.VERTEX_SHADER,r.MEDIUM_FLOAT).precision>0&&r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}const o=typeof WebGL2RenderingContext<"u"&&r.constructor.name==="WebGL2RenderingContext";let a=t.precision!==void 0?t.precision:"highp";const l=s(a);l!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",l,"instead."),a=l);const c=o||e.has("WEBGL_draw_buffers"),u=t.logarithmicDepthBuffer===!0,f=r.getParameter(r.MAX_TEXTURE_IMAGE_UNITS),h=r.getParameter(r.MAX_VERTEX_TEXTURE_IMAGE_UNITS),p=r.getParameter(r.MAX_TEXTURE_SIZE),_=r.getParameter(r.MAX_CUBE_MAP_TEXTURE_SIZE),g=r.getParameter(r.MAX_VERTEX_ATTRIBS),m=r.getParameter(r.MAX_VERTEX_UNIFORM_VECTORS),d=r.getParameter(r.MAX_VARYING_VECTORS),x=r.getParameter(r.MAX_FRAGMENT_UNIFORM_VECTORS),v=h>0,y=o||e.has("OES_texture_float"),b=v&&y,M=o?r.getParameter(r.MAX_SAMPLES):0;return{isWebGL2:o,drawBuffers:c,getMaxAnisotropy:i,getMaxPrecision:s,precision:a,logarithmicDepthBuffer:u,maxTextures:f,maxVertexTextures:h,maxTextureSize:p,maxCubemapSize:_,maxAttributes:g,maxVertexUniforms:m,maxVaryings:d,maxFragmentUniforms:x,vertexTextures:v,floatFragmentTextures:y,floatVertexTextures:b,maxSamples:M}}function Eg(r){const e=this;let t=null,n=0,i=!1,s=!1;const o=new ci,a=new st,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(f,h){const p=f.length!==0||h||n!==0||i;return i=h,n=f.length,p},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(f,h){t=u(f,h,0)},this.setState=function(f,h,p){const _=f.clippingPlanes,g=f.clipIntersection,m=f.clipShadows,d=r.get(f);if(!i||_===null||_.length===0||s&&!m)s?u(null):c();else{const x=s?0:n,v=x*4;let y=d.clippingState||null;l.value=y,y=u(_,h,v,p);for(let b=0;b!==v;++b)y[b]=t[b];d.clippingState=y,this.numIntersection=g?this.numPlanes:0,this.numPlanes+=x}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function u(f,h,p,_){const g=f!==null?f.length:0;let m=null;if(g!==0){if(m=l.value,_!==!0||m===null){const d=p+g*4,x=h.matrixWorldInverse;a.getNormalMatrix(x),(m===null||m.length0){const c=new Op(l.height/2);return c.fromEquirectangularTexture(r,o),e.set(o,c),o.addEventListener("dispose",i),t(c.texture,o.mapping)}else return null}}return o}function i(o){const a=o.target;a.removeEventListener("dispose",i);const l=e.get(a);l!==void 0&&(e.delete(a),l.dispose())}function s(){e=new WeakMap}return{get:n,dispose:s}}class oo extends Sf{constructor(e=-1,t=1,n=1,i=-1,s=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=i,this.near=s,this.far=o,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,i,s,o){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let s=n-e,o=n+e,a=i+t,l=i-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,o=s+c*this.view.width,a-=u*this.view.offsetY,l=a-u*this.view.height}this.projectionMatrix.makeOrthographic(s,o,a,l,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}const ns=4,Mu=[.125,.215,.35,.446,.526,.582],hr=20,Ja=new oo,Tu=new tt;let Qa=null,el=0,tl=0;const lr=(1+Math.sqrt(5))/2,Vr=1/lr,Au=[new C(1,1,1),new C(-1,1,1),new C(1,1,-1),new C(-1,1,-1),new C(0,lr,Vr),new C(0,lr,-Vr),new C(Vr,0,lr),new C(-Vr,0,lr),new C(lr,Vr,0),new C(-lr,Vr,0)];class Ru{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,i=100){Qa=this._renderer.getRenderTarget(),el=this._renderer.getActiveCubeFace(),tl=this._renderer.getActiveMipmapLevel(),this._setSize(256);const s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(e,n,i,s),t>0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Pu(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Cu(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?v:0,v,v),u.setRenderTarget(i),g&&u.render(_,a),u.render(e,a)}_.geometry.dispose(),_.material.dispose(),u.toneMapping=h,u.autoClear=f,e.background=m}_textureToCubeUV(e,t){const n=this._renderer,i=e.mapping===ls||e.mapping===cs;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=Pu()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Cu());const s=i?this._cubemapMaterial:this._equirectMaterial,o=new Mn(this._lodPlanes[0],s),a=s.uniforms;a.envMap.value=e;const l=this._cubeSize;Co(t,0,0,3*l,2*l),n.setRenderTarget(t),n.render(o,Ja)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;for(let i=1;ihr&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${hr}`);const d=[];let x=0;for(let T=0;Tv-ns?i-v+ns:0),M=4*(this._cubeSize-y);Co(t,b,M,3*y,2*y),l.setRenderTarget(t),l.render(f,Ja)}}function Mg(r){const e=[],t=[],n=[];let i=r;const s=r-ns+1+Mu.length;for(let o=0;or-ns?l=Mu[o-r+ns-1]:o===0&&(l=0),n.push(l);const c=1/(a-2),u=-c,f=1+c,h=[u,u,f,u,f,f,u,u,f,f,u,f],p=6,_=6,g=3,m=2,d=1,x=new Float32Array(g*_*p),v=new Float32Array(m*_*p),y=new Float32Array(d*_*p);for(let M=0;M2?0:-1,S=[T,I,0,T+2/3,I,0,T+2/3,I+1,0,T,I,0,T+2/3,I+1,0,T,I+1,0];x.set(S,g*_*M),v.set(h,m*_*M);const A=[M,M,M,M,M,M];y.set(A,d*_*M)}const b=new yn;b.setAttribute("position",new Yt(x,g)),b.setAttribute("uv",new Yt(v,m)),b.setAttribute("faceIndex",new Yt(y,d)),e.push(b),i>ns&&i--}return{lodPlanes:e,sizeLods:t,sigmas:n}}function Lu(r,e,t){const n=new $i(r,e,t);return n.texture.mapping=ga,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Co(r,e,t,n,i){r.viewport.set(e,t,n,i),r.scissor.set(e,t,n,i)}function Tg(r,e,t){const n=new Float32Array(hr),i=new C(0,1,0);return new Ki({name:"SphericalGaussianBlur",defines:{n:hr,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${r}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:rc(),fragmentShader:` +}`,it={alphahash_fragment:kp,alphahash_pars_fragment:Hp,alphamap_fragment:Vp,alphamap_pars_fragment:Gp,alphatest_fragment:Wp,alphatest_pars_fragment:Xp,aomap_fragment:qp,aomap_pars_fragment:jp,batching_pars_vertex:Yp,batching_vertex:$p,begin_vertex:Kp,beginnormal_vertex:Zp,bsdfs:Jp,iridescence_fragment:Qp,bumpmap_pars_fragment:em,clipping_planes_fragment:tm,clipping_planes_pars_fragment:nm,clipping_planes_pars_vertex:im,clipping_planes_vertex:rm,color_fragment:sm,color_pars_fragment:om,color_pars_vertex:am,color_vertex:lm,common:cm,cube_uv_reflection_fragment:um,defaultnormal_vertex:hm,displacementmap_pars_vertex:fm,displacementmap_vertex:dm,emissivemap_fragment:pm,emissivemap_pars_fragment:mm,colorspace_fragment:_m,colorspace_pars_fragment:gm,envmap_fragment:vm,envmap_common_pars_fragment:xm,envmap_pars_fragment:ym,envmap_pars_vertex:bm,envmap_physical_pars_fragment:Im,envmap_vertex:Sm,fog_vertex:Em,fog_pars_vertex:wm,fog_fragment:Mm,fog_pars_fragment:Tm,gradientmap_pars_fragment:Am,lightmap_fragment:Rm,lightmap_pars_fragment:Lm,lights_lambert_fragment:Cm,lights_lambert_pars_fragment:Pm,lights_pars_begin:Dm,lights_toon_fragment:Nm,lights_toon_pars_fragment:Fm,lights_phong_fragment:Om,lights_phong_pars_fragment:Um,lights_physical_fragment:Bm,lights_physical_pars_fragment:zm,lights_fragment_begin:km,lights_fragment_maps:Hm,lights_fragment_end:Vm,logdepthbuf_fragment:Gm,logdepthbuf_pars_fragment:Wm,logdepthbuf_pars_vertex:Xm,logdepthbuf_vertex:qm,map_fragment:jm,map_pars_fragment:Ym,map_particle_fragment:$m,map_particle_pars_fragment:Km,metalnessmap_fragment:Zm,metalnessmap_pars_fragment:Jm,morphcolor_vertex:Qm,morphnormal_vertex:e_,morphtarget_pars_vertex:t_,morphtarget_vertex:n_,normal_fragment_begin:i_,normal_fragment_maps:r_,normal_pars_fragment:s_,normal_pars_vertex:o_,normal_vertex:a_,normalmap_pars_fragment:l_,clearcoat_normal_fragment_begin:c_,clearcoat_normal_fragment_maps:u_,clearcoat_pars_fragment:h_,iridescence_pars_fragment:f_,opaque_fragment:d_,packing:p_,premultiplied_alpha_fragment:m_,project_vertex:__,dithering_fragment:g_,dithering_pars_fragment:v_,roughnessmap_fragment:x_,roughnessmap_pars_fragment:y_,shadowmap_pars_fragment:b_,shadowmap_pars_vertex:S_,shadowmap_vertex:E_,shadowmask_pars_fragment:w_,skinbase_vertex:M_,skinning_pars_vertex:T_,skinning_vertex:A_,skinnormal_vertex:R_,specularmap_fragment:L_,specularmap_pars_fragment:C_,tonemapping_fragment:P_,tonemapping_pars_fragment:D_,transmission_fragment:I_,transmission_pars_fragment:N_,uv_pars_fragment:F_,uv_pars_vertex:O_,uv_vertex:U_,worldpos_vertex:B_,background_vert:z_,background_frag:k_,backgroundCube_vert:H_,backgroundCube_frag:V_,cube_vert:G_,cube_frag:W_,depth_vert:X_,depth_frag:q_,distanceRGBA_vert:j_,distanceRGBA_frag:Y_,equirect_vert:$_,equirect_frag:K_,linedashed_vert:Z_,linedashed_frag:J_,meshbasic_vert:Q_,meshbasic_frag:eg,meshlambert_vert:tg,meshlambert_frag:ng,meshmatcap_vert:ig,meshmatcap_frag:rg,meshnormal_vert:sg,meshnormal_frag:og,meshphong_vert:ag,meshphong_frag:lg,meshphysical_vert:cg,meshphysical_frag:ug,meshtoon_vert:hg,meshtoon_frag:fg,points_vert:dg,points_frag:pg,shadow_vert:mg,shadow_frag:_g,sprite_vert:gg,sprite_frag:vg},xe={common:{diffuse:{value:new tt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new st},alphaMap:{value:null},alphaMapTransform:{value:new st},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new st}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new st}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new st}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new st},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new st},normalScale:{value:new Ue(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new st},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new st}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new st}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new st}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new tt(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new tt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new st},alphaTest:{value:0},uvTransform:{value:new st}},sprite:{diffuse:{value:new tt(16777215)},opacity:{value:1},center:{value:new Ue(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new st},alphaMap:{value:null},alphaMapTransform:{value:new st},alphaTest:{value:0}}},ui={basic:{uniforms:mn([xe.common,xe.specularmap,xe.envmap,xe.aomap,xe.lightmap,xe.fog]),vertexShader:it.meshbasic_vert,fragmentShader:it.meshbasic_frag},lambert:{uniforms:mn([xe.common,xe.specularmap,xe.envmap,xe.aomap,xe.lightmap,xe.emissivemap,xe.bumpmap,xe.normalmap,xe.displacementmap,xe.fog,xe.lights,{emissive:{value:new tt(0)}}]),vertexShader:it.meshlambert_vert,fragmentShader:it.meshlambert_frag},phong:{uniforms:mn([xe.common,xe.specularmap,xe.envmap,xe.aomap,xe.lightmap,xe.emissivemap,xe.bumpmap,xe.normalmap,xe.displacementmap,xe.fog,xe.lights,{emissive:{value:new tt(0)},specular:{value:new tt(1118481)},shininess:{value:30}}]),vertexShader:it.meshphong_vert,fragmentShader:it.meshphong_frag},standard:{uniforms:mn([xe.common,xe.envmap,xe.aomap,xe.lightmap,xe.emissivemap,xe.bumpmap,xe.normalmap,xe.displacementmap,xe.roughnessmap,xe.metalnessmap,xe.fog,xe.lights,{emissive:{value:new tt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:it.meshphysical_vert,fragmentShader:it.meshphysical_frag},toon:{uniforms:mn([xe.common,xe.aomap,xe.lightmap,xe.emissivemap,xe.bumpmap,xe.normalmap,xe.displacementmap,xe.gradientmap,xe.fog,xe.lights,{emissive:{value:new tt(0)}}]),vertexShader:it.meshtoon_vert,fragmentShader:it.meshtoon_frag},matcap:{uniforms:mn([xe.common,xe.bumpmap,xe.normalmap,xe.displacementmap,xe.fog,{matcap:{value:null}}]),vertexShader:it.meshmatcap_vert,fragmentShader:it.meshmatcap_frag},points:{uniforms:mn([xe.points,xe.fog]),vertexShader:it.points_vert,fragmentShader:it.points_frag},dashed:{uniforms:mn([xe.common,xe.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:it.linedashed_vert,fragmentShader:it.linedashed_frag},depth:{uniforms:mn([xe.common,xe.displacementmap]),vertexShader:it.depth_vert,fragmentShader:it.depth_frag},normal:{uniforms:mn([xe.common,xe.bumpmap,xe.normalmap,xe.displacementmap,{opacity:{value:1}}]),vertexShader:it.meshnormal_vert,fragmentShader:it.meshnormal_frag},sprite:{uniforms:mn([xe.sprite,xe.fog]),vertexShader:it.sprite_vert,fragmentShader:it.sprite_frag},background:{uniforms:{uvTransform:{value:new st},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:it.background_vert,fragmentShader:it.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:it.backgroundCube_vert,fragmentShader:it.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:it.cube_vert,fragmentShader:it.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:it.equirect_vert,fragmentShader:it.equirect_frag},distanceRGBA:{uniforms:mn([xe.common,xe.displacementmap,{referencePosition:{value:new C},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:it.distanceRGBA_vert,fragmentShader:it.distanceRGBA_frag},shadow:{uniforms:mn([xe.lights,xe.fog,{color:{value:new tt(0)},opacity:{value:1}}]),vertexShader:it.shadow_vert,fragmentShader:it.shadow_frag}};ui.physical={uniforms:mn([ui.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new st},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new st},clearcoatNormalScale:{value:new Ue(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new st},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new st},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new st},sheen:{value:0},sheenColor:{value:new tt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new st},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new st},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new st},transmissionSamplerSize:{value:new Ue},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new st},attenuationDistance:{value:0},attenuationColor:{value:new tt(0)},specularColor:{value:new tt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new st},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new st},anisotropyVector:{value:new Ue},anisotropyMap:{value:null},anisotropyMapTransform:{value:new st}}]),vertexShader:it.meshphysical_vert,fragmentShader:it.meshphysical_frag};const Lo={r:0,b:0,g:0};function xg(r,e,t,n,i,s,o){const a=new tt(0);let l=s===!0?0:1,c,u,f=null,h=0,p=null;function _(m,d){let x=!1,v=d.isScene===!0?d.background:null;v&&v.isTexture&&(v=(d.backgroundBlurriness>0?t:e).get(v)),v===null?g(a,l):v&&v.isColor&&(g(v,1),x=!0);const y=r.xr.getEnvironmentBlendMode();y==="additive"?n.buffers.color.setClear(0,0,0,1,o):y==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,o),(r.autoClear||x)&&r.clear(r.autoClearColor,r.autoClearDepth,r.autoClearStencil),v&&(v.isCubeTexture||v.mapping===ga)?(u===void 0&&(u=new Mn(new so(1,1,1),new Ki({name:"BackgroundCubeMaterial",uniforms:ps(ui.backgroundCube.uniforms),vertexShader:ui.backgroundCube.vertexShader,fragmentShader:ui.backgroundCube.fragmentShader,side:xn,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(b,M,T){this.matrixWorld.copyPosition(T.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(u)),u.material.uniforms.envMap.value=v,u.material.uniforms.flipEnvMap.value=v.isCubeTexture&&v.isRenderTargetTexture===!1?-1:1,u.material.uniforms.backgroundBlurriness.value=d.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=d.backgroundIntensity,u.material.toneMapped=pt.getTransfer(v.colorSpace)!==At,(f!==v||h!==v.version||p!==r.toneMapping)&&(u.material.needsUpdate=!0,f=v,h=v.version,p=r.toneMapping),u.layers.enableAll(),m.unshift(u,u.geometry,u.material,0,0,null)):v&&v.isTexture&&(c===void 0&&(c=new Mn(new ic(2,2),new Ki({name:"BackgroundMaterial",uniforms:ps(ui.background.uniforms),vertexShader:ui.background.vertexShader,fragmentShader:ui.background.fragmentShader,side:ei,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(c)),c.material.uniforms.t2D.value=v,c.material.uniforms.backgroundIntensity.value=d.backgroundIntensity,c.material.toneMapped=pt.getTransfer(v.colorSpace)!==At,v.matrixAutoUpdate===!0&&v.updateMatrix(),c.material.uniforms.uvTransform.value.copy(v.matrix),(f!==v||h!==v.version||p!==r.toneMapping)&&(c.material.needsUpdate=!0,f=v,h=v.version,p=r.toneMapping),c.layers.enableAll(),m.unshift(c,c.geometry,c.material,0,0,null))}function g(m,d){m.getRGB(Lo,bf(r)),n.buffers.color.setClear(Lo.r,Lo.g,Lo.b,d,o)}return{getClearColor:function(){return a},setClearColor:function(m,d=1){a.set(m),l=d,g(a,l)},getClearAlpha:function(){return l},setClearAlpha:function(m){l=m,g(a,l)},render:_}}function yg(r,e,t,n){const i=r.getParameter(r.MAX_VERTEX_ATTRIBS),s=n.isWebGL2?null:e.get("OES_vertex_array_object"),o=n.isWebGL2||s!==null,a={},l=m(null);let c=l,u=!1;function f(D,V,Z,J,ce){let ie=!1;if(o){const se=g(J,Z,V);c!==se&&(c=se,p(c.object)),ie=d(D,J,Z,ce),ie&&x(D,J,Z,ce)}else{const se=V.wireframe===!0;(c.geometry!==J.id||c.program!==Z.id||c.wireframe!==se)&&(c.geometry=J.id,c.program=Z.id,c.wireframe=se,ie=!0)}ce!==null&&t.update(ce,r.ELEMENT_ARRAY_BUFFER),(ie||u)&&(u=!1,I(D,V,Z,J),ce!==null&&r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,t.get(ce).buffer))}function h(){return n.isWebGL2?r.createVertexArray():s.createVertexArrayOES()}function p(D){return n.isWebGL2?r.bindVertexArray(D):s.bindVertexArrayOES(D)}function _(D){return n.isWebGL2?r.deleteVertexArray(D):s.deleteVertexArrayOES(D)}function g(D,V,Z){const J=Z.wireframe===!0;let ce=a[D.id];ce===void 0&&(ce={},a[D.id]=ce);let ie=ce[V.id];ie===void 0&&(ie={},ce[V.id]=ie);let se=ie[J];return se===void 0&&(se=m(h()),ie[J]=se),se}function m(D){const V=[],Z=[],J=[];for(let ce=0;ce=0){const oe=ce[ve];let Se=ie[ve];if(Se===void 0&&(ve==="instanceMatrix"&&D.instanceMatrix&&(Se=D.instanceMatrix),ve==="instanceColor"&&D.instanceColor&&(Se=D.instanceColor)),oe===void 0||oe.attribute!==Se||Se&&oe.data!==Se.data)return!0;se++}return c.attributesNum!==se||c.index!==J}function x(D,V,Z,J){const ce={},ie=V.attributes;let se=0;const me=Z.getAttributes();for(const ve in me)if(me[ve].location>=0){let oe=ie[ve];oe===void 0&&(ve==="instanceMatrix"&&D.instanceMatrix&&(oe=D.instanceMatrix),ve==="instanceColor"&&D.instanceColor&&(oe=D.instanceColor));const Se={};Se.attribute=oe,oe&&oe.data&&(Se.data=oe.data),ce[ve]=Se,se++}c.attributes=ce,c.attributesNum=se,c.index=J}function v(){const D=c.newAttributes;for(let V=0,Z=D.length;V=0){let Q=ce[me];if(Q===void 0&&(me==="instanceMatrix"&&D.instanceMatrix&&(Q=D.instanceMatrix),me==="instanceColor"&&D.instanceColor&&(Q=D.instanceColor)),Q!==void 0){const oe=Q.normalized,Se=Q.itemSize,De=t.get(Q);if(De===void 0)continue;const _e=De.buffer,qe=De.type,We=De.bytesPerElement,Fe=n.isWebGL2===!0&&(qe===r.INT||qe===r.UNSIGNED_INT||Q.gpuType===Ws);if(Q.isInterleavedBufferAttribute){const Ye=Q.data,X=Ye.stride,Lt=Q.offset;if(Ye.isInstancedInterleavedBuffer){for(let Ce=0;Ce0&&r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT).precision>0)return"highp";T="mediump"}return T==="mediump"&&r.getShaderPrecisionFormat(r.VERTEX_SHADER,r.MEDIUM_FLOAT).precision>0&&r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}const o=typeof WebGL2RenderingContext<"u"&&r.constructor.name==="WebGL2RenderingContext";let a=t.precision!==void 0?t.precision:"highp";const l=s(a);l!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",l,"instead."),a=l);const c=o||e.has("WEBGL_draw_buffers"),u=t.logarithmicDepthBuffer===!0,f=r.getParameter(r.MAX_TEXTURE_IMAGE_UNITS),h=r.getParameter(r.MAX_VERTEX_TEXTURE_IMAGE_UNITS),p=r.getParameter(r.MAX_TEXTURE_SIZE),_=r.getParameter(r.MAX_CUBE_MAP_TEXTURE_SIZE),g=r.getParameter(r.MAX_VERTEX_ATTRIBS),m=r.getParameter(r.MAX_VERTEX_UNIFORM_VECTORS),d=r.getParameter(r.MAX_VARYING_VECTORS),x=r.getParameter(r.MAX_FRAGMENT_UNIFORM_VECTORS),v=h>0,y=o||e.has("OES_texture_float"),b=v&&y,M=o?r.getParameter(r.MAX_SAMPLES):0;return{isWebGL2:o,drawBuffers:c,getMaxAnisotropy:i,getMaxPrecision:s,precision:a,logarithmicDepthBuffer:u,maxTextures:f,maxVertexTextures:h,maxTextureSize:p,maxCubemapSize:_,maxAttributes:g,maxVertexUniforms:m,maxVaryings:d,maxFragmentUniforms:x,vertexTextures:v,floatFragmentTextures:y,floatVertexTextures:b,maxSamples:M}}function Eg(r){const e=this;let t=null,n=0,i=!1,s=!1;const o=new ci,a=new st,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(f,h){const p=f.length!==0||h||n!==0||i;return i=h,n=f.length,p},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(f,h){t=u(f,h,0)},this.setState=function(f,h,p){const _=f.clippingPlanes,g=f.clipIntersection,m=f.clipShadows,d=r.get(f);if(!i||_===null||_.length===0||s&&!m)s?u(null):c();else{const x=s?0:n,v=x*4;let y=d.clippingState||null;l.value=y,y=u(_,h,v,p);for(let b=0;b!==v;++b)y[b]=t[b];d.clippingState=y,this.numIntersection=g?this.numPlanes:0,this.numPlanes+=x}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function u(f,h,p,_){const g=f!==null?f.length:0;let m=null;if(g!==0){if(m=l.value,_!==!0||m===null){const d=p+g*4,x=h.matrixWorldInverse;a.getNormalMatrix(x),(m===null||m.length0){const c=new Op(l.height/2);return c.fromEquirectangularTexture(r,o),e.set(o,c),o.addEventListener("dispose",i),t(c.texture,o.mapping)}else return null}}return o}function i(o){const a=o.target;a.removeEventListener("dispose",i);const l=e.get(a);l!==void 0&&(e.delete(a),l.dispose())}function s(){e=new WeakMap}return{get:n,dispose:s}}class oo extends Sf{constructor(e=-1,t=1,n=1,i=-1,s=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=i,this.near=s,this.far=o,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,i,s,o){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let s=n-e,o=n+e,a=i+t,l=i-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,o=s+c*this.view.width,a-=u*this.view.offsetY,l=a-u*this.view.height}this.projectionMatrix.makeOrthographic(s,o,a,l,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}const ns=4,Mu=[.125,.215,.35,.446,.526,.582],hr=20,Ja=new oo,Tu=new tt;let Qa=null,el=0,tl=0;const lr=(1+Math.sqrt(5))/2,Vr=1/lr,Au=[new C(1,1,1),new C(-1,1,1),new C(1,1,-1),new C(-1,1,-1),new C(0,lr,Vr),new C(0,lr,-Vr),new C(Vr,0,lr),new C(-Vr,0,lr),new C(lr,Vr,0),new C(-lr,Vr,0)];class Ru{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,i=100){Qa=this._renderer.getRenderTarget(),el=this._renderer.getActiveCubeFace(),tl=this._renderer.getActiveMipmapLevel(),this._setSize(256);const s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(e,n,i,s),t>0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Pu(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Cu(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?v:0,v,v),u.setRenderTarget(i),g&&u.render(_,a),u.render(e,a)}_.geometry.dispose(),_.material.dispose(),u.toneMapping=h,u.autoClear=f,e.background=m}_textureToCubeUV(e,t){const n=this._renderer,i=e.mapping===ls||e.mapping===cs;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=Pu()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Cu());const s=i?this._cubemapMaterial:this._equirectMaterial,o=new Mn(this._lodPlanes[0],s),a=s.uniforms;a.envMap.value=e;const l=this._cubeSize;Co(t,0,0,3*l,2*l),n.setRenderTarget(t),n.render(o,Ja)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;for(let i=1;ihr&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${hr}`);const d=[];let x=0;for(let T=0;Tv-ns?i-v+ns:0),M=4*(this._cubeSize-y);Co(t,b,M,3*y,2*y),l.setRenderTarget(t),l.render(f,Ja)}}function Mg(r){const e=[],t=[],n=[];let i=r;const s=r-ns+1+Mu.length;for(let o=0;or-ns?l=Mu[o-r+ns-1]:o===0&&(l=0),n.push(l);const c=1/(a-2),u=-c,f=1+c,h=[u,u,f,u,f,f,u,u,f,f,u,f],p=6,_=6,g=3,m=2,d=1,x=new Float32Array(g*_*p),v=new Float32Array(m*_*p),y=new Float32Array(d*_*p);for(let M=0;M2?0:-1,S=[T,I,0,T+2/3,I,0,T+2/3,I+1,0,T,I,0,T+2/3,I+1,0,T,I+1,0];x.set(S,g*_*M),v.set(h,m*_*M);const A=[M,M,M,M,M,M];y.set(A,d*_*M)}const b=new yn;b.setAttribute("position",new Yt(x,g)),b.setAttribute("uv",new Yt(v,m)),b.setAttribute("faceIndex",new Yt(y,d)),e.push(b),i>ns&&i--}return{lodPlanes:e,sizeLods:t,sigmas:n}}function Lu(r,e,t){const n=new $i(r,e,t);return n.texture.mapping=ga,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Co(r,e,t,n,i){r.viewport.set(e,t,n,i),r.scissor.set(e,t,n,i)}function Tg(r,e,t){const n=new Float32Array(hr),i=new C(0,1,0);return new Ki({name:"SphericalGaussianBlur",defines:{n:hr,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${r}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:rc(),fragmentShader:` precision mediump float; precision mediump int; @@ -3614,7 +3614,7 @@ precision `+r.precision+" int;";return r.precision==="highp"?e+=` Program Info Log: `+O+` `+J+` -`+ce)}else O!==""?console.warn("THREE.WebGLProgram: Program Info Log:",O):(W===""||D==="")&&(Z=!1);Z&&(z.diagnostics={runnable:V,programLog:O,vertexShader:{log:W,prefix:m},fragmentShader:{log:D,prefix:d}})}i.deleteShader(b),i.deleteShader(M),I=new sa(i,g),S=Nv(i,g)}let I;this.getUniforms=function(){return I===void 0&&T(this),I};let S;this.getAttributes=function(){return S===void 0&&T(this),S};let A=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return A===!1&&(A=i.getProgramParameter(g,Tv)),A},this.destroy=function(){n.releaseStatesOfProgram(this),i.deleteProgram(g),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=Av++,this.cacheKey=e,this.usedTimes=1,this.program=g,this.vertexShader=b,this.fragmentShader=M,this}let qv=0;class jv{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,i=this._getShaderStage(t),s=this._getShaderStage(n),o=this._getShaderCacheForMaterial(e);return o.has(i)===!1&&(o.add(i),i.usedTimes++),o.has(s)===!1&&(o.add(s),s.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return n===void 0&&(n=new Yv(e),t.set(e,n)),n}}class Yv{constructor(e){this.id=qv++,this.code=e,this.usedTimes=0}}function $v(r,e,t,n,i,s,o){const a=new gf,l=new jv,c=[],u=i.isWebGL2,f=i.logarithmicDepthBuffer,h=i.vertexTextures;let p=i.precision;const _={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function g(S){return S===0?"uv":`uv${S}`}function m(S,A,z,O,W){const D=O.fog,V=W.geometry,Z=S.isMeshStandardMaterial?O.environment:null,J=(S.isMeshStandardMaterial?t:e).get(S.envMap||Z),ce=J&&J.mapping===ga?J.image.height:null,ie=_[S.type];S.precision!==null&&(p=i.getMaxPrecision(S.precision),p!==S.precision&&console.warn("THREE.WebGLProgram.getParameters:",S.precision,"not supported, using",p,"instead."));const se=V.morphAttributes.position||V.morphAttributes.normal||V.morphAttributes.color,me=se!==void 0?se.length:0;let ve=0;V.morphAttributes.position!==void 0&&(ve=1),V.morphAttributes.normal!==void 0&&(ve=2),V.morphAttributes.color!==void 0&&(ve=3);let Q,oe,Se,De;if(ie){const Vt=ui[ie];Q=Vt.vertexShader,oe=Vt.fragmentShader}else Q=S.vertexShader,oe=S.fragmentShader,l.update(S),Se=l.getVertexShaderID(S),De=l.getFragmentShaderID(S);const _e=r.getRenderTarget(),qe=W.isInstancedMesh===!0,We=W.isBatchedMesh===!0,Fe=!!S.map,Ye=!!S.matcap,X=!!J,Lt=!!S.aoMap,Le=!!S.lightMap,$e=!!S.bumpMap,ze=!!S.normalMap,_t=!!S.displacementMap,Ke=!!S.emissiveMap,ke=!!S.metalnessMap,ot=!!S.roughnessMap,Tt=S.anisotropy>0,Ct=S.clearcoat>0,P=S.iridescence>0,E=S.sheen>0,q=S.transmission>0,le=Tt&&!!S.anisotropyMap,re=Ct&&!!S.clearcoatMap,fe=Ct&&!!S.clearcoatNormalMap,Me=Ct&&!!S.clearcoatRoughnessMap,pe=P&&!!S.iridescenceMap,ye=P&&!!S.iridescenceThicknessMap,N=E&&!!S.sheenColorMap,de=E&&!!S.sheenRoughnessMap,ne=!!S.specularMap,Oe=!!S.specularColorMap,Ae=!!S.specularIntensityMap,Ce=q&&!!S.transmissionMap,we=q&&!!S.thicknessMap,be=!!S.gradientMap,Ge=!!S.alphaMap,F=S.alphaTest>0,ge=!!S.alphaHash,ae=!!S.extensions,ee=!!V.attributes.uv1,he=!!V.attributes.uv2,Re=!!V.attributes.uv3;let nt=ji;return S.toneMapped&&(_e===null||_e.isXRRenderTarget===!0)&&(nt=r.toneMapping),{isWebGL2:u,shaderID:ie,shaderType:S.type,shaderName:S.name,vertexShader:Q,fragmentShader:oe,defines:S.defines,customVertexShaderID:Se,customFragmentShaderID:De,isRawShaderMaterial:S.isRawShaderMaterial===!0,glslVersion:S.glslVersion,precision:p,batching:We,instancing:qe,instancingColor:qe&&W.instanceColor!==null,supportsVertexTextures:h,outputColorSpace:_e===null?r.outputColorSpace:_e.isXRRenderTarget===!0?_e.texture.colorSpace:an,map:Fe,matcap:Ye,envMap:X,envMapMode:X&&J.mapping,envMapCubeUVHeight:ce,aoMap:Lt,lightMap:Le,bumpMap:$e,normalMap:ze,displacementMap:h&&_t,emissiveMap:Ke,normalMapObjectSpace:ze&&S.normalMapType===qd,normalMapTangentSpace:ze&&S.normalMapType===uf,metalnessMap:ke,roughnessMap:ot,anisotropy:Tt,anisotropyMap:le,clearcoat:Ct,clearcoatMap:re,clearcoatNormalMap:fe,clearcoatRoughnessMap:Me,iridescence:P,iridescenceMap:pe,iridescenceThicknessMap:ye,sheen:E,sheenColorMap:N,sheenRoughnessMap:de,specularMap:ne,specularColorMap:Oe,specularIntensityMap:Ae,transmission:q,transmissionMap:Ce,thicknessMap:we,gradientMap:be,opaque:S.transparent===!1&&S.blending===rs,alphaMap:Ge,alphaTest:F,alphaHash:ge,combine:S.combine,mapUv:Fe&&g(S.map.channel),aoMapUv:Lt&&g(S.aoMap.channel),lightMapUv:Le&&g(S.lightMap.channel),bumpMapUv:$e&&g(S.bumpMap.channel),normalMapUv:ze&&g(S.normalMap.channel),displacementMapUv:_t&&g(S.displacementMap.channel),emissiveMapUv:Ke&&g(S.emissiveMap.channel),metalnessMapUv:ke&&g(S.metalnessMap.channel),roughnessMapUv:ot&&g(S.roughnessMap.channel),anisotropyMapUv:le&&g(S.anisotropyMap.channel),clearcoatMapUv:re&&g(S.clearcoatMap.channel),clearcoatNormalMapUv:fe&&g(S.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Me&&g(S.clearcoatRoughnessMap.channel),iridescenceMapUv:pe&&g(S.iridescenceMap.channel),iridescenceThicknessMapUv:ye&&g(S.iridescenceThicknessMap.channel),sheenColorMapUv:N&&g(S.sheenColorMap.channel),sheenRoughnessMapUv:de&&g(S.sheenRoughnessMap.channel),specularMapUv:ne&&g(S.specularMap.channel),specularColorMapUv:Oe&&g(S.specularColorMap.channel),specularIntensityMapUv:Ae&&g(S.specularIntensityMap.channel),transmissionMapUv:Ce&&g(S.transmissionMap.channel),thicknessMapUv:we&&g(S.thicknessMap.channel),alphaMapUv:Ge&&g(S.alphaMap.channel),vertexTangents:!!V.attributes.tangent&&(ze||Tt),vertexColors:S.vertexColors,vertexAlphas:S.vertexColors===!0&&!!V.attributes.color&&V.attributes.color.itemSize===4,vertexUv1s:ee,vertexUv2s:he,vertexUv3s:Re,pointsUvs:W.isPoints===!0&&!!V.attributes.uv&&(Fe||Ge),fog:!!D,useFog:S.fog===!0,fogExp2:D&&D.isFogExp2,flatShading:S.flatShading===!0,sizeAttenuation:S.sizeAttenuation===!0,logarithmicDepthBuffer:f,skinning:W.isSkinnedMesh===!0,morphTargets:V.morphAttributes.position!==void 0,morphNormals:V.morphAttributes.normal!==void 0,morphColors:V.morphAttributes.color!==void 0,morphTargetsCount:me,morphTextureStride:ve,numDirLights:A.directional.length,numPointLights:A.point.length,numSpotLights:A.spot.length,numSpotLightMaps:A.spotLightMap.length,numRectAreaLights:A.rectArea.length,numHemiLights:A.hemi.length,numDirLightShadows:A.directionalShadowMap.length,numPointLightShadows:A.pointShadowMap.length,numSpotLightShadows:A.spotShadowMap.length,numSpotLightShadowsWithMaps:A.numSpotLightShadowsWithMaps,numLightProbes:A.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:S.dithering,shadowMapEnabled:r.shadowMap.enabled&&z.length>0,shadowMapType:r.shadowMap.type,toneMapping:nt,useLegacyLights:r._useLegacyLights,decodeVideoTexture:Fe&&S.map.isVideoTexture===!0&&pt.getTransfer(S.map.colorSpace)===At,premultipliedAlpha:S.premultipliedAlpha,doubleSided:S.side===Zn,flipSided:S.side===xn,useDepthPacking:S.depthPacking>=0,depthPacking:S.depthPacking||0,index0AttributeName:S.index0AttributeName,extensionDerivatives:ae&&S.extensions.derivatives===!0,extensionFragDepth:ae&&S.extensions.fragDepth===!0,extensionDrawBuffers:ae&&S.extensions.drawBuffers===!0,extensionShaderTextureLOD:ae&&S.extensions.shaderTextureLOD===!0,rendererExtensionFragDepth:u||n.has("EXT_frag_depth"),rendererExtensionDrawBuffers:u||n.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:u||n.has("EXT_shader_texture_lod"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:S.customProgramCacheKey()}}function d(S){const A=[];if(S.shaderID?A.push(S.shaderID):(A.push(S.customVertexShaderID),A.push(S.customFragmentShaderID)),S.defines!==void 0)for(const z in S.defines)A.push(z),A.push(S.defines[z]);return S.isRawShaderMaterial===!1&&(x(A,S),v(A,S),A.push(r.outputColorSpace)),A.push(S.customProgramCacheKey),A.join()}function x(S,A){S.push(A.precision),S.push(A.outputColorSpace),S.push(A.envMapMode),S.push(A.envMapCubeUVHeight),S.push(A.mapUv),S.push(A.alphaMapUv),S.push(A.lightMapUv),S.push(A.aoMapUv),S.push(A.bumpMapUv),S.push(A.normalMapUv),S.push(A.displacementMapUv),S.push(A.emissiveMapUv),S.push(A.metalnessMapUv),S.push(A.roughnessMapUv),S.push(A.anisotropyMapUv),S.push(A.clearcoatMapUv),S.push(A.clearcoatNormalMapUv),S.push(A.clearcoatRoughnessMapUv),S.push(A.iridescenceMapUv),S.push(A.iridescenceThicknessMapUv),S.push(A.sheenColorMapUv),S.push(A.sheenRoughnessMapUv),S.push(A.specularMapUv),S.push(A.specularColorMapUv),S.push(A.specularIntensityMapUv),S.push(A.transmissionMapUv),S.push(A.thicknessMapUv),S.push(A.combine),S.push(A.fogExp2),S.push(A.sizeAttenuation),S.push(A.morphTargetsCount),S.push(A.morphAttributeCount),S.push(A.numDirLights),S.push(A.numPointLights),S.push(A.numSpotLights),S.push(A.numSpotLightMaps),S.push(A.numHemiLights),S.push(A.numRectAreaLights),S.push(A.numDirLightShadows),S.push(A.numPointLightShadows),S.push(A.numSpotLightShadows),S.push(A.numSpotLightShadowsWithMaps),S.push(A.numLightProbes),S.push(A.shadowMapType),S.push(A.toneMapping),S.push(A.numClippingPlanes),S.push(A.numClipIntersection),S.push(A.depthPacking)}function v(S,A){a.disableAll(),A.isWebGL2&&a.enable(0),A.supportsVertexTextures&&a.enable(1),A.instancing&&a.enable(2),A.instancingColor&&a.enable(3),A.matcap&&a.enable(4),A.envMap&&a.enable(5),A.normalMapObjectSpace&&a.enable(6),A.normalMapTangentSpace&&a.enable(7),A.clearcoat&&a.enable(8),A.iridescence&&a.enable(9),A.alphaTest&&a.enable(10),A.vertexColors&&a.enable(11),A.vertexAlphas&&a.enable(12),A.vertexUv1s&&a.enable(13),A.vertexUv2s&&a.enable(14),A.vertexUv3s&&a.enable(15),A.vertexTangents&&a.enable(16),A.anisotropy&&a.enable(17),A.alphaHash&&a.enable(18),A.batching&&a.enable(19),S.push(a.mask),a.disableAll(),A.fog&&a.enable(0),A.useFog&&a.enable(1),A.flatShading&&a.enable(2),A.logarithmicDepthBuffer&&a.enable(3),A.skinning&&a.enable(4),A.morphTargets&&a.enable(5),A.morphNormals&&a.enable(6),A.morphColors&&a.enable(7),A.premultipliedAlpha&&a.enable(8),A.shadowMapEnabled&&a.enable(9),A.useLegacyLights&&a.enable(10),A.doubleSided&&a.enable(11),A.flipSided&&a.enable(12),A.useDepthPacking&&a.enable(13),A.dithering&&a.enable(14),A.transmission&&a.enable(15),A.sheen&&a.enable(16),A.opaque&&a.enable(17),A.pointsUvs&&a.enable(18),A.decodeVideoTexture&&a.enable(19),S.push(a.mask)}function y(S){const A=_[S.type];let z;if(A){const O=ui[A];z=Dp.clone(O.uniforms)}else z=S.uniforms;return z}function b(S,A){let z;for(let O=0,W=c.length;O0?n.push(d):p.transparent===!0?i.push(d):t.push(d)}function l(f,h,p,_,g,m){const d=o(f,h,p,_,g,m);p.transmission>0?n.unshift(d):p.transparent===!0?i.unshift(d):t.unshift(d)}function c(f,h){t.length>1&&t.sort(f||Zv),n.length>1&&n.sort(h||Wu),i.length>1&&i.sort(h||Wu)}function u(){for(let f=e,h=r.length;f=s.length?(o=new Xu,s.push(o)):o=s[i],o}function t(){r=new WeakMap}return{get:e,dispose:t}}function Qv(){const r={};return{get:function(e){if(r[e.id]!==void 0)return r[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new C,color:new tt};break;case"SpotLight":t={position:new C,direction:new C,color:new tt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new C,color:new tt,distance:0,decay:0};break;case"HemisphereLight":t={direction:new C,skyColor:new tt,groundColor:new tt};break;case"RectAreaLight":t={color:new tt,position:new C,halfWidth:new C,halfHeight:new C};break}return r[e.id]=t,t}}}function e0(){const r={};return{get:function(e){if(r[e.id]!==void 0)return r[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ue};break;case"SpotLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ue};break;case"PointLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ue,shadowCameraNear:1,shadowCameraFar:1e3};break}return r[e.id]=t,t}}}let t0=0;function n0(r,e){return(e.castShadow?2:0)-(r.castShadow?2:0)+(e.map?1:0)-(r.map?1:0)}function i0(r,e){const t=new Qv,n=e0(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let u=0;u<9;u++)i.probe.push(new C);const s=new C,o=new Ve,a=new Ve;function l(u,f){let h=0,p=0,_=0;for(let O=0;O<9;O++)i.probe[O].set(0,0,0);let g=0,m=0,d=0,x=0,v=0,y=0,b=0,M=0,T=0,I=0,S=0;u.sort(n0);const A=f===!0?Math.PI:1;for(let O=0,W=u.length;O0&&(e.isWebGL2||r.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=xe.LTC_FLOAT_1,i.rectAreaLTC2=xe.LTC_FLOAT_2):r.has("OES_texture_half_float_linear")===!0?(i.rectAreaLTC1=xe.LTC_HALF_1,i.rectAreaLTC2=xe.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=h,i.ambient[1]=p,i.ambient[2]=_;const z=i.hash;(z.directionalLength!==g||z.pointLength!==m||z.spotLength!==d||z.rectAreaLength!==x||z.hemiLength!==v||z.numDirectionalShadows!==y||z.numPointShadows!==b||z.numSpotShadows!==M||z.numSpotMaps!==T||z.numLightProbes!==S)&&(i.directional.length=g,i.spot.length=d,i.rectArea.length=x,i.point.length=m,i.hemi.length=v,i.directionalShadow.length=y,i.directionalShadowMap.length=y,i.pointShadow.length=b,i.pointShadowMap.length=b,i.spotShadow.length=M,i.spotShadowMap.length=M,i.directionalShadowMatrix.length=y,i.pointShadowMatrix.length=b,i.spotLightMatrix.length=M+T-I,i.spotLightMap.length=T,i.numSpotLightShadowsWithMaps=I,i.numLightProbes=S,z.directionalLength=g,z.pointLength=m,z.spotLength=d,z.rectAreaLength=x,z.hemiLength=v,z.numDirectionalShadows=y,z.numPointShadows=b,z.numSpotShadows=M,z.numSpotMaps=T,z.numLightProbes=S,i.version=t0++)}function c(u,f){let h=0,p=0,_=0,g=0,m=0;const d=f.matrixWorldInverse;for(let x=0,v=u.length;x=a.length?(l=new qu(r,e),a.push(l)):l=a[o],l}function i(){t=new WeakMap}return{get:n,dispose:i}}class s0 extends di{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Wd,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class o0 extends di{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}const a0=`void main() { +`+ce)}else O!==""?console.warn("THREE.WebGLProgram: Program Info Log:",O):(W===""||D==="")&&(Z=!1);Z&&(z.diagnostics={runnable:V,programLog:O,vertexShader:{log:W,prefix:m},fragmentShader:{log:D,prefix:d}})}i.deleteShader(b),i.deleteShader(M),I=new sa(i,g),S=Nv(i,g)}let I;this.getUniforms=function(){return I===void 0&&T(this),I};let S;this.getAttributes=function(){return S===void 0&&T(this),S};let A=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return A===!1&&(A=i.getProgramParameter(g,Tv)),A},this.destroy=function(){n.releaseStatesOfProgram(this),i.deleteProgram(g),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=Av++,this.cacheKey=e,this.usedTimes=1,this.program=g,this.vertexShader=b,this.fragmentShader=M,this}let qv=0;class jv{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,i=this._getShaderStage(t),s=this._getShaderStage(n),o=this._getShaderCacheForMaterial(e);return o.has(i)===!1&&(o.add(i),i.usedTimes++),o.has(s)===!1&&(o.add(s),s.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return n===void 0&&(n=new Yv(e),t.set(e,n)),n}}class Yv{constructor(e){this.id=qv++,this.code=e,this.usedTimes=0}}function $v(r,e,t,n,i,s,o){const a=new gf,l=new jv,c=[],u=i.isWebGL2,f=i.logarithmicDepthBuffer,h=i.vertexTextures;let p=i.precision;const _={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function g(S){return S===0?"uv":`uv${S}`}function m(S,A,z,O,W){const D=O.fog,V=W.geometry,Z=S.isMeshStandardMaterial?O.environment:null,J=(S.isMeshStandardMaterial?t:e).get(S.envMap||Z),ce=J&&J.mapping===ga?J.image.height:null,ie=_[S.type];S.precision!==null&&(p=i.getMaxPrecision(S.precision),p!==S.precision&&console.warn("THREE.WebGLProgram.getParameters:",S.precision,"not supported, using",p,"instead."));const se=V.morphAttributes.position||V.morphAttributes.normal||V.morphAttributes.color,me=se!==void 0?se.length:0;let ve=0;V.morphAttributes.position!==void 0&&(ve=1),V.morphAttributes.normal!==void 0&&(ve=2),V.morphAttributes.color!==void 0&&(ve=3);let Q,oe,Se,De;if(ie){const Vt=ui[ie];Q=Vt.vertexShader,oe=Vt.fragmentShader}else Q=S.vertexShader,oe=S.fragmentShader,l.update(S),Se=l.getVertexShaderID(S),De=l.getFragmentShaderID(S);const _e=r.getRenderTarget(),qe=W.isInstancedMesh===!0,We=W.isBatchedMesh===!0,Fe=!!S.map,Ye=!!S.matcap,X=!!J,Lt=!!S.aoMap,Ce=!!S.lightMap,$e=!!S.bumpMap,ze=!!S.normalMap,_t=!!S.displacementMap,Ke=!!S.emissiveMap,ke=!!S.metalnessMap,ot=!!S.roughnessMap,Tt=S.anisotropy>0,Ct=S.clearcoat>0,P=S.iridescence>0,E=S.sheen>0,q=S.transmission>0,le=Tt&&!!S.anisotropyMap,re=Ct&&!!S.clearcoatMap,fe=Ct&&!!S.clearcoatNormalMap,Me=Ct&&!!S.clearcoatRoughnessMap,pe=P&&!!S.iridescenceMap,ye=P&&!!S.iridescenceThicknessMap,N=E&&!!S.sheenColorMap,de=E&&!!S.sheenRoughnessMap,ne=!!S.specularMap,Oe=!!S.specularColorMap,Ae=!!S.specularIntensityMap,Pe=q&&!!S.transmissionMap,we=q&&!!S.thicknessMap,be=!!S.gradientMap,Ge=!!S.alphaMap,F=S.alphaTest>0,ge=!!S.alphaHash,ae=!!S.extensions,ee=!!V.attributes.uv1,he=!!V.attributes.uv2,Re=!!V.attributes.uv3;let nt=ji;return S.toneMapped&&(_e===null||_e.isXRRenderTarget===!0)&&(nt=r.toneMapping),{isWebGL2:u,shaderID:ie,shaderType:S.type,shaderName:S.name,vertexShader:Q,fragmentShader:oe,defines:S.defines,customVertexShaderID:Se,customFragmentShaderID:De,isRawShaderMaterial:S.isRawShaderMaterial===!0,glslVersion:S.glslVersion,precision:p,batching:We,instancing:qe,instancingColor:qe&&W.instanceColor!==null,supportsVertexTextures:h,outputColorSpace:_e===null?r.outputColorSpace:_e.isXRRenderTarget===!0?_e.texture.colorSpace:an,map:Fe,matcap:Ye,envMap:X,envMapMode:X&&J.mapping,envMapCubeUVHeight:ce,aoMap:Lt,lightMap:Ce,bumpMap:$e,normalMap:ze,displacementMap:h&&_t,emissiveMap:Ke,normalMapObjectSpace:ze&&S.normalMapType===qd,normalMapTangentSpace:ze&&S.normalMapType===uf,metalnessMap:ke,roughnessMap:ot,anisotropy:Tt,anisotropyMap:le,clearcoat:Ct,clearcoatMap:re,clearcoatNormalMap:fe,clearcoatRoughnessMap:Me,iridescence:P,iridescenceMap:pe,iridescenceThicknessMap:ye,sheen:E,sheenColorMap:N,sheenRoughnessMap:de,specularMap:ne,specularColorMap:Oe,specularIntensityMap:Ae,transmission:q,transmissionMap:Pe,thicknessMap:we,gradientMap:be,opaque:S.transparent===!1&&S.blending===rs,alphaMap:Ge,alphaTest:F,alphaHash:ge,combine:S.combine,mapUv:Fe&&g(S.map.channel),aoMapUv:Lt&&g(S.aoMap.channel),lightMapUv:Ce&&g(S.lightMap.channel),bumpMapUv:$e&&g(S.bumpMap.channel),normalMapUv:ze&&g(S.normalMap.channel),displacementMapUv:_t&&g(S.displacementMap.channel),emissiveMapUv:Ke&&g(S.emissiveMap.channel),metalnessMapUv:ke&&g(S.metalnessMap.channel),roughnessMapUv:ot&&g(S.roughnessMap.channel),anisotropyMapUv:le&&g(S.anisotropyMap.channel),clearcoatMapUv:re&&g(S.clearcoatMap.channel),clearcoatNormalMapUv:fe&&g(S.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Me&&g(S.clearcoatRoughnessMap.channel),iridescenceMapUv:pe&&g(S.iridescenceMap.channel),iridescenceThicknessMapUv:ye&&g(S.iridescenceThicknessMap.channel),sheenColorMapUv:N&&g(S.sheenColorMap.channel),sheenRoughnessMapUv:de&&g(S.sheenRoughnessMap.channel),specularMapUv:ne&&g(S.specularMap.channel),specularColorMapUv:Oe&&g(S.specularColorMap.channel),specularIntensityMapUv:Ae&&g(S.specularIntensityMap.channel),transmissionMapUv:Pe&&g(S.transmissionMap.channel),thicknessMapUv:we&&g(S.thicknessMap.channel),alphaMapUv:Ge&&g(S.alphaMap.channel),vertexTangents:!!V.attributes.tangent&&(ze||Tt),vertexColors:S.vertexColors,vertexAlphas:S.vertexColors===!0&&!!V.attributes.color&&V.attributes.color.itemSize===4,vertexUv1s:ee,vertexUv2s:he,vertexUv3s:Re,pointsUvs:W.isPoints===!0&&!!V.attributes.uv&&(Fe||Ge),fog:!!D,useFog:S.fog===!0,fogExp2:D&&D.isFogExp2,flatShading:S.flatShading===!0,sizeAttenuation:S.sizeAttenuation===!0,logarithmicDepthBuffer:f,skinning:W.isSkinnedMesh===!0,morphTargets:V.morphAttributes.position!==void 0,morphNormals:V.morphAttributes.normal!==void 0,morphColors:V.morphAttributes.color!==void 0,morphTargetsCount:me,morphTextureStride:ve,numDirLights:A.directional.length,numPointLights:A.point.length,numSpotLights:A.spot.length,numSpotLightMaps:A.spotLightMap.length,numRectAreaLights:A.rectArea.length,numHemiLights:A.hemi.length,numDirLightShadows:A.directionalShadowMap.length,numPointLightShadows:A.pointShadowMap.length,numSpotLightShadows:A.spotShadowMap.length,numSpotLightShadowsWithMaps:A.numSpotLightShadowsWithMaps,numLightProbes:A.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:S.dithering,shadowMapEnabled:r.shadowMap.enabled&&z.length>0,shadowMapType:r.shadowMap.type,toneMapping:nt,useLegacyLights:r._useLegacyLights,decodeVideoTexture:Fe&&S.map.isVideoTexture===!0&&pt.getTransfer(S.map.colorSpace)===At,premultipliedAlpha:S.premultipliedAlpha,doubleSided:S.side===Zn,flipSided:S.side===xn,useDepthPacking:S.depthPacking>=0,depthPacking:S.depthPacking||0,index0AttributeName:S.index0AttributeName,extensionDerivatives:ae&&S.extensions.derivatives===!0,extensionFragDepth:ae&&S.extensions.fragDepth===!0,extensionDrawBuffers:ae&&S.extensions.drawBuffers===!0,extensionShaderTextureLOD:ae&&S.extensions.shaderTextureLOD===!0,rendererExtensionFragDepth:u||n.has("EXT_frag_depth"),rendererExtensionDrawBuffers:u||n.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:u||n.has("EXT_shader_texture_lod"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:S.customProgramCacheKey()}}function d(S){const A=[];if(S.shaderID?A.push(S.shaderID):(A.push(S.customVertexShaderID),A.push(S.customFragmentShaderID)),S.defines!==void 0)for(const z in S.defines)A.push(z),A.push(S.defines[z]);return S.isRawShaderMaterial===!1&&(x(A,S),v(A,S),A.push(r.outputColorSpace)),A.push(S.customProgramCacheKey),A.join()}function x(S,A){S.push(A.precision),S.push(A.outputColorSpace),S.push(A.envMapMode),S.push(A.envMapCubeUVHeight),S.push(A.mapUv),S.push(A.alphaMapUv),S.push(A.lightMapUv),S.push(A.aoMapUv),S.push(A.bumpMapUv),S.push(A.normalMapUv),S.push(A.displacementMapUv),S.push(A.emissiveMapUv),S.push(A.metalnessMapUv),S.push(A.roughnessMapUv),S.push(A.anisotropyMapUv),S.push(A.clearcoatMapUv),S.push(A.clearcoatNormalMapUv),S.push(A.clearcoatRoughnessMapUv),S.push(A.iridescenceMapUv),S.push(A.iridescenceThicknessMapUv),S.push(A.sheenColorMapUv),S.push(A.sheenRoughnessMapUv),S.push(A.specularMapUv),S.push(A.specularColorMapUv),S.push(A.specularIntensityMapUv),S.push(A.transmissionMapUv),S.push(A.thicknessMapUv),S.push(A.combine),S.push(A.fogExp2),S.push(A.sizeAttenuation),S.push(A.morphTargetsCount),S.push(A.morphAttributeCount),S.push(A.numDirLights),S.push(A.numPointLights),S.push(A.numSpotLights),S.push(A.numSpotLightMaps),S.push(A.numHemiLights),S.push(A.numRectAreaLights),S.push(A.numDirLightShadows),S.push(A.numPointLightShadows),S.push(A.numSpotLightShadows),S.push(A.numSpotLightShadowsWithMaps),S.push(A.numLightProbes),S.push(A.shadowMapType),S.push(A.toneMapping),S.push(A.numClippingPlanes),S.push(A.numClipIntersection),S.push(A.depthPacking)}function v(S,A){a.disableAll(),A.isWebGL2&&a.enable(0),A.supportsVertexTextures&&a.enable(1),A.instancing&&a.enable(2),A.instancingColor&&a.enable(3),A.matcap&&a.enable(4),A.envMap&&a.enable(5),A.normalMapObjectSpace&&a.enable(6),A.normalMapTangentSpace&&a.enable(7),A.clearcoat&&a.enable(8),A.iridescence&&a.enable(9),A.alphaTest&&a.enable(10),A.vertexColors&&a.enable(11),A.vertexAlphas&&a.enable(12),A.vertexUv1s&&a.enable(13),A.vertexUv2s&&a.enable(14),A.vertexUv3s&&a.enable(15),A.vertexTangents&&a.enable(16),A.anisotropy&&a.enable(17),A.alphaHash&&a.enable(18),A.batching&&a.enable(19),S.push(a.mask),a.disableAll(),A.fog&&a.enable(0),A.useFog&&a.enable(1),A.flatShading&&a.enable(2),A.logarithmicDepthBuffer&&a.enable(3),A.skinning&&a.enable(4),A.morphTargets&&a.enable(5),A.morphNormals&&a.enable(6),A.morphColors&&a.enable(7),A.premultipliedAlpha&&a.enable(8),A.shadowMapEnabled&&a.enable(9),A.useLegacyLights&&a.enable(10),A.doubleSided&&a.enable(11),A.flipSided&&a.enable(12),A.useDepthPacking&&a.enable(13),A.dithering&&a.enable(14),A.transmission&&a.enable(15),A.sheen&&a.enable(16),A.opaque&&a.enable(17),A.pointsUvs&&a.enable(18),A.decodeVideoTexture&&a.enable(19),S.push(a.mask)}function y(S){const A=_[S.type];let z;if(A){const O=ui[A];z=Dp.clone(O.uniforms)}else z=S.uniforms;return z}function b(S,A){let z;for(let O=0,W=c.length;O0?n.push(d):p.transparent===!0?i.push(d):t.push(d)}function l(f,h,p,_,g,m){const d=o(f,h,p,_,g,m);p.transmission>0?n.unshift(d):p.transparent===!0?i.unshift(d):t.unshift(d)}function c(f,h){t.length>1&&t.sort(f||Zv),n.length>1&&n.sort(h||Wu),i.length>1&&i.sort(h||Wu)}function u(){for(let f=e,h=r.length;f=s.length?(o=new Xu,s.push(o)):o=s[i],o}function t(){r=new WeakMap}return{get:e,dispose:t}}function Qv(){const r={};return{get:function(e){if(r[e.id]!==void 0)return r[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new C,color:new tt};break;case"SpotLight":t={position:new C,direction:new C,color:new tt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new C,color:new tt,distance:0,decay:0};break;case"HemisphereLight":t={direction:new C,skyColor:new tt,groundColor:new tt};break;case"RectAreaLight":t={color:new tt,position:new C,halfWidth:new C,halfHeight:new C};break}return r[e.id]=t,t}}}function e0(){const r={};return{get:function(e){if(r[e.id]!==void 0)return r[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ue};break;case"SpotLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ue};break;case"PointLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ue,shadowCameraNear:1,shadowCameraFar:1e3};break}return r[e.id]=t,t}}}let t0=0;function n0(r,e){return(e.castShadow?2:0)-(r.castShadow?2:0)+(e.map?1:0)-(r.map?1:0)}function i0(r,e){const t=new Qv,n=e0(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let u=0;u<9;u++)i.probe.push(new C);const s=new C,o=new Ve,a=new Ve;function l(u,f){let h=0,p=0,_=0;for(let O=0;O<9;O++)i.probe[O].set(0,0,0);let g=0,m=0,d=0,x=0,v=0,y=0,b=0,M=0,T=0,I=0,S=0;u.sort(n0);const A=f===!0?Math.PI:1;for(let O=0,W=u.length;O0&&(e.isWebGL2||r.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=xe.LTC_FLOAT_1,i.rectAreaLTC2=xe.LTC_FLOAT_2):r.has("OES_texture_half_float_linear")===!0?(i.rectAreaLTC1=xe.LTC_HALF_1,i.rectAreaLTC2=xe.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=h,i.ambient[1]=p,i.ambient[2]=_;const z=i.hash;(z.directionalLength!==g||z.pointLength!==m||z.spotLength!==d||z.rectAreaLength!==x||z.hemiLength!==v||z.numDirectionalShadows!==y||z.numPointShadows!==b||z.numSpotShadows!==M||z.numSpotMaps!==T||z.numLightProbes!==S)&&(i.directional.length=g,i.spot.length=d,i.rectArea.length=x,i.point.length=m,i.hemi.length=v,i.directionalShadow.length=y,i.directionalShadowMap.length=y,i.pointShadow.length=b,i.pointShadowMap.length=b,i.spotShadow.length=M,i.spotShadowMap.length=M,i.directionalShadowMatrix.length=y,i.pointShadowMatrix.length=b,i.spotLightMatrix.length=M+T-I,i.spotLightMap.length=T,i.numSpotLightShadowsWithMaps=I,i.numLightProbes=S,z.directionalLength=g,z.pointLength=m,z.spotLength=d,z.rectAreaLength=x,z.hemiLength=v,z.numDirectionalShadows=y,z.numPointShadows=b,z.numSpotShadows=M,z.numSpotMaps=T,z.numLightProbes=S,i.version=t0++)}function c(u,f){let h=0,p=0,_=0,g=0,m=0;const d=f.matrixWorldInverse;for(let x=0,v=u.length;x=a.length?(l=new qu(r,e),a.push(l)):l=a[o],l}function i(){t=new WeakMap}return{get:n,dispose:i}}class s0 extends di{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Wd,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class o0 extends di{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}const a0=`void main() { gl_Position = vec4( position, 1.0 ); }`,l0=`uniform sampler2D shadow_pass; uniform vec2 resolution; @@ -3642,7 +3642,7 @@ void main() { squared_mean = squared_mean / samples; float std_dev = sqrt( squared_mean - mean * mean ); gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) ); -}`;function c0(r,e,t){let n=new nc;const i=new Ue,s=new Ue,o=new mt,a=new s0({depthPacking:Xd}),l=new o0,c={},u=t.maxTextureSize,f={[ei]:xn,[xn]:ei,[Zn]:Zn},h=new Ki({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ue},radius:{value:4}},vertexShader:a0,fragmentShader:l0}),p=h.clone();p.defines.HORIZONTAL_PASS=1;const _=new yn;_.setAttribute("position",new Yt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const g=new Mn(_,h),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Zh;let d=this.type;this.render=function(b,M,T){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||b.length===0)return;const I=r.getRenderTarget(),S=r.getActiveCubeFace(),A=r.getActiveMipmapLevel(),z=r.state;z.setBlending(qi),z.buffers.color.setClear(1,1,1,1),z.buffers.depth.setTest(!0),z.setScissorTest(!1);const O=d!==Mi&&this.type===Mi,W=d===Mi&&this.type!==Mi;for(let D=0,V=b.length;Du||i.y>u)&&(i.x>u&&(s.x=Math.floor(u/ce.x),i.x=s.x*ce.x,J.mapSize.x=s.x),i.y>u&&(s.y=Math.floor(u/ce.y),i.y=s.y*ce.y,J.mapSize.y=s.y)),J.map===null||O===!0||W===!0){const se=this.type!==Mi?{minFilter:Nt,magFilter:Nt}:{};J.map!==null&&J.map.dispose(),J.map=new $i(i.x,i.y,se),J.map.texture.name=Z.name+".shadowMap",J.camera.updateProjectionMatrix()}r.setRenderTarget(J.map),r.clear();const ie=J.getViewportCount();for(let se=0;se0||M.map&&M.alphaTest>0){const z=S.uuid,O=M.uuid;let W=c[z];W===void 0&&(W={},c[z]=W);let D=W[O];D===void 0&&(D=S.clone(),W[O]=D),S=D}if(S.visible=M.visible,S.wireframe=M.wireframe,I===Mi?S.side=M.shadowSide!==null?M.shadowSide:M.side:S.side=M.shadowSide!==null?M.shadowSide:f[M.side],S.alphaMap=M.alphaMap,S.alphaTest=M.alphaTest,S.map=M.map,S.clipShadows=M.clipShadows,S.clippingPlanes=M.clippingPlanes,S.clipIntersection=M.clipIntersection,S.displacementMap=M.displacementMap,S.displacementScale=M.displacementScale,S.displacementBias=M.displacementBias,S.wireframeLinewidth=M.wireframeLinewidth,S.linewidth=M.linewidth,T.isPointLight===!0&&S.isMeshDistanceMaterial===!0){const z=r.properties.get(S);z.light=T}return S}function y(b,M,T,I,S){if(b.visible===!1)return;if(b.layers.test(M.layers)&&(b.isMesh||b.isLine||b.isPoints)&&(b.castShadow||b.receiveShadow&&S===Mi)&&(!b.frustumCulled||n.intersectsObject(b))){b.modelViewMatrix.multiplyMatrices(T.matrixWorldInverse,b.matrixWorld);const O=e.update(b),W=b.material;if(Array.isArray(W)){const D=O.groups;for(let V=0,Z=D.length;V=1):se.indexOf("OpenGL ES")!==-1&&(ie=parseFloat(/^OpenGL ES (\d)/.exec(se)[1]),ce=ie>=2);let me=null,ve={};const Q=r.getParameter(r.SCISSOR_BOX),oe=r.getParameter(r.VIEWPORT),Se=new mt().fromArray(Q),De=new mt().fromArray(oe);function _e(F,ge,ae,ee){const he=new Uint8Array(4),Re=r.createTexture();r.bindTexture(F,Re),r.texParameteri(F,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(F,r.TEXTURE_MAG_FILTER,r.NEAREST);for(let nt=0;nt"u"?!1:/OculusBrowser/g.test(navigator.userAgent),_=new WeakMap;let g;const m=new WeakMap;let d=!1;try{d=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function x(P,E){return d?new OffscreenCanvas(P,E):to("canvas")}function v(P,E,q,le){let re=1;if((P.width>le||P.height>le)&&(re=le/Math.max(P.width,P.height)),re<1||E===!0)if(typeof HTMLImageElement<"u"&&P instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&P instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&P instanceof ImageBitmap){const fe=E?fa:Math.floor,Me=fe(re*P.width),pe=fe(re*P.height);g===void 0&&(g=x(Me,pe));const ye=q?x(Me,pe):g;return ye.width=Me,ye.height=pe,ye.getContext("2d").drawImage(P,0,0,Me,pe),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+P.width+"x"+P.height+") to ("+Me+"x"+pe+")."),ye}else return"data"in P&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+P.width+"x"+P.height+")."),P;return P}function y(P){return Ul(P.width)&&Ul(P.height)}function b(P){return a?!1:P.wrapS!==Hn||P.wrapT!==Hn||P.minFilter!==Nt&&P.minFilter!==En}function M(P,E){return P.generateMipmaps&&E&&P.minFilter!==Nt&&P.minFilter!==En}function T(P){r.generateMipmap(P)}function I(P,E,q,le,re=!1){if(a===!1)return E;if(P!==null){if(r[P]!==void 0)return r[P];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+P+"'")}let fe=E;if(E===r.RED&&(q===r.FLOAT&&(fe=r.R32F),q===r.HALF_FLOAT&&(fe=r.R16F),q===r.UNSIGNED_BYTE&&(fe=r.R8)),E===r.RED_INTEGER&&(q===r.UNSIGNED_BYTE&&(fe=r.R8UI),q===r.UNSIGNED_SHORT&&(fe=r.R16UI),q===r.UNSIGNED_INT&&(fe=r.R32UI),q===r.BYTE&&(fe=r.R8I),q===r.SHORT&&(fe=r.R16I),q===r.INT&&(fe=r.R32I)),E===r.RG&&(q===r.FLOAT&&(fe=r.RG32F),q===r.HALF_FLOAT&&(fe=r.RG16F),q===r.UNSIGNED_BYTE&&(fe=r.RG8)),E===r.RGBA){const Me=re?la:pt.getTransfer(le);q===r.FLOAT&&(fe=r.RGBA32F),q===r.HALF_FLOAT&&(fe=r.RGBA16F),q===r.UNSIGNED_BYTE&&(fe=Me===At?r.SRGB8_ALPHA8:r.RGBA8),q===r.UNSIGNED_SHORT_4_4_4_4&&(fe=r.RGBA4),q===r.UNSIGNED_SHORT_5_5_5_1&&(fe=r.RGB5_A1)}return(fe===r.R16F||fe===r.R32F||fe===r.RG16F||fe===r.RG32F||fe===r.RGBA16F||fe===r.RGBA32F)&&e.get("EXT_color_buffer_float"),fe}function S(P,E,q){return M(P,q)===!0||P.isFramebufferTexture&&P.minFilter!==Nt&&P.minFilter!==En?Math.log2(Math.max(E.width,E.height))+1:P.mipmaps!==void 0&&P.mipmaps.length>0?P.mipmaps.length:P.isCompressedTexture&&Array.isArray(P.image)?E.mipmaps.length:1}function A(P){return P===Nt||P===Dl||P===ra?r.NEAREST:r.LINEAR}function z(P){const E=P.target;E.removeEventListener("dispose",z),W(E),E.isVideoTexture&&_.delete(E)}function O(P){const E=P.target;E.removeEventListener("dispose",O),V(E)}function W(P){const E=n.get(P);if(E.__webglInit===void 0)return;const q=P.source,le=m.get(q);if(le){const re=le[E.__cacheKey];re.usedTimes--,re.usedTimes===0&&D(P),Object.keys(le).length===0&&m.delete(q)}n.remove(P)}function D(P){const E=n.get(P);r.deleteTexture(E.__webglTexture);const q=P.source,le=m.get(q);delete le[E.__cacheKey],o.memory.textures--}function V(P){const E=P.texture,q=n.get(P),le=n.get(E);if(le.__webglTexture!==void 0&&(r.deleteTexture(le.__webglTexture),o.memory.textures--),P.depthTexture&&P.depthTexture.dispose(),P.isWebGLCubeRenderTarget)for(let re=0;re<6;re++){if(Array.isArray(q.__webglFramebuffer[re]))for(let fe=0;fe=l&&console.warn("THREE.WebGLTextures: Trying to use "+P+" texture units while this GPU supports only "+l),Z+=1,P}function ie(P){const E=[];return E.push(P.wrapS),E.push(P.wrapT),E.push(P.wrapR||0),E.push(P.magFilter),E.push(P.minFilter),E.push(P.anisotropy),E.push(P.internalFormat),E.push(P.format),E.push(P.type),E.push(P.generateMipmaps),E.push(P.premultiplyAlpha),E.push(P.flipY),E.push(P.unpackAlignment),E.push(P.colorSpace),E.join()}function se(P,E){const q=n.get(P);if(P.isVideoTexture&&Tt(P),P.isRenderTargetTexture===!1&&P.version>0&&q.__version!==P.version){const le=P.image;if(le===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(le.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{We(q,P,E);return}}t.bindTexture(r.TEXTURE_2D,q.__webglTexture,r.TEXTURE0+E)}function me(P,E){const q=n.get(P);if(P.version>0&&q.__version!==P.version){We(q,P,E);return}t.bindTexture(r.TEXTURE_2D_ARRAY,q.__webglTexture,r.TEXTURE0+E)}function ve(P,E){const q=n.get(P);if(P.version>0&&q.__version!==P.version){We(q,P,E);return}t.bindTexture(r.TEXTURE_3D,q.__webglTexture,r.TEXTURE0+E)}function Q(P,E){const q=n.get(P);if(P.version>0&&q.__version!==P.version){Fe(q,P,E);return}t.bindTexture(r.TEXTURE_CUBE_MAP,q.__webglTexture,r.TEXTURE0+E)}const oe={[us]:r.REPEAT,[Hn]:r.CLAMP_TO_EDGE,[aa]:r.MIRRORED_REPEAT},Se={[Nt]:r.NEAREST,[Dl]:r.NEAREST_MIPMAP_NEAREST,[ra]:r.NEAREST_MIPMAP_LINEAR,[En]:r.LINEAR,[ef]:r.LINEAR_MIPMAP_NEAREST,[gr]:r.LINEAR_MIPMAP_LINEAR},De={[jd]:r.NEVER,[Qd]:r.ALWAYS,[Yd]:r.LESS,[hf]:r.LEQUAL,[$d]:r.EQUAL,[Jd]:r.GEQUAL,[Kd]:r.GREATER,[Zd]:r.NOTEQUAL};function _e(P,E,q){if(q?(r.texParameteri(P,r.TEXTURE_WRAP_S,oe[E.wrapS]),r.texParameteri(P,r.TEXTURE_WRAP_T,oe[E.wrapT]),(P===r.TEXTURE_3D||P===r.TEXTURE_2D_ARRAY)&&r.texParameteri(P,r.TEXTURE_WRAP_R,oe[E.wrapR]),r.texParameteri(P,r.TEXTURE_MAG_FILTER,Se[E.magFilter]),r.texParameteri(P,r.TEXTURE_MIN_FILTER,Se[E.minFilter])):(r.texParameteri(P,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(P,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),(P===r.TEXTURE_3D||P===r.TEXTURE_2D_ARRAY)&&r.texParameteri(P,r.TEXTURE_WRAP_R,r.CLAMP_TO_EDGE),(E.wrapS!==Hn||E.wrapT!==Hn)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),r.texParameteri(P,r.TEXTURE_MAG_FILTER,A(E.magFilter)),r.texParameteri(P,r.TEXTURE_MIN_FILTER,A(E.minFilter)),E.minFilter!==Nt&&E.minFilter!==En&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),E.compareFunction&&(r.texParameteri(P,r.TEXTURE_COMPARE_MODE,r.COMPARE_REF_TO_TEXTURE),r.texParameteri(P,r.TEXTURE_COMPARE_FUNC,De[E.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){const le=e.get("EXT_texture_filter_anisotropic");if(E.magFilter===Nt||E.minFilter!==ra&&E.minFilter!==gr||E.type===vn&&e.has("OES_texture_float_linear")===!1||a===!1&&E.type===Js&&e.has("OES_texture_half_float_linear")===!1)return;(E.anisotropy>1||n.get(E).__currentAnisotropy)&&(r.texParameterf(P,le.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(E.anisotropy,i.getMaxAnisotropy())),n.get(E).__currentAnisotropy=E.anisotropy)}}function qe(P,E){let q=!1;P.__webglInit===void 0&&(P.__webglInit=!0,E.addEventListener("dispose",z));const le=E.source;let re=m.get(le);re===void 0&&(re={},m.set(le,re));const fe=ie(E);if(fe!==P.__cacheKey){re[fe]===void 0&&(re[fe]={texture:r.createTexture(),usedTimes:0},o.memory.textures++,q=!0),re[fe].usedTimes++;const Me=re[P.__cacheKey];Me!==void 0&&(re[P.__cacheKey].usedTimes--,Me.usedTimes===0&&D(E)),P.__cacheKey=fe,P.__webglTexture=re[fe].texture}return q}function We(P,E,q){let le=r.TEXTURE_2D;(E.isDataArrayTexture||E.isCompressedArrayTexture)&&(le=r.TEXTURE_2D_ARRAY),E.isData3DTexture&&(le=r.TEXTURE_3D);const re=qe(P,E),fe=E.source;t.bindTexture(le,P.__webglTexture,r.TEXTURE0+q);const Me=n.get(fe);if(fe.version!==Me.__version||re===!0){t.activeTexture(r.TEXTURE0+q);const pe=pt.getPrimaries(pt.workingColorSpace),ye=E.colorSpace===Vn?null:pt.getPrimaries(E.colorSpace),N=E.colorSpace===Vn||pe===ye?r.NONE:r.BROWSER_DEFAULT_WEBGL;r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,E.flipY),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,E.premultiplyAlpha),r.pixelStorei(r.UNPACK_ALIGNMENT,E.unpackAlignment),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,N);const de=b(E)&&y(E.image)===!1;let ne=v(E.image,de,!1,u);ne=Ct(E,ne);const Oe=y(ne)||a,Ae=s.convert(E.format,E.colorSpace);let Ce=s.convert(E.type),we=I(E.internalFormat,Ae,Ce,E.colorSpace,E.isVideoTexture);_e(le,E,Oe);let be;const Ge=E.mipmaps,F=a&&E.isVideoTexture!==!0&&we!==af,ge=Me.__version===void 0||re===!0,ae=S(E,ne,Oe);if(E.isDepthTexture)we=r.DEPTH_COMPONENT,a?E.type===vn?we=r.DEPTH_COMPONENT32F:E.type===Dn?we=r.DEPTH_COMPONENT24:E.type===pr?we=r.DEPTH24_STENCIL8:we=r.DEPTH_COMPONENT16:E.type===vn&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),E.format===mr&&we===r.DEPTH_COMPONENT&&E.type!==va&&E.type!==Dn&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),E.type=Dn,Ce=s.convert(E.type)),E.format===hs&&we===r.DEPTH_COMPONENT&&(we=r.DEPTH_STENCIL,E.type!==pr&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),E.type=pr,Ce=s.convert(E.type))),ge&&(F?t.texStorage2D(r.TEXTURE_2D,1,we,ne.width,ne.height):t.texImage2D(r.TEXTURE_2D,0,we,ne.width,ne.height,0,Ae,Ce,null));else if(E.isDataTexture)if(Ge.length>0&&Oe){F&&ge&&t.texStorage2D(r.TEXTURE_2D,ae,we,Ge[0].width,Ge[0].height);for(let ee=0,he=Ge.length;ee>=1,he>>=1}}else if(Ge.length>0&&Oe){F&&ge&&t.texStorage2D(r.TEXTURE_2D,ae,we,Ge[0].width,Ge[0].height);for(let ee=0,he=Ge.length;ee0&&ge++,t.texStorage2D(r.TEXTURE_CUBE_MAP,ge,be,ne[0].width,ne[0].height));for(let ee=0;ee<6;ee++)if(de){Ge?t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ee,0,0,0,ne[ee].width,ne[ee].height,Ce,we,ne[ee].data):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ee,0,be,ne[ee].width,ne[ee].height,0,Ce,we,ne[ee].data);for(let he=0;he>fe),ne=Math.max(1,E.height>>fe);re===r.TEXTURE_3D||re===r.TEXTURE_2D_ARRAY?t.texImage3D(re,fe,ye,de,ne,E.depth,0,Me,pe,null):t.texImage2D(re,fe,ye,de,ne,0,Me,pe,null)}t.bindFramebuffer(r.FRAMEBUFFER,P),ot(E)?h.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,le,re,n.get(q).__webglTexture,0,ke(E)):(re===r.TEXTURE_2D||re>=r.TEXTURE_CUBE_MAP_POSITIVE_X&&re<=r.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&r.framebufferTexture2D(r.FRAMEBUFFER,le,re,n.get(q).__webglTexture,fe),t.bindFramebuffer(r.FRAMEBUFFER,null)}function X(P,E,q){if(r.bindRenderbuffer(r.RENDERBUFFER,P),E.depthBuffer&&!E.stencilBuffer){let le=a===!0?r.DEPTH_COMPONENT24:r.DEPTH_COMPONENT16;if(q||ot(E)){const re=E.depthTexture;re&&re.isDepthTexture&&(re.type===vn?le=r.DEPTH_COMPONENT32F:re.type===Dn&&(le=r.DEPTH_COMPONENT24));const fe=ke(E);ot(E)?h.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,fe,le,E.width,E.height):r.renderbufferStorageMultisample(r.RENDERBUFFER,fe,le,E.width,E.height)}else r.renderbufferStorage(r.RENDERBUFFER,le,E.width,E.height);r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.RENDERBUFFER,P)}else if(E.depthBuffer&&E.stencilBuffer){const le=ke(E);q&&ot(E)===!1?r.renderbufferStorageMultisample(r.RENDERBUFFER,le,r.DEPTH24_STENCIL8,E.width,E.height):ot(E)?h.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,le,r.DEPTH24_STENCIL8,E.width,E.height):r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_STENCIL,E.width,E.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.RENDERBUFFER,P)}else{const le=E.isWebGLMultipleRenderTargets===!0?E.texture:[E.texture];for(let re=0;re0){q.__webglFramebuffer[pe]=[];for(let ye=0;ye0){q.__webglFramebuffer=[];for(let pe=0;pe0&&ot(P)===!1){const pe=fe?E:[E];q.__webglMultisampledFramebuffer=r.createFramebuffer(),q.__webglColorRenderbuffer=[],t.bindFramebuffer(r.FRAMEBUFFER,q.__webglMultisampledFramebuffer);for(let ye=0;ye0)for(let ye=0;ye0)for(let ye=0;ye0&&ot(P)===!1){const E=P.isWebGLMultipleRenderTargets?P.texture:[P.texture],q=P.width,le=P.height;let re=r.COLOR_BUFFER_BIT;const fe=[],Me=P.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,pe=n.get(P),ye=P.isWebGLMultipleRenderTargets===!0;if(ye)for(let N=0;N0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&E.__useRenderToTexture!==!1}function Tt(P){const E=o.render.frame;_.get(P)!==E&&(_.set(P,E),P.update())}function Ct(P,E){const q=P.colorSpace,le=P.format,re=P.type;return P.isCompressedTexture===!0||P.isVideoTexture===!0||P.format===Ol||q!==an&&q!==Vn&&(pt.getTransfer(q)===At?a===!1?e.has("EXT_sRGB")===!0&&le===sn?(P.format=Ol,P.minFilter=En,P.generateMipmaps=!1):E=pf.sRGBToLinear(E):(le!==sn||re!==fi)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",q)),E}this.allocateTextureUnit=ce,this.resetTextureUnits=J,this.setTexture2D=se,this.setTexture2DArray=me,this.setTexture3D=ve,this.setTextureCube=Q,this.rebindTextures=$e,this.setupRenderTarget=ze,this.updateRenderTargetMipmap=_t,this.updateMultisampleRenderTarget=Ke,this.setupDepthRenderbuffer=Le,this.setupFrameBufferTexture=Ye,this.useMultisampledRTT=ot}function f0(r,e,t){const n=t.isWebGL2;function i(s,o=Vn){let a;const l=pt.getTransfer(o);if(s===fi)return r.UNSIGNED_BYTE;if(s===nf)return r.UNSIGNED_SHORT_4_4_4_4;if(s===rf)return r.UNSIGNED_SHORT_5_5_5_1;if(s===Il)return r.BYTE;if(s===tf)return r.SHORT;if(s===va)return r.UNSIGNED_SHORT;if(s===Ws)return r.INT;if(s===Dn)return r.UNSIGNED_INT;if(s===vn)return r.FLOAT;if(s===Js)return n?r.HALF_FLOAT:(a=e.get("OES_texture_half_float"),a!==null?a.HALF_FLOAT_OES:null);if(s===Bd)return r.ALPHA;if(s===sn)return r.RGBA;if(s===zd)return r.LUMINANCE;if(s===kd)return r.LUMINANCE_ALPHA;if(s===mr)return r.DEPTH_COMPONENT;if(s===hs)return r.DEPTH_STENCIL;if(s===Ol)return a=e.get("EXT_sRGB"),a!==null?a.SRGB_ALPHA_EXT:null;if(s===sf)return r.RED;if(s===Ql)return r.RED_INTEGER;if(s===of)return r.RG;if(s===xa)return r.RG_INTEGER;if(s===Qs)return r.RGBA_INTEGER;if(s===La||s===Ca||s===Pa||s===Da)if(l===At)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(s===La)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===Ca)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===Pa)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===Da)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=e.get("WEBGL_compressed_texture_s3tc"),a!==null){if(s===La)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===Ca)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===Pa)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===Da)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===Dc||s===Ic||s===Nc||s===Fc)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(s===Dc)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===Ic)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===Nc)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===Fc)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===af)return a=e.get("WEBGL_compressed_texture_etc1"),a!==null?a.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===Oc||s===Uc)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(s===Oc)return l===At?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(s===Uc)return l===At?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===Bc||s===zc||s===kc||s===Hc||s===Vc||s===Gc||s===Wc||s===Xc||s===qc||s===jc||s===Yc||s===$c||s===Kc||s===Zc)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(s===Bc)return l===At?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===zc)return l===At?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===kc)return l===At?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===Hc)return l===At?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===Vc)return l===At?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===Gc)return l===At?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===Wc)return l===At?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===Xc)return l===At?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===qc)return l===At?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===jc)return l===At?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===Yc)return l===At?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===$c)return l===At?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===Kc)return l===At?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===Zc)return l===At?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===Ia||s===Jc||s===Qc)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(s===Ia)return l===At?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(s===Jc)return a.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(s===Qc)return a.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(s===Hd||s===eu||s===tu||s===nu)if(a=e.get("EXT_texture_compression_rgtc"),a!==null){if(s===Ia)return a.COMPRESSED_RED_RGTC1_EXT;if(s===eu)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(s===tu)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(s===nu)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return s===pr?n?r.UNSIGNED_INT_24_8:(a=e.get("WEBGL_depth_texture"),a!==null?a.UNSIGNED_INT_24_8_WEBGL:null):r[s]!==void 0?r[s]:null}return{convert:i}}class d0 extends gn{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class dr extends Bt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const p0={type:"move"};class il{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new dr,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new dr,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new C,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new C),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new dr,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new C,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new C),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let i=null,s=null,o=null;const a=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){o=!0;for(const g of e.hand.values()){const m=t.getJointPose(g,n),d=this._getHandJoint(c,g);m!==null&&(d.matrix.fromArray(m.transform.matrix),d.matrix.decompose(d.position,d.rotation,d.scale),d.matrixWorldNeedsUpdate=!0,d.jointRadius=m.radius),d.visible=m!==null}const u=c.joints["index-finger-tip"],f=c.joints["thumb-tip"],h=u.position.distanceTo(f.position),p=.02,_=.005;c.inputState.pinching&&h>p+_?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&h<=p-_&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,n),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));a!==null&&(i=t.getPose(e.targetRaySpace,n),i===null&&s!==null&&(i=s),i!==null&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(p0)))}return a!==null&&(a.visible=i!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=o!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new dr;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}class m0 extends xr{constructor(e,t){super();const n=this;let i=null,s=1,o=null,a="local-floor",l=1,c=null,u=null,f=null,h=null,p=null,_=null;const g=t.getContextAttributes();let m=null,d=null;const x=[],v=[],y=new Ue;let b=null;const M=new gn;M.layers.enable(1),M.viewport=new mt;const T=new gn;T.layers.enable(2),T.viewport=new mt;const I=[M,T],S=new d0;S.layers.enable(1),S.layers.enable(2);let A=null,z=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Q){let oe=x[Q];return oe===void 0&&(oe=new il,x[Q]=oe),oe.getTargetRaySpace()},this.getControllerGrip=function(Q){let oe=x[Q];return oe===void 0&&(oe=new il,x[Q]=oe),oe.getGripSpace()},this.getHand=function(Q){let oe=x[Q];return oe===void 0&&(oe=new il,x[Q]=oe),oe.getHandSpace()};function O(Q){const oe=v.indexOf(Q.inputSource);if(oe===-1)return;const Se=x[oe];Se!==void 0&&(Se.update(Q.inputSource,Q.frame,c||o),Se.dispatchEvent({type:Q.type,data:Q.inputSource}))}function W(){i.removeEventListener("select",O),i.removeEventListener("selectstart",O),i.removeEventListener("selectend",O),i.removeEventListener("squeeze",O),i.removeEventListener("squeezestart",O),i.removeEventListener("squeezeend",O),i.removeEventListener("end",W),i.removeEventListener("inputsourceschange",D);for(let Q=0;Q=0&&(v[De]=null,x[De].disconnect(Se))}for(let oe=0;oe=v.length){v.push(Se),De=qe;break}else if(v[qe]===null){v[qe]=Se,De=qe;break}if(De===-1)break}const _e=x[De];_e&&_e.connect(Se)}}const V=new C,Z=new C;function J(Q,oe,Se){V.setFromMatrixPosition(oe.matrixWorld),Z.setFromMatrixPosition(Se.matrixWorld);const De=V.distanceTo(Z),_e=oe.projectionMatrix.elements,qe=Se.projectionMatrix.elements,We=_e[14]/(_e[10]-1),Fe=_e[14]/(_e[10]+1),Ye=(_e[9]+1)/_e[5],X=(_e[9]-1)/_e[5],Lt=(_e[8]-1)/_e[0],Le=(qe[8]+1)/qe[0],$e=We*Lt,ze=We*Le,_t=De/(-Lt+Le),Ke=_t*-Lt;oe.matrixWorld.decompose(Q.position,Q.quaternion,Q.scale),Q.translateX(Ke),Q.translateZ(_t),Q.matrixWorld.compose(Q.position,Q.quaternion,Q.scale),Q.matrixWorldInverse.copy(Q.matrixWorld).invert();const ke=We+_t,ot=Fe+_t,Tt=$e-Ke,Ct=ze+(De-Ke),P=Ye*Fe/ot*ke,E=X*Fe/ot*ke;Q.projectionMatrix.makePerspective(Tt,Ct,P,E,ke,ot),Q.projectionMatrixInverse.copy(Q.projectionMatrix).invert()}function ce(Q,oe){oe===null?Q.matrixWorld.copy(Q.matrix):Q.matrixWorld.multiplyMatrices(oe.matrixWorld,Q.matrix),Q.matrixWorldInverse.copy(Q.matrixWorld).invert()}this.updateCamera=function(Q){if(i===null)return;S.near=T.near=M.near=Q.near,S.far=T.far=M.far=Q.far,(A!==S.near||z!==S.far)&&(i.updateRenderState({depthNear:S.near,depthFar:S.far}),A=S.near,z=S.far);const oe=Q.parent,Se=S.cameras;ce(S,oe);for(let De=0;De0&&(m.alphaTest.value=d.alphaTest);const x=e.get(d).envMap;if(x&&(m.envMap.value=x,m.flipEnvMap.value=x.isCubeTexture&&x.isRenderTargetTexture===!1?-1:1,m.reflectivity.value=d.reflectivity,m.ior.value=d.ior,m.refractionRatio.value=d.refractionRatio),d.lightMap){m.lightMap.value=d.lightMap;const v=r._useLegacyLights===!0?Math.PI:1;m.lightMapIntensity.value=d.lightMapIntensity*v,t(d.lightMap,m.lightMapTransform)}d.aoMap&&(m.aoMap.value=d.aoMap,m.aoMapIntensity.value=d.aoMapIntensity,t(d.aoMap,m.aoMapTransform))}function o(m,d){m.diffuse.value.copy(d.color),m.opacity.value=d.opacity,d.map&&(m.map.value=d.map,t(d.map,m.mapTransform))}function a(m,d){m.dashSize.value=d.dashSize,m.totalSize.value=d.dashSize+d.gapSize,m.scale.value=d.scale}function l(m,d,x,v){m.diffuse.value.copy(d.color),m.opacity.value=d.opacity,m.size.value=d.size*x,m.scale.value=v*.5,d.map&&(m.map.value=d.map,t(d.map,m.uvTransform)),d.alphaMap&&(m.alphaMap.value=d.alphaMap,t(d.alphaMap,m.alphaMapTransform)),d.alphaTest>0&&(m.alphaTest.value=d.alphaTest)}function c(m,d){m.diffuse.value.copy(d.color),m.opacity.value=d.opacity,m.rotation.value=d.rotation,d.map&&(m.map.value=d.map,t(d.map,m.mapTransform)),d.alphaMap&&(m.alphaMap.value=d.alphaMap,t(d.alphaMap,m.alphaMapTransform)),d.alphaTest>0&&(m.alphaTest.value=d.alphaTest)}function u(m,d){m.specular.value.copy(d.specular),m.shininess.value=Math.max(d.shininess,1e-4)}function f(m,d){d.gradientMap&&(m.gradientMap.value=d.gradientMap)}function h(m,d){m.metalness.value=d.metalness,d.metalnessMap&&(m.metalnessMap.value=d.metalnessMap,t(d.metalnessMap,m.metalnessMapTransform)),m.roughness.value=d.roughness,d.roughnessMap&&(m.roughnessMap.value=d.roughnessMap,t(d.roughnessMap,m.roughnessMapTransform)),e.get(d).envMap&&(m.envMapIntensity.value=d.envMapIntensity)}function p(m,d,x){m.ior.value=d.ior,d.sheen>0&&(m.sheenColor.value.copy(d.sheenColor).multiplyScalar(d.sheen),m.sheenRoughness.value=d.sheenRoughness,d.sheenColorMap&&(m.sheenColorMap.value=d.sheenColorMap,t(d.sheenColorMap,m.sheenColorMapTransform)),d.sheenRoughnessMap&&(m.sheenRoughnessMap.value=d.sheenRoughnessMap,t(d.sheenRoughnessMap,m.sheenRoughnessMapTransform))),d.clearcoat>0&&(m.clearcoat.value=d.clearcoat,m.clearcoatRoughness.value=d.clearcoatRoughness,d.clearcoatMap&&(m.clearcoatMap.value=d.clearcoatMap,t(d.clearcoatMap,m.clearcoatMapTransform)),d.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=d.clearcoatRoughnessMap,t(d.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),d.clearcoatNormalMap&&(m.clearcoatNormalMap.value=d.clearcoatNormalMap,t(d.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(d.clearcoatNormalScale),d.side===xn&&m.clearcoatNormalScale.value.negate())),d.iridescence>0&&(m.iridescence.value=d.iridescence,m.iridescenceIOR.value=d.iridescenceIOR,m.iridescenceThicknessMinimum.value=d.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=d.iridescenceThicknessRange[1],d.iridescenceMap&&(m.iridescenceMap.value=d.iridescenceMap,t(d.iridescenceMap,m.iridescenceMapTransform)),d.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=d.iridescenceThicknessMap,t(d.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),d.transmission>0&&(m.transmission.value=d.transmission,m.transmissionSamplerMap.value=x.texture,m.transmissionSamplerSize.value.set(x.width,x.height),d.transmissionMap&&(m.transmissionMap.value=d.transmissionMap,t(d.transmissionMap,m.transmissionMapTransform)),m.thickness.value=d.thickness,d.thicknessMap&&(m.thicknessMap.value=d.thicknessMap,t(d.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=d.attenuationDistance,m.attenuationColor.value.copy(d.attenuationColor)),d.anisotropy>0&&(m.anisotropyVector.value.set(d.anisotropy*Math.cos(d.anisotropyRotation),d.anisotropy*Math.sin(d.anisotropyRotation)),d.anisotropyMap&&(m.anisotropyMap.value=d.anisotropyMap,t(d.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=d.specularIntensity,m.specularColor.value.copy(d.specularColor),d.specularColorMap&&(m.specularColorMap.value=d.specularColorMap,t(d.specularColorMap,m.specularColorMapTransform)),d.specularIntensityMap&&(m.specularIntensityMap.value=d.specularIntensityMap,t(d.specularIntensityMap,m.specularIntensityMapTransform))}function _(m,d){d.matcap&&(m.matcap.value=d.matcap)}function g(m,d){const x=e.get(d).light;m.referencePosition.value.setFromMatrixPosition(x.matrixWorld),m.nearDistance.value=x.shadow.camera.near,m.farDistance.value=x.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:i}}function g0(r,e,t,n){let i={},s={},o=[];const a=t.isWebGL2?r.getParameter(r.MAX_UNIFORM_BUFFER_BINDINGS):0;function l(x,v){const y=v.program;n.uniformBlockBinding(x,y)}function c(x,v){let y=i[x.id];y===void 0&&(_(x),y=u(x),i[x.id]=y,x.addEventListener("dispose",m));const b=v.program;n.updateUBOMapping(x,b);const M=e.render.frame;s[x.id]!==M&&(h(x),s[x.id]=M)}function u(x){const v=f();x.__bindingPointIndex=v;const y=r.createBuffer(),b=x.__size,M=x.usage;return r.bindBuffer(r.UNIFORM_BUFFER,y),r.bufferData(r.UNIFORM_BUFFER,b,M),r.bindBuffer(r.UNIFORM_BUFFER,null),r.bindBufferBase(r.UNIFORM_BUFFER,v,y),y}function f(){for(let x=0;x0){M=y%b;const O=b-M;M!==0&&O-A.boundary<0&&(y+=b-M,S.__offset=y)}y+=A.storage}return M=y%b,M>0&&(y+=b-M),x.__size=y,x.__cache={},this}function g(x){const v={boundary:0,storage:0};return typeof x=="number"?(v.boundary=4,v.storage=4):x.isVector2?(v.boundary=8,v.storage=8):x.isVector3||x.isColor?(v.boundary=16,v.storage=12):x.isVector4?(v.boundary=16,v.storage=16):x.isMatrix3?(v.boundary=48,v.storage=48):x.isMatrix4?(v.boundary=64,v.storage=64):x.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",x),v}function m(x){const v=x.target;v.removeEventListener("dispose",m);const y=o.indexOf(v.__bindingPointIndex);o.splice(y,1),r.deleteBuffer(i[v.id]),delete i[v.id],delete s[v.id]}function d(){for(const x in i)r.deleteBuffer(i[x]);o=[],i={},s={}}return{bind:l,update:c,dispose:d}}class Pf{constructor(e={}){const{canvas:t=pp(),context:n=null,depth:i=!0,stencil:s=!0,alpha:o=!1,antialias:a=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:f=!1}=e;this.isWebGLRenderer=!0;let h;n!==null?h=n.getContextAttributes().alpha:h=o;const p=new Uint32Array(4),_=new Int32Array(4);let g=null,m=null;const d=[],x=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=Ht,this._useLegacyLights=!1,this.toneMapping=ji,this.toneMappingExposure=1;const v=this;let y=!1,b=0,M=0,T=null,I=-1,S=null;const A=new mt,z=new mt;let O=null;const W=new tt(0);let D=0,V=t.width,Z=t.height,J=1,ce=null,ie=null;const se=new mt(0,0,V,Z),me=new mt(0,0,V,Z);let ve=!1;const Q=new nc;let oe=!1,Se=!1,De=null;const _e=new Ve,qe=new Ue,We=new C,Fe={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Ye(){return T===null?J:1}let X=n;function Lt(R,H){for(let j=0;j{function Ee(){if(K.forEach(function(Ie){Ke.get(Ie).currentProgram.isReady()&&K.delete(Ie)}),K.size===0){Y(R);return}setTimeout(Ee,10)}Le.get("KHR_parallel_shader_compile")!==null?Ee():setTimeout(Ee,10)})};let nt=null;function gt(R){nt&&nt(R)}function Vt(){ft.stop()}function ht(){ft.start()}const ft=new wf;ft.setAnimationLoop(gt),typeof self<"u"&&ft.setContext(self),this.setAnimationLoop=function(R){nt=R,be.setAnimationLoop(R),R===null?ft.stop():ft.start()},be.addEventListener("sessionstart",Vt),be.addEventListener("sessionend",ht),this.render=function(R,H){if(H!==void 0&&H.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(y===!0)return;R.matrixWorldAutoUpdate===!0&&R.updateMatrixWorld(),H.parent===null&&H.matrixWorldAutoUpdate===!0&&H.updateMatrixWorld(),be.enabled===!0&&be.isPresenting===!0&&(be.cameraAutoUpdate===!0&&be.updateCamera(H),H=be.getCamera()),R.isScene===!0&&R.onBeforeRender(v,R,H,T),m=fe.get(R,x.length),m.init(),x.push(m),_e.multiplyMatrices(H.projectionMatrix,H.matrixWorldInverse),Q.setFromProjectionMatrix(_e),Se=this.localClippingEnabled,oe=Me.init(this.clippingPlanes,Se),g=re.get(R,d.length),g.init(),d.push(g),Sn(R,H,0,v.sortObjects),g.finish(),v.sortObjects===!0&&g.sort(ce,ie),this.info.render.frame++,oe===!0&&Me.beginShadows();const j=m.state.shadowsArray;if(pe.render(j,R,H),oe===!0&&Me.endShadows(),this.info.autoReset===!0&&this.info.reset(),ye.render(g,R),m.setupLights(v._useLegacyLights),H.isArrayCamera){const K=H.cameras;for(let Y=0,Ee=K.length;Y0?m=x[x.length-1]:m=null,d.pop(),d.length>0?g=d[d.length-1]:g=null};function Sn(R,H,j,K){if(R.visible===!1)return;if(R.layers.test(H.layers)){if(R.isGroup)j=R.renderOrder;else if(R.isLOD)R.autoUpdate===!0&&R.update(H);else if(R.isLight)m.pushLight(R),R.castShadow&&m.pushShadow(R);else if(R.isSprite){if(!R.frustumCulled||Q.intersectsSprite(R)){K&&We.setFromMatrixPosition(R.matrixWorld).applyMatrix4(_e);const Ie=E.update(R),He=R.material;He.visible&&g.push(R,Ie,He,j,We.z,null)}}else if((R.isMesh||R.isLine||R.isPoints)&&(!R.frustumCulled||Q.intersectsObject(R))){const Ie=E.update(R),He=R.material;if(K&&(R.boundingSphere!==void 0?(R.boundingSphere===null&&R.computeBoundingSphere(),We.copy(R.boundingSphere.center)):(Ie.boundingSphere===null&&Ie.computeBoundingSphere(),We.copy(Ie.boundingSphere.center)),We.applyMatrix4(R.matrixWorld).applyMatrix4(_e)),Array.isArray(He)){const Xe=Ie.groups;for(let et=0,je=Xe.length;et0&&ln(Y,Ee,H,j),K&&ze.viewport(A.copy(K)),Y.length>0&&Pi(Y,H,j),Ee.length>0&&Pi(Ee,H,j),Ie.length>0&&Pi(Ie,H,j),ze.buffers.depth.setTest(!0),ze.buffers.depth.setMask(!0),ze.buffers.color.setMask(!0),ze.setPolygonOffset(!1)}function ln(R,H,j,K){if((j.isScene===!0?j.overrideMaterial:null)!==null)return;const Ee=$e.isWebGL2;De===null&&(De=new $i(1,1,{generateMipmaps:!0,type:Le.has("EXT_color_buffer_half_float")?Js:fi,minFilter:gr,samples:Ee?4:0})),v.getDrawingBufferSize(qe),Ee?De.setSize(qe.x,qe.y):De.setSize(fa(qe.x),fa(qe.y));const Ie=v.getRenderTarget();v.setRenderTarget(De),v.getClearColor(W),D=v.getClearAlpha(),D<1&&v.setClearColor(16777215,.5),v.clear();const He=v.toneMapping;v.toneMapping=ji,Pi(R,j,K),ke.updateMultisampleRenderTarget(De),ke.updateRenderTargetMipmap(De);let Xe=!1;for(let et=0,je=H.length;et0),Ze=!!j.morphAttributes.position,xt=!!j.morphAttributes.normal,Gt=!!j.morphAttributes.color;let zt=ji;K.toneMapped&&(T===null||T.isXRRenderTarget===!0)&&(zt=v.toneMapping);const cn=j.morphAttributes.position||j.morphAttributes.normal||j.morphAttributes.color,at=cn!==void 0?cn.length:0,Je=Ke.get(K),Ji=m.state.lights;if(oe===!0&&(Se===!0||R!==S)){const te=R===S&&K.id===I;Me.setState(K,R,te)}let yt=!1;K.version===Je.__version?(Je.needsLights&&Je.lightsStateVersion!==Ji.state.version||Je.outputColorSpace!==He||Y.isBatchedMesh&&Je.batching===!1||!Y.isBatchedMesh&&Je.batching===!0||Y.isInstancedMesh&&Je.instancing===!1||!Y.isInstancedMesh&&Je.instancing===!0||Y.isSkinnedMesh&&Je.skinning===!1||!Y.isSkinnedMesh&&Je.skinning===!0||Y.isInstancedMesh&&Je.instancingColor===!0&&Y.instanceColor===null||Y.isInstancedMesh&&Je.instancingColor===!1&&Y.instanceColor!==null||Je.envMap!==Xe||K.fog===!0&&Je.fog!==Ee||Je.numClippingPlanes!==void 0&&(Je.numClippingPlanes!==Me.numPlanes||Je.numIntersection!==Me.numIntersection)||Je.vertexAlphas!==et||Je.vertexTangents!==je||Je.morphTargets!==Ze||Je.morphNormals!==xt||Je.morphColors!==Gt||Je.toneMapping!==zt||$e.isWebGL2===!0&&Je.morphTargetsCount!==at)&&(yt=!0):(yt=!0,Je.__version=K.version);let Fn=Je.currentProgram;yt===!0&&(Fn=ri(K,H,Y));let Er=!1,Jt=!1,nn=!1;const Wt=Fn.getUniforms(),w=Je.uniforms;if(ze.useProgram(Fn.program)&&(Er=!0,Jt=!0,nn=!0),K.id!==I&&(I=K.id,Jt=!0),Er||S!==R){Wt.setValue(X,"projectionMatrix",R.projectionMatrix),Wt.setValue(X,"viewMatrix",R.matrixWorldInverse);const te=Wt.map.cameraPosition;te!==void 0&&te.setValue(X,We.setFromMatrixPosition(R.matrixWorld)),$e.logarithmicDepthBuffer&&Wt.setValue(X,"logDepthBufFC",2/(Math.log(R.far+1)/Math.LN2)),(K.isMeshPhongMaterial||K.isMeshToonMaterial||K.isMeshLambertMaterial||K.isMeshBasicMaterial||K.isMeshStandardMaterial||K.isShaderMaterial)&&Wt.setValue(X,"isOrthographic",R.isOrthographicCamera===!0),S!==R&&(S=R,Jt=!0,nn=!0)}if(Y.isSkinnedMesh){Wt.setOptional(X,Y,"bindMatrix"),Wt.setOptional(X,Y,"bindMatrixInverse");const te=Y.skeleton;te&&($e.floatVertexTextures?(te.boneTexture===null&&te.computeBoneTexture(),Wt.setValue(X,"boneTexture",te.boneTexture,ke)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}Y.isBatchedMesh&&(Wt.setOptional(X,Y,"batchingTexture"),Wt.setValue(X,"batchingTexture",Y._matricesTexture,ke));const B=j.morphAttributes;if((B.position!==void 0||B.normal!==void 0||B.color!==void 0&&$e.isWebGL2===!0)&&N.update(Y,j,Fn),(Jt||Je.receiveShadow!==Y.receiveShadow)&&(Je.receiveShadow=Y.receiveShadow,Wt.setValue(X,"receiveShadow",Y.receiveShadow)),K.isMeshGouraudMaterial&&K.envMap!==null&&(w.envMap.value=Xe,w.flipEnvMap.value=Xe.isCubeTexture&&Xe.isRenderTargetTexture===!1?-1:1),Jt&&(Wt.setValue(X,"toneMappingExposure",v.toneMappingExposure),Je.needsLights&&Di(w,nn),Ee&&K.fog===!0&&le.refreshFogUniforms(w,Ee),le.refreshMaterialUniforms(w,K,J,Z,De),sa.upload(X,br(Je),w,ke)),K.isShaderMaterial&&K.uniformsNeedUpdate===!0&&(sa.upload(X,br(Je),w,ke),K.uniformsNeedUpdate=!1),K.isSpriteMaterial&&Wt.setValue(X,"center",Y.center),Wt.setValue(X,"modelViewMatrix",Y.modelViewMatrix),Wt.setValue(X,"normalMatrix",Y.normalMatrix),Wt.setValue(X,"modelMatrix",Y.matrixWorld),K.isShaderMaterial||K.isRawShaderMaterial){const te=K.uniformsGroups;for(let G=0,ue=te.length;G0&&ke.useMultisampledRTT(R)===!1?Y=Ke.get(R).__webglMultisampledFramebuffer:Array.isArray(je)?Y=je[j]:Y=je,A.copy(R.viewport),z.copy(R.scissor),O=R.scissorTest}else A.copy(se).multiplyScalar(J).floor(),z.copy(me).multiplyScalar(J).floor(),O=ve;if(ze.bindFramebuffer(X.FRAMEBUFFER,Y)&&$e.drawBuffers&&K&&ze.drawBuffers(R,Y),ze.viewport(A),ze.scissor(z),ze.setScissorTest(O),Ee){const Xe=Ke.get(R.texture);X.framebufferTexture2D(X.FRAMEBUFFER,X.COLOR_ATTACHMENT0,X.TEXTURE_CUBE_MAP_POSITIVE_X+H,Xe.__webglTexture,j)}else if(Ie){const Xe=Ke.get(R.texture),et=H||0;X.framebufferTextureLayer(X.FRAMEBUFFER,X.COLOR_ATTACHMENT0,Xe.__webglTexture,j||0,et)}I=-1},this.readRenderTargetPixels=function(R,H,j,K,Y,Ee,Ie){if(!(R&&R.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let He=Ke.get(R).__webglFramebuffer;if(R.isWebGLCubeRenderTarget&&Ie!==void 0&&(He=He[Ie]),He){ze.bindFramebuffer(X.FRAMEBUFFER,He);try{const Xe=R.texture,et=Xe.format,je=Xe.type;if(et!==sn&&Oe.convert(et)!==X.getParameter(X.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const Ze=je===Js&&(Le.has("EXT_color_buffer_half_float")||$e.isWebGL2&&Le.has("EXT_color_buffer_float"));if(je!==fi&&Oe.convert(je)!==X.getParameter(X.IMPLEMENTATION_COLOR_READ_TYPE)&&!(je===vn&&($e.isWebGL2||Le.has("OES_texture_float")||Le.has("WEBGL_color_buffer_float")))&&!Ze){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}H>=0&&H<=R.width-K&&j>=0&&j<=R.height-Y&&X.readPixels(H,j,K,Y,Oe.convert(et),Oe.convert(je),Ee)}finally{const Xe=T!==null?Ke.get(T).__webglFramebuffer:null;ze.bindFramebuffer(X.FRAMEBUFFER,Xe)}}},this.copyFramebufferToTexture=function(R,H,j=0){const K=Math.pow(2,-j),Y=Math.floor(H.image.width*K),Ee=Math.floor(H.image.height*K);ke.setTexture2D(H,0),X.copyTexSubImage2D(X.TEXTURE_2D,j,0,0,R.x,R.y,Y,Ee),ze.unbindTexture()},this.copyTextureToTexture=function(R,H,j,K=0){const Y=H.image.width,Ee=H.image.height,Ie=Oe.convert(j.format),He=Oe.convert(j.type);ke.setTexture2D(j,0),X.pixelStorei(X.UNPACK_FLIP_Y_WEBGL,j.flipY),X.pixelStorei(X.UNPACK_PREMULTIPLY_ALPHA_WEBGL,j.premultiplyAlpha),X.pixelStorei(X.UNPACK_ALIGNMENT,j.unpackAlignment),H.isDataTexture?X.texSubImage2D(X.TEXTURE_2D,K,R.x,R.y,Y,Ee,Ie,He,H.image.data):H.isCompressedTexture?X.compressedTexSubImage2D(X.TEXTURE_2D,K,R.x,R.y,H.mipmaps[0].width,H.mipmaps[0].height,Ie,H.mipmaps[0].data):X.texSubImage2D(X.TEXTURE_2D,K,R.x,R.y,Ie,He,H.image),K===0&&j.generateMipmaps&&X.generateMipmap(X.TEXTURE_2D),ze.unbindTexture()},this.copyTextureToTexture3D=function(R,H,j,K,Y=0){if(v.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const Ee=R.max.x-R.min.x+1,Ie=R.max.y-R.min.y+1,He=R.max.z-R.min.z+1,Xe=Oe.convert(K.format),et=Oe.convert(K.type);let je;if(K.isData3DTexture)ke.setTexture3D(K,0),je=X.TEXTURE_3D;else if(K.isDataArrayTexture)ke.setTexture2DArray(K,0),je=X.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}X.pixelStorei(X.UNPACK_FLIP_Y_WEBGL,K.flipY),X.pixelStorei(X.UNPACK_PREMULTIPLY_ALPHA_WEBGL,K.premultiplyAlpha),X.pixelStorei(X.UNPACK_ALIGNMENT,K.unpackAlignment);const Ze=X.getParameter(X.UNPACK_ROW_LENGTH),xt=X.getParameter(X.UNPACK_IMAGE_HEIGHT),Gt=X.getParameter(X.UNPACK_SKIP_PIXELS),zt=X.getParameter(X.UNPACK_SKIP_ROWS),cn=X.getParameter(X.UNPACK_SKIP_IMAGES),at=j.isCompressedTexture?j.mipmaps[0]:j.image;X.pixelStorei(X.UNPACK_ROW_LENGTH,at.width),X.pixelStorei(X.UNPACK_IMAGE_HEIGHT,at.height),X.pixelStorei(X.UNPACK_SKIP_PIXELS,R.min.x),X.pixelStorei(X.UNPACK_SKIP_ROWS,R.min.y),X.pixelStorei(X.UNPACK_SKIP_IMAGES,R.min.z),j.isDataTexture||j.isData3DTexture?X.texSubImage3D(je,Y,H.x,H.y,H.z,Ee,Ie,He,Xe,et,at.data):j.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),X.compressedTexSubImage3D(je,Y,H.x,H.y,H.z,Ee,Ie,He,Xe,at.data)):X.texSubImage3D(je,Y,H.x,H.y,H.z,Ee,Ie,He,Xe,et,at),X.pixelStorei(X.UNPACK_ROW_LENGTH,Ze),X.pixelStorei(X.UNPACK_IMAGE_HEIGHT,xt),X.pixelStorei(X.UNPACK_SKIP_PIXELS,Gt),X.pixelStorei(X.UNPACK_SKIP_ROWS,zt),X.pixelStorei(X.UNPACK_SKIP_IMAGES,cn),Y===0&&K.generateMipmaps&&X.generateMipmap(je),ze.unbindTexture()},this.initTexture=function(R){R.isCubeTexture?ke.setTextureCube(R,0):R.isData3DTexture?ke.setTexture3D(R,0):R.isDataArrayTexture||R.isCompressedArrayTexture?ke.setTexture2DArray(R,0):ke.setTexture2D(R,0),ze.unbindTexture()},this.resetState=function(){b=0,M=0,T=null,ze.reset(),Ae.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Ai}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=e===ec?"display-p3":"srgb",t.unpackColorSpace=pt.workingColorSpace===ya?"display-p3":"srgb"}get physicallyCorrectLights(){return console.warn("THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),!this.useLegacyLights}set physicallyCorrectLights(e){console.warn("THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),this.useLegacyLights=!e}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===Ht?Yi:cf}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===Yi?Ht:an}get useLegacyLights(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights}set useLegacyLights(e){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=e}}class v0 extends Pf{}v0.prototype.isWebGL1Renderer=!0;class x0 extends Bt{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t}}class y0{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Fl,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=Jn()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return console.warn('THREE.InterleavedBuffer: "updateRange" is deprecated and removed in r169. Use "addUpdateRange()" instead.'),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,s=this.stride;il)continue;h.applyMatrix4(this.matrixWorld);const I=e.ray.origin.distanceTo(h);Ie.far||t.push({distance:I,point:f.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}else{const d=Math.max(0,o.start),x=Math.min(m.count,o.start+o.count);for(let v=d,y=x-1;vl)continue;h.applyMatrix4(this.matrixWorld);const M=e.ray.origin.distanceTo(h);Me.far||t.push({distance:M,point:f.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;si.far)return;s.push({distance:c,distanceToRay:Math.sqrt(a),point:l,index:e,face:null,object:o})}}class lc extends di{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new tt(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new tt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=uf,this.normalScale=new Ue(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.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Ci extends lc{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Ue(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return tn(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new tt(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new tt(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new tt(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}function Oo(r,e,t){return!r||!t&&r.constructor===e?r:typeof e.BYTES_PER_ELEMENT=="number"?new e(r):Array.prototype.slice.call(r)}function L0(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}function C0(r){function e(i,s){return r[i]-r[s]}const t=r.length,n=new Array(t);for(let i=0;i!==t;++i)n[i]=i;return n.sort(e),n}function lh(r,e,t){const n=r.length,i=new r.constructor(n);for(let s=0,o=0;o!==n;++s){const a=t[s]*e;for(let l=0;l!==e;++l)i[o++]=r[a+l]}return i}function Ff(r,e,t,n){let i=1,s=r[0];for(;s!==void 0&&s[n]===void 0;)s=r[i++];if(s===void 0)return;let o=s[n];if(o!==void 0)if(Array.isArray(o))do o=s[n],o!==void 0&&(e.push(s.time),t.push.apply(t,o)),s=r[i++];while(s!==void 0);else if(o.toArray!==void 0)do o=s[n],o!==void 0&&(e.push(s.time),o.toArray(t,t.length)),s=r[i++];while(s!==void 0);else do o=s[n],o!==void 0&&(e.push(s.time),t.push(o)),s=r[i++];while(s!==void 0)}class ao{constructor(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let n=this._cachedIndex,i=t[n],s=t[n-1];n:{e:{let o;t:{i:if(!(e=s)){const a=t[1];e=s)break e}o=n,n=0;break t}break n}for(;n>>1;et;)--o;if(++o,s!==0||o!==i){s>=o&&(o=Math.max(o,1),s=o-1);const a=this.getValueSize();this.times=n.slice(s,o),this.values=this.values.slice(s*a,o*a)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,i=this.values,s=n.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let a=0;a!==s;a++){const l=n[a];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,l),e=!1;break}if(o!==null&&o>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,l,o),e=!1;break}o=l}if(i!==void 0&&L0(i))for(let a=0,l=i.length;a!==l;++a){const c=i[a];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,c),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===Na,s=e.length-1;let o=1;for(let a=1;a0){e[o]=e[s];for(let a=s*n,l=o*n,c=0;c!==n;++c)t[l+c]=t[a+c];++o}return o!==e.length?(this.times=e.slice(0,o),this.values=t.slice(0,o*n)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),n=this.constructor,i=new n(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}}_i.prototype.TimeBufferType=Float32Array;_i.prototype.ValueBufferType=Float32Array;_i.prototype.DefaultInterpolation=fs;class xs extends _i{}xs.prototype.ValueTypeName="bool";xs.prototype.ValueBufferType=Array;xs.prototype.DefaultInterpolation=eo;xs.prototype.InterpolantFactoryMethodLinear=void 0;xs.prototype.InterpolantFactoryMethodSmooth=void 0;class Of extends _i{}Of.prototype.ValueTypeName="color";class ms extends _i{}ms.prototype.ValueTypeName="number";class N0 extends ao{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(n-t)/(i-t);let c=e*a;for(let u=c+a;c!==u;c+=4)mi.slerpFlat(s,0,o,c-a,o,c,l);return s}}class vr extends _i{InterpolantFactoryMethodLinear(e){return new N0(this.times,this.values,this.getValueSize(),e)}}vr.prototype.ValueTypeName="quaternion";vr.prototype.DefaultInterpolation=fs;vr.prototype.InterpolantFactoryMethodSmooth=void 0;class ys extends _i{}ys.prototype.ValueTypeName="string";ys.prototype.ValueBufferType=Array;ys.prototype.DefaultInterpolation=eo;ys.prototype.InterpolantFactoryMethodLinear=void 0;ys.prototype.InterpolantFactoryMethodSmooth=void 0;class _s extends _i{}_s.prototype.ValueTypeName="vector";class F0{constructor(e,t=-1,n,i=Vd){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=Jn(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,i=1/(e.fps||1);for(let o=0,a=n.length;o!==a;++o)t.push(U0(n[o]).scale(i));const s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){const t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,o=n.length;s!==o;++s)t.push(_i.toJSON(n[s]));return i}static CreateFromMorphTargetSequence(e,t,n,i){const s=t.length,o=[];for(let a=0;a1){const f=u[1];let h=i[f];h||(i[f]=h=[]),h.push(c)}}const o=[];for(const a in i)o.push(this.CreateFromMorphTargetSequence(a,i[a],t,n));return o}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(f,h,p,_,g){if(p.length!==0){const m=[],d=[];Ff(p,m,d,_),m.length!==0&&g.push(new f(h,m,d))}},i=[],s=e.name||"default",o=e.fps||30,a=e.blendMode;let l=e.length||-1;const c=e.hierarchy||[];for(let f=0;f{t&&t(s),this.manager.itemEnd(e)},0),s;if(wi[e]!==void 0){wi[e].push({onLoad:t,onProgress:n,onError:i});return}wi[e]=[],wi[e].push({onLoad:t,onProgress:n,onError:i});const o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,l=this.responseType;fetch(o).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;const u=wi[e],f=c.body.getReader(),h=c.headers.get("Content-Length")||c.headers.get("X-File-Size"),p=h?parseInt(h):0,_=p!==0;let g=0;const m=new ReadableStream({start(d){x();function x(){f.read().then(({done:v,value:y})=>{if(v)d.close();else{g+=y.byteLength;const b=new ProgressEvent("progress",{lengthComputable:_,loaded:g,total:p});for(let M=0,T=u.length;M{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(u=>new DOMParser().parseFromString(u,a));case"json":return c.json();default:if(a===void 0)return c.text();{const f=/charset="?([^;"\s]*)"?/i.exec(a),h=f&&f[1]?f[1].toLowerCase():void 0,p=new TextDecoder(h);return c.arrayBuffer().then(_=>p.decode(_))}}}).then(c=>{gs.add(e,c);const u=wi[e];delete wi[e];for(let f=0,h=u.length;f{const u=wi[e];if(u===void 0)throw this.manager.itemError(e),c;delete wi[e];for(let f=0,h=u.length;f{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class H0 extends bs{constructor(e){super(e)}load(e,t,n,i){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,o=gs.get(e);if(o!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o;const a=to("img");function l(){u(),gs.add(e,this),t&&t(this),s.manager.itemEnd(e)}function c(f){u(),i&&i(f),s.manager.itemError(e),s.manager.itemEnd(e)}function u(){a.removeEventListener("load",l,!1),a.removeEventListener("error",c,!1)}return a.addEventListener("load",l,!1),a.addEventListener("error",c,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),s.manager.itemStart(e),a.src=e,a}}class V0 extends bs{constructor(e){super(e)}load(e,t,n,i){const s=new on,o=new H0(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(e,function(a){s.image=a,s.needsUpdate=!0,t!==void 0&&t(s)},n,i),s}}class Ea extends Bt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new tt(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),t}}const al=new Ve,ch=new C,uh=new C;class cc{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Ue(512,512),this.map=null,this.mapPass=null,this.matrix=new Ve,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new nc,this._frameExtents=new Ue(1,1),this._viewportCount=1,this._viewports=[new mt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;ch.setFromMatrixPosition(e.matrixWorld),t.position.copy(ch),uh.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(uh),t.updateMatrixWorld(),al.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(al),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(al)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class G0 extends cc{constructor(){super(new gn(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const t=this.camera,n=ds*2*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height,s=e.distance||t.far;(n!==t.fov||i!==t.aspect||s!==t.far)&&(t.fov=n,t.aspect=i,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class W0 extends Ea{constructor(e,t,n=0,i=Math.PI/3,s=0,o=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Bt.DEFAULT_UP),this.updateMatrix(),this.target=new Bt,this.distance=n,this.angle=i,this.penumbra=s,this.decay=o,this.map=null,this.shadow=new G0}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}const hh=new Ve,Ds=new C,ll=new C;class X0 extends cc{constructor(){super(new gn(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Ue(4,2),this._viewportCount=6,this._viewports=[new mt(2,1,1,1),new mt(0,1,1,1),new mt(3,1,1,1),new mt(1,1,1,1),new mt(3,0,1,1),new mt(1,0,1,1)],this._cubeDirections=[new C(1,0,0),new C(-1,0,0),new C(0,0,1),new C(0,0,-1),new C(0,1,0),new C(0,-1,0)],this._cubeUps=[new C(0,1,0),new C(0,1,0),new C(0,1,0),new C(0,1,0),new C(0,0,1),new C(0,0,-1)]}updateMatrices(e,t=0){const n=this.camera,i=this.matrix,s=e.distance||n.far;s!==n.far&&(n.far=s,n.updateProjectionMatrix()),Ds.setFromMatrixPosition(e.matrixWorld),n.position.copy(Ds),ll.copy(n.position),ll.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(ll),n.updateMatrixWorld(),i.makeTranslation(-Ds.x,-Ds.y,-Ds.z),hh.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(hh)}}class q0 extends Ea{constructor(e,t,n=0,i=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new X0}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class j0 extends cc{constructor(){super(new oo(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Bf extends Ea{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Bt.DEFAULT_UP),this.updateMatrix(),this.target=new Bt,this.shadow=new j0}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class Y0 extends Ea{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class Ys{static decodeText(e){if(typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let n=0,i=e.length;n"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,o=gs.get(e);if(o!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o;const a={};a.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",a.headers=this.requestHeader,fetch(e,a).then(function(l){return l.blob()}).then(function(l){return createImageBitmap(l,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(l){gs.add(e,l),t&&t(l),s.manager.itemEnd(e)}).catch(function(l){i&&i(l),s.manager.itemError(e),s.manager.itemEnd(e)}),s.manager.itemStart(e)}}const uc="\\[\\]\\.:\\/",K0=new RegExp("["+uc+"]","g"),hc="[^"+uc+"]",Z0="[^"+uc.replace("\\.","")+"]",J0=/((?:WC+[\/:])*)/.source.replace("WC",hc),Q0=/(WCOD+)?/.source.replace("WCOD",Z0),ex=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",hc),tx=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",hc),nx=new RegExp("^"+J0+Q0+ex+tx+"$"),ix=["material","materials","bones","map"];class rx{constructor(e,t,n){const i=n||vt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,s=n.length;i!==s;++i)n[i].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class vt{constructor(e,t,n){this.path=t,this.parsedPath=n||vt.parseTrackName(t),this.node=vt.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new vt.Composite(e,t,n):new vt(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(K0,"")}static parseTrackName(e){const t=nx.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){const s=n.nodeName.substring(i+1);ix.indexOf(s)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=s)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){const n=function(s){for(let o=0;oMath.PI&&(ge-=we),ae<-Math.PI?ae+=we:ae>Math.PI&&(ae-=we),ge<=ae?a.theta=Math.max(ge,Math.min(ae,a.theta)):a.theta=a.theta>(ge+ae)/2?Math.max(ge,a.theta):Math.min(ae,a.theta)),a.phi=Math.max(n.minPolarAngle,Math.min(n.maxPolarAngle,a.phi)),a.makeSafe(),n.enableDamping===!0?n.target.addScaledVector(u,n.dampingFactor):n.target.add(u),n.target.sub(n.cursor),n.target.clampLength(n.minTargetRadius,n.maxTargetRadius),n.target.add(n.cursor),n.zoomToCursor&&M||n.object.isOrthographicCamera?a.radius=ie(a.radius):a.radius=ie(a.radius*c),N.setFromSpherical(a),N.applyQuaternion(ne),F.copy(n.target).add(N),n.object.lookAt(n.target),n.enableDamping===!0?(l.theta*=1-n.dampingFactor,l.phi*=1-n.dampingFactor,u.multiplyScalar(1-n.dampingFactor)):(l.set(0,0,0),u.set(0,0,0));let ee=!1;if(n.zoomToCursor&&M){let he=null;if(n.object.isPerspectiveCamera){const Re=N.length();he=ie(Re*c);const nt=Re-he;n.object.position.addScaledVector(y,nt),n.object.updateMatrixWorld()}else if(n.object.isOrthographicCamera){const Re=new C(b.x,b.y,0);Re.unproject(n.object),n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/c)),n.object.updateProjectionMatrix(),ee=!0;const nt=new C(b.x,b.y,0);nt.unproject(n.object),n.object.position.sub(nt).add(Re),n.object.updateMatrixWorld(),he=N.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),n.zoomToCursor=!1;he!==null&&(this.screenSpacePanning?n.target.set(0,0,-1).transformDirection(n.object.matrix).multiplyScalar(he).add(n.object.position):(Bo.origin.copy(n.object.position),Bo.direction.set(0,0,-1).transformDirection(n.object.matrix),Math.abs(n.object.up.dot(Bo.direction))o||8*(1-Ae.dot(n.object.quaternion))>o||Ce.distanceToSquared(n.target)>0?(n.dispatchEvent(ph),Oe.copy(n.object.position),Ae.copy(n.object.quaternion),Ce.copy(n.target),!0):!1}}(),this.dispose=function(){n.domElement.removeEventListener("contextmenu",re),n.domElement.removeEventListener("pointerdown",Ke),n.domElement.removeEventListener("pointercancel",ot),n.domElement.removeEventListener("wheel",P),n.domElement.removeEventListener("pointermove",ke),n.domElement.removeEventListener("pointerup",ot),n._domElementKeyEvents!==null&&(n._domElementKeyEvents.removeEventListener("keydown",E),n._domElementKeyEvents=null)};const n=this,i={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let s=i.NONE;const o=1e-6,a=new fh,l=new fh;let c=1;const u=new C,f=new Ue,h=new Ue,p=new Ue,_=new Ue,g=new Ue,m=new Ue,d=new Ue,x=new Ue,v=new Ue,y=new C,b=new Ue;let M=!1;const T=[],I={};function S(N){return N!==null?2*Math.PI/60*n.autoRotateSpeed*N:2*Math.PI/60/60*n.autoRotateSpeed}function A(){return Math.pow(.95,n.zoomSpeed)}function z(N){l.theta-=N}function O(N){l.phi-=N}const W=function(){const N=new C;return function(ne,Oe){N.setFromMatrixColumn(Oe,0),N.multiplyScalar(-ne),u.add(N)}}(),D=function(){const N=new C;return function(ne,Oe){n.screenSpacePanning===!0?N.setFromMatrixColumn(Oe,1):(N.setFromMatrixColumn(Oe,0),N.crossVectors(n.object.up,N)),N.multiplyScalar(ne),u.add(N)}}(),V=function(){const N=new C;return function(ne,Oe){const Ae=n.domElement;if(n.object.isPerspectiveCamera){const Ce=n.object.position;N.copy(Ce).sub(n.target);let we=N.length();we*=Math.tan(n.object.fov/2*Math.PI/180),W(2*ne*we/Ae.clientHeight,n.object.matrix),D(2*Oe*we/Ae.clientHeight,n.object.matrix)}else n.object.isOrthographicCamera?(W(ne*(n.object.right-n.object.left)/n.object.zoom/Ae.clientWidth,n.object.matrix),D(Oe*(n.object.top-n.object.bottom)/n.object.zoom/Ae.clientHeight,n.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),n.enablePan=!1)}}();function Z(N){n.object.isPerspectiveCamera||n.object.isOrthographicCamera?c/=N:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function J(N){n.object.isPerspectiveCamera||n.object.isOrthographicCamera?c*=N:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function ce(N){if(!n.zoomToCursor)return;M=!0;const de=n.domElement.getBoundingClientRect(),ne=N.clientX-de.left,Oe=N.clientY-de.top,Ae=de.width,Ce=de.height;b.x=ne/Ae*2-1,b.y=-(Oe/Ce)*2+1,y.set(b.x,b.y,1).unproject(n.object).sub(n.object.position).normalize()}function ie(N){return Math.max(n.minDistance,Math.min(n.maxDistance,N))}function se(N){f.set(N.clientX,N.clientY)}function me(N){ce(N),d.set(N.clientX,N.clientY)}function ve(N){_.set(N.clientX,N.clientY)}function Q(N){h.set(N.clientX,N.clientY),p.subVectors(h,f).multiplyScalar(n.rotateSpeed);const de=n.domElement;z(2*Math.PI*p.x/de.clientHeight),O(2*Math.PI*p.y/de.clientHeight),f.copy(h),n.update()}function oe(N){x.set(N.clientX,N.clientY),v.subVectors(x,d),v.y>0?Z(A()):v.y<0&&J(A()),d.copy(x),n.update()}function Se(N){g.set(N.clientX,N.clientY),m.subVectors(g,_).multiplyScalar(n.panSpeed),V(m.x,m.y),_.copy(g),n.update()}function De(N){ce(N),N.deltaY<0?J(A()):N.deltaY>0&&Z(A()),n.update()}function _e(N){let de=!1;switch(N.code){case n.keys.UP:N.ctrlKey||N.metaKey||N.shiftKey?O(2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):V(0,n.keyPanSpeed),de=!0;break;case n.keys.BOTTOM:N.ctrlKey||N.metaKey||N.shiftKey?O(-2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):V(0,-n.keyPanSpeed),de=!0;break;case n.keys.LEFT:N.ctrlKey||N.metaKey||N.shiftKey?z(2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):V(n.keyPanSpeed,0),de=!0;break;case n.keys.RIGHT:N.ctrlKey||N.metaKey||N.shiftKey?z(-2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):V(-n.keyPanSpeed,0),de=!0;break}de&&(N.preventDefault(),n.update())}function qe(){if(T.length===1)f.set(T[0].pageX,T[0].pageY);else{const N=.5*(T[0].pageX+T[1].pageX),de=.5*(T[0].pageY+T[1].pageY);f.set(N,de)}}function We(){if(T.length===1)_.set(T[0].pageX,T[0].pageY);else{const N=.5*(T[0].pageX+T[1].pageX),de=.5*(T[0].pageY+T[1].pageY);_.set(N,de)}}function Fe(){const N=T[0].pageX-T[1].pageX,de=T[0].pageY-T[1].pageY,ne=Math.sqrt(N*N+de*de);d.set(0,ne)}function Ye(){n.enableZoom&&Fe(),n.enablePan&&We()}function X(){n.enableZoom&&Fe(),n.enableRotate&&qe()}function Lt(N){if(T.length==1)h.set(N.pageX,N.pageY);else{const ne=ye(N),Oe=.5*(N.pageX+ne.x),Ae=.5*(N.pageY+ne.y);h.set(Oe,Ae)}p.subVectors(h,f).multiplyScalar(n.rotateSpeed);const de=n.domElement;z(2*Math.PI*p.x/de.clientHeight),O(2*Math.PI*p.y/de.clientHeight),f.copy(h)}function Le(N){if(T.length===1)g.set(N.pageX,N.pageY);else{const de=ye(N),ne=.5*(N.pageX+de.x),Oe=.5*(N.pageY+de.y);g.set(ne,Oe)}m.subVectors(g,_).multiplyScalar(n.panSpeed),V(m.x,m.y),_.copy(g)}function $e(N){const de=ye(N),ne=N.pageX-de.x,Oe=N.pageY-de.y,Ae=Math.sqrt(ne*ne+Oe*Oe);x.set(0,Ae),v.set(0,Math.pow(x.y/d.y,n.zoomSpeed)),Z(v.y),d.copy(x)}function ze(N){n.enableZoom&&$e(N),n.enablePan&&Le(N)}function _t(N){n.enableZoom&&$e(N),n.enableRotate&&Lt(N)}function Ke(N){n.enabled!==!1&&(T.length===0&&(n.domElement.setPointerCapture(N.pointerId),n.domElement.addEventListener("pointermove",ke),n.domElement.addEventListener("pointerup",ot)),fe(N),N.pointerType==="touch"?q(N):Tt(N))}function ke(N){n.enabled!==!1&&(N.pointerType==="touch"?le(N):Ct(N))}function ot(N){Me(N),T.length===0&&(n.domElement.releasePointerCapture(N.pointerId),n.domElement.removeEventListener("pointermove",ke),n.domElement.removeEventListener("pointerup",ot)),n.dispatchEvent(mh),s=i.NONE}function Tt(N){let de;switch(N.button){case 0:de=n.mouseButtons.LEFT;break;case 1:de=n.mouseButtons.MIDDLE;break;case 2:de=n.mouseButtons.RIGHT;break;default:de=-1}switch(de){case Mr.DOLLY:if(n.enableZoom===!1)return;me(N),s=i.DOLLY;break;case Mr.ROTATE:if(N.ctrlKey||N.metaKey||N.shiftKey){if(n.enablePan===!1)return;ve(N),s=i.PAN}else{if(n.enableRotate===!1)return;se(N),s=i.ROTATE}break;case Mr.PAN:if(N.ctrlKey||N.metaKey||N.shiftKey){if(n.enableRotate===!1)return;se(N),s=i.ROTATE}else{if(n.enablePan===!1)return;ve(N),s=i.PAN}break;default:s=i.NONE}s!==i.NONE&&n.dispatchEvent(cl)}function Ct(N){switch(s){case i.ROTATE:if(n.enableRotate===!1)return;Q(N);break;case i.DOLLY:if(n.enableZoom===!1)return;oe(N);break;case i.PAN:if(n.enablePan===!1)return;Se(N);break}}function P(N){n.enabled===!1||n.enableZoom===!1||s!==i.NONE||(N.preventDefault(),n.dispatchEvent(cl),De(N),n.dispatchEvent(mh))}function E(N){n.enabled===!1||n.enablePan===!1||_e(N)}function q(N){switch(pe(N),T.length){case 1:switch(n.touches.ONE){case Tr.ROTATE:if(n.enableRotate===!1)return;qe(),s=i.TOUCH_ROTATE;break;case Tr.PAN:if(n.enablePan===!1)return;We(),s=i.TOUCH_PAN;break;default:s=i.NONE}break;case 2:switch(n.touches.TWO){case Tr.DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;Ye(),s=i.TOUCH_DOLLY_PAN;break;case Tr.DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;X(),s=i.TOUCH_DOLLY_ROTATE;break;default:s=i.NONE}break;default:s=i.NONE}s!==i.NONE&&n.dispatchEvent(cl)}function le(N){switch(pe(N),s){case i.TOUCH_ROTATE:if(n.enableRotate===!1)return;Lt(N),n.update();break;case i.TOUCH_PAN:if(n.enablePan===!1)return;Le(N),n.update();break;case i.TOUCH_DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;ze(N),n.update();break;case i.TOUCH_DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;_t(N),n.update();break;default:s=i.NONE}}function re(N){n.enabled!==!1&&N.preventDefault()}function fe(N){T.push(N)}function Me(N){delete I[N.pointerId];for(let de=0;de=2.0 are supported."));return}const c=new Vx(s,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let u=0;u=0&&a[f]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+f+'".')}}c.setExtensions(o),c.setPlugins(a),c.parse(n,i)}parseAsync(e,t){const n=this;return new Promise(function(i,s){n.parse(e,t,i,s)})}}function hx(){let r={};return{get:function(e){return r[e]},add:function(e,t){r[e]=t},remove:function(e){delete r[e]},removeAll:function(){r={}}}}const lt={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class fx{constructor(e){this.parser=e,this.name=lt.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,s.source,o)}}class Mx{constructor(e){this.parser=e,this.name=lt.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,i=n.json,s=i.textures[e];if(!s.extensions||!s.extensions[t])return null;const o=s.extensions[t],a=i.images[o.source];let l=n.textureLoader;if(a.uri){const c=n.options.manager.getHandler(a.uri);c!==null&&(l=c)}return this.detectSupport().then(function(c){if(c)return n.loadTextureImage(e,o.source,l);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class Tx{constructor(e){this.parser=e,this.name=lt.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,i=n.json,s=i.textures[e];if(!s.extensions||!s.extensions[t])return null;const o=s.extensions[t],a=i.images[o.source];let l=n.textureLoader;if(a.uri){const c=n.options.manager.getHandler(a.uri);c!==null&&(l=c)}return this.detectSupport().then(function(c){if(c)return n.loadTextureImage(e,o.source,l);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class Ax{constructor(e){this.name=lt.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const i=n.extensions[this.name],s=this.parser.getDependency("buffer",i.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return s.then(function(a){const l=i.byteOffset||0,c=i.byteLength||0,u=i.count,f=i.byteStride,h=new Uint8Array(a,l,c);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(u,f,h,i.mode,i.filter).then(function(p){return p.buffer}):o.ready.then(function(){const p=new ArrayBuffer(u*f);return o.decodeGltfBuffer(new Uint8Array(p),u,f,h,i.mode,i.filter),p})})}else return null}}class Rx{constructor(e){this.name=lt.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;const i=t.meshes[n.mesh];for(const c of i.primitives)if(c.mode!==kn.TRIANGLES&&c.mode!==kn.TRIANGLE_STRIP&&c.mode!==kn.TRIANGLE_FAN&&c.mode!==void 0)return null;const o=n.extensions[this.name].attributes,a=[],l={};for(const c in o)a.push(this.parser.getDependency("accessor",o[c]).then(u=>(l[c]=u,l[c])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(c=>{const u=c.pop(),f=u.isGroup?u.children:[u],h=c[0].count,p=[];for(const _ of f){const g=new Ve,m=new C,d=new mi,x=new C(1,1,1),v=new M0(_.geometry,_.material,h);for(let y=0;y0||r.search(/^data\:image\/jpeg/)===0?"image/jpeg":r.search(/\.webp($|\?)/i)>0||r.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}const Hx=new Ve;class Vx{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new hx,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,i=!1,s=-1;typeof navigator<"u"&&(n=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,i=navigator.userAgent.indexOf("Firefox")>-1,s=i?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||n||i&&s<98?this.textureLoader=new V0(this.options.manager):this.textureLoader=new $0(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Uf(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,i=this.json,s=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(o){const a={scene:o[0][i.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:i.asset,parser:n,userData:{}};return rr(s,a,i),Hi(a,i),Promise.all(n._invokeAll(function(l){return l.afterRoot&&l.afterRoot(a)})).then(function(){e(a)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let i=0,s=t.length;i{const l=this.associations.get(o);l!=null&&this.associations.set(a,l);for(const[c,u]of o.children.entries())s(u,a.children[c])};return s(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n=2&&m.setY(S,M[T*l+1]),l>=3&&m.setZ(S,M[T*l+2]),l>=4&&m.setW(S,M[T*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return m})}loadTexture(e){const t=this.json,n=this.options,s=t.textures[e].source,o=t.images[s];let a=this.textureLoader;if(o.uri){const l=n.manager.getHandler(o.uri);l!==null&&(a=l)}return this.loadTextureImage(e,s,a)}loadTextureImage(e,t,n){const i=this,s=this.json,o=s.textures[e],a=s.images[t],l=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[l])return this.textureCache[l];const c=this.loadImageSource(t,n).then(function(u){u.flipY=!1,u.name=o.name||a.name||"",u.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(u.name=a.uri);const h=(s.samplers||{})[o.sampler]||{};return u.magFilter=yh[h.magFilter]||En,u.minFilter=yh[h.minFilter]||gr,u.wrapS=bh[h.wrapS]||us,u.wrapT=bh[h.wrapT]||us,i.associations.set(u,{textures:e}),u}).catch(function(){return null});return this.textureCache[l]=c,c}loadImageSource(e,t){const n=this,i=this.json,s=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(f=>f.clone());const o=i.images[e],a=self.URL||self.webkitURL;let l=o.uri||"",c=!1;if(o.bufferView!==void 0)l=n.getDependency("bufferView",o.bufferView).then(function(f){c=!0;const h=new Blob([f],{type:o.mimeType});return l=a.createObjectURL(h),l});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const u=Promise.resolve(l).then(function(f){return new Promise(function(h,p){let _=h;t.isImageBitmapLoader===!0&&(_=function(g){const m=new on(g);m.needsUpdate=!0,h(m)}),t.load(Ys.resolveURL(f,s.path),_,void 0,p)})}).then(function(f){return c===!0&&a.revokeObjectURL(l),f.userData.mimeType=o.mimeType||kx(o.uri),f}).catch(function(f){throw console.error("THREE.GLTFLoader: Couldn't load texture",l),f});return this.sourceCache[e]=u,u}assignTexture(e,t,n,i){const s=this;return this.getDependency("texture",n.index).then(function(o){if(!o)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(o=o.clone(),o.channel=n.texCoord),s.extensions[lt.KHR_TEXTURE_TRANSFORM]){const a=n.extensions!==void 0?n.extensions[lt.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const l=s.associations.get(o);o=s.extensions[lt.KHR_TEXTURE_TRANSFORM].extendTexture(o,a),s.associations.set(o,l)}}return i!==void 0&&(o.colorSpace=i),e[t]=o,o})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const i=t.attributes.tangent===void 0,s=t.attributes.color!==void 0,o=t.attributes.normal===void 0;if(e.isPoints){const a="PointsMaterial:"+n.uuid;let l=this.cache.get(a);l||(l=new Nf,di.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,l.sizeAttenuation=!1,this.cache.add(a,l)),n=l}else if(e.isLine){const a="LineBasicMaterial:"+n.uuid;let l=this.cache.get(a);l||(l=new If,di.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,this.cache.add(a,l)),n=l}if(i||s||o){let a="ClonedMaterial:"+n.uuid+":";i&&(a+="derivative-tangents:"),s&&(a+="vertex-colors:"),o&&(a+="flat-shading:");let l=this.cache.get(a);l||(l=n.clone(),s&&(l.vertexColors=!0),o&&(l.flatShading=!0),i&&(l.normalScale&&(l.normalScale.y*=-1),l.clearcoatNormalScale&&(l.clearcoatNormalScale.y*=-1)),this.cache.add(a,l),this.associations.set(l,this.associations.get(n))),n=l}e.material=n}getMaterialType(){return lc}loadMaterial(e){const t=this,n=this.json,i=this.extensions,s=n.materials[e];let o;const a={},l=s.extensions||{},c=[];if(l[lt.KHR_MATERIALS_UNLIT]){const f=i[lt.KHR_MATERIALS_UNLIT];o=f.getMaterialType(),c.push(f.extendParams(a,s,t))}else{const f=s.pbrMetallicRoughness||{};if(a.color=new tt(1,1,1),a.opacity=1,Array.isArray(f.baseColorFactor)){const h=f.baseColorFactor;a.color.setRGB(h[0],h[1],h[2],an),a.opacity=h[3]}f.baseColorTexture!==void 0&&c.push(t.assignTexture(a,"map",f.baseColorTexture,Ht)),a.metalness=f.metallicFactor!==void 0?f.metallicFactor:1,a.roughness=f.roughnessFactor!==void 0?f.roughnessFactor:1,f.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(a,"metalnessMap",f.metallicRoughnessTexture)),c.push(t.assignTexture(a,"roughnessMap",f.metallicRoughnessTexture))),o=this._invokeOne(function(h){return h.getMaterialType&&h.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(h){return h.extendMaterialParams&&h.extendMaterialParams(e,a)})))}s.doubleSided===!0&&(a.side=Zn);const u=s.alphaMode||hl.OPAQUE;if(u===hl.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,u===hl.MASK&&(a.alphaTest=s.alphaCutoff!==void 0?s.alphaCutoff:.5)),s.normalTexture!==void 0&&o!==Wi&&(c.push(t.assignTexture(a,"normalMap",s.normalTexture)),a.normalScale=new Ue(1,1),s.normalTexture.scale!==void 0)){const f=s.normalTexture.scale;a.normalScale.set(f,f)}if(s.occlusionTexture!==void 0&&o!==Wi&&(c.push(t.assignTexture(a,"aoMap",s.occlusionTexture)),s.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=s.occlusionTexture.strength)),s.emissiveFactor!==void 0&&o!==Wi){const f=s.emissiveFactor;a.emissive=new tt().setRGB(f[0],f[1],f[2],an)}return s.emissiveTexture!==void 0&&o!==Wi&&c.push(t.assignTexture(a,"emissiveMap",s.emissiveTexture,Ht)),Promise.all(c).then(function(){const f=new o(a);return s.name&&(f.name=s.name),Hi(f,s),t.associations.set(f,{materials:e}),s.extensions&&rr(i,f,s),f})}createUniqueName(e){const t=vt.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,i=this.primitiveCache;function s(a){return n[lt.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(l){return Sh(l,a,t)})}const o=[];for(let a=0,l=e.length;a0&&Bx(d,s),d.name=t.createUniqueName(s.name||"mesh_"+e),Hi(d,s),m.extensions&&rr(i,d,m),t.assignFinalMaterial(d),f.push(d)}for(let p=0,_=f.length;p<_;p++)t.associations.set(f[p],{meshes:e,primitives:p});if(f.length===1)return s.extensions&&rr(i,f[0],s),f[0];const h=new dr;s.extensions&&rr(i,h,s),t.associations.set(h,{meshes:e});for(let p=0,_=f.length;p<_;p++)h.add(f[p]);return h})}loadCamera(e){let t;const n=this.json.cameras[e],i=n[n.type];if(!i){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new gn(ff.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):n.type==="orthographic"&&(t=new oo(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),Hi(t,n),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],n=[];for(let i=0,s=t.joints.length;i1?u=new dr:c.length===1?u=c[0]:u=new Bt,u!==c[0])for(let f=0,h=c.length;f{const f=new Map;for(const[h,p]of i.associations)(h instanceof di||h instanceof on)&&f.set(h,p);return u.traverse(h=>{const p=i.associations.get(h);p!=null&&f.set(h,p)}),f};return i.associations=c(s),s})}_createAnimationTracks(e,t,n,i,s){const o=[],a=e.name?e.name:e.uuid,l=[];Bi[s.path]===Bi.weights?e.traverse(function(h){h.morphTargetInfluences&&l.push(h.name?h.name:h.uuid)}):l.push(a);let c;switch(Bi[s.path]){case Bi.weights:c=ms;break;case Bi.rotation:c=vr;break;case Bi.position:case Bi.scale:c=_s;break;default:switch(n.itemSize){case 1:c=ms;break;case 2:case 3:default:c=_s;break}break}const u=i.interpolation!==void 0?Fx[i.interpolation]:fs,f=this._getArrayFromAccessor(n);for(let h=0,p=l.length;hl+1e3&&(u.update(1e3*c/(p-l),100),l=p,c=0,h)){var _=performance.memory;h.update(_.usedJSHeapSize/1048576,_.jsHeapSizeLimit/1048576)}return p},update:function(){a=this.end()},domElement:o,setMode:i}};return t.Panel=function(n,i,s){var o=1/0,a=0,l=Math.round,c=l(window.devicePixelRatio||1),u=80*c,f=48*c,h=3*c,p=2*c,_=3*c,g=15*c,m=74*c,d=30*c,x=document.createElement("canvas");x.width=u,x.height=f,x.style.cssText="width:80px;height:48px";var v=x.getContext("2d");return v.font="bold "+9*c+"px Helvetica,Arial,sans-serif",v.textBaseline="top",v.fillStyle=s,v.fillRect(0,0,u,f),v.fillStyle=i,v.fillText(n,h,p),v.fillRect(_,g,m,d),v.fillStyle=s,v.globalAlpha=.9,v.fillRect(_,g,m,d),{dom:x,update:function(y,b){o=Math.min(o,y),a=Math.max(a,y),v.fillStyle=s,v.globalAlpha=1,v.fillRect(0,0,u,g),v.fillStyle=i,v.fillText(l(y)+" "+n+" ("+l(o)+"-"+l(a)+")",h,p),v.drawImage(x,_+c,g,m-c,d,_,g,m-c,d),v.fillRect(_+m-c,g,c,d),v.fillStyle=s,v.globalAlpha=.9,v.fillRect(_+m-c,g,c,l((1-y/b)*d))}}},t})})(Hf);var Xx=Hf.exports;const qx=Wx(Xx),Vf=0,jx=1,Gf=2,Eh=2,dl=1.25,wh=1,_r=6*4+4+4,wa=65535,Yx=Math.pow(2,-24),pl=Symbol("SKIP_GENERATION");function Wf(r){return r.index?r.index.count:r.attributes.position.count}function Ss(r){return Wf(r)/3}function Xf(r,e=ArrayBuffer){return r>65535?new Uint32Array(new e(4*r)):new Uint16Array(new e(2*r))}function $x(r,e){if(!r.index){const t=r.attributes.position.count,n=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=Xf(t,n);r.setIndex(new Yt(i,1));for(let s=0;sa-l);for(let a=0;as.offset-o.offset),n=t[t.length-1];n.count=Math.min(e-n.offset,n.count);let i=0;return t.forEach(({count:s})=>i+=s),e!==i}function Ut(r,e,t){return t.min.x=e[r],t.min.y=e[r+1],t.min.z=e[r+2],t.max.x=e[r+3],t.max.y=e[r+4],t.max.z=e[r+5],t}function Zx(r){r[0]=r[1]=r[2]=1/0,r[3]=r[4]=r[5]=-1/0}function Mh(r){let e=-1,t=-1/0;for(let n=0;n<3;n++){const i=r[n+3]-r[n];i>t&&(t=i,e=n)}return e}function Th(r,e){e.set(r)}function Ah(r,e,t){let n,i;for(let s=0;s<3;s++){const o=s+3;n=r[s],i=e[s],t[s]=ni?n:i}}function zo(r,e,t){for(let n=0;n<3;n++){const i=e[r+2*n],s=e[r+2*n+1],o=i-s,a=i+s;ot[n+3]&&(t[n+3]=a)}}function Ns(r){const e=r[3]-r[0],t=r[4]-r[1],n=r[5]-r[2];return 2*(e*t+t*n+n*e)}function ml(r,e,t,n,i=null){let s=1/0,o=1/0,a=1/0,l=-1/0,c=-1/0,u=-1/0,f=1/0,h=1/0,p=1/0,_=-1/0,g=-1/0,m=-1/0;const d=i!==null;for(let x=e*6,v=(e+t)*6;xl&&(l=T),d&&y_&&(_=y);const I=r[x+2],S=r[x+3],A=I-S,z=I+S;Ac&&(c=z),d&&Ig&&(g=I);const O=r[x+4],W=r[x+5],D=O-W,V=O+W;Du&&(u=V),d&&Om&&(m=O)}n[0]=s,n[1]=o,n[2]=a,n[3]=l,n[4]=c,n[5]=u,d&&(i[0]=f,i[1]=h,i[2]=p,i[3]=_,i[4]=g,i[5]=m)}function Jx(r,e,t,n){let i=1/0,s=1/0,o=1/0,a=-1/0,l=-1/0,c=-1/0;for(let u=e*6,f=(e+t)*6;ua&&(a=h);const p=r[u+2];pl&&(l=p);const _=r[u+4];_c&&(c=_)}n[0]=i,n[1]=s,n[2]=o,n[3]=a,n[4]=l,n[5]=c}function Qx(r,e){Zx(e);const t=r.attributes.position,n=r.index?r.index.array:null,i=Ss(r),s=new Float32Array(i*6),o=t.normalized,a=t.array,l=t.offset||0;let c=3;t.isInterleavedBufferAttribute&&(c=t.data.stride);const u=["getX","getY","getZ"];for(let f=0;fM&&(M=v),y>M&&(M=y);const T=(M-b)/2,I=d*2;s[p+I+0]=b+T,s[p+I+1]=T+(Math.abs(b)+T)*Yx,be[d+3]&&(e[d+3]=M)}}return s}const Ti=32,ey=(r,e)=>r.candidate-e.candidate,zi=new Array(Ti).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),ko=new Float32Array(6);function ty(r,e,t,n,i,s){let o=-1,a=0;if(s===Vf)o=Mh(e),o!==-1&&(a=(e[o]+e[o+3])/2);else if(s===jx)o=Mh(r),o!==-1&&(a=ny(t,n,i,o));else if(s===Gf){const l=Ns(r);let c=dl*i;const u=n*6,f=(n+i)*6;for(let h=0;h<3;h++){const p=e[h],m=(e[h+3]-p)/Ti;if(i=T.candidate?zo(y,t,T.rightCacheBounds):(zo(y,t,T.leftCacheBounds),T.count++)}}for(let y=0;y=Ti&&(M=Ti-1);const T=zi[M];T.count++,zo(v,t,T.bounds)}const d=zi[Ti-1];Th(d.bounds,d.rightCacheBounds);for(let v=Ti-2;v>=0;v--){const y=zi[v],b=zi[v+1];Ah(y.bounds,b.rightCacheBounds,y.rightCacheBounds)}let x=0;for(let v=0;v=l;)a--;if(o=l;)a--;if(o2**16,i=n?4:2,s=e?new SharedArrayBuffer(t*i):new ArrayBuffer(t*i),o=n?new Uint32Array(s):new Uint16Array(s);for(let a=0,l=o.length;a=i&&(f=!0,s&&(console.warn(`MeshBVH: Max depth of ${i} reached when generating BVH. Consider increasing maxDepth.`),console.warn(t))),M<=o||I>=i)return x(b+M),y.offset=b,y.count=M,y;const S=ty(y.boundingData,T,_,b,M,a);if(S.axis===-1)return x(b+M),y.offset=b,y.count=M,y;const A=g(u,n,_,b,M,S);if(A===b||A===b+M)x(b+M),y.offset=b,y.count=M;else{y.splitAxis=S.axis;const z=new Ho,O=b,W=A-b;y.left=z,z.boundingData=new Float32Array(6),ml(_,O,W,z.boundingData,p),v(z,O,W,p,I+1);const D=new Ho,V=A,Z=M-W;y.right=D,D.boundingData=new Float32Array(6),ml(_,V,Z,D.boundingData,p),v(D,V,Z,p,I+1)}return y}}function ay(r,e){const t=r.geometry;e.indirect&&(r._indirectBuffer=sy(t,e.useSharedArrayBuffer),Kx(t)&&!e.verbose&&console.warn('MeshBVH: Provided geometry contains groups that do not fully span the vertex contents while using the "indirect" option. BVH may incorrectly report intersections on unrendered portions of the geometry.')),r._indirectBuffer||$x(t,e);const n=oy(r,e);let i,s,o;const a=[],l=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let f=0;fMath.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return s[p+6]=y/4,y=u(y,x),s[p+7]=v,y}}}class Li{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let n=1/0,i=-1/0;for(let s=0,o=e.length;si?l:i}this.min=n,this.max=i}setFromPoints(e,t){let n=1/0,i=-1/0;for(let s=0,o=t.length;si?l:i}this.min=n,this.max=i}isSeparated(e){return this.min>e.max||e.min>this.max}}Li.prototype.setFromBox=function(){const r=new C;return function(t,n){const i=n.min,s=n.max;let o=1/0,a=-1/0;for(let l=0;l<=1;l++)for(let c=0;c<=1;c++)for(let u=0;u<=1;u++){r.x=i.x*l+s.x*(1-l),r.y=i.y*c+s.y*(1-c),r.z=i.z*u+s.z*(1-u);const f=t.dot(r);o=Math.min(f,o),a=Math.max(f,a)}this.min=o,this.max=a}}();const ly=function(){const r=new C,e=new C,t=new C;return function(i,s,o){const a=i.start,l=r,c=s.start,u=e;t.subVectors(a,c),r.subVectors(i.end,i.start),e.subVectors(s.end,s.start);const f=t.dot(u),h=u.dot(l),p=u.dot(u),_=t.dot(l),m=l.dot(l)*p-h*h;let d,x;m!==0?d=(f*h-_*p)/m:d=0,x=(f+d*h)/p,o.x=d,o.y=x}}(),fc=function(){const r=new Ue,e=new C,t=new C;return function(i,s,o,a){ly(i,s,r);let l=r.x,c=r.y;if(l>=0&&l<=1&&c>=0&&c<=1){i.at(l,o),s.at(c,a);return}else if(l>=0&&l<=1){c<0?s.at(0,a):s.at(1,a),i.closestPointToPoint(a,!0,o);return}else if(c>=0&&c<=1){l<0?i.at(0,o):i.at(1,o),s.closestPointToPoint(o,!0,a);return}else{let u;l<0?u=i.start:u=i.end;let f;c<0?f=s.start:f=s.end;const h=e,p=t;if(i.closestPointToPoint(f,!0,e),s.closestPointToPoint(u,!0,t),h.distanceToSquared(f)<=p.distanceToSquared(u)){o.copy(h),a.copy(f);return}else{o.copy(u),a.copy(p);return}}}}(),cy=function(){const r=new C,e=new C,t=new ci,n=new Ri;return function(s,o){const{radius:a,center:l}=s,{a:c,b:u,c:f}=o;if(n.start=c,n.end=u,n.closestPointToPoint(l,!0,r).distanceTo(l)<=a||(n.start=c,n.end=f,n.closestPointToPoint(l,!0,r).distanceTo(l)<=a)||(n.start=u,n.end=f,n.closestPointToPoint(l,!0,r).distanceTo(l)<=a))return!0;const g=o.getPlane(t);if(Math.abs(g.distanceToPoint(l))<=a){const d=g.projectPoint(l,e);if(o.containsPoint(d))return!0}return!1}}(),uy=1e-15;function _l(r){return Math.abs(r)new C),this.satBounds=new Array(4).fill().map(()=>new Li),this.points=[this.a,this.b,this.c],this.sphere=new ni,this.plane=new ci,this.needsUpdate=!0}intersectsSphere(e){return cy(e,this)}update(){const e=this.a,t=this.b,n=this.c,i=this.points,s=this.satAxes,o=this.satBounds,a=s[0],l=o[0];this.getNormal(a),l.setFromPoints(a,i);const c=s[1],u=o[1];c.subVectors(e,t),u.setFromPoints(c,i);const f=s[2],h=o[2];f.subVectors(t,n),h.setFromPoints(f,i);const p=s[3],_=o[3];p.subVectors(n,e),_.setFromPoints(p,i),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(a,e),this.needsUpdate=!1}}ti.prototype.closestPointToSegment=function(){const r=new C,e=new C,t=new Ri;return function(i,s=null,o=null){const{start:a,end:l}=i,c=this.points;let u,f=1/0;for(let h=0;h<3;h++){const p=(h+1)%3;t.start.copy(c[h]),t.end.copy(c[p]),fc(t,i,r,e),u=r.distanceToSquared(e),u=2){(y===1?d.start:d.end).copy(p),v=2;break}if(v++,v===2&&y===-1)break}}return v}return function(m,d=null,x=!1){this.needsUpdate&&this.update(),m.isExtendedTriangle?m.needsUpdate&&m.update():(r.copy(m),r.update(),m=r);const v=this.plane,y=m.plane;if(Math.abs(v.normal.dot(y.normal))>1-1e-10){const b=this.satBounds,M=this.satAxes;t[0]=m.a,t[1]=m.b,t[2]=m.c;for(let S=0;S<4;S++){const A=b[S],z=M[S];if(n.setFromPoints(z,t),A.isSeparated(n))return!1}const T=m.satBounds,I=m.satAxes;e[0]=this.a,e[1]=this.b,e[2]=this.c;for(let S=0;S<4;S++){const A=T[S],z=I[S];if(n.setFromPoints(z,e),A.isSeparated(n))return!1}for(let S=0;S<4;S++){const A=M[S];for(let z=0;z<4;z++){const O=I[z];if(s.crossVectors(A,O),n.setFromPoints(s,e),i.setFromPoints(s,t),n.isSeparated(i))return!1}}return d&&(x||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),d.start.set(0,0,0),d.end.set(0,0,0)),!0}else{const b=_(this,y,f);if(b===1&&m.containsPoint(f.end))return d&&(d.start.copy(f.end),d.end.copy(f.end)),!0;if(b!==2)return!1;const M=_(m,v,h);if(M===1&&this.containsPoint(h.end))return d&&(d.start.copy(h.end),d.end.copy(h.end)),!0;if(M!==2)return!1;if(f.delta(a),h.delta(l),a.dot(l)<0){let W=h.start;h.start=h.end,h.end=W}const T=f.start.dot(a),I=f.end.dot(a),S=h.start.dot(a),A=h.end.dot(a),z=I0?d.start.copy(f.start):d.start.copy(h.start),c.subVectors(f.end,h.end),c.dot(a)<0?d.end.copy(f.end):d.end.copy(h.end)),!0)}}}();ti.prototype.distanceToPoint=function(){const r=new C;return function(t){return this.closestPointToPoint(t,r),t.distanceTo(r)}}();ti.prototype.distanceToTriangle=function(){const r=new C,e=new C,t=["a","b","c"],n=new Ri,i=new Ri;return function(o,a=null,l=null){const c=a||l?n:null;if(this.intersectsTriangle(o,c))return(a||l)&&(a&&c.getCenter(a),l&&c.getCenter(l)),0;let u=1/0;for(let f=0;f<3;f++){let h;const p=t[f],_=o[p];this.closestPointToPoint(_,r),h=_.distanceToSquared(r),hnew C),this.satAxes=new Array(3).fill().map(()=>new C),this.satBounds=new Array(3).fill().map(()=>new Li),this.alignedSatBounds=new Array(3).fill().map(()=>new Li),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),n&&this.matrix.copy(n)}set(e,t,n){this.min.copy(e),this.max.copy(t),this.matrix.copy(n),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}}bn.prototype.update=function(){return function(){const e=this.matrix,t=this.min,n=this.max,i=this.points;for(let c=0;c<=1;c++)for(let u=0;u<=1;u++)for(let f=0;f<=1;f++){const h=1*c|2*u|4*f,p=i[h];p.x=c?n.x:t.x,p.y=u?n.y:t.y,p.z=f?n.z:t.z,p.applyMatrix4(e)}const s=this.satBounds,o=this.satAxes,a=i[0];for(let c=0;c<3;c++){const u=o[c],f=s[c],h=1<new Ri),t=new Array(12).fill().map(()=>new Ri),n=new C,i=new C;return function(o,a=0,l=null,c=null){if(this.needsUpdate&&this.update(),this.intersectsBox(o))return(l||c)&&(o.getCenter(i),this.closestPointToPoint(i,n),o.closestPointToPoint(n,i),l&&l.copy(n),c&&c.copy(i)),0;const u=a*a,f=o.min,h=o.max,p=this.points;let _=1/0;for(let m=0;m<8;m++){const d=p[m];i.copy(d).clamp(f,h);const x=d.distanceToSquared(i);if(x<_&&(_=x,l&&l.copy(d),c&&c.copy(i),xnew ti)}}const Gn=new hy;function wn(r,e){return e[r+15]===65535}function Tn(r,e){return e[r+6]}function In(r,e){return e[r+14]}function Wn(r){return r+8}function Nn(r,e){return e[r+6]}function pc(r,e){return e[r+7]}class fy{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const e=[];let t=null;this.setBuffer=n=>{t&&e.push(t),t=n,this.float32Array=new Float32Array(n),this.uint16Array=new Uint16Array(n),this.uint32Array=new Uint32Array(n)},this.clearBuffer=()=>{t=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,e.length!==0&&this.setBuffer(e.pop())}}}const Rt=new fy;let Xi,is;const Wr=[],Vo=new dc(()=>new $t);function dy(r,e,t,n,i,s){Xi=Vo.getPrimitive(),is=Vo.getPrimitive(),Wr.push(Xi,is),Rt.setBuffer(r._roots[e]);const o=Wl(0,r.geometry,t,n,i,s);Rt.clearBuffer(),Vo.releasePrimitive(Xi),Vo.releasePrimitive(is),Wr.pop(),Wr.pop();const a=Wr.length;return a>0&&(is=Wr[a-1],Xi=Wr[a-2]),o}function Wl(r,e,t,n,i=null,s=0,o=0){const{float32Array:a,uint16Array:l,uint32Array:c}=Rt;let u=r*2;if(wn(u,l)){const _=Tn(r,c),g=In(u,l);return Ut(r,a,Xi),n(_,g,!1,o,s+r,Xi)}else{let O=function(D){const{uint16Array:V,uint32Array:Z}=Rt;let J=D*2;for(;!wn(J,V);)D=Wn(D),J=D*2;return Tn(D,Z)},W=function(D){const{uint16Array:V,uint32Array:Z}=Rt;let J=D*2;for(;!wn(J,V);)D=Nn(D,Z),J=D*2;return Tn(D,Z)+In(J,V)};var h=O,p=W;const _=Wn(r),g=Nn(r,c);let m=_,d=g,x,v,y,b;if(i&&(y=Xi,b=is,Ut(m,a,y),Ut(d,a,b),x=i(y),v=i(b),v(Fs.copy(e).clamp(u.min,u.max),Fs.distanceToSquared(e)),intersectsBounds:(u,f,h)=>h{u.closestPointToPoint(e,Fs);const h=e.distanceToSquared(Fs);return h0&&c.normal.multiplyScalar(-1));const u={a:s,b:o,c:a,normal:new C,materialIndex:0};fn.getNormal(Xr,qr,jr,u.normal),c.face=u,c.faceIndex=s}return c}function Ma(r,e,t,n,i){const s=n*3;let o=s+0,a=s+1,l=s+2;const c=r.index;r.index&&(o=c.getX(o),a=c.getX(a),l=c.getX(l));const{position:u,normal:f,uv:h,uv1:p}=r.attributes,_=_y(t,u,f,h,p,o,a,l,e);return _?(_.faceIndex=n,i&&i.push(_),_):null}function jt(r,e,t,n){const i=r.a,s=r.b,o=r.c;let a=e,l=e+1,c=e+2;t&&(a=t.getX(a),l=t.getX(l),c=t.getX(c)),i.x=n.getX(a),i.y=n.getY(a),i.z=n.getZ(a),s.x=n.getX(l),s.y=n.getY(l),s.z=n.getZ(l),o.x=n.getX(c),o.y=n.getY(c),o.z=n.getZ(c)}function gy(r,e,t,n,i,s){const{geometry:o,_indirectBuffer:a}=r;for(let l=n,c=n+i;lM&&(M=O),WT&&(T=W),DI&&(I=D)}return l[h+0]!==v||l[h+1]!==y||l[h+2]!==b||l[h+3]!==M||l[h+4]!==T||l[h+5]!==I?(l[h+0]=v,l[h+1]=y,l[h+2]=b,l[h+3]=M,l[h+4]=T,l[h+5]=I,!0):!1}else{const d=h+8,x=o[h+6],v=d+p,y=x+p;let b=_,M=!1,T=!1;e?b||(M=e.has(v),T=e.has(y),b=!M&&!T):(M=!0,T=!0);const I=b||M,S=b||T;let A=!1;I&&(A=f(d,p,b));let z=!1;S&&(z=f(x,p,b));const O=A||z;if(O)for(let W=0;W<3;W++){const D=d+W,V=x+W,Z=l[D],J=l[D+3],ce=l[V],ie=l[V+3];l[h+W]=Zie?J:ie}return O}}}const Ph=new $t;function Zi(r,e,t,n){return Ut(r,e,Ph),t.intersectBox(Ph,n)}function by(r,e,t,n,i,s){const{geometry:o,_indirectBuffer:a}=r;for(let l=n,c=n+i;l=0;let p,_;h?(p=Wn(r),_=Nn(r,o)):(p=Nn(r,o),_=Wn(r));const m=Zi(p,i,n,Ih)?ql(p,e,t,n):null;if(m){const v=m.point[u];if(h?v<=i[_+c]:v>=i[_+c+3])return m}const x=Zi(_,i,n,Ih)?ql(_,e,t,n):null;return m&&x?m.distance<=x.distance?m:x:m||x||null}}const jo=new $t,Yr=new ti,$r=new ti,Os=new Ve,Nh=new bn,Yo=new bn;function Ay(r,e,t,n){Rt.setBuffer(r._roots[e]);const i=jl(0,r,t,n);return Rt.clearBuffer(),i}function jl(r,e,t,n,i=null){const{float32Array:s,uint16Array:o,uint32Array:a}=Rt;let l=r*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),Nh.set(t.boundingBox.min,t.boundingBox.max,n),i=Nh),wn(l,o)){const u=e.geometry,f=u.index,h=u.attributes.position,p=t.index,_=t.attributes.position,g=Tn(r,a),m=In(l,o);if(Os.copy(n).invert(),t.boundsTree)return Ut(r,s,Yo),Yo.matrix.copy(Os),Yo.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:x=>Yo.intersectsBox(x),intersectsTriangle:x=>{x.a.applyMatrix4(n),x.b.applyMatrix4(n),x.c.applyMatrix4(n),x.needsUpdate=!0;for(let v=g*3,y=(m+g)*3;vvl.distanceToBox(b),intersectsBounds:(b,M,T)=>T{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:I=>Us.distanceToBox(I),intersectsBounds:(I,S,A)=>A{for(let A=I,z=I+S;AM&&(M=D),VT&&(T=V),ZI&&(I=Z)}}return l[h+0]!==v||l[h+1]!==y||l[h+2]!==b||l[h+3]!==M||l[h+4]!==T||l[h+5]!==I?(l[h+0]=v,l[h+1]=y,l[h+2]=b,l[h+3]=M,l[h+4]=T,l[h+5]=I,!0):!1}else{const d=h+8,x=o[h+6],v=d+p,y=x+p;let b=_,M=!1,T=!1;e?b||(M=e.has(v),T=e.has(y),b=!M&&!T):(M=!0,T=!0);const I=b||M,S=b||T;let A=!1;I&&(A=f(d,p,b));let z=!1;S&&(z=f(x,p,b));const O=A||z;if(O)for(let W=0;W<3;W++){const D=d+W,V=x+W,Z=l[D],J=l[D+3],ce=l[V],ie=l[V+3];l[h+W]=Zie?J:ie}return O}}}const Fh=new C;function Ny(r,e,t,n,i){Rt.setBuffer(r._roots[e]),Yl(0,r,t,n,i),Rt.clearBuffer()}function Yl(r,e,t,n,i){const{float32Array:s,uint16Array:o,uint32Array:a}=Rt,l=r*2;if(wn(l,o)){const u=Tn(r,a),f=In(l,o);by(e,t,n,u,f,i)}else{const u=Wn(r);Zi(u,s,n,Fh)&&Yl(u,e,t,n,i);const f=Nn(r,a);Zi(f,s,n,Fh)&&Yl(f,e,t,n,i)}}const Oh=new C,Fy=["x","y","z"];function Oy(r,e,t,n){Rt.setBuffer(r._roots[e]);const i=$l(0,r,t,n);return Rt.clearBuffer(),i}function $l(r,e,t,n){const{float32Array:i,uint16Array:s,uint32Array:o}=Rt;let a=r*2;if(wn(a,s)){const c=Tn(r,o),u=In(a,s);return Sy(e,t,n,c,u)}else{const c=pc(r,o),u=Fy[c],h=n.direction[u]>=0;let p,_;h?(p=Wn(r),_=Nn(r,o)):(p=Nn(r,o),_=Wn(r));const m=Zi(p,i,n,Oh)?$l(p,e,t,n):null;if(m){const v=m.point[u];if(h?v<=i[_+c]:v>=i[_+c+3])return m}const x=Zi(_,i,n,Oh)?$l(_,e,t,n):null;return m&&x?m.distance<=x.distance?m:x:m||x||null}}const Ko=new $t,Kr=new ti,Zr=new ti,Bs=new Ve,Uh=new bn,Zo=new bn;function Uy(r,e,t,n){Rt.setBuffer(r._roots[e]);const i=Kl(0,r,t,n);return Rt.clearBuffer(),i}function Kl(r,e,t,n,i=null){const{float32Array:s,uint16Array:o,uint32Array:a}=Rt;let l=r*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),Uh.set(t.boundingBox.min,t.boundingBox.max,n),i=Uh),wn(l,o)){const u=e.geometry,f=u.index,h=u.attributes.position,p=t.index,_=t.attributes.position,g=Tn(r,a),m=In(l,o);if(Bs.copy(n).invert(),t.boundsTree)return Ut(r,s,Zo),Zo.matrix.copy(Bs),Zo.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:x=>Zo.intersectsBox(x),intersectsTriangle:x=>{x.a.applyMatrix4(n),x.b.applyMatrix4(n),x.c.applyMatrix4(n),x.needsUpdate=!0;for(let v=g,y=m+g;vxl.distanceToBox(b),intersectsBounds:(b,M,T)=>T{if(e.boundsTree){const T=e.boundsTree;return T.shapecast({boundsTraverseOrder:I=>zs.distanceToBox(I),intersectsBounds:(I,S,A)=>A{for(let A=I,z=I+S;Anew $t),Jr=new $t,Qr=new $t,yl=new $t,bl=new $t;let Sl=!1;function Wy(r,e,t,n){if(Sl)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");Sl=!0;const i=r._roots,s=e._roots;let o,a=0,l=0;const c=new Ve().copy(t).invert();for(let u=0,f=i.length;ul.slice()),index:o.array.slice(),indirectBuffer:s?s.slice():null}:a={roots:i,index:o.array,indirectBuffer:s},a}static deserialize(e,t,n={}){n={setIndex:!0,indirect:!!e.indirectBuffer,...n};const{index:i,roots:s,indirectBuffer:o}=e,a=new mc(t,{...n,[pl]:!0});if(a._roots=s,a._indirectBuffer=o||null,n.setIndex){const l=t.getIndex();if(l===null){const c=new Yt(e.index,1,!1);t.setIndex(c)}else l.array!==i&&(l.array.set(i),l.needsUpdate=!0)}return a}get indirect(){return!!this._indirectBuffer}constructor(e,t={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(t=Object.assign({strategy:Vf,maxDepth:40,maxLeafTris:10,verbose:!0,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,[pl]:!1},t),t.useSharedArrayBuffer&&!Gy())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=e,this._roots=null,this._indirectBuffer=null,t[pl]||(ay(this,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new $t)));const{_indirectBuffer:n}=this;this.resolveTriangleIndex=t.indirect?i=>n[i]:i=>i}refit(e=null){return(this.indirect?Iy:yy)(this,e)}traverse(e,t=0){const n=this._roots[t],i=new Uint32Array(n),s=new Uint16Array(n);o(0);function o(a,l=0){const c=a*2,u=s[c+15]===wa;if(u){const f=i[a+6],h=s[c+14];e(l,u,new Float32Array(n,a*4,6),f,h)}else{const f=a+_r/4,h=i[a+6],p=i[a+7];e(l,u,new Float32Array(n,a*4,6),p)||(o(f,l+1),o(h,l+1))}}}raycast(e,t=ei){const n=this._roots,i=this.geometry,s=[],o=t.isMaterial,a=Array.isArray(t),l=i.groups,c=o?t.side:t,u=this.indirect?Ny:wy;for(let f=0,h=n.length;ff(h,p,_,g,m)?!0:n(h,p,this,a,_,g,t)}else o||(a?o=(f,h,p,_)=>n(f,h,this,a,p,_,t):o=(f,h,p)=>p);let l=!1,c=0;const u=this._roots;for(let f=0,h=u.length;f{const g=this.resolveTriangleIndex(_);jt(o,g*3,a,l)}:_=>{jt(o,_*3,a,l)},u=Gn.getPrimitive(),f=e.geometry.index,h=e.geometry.attributes.position,p=e.indirect?_=>{const g=e.resolveTriangleIndex(_);jt(u,g*3,f,h)}:_=>{jt(u,_*3,f,h)};if(s){const _=(g,m,d,x,v,y,b,M)=>{for(let T=d,I=d+x;TQo.intersectsBox(n),intersectsTriangle:n=>Qo.intersectsTriangle(n)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,n={},i={},s=0,o=1/0){return(this.indirect?Vy:Dy)(this,e,t,n,i,s,o)}closestPointToPoint(e,t={},n=0,i=1/0){return py(this,e,t,n,i)}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(n=>{Ut(0,new Float32Array(n),Bh),e.union(Bh)}),e}}function Xy(r){switch(r){case 1:return"R";case 2:return"RG";case 3:return"RGBA";case 4:return"RGBA"}throw new Error}function qy(r){switch(r){case 1:return sf;case 2:return of;case 3:return sn;case 4:return sn}}function zh(r){switch(r){case 1:return Ql;case 2:return xa;case 3:return Qs;case 4:return Qs}}class Yf extends da{constructor(){super(),this.minFilter=Nt,this.magFilter=Nt,this.generateMipmaps=!1,this.overrideItemSize=null,this._forcedType=null}updateFrom(e){const t=this.overrideItemSize,n=e.itemSize,i=e.count;if(t!==null){if(n*i%t!==0)throw new Error("VertexAttributeTexture: overrideItemSize must divide evenly into buffer length.");e.itemSize=t,e.count=i*n/t}const s=e.itemSize,o=e.count,a=e.normalized,l=e.array.constructor,c=l.BYTES_PER_ELEMENT;let u=this._forcedType,f=s;if(u===null)switch(l){case Float32Array:u=vn;break;case Uint8Array:case Uint16Array:case Uint32Array:u=Dn;break;case Int8Array:case Int16Array:case Int32Array:u=Ws;break}let h,p,_,g,m=Xy(s);switch(u){case vn:_=1,p=qy(s),a&&c===1?(g=l,m+="8",l===Uint8Array?h=fi:(h=Il,m+="_SNORM")):(g=Float32Array,m+="32F",h=vn);break;case Ws:m+=c*8+"I",_=a?Math.pow(2,l.BYTES_PER_ELEMENT*8-1):1,p=zh(s),c===1?(g=Int8Array,h=Il):c===2?(g=Int16Array,h=tf):(g=Int32Array,h=Ws);break;case Dn:m+=c*8+"UI",_=a?Math.pow(2,l.BYTES_PER_ELEMENT*8-1):1,p=zh(s),c===1?(g=Uint8Array,h=fi):c===2?(g=Uint16Array,h=va):(g=Uint32Array,h=Dn);break}f===3&&(p===sn||p===Qs)&&(f=4);const d=Math.ceil(Math.sqrt(o)),x=f*d*d,v=new g(x),y=e.normalized;e.normalized=!1;for(let b=0;b=2&&(v[M+1]=e.getY(b)/_),s>=3&&(v[M+2]=e.getZ(b)/_,f===4&&(v[M+3]=1)),s>=4&&(v[M+3]=e.getW(b)/_)}e.normalized=y,this.internalFormat=m,this.format=p,this.type=h,this.image.width=d,this.image.height=d,this.image.data=v,this.needsUpdate=!0,this.dispose(),e.itemSize=n,e.count=i}}class jy extends Yf{constructor(){super(),this._forcedType=Dn}}class Vs extends Yf{constructor(){super(),this._forcedType=vn}}class kh{constructor(){this.index=new jy,this.position=new Vs,this.bvhBounds=new da,this.bvhContents=new da,this._cachedIndexAttr=null,this.index.overrideItemSize=3}updateFrom(e){const{geometry:t}=e;if($y(e,this.bvhBounds,this.bvhContents),this.position.updateFrom(t.attributes.position),e.indirect){const n=e._indirectBuffer;if(this._cachedIndexAttr===null||this._cachedIndexAttr.count!==n.length)if(t.index)this._cachedIndexAttr=t.index.clone();else{const i=Xf(Wf(t));this._cachedIndexAttr=new Yt(i,1,!1)}Yy(t,n,this._cachedIndexAttr),this.index.updateFrom(this._cachedIndexAttr)}else this.index.updateFrom(t.index)}dispose(){const{index:e,position:t,bvhBounds:n,bvhContents:i}=this;e&&e.dispose(),t&&t.dispose(),n&&n.dispose(),i&&i.dispose()}}function Yy(r,e,t){const n=t.array,i=r.index?r.index.array:null;for(let s=0,o=e.length;su||i.y>u)&&(i.x>u&&(s.x=Math.floor(u/ce.x),i.x=s.x*ce.x,J.mapSize.x=s.x),i.y>u&&(s.y=Math.floor(u/ce.y),i.y=s.y*ce.y,J.mapSize.y=s.y)),J.map===null||O===!0||W===!0){const se=this.type!==Mi?{minFilter:Nt,magFilter:Nt}:{};J.map!==null&&J.map.dispose(),J.map=new $i(i.x,i.y,se),J.map.texture.name=Z.name+".shadowMap",J.camera.updateProjectionMatrix()}r.setRenderTarget(J.map),r.clear();const ie=J.getViewportCount();for(let se=0;se0||M.map&&M.alphaTest>0){const z=S.uuid,O=M.uuid;let W=c[z];W===void 0&&(W={},c[z]=W);let D=W[O];D===void 0&&(D=S.clone(),W[O]=D),S=D}if(S.visible=M.visible,S.wireframe=M.wireframe,I===Mi?S.side=M.shadowSide!==null?M.shadowSide:M.side:S.side=M.shadowSide!==null?M.shadowSide:f[M.side],S.alphaMap=M.alphaMap,S.alphaTest=M.alphaTest,S.map=M.map,S.clipShadows=M.clipShadows,S.clippingPlanes=M.clippingPlanes,S.clipIntersection=M.clipIntersection,S.displacementMap=M.displacementMap,S.displacementScale=M.displacementScale,S.displacementBias=M.displacementBias,S.wireframeLinewidth=M.wireframeLinewidth,S.linewidth=M.linewidth,T.isPointLight===!0&&S.isMeshDistanceMaterial===!0){const z=r.properties.get(S);z.light=T}return S}function y(b,M,T,I,S){if(b.visible===!1)return;if(b.layers.test(M.layers)&&(b.isMesh||b.isLine||b.isPoints)&&(b.castShadow||b.receiveShadow&&S===Mi)&&(!b.frustumCulled||n.intersectsObject(b))){b.modelViewMatrix.multiplyMatrices(T.matrixWorldInverse,b.matrixWorld);const O=e.update(b),W=b.material;if(Array.isArray(W)){const D=O.groups;for(let V=0,Z=D.length;V=1):se.indexOf("OpenGL ES")!==-1&&(ie=parseFloat(/^OpenGL ES (\d)/.exec(se)[1]),ce=ie>=2);let me=null,ve={};const Q=r.getParameter(r.SCISSOR_BOX),oe=r.getParameter(r.VIEWPORT),Se=new mt().fromArray(Q),De=new mt().fromArray(oe);function _e(F,ge,ae,ee){const he=new Uint8Array(4),Re=r.createTexture();r.bindTexture(F,Re),r.texParameteri(F,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(F,r.TEXTURE_MAG_FILTER,r.NEAREST);for(let nt=0;nt"u"?!1:/OculusBrowser/g.test(navigator.userAgent),_=new WeakMap;let g;const m=new WeakMap;let d=!1;try{d=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function x(P,E){return d?new OffscreenCanvas(P,E):to("canvas")}function v(P,E,q,le){let re=1;if((P.width>le||P.height>le)&&(re=le/Math.max(P.width,P.height)),re<1||E===!0)if(typeof HTMLImageElement<"u"&&P instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&P instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&P instanceof ImageBitmap){const fe=E?fa:Math.floor,Me=fe(re*P.width),pe=fe(re*P.height);g===void 0&&(g=x(Me,pe));const ye=q?x(Me,pe):g;return ye.width=Me,ye.height=pe,ye.getContext("2d").drawImage(P,0,0,Me,pe),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+P.width+"x"+P.height+") to ("+Me+"x"+pe+")."),ye}else return"data"in P&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+P.width+"x"+P.height+")."),P;return P}function y(P){return Ul(P.width)&&Ul(P.height)}function b(P){return a?!1:P.wrapS!==Hn||P.wrapT!==Hn||P.minFilter!==Nt&&P.minFilter!==En}function M(P,E){return P.generateMipmaps&&E&&P.minFilter!==Nt&&P.minFilter!==En}function T(P){r.generateMipmap(P)}function I(P,E,q,le,re=!1){if(a===!1)return E;if(P!==null){if(r[P]!==void 0)return r[P];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+P+"'")}let fe=E;if(E===r.RED&&(q===r.FLOAT&&(fe=r.R32F),q===r.HALF_FLOAT&&(fe=r.R16F),q===r.UNSIGNED_BYTE&&(fe=r.R8)),E===r.RED_INTEGER&&(q===r.UNSIGNED_BYTE&&(fe=r.R8UI),q===r.UNSIGNED_SHORT&&(fe=r.R16UI),q===r.UNSIGNED_INT&&(fe=r.R32UI),q===r.BYTE&&(fe=r.R8I),q===r.SHORT&&(fe=r.R16I),q===r.INT&&(fe=r.R32I)),E===r.RG&&(q===r.FLOAT&&(fe=r.RG32F),q===r.HALF_FLOAT&&(fe=r.RG16F),q===r.UNSIGNED_BYTE&&(fe=r.RG8)),E===r.RGBA){const Me=re?la:pt.getTransfer(le);q===r.FLOAT&&(fe=r.RGBA32F),q===r.HALF_FLOAT&&(fe=r.RGBA16F),q===r.UNSIGNED_BYTE&&(fe=Me===At?r.SRGB8_ALPHA8:r.RGBA8),q===r.UNSIGNED_SHORT_4_4_4_4&&(fe=r.RGBA4),q===r.UNSIGNED_SHORT_5_5_5_1&&(fe=r.RGB5_A1)}return(fe===r.R16F||fe===r.R32F||fe===r.RG16F||fe===r.RG32F||fe===r.RGBA16F||fe===r.RGBA32F)&&e.get("EXT_color_buffer_float"),fe}function S(P,E,q){return M(P,q)===!0||P.isFramebufferTexture&&P.minFilter!==Nt&&P.minFilter!==En?Math.log2(Math.max(E.width,E.height))+1:P.mipmaps!==void 0&&P.mipmaps.length>0?P.mipmaps.length:P.isCompressedTexture&&Array.isArray(P.image)?E.mipmaps.length:1}function A(P){return P===Nt||P===Dl||P===ra?r.NEAREST:r.LINEAR}function z(P){const E=P.target;E.removeEventListener("dispose",z),W(E),E.isVideoTexture&&_.delete(E)}function O(P){const E=P.target;E.removeEventListener("dispose",O),V(E)}function W(P){const E=n.get(P);if(E.__webglInit===void 0)return;const q=P.source,le=m.get(q);if(le){const re=le[E.__cacheKey];re.usedTimes--,re.usedTimes===0&&D(P),Object.keys(le).length===0&&m.delete(q)}n.remove(P)}function D(P){const E=n.get(P);r.deleteTexture(E.__webglTexture);const q=P.source,le=m.get(q);delete le[E.__cacheKey],o.memory.textures--}function V(P){const E=P.texture,q=n.get(P),le=n.get(E);if(le.__webglTexture!==void 0&&(r.deleteTexture(le.__webglTexture),o.memory.textures--),P.depthTexture&&P.depthTexture.dispose(),P.isWebGLCubeRenderTarget)for(let re=0;re<6;re++){if(Array.isArray(q.__webglFramebuffer[re]))for(let fe=0;fe=l&&console.warn("THREE.WebGLTextures: Trying to use "+P+" texture units while this GPU supports only "+l),Z+=1,P}function ie(P){const E=[];return E.push(P.wrapS),E.push(P.wrapT),E.push(P.wrapR||0),E.push(P.magFilter),E.push(P.minFilter),E.push(P.anisotropy),E.push(P.internalFormat),E.push(P.format),E.push(P.type),E.push(P.generateMipmaps),E.push(P.premultiplyAlpha),E.push(P.flipY),E.push(P.unpackAlignment),E.push(P.colorSpace),E.join()}function se(P,E){const q=n.get(P);if(P.isVideoTexture&&Tt(P),P.isRenderTargetTexture===!1&&P.version>0&&q.__version!==P.version){const le=P.image;if(le===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(le.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{We(q,P,E);return}}t.bindTexture(r.TEXTURE_2D,q.__webglTexture,r.TEXTURE0+E)}function me(P,E){const q=n.get(P);if(P.version>0&&q.__version!==P.version){We(q,P,E);return}t.bindTexture(r.TEXTURE_2D_ARRAY,q.__webglTexture,r.TEXTURE0+E)}function ve(P,E){const q=n.get(P);if(P.version>0&&q.__version!==P.version){We(q,P,E);return}t.bindTexture(r.TEXTURE_3D,q.__webglTexture,r.TEXTURE0+E)}function Q(P,E){const q=n.get(P);if(P.version>0&&q.__version!==P.version){Fe(q,P,E);return}t.bindTexture(r.TEXTURE_CUBE_MAP,q.__webglTexture,r.TEXTURE0+E)}const oe={[us]:r.REPEAT,[Hn]:r.CLAMP_TO_EDGE,[aa]:r.MIRRORED_REPEAT},Se={[Nt]:r.NEAREST,[Dl]:r.NEAREST_MIPMAP_NEAREST,[ra]:r.NEAREST_MIPMAP_LINEAR,[En]:r.LINEAR,[ef]:r.LINEAR_MIPMAP_NEAREST,[gr]:r.LINEAR_MIPMAP_LINEAR},De={[jd]:r.NEVER,[Qd]:r.ALWAYS,[Yd]:r.LESS,[hf]:r.LEQUAL,[$d]:r.EQUAL,[Jd]:r.GEQUAL,[Kd]:r.GREATER,[Zd]:r.NOTEQUAL};function _e(P,E,q){if(q?(r.texParameteri(P,r.TEXTURE_WRAP_S,oe[E.wrapS]),r.texParameteri(P,r.TEXTURE_WRAP_T,oe[E.wrapT]),(P===r.TEXTURE_3D||P===r.TEXTURE_2D_ARRAY)&&r.texParameteri(P,r.TEXTURE_WRAP_R,oe[E.wrapR]),r.texParameteri(P,r.TEXTURE_MAG_FILTER,Se[E.magFilter]),r.texParameteri(P,r.TEXTURE_MIN_FILTER,Se[E.minFilter])):(r.texParameteri(P,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(P,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),(P===r.TEXTURE_3D||P===r.TEXTURE_2D_ARRAY)&&r.texParameteri(P,r.TEXTURE_WRAP_R,r.CLAMP_TO_EDGE),(E.wrapS!==Hn||E.wrapT!==Hn)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),r.texParameteri(P,r.TEXTURE_MAG_FILTER,A(E.magFilter)),r.texParameteri(P,r.TEXTURE_MIN_FILTER,A(E.minFilter)),E.minFilter!==Nt&&E.minFilter!==En&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),E.compareFunction&&(r.texParameteri(P,r.TEXTURE_COMPARE_MODE,r.COMPARE_REF_TO_TEXTURE),r.texParameteri(P,r.TEXTURE_COMPARE_FUNC,De[E.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){const le=e.get("EXT_texture_filter_anisotropic");if(E.magFilter===Nt||E.minFilter!==ra&&E.minFilter!==gr||E.type===vn&&e.has("OES_texture_float_linear")===!1||a===!1&&E.type===Js&&e.has("OES_texture_half_float_linear")===!1)return;(E.anisotropy>1||n.get(E).__currentAnisotropy)&&(r.texParameterf(P,le.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(E.anisotropy,i.getMaxAnisotropy())),n.get(E).__currentAnisotropy=E.anisotropy)}}function qe(P,E){let q=!1;P.__webglInit===void 0&&(P.__webglInit=!0,E.addEventListener("dispose",z));const le=E.source;let re=m.get(le);re===void 0&&(re={},m.set(le,re));const fe=ie(E);if(fe!==P.__cacheKey){re[fe]===void 0&&(re[fe]={texture:r.createTexture(),usedTimes:0},o.memory.textures++,q=!0),re[fe].usedTimes++;const Me=re[P.__cacheKey];Me!==void 0&&(re[P.__cacheKey].usedTimes--,Me.usedTimes===0&&D(E)),P.__cacheKey=fe,P.__webglTexture=re[fe].texture}return q}function We(P,E,q){let le=r.TEXTURE_2D;(E.isDataArrayTexture||E.isCompressedArrayTexture)&&(le=r.TEXTURE_2D_ARRAY),E.isData3DTexture&&(le=r.TEXTURE_3D);const re=qe(P,E),fe=E.source;t.bindTexture(le,P.__webglTexture,r.TEXTURE0+q);const Me=n.get(fe);if(fe.version!==Me.__version||re===!0){t.activeTexture(r.TEXTURE0+q);const pe=pt.getPrimaries(pt.workingColorSpace),ye=E.colorSpace===Vn?null:pt.getPrimaries(E.colorSpace),N=E.colorSpace===Vn||pe===ye?r.NONE:r.BROWSER_DEFAULT_WEBGL;r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,E.flipY),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,E.premultiplyAlpha),r.pixelStorei(r.UNPACK_ALIGNMENT,E.unpackAlignment),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,N);const de=b(E)&&y(E.image)===!1;let ne=v(E.image,de,!1,u);ne=Ct(E,ne);const Oe=y(ne)||a,Ae=s.convert(E.format,E.colorSpace);let Pe=s.convert(E.type),we=I(E.internalFormat,Ae,Pe,E.colorSpace,E.isVideoTexture);_e(le,E,Oe);let be;const Ge=E.mipmaps,F=a&&E.isVideoTexture!==!0&&we!==af,ge=Me.__version===void 0||re===!0,ae=S(E,ne,Oe);if(E.isDepthTexture)we=r.DEPTH_COMPONENT,a?E.type===vn?we=r.DEPTH_COMPONENT32F:E.type===Dn?we=r.DEPTH_COMPONENT24:E.type===pr?we=r.DEPTH24_STENCIL8:we=r.DEPTH_COMPONENT16:E.type===vn&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),E.format===mr&&we===r.DEPTH_COMPONENT&&E.type!==va&&E.type!==Dn&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),E.type=Dn,Pe=s.convert(E.type)),E.format===hs&&we===r.DEPTH_COMPONENT&&(we=r.DEPTH_STENCIL,E.type!==pr&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),E.type=pr,Pe=s.convert(E.type))),ge&&(F?t.texStorage2D(r.TEXTURE_2D,1,we,ne.width,ne.height):t.texImage2D(r.TEXTURE_2D,0,we,ne.width,ne.height,0,Ae,Pe,null));else if(E.isDataTexture)if(Ge.length>0&&Oe){F&&ge&&t.texStorage2D(r.TEXTURE_2D,ae,we,Ge[0].width,Ge[0].height);for(let ee=0,he=Ge.length;ee>=1,he>>=1}}else if(Ge.length>0&&Oe){F&&ge&&t.texStorage2D(r.TEXTURE_2D,ae,we,Ge[0].width,Ge[0].height);for(let ee=0,he=Ge.length;ee0&&ge++,t.texStorage2D(r.TEXTURE_CUBE_MAP,ge,be,ne[0].width,ne[0].height));for(let ee=0;ee<6;ee++)if(de){Ge?t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ee,0,0,0,ne[ee].width,ne[ee].height,Pe,we,ne[ee].data):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ee,0,be,ne[ee].width,ne[ee].height,0,Pe,we,ne[ee].data);for(let he=0;he>fe),ne=Math.max(1,E.height>>fe);re===r.TEXTURE_3D||re===r.TEXTURE_2D_ARRAY?t.texImage3D(re,fe,ye,de,ne,E.depth,0,Me,pe,null):t.texImage2D(re,fe,ye,de,ne,0,Me,pe,null)}t.bindFramebuffer(r.FRAMEBUFFER,P),ot(E)?h.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,le,re,n.get(q).__webglTexture,0,ke(E)):(re===r.TEXTURE_2D||re>=r.TEXTURE_CUBE_MAP_POSITIVE_X&&re<=r.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&r.framebufferTexture2D(r.FRAMEBUFFER,le,re,n.get(q).__webglTexture,fe),t.bindFramebuffer(r.FRAMEBUFFER,null)}function X(P,E,q){if(r.bindRenderbuffer(r.RENDERBUFFER,P),E.depthBuffer&&!E.stencilBuffer){let le=a===!0?r.DEPTH_COMPONENT24:r.DEPTH_COMPONENT16;if(q||ot(E)){const re=E.depthTexture;re&&re.isDepthTexture&&(re.type===vn?le=r.DEPTH_COMPONENT32F:re.type===Dn&&(le=r.DEPTH_COMPONENT24));const fe=ke(E);ot(E)?h.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,fe,le,E.width,E.height):r.renderbufferStorageMultisample(r.RENDERBUFFER,fe,le,E.width,E.height)}else r.renderbufferStorage(r.RENDERBUFFER,le,E.width,E.height);r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.RENDERBUFFER,P)}else if(E.depthBuffer&&E.stencilBuffer){const le=ke(E);q&&ot(E)===!1?r.renderbufferStorageMultisample(r.RENDERBUFFER,le,r.DEPTH24_STENCIL8,E.width,E.height):ot(E)?h.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,le,r.DEPTH24_STENCIL8,E.width,E.height):r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_STENCIL,E.width,E.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.RENDERBUFFER,P)}else{const le=E.isWebGLMultipleRenderTargets===!0?E.texture:[E.texture];for(let re=0;re0){q.__webglFramebuffer[pe]=[];for(let ye=0;ye0){q.__webglFramebuffer=[];for(let pe=0;pe0&&ot(P)===!1){const pe=fe?E:[E];q.__webglMultisampledFramebuffer=r.createFramebuffer(),q.__webglColorRenderbuffer=[],t.bindFramebuffer(r.FRAMEBUFFER,q.__webglMultisampledFramebuffer);for(let ye=0;ye0)for(let ye=0;ye0)for(let ye=0;ye0&&ot(P)===!1){const E=P.isWebGLMultipleRenderTargets?P.texture:[P.texture],q=P.width,le=P.height;let re=r.COLOR_BUFFER_BIT;const fe=[],Me=P.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,pe=n.get(P),ye=P.isWebGLMultipleRenderTargets===!0;if(ye)for(let N=0;N0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&E.__useRenderToTexture!==!1}function Tt(P){const E=o.render.frame;_.get(P)!==E&&(_.set(P,E),P.update())}function Ct(P,E){const q=P.colorSpace,le=P.format,re=P.type;return P.isCompressedTexture===!0||P.isVideoTexture===!0||P.format===Ol||q!==an&&q!==Vn&&(pt.getTransfer(q)===At?a===!1?e.has("EXT_sRGB")===!0&&le===sn?(P.format=Ol,P.minFilter=En,P.generateMipmaps=!1):E=pf.sRGBToLinear(E):(le!==sn||re!==fi)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",q)),E}this.allocateTextureUnit=ce,this.resetTextureUnits=J,this.setTexture2D=se,this.setTexture2DArray=me,this.setTexture3D=ve,this.setTextureCube=Q,this.rebindTextures=$e,this.setupRenderTarget=ze,this.updateRenderTargetMipmap=_t,this.updateMultisampleRenderTarget=Ke,this.setupDepthRenderbuffer=Ce,this.setupFrameBufferTexture=Ye,this.useMultisampledRTT=ot}function f0(r,e,t){const n=t.isWebGL2;function i(s,o=Vn){let a;const l=pt.getTransfer(o);if(s===fi)return r.UNSIGNED_BYTE;if(s===nf)return r.UNSIGNED_SHORT_4_4_4_4;if(s===rf)return r.UNSIGNED_SHORT_5_5_5_1;if(s===Il)return r.BYTE;if(s===tf)return r.SHORT;if(s===va)return r.UNSIGNED_SHORT;if(s===Ws)return r.INT;if(s===Dn)return r.UNSIGNED_INT;if(s===vn)return r.FLOAT;if(s===Js)return n?r.HALF_FLOAT:(a=e.get("OES_texture_half_float"),a!==null?a.HALF_FLOAT_OES:null);if(s===Bd)return r.ALPHA;if(s===sn)return r.RGBA;if(s===zd)return r.LUMINANCE;if(s===kd)return r.LUMINANCE_ALPHA;if(s===mr)return r.DEPTH_COMPONENT;if(s===hs)return r.DEPTH_STENCIL;if(s===Ol)return a=e.get("EXT_sRGB"),a!==null?a.SRGB_ALPHA_EXT:null;if(s===sf)return r.RED;if(s===Ql)return r.RED_INTEGER;if(s===of)return r.RG;if(s===xa)return r.RG_INTEGER;if(s===Qs)return r.RGBA_INTEGER;if(s===La||s===Ca||s===Pa||s===Da)if(l===At)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(s===La)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===Ca)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===Pa)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===Da)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=e.get("WEBGL_compressed_texture_s3tc"),a!==null){if(s===La)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===Ca)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===Pa)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===Da)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===Dc||s===Ic||s===Nc||s===Fc)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(s===Dc)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===Ic)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===Nc)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===Fc)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===af)return a=e.get("WEBGL_compressed_texture_etc1"),a!==null?a.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===Oc||s===Uc)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(s===Oc)return l===At?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(s===Uc)return l===At?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===Bc||s===zc||s===kc||s===Hc||s===Vc||s===Gc||s===Wc||s===Xc||s===qc||s===jc||s===Yc||s===$c||s===Kc||s===Zc)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(s===Bc)return l===At?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===zc)return l===At?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===kc)return l===At?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===Hc)return l===At?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===Vc)return l===At?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===Gc)return l===At?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===Wc)return l===At?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===Xc)return l===At?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===qc)return l===At?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===jc)return l===At?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===Yc)return l===At?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===$c)return l===At?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===Kc)return l===At?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===Zc)return l===At?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===Ia||s===Jc||s===Qc)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(s===Ia)return l===At?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(s===Jc)return a.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(s===Qc)return a.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(s===Hd||s===eu||s===tu||s===nu)if(a=e.get("EXT_texture_compression_rgtc"),a!==null){if(s===Ia)return a.COMPRESSED_RED_RGTC1_EXT;if(s===eu)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(s===tu)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(s===nu)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return s===pr?n?r.UNSIGNED_INT_24_8:(a=e.get("WEBGL_depth_texture"),a!==null?a.UNSIGNED_INT_24_8_WEBGL:null):r[s]!==void 0?r[s]:null}return{convert:i}}class d0 extends gn{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class dr extends Bt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const p0={type:"move"};class il{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new dr,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new dr,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new C,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new C),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new dr,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new C,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new C),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let i=null,s=null,o=null;const a=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){o=!0;for(const g of e.hand.values()){const m=t.getJointPose(g,n),d=this._getHandJoint(c,g);m!==null&&(d.matrix.fromArray(m.transform.matrix),d.matrix.decompose(d.position,d.rotation,d.scale),d.matrixWorldNeedsUpdate=!0,d.jointRadius=m.radius),d.visible=m!==null}const u=c.joints["index-finger-tip"],f=c.joints["thumb-tip"],h=u.position.distanceTo(f.position),p=.02,_=.005;c.inputState.pinching&&h>p+_?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&h<=p-_&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,n),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));a!==null&&(i=t.getPose(e.targetRaySpace,n),i===null&&s!==null&&(i=s),i!==null&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(p0)))}return a!==null&&(a.visible=i!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=o!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new dr;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}class m0 extends xr{constructor(e,t){super();const n=this;let i=null,s=1,o=null,a="local-floor",l=1,c=null,u=null,f=null,h=null,p=null,_=null;const g=t.getContextAttributes();let m=null,d=null;const x=[],v=[],y=new Ue;let b=null;const M=new gn;M.layers.enable(1),M.viewport=new mt;const T=new gn;T.layers.enable(2),T.viewport=new mt;const I=[M,T],S=new d0;S.layers.enable(1),S.layers.enable(2);let A=null,z=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Q){let oe=x[Q];return oe===void 0&&(oe=new il,x[Q]=oe),oe.getTargetRaySpace()},this.getControllerGrip=function(Q){let oe=x[Q];return oe===void 0&&(oe=new il,x[Q]=oe),oe.getGripSpace()},this.getHand=function(Q){let oe=x[Q];return oe===void 0&&(oe=new il,x[Q]=oe),oe.getHandSpace()};function O(Q){const oe=v.indexOf(Q.inputSource);if(oe===-1)return;const Se=x[oe];Se!==void 0&&(Se.update(Q.inputSource,Q.frame,c||o),Se.dispatchEvent({type:Q.type,data:Q.inputSource}))}function W(){i.removeEventListener("select",O),i.removeEventListener("selectstart",O),i.removeEventListener("selectend",O),i.removeEventListener("squeeze",O),i.removeEventListener("squeezestart",O),i.removeEventListener("squeezeend",O),i.removeEventListener("end",W),i.removeEventListener("inputsourceschange",D);for(let Q=0;Q=0&&(v[De]=null,x[De].disconnect(Se))}for(let oe=0;oe=v.length){v.push(Se),De=qe;break}else if(v[qe]===null){v[qe]=Se,De=qe;break}if(De===-1)break}const _e=x[De];_e&&_e.connect(Se)}}const V=new C,Z=new C;function J(Q,oe,Se){V.setFromMatrixPosition(oe.matrixWorld),Z.setFromMatrixPosition(Se.matrixWorld);const De=V.distanceTo(Z),_e=oe.projectionMatrix.elements,qe=Se.projectionMatrix.elements,We=_e[14]/(_e[10]-1),Fe=_e[14]/(_e[10]+1),Ye=(_e[9]+1)/_e[5],X=(_e[9]-1)/_e[5],Lt=(_e[8]-1)/_e[0],Ce=(qe[8]+1)/qe[0],$e=We*Lt,ze=We*Ce,_t=De/(-Lt+Ce),Ke=_t*-Lt;oe.matrixWorld.decompose(Q.position,Q.quaternion,Q.scale),Q.translateX(Ke),Q.translateZ(_t),Q.matrixWorld.compose(Q.position,Q.quaternion,Q.scale),Q.matrixWorldInverse.copy(Q.matrixWorld).invert();const ke=We+_t,ot=Fe+_t,Tt=$e-Ke,Ct=ze+(De-Ke),P=Ye*Fe/ot*ke,E=X*Fe/ot*ke;Q.projectionMatrix.makePerspective(Tt,Ct,P,E,ke,ot),Q.projectionMatrixInverse.copy(Q.projectionMatrix).invert()}function ce(Q,oe){oe===null?Q.matrixWorld.copy(Q.matrix):Q.matrixWorld.multiplyMatrices(oe.matrixWorld,Q.matrix),Q.matrixWorldInverse.copy(Q.matrixWorld).invert()}this.updateCamera=function(Q){if(i===null)return;S.near=T.near=M.near=Q.near,S.far=T.far=M.far=Q.far,(A!==S.near||z!==S.far)&&(i.updateRenderState({depthNear:S.near,depthFar:S.far}),A=S.near,z=S.far);const oe=Q.parent,Se=S.cameras;ce(S,oe);for(let De=0;De0&&(m.alphaTest.value=d.alphaTest);const x=e.get(d).envMap;if(x&&(m.envMap.value=x,m.flipEnvMap.value=x.isCubeTexture&&x.isRenderTargetTexture===!1?-1:1,m.reflectivity.value=d.reflectivity,m.ior.value=d.ior,m.refractionRatio.value=d.refractionRatio),d.lightMap){m.lightMap.value=d.lightMap;const v=r._useLegacyLights===!0?Math.PI:1;m.lightMapIntensity.value=d.lightMapIntensity*v,t(d.lightMap,m.lightMapTransform)}d.aoMap&&(m.aoMap.value=d.aoMap,m.aoMapIntensity.value=d.aoMapIntensity,t(d.aoMap,m.aoMapTransform))}function o(m,d){m.diffuse.value.copy(d.color),m.opacity.value=d.opacity,d.map&&(m.map.value=d.map,t(d.map,m.mapTransform))}function a(m,d){m.dashSize.value=d.dashSize,m.totalSize.value=d.dashSize+d.gapSize,m.scale.value=d.scale}function l(m,d,x,v){m.diffuse.value.copy(d.color),m.opacity.value=d.opacity,m.size.value=d.size*x,m.scale.value=v*.5,d.map&&(m.map.value=d.map,t(d.map,m.uvTransform)),d.alphaMap&&(m.alphaMap.value=d.alphaMap,t(d.alphaMap,m.alphaMapTransform)),d.alphaTest>0&&(m.alphaTest.value=d.alphaTest)}function c(m,d){m.diffuse.value.copy(d.color),m.opacity.value=d.opacity,m.rotation.value=d.rotation,d.map&&(m.map.value=d.map,t(d.map,m.mapTransform)),d.alphaMap&&(m.alphaMap.value=d.alphaMap,t(d.alphaMap,m.alphaMapTransform)),d.alphaTest>0&&(m.alphaTest.value=d.alphaTest)}function u(m,d){m.specular.value.copy(d.specular),m.shininess.value=Math.max(d.shininess,1e-4)}function f(m,d){d.gradientMap&&(m.gradientMap.value=d.gradientMap)}function h(m,d){m.metalness.value=d.metalness,d.metalnessMap&&(m.metalnessMap.value=d.metalnessMap,t(d.metalnessMap,m.metalnessMapTransform)),m.roughness.value=d.roughness,d.roughnessMap&&(m.roughnessMap.value=d.roughnessMap,t(d.roughnessMap,m.roughnessMapTransform)),e.get(d).envMap&&(m.envMapIntensity.value=d.envMapIntensity)}function p(m,d,x){m.ior.value=d.ior,d.sheen>0&&(m.sheenColor.value.copy(d.sheenColor).multiplyScalar(d.sheen),m.sheenRoughness.value=d.sheenRoughness,d.sheenColorMap&&(m.sheenColorMap.value=d.sheenColorMap,t(d.sheenColorMap,m.sheenColorMapTransform)),d.sheenRoughnessMap&&(m.sheenRoughnessMap.value=d.sheenRoughnessMap,t(d.sheenRoughnessMap,m.sheenRoughnessMapTransform))),d.clearcoat>0&&(m.clearcoat.value=d.clearcoat,m.clearcoatRoughness.value=d.clearcoatRoughness,d.clearcoatMap&&(m.clearcoatMap.value=d.clearcoatMap,t(d.clearcoatMap,m.clearcoatMapTransform)),d.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=d.clearcoatRoughnessMap,t(d.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),d.clearcoatNormalMap&&(m.clearcoatNormalMap.value=d.clearcoatNormalMap,t(d.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(d.clearcoatNormalScale),d.side===xn&&m.clearcoatNormalScale.value.negate())),d.iridescence>0&&(m.iridescence.value=d.iridescence,m.iridescenceIOR.value=d.iridescenceIOR,m.iridescenceThicknessMinimum.value=d.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=d.iridescenceThicknessRange[1],d.iridescenceMap&&(m.iridescenceMap.value=d.iridescenceMap,t(d.iridescenceMap,m.iridescenceMapTransform)),d.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=d.iridescenceThicknessMap,t(d.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),d.transmission>0&&(m.transmission.value=d.transmission,m.transmissionSamplerMap.value=x.texture,m.transmissionSamplerSize.value.set(x.width,x.height),d.transmissionMap&&(m.transmissionMap.value=d.transmissionMap,t(d.transmissionMap,m.transmissionMapTransform)),m.thickness.value=d.thickness,d.thicknessMap&&(m.thicknessMap.value=d.thicknessMap,t(d.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=d.attenuationDistance,m.attenuationColor.value.copy(d.attenuationColor)),d.anisotropy>0&&(m.anisotropyVector.value.set(d.anisotropy*Math.cos(d.anisotropyRotation),d.anisotropy*Math.sin(d.anisotropyRotation)),d.anisotropyMap&&(m.anisotropyMap.value=d.anisotropyMap,t(d.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=d.specularIntensity,m.specularColor.value.copy(d.specularColor),d.specularColorMap&&(m.specularColorMap.value=d.specularColorMap,t(d.specularColorMap,m.specularColorMapTransform)),d.specularIntensityMap&&(m.specularIntensityMap.value=d.specularIntensityMap,t(d.specularIntensityMap,m.specularIntensityMapTransform))}function _(m,d){d.matcap&&(m.matcap.value=d.matcap)}function g(m,d){const x=e.get(d).light;m.referencePosition.value.setFromMatrixPosition(x.matrixWorld),m.nearDistance.value=x.shadow.camera.near,m.farDistance.value=x.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:i}}function g0(r,e,t,n){let i={},s={},o=[];const a=t.isWebGL2?r.getParameter(r.MAX_UNIFORM_BUFFER_BINDINGS):0;function l(x,v){const y=v.program;n.uniformBlockBinding(x,y)}function c(x,v){let y=i[x.id];y===void 0&&(_(x),y=u(x),i[x.id]=y,x.addEventListener("dispose",m));const b=v.program;n.updateUBOMapping(x,b);const M=e.render.frame;s[x.id]!==M&&(h(x),s[x.id]=M)}function u(x){const v=f();x.__bindingPointIndex=v;const y=r.createBuffer(),b=x.__size,M=x.usage;return r.bindBuffer(r.UNIFORM_BUFFER,y),r.bufferData(r.UNIFORM_BUFFER,b,M),r.bindBuffer(r.UNIFORM_BUFFER,null),r.bindBufferBase(r.UNIFORM_BUFFER,v,y),y}function f(){for(let x=0;x0){M=y%b;const O=b-M;M!==0&&O-A.boundary<0&&(y+=b-M,S.__offset=y)}y+=A.storage}return M=y%b,M>0&&(y+=b-M),x.__size=y,x.__cache={},this}function g(x){const v={boundary:0,storage:0};return typeof x=="number"?(v.boundary=4,v.storage=4):x.isVector2?(v.boundary=8,v.storage=8):x.isVector3||x.isColor?(v.boundary=16,v.storage=12):x.isVector4?(v.boundary=16,v.storage=16):x.isMatrix3?(v.boundary=48,v.storage=48):x.isMatrix4?(v.boundary=64,v.storage=64):x.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",x),v}function m(x){const v=x.target;v.removeEventListener("dispose",m);const y=o.indexOf(v.__bindingPointIndex);o.splice(y,1),r.deleteBuffer(i[v.id]),delete i[v.id],delete s[v.id]}function d(){for(const x in i)r.deleteBuffer(i[x]);o=[],i={},s={}}return{bind:l,update:c,dispose:d}}class Pf{constructor(e={}){const{canvas:t=pp(),context:n=null,depth:i=!0,stencil:s=!0,alpha:o=!1,antialias:a=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:f=!1}=e;this.isWebGLRenderer=!0;let h;n!==null?h=n.getContextAttributes().alpha:h=o;const p=new Uint32Array(4),_=new Int32Array(4);let g=null,m=null;const d=[],x=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=Ht,this._useLegacyLights=!1,this.toneMapping=ji,this.toneMappingExposure=1;const v=this;let y=!1,b=0,M=0,T=null,I=-1,S=null;const A=new mt,z=new mt;let O=null;const W=new tt(0);let D=0,V=t.width,Z=t.height,J=1,ce=null,ie=null;const se=new mt(0,0,V,Z),me=new mt(0,0,V,Z);let ve=!1;const Q=new nc;let oe=!1,Se=!1,De=null;const _e=new Ve,qe=new Ue,We=new C,Fe={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Ye(){return T===null?J:1}let X=n;function Lt(R,H){for(let j=0;j{function Ee(){if(K.forEach(function(Ie){Ke.get(Ie).currentProgram.isReady()&&K.delete(Ie)}),K.size===0){Y(R);return}setTimeout(Ee,10)}Ce.get("KHR_parallel_shader_compile")!==null?Ee():setTimeout(Ee,10)})};let nt=null;function gt(R){nt&&nt(R)}function Vt(){ft.stop()}function ht(){ft.start()}const ft=new wf;ft.setAnimationLoop(gt),typeof self<"u"&&ft.setContext(self),this.setAnimationLoop=function(R){nt=R,be.setAnimationLoop(R),R===null?ft.stop():ft.start()},be.addEventListener("sessionstart",Vt),be.addEventListener("sessionend",ht),this.render=function(R,H){if(H!==void 0&&H.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(y===!0)return;R.matrixWorldAutoUpdate===!0&&R.updateMatrixWorld(),H.parent===null&&H.matrixWorldAutoUpdate===!0&&H.updateMatrixWorld(),be.enabled===!0&&be.isPresenting===!0&&(be.cameraAutoUpdate===!0&&be.updateCamera(H),H=be.getCamera()),R.isScene===!0&&R.onBeforeRender(v,R,H,T),m=fe.get(R,x.length),m.init(),x.push(m),_e.multiplyMatrices(H.projectionMatrix,H.matrixWorldInverse),Q.setFromProjectionMatrix(_e),Se=this.localClippingEnabled,oe=Me.init(this.clippingPlanes,Se),g=re.get(R,d.length),g.init(),d.push(g),Sn(R,H,0,v.sortObjects),g.finish(),v.sortObjects===!0&&g.sort(ce,ie),this.info.render.frame++,oe===!0&&Me.beginShadows();const j=m.state.shadowsArray;if(pe.render(j,R,H),oe===!0&&Me.endShadows(),this.info.autoReset===!0&&this.info.reset(),ye.render(g,R),m.setupLights(v._useLegacyLights),H.isArrayCamera){const K=H.cameras;for(let Y=0,Ee=K.length;Y0?m=x[x.length-1]:m=null,d.pop(),d.length>0?g=d[d.length-1]:g=null};function Sn(R,H,j,K){if(R.visible===!1)return;if(R.layers.test(H.layers)){if(R.isGroup)j=R.renderOrder;else if(R.isLOD)R.autoUpdate===!0&&R.update(H);else if(R.isLight)m.pushLight(R),R.castShadow&&m.pushShadow(R);else if(R.isSprite){if(!R.frustumCulled||Q.intersectsSprite(R)){K&&We.setFromMatrixPosition(R.matrixWorld).applyMatrix4(_e);const Ie=E.update(R),He=R.material;He.visible&&g.push(R,Ie,He,j,We.z,null)}}else if((R.isMesh||R.isLine||R.isPoints)&&(!R.frustumCulled||Q.intersectsObject(R))){const Ie=E.update(R),He=R.material;if(K&&(R.boundingSphere!==void 0?(R.boundingSphere===null&&R.computeBoundingSphere(),We.copy(R.boundingSphere.center)):(Ie.boundingSphere===null&&Ie.computeBoundingSphere(),We.copy(Ie.boundingSphere.center)),We.applyMatrix4(R.matrixWorld).applyMatrix4(_e)),Array.isArray(He)){const Xe=Ie.groups;for(let et=0,je=Xe.length;et0&&ln(Y,Ee,H,j),K&&ze.viewport(A.copy(K)),Y.length>0&&Pi(Y,H,j),Ee.length>0&&Pi(Ee,H,j),Ie.length>0&&Pi(Ie,H,j),ze.buffers.depth.setTest(!0),ze.buffers.depth.setMask(!0),ze.buffers.color.setMask(!0),ze.setPolygonOffset(!1)}function ln(R,H,j,K){if((j.isScene===!0?j.overrideMaterial:null)!==null)return;const Ee=$e.isWebGL2;De===null&&(De=new $i(1,1,{generateMipmaps:!0,type:Ce.has("EXT_color_buffer_half_float")?Js:fi,minFilter:gr,samples:Ee?4:0})),v.getDrawingBufferSize(qe),Ee?De.setSize(qe.x,qe.y):De.setSize(fa(qe.x),fa(qe.y));const Ie=v.getRenderTarget();v.setRenderTarget(De),v.getClearColor(W),D=v.getClearAlpha(),D<1&&v.setClearColor(16777215,.5),v.clear();const He=v.toneMapping;v.toneMapping=ji,Pi(R,j,K),ke.updateMultisampleRenderTarget(De),ke.updateRenderTargetMipmap(De);let Xe=!1;for(let et=0,je=H.length;et0),Ze=!!j.morphAttributes.position,xt=!!j.morphAttributes.normal,Gt=!!j.morphAttributes.color;let zt=ji;K.toneMapped&&(T===null||T.isXRRenderTarget===!0)&&(zt=v.toneMapping);const cn=j.morphAttributes.position||j.morphAttributes.normal||j.morphAttributes.color,at=cn!==void 0?cn.length:0,Je=Ke.get(K),Ji=m.state.lights;if(oe===!0&&(Se===!0||R!==S)){const te=R===S&&K.id===I;Me.setState(K,R,te)}let yt=!1;K.version===Je.__version?(Je.needsLights&&Je.lightsStateVersion!==Ji.state.version||Je.outputColorSpace!==He||Y.isBatchedMesh&&Je.batching===!1||!Y.isBatchedMesh&&Je.batching===!0||Y.isInstancedMesh&&Je.instancing===!1||!Y.isInstancedMesh&&Je.instancing===!0||Y.isSkinnedMesh&&Je.skinning===!1||!Y.isSkinnedMesh&&Je.skinning===!0||Y.isInstancedMesh&&Je.instancingColor===!0&&Y.instanceColor===null||Y.isInstancedMesh&&Je.instancingColor===!1&&Y.instanceColor!==null||Je.envMap!==Xe||K.fog===!0&&Je.fog!==Ee||Je.numClippingPlanes!==void 0&&(Je.numClippingPlanes!==Me.numPlanes||Je.numIntersection!==Me.numIntersection)||Je.vertexAlphas!==et||Je.vertexTangents!==je||Je.morphTargets!==Ze||Je.morphNormals!==xt||Je.morphColors!==Gt||Je.toneMapping!==zt||$e.isWebGL2===!0&&Je.morphTargetsCount!==at)&&(yt=!0):(yt=!0,Je.__version=K.version);let Fn=Je.currentProgram;yt===!0&&(Fn=ri(K,H,Y));let Er=!1,Jt=!1,nn=!1;const Wt=Fn.getUniforms(),w=Je.uniforms;if(ze.useProgram(Fn.program)&&(Er=!0,Jt=!0,nn=!0),K.id!==I&&(I=K.id,Jt=!0),Er||S!==R){Wt.setValue(X,"projectionMatrix",R.projectionMatrix),Wt.setValue(X,"viewMatrix",R.matrixWorldInverse);const te=Wt.map.cameraPosition;te!==void 0&&te.setValue(X,We.setFromMatrixPosition(R.matrixWorld)),$e.logarithmicDepthBuffer&&Wt.setValue(X,"logDepthBufFC",2/(Math.log(R.far+1)/Math.LN2)),(K.isMeshPhongMaterial||K.isMeshToonMaterial||K.isMeshLambertMaterial||K.isMeshBasicMaterial||K.isMeshStandardMaterial||K.isShaderMaterial)&&Wt.setValue(X,"isOrthographic",R.isOrthographicCamera===!0),S!==R&&(S=R,Jt=!0,nn=!0)}if(Y.isSkinnedMesh){Wt.setOptional(X,Y,"bindMatrix"),Wt.setOptional(X,Y,"bindMatrixInverse");const te=Y.skeleton;te&&($e.floatVertexTextures?(te.boneTexture===null&&te.computeBoneTexture(),Wt.setValue(X,"boneTexture",te.boneTexture,ke)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}Y.isBatchedMesh&&(Wt.setOptional(X,Y,"batchingTexture"),Wt.setValue(X,"batchingTexture",Y._matricesTexture,ke));const B=j.morphAttributes;if((B.position!==void 0||B.normal!==void 0||B.color!==void 0&&$e.isWebGL2===!0)&&N.update(Y,j,Fn),(Jt||Je.receiveShadow!==Y.receiveShadow)&&(Je.receiveShadow=Y.receiveShadow,Wt.setValue(X,"receiveShadow",Y.receiveShadow)),K.isMeshGouraudMaterial&&K.envMap!==null&&(w.envMap.value=Xe,w.flipEnvMap.value=Xe.isCubeTexture&&Xe.isRenderTargetTexture===!1?-1:1),Jt&&(Wt.setValue(X,"toneMappingExposure",v.toneMappingExposure),Je.needsLights&&Di(w,nn),Ee&&K.fog===!0&&le.refreshFogUniforms(w,Ee),le.refreshMaterialUniforms(w,K,J,Z,De),sa.upload(X,br(Je),w,ke)),K.isShaderMaterial&&K.uniformsNeedUpdate===!0&&(sa.upload(X,br(Je),w,ke),K.uniformsNeedUpdate=!1),K.isSpriteMaterial&&Wt.setValue(X,"center",Y.center),Wt.setValue(X,"modelViewMatrix",Y.modelViewMatrix),Wt.setValue(X,"normalMatrix",Y.normalMatrix),Wt.setValue(X,"modelMatrix",Y.matrixWorld),K.isShaderMaterial||K.isRawShaderMaterial){const te=K.uniformsGroups;for(let G=0,ue=te.length;G0&&ke.useMultisampledRTT(R)===!1?Y=Ke.get(R).__webglMultisampledFramebuffer:Array.isArray(je)?Y=je[j]:Y=je,A.copy(R.viewport),z.copy(R.scissor),O=R.scissorTest}else A.copy(se).multiplyScalar(J).floor(),z.copy(me).multiplyScalar(J).floor(),O=ve;if(ze.bindFramebuffer(X.FRAMEBUFFER,Y)&&$e.drawBuffers&&K&&ze.drawBuffers(R,Y),ze.viewport(A),ze.scissor(z),ze.setScissorTest(O),Ee){const Xe=Ke.get(R.texture);X.framebufferTexture2D(X.FRAMEBUFFER,X.COLOR_ATTACHMENT0,X.TEXTURE_CUBE_MAP_POSITIVE_X+H,Xe.__webglTexture,j)}else if(Ie){const Xe=Ke.get(R.texture),et=H||0;X.framebufferTextureLayer(X.FRAMEBUFFER,X.COLOR_ATTACHMENT0,Xe.__webglTexture,j||0,et)}I=-1},this.readRenderTargetPixels=function(R,H,j,K,Y,Ee,Ie){if(!(R&&R.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let He=Ke.get(R).__webglFramebuffer;if(R.isWebGLCubeRenderTarget&&Ie!==void 0&&(He=He[Ie]),He){ze.bindFramebuffer(X.FRAMEBUFFER,He);try{const Xe=R.texture,et=Xe.format,je=Xe.type;if(et!==sn&&Oe.convert(et)!==X.getParameter(X.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const Ze=je===Js&&(Ce.has("EXT_color_buffer_half_float")||$e.isWebGL2&&Ce.has("EXT_color_buffer_float"));if(je!==fi&&Oe.convert(je)!==X.getParameter(X.IMPLEMENTATION_COLOR_READ_TYPE)&&!(je===vn&&($e.isWebGL2||Ce.has("OES_texture_float")||Ce.has("WEBGL_color_buffer_float")))&&!Ze){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}H>=0&&H<=R.width-K&&j>=0&&j<=R.height-Y&&X.readPixels(H,j,K,Y,Oe.convert(et),Oe.convert(je),Ee)}finally{const Xe=T!==null?Ke.get(T).__webglFramebuffer:null;ze.bindFramebuffer(X.FRAMEBUFFER,Xe)}}},this.copyFramebufferToTexture=function(R,H,j=0){const K=Math.pow(2,-j),Y=Math.floor(H.image.width*K),Ee=Math.floor(H.image.height*K);ke.setTexture2D(H,0),X.copyTexSubImage2D(X.TEXTURE_2D,j,0,0,R.x,R.y,Y,Ee),ze.unbindTexture()},this.copyTextureToTexture=function(R,H,j,K=0){const Y=H.image.width,Ee=H.image.height,Ie=Oe.convert(j.format),He=Oe.convert(j.type);ke.setTexture2D(j,0),X.pixelStorei(X.UNPACK_FLIP_Y_WEBGL,j.flipY),X.pixelStorei(X.UNPACK_PREMULTIPLY_ALPHA_WEBGL,j.premultiplyAlpha),X.pixelStorei(X.UNPACK_ALIGNMENT,j.unpackAlignment),H.isDataTexture?X.texSubImage2D(X.TEXTURE_2D,K,R.x,R.y,Y,Ee,Ie,He,H.image.data):H.isCompressedTexture?X.compressedTexSubImage2D(X.TEXTURE_2D,K,R.x,R.y,H.mipmaps[0].width,H.mipmaps[0].height,Ie,H.mipmaps[0].data):X.texSubImage2D(X.TEXTURE_2D,K,R.x,R.y,Ie,He,H.image),K===0&&j.generateMipmaps&&X.generateMipmap(X.TEXTURE_2D),ze.unbindTexture()},this.copyTextureToTexture3D=function(R,H,j,K,Y=0){if(v.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const Ee=R.max.x-R.min.x+1,Ie=R.max.y-R.min.y+1,He=R.max.z-R.min.z+1,Xe=Oe.convert(K.format),et=Oe.convert(K.type);let je;if(K.isData3DTexture)ke.setTexture3D(K,0),je=X.TEXTURE_3D;else if(K.isDataArrayTexture)ke.setTexture2DArray(K,0),je=X.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}X.pixelStorei(X.UNPACK_FLIP_Y_WEBGL,K.flipY),X.pixelStorei(X.UNPACK_PREMULTIPLY_ALPHA_WEBGL,K.premultiplyAlpha),X.pixelStorei(X.UNPACK_ALIGNMENT,K.unpackAlignment);const Ze=X.getParameter(X.UNPACK_ROW_LENGTH),xt=X.getParameter(X.UNPACK_IMAGE_HEIGHT),Gt=X.getParameter(X.UNPACK_SKIP_PIXELS),zt=X.getParameter(X.UNPACK_SKIP_ROWS),cn=X.getParameter(X.UNPACK_SKIP_IMAGES),at=j.isCompressedTexture?j.mipmaps[0]:j.image;X.pixelStorei(X.UNPACK_ROW_LENGTH,at.width),X.pixelStorei(X.UNPACK_IMAGE_HEIGHT,at.height),X.pixelStorei(X.UNPACK_SKIP_PIXELS,R.min.x),X.pixelStorei(X.UNPACK_SKIP_ROWS,R.min.y),X.pixelStorei(X.UNPACK_SKIP_IMAGES,R.min.z),j.isDataTexture||j.isData3DTexture?X.texSubImage3D(je,Y,H.x,H.y,H.z,Ee,Ie,He,Xe,et,at.data):j.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),X.compressedTexSubImage3D(je,Y,H.x,H.y,H.z,Ee,Ie,He,Xe,at.data)):X.texSubImage3D(je,Y,H.x,H.y,H.z,Ee,Ie,He,Xe,et,at),X.pixelStorei(X.UNPACK_ROW_LENGTH,Ze),X.pixelStorei(X.UNPACK_IMAGE_HEIGHT,xt),X.pixelStorei(X.UNPACK_SKIP_PIXELS,Gt),X.pixelStorei(X.UNPACK_SKIP_ROWS,zt),X.pixelStorei(X.UNPACK_SKIP_IMAGES,cn),Y===0&&K.generateMipmaps&&X.generateMipmap(je),ze.unbindTexture()},this.initTexture=function(R){R.isCubeTexture?ke.setTextureCube(R,0):R.isData3DTexture?ke.setTexture3D(R,0):R.isDataArrayTexture||R.isCompressedArrayTexture?ke.setTexture2DArray(R,0):ke.setTexture2D(R,0),ze.unbindTexture()},this.resetState=function(){b=0,M=0,T=null,ze.reset(),Ae.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Ai}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=e===ec?"display-p3":"srgb",t.unpackColorSpace=pt.workingColorSpace===ya?"display-p3":"srgb"}get physicallyCorrectLights(){return console.warn("THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),!this.useLegacyLights}set physicallyCorrectLights(e){console.warn("THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),this.useLegacyLights=!e}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===Ht?Yi:cf}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===Yi?Ht:an}get useLegacyLights(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights}set useLegacyLights(e){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=e}}class v0 extends Pf{}v0.prototype.isWebGL1Renderer=!0;class x0 extends Bt{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t}}class y0{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Fl,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=Jn()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return console.warn('THREE.InterleavedBuffer: "updateRange" is deprecated and removed in r169. Use "addUpdateRange()" instead.'),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,s=this.stride;il)continue;h.applyMatrix4(this.matrixWorld);const I=e.ray.origin.distanceTo(h);Ie.far||t.push({distance:I,point:f.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}else{const d=Math.max(0,o.start),x=Math.min(m.count,o.start+o.count);for(let v=d,y=x-1;vl)continue;h.applyMatrix4(this.matrixWorld);const M=e.ray.origin.distanceTo(h);Me.far||t.push({distance:M,point:f.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;si.far)return;s.push({distance:c,distanceToRay:Math.sqrt(a),point:l,index:e,face:null,object:o})}}class lc extends di{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new tt(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new tt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=uf,this.normalScale=new Ue(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.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Ci extends lc{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Ue(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return tn(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new tt(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new tt(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new tt(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}function Oo(r,e,t){return!r||!t&&r.constructor===e?r:typeof e.BYTES_PER_ELEMENT=="number"?new e(r):Array.prototype.slice.call(r)}function L0(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}function C0(r){function e(i,s){return r[i]-r[s]}const t=r.length,n=new Array(t);for(let i=0;i!==t;++i)n[i]=i;return n.sort(e),n}function lh(r,e,t){const n=r.length,i=new r.constructor(n);for(let s=0,o=0;o!==n;++s){const a=t[s]*e;for(let l=0;l!==e;++l)i[o++]=r[a+l]}return i}function Ff(r,e,t,n){let i=1,s=r[0];for(;s!==void 0&&s[n]===void 0;)s=r[i++];if(s===void 0)return;let o=s[n];if(o!==void 0)if(Array.isArray(o))do o=s[n],o!==void 0&&(e.push(s.time),t.push.apply(t,o)),s=r[i++];while(s!==void 0);else if(o.toArray!==void 0)do o=s[n],o!==void 0&&(e.push(s.time),o.toArray(t,t.length)),s=r[i++];while(s!==void 0);else do o=s[n],o!==void 0&&(e.push(s.time),t.push(o)),s=r[i++];while(s!==void 0)}class ao{constructor(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let n=this._cachedIndex,i=t[n],s=t[n-1];n:{e:{let o;t:{i:if(!(e=s)){const a=t[1];e=s)break e}o=n,n=0;break t}break n}for(;n>>1;et;)--o;if(++o,s!==0||o!==i){s>=o&&(o=Math.max(o,1),s=o-1);const a=this.getValueSize();this.times=n.slice(s,o),this.values=this.values.slice(s*a,o*a)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,i=this.values,s=n.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let a=0;a!==s;a++){const l=n[a];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,l),e=!1;break}if(o!==null&&o>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,l,o),e=!1;break}o=l}if(i!==void 0&&L0(i))for(let a=0,l=i.length;a!==l;++a){const c=i[a];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,c),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===Na,s=e.length-1;let o=1;for(let a=1;a0){e[o]=e[s];for(let a=s*n,l=o*n,c=0;c!==n;++c)t[l+c]=t[a+c];++o}return o!==e.length?(this.times=e.slice(0,o),this.values=t.slice(0,o*n)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),n=this.constructor,i=new n(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}}_i.prototype.TimeBufferType=Float32Array;_i.prototype.ValueBufferType=Float32Array;_i.prototype.DefaultInterpolation=fs;class xs extends _i{}xs.prototype.ValueTypeName="bool";xs.prototype.ValueBufferType=Array;xs.prototype.DefaultInterpolation=eo;xs.prototype.InterpolantFactoryMethodLinear=void 0;xs.prototype.InterpolantFactoryMethodSmooth=void 0;class Of extends _i{}Of.prototype.ValueTypeName="color";class ms extends _i{}ms.prototype.ValueTypeName="number";class N0 extends ao{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(n-t)/(i-t);let c=e*a;for(let u=c+a;c!==u;c+=4)mi.slerpFlat(s,0,o,c-a,o,c,l);return s}}class vr extends _i{InterpolantFactoryMethodLinear(e){return new N0(this.times,this.values,this.getValueSize(),e)}}vr.prototype.ValueTypeName="quaternion";vr.prototype.DefaultInterpolation=fs;vr.prototype.InterpolantFactoryMethodSmooth=void 0;class ys extends _i{}ys.prototype.ValueTypeName="string";ys.prototype.ValueBufferType=Array;ys.prototype.DefaultInterpolation=eo;ys.prototype.InterpolantFactoryMethodLinear=void 0;ys.prototype.InterpolantFactoryMethodSmooth=void 0;class _s extends _i{}_s.prototype.ValueTypeName="vector";class F0{constructor(e,t=-1,n,i=Vd){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=Jn(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,i=1/(e.fps||1);for(let o=0,a=n.length;o!==a;++o)t.push(U0(n[o]).scale(i));const s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){const t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,o=n.length;s!==o;++s)t.push(_i.toJSON(n[s]));return i}static CreateFromMorphTargetSequence(e,t,n,i){const s=t.length,o=[];for(let a=0;a1){const f=u[1];let h=i[f];h||(i[f]=h=[]),h.push(c)}}const o=[];for(const a in i)o.push(this.CreateFromMorphTargetSequence(a,i[a],t,n));return o}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(f,h,p,_,g){if(p.length!==0){const m=[],d=[];Ff(p,m,d,_),m.length!==0&&g.push(new f(h,m,d))}},i=[],s=e.name||"default",o=e.fps||30,a=e.blendMode;let l=e.length||-1;const c=e.hierarchy||[];for(let f=0;f{t&&t(s),this.manager.itemEnd(e)},0),s;if(wi[e]!==void 0){wi[e].push({onLoad:t,onProgress:n,onError:i});return}wi[e]=[],wi[e].push({onLoad:t,onProgress:n,onError:i});const o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,l=this.responseType;fetch(o).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;const u=wi[e],f=c.body.getReader(),h=c.headers.get("Content-Length")||c.headers.get("X-File-Size"),p=h?parseInt(h):0,_=p!==0;let g=0;const m=new ReadableStream({start(d){x();function x(){f.read().then(({done:v,value:y})=>{if(v)d.close();else{g+=y.byteLength;const b=new ProgressEvent("progress",{lengthComputable:_,loaded:g,total:p});for(let M=0,T=u.length;M{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(u=>new DOMParser().parseFromString(u,a));case"json":return c.json();default:if(a===void 0)return c.text();{const f=/charset="?([^;"\s]*)"?/i.exec(a),h=f&&f[1]?f[1].toLowerCase():void 0,p=new TextDecoder(h);return c.arrayBuffer().then(_=>p.decode(_))}}}).then(c=>{gs.add(e,c);const u=wi[e];delete wi[e];for(let f=0,h=u.length;f{const u=wi[e];if(u===void 0)throw this.manager.itemError(e),c;delete wi[e];for(let f=0,h=u.length;f{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class H0 extends bs{constructor(e){super(e)}load(e,t,n,i){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,o=gs.get(e);if(o!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o;const a=to("img");function l(){u(),gs.add(e,this),t&&t(this),s.manager.itemEnd(e)}function c(f){u(),i&&i(f),s.manager.itemError(e),s.manager.itemEnd(e)}function u(){a.removeEventListener("load",l,!1),a.removeEventListener("error",c,!1)}return a.addEventListener("load",l,!1),a.addEventListener("error",c,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),s.manager.itemStart(e),a.src=e,a}}class V0 extends bs{constructor(e){super(e)}load(e,t,n,i){const s=new on,o=new H0(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(e,function(a){s.image=a,s.needsUpdate=!0,t!==void 0&&t(s)},n,i),s}}class Ea extends Bt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new tt(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),t}}const al=new Ve,ch=new C,uh=new C;class cc{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Ue(512,512),this.map=null,this.mapPass=null,this.matrix=new Ve,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new nc,this._frameExtents=new Ue(1,1),this._viewportCount=1,this._viewports=[new mt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;ch.setFromMatrixPosition(e.matrixWorld),t.position.copy(ch),uh.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(uh),t.updateMatrixWorld(),al.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(al),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(al)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class G0 extends cc{constructor(){super(new gn(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const t=this.camera,n=ds*2*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height,s=e.distance||t.far;(n!==t.fov||i!==t.aspect||s!==t.far)&&(t.fov=n,t.aspect=i,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class W0 extends Ea{constructor(e,t,n=0,i=Math.PI/3,s=0,o=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Bt.DEFAULT_UP),this.updateMatrix(),this.target=new Bt,this.distance=n,this.angle=i,this.penumbra=s,this.decay=o,this.map=null,this.shadow=new G0}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}const hh=new Ve,Ds=new C,ll=new C;class X0 extends cc{constructor(){super(new gn(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Ue(4,2),this._viewportCount=6,this._viewports=[new mt(2,1,1,1),new mt(0,1,1,1),new mt(3,1,1,1),new mt(1,1,1,1),new mt(3,0,1,1),new mt(1,0,1,1)],this._cubeDirections=[new C(1,0,0),new C(-1,0,0),new C(0,0,1),new C(0,0,-1),new C(0,1,0),new C(0,-1,0)],this._cubeUps=[new C(0,1,0),new C(0,1,0),new C(0,1,0),new C(0,1,0),new C(0,0,1),new C(0,0,-1)]}updateMatrices(e,t=0){const n=this.camera,i=this.matrix,s=e.distance||n.far;s!==n.far&&(n.far=s,n.updateProjectionMatrix()),Ds.setFromMatrixPosition(e.matrixWorld),n.position.copy(Ds),ll.copy(n.position),ll.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(ll),n.updateMatrixWorld(),i.makeTranslation(-Ds.x,-Ds.y,-Ds.z),hh.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(hh)}}class q0 extends Ea{constructor(e,t,n=0,i=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new X0}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class j0 extends cc{constructor(){super(new oo(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Bf extends Ea{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Bt.DEFAULT_UP),this.updateMatrix(),this.target=new Bt,this.shadow=new j0}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class Y0 extends Ea{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class Ys{static decodeText(e){if(typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let n=0,i=e.length;n"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,o=gs.get(e);if(o!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o;const a={};a.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",a.headers=this.requestHeader,fetch(e,a).then(function(l){return l.blob()}).then(function(l){return createImageBitmap(l,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(l){gs.add(e,l),t&&t(l),s.manager.itemEnd(e)}).catch(function(l){i&&i(l),s.manager.itemError(e),s.manager.itemEnd(e)}),s.manager.itemStart(e)}}const uc="\\[\\]\\.:\\/",K0=new RegExp("["+uc+"]","g"),hc="[^"+uc+"]",Z0="[^"+uc.replace("\\.","")+"]",J0=/((?:WC+[\/:])*)/.source.replace("WC",hc),Q0=/(WCOD+)?/.source.replace("WCOD",Z0),ex=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",hc),tx=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",hc),nx=new RegExp("^"+J0+Q0+ex+tx+"$"),ix=["material","materials","bones","map"];class rx{constructor(e,t,n){const i=n||vt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,s=n.length;i!==s;++i)n[i].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class vt{constructor(e,t,n){this.path=t,this.parsedPath=n||vt.parseTrackName(t),this.node=vt.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new vt.Composite(e,t,n):new vt(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(K0,"")}static parseTrackName(e){const t=nx.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){const s=n.nodeName.substring(i+1);ix.indexOf(s)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=s)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){const n=function(s){for(let o=0;oMath.PI&&(ge-=we),ae<-Math.PI?ae+=we:ae>Math.PI&&(ae-=we),ge<=ae?a.theta=Math.max(ge,Math.min(ae,a.theta)):a.theta=a.theta>(ge+ae)/2?Math.max(ge,a.theta):Math.min(ae,a.theta)),a.phi=Math.max(n.minPolarAngle,Math.min(n.maxPolarAngle,a.phi)),a.makeSafe(),n.enableDamping===!0?n.target.addScaledVector(u,n.dampingFactor):n.target.add(u),n.target.sub(n.cursor),n.target.clampLength(n.minTargetRadius,n.maxTargetRadius),n.target.add(n.cursor),n.zoomToCursor&&M||n.object.isOrthographicCamera?a.radius=ie(a.radius):a.radius=ie(a.radius*c),N.setFromSpherical(a),N.applyQuaternion(ne),F.copy(n.target).add(N),n.object.lookAt(n.target),n.enableDamping===!0?(l.theta*=1-n.dampingFactor,l.phi*=1-n.dampingFactor,u.multiplyScalar(1-n.dampingFactor)):(l.set(0,0,0),u.set(0,0,0));let ee=!1;if(n.zoomToCursor&&M){let he=null;if(n.object.isPerspectiveCamera){const Re=N.length();he=ie(Re*c);const nt=Re-he;n.object.position.addScaledVector(y,nt),n.object.updateMatrixWorld()}else if(n.object.isOrthographicCamera){const Re=new C(b.x,b.y,0);Re.unproject(n.object),n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/c)),n.object.updateProjectionMatrix(),ee=!0;const nt=new C(b.x,b.y,0);nt.unproject(n.object),n.object.position.sub(nt).add(Re),n.object.updateMatrixWorld(),he=N.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),n.zoomToCursor=!1;he!==null&&(this.screenSpacePanning?n.target.set(0,0,-1).transformDirection(n.object.matrix).multiplyScalar(he).add(n.object.position):(Bo.origin.copy(n.object.position),Bo.direction.set(0,0,-1).transformDirection(n.object.matrix),Math.abs(n.object.up.dot(Bo.direction))o||8*(1-Ae.dot(n.object.quaternion))>o||Pe.distanceToSquared(n.target)>0?(n.dispatchEvent(ph),Oe.copy(n.object.position),Ae.copy(n.object.quaternion),Pe.copy(n.target),!0):!1}}(),this.dispose=function(){n.domElement.removeEventListener("contextmenu",re),n.domElement.removeEventListener("pointerdown",Ke),n.domElement.removeEventListener("pointercancel",ot),n.domElement.removeEventListener("wheel",P),n.domElement.removeEventListener("pointermove",ke),n.domElement.removeEventListener("pointerup",ot),n._domElementKeyEvents!==null&&(n._domElementKeyEvents.removeEventListener("keydown",E),n._domElementKeyEvents=null)};const n=this,i={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let s=i.NONE;const o=1e-6,a=new fh,l=new fh;let c=1;const u=new C,f=new Ue,h=new Ue,p=new Ue,_=new Ue,g=new Ue,m=new Ue,d=new Ue,x=new Ue,v=new Ue,y=new C,b=new Ue;let M=!1;const T=[],I={};function S(N){return N!==null?2*Math.PI/60*n.autoRotateSpeed*N:2*Math.PI/60/60*n.autoRotateSpeed}function A(){return Math.pow(.95,n.zoomSpeed)}function z(N){l.theta-=N}function O(N){l.phi-=N}const W=function(){const N=new C;return function(ne,Oe){N.setFromMatrixColumn(Oe,0),N.multiplyScalar(-ne),u.add(N)}}(),D=function(){const N=new C;return function(ne,Oe){n.screenSpacePanning===!0?N.setFromMatrixColumn(Oe,1):(N.setFromMatrixColumn(Oe,0),N.crossVectors(n.object.up,N)),N.multiplyScalar(ne),u.add(N)}}(),V=function(){const N=new C;return function(ne,Oe){const Ae=n.domElement;if(n.object.isPerspectiveCamera){const Pe=n.object.position;N.copy(Pe).sub(n.target);let we=N.length();we*=Math.tan(n.object.fov/2*Math.PI/180),W(2*ne*we/Ae.clientHeight,n.object.matrix),D(2*Oe*we/Ae.clientHeight,n.object.matrix)}else n.object.isOrthographicCamera?(W(ne*(n.object.right-n.object.left)/n.object.zoom/Ae.clientWidth,n.object.matrix),D(Oe*(n.object.top-n.object.bottom)/n.object.zoom/Ae.clientHeight,n.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),n.enablePan=!1)}}();function Z(N){n.object.isPerspectiveCamera||n.object.isOrthographicCamera?c/=N:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function J(N){n.object.isPerspectiveCamera||n.object.isOrthographicCamera?c*=N:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function ce(N){if(!n.zoomToCursor)return;M=!0;const de=n.domElement.getBoundingClientRect(),ne=N.clientX-de.left,Oe=N.clientY-de.top,Ae=de.width,Pe=de.height;b.x=ne/Ae*2-1,b.y=-(Oe/Pe)*2+1,y.set(b.x,b.y,1).unproject(n.object).sub(n.object.position).normalize()}function ie(N){return Math.max(n.minDistance,Math.min(n.maxDistance,N))}function se(N){f.set(N.clientX,N.clientY)}function me(N){ce(N),d.set(N.clientX,N.clientY)}function ve(N){_.set(N.clientX,N.clientY)}function Q(N){h.set(N.clientX,N.clientY),p.subVectors(h,f).multiplyScalar(n.rotateSpeed);const de=n.domElement;z(2*Math.PI*p.x/de.clientHeight),O(2*Math.PI*p.y/de.clientHeight),f.copy(h),n.update()}function oe(N){x.set(N.clientX,N.clientY),v.subVectors(x,d),v.y>0?Z(A()):v.y<0&&J(A()),d.copy(x),n.update()}function Se(N){g.set(N.clientX,N.clientY),m.subVectors(g,_).multiplyScalar(n.panSpeed),V(m.x,m.y),_.copy(g),n.update()}function De(N){ce(N),N.deltaY<0?J(A()):N.deltaY>0&&Z(A()),n.update()}function _e(N){let de=!1;switch(N.code){case n.keys.UP:N.ctrlKey||N.metaKey||N.shiftKey?O(2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):V(0,n.keyPanSpeed),de=!0;break;case n.keys.BOTTOM:N.ctrlKey||N.metaKey||N.shiftKey?O(-2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):V(0,-n.keyPanSpeed),de=!0;break;case n.keys.LEFT:N.ctrlKey||N.metaKey||N.shiftKey?z(2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):V(n.keyPanSpeed,0),de=!0;break;case n.keys.RIGHT:N.ctrlKey||N.metaKey||N.shiftKey?z(-2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):V(-n.keyPanSpeed,0),de=!0;break}de&&(N.preventDefault(),n.update())}function qe(){if(T.length===1)f.set(T[0].pageX,T[0].pageY);else{const N=.5*(T[0].pageX+T[1].pageX),de=.5*(T[0].pageY+T[1].pageY);f.set(N,de)}}function We(){if(T.length===1)_.set(T[0].pageX,T[0].pageY);else{const N=.5*(T[0].pageX+T[1].pageX),de=.5*(T[0].pageY+T[1].pageY);_.set(N,de)}}function Fe(){const N=T[0].pageX-T[1].pageX,de=T[0].pageY-T[1].pageY,ne=Math.sqrt(N*N+de*de);d.set(0,ne)}function Ye(){n.enableZoom&&Fe(),n.enablePan&&We()}function X(){n.enableZoom&&Fe(),n.enableRotate&&qe()}function Lt(N){if(T.length==1)h.set(N.pageX,N.pageY);else{const ne=ye(N),Oe=.5*(N.pageX+ne.x),Ae=.5*(N.pageY+ne.y);h.set(Oe,Ae)}p.subVectors(h,f).multiplyScalar(n.rotateSpeed);const de=n.domElement;z(2*Math.PI*p.x/de.clientHeight),O(2*Math.PI*p.y/de.clientHeight),f.copy(h)}function Ce(N){if(T.length===1)g.set(N.pageX,N.pageY);else{const de=ye(N),ne=.5*(N.pageX+de.x),Oe=.5*(N.pageY+de.y);g.set(ne,Oe)}m.subVectors(g,_).multiplyScalar(n.panSpeed),V(m.x,m.y),_.copy(g)}function $e(N){const de=ye(N),ne=N.pageX-de.x,Oe=N.pageY-de.y,Ae=Math.sqrt(ne*ne+Oe*Oe);x.set(0,Ae),v.set(0,Math.pow(x.y/d.y,n.zoomSpeed)),Z(v.y),d.copy(x)}function ze(N){n.enableZoom&&$e(N),n.enablePan&&Ce(N)}function _t(N){n.enableZoom&&$e(N),n.enableRotate&&Lt(N)}function Ke(N){n.enabled!==!1&&(T.length===0&&(n.domElement.setPointerCapture(N.pointerId),n.domElement.addEventListener("pointermove",ke),n.domElement.addEventListener("pointerup",ot)),fe(N),N.pointerType==="touch"?q(N):Tt(N))}function ke(N){n.enabled!==!1&&(N.pointerType==="touch"?le(N):Ct(N))}function ot(N){Me(N),T.length===0&&(n.domElement.releasePointerCapture(N.pointerId),n.domElement.removeEventListener("pointermove",ke),n.domElement.removeEventListener("pointerup",ot)),n.dispatchEvent(mh),s=i.NONE}function Tt(N){let de;switch(N.button){case 0:de=n.mouseButtons.LEFT;break;case 1:de=n.mouseButtons.MIDDLE;break;case 2:de=n.mouseButtons.RIGHT;break;default:de=-1}switch(de){case Mr.DOLLY:if(n.enableZoom===!1)return;me(N),s=i.DOLLY;break;case Mr.ROTATE:if(N.ctrlKey||N.metaKey||N.shiftKey){if(n.enablePan===!1)return;ve(N),s=i.PAN}else{if(n.enableRotate===!1)return;se(N),s=i.ROTATE}break;case Mr.PAN:if(N.ctrlKey||N.metaKey||N.shiftKey){if(n.enableRotate===!1)return;se(N),s=i.ROTATE}else{if(n.enablePan===!1)return;ve(N),s=i.PAN}break;default:s=i.NONE}s!==i.NONE&&n.dispatchEvent(cl)}function Ct(N){switch(s){case i.ROTATE:if(n.enableRotate===!1)return;Q(N);break;case i.DOLLY:if(n.enableZoom===!1)return;oe(N);break;case i.PAN:if(n.enablePan===!1)return;Se(N);break}}function P(N){n.enabled===!1||n.enableZoom===!1||s!==i.NONE||(N.preventDefault(),n.dispatchEvent(cl),De(N),n.dispatchEvent(mh))}function E(N){n.enabled===!1||n.enablePan===!1||_e(N)}function q(N){switch(pe(N),T.length){case 1:switch(n.touches.ONE){case Tr.ROTATE:if(n.enableRotate===!1)return;qe(),s=i.TOUCH_ROTATE;break;case Tr.PAN:if(n.enablePan===!1)return;We(),s=i.TOUCH_PAN;break;default:s=i.NONE}break;case 2:switch(n.touches.TWO){case Tr.DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;Ye(),s=i.TOUCH_DOLLY_PAN;break;case Tr.DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;X(),s=i.TOUCH_DOLLY_ROTATE;break;default:s=i.NONE}break;default:s=i.NONE}s!==i.NONE&&n.dispatchEvent(cl)}function le(N){switch(pe(N),s){case i.TOUCH_ROTATE:if(n.enableRotate===!1)return;Lt(N),n.update();break;case i.TOUCH_PAN:if(n.enablePan===!1)return;Ce(N),n.update();break;case i.TOUCH_DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;ze(N),n.update();break;case i.TOUCH_DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;_t(N),n.update();break;default:s=i.NONE}}function re(N){n.enabled!==!1&&N.preventDefault()}function fe(N){T.push(N)}function Me(N){delete I[N.pointerId];for(let de=0;de=2.0 are supported."));return}const c=new Vx(s,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let u=0;u=0&&a[f]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+f+'".')}}c.setExtensions(o),c.setPlugins(a),c.parse(n,i)}parseAsync(e,t){const n=this;return new Promise(function(i,s){n.parse(e,t,i,s)})}}function hx(){let r={};return{get:function(e){return r[e]},add:function(e,t){r[e]=t},remove:function(e){delete r[e]},removeAll:function(){r={}}}}const lt={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class fx{constructor(e){this.parser=e,this.name=lt.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,s.source,o)}}class Mx{constructor(e){this.parser=e,this.name=lt.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,i=n.json,s=i.textures[e];if(!s.extensions||!s.extensions[t])return null;const o=s.extensions[t],a=i.images[o.source];let l=n.textureLoader;if(a.uri){const c=n.options.manager.getHandler(a.uri);c!==null&&(l=c)}return this.detectSupport().then(function(c){if(c)return n.loadTextureImage(e,o.source,l);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class Tx{constructor(e){this.parser=e,this.name=lt.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,i=n.json,s=i.textures[e];if(!s.extensions||!s.extensions[t])return null;const o=s.extensions[t],a=i.images[o.source];let l=n.textureLoader;if(a.uri){const c=n.options.manager.getHandler(a.uri);c!==null&&(l=c)}return this.detectSupport().then(function(c){if(c)return n.loadTextureImage(e,o.source,l);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class Ax{constructor(e){this.name=lt.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const i=n.extensions[this.name],s=this.parser.getDependency("buffer",i.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return s.then(function(a){const l=i.byteOffset||0,c=i.byteLength||0,u=i.count,f=i.byteStride,h=new Uint8Array(a,l,c);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(u,f,h,i.mode,i.filter).then(function(p){return p.buffer}):o.ready.then(function(){const p=new ArrayBuffer(u*f);return o.decodeGltfBuffer(new Uint8Array(p),u,f,h,i.mode,i.filter),p})})}else return null}}class Rx{constructor(e){this.name=lt.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;const i=t.meshes[n.mesh];for(const c of i.primitives)if(c.mode!==kn.TRIANGLES&&c.mode!==kn.TRIANGLE_STRIP&&c.mode!==kn.TRIANGLE_FAN&&c.mode!==void 0)return null;const o=n.extensions[this.name].attributes,a=[],l={};for(const c in o)a.push(this.parser.getDependency("accessor",o[c]).then(u=>(l[c]=u,l[c])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(c=>{const u=c.pop(),f=u.isGroup?u.children:[u],h=c[0].count,p=[];for(const _ of f){const g=new Ve,m=new C,d=new mi,x=new C(1,1,1),v=new M0(_.geometry,_.material,h);for(let y=0;y0||r.search(/^data\:image\/jpeg/)===0?"image/jpeg":r.search(/\.webp($|\?)/i)>0||r.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}const Hx=new Ve;class Vx{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new hx,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,i=!1,s=-1;typeof navigator<"u"&&(n=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,i=navigator.userAgent.indexOf("Firefox")>-1,s=i?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||n||i&&s<98?this.textureLoader=new V0(this.options.manager):this.textureLoader=new $0(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Uf(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,i=this.json,s=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(o){const a={scene:o[0][i.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:i.asset,parser:n,userData:{}};return rr(s,a,i),Hi(a,i),Promise.all(n._invokeAll(function(l){return l.afterRoot&&l.afterRoot(a)})).then(function(){e(a)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let i=0,s=t.length;i{const l=this.associations.get(o);l!=null&&this.associations.set(a,l);for(const[c,u]of o.children.entries())s(u,a.children[c])};return s(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n=2&&m.setY(S,M[T*l+1]),l>=3&&m.setZ(S,M[T*l+2]),l>=4&&m.setW(S,M[T*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return m})}loadTexture(e){const t=this.json,n=this.options,s=t.textures[e].source,o=t.images[s];let a=this.textureLoader;if(o.uri){const l=n.manager.getHandler(o.uri);l!==null&&(a=l)}return this.loadTextureImage(e,s,a)}loadTextureImage(e,t,n){const i=this,s=this.json,o=s.textures[e],a=s.images[t],l=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[l])return this.textureCache[l];const c=this.loadImageSource(t,n).then(function(u){u.flipY=!1,u.name=o.name||a.name||"",u.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(u.name=a.uri);const h=(s.samplers||{})[o.sampler]||{};return u.magFilter=yh[h.magFilter]||En,u.minFilter=yh[h.minFilter]||gr,u.wrapS=bh[h.wrapS]||us,u.wrapT=bh[h.wrapT]||us,i.associations.set(u,{textures:e}),u}).catch(function(){return null});return this.textureCache[l]=c,c}loadImageSource(e,t){const n=this,i=this.json,s=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(f=>f.clone());const o=i.images[e],a=self.URL||self.webkitURL;let l=o.uri||"",c=!1;if(o.bufferView!==void 0)l=n.getDependency("bufferView",o.bufferView).then(function(f){c=!0;const h=new Blob([f],{type:o.mimeType});return l=a.createObjectURL(h),l});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const u=Promise.resolve(l).then(function(f){return new Promise(function(h,p){let _=h;t.isImageBitmapLoader===!0&&(_=function(g){const m=new on(g);m.needsUpdate=!0,h(m)}),t.load(Ys.resolveURL(f,s.path),_,void 0,p)})}).then(function(f){return c===!0&&a.revokeObjectURL(l),f.userData.mimeType=o.mimeType||kx(o.uri),f}).catch(function(f){throw console.error("THREE.GLTFLoader: Couldn't load texture",l),f});return this.sourceCache[e]=u,u}assignTexture(e,t,n,i){const s=this;return this.getDependency("texture",n.index).then(function(o){if(!o)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(o=o.clone(),o.channel=n.texCoord),s.extensions[lt.KHR_TEXTURE_TRANSFORM]){const a=n.extensions!==void 0?n.extensions[lt.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const l=s.associations.get(o);o=s.extensions[lt.KHR_TEXTURE_TRANSFORM].extendTexture(o,a),s.associations.set(o,l)}}return i!==void 0&&(o.colorSpace=i),e[t]=o,o})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const i=t.attributes.tangent===void 0,s=t.attributes.color!==void 0,o=t.attributes.normal===void 0;if(e.isPoints){const a="PointsMaterial:"+n.uuid;let l=this.cache.get(a);l||(l=new Nf,di.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,l.sizeAttenuation=!1,this.cache.add(a,l)),n=l}else if(e.isLine){const a="LineBasicMaterial:"+n.uuid;let l=this.cache.get(a);l||(l=new If,di.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,this.cache.add(a,l)),n=l}if(i||s||o){let a="ClonedMaterial:"+n.uuid+":";i&&(a+="derivative-tangents:"),s&&(a+="vertex-colors:"),o&&(a+="flat-shading:");let l=this.cache.get(a);l||(l=n.clone(),s&&(l.vertexColors=!0),o&&(l.flatShading=!0),i&&(l.normalScale&&(l.normalScale.y*=-1),l.clearcoatNormalScale&&(l.clearcoatNormalScale.y*=-1)),this.cache.add(a,l),this.associations.set(l,this.associations.get(n))),n=l}e.material=n}getMaterialType(){return lc}loadMaterial(e){const t=this,n=this.json,i=this.extensions,s=n.materials[e];let o;const a={},l=s.extensions||{},c=[];if(l[lt.KHR_MATERIALS_UNLIT]){const f=i[lt.KHR_MATERIALS_UNLIT];o=f.getMaterialType(),c.push(f.extendParams(a,s,t))}else{const f=s.pbrMetallicRoughness||{};if(a.color=new tt(1,1,1),a.opacity=1,Array.isArray(f.baseColorFactor)){const h=f.baseColorFactor;a.color.setRGB(h[0],h[1],h[2],an),a.opacity=h[3]}f.baseColorTexture!==void 0&&c.push(t.assignTexture(a,"map",f.baseColorTexture,Ht)),a.metalness=f.metallicFactor!==void 0?f.metallicFactor:1,a.roughness=f.roughnessFactor!==void 0?f.roughnessFactor:1,f.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(a,"metalnessMap",f.metallicRoughnessTexture)),c.push(t.assignTexture(a,"roughnessMap",f.metallicRoughnessTexture))),o=this._invokeOne(function(h){return h.getMaterialType&&h.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(h){return h.extendMaterialParams&&h.extendMaterialParams(e,a)})))}s.doubleSided===!0&&(a.side=Zn);const u=s.alphaMode||hl.OPAQUE;if(u===hl.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,u===hl.MASK&&(a.alphaTest=s.alphaCutoff!==void 0?s.alphaCutoff:.5)),s.normalTexture!==void 0&&o!==Wi&&(c.push(t.assignTexture(a,"normalMap",s.normalTexture)),a.normalScale=new Ue(1,1),s.normalTexture.scale!==void 0)){const f=s.normalTexture.scale;a.normalScale.set(f,f)}if(s.occlusionTexture!==void 0&&o!==Wi&&(c.push(t.assignTexture(a,"aoMap",s.occlusionTexture)),s.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=s.occlusionTexture.strength)),s.emissiveFactor!==void 0&&o!==Wi){const f=s.emissiveFactor;a.emissive=new tt().setRGB(f[0],f[1],f[2],an)}return s.emissiveTexture!==void 0&&o!==Wi&&c.push(t.assignTexture(a,"emissiveMap",s.emissiveTexture,Ht)),Promise.all(c).then(function(){const f=new o(a);return s.name&&(f.name=s.name),Hi(f,s),t.associations.set(f,{materials:e}),s.extensions&&rr(i,f,s),f})}createUniqueName(e){const t=vt.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,i=this.primitiveCache;function s(a){return n[lt.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(l){return Sh(l,a,t)})}const o=[];for(let a=0,l=e.length;a0&&Bx(d,s),d.name=t.createUniqueName(s.name||"mesh_"+e),Hi(d,s),m.extensions&&rr(i,d,m),t.assignFinalMaterial(d),f.push(d)}for(let p=0,_=f.length;p<_;p++)t.associations.set(f[p],{meshes:e,primitives:p});if(f.length===1)return s.extensions&&rr(i,f[0],s),f[0];const h=new dr;s.extensions&&rr(i,h,s),t.associations.set(h,{meshes:e});for(let p=0,_=f.length;p<_;p++)h.add(f[p]);return h})}loadCamera(e){let t;const n=this.json.cameras[e],i=n[n.type];if(!i){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new gn(ff.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):n.type==="orthographic"&&(t=new oo(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),Hi(t,n),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],n=[];for(let i=0,s=t.joints.length;i1?u=new dr:c.length===1?u=c[0]:u=new Bt,u!==c[0])for(let f=0,h=c.length;f{const f=new Map;for(const[h,p]of i.associations)(h instanceof di||h instanceof on)&&f.set(h,p);return u.traverse(h=>{const p=i.associations.get(h);p!=null&&f.set(h,p)}),f};return i.associations=c(s),s})}_createAnimationTracks(e,t,n,i,s){const o=[],a=e.name?e.name:e.uuid,l=[];Bi[s.path]===Bi.weights?e.traverse(function(h){h.morphTargetInfluences&&l.push(h.name?h.name:h.uuid)}):l.push(a);let c;switch(Bi[s.path]){case Bi.weights:c=ms;break;case Bi.rotation:c=vr;break;case Bi.position:case Bi.scale:c=_s;break;default:switch(n.itemSize){case 1:c=ms;break;case 2:case 3:default:c=_s;break}break}const u=i.interpolation!==void 0?Fx[i.interpolation]:fs,f=this._getArrayFromAccessor(n);for(let h=0,p=l.length;hl+1e3&&(u.update(1e3*c/(p-l),100),l=p,c=0,h)){var _=performance.memory;h.update(_.usedJSHeapSize/1048576,_.jsHeapSizeLimit/1048576)}return p},update:function(){a=this.end()},domElement:o,setMode:i}};return t.Panel=function(n,i,s){var o=1/0,a=0,l=Math.round,c=l(window.devicePixelRatio||1),u=80*c,f=48*c,h=3*c,p=2*c,_=3*c,g=15*c,m=74*c,d=30*c,x=document.createElement("canvas");x.width=u,x.height=f,x.style.cssText="width:80px;height:48px";var v=x.getContext("2d");return v.font="bold "+9*c+"px Helvetica,Arial,sans-serif",v.textBaseline="top",v.fillStyle=s,v.fillRect(0,0,u,f),v.fillStyle=i,v.fillText(n,h,p),v.fillRect(_,g,m,d),v.fillStyle=s,v.globalAlpha=.9,v.fillRect(_,g,m,d),{dom:x,update:function(y,b){o=Math.min(o,y),a=Math.max(a,y),v.fillStyle=s,v.globalAlpha=1,v.fillRect(0,0,u,g),v.fillStyle=i,v.fillText(l(y)+" "+n+" ("+l(o)+"-"+l(a)+")",h,p),v.drawImage(x,_+c,g,m-c,d,_,g,m-c,d),v.fillRect(_+m-c,g,c,d),v.fillStyle=s,v.globalAlpha=.9,v.fillRect(_+m-c,g,c,l((1-y/b)*d))}}},t})})(Hf);var Xx=Hf.exports;const qx=Wx(Xx),Vf=0,jx=1,Gf=2,Eh=2,dl=1.25,wh=1,_r=6*4+4+4,wa=65535,Yx=Math.pow(2,-24),pl=Symbol("SKIP_GENERATION");function Wf(r){return r.index?r.index.count:r.attributes.position.count}function Ss(r){return Wf(r)/3}function Xf(r,e=ArrayBuffer){return r>65535?new Uint32Array(new e(4*r)):new Uint16Array(new e(2*r))}function $x(r,e){if(!r.index){const t=r.attributes.position.count,n=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=Xf(t,n);r.setIndex(new Yt(i,1));for(let s=0;sa-l);for(let a=0;as.offset-o.offset),n=t[t.length-1];n.count=Math.min(e-n.offset,n.count);let i=0;return t.forEach(({count:s})=>i+=s),e!==i}function Ut(r,e,t){return t.min.x=e[r],t.min.y=e[r+1],t.min.z=e[r+2],t.max.x=e[r+3],t.max.y=e[r+4],t.max.z=e[r+5],t}function Zx(r){r[0]=r[1]=r[2]=1/0,r[3]=r[4]=r[5]=-1/0}function Mh(r){let e=-1,t=-1/0;for(let n=0;n<3;n++){const i=r[n+3]-r[n];i>t&&(t=i,e=n)}return e}function Th(r,e){e.set(r)}function Ah(r,e,t){let n,i;for(let s=0;s<3;s++){const o=s+3;n=r[s],i=e[s],t[s]=ni?n:i}}function zo(r,e,t){for(let n=0;n<3;n++){const i=e[r+2*n],s=e[r+2*n+1],o=i-s,a=i+s;ot[n+3]&&(t[n+3]=a)}}function Ns(r){const e=r[3]-r[0],t=r[4]-r[1],n=r[5]-r[2];return 2*(e*t+t*n+n*e)}function ml(r,e,t,n,i=null){let s=1/0,o=1/0,a=1/0,l=-1/0,c=-1/0,u=-1/0,f=1/0,h=1/0,p=1/0,_=-1/0,g=-1/0,m=-1/0;const d=i!==null;for(let x=e*6,v=(e+t)*6;xl&&(l=T),d&&y_&&(_=y);const I=r[x+2],S=r[x+3],A=I-S,z=I+S;Ac&&(c=z),d&&Ig&&(g=I);const O=r[x+4],W=r[x+5],D=O-W,V=O+W;Du&&(u=V),d&&Om&&(m=O)}n[0]=s,n[1]=o,n[2]=a,n[3]=l,n[4]=c,n[5]=u,d&&(i[0]=f,i[1]=h,i[2]=p,i[3]=_,i[4]=g,i[5]=m)}function Jx(r,e,t,n){let i=1/0,s=1/0,o=1/0,a=-1/0,l=-1/0,c=-1/0;for(let u=e*6,f=(e+t)*6;ua&&(a=h);const p=r[u+2];pl&&(l=p);const _=r[u+4];_c&&(c=_)}n[0]=i,n[1]=s,n[2]=o,n[3]=a,n[4]=l,n[5]=c}function Qx(r,e){Zx(e);const t=r.attributes.position,n=r.index?r.index.array:null,i=Ss(r),s=new Float32Array(i*6),o=t.normalized,a=t.array,l=t.offset||0;let c=3;t.isInterleavedBufferAttribute&&(c=t.data.stride);const u=["getX","getY","getZ"];for(let f=0;fM&&(M=v),y>M&&(M=y);const T=(M-b)/2,I=d*2;s[p+I+0]=b+T,s[p+I+1]=T+(Math.abs(b)+T)*Yx,be[d+3]&&(e[d+3]=M)}}return s}const Ti=32,ey=(r,e)=>r.candidate-e.candidate,zi=new Array(Ti).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),ko=new Float32Array(6);function ty(r,e,t,n,i,s){let o=-1,a=0;if(s===Vf)o=Mh(e),o!==-1&&(a=(e[o]+e[o+3])/2);else if(s===jx)o=Mh(r),o!==-1&&(a=ny(t,n,i,o));else if(s===Gf){const l=Ns(r);let c=dl*i;const u=n*6,f=(n+i)*6;for(let h=0;h<3;h++){const p=e[h],m=(e[h+3]-p)/Ti;if(i=T.candidate?zo(y,t,T.rightCacheBounds):(zo(y,t,T.leftCacheBounds),T.count++)}}for(let y=0;y=Ti&&(M=Ti-1);const T=zi[M];T.count++,zo(v,t,T.bounds)}const d=zi[Ti-1];Th(d.bounds,d.rightCacheBounds);for(let v=Ti-2;v>=0;v--){const y=zi[v],b=zi[v+1];Ah(y.bounds,b.rightCacheBounds,y.rightCacheBounds)}let x=0;for(let v=0;v=l;)a--;if(o=l;)a--;if(o2**16,i=n?4:2,s=e?new SharedArrayBuffer(t*i):new ArrayBuffer(t*i),o=n?new Uint32Array(s):new Uint16Array(s);for(let a=0,l=o.length;a=i&&(f=!0,s&&(console.warn(`MeshBVH: Max depth of ${i} reached when generating BVH. Consider increasing maxDepth.`),console.warn(t))),M<=o||I>=i)return x(b+M),y.offset=b,y.count=M,y;const S=ty(y.boundingData,T,_,b,M,a);if(S.axis===-1)return x(b+M),y.offset=b,y.count=M,y;const A=g(u,n,_,b,M,S);if(A===b||A===b+M)x(b+M),y.offset=b,y.count=M;else{y.splitAxis=S.axis;const z=new Ho,O=b,W=A-b;y.left=z,z.boundingData=new Float32Array(6),ml(_,O,W,z.boundingData,p),v(z,O,W,p,I+1);const D=new Ho,V=A,Z=M-W;y.right=D,D.boundingData=new Float32Array(6),ml(_,V,Z,D.boundingData,p),v(D,V,Z,p,I+1)}return y}}function ay(r,e){const t=r.geometry;e.indirect&&(r._indirectBuffer=sy(t,e.useSharedArrayBuffer),Kx(t)&&!e.verbose&&console.warn('MeshBVH: Provided geometry contains groups that do not fully span the vertex contents while using the "indirect" option. BVH may incorrectly report intersections on unrendered portions of the geometry.')),r._indirectBuffer||$x(t,e);const n=oy(r,e);let i,s,o;const a=[],l=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let f=0;fMath.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return s[p+6]=y/4,y=u(y,x),s[p+7]=v,y}}}class Li{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let n=1/0,i=-1/0;for(let s=0,o=e.length;si?l:i}this.min=n,this.max=i}setFromPoints(e,t){let n=1/0,i=-1/0;for(let s=0,o=t.length;si?l:i}this.min=n,this.max=i}isSeparated(e){return this.min>e.max||e.min>this.max}}Li.prototype.setFromBox=function(){const r=new C;return function(t,n){const i=n.min,s=n.max;let o=1/0,a=-1/0;for(let l=0;l<=1;l++)for(let c=0;c<=1;c++)for(let u=0;u<=1;u++){r.x=i.x*l+s.x*(1-l),r.y=i.y*c+s.y*(1-c),r.z=i.z*u+s.z*(1-u);const f=t.dot(r);o=Math.min(f,o),a=Math.max(f,a)}this.min=o,this.max=a}}();const ly=function(){const r=new C,e=new C,t=new C;return function(i,s,o){const a=i.start,l=r,c=s.start,u=e;t.subVectors(a,c),r.subVectors(i.end,i.start),e.subVectors(s.end,s.start);const f=t.dot(u),h=u.dot(l),p=u.dot(u),_=t.dot(l),m=l.dot(l)*p-h*h;let d,x;m!==0?d=(f*h-_*p)/m:d=0,x=(f+d*h)/p,o.x=d,o.y=x}}(),fc=function(){const r=new Ue,e=new C,t=new C;return function(i,s,o,a){ly(i,s,r);let l=r.x,c=r.y;if(l>=0&&l<=1&&c>=0&&c<=1){i.at(l,o),s.at(c,a);return}else if(l>=0&&l<=1){c<0?s.at(0,a):s.at(1,a),i.closestPointToPoint(a,!0,o);return}else if(c>=0&&c<=1){l<0?i.at(0,o):i.at(1,o),s.closestPointToPoint(o,!0,a);return}else{let u;l<0?u=i.start:u=i.end;let f;c<0?f=s.start:f=s.end;const h=e,p=t;if(i.closestPointToPoint(f,!0,e),s.closestPointToPoint(u,!0,t),h.distanceToSquared(f)<=p.distanceToSquared(u)){o.copy(h),a.copy(f);return}else{o.copy(u),a.copy(p);return}}}}(),cy=function(){const r=new C,e=new C,t=new ci,n=new Ri;return function(s,o){const{radius:a,center:l}=s,{a:c,b:u,c:f}=o;if(n.start=c,n.end=u,n.closestPointToPoint(l,!0,r).distanceTo(l)<=a||(n.start=c,n.end=f,n.closestPointToPoint(l,!0,r).distanceTo(l)<=a)||(n.start=u,n.end=f,n.closestPointToPoint(l,!0,r).distanceTo(l)<=a))return!0;const g=o.getPlane(t);if(Math.abs(g.distanceToPoint(l))<=a){const d=g.projectPoint(l,e);if(o.containsPoint(d))return!0}return!1}}(),uy=1e-15;function _l(r){return Math.abs(r)new C),this.satBounds=new Array(4).fill().map(()=>new Li),this.points=[this.a,this.b,this.c],this.sphere=new ni,this.plane=new ci,this.needsUpdate=!0}intersectsSphere(e){return cy(e,this)}update(){const e=this.a,t=this.b,n=this.c,i=this.points,s=this.satAxes,o=this.satBounds,a=s[0],l=o[0];this.getNormal(a),l.setFromPoints(a,i);const c=s[1],u=o[1];c.subVectors(e,t),u.setFromPoints(c,i);const f=s[2],h=o[2];f.subVectors(t,n),h.setFromPoints(f,i);const p=s[3],_=o[3];p.subVectors(n,e),_.setFromPoints(p,i),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(a,e),this.needsUpdate=!1}}ti.prototype.closestPointToSegment=function(){const r=new C,e=new C,t=new Ri;return function(i,s=null,o=null){const{start:a,end:l}=i,c=this.points;let u,f=1/0;for(let h=0;h<3;h++){const p=(h+1)%3;t.start.copy(c[h]),t.end.copy(c[p]),fc(t,i,r,e),u=r.distanceToSquared(e),u=2){(y===1?d.start:d.end).copy(p),v=2;break}if(v++,v===2&&y===-1)break}}return v}return function(m,d=null,x=!1){this.needsUpdate&&this.update(),m.isExtendedTriangle?m.needsUpdate&&m.update():(r.copy(m),r.update(),m=r);const v=this.plane,y=m.plane;if(Math.abs(v.normal.dot(y.normal))>1-1e-10){const b=this.satBounds,M=this.satAxes;t[0]=m.a,t[1]=m.b,t[2]=m.c;for(let S=0;S<4;S++){const A=b[S],z=M[S];if(n.setFromPoints(z,t),A.isSeparated(n))return!1}const T=m.satBounds,I=m.satAxes;e[0]=this.a,e[1]=this.b,e[2]=this.c;for(let S=0;S<4;S++){const A=T[S],z=I[S];if(n.setFromPoints(z,e),A.isSeparated(n))return!1}for(let S=0;S<4;S++){const A=M[S];for(let z=0;z<4;z++){const O=I[z];if(s.crossVectors(A,O),n.setFromPoints(s,e),i.setFromPoints(s,t),n.isSeparated(i))return!1}}return d&&(x||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),d.start.set(0,0,0),d.end.set(0,0,0)),!0}else{const b=_(this,y,f);if(b===1&&m.containsPoint(f.end))return d&&(d.start.copy(f.end),d.end.copy(f.end)),!0;if(b!==2)return!1;const M=_(m,v,h);if(M===1&&this.containsPoint(h.end))return d&&(d.start.copy(h.end),d.end.copy(h.end)),!0;if(M!==2)return!1;if(f.delta(a),h.delta(l),a.dot(l)<0){let W=h.start;h.start=h.end,h.end=W}const T=f.start.dot(a),I=f.end.dot(a),S=h.start.dot(a),A=h.end.dot(a),z=I0?d.start.copy(f.start):d.start.copy(h.start),c.subVectors(f.end,h.end),c.dot(a)<0?d.end.copy(f.end):d.end.copy(h.end)),!0)}}}();ti.prototype.distanceToPoint=function(){const r=new C;return function(t){return this.closestPointToPoint(t,r),t.distanceTo(r)}}();ti.prototype.distanceToTriangle=function(){const r=new C,e=new C,t=["a","b","c"],n=new Ri,i=new Ri;return function(o,a=null,l=null){const c=a||l?n:null;if(this.intersectsTriangle(o,c))return(a||l)&&(a&&c.getCenter(a),l&&c.getCenter(l)),0;let u=1/0;for(let f=0;f<3;f++){let h;const p=t[f],_=o[p];this.closestPointToPoint(_,r),h=_.distanceToSquared(r),hnew C),this.satAxes=new Array(3).fill().map(()=>new C),this.satBounds=new Array(3).fill().map(()=>new Li),this.alignedSatBounds=new Array(3).fill().map(()=>new Li),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),n&&this.matrix.copy(n)}set(e,t,n){this.min.copy(e),this.max.copy(t),this.matrix.copy(n),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}}bn.prototype.update=function(){return function(){const e=this.matrix,t=this.min,n=this.max,i=this.points;for(let c=0;c<=1;c++)for(let u=0;u<=1;u++)for(let f=0;f<=1;f++){const h=1*c|2*u|4*f,p=i[h];p.x=c?n.x:t.x,p.y=u?n.y:t.y,p.z=f?n.z:t.z,p.applyMatrix4(e)}const s=this.satBounds,o=this.satAxes,a=i[0];for(let c=0;c<3;c++){const u=o[c],f=s[c],h=1<new Ri),t=new Array(12).fill().map(()=>new Ri),n=new C,i=new C;return function(o,a=0,l=null,c=null){if(this.needsUpdate&&this.update(),this.intersectsBox(o))return(l||c)&&(o.getCenter(i),this.closestPointToPoint(i,n),o.closestPointToPoint(n,i),l&&l.copy(n),c&&c.copy(i)),0;const u=a*a,f=o.min,h=o.max,p=this.points;let _=1/0;for(let m=0;m<8;m++){const d=p[m];i.copy(d).clamp(f,h);const x=d.distanceToSquared(i);if(x<_&&(_=x,l&&l.copy(d),c&&c.copy(i),xnew ti)}}const Gn=new hy;function wn(r,e){return e[r+15]===65535}function Tn(r,e){return e[r+6]}function In(r,e){return e[r+14]}function Wn(r){return r+8}function Nn(r,e){return e[r+6]}function pc(r,e){return e[r+7]}class fy{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const e=[];let t=null;this.setBuffer=n=>{t&&e.push(t),t=n,this.float32Array=new Float32Array(n),this.uint16Array=new Uint16Array(n),this.uint32Array=new Uint32Array(n)},this.clearBuffer=()=>{t=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,e.length!==0&&this.setBuffer(e.pop())}}}const Rt=new fy;let Xi,is;const Wr=[],Vo=new dc(()=>new $t);function dy(r,e,t,n,i,s){Xi=Vo.getPrimitive(),is=Vo.getPrimitive(),Wr.push(Xi,is),Rt.setBuffer(r._roots[e]);const o=Wl(0,r.geometry,t,n,i,s);Rt.clearBuffer(),Vo.releasePrimitive(Xi),Vo.releasePrimitive(is),Wr.pop(),Wr.pop();const a=Wr.length;return a>0&&(is=Wr[a-1],Xi=Wr[a-2]),o}function Wl(r,e,t,n,i=null,s=0,o=0){const{float32Array:a,uint16Array:l,uint32Array:c}=Rt;let u=r*2;if(wn(u,l)){const _=Tn(r,c),g=In(u,l);return Ut(r,a,Xi),n(_,g,!1,o,s+r,Xi)}else{let O=function(D){const{uint16Array:V,uint32Array:Z}=Rt;let J=D*2;for(;!wn(J,V);)D=Wn(D),J=D*2;return Tn(D,Z)},W=function(D){const{uint16Array:V,uint32Array:Z}=Rt;let J=D*2;for(;!wn(J,V);)D=Nn(D,Z),J=D*2;return Tn(D,Z)+In(J,V)};var h=O,p=W;const _=Wn(r),g=Nn(r,c);let m=_,d=g,x,v,y,b;if(i&&(y=Xi,b=is,Ut(m,a,y),Ut(d,a,b),x=i(y),v=i(b),v(Fs.copy(e).clamp(u.min,u.max),Fs.distanceToSquared(e)),intersectsBounds:(u,f,h)=>h{u.closestPointToPoint(e,Fs);const h=e.distanceToSquared(Fs);return h0&&c.normal.multiplyScalar(-1));const u={a:s,b:o,c:a,normal:new C,materialIndex:0};fn.getNormal(Xr,qr,jr,u.normal),c.face=u,c.faceIndex=s}return c}function Ma(r,e,t,n,i){const s=n*3;let o=s+0,a=s+1,l=s+2;const c=r.index;r.index&&(o=c.getX(o),a=c.getX(a),l=c.getX(l));const{position:u,normal:f,uv:h,uv1:p}=r.attributes,_=_y(t,u,f,h,p,o,a,l,e);return _?(_.faceIndex=n,i&&i.push(_),_):null}function jt(r,e,t,n){const i=r.a,s=r.b,o=r.c;let a=e,l=e+1,c=e+2;t&&(a=t.getX(a),l=t.getX(l),c=t.getX(c)),i.x=n.getX(a),i.y=n.getY(a),i.z=n.getZ(a),s.x=n.getX(l),s.y=n.getY(l),s.z=n.getZ(l),o.x=n.getX(c),o.y=n.getY(c),o.z=n.getZ(c)}function gy(r,e,t,n,i,s){const{geometry:o,_indirectBuffer:a}=r;for(let l=n,c=n+i;lM&&(M=O),WT&&(T=W),DI&&(I=D)}return l[h+0]!==v||l[h+1]!==y||l[h+2]!==b||l[h+3]!==M||l[h+4]!==T||l[h+5]!==I?(l[h+0]=v,l[h+1]=y,l[h+2]=b,l[h+3]=M,l[h+4]=T,l[h+5]=I,!0):!1}else{const d=h+8,x=o[h+6],v=d+p,y=x+p;let b=_,M=!1,T=!1;e?b||(M=e.has(v),T=e.has(y),b=!M&&!T):(M=!0,T=!0);const I=b||M,S=b||T;let A=!1;I&&(A=f(d,p,b));let z=!1;S&&(z=f(x,p,b));const O=A||z;if(O)for(let W=0;W<3;W++){const D=d+W,V=x+W,Z=l[D],J=l[D+3],ce=l[V],ie=l[V+3];l[h+W]=Zie?J:ie}return O}}}const Ph=new $t;function Zi(r,e,t,n){return Ut(r,e,Ph),t.intersectBox(Ph,n)}function by(r,e,t,n,i,s){const{geometry:o,_indirectBuffer:a}=r;for(let l=n,c=n+i;l=0;let p,_;h?(p=Wn(r),_=Nn(r,o)):(p=Nn(r,o),_=Wn(r));const m=Zi(p,i,n,Ih)?ql(p,e,t,n):null;if(m){const v=m.point[u];if(h?v<=i[_+c]:v>=i[_+c+3])return m}const x=Zi(_,i,n,Ih)?ql(_,e,t,n):null;return m&&x?m.distance<=x.distance?m:x:m||x||null}}const jo=new $t,Yr=new ti,$r=new ti,Os=new Ve,Nh=new bn,Yo=new bn;function Ay(r,e,t,n){Rt.setBuffer(r._roots[e]);const i=jl(0,r,t,n);return Rt.clearBuffer(),i}function jl(r,e,t,n,i=null){const{float32Array:s,uint16Array:o,uint32Array:a}=Rt;let l=r*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),Nh.set(t.boundingBox.min,t.boundingBox.max,n),i=Nh),wn(l,o)){const u=e.geometry,f=u.index,h=u.attributes.position,p=t.index,_=t.attributes.position,g=Tn(r,a),m=In(l,o);if(Os.copy(n).invert(),t.boundsTree)return Ut(r,s,Yo),Yo.matrix.copy(Os),Yo.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:x=>Yo.intersectsBox(x),intersectsTriangle:x=>{x.a.applyMatrix4(n),x.b.applyMatrix4(n),x.c.applyMatrix4(n),x.needsUpdate=!0;for(let v=g*3,y=(m+g)*3;vvl.distanceToBox(b),intersectsBounds:(b,M,T)=>T{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:I=>Us.distanceToBox(I),intersectsBounds:(I,S,A)=>A{for(let A=I,z=I+S;AM&&(M=D),VT&&(T=V),ZI&&(I=Z)}}return l[h+0]!==v||l[h+1]!==y||l[h+2]!==b||l[h+3]!==M||l[h+4]!==T||l[h+5]!==I?(l[h+0]=v,l[h+1]=y,l[h+2]=b,l[h+3]=M,l[h+4]=T,l[h+5]=I,!0):!1}else{const d=h+8,x=o[h+6],v=d+p,y=x+p;let b=_,M=!1,T=!1;e?b||(M=e.has(v),T=e.has(y),b=!M&&!T):(M=!0,T=!0);const I=b||M,S=b||T;let A=!1;I&&(A=f(d,p,b));let z=!1;S&&(z=f(x,p,b));const O=A||z;if(O)for(let W=0;W<3;W++){const D=d+W,V=x+W,Z=l[D],J=l[D+3],ce=l[V],ie=l[V+3];l[h+W]=Zie?J:ie}return O}}}const Fh=new C;function Ny(r,e,t,n,i){Rt.setBuffer(r._roots[e]),Yl(0,r,t,n,i),Rt.clearBuffer()}function Yl(r,e,t,n,i){const{float32Array:s,uint16Array:o,uint32Array:a}=Rt,l=r*2;if(wn(l,o)){const u=Tn(r,a),f=In(l,o);by(e,t,n,u,f,i)}else{const u=Wn(r);Zi(u,s,n,Fh)&&Yl(u,e,t,n,i);const f=Nn(r,a);Zi(f,s,n,Fh)&&Yl(f,e,t,n,i)}}const Oh=new C,Fy=["x","y","z"];function Oy(r,e,t,n){Rt.setBuffer(r._roots[e]);const i=$l(0,r,t,n);return Rt.clearBuffer(),i}function $l(r,e,t,n){const{float32Array:i,uint16Array:s,uint32Array:o}=Rt;let a=r*2;if(wn(a,s)){const c=Tn(r,o),u=In(a,s);return Sy(e,t,n,c,u)}else{const c=pc(r,o),u=Fy[c],h=n.direction[u]>=0;let p,_;h?(p=Wn(r),_=Nn(r,o)):(p=Nn(r,o),_=Wn(r));const m=Zi(p,i,n,Oh)?$l(p,e,t,n):null;if(m){const v=m.point[u];if(h?v<=i[_+c]:v>=i[_+c+3])return m}const x=Zi(_,i,n,Oh)?$l(_,e,t,n):null;return m&&x?m.distance<=x.distance?m:x:m||x||null}}const Ko=new $t,Kr=new ti,Zr=new ti,Bs=new Ve,Uh=new bn,Zo=new bn;function Uy(r,e,t,n){Rt.setBuffer(r._roots[e]);const i=Kl(0,r,t,n);return Rt.clearBuffer(),i}function Kl(r,e,t,n,i=null){const{float32Array:s,uint16Array:o,uint32Array:a}=Rt;let l=r*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),Uh.set(t.boundingBox.min,t.boundingBox.max,n),i=Uh),wn(l,o)){const u=e.geometry,f=u.index,h=u.attributes.position,p=t.index,_=t.attributes.position,g=Tn(r,a),m=In(l,o);if(Bs.copy(n).invert(),t.boundsTree)return Ut(r,s,Zo),Zo.matrix.copy(Bs),Zo.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:x=>Zo.intersectsBox(x),intersectsTriangle:x=>{x.a.applyMatrix4(n),x.b.applyMatrix4(n),x.c.applyMatrix4(n),x.needsUpdate=!0;for(let v=g,y=m+g;vxl.distanceToBox(b),intersectsBounds:(b,M,T)=>T{if(e.boundsTree){const T=e.boundsTree;return T.shapecast({boundsTraverseOrder:I=>zs.distanceToBox(I),intersectsBounds:(I,S,A)=>A{for(let A=I,z=I+S;Anew $t),Jr=new $t,Qr=new $t,yl=new $t,bl=new $t;let Sl=!1;function Wy(r,e,t,n){if(Sl)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");Sl=!0;const i=r._roots,s=e._roots;let o,a=0,l=0;const c=new Ve().copy(t).invert();for(let u=0,f=i.length;ul.slice()),index:o.array.slice(),indirectBuffer:s?s.slice():null}:a={roots:i,index:o.array,indirectBuffer:s},a}static deserialize(e,t,n={}){n={setIndex:!0,indirect:!!e.indirectBuffer,...n};const{index:i,roots:s,indirectBuffer:o}=e,a=new mc(t,{...n,[pl]:!0});if(a._roots=s,a._indirectBuffer=o||null,n.setIndex){const l=t.getIndex();if(l===null){const c=new Yt(e.index,1,!1);t.setIndex(c)}else l.array!==i&&(l.array.set(i),l.needsUpdate=!0)}return a}get indirect(){return!!this._indirectBuffer}constructor(e,t={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(t=Object.assign({strategy:Vf,maxDepth:40,maxLeafTris:10,verbose:!0,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,[pl]:!1},t),t.useSharedArrayBuffer&&!Gy())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=e,this._roots=null,this._indirectBuffer=null,t[pl]||(ay(this,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new $t)));const{_indirectBuffer:n}=this;this.resolveTriangleIndex=t.indirect?i=>n[i]:i=>i}refit(e=null){return(this.indirect?Iy:yy)(this,e)}traverse(e,t=0){const n=this._roots[t],i=new Uint32Array(n),s=new Uint16Array(n);o(0);function o(a,l=0){const c=a*2,u=s[c+15]===wa;if(u){const f=i[a+6],h=s[c+14];e(l,u,new Float32Array(n,a*4,6),f,h)}else{const f=a+_r/4,h=i[a+6],p=i[a+7];e(l,u,new Float32Array(n,a*4,6),p)||(o(f,l+1),o(h,l+1))}}}raycast(e,t=ei){const n=this._roots,i=this.geometry,s=[],o=t.isMaterial,a=Array.isArray(t),l=i.groups,c=o?t.side:t,u=this.indirect?Ny:wy;for(let f=0,h=n.length;ff(h,p,_,g,m)?!0:n(h,p,this,a,_,g,t)}else o||(a?o=(f,h,p,_)=>n(f,h,this,a,p,_,t):o=(f,h,p)=>p);let l=!1,c=0;const u=this._roots;for(let f=0,h=u.length;f{const g=this.resolveTriangleIndex(_);jt(o,g*3,a,l)}:_=>{jt(o,_*3,a,l)},u=Gn.getPrimitive(),f=e.geometry.index,h=e.geometry.attributes.position,p=e.indirect?_=>{const g=e.resolveTriangleIndex(_);jt(u,g*3,f,h)}:_=>{jt(u,_*3,f,h)};if(s){const _=(g,m,d,x,v,y,b,M)=>{for(let T=d,I=d+x;TQo.intersectsBox(n),intersectsTriangle:n=>Qo.intersectsTriangle(n)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,n={},i={},s=0,o=1/0){return(this.indirect?Vy:Dy)(this,e,t,n,i,s,o)}closestPointToPoint(e,t={},n=0,i=1/0){return py(this,e,t,n,i)}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(n=>{Ut(0,new Float32Array(n),Bh),e.union(Bh)}),e}}function Xy(r){switch(r){case 1:return"R";case 2:return"RG";case 3:return"RGBA";case 4:return"RGBA"}throw new Error}function qy(r){switch(r){case 1:return sf;case 2:return of;case 3:return sn;case 4:return sn}}function zh(r){switch(r){case 1:return Ql;case 2:return xa;case 3:return Qs;case 4:return Qs}}class Yf extends da{constructor(){super(),this.minFilter=Nt,this.magFilter=Nt,this.generateMipmaps=!1,this.overrideItemSize=null,this._forcedType=null}updateFrom(e){const t=this.overrideItemSize,n=e.itemSize,i=e.count;if(t!==null){if(n*i%t!==0)throw new Error("VertexAttributeTexture: overrideItemSize must divide evenly into buffer length.");e.itemSize=t,e.count=i*n/t}const s=e.itemSize,o=e.count,a=e.normalized,l=e.array.constructor,c=l.BYTES_PER_ELEMENT;let u=this._forcedType,f=s;if(u===null)switch(l){case Float32Array:u=vn;break;case Uint8Array:case Uint16Array:case Uint32Array:u=Dn;break;case Int8Array:case Int16Array:case Int32Array:u=Ws;break}let h,p,_,g,m=Xy(s);switch(u){case vn:_=1,p=qy(s),a&&c===1?(g=l,m+="8",l===Uint8Array?h=fi:(h=Il,m+="_SNORM")):(g=Float32Array,m+="32F",h=vn);break;case Ws:m+=c*8+"I",_=a?Math.pow(2,l.BYTES_PER_ELEMENT*8-1):1,p=zh(s),c===1?(g=Int8Array,h=Il):c===2?(g=Int16Array,h=tf):(g=Int32Array,h=Ws);break;case Dn:m+=c*8+"UI",_=a?Math.pow(2,l.BYTES_PER_ELEMENT*8-1):1,p=zh(s),c===1?(g=Uint8Array,h=fi):c===2?(g=Uint16Array,h=va):(g=Uint32Array,h=Dn);break}f===3&&(p===sn||p===Qs)&&(f=4);const d=Math.ceil(Math.sqrt(o)),x=f*d*d,v=new g(x),y=e.normalized;e.normalized=!1;for(let b=0;b=2&&(v[M+1]=e.getY(b)/_),s>=3&&(v[M+2]=e.getZ(b)/_,f===4&&(v[M+3]=1)),s>=4&&(v[M+3]=e.getW(b)/_)}e.normalized=y,this.internalFormat=m,this.format=p,this.type=h,this.image.width=d,this.image.height=d,this.image.data=v,this.needsUpdate=!0,this.dispose(),e.itemSize=n,e.count=i}}class jy extends Yf{constructor(){super(),this._forcedType=Dn}}class Vs extends Yf{constructor(){super(),this._forcedType=vn}}class kh{constructor(){this.index=new jy,this.position=new Vs,this.bvhBounds=new da,this.bvhContents=new da,this._cachedIndexAttr=null,this.index.overrideItemSize=3}updateFrom(e){const{geometry:t}=e;if($y(e,this.bvhBounds,this.bvhContents),this.position.updateFrom(t.attributes.position),e.indirect){const n=e._indirectBuffer;if(this._cachedIndexAttr===null||this._cachedIndexAttr.count!==n.length)if(t.index)this._cachedIndexAttr=t.index.clone();else{const i=Xf(Wf(t));this._cachedIndexAttr=new Yt(i,1,!1)}Yy(t,n,this._cachedIndexAttr),this.index.updateFrom(this._cachedIndexAttr)}else this.index.updateFrom(t.index)}dispose(){const{index:e,position:t,bvhBounds:n,bvhContents:i}=this;e&&e.dispose(),t&&t.dispose(),n&&n.dispose(),i&&i.dispose()}}function Yy(r,e,t){const n=t.array,i=r.index?r.index.array:null;for(let s=0,o=e.length;s 1e-4 && sinThetaO > 1e-4)\r + // Qualitative model / Fast approximation\r + float cosThetaI = V.z, sinThetaI = sqrt(1.0 - cosThetaI * cosThetaI);\r + float cosThetaO = L.z, sinThetaO = sqrt(1.0 - cosThetaO * cosThetaO);\r + float cosPhiDiff = 0.0;\r + float sinAlpha, tanBeta;\r + if (cosThetaI > cosThetaO)\r {\r - float sinPhiI = sinPhi(winputL); float cosPhiI = cosPhi(winputL);\r - float sinPhiO = sinPhi(woutputL); float cosPhiO = cosPhi(woutputL);\r - float dCos = cosPhiI * cosPhiO + sinPhiI * sinPhiO;\r - maxCos = max(0.0, dCos);\r + sinAlpha = sinThetaO;\r + tanBeta = sinThetaI / cosThetaI;\r }\r - float sinAlpha, tanBeta;\r - if (abs(cosTheta(winputL)) > abs(cosTheta(woutputL)))\r + else\r + {\r + sinAlpha = sinThetaI;\r + tanBeta = sinThetaO / cosThetaO;\r + }\r + float sigma2 = sqr(sigma);\r + float A = 1.0f - 0.5f * sigma2 / (sigma2 + 0.33f);\r + float B = 0.45f * sigma2 / (sigma2 + 0.09f);\r + return Albedo * (cosThetaO / PI) * (A + B * max(cosPhiDiff, 0.0) * sinAlpha * tanBeta);\r +}\r +\r +float safeacos(const float x)\r +{\r + return acos(clamp(x, -1.0, 1.0));\r +}\r +\r +vec3 ON_full(in vec3 Albedo, float sigma,\r + in vec3 V, in vec3 L)\r +{\r + // Full model\r + float cosThetaI = V.z, sinThetaI = sqrt(1.0 - cosThetaI * cosThetaI);\r + float cosThetaO = L.z, sinThetaO = sqrt(1.0 - cosThetaO * cosThetaO);\r + float cosPhiDiff = 0.0;\r + float thetaI = safeacos(V.z),\r + thetaO = safeacos(L.z),\r + alpha = max(thetaI, thetaO),\r + beta = min(thetaI, thetaO);\r +\r + float sinAlpha, sinBeta, tanBeta;\r + if (V.z > L.z)\r {\r sinAlpha = sinThetaO;\r - tanBeta = sinThetaI / abs(cosTheta(winputL));\r + sinBeta = sinThetaI;\r + tanBeta = sinThetaI / cosThetaI;\r }\r else\r {\r sinAlpha = sinThetaI;\r - tanBeta = sinThetaO / abs(cosTheta(woutputL));\r + sinBeta = sinThetaO;\r + tanBeta = sinThetaO / cosThetaO;\r }\r - return base_weight * base_color / PI * (A + B * maxCos * sinAlpha * tanBeta);\r +\r + float sigma2 = sqr(sigma);\r + float tmp = sigma2 / (sigma2 + 0.09f),\r + tmp2 = (4.0 / (PI * PI)) * alpha * beta,\r + tmp3 = 2.0 * beta / PI;\r +\r + float C1 = 1.0f - 0.5f * sigma2 / (sigma2 + 0.33f),\r + C2 = 0.45f * tmp,\r + C3 = 0.125f * tmp * tmp2 * tmp2,\r + C4 = 0.17f * sigma2 / (sigma2 + 0.13f);\r +\r + if (cosPhiDiff > 0.0)\r + C2 *= sinAlpha;\r + else\r + C2 *= sinAlpha - tmp3*tmp3*tmp3;\r +\r + /* Compute tan(0.5 * (alpha+beta)) using the half-angle formulae */\r + float tanHalf = (sinAlpha + sinBeta) / (sqrt(1.0f - sinAlpha * sinAlpha) + sqrt(1.0f - sinBeta * sinBeta));\r + vec3 rho = Albedo;\r + vec3 snglScat = rho * (C1 + cosPhiDiff * C2 * tanBeta + (1.0f - abs(cosPhiDiff)) * C3 * tanHalf);\r + vec3 dblScat = rho * rho * (C4 * (1.0f - cosPhiDiff*tmp3*tmp3));\r + return (snglScat + dblScat) * (cosThetaO / PI);\r }\r \r \r +////////////////////////////////////////////////////////////////////////////////////\r +// Fujii models\r +////////////////////////////////////////////////////////////////////////////////////\r +\r +vec3 fujii_brdf(in vec3 Albedo, float sigma, float stinv)\r +{\r + // Recommended A,B are different from Oren-Nayar's\r + float A = 1.0 / (PI + (PI / 2.0 - 2.0 / 3.0) * sigma);\r + float B = sigma * A;\r + return Albedo * max(A + B * stinv, 0.0);\r +}\r +\r +vec3 fujii_qualitative(in vec3 Albedo, float roughness, in vec3 V, in vec3 L)\r +{\r + // Has dark ring artifact + gains energy at grazing angles\r + float NdotV = V.z;\r + float NdotL = L.z;\r + float s = dot(L, V) - NdotV * NdotL;\r + float stinv = s > 0.0 ? s / max(NdotV, NdotL) : 0.0;\r + float sigma = roughness;\r + return NdotL * fujii_brdf(Albedo, sigma, stinv);\r +}\r +\r +vec3 fujii_improved(in vec3 Albedo, float roughness, in vec3 V, in vec3 L)\r +{\r + // No more dark ring, but loses a bit of energy as roughness->1.0\r + float NdotV = V.z;\r + float NdotL = L.z;\r + float s = dot(L, V) - NdotV * NdotL;\r + float stinv = s > 0.0 ? s / max(NdotV, NdotL) : s;\r + float sigma = roughness;\r + return NdotL * fujii_brdf(Albedo, sigma, stinv);\r +}\r +\r +vec3 fujii_materialx(in vec3 Albedo, float roughness, in vec3 V, in vec3 L)\r +{\r + // https://github.com/AcademySoftwareFoundation/MaterialX/blob/main/libraries/pbrlib/genglsl/lib/mx_microfacet_diffuse.glsl#endif\r + // similar to Fujii qualitative but using different A/B and using sigma=r*PI\r + // Has the dark ring artifact and loses energy as roughness->1.0\r + float NdotV = V.z;\r + float NdotL = L.z;\r + float s = dot(L, V) - NdotV * NdotL;\r + float stinv = (s > 0.0f) ? s / max(NdotL, NdotV) : 0.0;\r + float sigma = roughness;\r + float sigma2 = sqr(sigma);\r + float A = 1.0 - 0.5 * (sigma2 / (sigma2 + 0.33));\r + float B = 0.45 * sigma2 / (sigma2 + 0.09);\r + return Albedo * NdotL / PI * (A + B * stinv);\r +}\r +\r +\r +////////////////////////////////////////////////////////////////////////////////////\r +// d'Eon Lambertian Microsphere BRDF\r +////////////////////////////////////////////////////////////////////////////////////\r +\r +// Copied from: https://www.shadertoy.com/view/ftlXWl\r +float phase(float u) {\r + return (2.0*(sqrt(1.0 - u*u) - u*acos(u)))/(3.0*PI*PI);\r +}\r +\r +vec3 deon_lambertian_sphere(vec3 kd, vec3 wi, vec3 wo)\r +{\r + vec3 N = vec3(0.0, 0.0, 1.0);\r + float ui = dot(wi, N);\r + float uo = dot(wo, N);\r + if (ui <= 0.0 || uo <= 0.0) return vec3(0.0);\r +\r + float ui2 = ui*ui;\r + float uo2 = uo*uo;\r + float S = sqrt((1.0-ui2)*(1.0-uo2));\r + float cp = -((-dot(wi, wo) + ui*uo)/S);\r + float phi = safeacos(cp);\r + float iodot = dot(wi, wo);\r +\r + vec3 c = (1.0 - pow(1.0 - kd, vec3(2.73556))) / (1.0 - 0.184096*pow(1.0 - kd, vec3(2.48423)));\r +\r + // Single-Scattering component, corresponds to "f_1" in the paper.\r + vec3 SS = c*(phase(-iodot) / (ui + uo));\r +\r + // These next two blocks are identical. The first block is a copy of the implementation from\r + // https://github.com/eugenedeon/mitsuba/blob/master/src/bsdfs/lambert_sphere_fast.cpp\r + // The second block is a literal coding of Equation 48 from the paper.\r +#if 1\r + float p = ui * uo;\r + return uo * max(\r + vec3(0.0),\r + 0.995917*SS+(0.0684744*(((phi+sqrt(p))*(-0.249978+c)/(4.50996*((safeacos(S)/S)+0.113706)))+pow(max(1.94208*kd,0.0),vec3(1.85432))))\r + );\r +#else\r + vec3 fr = max(\r + vec3(0.0),\r + SS + 0.234459*pow(kd, vec3(1.85432)) \\\r + + (0.0151829*(c-0.24998)*(abs(phi)+sqrt(ui*uo))) / (0.113706 + (safeacos(S)/S))\r + );\r + return uo * fr;\r +#endif\r +}\r +\r +////////////////////////////////////////////////////////////////////////////////////\r +// Chan Diffuse (Unreal)\r +////////////////////////////////////////////////////////////////////////////////////\r +\r +vec3 chan_unreal_diffuse(in vec3 Albedo, float Roughness, in vec3 V, in vec3 L)\r +{\r + // https://advances.realtimerendering.com/s2018/MaterialAdvancesInWWII-course_notes.pdf\r + float NdotV = V.z;\r + float NdotL = L.z;\r + vec3 H = normalize(L + V);\r + float NoV = clamp(NdotV, 0.0, 1.0);\r + float NoL = clamp(NdotL, 0.0, 1.0);\r + float VoH = clamp(dot(V, H), 0.0, 1.0);\r + float NoH = clamp(H.z, 0.0, 1.0);\r + float a2 = pow(Roughness, 4.0);\r + float g = clamp((1.0 / 18.0) * log2( 2.0 / a2 - 1.0 ), 0.0, 1.0);\r + float F0 = VoH + pow(1.0 - VoH, 5.0);\r + float FdV = 1.0 - 0.75 * pow(1.0 - NoV, 5.0);\r + float FdL = 1.0 - 0.75 * pow(1.0 - NoL, 5.0);\r + float Fd = mix( F0, FdV * FdL, clamp(2.2 * g - 0.5, 0.0, 1.0) );\r + float Fb = ( (34.5 * g - 59.0 ) * g + 24.5 ) * VoH * exp2( -max( 73.2 * g - 21.2, 8.9 ) * sqrt(NoH));\r + return Albedo * ((NdotL / PI) * ( Fd + Fb ));\r +\r +}\r +\r +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////\r +// diffuse BRDF\r +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////\r +\r +/* A selection of possible diffuse models,\r + copied from https://www.shadertoy.com/view/X3BSDD\r + by Chris Kulla\r +*/\r +\r +vec3 diffuse_brdf_eval_implementations(in vec3 woutputL, in vec3 winputL)\r +{\r + vec3 Albedo = base_weight * base_color;\r + vec3 V = winputL;\r + vec3 L = woutputL;\r + float NdotL = max(FLT_EPSILON, abs(L.z));\r +\r + switch (diffuse_mode)\r + {\r + case 0: return Albedo / PI; // Lambert\r + case 1: // ON Qualitative (Mitsuba)\r + case 2: // ON Full (Mitsuba)\r + {\r + float sigma = base_roughness / sqrt(2.0);\r + if (diffuse_mode == 1) return ON_qualitative(Albedo, sigma, V, L) / NdotL;\r + else return ON_full( Albedo, sigma, V, L) / NdotL;\r + }\r + case 3: return deon_lambertian_sphere(Albedo, V, L) / NdotL;\r + case 4: return fujii_qualitative (Albedo, base_roughness, V, L) / NdotL;\r + case 5: return fujii_improved (Albedo, base_roughness, V, L) / NdotL;\r + case 6: return fujii_materialx (Albedo, base_roughness, V, L) / NdotL;\r + case 7: return chan_unreal_diffuse (Albedo, base_roughness, V, L) / NdotL;\r + }\r +}\r +\r vec3 diffuse_brdf_evaluate(in vec3 pW, in Basis basis, in vec3 winputL, in vec3 woutputL,\r inout float pdf_woutputL)\r {\r if (winputL.z < DENOM_TOLERANCE || woutputL.z < DENOM_TOLERANCE) return vec3(0.0);\r pdf_woutputL = pdfHemisphereCosineWeighted(woutputL);\r - return oren_nayar_eval(winputL, woutputL);\r + return diffuse_brdf_eval_implementations(winputL, woutputL);\r }\r \r \r @@ -5774,7 +5976,7 @@ vec3 diffuse_brdf_sample(in vec3 pW, in Basis basis, in vec3 winputL, inout uint {\r if (winputL.z < DENOM_TOLERANCE) return vec3(0.0);\r woutputL = sampleHemisphereCosineWeighted(rndSeed, pdf_woutputL);\r - return oren_nayar_eval(winputL, woutputL);\r + return diffuse_brdf_eval_implementations(winputL, woutputL);\r }\r \r \r @@ -6094,6 +6296,16 @@ void fill_subsurface_medium(inout Volume internal_medium)\r internal_medium.extinction = mu_t;\r break;\r }\r + case 8: // "interfaced van de Hulst"\r + {\r + float K = 1.0 - (1.0 - average_dielectric_fresnel(specular_ior))/sqr(specular_ior);\r + vec3 Ap = A * (1.0 - K) / (1.0 - A*K);\r + s2 = sqr(4.09712 + Ap*4.20863 - sqrt(max(vec3(0.0), 9.59217 + Ap*41.6808 + sqr(Ap)*17.7126)));\r + vec3 mu_t = 1.0 / max(mfp_epsilon, r);\r + internal_medium.extinction = mu_t;\r + break;\r + }\r +\r }\r internal_medium.albedo = (1.0 - s2) / (1.0 - g*s2); // single-scattering albedo accounting for anisotropy\r internal_medium.anisotropy = g;\r @@ -6307,19 +6519,19 @@ float TraceShadow(in vec3 rayOrigin, in vec3 rayDir, in float maxDistance)\r vec3 neutral_brdf_evaluate(in vec3 pW, in Basis basis, in vec3 winputL, in vec3 woutputL,\r inout float pdf_woutputL)\r {\r - pdf_woutputL = pdfHemisphereCosineWeighted(winputL);\r - if (winputL.z < 0.0 || woutputL.z < 0.0) return vec3(0.0);\r + if (winputL.z < DENOM_TOLERANCE || woutputL.z < DENOM_TOLERANCE) return vec3(0.0);\r + pdf_woutputL = pdfHemisphereCosineWeighted(woutputL);\r if (wireframe && minComponent(basis.baryCoord) < 0.003) return vec3(0.0);\r - return neutral_color/PI;\r + return neutral_color / PI;\r }\r \r vec3 neutral_brdf_sample(in vec3 pW, in Basis basis, in vec3 winputL, inout uint rndSeed,\r out vec3 woutputL, out float pdf_woutputL)\r {\r + if (winputL.z < DENOM_TOLERANCE) return vec3(0.0);\r woutputL = sampleHemisphereCosineWeighted(rndSeed, pdf_woutputL);\r - if (winputL.z < 0.0) return vec3(0.0);\r if (wireframe && minComponent(basis.baryCoord) < 0.003) return vec3(0.0);\r - return neutral_color/PI;\r + return neutral_color / PI;\r }\r \r //////////////////////////////////////\r @@ -6415,7 +6627,7 @@ float skyPdf(in vec3 woutputL, in vec3 woutputWs)\r return pdfHemisphereCosineWeighted(woutputL);\r }\r \r -// Estimate direct radiance at the given surface vertex\r +// Sample direct radiance at the given surface vertex\r vec3 LiDirect(in vec3 pW, in Basis basis,\r out vec3 shadowL, out vec3 shadowW,\r out float lightPdf,\r @@ -6450,6 +6662,20 @@ vec3 LiDirect(in vec3 pW, in Basis basis,\r return visibility * Li;\r }\r \r +// Corresponding PDF of direct radiance in the given shadow ray direction (for MIS)\r +float LiPDF(in vec3 shadowW, in Basis basis)\r +{\r + vec3 shadowL = worldToLocal(shadowW, basis);\r + float pdf_sky = skyPdf(shadowL, shadowW);\r + float pdf_sun = sunPdf(shadowL, shadowW);\r + float w_sun = sunTotalPower();\r + float w_sky = skyTotalPower();\r + float P_sun = w_sun / (w_sun + w_sky);\r + float P_sky = max(0.0, 1.0 - P_sun);\r + float lightPdf = P_sun*pdf_sun + P_sky*pdf_sky; // Light PDF according to 1-sample MIS\r + return lightPdf;\r +}\r +\r vec3 evaluateEdf(in vec3 pW, in Basis basis, in vec3 winputL)\r {\r return emission_color * emission_luminance;\r @@ -6573,7 +6799,8 @@ void main()\r // Perform uni-directional pathtrace starting from the (pinhole) camera lens to estimate the primary ray radiance, L\r vec3 L = vec3(0.0);\r vec3 throughput = vec3(1.0);\r - float misWeightBSDF = 1.0; // For MIS book-keeping\r + Basis basis; // kept for MIS book-keeping\r + float bsdfPdf_continuation = 1.0; // ditto\r \r #ifdef VOLUME_ENABLED\r // Initialize volumetric medium of camera ray\r @@ -6594,10 +6821,8 @@ void main()\r \r for (int vertex=0; vertex <= BOUNCES; vertex++)\r {\r - if (maxComponent(throughput) < THROUGHPUT_EPSILON)\r - break;\r -\r // Generate next surface hit, given current vertex pW and current propagation direction dW\r + // (where vertex 0 corresponds to the camera position)\r bool surface_hit;\r vec3 pW_next;\r vec3 NsW_next;\r @@ -6644,26 +6869,18 @@ void main()\r throughput *= volume_throughput;\r }\r #endif // VOLUME_ENABLED\r -\r - if (maxComponent(throughput) < THROUGHPUT_EPSILON)\r - break;\r \r if (!surface_hit)\r {\r - // Camera ray missed all geometry; add contribution from distant lights\r - L += throughput * misWeightBSDF * (sunRadiance(dW) + skyRadiance(dW));\r -\r - // Ray escapes to infinity, terminate path\r - break;\r - }\r -\r - // Russian roulette termination (unbiased)\r - if (maxComponent(throughput) < 1.0 && vertex > 1)\r - {\r - float q = max(0.0, 1.0 - maxComponent(throughput));\r - if (rand(rndSeed) < q)\r - break;\r - throughput /= 1.0 - q;\r + // Ray missed all geometry; add contribution from distant lights\r + float misWeightLight = 1.0;\r + if (vertex > 0)\r + {\r + float lightPdf = LiPDF(dW, basis); // surface basis of previous hit\r + misWeightLight = powerHeuristic(bsdfPdf_continuation, lightPdf);\r + }\r + L += throughput * misWeightLight * (sunRadiance(dW) + skyRadiance(dW));\r + break; // Ray escapes to infinity, terminate path\r }\r \r // Terminate at max bounce count (biased)\r @@ -6697,7 +6914,6 @@ void main()\r if (dot(NgW, NsW) < 0.0) NgW *= -1.0;\r \r // Construct local shading frame\r - Basis basis;\r if (smooth_normals)\r {\r // If the surface is opaque, but the incident ray lies below the hemisphere of the normal,\r @@ -6718,7 +6934,6 @@ void main()\r openpbr_prepare(pW, basis, winputL, rndSeed);\r \r // Sample BSDF for the continuation ray direction\r - float bsdfPdf_continuation;\r Volume internal_medium;\r vec3 surface_throughput;\r {\r @@ -6764,7 +6979,6 @@ void main()\r } // transmitted\r \r // Add direct lighting term at the current surface vertex\r - misWeightBSDF = 1.0;\r if (!in_dielectric && !transmitted)\r {\r vec3 shadowL, shadowW; // sampled shadow ray direction\r @@ -6776,21 +6990,30 @@ void main()\r vec3 fshadow = evaluateBsdf(pW, basis, winputL, shadowL, material, bsdfPdf_shadow);\r float misWeightLight = powerHeuristic(lightPdf, bsdfPdf_shadow);\r L += throughput * misWeightLight * fshadow * abs(dot(shadowW, basis.nW)) * Li / max(PDF_EPSILON, lightPdf);\r - misWeightBSDF = powerHeuristic(bsdfPdf_continuation, lightPdf);\r +\r }\r } // direct lighting\r \r // Update path continuation throughput\r throughput *= surface_throughput;\r +\r + // Russian roulette termination (unbiased)\r + if (maxComponent(throughput) < 1.0 && vertex > 1)\r + {\r + float q = max(0.0, 1.0 - maxComponent(throughput));\r + if (rand(rndSeed) < q)\r + break;\r + throughput /= 1.0 - q;\r + }\r \r } // bounce loop\r \r gl_FragColor.rgb = L;\r gl_FragColor.a = accumulation_weight; // Implements Monte-Carlo accumulation via alpha blending\r }\r -`;function na(r){throw new Error('Could not dynamically require "'+r+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Kf={exports:{}};(function(r,e){(function(t){r.exports=t()})(function(){return function(){function t(n,i,s){function o(c,u){if(!i[c]){if(!n[c]){var f=typeof na=="function"&&na;if(!u&&f)return f(c,!0);if(a)return a(c,!0);var h=new Error("Cannot find module '"+c+"'");throw h.code="MODULE_NOT_FOUND",h}var p=i[c]={exports:{}};n[c][0].call(p.exports,function(_){var g=n[c][1][_];return o(g||_)},p,p.exports,t,n,i,s)}return i[c].exports}for(var a=typeof na=="function"&&na,l=0;l-1}function Sr(L,U){var $=this.__data__,Te=xt($,L);return Te<0?(++this.size,$.push([L,U])):$[Te][1]=U,this}ln.prototype.clear=Pi,ln.prototype.delete=yr,ln.prototype.get=ri,ln.prototype.has=br,ln.prototype.set=Sr;function Xn(L){var U=-1,$=L==null?0:L.length;for(this.clear();++U<$;){var Te=L[U];this.set(Te[0],Te[1])}}function Di(){this.size=0,this.__data__={hash:new gt,map:new(he||ln),string:new gt}}function Es(L){var U=Be(this,L).delete(L);return this.size-=U?1:0,U}function R(L){return Be(this,L).get(L)}function H(L){return Be(this,L).has(L)}function j(L,U){var $=Be(this,L),Te=$.size;return $.set(L,U),this.size+=$.size==Te?0:1,this}Xn.prototype.clear=Di,Xn.prototype.delete=Es,Xn.prototype.get=R,Xn.prototype.has=H,Xn.prototype.set=j;function K(L){var U=this.__data__=new ln(L);this.size=U.size}function Y(){this.__data__=new ln,this.size=0}function Ee(L){var U=this.__data__,$=U.delete(L);return this.size=U.size,$}function Ie(L){return this.__data__.get(L)}function He(L){return this.__data__.has(L)}function Xe(L,U){var $=this.__data__;if($ instanceof ln){var Te=$.__data__;if(!he||Te.length1?$[ut-1]:void 0,Dt=ut>2?$[2]:void 0;for(wt=L.length>3&&typeof wt=="function"?(ut--,wt):void 0,Dt&&Pt($[0],$[1],Dt)&&(wt=ut<3?void 0:wt,ut=1),U=Object(U);++Te-1&&L%1==0&&L0){if(++U>=l)return arguments[0]}else U=0;return L.apply(void 0,arguments)}}function Qt(L){if(L!=null){try{return le.call(L)}catch{}try{return L+""}catch{}}return""}function dn(L,U){return L===U||L!==L&&U!==U}var An=at(function(){return arguments}())?at:function(L){return ws(L)&&re.call(L,"callee")&&!we.call(L,"callee")},qn=Array.isArray;function wr(L){return L!=null&&yc(L.length)&&!Ta(L)}function Jf(L){return ws(L)&&wr(L)}var xc=ge||id;function Ta(L){if(!Qi(L))return!1;var U=cn(L);return U==d||U==x||U==p||U==T}function yc(L){return typeof L=="number"&&L>-1&&L%1==0&&L<=u}function Qi(L){var U=typeof L;return L!=null&&(U=="object"||U=="function")}function ws(L){return L!=null&&typeof L=="object"}function Qf(L){if(!ws(L)||cn(L)!=M)return!1;var U=Ae(L);if(U===null)return!0;var $=re.call(U,"constructor")&&U.constructor;return typeof $=="function"&&$ instanceof $&&le.call($)==pe}var bc=ze?ke(ze):Ji;function ed(L){return G(L,Sc(L))}function Sc(L){return wr(L)?et(L,!0):yt(L)}var td=ue(function(L,U,$){Fn(L,U,$)});function nd(L){return function(){return L}}function Ec(L){return L}function id(){return!1}n.exports=td}).call(this)}).call(this,typeof Gl<"u"?Gl:typeof self<"u"?self:typeof window<"u"?window:{})},{}],2:[function(t,n,i){/*! For license information please see shifty.js.LICENSE.txt */(function(s,o){typeof i=="object"&&typeof n=="object"?n.exports=o():typeof i=="object"?i.shifty=o():s.shifty=o()})(self,function(){return function(){var s={720:function(l,c,u){u.r(c),u.d(c,{Scene:function(){return Wt},Tweenable:function(){return ft},interpolate:function(){return Ji},processTweens:function(){return ae},setBezierFunction:function(){return $e},shouldScheduleUpdate:function(){return Re},tween:function(){return Sn},unsetBezierFunction:function(){return ze}});var f={};u.r(f),u.d(f,{bounce:function(){return _e},bouncePast:function(){return qe},easeFrom:function(){return Fe},easeFromTo:function(){return We},easeInBack:function(){return se},easeInCirc:function(){return Z},easeInCubic:function(){return d},easeInExpo:function(){return W},easeInOutBack:function(){return ve},easeInOutCirc:function(){return ce},easeInOutCubic:function(){return v},easeInOutExpo:function(){return V},easeInOutQuad:function(){return m},easeInOutQuart:function(){return M},easeInOutQuint:function(){return S},easeInOutSine:function(){return O},easeInQuad:function(){return _},easeInQuart:function(){return y},easeInQuint:function(){return T},easeInSine:function(){return A},easeOutBack:function(){return me},easeOutBounce:function(){return ie},easeOutCirc:function(){return J},easeOutCubic:function(){return x},easeOutExpo:function(){return D},easeOutQuad:function(){return g},easeOutQuart:function(){return b},easeOutQuint:function(){return I},easeOutSine:function(){return z},easeTo:function(){return Ye},elastic:function(){return Q},linear:function(){return p},swingFrom:function(){return Se},swingFromTo:function(){return oe},swingTo:function(){return De}});var h={};u.r(h),u.d(h,{afterTween:function(){return xt},beforeTween:function(){return Ze},doesApply:function(){return et},tweenCreated:function(){return je}});var p=function(w){return w},_=function(w){return Math.pow(w,2)},g=function(w){return-(Math.pow(w-1,2)-1)},m=function(w){return(w/=.5)<1?.5*Math.pow(w,2):-.5*((w-=2)*w-2)},d=function(w){return Math.pow(w,3)},x=function(w){return Math.pow(w-1,3)+1},v=function(w){return(w/=.5)<1?.5*Math.pow(w,3):.5*(Math.pow(w-2,3)+2)},y=function(w){return Math.pow(w,4)},b=function(w){return-(Math.pow(w-1,4)-1)},M=function(w){return(w/=.5)<1?.5*Math.pow(w,4):-.5*((w-=2)*Math.pow(w,3)-2)},T=function(w){return Math.pow(w,5)},I=function(w){return Math.pow(w-1,5)+1},S=function(w){return(w/=.5)<1?.5*Math.pow(w,5):.5*(Math.pow(w-2,5)+2)},A=function(w){return 1-Math.cos(w*(Math.PI/2))},z=function(w){return Math.sin(w*(Math.PI/2))},O=function(w){return-.5*(Math.cos(Math.PI*w)-1)},W=function(w){return w===0?0:Math.pow(2,10*(w-1))},D=function(w){return w===1?1:1-Math.pow(2,-10*w)},V=function(w){return w===0?0:w===1?1:(w/=.5)<1?.5*Math.pow(2,10*(w-1)):.5*(2-Math.pow(2,-10*--w))},Z=function(w){return-(Math.sqrt(1-w*w)-1)},J=function(w){return Math.sqrt(1-Math.pow(w-1,2))},ce=function(w){return(w/=.5)<1?-.5*(Math.sqrt(1-w*w)-1):.5*(Math.sqrt(1-(w-=2)*w)+1)},ie=function(w){return w<1/2.75?7.5625*w*w:w<2/2.75?7.5625*(w-=1.5/2.75)*w+.75:w<2.5/2.75?7.5625*(w-=2.25/2.75)*w+.9375:7.5625*(w-=2.625/2.75)*w+.984375},se=function(w){var B=1.70158;return w*w*((B+1)*w-B)},me=function(w){var B=1.70158;return(w-=1)*w*((B+1)*w+B)+1},ve=function(w){var B=1.70158;return(w/=.5)<1?w*w*((1+(B*=1.525))*w-B)*.5:.5*((w-=2)*w*((1+(B*=1.525))*w+B)+2)},Q=function(w){return-1*Math.pow(4,-8*w)*Math.sin((6*w-1)*(2*Math.PI)/2)+1},oe=function(w){var B=1.70158;return(w/=.5)<1?w*w*((1+(B*=1.525))*w-B)*.5:.5*((w-=2)*w*((1+(B*=1.525))*w+B)+2)},Se=function(w){var B=1.70158;return w*w*((B+1)*w-B)},De=function(w){var B=1.70158;return(w-=1)*w*((B+1)*w+B)+1},_e=function(w){return w<1/2.75?7.5625*w*w:w<2/2.75?7.5625*(w-=1.5/2.75)*w+.75:w<2.5/2.75?7.5625*(w-=2.25/2.75)*w+.9375:7.5625*(w-=2.625/2.75)*w+.984375},qe=function(w){return w<1/2.75?7.5625*w*w:w<2/2.75?2-(7.5625*(w-=1.5/2.75)*w+.75):w<2.5/2.75?2-(7.5625*(w-=2.25/2.75)*w+.9375):2-(7.5625*(w-=2.625/2.75)*w+.984375)},We=function(w){return(w/=.5)<1?.5*Math.pow(w,4):-.5*((w-=2)*Math.pow(w,3)-2)},Fe=function(w){return Math.pow(w,4)},Ye=function(w){return Math.pow(w,.25)};function X(w,B,te,G,ue,Ne){var Be,rt,dt,Ft,St,Pt=0,kt=0,rn=0,gi=function(Et){return((Pt*Et+kt)*Et+rn)*Et},si=function(Et){return(3*Pt*Et+2*kt)*Et+rn},oi=function(Et){return Et>=0?Et:0-Et};return Pt=1-(rn=3*B)-(kt=3*(G-B)-rn),dt=1-(St=3*te)-(Ft=3*(ue-te)-St),Be=w,rt=function(Et){return 1/(200*Et)}(Ne),function(Et){return((dt*Et+Ft)*Et+St)*Et}(function(Et,ai){var li,vi,Qt,dn,An,qn;for(Qt=Et,qn=0;qn<8;qn++){if(dn=gi(Qt)-Et,oi(dn)(vi=1))return vi;for(;lidn?li=Qt:vi=Qt,Qt=.5*(vi-li)+li}return Qt}(Be,rt))}var Lt,Le=function(){var w=arguments.length>0&&arguments[0]!==void 0?arguments[0]:.25,B=arguments.length>1&&arguments[1]!==void 0?arguments[1]:.25,te=arguments.length>2&&arguments[2]!==void 0?arguments[2]:.75,G=arguments.length>3&&arguments[3]!==void 0?arguments[3]:.75;return function(ue){return X(ue,w,B,te,G,1)}},$e=function(w,B,te,G,ue){var Ne=Le(B,te,G,ue);return Ne.displayName=w,Ne.x1=B,Ne.y1=te,Ne.x2=G,Ne.y2=ue,ft.formulas[w]=Ne},ze=function(w){return delete ft.formulas[w]};function _t(w,B){if(!(w instanceof B))throw new TypeError("Cannot call a class as a function")}function Ke(w,B){for(var te=0;tew.length)&&(B=w.length);for(var te=0,G=new Array(B);tert?rt:B;w._hasEnded=dt>=rt;var Ft=Ne-(rt-dt),St=w._filters.length>0;if(w._hasEnded)return w._render(Be,w._data,Ft),w.stop(!0);St&&w._applyFilter(N),dt1&&arguments[1]!==void 0?arguments[1]:fe,te=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(Array.isArray(B)){var G=Le.apply(void 0,ot(B));return G}var ue=ke(B);if(Ge[B])return Ge[B];if(ue===Oe||ue===ne)for(var Ne in w)te[Ne]=B;else for(var Be in w)te[Be]=B[Be]||fe;return te},Vt=function(w){w===we?(we=w._next)?we._previous=null:be=null:w===be?(be=w._previous)?be._next=null:we=null:(le=w._previous,re=w._next,le._next=re,re._previous=le),w._previous=w._next=null},ht=typeof Promise=="function"?Promise:null;Lt=Symbol.toStringTag;var ft=function(){function w(){var G=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},ue=arguments.length>1&&arguments[1]!==void 0?arguments[1]:void 0;_t(this,w),E(this,Lt,"Promise"),this._config={},this._data={},this._delay=0,this._filters=[],this._next=null,this._previous=null,this._timestamp=null,this._hasEnded=!1,this._resolve=null,this._reject=null,this._currentState=G||{},this._originalState={},this._targetState={},this._start=Ce,this._render=Ce,this._promiseCtor=ht,ue&&this.setConfig(ue)}var B,te;return B=w,te=[{key:"_applyFilter",value:function(G){for(var ue=this._filters.length;ue>0;ue--){var Ne=this._filters[ue-ue][G];Ne&&Ne(this)}}},{key:"tween",value:function(){var G=arguments.length>0&&arguments[0]!==void 0?arguments[0]:void 0;return this._isPlaying&&this.stop(),!G&&this._config||this.setConfig(G),this._pausedAtTime=null,this._timestamp=w.now(),this._start(this.get(),this._data),this._delay&&this._render(this._currentState,this._data,0),this._resume(this._timestamp)}},{key:"setConfig",value:function(){var G=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},ue=this._config;for(var Ne in G)ue[Ne]=G[Ne];var Be=ue.promise,rt=Be===void 0?this._promiseCtor:Be,dt=ue.start,Ft=dt===void 0?Ce:dt,St=ue.finish,Pt=ue.render,kt=Pt===void 0?this._config.step||Ce:Pt,rn=ue.step,gi=rn===void 0?Ce:rn;this._data=ue.data||ue.attachment||this._data,this._isPlaying=!1,this._pausedAtTime=null,this._scheduleId=null,this._delay=G.delay||0,this._start=Ft,this._render=kt||gi,this._duration=ue.duration||500,this._promiseCtor=rt,St&&(this._resolve=St);var si=G.from,oi=G.to,Et=oi===void 0?{}:oi,ai=this._currentState,li=this._originalState,vi=this._targetState;for(var Qt in si)ai[Qt]=si[Qt];var dn=!1;for(var An in ai){var qn=ai[An];dn||ke(qn)!==Oe||(dn=!0),li[An]=qn,vi[An]=Et.hasOwnProperty(An)?Et[An]:qn}if(this._easing=gt(this._currentState,ue.easing,this._easing),this._filters.length=0,dn){for(var wr in w.filters)w.filters[wr].doesApply(this)&&this._filters.push(w.filters[wr]);this._applyFilter(de)}return this}},{key:"then",value:function(G,ue){var Ne=this;return this._promise=new this._promiseCtor(function(Be,rt){Ne._resolve=Be,Ne._reject=rt}),this._promise.then(G,ue)}},{key:"catch",value:function(G){return this.then().catch(G)}},{key:"finally",value:function(G){return this.then().finally(G)}},{key:"get",value:function(){return P({},this._currentState)}},{key:"set",value:function(G){this._currentState=G}},{key:"pause",value:function(){if(this._isPlaying)return this._pausedAtTime=w.now(),this._isPlaying=!1,Vt(this),this}},{key:"resume",value:function(){return this._resume()}},{key:"_resume",value:function(){var G=arguments.length>0&&arguments[0]!==void 0?arguments[0]:w.now();return this._timestamp===null?this.tween():this._isPlaying?this._promise:(this._pausedAtTime&&(this._timestamp+=G-this._pausedAtTime,this._pausedAtTime=null),this._isPlaying=!0,we===null?(we=this,be=this):(this._previous=be,be._next=this,be=this),this)}},{key:"seek",value:function(G){G=Math.max(G,0);var ue=w.now();return this._timestamp+G===0||(this._timestamp=ue-G,ge(this,ue)),this}},{key:"stop",value:function(){var G=arguments.length>0&&arguments[0]!==void 0&&arguments[0];if(!this._isPlaying)return this;this._isPlaying=!1,Vt(this);var ue=this._filters.length>0;return G&&(ue&&this._applyFilter(N),F(1,this._currentState,this._originalState,this._targetState,1,0,this._easing),ue&&(this._applyFilter(pe),this._applyFilter(ye))),this._resolve&&this._resolve({data:this._data,state:this._currentState,tweenable:this}),this._resolve=null,this._reject=null,this}},{key:"cancel",value:function(){var G=arguments.length>0&&arguments[0]!==void 0&&arguments[0],ue=this._currentState,Ne=this._data,Be=this._isPlaying;return Be?(this._reject&&this._reject({data:Ne,state:ue,tweenable:this}),this._resolve=null,this._reject=null,this.stop(G)):this}},{key:"isPlaying",value:function(){return this._isPlaying}},{key:"hasEnded",value:function(){return this._hasEnded}},{key:"setScheduleFunction",value:function(G){w.setScheduleFunction(G)}},{key:"data",value:function(){var G=arguments.length>0&&arguments[0]!==void 0?arguments[0]:null;return G&&(this._data=P({},G)),this._data}},{key:"dispose",value:function(){for(var G in this)delete this[G]}}],te&&Ke(B.prototype,te),w}();function Sn(){var w=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},B=new ft;return B.tween(w),B.tweenable=B,B}E(ft,"now",function(){return q}),E(ft,"setScheduleFunction",function(w){return Ae=w}),E(ft,"filters",{}),E(ft,"formulas",Ge),Re(!0);var ii,ln,Pi=/(\d|-|\.)/,yr=/([^\-0-9.]+)/g,ri=/[0-9.-]+/g,br=(ii=ri.source,ln=/,\s*/.source,new RegExp("rgba?\\(".concat(ii).concat(ln).concat(ii).concat(ln).concat(ii,"(").concat(ln).concat(ii,")?\\)"),"g")),Sr=/^.*\(/,Xn=/#([0-9]|[a-f]){3,6}/gi,Di="VAL",Es=function(w,B){return w.map(function(te,G){return"_".concat(B,"_").concat(G)})};function R(w){return parseInt(w,16)}var H=function(w){return"rgb(".concat((B=w,(B=B.replace(/#/,"")).length===3&&(B=(B=B.split(""))[0]+B[0]+B[1]+B[1]+B[2]+B[2]),[R(B.substr(0,2)),R(B.substr(2,2)),R(B.substr(4,2))]).join(","),")");var B},j=function(w,B,te){var G=B.match(w),ue=B.replace(w,Di);return G&&G.forEach(function(Ne){return ue=ue.replace(Di,te(Ne))}),ue},K=function(w){for(var B in w){var te=w[B];typeof te=="string"&&te.match(Xn)&&(w[B]=j(Xn,te,H))}},Y=function(w){var B=w.match(ri),te=B.slice(0,3).map(Math.floor),G=w.match(Sr)[0];if(B.length===3)return"".concat(G).concat(te.join(","),")");if(B.length===4)return"".concat(G).concat(te.join(","),",").concat(B[3],")");throw new Error("Invalid rgbChunk: ".concat(w))},Ee=function(w){return w.match(ri)},Ie=function(w,B){var te={};return B.forEach(function(G){te[G]=w[G],delete w[G]}),te},He=function(w,B){return B.map(function(te){return w[te]})},Xe=function(w,B){return B.forEach(function(te){return w=w.replace(Di,+te.toFixed(4))}),w},et=function(w){for(var B in w._currentState)if(typeof w._currentState[B]=="string")return!0;return!1};function je(w){var B=w._currentState;[B,w._originalState,w._targetState].forEach(K),w._tokenData=function(te){var G,ue,Ne={};for(var Be in te){var rt=te[Be];typeof rt=="string"&&(Ne[Be]={formatString:(G=rt,ue=void 0,ue=G.match(yr),ue?(ue.length===1||G.charAt(0).match(Pi))&&ue.unshift(""):ue=["",""],ue.join(Di)),chunkNames:Es(Ee(rt),Be)})}return Ne}(B)}function Ze(w){var B=w._currentState,te=w._originalState,G=w._targetState,ue=w._easing,Ne=w._tokenData;(function(Be,rt){var dt=function(St){var Pt=rt[St].chunkNames,kt=Be[St];if(typeof kt=="string"){var rn=kt.split(" "),gi=rn[rn.length-1];Pt.forEach(function(si,oi){return Be[si]=rn[oi]||gi})}else Pt.forEach(function(si){return Be[si]=kt});delete Be[St]};for(var Ft in rt)dt(Ft)})(ue,Ne),[B,te,G].forEach(function(Be){return function(rt,dt){var Ft=function(Pt){Ee(rt[Pt]).forEach(function(kt,rn){return rt[dt[Pt].chunkNames[rn]]=+kt}),delete rt[Pt]};for(var St in dt)Ft(St)}(Be,Ne)})}function xt(w){var B=w._currentState,te=w._originalState,G=w._targetState,ue=w._easing,Ne=w._tokenData;[B,te,G].forEach(function(Be){return function(rt,dt){for(var Ft in dt){var St=dt[Ft],Pt=St.chunkNames,kt=St.formatString,rn=Xe(kt,He(Ie(rt,Pt),Pt));rt[Ft]=j(br,rn,Y)}}(Be,Ne)}),function(Be,rt){for(var dt in rt){var Ft=rt[dt].chunkNames,St=Be[Ft[0]];Be[dt]=typeof St=="string"?Ft.map(function(Pt){var kt=Be[Pt];return delete Be[Pt],kt}).join(" "):St}}(ue,Ne)}function Gt(w,B){var te=Object.keys(w);if(Object.getOwnPropertySymbols){var G=Object.getOwnPropertySymbols(w);B&&(G=G.filter(function(ue){return Object.getOwnPropertyDescriptor(w,ue).enumerable})),te.push.apply(te,G)}return te}function zt(w){for(var B=1;B4&&arguments[4]!==void 0?arguments[4]:0,Ne=zt({},w),Be=gt(w,G);for(var rt in at._filters.length=0,at.set({}),at._currentState=Ne,at._originalState=w,at._targetState=B,at._easing=Be,Je)Je[rt].doesApply(at)&&at._filters.push(Je[rt]);at._applyFilter("tweenCreated"),at._applyFilter("beforeTween");var dt=F(te,Ne,w,B,1,ue,Be);return at._applyFilter("afterTween"),dt};function yt(w,B){(B==null||B>w.length)&&(B=w.length);for(var te=0,G=new Array(B);tec.strokeWidth&&(u=c.trailWidth);var f=50-u/2;return o.render(this._pathTemplate,{radius:f,"2radius":f*2})},a.prototype._trailString=function(c){return this._pathString(c)},n.exports=a},{"./shape":8,"./utils":10}],4:[function(t,n,i){var s=t("./shape"),o=t("./utils"),a=function(c,u){this._pathTemplate=u.vertical?"M {center},100 L {center},0":"M 0,{center} L 100,{center}",s.apply(this,arguments)};a.prototype=new s,a.prototype.constructor=a,a.prototype._initializeSvg=function(c,u){var f=u.vertical?"0 0 "+u.strokeWidth+" 100":"0 0 100 "+u.strokeWidth;c.setAttribute("viewBox",f),c.setAttribute("preserveAspectRatio","none")},a.prototype._pathString=function(c){return o.render(this._pathTemplate,{center:c.strokeWidth/2})},a.prototype._trailString=function(c){return this._pathString(c)},n.exports=a},{"./shape":8,"./utils":10}],5:[function(t,n,i){n.exports={Line:t("./line"),Circle:t("./circle"),SemiCircle:t("./semicircle"),Square:t("./square"),Path:t("./path"),Shape:t("./shape"),utils:t("./utils")}},{"./circle":3,"./line":4,"./path":6,"./semicircle":7,"./shape":8,"./square":9,"./utils":10}],6:[function(t,n,i){var s=t("shifty"),o=t("./utils"),a=s.Tweenable,l={easeIn:"easeInCubic",easeOut:"easeOutCubic",easeInOut:"easeInOutCubic"},c=function u(f,h){if(!(this instanceof u))throw new Error("Constructor was called without new keyword");h=o.extend({delay:0,duration:800,easing:"linear",from:{},to:{},step:function(){}},h);var p;o.isString(f)?p=document.querySelector(f):p=f,this.path=p,this._opts=h,this._tweenable=null;var _=this.path.getTotalLength();this.path.style.strokeDasharray=_+" "+_,this.set(0)};c.prototype.value=function(){var f=this._getComputedDashOffset(),h=this.path.getTotalLength(),p=1-f/h;return parseFloat(p.toFixed(6),10)},c.prototype.set=function(f){this.stop(),this.path.style.strokeDashoffset=this._progressToOffset(f);var h=this._opts.step;if(o.isFunction(h)){var p=this._easing(this._opts.easing),_=this._calculateTo(f,p),g=this._opts.shape||this;h(_,g,this._opts.attachment)}},c.prototype.stop=function(){this._stopTween(),this.path.style.strokeDashoffset=this._getComputedDashOffset()},c.prototype.animate=function(f,h,p){h=h||{},o.isFunction(h)&&(p=h,h={});var _=o.extend({},h),g=o.extend({},this._opts);h=o.extend(g,h);var m=this._easing(h.easing),d=this._resolveFromAndTo(f,m,_);this.stop(),this.path.getBoundingClientRect();var x=this._getComputedDashOffset(),v=this._progressToOffset(f),y=this;this._tweenable=new a,this._tweenable.tween({from:o.extend({offset:x},d.from),to:o.extend({offset:v},d.to),duration:h.duration,delay:h.delay,easing:m,step:function(b){y.path.style.strokeDashoffset=b.offset;var M=h.shape||y;h.step(b,M,h.attachment)}}).then(function(b){o.isFunction(p)&&p()}).catch(function(b){throw console.error("Error in tweening:",b),b})},c.prototype._getComputedDashOffset=function(){var f=window.getComputedStyle(this.path,null);return parseFloat(f.getPropertyValue("stroke-dashoffset"),10)},c.prototype._progressToOffset=function(f){var h=this.path.getTotalLength();return h-f*h},c.prototype._resolveFromAndTo=function(f,h,p){return p.from&&p.to?{from:p.from,to:p.to}:{from:this._calculateFrom(h),to:this._calculateTo(f,h)}},c.prototype._calculateFrom=function(f){return s.interpolate(this._opts.from,this._opts.to,this.value(),f)},c.prototype._calculateTo=function(f,h){return s.interpolate(this._opts.from,this._opts.to,f,h)},c.prototype._stopTween=function(){this._tweenable!==null&&(this._tweenable.stop(!0),this._tweenable=null)},c.prototype._easing=function(f){return l.hasOwnProperty(f)?l[f]:f},n.exports=c},{"./utils":10,shifty:2}],7:[function(t,n,i){var s=t("./shape"),o=t("./circle"),a=t("./utils"),l=function(u,f){this._pathTemplate="M 50,50 m -{radius},0 a {radius},{radius} 0 1 1 {2radius},0",this.containerAspectRatio=2,s.apply(this,arguments)};l.prototype=new s,l.prototype.constructor=l,l.prototype._initializeSvg=function(u,f){u.setAttribute("viewBox","0 0 100 50")},l.prototype._initializeTextContainer=function(u,f,h){u.text.style&&(h.style.top="auto",h.style.bottom="0",u.text.alignToBottom?a.setStyle(h,"transform","translate(-50%, 0)"):a.setStyle(h,"transform","translate(-50%, 50%)"))},l.prototype._pathString=o.prototype._pathString,l.prototype._trailString=o.prototype._trailString,n.exports=l},{"./circle":3,"./shape":8,"./utils":10}],8:[function(t,n,i){var s=t("./path"),o=t("./utils"),a="Object is destroyed",l=function c(u,f){if(!(this instanceof c))throw new Error("Constructor was called without new keyword");if(arguments.length!==0){this._opts=o.extend({color:"#555",strokeWidth:1,trailColor:null,trailWidth:null,fill:null,text:{style:{color:null,position:"absolute",left:"50%",top:"50%",padding:0,margin:0,transform:{prefix:!0,value:"translate(-50%, -50%)"}},autoStyleContainer:!0,alignToBottom:!0,value:null,className:"progressbar-text"},svgStyle:{display:"block",width:"100%"},warnings:!1},f,!0),o.isObject(f)&&f.svgStyle!==void 0&&(this._opts.svgStyle=f.svgStyle),o.isObject(f)&&o.isObject(f.text)&&f.text.style!==void 0&&(this._opts.text.style=f.text.style);var h=this._createSvgView(this._opts),p;if(o.isString(u)?p=document.querySelector(u):p=u,!p)throw new Error("Container does not exist: "+u);this._container=p,this._container.appendChild(h.svg),this._opts.warnings&&this._warnContainerAspectRatio(this._container),this._opts.svgStyle&&o.setStyles(h.svg,this._opts.svgStyle),this.svg=h.svg,this.path=h.path,this.trail=h.trail,this.text=null;var _=o.extend({attachment:void 0,shape:this},this._opts);this._progressPath=new s(h.path,_),o.isObject(this._opts.text)&&this._opts.text.value!==null&&this.setText(this._opts.text.value)}};l.prototype.animate=function(u,f,h){if(this._progressPath===null)throw new Error(a);this._progressPath.animate(u,f,h)},l.prototype.stop=function(){if(this._progressPath===null)throw new Error(a);this._progressPath!==void 0&&this._progressPath.stop()},l.prototype.pause=function(){if(this._progressPath===null)throw new Error(a);this._progressPath!==void 0&&this._progressPath._tweenable&&this._progressPath._tweenable.pause()},l.prototype.resume=function(){if(this._progressPath===null)throw new Error(a);this._progressPath!==void 0&&this._progressPath._tweenable&&this._progressPath._tweenable.resume()},l.prototype.destroy=function(){if(this._progressPath===null)throw new Error(a);this.stop(),this.svg.parentNode.removeChild(this.svg),this.svg=null,this.path=null,this.trail=null,this._progressPath=null,this.text!==null&&(this.text.parentNode.removeChild(this.text),this.text=null)},l.prototype.set=function(u){if(this._progressPath===null)throw new Error(a);this._progressPath.set(u)},l.prototype.value=function(){if(this._progressPath===null)throw new Error(a);return this._progressPath===void 0?0:this._progressPath.value()},l.prototype.setText=function(u){if(this._progressPath===null)throw new Error(a);this.text===null&&(this.text=this._createTextContainer(this._opts,this._container),this._container.appendChild(this.text)),o.isObject(u)?(o.removeChildren(this.text),this.text.appendChild(u)):this.text.innerHTML=u},l.prototype._createSvgView=function(u){var f=document.createElementNS("http://www.w3.org/2000/svg","svg");this._initializeSvg(f,u);var h=null;(u.trailColor||u.trailWidth)&&(h=this._createTrail(u),f.appendChild(h));var p=this._createPath(u);return f.appendChild(p),{svg:f,path:p,trail:h}},l.prototype._initializeSvg=function(u,f){u.setAttribute("viewBox","0 0 100 100")},l.prototype._createPath=function(u){var f=this._pathString(u);return this._createPathElement(f,u)},l.prototype._createTrail=function(u){var f=this._trailString(u),h=o.extend({},u);return h.trailColor||(h.trailColor="#eee"),h.trailWidth||(h.trailWidth=h.strokeWidth),h.color=h.trailColor,h.strokeWidth=h.trailWidth,h.fill=null,this._createPathElement(f,h)},l.prototype._createPathElement=function(u,f){var h=document.createElementNS("http://www.w3.org/2000/svg","path");return h.setAttribute("d",u),h.setAttribute("stroke",f.color),h.setAttribute("stroke-width",f.strokeWidth),f.fill?h.setAttribute("fill",f.fill):h.setAttribute("fill-opacity","0"),h},l.prototype._createTextContainer=function(u,f){var h=document.createElement("div");h.className=u.text.className;var p=u.text.style;return p&&(u.text.autoStyleContainer&&(f.style.position="relative"),o.setStyles(h,p),p.color||(h.style.color=u.color)),this._initializeTextContainer(u,f,h),h},l.prototype._initializeTextContainer=function(c,u,f){},l.prototype._pathString=function(u){throw new Error("Override this function for each progress bar")},l.prototype._trailString=function(u){throw new Error("Override this function for each progress bar")},l.prototype._warnContainerAspectRatio=function(u){if(this.containerAspectRatio){var f=window.getComputedStyle(u,null),h=parseFloat(f.getPropertyValue("width"),10),p=parseFloat(f.getPropertyValue("height"),10);o.floatEquals(this.containerAspectRatio,h/p)||(console.warn("Incorrect aspect ratio of container","#"+u.id,"detected:",f.getPropertyValue("width")+"(width)","/",f.getPropertyValue("height")+"(height)","=",h/p),console.warn("Aspect ratio of should be",this.containerAspectRatio))}},n.exports=l},{"./path":6,"./utils":10}],9:[function(t,n,i){var s=t("./shape"),o=t("./utils"),a=function(c,u){this._pathTemplate="M 0,{halfOfStrokeWidth} L {width},{halfOfStrokeWidth} L {width},{width} L {halfOfStrokeWidth},{width} L {halfOfStrokeWidth},{strokeWidth}",this._trailTemplate="M {startMargin},{halfOfStrokeWidth} L {width},{halfOfStrokeWidth} L {width},{width} L {halfOfStrokeWidth},{width} L {halfOfStrokeWidth},{halfOfStrokeWidth}",s.apply(this,arguments)};a.prototype=new s,a.prototype.constructor=a,a.prototype._pathString=function(c){var u=100-c.strokeWidth/2;return o.render(this._pathTemplate,{width:u,strokeWidth:c.strokeWidth,halfOfStrokeWidth:c.strokeWidth/2})},a.prototype._trailString=function(c){var u=100-c.strokeWidth/2;return o.render(this._trailTemplate,{width:u,strokeWidth:c.strokeWidth,halfOfStrokeWidth:c.strokeWidth/2,startMargin:c.strokeWidth/2-c.trailWidth/2})},n.exports=a},{"./shape":8,"./utils":10}],10:[function(t,n,i){var s=t("lodash.merge"),o="Webkit Moz O ms".split(" "),a=.001;function l(v,y){var b=v;for(var M in y)if(y.hasOwnProperty(M)){var T=y[M],I="\\{"+M+"\\}",S=new RegExp(I,"g");b=b.replace(S,T)}return b}function c(v,y,b){for(var M=v.style,T=0;T{if(o.isMesh){const a=new nb(o);a.attributes=["position","color","normal","tangent","uv","uv2"],a.applyWorldTransforms=!1;const l={strategy:Gf,maxLeafTris:1};let c=new mc(a.generate(),l);return new Mn(a.generate(),o.material),this.result={scene:t.scene,bvh:c,mesh:o},console.log("==> loaded mesh ",e),this.result}});return this.result}}function Bn(r){return new C(r[0],r[1],r[2])}const k={smooth_normals:!0,bounces:6,max_samples:1024,max_volume_steps:8,wireframe:!0,neutral_color:[.5,.5,.5],skyPower:.5,skyColor:[.8,.8,1],sunPower:.35,sunAngularSize:40,sunLatitude:40,sunLongitude:180,sunColor:[1,1,.8],base_weight:1,base_color:[.8,.8,.8],base_roughness:0,base_metalness:0,specular_weight:1,specular_color:[1,1,1],specular_roughness:.1,specular_anisotropy:0,specular_rotation:0,specular_ior:1.6,transmission_weight:0,transmission_color:[1,1,1],transmission_depth:0,transmission_scatter:[0,0,0],transmission_scatter_anisotropy:0,transmission_dispersion_abbe_number:20,transmission_dispersion_scale:0,subsurface_weight:0,subsurface_color:[.8,.8,.8],subsurface_radius:.2,subsurface_radius_scale:[1,.5,.25],subsurface_anisotropy:0,subsurface_mode:0,coat_weight:0,coat_color:[1,1,1],coat_roughness:0,coat_anisotropy:0,coat_rotation:0,coat_ior:1.3,coat_darkening:1,fuzz_weight:0,fuzz_color:[1,1,1],fuzz_roughness:.5,emission_luminance:0,emission_color:[1,1,1],thin_film_weight:0,thin_film_thickness:1e3,thin_film_ior:1.4,geometry_opacity:1,geometry_thin_walled:!1,reset_camera:function(){vc()}};let qt,Mt,Ot,fr,Gi,as,ma,Qe,Zf,io,cr=0,es,ts,Tl,Al;var _n,gc,_a,Ks,Tb={"OpenPBR (orig, 3-float)":0,"OpenPBR (luminace)":1,"OpenPBR (average)":2,"OpenPBR (max value)":3,"OpenPBR (weighted average)":4,"SPI / Arnold v1":5,"Arnold v2":6,"Uniform scattering":7};Rb();Zs();function Ab(){let r=(90-k.sunLatitude)*Math.PI/180,e=k.sunLongitude*Math.PI/180,t=Math.cos(r),n=Math.sin(r),i=Math.cos(e),s=Math.sin(e),o=n*i,a=n*s,l=t;k.sunDir=[o,l,a]}function Rb(){_n=new wb.Circle("#progress_overlay",{color:"rgba(255, 128, 64, 0.75)",strokeWidth:5,trailColor:"rgba(255, 128, 64, 0.333)",trailWidth:3,svgStyle:{display:"block",width:"100%"},text:{value:"",className:"progressbar__label",style:{color:"rgba(169, 85, 42, 1.0)",position:"absolute",fontWeight:"bold",left:"50%",top:"50%",padding:0,margin:0,transform:{prefix:!0,value:"translate(-50%, -50%)"}},autoStyleContainer:!0,alignToBottom:!0},fill:null,duration:2e3,easing:"linear",from:{color:"rgba( 0, 0, 0, 0.0)"},to:{color:"rgba(32, 255, 32, 1.0)"},warnings:!0}),_n.set(0),_n.setText(""),_a=!1,es=null,ts=null,Tl=null,Al=null,qt=new Pf({antialias:!0,preserveDrawingBuffer:!0}),qt.setPixelRatio(window.devicePixelRatio),qt.setClearColor(594970),qt.setSize(window.innerWidth,window.innerHeight),qt.outputEncoding=Yi,document.body.appendChild(qt.domElement),fr=new x0;const r=new Bf(16777215,1);r.position.set(1,1,1),fr.add(r),fr.add(new Y0(11583173,.5)),as=new qx,document.body.appendChild(as.dom);let e=document.getElementById("samples");e.style.visibility="visible";let t=document.getElementById("info");t.style.visibility="visible",Qe=new Ki({defines:{BOUNCES:k.bounces,MAX_VOLUME_STEPS:k.max_volume_steps,COAT_ENABLED:!1,TRANSMISSION_ENABLED:!1,VOLUME_ENABLED:!1,DISPERSION_ENABLED:!1,THIN_FILM_ENABLED:!1},uniforms:{bvh_surface:{value:new kh},normalAttribute_surface:{value:new Vs},tangentAttribute_surface:{value:new Vs},has_normals_surface:{value:1},has_tangents_surface:{value:0},bvh_props:{value:new kh},normalAttribute_props:{value:new Vs},tangentAttribute_props:{value:new Vs},has_normals_props:{value:1},has_tangents_props:{value:0},cameraWorldMatrix:{value:new Ve},invProjectionMatrix:{value:new Ve},invModelMatrix:{value:new Ve},resolution:{value:new Ue},samples:{value:0},accumulation_weight:{value:1},wireframe:{value:k.wireframe},neutral_color:{value:new C().fromArray(k.neutral_color)},smooth_normals:{value:k.smooth_normals},skyPower:{value:k.skyPower},skyColor:{value:Bn(k.skyColor)},sunPower:{value:Math.pow(10,k.sunPower)},sunAngularSize:{value:k.sunAngularSize},sunColor:{value:Bn(k.sunColor)},sunDir:{value:Bn([0,0,0])},base_weight:{value:k.base_weight},base_color:{value:Bn(k.base_color)},base_roughness:{value:k.base_roughness},base_metalness:{value:k.base_metalness},specular_weight:{value:k.specular_weight},specular_color:{value:Bn(k.specular_color)},specular_roughness:{value:k.specular_roughness},specular_anisotropy:{value:k.specular_anisotropy},specular_rotation:{value:k.specular_rotation},specular_ior:{value:k.specular_ior},transmission_weight:{value:k.transmission_weight},transmission_color:{value:Bn(k.transmission_color)},transmission_depth:{value:k.transmission_depth},transmission_scatter:{value:Bn(k.transmission_scatter)},transmission_scatter_anisotropy:{value:k.transmission_scatter_anisotropy},transmission_dispersion_abbe_number:{value:k.transmission_dispersion_abbe_number},transmission_dispersion_scale:{value:k.transmission_dispersion_scale},subsurface_weight:{value:k.subsurface_weight},subsurface_color:{value:Bn(k.subsurface_color)},subsurface_radius:{value:k.subsurface_radius},subsurface_radius_scale:{value:Bn(k.subsurface_radius_scale)},subsurface_anisotropy:{value:k.subsurface_anisotropy},subsurface_mode:{value:k.subsurface_mode},coat_weight:{value:k.coat_weight},coat_color:{value:Bn(k.coat_color)},coat_roughness:{value:k.coat_roughness},coat_anisotropy:{value:k.coat_anisotropy},coat_rotation:{value:k.coat_rotation},coat_ior:{value:k.coat_ior},coat_darkening:{value:k.coat_darkening},fuzz_weight:{value:k.fuzz_weight},fuzz_color:{value:Bn(k.fuzz_color)},fuzz_roughness:{value:k.fuzz_roughness},emission_luminance:{value:k.emission_luminance},emission_color:{value:Bn(k.emission_color)},thin_film_weight:{value:k.thin_film_weight},thin_film_thickness:{value:k.thin_film_thickness},thin_film_ior:{value:k.thin_film_ior},geometry_opacity:{value:k.geometry_opacity},geometry_thin_walled:{value:k.geometry_thin_walled}},vertexShader:` +`;function na(r){throw new Error('Could not dynamically require "'+r+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Kf={exports:{}};(function(r,e){(function(t){r.exports=t()})(function(){return function(){function t(n,i,s){function o(c,u){if(!i[c]){if(!n[c]){var f=typeof na=="function"&&na;if(!u&&f)return f(c,!0);if(a)return a(c,!0);var h=new Error("Cannot find module '"+c+"'");throw h.code="MODULE_NOT_FOUND",h}var p=i[c]={exports:{}};n[c][0].call(p.exports,function(_){var g=n[c][1][_];return o(g||_)},p,p.exports,t,n,i,s)}return i[c].exports}for(var a=typeof na=="function"&&na,l=0;l-1}function Sr(L,U){var $=this.__data__,Te=xt($,L);return Te<0?(++this.size,$.push([L,U])):$[Te][1]=U,this}ln.prototype.clear=Pi,ln.prototype.delete=yr,ln.prototype.get=ri,ln.prototype.has=br,ln.prototype.set=Sr;function Xn(L){var U=-1,$=L==null?0:L.length;for(this.clear();++U<$;){var Te=L[U];this.set(Te[0],Te[1])}}function Di(){this.size=0,this.__data__={hash:new gt,map:new(he||ln),string:new gt}}function Es(L){var U=Be(this,L).delete(L);return this.size-=U?1:0,U}function R(L){return Be(this,L).get(L)}function H(L){return Be(this,L).has(L)}function j(L,U){var $=Be(this,L),Te=$.size;return $.set(L,U),this.size+=$.size==Te?0:1,this}Xn.prototype.clear=Di,Xn.prototype.delete=Es,Xn.prototype.get=R,Xn.prototype.has=H,Xn.prototype.set=j;function K(L){var U=this.__data__=new ln(L);this.size=U.size}function Y(){this.__data__=new ln,this.size=0}function Ee(L){var U=this.__data__,$=U.delete(L);return this.size=U.size,$}function Ie(L){return this.__data__.get(L)}function He(L){return this.__data__.has(L)}function Xe(L,U){var $=this.__data__;if($ instanceof ln){var Te=$.__data__;if(!he||Te.length1?$[ut-1]:void 0,Dt=ut>2?$[2]:void 0;for(wt=L.length>3&&typeof wt=="function"?(ut--,wt):void 0,Dt&&Pt($[0],$[1],Dt)&&(wt=ut<3?void 0:wt,ut=1),U=Object(U);++Te-1&&L%1==0&&L0){if(++U>=l)return arguments[0]}else U=0;return L.apply(void 0,arguments)}}function Qt(L){if(L!=null){try{return le.call(L)}catch{}try{return L+""}catch{}}return""}function dn(L,U){return L===U||L!==L&&U!==U}var An=at(function(){return arguments}())?at:function(L){return ws(L)&&re.call(L,"callee")&&!we.call(L,"callee")},qn=Array.isArray;function wr(L){return L!=null&&yc(L.length)&&!Ta(L)}function Jf(L){return ws(L)&&wr(L)}var xc=ge||id;function Ta(L){if(!Qi(L))return!1;var U=cn(L);return U==d||U==x||U==p||U==T}function yc(L){return typeof L=="number"&&L>-1&&L%1==0&&L<=u}function Qi(L){var U=typeof L;return L!=null&&(U=="object"||U=="function")}function ws(L){return L!=null&&typeof L=="object"}function Qf(L){if(!ws(L)||cn(L)!=M)return!1;var U=Ae(L);if(U===null)return!0;var $=re.call(U,"constructor")&&U.constructor;return typeof $=="function"&&$ instanceof $&&le.call($)==pe}var bc=ze?ke(ze):Ji;function ed(L){return G(L,Sc(L))}function Sc(L){return wr(L)?et(L,!0):yt(L)}var td=ue(function(L,U,$){Fn(L,U,$)});function nd(L){return function(){return L}}function Ec(L){return L}function id(){return!1}n.exports=td}).call(this)}).call(this,typeof Gl<"u"?Gl:typeof self<"u"?self:typeof window<"u"?window:{})},{}],2:[function(t,n,i){/*! For license information please see shifty.js.LICENSE.txt */(function(s,o){typeof i=="object"&&typeof n=="object"?n.exports=o():typeof i=="object"?i.shifty=o():s.shifty=o()})(self,function(){return function(){var s={720:function(l,c,u){u.r(c),u.d(c,{Scene:function(){return Wt},Tweenable:function(){return ft},interpolate:function(){return Ji},processTweens:function(){return ae},setBezierFunction:function(){return $e},shouldScheduleUpdate:function(){return Re},tween:function(){return Sn},unsetBezierFunction:function(){return ze}});var f={};u.r(f),u.d(f,{bounce:function(){return _e},bouncePast:function(){return qe},easeFrom:function(){return Fe},easeFromTo:function(){return We},easeInBack:function(){return se},easeInCirc:function(){return Z},easeInCubic:function(){return d},easeInExpo:function(){return W},easeInOutBack:function(){return ve},easeInOutCirc:function(){return ce},easeInOutCubic:function(){return v},easeInOutExpo:function(){return V},easeInOutQuad:function(){return m},easeInOutQuart:function(){return M},easeInOutQuint:function(){return S},easeInOutSine:function(){return O},easeInQuad:function(){return _},easeInQuart:function(){return y},easeInQuint:function(){return T},easeInSine:function(){return A},easeOutBack:function(){return me},easeOutBounce:function(){return ie},easeOutCirc:function(){return J},easeOutCubic:function(){return x},easeOutExpo:function(){return D},easeOutQuad:function(){return g},easeOutQuart:function(){return b},easeOutQuint:function(){return I},easeOutSine:function(){return z},easeTo:function(){return Ye},elastic:function(){return Q},linear:function(){return p},swingFrom:function(){return Se},swingFromTo:function(){return oe},swingTo:function(){return De}});var h={};u.r(h),u.d(h,{afterTween:function(){return xt},beforeTween:function(){return Ze},doesApply:function(){return et},tweenCreated:function(){return je}});var p=function(w){return w},_=function(w){return Math.pow(w,2)},g=function(w){return-(Math.pow(w-1,2)-1)},m=function(w){return(w/=.5)<1?.5*Math.pow(w,2):-.5*((w-=2)*w-2)},d=function(w){return Math.pow(w,3)},x=function(w){return Math.pow(w-1,3)+1},v=function(w){return(w/=.5)<1?.5*Math.pow(w,3):.5*(Math.pow(w-2,3)+2)},y=function(w){return Math.pow(w,4)},b=function(w){return-(Math.pow(w-1,4)-1)},M=function(w){return(w/=.5)<1?.5*Math.pow(w,4):-.5*((w-=2)*Math.pow(w,3)-2)},T=function(w){return Math.pow(w,5)},I=function(w){return Math.pow(w-1,5)+1},S=function(w){return(w/=.5)<1?.5*Math.pow(w,5):.5*(Math.pow(w-2,5)+2)},A=function(w){return 1-Math.cos(w*(Math.PI/2))},z=function(w){return Math.sin(w*(Math.PI/2))},O=function(w){return-.5*(Math.cos(Math.PI*w)-1)},W=function(w){return w===0?0:Math.pow(2,10*(w-1))},D=function(w){return w===1?1:1-Math.pow(2,-10*w)},V=function(w){return w===0?0:w===1?1:(w/=.5)<1?.5*Math.pow(2,10*(w-1)):.5*(2-Math.pow(2,-10*--w))},Z=function(w){return-(Math.sqrt(1-w*w)-1)},J=function(w){return Math.sqrt(1-Math.pow(w-1,2))},ce=function(w){return(w/=.5)<1?-.5*(Math.sqrt(1-w*w)-1):.5*(Math.sqrt(1-(w-=2)*w)+1)},ie=function(w){return w<1/2.75?7.5625*w*w:w<2/2.75?7.5625*(w-=1.5/2.75)*w+.75:w<2.5/2.75?7.5625*(w-=2.25/2.75)*w+.9375:7.5625*(w-=2.625/2.75)*w+.984375},se=function(w){var B=1.70158;return w*w*((B+1)*w-B)},me=function(w){var B=1.70158;return(w-=1)*w*((B+1)*w+B)+1},ve=function(w){var B=1.70158;return(w/=.5)<1?w*w*((1+(B*=1.525))*w-B)*.5:.5*((w-=2)*w*((1+(B*=1.525))*w+B)+2)},Q=function(w){return-1*Math.pow(4,-8*w)*Math.sin((6*w-1)*(2*Math.PI)/2)+1},oe=function(w){var B=1.70158;return(w/=.5)<1?w*w*((1+(B*=1.525))*w-B)*.5:.5*((w-=2)*w*((1+(B*=1.525))*w+B)+2)},Se=function(w){var B=1.70158;return w*w*((B+1)*w-B)},De=function(w){var B=1.70158;return(w-=1)*w*((B+1)*w+B)+1},_e=function(w){return w<1/2.75?7.5625*w*w:w<2/2.75?7.5625*(w-=1.5/2.75)*w+.75:w<2.5/2.75?7.5625*(w-=2.25/2.75)*w+.9375:7.5625*(w-=2.625/2.75)*w+.984375},qe=function(w){return w<1/2.75?7.5625*w*w:w<2/2.75?2-(7.5625*(w-=1.5/2.75)*w+.75):w<2.5/2.75?2-(7.5625*(w-=2.25/2.75)*w+.9375):2-(7.5625*(w-=2.625/2.75)*w+.984375)},We=function(w){return(w/=.5)<1?.5*Math.pow(w,4):-.5*((w-=2)*Math.pow(w,3)-2)},Fe=function(w){return Math.pow(w,4)},Ye=function(w){return Math.pow(w,.25)};function X(w,B,te,G,ue,Ne){var Be,rt,dt,Ft,St,Pt=0,kt=0,rn=0,gi=function(Et){return((Pt*Et+kt)*Et+rn)*Et},si=function(Et){return(3*Pt*Et+2*kt)*Et+rn},oi=function(Et){return Et>=0?Et:0-Et};return Pt=1-(rn=3*B)-(kt=3*(G-B)-rn),dt=1-(St=3*te)-(Ft=3*(ue-te)-St),Be=w,rt=function(Et){return 1/(200*Et)}(Ne),function(Et){return((dt*Et+Ft)*Et+St)*Et}(function(Et,ai){var li,vi,Qt,dn,An,qn;for(Qt=Et,qn=0;qn<8;qn++){if(dn=gi(Qt)-Et,oi(dn)(vi=1))return vi;for(;lidn?li=Qt:vi=Qt,Qt=.5*(vi-li)+li}return Qt}(Be,rt))}var Lt,Ce=function(){var w=arguments.length>0&&arguments[0]!==void 0?arguments[0]:.25,B=arguments.length>1&&arguments[1]!==void 0?arguments[1]:.25,te=arguments.length>2&&arguments[2]!==void 0?arguments[2]:.75,G=arguments.length>3&&arguments[3]!==void 0?arguments[3]:.75;return function(ue){return X(ue,w,B,te,G,1)}},$e=function(w,B,te,G,ue){var Ne=Ce(B,te,G,ue);return Ne.displayName=w,Ne.x1=B,Ne.y1=te,Ne.x2=G,Ne.y2=ue,ft.formulas[w]=Ne},ze=function(w){return delete ft.formulas[w]};function _t(w,B){if(!(w instanceof B))throw new TypeError("Cannot call a class as a function")}function Ke(w,B){for(var te=0;tew.length)&&(B=w.length);for(var te=0,G=new Array(B);tert?rt:B;w._hasEnded=dt>=rt;var Ft=Ne-(rt-dt),St=w._filters.length>0;if(w._hasEnded)return w._render(Be,w._data,Ft),w.stop(!0);St&&w._applyFilter(N),dt1&&arguments[1]!==void 0?arguments[1]:fe,te=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(Array.isArray(B)){var G=Ce.apply(void 0,ot(B));return G}var ue=ke(B);if(Ge[B])return Ge[B];if(ue===Oe||ue===ne)for(var Ne in w)te[Ne]=B;else for(var Be in w)te[Be]=B[Be]||fe;return te},Vt=function(w){w===we?(we=w._next)?we._previous=null:be=null:w===be?(be=w._previous)?be._next=null:we=null:(le=w._previous,re=w._next,le._next=re,re._previous=le),w._previous=w._next=null},ht=typeof Promise=="function"?Promise:null;Lt=Symbol.toStringTag;var ft=function(){function w(){var G=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},ue=arguments.length>1&&arguments[1]!==void 0?arguments[1]:void 0;_t(this,w),E(this,Lt,"Promise"),this._config={},this._data={},this._delay=0,this._filters=[],this._next=null,this._previous=null,this._timestamp=null,this._hasEnded=!1,this._resolve=null,this._reject=null,this._currentState=G||{},this._originalState={},this._targetState={},this._start=Pe,this._render=Pe,this._promiseCtor=ht,ue&&this.setConfig(ue)}var B,te;return B=w,te=[{key:"_applyFilter",value:function(G){for(var ue=this._filters.length;ue>0;ue--){var Ne=this._filters[ue-ue][G];Ne&&Ne(this)}}},{key:"tween",value:function(){var G=arguments.length>0&&arguments[0]!==void 0?arguments[0]:void 0;return this._isPlaying&&this.stop(),!G&&this._config||this.setConfig(G),this._pausedAtTime=null,this._timestamp=w.now(),this._start(this.get(),this._data),this._delay&&this._render(this._currentState,this._data,0),this._resume(this._timestamp)}},{key:"setConfig",value:function(){var G=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},ue=this._config;for(var Ne in G)ue[Ne]=G[Ne];var Be=ue.promise,rt=Be===void 0?this._promiseCtor:Be,dt=ue.start,Ft=dt===void 0?Pe:dt,St=ue.finish,Pt=ue.render,kt=Pt===void 0?this._config.step||Pe:Pt,rn=ue.step,gi=rn===void 0?Pe:rn;this._data=ue.data||ue.attachment||this._data,this._isPlaying=!1,this._pausedAtTime=null,this._scheduleId=null,this._delay=G.delay||0,this._start=Ft,this._render=kt||gi,this._duration=ue.duration||500,this._promiseCtor=rt,St&&(this._resolve=St);var si=G.from,oi=G.to,Et=oi===void 0?{}:oi,ai=this._currentState,li=this._originalState,vi=this._targetState;for(var Qt in si)ai[Qt]=si[Qt];var dn=!1;for(var An in ai){var qn=ai[An];dn||ke(qn)!==Oe||(dn=!0),li[An]=qn,vi[An]=Et.hasOwnProperty(An)?Et[An]:qn}if(this._easing=gt(this._currentState,ue.easing,this._easing),this._filters.length=0,dn){for(var wr in w.filters)w.filters[wr].doesApply(this)&&this._filters.push(w.filters[wr]);this._applyFilter(de)}return this}},{key:"then",value:function(G,ue){var Ne=this;return this._promise=new this._promiseCtor(function(Be,rt){Ne._resolve=Be,Ne._reject=rt}),this._promise.then(G,ue)}},{key:"catch",value:function(G){return this.then().catch(G)}},{key:"finally",value:function(G){return this.then().finally(G)}},{key:"get",value:function(){return P({},this._currentState)}},{key:"set",value:function(G){this._currentState=G}},{key:"pause",value:function(){if(this._isPlaying)return this._pausedAtTime=w.now(),this._isPlaying=!1,Vt(this),this}},{key:"resume",value:function(){return this._resume()}},{key:"_resume",value:function(){var G=arguments.length>0&&arguments[0]!==void 0?arguments[0]:w.now();return this._timestamp===null?this.tween():this._isPlaying?this._promise:(this._pausedAtTime&&(this._timestamp+=G-this._pausedAtTime,this._pausedAtTime=null),this._isPlaying=!0,we===null?(we=this,be=this):(this._previous=be,be._next=this,be=this),this)}},{key:"seek",value:function(G){G=Math.max(G,0);var ue=w.now();return this._timestamp+G===0||(this._timestamp=ue-G,ge(this,ue)),this}},{key:"stop",value:function(){var G=arguments.length>0&&arguments[0]!==void 0&&arguments[0];if(!this._isPlaying)return this;this._isPlaying=!1,Vt(this);var ue=this._filters.length>0;return G&&(ue&&this._applyFilter(N),F(1,this._currentState,this._originalState,this._targetState,1,0,this._easing),ue&&(this._applyFilter(pe),this._applyFilter(ye))),this._resolve&&this._resolve({data:this._data,state:this._currentState,tweenable:this}),this._resolve=null,this._reject=null,this}},{key:"cancel",value:function(){var G=arguments.length>0&&arguments[0]!==void 0&&arguments[0],ue=this._currentState,Ne=this._data,Be=this._isPlaying;return Be?(this._reject&&this._reject({data:Ne,state:ue,tweenable:this}),this._resolve=null,this._reject=null,this.stop(G)):this}},{key:"isPlaying",value:function(){return this._isPlaying}},{key:"hasEnded",value:function(){return this._hasEnded}},{key:"setScheduleFunction",value:function(G){w.setScheduleFunction(G)}},{key:"data",value:function(){var G=arguments.length>0&&arguments[0]!==void 0?arguments[0]:null;return G&&(this._data=P({},G)),this._data}},{key:"dispose",value:function(){for(var G in this)delete this[G]}}],te&&Ke(B.prototype,te),w}();function Sn(){var w=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},B=new ft;return B.tween(w),B.tweenable=B,B}E(ft,"now",function(){return q}),E(ft,"setScheduleFunction",function(w){return Ae=w}),E(ft,"filters",{}),E(ft,"formulas",Ge),Re(!0);var ii,ln,Pi=/(\d|-|\.)/,yr=/([^\-0-9.]+)/g,ri=/[0-9.-]+/g,br=(ii=ri.source,ln=/,\s*/.source,new RegExp("rgba?\\(".concat(ii).concat(ln).concat(ii).concat(ln).concat(ii,"(").concat(ln).concat(ii,")?\\)"),"g")),Sr=/^.*\(/,Xn=/#([0-9]|[a-f]){3,6}/gi,Di="VAL",Es=function(w,B){return w.map(function(te,G){return"_".concat(B,"_").concat(G)})};function R(w){return parseInt(w,16)}var H=function(w){return"rgb(".concat((B=w,(B=B.replace(/#/,"")).length===3&&(B=(B=B.split(""))[0]+B[0]+B[1]+B[1]+B[2]+B[2]),[R(B.substr(0,2)),R(B.substr(2,2)),R(B.substr(4,2))]).join(","),")");var B},j=function(w,B,te){var G=B.match(w),ue=B.replace(w,Di);return G&&G.forEach(function(Ne){return ue=ue.replace(Di,te(Ne))}),ue},K=function(w){for(var B in w){var te=w[B];typeof te=="string"&&te.match(Xn)&&(w[B]=j(Xn,te,H))}},Y=function(w){var B=w.match(ri),te=B.slice(0,3).map(Math.floor),G=w.match(Sr)[0];if(B.length===3)return"".concat(G).concat(te.join(","),")");if(B.length===4)return"".concat(G).concat(te.join(","),",").concat(B[3],")");throw new Error("Invalid rgbChunk: ".concat(w))},Ee=function(w){return w.match(ri)},Ie=function(w,B){var te={};return B.forEach(function(G){te[G]=w[G],delete w[G]}),te},He=function(w,B){return B.map(function(te){return w[te]})},Xe=function(w,B){return B.forEach(function(te){return w=w.replace(Di,+te.toFixed(4))}),w},et=function(w){for(var B in w._currentState)if(typeof w._currentState[B]=="string")return!0;return!1};function je(w){var B=w._currentState;[B,w._originalState,w._targetState].forEach(K),w._tokenData=function(te){var G,ue,Ne={};for(var Be in te){var rt=te[Be];typeof rt=="string"&&(Ne[Be]={formatString:(G=rt,ue=void 0,ue=G.match(yr),ue?(ue.length===1||G.charAt(0).match(Pi))&&ue.unshift(""):ue=["",""],ue.join(Di)),chunkNames:Es(Ee(rt),Be)})}return Ne}(B)}function Ze(w){var B=w._currentState,te=w._originalState,G=w._targetState,ue=w._easing,Ne=w._tokenData;(function(Be,rt){var dt=function(St){var Pt=rt[St].chunkNames,kt=Be[St];if(typeof kt=="string"){var rn=kt.split(" "),gi=rn[rn.length-1];Pt.forEach(function(si,oi){return Be[si]=rn[oi]||gi})}else Pt.forEach(function(si){return Be[si]=kt});delete Be[St]};for(var Ft in rt)dt(Ft)})(ue,Ne),[B,te,G].forEach(function(Be){return function(rt,dt){var Ft=function(Pt){Ee(rt[Pt]).forEach(function(kt,rn){return rt[dt[Pt].chunkNames[rn]]=+kt}),delete rt[Pt]};for(var St in dt)Ft(St)}(Be,Ne)})}function xt(w){var B=w._currentState,te=w._originalState,G=w._targetState,ue=w._easing,Ne=w._tokenData;[B,te,G].forEach(function(Be){return function(rt,dt){for(var Ft in dt){var St=dt[Ft],Pt=St.chunkNames,kt=St.formatString,rn=Xe(kt,He(Ie(rt,Pt),Pt));rt[Ft]=j(br,rn,Y)}}(Be,Ne)}),function(Be,rt){for(var dt in rt){var Ft=rt[dt].chunkNames,St=Be[Ft[0]];Be[dt]=typeof St=="string"?Ft.map(function(Pt){var kt=Be[Pt];return delete Be[Pt],kt}).join(" "):St}}(ue,Ne)}function Gt(w,B){var te=Object.keys(w);if(Object.getOwnPropertySymbols){var G=Object.getOwnPropertySymbols(w);B&&(G=G.filter(function(ue){return Object.getOwnPropertyDescriptor(w,ue).enumerable})),te.push.apply(te,G)}return te}function zt(w){for(var B=1;B4&&arguments[4]!==void 0?arguments[4]:0,Ne=zt({},w),Be=gt(w,G);for(var rt in at._filters.length=0,at.set({}),at._currentState=Ne,at._originalState=w,at._targetState=B,at._easing=Be,Je)Je[rt].doesApply(at)&&at._filters.push(Je[rt]);at._applyFilter("tweenCreated"),at._applyFilter("beforeTween");var dt=F(te,Ne,w,B,1,ue,Be);return at._applyFilter("afterTween"),dt};function yt(w,B){(B==null||B>w.length)&&(B=w.length);for(var te=0,G=new Array(B);tec.strokeWidth&&(u=c.trailWidth);var f=50-u/2;return o.render(this._pathTemplate,{radius:f,"2radius":f*2})},a.prototype._trailString=function(c){return this._pathString(c)},n.exports=a},{"./shape":8,"./utils":10}],4:[function(t,n,i){var s=t("./shape"),o=t("./utils"),a=function(c,u){this._pathTemplate=u.vertical?"M {center},100 L {center},0":"M 0,{center} L 100,{center}",s.apply(this,arguments)};a.prototype=new s,a.prototype.constructor=a,a.prototype._initializeSvg=function(c,u){var f=u.vertical?"0 0 "+u.strokeWidth+" 100":"0 0 100 "+u.strokeWidth;c.setAttribute("viewBox",f),c.setAttribute("preserveAspectRatio","none")},a.prototype._pathString=function(c){return o.render(this._pathTemplate,{center:c.strokeWidth/2})},a.prototype._trailString=function(c){return this._pathString(c)},n.exports=a},{"./shape":8,"./utils":10}],5:[function(t,n,i){n.exports={Line:t("./line"),Circle:t("./circle"),SemiCircle:t("./semicircle"),Square:t("./square"),Path:t("./path"),Shape:t("./shape"),utils:t("./utils")}},{"./circle":3,"./line":4,"./path":6,"./semicircle":7,"./shape":8,"./square":9,"./utils":10}],6:[function(t,n,i){var s=t("shifty"),o=t("./utils"),a=s.Tweenable,l={easeIn:"easeInCubic",easeOut:"easeOutCubic",easeInOut:"easeInOutCubic"},c=function u(f,h){if(!(this instanceof u))throw new Error("Constructor was called without new keyword");h=o.extend({delay:0,duration:800,easing:"linear",from:{},to:{},step:function(){}},h);var p;o.isString(f)?p=document.querySelector(f):p=f,this.path=p,this._opts=h,this._tweenable=null;var _=this.path.getTotalLength();this.path.style.strokeDasharray=_+" "+_,this.set(0)};c.prototype.value=function(){var f=this._getComputedDashOffset(),h=this.path.getTotalLength(),p=1-f/h;return parseFloat(p.toFixed(6),10)},c.prototype.set=function(f){this.stop(),this.path.style.strokeDashoffset=this._progressToOffset(f);var h=this._opts.step;if(o.isFunction(h)){var p=this._easing(this._opts.easing),_=this._calculateTo(f,p),g=this._opts.shape||this;h(_,g,this._opts.attachment)}},c.prototype.stop=function(){this._stopTween(),this.path.style.strokeDashoffset=this._getComputedDashOffset()},c.prototype.animate=function(f,h,p){h=h||{},o.isFunction(h)&&(p=h,h={});var _=o.extend({},h),g=o.extend({},this._opts);h=o.extend(g,h);var m=this._easing(h.easing),d=this._resolveFromAndTo(f,m,_);this.stop(),this.path.getBoundingClientRect();var x=this._getComputedDashOffset(),v=this._progressToOffset(f),y=this;this._tweenable=new a,this._tweenable.tween({from:o.extend({offset:x},d.from),to:o.extend({offset:v},d.to),duration:h.duration,delay:h.delay,easing:m,step:function(b){y.path.style.strokeDashoffset=b.offset;var M=h.shape||y;h.step(b,M,h.attachment)}}).then(function(b){o.isFunction(p)&&p()}).catch(function(b){throw console.error("Error in tweening:",b),b})},c.prototype._getComputedDashOffset=function(){var f=window.getComputedStyle(this.path,null);return parseFloat(f.getPropertyValue("stroke-dashoffset"),10)},c.prototype._progressToOffset=function(f){var h=this.path.getTotalLength();return h-f*h},c.prototype._resolveFromAndTo=function(f,h,p){return p.from&&p.to?{from:p.from,to:p.to}:{from:this._calculateFrom(h),to:this._calculateTo(f,h)}},c.prototype._calculateFrom=function(f){return s.interpolate(this._opts.from,this._opts.to,this.value(),f)},c.prototype._calculateTo=function(f,h){return s.interpolate(this._opts.from,this._opts.to,f,h)},c.prototype._stopTween=function(){this._tweenable!==null&&(this._tweenable.stop(!0),this._tweenable=null)},c.prototype._easing=function(f){return l.hasOwnProperty(f)?l[f]:f},n.exports=c},{"./utils":10,shifty:2}],7:[function(t,n,i){var s=t("./shape"),o=t("./circle"),a=t("./utils"),l=function(u,f){this._pathTemplate="M 50,50 m -{radius},0 a {radius},{radius} 0 1 1 {2radius},0",this.containerAspectRatio=2,s.apply(this,arguments)};l.prototype=new s,l.prototype.constructor=l,l.prototype._initializeSvg=function(u,f){u.setAttribute("viewBox","0 0 100 50")},l.prototype._initializeTextContainer=function(u,f,h){u.text.style&&(h.style.top="auto",h.style.bottom="0",u.text.alignToBottom?a.setStyle(h,"transform","translate(-50%, 0)"):a.setStyle(h,"transform","translate(-50%, 50%)"))},l.prototype._pathString=o.prototype._pathString,l.prototype._trailString=o.prototype._trailString,n.exports=l},{"./circle":3,"./shape":8,"./utils":10}],8:[function(t,n,i){var s=t("./path"),o=t("./utils"),a="Object is destroyed",l=function c(u,f){if(!(this instanceof c))throw new Error("Constructor was called without new keyword");if(arguments.length!==0){this._opts=o.extend({color:"#555",strokeWidth:1,trailColor:null,trailWidth:null,fill:null,text:{style:{color:null,position:"absolute",left:"50%",top:"50%",padding:0,margin:0,transform:{prefix:!0,value:"translate(-50%, -50%)"}},autoStyleContainer:!0,alignToBottom:!0,value:null,className:"progressbar-text"},svgStyle:{display:"block",width:"100%"},warnings:!1},f,!0),o.isObject(f)&&f.svgStyle!==void 0&&(this._opts.svgStyle=f.svgStyle),o.isObject(f)&&o.isObject(f.text)&&f.text.style!==void 0&&(this._opts.text.style=f.text.style);var h=this._createSvgView(this._opts),p;if(o.isString(u)?p=document.querySelector(u):p=u,!p)throw new Error("Container does not exist: "+u);this._container=p,this._container.appendChild(h.svg),this._opts.warnings&&this._warnContainerAspectRatio(this._container),this._opts.svgStyle&&o.setStyles(h.svg,this._opts.svgStyle),this.svg=h.svg,this.path=h.path,this.trail=h.trail,this.text=null;var _=o.extend({attachment:void 0,shape:this},this._opts);this._progressPath=new s(h.path,_),o.isObject(this._opts.text)&&this._opts.text.value!==null&&this.setText(this._opts.text.value)}};l.prototype.animate=function(u,f,h){if(this._progressPath===null)throw new Error(a);this._progressPath.animate(u,f,h)},l.prototype.stop=function(){if(this._progressPath===null)throw new Error(a);this._progressPath!==void 0&&this._progressPath.stop()},l.prototype.pause=function(){if(this._progressPath===null)throw new Error(a);this._progressPath!==void 0&&this._progressPath._tweenable&&this._progressPath._tweenable.pause()},l.prototype.resume=function(){if(this._progressPath===null)throw new Error(a);this._progressPath!==void 0&&this._progressPath._tweenable&&this._progressPath._tweenable.resume()},l.prototype.destroy=function(){if(this._progressPath===null)throw new Error(a);this.stop(),this.svg.parentNode.removeChild(this.svg),this.svg=null,this.path=null,this.trail=null,this._progressPath=null,this.text!==null&&(this.text.parentNode.removeChild(this.text),this.text=null)},l.prototype.set=function(u){if(this._progressPath===null)throw new Error(a);this._progressPath.set(u)},l.prototype.value=function(){if(this._progressPath===null)throw new Error(a);return this._progressPath===void 0?0:this._progressPath.value()},l.prototype.setText=function(u){if(this._progressPath===null)throw new Error(a);this.text===null&&(this.text=this._createTextContainer(this._opts,this._container),this._container.appendChild(this.text)),o.isObject(u)?(o.removeChildren(this.text),this.text.appendChild(u)):this.text.innerHTML=u},l.prototype._createSvgView=function(u){var f=document.createElementNS("http://www.w3.org/2000/svg","svg");this._initializeSvg(f,u);var h=null;(u.trailColor||u.trailWidth)&&(h=this._createTrail(u),f.appendChild(h));var p=this._createPath(u);return f.appendChild(p),{svg:f,path:p,trail:h}},l.prototype._initializeSvg=function(u,f){u.setAttribute("viewBox","0 0 100 100")},l.prototype._createPath=function(u){var f=this._pathString(u);return this._createPathElement(f,u)},l.prototype._createTrail=function(u){var f=this._trailString(u),h=o.extend({},u);return h.trailColor||(h.trailColor="#eee"),h.trailWidth||(h.trailWidth=h.strokeWidth),h.color=h.trailColor,h.strokeWidth=h.trailWidth,h.fill=null,this._createPathElement(f,h)},l.prototype._createPathElement=function(u,f){var h=document.createElementNS("http://www.w3.org/2000/svg","path");return h.setAttribute("d",u),h.setAttribute("stroke",f.color),h.setAttribute("stroke-width",f.strokeWidth),f.fill?h.setAttribute("fill",f.fill):h.setAttribute("fill-opacity","0"),h},l.prototype._createTextContainer=function(u,f){var h=document.createElement("div");h.className=u.text.className;var p=u.text.style;return p&&(u.text.autoStyleContainer&&(f.style.position="relative"),o.setStyles(h,p),p.color||(h.style.color=u.color)),this._initializeTextContainer(u,f,h),h},l.prototype._initializeTextContainer=function(c,u,f){},l.prototype._pathString=function(u){throw new Error("Override this function for each progress bar")},l.prototype._trailString=function(u){throw new Error("Override this function for each progress bar")},l.prototype._warnContainerAspectRatio=function(u){if(this.containerAspectRatio){var f=window.getComputedStyle(u,null),h=parseFloat(f.getPropertyValue("width"),10),p=parseFloat(f.getPropertyValue("height"),10);o.floatEquals(this.containerAspectRatio,h/p)||(console.warn("Incorrect aspect ratio of container","#"+u.id,"detected:",f.getPropertyValue("width")+"(width)","/",f.getPropertyValue("height")+"(height)","=",h/p),console.warn("Aspect ratio of should be",this.containerAspectRatio))}},n.exports=l},{"./path":6,"./utils":10}],9:[function(t,n,i){var s=t("./shape"),o=t("./utils"),a=function(c,u){this._pathTemplate="M 0,{halfOfStrokeWidth} L {width},{halfOfStrokeWidth} L {width},{width} L {halfOfStrokeWidth},{width} L {halfOfStrokeWidth},{strokeWidth}",this._trailTemplate="M {startMargin},{halfOfStrokeWidth} L {width},{halfOfStrokeWidth} L {width},{width} L {halfOfStrokeWidth},{width} L {halfOfStrokeWidth},{halfOfStrokeWidth}",s.apply(this,arguments)};a.prototype=new s,a.prototype.constructor=a,a.prototype._pathString=function(c){var u=100-c.strokeWidth/2;return o.render(this._pathTemplate,{width:u,strokeWidth:c.strokeWidth,halfOfStrokeWidth:c.strokeWidth/2})},a.prototype._trailString=function(c){var u=100-c.strokeWidth/2;return o.render(this._trailTemplate,{width:u,strokeWidth:c.strokeWidth,halfOfStrokeWidth:c.strokeWidth/2,startMargin:c.strokeWidth/2-c.trailWidth/2})},n.exports=a},{"./shape":8,"./utils":10}],10:[function(t,n,i){var s=t("lodash.merge"),o="Webkit Moz O ms".split(" "),a=.001;function l(v,y){var b=v;for(var M in y)if(y.hasOwnProperty(M)){var T=y[M],I="\\{"+M+"\\}",S=new RegExp(I,"g");b=b.replace(S,T)}return b}function c(v,y,b){for(var M=v.style,T=0;T{if(o.isMesh){const a=new nb(o);a.attributes=["position","color","normal","tangent","uv","uv2"],a.applyWorldTransforms=!1;const l={strategy:Gf,maxLeafTris:1};let c=new mc(a.generate(),l);return new Mn(a.generate(),o.material),this.result={scene:t.scene,bvh:c,mesh:o},console.log("==> loaded mesh ",e),this.result}});return this.result}}function Bn(r){return new C(r[0],r[1],r[2])}const k={smooth_normals:!0,bounces:6,max_samples:1024,max_volume_steps:8,wireframe:!0,neutral_color:[.5,.5,.5],skyPower:.5,skyColor:[.8,.8,1],sunPower:.35,sunAngularSize:40,sunLatitude:40,sunLongitude:180,sunColor:[1,1,.8],base_weight:1,base_color:[.8,.8,.8],base_roughness:0,base_metalness:0,diffuse_mode:1,specular_weight:1,specular_color:[1,1,1],specular_roughness:.1,specular_anisotropy:0,specular_rotation:0,specular_ior:1.6,transmission_weight:0,transmission_color:[1,1,1],transmission_depth:0,transmission_scatter:[0,0,0],transmission_scatter_anisotropy:0,transmission_dispersion_abbe_number:20,transmission_dispersion_scale:0,subsurface_weight:0,subsurface_color:[.8,.8,.8],subsurface_radius:.2,subsurface_radius_scale:[1,.5,.25],subsurface_anisotropy:0,subsurface_mode:0,coat_weight:0,coat_color:[1,1,1],coat_roughness:0,coat_anisotropy:0,coat_rotation:0,coat_ior:1.3,coat_darkening:1,fuzz_weight:0,fuzz_color:[1,1,1],fuzz_roughness:.5,emission_luminance:0,emission_color:[1,1,1],thin_film_weight:0,thin_film_thickness:1e3,thin_film_ior:1.4,geometry_opacity:1,geometry_thin_walled:!1,reset_camera:function(){vc()}};let qt,Mt,Ot,fr,Gi,as,ma,Qe,Zf,io,cr=0,es,ts,Tl,Al;var _n,gc,_a,Ks,Tb={"OpenPBR (orig, 3-float)":0,"OpenPBR (luminace)":1,"OpenPBR (average)":2,"OpenPBR (max value)":3,"OpenPBR (weighted average)":4,"SPI / Arnold v1":5,"Arnold v2":6,"Uniform scattering":7,"Interfaced van de Hulst":8},Ab={Lambert:0,"ON Qualitative (Mitsuba)":1,"ON Full (Mitsuba)":2,"d'Eon sphere model":3,"Fujii - Qualitative":4,"Fujii - Improved":5,"Fujii - MaterialX":6,"Chan Diffuse (Unreal)":7};Lb();Zs();function Rb(){let r=(90-k.sunLatitude)*Math.PI/180,e=k.sunLongitude*Math.PI/180,t=Math.cos(r),n=Math.sin(r),i=Math.cos(e),s=Math.sin(e),o=n*i,a=n*s,l=t;k.sunDir=[o,l,a]}function Lb(){_n=new wb.Circle("#progress_overlay",{color:"rgba(255, 128, 64, 0.75)",strokeWidth:5,trailColor:"rgba(255, 128, 64, 0.333)",trailWidth:3,svgStyle:{display:"block",width:"100%"},text:{value:"",className:"progressbar__label",style:{color:"rgba(169, 85, 42, 1.0)",position:"absolute",fontWeight:"bold",left:"50%",top:"50%",padding:0,margin:0,transform:{prefix:!0,value:"translate(-50%, -50%)"}},autoStyleContainer:!0,alignToBottom:!0},fill:null,duration:2e3,easing:"linear",from:{color:"rgba( 0, 0, 0, 0.0)"},to:{color:"rgba(32, 255, 32, 1.0)"},warnings:!0}),_n.set(0),_n.setText(""),_a=!1,es=null,ts=null,Tl=null,Al=null,qt=new Pf({antialias:!0,preserveDrawingBuffer:!0}),qt.setPixelRatio(window.devicePixelRatio),qt.setClearColor(594970),qt.setSize(window.innerWidth,window.innerHeight),qt.outputEncoding=Yi,document.body.appendChild(qt.domElement),fr=new x0;const r=new Bf(16777215,1);r.position.set(1,1,1),fr.add(r),fr.add(new Y0(11583173,.5)),as=new qx,document.body.appendChild(as.dom);let e=document.getElementById("samples");e.style.visibility="visible";let t=document.getElementById("info");t.style.visibility="visible",Qe=new Ki({defines:{BOUNCES:k.bounces,MAX_VOLUME_STEPS:k.max_volume_steps,COAT_ENABLED:!1,TRANSMISSION_ENABLED:!1,VOLUME_ENABLED:!1,DISPERSION_ENABLED:!1,THIN_FILM_ENABLED:!1},uniforms:{bvh_surface:{value:new kh},normalAttribute_surface:{value:new Vs},tangentAttribute_surface:{value:new Vs},has_normals_surface:{value:1},has_tangents_surface:{value:0},bvh_props:{value:new kh},normalAttribute_props:{value:new Vs},tangentAttribute_props:{value:new Vs},has_normals_props:{value:1},has_tangents_props:{value:0},cameraWorldMatrix:{value:new Ve},invProjectionMatrix:{value:new Ve},invModelMatrix:{value:new Ve},resolution:{value:new Ue},samples:{value:0},accumulation_weight:{value:1},wireframe:{value:k.wireframe},neutral_color:{value:new C().fromArray(k.neutral_color)},smooth_normals:{value:k.smooth_normals},skyPower:{value:k.skyPower},skyColor:{value:Bn(k.skyColor)},sunPower:{value:Math.pow(10,k.sunPower)},sunAngularSize:{value:k.sunAngularSize},sunColor:{value:Bn(k.sunColor)},sunDir:{value:Bn([0,0,0])},diffuse_mode:{value:k.diffuse_mode},base_weight:{value:k.base_weight},base_color:{value:Bn(k.base_color)},base_roughness:{value:k.base_roughness},base_metalness:{value:k.base_metalness},specular_weight:{value:k.specular_weight},specular_color:{value:Bn(k.specular_color)},specular_roughness:{value:k.specular_roughness},specular_anisotropy:{value:k.specular_anisotropy},specular_rotation:{value:k.specular_rotation},specular_ior:{value:k.specular_ior},transmission_weight:{value:k.transmission_weight},transmission_color:{value:Bn(k.transmission_color)},transmission_depth:{value:k.transmission_depth},transmission_scatter:{value:Bn(k.transmission_scatter)},transmission_scatter_anisotropy:{value:k.transmission_scatter_anisotropy},transmission_dispersion_abbe_number:{value:k.transmission_dispersion_abbe_number},transmission_dispersion_scale:{value:k.transmission_dispersion_scale},subsurface_weight:{value:k.subsurface_weight},subsurface_color:{value:Bn(k.subsurface_color)},subsurface_radius:{value:k.subsurface_radius},subsurface_radius_scale:{value:Bn(k.subsurface_radius_scale)},subsurface_anisotropy:{value:k.subsurface_anisotropy},subsurface_mode:{value:k.subsurface_mode},coat_weight:{value:k.coat_weight},coat_color:{value:Bn(k.coat_color)},coat_roughness:{value:k.coat_roughness},coat_anisotropy:{value:k.coat_anisotropy},coat_rotation:{value:k.coat_rotation},coat_ior:{value:k.coat_ior},coat_darkening:{value:k.coat_darkening},fuzz_weight:{value:k.fuzz_weight},fuzz_color:{value:Bn(k.fuzz_color)},fuzz_roughness:{value:k.fuzz_roughness},emission_luminance:{value:k.emission_luminance},emission_color:{value:Bn(k.emission_color)},thin_film_weight:{value:k.thin_film_weight},thin_film_thickness:{value:k.thin_film_thickness},thin_film_ior:{value:k.thin_film_ior},geometry_opacity:{value:k.geometry_opacity},geometry_thin_walled:{value:k.geometry_thin_walled}},vertexShader:` varying vec2 vUv; void main() { @@ -6804,4 +7027,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho precision highp int; ${Ky} ${Zy} - `+mb+_b+gb+xb+yb+vb+bb+Sb+Eb}),_n.setText("loading meshes..."),_n.animate(.5);const n=new Mb;n.load("standard-shader-ball/neutral_objects.gltf").then(()=>{fr.add(n.result.scene),ts=n.result.mesh,Al=n.result.bvh,Qe.uniforms.bvh_props.value.updateFrom(Al),Qe.uniforms.has_normals_props.value=!1,Qe.uniforms.has_tangents_props.value=!1,ts.geometry.attributes.normal&&(Qe.uniforms.normalAttribute_props.value.updateFrom(ts.geometry.attributes.normal),Qe.uniforms.has_normals_props.value=!0),ts.geometry.attributes.tangent&&(Qe.uniforms.tangentAttribute_props.value.updateFrom(ts.geometry.attributes.tangent),Qe.uniforms.has_tangents_props.value=!0),console.log(" has_normals_scene: ",Qe.uniforms.has_normals_props),console.log(" has_tangents_scene: ",Qe.uniforms.has_tangents_props),_n.animate(.75),n.reset(),n.load("standard-shader-ball/shaderball.gltf").then(()=>{fr.add(n.result.scene),es=n.result.mesh,Tl=n.result.bvh,Qe.uniforms.bvh_surface.value.updateFrom(Tl),Qe.uniforms.has_normals_surface.value=!1,Qe.uniforms.has_tangents_surface.value=!1,es.geometry.attributes.normal&&(Qe.uniforms.normalAttribute_surface.value.updateFrom(es.geometry.attributes.normal),Qe.uniforms.has_normals_surface.value=!0),es.geometry.attributes.tangent&&(Qe.uniforms.tangentAttribute_surface.value.updateFrom(es.geometry.attributes.tangent),Qe.uniforms.has_tangents_surface.value=!0),console.log(" has_normals_surface: ",Qe.uniforms.has_normals_surface),console.log(" has_tangents_surface: ",Qe.uniforms.has_tangents_surface),console.log("===> LOADED"),_a=!0,Lb(),_n.animate(1),document.getElementById("progress_overlay"),gc=performance.now()})})}function vc(){let r=23.6701655,e=.01,t=1e3;Mt=new gn(r,window.innerWidth/window.innerHeight,e,t),Ot=new ox(Mt,qt.domElement),Ot.addEventListener("change",()=>{Pe()});let n=new Ve;n.set(.9396926207859084,0,-.3420201433256687,0,-.2203032561704394,.7649214009184319,-.6052782217606094,0,.26161852717499334,.6441236297613865,.7187909959242699,0,6.531538924716362,19.5,17.948521838355774,1),n.transpose(),Mt.matrixAutoUpdate=!1,Mt.applyMatrix4(n),Mt.matrixAutoUpdate=!0,Mt.updateMatrixWorld();let i=new C;Mt.getWorldDirection(i);let s=Mt.position.clone();s.addScaledVector(i,23.39613),Ot.target.copy(s),Ot.zoomSpeed=1.5,Ot.flySpeed=.01,Ot.update()}function jh(){return k.coat_weight!=0}function ki(){return k.base_metalness==1?!1:k.transmission_weight>0&&k.transmission_depth>0||k.subsurface_weight>0}function ia(){return k.transmission_weight>0||k.subsurface_weight>0}function Yh(){return k.transmission_dispersion_scale>0}function $h(){return k.thin_film_weight>0}function Lb(){ma=new gh(Qe),Qe.transparent=!0,Qe.depthWrite=!1,io=new $i(1,1,{format:sn,type:vn}),Zf=new gh(new Wi({map:io.texture})),zn(),vc(),Gi=new _c({width:300});const r=Gi.addFolder("Material"),e=r.addFolder("Base");e.add(k,"base_weight",0,1).onChange(h=>{Pe()}),e.addColor(k,"base_color").onChange(h=>{Pe()}),e.add(k,"base_roughness",0,1).onChange(h=>{Pe()}),e.add(k,"base_metalness",0,1).onChange(h=>{Pe(),ki()!=Qe.defines.VOLUME_ENABLED&&(Qe.defines.VOLUME_ENABLED=ki(),zn())});const t=r.addFolder("Specular");t.add(k,"specular_weight",0,1).onChange(h=>{Pe()}),t.addColor(k,"specular_color").onChange(h=>{Pe()}),t.add(k,"specular_roughness",0,1).onChange(h=>{Pe()}),t.add(k,"specular_ior",1,5).onChange(h=>{Pe()}),t.add(k,"specular_anisotropy",0,1).onChange(h=>{Pe()}),t.add(k,"specular_rotation",0,1).onChange(h=>{Pe()});const n=r.addFolder("Transmission");n.add(k,"transmission_weight",0,1).onChange(h=>{Pe(),ki()!=Qe.defines.VOLUME_ENABLED&&(Qe.defines.VOLUME_ENABLED=ki(),zn()),ia()!=Qe.defines.TRANSMISSION_ENABLED&&(Qe.defines.TRANSMISSION_ENABLED=ia(),zn())}),n.addColor(k,"transmission_color").onChange(h=>{Pe()}),n.add(k,"transmission_depth",0,1).onChange(h=>{Pe(),ki()!=Qe.defines.VOLUME_ENABLED&&(Qe.defines.VOLUME_ENABLED=ki(),zn())}),n.addColor(k,"transmission_scatter").onChange(h=>{Pe()}),n.add(k,"transmission_scatter_anisotropy",-1,1).onChange(h=>{Pe()}),n.add(k,"transmission_dispersion_abbe_number",9,91).onChange(h=>{Pe()}),n.add(k,"transmission_dispersion_scale",0,1).onChange(h=>{Pe(),Yh()!=Qe.defines.DISPERSION_ENABLED&&(Qe.defines.DISPERSION_ENABLED=Yh(),zn())}),n.close();const i=r.addFolder("Subsurface");i.add(k,"subsurface_weight",0,1).onChange(h=>{Pe(),ki()!=Qe.defines.VOLUME_ENABLED&&(Qe.defines.VOLUME_ENABLED=ki(),zn()),ia()!=Qe.defines.TRANSMISSION_ENABLED&&(Qe.defines.TRANSMISSION_ENABLED=ia(),zn())}),i.addColor(k,"subsurface_color").onChange(h=>{Pe()}),i.add(k,"subsurface_radius",0,1).onChange(h=>{Pe()}),i.addColor(k,"subsurface_radius_scale").onChange(h=>{Pe()}),i.add(k,"subsurface_anisotropy",-1,1).onChange(h=>{Pe()}),i.add(k,"subsurface_mode",Tb).onChange(h=>{Pe()}),i.close();const s=r.addFolder("Coat");s.add(k,"coat_weight",0,1).onChange(h=>{Pe(),jh()!=Qe.defines.COAT_ENABLED&&(Qe.defines.COAT_ENABLED=jh(),zn())}),s.addColor(k,"coat_color").onChange(h=>{Pe()}),s.add(k,"coat_roughness",0,1).onChange(h=>{Pe()}),s.add(k,"coat_ior",1,3).onChange(h=>{Pe()}),s.add(k,"coat_anisotropy",0,1).onChange(h=>{Pe()}),s.add(k,"coat_rotation",0,1).onChange(h=>{Pe()}),s.add(k,"coat_darkening",0,1).onChange(h=>{Pe()}),s.close();const o=r.addFolder("Fuzz");o.add(k,"fuzz_weight",0,1).onChange(h=>{Pe()}),o.addColor(k,"fuzz_color").onChange(h=>{Pe()}),o.add(k,"fuzz_roughness",0,1).onChange(h=>{Pe()}),o.close();const a=r.addFolder("Emission");a.add(k,"emission_luminance",0,10).onChange(h=>{Pe()}),a.addColor(k,"emission_color").onChange(h=>{Pe()}),a.close();const l=r.addFolder("Thin Film");l.add(k,"thin_film_weight",0,1).onChange(h=>{Pe(),$h()!=Qe.defines.THIN_FILM_ENABLED&&(Qe.defines.THIN_FILM_ENABLED=$h(),zn())}),l.add(k,"thin_film_thickness",0,2e3).onChange(h=>{Pe()}),l.add(k,"thin_film_ior",1,3).onChange(h=>{Pe()}),l.close();const c=r.addFolder("Geometry");c.add(k,"geometry_opacity",0,1).onChange(h=>{Pe()}),c.add(k,"geometry_thin_walled").onChange(h=>{Pe()}),c.close();const u=Gi.addFolder("Lighting");u.add(k,"skyPower",0,2).onChange(h=>{Pe()}),u.addColor(k,"skyColor").onChange(h=>{Pe()}),u.add(k,"sunPower",-4,4).onChange(h=>{Pe()}),u.add(k,"sunAngularSize",0,40).onChange(h=>{Pe()}),u.add(k,"sunLatitude",0,90).onChange(h=>{Pe()}),u.add(k,"sunLongitude",0,360).onChange(h=>{Pe()}),u.addColor(k,"sunColor").onChange(h=>{Pe()}),u.close();const f=Gi.addFolder("Renderer");f.add(k,"smooth_normals").onChange(h=>{Pe()}),f.add(k,"wireframe").onChange(h=>{Pe()}),f.addColor(k,"neutral_color").onChange(h=>{Pe()}),f.add(k,"bounces",1,16,1).onChange(h=>{Qe.defines.BOUNCES=parseInt(h),Pe(),zn()}),f.add(k,"max_samples").onChange(h=>{Pe()}),f.add(k,"max_volume_steps",1,256,1).onChange(h=>{Qe.defines.MAX_VOLUME_STEPS=parseInt(h),Pe(),zn()}),f.close(),Gi.add(k,"reset_camera"),Gi.open(),window.addEventListener("resize",Kh,!1),Kh()}function zn(){qt.setRenderTarget(io);let r=new oo(-1,1,1,-1,0,1);Cb(),qt.compileAsync(ma._mesh,r).then(t=>{console.log("shaders successfully compiled."),Pb()}).catch(t=>{console.log("shader compilation error: "+t)}).finally(()=>{})}function Cb(){let r=document.getElementById("progress_overlay");r.style.display="block",r.style.opacity=1,_n.set(0),_n.setText("shaders compiling..."),Ks=!0}function Pb(){_n.set(1),gc=performance.now(),Ks=!1}function Kh(){Mt.aspect=window.innerWidth/window.innerHeight,Mt.updateProjectionMatrix();const r=window.innerWidth,e=window.innerHeight;qt.setSize(r,e),qt.setPixelRatio(1),io.setSize(r,e),Pe()}function Pn(r){return new C(r[0],r[1],r[2])}function Pe(){Qe&&(Qe.needsUpdate=!0),cr=0}function Db(r){let e=document.getElementById("progress_overlay");var t=setInterval(function(){e.style.opacity||(e.style.opacity=1),e.style.opacity>0?e.style.opacity-=.025:(e.style.display="none",e.style.opacity=0,clearInterval(t))},r)}function Zs(){if(!_a){console.log("not LOADED"),requestAnimationFrame(Zs);return}if(qt.domElement.style.imageRendering="auto",cr>=k.max_samples){requestAnimationFrame(Zs);return}if(!Ks&&_a){Mt.updateMatrixWorld();const r=ma.material.uniforms,e=window.innerWidth,t=window.innerHeight;r.cameraWorldMatrix.value.copy(Mt.matrixWorld),r.invProjectionMatrix.value.copy(Mt.projectionMatrixInverse),r.invModelMatrix.value.copy(fr.matrixWorld).invert();let n=new Ue(e,t);r.resolution.value.copy(n),r.accumulation_weight.value=1/(cr+1),r.samples.value=cr,r.wireframe.value=k.wireframe,r.neutral_color.value.copy(Pn(k.neutral_color)),r.smooth_normals.value=k.smooth_normals,r.base_weight.value=k.base_weight,r.base_color.value.copy(Pn(k.base_color)),r.base_roughness.value=k.base_roughness,r.base_metalness.value=k.base_metalness,r.specular_weight.value=k.specular_weight,r.specular_color.value.copy(Pn(k.specular_color)),r.specular_roughness.value=k.specular_roughness,r.specular_anisotropy.value=k.specular_anisotropy,r.specular_rotation.value=k.specular_rotation,r.specular_ior.value=k.specular_ior,r.transmission_weight.value=k.transmission_weight,r.transmission_color.value.copy(Pn(k.transmission_color)),r.transmission_depth.value=k.transmission_depth,r.transmission_scatter.value.copy(Pn(k.transmission_scatter)),r.transmission_scatter_anisotropy.value=k.transmission_scatter_anisotropy,r.transmission_dispersion_abbe_number.value=k.transmission_dispersion_abbe_number,r.transmission_dispersion_scale.value=k.transmission_dispersion_scale,r.subsurface_weight.value=k.subsurface_weight,r.subsurface_color.value.copy(Pn(k.subsurface_color)),r.subsurface_radius.value=k.subsurface_radius,r.subsurface_radius_scale.value.copy(Pn(k.subsurface_radius_scale)),r.subsurface_anisotropy.value=k.subsurface_anisotropy,r.subsurface_mode.value=k.subsurface_mode,r.coat_weight.value=k.coat_weight,r.coat_color.value.copy(Pn(k.coat_color)),r.coat_roughness.value=k.coat_roughness,r.coat_anisotropy.value=k.coat_anisotropy,r.coat_rotation.value=k.coat_rotation,r.coat_ior.value=k.coat_ior,r.coat_darkening.value=k.coat_darkening,r.fuzz_weight.value=k.fuzz_weight,r.fuzz_color.value.copy(Pn(k.fuzz_color)),r.fuzz_roughness.value=k.fuzz_roughness,r.emission_luminance.value=k.emission_luminance,r.emission_color.value.copy(Pn(k.emission_color)),r.thin_film_weight.value=k.thin_film_weight,r.thin_film_thickness.value=k.thin_film_thickness,r.thin_film_ior.value=k.thin_film_ior,r.geometry_opacity.value=k.geometry_opacity,r.geometry_thin_walled.value=k.geometry_thin_walled,r.skyPower.value=k.skyPower,r.skyColor.value.copy(Pn(k.skyColor)),r.sunPower.value=Math.pow(10,k.sunPower),r.sunAngularSize.value=k.sunAngularSize,r.sunColor.value.copy(Pn(k.sunColor)),Ab(),r.sunDir.value.copy(Pn(k.sunDir)),qt.autoClear=cr===0,qt.setRenderTarget(io),ma.render(qt),qt.setRenderTarget(null),Zf.render(qt),qt.autoClear=!0,cr++}else Pe(),Mt.updateProjectionMatrix(),Mt.clearViewOffset(),qt.render(fr,Mt);document.getElementById("samples").innerText=`samples: ${cr}`,Ks||document.getElementById("progress_overlay").style.display!="none"&&performance.now()-gc>300&&Db(300),Ks&&(_n.value()<.01?_n.animate(1):_n.value()>.99&&(_n.set(0),_n.animate(1))),as.update(),requestAnimationFrame(Zs)}document.onkeydown=function(r){r=r||window.event;var e=r.which?r.which:r.keyCode;switch(e){case 122:{var t=document.body;"webkitCancelFullScreen"in document?t.webkitRequestFullScreen():"mozCancelFullScreen"in document?t.mozRequestFullScreen():console.assert(!1),Ot.update(),Pe();break}case 70:{vc();break}case 72:{Gi.show(Gi._hidden),document.body.contains(as.dom)?document.body.removeChild(as.dom):document.body.appendChild(as.dom);let a=document.getElementById("info");a.style.visibility=="visible"?a.style.visibility="hidden":a.style.visibility="visible";let l=document.getElementById("samples");l.style.visibility=="visible"?l.style.visibility="hidden":l.style.visibility="visible";break}case 87:{let a=new C;a.copy(Ot.target),a.sub(Mt.position);let l=a.length();a.normalize();var n=new C;n.copy(a),n.multiplyScalar(Ot.flySpeed*l),Mt.position.add(n),Ot.target.add(n),Ot.update(),Pe();break}case 65:{let a=new C;a.copy(Ot.target),a.sub(Mt.position);let l=a.length();var i=new C(1,0,0),s=i.transformDirection(Mt.matrix),n=new C;n.copy(s),n.multiplyScalar(-Ot.flySpeed*l),Mt.position.add(n),Ot.target.add(n),Ot.update(),Pe();break}case 83:{let a=new C;a.copy(Ot.target),a.sub(Mt.position);let l=a.length();a.normalize();var n=new C;n.copy(a),n.multiplyScalar(-Ot.flySpeed*l),Mt.position.add(n),Ot.target.add(n),Ot.update(),Pe();break}case 68:{let a=new C;a.copy(Ot.target),a.sub(Mt.position);let l=a.length();var i=new C(1,0,0),s=i.transformDirection(Mt.matrix),n=new C;n.copy(s),n.multiplyScalar(Ot.flySpeed*l),Mt.position.add(n),Ot.target.add(n),Ot.update(),Pe();break}case 80:{var o=document.createElement("a");let a="openpbr-example-screenshot.png";o.download=a,qt.domElement.toBlob(function(l){o.href=URL.createObjectURL(l);var c=new MouseEvent("click");o.dispatchEvent(c),requestAnimationFrame(Zs)},"image/png",1);break}}}; + `+mb+_b+gb+xb+yb+vb+bb+Sb+Eb}),_n.setText("loading meshes..."),_n.animate(.5);const n=new Mb;n.load("standard-shader-ball/neutral_objects.gltf").then(()=>{fr.add(n.result.scene),ts=n.result.mesh,Al=n.result.bvh,Qe.uniforms.bvh_props.value.updateFrom(Al),Qe.uniforms.has_normals_props.value=!1,Qe.uniforms.has_tangents_props.value=!1,ts.geometry.attributes.normal&&(Qe.uniforms.normalAttribute_props.value.updateFrom(ts.geometry.attributes.normal),Qe.uniforms.has_normals_props.value=!0),ts.geometry.attributes.tangent&&(Qe.uniforms.tangentAttribute_props.value.updateFrom(ts.geometry.attributes.tangent),Qe.uniforms.has_tangents_props.value=!0),console.log(" has_normals_scene: ",Qe.uniforms.has_normals_props),console.log(" has_tangents_scene: ",Qe.uniforms.has_tangents_props),_n.animate(.75),n.reset(),n.load("standard-shader-ball/shaderball.gltf").then(()=>{fr.add(n.result.scene),es=n.result.mesh,Tl=n.result.bvh,Qe.uniforms.bvh_surface.value.updateFrom(Tl),Qe.uniforms.has_normals_surface.value=!1,Qe.uniforms.has_tangents_surface.value=!1,es.geometry.attributes.normal&&(Qe.uniforms.normalAttribute_surface.value.updateFrom(es.geometry.attributes.normal),Qe.uniforms.has_normals_surface.value=!0),es.geometry.attributes.tangent&&(Qe.uniforms.tangentAttribute_surface.value.updateFrom(es.geometry.attributes.tangent),Qe.uniforms.has_tangents_surface.value=!0),console.log(" has_normals_surface: ",Qe.uniforms.has_normals_surface),console.log(" has_tangents_surface: ",Qe.uniforms.has_tangents_surface),console.log("===> LOADED"),_a=!0,Cb(),_n.animate(1),document.getElementById("progress_overlay"),gc=performance.now()})})}function vc(){let r=23.6701655,e=.01,t=1e3;Mt=new gn(r,window.innerWidth/window.innerHeight,e,t),Ot=new ox(Mt,qt.domElement),Ot.addEventListener("change",()=>{Le()});let n=new Ve;n.set(.9396926207859084,0,-.3420201433256687,0,-.2203032561704394,.7649214009184319,-.6052782217606094,0,.26161852717499334,.6441236297613865,.7187909959242699,0,6.531538924716362,19.5,17.948521838355774,1),n.transpose(),Mt.matrixAutoUpdate=!1,Mt.applyMatrix4(n),Mt.matrixAutoUpdate=!0,Mt.updateMatrixWorld();let i=new C;Mt.getWorldDirection(i);let s=Mt.position.clone();s.addScaledVector(i,23.39613),Ot.target.copy(s),Ot.zoomSpeed=1.5,Ot.flySpeed=.01,Ot.update()}function jh(){return k.coat_weight!=0}function ki(){return k.base_metalness==1?!1:k.transmission_weight>0&&k.transmission_depth>0||k.subsurface_weight>0}function ia(){return k.transmission_weight>0||k.subsurface_weight>0}function Yh(){return k.transmission_dispersion_scale>0}function $h(){return k.thin_film_weight>0}function Cb(){ma=new gh(Qe),Qe.transparent=!0,Qe.depthWrite=!1,io=new $i(1,1,{format:sn,type:vn}),Zf=new gh(new Wi({map:io.texture})),zn(),vc(),Gi=new _c({width:300});const r=Gi.addFolder("Material"),e=r.addFolder("Base");e.add(k,"base_weight",0,1).onChange(h=>{Le()}),e.addColor(k,"base_color").onChange(h=>{Le()}),e.add(k,"base_roughness",0,1).onChange(h=>{Le()}),e.add(k,"base_metalness",0,1).onChange(h=>{Le(),ki()!=Qe.defines.VOLUME_ENABLED&&(Qe.defines.VOLUME_ENABLED=ki(),zn())}),e.add(k,"diffuse_mode",Ab).onChange(h=>{Le()});const t=r.addFolder("Specular");t.add(k,"specular_weight",0,1).onChange(h=>{Le()}),t.addColor(k,"specular_color").onChange(h=>{Le()}),t.add(k,"specular_roughness",0,1).onChange(h=>{Le()}),t.add(k,"specular_ior",1,5).onChange(h=>{Le()}),t.add(k,"specular_anisotropy",0,1).onChange(h=>{Le()}),t.add(k,"specular_rotation",0,1).onChange(h=>{Le()});const n=r.addFolder("Transmission");n.add(k,"transmission_weight",0,1).onChange(h=>{Le(),ki()!=Qe.defines.VOLUME_ENABLED&&(Qe.defines.VOLUME_ENABLED=ki(),zn()),ia()!=Qe.defines.TRANSMISSION_ENABLED&&(Qe.defines.TRANSMISSION_ENABLED=ia(),zn())}),n.addColor(k,"transmission_color").onChange(h=>{Le()}),n.add(k,"transmission_depth",0,1).onChange(h=>{Le(),ki()!=Qe.defines.VOLUME_ENABLED&&(Qe.defines.VOLUME_ENABLED=ki(),zn())}),n.addColor(k,"transmission_scatter").onChange(h=>{Le()}),n.add(k,"transmission_scatter_anisotropy",-1,1).onChange(h=>{Le()}),n.add(k,"transmission_dispersion_abbe_number",9,91).onChange(h=>{Le()}),n.add(k,"transmission_dispersion_scale",0,1).onChange(h=>{Le(),Yh()!=Qe.defines.DISPERSION_ENABLED&&(Qe.defines.DISPERSION_ENABLED=Yh(),zn())}),n.close();const i=r.addFolder("Subsurface");i.add(k,"subsurface_weight",0,1).onChange(h=>{Le(),ki()!=Qe.defines.VOLUME_ENABLED&&(Qe.defines.VOLUME_ENABLED=ki(),zn()),ia()!=Qe.defines.TRANSMISSION_ENABLED&&(Qe.defines.TRANSMISSION_ENABLED=ia(),zn())}),i.addColor(k,"subsurface_color").onChange(h=>{Le()}),i.add(k,"subsurface_radius",0,1).onChange(h=>{Le()}),i.addColor(k,"subsurface_radius_scale").onChange(h=>{Le()}),i.add(k,"subsurface_anisotropy",-1,1).onChange(h=>{Le()}),i.add(k,"subsurface_mode",Tb).onChange(h=>{Le()}),i.close();const s=r.addFolder("Coat");s.add(k,"coat_weight",0,1).onChange(h=>{Le(),jh()!=Qe.defines.COAT_ENABLED&&(Qe.defines.COAT_ENABLED=jh(),zn())}),s.addColor(k,"coat_color").onChange(h=>{Le()}),s.add(k,"coat_roughness",0,1).onChange(h=>{Le()}),s.add(k,"coat_ior",1,3).onChange(h=>{Le()}),s.add(k,"coat_anisotropy",0,1).onChange(h=>{Le()}),s.add(k,"coat_rotation",0,1).onChange(h=>{Le()}),s.add(k,"coat_darkening",0,1).onChange(h=>{Le()}),s.close();const o=r.addFolder("Fuzz");o.add(k,"fuzz_weight",0,1).onChange(h=>{Le()}),o.addColor(k,"fuzz_color").onChange(h=>{Le()}),o.add(k,"fuzz_roughness",0,1).onChange(h=>{Le()}),o.close();const a=r.addFolder("Emission");a.add(k,"emission_luminance",0,10).onChange(h=>{Le()}),a.addColor(k,"emission_color").onChange(h=>{Le()}),a.close();const l=r.addFolder("Thin Film");l.add(k,"thin_film_weight",0,1).onChange(h=>{Le(),$h()!=Qe.defines.THIN_FILM_ENABLED&&(Qe.defines.THIN_FILM_ENABLED=$h(),zn())}),l.add(k,"thin_film_thickness",0,2e3).onChange(h=>{Le()}),l.add(k,"thin_film_ior",1,3).onChange(h=>{Le()}),l.close();const c=r.addFolder("Geometry");c.add(k,"geometry_opacity",0,1).onChange(h=>{Le()}),c.add(k,"geometry_thin_walled").onChange(h=>{Le()}),c.close();const u=Gi.addFolder("Lighting");u.add(k,"skyPower",0,2).onChange(h=>{Le()}),u.addColor(k,"skyColor").onChange(h=>{Le()}),u.add(k,"sunPower",-4,4).onChange(h=>{Le()}),u.add(k,"sunAngularSize",0,40).onChange(h=>{Le()}),u.add(k,"sunLatitude",0,90).onChange(h=>{Le()}),u.add(k,"sunLongitude",0,360).onChange(h=>{Le()}),u.addColor(k,"sunColor").onChange(h=>{Le()}),u.close();const f=Gi.addFolder("Renderer");f.add(k,"smooth_normals").onChange(h=>{Le()}),f.add(k,"wireframe").onChange(h=>{Le()}),f.addColor(k,"neutral_color").onChange(h=>{Le()}),f.add(k,"bounces",0,100,1).onChange(h=>{Qe.defines.BOUNCES=parseInt(h),Le(),zn()}),f.add(k,"max_samples").onChange(h=>{Le()}),f.add(k,"max_volume_steps",1,100,1).onChange(h=>{Qe.defines.MAX_VOLUME_STEPS=parseInt(h),Le(),zn()}),f.close(),Gi.add(k,"reset_camera"),Gi.open(),window.addEventListener("resize",Kh,!1),Kh()}function zn(){qt.setRenderTarget(io);let r=new oo(-1,1,1,-1,0,1);Pb(),qt.compileAsync(ma._mesh,r).then(t=>{console.log("shaders successfully compiled."),Db()}).catch(t=>{console.log("shader compilation error: "+t)}).finally(()=>{})}function Pb(){let r=document.getElementById("progress_overlay");r.style.display="block",r.style.opacity=1,_n.set(0),_n.setText("shaders compiling..."),Ks=!0}function Db(){_n.set(1),gc=performance.now(),Ks=!1}function Kh(){Mt.aspect=window.innerWidth/window.innerHeight,Mt.updateProjectionMatrix();const r=window.innerWidth,e=window.innerHeight;qt.setSize(r,e),qt.setPixelRatio(1),io.setSize(r,e),Le()}function Pn(r){return new C(r[0],r[1],r[2])}function Le(){Qe&&(Qe.needsUpdate=!0),cr=0}function Ib(r){let e=document.getElementById("progress_overlay");var t=setInterval(function(){e.style.opacity||(e.style.opacity=1),e.style.opacity>0?e.style.opacity-=.025:(e.style.display="none",e.style.opacity=0,clearInterval(t))},r)}function Zs(){if(!_a){console.log("not LOADED"),requestAnimationFrame(Zs);return}if(qt.domElement.style.imageRendering="auto",cr>=k.max_samples){requestAnimationFrame(Zs);return}if(!Ks&&_a){Mt.updateMatrixWorld();const r=ma.material.uniforms,e=window.innerWidth,t=window.innerHeight;r.cameraWorldMatrix.value.copy(Mt.matrixWorld),r.invProjectionMatrix.value.copy(Mt.projectionMatrixInverse),r.invModelMatrix.value.copy(fr.matrixWorld).invert();let n=new Ue(e,t);r.resolution.value.copy(n),r.accumulation_weight.value=1/(cr+1),r.samples.value=cr,r.wireframe.value=k.wireframe,r.neutral_color.value.copy(Pn(k.neutral_color)),r.smooth_normals.value=k.smooth_normals,r.base_weight.value=k.base_weight,r.base_color.value.copy(Pn(k.base_color)),r.base_roughness.value=k.base_roughness,r.base_metalness.value=k.base_metalness,r.diffuse_mode.value=k.diffuse_mode,r.specular_weight.value=k.specular_weight,r.specular_color.value.copy(Pn(k.specular_color)),r.specular_roughness.value=k.specular_roughness,r.specular_anisotropy.value=k.specular_anisotropy,r.specular_rotation.value=k.specular_rotation,r.specular_ior.value=k.specular_ior,r.transmission_weight.value=k.transmission_weight,r.transmission_color.value.copy(Pn(k.transmission_color)),r.transmission_depth.value=k.transmission_depth,r.transmission_scatter.value.copy(Pn(k.transmission_scatter)),r.transmission_scatter_anisotropy.value=k.transmission_scatter_anisotropy,r.transmission_dispersion_abbe_number.value=k.transmission_dispersion_abbe_number,r.transmission_dispersion_scale.value=k.transmission_dispersion_scale,r.subsurface_weight.value=k.subsurface_weight,r.subsurface_color.value.copy(Pn(k.subsurface_color)),r.subsurface_radius.value=k.subsurface_radius,r.subsurface_radius_scale.value.copy(Pn(k.subsurface_radius_scale)),r.subsurface_anisotropy.value=k.subsurface_anisotropy,r.subsurface_mode.value=k.subsurface_mode,r.coat_weight.value=k.coat_weight,r.coat_color.value.copy(Pn(k.coat_color)),r.coat_roughness.value=k.coat_roughness,r.coat_anisotropy.value=k.coat_anisotropy,r.coat_rotation.value=k.coat_rotation,r.coat_ior.value=k.coat_ior,r.coat_darkening.value=k.coat_darkening,r.fuzz_weight.value=k.fuzz_weight,r.fuzz_color.value.copy(Pn(k.fuzz_color)),r.fuzz_roughness.value=k.fuzz_roughness,r.emission_luminance.value=k.emission_luminance,r.emission_color.value.copy(Pn(k.emission_color)),r.thin_film_weight.value=k.thin_film_weight,r.thin_film_thickness.value=k.thin_film_thickness,r.thin_film_ior.value=k.thin_film_ior,r.geometry_opacity.value=k.geometry_opacity,r.geometry_thin_walled.value=k.geometry_thin_walled,r.skyPower.value=k.skyPower,r.skyColor.value.copy(Pn(k.skyColor)),r.sunPower.value=Math.pow(10,k.sunPower),r.sunAngularSize.value=k.sunAngularSize,r.sunColor.value.copy(Pn(k.sunColor)),Rb(),r.sunDir.value.copy(Pn(k.sunDir)),qt.autoClear=cr===0,qt.setRenderTarget(io),ma.render(qt),qt.setRenderTarget(null),Zf.render(qt),qt.autoClear=!0,cr++}else Le(),Mt.updateProjectionMatrix(),Mt.clearViewOffset(),qt.render(fr,Mt);document.getElementById("samples").innerText=`samples: ${cr}`,Ks||document.getElementById("progress_overlay").style.display!="none"&&performance.now()-gc>300&&Ib(300),Ks&&(_n.value()<.01?_n.animate(1):_n.value()>.99&&(_n.set(0),_n.animate(1))),as.update(),requestAnimationFrame(Zs)}document.onkeydown=function(r){r=r||window.event;var e=r.which?r.which:r.keyCode;switch(e){case 122:{var t=document.body;"webkitCancelFullScreen"in document?t.webkitRequestFullScreen():"mozCancelFullScreen"in document?t.mozRequestFullScreen():console.assert(!1),Ot.update(),Le();break}case 70:{vc();break}case 72:{Gi.show(Gi._hidden),document.body.contains(as.dom)?document.body.removeChild(as.dom):document.body.appendChild(as.dom);let a=document.getElementById("info");a.style.visibility=="visible"?a.style.visibility="hidden":a.style.visibility="visible";let l=document.getElementById("samples");l.style.visibility=="visible"?l.style.visibility="hidden":l.style.visibility="visible";break}case 87:{let a=new C;a.copy(Ot.target),a.sub(Mt.position);let l=a.length();a.normalize();var n=new C;n.copy(a),n.multiplyScalar(Ot.flySpeed*l),Mt.position.add(n),Ot.target.add(n),Ot.update(),Le();break}case 65:{let a=new C;a.copy(Ot.target),a.sub(Mt.position);let l=a.length();var i=new C(1,0,0),s=i.transformDirection(Mt.matrix),n=new C;n.copy(s),n.multiplyScalar(-Ot.flySpeed*l),Mt.position.add(n),Ot.target.add(n),Ot.update(),Le();break}case 83:{let a=new C;a.copy(Ot.target),a.sub(Mt.position);let l=a.length();a.normalize();var n=new C;n.copy(a),n.multiplyScalar(-Ot.flySpeed*l),Mt.position.add(n),Ot.target.add(n),Ot.update(),Le();break}case 68:{let a=new C;a.copy(Ot.target),a.sub(Mt.position);let l=a.length();var i=new C(1,0,0),s=i.transformDirection(Mt.matrix),n=new C;n.copy(s),n.multiplyScalar(Ot.flySpeed*l),Mt.position.add(n),Ot.target.add(n),Ot.update(),Le();break}case 80:{var o=document.createElement("a");let a="openpbr-example-screenshot.png";o.download=a,qt.domElement.toBlob(function(l){o.href=URL.createObjectURL(l);var c=new MouseEvent("click");o.dispatchEvent(c),requestAnimationFrame(Zs)},"image/png",1);break}}}; diff --git a/index.html b/index.html index c5b4bb6..5b61cdf 100644 --- a/index.html +++ b/index.html @@ -63,7 +63,7 @@ overflow:hidden; } - +