diff --git a/public/dist/ATON.min.js b/public/dist/ATON.min.js index 02bab486..ad8940f5 100644 --- a/public/dist/ATON.min.js +++ b/public/dist/ATON.min.js @@ -1,2 +1,2 @@ /*! For license information please see ATON.min.js.LICENSE.txt */ -(()=>{"use strict";class e extends THREE.Group{constructor(e,t){super(),this.type=t||ATON.NTYPES.SCENE,this.enablePicking(),this.type===ATON.NTYPES.SCENE&&(this._rootG=ATON._rootVisible,this._nodes=ATON.snodes),this.type===ATON.NTYPES.SEM&&(this._rootG=ATON._rootSem,this._nodes=ATON.semnodes),this.type===ATON.NTYPES.UI&&(this._rootG=ATON._rootUI,this._nodes=ATON.uinodes),this.as(e),this.kwords=void 0,this._bCloneOnLoadHit=!0,this._tlist=void 0,this._aniMixers=void 0,this.castShadow=!1,this.receiveShadow=!1,this._bs=new THREE.Sphere,this.autocenter=!1,this.onHover=void 0,this.onLeave=void 0,this.onSelect=void 0}as(e){if(void 0!==e&&e!==ATON.ROOT_NID)return this._nodes[e]=this,this.nid=e,this.name=e,this}setAsRoot(){return this._nodes[ATON.ROOT_NID]=this,this.nid=ATON.ROOT_NID,this}setCloneOnLoadHit(e){return this._bCloneOnLoadHit=e,this}addKeywords(e){let t=e.split(",");void 0===this.kwords&&(this.kwords={});for(let e in t){let o=t[e].trim();o.length>0&&(this.kwords[o]=!0)}for(let t in this.children){let o=this.children[t];void 0!==o.type&&o.addKeywords(e)}return this}hasKeyword(e){if(void 0!==this.kwords)return void 0!==this.kwords[e]}setDescription(e){return this.userData.description=e,this}getDescription(){return this.userData.description}setAudio(e){return this.userData.audio=e,this}getAudio(){return this.userData.audio}hide(){return this.visible=!1,ATON.Utils.setPicking(this,this.type,!1),ATON._renderer.shadowMap.enabled&&(ATON._dMainL.shadow.needsUpdate=!0),this}show(){return this.visible=!0,ATON.Utils.setPicking(this,this.type,this.bPickable),ATON._renderer.shadowMap.enabled&&void 0!==ATON._dMainL&&void 0!==ATON._dMainL.shadow&&(ATON._dMainL.shadow.needsUpdate=!0),this}toggle(e){return void 0===e?this.visible?this.hide():this.show():e?this.show():this.hide()}disablePicking(){return this.bPickable=!1,ATON.Utils.setPicking(this,this.type,this.bPickable),this}enablePicking(){return this.bPickable=!0,ATON.Utils.setPicking(this,this.type,this.bPickable),this}setPickable(e){return e?this.enablePicking():this.disablePicking(),this}setMaterial(e){this.userData.cMat=e,this.traverse((t=>{t.isMesh&&(t.material=e),t.type&&(this.userData.cMat=e)}));for(let t in this.children){let o=this.children[t];o.setMaterial&&o.setMaterial(e)}return this}getMaterial(){return this.userData.cMat}setDefaultAndHighlightMaterials(e,t){return this.userData.matSTD=e,this.userData.matHL=t,this}highlight(){return this.userData.matHL&&this.setMaterial(this.userData.matHL),this}restoreDefaultMaterial(){return this.userData.matSTD&&this.setMaterial(this.userData.matSTD),this}setOpacity(e){return this.traverse((t=>{t.isMesh&&(t.material.opacity=e)})),this}setShadowCast(e){return this.castShadow=e,this.traverse((t=>{t.isMesh&&(t.castShadow=e)})),this}setShadowReceive(e){return this.receiveShadow=e,this.traverse((t=>{t.isMesh&&(t.receiveShadow=e)})),this}setEnvMap(e){return this.traverse((t=>{t.isMesh&&(t.material.envMap=e)})),this}assignLightProbe(e){return this.traverse((t=>{t.isMesh&&t.geometry&&ATON.Utils.assignLightProbeToMesh(e,t)})),this}assignLightProbesByProximity(){return 0===ATON._lps.length||this.traverse((e=>{if(e.isMesh&&e.geometry){let t,o,i=new THREE.Vector3;(new THREE.Box3).setFromObject(e).getCenter(i);for(let e in ATON._lps){let r=ATON._lps[e],a=i.distanceToSquared(r.pos);(void 0===t||a{e.isMesh&&e.geometry&&(ATON.Utils.clearLightProbeFromMesh(e),e.material&&(e.material.envMap.dispose(),e.material.needsUpdate=!0))})),this}updateLightProbes=()=>(this.traverse((e=>{if(e.isMesh&&e.geometry){let t=e.userData.LP;void 0!==t&&(t.update(),e.material.envMap=t.getEnvTex(),e.material.needsUpdate=!0)}})),this);duplicate(){let e=this.clone();return e.traverse((e=>{e.isMesh&&(e.material=e.material.clone())})),e}delete(){let e=this.parent;void 0!==e&&void 0!==e.nid&&e.removeChild(this)}removeChild(e){if(void 0!==e)return e.nid,void 0!==e.nid&&(this._nodes[e.nid]=void 0),e.parent=void 0,e.traverse((e=>{e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()})),this.remove(e),this}removeChildren(){for(let e=this.children.length-1;e>=0;e--)this.removeChild(this.children[e]);return this}attachTo(e){let t="string"==typeof e?this._nodes[e]:e;return t&&(t.add(this),void 0!==t.userData.cMat&&(this.userData.cMat=t.userData.cMat),void 0!==t.bPickable&&(this.bPickable=t.bPickable)),t}attachToRoot(){return this._rootG.add(this),void 0!==this._rootG.userData.cMat&&(this.userData.cMat=this._rootG.userData.cMat),void 0!==this._rootG.bPickable&&(this.bPickable=this._rootG.bPickable),this._rootG}getBound(){return this.dirtyBound(),this._bs}dirtyBound(){return(new THREE.Box3).setFromObject(this).getBoundingSphere(this._bs),this}autoFit(e,t){if(this.dirtyBound(),e&&(this.position.copy(this._bs.center),this.position.multiplyScalar(-1)),t&&t>0&&this._bs.radius>0){let e=t/this._bs.radius;this.scale.set(e,e,e)}}setPosition(e,t,o){return e instanceof THREE.Vector3?this.position.copy(e):this.position.set(e,t,o),this}setScale(e,t,o){return e instanceof THREE.Vector3?this.scale.copy(e):(void 0===t&&(t=e,o=e),this.scale.set(e,t,o)),this}setRotation(e,t,o){return e instanceof THREE.Vector3?this.rotation.copy(e):this.rotation.set(e,t,o),this}orientToCamera(){return this.quaternion.copy(ATON.Nav._qOri),this}orientToLocation(e,t,o){return e instanceof THREE.Vector3?this.lookAt(e):this.lookAt(e,t,o),this}orientToNode(e){return e?(this.orientToLocation(e.position),this):this}setYup(){return this.rotation.set(-1.57079632679,0,0),this}addTransform(e){let t;return"string"==typeof e&&(t=ATON.Utils.parseTransformString(e)),void 0===t||(void 0===this._tlist&&(this._tlist=[]),this._tlist.push(t)),this}load(e,t){if(void 0===e)return this;let o=this;if(e=ATON.Utils.resolveCollectionURL(e),ATON.Utils.tryLoadFromService(e,o))return t&&t(),o;if("json"===ATON.Utils.getFileExtension(e))return ATON.MRes.loadTileSetFromURL(e,o),t&&t(),o;if(ATON._resHandler)for(let t in ATON._resHandler)if(ATON._resHandler[t](e,o))return o;if(o._bCloneOnLoadHit&&void 0!==ATON._assetsManager[e])return ATON._assetsManager[e].then((e=>{let i=e.clone();if(ATON.Utils.modelVisitor(o,i),void 0!==o._tlist)for(let e in o._tlist)o._tlist[e].add(i.clone()),o.add(o._tlist[e]);else o.add(i);t&&t()})),o;ATON._assetReqNew(e);let i=new Promise(((i,r)=>{ATON._aLoader.load(e,(r=>{let a=r.scene||r.scene[0];if(ATON.Utils.modelVisitor(o,a),void 0!==o._tlist)for(let e in o._tlist)o._tlist[e].add(a.clone()),o.add(o._tlist[e]);else o.add(a);ATON.Utils.registerAniMixers(o,r),ATON.CC.extract(r),i(a),console.log("%cModel loaded","color:green"),ATON._assetReqComplete(e),o.type===ATON.NTYPES.SCENE&&(ATON._bqScene=!0),o.type===ATON.NTYPES.SEM&&(ATON._bqSem=!0),o.bPickable&&o.enablePicking(),o.dirtyBound(),t&&t()}),void 0,(o=>{console.log("%cError loading model "+e,"color:red"),ATON._assetReqComplete(e),t&&t()}))}));return o._bCloneOnLoadHit&&(ATON._assetsManager[e]=i),this}exportAs(e){return ATON.Utils.exportNode(this,e),this}setOnHover(e){return this.onHover=e,this}setOnLeave(e){return this.onLeave=e,this}setOnSelect(e){return this.onSelect=e,this}loadCesiumIONAsset(e){return ATON.MRes.loadCesiumIONAsset(e,this),this}loadSketchfabAsset(e){let t=ATON.getAPIToken("sketchfab"),o=this;return null==t&&(console.log("A valid Sketchfab token is required"),t=prompt("Please enter a valid Sketchfab token:"),null==t||""==t)||fetch("https://api.sketchfab.com/v3/models/"+e+"/download",{method:"GET",headers:{Authorization:"Token "+t},mode:"cors"}).then((function(e){return e.json()})).then((function(e){if(ATON.setAPIToken("sketchfab",t),e.glb){let t=e.glb.url;return o.load(t),o}})),this}}const t=e;let o={init:()=>{o.evLocal={},o.evNetwork={},ATON.on=o.on,ATON.fireEvent=o.fireEvent,ATON.clearEventHandlers=o.clearEventHandlers},clearEventHandlers:e=>{o.evLocal[e]=[],o.evNetwork[e]=[]},executeHandlers:(e,t)=>{if(e)for(let o=0;o{if(void 0!==t){const i=o.evLocal;void 0===i[e]&&(i[e]=[]),i[e].push(t)}void 0!==i&&ATON.Photon.on(e,i)},fireEvent:(e,t,i)=>{const r=o.evLocal[e];o.executeHandlers(r,t),i&&ATON.Photon.fireEvent(e,t)}};const i=o;let r={init:()=>{r.materials={},r.colors={},r._loader=new THREE.MaterialLoader,r._uSem={time:{type:"float",value:0},tint:{type:"vec4",value:new THREE.Vector4(.2,.2,1,.2)}},r.addDefaults()},getDefVertexShader:()=>"\n varying vec3 vPositionW;\n varying vec3 vNormalW;\n varying vec3 vNormalV;\n varying vec2 vUv;\n\n void main(){\n vUv = uv;\n\n vPositionW = ( modelMatrix * vec4( position, 1.0 )).xyz;\n vNormalV = normalize( vec3( normalMatrix * normal ));\n vNormalW = ( modelMatrix * vec4(normal, 0.0 )).xyz;\n\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }\n ",addDefaults:()=>{r.colors.white=new THREE.Color(1,1,1),r.colors.black=new THREE.Color(0,0,0),r.colors.green=new THREE.Color(0,1,0),r.colors.yellow=new THREE.Color(1,1,0),r.colors.red=new THREE.Color(1,0,0),r.colors.blue=new THREE.Color(0,0,1),r.colors.orange=new THREE.Color(1,.5,0),r.colors.defUI=new THREE.Color(.85,1,.95),r.colors.sem=new THREE.Color(0,1,.5),r.colors.darksem=new THREE.Color(0,0,.1),r.materials.fullyTransparent=new THREE.MeshBasicMaterial({transparent:!0,depthWrite:!1,opacity:0}),r.materials.defUI=new THREE.ShaderMaterial({uniforms:{tint:{type:"vec3",value:r.colors.defUI},opacity:{type:"float",value:0}},vertexShader:r.getDefVertexShader(),fragmentShader:"\n varying vec3 vPositionW;\n\t\t varying vec3 vNormalW;\n varying vec3 vNormalV;\n uniform vec3 tint;\n //uniform vec3 base;\n uniform float opacity;\n\n\t\t void main(){\n\t\t //vec3 viewDirectionW = normalize(cameraPosition - vPositionW);\n\n float f;\n\t\t //f = dot(vNormalV, viewDirectionW);\n f = dot(vNormalV, vec3(0,0,1));\n\t\t f = clamp(1.0-f, 0.0, 1.0);\n f *= f;\n\n f = mix(opacity, 1.0 + opacity, f);\n f = clamp(f, 0.0,1.0);\n\n //vec3 col = mix(base,tint, f);\n\t\t //gl_FragColor = vec4(col, f * opacity);\n\n gl_FragColor = vec4(tint, f);\n\t\t }\n ",transparent:!0,depthWrite:!1}),r.materials.selector=r.materials.defUI.clone(),r.materials.outline=new THREE.MeshBasicMaterial({color:r.colors.black,side:THREE.BackSide,transparent:!0,depthWrite:!1,opacity:.2}),r.materials.controllerRay=r.materials.defUI.clone(),r.materials.controllerRay.uniforms.tint.value=r.colors.white,r.materials.xray=r.materials.defUI.clone(),r.materials.xray.uniforms.tint.value=r.colors.white,r.materials.xray.uniforms.opacity.value=.5,r.materials.teleportLoc=new THREE.MeshBasicMaterial({transparent:!0,opacity:1,depthWrite:!1,side:THREE.DoubleSide}),ATON.Utils.textureLoader.load(ATON.PATH_RES+"grad.png",(e=>{r.materials.teleportLoc.map=e})),r.materials.measurement=new THREE.MeshBasicMaterial({color:r.colors.white,transparent:!0,depthWrite:!1,opacity:.5,depthTest:!1}),r.materials.semanticShape=new THREE.ShaderMaterial({uniforms:r._uSem,vertexShader:r.getDefVertexShader(),fragmentShader:"\n varying vec3 vPositionW;\n\t\t varying vec3 vNormalW;\n varying vec3 vNormalV;\n\n uniform float time;\n uniform vec4 tint;\n\n\t\t void main(){\n\t\t //vec3 viewDirectionW = normalize(cameraPosition - vPositionW);\n\n //float ff = dot(vNormalV, vec3(0,0,1));\n\t\t //ff = clamp(1.0-ff, 0.0, 1.0);\n\n float f = (1.0 * cos(time*2.0)); // - 0.5;\n //f = cos(time + (vPositionW.y*10.0));\n f = clamp(f, 0.0,1.0);\n\n\t\t gl_FragColor = vec4(tint.rgb, tint.a * f);\n //gl_FragColor = vec4(tint.rgb, ff);\n\t\t }\n ",transparent:!0,depthWrite:!1}),r.materials.semanticShapeHL=new THREE.MeshBasicMaterial({color:r.colors.sem,transparent:!0,depthWrite:!1,opacity:.2}),r.materials.semanticShapeEdit=new THREE.MeshBasicMaterial({color:r.colors.orange,transparent:!0,depthWrite:!1,opacity:.5}),r.materials.transWhite=new THREE.MeshBasicMaterial({color:r.colors.white,transparent:!0,depthWrite:!1,side:THREE.DoubleSide,opacity:.2}),r.materials.transBlack=new THREE.MeshBasicMaterial({color:r.colors.black,transparent:!0,depthWrite:!1,side:THREE.DoubleSide,opacity:.2}),r.materials.wireframe=new THREE.MeshBasicMaterial({color:r.colors.black,transparent:!0,depthWrite:!1,opacity:.1,wireframe:!0}),r.materials.normSlope=new THREE.ShaderMaterial({vertexShader:r.getDefVertexShader(),fragmentShader:"\n varying vec3 vPositionW;\n\t\t varying vec3 vNormalW;\n\n\t\t void main(){\n vec4 A = vec4(0,1,0, 1.0);\n vec4 B = vec4(1,0,0, 1.0);\n\n float f;\n f = dot(vNormalW, vec3(0,1,0));\n\n\t\t gl_FragColor = mix(B,A, f);\n\t\t }\n "}),r.materials.gradient=new THREE.ShaderMaterial({uniforms:{range:{type:"vec2",value:new THREE.Vector2(-4,5)}},vertexShader:r.getDefVertexShader(),fragmentShader:"\n varying vec3 vPositionW;\n\n uniform vec2 range;\n\n\t\t void main(){\n vec4 A = vec4(0,0,0, 1.0);\n vec4 B = vec4(0,0.5,1, 1.0);\n\n float t = (vPositionW.y - range.x)/(range.y - range.x);\n t = clamp(t, 0.0,1.0);\n\n\t\t gl_FragColor = mix(A,B, t);\n\t\t }\n "}),r.materials.lp=new THREE.ShaderMaterial({vertexShader:r.getDefVertexShader(),fragmentShader:"\n varying vec3 vPositionW;\n\t\t varying vec3 vNormalW;\n varying vec3 vNormalV;\n\n\t\t void main(){\n\t\t vec3 viewDirectionW = normalize(cameraPosition - vPositionW);\n\n float f;\n\t\t //f = dot(viewDirectionW, vNormalW);\n f = dot(vNormalV, vec3(0,0,1));\n\t\t f = clamp(1.0 - f, 0.0, 1.0);\n\n\t\t gl_FragColor = vec4(1.0,1.0,1.0, f);\n\t\t }\n ",transparent:!0,depthWrite:!1});let e=(new THREE.TextureLoader).load(ATON.PATH_RES+"point-mask.png");e.generateMipmaps=!1,r.materials.point=new THREE.PointsMaterial({vertexColors:!0,alphaMap:e,alphaTest:.5,depthTest:!0,transparent:!1,size:4,sizeAttenuation:!1}),r.materials.chromakey=new THREE.ShaderMaterial({uniforms:{tBase:{type:"t"},keycolor:{type:"vec4",value:new THREE.Vector4(0,1,0,0)},similarity:{type:"float",value:.4},smoothness:{type:"float",value:.08},spill:{type:"float",value:.1}},vertexShader:r.getDefVertexShader(),fragmentShader:"\n uniform sampler2D tBase;\n uniform vec4 keycolor;\n\n uniform float similarity;\n uniform float smoothness;\n uniform float spill;\n\n varying vec2 vUv;\n\n // From https://github.com/libretro/glsl-shaders/blob/master/nnedi3/shaders/rgb-to-yuv.glsl\n vec2 RGBtoUV(vec3 rgb){\n return vec2(\n rgb.r * -0.169 + rgb.g * -0.331 + rgb.b * 0.5 + 0.5,\n rgb.r * 0.5 + rgb.g * -0.419 + rgb.b * -0.081 + 0.5\n );\n }\n\n // From https://godotshaders.com/shader/green-screen-chromakey/\n\t\t void main(){\n\t\t vec4 frag = texture2D(tBase, vUv);\n vec4 orig = frag;\n\n float chromaDist = distance(RGBtoUV(frag.rgb), RGBtoUV(keycolor.rgb));\n\n float baseMask = chromaDist - similarity;\n float fullMask = pow(clamp(baseMask / smoothness, 0.0,1.0), 1.5);\n frag.a = fullMask;\n \n float spillVal = pow(clamp(baseMask / spill, 0.0,1.0), 1.5);\n float desat = clamp(frag.r * 0.2126 + frag.g * 0.7152 + frag.b * 0.0722, 0.0,1.0);\n frag.rgb = mix(vec3(desat, desat, desat), frag.rgb, spillVal);\n\n frag = mix(orig,frag, keycolor.w);\n\n\t\t gl_FragColor = frag;\n\t\t }\n ",transparent:!0,side:THREE.DoubleSide})},addMaterial:(e,t)=>{r.materials[e]?console.log("MatHub: material "+e+" already registered"):r.materials[e]=t},loadMaterial:(e,t)=>{r._loader.load(t,(t=>{r.addMaterial(e,t)}),void 0,(e=>{console.log(e)}))},getMaterial:e=>r.materials[e],update:()=>{r._uSem.time.value+=ATON._dt}};const a=r;let s={TSTRING_SEPARATOR:" ",VOID_CAST:(e,t)=>{},init:()=>{ATON.device={},s.geomUnitSphere=new THREE.SphereGeometry(1,32,32),s.geomUnitCube=new THREE.BoxGeometry,s.exporterGLTF=void 0,s.exporterOBJ=void 0,s.exporterUSDZ=void 0,s._dlink=document.createElement("a"),s._dlink.style.display="none",document.body.appendChild(s._dlink),s.textureLoader=new THREE.TextureLoader,s._bvhBounds=0,s.stats={},s.stats.numVertices=0,s.stats.numTris=0},generateID:e=>(void 0===e&&(e="id"),e+"-"+Math.random().toString(36).substr(2,9)),goToURL:e=>{window.location.href=e},goToScene:(e,t)=>{if(void 0===e)return;if(e.length<2)return;let o=ATON.PATH_FE+e;void 0!==t&&(o+="&vrc="+t),window.location.href=o},isConnectionSecure:()=>window.isSecureContext,isLocalhost:()=>!!window.location.origin.includes("localhost")||!!window.location.origin.includes("127.0.0.1"),showBVHbounds:e=>{e>0&&(s._bvhBounds=e)},_addBVHbounds:(e,t)=>{if(void 0===e)return;let o=new ThreeMeshBVH.MeshBVHHelper(e,t);o.displayParents=!0,o.update(),e.parent.add(o)},profileDevice:()=>{ATON.device.isMobile=!1,ATON.device.isMobile=!(!/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|ipad|iris|kindle|Android|Silk|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent)&&!/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(navigator.userAgent.substr(0,4))),ATON.device.xrSupported={},ATON.device.xrSupported["immersive-vr"]=!1,ATON.device.xrSupported["immersive-ar"]=!1,"xr"in navigator&&(navigator.xr.isSessionSupported("immersive-vr").then((e=>{ATON.device.xrSupported["immersive-vr"]=!!e,console.log("WebXR VR session support: "+ATON.device.xrSupported["immersive-vr"]),ATON.fireEvent("XR_support",{type:"immersive-vr",v:ATON.device.xrSupported["immersive-vr"]})})),navigator.xr.isSessionSupported("immersive-ar").then((e=>{ATON.device.xrSupported["immersive-ar"]=!!e,console.log("WebXR AR session support: "+ATON.device.xrSupported["immersive-ar"]),ATON.fireEvent("XR_support",{type:"immersive-ar",v:ATON.device.xrSupported["immersive-ar"]})})))},profileRenderingCapabilities:()=>{if(void 0===ATON._renderer)return;let e=ATON._renderer.capabilities;void 0!==e&&(ATON.device.lowGPU=!1,e.isWebGL2||(ATON.device.lowGPU=!0),e.maxTextureSize<8192&&(ATON.device.lowGPU=!0),e.maxCubemapSize<4096&&(ATON.device.lowGPU=!0),console.log(e))},isMobile:()=>ATON.device.isMobile,isVRsupported:()=>ATON.device.xrSupported["immersive-vr"],isARsupported:()=>ATON.device.xrSupported["immersive-ar"],getFileExtension:e=>e.substr(e.lastIndexOf(".")+1).toLowerCase(),removeFileExtension:e=>e.replace(/\.[^/.]+$/,""),isVideo:e=>{let t=s.getFileExtension(e);return"mp4"===t||"webm"===t||"m3u8"===t},getBaseFolder:e=>{var t=e.lastIndexOf("/");return-1!==t?e.substring(0,t+1):""},getFilename:e=>e.split(/(\\|\/)/g).pop(),isResourceURL:e=>!!e.startsWith("http://")||!!e.startsWith("https://"),URLify:e=>{if("string"!=typeof e)return e;const t=e.match(/(((ftp|https?):\/\/)[\-\w@:%_\+.~#?,&\/\/=]+)/g);return t&&t.forEach((function(t){e=e.replace(t,"")})),e},resolveCollectionURL:e=>e?(ATON._collMod&&(e=ATON._collMod(e)),e.startsWith("http")?e:ATON.PATH_COLLECTION+e):"",tryLoadFromService:(e,t)=>{if(!t)return!1;if(e.startsWith("https://cesium.com/ion/assets/")||e.startsWith("https://ion.cesium.com/assets/")){let o=e.split("/"),i=o[o.length-1];return t.loadCesiumIONAsset(i),!0}if(e.startsWith("https://assets.cesium.com/")){let o=e.split("/"),i=o[o.length-2];return t.loadCesiumIONAsset(i),!0}if(e.startsWith("https://sketchfab.com/3d-models/")){let o=e.split("-"),i=o[o.length-1];return t.loadSketchfabAsset(i),!0}for(let o in ATON._resMappers){let i=ATON._resMappers[o](e);if(void 0!==i)return t.load(i),!0}return!1},postJSON:(e,t,o,i)=>{$.ajax({url:e,type:"POST",xhrFields:{withCredentials:!0},data:JSON.stringify(t),contentType:"application/json; charset=utf-8",dataType:"json",success:e=>{o&&o(e)}}).fail((e=>{console.log(e),i&&i()}))},runAsync:e=>{const t=new Worker(URL.createObjectURL(new Blob([`postMessage((${e})());`]),{type:"application/javascript; charset=utf-8"}));return new Promise(((e,o)=>{t.onmessage=({data:o})=>{e(o),t.terminate()},t.onerror=e=>{o(e),t.terminate()}}))},mergeObject:e=>{e.updateMatrixWorld(!0);const t=[];e.traverse((e=>{if(e.isMesh){const o=e.geometry;o.applyMatrix4(e.matrixWorld),t.push(o.toNonIndexed())}}));const o=THREE.BufferGeometryUtils.mergeGeometries(t,!1),i=THREE.BufferGeometryUtils.mergeVertices(o).center(),r=new THREE.Group,a=new THREE.Mesh(i);return r.add(a),r},setPicking:(e,t,o)=>{void 0===o&&(o=!0),e.traverse((e=>{o?e.layers.enable(t):e.layers.disable(t)}))},graphPostVisitor:e=>{e.visible?console.log(e):s.setPicking(e,e.type,!1)},rotationBetweenDirections:(e,t)=>{const o=new THREE.Quaternion,i=(new THREE.Vector3).crossVectors(e,t);return o.x=i.x,o.y=i.y,o.z=i.z,o.w=1+e.clone().dot(t),o.normalize(),o},clampValue:(e,t,o)=>Math.min(Math.max(e,t),o),loadTexture:(e,t)=>{e.endsWith(".ktx2")?ATON._ktx2Loader.load(e,t):s.textureLoader.load(e,t)},modelVisitor:(e,t)=>{if(void 0===t)return;if(void 0===e)return;let o=e.type;t.traverse((t=>{t.isMesh&&(o===ATON.NTYPES.SCENE&&(t.castShadow=!0,t.receiveShadow=!0,t.geometry&&(t.geometry.computeBoundsTree(),console.log("Computed visible BVH"),s._bvhBounds>0&&s._addBVHbounds(t,s._bvhBounds)),s.processMaterial(t.material)),o===ATON.NTYPES.SEM&&(t.material=ATON.MatHub.materials.semanticShape,t.geometry&&(t.geometry.computeBoundsTree(),console.log("Computed semantic BVH"))),e.userData.cMat&&(t.material=e.userData.cMat))}))},processMaterial:e=>{void 0!==e&&null!==e.map&&void 0!==e.map&&(e.map.generateMipmaps=!0,e.map.anisotropy=ATON.device.isMobile?0:ATON._maxAnisotropy,e.map.minFilter=THREE.LinearMipmapLinearFilter,e.map.magFilter=THREE.LinearFilter,e.map.colorSpace=ATON._stdEncoding)},cleanupVisitor:e=>{e.traverse((e=>{if(e.material)if(e.material.length)for(let t=0;t{let o=t.scene||t.scene[0],i=!1;if(void 0===t.animations)return;let r=new THREE.AnimationMixer(o);t.animations.forEach((e=>{r.clipAction(e).play(),i=!0})),i&&(ATON._aniMixers.push(r),void 0===e._aniMixers&&(e._aniMixers=[]),e._aniMixers.push(r))},parseTransformString:e=>{let t=new THREE.Group,o=e.split(s.TSTRING_SEPARATOR),i=o.length;return i<3||(t.position.set(parseFloat(o[0]),parseFloat(o[1]),parseFloat(o[2])),i<6||(t.rotation.set(parseFloat(o[3]),parseFloat(o[4]),parseFloat(o[5])),i<9||t.scale.set(parseFloat(o[6]),parseFloat(o[7]),parseFloat(o[8])))),t},setVectorPrecision:(e,t)=>(e.x=parseFloat(e.x.toPrecision(t)),e.y=parseFloat(e.y.toPrecision(t)),e.z=parseFloat(e.z.toPrecision(t)),e),parseMD:e=>(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=e.replace(/^\s*\n\*/gm,"
    \n*")).replace(/^(\*.+)\s*\n([^\*])/gm,"$1\n
\n\n$2")).replace(/^\*(.+)/gm,"
  • $1
  • ")).replace(/^\s*\n\d\./gm,"
      \n1.")).replace(/^(\d\..+)\s*\n([^\d\.])/gm,"$1\n
    \n\n$2")).replace(/^\d\.(.+)/gm,"
  • $1
  • ")).replace(/^\>(.+)/gm,"
    $1
    ")).replace(/[\#]{6}(.+)/g,"
    $1
    ")).replace(/[\#]{5}(.+)/g,"
    $1
    ")).replace(/[\#]{4}(.+)/g,"

    $1

    ")).replace(/[\#]{3}(.+)/g,"

    $1

    ")).replace(/[\#]{2}(.+)/g,"

    $1

    ")).replace(/[\#]{1}(.+)/g,"

    $1

    ")).replace(/^(.+)\n\=+/gm,"

    $1

    ")).replace(/^(.+)\n\-+/gm,"

    $1

    ")).replace(/\!\[([^\]]+)\]\(([^\)]+)\)/g,'$1')).replace(/[\[]{1}([^\]]+)[\]]{1}[\(]{1}([^\)\"]+)(\"(.+)\")?[\)]{1}/g,'$1')).replace(/[\*\_]{2}([^\*\_]+)[\*\_]{2}/g,"$1")).replace(/[\*\_]{1}([^\*\_]+)[\*\_]{1}/g,"$1")).replace(/[\~]{2}([^\~]+)[\~]{2}/g,"$1")).replace(/^\s*\n\`\`\`(([^\s]+))?/gm,'
    ')).replace(/^\`\`\`\s*\n/gm,"
    \n\n")).replace(/[\`]{1}([^\`]+)[\`]{1}/g,"$1")).replace(/^\s*(\n)?(.+)/gm,(function(e){return/\<(\/)?(h\d|ul|ol|li|blockquote|pre|img)/.test(e)?e:"

    "+e+"

    "}))).replace(/(\)\s*\n\(.+)\<\/p\>/gm,"$1$2"),checkAuth:e=>{$.ajax({type:"GET",url:ATON.PATH_RESTAPI+"user",xhrFields:{withCredentials:!0},dataType:"json",success:t=>{e(t)}})},getHumanReadableDistance:e=>{let t=" m";return e<.01?(t=" mm",t=(e*=1e3).toPrecision(3)+t,t):e<1?(t=" cm",t=(e*=100).toPrecision(3)+t,t):e>1e3?(t=" km",t=e.toPrecision(3)+t,t):(t=e.toPrecision(3)+t,t)},stripHTMLtagsFromString:e=>e.replace(/(<([^>]+)>)/gi,""),requestFullscreen:()=>{let e=document.documentElement;return e.requestFullscreen?e.requestFullscreen():e.mozRequestFullScreen?e.mozRequestFullScreen():e.webkitRequestFullscreen?e.webkitRequestFullscreen():e.msRequestFullscreen&&e.msRequestFullscreen(),!0},downloadBlob:(e,t)=>{void 0!==t&&(s._dlink.href=URL.createObjectURL(e),s._dlink.download=t,s._dlink.click())},downloadText:(e,t)=>{s.downloadBlob(new Blob([e],{type:"text/plain"}),t)},downloadJSONobj:(e,t)=>{s.downloadText(JSON.stringify(e),t)},downloadArrayBuffer:(e,t)=>{s.downloadBlob(new Blob([e],{type:"application/octet-stream"}),t)},downloadImageFromCanvas:(e,t)=>{if(!e)return;let o=e.toDataURL();ATON.Utils._dlink.href=o,ATON.Utils._dlink.download=t,ATON.Utils._dlink.click()},exportNode:(e,t)=>{let o=s.getFileExtension(t);if(!(o.length<1)){if("glb"===o||"gltf"===o){let i={binary:"glb"===o};void 0===s.exporterGLTF&&(s.exporterGLTF=new THREE.GLTFExporter),s.exporterGLTF.parse(e,(e=>{e instanceof ArrayBuffer?s.downloadArrayBuffer(e,t):(console.log(e),s.downloadJSONobj(e,t))}),i)}if("obj"===o){void 0===s.exporterOBJ&&(s.exporterOBJ=new THREE.OBJExporter);let o=s.exporterOBJ.parse(e);s.downloadText(o,t)}"usdz"===o&&(void 0===s.exporterUSDZ&&(s.exporterUSDZ=new THREE.USDZExporter),$("#idLoader").show(),s.exporterUSDZ.parse(e).then((e=>{s.downloadArrayBuffer(e,t),$("#idLoader").hide()})))}},takeScreenshot:(e,t)=>{let o=new Image;console.log("Screenshot with size:"+e),ATON.Nav._camera.aspect=1,ATON.Nav._camera.updateProjectionMatrix(),ATON._renderer.setSize(e,e),ATON._renderer.render(ATON._mainRoot,ATON.Nav._camera);let i=ATON._renderer.domElement;if(ATON.FX.composer){if(ATON.FX.composer.setSize(e,e),ATON.FX.passes[ATON.FX.PASS_AA]){let t=ATON.FX.passes[ATON.FX.PASS_AA].material.uniforms;t&&t.resolution.value.set(1/e,1/e)}ATON.FX.composer.render(),i=ATON.FX.composer.renderer.domElement}let r=ATON._renderer.domElement.toDataURL();return o.src=r,t&&(s._dlink.href=r.replace("image/png","image/octet-stream"),s._dlink.download=t,s._dlink.click()),ATON._onResize(),o},assignLightProbeToMesh:(e,t)=>{void 0!==e&&void 0!==t&&(t.noLP||(t.userData.LP=e))},clearLightProbeFromMesh:e=>{void 0!==e&&(e.noLP||(e.userData.LP=null))},vibrate:e=>{void 0===e&&(e=100),window.navigator.vibrate(e)},createATONCube:e=>{let t=new THREE.BoxGeometry(1,1,1),o=new THREE.MeshStandardMaterial;s.textureLoader.load(ATON.PATH_RES+"models/aton-cube.jpg",(e=>{e.colorSpace=ATON._stdEncoding,o.map=e}));let i=ATON.createSceneNode(e);return i.add(new THREE.Mesh(t)),i.setMaterial(o),i.enablePicking(),i},createATONCubePBR:e=>{let t=new THREE.BoxGeometry(1,1,1),o=new THREE.MeshStandardMaterial;o.metalness=1,s.textureLoader.load(ATON.PATH_RES+"models/aton-cube.jpg",(e=>{e.colorSpace=ATON._stdEncoding,o.map=e})),s.textureLoader.load(ATON.PATH_RES+"models/aton-cube-pbr.jpg",(e=>{e.colorSpace=ATON._stdEncoding,o.metalnessMap=e,o.roughnessMap=e})),s.textureLoader.load(ATON.PATH_RES+"models/aton-cube-nrm.png",(e=>{e.colorSpace=ATON._stdEncoding,o.normalMap=e}));let i=ATON.createSceneNode(e);return i.add(new THREE.Mesh(t)),i.setMaterial(o),i.enablePicking(),i},createGround:(e,t,o)=>{void 0===t&&(t=1),void 0===o&&(o=1);let i=new THREE.PlaneGeometry(t,o),r=new THREE.MeshStandardMaterial;void 0!==e&&s.textureLoader.load(e,(e=>{e.colorSpace=ATON._stdEncoding,r.map=e}));let a=ATON.createSceneNode().rotateX(.5*-Math.PI);return a.add(new THREE.Mesh(i,r)),a.enablePicking(),a}};const n=s;let l={MODE_ADD:0,MODE_DEL:1,FLOAT_PREC:5,init:()=>{l.currID=void 0,l.currData=void 0,l._bEdit=!1,l._bLoading=!1,l._title=void 0,l._descr=void 0,l.initBaseParsers()},setEditMode:e=>{l._bEdit=e,console.log("Edit mode:"+e)},load:(e,t,o)=>(l._bLoading=!0,console.log("Loading Scene: "+t),$.getJSON(e,(e=>{l.currData=e,l.currID=t,l._bLoading=!1,l.parseScene(e),o&&o(),ATON.fireEvent("SceneJSONLoaded",t)}))),clearScene:()=>{if(!(ATON._rootVisible.children.length<=0)){ATON._rootVisible.removeChildren();for(let e in ATON.snodes)e!==ATON.ROOT_NID&&delete ATON.snodes[e];ATON.MRes.clear(),ATON.XPFNetwork.clear()}},clearSemantics:()=>{if(!(ATON._rootSem.children.length<=0)){ATON._rootSem.removeChildren();for(let e in ATON.semnodes)e!==ATON.ROOT_NID&&delete ATON.semnodes[e];ATON.SUI.gSemIcons&&ATON.SUI.gSemIcons.removeChildren(),ATON.SemFactory.stopCurrentConvex(),ATON.SemFactory.init()}},clear:()=>{l.clearScene(),l.clearSemantics(),ATON.Nav.clear()},parseScene:e=>{if(void 0!==(e=void 0===e?l.currData:e))for(let t in e)l._jsonParsers[t]&&l._jsonParsers[t](e[t])},getJSONchildren:(e,t)=>{let o;void 0===t&&(t=ATON.NTYPES.SCENE);let i=[];if(t===ATON.NTYPES.SEM&&(o=ATON.getSemanticNode(e)),t===ATON.NTYPES.SCENE&&(o=ATON.getSceneNode(e)),void 0!==o){for(let e in o.children){let t=o.children[e];void 0!==t.nid&&i.push(t.nid)}return i}},getJSONgraphEdges:e=>{void 0===e&&(e=ATON.NTYPES.SCENE);let t=ATON.snodes;e===ATON.NTYPES.SEM&&(t=ATON.semnodes),e===ATON.NTYPES.UI&&(t=ATON.uinodes);let o={};for(let e in t){let i=t[e];i&&i.parent&&i.parent.nid&&(void 0===o[i.parent.nid]&&(o[i.parent.nid]=[]),o[i.parent.nid].push(i.nid))}return o},getJSONsemanticSpheresList:e=>{let t=ATON.getSemanticNode(e);if(void 0===t)return;let o=[];for(let e in t.children){let i=t.children[e];i.type&&o.push([parseFloat(i.position.x.toPrecision(l.FLOAT_PREC)),parseFloat(i.position.y.toPrecision(l.FLOAT_PREC)),parseFloat(i.position.z.toPrecision(l.FLOAT_PREC)),parseFloat(i.scale.x.toPrecision(l.FLOAT_PREC))])}return o},getJSONsemanticConvexShapes:e=>{let t=ATON.getSemanticNode(e);if(void 0===t)return;let o=[];for(let e in t.children){let i=t.children[e];i.userData._convexPoints&&o.push(i.userData._convexPoints)}return o},_applyJSONTransformToNode:(e,t)=>{if(void 0!==e&&void 0!==t){if(e.bUseGeoCoords)return t.bUseGeoCoords=!0,void(e.scale&&t.setScale(e.scale[0],e.scale[1],e.scale[2]));e.autocenter?t.autocenter=!0:e.position&&t.setPosition(e.position[0],e.position[1],e.position[2]),e.rotation&&t.setRotation(e.rotation[0],e.rotation[1],e.rotation[2]),e.scale&&t.setScale(e.scale[0],e.scale[1],e.scale[2]),e.list&&Array.isArray(e.list)}},initBaseParsers:()=>{l._jsonParsers={},l._jsonParsers.title=e=>{void 0!==e&&l.setTitle(e)},l._jsonParsers.description=e=>{void 0!==e&&l.setDescription(e)},l._jsonParsers.fx=e=>{e.ao&&(ATON.FX.togglePass(ATON.FX.PASS_AO,!0),e.ao.i&&ATON.FX.setAOintensity(parseFloat(e.ao.i))),e.bloom&&(ATON.FX.togglePass(ATON.FX.PASS_BLOOM,!0),e.bloom.i&&ATON.FX.setBloomStrength(parseFloat(e.bloom.i)),e.bloom.t&&ATON.FX.setBloomThreshold(parseFloat(e.bloom.t))),e.dof&&(ATON.FX.togglePass(ATON.FX.PASS_DOF,!0),e.dof.f&&ATON.FX.setDOFfocus(parseFloat(e.dof.f)))},l._jsonParsers.environment=e=>{let t=e.mainpano;if(e.mainpano&&(t.url&&ATON.setMainPanorama(t.url),t.rotation&&ATON.setMainPanoramaRotation(t.rotation)),e.bgcolor){let t=new THREE.Color(e.bgcolor[0],e.bgcolor[1],e.bgcolor[2]);ATON.setBackgroundColor(t)}let o=e.mainlight;o?(o.direction&&ATON.setMainLightDirection(new THREE.Vector3(o.direction[0],o.direction[1],o.direction[2])),ATON._dMainL?(o.color&&(ATON._dMainL.color=new THREE.Color(o.color[0],o.color[1],o.color[2])),o.intensity&&(ATON._dMainL.intensity=o.intensity),void 0!==o.shadows?ATON.toggleShadows(o.shadows):ATON.toggleShadows(!1)):ATON.toggleMainLight(!1)):ATON.toggleMainLight(!1);let i=e.lightprobes;if(i&&(void 0!==i.auto&&ATON.setAutoLP(i.auto),i.list))for(let e in i.list){let t=i.list[e],o=new ATON.LightProbe(t.res);t.pos&&o.setPosition(parseFloat(t.pos[0]),parseFloat(t.pos[1]),parseFloat(t.pos[2])),t.near&&o.setNear(parseFloat(t.near)),t.far&&o.setFar(parseFloat(t.far)),ATON.addLightProbe(o),console.log(o)}e.exposure&&ATON.setExposure(e.exposure)},l._jsonParsers.soundscape=e=>{void 0!==e&&e.global&&ATON.setGlobalAudio(e.global.url,e.global.loop)},l._jsonParsers.navmode=e=>{void 0!==e&&ATON.Nav.setNavMode(e)},l._jsonParsers.locomotionGraph=e=>{if(void 0!==e){for(let t in e){let o=e[t];o.pos&&ATON.Nav.addLocomotionNode(parseFloat(o.pos[0]),parseFloat(o.pos[1]),parseFloat(o.pos[2]),!0)}ATON.Nav.setFirstPersonControl(),ATON.Nav.toggleLocomotionValidator(!1)}},l._jsonParsers.measurements=e=>{if(void 0!==e)for(let t in e){let o=e[t];if(o.points&&6===o.points.length){let e=new THREE.Vector3(parseFloat(o.points[0]),parseFloat(o.points[1]),parseFloat(o.points[2])),t=new THREE.Vector3(parseFloat(o.points[3]),parseFloat(o.points[4]),parseFloat(o.points[5]));ATON.SUI.addMeasurementPoint(e),ATON.SUI.addMeasurementPoint(t)}}},l._jsonParsers.viewpoints=e=>{if(void 0!==e)for(let t in e){let o=e[t];"home"===t?ATON.Nav.setHomePOV((new ATON.POV).setPosition(o.position[0],o.position[1],o.position[2]).setTarget(o.target[0],o.target[1],o.target[2]).setFOV(o.fov)):new ATON.POV(t).setPosition(o.position[0],o.position[1],o.position[2]).setTarget(o.target[0],o.target[1],o.target[2]).setFOV(o.fov)}},l._jsonParsers.scenegraph=e=>{if(void 0===e)return;let t=e.nodes,o=e.edges;for(let e in t){let o=t[e],i=ATON.getOrCreateSceneNode(e).removeChildren();l._applyJSONTransformToNode(o.transform,i);let r=o.urls;if(r&&(Array.isArray(r)?r.forEach((e=>{i.load(e)})):i.load(r)),o["cesium.ion"]){let e=o["cesium.ion"];ATON.MRes.loadCesiumIONAsset(e,i)}if(o.stream){let t,r=o.stream;if(r.src.startsWith("#")){let e=parseInt(r.src.substring(1));t=ATON.MediaFlow.getOrCreateVideoStream(e,void 0,!0)}else{let o=ATON.Utils.resolveCollectionURL(r.src);t=ATON.MediaFlow.getOrCreateVideoStream(e,o)}if(r.chromakey){let e=r.chromakey.color;e&&t.matStream.uniforms.keycolor.value.set(parseFloat(e[0]),parseFloat(e[1]),parseFloat(e[2]),parseFloat(e[3])),r.chromakey.smoothness&&(t.matStream.uniforms.smoothness.value=parseFloat(r.chromakey.smoothness)),r.chromakey.spill&&(t.matStream.uniforms.spill.value=parseFloat(r.chromakey.spill)),r.chromakey.similarity&&(t.matStream.uniforms.similarity.value=parseFloat(r.chromakey.similarity))}if(!o.urls){let e=new THREE.PlaneGeometry(1,1),o=new THREE.Mesh(e);o.scale.x=1,o.scale.y=-1,t.el.addEventListener("loadedmetadata",(e=>{let i=t.el.videoWidth/t.el.videoHeight;o.scale.x=i,o.scale.y=-1})),ATON.Utils.modelVisitor(i,o),i.add(o),ATON._bqScene=!0,i.setPickable(!0),i.dirtyBound()}i.setMaterial(t.matStream)}o.shadowcast&&i.setShadowCast(o.shadowcast),o.shadowreceive&&i.setShadowCast(o.shadowreceive),o.toYup&&i.setYup(),o.keywords&&(i.kwords=o.keywords)}for(let e in o){let t=o[e],i=ATON.getSceneNode(e);if(void 0!==i)for(let e in t){let o=t[e],r=ATON.getSceneNode(o);void 0!==r&&r.attachTo(i)}}for(let e in t){let o=t[e],i=ATON.getSceneNode(e);if(void 0!==i&&(void 0!==o.show&&(o.show?(i.show(),console.log("show "+e)):(i.hide(),console.log("hide "+e))),o.material)){let e;"string"==typeof o.material?e=ATON.MatHub.materials[o.material]:o.material.fragmentShader||o.material.vertexShader?(o.material.vertexShader||(o.material.vertexShader=ATON.MatHub.getDefVertexShader()),e=new THREE.ShaderMaterial(o.material)):e=new THREE.MeshStandardMaterial(o.material),e&&i.setMaterial(e)}}},l._jsonParsers.semanticgraph=e=>{if(void 0===e)return;let t=e.nodes,o=e.edges;for(let e in t){let o=t[e],i=ATON.getOrCreateSemanticNode(e).removeChildren(),r=o.urls;r&&(Array.isArray(r)?r.forEach((e=>{i.load(e)})):i.load(r)),o.toYup&&i.setYup(),o.description&&i.setDescription(o.description),o.audio&&i.setAudio(o.audio),o.keywords&&(i.kwords=o.keywords);let a=o.spheres;if(Array.isArray(a))for(let t in a){let o=a[t],i=new THREE.Vector3(parseFloat(o[0]),parseFloat(o[1]),parseFloat(o[2]));ATON.SemFactory.createSphere(e,i,parseFloat(o[3]))}let s=o.convexshapes;if(Array.isArray(s))for(let t in s){let o=s[t],i=[];for(let e=0;e{if(ATON.Nav.setFirstPersonControl(),e.list){let t=e.list,o=t.length;for(let e=0;e{ATON.XPFNetwork.setHomeXPF(0),ATON.XPFNetwork.requestTransitionByIndex(0,0)}))}},addSceneParser:(e,t)=>{l._jsonParsers[e]=t},patch:(e,t,o)=>{if(l._bLoading||!l._bEdit)return;if(void 0===e)return;void 0===t&&(t=l.MODE_ADD);let i=l.currID,r={};r.data=e,r.mode=t===l.MODE_DEL?"DEL":"ADD";let a=JSON.stringify(r);e=null,r=null,$.ajax({url:ATON.PATH_RESTAPI2+"scenes/"+i,type:"PATCH",data:a,contentType:"application/json; charset=utf-8",dataType:"json",success:e=>{e&&(l.currData=e),o&&o()}})}};l.sendEdit=l.patch,l.setVisibility=(e,t)=>{l.currData.visibility=e,l.sendEdit({visibility:e},ATON.SceneHub.MODE_ADD,t)},l.currSceneHasHomeConfig=()=>void 0!==l.currData&&void 0!==l.currData.viewpoints&&void 0!==l.currData.viewpoints.home,l.setTitle=e=>{l._title=e},l.getTitle=()=>l._title,l.setDescription=e=>{l._descr=e},l.getDescription=()=>l._descr;const d=l;let c={init:()=>{c._listener=new THREE.AudioListener,c._loader=new THREE.AudioLoader,c._bGenAuPlaying=!1},playOnceGlobally:(e,t)=>{if(t&&c._bGenAuPlaying)return;e=ATON.Utils.resolveCollectionURL(e);let o=new THREE.Audio(ATON.AudioHub._listener);return c._loader.load(e,(e=>{o.setBuffer(e),o.play(),t&&(c._bGenAuPlaying=!0)})),t&&(o.onEnded=()=>{c._bGenAuPlaying=!1}),o}};const u=c;class _ extends THREE.EventDispatcher{constructor(e){super(),!1===window.isSecureContext&&console.error("DeviceOrientationEvent is only available in secure contexts (https)"),this._zee=new THREE.Vector3(0,0,1),this._euler=new THREE.Euler,this._q0=new THREE.Quaternion,this._q1=new THREE.Quaternion(-Math.sqrt(.5),0,0,Math.sqrt(.5)),this._changeEvent={type:"change"};const t=this,o=new THREE.Quaternion;this.object=e,this.object.rotation.reorder("YXZ"),this.enabled=!0,this.deviceOrientation={},this.screenOrientation=0,this.alphaOffset=0;const i=function(e){t.deviceOrientation=e},r=function(){t.screenOrientation=window.orientation||0};this.connect=function(){r(),void 0!==window.DeviceOrientationEvent&&"function"==typeof window.DeviceOrientationEvent.requestPermission?window.DeviceOrientationEvent.requestPermission().then((function(e){"granted"==e&&(window.addEventListener("orientationchange",r),window.addEventListener("deviceorientation",i))})).catch((function(e){console.error("Unable to use DeviceOrientation API:",e)})):(window.addEventListener("orientationchange",r),window.addEventListener("deviceorientation",i)),t.enabled=!0},this.disconnect=function(){window.removeEventListener("orientationchange",r),window.removeEventListener("deviceorientation",i),t.enabled=!1},this.update=function(){if(!1===t.enabled)return;const e=t.deviceOrientation;if(e){const i=e.alpha?THREE.MathUtils.degToRad(e.alpha)+t.alphaOffset:0,r=e.beta?THREE.MathUtils.degToRad(e.beta):0,a=e.gamma?THREE.MathUtils.degToRad(e.gamma):0,s=t.screenOrientation?THREE.MathUtils.degToRad(t.screenOrientation):0;!function(e,o,i,r,a){t._euler.set(i,o,-r,"YXZ"),e.setFromEuler(t._euler),e.multiply(t._q1),e.multiply(t._q0.setFromAxisAngle(t._zee,-a))}(t.object.quaternion,i,r,a,s),8*(1-o.dot(t.object.quaternion))>1e-6&&(o.copy(t.object.quaternion),t.dispatchEvent(t._changeEvent))}},this.dispose=function(){t.disconnect()},this.connect()}}const p=_;let h={STD_FOV:50,STD_NEAR:.01,STD_FAR:800,FP_EPS:.01,STD_POV_TRANS_DURATION:2,STD_LOCNODE_SIZE:.5,MIN_LOC_VALID_DIST:1.5,MODE_ORBIT:0,MODE_FP:1,MODE_DEVORI:2,LocomotionNode:class{constructor(e){this.pos=new THREE.Vector3(0,0,0),this.id=e,this._iXPF=void 0,this._sui=void 0}setLocation(e,t,o){return e instanceof THREE.Vector3?this.pos.copy(e):this.pos.set(e,t,o),this._sui&&this._sui.position.copy(this.pos),this}getLocation(){return this.pos}realizeSUI(e){return void 0===ATON.SUI.gLocNodes||(this._sui=new THREE.Sprite(ATON.SUI.getOrCreateSpriteWalk()),this._sui.position.copy(this.pos),this._sui.scale.set(ATON.Nav.STD_LOCNODE_SIZE,ATON.Nav.STD_LOCNODE_SIZE,ATON.Nav.STD_LOCNODE_SIZE),ATON.SUI.gLocNodes.add(this._sui)),this}toggleSUI(e){return void 0===this._sui||(this._sui.visible=e),this}},init:()=>{h._mode=void 0,h.POVtransitionDuration=h.STD_POV_TRANS_DURATION,h._rotSpeedOrbit=.4,h._rotSpeedFP=-.2,h._inertia=.08,h._bControl=!0,h._bLocValidator=!0,h._bInteracting=!1,h._prevMode=void 0,h.setOrbitControl(),h._currPOV=(new ATON.POV).setPosition(0,0,0).setTarget(1,0,0).setFOV(ATON.Nav.STD_FOV),h._fromPOV=new ATON.POV,h._reqPOV=new ATON.POV,h.homePOV=void 0,h._tPOVcall=-1,h._tPOVprogress=0,h.povlist={},h._vDir=new THREE.Vector3(1,0,0),h._qOri=new THREE.Quaternion,h._lastPos=new THREE.Vector3(0,0,0),h._lastOri=new THREE.Quaternion,h._dOri=0,h._dPos=0,h._motionAmt=0,h._motionDir=new THREE.Vector3(0,1,0),h._bValidLocomotion=!1,h._locNodes=[],h._prevLN=void 0},getCurrentEyeLocation:()=>h._currPOV.pos,getCurrentDirection:()=>h._vDir,copyCurrentPOV:()=>{let e=new ATON.POV;return e.pos.copy(h._currPOV.pos),e.target.copy(h._currPOV.target),e.fov=h._currPOV.fov,e},addPOV:(e,t)=>{if(void 0!==e)return e.as(t),e},clearPOVs:()=>{for(let e in ATON.Nav.povlist)delete h.povlist[e]},isTransitioning:()=>h._tPOVcall>=0,currentQueryValidForLocomotion:()=>h._bValidLocomotion,locomotionValidator:()=>{if(void 0===ATON._queryDataScene)return void(h._bValidLocomotion=!1);let e=ATON._queryDataScene,t=(e.p,e.n);e.d<=h.MIN_LOC_VALID_DIST?h._bValidLocomotion=!1:t?t.y<=.7?h._bValidLocomotion=!1:h._bValidLocomotion=!0:h._bValidLocomotion=!1},toggleLocomotionValidator:e=>{e?h._bLocValidator=!0:(h._bLocValidator=!1,h._bValidLocomotion=!1)},addLocomotionNode:(e,t,o,i)=>{let r=(new h.LocomotionNode).setLocation(e,t,o);return i&&r.realizeSUI(),h._locNodes.push(r),ATON.fireEvent("LocomotionNodeAdded",r),r},getLocomotionNodeByIndex:e=>h._locNodes[e],clearLocomotionNodes:()=>{h._locNodes=[],h._prevLN=void 0,ATON.SUI.gLocNodes&&ATON.SUI.gLocNodes.removeChildren()},getLocomotionNodeInSight:()=>{let e=h._locNodes.length;if(e<=0)return;if(h.isTransitioning())return;let t,o,i=h._currPOV.pos,r=h._vDir;void 0===h._dirLNode&&(h._dirLNode=new THREE.Vector3);for(let a=0;a.8){let e=i.distanceToSquared(h._posLNode);e>.3&&(void 0===o||e{if(void 0===e)return;if(h._mode===h.MODE_ORBIT)return;let o=ATON.Nav._vDir,i=(new ATON.POV).setPosition(e.pos).setTarget(e.pos.x+o.x,e.pos.y+o.y,e.pos.z+o.z).setFOV(h._currPOV.fov);e.toggleSUI(!1),void 0!==h._prevLN&&h._prevLN.toggleSUI(!0),h.requestPOV(i,t),h._prevLN=e,ATON.fireEvent("LocomotionNodeRequested",e)},requestTransitionToLocomotionNodeInSightIfAny:e=>{let t=ATON.XPFNetwork.getNextXPFindex();if(void 0!==t)return h.requestTransitionToLocomotionNode(ATON.XPFNetwork._list[t]._lnode,e),!0;let o=ATON.Nav.getLocomotionNodeInSight();if(void 0===o)return!1;let i=h._locNodes[o];return h.requestTransitionToLocomotionNode(i,e),!0},requestDeltaRotation:(e,t,o)=>{if(ATON.XR._bPresenting)return;let i=new THREE.Vector3,r=new THREE.Vector3;i.crossVectors(h._vDir,THREE.Object3D.DEFAULT_UP),r.x=h._currPOV.target.x+i.x*e,r.y=h._currPOV.target.y+t,r.z=h._currPOV.target.z+i.z*e;let a=new ATON.POV;a.setTarget(r),a.setPosition(ATON.Nav._currPOV.pos),ATON.Nav.requestPOV(a,o)},setUserControl:e=>{void 0!==e&&e!==h._bControl&&(h._bControl=e,void 0!==h._controls&&(h._controls.enabled=e),h._cOrbit&&(h._cOrbit.enabled=e),h._cFirstPerson&&(h._cFirstPerson.enabled=e),console.log("Nav controls: "+h._bControl))},toggleUserControl:()=>{h.setUserControl(!h._bControl)},isUserControlEnabled:()=>h._bControl,isOrbit:()=>!ATON.XR._bPresenting&&h._mode===h.MODE_ORBIT,isFirstPerson:()=>!ATON.XR._bPresenting&&h._mode===h.MODE_FP,isDevOri:()=>!ATON.XR._bPresenting&&h._mode===h.MODE_DEVORI,setNavMode:e=>{void 0!==e&&(e===h.MODE_ORBIT&&h.setOrbitControl(),e===h.MODE_FP&&h.setFirstPersonControl(),e===h.MODE_DEVORI&&h.setDeviceOrientationControl())},restorePreviousNavMode:()=>{void 0===h._prevMode&&h.setOrbitControl(),h.setNavMode(h._prevMode)},_updCamera:e=>{if(void 0===e&&(e=h._camera),ATON.FX.composer){let t=ATON.FX.composer.passes;if(t)for(let o=0;o{if(!ATON.XR.isPresenting()){if(h._prevMode=h._mode,h._mode=h.MODE_ORBIT,h._bInteracting=!1,ATON.fireEvent("NavInteraction",!1),void 0===h._cOrbit){h._camOrbit=new THREE.PerspectiveCamera(h.STD_FOV,window.innerWidth/window.innerHeight,h.STD_NEAR,h.STD_FAR),h._camOrbit.layers.enableAll(),h._cOrbit=new THREE.OrbitControls(h._camOrbit,ATON._renderer.domElement);let e=h._cOrbit;e.rotateSpeed=h._rotSpeedOrbit,e.enablePan=!0,h._inertia>0&&(e.enableDamping=!0,e.dampingFactor=h._inertia),e.screenSpacePanning=!0,e.enableZoom=!0,e.minDistance=.03,e.maxDistance=300,h._bControl||(e.enabled=!1),e.addEventListener("start",(()=>{h._bInteracting=!0,ATON.fireEvent("NavInteraction",!0)})),e.addEventListener("end",(()=>{h._bInteracting=!1,ATON.fireEvent("NavInteraction",!1)}))}h._controls=h._cOrbit,h._camera=h._camOrbit,ATON.AudioHub._listener&&h._camera.children.length<1&&h._camera.add(ATON.AudioHub._listener),h._updCamera(),h._controls.update(),h._currPOV&&h.syncCurrCamera(),ATON._onResize(),ATON.toggleCenteredQuery(!1),ATON.fireEvent("NavMode",h._mode)}},setFirstPersonControl:()=>{if(!ATON.XR.isPresenting()){if(h._prevMode=h._mode,ATON.SUI.getSelectorRadius()>.1&&ATON.SUI.setSelectorRadius(.1),h._mode=h.MODE_FP,h._bInteracting=!1,ATON.fireEvent("NavInteraction",!1),void 0===h._cFirstPerson){h._camFP=new THREE.PerspectiveCamera(h.STD_FOV,window.innerWidth/window.innerHeight,h.STD_NEAR,h.STD_FAR),h._camFP.layers.enableAll(),h._cFirstPerson=new THREE.OrbitControls(h._camFP,ATON._renderer.domElement);let e=h._cFirstPerson;e.enableZoom=!1,e.enablePan=!1,e.rotateSpeed=h._rotSpeedFP,h._inertia>0&&(e.enableDamping=!0,e.dampingFactor=h._inertia),e.target.copy(h._camera.position),e.minDistance=.01,e.maxDistance=.01,h._bControl||(e.enabled=!1)}h._controls=h._cFirstPerson,h._camera=h._camFP,ATON.AudioHub._listener&&h._camera.children.length<1&&h._camera.add(ATON.AudioHub._listener),h._updCamera(),h._controls.update(),h._currPOV&&h.syncCurrCamera(),ATON._onResize(),ATON.toggleCenteredQuery(!1),ATON.fireEvent("NavMode",h._mode)}},setDeviceOrientationControl:()=>{ATON.Utils.isMobile()&&(h._prevMode=h._mode,h._mode=h.MODE_DEVORI,h._bInteracting=!1,ATON.fireEvent("NavInteraction",!1),ATON._screenPointerCoords.set(0,0),void 0===h._cDevOri&&(h._camDevOri=new THREE.PerspectiveCamera(h.STD_FOV,window.innerWidth/window.innerHeight,h.STD_NEAR,h.STD_FAR),h._camDevOri.layers.enableAll(),h._cDevOri=new p(h._camDevOri,ATON._renderer.domElement),h._cDevOri.alphaOffset=0),h._controls=h._cDevOri,h._camera=h._camDevOri,ATON.AudioHub._listener&&h._camera.children.length<1&&h._camera.add(ATON.AudioHub._listener),h._updCamera(),h._controls.update(),h._currPOV&&h.syncCurrCamera(),ATON._onResize(),ATON.toggleCenteredQuery(!0),ATON.fireEvent("NavMode",h._mode))},useAbsoluteOrientation:e=>{h._cDevOri},setMotionAmount:e=>{h._motionAmt=e},setMotionDirection:e=>{h._motionDir.copy(e)},stop:()=>{h._motionAmt=0},setFOV:e=>{if(ATON.XR.isPresenting())return;h._currPOV.fov=e;let t=h._camera;t.fov=e,t.updateProjectionMatrix()},getFOV:()=>h._currPOV.fov,_deltaMotions:()=>{h._dOri=h._lastOri.angleTo(ATON.Nav._qOri),h._dPos=h._lastPos.distanceToSquared(h._currPOV.pos),h._lastPos.copy(h._currPOV.pos),h._lastOri.copy(ATON.Nav._qOri)},syncCurrPOV:()=>{if(ATON.XR.isPresenting()){const e=ATON._renderer.xr.getCamera().cameras[0];return h._currPOV.pos.copy(e.position),h._qOri.copy(e.quaternion),e.getWorldDirection(h._vDir),h._currPOV.pos.x+=ATON.XR.rig.position.x,h._currPOV.pos.y+=ATON.XR.rig.position.y,h._currPOV.pos.z+=ATON.XR.rig.position.z,void h._deltaMotions()}const e=h._controls,t=h._camera;if(t.getWorldDirection(h._vDir),t.getWorldQuaternion(h._qOri),h._deltaMotions(),h._mode!==h.MODE_DEVORI){if(h._mode===h.MODE_FP)return h._currPOV.pos.copy(e.target),h._currPOV.target.x=h._currPOV.pos.x+h._vDir.x,h._currPOV.target.y=h._currPOV.pos.y+h._vDir.y,void(h._currPOV.target.z=h._currPOV.pos.z+h._vDir.z);h._currPOV.pos.copy(t.position),h._currPOV.target.copy(e.target)}else h._currPOV.pos.copy(t.position)},applyPOVconstraints:e=>{},handlePOV:()=>{ATON.XR.isPresenting()?h.handleXRtransition():h.handlePOVtransition(),h.handleMotion(),h.applyPOVconstraints(h._currPOV)},handleMotion:()=>{if(h.isTransitioning())return;if(0==h._motionAmt)return;ATON.XR.controller0&&ATON.XR.controller0.visible?(ATON.XR.controller0.getWorldDirection(h._motionDir),h._motionDir.negate()):h._motionDir.copy(h._vDir);let e=h._motionAmt*ATON._dt,t=h._motionDir.x*e,o=h._motionDir.y*e,i=h._motionDir.z*e;h._currPOV.pos.x+=t,h._currPOV.pos.y+=o,h._currPOV.pos.z+=i,h._currPOV.target.x+=t,h._currPOV.target.y+=o,h._currPOV.target.z+=i},handlePOVtransition:()=>{if(!(h._tPOVcall<0)){if(h.POVtransitionDuration<=0?h._tPOVprogress=1:h._tPOVprogress=(ATON._clock.elapsedTime-h._tPOVcall)/h.POVtransitionDuration,h._tPOVprogress>=1)return h._tPOVcall=-1,h._currPOV.pos.copy(h._reqPOV.pos),h._currPOV.target.copy(h._reqPOV.target),h._currPOV.fov=h._reqPOV.fov,void ATON.fireEvent("POVTransitionCompleted",h._reqPOV.id);var e;h._tPOVprogress=(e=h._tPOVprogress,(1-Math.cos(e*Math.PI))/2),h._currPOV.pos.lerpVectors(h._fromPOV.pos,h._reqPOV.pos,h._tPOVprogress),h._currPOV.target.lerpVectors(h._fromPOV.target,h._reqPOV.target,h._tPOVprogress),h._fromPOV.fov&&h._reqPOV.fov&&(h._currPOV.fov=THREE.MathUtils.lerp(h._fromPOV.fov,h._reqPOV.fov,h._tPOVprogress),h._camera.fov=h._currPOV.fov,h._camera.updateProjectionMatrix())}},handleXRtransition:()=>{if(!(h._tPOVcall<0)){if(h.POVtransitionDuration<=0?h._tPOVprogress=1:h._tPOVprogress=(ATON._clock.elapsedTime-h._tPOVcall)/h.POVtransitionDuration,h._tPOVprogress>=1)return h._tPOVcall=-1,ATON.XR._currPos.copy(ATON.XR._reqPos),void ATON.fireEvent("POVTransitionCompleted",h._reqPOV.id);ATON.XR._currPos.lerpVectors(ATON.XR._fromPos,ATON.XR._reqPos,h._tPOVprogress)}},syncCurrCamera:()=>{if(ATON.XR.isPresenting())return;let e=h._controls,t=h._camera,o=h._currPOV.pos,i=h._currPOV.target;h._mode!==h.MODE_DEVORI?(h._vDir.subVectors(i,o),h._vDir.normalize(),h._mode===h.MODE_FP?(e.target.copy(o),t.position.x=e.target.x-h._vDir.x*h.FP_EPS,t.position.y=e.target.y-h._vDir.y*h.FP_EPS,t.position.z=e.target.z-h._vDir.z*h.FP_EPS):(t.position.copy(o),e.target.copy(i))):t.position.copy(o)},update:()=>{h.syncCurrPOV(),h.handlePOV(),h.syncCurrCamera()},requestPOV:(e,t,o)=>{ATON._tPOVcall>=0||void 0!==e&&(ATON.XR._bPresenting&&"immersive-ar"===ATON.XR._sessionType||(h.POVtransitionDuration=void 0!==t?t:h.STD_POV_TRANS_DURATION,ATON.XR.isPresenting()?(h._reqPOV.pos.copy(e.pos?e.pos:h._currPOV.pos),h._fromPOV.pos.copy(h._currPOV.pos),ATON.XR._reqPos.copy(e.pos?e.pos:h._currPOV.pos),ATON.XR._fromPos.copy(ATON.XR._currPos)):(h._reqPOV.pos.copy(e.pos?e.pos:h._currPOV.pos),h._reqPOV.target.copy(e.target?e.target:h._currPOV.target),h._reqPOV.fov=e.fov?e.fov:h._currPOV.fov,h._fromPOV.pos.copy(h._currPOV.pos),h._fromPOV.target.copy(h._currPOV.target),h._fromPOV.fov=h._currPOV.fov),o&&(e.pos&&(h._reqPOV.pos.x*=ATON._worldScale,h._reqPOV.pos.y*=ATON._worldScale,h._reqPOV.pos.z*=ATON._worldScale,ATON.XR.isPresenting()&&(ATON.XR._reqPos.x*=ATON._worldScale,ATON.XR._reqPos.y*=ATON._worldScale,ATON.XR._reqPos.z*=ATON._worldScale)),e.target&&(h._reqPOV.target.x*=ATON._worldScale,h._reqPOV.target.y*=ATON._worldScale,h._reqPOV.target.z*=ATON._worldScale)),h._tPOVcall=ATON._clock.elapsedTime,ATON.fireEvent("POVTransitionRequested",e.id)))},requestPOVbyBound:(e,t)=>{if(void 0===e)return;let o=new THREE.Vector3,i=3*e.radius;o.x=e.center.x-i*h._vDir.x,o.y=e.center.y-i*h._vDir.y,o.z=e.center.z-i*h._vDir.z;let r=(new ATON.POV).setPosition(o).setTarget(e.center);h.requestPOV(r,t)},requestPOVbyNode:(e,t)=>{if(void 0===e)return;let o=e.getBound();h.requestPOVbyBound(o,t)},requestPOVbyID:(e,t)=>{if(void 0===e)return;let o=h.povlist[e];void 0!==o&&h.requestPOV(o,t)},requestRetarget:(e,t,o)=>{let i=new THREE.Vector3;if(void 0===t)i.lerpVectors(e,h._currPOV.pos,.8);else{let o=e.distanceTo(h._currPOV.pos);o*=.5,i.x=e.x+t.x*o,i.y=e.y+t.y*o,i.z=e.z+t.z*o}let r=e.distanceTo(i);ATON.FX.setDOFfocus(r);let a=(new ATON.POV).setPosition(i).setTarget(e).setFOV(h._currPOV.fov);h.requestPOV(a,o),console.log(a)},computeDefaultHome:(e,t)=>{void 0===e&&(e=new THREE.Vector3(1,.7,1)),void 0===t&&(t=ATON.getRootScene().getBound());let o=new THREE.Vector3(t.center.x+t.radius*e.x*1.5,t.center.y+t.radius*e.y*1.5,t.center.z+t.radius*e.z*1.5);h.homePOV=(new ATON.POV).setPosition(o).setTarget(t.center)},setHomePOV:e=>{h.homePOV=e},computeAndRequestDefaultHome:(e,t,o)=>{h.computeDefaultHome(t,o),h.requestPOV(h.homePOV,e)},requestHomePOV:e=>{h.requestPOV(h.homePOV,e)}};h.requestHome=h.requestHomePOV,h.setAndRequestHomePOV=(e,t)=>{h.setHomePOV(e),h.requestPOV(e,t)},h.clear=()=>{h.clearPOVs(),h.clearLocomotionNodes()},h.DeviceOrientationControls=function(e){let t=this;this.object=e,this.object.rotation.reorder("YXZ"),this.enabled=!0,this.deviceOrientation={},this.screenOrientation=0,this.alphaOffset=0,this.absolute=!1,this.alphaOffsetDevice=void 0,this.alphaOffsetScreen=void 0;let o=function(e){t.absolute||(t.deviceOrientation=e)},i=function(e){t.deviceOrientation=e,t.absolute=!0},r=function(){t.screenOrientation=window.orientation||0},a=function(){let e=new THREE.Vector3(0,0,1),t=new THREE.Euler,o=new THREE.Quaternion,i=new THREE.Quaternion(-Math.sqrt(.5),0,0,Math.sqrt(.5));return function(r,a,s,n,l){t.set(s,a,-n,"YXZ"),r.setFromEuler(t),r.multiply(i),r.multiply(o.setFromAxisAngle(e,-l))}}();this.connect=function(){r(),window.addEventListener("orientationchange",r,!1),window.addEventListener("deviceorientation",o,!1),window.addEventListener("deviceorientationabsolute",i,!1),t.enabled=!0},this.disconnect=function(){window.removeEventListener("orientationchange",r,!1),window.removeEventListener("deviceorientation",o,!1),window.removeEventListener("deviceorientationabsolute",i,!1),t.enabled=!1},this.update=function(){if(!1===t.enabled)return;let e;if(e=t.deviceOrientation,e){let o=this.getDirection()?THREE.Math.degToRad(this.getDirection())+t.alphaOffset:0,i=e.beta?THREE.Math.degToRad(e.beta):0,r=e.gamma?THREE.Math.degToRad(e.gamma):0,s=t.screenOrientation?THREE.Math.degToRad(t.screenOrientation):0;a(t.object.quaternion,o,i,r,s)}},this.dispose=()=>{t.disconnect()},this.iOSOrientationPermission=()=>{"function"==typeof DeviceOrientationEvent.requestPermission&&DeviceOrientationEvent.requestPermission().then((e=>{console.log(e)})).catch(console.error)},this.getDirection=()=>void 0!==t.deviceOrientation.webkitCompassHeading?t.deviceOrientation.webkitCompassHeading:t.deviceOrientation.alpha,this.getDirectionMap=()=>void 0!==t.deviceOrientation.webkitCompassHeading?360-t.deviceOrientation.webkitCompassHeading:t.deviceOrientation.alpha,this.connect()};const m=h;let v={STD_TELEP_DURATION:.03,HAND_R:0,HAND_L:1,MOBILE_DENSITY_F:.5,MAX_QUERY_DISTANCE:40,init:()=>{ATON._renderer.xr.enabled=!0,ATON._renderer.xr.setReferenceSpaceType("local"),ATON.device.isMobile?ATON._renderer.xr.setFramebufferScaleFactor(ATON._stdpxd*v.MOBILE_DENSITY_F):ATON._renderer.xr.setFramebufferScaleFactor(ATON._stdpxd),v._bPresenting=!1,v.currSession=null,v._sessionType="immersive-vr",v._bReqPresenting=!1,v.rig=new THREE.Group,v.rig.add(ATON.Nav._camera),ATON._rootUI.add(v.rig),v._cam=void 0,v._currPos=v.rig.position,v._fromPos=new THREE.Vector3,v._reqPos=new THREE.Vector3,v.gControllers=void 0,v.controller0=void 0,v.controller1=void 0,v.controller0pos=new THREE.Vector3,v.controller1pos=new THREE.Vector3,v.controller0dir=new THREE.Vector3,v.controller1dir=new THREE.Vector3,v._lastPosR=void 0,v._lastPosL=void 0,v._pointerLineGeom=void 0,v._pointerLineMesh=void 0,v.gpad0=void 0,v.gpad1=void 0,v._urlHand=ATON.PATH_RES+"models/hand/hand.glb",ATON.on("XRselectStart",(e=>{e===v.HAND_R&&ATON._stdActivation()})),ATON.on("XRselectEnd",(e=>{})),ATON.on("XRsqueezeStart",(e=>{e===v.HAND_R&&ATON.Photon.setFocusStreaming(!0)})),ATON.on("XRsqueezeEnd",(e=>{e===v.HAND_R&&ATON.Photon.setFocusStreaming(!1)})),ATON.on("VRC_IDassigned",(e=>{let t=ATON.getUINode("Rhand"),o=ATON.getUINode("Lhand"),i=ATON.MatHub.materials.avatars,r=i[e%i.length];o&&o.setMaterial(r),t&&t.setMaterial(r)}))},setSessionType:e=>{void 0!==e&&("immersive-vr"!==e&&"immersive-ar"!==e||(v._sessionType=e,console.log("Session type: "+e)))},isPresenting:()=>v._bPresenting,teleportOnQueriedPoint:()=>{if(!ATON.Nav.currentQueryValidForLocomotion())return!1;const e=ATON._queryDataScene.p;return ATON.Nav.requestPOV((new ATON.POV).setPosition(e.x,e.y+ATON.userHeight,e.z),v.STD_TELEP_DURATION),!0},setupQueryRay:e=>{void 0!==e&&(v.controller0?e.set(v.controller0pos,v.controller0dir):e.set(ATON.Nav.getCurrentEyeLocation(),ATON.Nav.getCurrentDirection()))},setRefSpaceLocation:e=>{v.rig.position.copy(e)},_setupControllerR:(e,t)=>{v.controller0||(v.controller0=e,console.log("R controller"),e.addEventListener("selectstart",(()=>{ATON.fireEvent("XRselectStart",v.HAND_R)})),e.addEventListener("selectend",(()=>{ATON.fireEvent("XRselectEnd",v.HAND_R)})),e.addEventListener("squeezestart",(()=>{ATON.fireEvent("XRsqueezeStart",v.HAND_R)})),e.addEventListener("squeezeend",(()=>{ATON.fireEvent("XRsqueezeEnd",v.HAND_R)})),v.setupControllerUI(v.HAND_R,t),ATON.fireEvent("XRcontrollerConnected",v.HAND_R))},_setupControllerL:(e,t)=>{v.controller1||(v.controller1=e,console.log("L controller"),e.addEventListener("selectstart",(()=>{ATON.fireEvent("XRselectStart",v.HAND_L)})),e.addEventListener("selectend",(()=>{ATON.fireEvent("XRselectEnd",v.HAND_L)})),e.addEventListener("squeezestart",(()=>{ATON.fireEvent("XRsqueezeStart",v.HAND_L)})),e.addEventListener("squeezeend",(()=>{ATON.fireEvent("XRsqueezeEnd",v.HAND_L)})),v.setupControllerUI(v.HAND_L,t),ATON.fireEvent("XRcontrollerConnected",v.HAND_L))},setupSceneForAR:()=>{if("immersive-ar"!==v._sessionType)return;ATON.recomputeSceneBounds();let e=ATON.bounds.center;ATON._rootVisible.position.x=-e.x,ATON._rootVisible.position.y=-e.y,ATON._rootVisible.position.z=-e.z,ATON._rootSem.position.x=-e.x,ATON._rootSem.position.y=-e.y,ATON._rootSem.position.z=-e.z,ATON.recomputeSceneBounds()},resetSceneOffsets:()=>{ATON._rootVisible.position.set(0,0,0),ATON._rootSem.position.set(0,0,0),ATON.recomputeSceneBounds()},onSessionStarted:e=>{v.currSession||(v._bReqPresenting=!1,e.addEventListener("end",v.onSessionEnded),e.isImmersive=!0,console.log(v._sessionType+" session started."),ATON.MediaFlow.stopAllStreams(),"immersive-ar"===v._sessionType&&ATON._renderer.xr.setReferenceSpaceType("local"),ATON._renderer.xr.setSession(e).then((()=>{if(v.currSession=e,console.log(v.currSession),"immersive-ar"===v._sessionType)ATON._mainRoot.background=null,ATON._mMainPano&&(ATON._mMainPano.visible=!1),ATON._renderer.xr.getController(0)&&ATON.device.isMobile&&(v.controller0=ATON._renderer.xr.getController(0),v.controller0.addEventListener("selectstart",(()=>{ATON.fireEvent("XRselectStart",v.HAND_R),console.log("Head-aligned select")})),v.controller0.addEventListener("selectend",(()=>{ATON.fireEvent("XRselectEnd",v.HAND_R)})),v.gControllers.add(v.controller0));else{for(let e=0;e<2;e++){const t=ATON._renderer.xr.getController(e);void 0===t||t.userData.bXRconfig||(t.visible=!1,t.userData.bXRconfig=!0,t.addEventListener("connected",(e=>{let o=e.data.handedness;t.gm=e.data.gamepad,console.log("Hand "+o),console.log("GamePad "+t.gm),"left"===o?v._setupControllerL(t,!0):"right"===o?v._setupControllerR(t,!0):(t.addEventListener("selectstart",(()=>{ATON.fireEvent("XRselectStart",v.HAND_R),console.log("Head-aligned select")})),t.addEventListener("selectend",(()=>{ATON.fireEvent("XRselectEnd",v.HAND_R)})),ATON.fireEvent("XRcontrollerConnected",v.HAND_R))})))}v.rig.add(ATON.Nav._camera),v.setRefSpaceLocation(ATON.Nav._currPOV.pos)}let t=ATON._renderer.xr.getCamera(ATON.Nav._camera);ATON.Nav._updCamera(t),v._bPresenting=!0,ATON.Nav._bInteracting=!1,console.log("XR now presenting"),ATON.fireEvent("XRmode",!0),ATON.toggleShadows(!1),ATON.SUI.getSelectorRadius()>ATON.FE.STD_SEL_RAD&&ATON.SUI.setSelectorRadius(ATON.FE.STD_SEL_RAD),ATON._qSyncInt=2,ATON.XPFNetwork.getNumXPFs()>0?ATON.setQueryRange(0,100):ATON.setQueryRange(0,v.MAX_QUERY_DISTANCE),ATON.MRes.estimateTSErrorTarget(),setTimeout((()=>{ATON.SUI.getSelectorRadius()>ATON.FE.STD_SEL_RAD&&ATON.SUI.setSelectorRadius(ATON.FE.STD_SEL_RAD)}),2e3)})))},onSessionEnded:()=>{v.currSession.removeEventListener("end",v.onSessionEnded),v.currSession=null,v._bReqPresenting=!1,v._bPresenting=!1,ATON.Nav._bInteracting=!1,"immersive-ar"===v._sessionType&&ATON._mMainPano&&(ATON._mMainPano.visible=!0),v.setRefSpaceLocation(new THREE.Vector3(0,0,0)),ATON.fireEvent("XRmode",!1),ATON._qSyncInt=1,ATON.MediaFlow.stopAllStreams(),ATON.Nav.requestHome(),ATON.Nav._updCamera(),ATON.setQueryRange(0,1/0),ATON.MRes.estimateTSErrorTarget(),console.log("Quit XR")},toggle:e=>{if(v.setSessionType(e),ATON.device.xrSupported[v._sessionType])if(null===v.currSession){let e={optionalFeatures:["high-refresh-rate"]};"immersive-ar"===v._sessionType&&(void 0===e.optionalFeatures&&(e.optionalFeatures=[]),e.optionalFeatures.push("light-estimation")),v._bReqPresenting=!0,navigator.xr.requestSession(v._sessionType,e).then(v.onSessionStarted)}else v.currSession.end()},setupControllerUI:(e,t)=>{let o,i;if(void 0===v.gControllers&&(v.gControllers=ATON.createUINode(),v.gControllers.disablePicking(),v.rig.add(v.gControllers)),e===v.HAND_L?(v.gControllers.add(v.controller1),t&&(i=ATON.createUINode("Lhand").load(v._urlHand).setMaterial(ATON.MatHub.materials.controllerRay).setScale(-1,1,1),v.controller1.add(i))):(v.gControllers.add(v.controller0),t&&(v._pointerLineGeom=new THREE.CylinderGeometry(.003,.003,1,4),v._pointerLineGeom.rotateX(-Math.PI/2),v._pointerLineGeom.translate(0,0,-.5),v._pointerLineMesh=new THREE.Mesh(v._pointerLineGeom,ATON.MatHub.materials.controllerRay),v.controller0.add(v._pointerLineMesh),v._pointerLineMesh.visible=!1,o=ATON.createUINode("Rhand").load(v._urlHand).setMaterial(ATON.MatHub.materials.controllerRay),v.controller0.add(o))),void 0!==ATON.Photon.uid&&t){let t=ATON.MatHub.materials.avatars,r=t[ATON.Photon.uid%t.length];e===v.HAND_L?i.setMaterial(r):o.setMaterial(r)}},switchHands:()=>{let e=v.controller1;v.controller1=v.controller0,v.controller0=e;for(let e in v.controller0.children)v.controller0.remove(v.controller0.children[e]);for(let e in v.controller1.children)v.controller1.remove(v.controller1.children[e]);v.gControllers.removeChildren(),v.setupControllerUI(v.HAND_L),v.setupControllerUI(v.HAND_R),console.log("VR controllers switched")},getControllerSpace:e=>{1===e?v.getControllerGrip(1):v.getControllerGrip(0)},getControllerWorldLocation:e=>1===e?v.controller1pos:v.controller0pos,getControllerWorldDirection:e=>1===e?v.controller1dir:v.controller0dir,_deltaMotionController:e=>{if(e===v.HAND_L&&void 0===v._lastPosL)return;if(e===v.HAND_R&&void 0===v._lastPosR)return;let t=e===v.HAND_L?v.controller1pos:v.controller0pos,o=e===v.HAND_L?v._lastPosL:v._lastPosR;THREE.Vector3(t.x-o.x,t.y-o.y,t.z-o.z).lengthSq(),e===v.HAND_L?v._lastPosL=t:v._lastPosR=t},update:()=>{v.controller0&&v.controller0.visible&&(v.controller0.getWorldPosition(v.controller0pos),v.controller0.getWorldDirection(v.controller0dir),v.controller0dir.negate()),v.controller1&&v.controller1.visible&&(v.controller1.getWorldPosition(v.controller1pos),v.controller1.getWorldDirection(v.controller1dir),v.controller1dir.negate())},getAxisValue:e=>{let t=new THREE.Vector2(0,0),o=e===v.HAND_L?v.controller1:v.controller0;if(void 0===o)return t;if(void 0===o.gm||void 0===o.gm.axes)return t;let i=o.gm.axes[0],r=o.gm.axes[2],a=o.gm.axes[1],s=o.gm.axes[3];return t.x=i>0?-i:r,t.y=a>0?a:-s,t}};const T=v,g=class extends t{constructor(e,t,o){super(e,ATON.NTYPES.UI),this.baseColor=ATON.MatHub.colors.black,this.baseOpacity=.5,this.container=new ThreeMeshUI.Block({width:t||.2,height:o||.05,padding:.001,borderRadius:.01,backgroundColor:this.baseColor,backgroundOpacity:this.baseOpacity,fontFamily:ATON.SUI.PATH_FONT_JSON,fontTexture:ATON.SUI.PATH_FONT_TEX,justifyContent:"center",textAlign:"center"}),this.container.position.z=.03,this.add(this.container),this.uiText=new ThreeMeshUI.Text({content:"Label",fontSize:.03,fontColor:ATON.MatHub.colors.white}),this.container.add(this.uiText),ThreeMeshUI.update()}setBaseColor(e){return this.baseColor=e,this.container.set({backgroundColor:this.baseColor}),ThreeMeshUI.update(),this}setTextColor(e){return this.uiText.set({fontColor:e}),ThreeMeshUI.update(),this}setBackgroundOpacity(e){return this.container.set({backgroundOpacity:e}),this.baseOpacity=e,ThreeMeshUI.update(),this}setText(e){return this.uiText.set({content:e}),ThreeMeshUI.update(),this}};let S={STD_BTN_SIZE:.1,STD_SELECTOR_TICKNESS:1.05};S.Button=class extends t{constructor(e,t=1,o=1){super(e,ATON.NTYPES.UI),this.baseColor=ATON.MatHub.colors.black,this.switchColor=ATON.MatHub.colors.green,this.baseOpacity=.5,this.hoverOpacity=.8,this._bSwitched=!1,this.container=new ThreeMeshUI.Block({width:.1*t,height:.1,padding:.01,borderRadius:.02,backgroundColor:this.baseColor,backgroundOpacity:this.baseOpacity,fontFamily:ATON.SUI.PATH_FONT_JSON,fontTexture:ATON.SUI.PATH_FONT_TEX,justifyContent:"center",textAlign:"center"}),this.add(this.container),this.uiText=new ThreeMeshUI.Text({content:"",fontSize:.02*o,fontColor:ATON.MatHub.colors.white}),this.container.add(this.uiText);let i=.9*ATON.SUI.STD_BTN_SIZE*t,r=.9*ATON.SUI.STD_BTN_SIZE;this._trigger=new THREE.Mesh(new THREE.PlaneGeometry(i,r,2),ATON.MatHub.materials.fullyTransparent),this._trigger.position.set(0,0,.002),this.add(this._trigger),this.onHover=()=>{this.container.set({backgroundOpacity:this.hoverOpacity})},this.onLeave=()=>{this.container.set({backgroundOpacity:this.baseOpacity})},this.enablePicking(),this.traverse((e=>{e.material&&(e.material.depthWrite=!1)})),ThreeMeshUI.update()}setBaseColor(e){return this.baseColor=e,this._bSwitched||this.container.set({backgroundColor:this.baseColor}),ThreeMeshUI.update(),this}setSwitchColor(e){return this.switchColor=e,this._bSwitched&&this.container.set({backgroundColor:this.switchColor}),ThreeMeshUI.update(),this}setBackgroundOpacity(e){return this.container.set({backgroundOpacity:e}),this.baseOpacity=e,ThreeMeshUI.update(),this}setText(e){return this.uiText.set({content:e}),ThreeMeshUI.update(),this}switch(e){return this._bSwitched=e,e?this.container.set({backgroundColor:this.switchColor}):this.container.set({backgroundColor:this.baseColor}),ThreeMeshUI.update(),this}setIcon(e,t){return ATON.Utils.textureLoader.load(e,(e=>{this._trigger.material=new THREE.MeshStandardMaterial({map:e,transparent:!0,depthWrite:!1}),t&&(this.setBackgroundOpacity(0),this.hoverOpacity=0),this.uiText.position.set(0,-.035,0)})),ThreeMeshUI.update(),this}},S.Label=g,S.MediaPanel=class extends t{constructor(e){super(e,ATON.NTYPES.UI),this._resurl=void 0,this._mediamesh=void 0,this._vs=void 0,this._yratio=1,this._titleYoffs=.6,this._color=ATON.MatHub.colors.black;let t=this;this.onSelect=()=>{t._vs&&t._vs.el}}load(e,t){this._yratio=1,this._mediamesh||(this._mediamesh=new THREE.Mesh(new THREE.PlaneGeometry(1,1)),this.add(this._mediamesh)),e=ATON.Utils.resolveCollectionURL(e);let o=this;return ATON.Utils.isVideo(e)?(this._vs=ATON.MediaFlow.getOrCreateVideoStream(this.nid,e,!1),this._mediamesh.material=this._vs.matStream,this._vs.el.addEventListener("loadedmetadata",(i=>{o._yratio=o._vs.el.videoHeight/o._vs.el.videoWidth,o._mediamesh.scale.y=-o._yratio,o._resurl=e,o._onContentLoad(),t&&t()}))):ATON.Utils.loadTexture(e,(i=>{i.image&&(this._yratio=i.image.height/i.image.width),o._mediamesh.scale.y=o._yratio,o._mediamesh.material=ATON.MatHub.materials.chromakey.clone(),o._mediamesh.material.uniforms.tBase.value=i,o._mediamesh.material.needsUpdate=!0,o._resurl=e,o._onContentLoad(),t&&t()})),this.setPickable(!0),this}setColor(e){return this._color=e,this._labelTitle&&this._labelTitle.setBaseColor(e),this._bd&&(this._bd.material.color=e),this}getMaterial(){return this._mediamesh.material}_onContentLoad(){this._labelTitle&&(this._labelTitle.position.y=this._yratio*this._titleYoffs),this._bd&&(this._bd.scale.y=1.05*this._yratio)}setTitle(e){return this._labelTitle||(this._labelTitle=new g(void 0,.5,.07),this._labelTitle.position.z=-.01,this._labelTitle.attachTo(this)),this._labelTitle.setText(e),this._labelTitle.setBaseColor(this._color),this}toggleTitle(e){return this._labelTitle?(this._labelTitle.toggle(e),this):this}setBackdrop(e){return this._bd=new THREE.Mesh(new THREE.PlaneGeometry(1,1)),this._bd.material=new THREE.MeshStandardMaterial({transparent:!0,side:THREE.DoubleSide,color:this._color,opacity:e||.5}),this._bd.scale.x=1.05,this._bd.scale.y=1.05*this._yratio,this._bd.position.z=-.005,this.add(this._bd),this}},S.init=()=>{S.initSelector(),S.fpTeleport=ATON.createUINode();let e=new THREE.CylinderGeometry(.4,.4,.9,32,1,!0),t=new THREE.Mesh(e,ATON.MatHub.getMaterial("teleportLoc"));t.renderOrder=100,S.fpTeleport.add(t),S.fpTeleport.disablePicking(),S.fpTeleport.visible=!1,ATON._rootUI.add(S.fpTeleport),S.PATH_FONT_JSON||(S.PATH_FONT_JSON=ATON.PATH_RES+"fonts/custom-msdf.json"),S.PATH_FONT_TEX||(S.PATH_FONT_TEX=ATON.PATH_RES+"fonts/custom.png"),S.gMeasures=ATON.createUINode(),S._prevMPoint=void 0,S._measLabels=[],ATON._rootUI.add(S.gMeasures);let o=(new THREE.BufferGeometry).setFromPoints([new THREE.Vector3,new THREE.Vector3]);S._measLine=new THREE.Line(o,ATON.MatHub.getMaterial("measurement")),S._measLine.visible=!1,ATON._rootUI.add(S._measLine),S.gPoints=ATON.createUINode(),ATON._rootUI.add(S.gPoints),S.gLocNodes=ATON.createUINode(),ATON._rootUI.add(S.gLocNodes),S.buildInfoNode(),S.bShowInfo=!0,S._labelScale=ATON.Utils.isMobile()?80:90,S._labelScaleVR=2,S.sprites={},S._sync=0},S.getOrCreateSpritePointEdit=()=>(S.sprites.pointEdit||(S.sprites.pointEdit=new THREE.SpriteMaterial({map:(new THREE.TextureLoader).load(ATON.PATH_RES+"sui-point.png"),color:ATON.MatHub.colors.orange,transparent:!0,opacity:1,depthTest:!1})),S.sprites.pointEdit),S.getOrCreateSpriteSemIcon=()=>(S.sprites.semIcon||(S.sprites.semIcon=new THREE.SpriteMaterial({map:(new THREE.TextureLoader).load(ATON.PATH_RES+"sui-sem.png"),transparent:!0,opacity:1,depthWrite:!1,depthTest:!1})),S.sprites.semIcon),S.getOrCreateSpriteLP=()=>(S.sprites.lp||(S.sprites.lp=new THREE.SpriteMaterial({map:(new THREE.TextureLoader).load(ATON.PATH_RES+"sui-lp.png"),transparent:!0,opacity:1,depthWrite:!1}),S.sprites.lp.sizeAttenuation=!1),S.sprites.lp),S.getOrCreateSpriteWalk=()=>(S.sprites.walk||(S.sprites.walk=new THREE.SpriteMaterial({map:(new THREE.TextureLoader).load(ATON.PATH_RES+"sui-walk.png"),transparent:!0,opacity:1,depthWrite:!1})),S.sprites.walk),S.initSelector=()=>{S.mainSelector=ATON.createUINode(),S._mSelectorSphere=new THREE.Mesh(ATON.Utils.geomUnitSphere,ATON.MatHub.getMaterial("selector")),S._mSelectorSphere.renderOrder=100,S.mainSelector.add(S._mSelectorSphere),S.mainSelector.disablePicking(),S.setSelectorRadius(.05),S.mainSelector.visible=!1,ATON._rootUI.add(S.mainSelector),S._selOffset=new THREE.Vector3,S._bShowSelector=!0},S.enableLPIcons=()=>{S.gLPIcons=ATON.createUINode(),S.gLPIcons.disablePicking(),ATON._rootUI.add(S.gLPIcons)},S.enableSemIcons=()=>{S.gSemIcons=ATON.createUINode(),S.gSemIcons.disablePicking(),ATON._rootUI.add(S.gSemIcons)},S.showSelector=e=>{S._bShowSelector=e},S.setSelectorRadius=e=>{S._selectorRad=e,S.mainSelector.scale.set(e,e,e)},S.setSelectorOffset=(e,t,o)=>{void 0!==e&&(S._selOffset.x=e),void 0!==t&&(S._selOffset.y=t),void 0!==o&&(S._selOffset.z=o);let i=ATON.getSceneQueriedPoint();void 0!==i&&(S.mainSelector.position.x=i.x+S._selOffset.x,S.mainSelector.position.y=i.y+S._selOffset.y,S.mainSelector.position.z=i.z+S._selOffset.z)},S.getSelectorRadius=()=>S._selectorRad,S.getSelectorLocation=()=>S.mainSelector.position,S.setSelectorModel=(e,t)=>{void 0!==e&&(S.mainSelector.removeChildren(),S.mainSelector.load(e).disablePicking(),t&&S.mainSelector.setMaterial(ATON.MatHub.getMaterial("selector")))},S.setSelectorColor=(e,t)=>{let o=ATON.MatHub.materials.selector;o.uniforms.tint.value=e,void 0!==t&&(o.uniforms.opacity.value=t)},S.addSemIcon=(e,t)=>{if(void 0===S.gSemIcons)return;let o=(new THREE.Box3).setFromObject(t),i=new THREE.Sphere;o.getBoundingSphere(i);let r=new THREE.Sprite(S.getOrCreateSpriteSemIcon());r.position.copy(i.center),r.scale.set(.8,.8,1),r.name=e,S.gSemIcons.add(r)},S.addLPIcon=e=>{if(void 0===S.gLPIcons)return;let t=e._near,o=new THREE.Sprite(S.getOrCreateSpriteLP());o.position.copy(e.pos),o.scale.set(.1,.1,.1);let i=new THREE.Mesh(ATON.Utils.geomUnitSphere,ATON.MatHub.materials.lp);i.scale.set(t,t,t),i.position.copy(e.pos),S.gLPIcons.add(o),S.gLPIcons.add(i)},S.setSemIconsOpacity=e=>{ATON.MatHub.spriteSemIcon.opacity=void 0===e?1:e},S.buildInfoNode=()=>{S.infoNode=ATON.createUINode(),S.infoNode.attachToRoot(),S.infoContainer=new ThreeMeshUI.Block({width:.2,height:.05,padding:.01,borderRadius:.02,backgroundColor:ATON.MatHub.colors.black,backgroundOpacity:.4,fontFamily:S.PATH_FONT_JSON,fontTexture:S.PATH_FONT_TEX,justifyContent:"center",textAlign:"center"}),S.infoContainer.position.y=.03,S.infoNode.add(S.infoContainer),S.infoNodeText=new ThreeMeshUI.Text({content:"Info",fontSize:.02,fontColor:ATON.MatHub.colors.white}),S.infoContainer.add(S.infoNodeText),ThreeMeshUI.update()},S.getInfoNode=()=>S.infoNode,S.setInfoNodeText=e=>{S.bShowInfo&&(S.infoNodeText.set({content:e}),ThreeMeshUI.update())},S.createToolbar=(e,t,o)=>{let i=ATON.createUINode(),r=e.length,a=.3*S.STD_BTN_SIZE,s=new ThreeMeshUI.Block({width:S.STD_BTN_SIZE*r*1.1+a,height:S.STD_BTN_SIZE+a,padding:.01,borderRadius:.02,backgroundColor:t||ATON.MatHub.colors.black,backgroundOpacity:void 0!==o?o:.3,fontFamily:S.PATH_FONT_JSON,fontTexture:S.PATH_FONT_TEX,justifyContent:"center",textAlign:"center"}),n=.5*r*S.STD_BTN_SIZE*1.1;n-=.5*S.STD_BTN_SIZE;for(let t=0;t{void 0===o&&(o=1),void 0===i&&(i=1);let r=ATON.createUINode(e),a=new THREE.Mesh(new THREE.PlaneGeometry(o,i,2),ATON.MatHub.materials.fullyTransparent);return r.add(a),void 0!==t&&ATON.Utils.textureLoader.load(t,(e=>{a.material=new THREE.MeshStandardMaterial({map:e,transparent:!0,depthWrite:!1,side:THREE.DoubleSide})})),r},S.createLayout=(e,t)=>{let o=e.children.length;for(let i=0;i{if(void 0===e)return;let t=.01,o=.001;if(void 0===S._prevMPoint){S._prevMPoint=e;let t=S._measLine.geometry.attributes.position.array;return t[0]=e.x,t[1]=e.y,void(t[2]=e.z)}S._measLine.visible=!1;let i=S._prevMPoint.distanceTo(e);t*=i,o*=i;let r=new THREE.Mesh(ATON.Utils.geomUnitCube,ATON.MatHub.getMaterial("measurement"));r.position.copy(S._prevMPoint),r.scale.set(t,t,t),S.gMeasures.add(r);let a=new THREE.Mesh(ATON.Utils.geomUnitCube,ATON.MatHub.getMaterial("measurement"));a.position.copy(e),a.scale.set(t,t,t),S.gMeasures.add(a);let s=2*i,n=(new THREE.BufferGeometry).setFromPoints([S._prevMPoint,e]);S.gMeasures.add(new THREE.Line(n,ATON.MatHub.getMaterial("measurement")));let l=new S.Label;l.setBaseColor(ATON.MatHub.colors.white).setTextColor(ATON.MatHub.colors.black),l.userData.vStart=new THREE.Vector3,l.userData.vEnd=new THREE.Vector3,l.userData.vStart.copy(S._prevMPoint),l.userData.vEnd.copy(e),l.userData.vSEdir=new THREE.Vector3,l.userData.vSEdir.x=l.userData.vStart.x-l.userData.vEnd.x,l.userData.vSEdir.y=l.userData.vStart.y-l.userData.vEnd.y,l.userData.vSEdir.z=l.userData.vStart.z-l.userData.vEnd.z,l.userData.vSEdir.normalize(),l.setPosition(.5*(S._prevMPoint.x+e.x),.5*(S._prevMPoint.y+e.y),.5*(S._prevMPoint.z+e.z)),l.setScale(s).setText(ATON.Utils.getHumanReadableDistance(i)),S.gMeasures.add(l),S._measLabels.push(l);let d={};return d.A=l.userData.vStart,d.B=l.userData.vEnd,S._prevMPoint=void 0,d},S.clearMeasurements=()=>{S.gMeasures.removeChildren(),S._measLabels=[]},S._updateMeasurements=()=>{if(!(S._measLabels.length<=0))for(let e in S._measLabels)S._measLabels[e].orientToCamera()},S.update=()=>{if(ATON.Nav.isTransitioning()||ATON._bPauseQuery)S.infoNode.visible=!1;else{if(S._prevMPoint){if(ATON._queryDataScene){let e=S._measLine.geometry.attributes.position.array;e[3]=ATON._queryDataScene.p.x,e[4]=ATON._queryDataScene.p.y,e[5]=ATON._queryDataScene.p.z,S._measLine.geometry.attributes.position.needsUpdate=!0}S._measLine.visible=!0}else S._measLine.visible=!1;if(ATON._queryDataScene&&!ATON.Nav._bInteracting?(S._bShowSelector&&(S.mainSelector.visible=!0),S.mainSelector.position.x=ATON._queryDataScene.p.x+S._selOffset.x,S.mainSelector.position.y=ATON._queryDataScene.p.y+S._selOffset.y,S.mainSelector.position.z=ATON._queryDataScene.p.z+S._selOffset.z):S.mainSelector.visible=!1,S.gSemIcons&&(ATON.Nav._bInteracting?S.gSemIcons.hide():void 0===ATON._hoveredSemNode&&S.gSemIcons.show()),ATON.Nav.isOrbit()&&!ATON.XR._bPresenting||!ATON.Nav.currentQueryValidForLocomotion()?S.fpTeleport.visible=!1:(S.fpTeleport.visible=!0,S.fpTeleport.position.copy(ATON._queryDataScene.p)),ATON.XR._pointerLineMesh){let e=0;ATON._queryDataScene&&(e=ATON._queryDataScene.d),ATON._queryDataUI&&(e<=0||ATON._queryDataUI.d0?(ATON.XR._pointerLineMesh.visible=!0,ATON.XR._pointerLineMesh.scale.set(1,1,e)):ATON.XR._pointerLineMesh.visible=!1}if(S._updateMeasurements(),ATON._queryDataSem)ATON.XR._bPresenting&&(S.bShowInfo&&(S.infoNode.visible=!0),ATON.XR.controller0?(S.infoNode.position.copy(ATON.XR.controller0pos),S.infoNode.position.x-=.1*ATON.XR.controller0dir.x,S.infoNode.position.y-=.1*ATON.XR.controller0dir.y,S.infoNode.position.z-=.1*ATON.XR.controller0dir.z,S.infoNode.setScale(1)):(S.infoNode.position.lerpVectors(ATON._queryDataSem.p,ATON.Nav._currPOV.pos,.1),S.infoNode.setScale(ATON._queryDataSem.d*S._labelScaleVR)),S.infoNode.orientToCamera()),ATON.Photon._bStreamFocus||(S.mainSelector.visible=!1);else if(ATON.XR._bPresenting&&S.bShowInfo&&ATON._queryDataScene&&void 0!==ATON.XPFNetwork._semCurr){S.infoNode.position.lerpVectors(ATON._queryDataScene.p,ATON.Nav._currPOV.pos,.5);const e=ATON._queryDataScene.d*(ATON.Nav._currPOV.fov/S._labelScale);S.infoNode.setScale(e),S.infoNode.orientToCamera(),S.infoNode.visible=!0}else S.infoNode.visible=!1;if(S.mainSelector.visible&&ATON.Photon._bStreamFocus){let e=S._selectorRad*(1+.2*Math.cos(10*ATON._clock.elapsedTime));S.mainSelector.scale.set(e,e,e);let t=ATON.getSceneFocalPoint();void 0!==t&&void 0!==ATON.plight&&(ATON.enablePointLight(),ATON.plight.position.copy(t),ATON.plight.distance=2*S._selectorRad)}}};const N=S;let O={init:()=>{window.bootstrap&&(O.PATH_RES_ICONS=ATON.PATH_RES+"icons/",O._bModal=!1,O._bSidePanel=!1,O._bSemL=!1,O._setupBase())},createElemementFromHTMLString:e=>{const t=document.createElement("div");return t.innerHTML=e,t.firstElementChild},onContextMenu:()=>!1,_setupBase:()=>{document.body.oncontextmenu=O.onContextMenu,document.body.setAttribute("data-bs-theme","dark"),O.elCenteredOverlay=O.createElemementFromHTMLString('\n
    \n
    Loading...
    \n
    \n\t'),document.body.append(O.elCenteredOverlay),O.hideCenteredOverlay(),O.elLabelCon=document.createElement("div"),O.elLabelCon.classList.add("aton-floating-label-container"),O.elLabel=document.createElement("div"),O.elLabel.classList.add("aton-floating-label"),O.elLabelCon.append(O.elLabel),document.body.prepend(O.elLabelCon),O.hideSemLabel(),O.elModal=O.createElemementFromHTMLString('\n \n\t'),O.modal=new bootstrap.Modal(O.elModal),document.body.append(O.elModal),O.elModalContent=document.getElementById("uiModalContent"),O.elSidePanel=O.createElemementFromHTMLString('\n
    \n\t'),O.sidepanel=new bootstrap.Offcanvas(O.elSidePanel),document.body.append(O.elSidePanel)},showCenteredOverlay:e=>{O.elCenteredOverlay.classList.add("d-flex"),O.elCenteredOverlay.classList.remove("d-none")},hideCenteredOverlay:()=>{O.elCenteredOverlay.classList.remove("d-flex"),O.elCenteredOverlay.classList.add("d-none")},showModal:e=>{if(e){if(O.elModalContent.innerHTML="",e.header){let t=document.createElement("div");t.classList.add("modal-header"),t.innerHTML="",O.elModalContent.append(t)}if(e.body){let t=document.createElement("div");t.classList.add("modal-body"),t.append(e.body),O.elModalContent.append(t)}if(e.footer){let t=document.createElement("div");t.classList.add("modal-footer"),t.append(e.footer),O.elModalContent.append(t)}O.modal.show(),O._bModal=!0}},hideModal:()=>{O.modal.hide(),O._bModal=!1},showSidePanel:e=>{if(e){if(O.elSidePanel.innerHTML="",e.header){let t=document.createElement("div");t.classList.add("offcanvas-header"),t.innerHTML="

    "+e.header+"

    ",O.elSidePanel.append(t)}if(e.body){let t=document.createElement("div");t.classList.add("offcanvas-body"),t.append(e.body),O.elSidePanel.append(t)}O.sidepanel.show(),O._bSidePanel=!0}},hideSidePanel:()=>{O.sidepanel.hide(),O._bSidePanel=!1},addBasicEvents:()=>{ATON.on("NodeRequestFired",(()=>{O.showCenteredOverlay()})),ATON.on("AllNodeRequestsCompleted",(()=>{O.hideCenteredOverlay()})),ATON.on("SemanticNodeHover",(e=>{let t=ATON.getSemanticNode(e);void 0!==t&&(O.showSemLabel(e),t.highlight(),$("canvas").css({cursor:"pointer"}),ATON.SUI.gSemIcons&&ATON.SUI.gSemIcons.hide())})),ATON.on("SemanticNodeLeave",(e=>{let t=ATON.getSemanticNode(e);void 0!==t&&(O.hideSemLabel(),t.restoreDefaultMaterial(),$("canvas").css({cursor:"grab"}),ATON.SUI.gSemIcons&&ATON.SUI.gSemIcons.show())})),ATON.on("SemanticMaskHover",(e=>{O.showSemLabel(e),$("canvas").css({cursor:"pointer"})})),ATON.on("SemanticMaskLeave",(e=>{O.hideSemLabel(),$("canvas").css({cursor:"grab"})})),ATON.addUpdateRoutine(O.update)},update:()=>{if(O._bSemL&&!ATON.XR._bPresenting){let e=.5*ATON._screenPointerCoords.x*window.innerWidth,t=.5*(1-ATON._screenPointerCoords.y)*window.innerHeight;t-=35,O.elLabel.style.transform="translate("+e+"px, "+t+"px)"}},showSemLabel:e=>{O.elLabel.innerHTML=e,O.elLabel.style.display="inline-block",O._bSemL=!0},hideSemLabel:()=>{O.elLabel.style.display="none",O._bSemL=!1},loadPartial:(e,t,o,i)=>{$.get(e,(e=>{t?o?$("#"+t).prepend(e):$("#"+t).append(e):o?$("body").prepend(e):$("body").append(e),i&&i()}))},resolveIconURL:e=>e.includes("/")?e:O.PATH_RES_ICONS+e+".png",createButton:e=>{let t=document.createElement("button");return t.classList.add("btn","aton-btn"),t.setAttribute("type","button"),e.variant&&t.classList.add("btn-"+e.variant),e.text&&(t.innerText=e.text),e.icon&&t.prepend(O.createElemementFromHTMLString("")),e.onpress&&(t.onclick=e.onpress),t},createTabsGroup:e=>{let t=ATON.Utils.generateID("tabgroup"),o=document.createElement("div"),i=document.createElement("ul");i.classList.add("nav","nav-justified","nav-tabs"),i.setAttribute("role","tablist");let r=document.createElement("div");r.classList.add("tab-content"),o.append(i),o.append(r);for(let o=0;o");let c,u=t+"-"+s,_=document.createElement("li");_.classList.add("nav-item"),_.setAttribute("role","presentation"),_.innerHTML=0===o?"":"",i.append(_),c=0===o?O.createElemementFromHTMLString("
    "):O.createElemementFromHTMLString("
    "),c.style.padding="10px 0px 10px 0px",c.append(n),r.append(c)}return o}};const A=O;let b={USER_STATE_FREQ:.25,REPLICATED_EVT:"EREP",THRES_STATE_POS:.01,THRES_STATE_ORI:.08};b.Avatar=class extends t{constructor(e){super(void 0,ATON.NTYPES.UI),this.userid=e,this.username=void 0,this.message="...",this.color=ATON.Photon.ucolors[this.userid%ATON.Photon.ucolors.length],this._auTalk=[],this._auTalk.push(new THREE.PositionalAudio(ATON.AudioHub._listener)),this._auTalk.push(new THREE.PositionalAudio(ATON.AudioHub._listener));for(let e=0;e<2;e++)this._auTalk[e].setRefDistance(30),this._auTalk[e].setLoop(!1),this.add(this._auTalk[e]);this._auTalki=0,this.bMuted=!1,this._bPlayingAudio=!1,this._blob=void 0,this._b64=void 0,this._tStateCall=-1,this._tProgress=0,this._tFocCall=-1,this._currFocusPos=new THREE.Vector3,this._tgtFocusPos=new THREE.Vector3,this._currState={position:new THREE.Vector3,quaternion:new THREE.Quaternion,scale:1},this._tgtState={position:new THREE.Vector3,quaternion:new THREE.Quaternion,scale:1},this.userlabelnode=void 0,this.mStream=void 0,this._elVStream=void 0,this.realize()}getColor(){return this.color}setTalkDistance(e){e>0&&this._auTalk.setRefDistance(e)}setMuted(e){this.bMuted=e}getAvatarMaterialByUID(e){let t=ATON.MatHub.materials.avatars;return t[e%t.length]}_buildLabel(){this.userlabelnode=ATON.createUINode(),this.labelcontainer=new ThreeMeshUI.Block({width:.7,height:.25,padding:.03,borderRadius:.05,backgroundColor:ATON.MatHub.colors.black,fontFamily:ATON.SUI.PATH_FONT_JSON,fontTexture:ATON.SUI.PATH_FONT_TEX,justifyContent:"center",textAlign:"center"}),this.userlabelnode.position.y=.4,this.userlabelnode.add(this.labelcontainer),this.usernametext=new ThreeMeshUI.Text({content:"User #"+this.userid,fontSize:.09,fontColor:this.color}),this.usernametext.position.y=0,this.usermessagetext=new ThreeMeshUI.Text({content:"\n...",fontSize:.03,fontColor:ATON.MatHub.colors.white}),this.usermessagetext.position.y=0,this.labelcontainer.add(this.usernametext),this.labelcontainer.add(this.usermessagetext),this.add(this.userlabelnode),ThreeMeshUI.update()}realizeStreamPanel(){let e=ATON.MediaFlow.getOrCreateVideoStream(this.userid,void 0,!0);this._elVStream=e.el;let t=new THREE.PlaneGeometry(1,1);this.mStream=new THREE.Mesh(t,e.matStream),this.mStream.position.y=1;let o=.5625;this.mStream.scale.y=-o,this.mStream.position.y=.8*o,this._elVStream.addEventListener("loadedmetadata",(e=>{o=this._elVStream.videoHeight/this._elVStream.videoWidth,this.mStream.scale.y=-o,this.mStream.position.y=.8*o}))}getStreamPanel(){return this.mStream}toggleStreamPanel(e){void 0!==this.mStream&&(this.mStream.visible=e)}realize(){let e=new THREE.SphereGeometry(.2,16,16);ATON.Photon.customAvatarMaterial?this.usermaterial=ATON.Photon.customAvatarMaterial():this.usermaterial=this.getAvatarMaterialByUID(this.userid);let t=new THREE.Mesh(e,this.usermaterial);this.usermeshnode=ATON.createUINode(),this.usermeshnode.add(t),this.usermeshnode.setMaterial(this.usermaterial),this.usermeshnode.setCloneOnLoadHit(!1),this.add(this.usermeshnode),this.userauinode=new THREE.Sprite(ATON.Photon.uspritemats[this.userid%ATON.Photon.uspritemats.length]),this.userauinode.position.set(0,0,0),this.userauinode.visible=!1,this.add(this.userauinode),this.userfpnode=new THREE.Sprite(ATON.Photon.ufocmats[this.userid%ATON.Photon.ufocmats.length]),this.userfpnode.position.set(0,0,0),this.userfpnode.visible=!1,void 0===ATON.Photon._focNodes[this.userid]&&(ATON.Photon._focNodes[this.userid]=this.userfpnode,ATON.Photon.focGroup.add(this.userfpnode)),this._buildLabel()}loadRepresentation(e){let t=this;return void 0!==t.usermeshnode.children[0]&&t.usermeshnode.remove(t.usermeshnode.children[0]),t.usermeshnode.load(e),this}setUsername(e){return void 0===this.userlabelnode||(this.username=e,this.usernametext.set({content:e}),ThreeMeshUI.update()),this}getUsername(){if(void 0!==this.userid)return void 0===this.username?"User #"+this.userid:this.username}setMessage(e){return void 0===this.userlabelnode||(this.message=e,this.usermessagetext.set({content:"\n"+e}),ThreeMeshUI.update()),this}setTalkVolume(e){if(void 0!==e)if(e>0){this.userauinode.visible=!0;let t=.1+.03*e;this.userauinode.scale.set(t,t,t)}else this.userauinode.visible=!1;else this.userauinode.visible=!1}hideFocalPoint(){this.userfpnode.visible=!1}requestFocus(e){if(void 0===e)return;if(this._tFocCall>=0)return;this._tFocCall=ATON._clock.elapsedTime,this._currFocusPos.copy(this.userfpnode.position);let t=this.scale.x*ATON._worldScale,o=parseFloat(e[0])*t,i=parseFloat(e[1])*t,r=parseFloat(e[2])*t,a=parseFloat(e[3])*t;this._tgtFocusPos.set(o,i,r),this._tgtFocusRad=2*a,this.userfpnode.scale.set(this._tgtFocusRad,this._tgtFocusRad,this._tgtFocusRad),this.userfpnode.visible=!0,ATON.enablePointLight(),ATON.plight.color=this.color,ATON.plight.position.copy(this._tgtFocusPos),ATON.plight.distance=this._tgtFocusRad}handleFocusTransition(){if(this._tFocCall<0)return;let e=ATON.Photon.USER_STATE_FREQ,t=(ATON._clock.elapsedTime-this._tFocCall)/e;if(t>=1)return this._tFocCall=-1,this.userfpnode.position.copy(this._tgtFocusPos),this.userfpnode.scale.set(this._tgtFocusRad,this._tgtFocusRad,this._tgtFocusRad),void(this.userfpnode.visible=!0);this.userfpnode.position.lerpVectors(this._currFocusPos,this._tgtFocusPos,t),ATON.plight.position.copy(this.userfpnode.position),this.userfpnode.visible=!0}requestStateTransition(e){this._tStateCall>=0||void 0!==e&&(this._tStateCall=ATON._clock.elapsedTime,this._currState.position.copy(this.position),this._currState.quaternion.copy(this.quaternion),this._currState.scale=this.scale,this._tgtState.position.copy(e.position),this._tgtState.quaternion.copy(e.quaternion),this._tgtState.scale=1/e.scale)}handleStateTransition(){if(this._tStateCall<0)return;let e=ATON.Photon.USER_STATE_FREQ;this._tProgress=e<=0?1:(ATON._clock.elapsedTime-this._tStateCall)/e;let t=this._currState,o=this._tgtState;if(this._tProgress>=1)return this._tStateCall=-1,this.position.copy(o.position),void this.usermeshnode.quaternion.copy(o.quaternion);this.position.lerpVectors(t.position,o.position,this._tProgress),this.usermeshnode.quaternion.slerp(o.quaternion,this._tProgress)}update(){if(this.handleStateTransition(),this.userfpnode&&this.userfpnode.visible){this.handleFocusTransition();let e=this.userfpnode.scale.x;e>.001?(this.userfpnode.scale.set(.99*e,.99*e,.99*e),ATON.plight.intensity*=.99):(this.userfpnode.visible=!1,ATON.disablePointLight())}let e=ATON.Nav._camera,t=ATON.Nav._currPOV.pos;if(void 0===e||void 0===t)return;this.userlabelnode&&this.userlabelnode.orientToCamera();let o=this.userauinode.scale.x;o*=.99,o>.01?this.userauinode.scale.set(o,o,o):this.userauinode.visible=!1}_handleTalk(){if(this._auTalk.isPlaying)return;if(this._auChunks.length<2)return;let e=this._auChunks[this._iAU];this._auTalk.setBuffer(e),this._auTalk.play(),this.setTalkVolume(5)}_handleTalkOLD(){if(this._bPlayingAudio)return;if(this._auChunks.length<1)return;let e=this._auChunks.shift();this._auTalk.setBuffer(e),this._auTalk.play(),this._bPlayingAudio=!0,this._auTalk.onended=()=>{this._bPlayingAudio=!1,e=null},this.setTalkVolume(5)}},b.init=()=>{b.address=window.location.origin,b.initMaterials(),b.socket=void 0,b._connected=!1,b._reqSSID=void 0,b._username=void 0,b.uid=void 0,b.color=ATON.MatHub.colors.white,b._bStreamFocus=!1,b._numUsers=1,b.avatarList=[],b.avaGroup=ATON.createUINode("avatars"),b.avaGroup.attachToRoot(),b.focGroup=ATON.createUINode("focus"),b.focGroup.attachTo(b.avaGroup),b._focNodes=[],b.bSendState=!0,window.setInterval(b.sendState,1e3*b.USER_STATE_FREQ),b._lastStateSent=void 0,b._bShowAvaG=!0,b._bSpatial=!0,console.log("Photon initialized"),b.enableChatLog(),b._elVStream=void 0,b._decS={quaternion:new THREE.Quaternion,position:new THREE.Vector3},b.customAvatarMaterial=void 0,window.addEventListener("beforeunload",(e=>{b.disconnect()}))},b.setCustomAvatarMaterialRoutine=e=>{b.customAvatarMaterial=e},b.enableChatLog=()=>{b._elChat=$("
    ").text("")},b.getNumUsers=()=>b._numUsers,b.initMaterials=()=>{b.ucolorhex=[],b.ucolorhex.push("#F00"),b.ucolorhex.push("#FF0"),b.ucolorhex.push("#0F0"),b.ucolorhex.push("#0FF"),b.ucolorhex.push("#00F"),b.ucolorhex.push("#F0F"),b.ucolorhex_light=[],b.ucolorhex_light.push("#FAA"),b.ucolorhex_light.push("#FFA"),b.ucolorhex_light.push("#AFA"),b.ucolorhex_light.push("#AFF"),b.ucolorhex_light.push("#AAF"),b.ucolorhex_light.push("#FAF"),b.ucolors=[],b.ucolors.push(new THREE.Color(b.ucolorhex[0])),b.ucolors.push(new THREE.Color(b.ucolorhex[1])),b.ucolors.push(new THREE.Color(b.ucolorhex[2])),b.ucolors.push(new THREE.Color(b.ucolorhex[3])),b.ucolors.push(new THREE.Color(b.ucolorhex[4])),b.ucolors.push(new THREE.Color(b.ucolorhex[5])),b.ucolorsdark=[],b.ucolorsdark.push(new THREE.Color(.2,0,0)),b.ucolorsdark.push(new THREE.Color(.2,.2,0)),b.ucolorsdark.push(new THREE.Color(0,.2,0)),b.ucolorsdark.push(new THREE.Color(0,.2,.2)),b.ucolorsdark.push(new THREE.Color(0,0,.2)),b.ucolorsdark.push(new THREE.Color(.2,0,.2));let e=ATON.MatHub.materials;e.avatars=[];for(let t=0;t{if(!b._connected)return;let o=b.socket;o&&o.emit(b.REPLICATED_EVT,{e,d:t})},b.on=(e,t)=>{if(void 0===t)return;let o=ATON.EventHub.evNetwork;void 0===o[e]&&(o[e]=[]),o[e].push(t)},b.isConnected=()=>void 0!==b.socket&&b._connected,b.hasID=()=>void 0!==b.uid,b.log=e=>{if(!b._connected)return;let t=b.socket;t&&t.emit("UMSG",e)},b.joinSession=e=>{b.socket&&(void 0===e&&(e=ATON.SceneHub.currID),void 0!==e?(console.log("Joining Photon session '"+e+"'..."),b.socket.emit("SENTER",e)):console.log("Photon ERROR: current session ID is undefined"))},b.requestSceneState=()=>{b.socket&&b.socket.emit("SSTATE")},b.setAvatarsVisibility=e=>{b._bShowAvaG=e,e?b.avaGroup.show():b.avaGroup.hide()},b.disableSpatiality=()=>{b._bSpatial=!1},b.enableSpatiality=()=>{b._bSpatial=!0},b.setAddress=e=>{e&&(b.address=e)},b.connect=e=>{if(b._connected)return;b._reqSSID=e;let t={};ATON.Utils.isConnectionSecure()?(t.path="/svrc/socket.io",t.secure=!0,t.rejectUnauthorized=!1):t.path="/vrc/socket.io",b.socket=io.connect(b.address,t),void 0!==b.socket&&(b._connected=b.socket.connected,b._registerSocketHandlers())},b.disconnect=()=>{void 0!==b.socket&&(b._numUsers=1,b.socket.disconnect(),b.color=ATON.MatHub.colors.white,ATON.plight.color=ATON.MatHub.colors.white,b._connected=!1)},b._onConnected=()=>{},b.setUsername=e=>{(e=e.trim()).length<1||(b._username=e,void 0!==b.socket&&void 0!==b.uid&&(b.appendToChatBox("Your username is now: "+e+""),b.socket.emit("UNAME",e)))},b.setMessage=e=>{(e=e.trim()).length<1||e.length>3e3||(b._msg=e,void 0!==b.socket&&void 0!==b.uid&&(b.socket.emit("UMSG",e),b._elChat&&(e=b.chatMessageProcessor(b.uid,e),b.appendToChatBox("
    YOU
    : "+e+""))))},b.appendToChatBox=e=>{b._elChat&&(b._elChat.append("
    "+e+"
    "),b._elChat.scrollTop(b._elChat[0].scrollHeight))},b._registerSocketHandlers=()=>{b.socket.on("connect",(()=>{b._connected=!0,void 0!==b._reqSSID?b.joinSession(b._reqSSID):b.joinSession(ATON.SceneHub.currID),console.log("Connected to Photon service!"),ATON.fireEvent("VRC_Connected"),b._onConnected()})),b.socket.on("disconnect",(()=>{b._connected=!1,b.uid=void 0,b.avaGroup.hide(),b.appendToChatBox("YOU disconnected from the Photon session"),console.log("Disconnected from Photon service!"),ATON.fireEvent("VRC_Disconnected")})),b.socket.on(b.REPLICATED_EVT,(e=>{let t=e.e,o=e.d,i=ATON.EventHub.evNetwork[t];ATON.EventHub.executeHandlers(i,o)})),b.socket.on("ID",(e=>{console.log("Your ID is "+e),b.uid=e,b.color=b.ucolors[b.uid%b.ucolors.length],b._bShowAvaG&&b.avaGroup.show(),b.appendToChatBox("Your ID is #"+e+""),b.requestSceneState(),ATON.fireEvent("VRC_IDassigned",e)})),b.socket.on("SSTATE",(e=>{b._numUsers=e.numUsers,console.log("Num. users: "+b._numUsers),ATON.fireEvent("VRC_SceneState",e)})),b.socket.on("UENTER",(e=>{let t=e;console.log("User #"+t+" entered the session"),b.appendToChatBox("User #"+t+" entered the session"),b.requestSceneState(),ATON.fireEvent("VRC_UserEnter",t)})),b.socket.on("ULEAVE",(e=>{let t=e;if(void 0===t)return;let o=b.avatarList[t];o&&(o.toggleStreamPanel(!1),o.hide()),console.log("User #"+t+" left the session"),b.appendToChatBox("User #"+t+" left the session"),b.requestSceneState(),ATON.fireEvent("VRC_UserLeave",t)})),b.socket.on("USTATE",(e=>{if(!b._bShowAvaG)return;if(!b._bSpatial)return;let t=b.decodeState(e),o=t.userid,i=b.touchAvatar(o);i.requestStateTransition(t);let r=1/t.scale;i.scale.set(r,r,r)})),b.socket.on("UFOCUS",(e=>{if(!b._bSpatial)return;let t=e.uid,o=e.fp;b.touchAvatar(t).requestFocus(o)})),b.socket.on("UNAME",(e=>{let t=e.uid,o=e.name;void 0!==t&&(b.touchAvatar(t).setUsername(o),console.log("User #"+t+" changed username to: "+o),b.appendToChatBox("User #"+t+" changed username to: "+o+""),ATON.fireEvent("VRC_UName",e))})),b.socket.on("UMSG",(e=>{let t=e.uid,o=e.msg;if(void 0===t)return;let i=b.touchAvatar(t);o.length<100&&i.setMessage(o),console.log("User #"+t+": "+o);let r=i.getUsername();o=b.chatMessageProcessor(t,o),b.ucolorhex[t%6];let a=b.ucolorhex_light[t%6];b.appendToChatBox("
    "+r+"
    : "+o+""),ATON.fireEvent("VRC_UMessage",e)})),b.socket.on("UTALK",(e=>{let t=e.uid;if(void 0===t)return;let o=e.audio;if(o){if(b._bSpatial){let e=b.touchAvatar(t);if(e.bMuted)return;ATON.AudioHub._loader.load(o,(t=>{let o=e._auTalk[e._auTalki],i=(e._auTalki+1)%2;o.setBuffer(t),o.isPlaying||o.play(),e.setTalkVolume(5),e._auTalki=i}))}ATON.fireEvent("VRC_UTalk",e),o=null}})),b.socket.on("UTALKSTOP",(e=>{void 0!==e.uid&&ATON.fireEvent("VRC_UTalkStop",e)})),b.socket.on("UVIDEO",(e=>{void 0!==e.uid&&ATON.fireEvent("VRC_UVideo",e)})),b.socket.on("UVIDEOSTOP",(e=>{let t=e.uid;if(void 0===t)return;let o=b.avatarList[t];o&&o.toggleStreamPanel(!1),ATON.fireEvent("VRC_UVideoStop",e)}))},b.chatMessageProcessor=(e,t)=>{const o=(t=String(t)).match(/(((ftp|https?):\/\/)[\-\w@:%_\+.~#?,&\/\/=]+)/g);return o&&o.forEach((e=>{t=t.replace(e,""+e+"")})),t},b.encodeState=e=>{if(!e)return;let t=new Float32Array(5);t[0]=e.position.x,t[1]=e.position.y,t[2]=e.position.z;var o=new Int8Array(t.buffer);return o[12]=128*e.quaternion.x,o[13]=128*e.quaternion.y,o[14]=128*e.quaternion.z,o[15]=128*e.quaternion.w,o[16]=e.userid,o[17]=ATON._ws,o},b.decodeState=e=>{let t=new Int8Array(e);b._decS.userid=t[16];let o=ATON._unpackScale(t[17]);return b._decS.scale=o,b._decS.quaternion.set(parseFloat(t[12])/128,parseFloat(t[13])/128,parseFloat(t[14])/128,parseFloat(t[15])/128),t=new Float32Array(e),b._decS.position.set(parseFloat(t[0])/o,parseFloat(t[1])/o,parseFloat(t[2])/o),b._decS},b.update=()=>{if(b._connected)for(let e=0;e{if(void 0!==e){if(e)return b._bStreamFocus||(ATON.fireEvent("VRC_FocusStreamingStarted"),ATON.enablePointLight(),ATON.plight.color=ATON.Photon.color),void(b._bStreamFocus=!0);{b._bStreamFocus&&(ATON.fireEvent("VRC_FocusStreamingStopped"),ATON.disablePointLight());let e=ATON.SUI._selectorRad;ATON.SUI.mainSelector.scale.set(e,e,e),b._bStreamFocus=!1}}},b.sendState=()=>{if(!b.bSendState||!b._bSpatial)return;if(void 0===b.uid)return;if(!b.socket||!b._connected)return;let e=ATON.Nav._currPOV;if(!e)return;let t=ATON.getSceneFocalPoint();if(b._bStreamFocus&&void 0!==t){let e=t.x.toFixed(3),o=t.y.toFixed(3),i=t.z.toFixed(3),r=ATON.SUI.getSelectorRadius().toFixed(3);b.socket.emit("UFOCUS",[e,o,i,r])}if(!e.pos)return;if(!ATON.Nav._qOri)return;if(void 0!==b._lastStateSent){let t=b._lastStateSent.position,o=b._lastStateSent.quaternion,i=t.distanceToSquared(e.pos),r=o.angleTo(ATON.Nav._qOri);if(ib.avatarList[e],b.touchAvatar=e=>{if(void 0===b.avatarList[e]){let t=new b.Avatar(e);t.attachTo(b.avaGroup),t.loadRepresentation(ATON.PATH_RES+"models/vrc/head.gltf"),b.avatarList[e]=t}let t=b.avatarList[e];return t.visible||ATON.fireEvent("VRC_UserEnter",e),b._bShowAvaG&&t.show(),t},b.destroyAvatar=e=>{let t=b.avatarList[e];void 0!==t&&t.destroy()},b.clearAllAvatars=()=>{for(let e in b.avatarList)b.avatarList[e].hide()};const P=b;let E={FLOAT_PREC:5,init:()=>{E.bConvexBuilding=!1,E.convexPoints=[],E.convexNode=void 0,E.currConvexMesh=void 0,E.currSemNode=ATON.createSemanticNode(),E.currSemNode.disablePicking(),E.currSemNode.attachToRoot(),E.resetMaterial(),E._numShapes=0},resetMaterial:()=>{E.currMaterial=ATON.MatHub.getMaterial("semanticShapeHL")},setMaterial:e=>{void 0!==e&&(E.currMaterial=e)},addConvexPoint:e=>{if(void 0===e)return!1;if(E.convexPoints.length>0){let t=E.convexPoints[E.convexPoints.length-1];if(e.equals(t))return!1}E.convexPoints.push(e);let t=E.convexPoints.length,o=new THREE.Sprite(ATON.SUI.getOrCreateSpritePointEdit()),i=.02*ATON.getSceneQueriedDistance();if(void 0===i&&(i=.02),o.position.copy(e),o.scale.set(i,i,i),ATON.SUI.gPoints.add(o),t<4)return!1;let r=new THREE.ConvexGeometry(E.convexPoints),a=new THREE.Mesh(r,ATON.MatHub.getMaterial("semanticShapeEdit"));if(E.bConvexBuilding){let t=E.currConvexMesh;t.geometry.dispose(),t.geometry=r,ATON.Utils.setVectorPrecision(e,4),t.userData._convexPoints.push(e.x),t.userData._convexPoints.push(e.y),t.userData._convexPoints.push(e.z)}else{E.currSemNode.add(a),a.userData._convexPoints=[];for(let e=0;e{if(0!==E.convexPoints.length&&(E.convexPoints.pop(),E.currConvexMesh)){let e=E.currConvexMesh.userData;e._convexPoints&&e._convexPoints.pop()}},stopCurrentConvex:()=>{E.bConvexBuilding&&(E.convexPoints=[],E.bConvexBuilding=!1,E.currSemNode.removeChildren(),ATON.SUI.gPoints.removeChildren())},getCurrentConvexShape:()=>E.currSemNode,isBuildingShape:()=>E.convexPoints.length>0,completeConvexShape:e=>{if(E.convexPoints=[],E.bConvexBuilding=!1,void 0===E.currSemNode)return;void 0===e&&(e="sem"+E._numShapes);let t=ATON.getSemanticNode(e)||ATON.createSemanticNode(e),o=E.currSemNode.children[0];return ATON.SUI.addSemIcon(e,o),t.add(o),t.setMaterial(ATON.MatHub.materials.semanticShape),t.setDefaultAndHighlightMaterials(ATON.MatHub.materials.semanticShape,E.currMaterial),t.enablePicking(),E.currSemNode.removeChildren(),E._numShapes++,ATON.SUI.gPoints.removeChildren(),ATON._bqSem=!0,t},createConvexShape:(e,t)=>{let o=new THREE.ConvexGeometry(t),i=new THREE.Mesh(o,ATON.MatHub.materials.semanticShape);i.userData._convexPoints=[];for(let e=0;e{if(void 0===ATON._queryDataScene)return!1;void 0===e&&(e=.02);let t=ATON._queryDataScene.p,o=ATON.Nav.getCurrentEyeLocation();return t.lerpVectors(t,o,e),E.addConvexPoint(t),t},createSphere:(e,t,o)=>{if(void 0===t)return;if(void 0===o)return;void 0===e&&(e="sem"+E._numShapes);let i=ATON.getOrCreateSemanticNode(e),r=new THREE.Mesh(ATON.Utils.geomUnitSphere,ATON.MatHub.materials.semanticShape),a=new THREE.Object3D;return a.position.copy(t),a.scale.set(o,o,o),a.add(r),ATON.SUI.addSemIcon(e,a),i.add(a),i.enablePicking(),i.setDefaultAndHighlightMaterials(ATON.MatHub.materials.semanticShape,E.currMaterial),E._numShapes++,ATON._bqSem=!0,i},createSurfaceSphere:e=>{if(!ATON._queryDataScene)return;let t=ATON._queryDataScene.p,o=ATON.SUI.getSelectorRadius();return E.createSphere(e,t,o)},deleteSemanticNode:e=>{let t=ATON.getSemanticNode(e);if(void 0===t)return!1;if(t.removeChildren(),void 0===ATON.SUI.gSemIcons)return!0;for(let t in ATON.SUI.gSemIcons.children){let o=ATON.SUI.gSemIcons.children[t];o&&o.name===e&&ATON.SUI.gSemIcons.removeChild(o)}return!0}};const f=E;let R={SEMSHAPE_SPHERE:0,SEMSHAPE_CONVEX:1,POPUP_DT:500,STD_SEL_RAD:.05,_bRealized:!1,realize:()=>{if(R._bRealized)return;R.PATH_RES_ICONS=ATON.PATH_RES+"icons/",R._bPopup=!1,R._tPopup=void 0,R.popupBlurBG=0,R._userAuth={},R._bControlLight=!1,R._bControlSelScale=!1,R._cLightDir=new THREE.Vector3,R._auSemNode=void 0,R._auSemNodePlaying=!1,R._bReqHome=!1,R._bVRCsetup=!1,R.urlParams=new URLSearchParams(window.location.search),R._uiSetupBase(),R._uiProfiles={},R._uiCurrProfile=void 0,R._selRanges=[.01,50],R._selRefRadius=.5,ATON.realize(),ATON.on("Fullscreen",(e=>{R.uiSwitchButton("fullscreen",e)}));let e=ATON.FE.urlParams.get("d");e&&e>0&&(ATON.setDefaultPixelDensity(e),ATON.toggleAdaptiveDensity(!1));let t=ATON.FE.urlParams.get("dd");t&&t>0&&ATON.toggleAdaptiveDensity(!0),R._canvas=ATON._renderer.domElement,R._bSem=!1,R._bShowSemLabel=!0,R._bRealized=!0,R.loadSceneID=ATON.App.loadScene},_handleHomeReq:()=>{R._bReqHome||ATON.getRootScene().getBound().radius<=0||(R._bReqHome=!0,void 0!==ATON.Nav.homePOV?ATON.Nav.requestHome(1):ATON.Nav.computeAndRequestDefaultHome(.5))},addBasicLoaderEvents:()=>{ATON.on("NodeRequestFired",(()=>{$("#idLoader").show()})),ATON.on("SceneJSONLoaded",(()=>{ATON.SceneHub.getDescription()&&$("#btn-info").show(),void 0!==ATON.Nav.homePOV&&ATON.Nav.requestHome(1),ATON.XPFNetwork._list.length>0&&void 0===ATON.Nav.homePOV&&(ATON.XPFNetwork.setHomeXPF(0),ATON.XPFNetwork.requestTransitionByIndex(0))})),ATON.on("AllNodeRequestsCompleted",(()=>{$("#idLoader").hide(),ATON.CC.anyCopyrightFound()&&$("#btn-cc").show(),R.computeSelectorRanges(),ATON.SUI.setSelectorRadius(Math.min(R.STD_SEL_RAD,R._selRefRadius)),R._handleHomeReq()})),ATON.on("XR_support",(e=>{"immersive-vr"===e.type&&(e.v?$("#btn-vr").show():$("#btn-vr").hide())})),ATON.on("SemanticNodeHover",(e=>{let t=ATON.getSemanticNode(e);void 0!==t&&(R.showSemLabel(e),R._bSem=!0,t.highlight(),$("canvas").css({cursor:"crosshair"}),ATON.SUI.gSemIcons&&ATON.SUI.gSemIcons.hide())})),ATON.on("SemanticNodeLeave",(e=>{let t=ATON.getSemanticNode(e);void 0!==t&&(R.hideSemLabel(),R._bSem=!1,t.restoreDefaultMaterial(),$("canvas").css({cursor:"grab"}),ATON.SUI.gSemIcons&&ATON.SUI.gSemIcons.show())})),ATON.on("SemanticMaskHover",(e=>{R.showSemLabel(e),R._bSem=!0,$("canvas").css({cursor:"crosshair"})})),ATON.on("SemanticMaskLeave",(e=>{R.hideSemLabel(),R._bSem=!1,$("canvas").css({cursor:"grab"})})),ATON.addUpdateRoutine(R._update)},showSemLabel:e=>{R._bShowSemLabel&&($("#idPopupLabel").html(e),$("#idPopupLabel").show(),ATON.SUI.setInfoNodeText(e))},hideSemLabel:()=>{$("#idPopupLabel").hide(),$("#idPopupLabel").html("")},controlLight:e=>{R._bControlLight=e,ATON.Nav.setUserControl(!e)},controlSelectorScale:e=>{R._bControlSelScale=e,ATON._bPauseQuery=e,ATON.Nav.setUserControl(!e)},attachGizmoToNode:e=>{if(void 0===ATON._gizmo)return;let t=ATON.getSceneNode(e);void 0!==t&&ATON._gizmo.attach(t)},useMouseWheelToScaleSelector:e=>{void 0===e&&(e=.9),ATON.on("MouseWheel",(t=>{if(ATON._kModCtrl){let e=ATON.Nav.getFOV();return t>0?e+=1:e-=1,void ATON.Nav.setFOV(e)}if(ATON._kModShift){let o=ATON.SUI.mainSelector.scale.x;return t>0?o*=e:o/=e,oR._selRanges[1]&&(o=R._selRanges[1]),void ATON.SUI.setSelectorRadius(o)}}))},_update:()=>{if(R._bControlLight){const e=ATON._screenPointerCoords.x,t=ATON._screenPointerCoords.y;R._cLightDir.x=-Math.cos(e*Math.PI),R._cLightDir.y=4*-t,R._cLightDir.z=-Math.sin(e*Math.PI),R._cLightDir.normalize(),ATON.setMainLightDirection(R._cLightDir)}if(ATON.XR._bPresenting){let e=ATON.XR.getAxisValue(ATON.XR.HAND_R);if(!ATON.Photon._bStreamFocus){let t=ATON.SUI._selectorRad;t+=.01*e.y,t>.001&&ATON.SUI.setSelectorRadius(t)}}else{if(ATON.Nav.isTransitioning()||ATON.Nav._bInteracting||ATON._bPauseQuery)return void $("#idPopupLabel").hide();if(R._bSem&&R._bShowSemLabel){$("#idPopupLabel").show();let e=.5*ATON._screenPointerCoords.x*window.innerWidth,t=.5*(1-ATON._screenPointerCoords.y)*window.innerHeight;t-=55,$("#idPopupLabel").css("transform","translate("+e+"px, "+t+"px)")}else $("#idPopupLabel").hide()}},uiBasicSetup:()=>{R.uiAddButton("idTopToolbar","fullscreen",ATON.toggleFullScreen),ATON.Utils.isConnectionSecure()&&R.uiAddButton("idTopToolbar","vr",ATON.XR.toggle),R.uiAddButton("idBottomToolbar","home",(()=>{ATON.Nav.requestHome(.1)}))},_uiSetupBase:()=>{$("#idPopup").click(R.popupClose),$("#idLoader").html(""),$("body").prepend("
    "),R.hideSemLabel()},uiAddButton:(e,t,o,i)=>{let r,a;t.endsWith(".png")?(r=t,a=t.slice(0,-4)):(r=R.PATH_RES_ICONS+t+".png",a=t);let s=$("
    ");$("#"+e).append(s),o&&s.click(o),i&&s.attr("title",i)},uiSwitchButton:(e,t)=>{t?$("#btn-"+e).addClass("switchedON"):$("#btn-"+e).removeClass("switchedON")},uiSetButtonHandler:(e,t)=>{$("#"+e).click(t)},uiAddButtonHome:e=>{R.uiAddButton(e,"home",(()=>{ATON.Nav.requestHome(.3)}),"Home viewpoint")},uiAddButtonBack:(e,t)=>{R.uiAddButton(e,"back",(()=>{t&&t.length>1&&t.startsWith("http:")?ATON.Utils.goToURL(t):history.back()}),"Go Back")},uiAddButtonFirstPerson:e=>{R.uiAddButton(e,"fp",(()=>{ATON.Nav.isFirstPerson()?(ATON.Nav.setOrbitControl(),R.uiSwitchButton("fp",!1)):(ATON.Nav.setFirstPersonControl(),R.uiSwitchButton("fp",!0))}),"First-person navigation mode"),ATON.Nav.isFirstPerson()?R.uiSwitchButton("fp",!0):R.uiSwitchButton("fp",!1)},uiAddButtonVR:e=>{ATON.Utils.isConnectionSecure()&&(R.uiAddButton(e,"vr",(()=>{ATON.XR.toggle("immersive-vr")}),"Immersive VR mode"),ATON.Utils.isVRsupported()||$("#btn-vr").hide())},uiAddButtonAR:e=>{ATON.Utils.isConnectionSecure()&&R.uiAddButton(e,"ar",(()=>{ATON.Utils.isARsupported()&&ATON.XR.toggle("immersive-ar")}),"Immersive AR mode")},uiAddButtonDeviceOrientation:e=>{ATON.Utils.isConnectionSecure()&&ATON.Utils.isMobile()&&(R.uiAddButton(e,"devori",(()=>{ATON.Nav.isDevOri()?(ATON.Nav.restorePreviousNavMode(),R.uiSwitchButton("devori",!1)):(ATON.Nav.setDeviceOrientationControl(),R.uiSwitchButton("devori",!0))}),"Device-orientation mode"),ATON.Nav.isDevOri()?R.uiSwitchButton("devori",!0):R.uiSwitchButton("devori",!1))},uiAddButtonNav:e=>{R.uiAddButton(e,"nav",(()=>{R.popupNav()}),"Navigation")},uiAddButtonTalk:e=>{ATON.Utils.isConnectionSecure()&&(R.uiAddButton(e,"talk",(()=>{ATON.MediaFlow.isAudioRecording()?(ATON.MediaFlow.stopAudioStreaming(),$("#btn-talk").removeClass("atonBTN-rec")):(ATON.MediaFlow.startAudioStreaming(),$("#btn-talk").addClass("atonBTN-rec"))}),"Talk ON/OFF"),ATON.MediaFlow.isAudioRecording()?$("#btn-talk").addClass("atonBTN-rec"):$("#btn-talk").removeClass("atonBTN-rec"))},uiAddButtonStreamFocus:e=>{R.uiAddButton(e,"focus",(()=>{ATON.Photon._bStreamFocus?(ATON.Photon.setFocusStreaming(!1),$("#btn-focus").removeClass("atonBTN-rec")):(ATON.Photon.setFocusStreaming(!0),$("#btn-focus").addClass("atonBTN-rec"))}),"Focus streaming ON/OFF"),ATON.Photon._bStreamFocus?$("#btn-focus").addClass("atonBTN-rec"):$("#btn-focus").removeClass("atonBTN-rec")},uiAddButtonMainVideoPanoPlayPause:e=>{R.uiAddButton(e,"playpause",(()=>{ATON._vpanoPlaying?ATON._elPanoVideo&&ATON._elPanoVideo.pause():ATON._elPanoVideo&&ATON._elPanoVideo.play()}),"360 Video play/pause"),ATON._elPanoVideo?$("#btn-playpause").show():$("#btn-playpause").hide()},uiAddButtonQR:e=>{ATON.Utils.isLocalhost()||R.uiAddButton(e,"qr",R.popupQR,"QR-code")},uiAddButtonScreenshot:e=>{R.uiAddButton(e,"sshot",R.popupScreenShot,"Screenshot")},uiAddButtonInfo:e=>{R.uiAddButton(e,"info",ATON.FE.popupSceneInfo,"Scene information"),$("#btn-info").hide()},uiAddButtonFullScreen:e=>{R.uiAddButton(e,"fullscreen",(()=>{ATON.toggleFullScreen()}),"Fullscreen"),R.uiSwitchButton("fullscreen",ATON.isFullscreen())},uiAddKeywordsArea:(e,t,o,i)=>{let r="";r+="Add keyword:

    ",r+="
    ",$("#"+e).html(r),R.uiAttachInputFilterID("idKWordInput"),$.getJSON(ATON.PATH_RESTAPI+"keywords/",(t=>{let o="";for(let e in t)o+="";o+="",$("#"+e).append(o)}));let a={},s=e=>{a[e]||(e=e.toLowerCase().trim(),$("#idKWordInput").val(""),a[e]=1,console.log("Added keyword "+e),o&&o(e),$("#idKWords").append("
    "+e+"
    "),$("#idkw-"+e).click((()=>{$("#idkw-"+e).remove(),a[e]=void 0,console.log("Removed keyword "+e),i&&i(e)})))};if(t)for(let e in t)s(t[e]);$("#idKWordInput").keypress((function(e){if("13"!=(e.keyCode?e.keyCode:e.which))return;let t=$("#idKWordInput").val().toLowerCase().trim();!t||t.length<3||s(t)})),$("#idKWadd").click((()=>{let e=$("#idKWordInput").val().toLowerCase().trim();!e||e.length<3||s(e)}))},uiAttachCollectionItemsToInput:(e,t)=>{let o="";$("#"+e).attr("list",e+"-list"),$("#"+e).attr("name",e+"-list"),$.getJSON(ATON.PATH_RESTAPI+"c/"+t+"/",(t=>{o+="";for(let e in t){let i=t[e];o+=""}o+="",$("#"+e).html(o)}))},getVRCclassFromID:e=>"atonVRCu"+e%6,_setupVRCevents:()=>{R._bVRCsetup||(ATON.on("VRC_IDassigned",(e=>{$("#btn-vrc").addClass(R.getVRCclassFromID(e)),ATON.SUI.setSelectorColor(ATON.Photon.color),ATON.plight.color=ATON.Photon.color,R.checkAuth((e=>{void 0!==e.username&&ATON.Photon.setUsername(e.username)}))})),ATON.on("VRC_SceneState",(e=>{let t=ATON.Photon.getNumUsers();t>1?$("#idVRCnumusers").html(t):$("#idVRCnumusers").html(""),console.log("Users: "+t)})),ATON.on("VRC_Disconnected",(()=>{$("#btn-vrc").attr("class","atonBTN"),ATON.SUI.setSelectorColor(ATON.MatHub.colors.defUI),ATON.MediaFlow.stopAllStreams(),$("#idVRCnumusers").html("")})),R._bVRCsetup=!0)},uiAddButtonPhoton:e=>{R.uiAddButton(e,"vrc",(()=>{ATON.Photon.isConnected()?R.popupVRC():ATON.Photon.connect()}),"Photon (collaborative session)"),$("#btn-vrc").append(""),R._setupVRCevents(),void 0!==ATON.Photon.uid?$("#btn-vrc").addClass(R.getVRCclassFromID(ATON.Photon.uid)):$("#btn-vrc").attr("class","atonBTN")}};R.uiAddButtonVRC=R.uiAddButtonPhoton,R.uiAddButtonUser=e=>{R.uiAddButton(e,"user",(()=>{R.popupUser()}),"User"),R.checkAuth((e=>{void 0!==e.username?$("#btn-user").addClass("switchedON"):$("#btn-user").removeClass("switchedON")}))},R.uiSetEditMode=(e,t)=>{ATON.SceneHub._bEdit=e,R.uiSwitchButton("edit",e),ATON._renderer.domElement,e?$("#"+t).addClass("atonToolbar-bg-edit"):$("#"+t).removeClass("atonToolbar-bg-edit")},R.uiAddButtonEditMode=e=>{R.uiAddButton(e,"edit",(()=>{R.checkAuth((t=>{void 0!==t.username?(ATON.SceneHub._bEdit?R.uiSetEditMode(!1,e):R.uiSetEditMode(!0,e),console.log("Persistent Edit Mode: "+ATON.SceneHub._bEdit)):R.popupUser()}))}),"Persistent Edit Mode"),ATON.SceneHub._bEdit?R.uiSwitchButton("edit",!0):R.uiSwitchButton("edit",!1)},R.uiAddProfile=(e,t)=>{"function"==typeof t&&(R._uiProfiles[e]=t)},R.uiLoadProfile=e=>{let t=R._uiProfiles[e];void 0!==t&&(t(),R._uiCurrProfile=e,console.log("Loaded UI Profile: "+R._uiCurrProfile))},R.getCurrentUIP=()=>R._uiCurrProfile,R.attachHandlerToButton=(e,t)=>{void 0!==t&&$("#"+e).click((()=>{t()}))},R.uiAttachInputFilterID=e=>{$("#"+e).on("keyup change input",(()=>{let t=$("#"+e).val(),o=new RegExp("[^A-Za-z0-9-_]","ig");$("#"+e).val(t.replace(o,""))}))},R.switchNode=(e,t,o)=>{let i;i=o===ATON.NTYPES.SEM?ATON.getSemanticNode(e):ATON.getSceneNode(e),void 0!==i&&(i.toggle(t),ATON.fireEvent("FE_NodeSwitch",{nid:e,t:o,v:t}))},R.uiCreateGraph=e=>{let t=ATON.snodes;e===ATON.NTYPES.SEM&&(t=ATON.semnodes);let o="";for(let i in t){let r=t[i].visible?"checked":"";"."!==i&&(o+="'+i,o+="
    ")}return o},R.setupBasicUISounds=()=>{R.auLib={},R.auLib.switch=new Audio(ATON.PATH_RES+"audio/switch.wav"),R.auLib.switch.loop=!1},R.playAudioFromSemanticNode=e=>{if(void 0===e)return;let t=ATON.getSemanticNode(e);if(void 0===t)return;let o=t.getAudio();void 0!==o&&("string"!=typeof o||o.startsWith("data:audio")||(o=ATON.Utils.resolveCollectionURL(o)),void 0===R._auSemNode||null===R._auSemNode?R._auSemNode=new THREE.Audio(ATON.AudioHub._listener):R._auSemNode.stop(),ATON.AudioHub._loader.load(o,(e=>{R._auSemNode.setBuffer(e),R._auSemNode.setLoop(!1),R._auSemNode.play()})))},R.popupShow=(e,t)=>{if(R._bPopup)return!1;R._tPopup=Date.now();let o="atonPopup ";t&&(o+=t);let i="
    ";return i+=e+"
    ",R._bPopup=!0,ATON._bListenKeyboardEvents=!1,$("#idPopup").html(i),$("#idPopupContent").click((e=>{e.stopPropagation()})),$("#idPopup").show(),R.popupBlurBG>0&&(ATON._renderer.domElement.style.filter="blur("+R.popupBlurBG+"px)"),ATON._bPauseQuery=!0,$("#idTopToolbar").hide(),$("#idBottomToolbar").hide(),$("#idBottomRToolbar").hide(),$("#idPoweredBy").hide(),!0},R.popupClose=e=>{Date.now()-R._tPopup0&&(ATON._renderer.domElement.style.filter="none"),$("#idPopup").hide(),ATON._bPauseQuery=!1,$("#idTopToolbar").show(),$("#idBottomToolbar").show(),$("#idBottomRToolbar").show(),$("#idPoweredBy").show(),ATON.focusOn3DView())},R.subPopup=e=>{ATON.FE.popupClose(),e()},R.popupQR=()=>{let e="
    Share
    ";if(e+="


    ",!ATON.FE.popupShow("
    Share


    "))return;let t=window.location.href;new QRCode(document.getElementById("idQRcode"),t)},R.popupScreenShot=()=>{let e=ATON.Utils.takeScreenshot(256);R.checkAuth((t=>{let o="
    Capture
    ";o+="This is a preview of what your screenshot will look like:

    ",o+="
    ",o+="Resolution: px
    ",o+="
    Screenshot
    ",o+="
    Record video
    ",void 0!==t.username&&(o+="
    Set as Cover
    "),ATON.FE.popupShow(o)&&(ATON.MediaFlow._bScreenRec?$("#btnScreenRec").addClass("atonBTN-rec"):$("#btnScreenRec").removeClass("atonBTN-rec"),$("#btnScreenShot").click((()=>{let e=parseInt($("#isShotSize").val());e<100||(ATON.FE.popupClose(),ATON.Utils.takeScreenshot(e,"shot.png"))})),$("#btnScreenRec").click((()=>{ATON.MediaFlow._bScreenRec||ATON.MediaFlow.startScreenRecording(),ATON.FE.popupClose()})),$("#btnSetCover").click((()=>{ATON.FE.popupClose(),ATON.Utils.postJSON(ATON.PATH_RESTAPI+"cover/scene/",{sid:ATON.SceneHub.currID,img:e.src},(e=>{console.log(e)}))})))}))},R.popupVRC=()=>{let e="",t=ATON.Photon.getNumUsers();e+=t>1?"
    Collaborative Session ("+t+" users)
    ":"
    Collaborative Session
    ",e+="
    ",e+="",e+="",e+="
    LEAVE
    ",e+="
    ",e+="",ATON.FE.popupShow(e,"atonPopupLarge")&&(ATON.checkAuth((e=>{console.log(e),ATON.MediaFlow._bCamStream||ATON.FE.uiAddButton("idCollabTools","screenshare",(()=>{ATON.MediaFlow._bScreenStream?$("#btn-screenshare").addClass("atonBTN-rec"):$("#btn-screenshare").removeClass("atonBTN-rec"),ATON.MediaFlow.startOrStopScreenStreaming(),ATON.FE.popupClose()}),"Share your screen with other participants"),!ATON.MediaFlow._bScreenStream&&ATON.MediaFlow.hasVideoInput()&&ATON.FE.uiAddButton("idCollabTools","camera",(()=>{ATON.MediaFlow._bCamStream?$("#btn-camera").addClass("atonBTN-rec"):$("#btn-camera").removeClass("atonBTN-rec"),ATON.MediaFlow.startOrStopCameraStreaming(),ATON.FE.popupClose()}),"Share your camera with other participants"),ATON.MediaFlow._bScreenStream?$("#btn-screenshare").addClass("atonBTN-rec"):$("#btn-screenshare").removeClass("atonBTN-rec"),ATON.MediaFlow._bCamStream?$("#btn-camera").addClass("atonBTN-rec"):$("#btn-camera").removeClass("atonBTN-rec")})),void 0===ATON.Photon._username?($("#idVRCusername").show(),$("#idVRCusernameBTN").hide()):($("#idVRCusername").val(ATON.Photon._username),$("#idVRCusername").hide(),$("#idVRCusernameBTN").show()),void 0!==ATON.Photon.uid&&$("#idVRCusernameBTN").addClass("atonVRCu"+ATON.Photon.uid%6),$("#idChatBoxPopup").append(ATON.Photon._elChat),$("#idVRCmsg").keypress((e=>{if("13"==(e.keyCode?e.keyCode:e.which)){let e=$("#idVRCmsg").val();ATON.Photon.setMessage(e),$("#idVRCmsg").val("")}})),$("#idVRCusername").keypress((e=>{if("13"==(e.keyCode?e.keyCode:e.which)){let e=$("#idVRCusername").val();ATON.Photon.setUsername(e),$("#idVRCusername").hide(),$("#idVRCusernameBTN").html(ATON.Photon._username),$("#idVRCusernameBTN").show()}})),$("#idVRCusernameBTN").click((()=>{$("#idVRCusername").show(),$("#idVRCusernameBTN").hide()})),$("#idVRCdisconnect").click((()=>{ATON.Photon.disconnect(),ATON.FE.popupClose()})))},R.checkAuth=e=>{ATON.Utils.checkAuth((t=>{R._userAuth=t,void 0!==t.username?($("#btn-user").addClass("switchedON"),void 0===ATON.Photon._username&&ATON.Photon.setUsername(t.username)):$("#btn-user").removeClass("switchedON"),e&&e(t)}))},R.popupUser=()=>{R.checkAuth((e=>{if(void 0!==e.username){let t="
    ";if(t+="'"+e.username+"'

    ",Object.keys(R._uiProfiles).length>0){t+="UI Profile:


    "}if(t+="
    LOGOUT
    ",!ATON.FE.popupShow(t))return;R._uiCurrProfile&&(console.log(R._uiCurrProfile),$("#idUIProfiles").val(R._uiCurrProfile)),$("#idLogoutBTN").click((()=>{$.get(ATON.PATH_RESTAPI+"logout",(e=>{console.log(e),ATON.SceneHub.setEditMode(!1),R.uiSwitchButton("edit",!1),ATON.fireEvent("Logout"),$("#btn-user").removeClass("switchedON")})),ATON.FE.popupClose()})),$("#idSHUscenes").click((()=>{ATON.Utils.goToURL("/shu/scenes/")})),$("#idSHUuser").click((()=>{ATON.Utils.goToURL("/shu/auth/")})),$("#idUIProfiles").on("change",(()=>{let e=$("#idUIProfiles").val();R.uiLoadProfile(e),ATON.FE.popupClose()}))}else{let e="
    ";if(e+="username:
    ",e+="password:
    ",e+="
    LOGIN
    ",!ATON.FE.popupShow(e))return;$("#idLoginBTN").click((()=>{let e=JSON.stringify({username:$("#idUsername").val(),password:$("#idPassword").val()});$.ajax({url:ATON.PATH_RESTAPI+"login",type:"POST",data:e,contentType:"application/json; charset=utf-8",dataType:"json",success:e=>{console.log(e),e&&(ATON.fireEvent("Login",e),$("#btn-user").addClass("switchedON"),ATON.FE.popupClose())}}).fail((e=>{$("#idLoginBTN").html("LOGIN FAILED"),$("#idLoginBTN").attr("class","atonBTN atonBTN-red")}))}))}}))},R.popupSceneInfo=()=>{let e=ATON.SceneHub.getTitle();void 0===e&&(e=ATON.SceneHub.currID);let t=ATON.SceneHub.getDescription(),o="
    "+e+"
    ";t&&(o+="
    "+JSON.parse(t)+"
    "),o+="
    OK
    ",ATON.FE.popupShow(o)&&$("#btnOK").click((()=>{ATON._onUserInteraction(),ATON.FE.popupClose()}))},R.computeSelectorRanges=()=>{let e=ATON.bounds.radius;e<=0||(R._selRanges[0]=.001*e,R._selRefRadius=.01*e,R._selRanges[1]=.5*e)},R.popupSelector=()=>{let e="
    3D Selector
    ",t=ATON.SUI.getSelectorRadius(),o=ATON.Utils.getHumanReadableDistance(t);R.computeSelectorRanges(),e+="Radius ("+o+"):
    ",e+="",ATON.FE.popupShow(e,"atonPopupLarge")&&($("#idSelRad").val(t),$("#idSelRad").on("input change",(()=>{let e=parseFloat($("#idSelRad").val());ATON.SUI.setSelectorRadius(e),$("#idSelRadTxt").html(ATON.Utils.getHumanReadableDistance(e))})))},R.popupNav=()=>{let e="
    Navigation
    ";e+="
    ",e+="
    ",e+="
    Switch between first-person and orbit navigation mode
    ",e+="
    ",ATON.Utils.isConnectionSecure()&&(e+="
    ",e+="
    ",e+="
    Immersive VR mode
    ",e+="
    ",ATON.Utils.isMobile()&&(e+="
    ",e+="
    ",e+="
    Enable or disable device-orientation mode
    ",e+="
    ")),R.popupShow(e)&&(R.uiAddButtonFirstPerson("idNMfp"),R.uiAddButtonDeviceOrientation("idNMdevori"),R.uiAddButtonVR("idNMvr"))},R.popupModalToken=(e,t)=>{if(void 0===t)return;ATON.FE.popupClose();let o="
    Token Required
    ";e&&(o+=e),o+="

    ",o+="
    OK
    ",R.popupShow(o)&&$("#btnTokenOK").click((()=>{let e=$("#idTokStr").val();void 0===e||e.length<2||(ATON.FE.popupClose(),t(e))}))},R.popupNewNode=e=>{void 0===e&&(e=ATON.NTYPES.SCENE);let t="";e===ATON.NTYPES.SCENE&&(t="
    New Scene Node
    "),e===ATON.NTYPES.SEM&&(t="
    New Semantic Node
    "),t+="ID:
    ",t+="
    Add

    ",R.popupShow(t)&&$("#btnNewNID").click((()=>{let t=$("#idNID").val().trim();void 0===t||t.length<3||new ATON.Node(t,e).attachToRoot()}))};const y=R;let w={auType:"audio/wav",auStreamSegmentInterval:200,auStreamNumSegments:2,vidStreamSegmentInterval:300,vidStreamNumSegments:1,auMinVol:1,init:()=>{w._bAudioRecording=!1,w._bAudioStreaming=!1,w._bScreenRec=!1,w._blobOptAudio={type:"audio/wav"},w._blobOptVideo={type:"video/mp4"},w._cAuStream={audio:{channelCount:1,echoCancellation:!0,noiseSuppression:!0}},w._cAuRec={audio:{channelCount:1}},w._cScreenRec={video:{width:1280,height:720,framerate:30}},w._cScreenStream={video:{cursor:"always",width:{max:640},height:{max:360},framerate:15}},w._cCamStream={video:{width:{max:512},height:{max:512}}},w._oStream={audioBitsPerSecond:9e3,videoBitsPerSecond:5e5},w._aurec=void 0,w._sblob=void 0,w._schunks=[],w._bVideoStream=!1,w._vrec=void 0,w._scblob=void 0,w._scchunks=[],w._bCamStream=!1,w._bScreenStream=!1,w._setupFR(),w.detectDevices(),navigator.mediaDevices&&navigator.mediaDevices.addEventListener("devicechange",(e=>{w.detectDevices()})),w._vStreams={}},_setupFR:()=>{w._frAR=new window.FileReader,w._frAR.onloadend=()=>{let e=w._frAR.result;ATON.fireEvent("AudioRecordCompleted",e),w._bAudioRecording=!1},w._frAS=new window.FileReader,w._frAS.onloadend=()=>{if(!w._bAudioStreaming)return;let e=w._frAS.result;ATON.Photon.socket.emit("UTALK",{audio:e,uid:ATON.Photon.uid}),e=null},w._frVS=new window.FileReader,w._frVS.onloadend=()=>{if(!w._bVideoStream)return;let e=w._frVS.result;ATON.Photon.socket.emit("UVIDEO",{video:e,uid:ATON.Photon.uid}),e=null}},detectDevices:()=>{w.audioInputDevices=[],w.videoInputDevices=[],navigator.mediaDevices&&navigator.mediaDevices.enumerateDevices().then((e=>{for(let t in e){let o=e[t];"audioinput"===o.kind&&w.audioInputDevices.push(o),"videoinput"===o.kind&&w.videoInputDevices.push(o)}}))},hasAudioInput:()=>w.audioInputDevices.length>0,hasVideoInput:()=>w.videoInputDevices.length>0,isAudioRecording:()=>w._bAudioRecording,startRecording:()=>{w._bAudioRecording?console.log("Already recording."):navigator.mediaDevices.getUserMedia(w._cAuRec).then((e=>{w._aurec=new MediaRecorder(e),w._aurec.onstart=function(e){console.log("Start recording..."),w._bAudioRecording=!0,w._schunks=[]},w._aurec.ondataavailable=function(e){w._schunks.push(e.data)},w._aurec.onstop=function(e){console.log("Stop recording..."),w._sblob=new Blob(w._schunks,w._blobOptAudio),w._frAR.readAsDataURL(w._sblob)},w._aurec.start()})).catch((e=>{console.log(e)}))},stopRecording:()=>{w._aurec&&w._bAudioRecording&&w._aurec.stop()},startOrStopRecording:()=>{w._bAudioRecording?w.stopRecording():w.startRecording()},startAudioStreaming:()=>{navigator.mediaDevices.getUserMedia(w._cAuStream).then((e=>{w._aurec=new MediaRecorder(e,w._oStream),w._aurec.start(w.auStreamSegmentInterval),console.log("Start audio streaming"),w._aurec.onstart=e=>{w._bAudioStreaming=!0,w._bAudioRecording=!0,w._schunks=[]},w._aurec.ondataavailable=e=>{e.data.size<=0||(w._schunks.push(e.data),w._schunks.length{w._sblob=new Blob(w._schunks,w._blobOptAudio),w._frAS.readAsDataURL(w._sblob),w._bAudioStreaming&&w._aurec.start(w.auStreamSegmentInterval)}})).catch((e=>{console.log(e)}))},stopAudioStreaming:()=>{w._aurec&&w._bAudioStreaming&&("inactive"!==w._aurec.state&&w._aurec.stop(),console.log("Stop audio streaming"),w._bAudioStreaming=!1,w._bAudioRecording=!1,ATON.Photon.socket.emit("UAUDIOSTOP",{uid:ATON.Photon.uid}))},startOrStopAudioStreaming:()=>{w._bAudioRecording?w.stopAudioStreaming():w.startAudioStreaming()},startScreenRecording:()=>{w._bScreenRec||w._bScreenStream||navigator.mediaDevices.getDisplayMedia(w._cScreenRec).then((e=>{w._vrec=new MediaRecorder(e),w._scchunks=[],w._vrec.ondataavailable=e=>{e.data.size>0&&w._scchunks.push(e.data)},w._vrec.onstop=()=>{w._scblob=new Blob(w._scchunks,w._blobOptVideo),console.log(w._scblob.size),ATON.Utils.downloadBlob(w._scblob,"capture.mp4"),w._scchunks=[],w._bScreenRec=!1},w._vrec.start(200),w._bScreenRec=!0})).catch((e=>{console.log(e)}))},stopScreenRecording:()=>{w._bScreenRec&&(w._vrec.stop(),w._bVideoStream=!1,w._bScreenStream=!1,console.log("Stop screen recording"))},startScreenStreaming:()=>{navigator.mediaDevices.getDisplayMedia(w._cScreenStream).then((e=>{w.realizeOrUpdateVStream(e,w.stopScreenStreaming),w._vrec=new MediaRecorder(e,w._oStream),w._vrec.start(w.vidStreamSegmentInterval),console.log("Start screen streaming"),w._vrec.onstart=e=>{w._bVideoStream=!0,w._bScreenStream=!0,w._scchunks=[]},w._vrec.ondataavailable=e=>{e.data.size<1||(w._scchunks.push(e.data),w._scchunks.length{w._scblob=new Blob(w._scchunks,w._blobOptVideo),w._frVS.readAsDataURL(w._scblob),w._bVideoStream&&w._vrec.start(w.vidStreamSegmentInterval)}})).catch((e=>{console.log(e)}))},stopScreenStreaming:()=>{if(w._vrec&&w._bVideoStream&&(w._vrec.stop(),w._bVideoStream=!1,w._bScreenStream=!1,console.log("Stop screen streaming"),void 0!==ATON.Photon.uid)){let e=w.getVideoStream(ATON.Photon.uid);e.el.style.display="none",e.el.pause(),ATON.Photon.socket.emit("UVIDEOSTOP",{uid:ATON.Photon.uid})}},startOrStopScreenStreaming:()=>{w._bVideoStream?w.stopScreenStreaming():w.startScreenStreaming()},startCameraStreaming:()=>{w._bVideoStream||navigator.mediaDevices.getUserMedia(w._cCamStream).then((e=>{w.realizeOrUpdateVStream(e,w.stopCameraStreaming),w._vrec=new MediaRecorder(e,w._oStream),w._vrec.start(w.vidStreamSegmentInterval),console.log("Start camera streaming"),w._vrec.onstart=e=>{w._bVideoStream=!0,w._bCamStream=!0,w._scchunks=[]},w._vrec.ondataavailable=e=>{e.data.size<1||(w._scchunks.push(e.data),w._scchunks.length{w._scblob=new Blob(w._scchunks,w._blobOptVideo),w._frVS.readAsDataURL(w._scblob),w._bVideoStream&&w._vrec.start(w.vidStreamSegmentInterval)}})).catch((e=>{console.log(e)}))},stopCameraStreaming:()=>{if(w._vrec&&w._bVideoStream&&(w._vrec.stop(),w._bVideoStream=!1,w._bCamStream=!1,console.log("Stop camera streaming"),void 0!==ATON.Photon.uid)){let e=w.getVideoStream(ATON.Photon.uid);e.el.style.display="none",e.el.pause(),ATON.Photon.socket.emit("UVIDEOSTOP",{uid:ATON.Photon.uid})}},startOrStopCameraStreaming:()=>{w._bVideoStream?w.stopCameraStreaming():w.startCameraStreaming()},realizeOrUpdateVStream:(e,t)=>{let o=ATON.Photon.uid;if(void 0===o)return;let i=w.getOrCreateVideoStream(o,void 0,!0);i.el.playsinline=!0,i.el.style.display="inline-block",i.el.classList.add("atonVRCvidStream"),i.el.classList.add("atonVRCu"+o%6),t&&(i.el.onclick=t),i.el.srcObject=e},stopAllStreams:()=>{w.stopAudioStreaming(),w.stopCameraStreaming(),w.stopScreenStreaming()},getOrCreateVideoStream:(e,t,o)=>{if(w._vStreams[e])t&&(w._vStreams[e].el.src=t);else{w._vStreams[e]={};let i="vStream-"+e;if(o&&(i="uStream"+e,w._vStreams[e].uid=e),$("").appendTo("body"),w._vStreams[e].el=document.getElementById(i),t)if(t.endsWith("m3u8"))if(Hls.isSupported()){let o=new Hls;o.loadSource(t),o.attachMedia(w._vStreams[e].el)}else w._vStreams[e].el.src=t;else w._vStreams[e].el.src=t;o||(w._vStreams[e].el.loop=!0),w._vStreams[e].texStream=new THREE.VideoTexture(w._vStreams[e].el),w._vStreams[e].texStream.colorSpace=ATON._stdEncoding,w._vStreams[e].texStream.flipY=!1,w._vStreams[e].matStream=ATON.MatHub.materials.chromakey.clone(),w._vStreams[e].matStream.uniforms.tBase.value=w._vStreams[e].texStream}return w._vStreams[e]},getVideoStream:e=>w._vStreams[e],downloadVideoSnapshot:(e,t,o)=>{o||(o=1);let i=e.videoWidth*o,r=e.videoHeight*o,a=document.createElement("canvas");a.width=i,a.height=r,a.getContext("2d").drawImage(e,0,0,i,r),ATON.Utils.downloadImageFromCanvas(a,t)}};const M=w;let L={EARTH_R_KM:6371};L.EARTH_D_KM=2*L.EARTH_R_KM,L.init=()=>{L._bActive=!1,L._wpid=void 0,L._currGeoPos=new THREE.Vector2,L._GeoPOIs=[],L._currGeoPOI=void 0,L._closestGeoPOI=void 0,L._maxGeoError=40},L.enableGeoTracking=()=>{L._bActive||ATON.Utils.isConnectionSecure()&&navigator.geolocation&&(L._wpid=navigator.geolocation.watchPosition(L._onGeoPosition,L._onGeoError,{enableHighAccuracy:!0}),L._bActive=!0)},L.disableGeoTracking=()=>{L._bActive&&(navigator.geolocation.clearWatch(L._wpid),L._bActive=!1)},L.setMaxGeoError=e=>{e>0&&(L._maxGeoError=e)},L._onGeoError=()=>{console.log("Geolocation error")},L._onGeoPosition=e=>{if(!L._bActive)return;if(!e.coords)return;let t=e.coords.accuracy;t&&t>L._maxGeoError||(L._currGeoPos.x=e.coords.latitude,L._currGeoPos.y=e.coords.longitude,ATON.fireEvent("GeoLocation",e),L._handleGeoPOIs())},L._handleGeoPOIs=()=>{let e=L._GeoPOIs.length;if(!(e<=0)){L._closestGeoPOIdist=void 0,L._closestGeoPOI=void 0;for(let t=0;t{if(L._bActive)return L._currGeoPos},L.geolocationFromLatLon=(e,t)=>new THREE.Vector2(e,t),L.geodistance_orig=(e,t)=>{let o=ATON.DEG2RAD*(t.x-e.x),i=ATON.DEG2RAD*(t.y-e.y),r=Math.sin(o/2)*Math.sin(o/2)+Math.cos(ATON.DEG2RAD*e.x)*Math.cos(ATON.DEG2RAD*t.x)*Math.sin(i/2)*Math.sin(i/2),a=2*Math.atan2(Math.sqrt(r),Math.sqrt(1-r));return L.EARTH_R_KM*a*1e3},L.geodistance=(e,t)=>{let o=.5-Math.cos((t.x-e.x)*ATON.DEG2RAD)/2+Math.cos(e.x*ATON.DEG2RAD)*Math.cos(t.x*ATON.DEG2RAD)*(1-Math.cos((t.y-e.y)*ATON.DEG2RAD))/2;return L.EARTH_D_KM*Math.asin(Math.sqrt(o))*1e3},L.addGeoPOI=(e,t)=>{let o={};return o.pos=new THREE.Vector2(e.x,e.y),o.radius=t,L._GeoPOIs.push(o),L._bActive||L.enableTracking(),L._handleGeoPOIs(),L._GeoPOIs.length-1},L.getGeoPOIbyIndex=e=>L._GeoPOIs[e],L.getClosestGeoPOI=()=>L._closestGeoPOI,L.getClosestGeoPOIdistance=()=>L._closestGeoPOIdist;const C=L;let H={};H._id=$("meta[name='aton\\:appid']").attr("content"),H._data={},H.setup=void 0,H.update=void 0,H._bRunning=!1,H._pDeps=[],H._fLoading=0,H._sendDataPatch=(e,t,o)=>new Promise(((i,r)=>{if(void 0===e)return void r("No storage ID specified");if(e.length<3)return void r("Storage ID too short");if(void 0===t)return void r("No storage patch");if(void 0===H._id)return void r("No app-ID");void 0===o&&(o=ATON.PATCH_ADD);let a={};a.wappid=H._id,a.fid=e,a.data=t,a.mode=o===ATON.PATCH_DEL?"DEL":"ADD";let s=JSON.stringify(a);$.ajax({url:ATON.PATH_RESTAPI+"patch/wapp",type:"POST",data:s,contentType:"application/json; charset=utf-8",dataType:"json",success:t=>{void 0!==t?(H._data[e]=t,i(t)):r("Error writing on server")}})})),H.getAppID=()=>H._id,H.addToStorage=(e,t)=>H._sendDataPatch(e,t,ATON.PATCH_ADD),H.deleteFromStorage=(e,t)=>H._sendDataPatch(e,t,ATON.PATCH_DEL),H.getStorage=e=>new Promise(((t,o)=>{void 0!==H._id?void 0!==e?$.getJSON(ATON.PATH_WAPPS+H._id+"/data/"+e+".json",(o=>{console.log(o),H._data[e]=o,t(o)})):o("No storage ID specified"):o()})),H.registerServiceWorker=e=>{if(e)return H.basePath&&(e=H.basePath+e),"serviceWorker"in navigator&&window.addEventListener("load",(()=>{navigator.serviceWorker.register(e).then((e=>console.log("PWA service worker registered"))).catch((e=>console.log("PWA service worker not registered",e)))})),H},H.requireFlares=e=>{if(e)return ATON._fReqList=e,console.log("Required Flares: "+ATON._fReqList),H},H.loadScene=(e,t)=>{void 0!==e&&ATON.SceneHub.load(ATON.PATH_RESTAPI2+"scenes/"+e,e,t)},H.realize=(e,t,o)=>{H.setup=e,H.update=t,H.params=new URLSearchParams(window.location.search),H.basePath=ATON.Utils.getBaseFolder(window.location.href.split("?")[0]),H.registerServiceWorker(o);let i=H.params.get("ff");if(i){let e=String(i).split(",");H.requireFlares(e)}return H},H.realizeAndRun=(e,t,o)=>{H.realize(e,t,o).run()},H.run=()=>!H._bRunning&&(H._bRunning=!0,H.setup?H.setup():(ATON.FE.realize(),console.log("App [Warn]: your App should define a setup() routine")),H.update&&(ATON.addUpdateRoutine(H.update),console.log("App: update routine registered")),ATON._fRequired<=0&&ATON.fireEvent("AllFlaresReady"),!0);const D=H;let x={PASS_BASE:"p_base",PASS_AA:"p_aa",PASS_AO:"p_ao",PASS_SSR:"p_ssr",PASS_BLOOM:"p_bloom",PASS_DOF:"p_dof",PASS_GAMMA:"p_gamma",PASS_SOBEL:"p_sobel",init:()=>{if(void 0===ATON._renderer)return;let e=ATON._renderer.getPixelRatio(),t=ATON._renderer.getSize(new THREE.Vector2);const o=new THREE.WebGLRenderTarget(t.width*e,t.height*e,{minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,format:THREE.RGBAFormat,colorSpace:ATON._stdEncoding});o.texture.name="EffectComposer.rt1",x.composer=new THREE.EffectComposer(ATON._renderer,o),x.passes={},ATON._renderer.autoClear=!1;let i=window.innerWidth*ATON._stdpxd,r=window.innerHeight*ATON._stdpxd;x.passes[x.PASS_BASE]=new THREE.RenderPass(ATON._mainRoot,ATON.Nav._camera),x.composer.addPass(x.passes[x.PASS_BASE]),x.passes[x.PASS_AO]=new THREE.SAOPass(ATON._mainRoot,ATON.Nav._camera,i,r),x.passes[x.PASS_AO].params.saoBias=1,x.passes[x.PASS_AO].params.saoScale=100,x.passes[x.PASS_AO].params.saoIntensity=.2,x.passes[x.PASS_BLOOM]=new THREE.UnrealBloomPass(new THREE.Vector2(i,r),1.5,.4,.85),x.passes[x.PASS_BLOOM].threshold=.9,x.passes[x.PASS_BLOOM].strength=1,x.passes[x.PASS_BLOOM].radius=1.2,x.passes[x.PASS_DOF]=new THREE.BokehPass(ATON._mainRoot,ATON.Nav._camera,{focus:5,aperture:.001,maxblur:.01,width:i,height:r}),x.composer.addPass(x.passes[x.PASS_AO]),x.composer.addPass(x.passes[x.PASS_BLOOM]),x.composer.addPass(x.passes[x.PASS_DOF]),x.togglePass(x.PASS_AO,!1),x.togglePass(x.PASS_BLOOM,!1),x.togglePass(x.PASS_DOF,!1)},togglePass:(e,t)=>{void 0!==x.composer&&(ATON.device.lowGPU||void 0!==x.passes[e]&&(x.passes[e].enabled=void 0===t?!x.passes[e].enabled:t))},isPassEnabled:e=>void 0!==x.composer&&(void 0!==x.passes[e]&&x.passes[e].enabled),setAOintensity:e=>{void 0!==x.composer&&void 0!==x.passes[x.PASS_AO]&&(x.passes[x.PASS_AO].params.saoIntensity=e)},getAOintensity:()=>void 0===x.composer||void 0===x.passes[x.PASS_AO]?0:x.passes[x.PASS_AO].params.saoIntensity,setBloomStrength:e=>{void 0!==x.composer&&void 0!==x.passes[x.PASS_BLOOM]&&(x.passes[x.PASS_BLOOM].strength=e)},getBloomStrength:()=>void 0===x.composer||void 0===x.passes[x.PASS_BLOOM]?0:x.passes[x.PASS_BLOOM].strength,setBloomThreshold:e=>{void 0!==x.composer&&void 0!==x.passes[x.PASS_BLOOM]&&(x.passes[x.PASS_BLOOM].threshold=e)},getBloomThreshold:()=>void 0===x.composer||void 0===x.passes[x.PASS_BLOOM]?0:x.passes[x.PASS_BLOOM].threshold,setDOFfocus:e=>{if(void 0===x.composer)return;if(void 0===x.passes[x.PASS_DOF])return;let t=x.passes[x.PASS_DOF].uniforms;void 0!==t&&(t.focus.value=e)},getDOFfocus:()=>{if(void 0===x.composer)return 0;if(void 0===x.passes[x.PASS_DOF])return 0;let e=x.passes[x.PASS_DOF].uniforms;return void 0===e?0:e.focus.value},setDOFaperture:e=>{if(void 0===x.composer)return;if(void 0===x.passes[x.PASS_DOF])return;let t=x.passes[x.PASS_DOF].uniforms;void 0!==t&&(t.aperture.value=e)}};const F=x;let V={STD_XPF_TRANSITION_DURATION:1,SEM_PREFIX:"XPF",SEMGROUP_PREFIX:"GXPF",init:()=>{V._list=[],V._iCurr=void 0,V._iNext=void 0,V._geom=void 0,V._mesh=void 0,V._mat=void 0,V._size=50,V._gSem=[],V._semIMGMasks={},V._semCanvas=void 0,V._semCTX=void 0,V._semCurr=void 0,V._shColor=new THREE.Color(0,0,1),V._shOpacity=.2,V._txCache={},V._pathMod=void 0,V._realizeBaseMat(),V._elVid=void 0,V._vidPlaying=!1},_realizeBaseMat:()=>{V._uniforms={tBase:{type:"t"},tSem:{type:"t"},tSemHint:{type:"t"},semHL:{type:"vec4",value:new THREE.Vector4(0,1,0,.15)},opacity:{type:"float",value:1},shColor:{type:"vec4",value:new THREE.Vector4(0,0,1,.2)},time:{type:"float",value:0}},V._mat=new THREE.ShaderMaterial({uniforms:V._uniforms,vertexShader:"\n varying vec3 vPositionW;\n varying vec3 vNormalW;\n varying vec3 vNormalV;\n varying vec2 vUv;\n\n void main(){\n vUv = uv;\n\n vPositionW = vec3( vec4( position, 1.0 ) * modelMatrix);\n vNormalW = normalize( vec3( vec4( normal, 0.0 ) * modelMatrix ) );\n vNormalV = normalize( vec3( normalMatrix * normal ));\n\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }\n ",fragmentShader:"\n varying vec3 vPositionW;\n\t\t varying vec3 vNormalW;\n varying vec3 vNormalV;\n varying vec2 vUv;\n\n uniform float time;\n uniform sampler2D tBase;\n uniform sampler2D tSem;\n uniform sampler2D tSemHint;\n //uniform sampler2D tDepth;\n\n uniform vec4 semHL, shColor;\n uniform float opacity;\n\n\t\t void main(){\n vec4 frag = texture2D(tBase, vUv);\n vec4 sem = texture2D(tSem, vUv);\n vec4 semH = texture2D(tSemHint, vUv);\n float shv = max( max(semH.r,semH.g), semH.b);\n\n float t = (1.0 * cos(time*2.0));\n t = clamp(t, 0.0,1.0);\n\n frag = mix(frag, semHL, (sem.r * semHL.a));\n\n frag = mix(frag, shColor, (t * shv * shColor.a));\n\n frag.a = opacity;\n\n gl_FragColor = frag;\n\t\t }\n ",depthTest:!1,depthWrite:!1}),V.setSemanticHintMapOpacity(.2)},setPathModifier:e=>{if(void 0!==e){V._pathMod=e;for(let t in V.list)V.list[t].setPathModifier(e)}},update:()=>{if(ATON.Nav.isTransitioning())return;if(V._list.length<1)return;let e,t,o,i,r=V._list.length,a=ATON.Nav._currPOV.pos,s=ATON.Nav._vDir;V._uniforms.time.value+=ATON._dt,void 0===V._dirLNode&&(V._dirLNode=new THREE.Vector3);for(let n=0;n.8&&(void 0===o||l{void 0===V._geom&&(V._group=new THREE.Group,ATON._rootVisibleGlobal.add(V._group),V._geom=new THREE.SphereGeometry(1,40,40),V._geom.scale(-V._size,V._size,V._size),V._geom.castShadow=!1,V._geom.receiveShadow=!1,V._mesh=new THREE.Mesh(V._geom,V._mat),V._mesh.frustumCulled=!1,V._mesh.renderOrder=-100,V._mesh.layers.enable(ATON.NTYPES.SCENE),V._group.add(V._mesh),V._mesh.visible=!1)},setBaseGeometry:e=>{},add:e=>{if(void 0===e)return;V.realizeBaseGeometry();let t=V._list.length;V._list.push(e);let o=e.getMesh();o&&V._group.add(o);let i=ATON.getOrCreateSemanticNode(V.SEMGROUP_PREFIX+t);V._gSem.push(i),i.attachToRoot(),t>0||(ATON.Nav.toggleLocomotionValidator(!1),ATON._bqScene=!0)},clear:()=>{V._iCurr=void 0,V._iNext=void 0,V._semCurr=void 0;for(let e=0;eV._list.length,getMainGroup:()=>V._group,getSemanticGroup:e=>V._gSem[e],getCurrentSemanticGroup:()=>{if(void 0!==V._iCurr)return V._gSem[V._iCurr]},_preloadBaseLayer:(e,t)=>{if(void 0!==V._txCache[e])return V._txCache[e];let o=V._list[e]._pathbaselayer;V._pathMod&&(o=V._pathMod(o)),ATON.Utils.textureLoader.load(o,(o=>{o.colorSpace=ATON._stdEncoding,o.generateMipmaps=!0,V._txCache[e]=o,t&&t(o)}))},_clearTexCache:()=>{if(void 0!==V._iCurr)for(let e in V._txCache)V._txCache[e]&&e!==V._iCurr&&(V._txCache[e].dispose(),V._txCache[e]=void 0)},_setBaseLayerTexture:(e,t)=>{V._mat.map=t,V._mat.needsUpdate=!0,V._mesh.position.copy(e.getLocation()),V._mesh.rotation.set(e.getRotation().x,e.getRotation().y,e.getRotation().z)},updateCurrentXPFbaseLayer:e=>{if(void 0===V._iCurr)return;let t=V._list[V._iCurr];if(void 0===t)return;let o=t._pathbaselayer;if(V._pathMod&&(o=V._pathMod(o)),ATON.Utils.isVideo(o)){if(void 0===V._elVid){let e="",$(e).appendTo("body"),V._elVid=document.getElementById("idXPFVideo"),V._elVid.onplaying=()=>{console.log("XPF VideoPano playing"),V._vidPlaying=!0},V._elVid.onpause=()=>{console.log("XPF VideoPano paused"),V._vidPlaying=!1},V._elVid.addEventListener("touchstart",(function(){V._elVid.play()})),enableInlineVideo(V._elVid)}let i=new THREE.VideoTexture(V._elVid);return i.colorSpace=ATON._stdEncoding,V._mat.map=i,V._mat.needsUpdate=!0,V._uniforms.tBase.value=i,V._mesh.position.copy(t.getLocation()),V._mesh.rotation.set(t.getRotation().x,t.getRotation().y,t.getRotation().z),void(e&&e(i))}ATON.Utils.textureLoader.load(o,(o=>{o.colorSpace=ATON._stdEncoding,o.generateMipmaps=!0,V._mat.map=o,V._mat.needsUpdate=!0,V._uniforms.tBase.value=o,V._mesh.position.copy(t.getLocation()),V._mesh.rotation.set(t.getRotation().x,t.getRotation().y,t.getRotation().z),e&&e(o)}))},playOrPauseXPFVideoStream:()=>{void 0!==V._elVid&&(V._vidPlaying?V._elVid.pause():V._elVid.play())},updateCurrentXPFsemLayer:e=>{let t=V._list.indexOf(e);t<0||t===V._iCurr&&V.loadSemanticMasksIfAny(V._iCurr)},setCurrentXPF:(e,t)=>{V.toggleSUI(e,!1),V._iCurr=e,V._iNext=void 0,V._mesh.visible=!0,V._gSem[e].show(),V.updateCurrentXPFbaseLayer(t),ATON.fireEvent("CurrentXPF",e),ATON.fireEvent("NextXPF",void 0),V.loadSemanticMasksIfAny(e)},toggleSUI:(e,t)=>{if(void 0===e)return;let o=V._list[e];void 0!==o&&o._lnode.toggleSUI(t)},loadSemanticMasksIfAny:e=>{let t=V._list[e];if(void 0!==t){V._semIMGMasks={},V._uniforms.tSemHint.value=0,void 0!==t._semHintURL&&(V._uniforms.tSemHint.value=ATON.Utils.textureLoader.load(t._semHintURL));for(let e in t._semMasksURLs){void 0===V._semCanvas&&(V._semCanvas=document.createElement("canvas"),V._semCanvas.width=2048,V._semCanvas.height=2048,V._semCTX=V._semCanvas.getContext("2d",{willReadFrequently:!0}));let o=t._semMasksURLs[e],i=new Image;i.src=o,V._semIMGMasks[e]=i}}},getXPFbyIndex:e=>V._list[e],getCurrentXPFindex:()=>V._iCurr,getCurrentXPF:()=>{if(void 0!==V._iCurr)return V._list[V._iCurr]},getNextXPFindex:()=>V._iNext,getNextXPF:()=>{if(void 0!==V._iNext)return V._list[V._iNext]},getDistanceToXPFindex:e=>{if(void 0===e)return;let t=V._list[e];return void 0!==t?ATON.Nav._currPOV.pos.distanceTo(t.getLocation()):void 0},showSUIonlyForXPF:e=>{let t=V._list.length;if(!(t<1))for(let o=0;o{let o=V._list[e];void 0!==o&&(void 0===t&&(t=V.STD_XPF_TRANSITION_DURATION),ATON.XR._bPresenting&&(t=0),V.setCurrentXPF(e),ATON.Nav.requestTransitionToLocomotionNode(o.getLocomotionNode(),t))},requestTransitionToTarget:(e,t,o)=>{if(void 0===e)return;let i=new ATON.POV;i.setTarget(e),i.setPosition(ATON.Nav._currPOV.pos),t&&i.setFOV(t),ATON.Nav.requestPOV(i,o)},requestTransitionToDirection:(e,t,o)=>{if(void 0===e)return;let i=new THREE.Vector3;i.x=e.x+ATON.Nav._currPOV.pos.x,i.y=e.y+ATON.Nav._currPOV.pos.y,i.z=e.z+ATON.Nav._currPOV.pos.z,V.requestTransitionToTarget(i,t,o)},setHomeXPF:e=>{let t=V._list[e];if(void 0===t)return;let o=t.getLocomotionNode(),i=(new ATON.POV).setPosition(o.pos).setTarget(o.pos.x,o.pos.y,o.pos.z+1);ATON.Nav.setHomePOV(i)},getSemanticMaskURLfromXPFindex:(e,t)=>{let o=V._list[e];if(void 0!==o)return o.getSemanticMaskURL(t)},getSemanticMaskURLfromCurrentXPF:e=>{if(void 0!==V._iCurr)return V.getSemanticMaskURLfromXPFindex(V._iCurr,e)},setSemanticColor:(e,t)=>{void 0===t&&(t=.15),V._uniforms.semHL.value=new THREE.Vector4(e.r,e.g,e.b,t)},setSemanticOpacity:e=>{void 0===e&&(e=.15),V._uniforms.semHL.value.w=e},setSemanticHintMapOpacity:e=>{void 0===e&&(e=.2),V._shOpacity=e,V._uniforms.shColor.value.w=e},setSemanticHintMapColor:(e,t)=>{void 0!==e&&(V._shColor=e,V._uniforms.shColor.value.x=e.r,V._uniforms.shColor.value.y=e.g,V._uniforms.shColor.value.z=e.b,void 0!==t&&V.setSemanticHintMapOpacity(t))},querySemanticMasks:()=>{if(void 0===V._semCTX)return;if(void 0===ATON._queryDataScene)return;if(void 0===ATON._queryDataScene.uv)return;let e,t=V._semCTX,o=ATON._queryDataScene.uv;for(let i in V._semIMGMasks){let r=V._semIMGMasks[i],a=parseInt(r.width*o.x),s=parseInt(r.height*(1-o.y));if(t.drawImage(r,0,0),t.getImageData(a,s,1,1).data[0]>127){e=i;break}}if(void 0===e)return void 0!==V._semCurr&&ATON.fireEvent("SemanticMaskLeave",V._semCurr),V._semCurr=void 0,V._uniforms.tSem.value=0,V._uniforms.shColor.value.w=V._shOpacity,void(V._mat.needsUpdate=!0);V.highlightSemanticMaskInCurrentXPF(e),V._semCurr=e},highlightSemanticMaskInCurrentXPF:e=>{if(void 0===e)return void 0!==V._semCurr&&ATON.fireEvent("SemanticMaskLeave",V._semCurr),V._semCurr=void 0,V._uniforms.tSem.value=0,V._uniforms.shColor.value.w=V._shOpacity,void(V._mat.needsUpdate=!0);if(V._semCurr===e)return;let t=V.getSemanticMaskURLfromCurrentXPF(e);V._uniforms.tSem.value=ATON.Utils.textureLoader.load(t),V._mat.needsUpdate=!0,ATON.fireEvent("SemanticMaskHover",e),V._uniforms.shColor.value.w=0,void 0!==V._semCurr&&ATON.fireEvent("SemanticMaskLeave",V._semCurr)},loadFromPhotoscanFile:(e,t)=>{if(void 0===e)return;e=ATON.Utils.resolveCollectionURL(e);let o=ATON.Utils.getBaseFolder(e),i=0;$.ajax({url:e,dataType:"text",success:function(e){e=e.split(/\r\n|\n/);for(let t in e){let r=e[t];if(!r.startsWith("#")){let e=r.split(/\s{2,}|\t/);if(e.length>10){let t=new ATON.XPF,r=o+e[0],a=parseFloat(e[1]),s=parseFloat(e[2]),n=parseFloat(e[3]),l=ATON.DEG2RAD*parseFloat(e[4]);ATON.DEG2RAD,parseFloat(e[5]),ATON.DEG2RAD,parseFloat(e[6]),t.setLocation(a,n,-s),t.setBaseLayer(r),t.setRotation(0,-l,0),V.add(t),i++}}}console.log("Num panoramas parsed: "+i),t&&t()}})}};const I=V;let U={init:()=>{U.list=[]},anyCopyrightFound:()=>U.list.length>0,extract:e=>{if(void 0===e)return;if(void 0===e.asset)return;let t={};if(e.asset.copyright&&(t.copyright=e.asset.copyright),e.asset.extras)for(let o in e.asset.extras)"string"==typeof e.asset.extras[o]&&(t[o]=e.asset.extras[o]);if(U.extractXMP3DC(e,t),0!==Object.keys(t).length){e.asset.generator&&(t.generator=e.asset.generator);for(let e in U.list){let o=U.list[e];if(U.compare(t,o))return}U.list.push(t),console.log(t)}},compare:(e,t)=>{if(void 0===e||void 0===t)return!1;const o=Object.keys(e),i=Object.keys(t);if(o.length!==i.length)return!1;for(let i of o)if(e[i]!==t[i])return!1;return!0},extractXMP3DC:(e,t)=>{if(void 0===e||void 0===t)return;if(!e.userData)return;let o=e.userData.gltfExtensions;if(!o)return;if(!o.KHR_xmp)return;let i=o.KHR_xmp.packets;if(!i)return;let r=i[0],a="en-us";r["model3d:spdxLicense"]&&(t.license=r["model3d:spdxLicense"]),r["dc:date"]&&(t.date=r["dc:date"]),r["dc:title"]&&(t.title=r["dc:title"][a]),r["dc:description"]&&(t.description=r["dc:description"][a]),r["dc:rights"]&&(t.rights=r["dc:rights"][a]),r["dc:source"]&&(t.source=r["dc:source"]),r["dc:subject"]&&(t.subject=r["dc:subject"]),r["dc:type"]&&(t.type=r["dc:type"]),r["xmpRights:Owner"]&&(t.owner=r["xmpRights:Owner"]),r["xmp:CreatorTool"]&&(t.creatorTool=r["xmp:CreatorTool"])}};const k=U;let B={REST_API_CESIUMION_DEF_TOKEN:"https://api.cesium.com/v2/tokens/default",THRES_ORI:.01,THRES_POS:1e-6,init:()=>{B._tsets=[],B._tsET=20,B._tsB=!1,B._bTileBVH=!0,B._tsTasks=[],B.tsSchedCB=e=>{B._tsTasks.push(e)},B._tseBase=8,B.estimateTSErrorTarget(),B._tsuSync=0,B._bPCs=!1,B._pqLRU=void 0,B._pqDownload=void 0,B._pqParse=void 0,B._numTilesLoaded=0,B._numTSLoaded=0},clear:()=>{for(let e in B._tsets)B._tsets[e]=null;B._tsets=[],B._bPCs=!1},getTSetsErrorTarget:()=>B._tsET,setTSetsErrorTarget:e=>{B._tsET=e;const t=B._tsets.length;if(!(t<=0))for(let o=0;o{B._tsB=e;const t=B._tsets.length;if(!(t<=0))for(let o=0;o{void 0===e&&(e=ATON.Nav._camera);const t=B._tsets.length;if(!(t<=0))for(let o=0;o{B._tseBase=e,console.log(B._tseBase),B.estimateTSErrorTarget()},estimateTSErrorTarget:()=>{let e=B._tseBase;(ATON.device.lowGPU||ATON.device.isMobile)&&(e+=4),ATON.XR._bPresenting&&(e+=3),e<1&&(e=1),e>25&&(e=25),console.log("Estimated TSet error target: "+e),B.setTSetsErrorTarget(e)},loadTileSetFromURL:(e,t,o)=>{if(void 0===t)return;let i=new TILES.TilesRenderer(e);if(!i)return;ATON._assetReqNew(e),i.displayBoxBounds=B._tsB,i.fetchOptions.mode="cors",o&&(i.fetchOptions.headers={},i.fetchOptions.headers.Authorization=`Bearer ${o.accessToken}`,i.preprocessURL=e=>(e=new URL(e),/^http/.test(e.protocol)&&e.searchParams.append("v",o.v),e.toString())),i.errorTarget=B._tsET,i.optimizeRaycast=!1,void 0===B._pqLRU?(i.downloadQueue.schedulingCallback=B.tsSchedCB,i.parseQueue.schedulingCallback=B.tsSchedCB,i.downloadQueue.maxJobs=6,i.parseQueue.maxJobs=1,B._pqLRU=i.lruCache,B._pqDownload=i.downloadQueue,B._pqParse=i.parseQueue):(i.lruCache=B._pqLRU,i.downloadQueue=B._pqDownload,i.parseQueue=B._pqParse),i.setCamera(ATON.Nav._camera),i.setResolutionFromRenderer(ATON.Nav._camera,ATON._renderer),i.manager.addHandler(/\.gltf$/,ATON._aLoader),i.manager.addHandler(/\.ktx2$/,ATON._ktx2Loader),i.manager.addHandler(/\.drc$/,ATON._dracoLoader),t.add(i.group),$.getJSON(e,(e=>{ATON.CC.extract(e)}));let r=new THREE.Box3,a=new THREE.Sphere;new THREE.Matrix4,new THREE.Vector3;let s=!1;i.addEventListener("load-tile-set",(()=>{if(console.log("TileSet loaded"),ATON._assetReqComplete(e),B._numTSLoaded++,o||t.bUseGeoCoords){console.log("TileSet using GeoCoords"),i.getBoundingSphere(a);const e=a.center.clone(),t=e.length(),o=e.normalize(),r=new THREE.Vector3(0,1,0),s=ATON.Utils.rotationBetweenDirections(o,r);i.group.quaternion.x=s.x,i.group.quaternion.y=s.y,i.group.quaternion.z=s.z,i.group.quaternion.w=s.w,i.group.position.y=-t}else i.getBoundingBox(r)?(r.getBoundingSphere(a),t.autocenter?(r.getCenter(i.group.position),i.group.position.multiplyScalar(-1)):void 0===ATON.Nav.homePOV&&ATON.Nav.computeAndRequestDefaultHome(.5,void 0,a)):i.getBoundingSphere(a)&&(t.autocenter?(i.group.position.copy(a.center),i.group.position.multiplyScalar(-1)):void 0===ATON.Nav.homePOV&&ATON.Nav.computeAndRequestDefaultHome(.5,void 0,a))})),i.addEventListener("load-model",(e=>{let o=e.scene;B._numTilesLoaded++,o.traverse((e=>{if(e.layers.enable(t.type),e.isMesh?(e.castShadow=!0,e.receiveShadow=!0,B._bTileBVH&&e.geometry&&(e.geometry.computeVertexNormals(),e.geometry.computeBoundsTree({}),ATON.Utils._bvhBounds>0&&ATON.Utils._addBVHbounds(e,ATON.Utils._bvhBounds)),ATON._bqScene=!0):(s=!0,B._bPCs=!0,e.layers.disable(t.type),e.raycast=ATON.Utils.VOID_CAST,e.material=ATON.MatHub.materials.point),t.userData.cMat&&(e.material=t.userData.cMat),e.material){let t=e.material.map;t&&(t.minFilter=THREE.LinearMipmapLinearFilter,t.magFilter=THREE.LinearFilter,t.colorSpace=ATON._stdEncoding)}})),ATON.fireEvent("TileLoaded",o)})),i.addEventListener("dispose-model",((e,t)=>{ATON.Utils.cleanupVisitor(e.scene),e=null})),s||ATON.Utils.setPicking(t,t.type,!0),B._tsets.push(i)},loadCesiumIONAsset:(e,t)=>{let o=ATON.getAPIToken("cesium.ion");if(null==o&&(console.log("A valid Cesium ION token is required"),o=prompt("Please enter a valid Cesium ION token:"),null==o||""==o))return;let i=new URL(`https://api.cesium.com/v1/assets/${e}/endpoint`);i.searchParams.append("access_token",o),fetch(i,{mode:"cors"}).then((e=>e.ok?e.json():Promise.reject(`${e.status} : ${e.statusText}`))).then((e=>{i=new URL(e.url);const r=i.searchParams.get("v");B.loadTileSetFromURL(i.toString(),t,{accessToken:e.accessToken,v:r}),ATON.setAPIToken("cesium.ion",o)}))},update:()=>{const e=B._tsets.length;if(e<1)return;for(let t=0;t!!ATON.Nav._bControl&&(ATON.Nav._dOri>B.THRES_ORI||ATON.Nav._dPos>B.THRES_POS)};const q=B;let z={};window.ATON=z,z.Node=t,z.POV=class{constructor(e){this.pos=new THREE.Vector3(1,0,0),this.target=new THREE.Vector3(0,0,0),this.up=ATON.STD_UPVECTOR,this.fov=void 0,this.nextPOV=void 0,this.prevPOV=void 0,this.as(e)}as(e){if(void 0!==e)return ATON.Nav.povlist[e]=this,this.id=e,this}setPosition(e,t,o){return e instanceof THREE.Vector3?this.pos.copy(e):this.pos.set(e,t,o),this}setTarget(e,t,o){return e instanceof THREE.Vector3?this.target.copy(e):this.target.set(e,t,o),this}setFOV(e){return this.fov=e,this}addKeywords(e){let t=e.split(",");void 0===this.kwords&&(this.kwords={});for(let e in t){let o=t[e].trim();o.length>0&&(this.kwords[o]=!0)}return this}hasKeyword(e){if(void 0!==this.kwords)return void 0!==this.kwords[e]}setNextPOV(e){if(e)return this.nextPOV=e,this}setPrevPOV(e){if(e)return this.prevPOV=e,this}},z.LightProbe=class{constructor(e,t,o){this.pos=new THREE.Vector3(0,0,0),this._res=void 0!==e?e:128,this._near=void 0!==t?t:1,this._far=void 0!==o?o:ATON.Nav.STD_FAR,this._envtex=void 0,this._CC=void 0,void 0===ATON._pmremGenerator&&(ATON._pmremGenerator=new THREE.PMREMGenerator(ATON._renderer),ATON._pmremGenerator.compileCubemapShader())}setPosition(e,t,o){return e instanceof THREE.Vector3?this.pos.copy(e):this.pos.set(e,t,o),this}setNear(e){return this._near=e,this}setFar(e){return this._far=e,this}_createCCtarget(){this._CCtarget||(this._CCtarget=new THREE.WebGLCubeRenderTarget(this._res,{format:THREE.RGBEFormat,generateMipmaps:!0,minFilter:THREE.LinearMipmapLinearFilter,colorSpace:ATON._stdEncoding}))}update(){return this._envtex&&this._envtex.dispose(),ATON._rootVisibleGlobal.position.set(-this.pos.x,-this.pos.y,-this.pos.z),ATON._render(),this._envtex=ATON._pmremGenerator.fromScene(ATON._mainRoot,0,this._near,this._far).texture,ATON._rootVisibleGlobal.position.set(0,0,0),ATON._renderer.shadowMap.enabled&&ATON._dMainL&&(ATON._dMainL.shadow.needsUpdate=!0),this}getEnvTex(){return this._envtex}assignToNode(e){}},z.XPF=class{constructor(e){this.id=e,this._geom=void 0,this._mesh=void 0,this._pathbaselayer=void 0,this._size=20,this._location=new THREE.Vector3(0,0,0),this._rotation=new THREE.Vector3(0,0,0),this._lnode=ATON.Nav.addLocomotionNode(this._location),this._pathMod=void 0,this._semMasksURLs={},this._semHintURL=void 0}setSize(e){this._size=e}realizeSUI(){return void 0===this._lnode||this._lnode.realizeSUI(),this}realizeGeometry(){return void 0!==this._geom||(this._geom=new THREE.SphereGeometry(1,60,60),this._geom.scale(-this._size,this._size,this._size),this._geom.castShadow=!1,this._geom.receiveShadow=!1,this._mat=new THREE.MeshBasicMaterial({depthTest:!1,depthWrite:!1}),this._mesh=new THREE.Mesh(this._geom,this._mat),this._mesh.frustumCulled=!1,this._mesh.renderOrder=-100),this}getMesh(){return this._mesh}getLocomotionNode(){return this._lnode}setRotation(e,t,o){return e instanceof THREE.Vector3?this._rotation.copy(e):this._rotation.set(e,t,o),void 0===this._mesh||this._mesh.rotation.copy(this._rotation),this}getRotation(){return this._rotation}setLocation(e,t,o){return e instanceof THREE.Vector3?this._location.copy(e):this._location.set(e,t,o),this._lnode&&this._lnode.setLocation(this._location),void 0===this._mesh||this._mesh.position.copy(this._location),this}getLocation(){return this._location}hasGeometry(){return void 0!==this._geom}setPathModifier=e=>(this._pathMod=e,this);updateBaseLayer(){}setBaseLayer(e){if(void 0===e)return this;this._pathbaselayer=ATON.Utils.resolveCollectionURL(e);let t=this;return this._pathMod&&(this._pathbaselayer=this._pathMod(this._pathbaselayer)),this.hasGeometry()?(ATON.Utils.isVideo(this._pathbaselayer)||ATON.Utils.textureLoader.load(t._pathbaselayer,(e=>{e.colorSpace=ATON._stdEncoding,e.generateMipmaps=!0,t._mat.map=e,t._mat.map.needsUpdate=!0,t._mat.needsUpdate=!0,console.log("XPF base layer "+t._pathbaselayer+" loaded")})),this):this}setSemanticMask(e,t){return void 0===e||(this._semMasksURLs[e]=ATON.Utils.resolveCollectionURL(t),ATON.XPFNetwork.updateCurrentXPFsemLayer(this)),this}removeSemanticMask(e){return void 0===e||(this._semMasksURLs[e]=void 0,ATON.XPFNetwork.updateCurrentXPFsemLayer(this)),this}removeAllSemanticMasks(){return this._semMasksURLs={},this}getSemanticMaskURL(e){return this._semMasksURLs[e]}setSemanticHintMap(e){return void 0===e||(this._semHintURL=ATON.Utils.resolveCollectionURL(e),ATON.XPFNetwork.updateCurrentXPFsemLayer(this)),this}removeSemanticHintMap(){return this._semHintURL=void 0,ATON.XPFNetwork.updateCurrentXPFsemLayer(this),this}},z.Flare=class{constructor(e){this._id=void 0,this._bDeployed=!1,e&&this.register(e)}register(e){return e&&(this._id=e),ATON.addFlare(this),this}getID(){return this._id}log(e){return this._id?console.log("[Flare "+this._id+"] "+e):console.log("[Flare]"+e),this}setSetup(e){return this.setup=e,this}setUpdate(e){return this.update=e,this}},z.EventHub=i,z.Utils=n,z.CC=k,z.SceneHub=d,z.MatHub=a,z.Nav=m,z.AudioHub=u,z.XR=T,z.SUI=N,z.UI=A,z.Photon=P,z.SemFactory=f,z.FE=y,z.MediaFlow=M,z.Phygital=C,z.App=D,z.FX=F,z.XPFNetwork=I,z.MRes=q,z.STD_UPVECTOR=new THREE.Vector3(0,1,0),z.ROOT_NID=".",z.RAD2DEG=180/Math.PI,z.DEG2RAD=Math.PI/180,z.PATCH_ADD=0,z.PATCH_DEL=1,z.NTYPES={},z.NTYPES.SCENE=3,z.NTYPES.SEM=4,z.NTYPES.UI=5,z.SHADOWS_NEAR=.1,z.SHADOWS_FAR=50,z.SHADOWS_SIZE=15,z.SHADOWS_RES=1024,z.AMB_L=.2,z.SCALE_DEFAULT=0,z.SCALE_BIG=5,z.SCALE_VERYBIG=10,z.SCALE_SMALL=-5,z.SCALE_VERYSMALL=-10,z.Flares={},z._fReqList=[],z._bInitialized=!1,z._resMappers=[],z.setBaseURL=e=>{z.BASE_URL=e,z.PATH_RESTAPI=`${z.BASE_URL}/api/`,z.PATH_RESTAPI_SCENE=`${z.PATH_RESTAPI}scene/`,z.PATH_RESTAPI2=`${z.BASE_URL}/api/v2/`,z.PATH_WAPPS=`${z.BASE_URL}/a/`,z.PATH_DRACO_LIB=`${z.BASE_URL}/dist/draco/`,z.PATH_BASIS_LIB=`${z.BASE_URL}/dist/basis/`,z.PATH_COLLECTION=`${z.BASE_URL}/collections/`,z.PATH_SCENES=`${z.BASE_URL}/scenes/`,z.PATH_RES=`${z.BASE_URL}/res/`,z.PATH_FE=`${z.BASE_URL}/s/`},z.setBaseURL(window.location.origin),z.setPathCollection=e=>{z.PATH_COLLECTION=e},z.setPathScenes=e=>{z.PATH_SCENES=e},z.setAsStandalone=e=>{e||(e="../"),z.PATH_DRACO_LIB=e+"dist/draco/",z.PATH_BASIS_LIB=e+"dist/basis/",z.PATH_RES=e+"res/"},z.addResourceMapper=e=>{z._resMappers.push(e)},z._onUserInteraction=()=>{z._elPanoVideo&&!z._vpanoPlaying&&z._elPanoVideo.play(),z.XPFNetwork._elVid&&!z.XPFNetwork._vidPlaying&&z.XPFNetwork._elVid.play(),z.AudioHub._listener&&z.AudioHub._listener.context&&"suspended"===z.AudioHub._listener.context.state&&z.AudioHub._listener.context.resume();for(let e in z.MediaFlow._vStreams){let t=z.MediaFlow._vStreams[e].el;t.playing||t.uid||t.play()}},z.checkAuth=(e,t)=>{$.ajax({type:"GET",url:z.PATH_RESTAPI+"user",xhrFields:{withCredentials:!0},dataType:"json",success:o=>{void 0!==o&&o.username?e(o):t&&t()},error:()=>{t&&t()}})},z._setupBaseListeners=()=>{let e,t,o=z._renderer.domElement;window.addEventListener("resize",z._onResize,!1),window.onorientationchange=z._readDeviceOrientationMode,document.addEventListener("fullscreenchange",(e=>{z._bFS=!!document.fullscreenElement,z.fireEvent("Fullscreen",z._bFS),z._bFS?console.log("Now fullscreen"):console.log("Exit fullscreen")})),void 0!==document.hidden?(e="hidden",t="visibilitychange"):void 0!==document.mozHidden?(e="mozHidden",t="mozvisibilitychange"):void 0!==document.msHidden?(e="msHidden",t="msvisibilitychange"):void 0!==document.webkitHidden&&(e="webkitHidden",t="webkitvisibilitychange"),void 0!==e&&document.addEventListener(t,(()=>{if(document[e]){if(z.XR._bPresenting)return;console.log("Suspend"),z.renderPause()}else{if(z.XR._bPresenting)return;console.log("Resume"),z.renderResume()}}),!1),o.addEventListener("mousemove",z._updateScreenMove,!1),o.addEventListener("mousedown",(e=>{1===e.button&&z.fireEvent("MouseMidButton"),2===e.button&&z.fireEvent("MouseRightButton")})),o.addEventListener("wheel",z._onMouseWheel,!1),z._bPointerDown=!1,Hammer(o).on("doubletap",(e=>{z._bPointerDown=!1,z._onUserInteraction(),z.fireEvent("DoubleTap",e.srcEvent)})),Hammer(o).on("tap",(e=>{if(z._bPointerDown=!1,z._onUserInteraction(),z._updateScreenMove(e.srcEvent),z._handleQueries(),z.fireEvent("Tap",e.srcEvent),void 0===z._hoveredUI)return;let t=z.getUINode(z._hoveredUI);t&&t.onSelect&&t.onSelect()})),z.on("DoubleTap",(e=>{z.defaultDoubleTapFromScreenCoords(e)})),z._kModShift=!1,z._kModCtrl=!1,z._bListenKeyboardEvents=!0,window.addEventListener("keydown",(e=>{z._onUserInteraction(),"Shift"===e.key&&(z._kModShift=!0),"Control"===e.key&&(z._kModCtrl=!0),z._bListenKeyboardEvents&&z.fireEvent("KeyPress",e.key)}),!1),window.addEventListener("keyup",(e=>{"Shift"===e.key&&(z._kModShift=!1),"Control"===e.key&&(z._kModCtrl=!1),z._bListenKeyboardEvents&&z.fireEvent("KeyUp",e.key)}),!1),z.on("KeyPress",(e=>{if("+"===e){let e=z.Nav.getFOV()+1;z.Nav.setFOV(e)}if("-"===e){let e=z.Nav.getFOV()-1;z.Nav.setFOV(e)}}))},z._onResize=()=>{if(z.Nav._camera.aspect=window.innerWidth/window.innerHeight,z.Nav._camera.updateProjectionMatrix(),z._renderer.setSize(window.innerWidth,window.innerHeight),z.FX.composer&&(z.FX.composer.setSize(window.innerWidth,window.innerHeight),z.FX.passes[z.FX.PASS_AA])){let e=z.FX.passes[z.FX.PASS_AA].material.uniforms;e&&e.resolution.value.set(1/window.innerWidth,1/window.innerHeight)}console.log("onResize")},z._onMouseWheel=e=>{e.preventDefault(),z.fireEvent("MouseWheel",e.deltaY)},z.focusOn3DView=()=>{z._renderer.domElement.focus()},z._SUIactivation=()=>{const e=z.getUINode(z._hoveredUI);return void 0!==e&&void 0!==e.onSelect&&(e.onSelect(),!0)},z._stdActivation=()=>{if(z._SUIactivation())return;if(!z.Nav._bControl)return;if(void 0!==z.XPFNetwork._semCurr&&z.fireEvent("SemanticMaskSelect",z.XPFNetwork._semCurr),z.XR._bPresenting){if(m.requestTransitionToLocomotionNodeInSightIfAny(z.XR.STD_TELEP_DURATION))return;return"immersive-vr"===z.XR._sessionType&&z.XR.teleportOnQueriedPoint(),void z.FE.playAudioFromSemanticNode(z._hoveredSemNode)}if(z.Nav.isFirstPerson()||z.Nav.isDevOri()){if(m.requestTransitionToLocomotionNodeInSightIfAny(.5))return;if(z.Nav.currentQueryValidForLocomotion()){let e=z._queryDataScene.p,t=z.Nav._vDir,o=new THREE.Vector3(e.x,e.y+z.userHeight,e.z),i=new THREE.Vector3(o.x+t.x,o.y+t.y,o.z+t.z),r=(new z.POV).setPosition(o).setTarget(i).setFOV(z.Nav._currPOV.fov);z.Nav.requestPOV(r,.5)}return}let e=z.getSemanticNode(z._hoveredSemNode);z._queryDataSem&&e?z.Nav.requestPOVbyNode(e,.5):z._queryDataScene&&z.Nav.requestRetarget(z._queryDataScene.p,void 0,.5)},z.defaultDoubleTapFromScreenCoords=e=>{z._updateScreenMove(e),z._handleQueryScene(),z._stdActivation()},z.isFullscreen=()=>z._bFS,z.toggleFullScreen=()=>{document.fullscreenElement?document.exitFullscreen&&document.exitFullscreen():document.documentElement.requestFullscreen()},z.realize=e=>{console.log("Initialize ATON..."),z.Utils.init(),z.Utils.profileDevice(),z._clock=new THREE.Clock(!0),z.bounds=new THREE.Sphere,z._worldScale=1,z._ws=0,z._bFS=!1,z._renderer=new THREE.WebGLRenderer({antialias:!0,alpha:!0}),z._renderer.setSize(window.innerWidth,window.innerHeight),z.Utils.profileRenderingCapabilities(),z._stdpxd=1,z._fps=60,z._dt=.01,z._dtAccum=0,z._dtCount=0,z._avgFPSaccum=0,z._avgFPS=60,z._dRenderBudgetMinFPS=20,z._dRenderBudgetMaxFPS=55,z._bAdaptiveDensity=!0,z._adMin=.4,z._adMax=1.5,z.device.lowGPU&&(z._adMax=1),z._aniMixers=[],z._stdEncoding=THREE.LinearSRGBColorSpace,z._renderer.outputColorSpace=z._stdEncoding,z._renderer.toneMapping=THREE.LinearToneMapping,z._renderer.toneMappingExposure=1,e||z._renderer.setAnimationLoop(z._onFrame),z._maxAnisotropy=z._renderer.capabilities.getMaxAnisotropy(),z.userHeight=1.7,e||document.body.appendChild(z._renderer.domElement);let t=z._renderer.domElement;t.id="idView3D",t.style.outline="none",t.style.border="none",z.UI.init(),z._vpanoPlaying=!1,z._bUserInts=0,z.EventHub.init(),z.MatHub.init(),z._assetsManager={},z._aLoader=new THREE.GLTFLoader,z._numReqLoad=0,z._collMod=void 0,z._ktx2Loader=new THREE.KTX2Loader,z._ktx2Loader.setTranscoderPath(z.PATH_BASIS_LIB),z._ktx2Loader.detectSupport(z._renderer),z._dracoLoader=new THREE.DRACOLoader,z._dracoLoader.setDecoderPath(z.PATH_DRACO_LIB),z._dracoLoader.setWorkerLimit(2),z._dracoLoader.preload(),z._aLoader.setDRACOLoader(z._dracoLoader),z._aLoader.setKTX2Loader(z._ktx2Loader),THREE.DefaultLoadingManager.addHandler(/\.ktx2$/,z._ktx2Loader),z._updRoutines=[],z._pmremGenerator=void 0,z._lps=[],z._bAutoLP=!1,z._envMapInt=1,z._numLPbounces=2,z._lpbCount=0,z._bShadowsFixedBound=!1,z._shadowsFixedBoundCenter=void 0,z._shadowsNear=z.SHADOWS_NEAR,z._shadowsFar=z.SHADOWS_FAR,z._shadowsSize=z.SHADOWS_SIZE,z._shadowsRes=z.SHADOWS_RES,z.initGraphs(),z.SceneHub.init(),z.MRes.init(),z.CC.init(),z.AudioHub.init(),z.Nav.init(),z.XR.init(),z.SUI.init(),z.Photon.init(),z.VRoadcast=z.Photon,z.MediaFlow.init(),z.SemFactory.init(),z.Phygital.init(),z.XPFNetwork.init(),z.device.lowGPU||z.device.isMobile||z.FX.init(),z.FX.composer||(z._render=()=>{z._renderer.render(z._mainRoot,z.Nav._camera)}),z.setDefaultPixelDensity(1),z._queryDataScene=void 0,z._queryDataSem=void 0,z._queryDataUI=void 0,z._hoveredSemNode=void 0,z._hoveredUI=void 0,z._bq=!0,z._bQuerySemOcclusion=!0,z._bQueryNormals=!0,z._bPauseQuery=!1,z._bCenteredQuery=!1,z._bqScene=!1,z._bqSem=!1,z._qSync=0,z._qSyncInt=1,z._tgiDur=void 0,z._tgiPer=void 0,z._tHover=void 0,z._bMainPanoInfinite=!0,z._matMainPano=void 0,z._mMainPano=void 0,z._screenPointerCoords=new THREE.Vector2(0,0),z._rcScene=new THREE.Raycaster,z._rcScene.layers.set(z.NTYPES.SCENE),z._rcScene.firstHitOnly=!0,z._rcSemantics=new THREE.Raycaster,z._rcSemantics.layers.set(z.NTYPES.SEM),z._rcSemantics.firstHitOnly=!0,z._rcUI=new THREE.Raycaster,z._rcUI.layers.set(z.NTYPES.UI),z._rcUI.firstHitOnly=!0,z._setupBaseListeners(),z.device.isMobile&&z._readDeviceOrientationMode(),z._fLoading=0,z._fRequired=z._fReqList.length,z._loadFlares(),z._gizmo=void 0,z._bGizmo=!1,z.focusOn3DView(),z._bInitialized=!0},z.addFlare=e=>{if(void 0===e)return;let t=Object.keys(z.Flares).length,o=e.getID();o?z.Flares[o]=e:z.Flares["F"+t]=e},z.registerFlare=z.addFlare,z.getFlare=e=>z.Flares[e],z.loadScript=(e,t,o)=>{let i=document.createElement("script");i.src=e,i.async=!1,document.head.appendChild(i),t&&(i.onload=t),o&&(i.onerror=o)},z._loadFlare=e=>{z._fLoading++,$.get(z.PATH_RESTAPI2+"flares/"+e,(t=>{let o=t.files;if(o){let t=o.length;for(let i in o)z.loadScript("/flares/"+e+"/"+o[i],(()=>{t--,t<=0&&z._onFlareLoaded(e)}),(()=>{console.log("Missing flare '"+e+"' dependency: "+o[i]),t--,t<=0&&z._onFlareLoaded(e)}))}})).fail((()=>{console.log("Flare "+e+" not found."),z._onFlareError(e)}))},z._loadFlares=()=>{if(z._fRequired<=0)z.fireEvent("AllFlaresReady");else for(let e in z._fReqList)z._loadFlare(z._fReqList[e])},z._onFlareLoaded=e=>{console.log("All deps loaded for flare '"+e+"'"),z._deployNewFlares(),z._fLoading--,z._fLoading<=0&&z._onAllFlaresLoaded()},z._onFlareError=e=>{z._fLoading--,z._fLoading<=0&&z._onAllFlaresLoaded()},z._onAllFlaresLoaded=()=>{console.log("All Flares ready!"),z.fireEvent("AllFlaresReady")},z._deployFlare=e=>{e._bDeployed||(void 0!==e.setup&&e.setup(),void 0!==e.update&&z.addUpdateRoutine(e.update),e._bDeployed=!0)},z._deployNewFlares=()=>{for(let e in z.Flares)z._deployFlare(z.Flares[e])},z.setCollectionPathModifier=e=>{z._collMod=e},z.setTimedGazeDuration=e=>{z._tgiDur=e},z.getTimedGazeProgress=()=>{if(void 0!==z._tgiDur)return z._tgiPer},z.getElapsedTime=()=>z._clock.elapsedTime,z.renderPause=()=>{z._renderer.setAnimationLoop(void 0)},z.renderResume=()=>{z._renderer.setAnimationLoop(z._onFrame)},z._setupLoadManager=()=>{z._loadManager=new THREE.LoadingManager,z._loadManager.onStart=(e,t,o)=>{console.log("Started loading file: "+e+".\nLoaded "+t+" of "+o+" files."),z.fireEvent("NodeRequestFired",e)},z._loadManager.onLoad=()=>{console.log("Loading complete!"),z.fireEvent("AllNodeRequestsCompleted")},z._loadManager.onProgress=(e,t,o)=>{},z._loadManager.onError=e=>{console.log("There was an error loading "+e)}},z.setDefaultPixelDensity=e=>{z._stdpxd=e,z._renderer.setPixelRatio(e),z.FX.composer&&z.FX.composer.setPixelRatio(e),void 0!==z._renderer.xr&&(z.device.isMobile?z._renderer.xr.setFramebufferScaleFactor(z._stdpxd*z.XR.MOBILE_DENSITY_F):z._renderer.xr.setFramebufferScaleFactor(z._stdpxd))},z.resetPixelDensity=()=>{z._renderer.setPixelRatio(z._stdpxd)},z._readDeviceOrientationMode=()=>{90===Math.abs(window.orientation)?(console.log("Landscape Mode"),z.fireEvent("MobileLandscapeMode")):(console.log("Portrait Mode"),z.fireEvent("MobilePortraitMode")),setTimeout(z._onResize,500)},z.snodes={},z.semnodes={},z.uinodes={},z.createSceneNode=e=>new z.Node(e,z.NTYPES.SCENE),z.getSceneNode=e=>{if(void 0!==e)return z.snodes[e]},z.getOrCreateSceneNode=e=>{let t=z.getSceneNode(e);return void 0!==t?t:z.createSceneNode(e)},z.getRootScene=()=>z._rootVisible,z.createSemanticNode=e=>new z.Node(e,z.NTYPES.SEM),z.getSemanticNode=e=>{if(void 0!==e)return z.semnodes[e]},z.getOrCreateSemanticNode=e=>{let t=z.getSemanticNode(e);return void 0!==t?t:z.createSemanticNode(e)},z.getRootSemantics=()=>z._rootSem,z.createUINode=e=>new z.Node(e,z.NTYPES.UI),z.getUINode=e=>{if(void 0!==e)return z.uinodes[e]},z.getRootUI=()=>z._rootUI,z._unpackScale=e=>0==e?1:e>=0?1.1*e:1/(-1.1*e),z.setUserScaleLevel=e=>{z.setWorldScaleLevel(-e)},z.getUserScale=()=>1/z._worldScale,z.setWorldScaleLevel=e=>{void 0===e&&(e=0),e<-127&&(e=127),e>127&&(e=127),z._ws=e;let t=z._unpackScale(e);z._rootVisible.scale.set(t,t,t),z._rootSem.scale.set(t,t,t),N.gLocNodes.scale.set(t,t,t),N.gMeasures.scale.set(t,t,t),z.Photon.avaGroup&&z.Photon.avaGroup.scale.set(t,t,t),z.recomputeSceneBounds();let o=t/z._worldScale;z.Nav._currPOV.pos.x*=o,z.Nav._currPOV.pos.y*=o,z.Nav._currPOV.pos.z*=o,z.Nav._currPOV.target.x*=o,z.Nav._currPOV.target.y*=o,z.Nav._currPOV.target.z*=o,z.Nav.syncCurrCamera(),z.XR._bPresenting&&z.XR.setRefSpaceLocation(z.Nav._currPOV.pos),z._worldScale=t,console.log("World scale: "+t)},z.getWorldScaleLevel=()=>z._ws,z.getWorldScale=()=>z._worldScale,z._assetReqNew=e=>{z._numReqLoad++,z.fireEvent("NodeRequestFired",e)},z._assetReqComplete=e=>{z.fireEvent("NodeRequestCompleted",e),z._numReqLoad--,z._numReqLoad<=0&&z._onAllReqsCompleted()},z._onAllReqsCompleted=()=>{z.recomputeSceneBounds(),z.getRootScene().assignLightProbesByProximity(),z.fireEvent("AllNodeRequestsCompleted"),z._postAllReqsCompleted(),setTimeout((()=>{z.updateLightProbes(),z._renderer.shadowMap.enabled&&z._bShadowsFixedBound&&0===z._aniMixers.length&&(z._dMainL.shadow.autoUpdate=!1,console.log("Lazy shadows"))}),1e3)},z._postAllReqsCompleted=e=>{void 0===e&&(e=z._rootVisible);for(let t in e.children){let o=e.children[t];o&&o.toggle&&(z._postAllReqsCompleted(o),o.toggle(o.visible))}ThreeMeshUI.update()},z.recomputeSceneBounds=e=>{e?z.bounds.union(e):(z.bounds.center.copy(z._rootVisible.getBound().center),z.bounds.radius=z._rootVisible.getBound().radius),z.bounds.radius<=0||(z._renderer.shadowMap.enabled&&(z._rootVisible.traverse((e=>{e.isMesh&&(e.castShadow=!0,e.receiveShadow=!0)})),z.adjustShadowsParamsFromSceneBounds(),z._bShadowsFixedBound&&z.updateDirShadows()),z._bAutoLP&&(void 0===z._lps[0]?z.addLightProbe((new z.LightProbe).setPosition(z.bounds.center).setNear(z.bounds.radius)):z._lps[0].setPosition(z.bounds.center).setNear(z.bounds.radius),console.log("Auto LP")),z.FX.composer&&z.FX.setDOFaperture(1/(30*z.bounds.radius)),z._mMainPano&&z._mMainPano.position.copy(z.bounds.center))},z.registerNodeResourceHandler=(e,t)=>{z._resHandler||(z._resHandler={}),z._resHandler[e]=t,console.log("Registered resource handler '"+e+"'")},z.removeNodeResourceHanlder=e=>{z._resHandler&&z._resHandler[e]&&(z._resHandler[e]=void 0)},z.initGraphs=()=>{z._mainRoot=new THREE.Scene,z._mainRoot.background=new THREE.Color(.7,.7,.7),z._rootVisibleGlobal=new THREE.Scene,z._mainRoot.add(z._rootVisibleGlobal),z._rootVisible=z.createSceneNode().setAsRoot(),z._rootVisibleGlobal.add(z._rootVisible),z._rootSem=z.createSemanticNode().setAsRoot(),z._mainRoot.add(z._rootSem),z._rootUI=z.createUINode().setAsRoot(),z._mainRoot.add(z._rootUI),z.ambLight=new THREE.AmbientLight(new THREE.Color(1,1,1)),z.ambLight.intensity=3,z._rootVisibleGlobal.add(z.ambLight),z.plight=new THREE.PointLight,z.plight.intensity=0,z.plight.decay=.2,z._rootVisibleGlobal.add(z.plight)},z.enablePointLight=()=>{z.plight.intensity=3},z.disablePointLight=()=>{z.plight.intensity=0},z.setBackgroundColor=e=>{z._mainRoot.background=e},z.setFog=(e,t)=>{void 0!==e&&(void 0===t&&(t=200),z._rootVisibleGlobal.fog=new THREE.Fog(e,1,t),z.setBackgroundColor(e))},z.disableFog=()=>{z._rootVisibleGlobal.fog=null},z.setAutoLP=e=>{z._bAutoLP=e},z.setNeutralAmbientLight=e=>{z.ambLight.color=new THREE.Color(e,e,e)},z.addLightProbe=e=>{void 0!==e&&(z._lps.push(e),z.setNeutralAmbientLight(0),void 0!==z.SUI.gLPIcons&&N.addLPIcon(e))},z.getNumLightProbes=()=>z._lps.length,z._updLP=()=>{for(let e in z._lps)z._lps[e].update();z._rootVisible.traverse((e=>{let t=e.userData.LP;void 0!==t&&t instanceof z.LightProbe&&(e.material.envMap=t.getEnvTex(),e.material.envMapIntensity=z._envMapInt,e.material.needsUpdate=!0)}))},z.setLightProbesNumBounces=e=>{e<1||(z._numLPbounces=e)},z.dirtyLightProbes=e=>{void 0===e&&(e=z._numLPbounces),z._lpbCount=e},z.updateLightProbes=()=>{if(!z.XR._bPresenting&&0!==z._lps.length){for(let e=0;e{let t;if(e=z.Utils.resolveCollectionURL(e),void 0===z._mMainPano&&(z._gMainPano=new THREE.SphereGeometry(1,60,60),z._gMainPano.castShadow=!1,z._gMainPano.receiveShadow=!1,z._mMainPano=new THREE.Mesh(z._gMainPano,z._matMainPano),z._mMainPano.frustumCulled=!1,z._mMainPano.renderOrder=-100,z._mMainPano.layers.disable(z.NTYPES.SCENE),z._mMainPano.layers.disable(z.NTYPES.SEM),z._mMainPano.layers.disable(z.NTYPES.UI),z._mMainPano.raycast=z.Utils.VOID_CAST,z.setMainPanoramaRadius(.8*z.Nav.STD_FAR)),z.Utils.isVideo(e)){if(void 0===z._elPanoVideo){let t="",$(t).appendTo("body"),z._elPanoVideo=document.getElementById("idPanoVideo"),z._elPanoVideo.onplaying=()=>{console.log("VideoPano playing"),z._vpanoPlaying=!0},z._elPanoVideo.onpause=()=>{console.log("VideoPano paused"),z._vpanoPlaying=!1},z._elPanoVideo.addEventListener("touchstart",(function(){z._elPanoVideo.play()})),enableInlineVideo(z._elPanoVideo)}t=new THREE.VideoTexture(z._elPanoVideo),t.colorSpace=z._stdEncoding,z._realizeOrUpdateMainPano(t),z.fireEvent("MainPanoVideo")}else{if(e.endsWith(".hdr"))return void(new THREE.RGBELoader).load(e,(e=>{e.minFilter=THREE.LinearMipmapLinearFilter,e.magFilter=THREE.LinearFilter,e.colorSpace=z._stdEncoding,z._realizeOrUpdateMainPano(e),z.fireEvent("MainPanoHDR")}));if(e.endsWith(".exr"))return void(new THREE.EXRLoader).load(e,(e=>{e.minFilter=THREE.LinearMipmapLinearFilter,e.magFilter=THREE.LinearFilter,e.colorSpace=z._stdEncoding,z._realizeOrUpdateMainPano(e),z.fireEvent("MainPanoHDR")}));z.Utils.textureLoader.load(e,(e=>{e.colorSpace=z._stdEncoding,e.generateMipmaps=!0,z._realizeOrUpdateMainPano(e),z.fireEvent("MainPano")}))}},z.playMainPanorama=()=>{z._elPanoVideo&&(z._vpanoPlaying||z._elPanoVideo.play())},z.pauseMainPanorama=()=>{z._elPanoVideo&&z._vpanoPlaying&&z._elPanoVideo.pause()},z.playOrPauseMainPanorama=()=>{z._elPanoVideo&&(z._vpanoPlaying?z._elPanoVideo.pause():z._elPanoVideo.play())},z.stopAndRemoveMainPanorama=()=>{z._elPanoVideo&&(z._vpanoPlaying&&z._elPanoVideo.pause(),z._elPanoVideo.remove(),z._elPanoVideo=void 0,z._vpanoPlaying=!1)},z._realizeOrUpdateMainPano=e=>{if(void 0!==z._matMainPano)return z._matMainPano.map=e,void z.updateLightProbes();z._matMainPano=new THREE.MeshBasicMaterial({map:e,depthTest:!1,depthWrite:!1}),z._mMainPano.material=z._matMainPano,z._bMainPanoInfinite&&(z._mMainPano.onAfterRender=()=>{"immersive-ar"!==z.XR._sessionType&&z.Nav._currPOV&&z._mMainPano.position.copy(z.Nav._currPOV.pos)}),z._rootVisibleGlobal.add(z._mMainPano),z.updateLightProbes()},z.setMainPanoramaRadius=e=>{void 0!==z._gMainPano&&z._gMainPano.scale(-e,e,e)},z.setMainPanoramaRotation=e=>{void 0!==z._mMainPano&&z._mMainPano.rotation.set(0,e,0)},z.setMainPanoramaInfinite=e=>{z._bMainPanoInfinite=e,void 0!==z._mMainPano&&(z._mMainPano.onAfterRender=e?()=>{z.Nav._currPOV&&z._mMainPano.position.copy(z.Nav._currPOV.pos)}:void 0)},z.setMainPanoramaLocation=e=>{z._bMainPanoInfinite||void 0!==z._mMainPano&&z._mMainPano.position.copy(e)},z.setMainLightDirection=e=>{let t=e.clone();t.normalize(),t.x*=.5*z.SHADOWS_FAR,t.y*=.5*z.SHADOWS_FAR,t.z*=.5*z.SHADOWS_FAR,void 0===z._dMainL&&(z._dMainL=new THREE.DirectionalLight(new THREE.Color(1,1,1),1),z._dMainL.castShadow=!1,z._dMainL.intensity=2,z._dMainLtgt=new THREE.Object3D,z._rootVisibleGlobal.add(z._dMainLtgt),z._dMainL.target=z._dMainLtgt,z._rootVisibleGlobal.add(z._dMainL),z._dMainLpos=new THREE.Vector3),z._dMainLdir=t,z._dMainL.position.set(-t.x,-t.y,-t.z),z._renderer.shadowMap.enabled&&(z._dMainL.shadow.needsUpdate=!0),z.toggleMainLight(!0)},z.getMainLightDirection=()=>{if(void 0===z._dMainLdir)return;let e=z._dMainLdir.clone();return e.normalize(),e},z.toggleMainLight=e=>{if(void 0===z._dMainL)return;z._dMainL.visible=e;let t=z._lps.length;e?(t>0?z.setNeutralAmbientLight(0):z.setNeutralAmbientLight(z.AMB_L),z.updateDirShadows()):t>0?z.setNeutralAmbientLight(0):z.setNeutralAmbientLight(z.AMB_L)},z.isMainLightEnabled=()=>void 0!==z._dMainL&&!!z._dMainL.visible,z.setExposure=e=>{z._renderer.toneMappingExposure=e},z.getExposure=()=>z._renderer.toneMappingExposure,z.adjustShadowsParamsFromSceneBounds=()=>{if(void 0===z._dMainL)return;let e=z._rootVisible.getBound().radius,t=z._rootVisible.getBound().center;e<=0||e>=z.SHADOWS_SIZE?(z._bShadowsFixedBound=!1,z._shadowsSize=z.SHADOWS_SIZE):(z._bShadowsFixedBound=!0,z._shadowsFixedBoundCenter=t,z._shadowsSize=1.5*e),z._dMainL.shadow.map&&(z._dMainL.shadow.map.dispose(),z._dMainL.shadow.map=null),z._dMainL.shadow.camera.left=-z._shadowsSize,z._dMainL.shadow.camera.right=z._shadowsSize,z._dMainL.shadow.camera.bottom=-z._shadowsSize,z._dMainL.shadow.camera.top=z._shadowsSize,z._dMainL.shadow.mapSize.width=z._shadowsRes,z._dMainL.shadow.mapSize.height=z._shadowsRes,z._dMainL.shadow.camera.near=z._shadowsNear,z._dMainL.shadow.camera.far=z._shadowsFar;let o=-2e-4*e;o<-.001&&(o=-.001),z._dMainL.shadow.bias=o},z.toggleShadows=e=>{if(void 0!==z._dMainL)if(e){if(z.XR.isPresenting())return;if(z.device.lowGPU)return;z._dMainL.castShadow=!0,z._renderer.shadowMap.enabled=!0,z.device.isMobile?z._renderer.shadowMap.type=THREE.PCFShadowMap:z._renderer.shadowMap.type=THREE.PCFSoftShadowMap,z._rootVisible.traverse((e=>{e.isMesh&&(e.castShadow=!0,e.receiveShadow=!0)})),z.adjustShadowsParamsFromSceneBounds(),z.updateDirShadows(),z._dMainL.shadow.needsUpdate=!0,console.log("Shadows ON")}else z._dMainL.castShadow=!1,z._renderer.shadowMap.enabled=!1,console.log("Shadows OFF")},z.updateDirShadows=()=>{if(void 0===z._dMainLdir)return;if(void 0===z._dMainLpos)return;let e=z._shadowsFixedBoundCenter;void 0===e?(e=z.Nav.getCurrentEyeLocation(),z._dMainLpos.x=e.x+z.Nav._vDir.x*z._shadowsSize,z._dMainLpos.y=e.y+z.Nav._vDir.y*z._shadowsSize,z._dMainLpos.z=e.z+z.Nav._vDir.z*z._shadowsSize):(z._dMainLpos.x=e.x,z._dMainLpos.y=e.y,z._dMainLpos.z=e.z),z._dMainL.position.set(z._dMainLpos.x-z._dMainLdir.x,z._dMainLpos.y-z._dMainLdir.y,z._dMainLpos.z-z._dMainLdir.z),z._dMainLtgt.position.copy(z._dMainLpos)},z._updateEnvironment=()=>{z._renderer.shadowMap.enabled&&(z._bShadowsFixedBound||z.updateDirShadows())},z.setGlobalAudio=(e,t)=>{void 0!==e&&(void 0===t&&(t=!0),e=z.Utils.resolveCollectionURL(e),void 0===z._auMain||null===z._auMain?z._auMain=new THREE.Audio(z.AudioHub._listener):z._auMain.isPlaying&&z._auMain.stop(),z.AudioHub._loader.load(e,(e=>{z._auMain.setBuffer(e),z._auMain.setLoop(t),z._auMain.play()})))},z._markFPS=()=>{z._numReqLoad>0||z._dt<0||(z._dtCount+=1,z._dtAccum+=z._dt,z._dtAccum<1||(z._fps=1/(z._dtAccum/z._dtCount),z._dtCount=0,z._dtAccum=0,z._handleDynamicRenderProfiles()))},z.toggleAdaptiveDensity=e=>{z._bAdaptiveDensity=e},z.setAdaptiveDensityRange=(e,t)=>{e>=t||(z._adMin=e,z._adMax=t)},z.setDynamicRenderingFPS=(e,t)=>{e>=t||(e&&(z._dRenderBudgetMinFPS=e),t&&(z._dRenderBudgetMaxFPS=t))},z._handleDynamicRenderProfiles=()=>{let e=z._renderer.getPixelRatio();z._fps=z._adMin&&(z._renderer.setPixelRatio(e),z.FX.composer&&z.FX.composer.setPixelRatio(e),console.log("Density: "+e.toPrecision(2)))),z.fireEvent("RequestLowerRender")),z._fps>z._dRenderBudgetMaxFPS&&(z._bAdaptiveDensity&&!z.XR._bPresenting&&(e+=.1,e<=z._adMax&&(z._renderer.setPixelRatio(e),z.FX.composer&&z.FX.composer.setPixelRatio(e),console.log("Density: "+e.toPrecision(2)))),z.fireEvent("RequestHigherRender"))},z._onFrame=()=>{z._dt=z._clock.getDelta(),z._markFPS(),z.XR._bPresenting?z.XR.update():z.Nav._controls.update(z._dt),z._handleQueries(),z.Nav.update(),z.Photon.update(),z.SUI.update(),z.MatHub.update(),z._updateEnvironment(),z._updateAniMixers(),z._updateRoutines(),z.MRes.update(),z.XPFNetwork.update(),z._render()},z._render=()=>{!z.FX.composer||z.XR._bPresenting?z._renderer.render(z._mainRoot,z.Nav._camera):z.FX.composer.render()},z.addUpdateRoutine=e=>{void 0!==e&&z._updRoutines.push(e)},z.deleteAllUpdateRoutines=()=>{z._updRoutines=[]},z._updateRoutines=()=>{let e=z._updRoutines.length;if(!(e<=0))for(let t=0;t{let e=z._aniMixers.length;if(!(e<1))for(let t=0;t{e.preventDefault&&e.preventDefault(),z._bCenteredQuery||(z._screenPointerCoords.x=e.clientX/window.innerWidth*2-1,z._screenPointerCoords.y=-e.clientY/window.innerHeight*2+1)},z.toggleCenteredQuery=e=>{z._bCenteredQuery=e,e&&(z._screenPointerCoords.x=0,z._screenPointerCoords.y=0)},z.toggleQueries=e=>{z._bq=e},z._registerRCS=()=>{z._rcRR=0,z._rcHandlers=[],z._rcHandlers.push(z._handleQueryScene),z._rcHandlers.push(z._handleQuerySemantics),z._rcHandlers.push(z._handleQueryUI)},z._handleQueries=()=>{if(!z._bq)return;if(z._bPauseQuery)return;if(z.Nav._bInteracting)return;if(z._numReqLoad>0)return;if(z.Nav.isTransitioning())return;if(z._handleQueryUI(),z._bqScene&&z._handleQueryScene(),z._bqSem&&z._handleQuerySemantics(),z.Nav._bLocValidator&&z.Nav.locomotionValidator(),void 0===z._tgiDur)return;if(void 0===z._tHover)return;const e=z._clock.elapsedTime-z._tHover;e>=z._tgiDur?(z._stdActivation(),z._tHover=void 0,z._tgiPer=void 0):z._tgiPer=e/z._tgiDur},z._handleQueryScene=()=>{if(z.XR.isPresenting()?z.XR.setupQueryRay(z._rcScene):z._rcScene.setFromCamera(z._screenPointerCoords,z.Nav._camera),z._hitsScene=[],z._rcScene.intersectObjects(z._mainRoot.children,!0,z._hitsScene),z._hitsScene.length<=0)return void(z._queryDataScene=void 0);const e=z._hitsScene[0];z._queryDataScene={},z._queryDataScene.p=e.point,z._queryDataScene.d=e.distance,z._queryDataScene.o=e.object,z._queryDataScene.uv=e.uv,z._bQueryNormals&&e.face&&e.face.normal&&(z._queryDataScene.matrixWorld=(new THREE.Matrix3).getNormalMatrix(e.object.matrixWorld),z._queryDataScene.n=e.face.normal.clone().applyMatrix3(z._queryDataScene.matrixWorld).normalize())},z.getSceneFocalPoint=()=>{if(void 0===z._queryDataScene)return;let e=z._queryDataScene.p,t=new THREE.Vector3;return t.lerpVectors(e,z.Nav._currPOV.pos,.02),t},z.getSceneQueriedPoint=()=>{if(void 0!==z._queryDataScene)return z._queryDataScene.p},z.getSceneQueriedDistance=()=>{if(void 0!==z._queryDataScene)return z._queryDataScene.d},z.getSceneQueriedNormal=()=>{if(void 0!==z._queryDataScene)return z._queryDataScene.n},z.getSceneQueriedObjectName=()=>{if(void 0!==z._queryDataScene&&void 0!==z._queryDataScene.o)return z._queryDataScene.o.name},z.getSceneQueriedUV=()=>{if(void 0!==z._queryDataScene)return z._queryDataScene.uv},z.setQueryRange=(e,t,o)=>{void 0!==o&&o!==z.NTYPES.SCENE||(z._rcScene.near=e,z._rcScene.far=t),void 0!==o&&o!==z.NTYPES.SEM||(z._rcSemantics.near=e,z._rcSemantics.far=t)},z._handleQuerySemantics=()=>{if(z.XR.isPresenting()?z.XR.setupQueryRay(z._rcSemantics):z._rcSemantics.setFromCamera(z._screenPointerCoords,z.Nav._camera),z._hitsSem=[],z._rcSemantics.intersectObjects(z._mainRoot.children,!0,z._hitsSem),z._hitsSem.length<=0){if(z._queryDataSem=void 0,z._hoveredSemNode){z.fireEvent("SemanticNodeLeave",z._hoveredSemNode);let e=z.getSemanticNode(z._hoveredSemNode);e&&e.onLeave&&e.onLeave()}return z._hoveredSemNode=void 0,void(z._tHover=void 0)}const e=z._hitsSem[0];if(z._bQuerySemOcclusion&&z._queryDataScene&&z._queryDataScene.d{if(z.XR.isPresenting()?z.XR.setupQueryRay(z._rcUI):z._rcUI.setFromCamera(z._screenPointerCoords,z.Nav._camera),z._hitsUI=[],z._rcUI.intersectObjects(z._mainRoot.children,!0,z._hitsUI),z._hitsUI.length<=0){if(z._queryDataUI=void 0,z._hoveredUI){z.fireEvent("UINodeLeave",z._hoveredUI);const e=z.getUINode(z._hoveredUI);e&&e.onLeave&&e.onLeave()}return z._hoveredUI=void 0,void(z._tHover=void 0)}const e=z._hitsUI[0];if(z._queryDataScene&&z._queryDataScene.d{if(void 0!==z._hoveredSemNode)return z.getSemanticNode(z._hoveredSemNode)},z.setAPIToken=(e,t)=>{window.sessionStorage.setItem("ATON.tokens."+e,t)},z.getAPIToken=e=>window.sessionStorage.getItem("ATON.tokens."+e),z.clearToken=e=>{window.sessionStorage.removeItem("ATON.tokens."+e)},z.useGizmo=e=>{z._bGizmo=e,z._setupGizmo()},z._setupGizmo=()=>{z._bGizmo?void 0!==z.Nav._camera&&void 0!==z._renderer&&(void 0===z._gizmo?(z._gizmo=new THREE.TransformControls(z.Nav._camera,z._renderer.domElement),z._rootUI.add(z._gizmo),z._gizmo.setMode("rotate"),z._gizmo.addEventListener("dragging-changed",(function(e){let t=e.value;z.Nav.setUserControl(!t),z._bPauseQuery=t,t||(z.recomputeSceneBounds(),z.updateLightProbes(),console.log(z._gizmo.object))}))):(z._gizmo.camera=z.Nav._camera,z._gizmo.detach())):z._gizmo&&z._gizmo.detach()}})(); \ No newline at end of file +(()=>{"use strict";class e extends THREE.Group{constructor(e,t){super(),this.type=t||ATON.NTYPES.SCENE,this.enablePicking(),this.type===ATON.NTYPES.SCENE&&(this._rootG=ATON._rootVisible,this._nodes=ATON.snodes),this.type===ATON.NTYPES.SEM&&(this._rootG=ATON._rootSem,this._nodes=ATON.semnodes),this.type===ATON.NTYPES.UI&&(this._rootG=ATON._rootUI,this._nodes=ATON.uinodes),this.as(e),this.kwords=void 0,this._bCloneOnLoadHit=!0,this._tlist=void 0,this._aniMixers=void 0,this.castShadow=!1,this.receiveShadow=!1,this._bs=new THREE.Sphere,this.autocenter=!1,this.onHover=void 0,this.onLeave=void 0,this.onSelect=void 0}as(e){if(void 0!==e&&e!==ATON.ROOT_NID)return this._nodes[e]=this,this.nid=e,this.name=e,this}setAsRoot(){return this._nodes[ATON.ROOT_NID]=this,this.nid=ATON.ROOT_NID,this}setCloneOnLoadHit(e){return this._bCloneOnLoadHit=e,this}addKeywords(e){let t=e.split(",");void 0===this.kwords&&(this.kwords={});for(let e in t){let o=t[e].trim();o.length>0&&(this.kwords[o]=!0)}for(let t in this.children){let o=this.children[t];void 0!==o.type&&o.addKeywords(e)}return this}hasKeyword(e){if(void 0!==this.kwords)return void 0!==this.kwords[e]}setDescription(e){return this.userData.description=e,this}getDescription(){return this.userData.description}setAudio(e){return this.userData.audio=e,this}getAudio(){return this.userData.audio}hide(){return this.visible=!1,ATON.Utils.setPicking(this,this.type,!1),ATON._renderer.shadowMap.enabled&&(ATON._dMainL.shadow.needsUpdate=!0),this}show(){return this.visible=!0,ATON.Utils.setPicking(this,this.type,this.bPickable),ATON._renderer.shadowMap.enabled&&void 0!==ATON._dMainL&&void 0!==ATON._dMainL.shadow&&(ATON._dMainL.shadow.needsUpdate=!0),this}toggle(e){return void 0===e?this.visible?this.hide():this.show():e?this.show():this.hide()}disablePicking(){return this.bPickable=!1,ATON.Utils.setPicking(this,this.type,this.bPickable),this}enablePicking(){return this.bPickable=!0,ATON.Utils.setPicking(this,this.type,this.bPickable),this}setPickable(e){return e?this.enablePicking():this.disablePicking(),this}setMaterial(e){this.userData.cMat=e,this.traverse((t=>{t.isMesh&&(t.material=e),t.type&&(this.userData.cMat=e)}));for(let t in this.children){let o=this.children[t];o.setMaterial&&o.setMaterial(e)}return this}getMaterial(){return this.userData.cMat}setDefaultAndHighlightMaterials(e,t){return this.userData.matSTD=e,this.userData.matHL=t,this}highlight(){return this.userData.matHL&&this.setMaterial(this.userData.matHL),this}restoreDefaultMaterial(){return this.userData.matSTD&&this.setMaterial(this.userData.matSTD),this}setOpacity(e){return this.traverse((t=>{t.isMesh&&(t.material.opacity=e)})),this}setShadowCast(e){return this.castShadow=e,this.traverse((t=>{t.isMesh&&(t.castShadow=e)})),this}setShadowReceive(e){return this.receiveShadow=e,this.traverse((t=>{t.isMesh&&(t.receiveShadow=e)})),this}setEnvMap(e){return this.traverse((t=>{t.isMesh&&(t.material.envMap=e)})),this}assignLightProbe(e){return this.traverse((t=>{t.isMesh&&t.geometry&&ATON.Utils.assignLightProbeToMesh(e,t)})),this}assignLightProbesByProximity(){return 0===ATON._lps.length||this.traverse((e=>{if(e.isMesh&&e.geometry){let t,o,i=new THREE.Vector3;(new THREE.Box3).setFromObject(e).getCenter(i);for(let e in ATON._lps){let r=ATON._lps[e],a=i.distanceToSquared(r.pos);(void 0===t||a{e.isMesh&&e.geometry&&(ATON.Utils.clearLightProbeFromMesh(e),e.material&&(e.material.envMap.dispose(),e.material.needsUpdate=!0))})),this}updateLightProbes=()=>(this.traverse((e=>{if(e.isMesh&&e.geometry){let t=e.userData.LP;void 0!==t&&(t.update(),e.material.envMap=t.getEnvTex(),e.material.needsUpdate=!0)}})),this);duplicate(){let e=this.clone();return e.traverse((e=>{e.isMesh&&(e.material=e.material.clone())})),e}delete(){let e=this.parent;void 0!==e&&void 0!==e.nid&&e.removeChild(this)}removeChild(e){if(void 0!==e)return e.nid,void 0!==e.nid&&(this._nodes[e.nid]=void 0),e.parent=void 0,e.traverse((e=>{e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()})),this.remove(e),this}removeChildren(){for(let e=this.children.length-1;e>=0;e--)this.removeChild(this.children[e]);return this}attachTo(e){let t="string"==typeof e?this._nodes[e]:e;return t&&(t.add(this),void 0!==t.userData.cMat&&(this.userData.cMat=t.userData.cMat),void 0!==t.bPickable&&(this.bPickable=t.bPickable)),t}attachToRoot(){return this._rootG.add(this),void 0!==this._rootG.userData.cMat&&(this.userData.cMat=this._rootG.userData.cMat),void 0!==this._rootG.bPickable&&(this.bPickable=this._rootG.bPickable),this._rootG}getBound(){return this.dirtyBound(),this._bs}dirtyBound(){return(new THREE.Box3).setFromObject(this).getBoundingSphere(this._bs),this}autoFit(e,t){if(this.dirtyBound(),e&&(this.position.copy(this._bs.center),this.position.multiplyScalar(-1)),t&&t>0&&this._bs.radius>0){let e=t/this._bs.radius;this.scale.set(e,e,e)}}setPosition(e,t,o){return e instanceof THREE.Vector3?this.position.copy(e):this.position.set(e,t,o),this}setScale(e,t,o){return e instanceof THREE.Vector3?this.scale.copy(e):(void 0===t&&(t=e,o=e),this.scale.set(e,t,o)),this}setRotation(e,t,o){return e instanceof THREE.Vector3?this.rotation.copy(e):this.rotation.set(e,t,o),this}orientToCamera(){return this.quaternion.copy(ATON.Nav._qOri),this}orientToLocation(e,t,o){return e instanceof THREE.Vector3?this.lookAt(e):this.lookAt(e,t,o),this}orientToNode(e){return e?(this.orientToLocation(e.position),this):this}setYup(){return this.rotation.set(-1.57079632679,0,0),this}addTransform(e){let t;return"string"==typeof e&&(t=ATON.Utils.parseTransformString(e)),void 0===t||(void 0===this._tlist&&(this._tlist=[]),this._tlist.push(t)),this}load(e,t){if(void 0===e)return this;let o=this;if(e=ATON.Utils.resolveCollectionURL(e),ATON.Utils.tryLoadFromService(e,o))return t&&t(),o;if("json"===ATON.Utils.getFileExtension(e))return ATON.MRes.loadTileSetFromURL(e,o),t&&t(),o;if(ATON._resHandler)for(let t in ATON._resHandler)if(ATON._resHandler[t](e,o))return o;if(o._bCloneOnLoadHit&&void 0!==ATON._assetsManager[e])return ATON._assetsManager[e].then((e=>{let i=e.clone();if(ATON.Utils.modelVisitor(o,i),void 0!==o._tlist)for(let e in o._tlist)o._tlist[e].add(i.clone()),o.add(o._tlist[e]);else o.add(i);t&&t()})),o;ATON._assetReqNew(e);let i=new Promise(((i,r)=>{ATON._aLoader.load(e,(r=>{let a=r.scene||r.scene[0];if(ATON.Utils.modelVisitor(o,a),void 0!==o._tlist)for(let e in o._tlist)o._tlist[e].add(a.clone()),o.add(o._tlist[e]);else o.add(a);ATON.Utils.registerAniMixers(o,r),ATON.CC.extract(r),i(a),console.log("%cModel loaded","color:green"),ATON._assetReqComplete(e),o.type===ATON.NTYPES.SCENE&&(ATON._bqScene=!0),o.type===ATON.NTYPES.SEM&&(ATON._bqSem=!0),o.bPickable&&o.enablePicking(),o.dirtyBound(),t&&t()}),void 0,(o=>{console.log("%cError loading model "+e,"color:red"),ATON._assetReqComplete(e),t&&t()}))}));return o._bCloneOnLoadHit&&(ATON._assetsManager[e]=i),this}exportAs(e){return ATON.Utils.exportNode(this,e),this}setOnHover(e){return this.onHover=e,this}setOnLeave(e){return this.onLeave=e,this}setOnSelect(e){return this.onSelect=e,this}loadCesiumIONAsset(e){return ATON.MRes.loadCesiumIONAsset(e,this),this}loadSketchfabAsset(e){let t=ATON.getAPIToken("sketchfab"),o=this;return null==t&&(console.log("A valid Sketchfab token is required"),t=prompt("Please enter a valid Sketchfab token:"),null==t||""==t)||fetch("https://api.sketchfab.com/v3/models/"+e+"/download",{method:"GET",headers:{Authorization:"Token "+t},mode:"cors"}).then((function(e){return e.json()})).then((function(e){if(ATON.setAPIToken("sketchfab",t),e.glb){let t=e.glb.url;return o.load(t),o}})),this}}const t=e;let o={init:()=>{o.evLocal={},o.evNetwork={},ATON.on=o.on,ATON.fireEvent=o.fireEvent,ATON.clearEventHandlers=o.clearEventHandlers},clearEventHandlers:e=>{o.evLocal[e]=[],o.evNetwork[e]=[]},executeHandlers:(e,t)=>{if(e)for(let o=0;o{if(void 0!==t){const i=o.evLocal;void 0===i[e]&&(i[e]=[]),i[e].push(t)}void 0!==i&&ATON.Photon.on(e,i)},fireEvent:(e,t,i)=>{const r=o.evLocal[e];o.executeHandlers(r,t),i&&ATON.Photon.fireEvent(e,t)}};const i=o;let r={init:()=>{r.materials={},r.colors={},r._loader=new THREE.MaterialLoader,r._uSem={time:{type:"float",value:0},tint:{type:"vec4",value:new THREE.Vector4(.2,.2,1,.2)}},r.addDefaults()},getDefVertexShader:()=>"\n varying vec3 vPositionW;\n varying vec3 vNormalW;\n varying vec3 vNormalV;\n varying vec2 vUv;\n\n void main(){\n vUv = uv;\n\n vPositionW = ( modelMatrix * vec4( position, 1.0 )).xyz;\n vNormalV = normalize( vec3( normalMatrix * normal ));\n vNormalW = ( modelMatrix * vec4(normal, 0.0 )).xyz;\n\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }\n ",addDefaults:()=>{r.colors.white=new THREE.Color(1,1,1),r.colors.black=new THREE.Color(0,0,0),r.colors.green=new THREE.Color(0,1,0),r.colors.yellow=new THREE.Color(1,1,0),r.colors.red=new THREE.Color(1,0,0),r.colors.blue=new THREE.Color(0,0,1),r.colors.orange=new THREE.Color(1,.5,0),r.colors.defUI=new THREE.Color(.85,1,.95),r.colors.sem=new THREE.Color(0,1,.5),r.colors.darksem=new THREE.Color(0,0,.1),r.materials.fullyTransparent=new THREE.MeshBasicMaterial({transparent:!0,depthWrite:!1,opacity:0}),r.materials.defUI=new THREE.ShaderMaterial({uniforms:{tint:{type:"vec3",value:r.colors.defUI},opacity:{type:"float",value:0}},vertexShader:r.getDefVertexShader(),fragmentShader:"\n varying vec3 vPositionW;\n\t\t varying vec3 vNormalW;\n varying vec3 vNormalV;\n uniform vec3 tint;\n //uniform vec3 base;\n uniform float opacity;\n\n\t\t void main(){\n\t\t //vec3 viewDirectionW = normalize(cameraPosition - vPositionW);\n\n float f;\n\t\t //f = dot(vNormalV, viewDirectionW);\n f = dot(vNormalV, vec3(0,0,1));\n\t\t f = clamp(1.0-f, 0.0, 1.0);\n f *= f;\n\n f = mix(opacity, 1.0 + opacity, f);\n f = clamp(f, 0.0,1.0);\n\n //vec3 col = mix(base,tint, f);\n\t\t //gl_FragColor = vec4(col, f * opacity);\n\n gl_FragColor = vec4(tint, f);\n\t\t }\n ",transparent:!0,depthWrite:!1}),r.materials.selector=r.materials.defUI.clone(),r.materials.outline=new THREE.MeshBasicMaterial({color:r.colors.black,side:THREE.BackSide,transparent:!0,depthWrite:!1,opacity:.2}),r.materials.controllerRay=r.materials.defUI.clone(),r.materials.controllerRay.uniforms.tint.value=r.colors.white,r.materials.xray=r.materials.defUI.clone(),r.materials.xray.uniforms.tint.value=r.colors.white,r.materials.xray.uniforms.opacity.value=.5,r.materials.teleportLoc=new THREE.MeshBasicMaterial({transparent:!0,opacity:1,depthWrite:!1,side:THREE.DoubleSide}),ATON.Utils.textureLoader.load(ATON.PATH_RES+"grad.png",(e=>{r.materials.teleportLoc.map=e})),r.materials.measurement=new THREE.MeshBasicMaterial({color:r.colors.white,transparent:!0,depthWrite:!1,opacity:.5,depthTest:!1}),r.materials.semanticShape=new THREE.ShaderMaterial({uniforms:r._uSem,vertexShader:r.getDefVertexShader(),fragmentShader:"\n varying vec3 vPositionW;\n\t\t varying vec3 vNormalW;\n varying vec3 vNormalV;\n\n uniform float time;\n uniform vec4 tint;\n\n\t\t void main(){\n\t\t //vec3 viewDirectionW = normalize(cameraPosition - vPositionW);\n\n //float ff = dot(vNormalV, vec3(0,0,1));\n\t\t //ff = clamp(1.0-ff, 0.0, 1.0);\n\n float f = (1.0 * cos(time*2.0)); // - 0.5;\n //f = cos(time + (vPositionW.y*10.0));\n f = clamp(f, 0.0,1.0);\n\n\t\t gl_FragColor = vec4(tint.rgb, tint.a * f);\n //gl_FragColor = vec4(tint.rgb, ff);\n\t\t }\n ",transparent:!0,depthWrite:!1}),r.materials.semanticShapeHL=new THREE.MeshBasicMaterial({color:r.colors.sem,transparent:!0,depthWrite:!1,opacity:.2}),r.materials.semanticShapeEdit=new THREE.MeshBasicMaterial({color:r.colors.orange,transparent:!0,depthWrite:!1,opacity:.5}),r.materials.transWhite=new THREE.MeshBasicMaterial({color:r.colors.white,transparent:!0,depthWrite:!1,side:THREE.DoubleSide,opacity:.2}),r.materials.transBlack=new THREE.MeshBasicMaterial({color:r.colors.black,transparent:!0,depthWrite:!1,side:THREE.DoubleSide,opacity:.2}),r.materials.wireframe=new THREE.MeshBasicMaterial({color:r.colors.black,transparent:!0,depthWrite:!1,opacity:.1,wireframe:!0}),r.materials.normSlope=new THREE.ShaderMaterial({vertexShader:r.getDefVertexShader(),fragmentShader:"\n varying vec3 vPositionW;\n\t\t varying vec3 vNormalW;\n\n\t\t void main(){\n vec4 A = vec4(0,1,0, 1.0);\n vec4 B = vec4(1,0,0, 1.0);\n\n float f;\n f = dot(vNormalW, vec3(0,1,0));\n\n\t\t gl_FragColor = mix(B,A, f);\n\t\t }\n "}),r.materials.gradient=new THREE.ShaderMaterial({uniforms:{range:{type:"vec2",value:new THREE.Vector2(-4,5)}},vertexShader:r.getDefVertexShader(),fragmentShader:"\n varying vec3 vPositionW;\n\n uniform vec2 range;\n\n\t\t void main(){\n vec4 A = vec4(0,0,0, 1.0);\n vec4 B = vec4(0,0.5,1, 1.0);\n\n float t = (vPositionW.y - range.x)/(range.y - range.x);\n t = clamp(t, 0.0,1.0);\n\n\t\t gl_FragColor = mix(A,B, t);\n\t\t }\n "}),r.materials.lp=new THREE.ShaderMaterial({vertexShader:r.getDefVertexShader(),fragmentShader:"\n varying vec3 vPositionW;\n\t\t varying vec3 vNormalW;\n varying vec3 vNormalV;\n\n\t\t void main(){\n\t\t vec3 viewDirectionW = normalize(cameraPosition - vPositionW);\n\n float f;\n\t\t //f = dot(viewDirectionW, vNormalW);\n f = dot(vNormalV, vec3(0,0,1));\n\t\t f = clamp(1.0 - f, 0.0, 1.0);\n\n\t\t gl_FragColor = vec4(1.0,1.0,1.0, f);\n\t\t }\n ",transparent:!0,depthWrite:!1});let e=(new THREE.TextureLoader).load(ATON.PATH_RES+"point-mask.png");e.generateMipmaps=!1,r.materials.point=new THREE.PointsMaterial({vertexColors:!0,alphaMap:e,alphaTest:.5,depthTest:!0,transparent:!1,size:4,sizeAttenuation:!1}),r.materials.chromakey=new THREE.ShaderMaterial({uniforms:{tBase:{type:"t"},keycolor:{type:"vec4",value:new THREE.Vector4(0,1,0,0)},similarity:{type:"float",value:.4},smoothness:{type:"float",value:.08},spill:{type:"float",value:.1}},vertexShader:r.getDefVertexShader(),fragmentShader:"\n uniform sampler2D tBase;\n uniform vec4 keycolor;\n\n uniform float similarity;\n uniform float smoothness;\n uniform float spill;\n\n varying vec2 vUv;\n\n // From https://github.com/libretro/glsl-shaders/blob/master/nnedi3/shaders/rgb-to-yuv.glsl\n vec2 RGBtoUV(vec3 rgb){\n return vec2(\n rgb.r * -0.169 + rgb.g * -0.331 + rgb.b * 0.5 + 0.5,\n rgb.r * 0.5 + rgb.g * -0.419 + rgb.b * -0.081 + 0.5\n );\n }\n\n // From https://godotshaders.com/shader/green-screen-chromakey/\n\t\t void main(){\n\t\t vec4 frag = texture2D(tBase, vUv);\n vec4 orig = frag;\n\n float chromaDist = distance(RGBtoUV(frag.rgb), RGBtoUV(keycolor.rgb));\n\n float baseMask = chromaDist - similarity;\n float fullMask = pow(clamp(baseMask / smoothness, 0.0,1.0), 1.5);\n frag.a = fullMask;\n \n float spillVal = pow(clamp(baseMask / spill, 0.0,1.0), 1.5);\n float desat = clamp(frag.r * 0.2126 + frag.g * 0.7152 + frag.b * 0.0722, 0.0,1.0);\n frag.rgb = mix(vec3(desat, desat, desat), frag.rgb, spillVal);\n\n frag = mix(orig,frag, keycolor.w);\n\n\t\t gl_FragColor = frag;\n\t\t }\n ",transparent:!0,side:THREE.DoubleSide})},addMaterial:(e,t)=>{r.materials[e]?console.log("MatHub: material "+e+" already registered"):r.materials[e]=t},loadMaterial:(e,t)=>{r._loader.load(t,(t=>{r.addMaterial(e,t)}),void 0,(e=>{console.log(e)}))},getMaterial:e=>r.materials[e],update:()=>{r._uSem.time.value+=ATON._dt}};const a=r;let s={TSTRING_SEPARATOR:" ",VOID_CAST:(e,t)=>{},init:()=>{ATON.device={},s.geomUnitSphere=new THREE.SphereGeometry(1,32,32),s.geomUnitCube=new THREE.BoxGeometry,s.exporterGLTF=void 0,s.exporterOBJ=void 0,s.exporterUSDZ=void 0,s._dlink=document.createElement("a"),s._dlink.style.display="none",document.body.appendChild(s._dlink),s.textureLoader=new THREE.TextureLoader,s._bvhBounds=0,s.stats={},s.stats.numVertices=0,s.stats.numTris=0},generateID:e=>(void 0===e&&(e="id"),e+"-"+Math.random().toString(36).substr(2,9)),goToURL:e=>{window.location.href=e},goToScene:(e,t)=>{if(void 0===e)return;if(e.length<2)return;let o=ATON.PATH_FE+e;void 0!==t&&(o+="&vrc="+t),window.location.href=o},isConnectionSecure:()=>window.isSecureContext,isLocalhost:()=>!!window.location.origin.includes("localhost")||!!window.location.origin.includes("127.0.0.1"),showBVHbounds:e=>{e>0&&(s._bvhBounds=e)},_addBVHbounds:(e,t)=>{if(void 0===e)return;let o=new ThreeMeshBVH.MeshBVHHelper(e,t);o.displayParents=!0,o.update(),e.parent.add(o)},profileDevice:()=>{ATON.device.isMobile=!1,ATON.device.isMobile=!(!/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|ipad|iris|kindle|Android|Silk|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent)&&!/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(navigator.userAgent.substr(0,4))),ATON.device.xrSupported={},ATON.device.xrSupported["immersive-vr"]=!1,ATON.device.xrSupported["immersive-ar"]=!1,"xr"in navigator&&(navigator.xr.isSessionSupported("immersive-vr").then((e=>{ATON.device.xrSupported["immersive-vr"]=!!e,console.log("WebXR VR session support: "+ATON.device.xrSupported["immersive-vr"]),ATON.fireEvent("XR_support",{type:"immersive-vr",v:ATON.device.xrSupported["immersive-vr"]})})),navigator.xr.isSessionSupported("immersive-ar").then((e=>{ATON.device.xrSupported["immersive-ar"]=!!e,console.log("WebXR AR session support: "+ATON.device.xrSupported["immersive-ar"]),ATON.fireEvent("XR_support",{type:"immersive-ar",v:ATON.device.xrSupported["immersive-ar"]})})))},profileRenderingCapabilities:()=>{if(void 0===ATON._renderer)return;let e=ATON._renderer.capabilities;void 0!==e&&(ATON.device.lowGPU=!1,e.isWebGL2||(ATON.device.lowGPU=!0),e.maxTextureSize<8192&&(ATON.device.lowGPU=!0),e.maxCubemapSize<4096&&(ATON.device.lowGPU=!0),console.log(e))},isMobile:()=>ATON.device.isMobile,isVRsupported:()=>ATON.device.xrSupported["immersive-vr"],isARsupported:()=>ATON.device.xrSupported["immersive-ar"],getFileExtension:e=>e.substr(e.lastIndexOf(".")+1).toLowerCase(),removeFileExtension:e=>e.replace(/\.[^/.]+$/,""),isVideo:e=>{let t=s.getFileExtension(e);return"mp4"===t||"webm"===t||"m3u8"===t},getBaseFolder:e=>{var t=e.lastIndexOf("/");return-1!==t?e.substring(0,t+1):""},getFilename:e=>e.split(/(\\|\/)/g).pop(),isResourceURL:e=>!!e.startsWith("http://")||!!e.startsWith("https://"),URLify:e=>{if("string"!=typeof e)return e;const t=e.match(/(((ftp|https?):\/\/)[\-\w@:%_\+.~#?,&\/\/=]+)/g);return t&&t.forEach((function(t){e=e.replace(t,"")})),e},resolveCollectionURL:e=>e?(ATON._collMod&&(e=ATON._collMod(e)),e.startsWith("http")?e:ATON.PATH_COLLECTION+e):"",tryLoadFromService:(e,t)=>{if(!t)return!1;if(e.startsWith("https://cesium.com/ion/assets/")||e.startsWith("https://ion.cesium.com/assets/")){let o=e.split("/"),i=o[o.length-1];return t.loadCesiumIONAsset(i),!0}if(e.startsWith("https://assets.cesium.com/")){let o=e.split("/"),i=o[o.length-2];return t.loadCesiumIONAsset(i),!0}if(e.startsWith("https://sketchfab.com/3d-models/")){let o=e.split("-"),i=o[o.length-1];return t.loadSketchfabAsset(i),!0}for(let o in ATON._resMappers){let i=ATON._resMappers[o](e);if(void 0!==i)return t.load(i),!0}return!1},postJSON:(e,t,o,i)=>{$.ajax({url:e,type:"POST",xhrFields:{withCredentials:!0},data:JSON.stringify(t),contentType:"application/json; charset=utf-8",dataType:"json",success:e=>{o&&o(e)}}).fail((e=>{console.log(e),i&&i()}))},runAsync:e=>{const t=new Worker(URL.createObjectURL(new Blob([`postMessage((${e})());`]),{type:"application/javascript; charset=utf-8"}));return new Promise(((e,o)=>{t.onmessage=({data:o})=>{e(o),t.terminate()},t.onerror=e=>{o(e),t.terminate()}}))},mergeObject:e=>{e.updateMatrixWorld(!0);const t=[];e.traverse((e=>{if(e.isMesh){const o=e.geometry;o.applyMatrix4(e.matrixWorld),t.push(o.toNonIndexed())}}));const o=THREE.BufferGeometryUtils.mergeGeometries(t,!1),i=THREE.BufferGeometryUtils.mergeVertices(o).center(),r=new THREE.Group,a=new THREE.Mesh(i);return r.add(a),r},setPicking:(e,t,o)=>{void 0===o&&(o=!0),e.traverse((e=>{o?e.layers.enable(t):e.layers.disable(t)}))},graphPostVisitor:e=>{e.visible?console.log(e):s.setPicking(e,e.type,!1)},rotationBetweenDirections:(e,t)=>{const o=new THREE.Quaternion,i=(new THREE.Vector3).crossVectors(e,t);return o.x=i.x,o.y=i.y,o.z=i.z,o.w=1+e.clone().dot(t),o.normalize(),o},clampValue:(e,t,o)=>Math.min(Math.max(e,t),o),loadTexture:(e,t)=>{e.endsWith(".ktx2")?ATON._ktx2Loader.load(e,t):s.textureLoader.load(e,t)},modelVisitor:(e,t)=>{if(void 0===t)return;if(void 0===e)return;let o=e.type;t.traverse((t=>{t.isMesh&&(o===ATON.NTYPES.SCENE&&(t.castShadow=!0,t.receiveShadow=!0,t.geometry&&(t.geometry.computeBoundsTree(),console.log("Computed visible BVH"),s._bvhBounds>0&&s._addBVHbounds(t,s._bvhBounds)),s.processMaterial(t.material)),o===ATON.NTYPES.SEM&&(t.material=ATON.MatHub.materials.semanticShape,t.geometry&&(t.geometry.computeBoundsTree(),console.log("Computed semantic BVH"))),e.userData.cMat&&(t.material=e.userData.cMat))}))},processMaterial:e=>{void 0!==e&&null!==e.map&&void 0!==e.map&&(e.map.generateMipmaps=!0,e.map.anisotropy=ATON.device.isMobile?0:ATON._maxAnisotropy,e.map.minFilter=THREE.LinearMipmapLinearFilter,e.map.magFilter=THREE.LinearFilter,e.map.colorSpace=ATON._stdEncoding)},cleanupVisitor:e=>{e.traverse((e=>{if(e.material)if(e.material.length)for(let t=0;t{let o=t.scene||t.scene[0],i=!1;if(void 0===t.animations)return;let r=new THREE.AnimationMixer(o);t.animations.forEach((e=>{r.clipAction(e).play(),i=!0})),i&&(ATON._aniMixers.push(r),void 0===e._aniMixers&&(e._aniMixers=[]),e._aniMixers.push(r))},parseTransformString:e=>{let t=new THREE.Group,o=e.split(s.TSTRING_SEPARATOR),i=o.length;return i<3||(t.position.set(parseFloat(o[0]),parseFloat(o[1]),parseFloat(o[2])),i<6||(t.rotation.set(parseFloat(o[3]),parseFloat(o[4]),parseFloat(o[5])),i<9||t.scale.set(parseFloat(o[6]),parseFloat(o[7]),parseFloat(o[8])))),t},setVectorPrecision:(e,t)=>(e.x=parseFloat(e.x.toPrecision(t)),e.y=parseFloat(e.y.toPrecision(t)),e.z=parseFloat(e.z.toPrecision(t)),e),parseMD:e=>(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=e.replace(/^\s*\n\*/gm,"
      \n*")).replace(/^(\*.+)\s*\n([^\*])/gm,"$1\n
    \n\n$2")).replace(/^\*(.+)/gm,"
  • $1
  • ")).replace(/^\s*\n\d\./gm,"
      \n1.")).replace(/^(\d\..+)\s*\n([^\d\.])/gm,"$1\n
    \n\n$2")).replace(/^\d\.(.+)/gm,"
  • $1
  • ")).replace(/^\>(.+)/gm,"
    $1
    ")).replace(/[\#]{6}(.+)/g,"
    $1
    ")).replace(/[\#]{5}(.+)/g,"
    $1
    ")).replace(/[\#]{4}(.+)/g,"

    $1

    ")).replace(/[\#]{3}(.+)/g,"

    $1

    ")).replace(/[\#]{2}(.+)/g,"

    $1

    ")).replace(/[\#]{1}(.+)/g,"

    $1

    ")).replace(/^(.+)\n\=+/gm,"

    $1

    ")).replace(/^(.+)\n\-+/gm,"

    $1

    ")).replace(/\!\[([^\]]+)\]\(([^\)]+)\)/g,'$1')).replace(/[\[]{1}([^\]]+)[\]]{1}[\(]{1}([^\)\"]+)(\"(.+)\")?[\)]{1}/g,'$1')).replace(/[\*\_]{2}([^\*\_]+)[\*\_]{2}/g,"$1")).replace(/[\*\_]{1}([^\*\_]+)[\*\_]{1}/g,"$1")).replace(/[\~]{2}([^\~]+)[\~]{2}/g,"$1")).replace(/^\s*\n\`\`\`(([^\s]+))?/gm,'
    ')).replace(/^\`\`\`\s*\n/gm,"
    \n\n")).replace(/[\`]{1}([^\`]+)[\`]{1}/g,"$1")).replace(/^\s*(\n)?(.+)/gm,(function(e){return/\<(\/)?(h\d|ul|ol|li|blockquote|pre|img)/.test(e)?e:"

    "+e+"

    "}))).replace(/(\)\s*\n\(.+)\<\/p\>/gm,"$1$2"),checkAuth:e=>{$.ajax({type:"GET",url:ATON.PATH_RESTAPI+"user",xhrFields:{withCredentials:!0},dataType:"json",success:t=>{e(t)}})},getHumanReadableDistance:e=>{let t=" m";return e<.01?(t=" mm",t=(e*=1e3).toPrecision(3)+t,t):e<1?(t=" cm",t=(e*=100).toPrecision(3)+t,t):e>1e3?(t=" km",t=e.toPrecision(3)+t,t):(t=e.toPrecision(3)+t,t)},stripHTMLtagsFromString:e=>e.replace(/(<([^>]+)>)/gi,""),requestFullscreen:()=>{let e=document.documentElement;return e.requestFullscreen?e.requestFullscreen():e.mozRequestFullScreen?e.mozRequestFullScreen():e.webkitRequestFullscreen?e.webkitRequestFullscreen():e.msRequestFullscreen&&e.msRequestFullscreen(),!0},downloadBlob:(e,t)=>{void 0!==t&&(s._dlink.href=URL.createObjectURL(e),s._dlink.download=t,s._dlink.click())},downloadText:(e,t)=>{s.downloadBlob(new Blob([e],{type:"text/plain"}),t)},downloadJSONobj:(e,t)=>{s.downloadText(JSON.stringify(e),t)},downloadArrayBuffer:(e,t)=>{s.downloadBlob(new Blob([e],{type:"application/octet-stream"}),t)},downloadImageFromCanvas:(e,t)=>{if(!e)return;let o=e.toDataURL();ATON.Utils._dlink.href=o,ATON.Utils._dlink.download=t,ATON.Utils._dlink.click()},exportNode:(e,t)=>{let o=s.getFileExtension(t);if(!(o.length<1)){if("glb"===o||"gltf"===o){let i={binary:"glb"===o};void 0===s.exporterGLTF&&(s.exporterGLTF=new THREE.GLTFExporter),s.exporterGLTF.parse(e,(e=>{e instanceof ArrayBuffer?s.downloadArrayBuffer(e,t):(console.log(e),s.downloadJSONobj(e,t))}),i)}if("obj"===o){void 0===s.exporterOBJ&&(s.exporterOBJ=new THREE.OBJExporter);let o=s.exporterOBJ.parse(e);s.downloadText(o,t)}"usdz"===o&&(void 0===s.exporterUSDZ&&(s.exporterUSDZ=new THREE.USDZExporter),$("#idLoader").show(),s.exporterUSDZ.parse(e).then((e=>{s.downloadArrayBuffer(e,t),$("#idLoader").hide()})))}},takeScreenshot:(e,t)=>{let o=new Image;console.log("Screenshot with size:"+e),ATON.Nav._camera.aspect=1,ATON.Nav._camera.updateProjectionMatrix(),ATON._renderer.setSize(e,e),ATON._renderer.render(ATON._mainRoot,ATON.Nav._camera);let i=ATON._renderer.domElement;if(ATON.FX.composer){if(ATON.FX.composer.setSize(e,e),ATON.FX.passes[ATON.FX.PASS_AA]){let t=ATON.FX.passes[ATON.FX.PASS_AA].material.uniforms;t&&t.resolution.value.set(1/e,1/e)}ATON.FX.composer.render(),i=ATON.FX.composer.renderer.domElement}let r=ATON._renderer.domElement.toDataURL();return o.src=r,t&&(s._dlink.href=r.replace("image/png","image/octet-stream"),s._dlink.download=t,s._dlink.click()),ATON._onResize(),o},assignLightProbeToMesh:(e,t)=>{void 0!==e&&void 0!==t&&(t.noLP||(t.userData.LP=e))},clearLightProbeFromMesh:e=>{void 0!==e&&(e.noLP||(e.userData.LP=null))},vibrate:e=>{void 0===e&&(e=100),window.navigator.vibrate(e)},createATONCube:e=>{let t=new THREE.BoxGeometry(1,1,1),o=new THREE.MeshStandardMaterial;s.textureLoader.load(ATON.PATH_RES+"models/aton-cube.jpg",(e=>{e.colorSpace=ATON._stdEncoding,o.map=e}));let i=ATON.createSceneNode(e);return i.add(new THREE.Mesh(t)),i.setMaterial(o),i.enablePicking(),i},createATONCubePBR:e=>{let t=new THREE.BoxGeometry(1,1,1),o=new THREE.MeshStandardMaterial;o.metalness=1,s.textureLoader.load(ATON.PATH_RES+"models/aton-cube.jpg",(e=>{e.colorSpace=ATON._stdEncoding,o.map=e})),s.textureLoader.load(ATON.PATH_RES+"models/aton-cube-pbr.jpg",(e=>{e.colorSpace=ATON._stdEncoding,o.metalnessMap=e,o.roughnessMap=e})),s.textureLoader.load(ATON.PATH_RES+"models/aton-cube-nrm.png",(e=>{e.colorSpace=ATON._stdEncoding,o.normalMap=e}));let i=ATON.createSceneNode(e);return i.add(new THREE.Mesh(t)),i.setMaterial(o),i.enablePicking(),i},createGround:(e,t,o)=>{void 0===t&&(t=1),void 0===o&&(o=1);let i=new THREE.PlaneGeometry(t,o),r=new THREE.MeshStandardMaterial;void 0!==e&&s.textureLoader.load(e,(e=>{e.colorSpace=ATON._stdEncoding,r.map=e}));let a=ATON.createSceneNode().rotateX(.5*-Math.PI);return a.add(new THREE.Mesh(i,r)),a.enablePicking(),a}};const n=s;let l={MODE_ADD:0,MODE_DEL:1,FLOAT_PREC:5,init:()=>{l.currID=void 0,l.currData=void 0,l._bEdit=!1,l._bLoading=!1,l._title=void 0,l._descr=void 0,l.initBaseParsers()},setEditMode:e=>{l._bEdit=e,console.log("Edit mode:"+e)},load:(e,t,o)=>(l._bLoading=!0,console.log("Loading Scene: "+t),$.getJSON(e,(e=>{l.currData=e,l.currID=t,l._bLoading=!1,l.parseScene(e),o&&o(),ATON.fireEvent("SceneJSONLoaded",t)}))),clearScene:()=>{if(!(ATON._rootVisible.children.length<=0)){ATON._rootVisible.removeChildren();for(let e in ATON.snodes)e!==ATON.ROOT_NID&&delete ATON.snodes[e];ATON.MRes.clear(),ATON.XPFNetwork.clear()}},clearSemantics:()=>{if(!(ATON._rootSem.children.length<=0)){ATON._rootSem.removeChildren();for(let e in ATON.semnodes)e!==ATON.ROOT_NID&&delete ATON.semnodes[e];ATON.SUI.gSemIcons&&ATON.SUI.gSemIcons.removeChildren(),ATON.SemFactory.stopCurrentConvex(),ATON.SemFactory.init()}},clear:()=>{l.clearScene(),l.clearSemantics(),ATON.Nav.clear()},parseScene:e=>{if(void 0!==(e=void 0===e?l.currData:e))for(let t in e)l._jsonParsers[t]&&l._jsonParsers[t](e[t])},getJSONchildren:(e,t)=>{let o;void 0===t&&(t=ATON.NTYPES.SCENE);let i=[];if(t===ATON.NTYPES.SEM&&(o=ATON.getSemanticNode(e)),t===ATON.NTYPES.SCENE&&(o=ATON.getSceneNode(e)),void 0!==o){for(let e in o.children){let t=o.children[e];void 0!==t.nid&&i.push(t.nid)}return i}},getJSONgraphEdges:e=>{void 0===e&&(e=ATON.NTYPES.SCENE);let t=ATON.snodes;e===ATON.NTYPES.SEM&&(t=ATON.semnodes),e===ATON.NTYPES.UI&&(t=ATON.uinodes);let o={};for(let e in t){let i=t[e];i&&i.parent&&i.parent.nid&&(void 0===o[i.parent.nid]&&(o[i.parent.nid]=[]),o[i.parent.nid].push(i.nid))}return o},getJSONsemanticSpheresList:e=>{let t=ATON.getSemanticNode(e);if(void 0===t)return;let o=[];for(let e in t.children){let i=t.children[e];i.type&&o.push([parseFloat(i.position.x.toPrecision(l.FLOAT_PREC)),parseFloat(i.position.y.toPrecision(l.FLOAT_PREC)),parseFloat(i.position.z.toPrecision(l.FLOAT_PREC)),parseFloat(i.scale.x.toPrecision(l.FLOAT_PREC))])}return o},getJSONsemanticConvexShapes:e=>{let t=ATON.getSemanticNode(e);if(void 0===t)return;let o=[];for(let e in t.children){let i=t.children[e];i.userData._convexPoints&&o.push(i.userData._convexPoints)}return o},_applyJSONTransformToNode:(e,t)=>{if(void 0!==e&&void 0!==t){if(e.bUseGeoCoords)return t.bUseGeoCoords=!0,void(e.scale&&t.setScale(e.scale[0],e.scale[1],e.scale[2]));e.autocenter?t.autocenter=!0:e.position&&t.setPosition(e.position[0],e.position[1],e.position[2]),e.rotation&&t.setRotation(e.rotation[0],e.rotation[1],e.rotation[2]),e.scale&&t.setScale(e.scale[0],e.scale[1],e.scale[2]),e.list&&Array.isArray(e.list)}},initBaseParsers:()=>{l._jsonParsers={},l._jsonParsers.title=e=>{void 0!==e&&l.setTitle(e)},l._jsonParsers.description=e=>{void 0!==e&&l.setDescription(e)},l._jsonParsers.fx=e=>{e.ao&&(ATON.FX.togglePass(ATON.FX.PASS_AO,!0),e.ao.i&&ATON.FX.setAOintensity(parseFloat(e.ao.i))),e.bloom&&(ATON.FX.togglePass(ATON.FX.PASS_BLOOM,!0),e.bloom.i&&ATON.FX.setBloomStrength(parseFloat(e.bloom.i)),e.bloom.t&&ATON.FX.setBloomThreshold(parseFloat(e.bloom.t))),e.dof&&(ATON.FX.togglePass(ATON.FX.PASS_DOF,!0),e.dof.f&&ATON.FX.setDOFfocus(parseFloat(e.dof.f)))},l._jsonParsers.environment=e=>{let t=e.mainpano;if(e.mainpano&&(t.url&&ATON.setMainPanorama(t.url),t.rotation&&ATON.setMainPanoramaRotation(t.rotation)),e.bgcolor){let t=new THREE.Color(e.bgcolor[0],e.bgcolor[1],e.bgcolor[2]);ATON.setBackgroundColor(t)}let o=e.mainlight;o?(o.direction&&ATON.setMainLightDirection(new THREE.Vector3(o.direction[0],o.direction[1],o.direction[2])),ATON._dMainL?(o.color&&(ATON._dMainL.color=new THREE.Color(o.color[0],o.color[1],o.color[2])),o.intensity&&(ATON._dMainL.intensity=o.intensity),void 0!==o.shadows?ATON.toggleShadows(o.shadows):ATON.toggleShadows(!1)):ATON.toggleMainLight(!1)):ATON.toggleMainLight(!1);let i=e.lightprobes;if(i&&(void 0!==i.auto&&ATON.setAutoLP(i.auto),i.list))for(let e in i.list){let t=i.list[e],o=new ATON.LightProbe(t.res);t.pos&&o.setPosition(parseFloat(t.pos[0]),parseFloat(t.pos[1]),parseFloat(t.pos[2])),t.near&&o.setNear(parseFloat(t.near)),t.far&&o.setFar(parseFloat(t.far)),ATON.addLightProbe(o),console.log(o)}e.exposure&&ATON.setExposure(e.exposure)},l._jsonParsers.soundscape=e=>{void 0!==e&&e.global&&ATON.setGlobalAudio(e.global.url,e.global.loop)},l._jsonParsers.navmode=e=>{void 0!==e&&ATON.Nav.setNavMode(e)},l._jsonParsers.locomotionGraph=e=>{if(void 0!==e){for(let t in e){let o=e[t];o.pos&&ATON.Nav.addLocomotionNode(parseFloat(o.pos[0]),parseFloat(o.pos[1]),parseFloat(o.pos[2]),!0)}ATON.Nav.setFirstPersonControl(),ATON.Nav.toggleLocomotionValidator(!1)}},l._jsonParsers.measurements=e=>{if(void 0!==e)for(let t in e){let o=e[t];if(o.points&&6===o.points.length){let e=new THREE.Vector3(parseFloat(o.points[0]),parseFloat(o.points[1]),parseFloat(o.points[2])),t=new THREE.Vector3(parseFloat(o.points[3]),parseFloat(o.points[4]),parseFloat(o.points[5]));ATON.SUI.addMeasurementPoint(e),ATON.SUI.addMeasurementPoint(t)}}},l._jsonParsers.viewpoints=e=>{if(void 0!==e)for(let t in e){let o=e[t];"home"===t?ATON.Nav.setHomePOV((new ATON.POV).setPosition(o.position[0],o.position[1],o.position[2]).setTarget(o.target[0],o.target[1],o.target[2]).setFOV(o.fov)):new ATON.POV(t).setPosition(o.position[0],o.position[1],o.position[2]).setTarget(o.target[0],o.target[1],o.target[2]).setFOV(o.fov)}},l._jsonParsers.scenegraph=e=>{if(void 0===e)return;let t=e.nodes,o=e.edges;for(let e in t){let o=t[e],i=ATON.getOrCreateSceneNode(e).removeChildren();l._applyJSONTransformToNode(o.transform,i);let r=o.urls;if(r&&(Array.isArray(r)?r.forEach((e=>{i.load(e)})):i.load(r)),o["cesium.ion"]){let e=o["cesium.ion"];ATON.MRes.loadCesiumIONAsset(e,i)}if(o.stream){let t,r=o.stream;if(r.src.startsWith("#")){let e=parseInt(r.src.substring(1));t=ATON.MediaFlow.getOrCreateVideoStream(e,void 0,!0)}else{let o=ATON.Utils.resolveCollectionURL(r.src);t=ATON.MediaFlow.getOrCreateVideoStream(e,o)}if(r.chromakey){let e=r.chromakey.color;e&&t.matStream.uniforms.keycolor.value.set(parseFloat(e[0]),parseFloat(e[1]),parseFloat(e[2]),parseFloat(e[3])),r.chromakey.smoothness&&(t.matStream.uniforms.smoothness.value=parseFloat(r.chromakey.smoothness)),r.chromakey.spill&&(t.matStream.uniforms.spill.value=parseFloat(r.chromakey.spill)),r.chromakey.similarity&&(t.matStream.uniforms.similarity.value=parseFloat(r.chromakey.similarity))}if(!o.urls){let e=new THREE.PlaneGeometry(1,1),o=new THREE.Mesh(e);o.scale.x=1,o.scale.y=-1,t.el.addEventListener("loadedmetadata",(e=>{let i=t.el.videoWidth/t.el.videoHeight;o.scale.x=i,o.scale.y=-1})),ATON.Utils.modelVisitor(i,o),i.add(o),ATON._bqScene=!0,i.setPickable(!0),i.dirtyBound()}i.setMaterial(t.matStream)}o.shadowcast&&i.setShadowCast(o.shadowcast),o.shadowreceive&&i.setShadowCast(o.shadowreceive),o.toYup&&i.setYup(),o.keywords&&(i.kwords=o.keywords)}for(let e in o){let t=o[e],i=ATON.getSceneNode(e);if(void 0!==i)for(let e in t){let o=t[e],r=ATON.getSceneNode(o);void 0!==r&&r.attachTo(i)}}for(let e in t){let o=t[e],i=ATON.getSceneNode(e);if(void 0!==i&&(void 0!==o.show&&(o.show?(i.show(),console.log("show "+e)):(i.hide(),console.log("hide "+e))),o.material)){let e;"string"==typeof o.material?e=ATON.MatHub.materials[o.material]:o.material.fragmentShader||o.material.vertexShader?(o.material.vertexShader||(o.material.vertexShader=ATON.MatHub.getDefVertexShader()),e=new THREE.ShaderMaterial(o.material)):e=new THREE.MeshStandardMaterial(o.material),e&&i.setMaterial(e)}}},l._jsonParsers.semanticgraph=e=>{if(void 0===e)return;let t=e.nodes,o=e.edges;for(let e in t){let o=t[e],i=ATON.getOrCreateSemanticNode(e).removeChildren(),r=o.urls;r&&(Array.isArray(r)?r.forEach((e=>{i.load(e)})):i.load(r)),o.toYup&&i.setYup(),o.description&&i.setDescription(o.description),o.audio&&i.setAudio(o.audio),o.keywords&&(i.kwords=o.keywords);let a=o.spheres;if(Array.isArray(a))for(let t in a){let o=a[t],i=new THREE.Vector3(parseFloat(o[0]),parseFloat(o[1]),parseFloat(o[2]));ATON.SemFactory.createSphere(e,i,parseFloat(o[3]))}let s=o.convexshapes;if(Array.isArray(s))for(let t in s){let o=s[t],i=[];for(let e=0;e{if(ATON.Nav.setFirstPersonControl(),e.list){let t=e.list,o=t.length;for(let e=0;e{ATON.XPFNetwork.setHomeXPF(0),ATON.XPFNetwork.requestTransitionByIndex(0,0)}))}},addSceneParser:(e,t)=>{l._jsonParsers[e]=t},patch:(e,t,o)=>{if(l._bLoading||!l._bEdit)return;if(void 0===e)return;void 0===t&&(t=l.MODE_ADD);let i=l.currID,r={};r.data=e,r.mode=t===l.MODE_DEL?"DEL":"ADD";let a=JSON.stringify(r);e=null,r=null,$.ajax({url:ATON.PATH_RESTAPI2+"scenes/"+i,type:"PATCH",data:a,contentType:"application/json; charset=utf-8",dataType:"json",success:e=>{e&&(l.currData=e),o&&o()}})}};l.sendEdit=l.patch,l.setVisibility=(e,t)=>{l.currData.visibility=e,l.sendEdit({visibility:e},ATON.SceneHub.MODE_ADD,t)},l.currSceneHasHomeConfig=()=>void 0!==l.currData&&void 0!==l.currData.viewpoints&&void 0!==l.currData.viewpoints.home,l.setTitle=e=>{l._title=e},l.getTitle=()=>l._title,l.setDescription=e=>{l._descr=e},l.getDescription=()=>l._descr;const d=l;let c={init:()=>{c._listener=new THREE.AudioListener,c._loader=new THREE.AudioLoader,c._bGenAuPlaying=!1},playOnceGlobally:(e,t)=>{if(t&&c._bGenAuPlaying)return;e=ATON.Utils.resolveCollectionURL(e);let o=new THREE.Audio(ATON.AudioHub._listener);return c._loader.load(e,(e=>{o.setBuffer(e),o.play(),t&&(c._bGenAuPlaying=!0)})),t&&(o.onEnded=()=>{c._bGenAuPlaying=!1}),o}};const u=c;class _ extends THREE.EventDispatcher{constructor(e){super(),!1===window.isSecureContext&&console.error("DeviceOrientationEvent is only available in secure contexts (https)"),this._zee=new THREE.Vector3(0,0,1),this._euler=new THREE.Euler,this._q0=new THREE.Quaternion,this._q1=new THREE.Quaternion(-Math.sqrt(.5),0,0,Math.sqrt(.5)),this._changeEvent={type:"change"};const t=this,o=new THREE.Quaternion;this.object=e,this.object.rotation.reorder("YXZ"),this.enabled=!0,this.deviceOrientation={},this.screenOrientation=0,this.alphaOffset=0;const i=function(e){t.deviceOrientation=e},r=function(){t.screenOrientation=window.orientation||0};this.connect=function(){r(),void 0!==window.DeviceOrientationEvent&&"function"==typeof window.DeviceOrientationEvent.requestPermission?window.DeviceOrientationEvent.requestPermission().then((function(e){"granted"==e&&(window.addEventListener("orientationchange",r),window.addEventListener("deviceorientation",i))})).catch((function(e){console.error("Unable to use DeviceOrientation API:",e)})):(window.addEventListener("orientationchange",r),window.addEventListener("deviceorientation",i)),t.enabled=!0},this.disconnect=function(){window.removeEventListener("orientationchange",r),window.removeEventListener("deviceorientation",i),t.enabled=!1},this.update=function(){if(!1===t.enabled)return;const e=t.deviceOrientation;if(e){const i=e.alpha?THREE.MathUtils.degToRad(e.alpha)+t.alphaOffset:0,r=e.beta?THREE.MathUtils.degToRad(e.beta):0,a=e.gamma?THREE.MathUtils.degToRad(e.gamma):0,s=t.screenOrientation?THREE.MathUtils.degToRad(t.screenOrientation):0;!function(e,o,i,r,a){t._euler.set(i,o,-r,"YXZ"),e.setFromEuler(t._euler),e.multiply(t._q1),e.multiply(t._q0.setFromAxisAngle(t._zee,-a))}(t.object.quaternion,i,r,a,s),8*(1-o.dot(t.object.quaternion))>1e-6&&(o.copy(t.object.quaternion),t.dispatchEvent(t._changeEvent))}},this.dispose=function(){t.disconnect()},this.connect()}}const p=_;let h={STD_FOV:50,STD_NEAR:.01,STD_FAR:800,FP_EPS:.01,STD_POV_TRANS_DURATION:2,STD_LOCNODE_SIZE:.5,MIN_LOC_VALID_DIST:1.5,MODE_ORBIT:0,MODE_FP:1,MODE_DEVORI:2,LocomotionNode:class{constructor(e){this.pos=new THREE.Vector3(0,0,0),this.id=e,this._iXPF=void 0,this._sui=void 0}setLocation(e,t,o){return e instanceof THREE.Vector3?this.pos.copy(e):this.pos.set(e,t,o),this._sui&&this._sui.position.copy(this.pos),this}getLocation(){return this.pos}realizeSUI(e){return void 0===ATON.SUI.gLocNodes||(this._sui=new THREE.Sprite(ATON.SUI.getOrCreateSpriteWalk()),this._sui.position.copy(this.pos),this._sui.scale.set(ATON.Nav.STD_LOCNODE_SIZE,ATON.Nav.STD_LOCNODE_SIZE,ATON.Nav.STD_LOCNODE_SIZE),ATON.SUI.gLocNodes.add(this._sui)),this}toggleSUI(e){return void 0===this._sui||(this._sui.visible=e),this}},init:()=>{h._mode=void 0,h.POVtransitionDuration=h.STD_POV_TRANS_DURATION,h._rotSpeedOrbit=.4,h._rotSpeedFP=-.2,h._inertia=.08,h._bControl=!0,h._bLocValidator=!0,h._bInteracting=!1,h._prevMode=void 0,h.setOrbitControl(),h._currPOV=(new ATON.POV).setPosition(0,0,0).setTarget(1,0,0).setFOV(ATON.Nav.STD_FOV),h._fromPOV=new ATON.POV,h._reqPOV=new ATON.POV,h.homePOV=void 0,h._tPOVcall=-1,h._tPOVprogress=0,h.povlist={},h._vDir=new THREE.Vector3(1,0,0),h._qOri=new THREE.Quaternion,h._lastPos=new THREE.Vector3(0,0,0),h._lastOri=new THREE.Quaternion,h._dOri=0,h._dPos=0,h._motionAmt=0,h._motionDir=new THREE.Vector3(0,1,0),h._bValidLocomotion=!1,h._locNodes=[],h._prevLN=void 0},getCurrentEyeLocation:()=>h._currPOV.pos,getCurrentDirection:()=>h._vDir,copyCurrentPOV:()=>{let e=new ATON.POV;return e.pos.copy(h._currPOV.pos),e.target.copy(h._currPOV.target),e.fov=h._currPOV.fov,e},addPOV:(e,t)=>{if(void 0!==e)return e.as(t),e},clearPOVs:()=>{for(let e in ATON.Nav.povlist)delete h.povlist[e]},isTransitioning:()=>h._tPOVcall>=0,currentQueryValidForLocomotion:()=>h._bValidLocomotion,locomotionValidator:()=>{if(void 0===ATON._queryDataScene)return void(h._bValidLocomotion=!1);let e=ATON._queryDataScene,t=(e.p,e.n);e.d<=h.MIN_LOC_VALID_DIST?h._bValidLocomotion=!1:t?t.y<=.7?h._bValidLocomotion=!1:h._bValidLocomotion=!0:h._bValidLocomotion=!1},toggleLocomotionValidator:e=>{e?h._bLocValidator=!0:(h._bLocValidator=!1,h._bValidLocomotion=!1)},addLocomotionNode:(e,t,o,i)=>{let r=(new h.LocomotionNode).setLocation(e,t,o);return i&&r.realizeSUI(),h._locNodes.push(r),ATON.fireEvent("LocomotionNodeAdded",r),r},getLocomotionNodeByIndex:e=>h._locNodes[e],clearLocomotionNodes:()=>{h._locNodes=[],h._prevLN=void 0,ATON.SUI.gLocNodes&&ATON.SUI.gLocNodes.removeChildren()},getLocomotionNodeInSight:()=>{let e=h._locNodes.length;if(e<=0)return;if(h.isTransitioning())return;let t,o,i=h._currPOV.pos,r=h._vDir;void 0===h._dirLNode&&(h._dirLNode=new THREE.Vector3);for(let a=0;a.8){let e=i.distanceToSquared(h._posLNode);e>.3&&(void 0===o||e{if(void 0===e)return;if(h._mode===h.MODE_ORBIT)return;let o=ATON.Nav._vDir,i=(new ATON.POV).setPosition(e.pos).setTarget(e.pos.x+o.x,e.pos.y+o.y,e.pos.z+o.z).setFOV(h._currPOV.fov);e.toggleSUI(!1),void 0!==h._prevLN&&h._prevLN.toggleSUI(!0),h.requestPOV(i,t),h._prevLN=e,ATON.fireEvent("LocomotionNodeRequested",e)},requestTransitionToLocomotionNodeInSightIfAny:e=>{let t=ATON.XPFNetwork.getNextXPFindex();if(void 0!==t)return h.requestTransitionToLocomotionNode(ATON.XPFNetwork._list[t]._lnode,e),!0;let o=ATON.Nav.getLocomotionNodeInSight();if(void 0===o)return!1;let i=h._locNodes[o];return h.requestTransitionToLocomotionNode(i,e),!0},requestDeltaRotation:(e,t,o)=>{if(ATON.XR._bPresenting)return;let i=new THREE.Vector3,r=new THREE.Vector3;i.crossVectors(h._vDir,THREE.Object3D.DEFAULT_UP),r.x=h._currPOV.target.x+i.x*e,r.y=h._currPOV.target.y+t,r.z=h._currPOV.target.z+i.z*e;let a=new ATON.POV;a.setTarget(r),a.setPosition(ATON.Nav._currPOV.pos),ATON.Nav.requestPOV(a,o)},setUserControl:e=>{void 0!==e&&e!==h._bControl&&(h._bControl=e,void 0!==h._controls&&(h._controls.enabled=e),h._cOrbit&&(h._cOrbit.enabled=e),h._cFirstPerson&&(h._cFirstPerson.enabled=e),console.log("Nav controls: "+h._bControl))},toggleUserControl:()=>{h.setUserControl(!h._bControl)},isUserControlEnabled:()=>h._bControl,isOrbit:()=>!ATON.XR._bPresenting&&h._mode===h.MODE_ORBIT,isFirstPerson:()=>!ATON.XR._bPresenting&&h._mode===h.MODE_FP,isDevOri:()=>!ATON.XR._bPresenting&&h._mode===h.MODE_DEVORI,setNavMode:e=>{void 0!==e&&(e===h.MODE_ORBIT&&h.setOrbitControl(),e===h.MODE_FP&&h.setFirstPersonControl(),e===h.MODE_DEVORI&&h.setDeviceOrientationControl())},restorePreviousNavMode:()=>{void 0===h._prevMode&&h.setOrbitControl(),h.setNavMode(h._prevMode)},_updCamera:e=>{if(void 0===e&&(e=h._camera),ATON.FX.composer){let t=ATON.FX.composer.passes;if(t)for(let o=0;o{if(!ATON.XR.isPresenting()){if(h._prevMode=h._mode,h._mode=h.MODE_ORBIT,h._bInteracting=!1,ATON.fireEvent("NavInteraction",!1),void 0===h._cOrbit){h._camOrbit=new THREE.PerspectiveCamera(h.STD_FOV,window.innerWidth/window.innerHeight,h.STD_NEAR,h.STD_FAR),h._camOrbit.layers.enableAll(),h._cOrbit=new THREE.OrbitControls(h._camOrbit,ATON._renderer.domElement);let e=h._cOrbit;e.rotateSpeed=h._rotSpeedOrbit,e.enablePan=!0,h._inertia>0&&(e.enableDamping=!0,e.dampingFactor=h._inertia),e.screenSpacePanning=!0,e.enableZoom=!0,e.minDistance=.03,e.maxDistance=300,h._bControl||(e.enabled=!1),e.addEventListener("start",(()=>{h._bInteracting=!0,ATON.fireEvent("NavInteraction",!0)})),e.addEventListener("end",(()=>{h._bInteracting=!1,ATON.fireEvent("NavInteraction",!1)}))}h._controls=h._cOrbit,h._camera=h._camOrbit,ATON.AudioHub._listener&&h._camera.children.length<1&&h._camera.add(ATON.AudioHub._listener),h._updCamera(),h._controls.update(),h._currPOV&&h.syncCurrCamera(),ATON._onResize(),ATON.toggleCenteredQuery(!1),ATON.fireEvent("NavMode",h._mode)}},setFirstPersonControl:()=>{if(!ATON.XR.isPresenting()){if(h._prevMode=h._mode,ATON.SUI.getSelectorRadius()>.1&&ATON.SUI.setSelectorRadius(.1),h._mode=h.MODE_FP,h._bInteracting=!1,ATON.fireEvent("NavInteraction",!1),void 0===h._cFirstPerson){h._camFP=new THREE.PerspectiveCamera(h.STD_FOV,window.innerWidth/window.innerHeight,h.STD_NEAR,h.STD_FAR),h._camFP.layers.enableAll(),h._cFirstPerson=new THREE.OrbitControls(h._camFP,ATON._renderer.domElement);let e=h._cFirstPerson;e.enableZoom=!1,e.enablePan=!1,e.rotateSpeed=h._rotSpeedFP,h._inertia>0&&(e.enableDamping=!0,e.dampingFactor=h._inertia),e.target.copy(h._camera.position),e.minDistance=.01,e.maxDistance=.01,h._bControl||(e.enabled=!1)}h._controls=h._cFirstPerson,h._camera=h._camFP,ATON.AudioHub._listener&&h._camera.children.length<1&&h._camera.add(ATON.AudioHub._listener),h._updCamera(),h._controls.update(),h._currPOV&&h.syncCurrCamera(),ATON._onResize(),ATON.toggleCenteredQuery(!1),ATON.fireEvent("NavMode",h._mode)}},setDeviceOrientationControl:()=>{ATON.Utils.isMobile()&&(h._prevMode=h._mode,h._mode=h.MODE_DEVORI,h._bInteracting=!1,ATON.fireEvent("NavInteraction",!1),ATON._screenPointerCoords.set(0,0),void 0===h._cDevOri&&(h._camDevOri=new THREE.PerspectiveCamera(h.STD_FOV,window.innerWidth/window.innerHeight,h.STD_NEAR,h.STD_FAR),h._camDevOri.layers.enableAll(),h._cDevOri=new p(h._camDevOri,ATON._renderer.domElement),h._cDevOri.alphaOffset=0),h._controls=h._cDevOri,h._camera=h._camDevOri,ATON.AudioHub._listener&&h._camera.children.length<1&&h._camera.add(ATON.AudioHub._listener),h._updCamera(),h._controls.update(),h._currPOV&&h.syncCurrCamera(),ATON._onResize(),ATON.toggleCenteredQuery(!0),ATON.fireEvent("NavMode",h._mode))},useAbsoluteOrientation:e=>{h._cDevOri},setMotionAmount:e=>{h._motionAmt=e},setMotionDirection:e=>{h._motionDir.copy(e)},stop:()=>{h._motionAmt=0},setFOV:e=>{if(ATON.XR.isPresenting())return;h._currPOV.fov=e;let t=h._camera;t.fov=e,t.updateProjectionMatrix()},getFOV:()=>h._currPOV.fov,_deltaMotions:()=>{h._dOri=h._lastOri.angleTo(ATON.Nav._qOri),h._dPos=h._lastPos.distanceToSquared(h._currPOV.pos),h._lastPos.copy(h._currPOV.pos),h._lastOri.copy(ATON.Nav._qOri)},syncCurrPOV:()=>{if(ATON.XR.isPresenting()){const e=ATON._renderer.xr.getCamera().cameras[0];return h._currPOV.pos.copy(e.position),h._qOri.copy(e.quaternion),e.getWorldDirection(h._vDir),h._currPOV.pos.x+=ATON.XR.rig.position.x,h._currPOV.pos.y+=ATON.XR.rig.position.y,h._currPOV.pos.z+=ATON.XR.rig.position.z,void h._deltaMotions()}const e=h._controls,t=h._camera;if(t.getWorldDirection(h._vDir),t.getWorldQuaternion(h._qOri),h._deltaMotions(),h._mode!==h.MODE_DEVORI){if(h._mode===h.MODE_FP)return h._currPOV.pos.copy(e.target),h._currPOV.target.x=h._currPOV.pos.x+h._vDir.x,h._currPOV.target.y=h._currPOV.pos.y+h._vDir.y,void(h._currPOV.target.z=h._currPOV.pos.z+h._vDir.z);h._currPOV.pos.copy(t.position),h._currPOV.target.copy(e.target)}else h._currPOV.pos.copy(t.position)},applyPOVconstraints:e=>{},handlePOV:()=>{ATON.XR.isPresenting()?h.handleXRtransition():h.handlePOVtransition(),h.handleMotion(),h.applyPOVconstraints(h._currPOV)},handleMotion:()=>{if(h.isTransitioning())return;if(0==h._motionAmt)return;ATON.XR.controller0&&ATON.XR.controller0.visible?(ATON.XR.controller0.getWorldDirection(h._motionDir),h._motionDir.negate()):h._motionDir.copy(h._vDir);let e=h._motionAmt*ATON._dt,t=h._motionDir.x*e,o=h._motionDir.y*e,i=h._motionDir.z*e;h._currPOV.pos.x+=t,h._currPOV.pos.y+=o,h._currPOV.pos.z+=i,h._currPOV.target.x+=t,h._currPOV.target.y+=o,h._currPOV.target.z+=i},handlePOVtransition:()=>{if(!(h._tPOVcall<0)){if(h.POVtransitionDuration<=0?h._tPOVprogress=1:h._tPOVprogress=(ATON._clock.elapsedTime-h._tPOVcall)/h.POVtransitionDuration,h._tPOVprogress>=1)return h._tPOVcall=-1,h._currPOV.pos.copy(h._reqPOV.pos),h._currPOV.target.copy(h._reqPOV.target),h._currPOV.fov=h._reqPOV.fov,void ATON.fireEvent("POVTransitionCompleted",h._reqPOV.id);var e;h._tPOVprogress=(e=h._tPOVprogress,(1-Math.cos(e*Math.PI))/2),h._currPOV.pos.lerpVectors(h._fromPOV.pos,h._reqPOV.pos,h._tPOVprogress),h._currPOV.target.lerpVectors(h._fromPOV.target,h._reqPOV.target,h._tPOVprogress),h._fromPOV.fov&&h._reqPOV.fov&&(h._currPOV.fov=THREE.MathUtils.lerp(h._fromPOV.fov,h._reqPOV.fov,h._tPOVprogress),h._camera.fov=h._currPOV.fov,h._camera.updateProjectionMatrix())}},handleXRtransition:()=>{if(!(h._tPOVcall<0)){if(h.POVtransitionDuration<=0?h._tPOVprogress=1:h._tPOVprogress=(ATON._clock.elapsedTime-h._tPOVcall)/h.POVtransitionDuration,h._tPOVprogress>=1)return h._tPOVcall=-1,ATON.XR._currPos.copy(ATON.XR._reqPos),void ATON.fireEvent("POVTransitionCompleted",h._reqPOV.id);ATON.XR._currPos.lerpVectors(ATON.XR._fromPos,ATON.XR._reqPos,h._tPOVprogress)}},syncCurrCamera:()=>{if(ATON.XR.isPresenting())return;let e=h._controls,t=h._camera,o=h._currPOV.pos,i=h._currPOV.target;h._mode!==h.MODE_DEVORI?(h._vDir.subVectors(i,o),h._vDir.normalize(),h._mode===h.MODE_FP?(e.target.copy(o),t.position.x=e.target.x-h._vDir.x*h.FP_EPS,t.position.y=e.target.y-h._vDir.y*h.FP_EPS,t.position.z=e.target.z-h._vDir.z*h.FP_EPS):(t.position.copy(o),e.target.copy(i))):t.position.copy(o)},update:()=>{h.syncCurrPOV(),h.handlePOV(),h.syncCurrCamera()},requestPOV:(e,t,o)=>{ATON._tPOVcall>=0||void 0!==e&&(ATON.XR._bPresenting&&"immersive-ar"===ATON.XR._sessionType||(h.POVtransitionDuration=void 0!==t?t:h.STD_POV_TRANS_DURATION,ATON.XR.isPresenting()?(h._reqPOV.pos.copy(e.pos?e.pos:h._currPOV.pos),h._fromPOV.pos.copy(h._currPOV.pos),ATON.XR._reqPos.copy(e.pos?e.pos:h._currPOV.pos),ATON.XR._fromPos.copy(ATON.XR._currPos)):(h._reqPOV.pos.copy(e.pos?e.pos:h._currPOV.pos),h._reqPOV.target.copy(e.target?e.target:h._currPOV.target),h._reqPOV.fov=e.fov?e.fov:h._currPOV.fov,h._fromPOV.pos.copy(h._currPOV.pos),h._fromPOV.target.copy(h._currPOV.target),h._fromPOV.fov=h._currPOV.fov),o&&(e.pos&&(h._reqPOV.pos.x*=ATON._worldScale,h._reqPOV.pos.y*=ATON._worldScale,h._reqPOV.pos.z*=ATON._worldScale,ATON.XR.isPresenting()&&(ATON.XR._reqPos.x*=ATON._worldScale,ATON.XR._reqPos.y*=ATON._worldScale,ATON.XR._reqPos.z*=ATON._worldScale)),e.target&&(h._reqPOV.target.x*=ATON._worldScale,h._reqPOV.target.y*=ATON._worldScale,h._reqPOV.target.z*=ATON._worldScale)),h._tPOVcall=ATON._clock.elapsedTime,ATON.fireEvent("POVTransitionRequested",e.id)))},requestPOVbyBound:(e,t)=>{if(void 0===e)return;let o=new THREE.Vector3,i=3*e.radius;o.x=e.center.x-i*h._vDir.x,o.y=e.center.y-i*h._vDir.y,o.z=e.center.z-i*h._vDir.z;let r=(new ATON.POV).setPosition(o).setTarget(e.center);h.requestPOV(r,t)},requestPOVbyNode:(e,t)=>{if(void 0===e)return;let o=e.getBound();h.requestPOVbyBound(o,t)},requestPOVbyID:(e,t)=>{if(void 0===e)return;let o=h.povlist[e];void 0!==o&&h.requestPOV(o,t)},requestRetarget:(e,t,o)=>{let i=new THREE.Vector3;if(void 0===t)i.lerpVectors(e,h._currPOV.pos,.8);else{let o=e.distanceTo(h._currPOV.pos);o*=.5,i.x=e.x+t.x*o,i.y=e.y+t.y*o,i.z=e.z+t.z*o}let r=e.distanceTo(i);ATON.FX.setDOFfocus(r);let a=(new ATON.POV).setPosition(i).setTarget(e).setFOV(h._currPOV.fov);h.requestPOV(a,o),console.log(a)},computeDefaultHome:(e,t)=>{void 0===e&&(e=new THREE.Vector3(1,.7,1)),void 0===t&&(t=ATON.getRootScene().getBound());let o=new THREE.Vector3(t.center.x+t.radius*e.x*1.5,t.center.y+t.radius*e.y*1.5,t.center.z+t.radius*e.z*1.5);h.homePOV=(new ATON.POV).setPosition(o).setTarget(t.center)},setHomePOV:e=>{h.homePOV=e},computeAndRequestDefaultHome:(e,t,o)=>{h.computeDefaultHome(t,o),h.requestPOV(h.homePOV,e)},requestHomePOV:e=>{h.requestPOV(h.homePOV,e)}};h.requestHome=h.requestHomePOV,h.setAndRequestHomePOV=(e,t)=>{h.setHomePOV(e),h.requestPOV(e,t)},h.clear=()=>{h.clearPOVs(),h.clearLocomotionNodes()},h.DeviceOrientationControls=function(e){let t=this;this.object=e,this.object.rotation.reorder("YXZ"),this.enabled=!0,this.deviceOrientation={},this.screenOrientation=0,this.alphaOffset=0,this.absolute=!1,this.alphaOffsetDevice=void 0,this.alphaOffsetScreen=void 0;let o=function(e){t.absolute||(t.deviceOrientation=e)},i=function(e){t.deviceOrientation=e,t.absolute=!0},r=function(){t.screenOrientation=window.orientation||0},a=function(){let e=new THREE.Vector3(0,0,1),t=new THREE.Euler,o=new THREE.Quaternion,i=new THREE.Quaternion(-Math.sqrt(.5),0,0,Math.sqrt(.5));return function(r,a,s,n,l){t.set(s,a,-n,"YXZ"),r.setFromEuler(t),r.multiply(i),r.multiply(o.setFromAxisAngle(e,-l))}}();this.connect=function(){r(),window.addEventListener("orientationchange",r,!1),window.addEventListener("deviceorientation",o,!1),window.addEventListener("deviceorientationabsolute",i,!1),t.enabled=!0},this.disconnect=function(){window.removeEventListener("orientationchange",r,!1),window.removeEventListener("deviceorientation",o,!1),window.removeEventListener("deviceorientationabsolute",i,!1),t.enabled=!1},this.update=function(){if(!1===t.enabled)return;let e;if(e=t.deviceOrientation,e){let o=this.getDirection()?THREE.Math.degToRad(this.getDirection())+t.alphaOffset:0,i=e.beta?THREE.Math.degToRad(e.beta):0,r=e.gamma?THREE.Math.degToRad(e.gamma):0,s=t.screenOrientation?THREE.Math.degToRad(t.screenOrientation):0;a(t.object.quaternion,o,i,r,s)}},this.dispose=()=>{t.disconnect()},this.iOSOrientationPermission=()=>{"function"==typeof DeviceOrientationEvent.requestPermission&&DeviceOrientationEvent.requestPermission().then((e=>{console.log(e)})).catch(console.error)},this.getDirection=()=>void 0!==t.deviceOrientation.webkitCompassHeading?t.deviceOrientation.webkitCompassHeading:t.deviceOrientation.alpha,this.getDirectionMap=()=>void 0!==t.deviceOrientation.webkitCompassHeading?360-t.deviceOrientation.webkitCompassHeading:t.deviceOrientation.alpha,this.connect()};const m=h;let v={STD_TELEP_DURATION:.03,HAND_R:0,HAND_L:1,MOBILE_DENSITY_F:.5,MAX_QUERY_DISTANCE:40,init:()=>{ATON._renderer.xr.enabled=!0,ATON._renderer.xr.setReferenceSpaceType("local"),ATON.device.isMobile?ATON._renderer.xr.setFramebufferScaleFactor(ATON._stdpxd*v.MOBILE_DENSITY_F):ATON._renderer.xr.setFramebufferScaleFactor(ATON._stdpxd),v._bPresenting=!1,v.currSession=null,v._sessionType="immersive-vr",v._bReqPresenting=!1,v.rig=new THREE.Group,v.rig.add(ATON.Nav._camera),ATON._rootUI.add(v.rig),v._cam=void 0,v._currPos=v.rig.position,v._fromPos=new THREE.Vector3,v._reqPos=new THREE.Vector3,v.gControllers=void 0,v.controller0=void 0,v.controller1=void 0,v.controller0pos=new THREE.Vector3,v.controller1pos=new THREE.Vector3,v.controller0dir=new THREE.Vector3,v.controller1dir=new THREE.Vector3,v._lastPosR=void 0,v._lastPosL=void 0,v._pointerLineGeom=void 0,v._pointerLineMesh=void 0,v.gpad0=void 0,v.gpad1=void 0,v._urlHand=ATON.PATH_RES+"models/hand/hand.glb",ATON.on("XRselectStart",(e=>{e===v.HAND_R&&ATON._stdActivation()})),ATON.on("XRselectEnd",(e=>{})),ATON.on("XRsqueezeStart",(e=>{e===v.HAND_R&&ATON.Photon.setFocusStreaming(!0)})),ATON.on("XRsqueezeEnd",(e=>{e===v.HAND_R&&ATON.Photon.setFocusStreaming(!1)})),ATON.on("VRC_IDassigned",(e=>{let t=ATON.getUINode("Rhand"),o=ATON.getUINode("Lhand"),i=ATON.MatHub.materials.avatars,r=i[e%i.length];o&&o.setMaterial(r),t&&t.setMaterial(r)}))},setSessionType:e=>{void 0!==e&&("immersive-vr"!==e&&"immersive-ar"!==e||(v._sessionType=e,console.log("Session type: "+e)))},isPresenting:()=>v._bPresenting,teleportOnQueriedPoint:()=>{if(!ATON.Nav.currentQueryValidForLocomotion())return!1;const e=ATON._queryDataScene.p;return ATON.Nav.requestPOV((new ATON.POV).setPosition(e.x,e.y+ATON.userHeight,e.z),v.STD_TELEP_DURATION),!0},setupQueryRay:e=>{void 0!==e&&(v.controller0?e.set(v.controller0pos,v.controller0dir):e.set(ATON.Nav.getCurrentEyeLocation(),ATON.Nav.getCurrentDirection()))},setRefSpaceLocation:e=>{v.rig.position.copy(e)},_setupControllerR:(e,t)=>{v.controller0||(v.controller0=e,console.log("R controller"),e.addEventListener("selectstart",(()=>{ATON.fireEvent("XRselectStart",v.HAND_R)})),e.addEventListener("selectend",(()=>{ATON.fireEvent("XRselectEnd",v.HAND_R)})),e.addEventListener("squeezestart",(()=>{ATON.fireEvent("XRsqueezeStart",v.HAND_R)})),e.addEventListener("squeezeend",(()=>{ATON.fireEvent("XRsqueezeEnd",v.HAND_R)})),v.setupControllerUI(v.HAND_R,t),ATON.fireEvent("XRcontrollerConnected",v.HAND_R))},_setupControllerL:(e,t)=>{v.controller1||(v.controller1=e,console.log("L controller"),e.addEventListener("selectstart",(()=>{ATON.fireEvent("XRselectStart",v.HAND_L)})),e.addEventListener("selectend",(()=>{ATON.fireEvent("XRselectEnd",v.HAND_L)})),e.addEventListener("squeezestart",(()=>{ATON.fireEvent("XRsqueezeStart",v.HAND_L)})),e.addEventListener("squeezeend",(()=>{ATON.fireEvent("XRsqueezeEnd",v.HAND_L)})),v.setupControllerUI(v.HAND_L,t),ATON.fireEvent("XRcontrollerConnected",v.HAND_L))},setupSceneForAR:()=>{if("immersive-ar"!==v._sessionType)return;ATON.recomputeSceneBounds();let e=ATON.bounds.center;ATON._rootVisible.position.x=-e.x,ATON._rootVisible.position.y=-e.y,ATON._rootVisible.position.z=-e.z,ATON._rootSem.position.x=-e.x,ATON._rootSem.position.y=-e.y,ATON._rootSem.position.z=-e.z,ATON.recomputeSceneBounds()},resetSceneOffsets:()=>{ATON._rootVisible.position.set(0,0,0),ATON._rootSem.position.set(0,0,0),ATON.recomputeSceneBounds()},onSessionStarted:e=>{v.currSession||(v._bReqPresenting=!1,e.addEventListener("end",v.onSessionEnded),e.isImmersive=!0,console.log(v._sessionType+" session started."),ATON.MediaFlow.stopAllStreams(),"immersive-ar"===v._sessionType&&ATON._renderer.xr.setReferenceSpaceType("local"),ATON._renderer.xr.setSession(e).then((()=>{if(v.currSession=e,console.log(v.currSession),"immersive-ar"===v._sessionType)ATON._mainRoot.background=null,ATON._mMainPano&&(ATON._mMainPano.visible=!1),ATON._renderer.xr.getController(0)&&ATON.device.isMobile&&(v.controller0=ATON._renderer.xr.getController(0),v.controller0.addEventListener("selectstart",(()=>{ATON.fireEvent("XRselectStart",v.HAND_R),console.log("Head-aligned select")})),v.controller0.addEventListener("selectend",(()=>{ATON.fireEvent("XRselectEnd",v.HAND_R)})),v.gControllers.add(v.controller0));else{for(let e=0;e<2;e++){const t=ATON._renderer.xr.getController(e);void 0===t||t.userData.bXRconfig||(t.visible=!1,t.userData.bXRconfig=!0,t.addEventListener("connected",(e=>{let o=e.data.handedness;t.gm=e.data.gamepad,console.log("Hand "+o),console.log("GamePad "+t.gm),"left"===o?v._setupControllerL(t,!0):"right"===o?v._setupControllerR(t,!0):(t.addEventListener("selectstart",(()=>{ATON.fireEvent("XRselectStart",v.HAND_R),console.log("Head-aligned select")})),t.addEventListener("selectend",(()=>{ATON.fireEvent("XRselectEnd",v.HAND_R)})),ATON.fireEvent("XRcontrollerConnected",v.HAND_R))})))}v.rig.add(ATON.Nav._camera),v.setRefSpaceLocation(ATON.Nav._currPOV.pos)}let t=ATON._renderer.xr.getCamera(ATON.Nav._camera);ATON.Nav._updCamera(t),v._bPresenting=!0,ATON.Nav._bInteracting=!1,console.log("XR now presenting"),ATON.fireEvent("XRmode",!0),ATON.toggleShadows(!1),ATON.SUI.getSelectorRadius()>ATON.FE.STD_SEL_RAD&&ATON.SUI.setSelectorRadius(ATON.FE.STD_SEL_RAD),ATON._qSyncInt=2,ATON.XPFNetwork.getNumXPFs()>0?ATON.setQueryRange(0,100):ATON.setQueryRange(0,v.MAX_QUERY_DISTANCE),ATON.MRes.estimateTSErrorTarget(),setTimeout((()=>{ATON.SUI.getSelectorRadius()>ATON.FE.STD_SEL_RAD&&ATON.SUI.setSelectorRadius(ATON.FE.STD_SEL_RAD)}),2e3)})))},onSessionEnded:()=>{v.currSession.removeEventListener("end",v.onSessionEnded),v.currSession=null,v._bReqPresenting=!1,v._bPresenting=!1,ATON.Nav._bInteracting=!1,"immersive-ar"===v._sessionType&&ATON._mMainPano&&(ATON._mMainPano.visible=!0),v.setRefSpaceLocation(new THREE.Vector3(0,0,0)),ATON.fireEvent("XRmode",!1),ATON._qSyncInt=1,ATON.MediaFlow.stopAllStreams(),ATON.Nav.requestHome(),ATON.Nav._updCamera(),ATON.setQueryRange(0,1/0),ATON.MRes.estimateTSErrorTarget(),console.log("Quit XR")},toggle:e=>{if(v.setSessionType(e),ATON.device.xrSupported[v._sessionType])if(null===v.currSession){let e={optionalFeatures:["high-refresh-rate"]};"immersive-ar"===v._sessionType&&(void 0===e.optionalFeatures&&(e.optionalFeatures=[]),e.optionalFeatures.push("light-estimation")),v._bReqPresenting=!0,navigator.xr.requestSession(v._sessionType,e).then(v.onSessionStarted)}else v.currSession.end()},setupControllerUI:(e,t)=>{let o,i;if(void 0===v.gControllers&&(v.gControllers=ATON.createUINode(),v.gControllers.disablePicking(),v.rig.add(v.gControllers)),e===v.HAND_L?(v.gControllers.add(v.controller1),t&&(i=ATON.createUINode("Lhand").load(v._urlHand).setMaterial(ATON.MatHub.materials.controllerRay).setScale(-1,1,1),v.controller1.add(i))):(v.gControllers.add(v.controller0),t&&(v._pointerLineGeom=new THREE.CylinderGeometry(.003,.003,1,4),v._pointerLineGeom.rotateX(-Math.PI/2),v._pointerLineGeom.translate(0,0,-.5),v._pointerLineMesh=new THREE.Mesh(v._pointerLineGeom,ATON.MatHub.materials.controllerRay),v.controller0.add(v._pointerLineMesh),v._pointerLineMesh.visible=!1,o=ATON.createUINode("Rhand").load(v._urlHand).setMaterial(ATON.MatHub.materials.controllerRay),v.controller0.add(o))),void 0!==ATON.Photon.uid&&t){let t=ATON.MatHub.materials.avatars,r=t[ATON.Photon.uid%t.length];e===v.HAND_L?i.setMaterial(r):o.setMaterial(r)}},switchHands:()=>{let e=v.controller1;v.controller1=v.controller0,v.controller0=e;for(let e in v.controller0.children)v.controller0.remove(v.controller0.children[e]);for(let e in v.controller1.children)v.controller1.remove(v.controller1.children[e]);v.gControllers.removeChildren(),v.setupControllerUI(v.HAND_L),v.setupControllerUI(v.HAND_R),console.log("VR controllers switched")},getControllerSpace:e=>{1===e?v.getControllerGrip(1):v.getControllerGrip(0)},getControllerWorldLocation:e=>1===e?v.controller1pos:v.controller0pos,getControllerWorldDirection:e=>1===e?v.controller1dir:v.controller0dir,_deltaMotionController:e=>{if(e===v.HAND_L&&void 0===v._lastPosL)return;if(e===v.HAND_R&&void 0===v._lastPosR)return;let t=e===v.HAND_L?v.controller1pos:v.controller0pos,o=e===v.HAND_L?v._lastPosL:v._lastPosR;THREE.Vector3(t.x-o.x,t.y-o.y,t.z-o.z).lengthSq(),e===v.HAND_L?v._lastPosL=t:v._lastPosR=t},update:()=>{v.controller0&&v.controller0.visible&&(v.controller0.getWorldPosition(v.controller0pos),v.controller0.getWorldDirection(v.controller0dir),v.controller0dir.negate()),v.controller1&&v.controller1.visible&&(v.controller1.getWorldPosition(v.controller1pos),v.controller1.getWorldDirection(v.controller1dir),v.controller1dir.negate())},getAxisValue:e=>{let t=new THREE.Vector2(0,0),o=e===v.HAND_L?v.controller1:v.controller0;if(void 0===o)return t;if(void 0===o.gm||void 0===o.gm.axes)return t;let i=o.gm.axes[0],r=o.gm.axes[2],a=o.gm.axes[1],s=o.gm.axes[3];return t.x=i>0?-i:r,t.y=a>0?a:-s,t}};const T=v,g=class extends t{constructor(e,t,o){super(e,ATON.NTYPES.UI),this.baseColor=ATON.MatHub.colors.black,this.baseOpacity=.5,this.container=new ThreeMeshUI.Block({width:t||.2,height:o||.05,padding:.001,borderRadius:.01,backgroundColor:this.baseColor,backgroundOpacity:this.baseOpacity,fontFamily:ATON.SUI.PATH_FONT_JSON,fontTexture:ATON.SUI.PATH_FONT_TEX,justifyContent:"center",textAlign:"center"}),this.container.position.z=.03,this.add(this.container),this.uiText=new ThreeMeshUI.Text({content:"Label",fontSize:.03,fontColor:ATON.MatHub.colors.white}),this.container.add(this.uiText),ThreeMeshUI.update()}setBaseColor(e){return this.baseColor=e,this.container.set({backgroundColor:this.baseColor}),ThreeMeshUI.update(),this}setTextColor(e){return this.uiText.set({fontColor:e}),ThreeMeshUI.update(),this}setBackgroundOpacity(e){return this.container.set({backgroundOpacity:e}),this.baseOpacity=e,ThreeMeshUI.update(),this}setText(e){return this.uiText.set({content:e}),ThreeMeshUI.update(),this}};let S={STD_BTN_SIZE:.1,STD_SELECTOR_TICKNESS:1.05};S.Button=class extends t{constructor(e,t=1,o=1){super(e,ATON.NTYPES.UI),this.baseColor=ATON.MatHub.colors.black,this.switchColor=ATON.MatHub.colors.green,this.baseOpacity=.5,this.hoverOpacity=.8,this._bSwitched=!1,this.container=new ThreeMeshUI.Block({width:.1*t,height:.1,padding:.01,borderRadius:.02,backgroundColor:this.baseColor,backgroundOpacity:this.baseOpacity,fontFamily:ATON.SUI.PATH_FONT_JSON,fontTexture:ATON.SUI.PATH_FONT_TEX,justifyContent:"center",textAlign:"center"}),this.add(this.container),this.uiText=new ThreeMeshUI.Text({content:"",fontSize:.02*o,fontColor:ATON.MatHub.colors.white}),this.container.add(this.uiText);let i=.9*ATON.SUI.STD_BTN_SIZE*t,r=.9*ATON.SUI.STD_BTN_SIZE;this._trigger=new THREE.Mesh(new THREE.PlaneGeometry(i,r,2),ATON.MatHub.materials.fullyTransparent),this._trigger.position.set(0,0,.002),this.add(this._trigger),this.onHover=()=>{this.container.set({backgroundOpacity:this.hoverOpacity})},this.onLeave=()=>{this.container.set({backgroundOpacity:this.baseOpacity})},this.enablePicking(),this.traverse((e=>{e.material&&(e.material.depthWrite=!1)})),ThreeMeshUI.update()}setBaseColor(e){return this.baseColor=e,this._bSwitched||this.container.set({backgroundColor:this.baseColor}),ThreeMeshUI.update(),this}setSwitchColor(e){return this.switchColor=e,this._bSwitched&&this.container.set({backgroundColor:this.switchColor}),ThreeMeshUI.update(),this}setBackgroundOpacity(e){return this.container.set({backgroundOpacity:e}),this.baseOpacity=e,ThreeMeshUI.update(),this}setText(e){return this.uiText.set({content:e}),ThreeMeshUI.update(),this}switch(e){return this._bSwitched=e,e?this.container.set({backgroundColor:this.switchColor}):this.container.set({backgroundColor:this.baseColor}),ThreeMeshUI.update(),this}setIcon(e,t){return ATON.Utils.textureLoader.load(e,(e=>{this._trigger.material=new THREE.MeshStandardMaterial({map:e,transparent:!0,depthWrite:!1}),t&&(this.setBackgroundOpacity(0),this.hoverOpacity=0),this.uiText.position.set(0,-.035,0)})),ThreeMeshUI.update(),this}},S.Label=g,S.MediaPanel=class extends t{constructor(e){super(e,ATON.NTYPES.UI),this._resurl=void 0,this._mediamesh=void 0,this._vs=void 0,this._yratio=1,this._titleYoffs=.6,this._color=ATON.MatHub.colors.black;let t=this;this.onSelect=()=>{t._vs&&t._vs.el}}load(e,t){this._yratio=1,this._mediamesh||(this._mediamesh=new THREE.Mesh(new THREE.PlaneGeometry(1,1)),this.add(this._mediamesh)),e=ATON.Utils.resolveCollectionURL(e);let o=this;return ATON.Utils.isVideo(e)?(this._vs=ATON.MediaFlow.getOrCreateVideoStream(this.nid,e,!1),this._mediamesh.material=this._vs.matStream,this._vs.el.addEventListener("loadedmetadata",(i=>{o._yratio=o._vs.el.videoHeight/o._vs.el.videoWidth,o._mediamesh.scale.y=-o._yratio,o._resurl=e,o._onContentLoad(),t&&t()}))):ATON.Utils.loadTexture(e,(i=>{i.image&&(this._yratio=i.image.height/i.image.width),o._mediamesh.scale.y=o._yratio,o._mediamesh.material=ATON.MatHub.materials.chromakey.clone(),o._mediamesh.material.uniforms.tBase.value=i,o._mediamesh.material.needsUpdate=!0,o._resurl=e,o._onContentLoad(),t&&t()})),this.setPickable(!0),this}setColor(e){return this._color=e,this._labelTitle&&this._labelTitle.setBaseColor(e),this._bd&&(this._bd.material.color=e),this}getMaterial(){return this._mediamesh.material}_onContentLoad(){this._labelTitle&&(this._labelTitle.position.y=this._yratio*this._titleYoffs),this._bd&&(this._bd.scale.y=1.05*this._yratio)}setTitle(e){return this._labelTitle||(this._labelTitle=new g(void 0,.5,.07),this._labelTitle.position.z=-.01,this._labelTitle.attachTo(this)),this._labelTitle.setText(e),this._labelTitle.setBaseColor(this._color),this}toggleTitle(e){return this._labelTitle?(this._labelTitle.toggle(e),this):this}setBackdrop(e){return this._bd=new THREE.Mesh(new THREE.PlaneGeometry(1,1)),this._bd.material=new THREE.MeshStandardMaterial({transparent:!0,side:THREE.DoubleSide,color:this._color,opacity:e||.5}),this._bd.scale.x=1.05,this._bd.scale.y=1.05*this._yratio,this._bd.position.z=-.005,this.add(this._bd),this}},S.init=()=>{S.initSelector(),S.fpTeleport=ATON.createUINode();let e=new THREE.CylinderGeometry(.4,.4,.9,32,1,!0),t=new THREE.Mesh(e,ATON.MatHub.getMaterial("teleportLoc"));t.renderOrder=100,S.fpTeleport.add(t),S.fpTeleport.disablePicking(),S.fpTeleport.visible=!1,ATON._rootUI.add(S.fpTeleport),S.PATH_FONT_JSON||(S.PATH_FONT_JSON=ATON.PATH_RES+"fonts/custom-msdf.json"),S.PATH_FONT_TEX||(S.PATH_FONT_TEX=ATON.PATH_RES+"fonts/custom.png"),S.gMeasures=ATON.createUINode(),S._prevMPoint=void 0,S._measLabels=[],ATON._rootUI.add(S.gMeasures);let o=(new THREE.BufferGeometry).setFromPoints([new THREE.Vector3,new THREE.Vector3]);S._measLine=new THREE.Line(o,ATON.MatHub.getMaterial("measurement")),S._measLine.visible=!1,ATON._rootUI.add(S._measLine),S.gPoints=ATON.createUINode(),ATON._rootUI.add(S.gPoints),S.gLocNodes=ATON.createUINode(),ATON._rootUI.add(S.gLocNodes),S.buildInfoNode(),S.bShowInfo=!0,S._labelScale=ATON.Utils.isMobile()?80:90,S._labelScaleVR=2,S.sprites={},S._sync=0},S.getOrCreateSpritePointEdit=()=>(S.sprites.pointEdit||(S.sprites.pointEdit=new THREE.SpriteMaterial({map:(new THREE.TextureLoader).load(ATON.PATH_RES+"sui-point.png"),color:ATON.MatHub.colors.orange,transparent:!0,opacity:1,depthTest:!1})),S.sprites.pointEdit),S.getOrCreateSpriteSemIcon=()=>(S.sprites.semIcon||(S.sprites.semIcon=new THREE.SpriteMaterial({map:(new THREE.TextureLoader).load(ATON.PATH_RES+"sui-sem.png"),transparent:!0,opacity:1,depthWrite:!1,depthTest:!1})),S.sprites.semIcon),S.getOrCreateSpriteLP=()=>(S.sprites.lp||(S.sprites.lp=new THREE.SpriteMaterial({map:(new THREE.TextureLoader).load(ATON.PATH_RES+"sui-lp.png"),transparent:!0,opacity:1,depthWrite:!1}),S.sprites.lp.sizeAttenuation=!1),S.sprites.lp),S.getOrCreateSpriteWalk=()=>(S.sprites.walk||(S.sprites.walk=new THREE.SpriteMaterial({map:(new THREE.TextureLoader).load(ATON.PATH_RES+"sui-walk.png"),transparent:!0,opacity:1,depthWrite:!1})),S.sprites.walk),S.initSelector=()=>{S.mainSelector=ATON.createUINode(),S._mSelectorSphere=new THREE.Mesh(ATON.Utils.geomUnitSphere,ATON.MatHub.getMaterial("selector")),S._mSelectorSphere.renderOrder=100,S.mainSelector.add(S._mSelectorSphere),S.mainSelector.disablePicking(),S.setSelectorRadius(.05),S.mainSelector.visible=!1,ATON._rootUI.add(S.mainSelector),S._selOffset=new THREE.Vector3,S._bShowSelector=!0},S.enableLPIcons=()=>{S.gLPIcons=ATON.createUINode(),S.gLPIcons.disablePicking(),ATON._rootUI.add(S.gLPIcons)},S.enableSemIcons=()=>{S.gSemIcons=ATON.createUINode(),S.gSemIcons.disablePicking(),ATON._rootUI.add(S.gSemIcons)},S.showSelector=e=>{S._bShowSelector=e},S.setSelectorRadius=e=>{S._selectorRad=e,S.mainSelector.scale.set(e,e,e)},S.setSelectorOffset=(e,t,o)=>{void 0!==e&&(S._selOffset.x=e),void 0!==t&&(S._selOffset.y=t),void 0!==o&&(S._selOffset.z=o);let i=ATON.getSceneQueriedPoint();void 0!==i&&(S.mainSelector.position.x=i.x+S._selOffset.x,S.mainSelector.position.y=i.y+S._selOffset.y,S.mainSelector.position.z=i.z+S._selOffset.z)},S.getSelectorRadius=()=>S._selectorRad,S.getSelectorLocation=()=>S.mainSelector.position,S.setSelectorModel=(e,t)=>{void 0!==e&&(S.mainSelector.removeChildren(),S.mainSelector.load(e).disablePicking(),t&&S.mainSelector.setMaterial(ATON.MatHub.getMaterial("selector")))},S.setSelectorColor=(e,t)=>{let o=ATON.MatHub.materials.selector;o.uniforms.tint.value=e,void 0!==t&&(o.uniforms.opacity.value=t)},S.addSemIcon=(e,t)=>{if(void 0===S.gSemIcons)return;let o=(new THREE.Box3).setFromObject(t),i=new THREE.Sphere;o.getBoundingSphere(i);let r=new THREE.Sprite(S.getOrCreateSpriteSemIcon());r.position.copy(i.center),r.scale.set(.8,.8,1),r.name=e,S.gSemIcons.add(r)},S.addLPIcon=e=>{if(void 0===S.gLPIcons)return;let t=e._near,o=new THREE.Sprite(S.getOrCreateSpriteLP());o.position.copy(e.pos),o.scale.set(.1,.1,.1);let i=new THREE.Mesh(ATON.Utils.geomUnitSphere,ATON.MatHub.materials.lp);i.scale.set(t,t,t),i.position.copy(e.pos),S.gLPIcons.add(o),S.gLPIcons.add(i)},S.setSemIconsOpacity=e=>{ATON.MatHub.spriteSemIcon.opacity=void 0===e?1:e},S.buildInfoNode=()=>{S.infoNode=ATON.createUINode(),S.infoNode.attachToRoot(),S.infoContainer=new ThreeMeshUI.Block({width:.2,height:.05,padding:.01,borderRadius:.02,backgroundColor:ATON.MatHub.colors.black,backgroundOpacity:.4,fontFamily:S.PATH_FONT_JSON,fontTexture:S.PATH_FONT_TEX,justifyContent:"center",textAlign:"center"}),S.infoContainer.position.y=.03,S.infoNode.add(S.infoContainer),S.infoNodeText=new ThreeMeshUI.Text({content:"Info",fontSize:.02,fontColor:ATON.MatHub.colors.white}),S.infoContainer.add(S.infoNodeText),ThreeMeshUI.update()},S.getInfoNode=()=>S.infoNode,S.setInfoNodeText=e=>{S.bShowInfo&&(S.infoNodeText.set({content:e}),ThreeMeshUI.update())},S.createToolbar=(e,t,o)=>{let i=ATON.createUINode(),r=e.length,a=.3*S.STD_BTN_SIZE,s=new ThreeMeshUI.Block({width:S.STD_BTN_SIZE*r*1.1+a,height:S.STD_BTN_SIZE+a,padding:.01,borderRadius:.02,backgroundColor:t||ATON.MatHub.colors.black,backgroundOpacity:void 0!==o?o:.3,fontFamily:S.PATH_FONT_JSON,fontTexture:S.PATH_FONT_TEX,justifyContent:"center",textAlign:"center"}),n=.5*r*S.STD_BTN_SIZE*1.1;n-=.5*S.STD_BTN_SIZE;for(let t=0;t{void 0===o&&(o=1),void 0===i&&(i=1);let r=ATON.createUINode(e),a=new THREE.Mesh(new THREE.PlaneGeometry(o,i,2),ATON.MatHub.materials.fullyTransparent);return r.add(a),void 0!==t&&ATON.Utils.textureLoader.load(t,(e=>{a.material=new THREE.MeshStandardMaterial({map:e,transparent:!0,depthWrite:!1,side:THREE.DoubleSide})})),r},S.createLayout=(e,t)=>{let o=e.children.length;for(let i=0;i{if(void 0===e)return;let t=.01,o=.001;if(void 0===S._prevMPoint){S._prevMPoint=e;let t=S._measLine.geometry.attributes.position.array;return t[0]=e.x,t[1]=e.y,void(t[2]=e.z)}S._measLine.visible=!1;let i=S._prevMPoint.distanceTo(e);t*=i,o*=i;let r=new THREE.Mesh(ATON.Utils.geomUnitCube,ATON.MatHub.getMaterial("measurement"));r.position.copy(S._prevMPoint),r.scale.set(t,t,t),S.gMeasures.add(r);let a=new THREE.Mesh(ATON.Utils.geomUnitCube,ATON.MatHub.getMaterial("measurement"));a.position.copy(e),a.scale.set(t,t,t),S.gMeasures.add(a);let s=2*i,n=(new THREE.BufferGeometry).setFromPoints([S._prevMPoint,e]);S.gMeasures.add(new THREE.Line(n,ATON.MatHub.getMaterial("measurement")));let l=new S.Label;l.setBaseColor(ATON.MatHub.colors.white).setTextColor(ATON.MatHub.colors.black),l.userData.vStart=new THREE.Vector3,l.userData.vEnd=new THREE.Vector3,l.userData.vStart.copy(S._prevMPoint),l.userData.vEnd.copy(e),l.userData.vSEdir=new THREE.Vector3,l.userData.vSEdir.x=l.userData.vStart.x-l.userData.vEnd.x,l.userData.vSEdir.y=l.userData.vStart.y-l.userData.vEnd.y,l.userData.vSEdir.z=l.userData.vStart.z-l.userData.vEnd.z,l.userData.vSEdir.normalize(),l.setPosition(.5*(S._prevMPoint.x+e.x),.5*(S._prevMPoint.y+e.y),.5*(S._prevMPoint.z+e.z)),l.setScale(s).setText(ATON.Utils.getHumanReadableDistance(i)),S.gMeasures.add(l),S._measLabels.push(l);let d={};return d.A=l.userData.vStart,d.B=l.userData.vEnd,S._prevMPoint=void 0,d},S.clearMeasurements=()=>{S.gMeasures.removeChildren(),S._measLabels=[]},S._updateMeasurements=()=>{if(!(S._measLabels.length<=0))for(let e in S._measLabels)S._measLabels[e].orientToCamera()},S.update=()=>{if(ATON.Nav.isTransitioning()||ATON._bPauseQuery)S.infoNode.visible=!1;else{if(S._prevMPoint){if(ATON._queryDataScene){let e=S._measLine.geometry.attributes.position.array;e[3]=ATON._queryDataScene.p.x,e[4]=ATON._queryDataScene.p.y,e[5]=ATON._queryDataScene.p.z,S._measLine.geometry.attributes.position.needsUpdate=!0}S._measLine.visible=!0}else S._measLine.visible=!1;if(ATON._queryDataScene&&!ATON.Nav._bInteracting?(S._bShowSelector&&(S.mainSelector.visible=!0),S.mainSelector.position.x=ATON._queryDataScene.p.x+S._selOffset.x,S.mainSelector.position.y=ATON._queryDataScene.p.y+S._selOffset.y,S.mainSelector.position.z=ATON._queryDataScene.p.z+S._selOffset.z):S.mainSelector.visible=!1,S.gSemIcons&&(ATON.Nav._bInteracting?S.gSemIcons.hide():void 0===ATON._hoveredSemNode&&S.gSemIcons.show()),ATON.Nav.isOrbit()&&!ATON.XR._bPresenting||!ATON.Nav.currentQueryValidForLocomotion()?S.fpTeleport.visible=!1:(S.fpTeleport.visible=!0,S.fpTeleport.position.copy(ATON._queryDataScene.p)),ATON.XR._pointerLineMesh){let e=0;ATON._queryDataScene&&(e=ATON._queryDataScene.d),ATON._queryDataUI&&(e<=0||ATON._queryDataUI.d0?(ATON.XR._pointerLineMesh.visible=!0,ATON.XR._pointerLineMesh.scale.set(1,1,e)):ATON.XR._pointerLineMesh.visible=!1}if(S._updateMeasurements(),ATON._queryDataSem)ATON.XR._bPresenting&&(S.bShowInfo&&(S.infoNode.visible=!0),ATON.XR.controller0?(S.infoNode.position.copy(ATON.XR.controller0pos),S.infoNode.position.x-=.1*ATON.XR.controller0dir.x,S.infoNode.position.y-=.1*ATON.XR.controller0dir.y,S.infoNode.position.z-=.1*ATON.XR.controller0dir.z,S.infoNode.setScale(1)):(S.infoNode.position.lerpVectors(ATON._queryDataSem.p,ATON.Nav._currPOV.pos,.1),S.infoNode.setScale(ATON._queryDataSem.d*S._labelScaleVR)),S.infoNode.orientToCamera()),ATON.Photon._bStreamFocus||(S.mainSelector.visible=!1);else if(ATON.XR._bPresenting&&S.bShowInfo&&ATON._queryDataScene&&void 0!==ATON.XPFNetwork._semCurr){S.infoNode.position.lerpVectors(ATON._queryDataScene.p,ATON.Nav._currPOV.pos,.5);const e=ATON._queryDataScene.d*(ATON.Nav._currPOV.fov/S._labelScale);S.infoNode.setScale(e),S.infoNode.orientToCamera(),S.infoNode.visible=!0}else S.infoNode.visible=!1;if(S.mainSelector.visible&&ATON.Photon._bStreamFocus){let e=S._selectorRad*(1+.2*Math.cos(10*ATON._clock.elapsedTime));S.mainSelector.scale.set(e,e,e);let t=ATON.getSceneFocalPoint();void 0!==t&&void 0!==ATON.plight&&(ATON.enablePointLight(),ATON.plight.position.copy(t),ATON.plight.distance=2*S._selectorRad)}}};const N=S;let O={init:()=>{window.bootstrap&&(O.PATH_RES_ICONS=ATON.PATH_RES+"icons/",O._bModal=!1,O._bSidePanel=!1,O._bSemL=!1,O._setupBase())},createElemementFromHTMLString:e=>{const t=document.createElement("div");return t.innerHTML=e,t.firstElementChild},onContextMenu:()=>!1,_setupBase:()=>{document.body.oncontextmenu=O.onContextMenu,document.body.setAttribute("data-bs-theme","dark"),O.elCenteredOverlay=O.createElemementFromHTMLString('\n
    \n
    Loading...
    \n
    \n\t'),document.body.append(O.elCenteredOverlay),O.hideCenteredOverlay(),O.elLabelCon=document.createElement("div"),O.elLabelCon.classList.add("aton-floating-label-container"),O.elLabel=document.createElement("div"),O.elLabel.classList.add("aton-floating-label"),O.elLabelCon.append(O.elLabel),document.body.prepend(O.elLabelCon),O.hideSemLabel(),O.elModal=O.createElemementFromHTMLString('\n \n\t'),O.modal=new bootstrap.Modal(O.elModal),document.body.append(O.elModal),O.elModalContent=document.getElementById("uiModalContent"),O.elSidePanel=O.createElemementFromHTMLString('\n
    \n\t'),O.sidepanel=new bootstrap.Offcanvas(O.elSidePanel),document.body.append(O.elSidePanel)},showCenteredOverlay:e=>{O.elCenteredOverlay.classList.add("d-flex"),O.elCenteredOverlay.classList.remove("d-none")},hideCenteredOverlay:()=>{O.elCenteredOverlay.classList.remove("d-flex"),O.elCenteredOverlay.classList.add("d-none")},showModal:e=>{if(e){if(O.elModalContent.innerHTML="",e.header){let t=document.createElement("div");t.classList.add("modal-header"),t.innerHTML="",O.elModalContent.append(t)}if(e.body){let t=document.createElement("div");t.classList.add("modal-body"),t.append(e.body),O.elModalContent.append(t)}if(e.footer){let t=document.createElement("div");t.classList.add("modal-footer"),t.append(e.footer),O.elModalContent.append(t)}O.modal.show(),O._bModal=!0}},hideModal:()=>{O.modal.hide(),O._bModal=!1},showSidePanel:e=>{if(e){if(O.elSidePanel.innerHTML="",e.header){let t=document.createElement("div");t.classList.add("offcanvas-header"),t.innerHTML="

    "+e.header+"

    ",O.elSidePanel.append(t)}if(e.body){let t=document.createElement("div");t.classList.add("offcanvas-body"),t.append(e.body),O.elSidePanel.append(t)}O.sidepanel.show(),O._bSidePanel=!0}},hideSidePanel:()=>{O.sidepanel.hide(),O._bSidePanel=!1},addBasicEvents:()=>{ATON.on("NodeRequestFired",(()=>{O.showCenteredOverlay()})),ATON.on("AllNodeRequestsCompleted",(()=>{O.hideCenteredOverlay()})),ATON.on("SemanticNodeHover",(e=>{let t=ATON.getSemanticNode(e);void 0!==t&&(O.showSemLabel(e),t.highlight(),$("canvas").css({cursor:"pointer"}),ATON.SUI.gSemIcons&&ATON.SUI.gSemIcons.hide())})),ATON.on("SemanticNodeLeave",(e=>{let t=ATON.getSemanticNode(e);void 0!==t&&(O.hideSemLabel(),t.restoreDefaultMaterial(),$("canvas").css({cursor:"grab"}),ATON.SUI.gSemIcons&&ATON.SUI.gSemIcons.show())})),ATON.on("SemanticMaskHover",(e=>{O.showSemLabel(e),$("canvas").css({cursor:"pointer"})})),ATON.on("SemanticMaskLeave",(e=>{O.hideSemLabel(),$("canvas").css({cursor:"grab"})})),ATON.addUpdateRoutine(O.update)},update:()=>{if(O._bSemL&&!ATON.XR._bPresenting){let e=.5*ATON._screenPointerCoords.x*window.innerWidth,t=.5*(1-ATON._screenPointerCoords.y)*window.innerHeight;t-=35,O.elLabel.style.transform="translate("+e+"px, "+t+"px)"}},showSemLabel:e=>{O.elLabel.innerHTML=e,O.elLabel.style.display="inline-block",O._bSemL=!0},hideSemLabel:()=>{O.elLabel.style.display="none",O._bSemL=!1},loadPartial:(e,t,o,i)=>{$.get(e,(e=>{t?o?$("#"+t).prepend(e):$("#"+t).append(e):o?$("body").prepend(e):$("body").append(e),i&&i()}))},resolveIconURL:e=>e.includes("/")?e:O.PATH_RES_ICONS+e+".png",createButton:e=>{let t=document.createElement("button");return t.classList.add("btn","aton-btn"),t.setAttribute("type","button"),e.variant&&t.classList.add("btn-"+e.variant),e.text&&(t.innerText=e.text),e.icon&&t.prepend(O.createElemementFromHTMLString("")),e.onpress&&(t.onclick=e.onpress),t},createTabsGroup:e=>{let t=ATON.Utils.generateID("tabgroup"),o=document.createElement("div"),i=document.createElement("ul");i.classList.add("nav","nav-justified","nav-tabs"),i.setAttribute("role","tablist");let r=document.createElement("div");r.classList.add("tab-content"),o.append(i),o.append(r);for(let o=0;o");let c,u=t+"-"+s,_=document.createElement("li");_.classList.add("nav-item"),_.setAttribute("role","presentation"),_.innerHTML=0===o?"":"",i.append(_),c=0===o?O.createElemementFromHTMLString("
    "):O.createElemementFromHTMLString("
    "),c.style.padding="10px 0px 10px 0px",c.append(n),r.append(c)}return o}};const A=O;let P={USER_STATE_FREQ:.25,REPLICATED_EVT:"EREP",THRES_STATE_POS:.01,THRES_STATE_ORI:.08};P.Avatar=class extends t{constructor(e){super(void 0,ATON.NTYPES.UI),this.userid=e,this.username=void 0,this.message="...",this.color=ATON.Photon.ucolors[this.userid%ATON.Photon.ucolors.length],this._auTalk=[],this._auTalk.push(new THREE.PositionalAudio(ATON.AudioHub._listener)),this._auTalk.push(new THREE.PositionalAudio(ATON.AudioHub._listener));for(let e=0;e<2;e++)this._auTalk[e].setRefDistance(30),this._auTalk[e].setLoop(!1),this.add(this._auTalk[e]);this._auTalki=0,this.bMuted=!1,this._bPlayingAudio=!1,this._blob=void 0,this._b64=void 0,this._tStateCall=-1,this._tProgress=0,this._tFocCall=-1,this._currFocusPos=new THREE.Vector3,this._tgtFocusPos=new THREE.Vector3,this._currState={position:new THREE.Vector3,quaternion:new THREE.Quaternion,scale:1},this._tgtState={position:new THREE.Vector3,quaternion:new THREE.Quaternion,scale:1},this.userlabelnode=void 0,this.mStream=void 0,this._elVStream=void 0,this.realize()}getColor(){return this.color}setTalkDistance(e){e>0&&this._auTalk.setRefDistance(e)}setMuted(e){this.bMuted=e}getAvatarMaterialByUID(e){let t=ATON.MatHub.materials.avatars;return t[e%t.length]}_buildLabel(){this.userlabelnode=ATON.createUINode(),this.labelcontainer=new ThreeMeshUI.Block({width:.7,height:.25,padding:.03,borderRadius:.05,backgroundColor:ATON.MatHub.colors.black,fontFamily:ATON.SUI.PATH_FONT_JSON,fontTexture:ATON.SUI.PATH_FONT_TEX,justifyContent:"center",textAlign:"center"}),this.userlabelnode.position.y=.4,this.userlabelnode.add(this.labelcontainer),this.usernametext=new ThreeMeshUI.Text({content:"User #"+this.userid,fontSize:.09,fontColor:this.color}),this.usernametext.position.y=0,this.usermessagetext=new ThreeMeshUI.Text({content:"\n...",fontSize:.03,fontColor:ATON.MatHub.colors.white}),this.usermessagetext.position.y=0,this.labelcontainer.add(this.usernametext),this.labelcontainer.add(this.usermessagetext),this.add(this.userlabelnode),ThreeMeshUI.update()}realizeStreamPanel(){let e=ATON.MediaFlow.getOrCreateVideoStream(this.userid,void 0,!0);this._elVStream=e.el;let t=new THREE.PlaneGeometry(1,1);this.mStream=new THREE.Mesh(t,e.matStream),this.mStream.position.y=1;let o=.5625;this.mStream.scale.y=-o,this.mStream.position.y=.8*o,this._elVStream.addEventListener("loadedmetadata",(e=>{o=this._elVStream.videoHeight/this._elVStream.videoWidth,this.mStream.scale.y=-o,this.mStream.position.y=.8*o}))}getStreamPanel(){return this.mStream}toggleStreamPanel(e){void 0!==this.mStream&&(this.mStream.visible=e)}realize(){let e=new THREE.SphereGeometry(.2,16,16);ATON.Photon.customAvatarMaterial?this.usermaterial=ATON.Photon.customAvatarMaterial():this.usermaterial=this.getAvatarMaterialByUID(this.userid);let t=new THREE.Mesh(e,this.usermaterial);this.usermeshnode=ATON.createUINode(),this.usermeshnode.add(t),this.usermeshnode.setMaterial(this.usermaterial),this.usermeshnode.setCloneOnLoadHit(!1),this.add(this.usermeshnode),this.userauinode=new THREE.Sprite(ATON.Photon.uspritemats[this.userid%ATON.Photon.uspritemats.length]),this.userauinode.position.set(0,0,0),this.userauinode.visible=!1,this.add(this.userauinode),this.userfpnode=new THREE.Sprite(ATON.Photon.ufocmats[this.userid%ATON.Photon.ufocmats.length]),this.userfpnode.position.set(0,0,0),this.userfpnode.visible=!1,void 0===ATON.Photon._focNodes[this.userid]&&(ATON.Photon._focNodes[this.userid]=this.userfpnode,ATON.Photon.focGroup.add(this.userfpnode)),this._buildLabel()}loadRepresentation(e){let t=this;return void 0!==t.usermeshnode.children[0]&&t.usermeshnode.remove(t.usermeshnode.children[0]),t.usermeshnode.load(e),this}setUsername(e){return void 0===this.userlabelnode||(this.username=e,this.usernametext.set({content:e}),ThreeMeshUI.update()),this}getUsername(){if(void 0!==this.userid)return void 0===this.username?"User #"+this.userid:this.username}setMessage(e){return void 0===this.userlabelnode||(this.message=e,this.usermessagetext.set({content:"\n"+e}),ThreeMeshUI.update()),this}setTalkVolume(e){if(void 0!==e)if(e>0){this.userauinode.visible=!0;let t=.1+.03*e;this.userauinode.scale.set(t,t,t)}else this.userauinode.visible=!1;else this.userauinode.visible=!1}hideFocalPoint(){this.userfpnode.visible=!1}requestFocus(e){if(void 0===e)return;if(this._tFocCall>=0)return;this._tFocCall=ATON._clock.elapsedTime,this._currFocusPos.copy(this.userfpnode.position);let t=this.scale.x*ATON._worldScale,o=parseFloat(e[0])*t,i=parseFloat(e[1])*t,r=parseFloat(e[2])*t,a=parseFloat(e[3])*t;this._tgtFocusPos.set(o,i,r),this._tgtFocusRad=2*a,this.userfpnode.scale.set(this._tgtFocusRad,this._tgtFocusRad,this._tgtFocusRad),this.userfpnode.visible=!0,ATON.enablePointLight(),ATON.plight.color=this.color,ATON.plight.position.copy(this._tgtFocusPos),ATON.plight.distance=this._tgtFocusRad}handleFocusTransition(){if(this._tFocCall<0)return;let e=ATON.Photon.USER_STATE_FREQ,t=(ATON._clock.elapsedTime-this._tFocCall)/e;if(t>=1)return this._tFocCall=-1,this.userfpnode.position.copy(this._tgtFocusPos),this.userfpnode.scale.set(this._tgtFocusRad,this._tgtFocusRad,this._tgtFocusRad),void(this.userfpnode.visible=!0);this.userfpnode.position.lerpVectors(this._currFocusPos,this._tgtFocusPos,t),ATON.plight.position.copy(this.userfpnode.position),this.userfpnode.visible=!0}requestStateTransition(e){this._tStateCall>=0||void 0!==e&&(this._tStateCall=ATON._clock.elapsedTime,this._currState.position.copy(this.position),this._currState.quaternion.copy(this.quaternion),this._currState.scale=this.scale,this._tgtState.position.copy(e.position),this._tgtState.quaternion.copy(e.quaternion),this._tgtState.scale=1/e.scale)}handleStateTransition(){if(this._tStateCall<0)return;let e=ATON.Photon.USER_STATE_FREQ;this._tProgress=e<=0?1:(ATON._clock.elapsedTime-this._tStateCall)/e;let t=this._currState,o=this._tgtState;if(this._tProgress>=1)return this._tStateCall=-1,this.position.copy(o.position),void this.usermeshnode.quaternion.copy(o.quaternion);this.position.lerpVectors(t.position,o.position,this._tProgress),this.usermeshnode.quaternion.slerp(o.quaternion,this._tProgress)}update(){if(this.handleStateTransition(),this.userfpnode&&this.userfpnode.visible){this.handleFocusTransition();let e=this.userfpnode.scale.x;e>.001?(this.userfpnode.scale.set(.99*e,.99*e,.99*e),ATON.plight.intensity*=.99):(this.userfpnode.visible=!1,ATON.disablePointLight())}let e=ATON.Nav._camera,t=ATON.Nav._currPOV.pos;if(void 0===e||void 0===t)return;this.userlabelnode&&this.userlabelnode.orientToCamera();let o=this.userauinode.scale.x;o*=.99,o>.01?this.userauinode.scale.set(o,o,o):this.userauinode.visible=!1}_handleTalk(){if(this._auTalk.isPlaying)return;if(this._auChunks.length<2)return;let e=this._auChunks[this._iAU];this._auTalk.setBuffer(e),this._auTalk.play(),this.setTalkVolume(5)}_handleTalkOLD(){if(this._bPlayingAudio)return;if(this._auChunks.length<1)return;let e=this._auChunks.shift();this._auTalk.setBuffer(e),this._auTalk.play(),this._bPlayingAudio=!0,this._auTalk.onended=()=>{this._bPlayingAudio=!1,e=null},this.setTalkVolume(5)}},P.init=()=>{P.address=window.location.origin,P.initMaterials(),P.socket=void 0,P._connected=!1,P._reqSSID=void 0,P._username=void 0,P.uid=void 0,P.color=ATON.MatHub.colors.white,P._bStreamFocus=!1,P._numUsers=1,P.avatarList=[],P.avaGroup=ATON.createUINode("avatars"),P.avaGroup.attachToRoot(),P.focGroup=ATON.createUINode("focus"),P.focGroup.attachTo(P.avaGroup),P._focNodes=[],P.bSendState=!0,window.setInterval(P.sendState,1e3*P.USER_STATE_FREQ),P._lastStateSent=void 0,P._bShowAvaG=!0,P._bSpatial=!0,console.log("Photon initialized"),P.enableChatLog(),P._elVStream=void 0,P._decS={quaternion:new THREE.Quaternion,position:new THREE.Vector3},P.customAvatarMaterial=void 0,window.addEventListener("beforeunload",(e=>{P.disconnect()}))},P.setCustomAvatarMaterialRoutine=e=>{P.customAvatarMaterial=e},P.enableChatLog=()=>{P._elChat=$("
    ").text("")},P.getNumUsers=()=>P._numUsers,P.initMaterials=()=>{P.ucolorhex=[],P.ucolorhex.push("#F00"),P.ucolorhex.push("#FF0"),P.ucolorhex.push("#0F0"),P.ucolorhex.push("#0FF"),P.ucolorhex.push("#00F"),P.ucolorhex.push("#F0F"),P.ucolorhex_light=[],P.ucolorhex_light.push("#FAA"),P.ucolorhex_light.push("#FFA"),P.ucolorhex_light.push("#AFA"),P.ucolorhex_light.push("#AFF"),P.ucolorhex_light.push("#AAF"),P.ucolorhex_light.push("#FAF"),P.ucolors=[],P.ucolors.push(new THREE.Color(P.ucolorhex[0])),P.ucolors.push(new THREE.Color(P.ucolorhex[1])),P.ucolors.push(new THREE.Color(P.ucolorhex[2])),P.ucolors.push(new THREE.Color(P.ucolorhex[3])),P.ucolors.push(new THREE.Color(P.ucolorhex[4])),P.ucolors.push(new THREE.Color(P.ucolorhex[5])),P.ucolorsdark=[],P.ucolorsdark.push(new THREE.Color(.2,0,0)),P.ucolorsdark.push(new THREE.Color(.2,.2,0)),P.ucolorsdark.push(new THREE.Color(0,.2,0)),P.ucolorsdark.push(new THREE.Color(0,.2,.2)),P.ucolorsdark.push(new THREE.Color(0,0,.2)),P.ucolorsdark.push(new THREE.Color(.2,0,.2));let e=ATON.MatHub.materials;e.avatars=[];for(let t=0;t{if(!P._connected)return;let o=P.socket;o&&o.emit(P.REPLICATED_EVT,{e,d:t})},P.on=(e,t)=>{if(void 0===t)return;let o=ATON.EventHub.evNetwork;void 0===o[e]&&(o[e]=[]),o[e].push(t)},P.isConnected=()=>void 0!==P.socket&&P._connected,P.hasID=()=>void 0!==P.uid,P.log=e=>{if(!P._connected)return;let t=P.socket;t&&t.emit("UMSG",e)},P.joinSession=e=>{P.socket&&(void 0===e&&(e=ATON.SceneHub.currID),void 0!==e?(console.log("Joining Photon session '"+e+"'..."),P.socket.emit("SENTER",e)):console.log("Photon ERROR: current session ID is undefined"))},P.requestSceneState=()=>{P.socket&&P.socket.emit("SSTATE")},P.setAvatarsVisibility=e=>{P._bShowAvaG=e,e?P.avaGroup.show():P.avaGroup.hide()},P.disableSpatiality=()=>{P._bSpatial=!1},P.enableSpatiality=()=>{P._bSpatial=!0},P.setAddress=e=>{e&&(P.address=e)},P.connect=e=>{if(P._connected)return;P._reqSSID=e;let t={};ATON.Utils.isConnectionSecure()?(t.path="/svrc/socket.io",t.secure=!0,t.rejectUnauthorized=!1):t.path="/vrc/socket.io",P.socket=io.connect(P.address,t),void 0!==P.socket&&(P._connected=P.socket.connected,P._registerSocketHandlers())},P.disconnect=()=>{void 0!==P.socket&&(P._numUsers=1,P.socket.disconnect(),P.color=ATON.MatHub.colors.white,ATON.plight.color=ATON.MatHub.colors.white,P._connected=!1)},P._onConnected=()=>{},P.setUsername=e=>{(e=e.trim()).length<1||(P._username=e,void 0!==P.socket&&void 0!==P.uid&&(P.appendToChatBox("Your username is now: "+e+""),P.socket.emit("UNAME",e)))},P.setMessage=e=>{(e=e.trim()).length<1||e.length>3e3||(P._msg=e,void 0!==P.socket&&void 0!==P.uid&&(P.socket.emit("UMSG",e),P._elChat&&(e=P.chatMessageProcessor(P.uid,e),P.appendToChatBox("
    YOU
    : "+e+""))))},P.appendToChatBox=e=>{P._elChat&&(P._elChat.append("
    "+e+"
    "),P._elChat.scrollTop(P._elChat[0].scrollHeight))},P._registerSocketHandlers=()=>{P.socket.on("connect",(()=>{P._connected=!0,void 0!==P._reqSSID?P.joinSession(P._reqSSID):P.joinSession(ATON.SceneHub.currID),console.log("Connected to Photon service!"),ATON.fireEvent("VRC_Connected"),P._onConnected()})),P.socket.on("disconnect",(()=>{P._connected=!1,P.uid=void 0,P.avaGroup.hide(),P.appendToChatBox("YOU disconnected from the Photon session"),console.log("Disconnected from Photon service!"),ATON.fireEvent("VRC_Disconnected")})),P.socket.on(P.REPLICATED_EVT,(e=>{let t=e.e,o=e.d,i=ATON.EventHub.evNetwork[t];ATON.EventHub.executeHandlers(i,o)})),P.socket.on("ID",(e=>{console.log("Your ID is "+e),P.uid=e,P.color=P.ucolors[P.uid%P.ucolors.length],P._bShowAvaG&&P.avaGroup.show(),P.appendToChatBox("Your ID is #"+e+""),P.requestSceneState(),ATON.fireEvent("VRC_IDassigned",e)})),P.socket.on("SSTATE",(e=>{P._numUsers=e.numUsers,console.log("Num. users: "+P._numUsers),ATON.fireEvent("VRC_SceneState",e)})),P.socket.on("UENTER",(e=>{let t=e;console.log("User #"+t+" entered the session"),P.appendToChatBox("User #"+t+" entered the session"),P.requestSceneState(),ATON.fireEvent("VRC_UserEnter",t)})),P.socket.on("ULEAVE",(e=>{let t=e;if(void 0===t)return;let o=P.avatarList[t];o&&(o.toggleStreamPanel(!1),o.hide()),console.log("User #"+t+" left the session"),P.appendToChatBox("User #"+t+" left the session"),P.requestSceneState(),ATON.fireEvent("VRC_UserLeave",t)})),P.socket.on("USTATE",(e=>{if(!P._bShowAvaG)return;if(!P._bSpatial)return;let t=P.decodeState(e),o=t.userid,i=P.touchAvatar(o);i.requestStateTransition(t);let r=1/t.scale;i.scale.set(r,r,r)})),P.socket.on("UFOCUS",(e=>{if(!P._bSpatial)return;let t=e.uid,o=e.fp;P.touchAvatar(t).requestFocus(o)})),P.socket.on("UNAME",(e=>{let t=e.uid,o=e.name;void 0!==t&&(P.touchAvatar(t).setUsername(o),console.log("User #"+t+" changed username to: "+o),P.appendToChatBox("User #"+t+" changed username to: "+o+""),ATON.fireEvent("VRC_UName",e))})),P.socket.on("UMSG",(e=>{let t=e.uid,o=e.msg;if(void 0===t)return;let i=P.touchAvatar(t);o.length<100&&i.setMessage(o),console.log("User #"+t+": "+o);let r=i.getUsername();o=P.chatMessageProcessor(t,o),P.ucolorhex[t%6];let a=P.ucolorhex_light[t%6];P.appendToChatBox("
    "+r+"
    : "+o+""),ATON.fireEvent("VRC_UMessage",e)})),P.socket.on("UTALK",(e=>{let t=e.uid;if(void 0===t)return;let o=e.audio;if(o){if(P._bSpatial){let e=P.touchAvatar(t);if(e.bMuted)return;ATON.AudioHub._loader.load(o,(t=>{let o=e._auTalk[e._auTalki],i=(e._auTalki+1)%2;o.setBuffer(t),o.isPlaying||o.play(),e.setTalkVolume(5),e._auTalki=i}))}ATON.fireEvent("VRC_UTalk",e),o=null}})),P.socket.on("UTALKSTOP",(e=>{void 0!==e.uid&&ATON.fireEvent("VRC_UTalkStop",e)})),P.socket.on("UVIDEO",(e=>{void 0!==e.uid&&ATON.fireEvent("VRC_UVideo",e)})),P.socket.on("UVIDEOSTOP",(e=>{let t=e.uid;if(void 0===t)return;let o=P.avatarList[t];o&&o.toggleStreamPanel(!1),ATON.fireEvent("VRC_UVideoStop",e)}))},P.chatMessageProcessor=(e,t)=>{const o=(t=String(t)).match(/(((ftp|https?):\/\/)[\-\w@:%_\+.~#?,&\/\/=]+)/g);return o&&o.forEach((e=>{t=t.replace(e,""+e+"")})),t},P.encodeState=e=>{if(!e)return;let t=new Float32Array(5);t[0]=e.position.x,t[1]=e.position.y,t[2]=e.position.z;var o=new Int8Array(t.buffer);return o[12]=128*e.quaternion.x,o[13]=128*e.quaternion.y,o[14]=128*e.quaternion.z,o[15]=128*e.quaternion.w,o[16]=e.userid,o[17]=ATON._ws,o},P.decodeState=e=>{let t=new Int8Array(e);P._decS.userid=t[16];let o=ATON._unpackScale(t[17]);return P._decS.scale=o,P._decS.quaternion.set(parseFloat(t[12])/128,parseFloat(t[13])/128,parseFloat(t[14])/128,parseFloat(t[15])/128),t=new Float32Array(e),P._decS.position.set(parseFloat(t[0])/o,parseFloat(t[1])/o,parseFloat(t[2])/o),P._decS},P.update=()=>{if(P._connected)for(let e=0;e{if(void 0!==e){if(e)return P._bStreamFocus||(ATON.fireEvent("VRC_FocusStreamingStarted"),ATON.enablePointLight(),ATON.plight.color=ATON.Photon.color),void(P._bStreamFocus=!0);{P._bStreamFocus&&(ATON.fireEvent("VRC_FocusStreamingStopped"),ATON.disablePointLight());let e=ATON.SUI._selectorRad;ATON.SUI.mainSelector.scale.set(e,e,e),P._bStreamFocus=!1}}},P.sendState=()=>{if(!P.bSendState||!P._bSpatial)return;if(void 0===P.uid)return;if(!P.socket||!P._connected)return;let e=ATON.Nav._currPOV;if(!e)return;let t=ATON.getSceneFocalPoint();if(P._bStreamFocus&&void 0!==t){let e=t.x.toFixed(3),o=t.y.toFixed(3),i=t.z.toFixed(3),r=ATON.SUI.getSelectorRadius().toFixed(3);P.socket.emit("UFOCUS",[e,o,i,r])}if(!e.pos)return;if(!ATON.Nav._qOri)return;if(void 0!==P._lastStateSent){let t=P._lastStateSent.position,o=P._lastStateSent.quaternion,i=t.distanceToSquared(e.pos),r=o.angleTo(ATON.Nav._qOri);if(iP.avatarList[e],P.touchAvatar=e=>{if(void 0===P.avatarList[e]){let t=new P.Avatar(e);t.attachTo(P.avaGroup),t.loadRepresentation(ATON.PATH_RES+"models/vrc/head.gltf"),P.avatarList[e]=t}let t=P.avatarList[e];return t.visible||ATON.fireEvent("VRC_UserEnter",e),P._bShowAvaG&&t.show(),t},P.destroyAvatar=e=>{let t=P.avatarList[e];void 0!==t&&t.destroy()},P.clearAllAvatars=()=>{for(let e in P.avatarList)P.avatarList[e].hide()};const b=P;let E={FLOAT_PREC:5,init:()=>{E.bConvexBuilding=!1,E.convexPoints=[],E.convexNode=void 0,E.currConvexMesh=void 0,E.currSemNode=ATON.createSemanticNode(),E.currSemNode.disablePicking(),E.currSemNode.attachToRoot(),E.resetMaterial(),E._numShapes=0},resetMaterial:()=>{E.currMaterial=ATON.MatHub.getMaterial("semanticShapeHL")},setMaterial:e=>{void 0!==e&&(E.currMaterial=e)},addConvexPoint:e=>{if(void 0===e)return!1;if(E.convexPoints.length>0){let t=E.convexPoints[E.convexPoints.length-1];if(e.equals(t))return!1}E.convexPoints.push(e);let t=E.convexPoints.length,o=new THREE.Sprite(ATON.SUI.getOrCreateSpritePointEdit()),i=.02*ATON.getSceneQueriedDistance();if(void 0===i&&(i=.02),o.position.copy(e),o.scale.set(i,i,i),ATON.SUI.gPoints.add(o),t<4)return!1;let r=new THREE.ConvexGeometry(E.convexPoints),a=new THREE.Mesh(r,ATON.MatHub.getMaterial("semanticShapeEdit"));if(E.bConvexBuilding){let t=E.currConvexMesh;t.geometry.dispose(),t.geometry=r,ATON.Utils.setVectorPrecision(e,4),t.userData._convexPoints.push(e.x),t.userData._convexPoints.push(e.y),t.userData._convexPoints.push(e.z)}else{E.currSemNode.add(a),a.userData._convexPoints=[];for(let e=0;e{if(0!==E.convexPoints.length&&(E.convexPoints.pop(),E.currConvexMesh)){let e=E.currConvexMesh.userData;e._convexPoints&&e._convexPoints.pop()}},stopCurrentConvex:()=>{E.bConvexBuilding&&(E.convexPoints=[],E.bConvexBuilding=!1,E.currSemNode.removeChildren(),ATON.SUI.gPoints.removeChildren())},getCurrentConvexShape:()=>E.currSemNode,isBuildingShape:()=>E.convexPoints.length>0,completeConvexShape:e=>{if(E.convexPoints=[],E.bConvexBuilding=!1,void 0===E.currSemNode)return;void 0===e&&(e="sem"+E._numShapes);let t=ATON.getSemanticNode(e)||ATON.createSemanticNode(e),o=E.currSemNode.children[0];return ATON.SUI.addSemIcon(e,o),t.add(o),t.setMaterial(ATON.MatHub.materials.semanticShape),t.setDefaultAndHighlightMaterials(ATON.MatHub.materials.semanticShape,E.currMaterial),t.enablePicking(),E.currSemNode.removeChildren(),E._numShapes++,ATON.SUI.gPoints.removeChildren(),ATON._bqSem=!0,t},createConvexShape:(e,t)=>{let o=new THREE.ConvexGeometry(t),i=new THREE.Mesh(o,ATON.MatHub.materials.semanticShape);i.userData._convexPoints=[];for(let e=0;e{if(void 0===ATON._queryDataScene)return!1;void 0===e&&(e=.02);let t=ATON._queryDataScene.p,o=ATON.Nav.getCurrentEyeLocation();return t.lerpVectors(t,o,e),E.addConvexPoint(t),t},createSphere:(e,t,o)=>{if(void 0===t)return;if(void 0===o)return;void 0===e&&(e="sem"+E._numShapes);let i=ATON.getOrCreateSemanticNode(e),r=new THREE.Mesh(ATON.Utils.geomUnitSphere,ATON.MatHub.materials.semanticShape),a=new THREE.Object3D;return a.position.copy(t),a.scale.set(o,o,o),a.add(r),ATON.SUI.addSemIcon(e,a),i.add(a),i.enablePicking(),i.setDefaultAndHighlightMaterials(ATON.MatHub.materials.semanticShape,E.currMaterial),E._numShapes++,ATON._bqSem=!0,i},createSurfaceSphere:e=>{if(!ATON._queryDataScene)return;let t=ATON._queryDataScene.p,o=ATON.SUI.getSelectorRadius();return E.createSphere(e,t,o)},deleteSemanticNode:e=>{let t=ATON.getSemanticNode(e);if(void 0===t)return!1;if(t.removeChildren(),void 0===ATON.SUI.gSemIcons)return!0;for(let t in ATON.SUI.gSemIcons.children){let o=ATON.SUI.gSemIcons.children[t];o&&o.name===e&&ATON.SUI.gSemIcons.removeChild(o)}return!0}};const f=E;let R={SEMSHAPE_SPHERE:0,SEMSHAPE_CONVEX:1,POPUP_DT:500,STD_SEL_RAD:.05,_bRealized:!1,realize:()=>{if(R._bRealized)return;R.PATH_RES_ICONS=ATON.PATH_RES+"icons/",R._bPopup=!1,R._tPopup=void 0,R.popupBlurBG=0,R._userAuth={},R._bControlLight=!1,R._bControlSelScale=!1,R._cLightDir=new THREE.Vector3,R._auSemNode=void 0,R._auSemNodePlaying=!1,R._bReqHome=!1,R._bVRCsetup=!1,R.urlParams=new URLSearchParams(window.location.search),R._uiSetupBase(),R._uiProfiles={},R._uiCurrProfile=void 0,R._selRanges=[.01,50],R._selRefRadius=.5,ATON.realize(),ATON.on("Fullscreen",(e=>{R.uiSwitchButton("fullscreen",e)}));let e=ATON.FE.urlParams.get("d");e&&e>0&&(ATON.setDefaultPixelDensity(e),ATON.toggleAdaptiveDensity(!1));let t=ATON.FE.urlParams.get("dd");t&&t>0&&ATON.toggleAdaptiveDensity(!0),R._canvas=ATON._renderer.domElement,R._bSem=!1,R._bShowSemLabel=!0,R._bRealized=!0,R.loadSceneID=ATON.App.loadScene},_handleHomeReq:()=>{R._bReqHome||ATON.getRootScene().getBound().radius<=0||(R._bReqHome=!0,void 0!==ATON.Nav.homePOV?ATON.Nav.requestHome(1):ATON.Nav.computeAndRequestDefaultHome(.5))},addBasicLoaderEvents:()=>{ATON.on("NodeRequestFired",(()=>{$("#idLoader").show()})),ATON.on("SceneJSONLoaded",(()=>{ATON.SceneHub.getDescription()&&$("#btn-info").show(),void 0!==ATON.Nav.homePOV&&ATON.Nav.requestHome(1),ATON.XPFNetwork._list.length>0&&void 0===ATON.Nav.homePOV&&(ATON.XPFNetwork.setHomeXPF(0),ATON.XPFNetwork.requestTransitionByIndex(0))})),ATON.on("AllNodeRequestsCompleted",(()=>{$("#idLoader").hide(),ATON.CC.anyCopyrightFound()&&$("#btn-cc").show(),R.computeSelectorRanges(),ATON.SUI.setSelectorRadius(Math.min(R.STD_SEL_RAD,R._selRefRadius)),R._handleHomeReq()})),ATON.on("XR_support",(e=>{"immersive-vr"===e.type&&(e.v?$("#btn-vr").show():$("#btn-vr").hide())})),ATON.on("SemanticNodeHover",(e=>{let t=ATON.getSemanticNode(e);void 0!==t&&(R.showSemLabel(e),R._bSem=!0,t.highlight(),$("canvas").css({cursor:"crosshair"}),ATON.SUI.gSemIcons&&ATON.SUI.gSemIcons.hide())})),ATON.on("SemanticNodeLeave",(e=>{let t=ATON.getSemanticNode(e);void 0!==t&&(R.hideSemLabel(),R._bSem=!1,t.restoreDefaultMaterial(),$("canvas").css({cursor:"grab"}),ATON.SUI.gSemIcons&&ATON.SUI.gSemIcons.show())})),ATON.on("SemanticMaskHover",(e=>{R.showSemLabel(e),R._bSem=!0,$("canvas").css({cursor:"crosshair"})})),ATON.on("SemanticMaskLeave",(e=>{R.hideSemLabel(),R._bSem=!1,$("canvas").css({cursor:"grab"})})),ATON.addUpdateRoutine(R._update)},showSemLabel:e=>{R._bShowSemLabel&&($("#idPopupLabel").html(e),$("#idPopupLabel").show(),ATON.SUI.setInfoNodeText(e))},hideSemLabel:()=>{$("#idPopupLabel").hide(),$("#idPopupLabel").html("")},controlLight:e=>{R._bControlLight=e,ATON.Nav.setUserControl(!e)},controlSelectorScale:e=>{R._bControlSelScale=e,ATON._bPauseQuery=e,ATON.Nav.setUserControl(!e)},attachGizmoToNode:e=>{if(void 0===ATON._gizmo)return;let t=ATON.getSceneNode(e);void 0!==t&&ATON._gizmo.attach(t)},useMouseWheelToScaleSelector:e=>{void 0===e&&(e=.9),ATON.on("MouseWheel",(t=>{if(ATON._kModCtrl){let e=ATON.Nav.getFOV();return t>0?e+=1:e-=1,void ATON.Nav.setFOV(e)}if(ATON._kModShift){let o=ATON.SUI.mainSelector.scale.x;return t>0?o*=e:o/=e,oR._selRanges[1]&&(o=R._selRanges[1]),void ATON.SUI.setSelectorRadius(o)}}))},_update:()=>{if(R._bControlLight){const e=ATON._screenPointerCoords.x,t=ATON._screenPointerCoords.y;R._cLightDir.x=-Math.cos(e*Math.PI),R._cLightDir.y=4*-t,R._cLightDir.z=-Math.sin(e*Math.PI),R._cLightDir.normalize(),ATON.setMainLightDirection(R._cLightDir)}if(ATON.XR._bPresenting){let e=ATON.XR.getAxisValue(ATON.XR.HAND_R);if(!ATON.Photon._bStreamFocus){let t=ATON.SUI._selectorRad;t+=.01*e.y,t>.001&&ATON.SUI.setSelectorRadius(t)}}else{if(ATON.Nav.isTransitioning()||ATON.Nav._bInteracting||ATON._bPauseQuery)return void $("#idPopupLabel").hide();if(R._bSem&&R._bShowSemLabel){$("#idPopupLabel").show();let e=.5*ATON._screenPointerCoords.x*window.innerWidth,t=.5*(1-ATON._screenPointerCoords.y)*window.innerHeight;t-=55,$("#idPopupLabel").css("transform","translate("+e+"px, "+t+"px)")}else $("#idPopupLabel").hide()}},uiBasicSetup:()=>{R.uiAddButton("idTopToolbar","fullscreen",ATON.toggleFullScreen),ATON.Utils.isConnectionSecure()&&R.uiAddButton("idTopToolbar","vr",ATON.XR.toggle),R.uiAddButton("idBottomToolbar","home",(()=>{ATON.Nav.requestHome(.1)}))},_uiSetupBase:()=>{$("#idPopup").click(R.popupClose),$("#idLoader").html(""),$("body").prepend("
    "),R.hideSemLabel()},uiAddButton:(e,t,o,i)=>{let r,a;t.endsWith(".png")?(r=t,a=t.slice(0,-4)):(r=R.PATH_RES_ICONS+t+".png",a=t);let s=$("
    ");$("#"+e).append(s),o&&s.click(o),i&&s.attr("title",i)},uiSwitchButton:(e,t)=>{t?$("#btn-"+e).addClass("switchedON"):$("#btn-"+e).removeClass("switchedON")},uiSetButtonHandler:(e,t)=>{$("#"+e).click(t)},uiAddButtonHome:e=>{R.uiAddButton(e,"home",(()=>{ATON.Nav.requestHome(.3)}),"Home viewpoint")},uiAddButtonBack:(e,t)=>{R.uiAddButton(e,"back",(()=>{t&&t.length>1&&t.startsWith("http:")?ATON.Utils.goToURL(t):history.back()}),"Go Back")},uiAddButtonFirstPerson:e=>{R.uiAddButton(e,"fp",(()=>{ATON.Nav.isFirstPerson()?(ATON.Nav.setOrbitControl(),R.uiSwitchButton("fp",!1)):(ATON.Nav.setFirstPersonControl(),R.uiSwitchButton("fp",!0))}),"First-person navigation mode"),ATON.Nav.isFirstPerson()?R.uiSwitchButton("fp",!0):R.uiSwitchButton("fp",!1)},uiAddButtonVR:e=>{ATON.Utils.isConnectionSecure()&&(R.uiAddButton(e,"vr",(()=>{ATON.XR.toggle("immersive-vr")}),"Immersive VR mode"),ATON.Utils.isVRsupported()||$("#btn-vr").hide())},uiAddButtonAR:e=>{ATON.Utils.isConnectionSecure()&&R.uiAddButton(e,"ar",(()=>{ATON.Utils.isARsupported()&&ATON.XR.toggle("immersive-ar")}),"Immersive AR mode")},uiAddButtonDeviceOrientation:e=>{ATON.Utils.isConnectionSecure()&&ATON.Utils.isMobile()&&(R.uiAddButton(e,"devori",(()=>{ATON.Nav.isDevOri()?(ATON.Nav.restorePreviousNavMode(),R.uiSwitchButton("devori",!1)):(ATON.Nav.setDeviceOrientationControl(),R.uiSwitchButton("devori",!0))}),"Device-orientation mode"),ATON.Nav.isDevOri()?R.uiSwitchButton("devori",!0):R.uiSwitchButton("devori",!1))},uiAddButtonNav:e=>{R.uiAddButton(e,"nav",(()=>{R.popupNav()}),"Navigation")},uiAddButtonTalk:e=>{ATON.Utils.isConnectionSecure()&&(R.uiAddButton(e,"talk",(()=>{ATON.MediaFlow.isAudioRecording()?(ATON.MediaFlow.stopAudioStreaming(),$("#btn-talk").removeClass("atonBTN-rec")):(ATON.MediaFlow.startAudioStreaming(),$("#btn-talk").addClass("atonBTN-rec"))}),"Talk ON/OFF"),ATON.MediaFlow.isAudioRecording()?$("#btn-talk").addClass("atonBTN-rec"):$("#btn-talk").removeClass("atonBTN-rec"))},uiAddButtonStreamFocus:e=>{R.uiAddButton(e,"focus",(()=>{ATON.Photon._bStreamFocus?(ATON.Photon.setFocusStreaming(!1),$("#btn-focus").removeClass("atonBTN-rec")):(ATON.Photon.setFocusStreaming(!0),$("#btn-focus").addClass("atonBTN-rec"))}),"Focus streaming ON/OFF"),ATON.Photon._bStreamFocus?$("#btn-focus").addClass("atonBTN-rec"):$("#btn-focus").removeClass("atonBTN-rec")},uiAddButtonMainVideoPanoPlayPause:e=>{R.uiAddButton(e,"playpause",(()=>{ATON._vpanoPlaying?ATON._elPanoVideo&&ATON._elPanoVideo.pause():ATON._elPanoVideo&&ATON._elPanoVideo.play()}),"360 Video play/pause"),ATON._elPanoVideo?$("#btn-playpause").show():$("#btn-playpause").hide()},uiAddButtonQR:e=>{ATON.Utils.isLocalhost()||R.uiAddButton(e,"qr",R.popupQR,"QR-code")},uiAddButtonScreenshot:e=>{R.uiAddButton(e,"sshot",R.popupScreenShot,"Screenshot")},uiAddButtonInfo:e=>{R.uiAddButton(e,"info",ATON.FE.popupSceneInfo,"Scene information"),$("#btn-info").hide()},uiAddButtonFullScreen:e=>{R.uiAddButton(e,"fullscreen",(()=>{ATON.toggleFullScreen()}),"Fullscreen"),R.uiSwitchButton("fullscreen",ATON.isFullscreen())},uiAddKeywordsArea:(e,t,o,i)=>{let r="";r+="Add keyword:

    ",r+="
    ",$("#"+e).html(r),R.uiAttachInputFilterID("idKWordInput"),$.getJSON(ATON.PATH_RESTAPI+"keywords/",(t=>{let o="";for(let e in t)o+="";o+="",$("#"+e).append(o)}));let a={},s=e=>{a[e]||(e=e.toLowerCase().trim(),$("#idKWordInput").val(""),a[e]=1,console.log("Added keyword "+e),o&&o(e),$("#idKWords").append("
    "+e+"
    "),$("#idkw-"+e).click((()=>{$("#idkw-"+e).remove(),a[e]=void 0,console.log("Removed keyword "+e),i&&i(e)})))};if(t)for(let e in t)s(t[e]);$("#idKWordInput").keypress((function(e){if("13"!=(e.keyCode?e.keyCode:e.which))return;let t=$("#idKWordInput").val().toLowerCase().trim();!t||t.length<3||s(t)})),$("#idKWadd").click((()=>{let e=$("#idKWordInput").val().toLowerCase().trim();!e||e.length<3||s(e)}))},uiAttachCollectionItemsToInput:(e,t)=>{let o="";$("#"+e).attr("list",e+"-list"),$("#"+e).attr("name",e+"-list"),$.getJSON(ATON.PATH_RESTAPI+"c/"+t+"/",(t=>{o+="";for(let e in t){let i=t[e];o+=""}o+="",$("#"+e).html(o)}))},getVRCclassFromID:e=>"atonVRCu"+e%6,_setupVRCevents:()=>{R._bVRCsetup||(ATON.on("VRC_IDassigned",(e=>{$("#btn-vrc").addClass(R.getVRCclassFromID(e)),ATON.SUI.setSelectorColor(ATON.Photon.color),ATON.plight.color=ATON.Photon.color,R.checkAuth((e=>{void 0!==e.username&&ATON.Photon.setUsername(e.username)}))})),ATON.on("VRC_SceneState",(e=>{let t=ATON.Photon.getNumUsers();t>1?$("#idVRCnumusers").html(t):$("#idVRCnumusers").html(""),console.log("Users: "+t)})),ATON.on("VRC_Disconnected",(()=>{$("#btn-vrc").attr("class","atonBTN"),ATON.SUI.setSelectorColor(ATON.MatHub.colors.defUI),ATON.MediaFlow.stopAllStreams(),$("#idVRCnumusers").html("")})),R._bVRCsetup=!0)},uiAddButtonPhoton:e=>{R.uiAddButton(e,"vrc",(()=>{ATON.Photon.isConnected()?R.popupVRC():ATON.Photon.connect()}),"Photon (collaborative session)"),$("#btn-vrc").append(""),R._setupVRCevents(),void 0!==ATON.Photon.uid?$("#btn-vrc").addClass(R.getVRCclassFromID(ATON.Photon.uid)):$("#btn-vrc").attr("class","atonBTN")}};R.uiAddButtonVRC=R.uiAddButtonPhoton,R.uiAddButtonUser=e=>{R.uiAddButton(e,"user",(()=>{R.popupUser()}),"User"),R.checkAuth((e=>{void 0!==e.username?$("#btn-user").addClass("switchedON"):$("#btn-user").removeClass("switchedON")}))},R.uiSetEditMode=(e,t)=>{ATON.SceneHub._bEdit=e,R.uiSwitchButton("edit",e),ATON._renderer.domElement,e?$("#"+t).addClass("atonToolbar-bg-edit"):$("#"+t).removeClass("atonToolbar-bg-edit")},R.uiAddButtonEditMode=e=>{R.uiAddButton(e,"edit",(()=>{R.checkAuth((t=>{void 0!==t.username?(ATON.SceneHub._bEdit?R.uiSetEditMode(!1,e):R.uiSetEditMode(!0,e),console.log("Persistent Edit Mode: "+ATON.SceneHub._bEdit)):R.popupUser()}))}),"Persistent Edit Mode"),ATON.SceneHub._bEdit?R.uiSwitchButton("edit",!0):R.uiSwitchButton("edit",!1)},R.uiAddProfile=(e,t)=>{"function"==typeof t&&(R._uiProfiles[e]=t)},R.uiLoadProfile=e=>{let t=R._uiProfiles[e];void 0!==t&&(t(),R._uiCurrProfile=e,console.log("Loaded UI Profile: "+R._uiCurrProfile))},R.getCurrentUIP=()=>R._uiCurrProfile,R.attachHandlerToButton=(e,t)=>{void 0!==t&&$("#"+e).click((()=>{t()}))},R.uiAttachInputFilterID=e=>{$("#"+e).on("keyup change input",(()=>{let t=$("#"+e).val(),o=new RegExp("[^A-Za-z0-9-_]","ig");$("#"+e).val(t.replace(o,""))}))},R.switchNode=(e,t,o)=>{let i;i=o===ATON.NTYPES.SEM?ATON.getSemanticNode(e):ATON.getSceneNode(e),void 0!==i&&(i.toggle(t),ATON.fireEvent("FE_NodeSwitch",{nid:e,t:o,v:t}))},R.uiCreateGraph=e=>{let t=ATON.snodes;e===ATON.NTYPES.SEM&&(t=ATON.semnodes);let o="";for(let i in t){let r=t[i].visible?"checked":"";"."!==i&&(o+="'+i,o+="
    ")}return o},R.setupBasicUISounds=()=>{R.auLib={},R.auLib.switch=new Audio(ATON.PATH_RES+"audio/switch.wav"),R.auLib.switch.loop=!1},R.playAudioFromSemanticNode=e=>{if(void 0===e)return;let t=ATON.getSemanticNode(e);if(void 0===t)return;let o=t.getAudio();void 0!==o&&("string"!=typeof o||o.startsWith("data:audio")||(o=ATON.Utils.resolveCollectionURL(o)),void 0===R._auSemNode||null===R._auSemNode?R._auSemNode=new THREE.Audio(ATON.AudioHub._listener):R._auSemNode.stop(),ATON.AudioHub._loader.load(o,(e=>{R._auSemNode.setBuffer(e),R._auSemNode.setLoop(!1),R._auSemNode.play()})))},R.popupShow=(e,t)=>{if(R._bPopup)return!1;R._tPopup=Date.now();let o="atonPopup ";t&&(o+=t);let i="
    ";return i+=e+"
    ",R._bPopup=!0,ATON._bListenKeyboardEvents=!1,$("#idPopup").html(i),$("#idPopupContent").click((e=>{e.stopPropagation()})),$("#idPopup").show(),R.popupBlurBG>0&&(ATON._renderer.domElement.style.filter="blur("+R.popupBlurBG+"px)"),ATON._bPauseQuery=!0,$("#idTopToolbar").hide(),$("#idBottomToolbar").hide(),$("#idBottomRToolbar").hide(),$("#idPoweredBy").hide(),!0},R.popupClose=e=>{Date.now()-R._tPopup0&&(ATON._renderer.domElement.style.filter="none"),$("#idPopup").hide(),ATON._bPauseQuery=!1,$("#idTopToolbar").show(),$("#idBottomToolbar").show(),$("#idBottomRToolbar").show(),$("#idPoweredBy").show(),ATON.focusOn3DView())},R.subPopup=e=>{ATON.FE.popupClose(),e()},R.popupQR=()=>{let e="
    Share
    ";if(e+="


    ",!ATON.FE.popupShow("
    Share


    "))return;let t=window.location.href;new QRCode(document.getElementById("idQRcode"),t)},R.popupScreenShot=()=>{let e=ATON.Utils.takeScreenshot(256);R.checkAuth((t=>{let o="
    Capture
    ";o+="This is a preview of what your screenshot will look like:

    ",o+="
    ",o+="Resolution: px
    ",o+="
    Screenshot
    ",o+="
    Record video
    ",void 0!==t.username&&(o+="
    Set as Cover
    "),ATON.FE.popupShow(o)&&(ATON.MediaFlow._bScreenRec?$("#btnScreenRec").addClass("atonBTN-rec"):$("#btnScreenRec").removeClass("atonBTN-rec"),$("#btnScreenShot").click((()=>{let e=parseInt($("#isShotSize").val());e<100||(ATON.FE.popupClose(),ATON.Utils.takeScreenshot(e,"shot.png"))})),$("#btnScreenRec").click((()=>{ATON.MediaFlow._bScreenRec||ATON.MediaFlow.startScreenRecording(),ATON.FE.popupClose()})),$("#btnSetCover").click((()=>{ATON.FE.popupClose(),ATON.Utils.postJSON(ATON.PATH_RESTAPI+"cover/scene/",{sid:ATON.SceneHub.currID,img:e.src},(e=>{console.log(e)}))})))}))},R.popupVRC=()=>{let e="",t=ATON.Photon.getNumUsers();e+=t>1?"
    Collaborative Session ("+t+" users)
    ":"
    Collaborative Session
    ",e+="
    ",e+="",e+="",e+="
    LEAVE
    ",e+="
    ",e+="",ATON.FE.popupShow(e,"atonPopupLarge")&&(ATON.checkAuth((e=>{console.log(e),ATON.MediaFlow._bCamStream||ATON.FE.uiAddButton("idCollabTools","screenshare",(()=>{ATON.MediaFlow._bScreenStream?$("#btn-screenshare").addClass("atonBTN-rec"):$("#btn-screenshare").removeClass("atonBTN-rec"),ATON.MediaFlow.startOrStopScreenStreaming(),ATON.FE.popupClose()}),"Share your screen with other participants"),!ATON.MediaFlow._bScreenStream&&ATON.MediaFlow.hasVideoInput()&&ATON.FE.uiAddButton("idCollabTools","camera",(()=>{ATON.MediaFlow._bCamStream?$("#btn-camera").addClass("atonBTN-rec"):$("#btn-camera").removeClass("atonBTN-rec"),ATON.MediaFlow.startOrStopCameraStreaming(),ATON.FE.popupClose()}),"Share your camera with other participants"),ATON.MediaFlow._bScreenStream?$("#btn-screenshare").addClass("atonBTN-rec"):$("#btn-screenshare").removeClass("atonBTN-rec"),ATON.MediaFlow._bCamStream?$("#btn-camera").addClass("atonBTN-rec"):$("#btn-camera").removeClass("atonBTN-rec")})),void 0===ATON.Photon._username?($("#idVRCusername").show(),$("#idVRCusernameBTN").hide()):($("#idVRCusername").val(ATON.Photon._username),$("#idVRCusername").hide(),$("#idVRCusernameBTN").show()),void 0!==ATON.Photon.uid&&$("#idVRCusernameBTN").addClass("atonVRCu"+ATON.Photon.uid%6),$("#idChatBoxPopup").append(ATON.Photon._elChat),$("#idVRCmsg").keypress((e=>{if("13"==(e.keyCode?e.keyCode:e.which)){let e=$("#idVRCmsg").val();ATON.Photon.setMessage(e),$("#idVRCmsg").val("")}})),$("#idVRCusername").keypress((e=>{if("13"==(e.keyCode?e.keyCode:e.which)){let e=$("#idVRCusername").val();ATON.Photon.setUsername(e),$("#idVRCusername").hide(),$("#idVRCusernameBTN").html(ATON.Photon._username),$("#idVRCusernameBTN").show()}})),$("#idVRCusernameBTN").click((()=>{$("#idVRCusername").show(),$("#idVRCusernameBTN").hide()})),$("#idVRCdisconnect").click((()=>{ATON.Photon.disconnect(),ATON.FE.popupClose()})))},R.checkAuth=e=>{ATON.Utils.checkAuth((t=>{R._userAuth=t,void 0!==t.username?($("#btn-user").addClass("switchedON"),void 0===ATON.Photon._username&&ATON.Photon.setUsername(t.username)):$("#btn-user").removeClass("switchedON"),e&&e(t)}))},R.popupUser=()=>{R.checkAuth((e=>{if(void 0!==e.username){let t="
    ";if(t+="'"+e.username+"'

    ",Object.keys(R._uiProfiles).length>0){t+="UI Profile:


    "}if(t+="
    LOGOUT
    ",!ATON.FE.popupShow(t))return;R._uiCurrProfile&&(console.log(R._uiCurrProfile),$("#idUIProfiles").val(R._uiCurrProfile)),$("#idLogoutBTN").click((()=>{$.get(ATON.PATH_RESTAPI+"logout",(e=>{console.log(e),ATON.SceneHub.setEditMode(!1),R.uiSwitchButton("edit",!1),ATON.fireEvent("Logout"),$("#btn-user").removeClass("switchedON")})),ATON.FE.popupClose()})),$("#idSHUscenes").click((()=>{ATON.Utils.goToURL("/shu/scenes/")})),$("#idSHUuser").click((()=>{ATON.Utils.goToURL("/shu/auth/")})),$("#idUIProfiles").on("change",(()=>{let e=$("#idUIProfiles").val();R.uiLoadProfile(e),ATON.FE.popupClose()}))}else{let e="
    ";if(e+="username:
    ",e+="password:
    ",e+="
    LOGIN
    ",!ATON.FE.popupShow(e))return;$("#idLoginBTN").click((()=>{let e=JSON.stringify({username:$("#idUsername").val(),password:$("#idPassword").val()});$.ajax({url:ATON.PATH_RESTAPI+"login",type:"POST",data:e,contentType:"application/json; charset=utf-8",dataType:"json",success:e=>{console.log(e),e&&(ATON.fireEvent("Login",e),$("#btn-user").addClass("switchedON"),ATON.FE.popupClose())}}).fail((e=>{$("#idLoginBTN").html("LOGIN FAILED"),$("#idLoginBTN").attr("class","atonBTN atonBTN-red")}))}))}}))},R.popupSceneInfo=()=>{let e=ATON.SceneHub.getTitle();void 0===e&&(e=ATON.SceneHub.currID);let t=ATON.SceneHub.getDescription(),o="
    "+e+"
    ";t&&(o+="
    "+JSON.parse(t)+"
    "),o+="
    OK
    ",ATON.FE.popupShow(o)&&$("#btnOK").click((()=>{ATON._onUserInteraction(),ATON.FE.popupClose()}))},R.computeSelectorRanges=()=>{let e=ATON.bounds.radius;e<=0||(R._selRanges[0]=.001*e,R._selRefRadius=.01*e,R._selRanges[1]=.5*e)},R.popupSelector=()=>{let e="
    3D Selector
    ",t=ATON.SUI.getSelectorRadius(),o=ATON.Utils.getHumanReadableDistance(t);R.computeSelectorRanges(),e+="Radius ("+o+"):
    ",e+="",ATON.FE.popupShow(e,"atonPopupLarge")&&($("#idSelRad").val(t),$("#idSelRad").on("input change",(()=>{let e=parseFloat($("#idSelRad").val());ATON.SUI.setSelectorRadius(e),$("#idSelRadTxt").html(ATON.Utils.getHumanReadableDistance(e))})))},R.popupNav=()=>{let e="
    Navigation
    ";e+="
    ",e+="
    ",e+="
    Switch between first-person and orbit navigation mode
    ",e+="
    ",ATON.Utils.isConnectionSecure()&&(e+="
    ",e+="
    ",e+="
    Immersive VR mode
    ",e+="
    ",ATON.Utils.isMobile()&&(e+="
    ",e+="
    ",e+="
    Enable or disable device-orientation mode
    ",e+="
    ")),R.popupShow(e)&&(R.uiAddButtonFirstPerson("idNMfp"),R.uiAddButtonDeviceOrientation("idNMdevori"),R.uiAddButtonVR("idNMvr"))},R.popupModalToken=(e,t)=>{if(void 0===t)return;ATON.FE.popupClose();let o="
    Token Required
    ";e&&(o+=e),o+="

    ",o+="
    OK
    ",R.popupShow(o)&&$("#btnTokenOK").click((()=>{let e=$("#idTokStr").val();void 0===e||e.length<2||(ATON.FE.popupClose(),t(e))}))},R.popupNewNode=e=>{void 0===e&&(e=ATON.NTYPES.SCENE);let t="";e===ATON.NTYPES.SCENE&&(t="
    New Scene Node
    "),e===ATON.NTYPES.SEM&&(t="
    New Semantic Node
    "),t+="ID:
    ",t+="
    Add

    ",R.popupShow(t)&&$("#btnNewNID").click((()=>{let t=$("#idNID").val().trim();void 0===t||t.length<3||new ATON.Node(t,e).attachToRoot()}))};const y=R;let w={auType:"audio/wav",auStreamSegmentInterval:200,auStreamNumSegments:2,vidStreamSegmentInterval:300,vidStreamNumSegments:1,auMinVol:1,init:()=>{w._bAudioRecording=!1,w._bAudioStreaming=!1,w._bScreenRec=!1,w._blobOptAudio={type:"audio/wav"},w._blobOptVideo={type:"video/mp4"},w._cAuStream={audio:{channelCount:1,echoCancellation:!0,noiseSuppression:!0}},w._cAuRec={audio:{channelCount:1}},w._cScreenRec={video:{width:1280,height:720,framerate:30}},w._cScreenStream={video:{cursor:"always",width:{max:640},height:{max:360},framerate:15}},w._cCamStream={video:{width:{max:512},height:{max:512}}},w._oStream={audioBitsPerSecond:9e3,videoBitsPerSecond:5e5},w._aurec=void 0,w._sblob=void 0,w._schunks=[],w._bVideoStream=!1,w._vrec=void 0,w._scblob=void 0,w._scchunks=[],w._bCamStream=!1,w._bScreenStream=!1,w._setupFR(),w.detectDevices(),navigator.mediaDevices&&navigator.mediaDevices.addEventListener("devicechange",(e=>{w.detectDevices()})),w._vStreams={}},_setupFR:()=>{w._frAR=new window.FileReader,w._frAR.onloadend=()=>{let e=w._frAR.result;ATON.fireEvent("AudioRecordCompleted",e),w._bAudioRecording=!1},w._frAS=new window.FileReader,w._frAS.onloadend=()=>{if(!w._bAudioStreaming)return;let e=w._frAS.result;ATON.Photon.socket.emit("UTALK",{audio:e,uid:ATON.Photon.uid}),e=null},w._frVS=new window.FileReader,w._frVS.onloadend=()=>{if(!w._bVideoStream)return;let e=w._frVS.result;ATON.Photon.socket.emit("UVIDEO",{video:e,uid:ATON.Photon.uid}),e=null}},detectDevices:()=>{w.audioInputDevices=[],w.videoInputDevices=[],navigator.mediaDevices&&navigator.mediaDevices.enumerateDevices().then((e=>{for(let t in e){let o=e[t];"audioinput"===o.kind&&w.audioInputDevices.push(o),"videoinput"===o.kind&&w.videoInputDevices.push(o)}}))},hasAudioInput:()=>w.audioInputDevices.length>0,hasVideoInput:()=>w.videoInputDevices.length>0,isAudioRecording:()=>w._bAudioRecording,startRecording:()=>{w._bAudioRecording?console.log("Already recording."):navigator.mediaDevices.getUserMedia(w._cAuRec).then((e=>{w._aurec=new MediaRecorder(e),w._aurec.onstart=function(e){console.log("Start recording..."),w._bAudioRecording=!0,w._schunks=[]},w._aurec.ondataavailable=function(e){w._schunks.push(e.data)},w._aurec.onstop=function(e){console.log("Stop recording..."),w._sblob=new Blob(w._schunks,w._blobOptAudio),w._frAR.readAsDataURL(w._sblob)},w._aurec.start()})).catch((e=>{console.log(e)}))},stopRecording:()=>{w._aurec&&w._bAudioRecording&&w._aurec.stop()},startOrStopRecording:()=>{w._bAudioRecording?w.stopRecording():w.startRecording()},startAudioStreaming:()=>{navigator.mediaDevices.getUserMedia(w._cAuStream).then((e=>{w._aurec=new MediaRecorder(e,w._oStream),w._aurec.start(w.auStreamSegmentInterval),console.log("Start audio streaming"),w._aurec.onstart=e=>{w._bAudioStreaming=!0,w._bAudioRecording=!0,w._schunks=[]},w._aurec.ondataavailable=e=>{e.data.size<=0||(w._schunks.push(e.data),w._schunks.length{w._sblob=new Blob(w._schunks,w._blobOptAudio),w._frAS.readAsDataURL(w._sblob),w._bAudioStreaming&&w._aurec.start(w.auStreamSegmentInterval)}})).catch((e=>{console.log(e)}))},stopAudioStreaming:()=>{w._aurec&&w._bAudioStreaming&&("inactive"!==w._aurec.state&&w._aurec.stop(),console.log("Stop audio streaming"),w._bAudioStreaming=!1,w._bAudioRecording=!1,ATON.Photon.socket.emit("UAUDIOSTOP",{uid:ATON.Photon.uid}))},startOrStopAudioStreaming:()=>{w._bAudioRecording?w.stopAudioStreaming():w.startAudioStreaming()},startScreenRecording:()=>{w._bScreenRec||w._bScreenStream||navigator.mediaDevices.getDisplayMedia(w._cScreenRec).then((e=>{w._vrec=new MediaRecorder(e),w._scchunks=[],w._vrec.ondataavailable=e=>{e.data.size>0&&w._scchunks.push(e.data)},w._vrec.onstop=()=>{w._scblob=new Blob(w._scchunks,w._blobOptVideo),console.log(w._scblob.size),ATON.Utils.downloadBlob(w._scblob,"capture.mp4"),w._scchunks=[],w._bScreenRec=!1},w._vrec.start(200),w._bScreenRec=!0})).catch((e=>{console.log(e)}))},stopScreenRecording:()=>{w._bScreenRec&&(w._vrec.stop(),w._bVideoStream=!1,w._bScreenStream=!1,console.log("Stop screen recording"))},startScreenStreaming:()=>{navigator.mediaDevices.getDisplayMedia(w._cScreenStream).then((e=>{w.realizeOrUpdateVStream(e,w.stopScreenStreaming),w._vrec=new MediaRecorder(e,w._oStream),w._vrec.start(w.vidStreamSegmentInterval),console.log("Start screen streaming"),w._vrec.onstart=e=>{w._bVideoStream=!0,w._bScreenStream=!0,w._scchunks=[]},w._vrec.ondataavailable=e=>{e.data.size<1||(w._scchunks.push(e.data),w._scchunks.length{w._scblob=new Blob(w._scchunks,w._blobOptVideo),w._frVS.readAsDataURL(w._scblob),w._bVideoStream&&w._vrec.start(w.vidStreamSegmentInterval)}})).catch((e=>{console.log(e)}))},stopScreenStreaming:()=>{if(w._vrec&&w._bVideoStream&&(w._vrec.stop(),w._bVideoStream=!1,w._bScreenStream=!1,console.log("Stop screen streaming"),void 0!==ATON.Photon.uid)){let e=w.getVideoStream(ATON.Photon.uid);e.el.style.display="none",e.el.pause(),ATON.Photon.socket.emit("UVIDEOSTOP",{uid:ATON.Photon.uid})}},startOrStopScreenStreaming:()=>{w._bVideoStream?w.stopScreenStreaming():w.startScreenStreaming()},startCameraStreaming:()=>{w._bVideoStream||navigator.mediaDevices.getUserMedia(w._cCamStream).then((e=>{w.realizeOrUpdateVStream(e,w.stopCameraStreaming),w._vrec=new MediaRecorder(e,w._oStream),w._vrec.start(w.vidStreamSegmentInterval),console.log("Start camera streaming"),w._vrec.onstart=e=>{w._bVideoStream=!0,w._bCamStream=!0,w._scchunks=[]},w._vrec.ondataavailable=e=>{e.data.size<1||(w._scchunks.push(e.data),w._scchunks.length{w._scblob=new Blob(w._scchunks,w._blobOptVideo),w._frVS.readAsDataURL(w._scblob),w._bVideoStream&&w._vrec.start(w.vidStreamSegmentInterval)}})).catch((e=>{console.log(e)}))},stopCameraStreaming:()=>{if(w._vrec&&w._bVideoStream&&(w._vrec.stop(),w._bVideoStream=!1,w._bCamStream=!1,console.log("Stop camera streaming"),void 0!==ATON.Photon.uid)){let e=w.getVideoStream(ATON.Photon.uid);e.el.style.display="none",e.el.pause(),ATON.Photon.socket.emit("UVIDEOSTOP",{uid:ATON.Photon.uid})}},startOrStopCameraStreaming:()=>{w._bVideoStream?w.stopCameraStreaming():w.startCameraStreaming()},realizeOrUpdateVStream:(e,t)=>{let o=ATON.Photon.uid;if(void 0===o)return;let i=w.getOrCreateVideoStream(o,void 0,!0);i.el.playsinline=!0,i.el.style.display="inline-block",i.el.classList.add("atonVRCvidStream"),i.el.classList.add("atonVRCu"+o%6),t&&(i.el.onclick=t),i.el.srcObject=e},stopAllStreams:()=>{w.stopAudioStreaming(),w.stopCameraStreaming(),w.stopScreenStreaming()},getOrCreateVideoStream:(e,t,o)=>{if(w._vStreams[e])t&&(w._vStreams[e].el.src=t);else{w._vStreams[e]={};let i="vStream-"+e;if(o&&(i="uStream"+e,w._vStreams[e].uid=e),$("").appendTo("body"),w._vStreams[e].el=document.getElementById(i),t)if(t.endsWith("m3u8"))if(Hls.isSupported()){let o=new Hls;o.loadSource(t),o.attachMedia(w._vStreams[e].el)}else w._vStreams[e].el.src=t;else w._vStreams[e].el.src=t;o||(w._vStreams[e].el.loop=!0),w._vStreams[e].texStream=new THREE.VideoTexture(w._vStreams[e].el),w._vStreams[e].texStream.colorSpace=ATON._stdEncoding,w._vStreams[e].texStream.flipY=!1,w._vStreams[e].matStream=ATON.MatHub.materials.chromakey.clone(),w._vStreams[e].matStream.uniforms.tBase.value=w._vStreams[e].texStream}return w._vStreams[e]},getVideoStream:e=>w._vStreams[e],downloadVideoSnapshot:(e,t,o)=>{o||(o=1);let i=e.videoWidth*o,r=e.videoHeight*o,a=document.createElement("canvas");a.width=i,a.height=r,a.getContext("2d").drawImage(e,0,0,i,r),ATON.Utils.downloadImageFromCanvas(a,t)}};const M=w;let L={EARTH_R_KM:6371};L.EARTH_D_KM=2*L.EARTH_R_KM,L.init=()=>{L._bActive=!1,L._wpid=void 0,L._currGeoPos=new THREE.Vector2,L._GeoPOIs=[],L._currGeoPOI=void 0,L._closestGeoPOI=void 0,L._maxGeoError=40},L.enableGeoTracking=()=>{L._bActive||ATON.Utils.isConnectionSecure()&&navigator.geolocation&&(L._wpid=navigator.geolocation.watchPosition(L._onGeoPosition,L._onGeoError,{enableHighAccuracy:!0}),L._bActive=!0)},L.disableGeoTracking=()=>{L._bActive&&(navigator.geolocation.clearWatch(L._wpid),L._bActive=!1)},L.setMaxGeoError=e=>{e>0&&(L._maxGeoError=e)},L._onGeoError=()=>{console.log("Geolocation error")},L._onGeoPosition=e=>{if(!L._bActive)return;if(!e.coords)return;let t=e.coords.accuracy;t&&t>L._maxGeoError||(L._currGeoPos.x=e.coords.latitude,L._currGeoPos.y=e.coords.longitude,ATON.fireEvent("GeoLocation",e),L._handleGeoPOIs())},L._handleGeoPOIs=()=>{let e=L._GeoPOIs.length;if(!(e<=0)){L._closestGeoPOIdist=void 0,L._closestGeoPOI=void 0;for(let t=0;t{if(L._bActive)return L._currGeoPos},L.geolocationFromLatLon=(e,t)=>new THREE.Vector2(e,t),L.geodistance_orig=(e,t)=>{let o=ATON.DEG2RAD*(t.x-e.x),i=ATON.DEG2RAD*(t.y-e.y),r=Math.sin(o/2)*Math.sin(o/2)+Math.cos(ATON.DEG2RAD*e.x)*Math.cos(ATON.DEG2RAD*t.x)*Math.sin(i/2)*Math.sin(i/2),a=2*Math.atan2(Math.sqrt(r),Math.sqrt(1-r));return L.EARTH_R_KM*a*1e3},L.geodistance=(e,t)=>{let o=.5-Math.cos((t.x-e.x)*ATON.DEG2RAD)/2+Math.cos(e.x*ATON.DEG2RAD)*Math.cos(t.x*ATON.DEG2RAD)*(1-Math.cos((t.y-e.y)*ATON.DEG2RAD))/2;return L.EARTH_D_KM*Math.asin(Math.sqrt(o))*1e3},L.addGeoPOI=(e,t)=>{let o={};return o.pos=new THREE.Vector2(e.x,e.y),o.radius=t,L._GeoPOIs.push(o),L._bActive||L.enableTracking(),L._handleGeoPOIs(),L._GeoPOIs.length-1},L.getGeoPOIbyIndex=e=>L._GeoPOIs[e],L.getClosestGeoPOI=()=>L._closestGeoPOI,L.getClosestGeoPOIdistance=()=>L._closestGeoPOIdist;const C=L;let H={};H._id=$("meta[name='aton\\:appid']").attr("content"),H._data={},H.setup=void 0,H.update=void 0,H._bRunning=!1,H._pDeps=[],H._fLoading=0,H._sendDataPatch=(e,t,o)=>new Promise(((i,r)=>{if(void 0===e)return void r("No storage ID specified");if(e.length<3)return void r("Storage ID too short");if(void 0===t)return void r("No storage patch");if(void 0===H._id)return void r("No app-ID");void 0===o&&(o=ATON.PATCH_ADD);let a={};a.wappid=H._id,a.fid=e,a.data=t,a.mode=o===ATON.PATCH_DEL?"DEL":"ADD";let s=JSON.stringify(a);$.ajax({url:ATON.PATH_RESTAPI+"patch/wapp",type:"POST",data:s,contentType:"application/json; charset=utf-8",dataType:"json",success:t=>{void 0!==t?(H._data[e]=t,i(t)):r("Error writing on server")}})})),H.getAppID=()=>H._id,H.addToStorage=(e,t)=>H._sendDataPatch(e,t,ATON.PATCH_ADD),H.deleteFromStorage=(e,t)=>H._sendDataPatch(e,t,ATON.PATCH_DEL),H.getStorage=e=>new Promise(((t,o)=>{void 0!==H._id?void 0!==e?$.getJSON(ATON.PATH_WAPPS+H._id+"/data/"+e+".json",(o=>{console.log(o),H._data[e]=o,t(o)})):o("No storage ID specified"):o()})),H.registerServiceWorker=e=>{if(e)return H.basePath&&(e=H.basePath+e),"serviceWorker"in navigator&&window.addEventListener("load",(()=>{navigator.serviceWorker.register(e).then((e=>console.log("PWA service worker registered"))).catch((e=>console.log("PWA service worker not registered",e)))})),H},H.requireFlares=e=>{if(e)return ATON._fReqList=e,console.log("Required Flares: "+ATON._fReqList),H},H.loadScene=(e,t)=>{void 0!==e&&ATON.SceneHub.load(ATON.PATH_RESTAPI2+"scenes/"+e,e,t)},H.realize=(e,t,o)=>{H.setup=e,H.update=t,H.params=new URLSearchParams(window.location.search),H.basePath=ATON.Utils.getBaseFolder(window.location.href.split("?")[0]),H.registerServiceWorker(o);let i=H.params.get("ff");if(i){let e=String(i).split(",");H.requireFlares(e)}return H},H.realizeAndRun=(e,t,o)=>{H.realize(e,t,o).run()},H.run=()=>!H._bRunning&&(H._bRunning=!0,H.setup?H.setup():(ATON.FE.realize(),console.log("App [Warn]: your App should define a setup() routine")),H.update&&(ATON.addUpdateRoutine(H.update),console.log("App: update routine registered")),ATON._fRequired<=0&&ATON.fireEvent("AllFlaresReady"),!0);const D=H;let x={PASS_BASE:"p_base",PASS_AA:"p_aa",PASS_AO:"p_ao",PASS_SSR:"p_ssr",PASS_BLOOM:"p_bloom",PASS_DOF:"p_dof",PASS_GAMMA:"p_gamma",PASS_SOBEL:"p_sobel",init:()=>{if(void 0===ATON._renderer)return;let e=ATON._renderer.getPixelRatio(),t=ATON._renderer.getSize(new THREE.Vector2);const o=new THREE.WebGLRenderTarget(t.width*e,t.height*e,{minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,format:THREE.RGBAFormat,colorSpace:ATON._stdEncoding});o.texture.name="EffectComposer.rt1",x.composer=new THREE.EffectComposer(ATON._renderer,o),x.passes={},ATON._renderer.autoClear=!1;let i=window.innerWidth*ATON._stdpxd,r=window.innerHeight*ATON._stdpxd;x.passes[x.PASS_BASE]=new THREE.RenderPass(ATON._mainRoot,ATON.Nav._camera),x.composer.addPass(x.passes[x.PASS_BASE]),x.passes[x.PASS_AO]=new THREE.SAOPass(ATON._mainRoot,ATON.Nav._camera,i,r),x.passes[x.PASS_AO].params.saoBias=1,x.passes[x.PASS_AO].params.saoScale=100,x.passes[x.PASS_AO].params.saoIntensity=.2,x.passes[x.PASS_BLOOM]=new THREE.UnrealBloomPass(new THREE.Vector2(i,r),1.5,.4,.85),x.passes[x.PASS_BLOOM].threshold=.9,x.passes[x.PASS_BLOOM].strength=1,x.passes[x.PASS_BLOOM].radius=1.2,x.passes[x.PASS_DOF]=new THREE.BokehPass(ATON._mainRoot,ATON.Nav._camera,{focus:5,aperture:.001,maxblur:.01,width:i,height:r}),x.composer.addPass(x.passes[x.PASS_AO]),x.composer.addPass(x.passes[x.PASS_BLOOM]),x.composer.addPass(x.passes[x.PASS_DOF]),x.togglePass(x.PASS_AO,!1),x.togglePass(x.PASS_BLOOM,!1),x.togglePass(x.PASS_DOF,!1)},togglePass:(e,t)=>{void 0!==x.composer&&(ATON.device.lowGPU||void 0!==x.passes[e]&&(x.passes[e].enabled=void 0===t?!x.passes[e].enabled:t))},isPassEnabled:e=>void 0!==x.composer&&(void 0!==x.passes[e]&&x.passes[e].enabled),setAOintensity:e=>{void 0!==x.composer&&void 0!==x.passes[x.PASS_AO]&&(x.passes[x.PASS_AO].params.saoIntensity=e)},getAOintensity:()=>void 0===x.composer||void 0===x.passes[x.PASS_AO]?0:x.passes[x.PASS_AO].params.saoIntensity,setBloomStrength:e=>{void 0!==x.composer&&void 0!==x.passes[x.PASS_BLOOM]&&(x.passes[x.PASS_BLOOM].strength=e)},getBloomStrength:()=>void 0===x.composer||void 0===x.passes[x.PASS_BLOOM]?0:x.passes[x.PASS_BLOOM].strength,setBloomThreshold:e=>{void 0!==x.composer&&void 0!==x.passes[x.PASS_BLOOM]&&(x.passes[x.PASS_BLOOM].threshold=e)},getBloomThreshold:()=>void 0===x.composer||void 0===x.passes[x.PASS_BLOOM]?0:x.passes[x.PASS_BLOOM].threshold,setDOFfocus:e=>{if(void 0===x.composer)return;if(void 0===x.passes[x.PASS_DOF])return;let t=x.passes[x.PASS_DOF].uniforms;void 0!==t&&(t.focus.value=e)},getDOFfocus:()=>{if(void 0===x.composer)return 0;if(void 0===x.passes[x.PASS_DOF])return 0;let e=x.passes[x.PASS_DOF].uniforms;return void 0===e?0:e.focus.value},setDOFaperture:e=>{if(void 0===x.composer)return;if(void 0===x.passes[x.PASS_DOF])return;let t=x.passes[x.PASS_DOF].uniforms;void 0!==t&&(t.aperture.value=e)}};const F=x;let V={STD_XPF_TRANSITION_DURATION:1,SEM_PREFIX:"XPF",SEMGROUP_PREFIX:"GXPF",init:()=>{V._list=[],V._iCurr=void 0,V._iNext=void 0,V._geom=void 0,V._mesh=void 0,V._mat=void 0,V._size=50,V._gSem=[],V._semIMGMasks={},V._semCanvas=void 0,V._semCTX=void 0,V._semCurr=void 0,V._shColor=new THREE.Color(0,0,1),V._shOpacity=.2,V._txCache={},V._pathMod=void 0,V._realizeBaseMat(),V._elVid=void 0,V._vidPlaying=!1},_realizeBaseMat:()=>{V._uniforms={tBase:{type:"t"},tSem:{type:"t"},tSemHint:{type:"t"},semHL:{type:"vec4",value:new THREE.Vector4(0,1,0,.15)},opacity:{type:"float",value:1},shColor:{type:"vec4",value:new THREE.Vector4(0,0,1,.2)},time:{type:"float",value:0}},V._mat=new THREE.ShaderMaterial({uniforms:V._uniforms,vertexShader:"\n varying vec3 vPositionW;\n varying vec3 vNormalW;\n varying vec3 vNormalV;\n varying vec2 vUv;\n\n void main(){\n vUv = uv;\n\n vPositionW = vec3( vec4( position, 1.0 ) * modelMatrix);\n vNormalW = normalize( vec3( vec4( normal, 0.0 ) * modelMatrix ) );\n vNormalV = normalize( vec3( normalMatrix * normal ));\n\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }\n ",fragmentShader:"\n varying vec3 vPositionW;\n\t\t varying vec3 vNormalW;\n varying vec3 vNormalV;\n varying vec2 vUv;\n\n uniform float time;\n uniform sampler2D tBase;\n uniform sampler2D tSem;\n uniform sampler2D tSemHint;\n //uniform sampler2D tDepth;\n\n uniform vec4 semHL, shColor;\n uniform float opacity;\n\n\t\t void main(){\n vec4 frag = texture2D(tBase, vUv);\n vec4 sem = texture2D(tSem, vUv);\n vec4 semH = texture2D(tSemHint, vUv);\n float shv = max( max(semH.r,semH.g), semH.b);\n\n float t = (1.0 * cos(time*2.0));\n t = clamp(t, 0.0,1.0);\n\n frag = mix(frag, semHL, (sem.r * semHL.a));\n\n frag = mix(frag, shColor, (t * shv * shColor.a));\n\n frag.a = opacity;\n\n gl_FragColor = frag;\n\t\t }\n ",depthTest:!1,depthWrite:!1}),V.setSemanticHintMapOpacity(.2)},setPathModifier:e=>{if(void 0!==e){V._pathMod=e;for(let t in V.list)V.list[t].setPathModifier(e)}},update:()=>{if(ATON.Nav.isTransitioning())return;if(V._list.length<1)return;let e,t,o,i,r=V._list.length,a=ATON.Nav._currPOV.pos,s=ATON.Nav._vDir;V._uniforms.time.value+=ATON._dt,void 0===V._dirLNode&&(V._dirLNode=new THREE.Vector3);for(let n=0;n.8&&(void 0===o||l{void 0===V._geom&&(V._group=new THREE.Group,ATON._rootVisibleGlobal.add(V._group),V._geom=new THREE.SphereGeometry(1,40,40),V._geom.scale(-V._size,V._size,V._size),V._geom.castShadow=!1,V._geom.receiveShadow=!1,V._mesh=new THREE.Mesh(V._geom,V._mat),V._mesh.frustumCulled=!1,V._mesh.renderOrder=-100,V._mesh.layers.enable(ATON.NTYPES.SCENE),V._group.add(V._mesh),V._mesh.visible=!1)},setBaseGeometry:e=>{},add:e=>{if(void 0===e)return;V.realizeBaseGeometry();let t=V._list.length;V._list.push(e);let o=e.getMesh();o&&V._group.add(o);let i=ATON.getOrCreateSemanticNode(V.SEMGROUP_PREFIX+t);V._gSem.push(i),i.attachToRoot(),t>0||(ATON.Nav.toggleLocomotionValidator(!1),ATON._bqScene=!0)},clear:()=>{V._iCurr=void 0,V._iNext=void 0,V._semCurr=void 0;for(let e=0;eV._list.length,getMainGroup:()=>V._group,getSemanticGroup:e=>V._gSem[e],getCurrentSemanticGroup:()=>{if(void 0!==V._iCurr)return V._gSem[V._iCurr]},_preloadBaseLayer:(e,t)=>{if(void 0!==V._txCache[e])return V._txCache[e];let o=V._list[e]._pathbaselayer;V._pathMod&&(o=V._pathMod(o)),ATON.Utils.textureLoader.load(o,(o=>{o.colorSpace=ATON._stdEncoding,o.generateMipmaps=!0,V._txCache[e]=o,t&&t(o)}))},_clearTexCache:()=>{if(void 0!==V._iCurr)for(let e in V._txCache)V._txCache[e]&&e!==V._iCurr&&(V._txCache[e].dispose(),V._txCache[e]=void 0)},_setBaseLayerTexture:(e,t)=>{V._mat.map=t,V._mat.needsUpdate=!0,V._mesh.position.copy(e.getLocation()),V._mesh.rotation.set(e.getRotation().x,e.getRotation().y,e.getRotation().z)},updateCurrentXPFbaseLayer:e=>{if(void 0===V._iCurr)return;let t=V._list[V._iCurr];if(void 0===t)return;let o=t._pathbaselayer;if(V._pathMod&&(o=V._pathMod(o)),ATON.Utils.isVideo(o)){if(void 0===V._elVid){let e="",$(e).appendTo("body"),V._elVid=document.getElementById("idXPFVideo"),V._elVid.onplaying=()=>{console.log("XPF VideoPano playing"),V._vidPlaying=!0},V._elVid.onpause=()=>{console.log("XPF VideoPano paused"),V._vidPlaying=!1},V._elVid.addEventListener("touchstart",(function(){V._elVid.play()})),enableInlineVideo(V._elVid)}let i=new THREE.VideoTexture(V._elVid);return i.colorSpace=ATON._stdEncoding,V._mat.map=i,V._mat.needsUpdate=!0,V._uniforms.tBase.value=i,V._mesh.position.copy(t.getLocation()),V._mesh.rotation.set(t.getRotation().x,t.getRotation().y,t.getRotation().z),void(e&&e(i))}ATON.Utils.textureLoader.load(o,(o=>{o.colorSpace=ATON._stdEncoding,o.generateMipmaps=!0,V._mat.map=o,V._mat.needsUpdate=!0,V._uniforms.tBase.value=o,V._mesh.position.copy(t.getLocation()),V._mesh.rotation.set(t.getRotation().x,t.getRotation().y,t.getRotation().z),e&&e(o)}))},playOrPauseXPFVideoStream:()=>{void 0!==V._elVid&&(V._vidPlaying?V._elVid.pause():V._elVid.play())},updateCurrentXPFsemLayer:e=>{let t=V._list.indexOf(e);t<0||t===V._iCurr&&V.loadSemanticMasksIfAny(V._iCurr)},setCurrentXPF:(e,t)=>{V.toggleSUI(e,!1),V._iCurr=e,V._iNext=void 0,V._mesh.visible=!0,V._gSem[e].show(),V.updateCurrentXPFbaseLayer(t),ATON.fireEvent("CurrentXPF",e),ATON.fireEvent("NextXPF",void 0),V.loadSemanticMasksIfAny(e)},toggleSUI:(e,t)=>{if(void 0===e)return;let o=V._list[e];void 0!==o&&o._lnode.toggleSUI(t)},loadSemanticMasksIfAny:e=>{let t=V._list[e];if(void 0!==t){V._semIMGMasks={},V._uniforms.tSemHint.value=0,void 0!==t._semHintURL&&(V._uniforms.tSemHint.value=ATON.Utils.textureLoader.load(t._semHintURL));for(let e in t._semMasksURLs){void 0===V._semCanvas&&(V._semCanvas=document.createElement("canvas"),V._semCanvas.width=2048,V._semCanvas.height=2048,V._semCTX=V._semCanvas.getContext("2d",{willReadFrequently:!0}));let o=t._semMasksURLs[e],i=new Image;i.src=o,V._semIMGMasks[e]=i}}},getXPFbyIndex:e=>V._list[e],getCurrentXPFindex:()=>V._iCurr,getCurrentXPF:()=>{if(void 0!==V._iCurr)return V._list[V._iCurr]},getNextXPFindex:()=>V._iNext,getNextXPF:()=>{if(void 0!==V._iNext)return V._list[V._iNext]},getDistanceToXPFindex:e=>{if(void 0===e)return;let t=V._list[e];return void 0!==t?ATON.Nav._currPOV.pos.distanceTo(t.getLocation()):void 0},showSUIonlyForXPF:e=>{let t=V._list.length;if(!(t<1))for(let o=0;o{let o=V._list[e];void 0!==o&&(void 0===t&&(t=V.STD_XPF_TRANSITION_DURATION),ATON.XR._bPresenting&&(t=0),V.setCurrentXPF(e),ATON.Nav.requestTransitionToLocomotionNode(o.getLocomotionNode(),t))},requestTransitionToTarget:(e,t,o)=>{if(void 0===e)return;let i=new ATON.POV;i.setTarget(e),i.setPosition(ATON.Nav._currPOV.pos),t&&i.setFOV(t),ATON.Nav.requestPOV(i,o)},requestTransitionToDirection:(e,t,o)=>{if(void 0===e)return;let i=new THREE.Vector3;i.x=e.x+ATON.Nav._currPOV.pos.x,i.y=e.y+ATON.Nav._currPOV.pos.y,i.z=e.z+ATON.Nav._currPOV.pos.z,V.requestTransitionToTarget(i,t,o)},setHomeXPF:e=>{let t=V._list[e];if(void 0===t)return;let o=t.getLocomotionNode(),i=(new ATON.POV).setPosition(o.pos).setTarget(o.pos.x,o.pos.y,o.pos.z+1);ATON.Nav.setHomePOV(i)},getSemanticMaskURLfromXPFindex:(e,t)=>{let o=V._list[e];if(void 0!==o)return o.getSemanticMaskURL(t)},getSemanticMaskURLfromCurrentXPF:e=>{if(void 0!==V._iCurr)return V.getSemanticMaskURLfromXPFindex(V._iCurr,e)},setSemanticColor:(e,t)=>{void 0===t&&(t=.15),V._uniforms.semHL.value=new THREE.Vector4(e.r,e.g,e.b,t)},setSemanticOpacity:e=>{void 0===e&&(e=.15),V._uniforms.semHL.value.w=e},setSemanticHintMapOpacity:e=>{void 0===e&&(e=.2),V._shOpacity=e,V._uniforms.shColor.value.w=e},setSemanticHintMapColor:(e,t)=>{void 0!==e&&(V._shColor=e,V._uniforms.shColor.value.x=e.r,V._uniforms.shColor.value.y=e.g,V._uniforms.shColor.value.z=e.b,void 0!==t&&V.setSemanticHintMapOpacity(t))},querySemanticMasks:()=>{if(void 0===V._semCTX)return;if(void 0===ATON._queryDataScene)return;if(void 0===ATON._queryDataScene.uv)return;let e,t=V._semCTX,o=ATON._queryDataScene.uv;for(let i in V._semIMGMasks){let r=V._semIMGMasks[i],a=parseInt(r.width*o.x),s=parseInt(r.height*(1-o.y));if(t.drawImage(r,0,0),t.getImageData(a,s,1,1).data[0]>127){e=i;break}}if(void 0===e)return void 0!==V._semCurr&&ATON.fireEvent("SemanticMaskLeave",V._semCurr),V._semCurr=void 0,V._uniforms.tSem.value=0,V._uniforms.shColor.value.w=V._shOpacity,void(V._mat.needsUpdate=!0);V.highlightSemanticMaskInCurrentXPF(e),V._semCurr=e},highlightSemanticMaskInCurrentXPF:e=>{if(void 0===e)return void 0!==V._semCurr&&ATON.fireEvent("SemanticMaskLeave",V._semCurr),V._semCurr=void 0,V._uniforms.tSem.value=0,V._uniforms.shColor.value.w=V._shOpacity,void(V._mat.needsUpdate=!0);if(V._semCurr===e)return;let t=V.getSemanticMaskURLfromCurrentXPF(e);V._uniforms.tSem.value=ATON.Utils.textureLoader.load(t),V._mat.needsUpdate=!0,ATON.fireEvent("SemanticMaskHover",e),V._uniforms.shColor.value.w=0,void 0!==V._semCurr&&ATON.fireEvent("SemanticMaskLeave",V._semCurr)},loadFromPhotoscanFile:(e,t)=>{if(void 0===e)return;e=ATON.Utils.resolveCollectionURL(e);let o=ATON.Utils.getBaseFolder(e),i=0;$.ajax({url:e,dataType:"text",success:function(e){e=e.split(/\r\n|\n/);for(let t in e){let r=e[t];if(!r.startsWith("#")){let e=r.split(/\s{2,}|\t/);if(e.length>10){let t=new ATON.XPF,r=o+e[0],a=parseFloat(e[1]),s=parseFloat(e[2]),n=parseFloat(e[3]),l=ATON.DEG2RAD*parseFloat(e[4]);ATON.DEG2RAD,parseFloat(e[5]),ATON.DEG2RAD,parseFloat(e[6]),t.setLocation(a,n,-s),t.setBaseLayer(r),t.setRotation(0,-l,0),V.add(t),i++}}}console.log("Num panoramas parsed: "+i),t&&t()}})}};const I=V;let U={init:()=>{U.list=[]},anyCopyrightFound:()=>U.list.length>0,extract:e=>{if(void 0===e)return;if(void 0===e.asset)return;let t={};if(e.asset.copyright&&(t.copyright=e.asset.copyright),e.asset.extras)for(let o in e.asset.extras)"string"==typeof e.asset.extras[o]&&(t[o]=e.asset.extras[o]);if(U.extractXMP3DC(e,t),0!==Object.keys(t).length){e.asset.generator&&(t.generator=e.asset.generator);for(let e in U.list){let o=U.list[e];if(U.compare(t,o))return}U.list.push(t),console.log(t)}},compare:(e,t)=>{if(void 0===e||void 0===t)return!1;const o=Object.keys(e),i=Object.keys(t);if(o.length!==i.length)return!1;for(let i of o)if(e[i]!==t[i])return!1;return!0},extractXMP3DC:(e,t)=>{if(void 0===e||void 0===t)return;if(!e.userData)return;let o=e.userData.gltfExtensions;if(!o)return;if(!o.KHR_xmp)return;let i=o.KHR_xmp.packets;if(!i)return;let r=i[0],a="en-us";r["model3d:spdxLicense"]&&(t.license=r["model3d:spdxLicense"]),r["dc:date"]&&(t.date=r["dc:date"]),r["dc:title"]&&(t.title=r["dc:title"][a]),r["dc:description"]&&(t.description=r["dc:description"][a]),r["dc:rights"]&&(t.rights=r["dc:rights"][a]),r["dc:source"]&&(t.source=r["dc:source"]),r["dc:subject"]&&(t.subject=r["dc:subject"]),r["dc:type"]&&(t.type=r["dc:type"]),r["xmpRights:Owner"]&&(t.owner=r["xmpRights:Owner"]),r["xmp:CreatorTool"]&&(t.creatorTool=r["xmp:CreatorTool"])}};const k=U;let B={REST_API_CESIUMION_DEF_TOKEN:"https://api.cesium.com/v2/tokens/default",THRES_ORI:.01,THRES_POS:1e-6,init:()=>{B._tsets=[],B._tsET=20,B._tsB=!1,B._bTileBVH=!0,B._tsTasks=[],B.tsSchedCB=e=>{B._tsTasks.push(e)},B._tseBase=8,B.estimateTSErrorTarget(),B._tsuSync=0,B._bPCs=!1,B._pqLRU=void 0,B._pqDownload=void 0,B._pqParse=void 0,B._numTilesLoaded=0,B._numTSLoaded=0},clear:()=>{for(let e in B._tsets)B._tsets[e]=null;B._tsets=[],B._bPCs=!1},getTSetsErrorTarget:()=>B._tsET,setTSetsErrorTarget:e=>{B._tsET=e;const t=B._tsets.length;if(!(t<=0))for(let o=0;o{B._tsB=e;const t=B._tsets.length;if(!(t<=0))for(let o=0;o{void 0===e&&(e=ATON.Nav._camera);const t=B._tsets.length;if(!(t<=0))for(let o=0;o{B._tseBase=e,console.log(B._tseBase),B.estimateTSErrorTarget()},estimateTSErrorTarget:()=>{let e=B._tseBase;(ATON.device.lowGPU||ATON.device.isMobile)&&(e+=4),ATON.XR._bPresenting&&(e+=3),e<1&&(e=1),e>25&&(e=25),console.log("Estimated TSet error target: "+e),B.setTSetsErrorTarget(e)},loadTileSetFromURL:(e,t,o)=>{if(void 0===t)return;let i=new TILES.TilesRenderer(e);if(!i)return;ATON._assetReqNew(e),i.displayBoxBounds=B._tsB,i.fetchOptions.mode="cors",i.registerPlugin(new TILES.ImplicitTilingPlugin),o&&(i.fetchOptions.headers={},i.fetchOptions.headers.Authorization=`Bearer ${o.accessToken}`,i.preprocessURL=e=>(e=new URL(e),/^http/.test(e.protocol)&&e.searchParams.append("v",o.v),e.toString())),i.errorTarget=B._tsET,i.optimizeRaycast=!1,void 0===B._pqLRU?(i.downloadQueue.schedulingCallback=B.tsSchedCB,i.parseQueue.schedulingCallback=B.tsSchedCB,i.downloadQueue.maxJobs=6,i.parseQueue.maxJobs=1,B._pqLRU=i.lruCache,B._pqDownload=i.downloadQueue,B._pqParse=i.parseQueue):(i.lruCache=B._pqLRU,i.downloadQueue=B._pqDownload,i.parseQueue=B._pqParse),i.setCamera(ATON.Nav._camera),i.setResolutionFromRenderer(ATON.Nav._camera,ATON._renderer),i.manager.addHandler(/\.gltf$/,ATON._aLoader),i.manager.addHandler(/\.ktx2$/,ATON._ktx2Loader),i.manager.addHandler(/\.drc$/,ATON._dracoLoader),t.add(i.group),$.getJSON(e,(e=>{ATON.CC.extract(e)}));let r=new THREE.Box3,a=new THREE.Sphere;new THREE.Matrix4,new THREE.Vector3;let s=!1;i.addEventListener("load-tile-set",(()=>{if(console.log("TileSet loaded"),ATON._assetReqComplete(e),B._numTSLoaded++,o||t.bUseGeoCoords){console.log("TileSet using GeoCoords"),i.getBoundingSphere(a);const e=a.center.clone(),t=e.length(),o=e.normalize(),r=new THREE.Vector3(0,1,0),s=ATON.Utils.rotationBetweenDirections(o,r);i.group.quaternion.x=s.x,i.group.quaternion.y=s.y,i.group.quaternion.z=s.z,i.group.quaternion.w=s.w,i.group.position.y=-t}else i.getBoundingBox(r)?(r.getBoundingSphere(a),t.autocenter?(r.getCenter(i.group.position),i.group.position.multiplyScalar(-1)):void 0===ATON.Nav.homePOV&&ATON.Nav.computeAndRequestDefaultHome(.5,void 0,a)):i.getBoundingSphere(a)&&(t.autocenter?(i.group.position.copy(a.center),i.group.position.multiplyScalar(-1)):void 0===ATON.Nav.homePOV&&ATON.Nav.computeAndRequestDefaultHome(.5,void 0,a))})),i.addEventListener("load-model",(e=>{let o=e.scene;B._numTilesLoaded++,o.traverse((e=>{if(e.layers.enable(t.type),e.isMesh?(e.castShadow=!0,e.receiveShadow=!0,B._bTileBVH&&e.geometry&&(e.geometry.computeVertexNormals(),e.geometry.computeBoundsTree({}),ATON.Utils._bvhBounds>0&&ATON.Utils._addBVHbounds(e,ATON.Utils._bvhBounds)),ATON._bqScene=!0):(s=!0,B._bPCs=!0,e.layers.disable(t.type),e.raycast=ATON.Utils.VOID_CAST,e.material=ATON.MatHub.materials.point),t.userData.cMat&&(e.material=t.userData.cMat),e.material){let t=e.material.map;t&&(t.minFilter=THREE.LinearMipmapLinearFilter,t.magFilter=THREE.LinearFilter,t.colorSpace=ATON._stdEncoding)}})),ATON.fireEvent("TileLoaded",o)})),i.addEventListener("dispose-model",((e,t)=>{ATON.Utils.cleanupVisitor(e.scene),e=null})),s||ATON.Utils.setPicking(t,t.type,!0),B._tsets.push(i)},loadCesiumIONAsset:(e,t)=>{let o=ATON.getAPIToken("cesium.ion");if(null==o&&(console.log("A valid Cesium ION token is required"),o=prompt("Please enter a valid Cesium ION token:"),null==o||""==o))return;let i=new URL(`https://api.cesium.com/v1/assets/${e}/endpoint`);i.searchParams.append("access_token",o),fetch(i,{mode:"cors"}).then((e=>e.ok?e.json():Promise.reject(`${e.status} : ${e.statusText}`))).then((e=>{i=new URL(e.url);const r=i.searchParams.get("v");B.loadTileSetFromURL(i.toString(),t,{accessToken:e.accessToken,v:r}),ATON.setAPIToken("cesium.ion",o)}))},update:()=>{const e=B._tsets.length;if(e<1)return;for(let t=0;t!!ATON.Nav._bControl&&(ATON.Nav._dOri>B.THRES_ORI||ATON.Nav._dPos>B.THRES_POS)};const q=B;let z={};window.ATON=z,z.Node=t,z.POV=class{constructor(e){this.pos=new THREE.Vector3(1,0,0),this.target=new THREE.Vector3(0,0,0),this.up=ATON.STD_UPVECTOR,this.fov=void 0,this.nextPOV=void 0,this.prevPOV=void 0,this.as(e)}as(e){if(void 0!==e)return ATON.Nav.povlist[e]=this,this.id=e,this}setPosition(e,t,o){return e instanceof THREE.Vector3?this.pos.copy(e):this.pos.set(e,t,o),this}setTarget(e,t,o){return e instanceof THREE.Vector3?this.target.copy(e):this.target.set(e,t,o),this}setFOV(e){return this.fov=e,this}addKeywords(e){let t=e.split(",");void 0===this.kwords&&(this.kwords={});for(let e in t){let o=t[e].trim();o.length>0&&(this.kwords[o]=!0)}return this}hasKeyword(e){if(void 0!==this.kwords)return void 0!==this.kwords[e]}setNextPOV(e){if(e)return this.nextPOV=e,this}setPrevPOV(e){if(e)return this.prevPOV=e,this}},z.LightProbe=class{constructor(e,t,o){this.pos=new THREE.Vector3(0,0,0),this._res=void 0!==e?e:128,this._near=void 0!==t?t:1,this._far=void 0!==o?o:ATON.Nav.STD_FAR,this._envtex=void 0,this._CC=void 0,void 0===ATON._pmremGenerator&&(ATON._pmremGenerator=new THREE.PMREMGenerator(ATON._renderer),ATON._pmremGenerator.compileCubemapShader())}setPosition(e,t,o){return e instanceof THREE.Vector3?this.pos.copy(e):this.pos.set(e,t,o),this}setNear(e){return this._near=e,this}setFar(e){return this._far=e,this}_createCCtarget(){this._CCtarget||(this._CCtarget=new THREE.WebGLCubeRenderTarget(this._res,{format:THREE.RGBEFormat,generateMipmaps:!0,minFilter:THREE.LinearMipmapLinearFilter,colorSpace:ATON._stdEncoding}))}update(){return this._envtex&&this._envtex.dispose(),ATON._rootVisibleGlobal.position.set(-this.pos.x,-this.pos.y,-this.pos.z),ATON._render(),this._envtex=ATON._pmremGenerator.fromScene(ATON._mainRoot,0,this._near,this._far).texture,ATON._rootVisibleGlobal.position.set(0,0,0),ATON._renderer.shadowMap.enabled&&ATON._dMainL&&(ATON._dMainL.shadow.needsUpdate=!0),this}getEnvTex(){return this._envtex}assignToNode(e){}},z.XPF=class{constructor(e){this.id=e,this._geom=void 0,this._mesh=void 0,this._pathbaselayer=void 0,this._size=20,this._location=new THREE.Vector3(0,0,0),this._rotation=new THREE.Vector3(0,0,0),this._lnode=ATON.Nav.addLocomotionNode(this._location),this._pathMod=void 0,this._semMasksURLs={},this._semHintURL=void 0}setSize(e){this._size=e}realizeSUI(){return void 0===this._lnode||this._lnode.realizeSUI(),this}realizeGeometry(){return void 0!==this._geom||(this._geom=new THREE.SphereGeometry(1,60,60),this._geom.scale(-this._size,this._size,this._size),this._geom.castShadow=!1,this._geom.receiveShadow=!1,this._mat=new THREE.MeshBasicMaterial({depthTest:!1,depthWrite:!1}),this._mesh=new THREE.Mesh(this._geom,this._mat),this._mesh.frustumCulled=!1,this._mesh.renderOrder=-100),this}getMesh(){return this._mesh}getLocomotionNode(){return this._lnode}setRotation(e,t,o){return e instanceof THREE.Vector3?this._rotation.copy(e):this._rotation.set(e,t,o),void 0===this._mesh||this._mesh.rotation.copy(this._rotation),this}getRotation(){return this._rotation}setLocation(e,t,o){return e instanceof THREE.Vector3?this._location.copy(e):this._location.set(e,t,o),this._lnode&&this._lnode.setLocation(this._location),void 0===this._mesh||this._mesh.position.copy(this._location),this}getLocation(){return this._location}hasGeometry(){return void 0!==this._geom}setPathModifier=e=>(this._pathMod=e,this);updateBaseLayer(){}setBaseLayer(e){if(void 0===e)return this;this._pathbaselayer=ATON.Utils.resolveCollectionURL(e);let t=this;return this._pathMod&&(this._pathbaselayer=this._pathMod(this._pathbaselayer)),this.hasGeometry()?(ATON.Utils.isVideo(this._pathbaselayer)||ATON.Utils.textureLoader.load(t._pathbaselayer,(e=>{e.colorSpace=ATON._stdEncoding,e.generateMipmaps=!0,t._mat.map=e,t._mat.map.needsUpdate=!0,t._mat.needsUpdate=!0,console.log("XPF base layer "+t._pathbaselayer+" loaded")})),this):this}setSemanticMask(e,t){return void 0===e||(this._semMasksURLs[e]=ATON.Utils.resolveCollectionURL(t),ATON.XPFNetwork.updateCurrentXPFsemLayer(this)),this}removeSemanticMask(e){return void 0===e||(this._semMasksURLs[e]=void 0,ATON.XPFNetwork.updateCurrentXPFsemLayer(this)),this}removeAllSemanticMasks(){return this._semMasksURLs={},this}getSemanticMaskURL(e){return this._semMasksURLs[e]}setSemanticHintMap(e){return void 0===e||(this._semHintURL=ATON.Utils.resolveCollectionURL(e),ATON.XPFNetwork.updateCurrentXPFsemLayer(this)),this}removeSemanticHintMap(){return this._semHintURL=void 0,ATON.XPFNetwork.updateCurrentXPFsemLayer(this),this}},z.Flare=class{constructor(e){this._id=void 0,this._bDeployed=!1,e&&this.register(e)}register(e){return e&&(this._id=e),ATON.addFlare(this),this}getID(){return this._id}log(e){return this._id?console.log("[Flare "+this._id+"] "+e):console.log("[Flare]"+e),this}setSetup(e){return this.setup=e,this}setUpdate(e){return this.update=e,this}},z.EventHub=i,z.Utils=n,z.CC=k,z.SceneHub=d,z.MatHub=a,z.Nav=m,z.AudioHub=u,z.XR=T,z.SUI=N,z.UI=A,z.Photon=b,z.SemFactory=f,z.FE=y,z.MediaFlow=M,z.Phygital=C,z.App=D,z.FX=F,z.XPFNetwork=I,z.MRes=q,z.STD_UPVECTOR=new THREE.Vector3(0,1,0),z.ROOT_NID=".",z.RAD2DEG=180/Math.PI,z.DEG2RAD=Math.PI/180,z.PATCH_ADD=0,z.PATCH_DEL=1,z.NTYPES={},z.NTYPES.SCENE=3,z.NTYPES.SEM=4,z.NTYPES.UI=5,z.SHADOWS_NEAR=.1,z.SHADOWS_FAR=50,z.SHADOWS_SIZE=15,z.SHADOWS_RES=1024,z.AMB_L=.2,z.SCALE_DEFAULT=0,z.SCALE_BIG=5,z.SCALE_VERYBIG=10,z.SCALE_SMALL=-5,z.SCALE_VERYSMALL=-10,z.Flares={},z._fReqList=[],z._bInitialized=!1,z._resMappers=[],z.setBaseURL=e=>{z.BASE_URL=e,z.PATH_RESTAPI=`${z.BASE_URL}/api/`,z.PATH_RESTAPI_SCENE=`${z.PATH_RESTAPI}scene/`,z.PATH_RESTAPI2=`${z.BASE_URL}/api/v2/`,z.PATH_WAPPS=`${z.BASE_URL}/a/`,z.PATH_DRACO_LIB=`${z.BASE_URL}/dist/draco/`,z.PATH_BASIS_LIB=`${z.BASE_URL}/dist/basis/`,z.PATH_COLLECTION=`${z.BASE_URL}/collections/`,z.PATH_SCENES=`${z.BASE_URL}/scenes/`,z.PATH_RES=`${z.BASE_URL}/res/`,z.PATH_FE=`${z.BASE_URL}/s/`},z.setBaseURL(window.location.origin),z.setPathCollection=e=>{z.PATH_COLLECTION=e},z.setPathScenes=e=>{z.PATH_SCENES=e},z.setAsStandalone=e=>{e||(e="../"),z.PATH_DRACO_LIB=e+"dist/draco/",z.PATH_BASIS_LIB=e+"dist/basis/",z.PATH_RES=e+"res/"},z.addResourceMapper=e=>{z._resMappers.push(e)},z._onUserInteraction=()=>{z._elPanoVideo&&!z._vpanoPlaying&&z._elPanoVideo.play(),z.XPFNetwork._elVid&&!z.XPFNetwork._vidPlaying&&z.XPFNetwork._elVid.play(),z.AudioHub._listener&&z.AudioHub._listener.context&&"suspended"===z.AudioHub._listener.context.state&&z.AudioHub._listener.context.resume();for(let e in z.MediaFlow._vStreams){let t=z.MediaFlow._vStreams[e].el;t.playing||t.uid||t.play()}},z.checkAuth=(e,t)=>{$.ajax({type:"GET",url:z.PATH_RESTAPI+"user",xhrFields:{withCredentials:!0},dataType:"json",success:o=>{void 0!==o&&o.username?e(o):t&&t()},error:()=>{t&&t()}})},z._setupBaseListeners=()=>{let e,t,o=z._renderer.domElement;window.addEventListener("resize",z._onResize,!1),window.onorientationchange=z._readDeviceOrientationMode,document.addEventListener("fullscreenchange",(e=>{z._bFS=!!document.fullscreenElement,z.fireEvent("Fullscreen",z._bFS),z._bFS?console.log("Now fullscreen"):console.log("Exit fullscreen")})),void 0!==document.hidden?(e="hidden",t="visibilitychange"):void 0!==document.mozHidden?(e="mozHidden",t="mozvisibilitychange"):void 0!==document.msHidden?(e="msHidden",t="msvisibilitychange"):void 0!==document.webkitHidden&&(e="webkitHidden",t="webkitvisibilitychange"),void 0!==e&&document.addEventListener(t,(()=>{if(document[e]){if(z.XR._bPresenting)return;console.log("Suspend"),z.renderPause()}else{if(z.XR._bPresenting)return;console.log("Resume"),z.renderResume()}}),!1),o.addEventListener("mousemove",z._updateScreenMove,!1),o.addEventListener("mousedown",(e=>{1===e.button&&z.fireEvent("MouseMidButton"),2===e.button&&z.fireEvent("MouseRightButton")})),o.addEventListener("wheel",z._onMouseWheel,!1),z._bPointerDown=!1,Hammer(o).on("doubletap",(e=>{z._bPointerDown=!1,z._onUserInteraction(),z.fireEvent("DoubleTap",e.srcEvent)})),Hammer(o).on("tap",(e=>{if(z._bPointerDown=!1,z._onUserInteraction(),z._updateScreenMove(e.srcEvent),z._handleQueries(),z.fireEvent("Tap",e.srcEvent),void 0===z._hoveredUI)return;let t=z.getUINode(z._hoveredUI);t&&t.onSelect&&t.onSelect()})),z.on("DoubleTap",(e=>{z.defaultDoubleTapFromScreenCoords(e)})),z._kModShift=!1,z._kModCtrl=!1,z._bListenKeyboardEvents=!0,window.addEventListener("keydown",(e=>{z._onUserInteraction(),"Shift"===e.key&&(z._kModShift=!0),"Control"===e.key&&(z._kModCtrl=!0),z._bListenKeyboardEvents&&z.fireEvent("KeyPress",e.key)}),!1),window.addEventListener("keyup",(e=>{"Shift"===e.key&&(z._kModShift=!1),"Control"===e.key&&(z._kModCtrl=!1),z._bListenKeyboardEvents&&z.fireEvent("KeyUp",e.key)}),!1),z.on("KeyPress",(e=>{if("+"===e){let e=z.Nav.getFOV()+1;z.Nav.setFOV(e)}if("-"===e){let e=z.Nav.getFOV()-1;z.Nav.setFOV(e)}}))},z._onResize=()=>{if(z.Nav._camera.aspect=window.innerWidth/window.innerHeight,z.Nav._camera.updateProjectionMatrix(),z._renderer.setSize(window.innerWidth,window.innerHeight),z.FX.composer&&(z.FX.composer.setSize(window.innerWidth,window.innerHeight),z.FX.passes[z.FX.PASS_AA])){let e=z.FX.passes[z.FX.PASS_AA].material.uniforms;e&&e.resolution.value.set(1/window.innerWidth,1/window.innerHeight)}console.log("onResize")},z._onMouseWheel=e=>{e.preventDefault(),z.fireEvent("MouseWheel",e.deltaY)},z.focusOn3DView=()=>{z._renderer.domElement.focus()},z._SUIactivation=()=>{const e=z.getUINode(z._hoveredUI);return void 0!==e&&void 0!==e.onSelect&&(e.onSelect(),!0)},z._stdActivation=()=>{if(z._SUIactivation())return;if(!z.Nav._bControl)return;if(void 0!==z.XPFNetwork._semCurr&&z.fireEvent("SemanticMaskSelect",z.XPFNetwork._semCurr),z.XR._bPresenting){if(m.requestTransitionToLocomotionNodeInSightIfAny(z.XR.STD_TELEP_DURATION))return;return"immersive-vr"===z.XR._sessionType&&z.XR.teleportOnQueriedPoint(),void z.FE.playAudioFromSemanticNode(z._hoveredSemNode)}if(z.Nav.isFirstPerson()||z.Nav.isDevOri()){if(m.requestTransitionToLocomotionNodeInSightIfAny(.5))return;if(z.Nav.currentQueryValidForLocomotion()){let e=z._queryDataScene.p,t=z.Nav._vDir,o=new THREE.Vector3(e.x,e.y+z.userHeight,e.z),i=new THREE.Vector3(o.x+t.x,o.y+t.y,o.z+t.z),r=(new z.POV).setPosition(o).setTarget(i).setFOV(z.Nav._currPOV.fov);z.Nav.requestPOV(r,.5)}return}let e=z.getSemanticNode(z._hoveredSemNode);z._queryDataSem&&e?z.Nav.requestPOVbyNode(e,.5):z._queryDataScene&&z.Nav.requestRetarget(z._queryDataScene.p,void 0,.5)},z.defaultDoubleTapFromScreenCoords=e=>{z._updateScreenMove(e),z._handleQueryScene(),z._stdActivation()},z.isFullscreen=()=>z._bFS,z.toggleFullScreen=()=>{document.fullscreenElement?document.exitFullscreen&&document.exitFullscreen():document.documentElement.requestFullscreen()},z.realize=e=>{console.log("Initialize ATON..."),z.Utils.init(),z.Utils.profileDevice(),z._clock=new THREE.Clock(!0),z.bounds=new THREE.Sphere,z._worldScale=1,z._ws=0,z._bFS=!1,z._renderer=new THREE.WebGLRenderer({antialias:!0,alpha:!0}),z._renderer.setSize(window.innerWidth,window.innerHeight),z.Utils.profileRenderingCapabilities(),z._stdpxd=1,z._fps=60,z._dt=.01,z._dtAccum=0,z._dtCount=0,z._avgFPSaccum=0,z._avgFPS=60,z._dRenderBudgetMinFPS=20,z._dRenderBudgetMaxFPS=55,z._bAdaptiveDensity=!0,z._adMin=.4,z._adMax=1.5,z.device.lowGPU&&(z._adMax=1),z._aniMixers=[],z._stdEncoding=THREE.LinearSRGBColorSpace,z._renderer.outputColorSpace=z._stdEncoding,z._renderer.toneMapping=THREE.LinearToneMapping,z._renderer.toneMappingExposure=1,e||z._renderer.setAnimationLoop(z._onFrame),z._maxAnisotropy=z._renderer.capabilities.getMaxAnisotropy(),z.userHeight=1.7,e||document.body.appendChild(z._renderer.domElement);let t=z._renderer.domElement;t.id="idView3D",t.style.outline="none",t.style.border="none",z.UI.init(),z._vpanoPlaying=!1,z._bUserInts=0,z.EventHub.init(),z.MatHub.init(),z._assetsManager={},z._aLoader=new THREE.GLTFLoader,z._numReqLoad=0,z._collMod=void 0,z._ktx2Loader=new THREE.KTX2Loader,z._ktx2Loader.setTranscoderPath(z.PATH_BASIS_LIB),z._ktx2Loader.detectSupport(z._renderer),z._dracoLoader=new THREE.DRACOLoader,z._dracoLoader.setDecoderPath(z.PATH_DRACO_LIB),z._dracoLoader.setWorkerLimit(2),z._dracoLoader.preload(),z._aLoader.setDRACOLoader(z._dracoLoader),z._aLoader.setKTX2Loader(z._ktx2Loader),THREE.DefaultLoadingManager.addHandler(/\.ktx2$/,z._ktx2Loader),z._updRoutines=[],z._pmremGenerator=void 0,z._lps=[],z._bAutoLP=!1,z._envMapInt=1,z._numLPbounces=2,z._lpbCount=0,z._bShadowsFixedBound=!1,z._shadowsFixedBoundCenter=void 0,z._shadowsNear=z.SHADOWS_NEAR,z._shadowsFar=z.SHADOWS_FAR,z._shadowsSize=z.SHADOWS_SIZE,z._shadowsRes=z.SHADOWS_RES,z.initGraphs(),z.SceneHub.init(),z.MRes.init(),z.CC.init(),z.AudioHub.init(),z.Nav.init(),z.XR.init(),z.SUI.init(),z.Photon.init(),z.VRoadcast=z.Photon,z.MediaFlow.init(),z.SemFactory.init(),z.Phygital.init(),z.XPFNetwork.init(),z.device.lowGPU||z.device.isMobile||z.FX.init(),z.FX.composer||(z._render=()=>{z._renderer.render(z._mainRoot,z.Nav._camera)}),z.setDefaultPixelDensity(1),z._queryDataScene=void 0,z._queryDataSem=void 0,z._queryDataUI=void 0,z._hoveredSemNode=void 0,z._hoveredUI=void 0,z._bq=!0,z._bQuerySemOcclusion=!0,z._bQueryNormals=!0,z._bPauseQuery=!1,z._bCenteredQuery=!1,z._bqScene=!1,z._bqSem=!1,z._qSync=0,z._qSyncInt=1,z._tgiDur=void 0,z._tgiPer=void 0,z._tHover=void 0,z._bMainPanoInfinite=!0,z._matMainPano=void 0,z._mMainPano=void 0,z._screenPointerCoords=new THREE.Vector2(0,0),z._rcScene=new THREE.Raycaster,z._rcScene.layers.set(z.NTYPES.SCENE),z._rcScene.firstHitOnly=!0,z._rcSemantics=new THREE.Raycaster,z._rcSemantics.layers.set(z.NTYPES.SEM),z._rcSemantics.firstHitOnly=!0,z._rcUI=new THREE.Raycaster,z._rcUI.layers.set(z.NTYPES.UI),z._rcUI.firstHitOnly=!0,z._setupBaseListeners(),z.device.isMobile&&z._readDeviceOrientationMode(),z._fLoading=0,z._fRequired=z._fReqList.length,z._loadFlares(),z._gizmo=void 0,z._bGizmo=!1,z.focusOn3DView(),z._bInitialized=!0},z.addFlare=e=>{if(void 0===e)return;let t=Object.keys(z.Flares).length,o=e.getID();o?z.Flares[o]=e:z.Flares["F"+t]=e},z.registerFlare=z.addFlare,z.getFlare=e=>z.Flares[e],z.loadScript=(e,t,o)=>{let i=document.createElement("script");i.src=e,i.async=!1,document.head.appendChild(i),t&&(i.onload=t),o&&(i.onerror=o)},z._loadFlare=e=>{z._fLoading++,$.get(z.PATH_RESTAPI2+"flares/"+e,(t=>{let o=t.files;if(o){let t=o.length;for(let i in o)z.loadScript("/flares/"+e+"/"+o[i],(()=>{t--,t<=0&&z._onFlareLoaded(e)}),(()=>{console.log("Missing flare '"+e+"' dependency: "+o[i]),t--,t<=0&&z._onFlareLoaded(e)}))}})).fail((()=>{console.log("Flare "+e+" not found."),z._onFlareError(e)}))},z._loadFlares=()=>{if(z._fRequired<=0)z.fireEvent("AllFlaresReady");else for(let e in z._fReqList)z._loadFlare(z._fReqList[e])},z._onFlareLoaded=e=>{console.log("All deps loaded for flare '"+e+"'"),z._deployNewFlares(),z._fLoading--,z._fLoading<=0&&z._onAllFlaresLoaded()},z._onFlareError=e=>{z._fLoading--,z._fLoading<=0&&z._onAllFlaresLoaded()},z._onAllFlaresLoaded=()=>{console.log("All Flares ready!"),z.fireEvent("AllFlaresReady")},z._deployFlare=e=>{e._bDeployed||(void 0!==e.setup&&e.setup(),void 0!==e.update&&z.addUpdateRoutine(e.update),e._bDeployed=!0)},z._deployNewFlares=()=>{for(let e in z.Flares)z._deployFlare(z.Flares[e])},z.setCollectionPathModifier=e=>{z._collMod=e},z.setTimedGazeDuration=e=>{z._tgiDur=e},z.getTimedGazeProgress=()=>{if(void 0!==z._tgiDur)return z._tgiPer},z.getElapsedTime=()=>z._clock.elapsedTime,z.renderPause=()=>{z._renderer.setAnimationLoop(void 0)},z.renderResume=()=>{z._renderer.setAnimationLoop(z._onFrame)},z._setupLoadManager=()=>{z._loadManager=new THREE.LoadingManager,z._loadManager.onStart=(e,t,o)=>{console.log("Started loading file: "+e+".\nLoaded "+t+" of "+o+" files."),z.fireEvent("NodeRequestFired",e)},z._loadManager.onLoad=()=>{console.log("Loading complete!"),z.fireEvent("AllNodeRequestsCompleted")},z._loadManager.onProgress=(e,t,o)=>{},z._loadManager.onError=e=>{console.log("There was an error loading "+e)}},z.setDefaultPixelDensity=e=>{z._stdpxd=e,z._renderer.setPixelRatio(e),z.FX.composer&&z.FX.composer.setPixelRatio(e),void 0!==z._renderer.xr&&(z.device.isMobile?z._renderer.xr.setFramebufferScaleFactor(z._stdpxd*z.XR.MOBILE_DENSITY_F):z._renderer.xr.setFramebufferScaleFactor(z._stdpxd))},z.resetPixelDensity=()=>{z._renderer.setPixelRatio(z._stdpxd)},z._readDeviceOrientationMode=()=>{90===Math.abs(window.orientation)?(console.log("Landscape Mode"),z.fireEvent("MobileLandscapeMode")):(console.log("Portrait Mode"),z.fireEvent("MobilePortraitMode")),setTimeout(z._onResize,500)},z.snodes={},z.semnodes={},z.uinodes={},z.createSceneNode=e=>new z.Node(e,z.NTYPES.SCENE),z.getSceneNode=e=>{if(void 0!==e)return z.snodes[e]},z.getOrCreateSceneNode=e=>{let t=z.getSceneNode(e);return void 0!==t?t:z.createSceneNode(e)},z.getRootScene=()=>z._rootVisible,z.createSemanticNode=e=>new z.Node(e,z.NTYPES.SEM),z.getSemanticNode=e=>{if(void 0!==e)return z.semnodes[e]},z.getOrCreateSemanticNode=e=>{let t=z.getSemanticNode(e);return void 0!==t?t:z.createSemanticNode(e)},z.getRootSemantics=()=>z._rootSem,z.createUINode=e=>new z.Node(e,z.NTYPES.UI),z.getUINode=e=>{if(void 0!==e)return z.uinodes[e]},z.getRootUI=()=>z._rootUI,z._unpackScale=e=>0==e?1:e>=0?1.1*e:1/(-1.1*e),z.setUserScaleLevel=e=>{z.setWorldScaleLevel(-e)},z.getUserScale=()=>1/z._worldScale,z.setWorldScaleLevel=e=>{void 0===e&&(e=0),e<-127&&(e=127),e>127&&(e=127),z._ws=e;let t=z._unpackScale(e);z._rootVisible.scale.set(t,t,t),z._rootSem.scale.set(t,t,t),N.gLocNodes.scale.set(t,t,t),N.gMeasures.scale.set(t,t,t),z.Photon.avaGroup&&z.Photon.avaGroup.scale.set(t,t,t),z.recomputeSceneBounds();let o=t/z._worldScale;z.Nav._currPOV.pos.x*=o,z.Nav._currPOV.pos.y*=o,z.Nav._currPOV.pos.z*=o,z.Nav._currPOV.target.x*=o,z.Nav._currPOV.target.y*=o,z.Nav._currPOV.target.z*=o,z.Nav.syncCurrCamera(),z.XR._bPresenting&&z.XR.setRefSpaceLocation(z.Nav._currPOV.pos),z._worldScale=t,console.log("World scale: "+t)},z.getWorldScaleLevel=()=>z._ws,z.getWorldScale=()=>z._worldScale,z._assetReqNew=e=>{z._numReqLoad++,z.fireEvent("NodeRequestFired",e)},z._assetReqComplete=e=>{z.fireEvent("NodeRequestCompleted",e),z._numReqLoad--,z._numReqLoad<=0&&z._onAllReqsCompleted()},z._onAllReqsCompleted=()=>{z.recomputeSceneBounds(),z.getRootScene().assignLightProbesByProximity(),z.fireEvent("AllNodeRequestsCompleted"),z._postAllReqsCompleted(),setTimeout((()=>{z.updateLightProbes(),z._renderer.shadowMap.enabled&&z._bShadowsFixedBound&&0===z._aniMixers.length&&(z._dMainL.shadow.autoUpdate=!1,console.log("Lazy shadows"))}),1e3)},z._postAllReqsCompleted=e=>{void 0===e&&(e=z._rootVisible);for(let t in e.children){let o=e.children[t];o&&o.toggle&&(z._postAllReqsCompleted(o),o.toggle(o.visible))}ThreeMeshUI.update()},z.recomputeSceneBounds=e=>{e?z.bounds.union(e):(z.bounds.center.copy(z._rootVisible.getBound().center),z.bounds.radius=z._rootVisible.getBound().radius),z.bounds.radius<=0||(z._renderer.shadowMap.enabled&&(z._rootVisible.traverse((e=>{e.isMesh&&(e.castShadow=!0,e.receiveShadow=!0)})),z.adjustShadowsParamsFromSceneBounds(),z._bShadowsFixedBound&&z.updateDirShadows()),z._bAutoLP&&(void 0===z._lps[0]?z.addLightProbe((new z.LightProbe).setPosition(z.bounds.center).setNear(z.bounds.radius)):z._lps[0].setPosition(z.bounds.center).setNear(z.bounds.radius),console.log("Auto LP")),z.FX.composer&&z.FX.setDOFaperture(1/(30*z.bounds.radius)),z._mMainPano&&z._mMainPano.position.copy(z.bounds.center))},z.registerNodeResourceHandler=(e,t)=>{z._resHandler||(z._resHandler={}),z._resHandler[e]=t,console.log("Registered resource handler '"+e+"'")},z.removeNodeResourceHanlder=e=>{z._resHandler&&z._resHandler[e]&&(z._resHandler[e]=void 0)},z.initGraphs=()=>{z._mainRoot=new THREE.Scene,z._mainRoot.background=new THREE.Color(.7,.7,.7),z._rootVisibleGlobal=new THREE.Scene,z._mainRoot.add(z._rootVisibleGlobal),z._rootVisible=z.createSceneNode().setAsRoot(),z._rootVisibleGlobal.add(z._rootVisible),z._rootSem=z.createSemanticNode().setAsRoot(),z._mainRoot.add(z._rootSem),z._rootUI=z.createUINode().setAsRoot(),z._mainRoot.add(z._rootUI),z.ambLight=new THREE.AmbientLight(new THREE.Color(1,1,1)),z.ambLight.intensity=3,z._rootVisibleGlobal.add(z.ambLight),z.plight=new THREE.PointLight,z.plight.intensity=0,z.plight.decay=.2,z._rootVisibleGlobal.add(z.plight)},z.enablePointLight=()=>{z.plight.intensity=3},z.disablePointLight=()=>{z.plight.intensity=0},z.setBackgroundColor=e=>{z._mainRoot.background=e},z.setFog=(e,t)=>{void 0!==e&&(void 0===t&&(t=200),z._rootVisibleGlobal.fog=new THREE.Fog(e,1,t),z.setBackgroundColor(e))},z.disableFog=()=>{z._rootVisibleGlobal.fog=null},z.setAutoLP=e=>{z._bAutoLP=e},z.setNeutralAmbientLight=e=>{z.ambLight.color=new THREE.Color(e,e,e)},z.addLightProbe=e=>{void 0!==e&&(z._lps.push(e),z.setNeutralAmbientLight(0),void 0!==z.SUI.gLPIcons&&N.addLPIcon(e))},z.getNumLightProbes=()=>z._lps.length,z._updLP=()=>{for(let e in z._lps)z._lps[e].update();z._rootVisible.traverse((e=>{let t=e.userData.LP;void 0!==t&&t instanceof z.LightProbe&&(e.material.envMap=t.getEnvTex(),e.material.envMapIntensity=z._envMapInt,e.material.needsUpdate=!0)}))},z.setLightProbesNumBounces=e=>{e<1||(z._numLPbounces=e)},z.dirtyLightProbes=e=>{void 0===e&&(e=z._numLPbounces),z._lpbCount=e},z.updateLightProbes=()=>{if(!z.XR._bPresenting&&0!==z._lps.length){for(let e=0;e{let t;if(e=z.Utils.resolveCollectionURL(e),void 0===z._mMainPano&&(z._gMainPano=new THREE.SphereGeometry(1,60,60),z._gMainPano.castShadow=!1,z._gMainPano.receiveShadow=!1,z._mMainPano=new THREE.Mesh(z._gMainPano,z._matMainPano),z._mMainPano.frustumCulled=!1,z._mMainPano.renderOrder=-100,z._mMainPano.layers.disable(z.NTYPES.SCENE),z._mMainPano.layers.disable(z.NTYPES.SEM),z._mMainPano.layers.disable(z.NTYPES.UI),z._mMainPano.raycast=z.Utils.VOID_CAST,z.setMainPanoramaRadius(.8*z.Nav.STD_FAR)),z.Utils.isVideo(e)){if(void 0===z._elPanoVideo){let t="",$(t).appendTo("body"),z._elPanoVideo=document.getElementById("idPanoVideo"),z._elPanoVideo.onplaying=()=>{console.log("VideoPano playing"),z._vpanoPlaying=!0},z._elPanoVideo.onpause=()=>{console.log("VideoPano paused"),z._vpanoPlaying=!1},z._elPanoVideo.addEventListener("touchstart",(function(){z._elPanoVideo.play()})),enableInlineVideo(z._elPanoVideo)}t=new THREE.VideoTexture(z._elPanoVideo),t.colorSpace=z._stdEncoding,z._realizeOrUpdateMainPano(t),z.fireEvent("MainPanoVideo")}else{if(e.endsWith(".hdr"))return void(new THREE.RGBELoader).load(e,(e=>{e.minFilter=THREE.LinearMipmapLinearFilter,e.magFilter=THREE.LinearFilter,e.colorSpace=z._stdEncoding,z._realizeOrUpdateMainPano(e),z.fireEvent("MainPanoHDR")}));if(e.endsWith(".exr"))return void(new THREE.EXRLoader).load(e,(e=>{e.minFilter=THREE.LinearMipmapLinearFilter,e.magFilter=THREE.LinearFilter,e.colorSpace=z._stdEncoding,z._realizeOrUpdateMainPano(e),z.fireEvent("MainPanoHDR")}));z.Utils.textureLoader.load(e,(e=>{e.colorSpace=z._stdEncoding,e.generateMipmaps=!0,z._realizeOrUpdateMainPano(e),z.fireEvent("MainPano")}))}},z.playMainPanorama=()=>{z._elPanoVideo&&(z._vpanoPlaying||z._elPanoVideo.play())},z.pauseMainPanorama=()=>{z._elPanoVideo&&z._vpanoPlaying&&z._elPanoVideo.pause()},z.playOrPauseMainPanorama=()=>{z._elPanoVideo&&(z._vpanoPlaying?z._elPanoVideo.pause():z._elPanoVideo.play())},z.stopAndRemoveMainPanorama=()=>{z._elPanoVideo&&(z._vpanoPlaying&&z._elPanoVideo.pause(),z._elPanoVideo.remove(),z._elPanoVideo=void 0,z._vpanoPlaying=!1)},z._realizeOrUpdateMainPano=e=>{if(void 0!==z._matMainPano)return z._matMainPano.map=e,void z.updateLightProbes();z._matMainPano=new THREE.MeshBasicMaterial({map:e,depthTest:!1,depthWrite:!1}),z._mMainPano.material=z._matMainPano,z._bMainPanoInfinite&&(z._mMainPano.onAfterRender=()=>{"immersive-ar"!==z.XR._sessionType&&z.Nav._currPOV&&z._mMainPano.position.copy(z.Nav._currPOV.pos)}),z._rootVisibleGlobal.add(z._mMainPano),z.updateLightProbes()},z.setMainPanoramaRadius=e=>{void 0!==z._gMainPano&&z._gMainPano.scale(-e,e,e)},z.setMainPanoramaRotation=e=>{void 0!==z._mMainPano&&z._mMainPano.rotation.set(0,e,0)},z.setMainPanoramaInfinite=e=>{z._bMainPanoInfinite=e,void 0!==z._mMainPano&&(z._mMainPano.onAfterRender=e?()=>{z.Nav._currPOV&&z._mMainPano.position.copy(z.Nav._currPOV.pos)}:void 0)},z.setMainPanoramaLocation=e=>{z._bMainPanoInfinite||void 0!==z._mMainPano&&z._mMainPano.position.copy(e)},z.setMainLightDirection=e=>{let t=e.clone();t.normalize(),t.x*=.5*z.SHADOWS_FAR,t.y*=.5*z.SHADOWS_FAR,t.z*=.5*z.SHADOWS_FAR,void 0===z._dMainL&&(z._dMainL=new THREE.DirectionalLight(new THREE.Color(1,1,1),1),z._dMainL.castShadow=!1,z._dMainL.intensity=2,z._dMainLtgt=new THREE.Object3D,z._rootVisibleGlobal.add(z._dMainLtgt),z._dMainL.target=z._dMainLtgt,z._rootVisibleGlobal.add(z._dMainL),z._dMainLpos=new THREE.Vector3),z._dMainLdir=t,z._dMainL.position.set(-t.x,-t.y,-t.z),z._renderer.shadowMap.enabled&&(z._dMainL.shadow.needsUpdate=!0),z.toggleMainLight(!0)},z.getMainLightDirection=()=>{if(void 0===z._dMainLdir)return;let e=z._dMainLdir.clone();return e.normalize(),e},z.toggleMainLight=e=>{if(void 0===z._dMainL)return;z._dMainL.visible=e;let t=z._lps.length;e?(t>0?z.setNeutralAmbientLight(0):z.setNeutralAmbientLight(z.AMB_L),z.updateDirShadows()):t>0?z.setNeutralAmbientLight(0):z.setNeutralAmbientLight(z.AMB_L)},z.isMainLightEnabled=()=>void 0!==z._dMainL&&!!z._dMainL.visible,z.setExposure=e=>{z._renderer.toneMappingExposure=e},z.getExposure=()=>z._renderer.toneMappingExposure,z.adjustShadowsParamsFromSceneBounds=()=>{if(void 0===z._dMainL)return;let e=z._rootVisible.getBound().radius,t=z._rootVisible.getBound().center;e<=0||e>=z.SHADOWS_SIZE?(z._bShadowsFixedBound=!1,z._shadowsSize=z.SHADOWS_SIZE):(z._bShadowsFixedBound=!0,z._shadowsFixedBoundCenter=t,z._shadowsSize=1.5*e),z._dMainL.shadow.map&&(z._dMainL.shadow.map.dispose(),z._dMainL.shadow.map=null),z._dMainL.shadow.camera.left=-z._shadowsSize,z._dMainL.shadow.camera.right=z._shadowsSize,z._dMainL.shadow.camera.bottom=-z._shadowsSize,z._dMainL.shadow.camera.top=z._shadowsSize,z._dMainL.shadow.mapSize.width=z._shadowsRes,z._dMainL.shadow.mapSize.height=z._shadowsRes,z._dMainL.shadow.camera.near=z._shadowsNear,z._dMainL.shadow.camera.far=z._shadowsFar;let o=-2e-4*e;o<-.001&&(o=-.001),z._dMainL.shadow.bias=o},z.toggleShadows=e=>{if(void 0!==z._dMainL)if(e){if(z.XR.isPresenting())return;if(z.device.lowGPU)return;z._dMainL.castShadow=!0,z._renderer.shadowMap.enabled=!0,z.device.isMobile?z._renderer.shadowMap.type=THREE.PCFShadowMap:z._renderer.shadowMap.type=THREE.PCFSoftShadowMap,z._rootVisible.traverse((e=>{e.isMesh&&(e.castShadow=!0,e.receiveShadow=!0)})),z.adjustShadowsParamsFromSceneBounds(),z.updateDirShadows(),z._dMainL.shadow.needsUpdate=!0,console.log("Shadows ON")}else z._dMainL.castShadow=!1,z._renderer.shadowMap.enabled=!1,console.log("Shadows OFF")},z.updateDirShadows=()=>{if(void 0===z._dMainLdir)return;if(void 0===z._dMainLpos)return;let e=z._shadowsFixedBoundCenter;void 0===e?(e=z.Nav.getCurrentEyeLocation(),z._dMainLpos.x=e.x+z.Nav._vDir.x*z._shadowsSize,z._dMainLpos.y=e.y+z.Nav._vDir.y*z._shadowsSize,z._dMainLpos.z=e.z+z.Nav._vDir.z*z._shadowsSize):(z._dMainLpos.x=e.x,z._dMainLpos.y=e.y,z._dMainLpos.z=e.z),z._dMainL.position.set(z._dMainLpos.x-z._dMainLdir.x,z._dMainLpos.y-z._dMainLdir.y,z._dMainLpos.z-z._dMainLdir.z),z._dMainLtgt.position.copy(z._dMainLpos)},z._updateEnvironment=()=>{z._renderer.shadowMap.enabled&&(z._bShadowsFixedBound||z.updateDirShadows())},z.setGlobalAudio=(e,t)=>{void 0!==e&&(void 0===t&&(t=!0),e=z.Utils.resolveCollectionURL(e),void 0===z._auMain||null===z._auMain?z._auMain=new THREE.Audio(z.AudioHub._listener):z._auMain.isPlaying&&z._auMain.stop(),z.AudioHub._loader.load(e,(e=>{z._auMain.setBuffer(e),z._auMain.setLoop(t),z._auMain.play()})))},z._markFPS=()=>{z._numReqLoad>0||z._dt<0||(z._dtCount+=1,z._dtAccum+=z._dt,z._dtAccum<1||(z._fps=1/(z._dtAccum/z._dtCount),z._dtCount=0,z._dtAccum=0,z._handleDynamicRenderProfiles()))},z.toggleAdaptiveDensity=e=>{z._bAdaptiveDensity=e},z.setAdaptiveDensityRange=(e,t)=>{e>=t||(z._adMin=e,z._adMax=t)},z.setDynamicRenderingFPS=(e,t)=>{e>=t||(e&&(z._dRenderBudgetMinFPS=e),t&&(z._dRenderBudgetMaxFPS=t))},z._handleDynamicRenderProfiles=()=>{let e=z._renderer.getPixelRatio();z._fps=z._adMin&&(z._renderer.setPixelRatio(e),z.FX.composer&&z.FX.composer.setPixelRatio(e),console.log("Density: "+e.toPrecision(2)))),z.fireEvent("RequestLowerRender")),z._fps>z._dRenderBudgetMaxFPS&&(z._bAdaptiveDensity&&!z.XR._bPresenting&&(e+=.1,e<=z._adMax&&(z._renderer.setPixelRatio(e),z.FX.composer&&z.FX.composer.setPixelRatio(e),console.log("Density: "+e.toPrecision(2)))),z.fireEvent("RequestHigherRender"))},z._onFrame=()=>{z._dt=z._clock.getDelta(),z._markFPS(),z.XR._bPresenting?z.XR.update():z.Nav._controls.update(z._dt),z._handleQueries(),z.Nav.update(),z.Photon.update(),z.SUI.update(),z.MatHub.update(),z._updateEnvironment(),z._updateAniMixers(),z._updateRoutines(),z.MRes.update(),z.XPFNetwork.update(),z._render()},z._render=()=>{!z.FX.composer||z.XR._bPresenting?z._renderer.render(z._mainRoot,z.Nav._camera):z.FX.composer.render()},z.addUpdateRoutine=e=>{void 0!==e&&z._updRoutines.push(e)},z.deleteAllUpdateRoutines=()=>{z._updRoutines=[]},z._updateRoutines=()=>{let e=z._updRoutines.length;if(!(e<=0))for(let t=0;t{let e=z._aniMixers.length;if(!(e<1))for(let t=0;t{e.preventDefault&&e.preventDefault(),z._bCenteredQuery||(z._screenPointerCoords.x=e.clientX/window.innerWidth*2-1,z._screenPointerCoords.y=-e.clientY/window.innerHeight*2+1)},z.toggleCenteredQuery=e=>{z._bCenteredQuery=e,e&&(z._screenPointerCoords.x=0,z._screenPointerCoords.y=0)},z.toggleQueries=e=>{z._bq=e},z._registerRCS=()=>{z._rcRR=0,z._rcHandlers=[],z._rcHandlers.push(z._handleQueryScene),z._rcHandlers.push(z._handleQuerySemantics),z._rcHandlers.push(z._handleQueryUI)},z._handleQueries=()=>{if(!z._bq)return;if(z._bPauseQuery)return;if(z.Nav._bInteracting)return;if(z._numReqLoad>0)return;if(z.Nav.isTransitioning())return;if(z._handleQueryUI(),z._bqScene&&z._handleQueryScene(),z._bqSem&&z._handleQuerySemantics(),z.Nav._bLocValidator&&z.Nav.locomotionValidator(),void 0===z._tgiDur)return;if(void 0===z._tHover)return;const e=z._clock.elapsedTime-z._tHover;e>=z._tgiDur?(z._stdActivation(),z._tHover=void 0,z._tgiPer=void 0):z._tgiPer=e/z._tgiDur},z._handleQueryScene=()=>{if(z.XR.isPresenting()?z.XR.setupQueryRay(z._rcScene):z._rcScene.setFromCamera(z._screenPointerCoords,z.Nav._camera),z._hitsScene=[],z._rcScene.intersectObjects(z._mainRoot.children,!0,z._hitsScene),z._hitsScene.length<=0)return void(z._queryDataScene=void 0);const e=z._hitsScene[0];z._queryDataScene={},z._queryDataScene.p=e.point,z._queryDataScene.d=e.distance,z._queryDataScene.o=e.object,z._queryDataScene.uv=e.uv,z._bQueryNormals&&e.face&&e.face.normal&&(z._queryDataScene.matrixWorld=(new THREE.Matrix3).getNormalMatrix(e.object.matrixWorld),z._queryDataScene.n=e.face.normal.clone().applyMatrix3(z._queryDataScene.matrixWorld).normalize())},z.getSceneFocalPoint=()=>{if(void 0===z._queryDataScene)return;let e=z._queryDataScene.p,t=new THREE.Vector3;return t.lerpVectors(e,z.Nav._currPOV.pos,.02),t},z.getSceneQueriedPoint=()=>{if(void 0!==z._queryDataScene)return z._queryDataScene.p},z.getSceneQueriedDistance=()=>{if(void 0!==z._queryDataScene)return z._queryDataScene.d},z.getSceneQueriedNormal=()=>{if(void 0!==z._queryDataScene)return z._queryDataScene.n},z.getSceneQueriedObjectName=()=>{if(void 0!==z._queryDataScene&&void 0!==z._queryDataScene.o)return z._queryDataScene.o.name},z.getSceneQueriedUV=()=>{if(void 0!==z._queryDataScene)return z._queryDataScene.uv},z.setQueryRange=(e,t,o)=>{void 0!==o&&o!==z.NTYPES.SCENE||(z._rcScene.near=e,z._rcScene.far=t),void 0!==o&&o!==z.NTYPES.SEM||(z._rcSemantics.near=e,z._rcSemantics.far=t)},z._handleQuerySemantics=()=>{if(z.XR.isPresenting()?z.XR.setupQueryRay(z._rcSemantics):z._rcSemantics.setFromCamera(z._screenPointerCoords,z.Nav._camera),z._hitsSem=[],z._rcSemantics.intersectObjects(z._mainRoot.children,!0,z._hitsSem),z._hitsSem.length<=0){if(z._queryDataSem=void 0,z._hoveredSemNode){z.fireEvent("SemanticNodeLeave",z._hoveredSemNode);let e=z.getSemanticNode(z._hoveredSemNode);e&&e.onLeave&&e.onLeave()}return z._hoveredSemNode=void 0,void(z._tHover=void 0)}const e=z._hitsSem[0];if(z._bQuerySemOcclusion&&z._queryDataScene&&z._queryDataScene.d{if(z.XR.isPresenting()?z.XR.setupQueryRay(z._rcUI):z._rcUI.setFromCamera(z._screenPointerCoords,z.Nav._camera),z._hitsUI=[],z._rcUI.intersectObjects(z._mainRoot.children,!0,z._hitsUI),z._hitsUI.length<=0){if(z._queryDataUI=void 0,z._hoveredUI){z.fireEvent("UINodeLeave",z._hoveredUI);const e=z.getUINode(z._hoveredUI);e&&e.onLeave&&e.onLeave()}return z._hoveredUI=void 0,void(z._tHover=void 0)}const e=z._hitsUI[0];if(z._queryDataScene&&z._queryDataScene.d{if(void 0!==z._hoveredSemNode)return z.getSemanticNode(z._hoveredSemNode)},z.setAPIToken=(e,t)=>{window.sessionStorage.setItem("ATON.tokens."+e,t)},z.getAPIToken=e=>window.sessionStorage.getItem("ATON.tokens."+e),z.clearToken=e=>{window.sessionStorage.removeItem("ATON.tokens."+e)},z.useGizmo=e=>{z._bGizmo=e,z._setupGizmo()},z._setupGizmo=()=>{z._bGizmo?void 0!==z.Nav._camera&&void 0!==z._renderer&&(void 0===z._gizmo?(z._gizmo=new THREE.TransformControls(z.Nav._camera,z._renderer.domElement),z._rootUI.add(z._gizmo),z._gizmo.setMode("rotate"),z._gizmo.addEventListener("dragging-changed",(function(e){let t=e.value;z.Nav.setUserControl(!t),z._bPauseQuery=t,t||(z.recomputeSceneBounds(),z.updateLightProbes(),console.log(z._gizmo.object))}))):(z._gizmo.camera=z.Nav._camera,z._gizmo.detach())):z._gizmo&&z._gizmo.detach()}})(); \ No newline at end of file diff --git a/public/dist/THREE.bundle.js b/public/dist/THREE.bundle.js index f72ac306..b6c56f6d 100644 --- a/public/dist/THREE.bundle.js +++ b/public/dist/THREE.bundle.js @@ -1,2 +1,2 @@ /*! For license information please see THREE.bundle.js.LICENSE.txt */ -(()=>{"use strict";var t={d:(e,n)=>{for(var i in n)t.o(n,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:n[i]})}};t.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),t.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),t.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var e={};t.r(e),t.d(e,{ACESFilmicToneMapping:()=>ft,AddEquation:()=>P,AddOperation:()=>ct,AdditiveAnimationBlendMode:()=>Ze,AdditiveBlending:()=>T,AgXToneMapping:()=>gt,AlphaFormat:()=>Kt,AlwaysCompare:()=>Fn,AlwaysDepth:()=>tt,AlwaysStencilFunc:()=>Tn,AmbientLight:()=>Ep,AnimationAction:()=>ff,AnimationClip:()=>Xd,AnimationLoader:()=>ip,AnimationMixer:()=>gf,AnimationObjectGroup:()=>pf,AnimationUtils:()=>Ud,ArcCurve:()=>tu,ArrayCamera:()=>ec,ArrowHelper:()=>cm,AttachedBindMode:()=>vt,Audio:()=>Kp,AudioAnalyser:()=>rf,AudioContext:()=>Op,AudioListener:()=>Jp,AudioLoader:()=>kp,AxesHelper:()=>hm,BackSide:()=>M,BasicDepthPacking:()=>nn,BasicShadowMap:()=>_,BatchedMesh:()=>Eh,Bone:()=>qc,BooleanKeyframeTrack:()=>zd,Box2:()=>Bf,Box3:()=>Wi,Box3Helper:()=>rm,BoxGeometry:()=>$s,BoxHelper:()=>im,BufferAttribute:()=>ws,BufferGeometry:()=>ks,BufferGeometryLoader:()=>Rp,ByteType:()=>Qt,Cache:()=>Jd,Camera:()=>sa,CameraHelper:()=>tm,CanvasTexture:()=>Kh,CapsuleGeometry:()=>xu,CatmullRomCurve3:()=>au,CineonToneMapping:()=>pt,CircleGeometry:()=>wu,ClampToEdgeWrapping:()=>St,Clock:()=>Vp,Color:()=>hs,ColorKeyframeTrack:()=>Gd,ColorManagement:()=>yi,CompressedArrayTexture:()=>Yh,CompressedCubeTexture:()=>Jh,CompressedTexture:()=>Xh,CompressedTextureLoader:()=>rp,ConeGeometry:()=>Eu,ConstantAlphaFactor:()=>K,ConstantColorFactor:()=>Y,Controls:()=>dm,CubeCamera:()=>ua,CubeReflectionMapping:()=>xt,CubeRefractionMapping:()=>wt,CubeTexture:()=>da,CubeTextureLoader:()=>ap,CubeUVReflectionMapping:()=>Mt,CubicBezierCurve:()=>hu,CubicBezierCurve3:()=>uu,CubicInterpolant:()=>Fd,CullFaceBack:()=>A,CullFaceFront:()=>v,CullFaceFrontBack:()=>y,CullFaceNone:()=>g,Curve:()=>Zh,CurvePath:()=>vu,CustomBlending:()=>D,CustomToneMapping:()=>mt,CylinderGeometry:()=>Cu,Cylindrical:()=>Sf,Data3DTexture:()=>ki,DataArrayTexture:()=>Fi,DataTexture:()=>Xc,DataTextureLoader:()=>op,DataUtils:()=>ys,DecrementStencilOp:()=>vn,DecrementWrapStencilOp:()=>_n,DefaultLoadingManager:()=>Zd,DepthFormat:()=>ne,DepthStencilFormat:()=>ie,DepthTexture:()=>so,DetachedBindMode:()=>yt,DirectionalLight:()=>Cp,DirectionalLightHelper:()=>Kf,DiscreteInterpolant:()=>kd,DodecahedronGeometry:()=>bu,DoubleSide:()=>b,DstAlphaFactor:()=>V,DstColorFactor:()=>j,DynamicCopyUsage:()=>Wn,DynamicDrawUsage:()=>kn,DynamicReadUsage:()=>Gn,EdgesGeometry:()=>Ru,EllipseCurve:()=>$h,EqualCompare:()=>Dn,EqualDepth:()=>it,EqualStencilFunc:()=>En,EquirectangularReflectionMapping:()=>Ct,EquirectangularRefractionMapping:()=>Et,Euler:()=>Ir,EventDispatcher:()=>Kn,ExtrudeGeometry:()=>ad,FileLoader:()=>np,Float16BufferAttribute:()=>Bs,Float32BufferAttribute:()=>Rs,FloatType:()=>Wt,Fog:()=>pc,FogExp2:()=>dc,FramebufferTexture:()=>qh,FrontSide:()=>E,Frustum:()=>_a,GLBufferAttribute:()=>xf,GLSL1:()=>qn,GLSL3:()=>Xn,GreaterCompare:()=>Ln,GreaterDepth:()=>st,GreaterEqualCompare:()=>Nn,GreaterEqualDepth:()=>rt,GreaterEqualStencilFunc:()=>In,GreaterStencilFunc:()=>bn,GridHelper:()=>jf,Group:()=>nc,HalfFloatType:()=>jt,HemisphereLight:()=>hp,HemisphereLightHelper:()=>Wf,IcosahedronGeometry:()=>ld,ImageBitmapLoader:()=>Np,ImageLoader:()=>sp,ImageUtils:()=>Ii,IncrementStencilOp:()=>An,IncrementWrapStencilOp:()=>yn,InstancedBufferAttribute:()=>Zc,InstancedBufferGeometry:()=>Bp,InstancedInterleavedBuffer:()=>_f,InstancedMesh:()=>ah,Int16BufferAttribute:()=>bs,Int32BufferAttribute:()=>Is,Int8BufferAttribute:()=>Cs,IntType:()=>Ht,InterleavedBuffer:()=>mc,InterleavedBufferAttribute:()=>Ac,Interpolant:()=>Nd,InterpolateDiscrete:()=>We,InterpolateLinear:()=>je,InterpolateSmooth:()=>qe,InvertStencilOp:()=>xn,KeepStencilOp:()=>mn,KeyframeTrack:()=>Qd,LOD:()=>Nc,LatheGeometry:()=>_u,Layers:()=>Tr,LessCompare:()=>Rn,LessDepth:()=>et,LessEqualCompare:()=>Pn,LessEqualDepth:()=>nt,LessEqualStencilFunc:()=>Mn,LessStencilFunc:()=>Cn,Light:()=>cp,LightProbe:()=>Sp,Line:()=>Ph,Line3:()=>Pf,LineBasicMaterial:()=>Mh,LineCurve:()=>du,LineCurve3:()=>pu,LineDashedMaterial:()=>Td,LineLoop:()=>Oh,LineSegments:()=>Fh,LinearFilter:()=>Lt,LinearInterpolant:()=>Od,LinearMipMapLinearFilter:()=>Ot,LinearMipMapNearestFilter:()=>Nt,LinearMipmapLinearFilter:()=>Ft,LinearMipmapNearestFilter:()=>Ut,LinearSRGBColorSpace:()=>un,LinearToneMapping:()=>ut,LinearTransfer:()=>dn,Loader:()=>$d,LoaderUtils:()=>Tp,LoadingManager:()=>Kd,LoopOnce:()=>Ge,LoopPingPong:()=>Ve,LoopRepeat:()=>He,LuminanceAlphaFormat:()=>ee,LuminanceFormat:()=>te,MOUSE:()=>f,Material:()=>ps,MaterialLoader:()=>Ip,MathUtils:()=>li,Matrix2:()=>If,Matrix3:()=>hi,Matrix4:()=>vr,MaxEquation:()=>F,Mesh:()=>Ks,MeshBasicMaterial:()=>fs,MeshDepthMaterial:()=>jl,MeshDistanceMaterial:()=>ql,MeshLambertMaterial:()=>Sd,MeshMatcapMaterial:()=>Id,MeshNormalMaterial:()=>bd,MeshPhongMaterial:()=>Ed,MeshPhysicalMaterial:()=>Cd,MeshStandardMaterial:()=>wd,MeshToonMaterial:()=>Md,MinEquation:()=>N,MirroredRepeatWrapping:()=>It,MixOperation:()=>lt,MultiplyBlending:()=>R,MultiplyOperation:()=>ot,NearestFilter:()=>Tt,NearestMipMapLinearFilter:()=>Pt,NearestMipMapNearestFilter:()=>Rt,NearestMipmapLinearFilter:()=>Dt,NearestMipmapNearestFilter:()=>Bt,NeutralToneMapping:()=>At,NeverCompare:()=>Bn,NeverDepth:()=>$,NeverStencilFunc:()=>wn,NoBlending:()=>S,NoColorSpace:()=>cn,NoToneMapping:()=>ht,NormalAnimationBlendMode:()=>Ke,NormalBlending:()=>I,NotEqualCompare:()=>Un,NotEqualDepth:()=>at,NotEqualStencilFunc:()=>Sn,NumberKeyframeTrack:()=>Hd,Object3D:()=>Wr,ObjectLoader:()=>Dp,ObjectSpaceNormalMap:()=>ln,OctahedronGeometry:()=>cd,OneFactor:()=>k,OneMinusConstantAlphaFactor:()=>Z,OneMinusConstantColorFactor:()=>J,OneMinusDstAlphaFactor:()=>W,OneMinusDstColorFactor:()=>q,OneMinusSrcAlphaFactor:()=>H,OneMinusSrcColorFactor:()=>z,OrthographicCamera:()=>Na,PCFShadowMap:()=>x,PCFSoftShadowMap:()=>w,PMREMGenerator:()=>qa,Path:()=>yu,PerspectiveCamera:()=>ca,Plane:()=>Aa,PlaneGeometry:()=>Ca,PlaneHelper:()=>sm,PointLight:()=>xp,PointLightHelper:()=>zf,Points:()=>Vh,PointsMaterial:()=>kh,PolarGridHelper:()=>qf,PolyhedronGeometry:()=>Mu,PositionalAudio:()=>nf,PropertyBinding:()=>df,PropertyMixer:()=>sf,QuadraticBezierCurve:()=>fu,QuadraticBezierCurve3:()=>mu,Quaternion:()=>zi,QuaternionKeyframeTrack:()=>Wd,QuaternionLinearInterpolant:()=>Vd,RED_GREEN_RGTC2_Format:()=>Qe,RED_RGTC1_Format:()=>Oe,REVISION:()=>p,RGBADepthPacking:()=>rn,RGBAFormat:()=>$t,RGBAIntegerFormat:()=>ce,RGBA_ASTC_10x10_Format:()=>De,RGBA_ASTC_10x5_Format:()=>Te,RGBA_ASTC_10x6_Format:()=>Be,RGBA_ASTC_10x8_Format:()=>Re,RGBA_ASTC_12x10_Format:()=>Pe,RGBA_ASTC_12x12_Format:()=>Le,RGBA_ASTC_4x4_Format:()=>xe,RGBA_ASTC_5x4_Format:()=>we,RGBA_ASTC_5x5_Format:()=>Ce,RGBA_ASTC_6x5_Format:()=>Ee,RGBA_ASTC_6x6_Format:()=>Me,RGBA_ASTC_8x5_Format:()=>be,RGBA_ASTC_8x6_Format:()=>Se,RGBA_ASTC_8x8_Format:()=>Ie,RGBA_BPTC_Format:()=>Ue,RGBA_ETC2_EAC_Format:()=>_e,RGBA_PVRTC_2BPPV1_Format:()=>Ae,RGBA_PVRTC_4BPPV1_Format:()=>ge,RGBA_S3TC_DXT1_Format:()=>ue,RGBA_S3TC_DXT3_Format:()=>de,RGBA_S3TC_DXT5_Format:()=>pe,RGBDepthPacking:()=>sn,RGBFormat:()=>Zt,RGBIntegerFormat:()=>le,RGB_BPTC_SIGNED_Format:()=>Ne,RGB_BPTC_UNSIGNED_Format:()=>Fe,RGB_ETC1_Format:()=>ve,RGB_ETC2_Format:()=>ye,RGB_PVRTC_2BPPV1_Format:()=>me,RGB_PVRTC_4BPPV1_Format:()=>fe,RGB_S3TC_DXT1_Format:()=>he,RGDepthPacking:()=>an,RGFormat:()=>ae,RGIntegerFormat:()=>oe,RawShaderMaterial:()=>xd,Ray:()=>Ar,Raycaster:()=>Cf,RectAreaLight:()=>Mp,RedFormat:()=>re,RedIntegerFormat:()=>se,ReinhardToneMapping:()=>dt,RenderTarget:()=>Ui,RepeatWrapping:()=>bt,ReplaceStencilOp:()=>gn,ReverseSubtractEquation:()=>U,RingGeometry:()=>hd,SIGNED_RED_GREEN_RGTC2_Format:()=>ze,SIGNED_RED_RGTC1_Format:()=>ke,SRGBColorSpace:()=>hn,SRGBTransfer:()=>pn,Scene:()=>fc,ShaderChunk:()=>Ea,ShaderLib:()=>ba,ShaderMaterial:()=>ra,ShadowMaterial:()=>_d,Shape:()=>Du,ShapeGeometry:()=>ud,ShapePath:()=>um,ShapeUtils:()=>id,ShortType:()=>zt,Skeleton:()=>Kc,SkeletonHelper:()=>kf,SkinnedMesh:()=>jc,Source:()=>Bi,Sphere:()=>cr,SphereGeometry:()=>dd,Spherical:()=>bf,SphericalHarmonics3:()=>bp,SplineCurve:()=>gu,SpotLight:()=>gp,SpotLightHelper:()=>Uf,Sprite:()=>Dc,SpriteMaterial:()=>vc,SrcAlphaFactor:()=>G,SrcAlphaSaturateFactor:()=>X,SrcColorFactor:()=>Q,StaticCopyUsage:()=>Vn,StaticDrawUsage:()=>On,StaticReadUsage:()=>zn,StereoCamera:()=>Hp,StreamCopyUsage:()=>jn,StreamDrawUsage:()=>Qn,StreamReadUsage:()=>Hn,StringKeyframeTrack:()=>jd,SubtractEquation:()=>L,SubtractiveBlending:()=>B,TOUCH:()=>m,TangentSpaceNormalMap:()=>on,TetrahedronGeometry:()=>pd,Texture:()=>Pi,TextureLoader:()=>lp,TextureUtils:()=>Zl,TorusGeometry:()=>fd,TorusKnotGeometry:()=>md,Triangle:()=>ss,TriangleFanDrawMode:()=>en,TriangleStripDrawMode:()=>tn,TrianglesDrawMode:()=>$e,TubeGeometry:()=>gd,UVMapping:()=>_t,Uint16BufferAttribute:()=>Ss,Uint32BufferAttribute:()=>Ts,Uint8BufferAttribute:()=>Es,Uint8ClampedBufferAttribute:()=>Ms,Uniform:()=>Af,UniformsGroup:()=>yf,UniformsLib:()=>Ma,UniformsUtils:()=>ia,UnsignedByteType:()=>kt,UnsignedInt248Type:()=>Yt,UnsignedInt5999Type:()=>Jt,UnsignedIntType:()=>Vt,UnsignedShort4444Type:()=>qt,UnsignedShort5551Type:()=>Xt,UnsignedShortType:()=>Gt,VSMShadowMap:()=>C,Vector2:()=>ci,Vector3:()=>Gi,Vector4:()=>Li,VectorKeyframeTrack:()=>qd,VideoTexture:()=>jh,WebGL3DRenderTarget:()=>Qi,WebGLArrayRenderTarget:()=>Oi,WebGLCoordinateSystem:()=>Yn,WebGLCubeRenderTarget:()=>pa,WebGLMultipleRenderTargets:()=>pm,WebGLRenderTarget:()=>Ni,WebGLRenderer:()=>uc,WebGLUtils:()=>tc,WebGPUCoordinateSystem:()=>Jn,WireframeGeometry:()=>Ad,WrapAroundEnding:()=>Je,ZeroCurvatureEnding:()=>Xe,ZeroFactor:()=>O,ZeroSlopeEnding:()=>Ye,ZeroStencilOp:()=>fn,createCanvasElement:()=>gi});var n={};t.r(n),t.d(n,{ru:()=>Dg,pP:()=>Bg,_c:()=>Pg});var i={};t.r(i);var r={};t.r(r),t.d(r,{COLUMN:()=>px,COLUMN_REVERSE:()=>fx,ROW:()=>ux,ROW_REVERSE:()=>dx,contentDirection:()=>mx});var s={};t.r(s),t.d(s,{CENTER:()=>Ax,END:()=>vx,START:()=>gx,STRETCH:()=>yx,alignItems:()=>_x,warnAboutDeprecatedAlignItems:()=>xx});var a={};t.r(a),t.d(a,{CENTER:()=>Mx,END:()=>bx,SPACE_AROUND:()=>Sx,SPACE_BETWEEN:()=>Ix,SPACE_EVENLY:()=>Tx,START:()=>Ex,justifyContent:()=>Bx});var o={};t.r(o),t.d(o,{NORMAL:()=>Lx,NOWRAP:()=>Ux,PRE:()=>Nx,PRE_LINE:()=>Fx,PRE_WRAP:()=>Ox,WHITE_CHARS:()=>Px,collapseWhitespaceOnInlines:()=>Gx,collapseWhitespaceOnString:()=>kx,newlineBreakability:()=>Qx,shouldBreak:()=>zx});var l={};t.r(l),t.d(l,{CENTER:()=>Xx,JUSTIFY:()=>Yx,JUSTIFY_CENTER:()=>Zx,JUSTIFY_LEFT:()=>Jx,JUSTIFY_RIGHT:()=>Kx,LEFT:()=>jx,RIGHT:()=>qx,textAlign:()=>$x});var c={};t.r(c),t.d(c,{bvh_distance_functions:()=>Mb,bvh_ray_functions:()=>bb,bvh_struct_definitions:()=>Sb,common_functions:()=>Eb});var h={};t.r(h),t.d(h,{AVERAGE:()=>Vw,BVHShaderGLSL:()=>c,CENTER:()=>Hw,CONTAINED:()=>Xw,ExtendedTriangle:()=>kC,FloatVertexAttributeTexture:()=>rb,INTERSECTED:()=>qw,IntVertexAttributeTexture:()=>ib,MeshBVH:()=>MM,MeshBVHHelper:()=>WM,MeshBVHUniformStruct:()=>sb,NOT_INTERSECTED:()=>jw,OrientedBox:()=>QC,SAH:()=>Ww,StaticGeometryGenerator:()=>Cb,UIntVertexAttributeTexture:()=>nb,VertexAttributeTexture:()=>eb,acceleratedRaycast:()=>UM,computeBatchedBoundsTree:()=>QM,computeBoundsTree:()=>OM,disposeBatchedBoundsTree:()=>zM,disposeBoundsTree:()=>kM,estimateMemoryInBytes:()=>KM,getBVHExtremes:()=>JM,getJSONStructure:()=>$M,getTriangleHitPointInfo:()=>vE,shaderDistanceFunction:()=>Tb,shaderIntersectFunction:()=>Bb,shaderStructs:()=>Ib,validateBounds:()=>ZM});var u={};t.r(u),t.d(u,{latitudeToSphericalPhi:()=>bS,sphericalPhiToLatitude:()=>MS,swapToGeoFrame:()=>CS,swapToThreeFrame:()=>ES,toLatLonString:()=>IS});var d={};t.r(d),t.d(d,{B3DMLoader:()=>fS,B3DMLoaderBase:()=>pS,CAMERA_FRAME:()=>VS,CMPTLoader:()=>cI,CMPTLoaderBase:()=>lI,CUSTOM_COLOR:()=>BT,CameraTransitionManager:()=>YR,CesiumIonAuthPlugin:()=>GB,CesiumIonTilesRenderer:()=>VB,DEPTH:()=>MT,DISTANCE:()=>ET,DebugCesiumIonTilesRenderer:()=>WB,DebugGooglePhotorealisticTilesRenderer:()=>QB,DebugGoogleTilesRenderer:()=>OB,DebugTilesPlugin:()=>PT,DebugTilesRenderer:()=>UT,ENU_FRAME:()=>HS,Ellipsoid:()=>jS,EllipsoidRegion:()=>kI,EnvironmentControls:()=>SR,FAILED:()=>Lb,GEOMETRIC_ERROR:()=>CT,GLTFCesiumRTCExtension:()=>uI,GLTFExtensionLoader:()=>dI,GLTFMeshFeaturesExtension:()=>BB,GLTFStructuralMetadataExtension:()=>wB,GeoUtils:()=>u,GlobeControls:()=>VR,GoogleCloudAuthPlugin:()=>LB,GooglePhotorealisticTilesRenderer:()=>kB,GoogleTilesRenderer:()=>FB,I3DMLoader:()=>oI,I3DMLoaderBase:()=>yS,IS_LEAF:()=>ST,ImplicitTilingPlugin:()=>eD,LOADED:()=>Ob,LOADING:()=>Nb,LOAD_ORDER:()=>RT,LRUCache:()=>Db,LUNAR_ELLIPSOID:()=>XS,LUNAR_HEIGHT:()=>Gb,LUNAR_RADIUS:()=>Hb,LoaderBase:()=>uS,NONE:()=>xT,OBJECT_FRAME:()=>WS,PARSING:()=>Fb,PNTSLoader:()=>vS,PNTSLoaderBase:()=>mS,PriorityQueue:()=>Pb,RANDOM_COLOR:()=>IT,RANDOM_NODE_COLOR:()=>TT,RELATIVE_DEPTH:()=>bT,SCREEN_ERROR:()=>wT,TilesRenderer:()=>sT,TilesRendererBase:()=>rS,UNLOADED:()=>Ub,WGS84_ELLIPSOID:()=>qS,WGS84_FLATTENING:()=>Qb,WGS84_HEIGHT:()=>zb,WGS84_RADIUS:()=>kb});const p="170",f={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},m={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},g=0,A=1,v=2,y=3,_=0,x=1,w=2,C=3,E=0,M=1,b=2,S=0,I=1,T=2,B=3,R=4,D=5,P=100,L=101,U=102,N=103,F=104,O=200,k=201,Q=202,z=203,G=204,H=205,V=206,W=207,j=208,q=209,X=210,Y=211,J=212,K=213,Z=214,$=0,tt=1,et=2,nt=3,it=4,rt=5,st=6,at=7,ot=0,lt=1,ct=2,ht=0,ut=1,dt=2,pt=3,ft=4,mt=5,gt=6,At=7,vt="attached",yt="detached",_t=300,xt=301,wt=302,Ct=303,Et=304,Mt=306,bt=1e3,St=1001,It=1002,Tt=1003,Bt=1004,Rt=1004,Dt=1005,Pt=1005,Lt=1006,Ut=1007,Nt=1007,Ft=1008,Ot=1008,kt=1009,Qt=1010,zt=1011,Gt=1012,Ht=1013,Vt=1014,Wt=1015,jt=1016,qt=1017,Xt=1018,Yt=1020,Jt=35902,Kt=1021,Zt=1022,$t=1023,te=1024,ee=1025,ne=1026,ie=1027,re=1028,se=1029,ae=1030,oe=1031,le=1032,ce=1033,he=33776,ue=33777,de=33778,pe=33779,fe=35840,me=35841,ge=35842,Ae=35843,ve=36196,ye=37492,_e=37496,xe=37808,we=37809,Ce=37810,Ee=37811,Me=37812,be=37813,Se=37814,Ie=37815,Te=37816,Be=37817,Re=37818,De=37819,Pe=37820,Le=37821,Ue=36492,Ne=36494,Fe=36495,Oe=36283,ke=36284,Qe=36285,ze=36286,Ge=2200,He=2201,Ve=2202,We=2300,je=2301,qe=2302,Xe=2400,Ye=2401,Je=2402,Ke=2500,Ze=2501,$e=0,tn=1,en=2,nn=3200,rn=3201,sn=3202,an=3203,on=0,ln=1,cn="",hn="srgb",un="srgb-linear",dn="linear",pn="srgb",fn=0,mn=7680,gn=7681,An=7682,vn=7683,yn=34055,_n=34056,xn=5386,wn=512,Cn=513,En=514,Mn=515,bn=516,Sn=517,In=518,Tn=519,Bn=512,Rn=513,Dn=514,Pn=515,Ln=516,Un=517,Nn=518,Fn=519,On=35044,kn=35048,Qn=35040,zn=35045,Gn=35049,Hn=35041,Vn=35046,Wn=35050,jn=35042,qn="100",Xn="300 es",Yn=2e3,Jn=2001;class Kn{addEventListener(t,e){void 0===this._listeners&&(this._listeners={});const n=this._listeners;void 0===n[t]&&(n[t]=[]),-1===n[t].indexOf(e)&&n[t].push(e)}hasEventListener(t,e){if(void 0===this._listeners)return!1;const n=this._listeners;return void 0!==n[t]&&-1!==n[t].indexOf(e)}removeEventListener(t,e){if(void 0===this._listeners)return;const n=this._listeners[t];if(void 0!==n){const t=n.indexOf(e);-1!==t&&n.splice(t,1)}}dispatchEvent(t){if(void 0===this._listeners)return;const e=this._listeners[t.type];if(void 0!==e){t.target=this;const n=e.slice(0);for(let e=0,i=n.length;e>8&255]+Zn[t>>16&255]+Zn[t>>24&255]+"-"+Zn[255&e]+Zn[e>>8&255]+"-"+Zn[e>>16&15|64]+Zn[e>>24&255]+"-"+Zn[63&n|128]+Zn[n>>8&255]+"-"+Zn[n>>16&255]+Zn[n>>24&255]+Zn[255&i]+Zn[i>>8&255]+Zn[i>>16&255]+Zn[i>>24&255]).toLowerCase()}function ii(t,e,n){return Math.max(e,Math.min(n,t))}function ri(t,e){return(t%e+e)%e}function si(t,e,n){return(1-n)*t+n*e}function ai(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("Invalid component type.")}}function oi(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return Math.round(4294967295*t);case Uint16Array:return Math.round(65535*t);case Uint8Array:return Math.round(255*t);case Int32Array:return Math.round(2147483647*t);case Int16Array:return Math.round(32767*t);case Int8Array:return Math.round(127*t);default:throw new Error("Invalid component type.")}}const li={DEG2RAD:ti,RAD2DEG:ei,generateUUID:ni,clamp:ii,euclideanModulo:ri,mapLinear:function(t,e,n,i,r){return i+(t-e)*(r-i)/(n-e)},inverseLerp:function(t,e,n){return t!==e?(n-t)/(e-t):0},lerp:si,damp:function(t,e,n,i){return si(t,e,1-Math.exp(-n*i))},pingpong:function(t,e=1){return e-Math.abs(ri(t,2*e)-e)},smoothstep:function(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e))*t*(3-2*t)},smootherstep:function(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e))*t*t*(t*(6*t-15)+10)},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},seededRandom:function(t){void 0!==t&&($n=t);let e=$n+=1831565813;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296},degToRad:function(t){return t*ti},radToDeg:function(t){return t*ei},isPowerOfTwo:function(t){return!(t&t-1)&&0!==t},ceilPowerOfTwo:function(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))},floorPowerOfTwo:function(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))},setQuaternionFromProperEuler:function(t,e,n,i,r){const s=Math.cos,a=Math.sin,o=s(n/2),l=a(n/2),c=s((e+i)/2),h=a((e+i)/2),u=s((e-i)/2),d=a((e-i)/2),p=s((i-e)/2),f=a((i-e)/2);switch(r){case"XYX":t.set(o*h,l*u,l*d,o*c);break;case"YZY":t.set(l*d,o*h,l*u,o*c);break;case"ZXZ":t.set(l*u,l*d,o*h,o*c);break;case"XZX":t.set(o*h,l*f,l*p,o*c);break;case"YXY":t.set(l*p,o*h,l*f,o*c);break;case"ZYZ":t.set(l*f,l*p,o*h,o*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}},normalize:oi,denormalize:ai};class ci{constructor(t=0,e=0){ci.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,n=this.y,i=t.elements;return this.x=i[0]*e+i[3]*n+i[6],this.y=i[1]*e+i[4]*n+i[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(ii(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const n=Math.cos(e),i=Math.sin(e),r=this.x-t.x,s=this.y-t.y;return this.x=r*n-s*i+t.x,this.y=r*i+s*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class hi{constructor(t,e,n,i,r,s,a,o,l){hi.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],void 0!==t&&this.set(t,e,n,i,r,s,a,o,l)}set(t,e,n,i,r,s,a,o,l){const c=this.elements;return c[0]=t,c[1]=i,c[2]=a,c[3]=e,c[4]=r,c[5]=o,c[6]=n,c[7]=s,c[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,i=e.elements,r=this.elements,s=n[0],a=n[3],o=n[6],l=n[1],c=n[4],h=n[7],u=n[2],d=n[5],p=n[8],f=i[0],m=i[3],g=i[6],A=i[1],v=i[4],y=i[7],_=i[2],x=i[5],w=i[8];return r[0]=s*f+a*A+o*_,r[3]=s*m+a*v+o*x,r[6]=s*g+a*y+o*w,r[1]=l*f+c*A+h*_,r[4]=l*m+c*v+h*x,r[7]=l*g+c*y+h*w,r[2]=u*f+d*A+p*_,r[5]=u*m+d*v+p*x,r[8]=u*g+d*y+p*w,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],s=t[4],a=t[5],o=t[6],l=t[7],c=t[8];return e*s*c-e*a*l-n*r*c+n*a*o+i*r*l-i*s*o}invert(){const t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],s=t[4],a=t[5],o=t[6],l=t[7],c=t[8],h=c*s-a*l,u=a*o-c*r,d=l*r-s*o,p=e*h+n*u+i*d;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);const f=1/p;return t[0]=h*f,t[1]=(i*l-c*n)*f,t[2]=(a*n-i*s)*f,t[3]=u*f,t[4]=(c*e-i*o)*f,t[5]=(i*r-a*e)*f,t[6]=d*f,t[7]=(n*o-l*e)*f,t[8]=(s*e-n*r)*f,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,i,r,s,a){const o=Math.cos(r),l=Math.sin(r);return this.set(n*o,n*l,-n*(o*s+l*a)+s+t,-i*l,i*o,-i*(-l*s+o*a)+a+e,0,0,1),this}scale(t,e){return this.premultiply(ui.makeScale(t,e)),this}rotate(t){return this.premultiply(ui.makeRotation(-t)),this}translate(t,e){return this.premultiply(ui.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,n,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,n=t.elements;for(let t=0;t<9;t++)if(e[t]!==n[t])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return(new this.constructor).fromArray(this.elements)}}const ui=new hi;function di(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}const pi={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function fi(t,e){return new pi[t](e)}function mi(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function gi(){const t=mi("canvas");return t.style.display="block",t}const Ai={};function vi(t){t in Ai||(Ai[t]=!0,console.warn(t))}const yi={enabled:!0,workingColorSpace:un,spaces:{},convert:function(t,e,n){return!1!==this.enabled&&e!==n&&e&&n?(this.spaces[e].transfer===pn&&(t.r=_i(t.r),t.g=_i(t.g),t.b=_i(t.b)),this.spaces[e].primaries!==this.spaces[n].primaries&&(t.applyMatrix3(this.spaces[e].toXYZ),t.applyMatrix3(this.spaces[n].fromXYZ)),this.spaces[n].transfer===pn&&(t.r=xi(t.r),t.g=xi(t.g),t.b=xi(t.b)),t):t},fromWorkingColorSpace:function(t,e){return this.convert(t,this.workingColorSpace,e)},toWorkingColorSpace:function(t,e){return this.convert(t,e,this.workingColorSpace)},getPrimaries:function(t){return this.spaces[t].primaries},getTransfer:function(t){return t===cn?dn:this.spaces[t].transfer},getLuminanceCoefficients:function(t,e=this.workingColorSpace){return t.fromArray(this.spaces[e].luminanceCoefficients)},define:function(t){Object.assign(this.spaces,t)},_getMatrix:function(t,e,n){return t.copy(this.spaces[e].toXYZ).multiply(this.spaces[n].fromXYZ)},_getDrawingBufferColorSpace:function(t){return this.spaces[t].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(t=this.workingColorSpace){return this.spaces[t].workingColorSpaceConfig.unpackColorSpace}};function _i(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function xi(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}const wi=[.64,.33,.3,.6,.15,.06],Ci=[.2126,.7152,.0722],Ei=[.3127,.329],Mi=(new hi).set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),bi=(new hi).set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);let Si;yi.define({[un]:{primaries:wi,whitePoint:Ei,transfer:dn,toXYZ:Mi,fromXYZ:bi,luminanceCoefficients:Ci,workingColorSpaceConfig:{unpackColorSpace:hn},outputColorSpaceConfig:{drawingBufferColorSpace:hn}},[hn]:{primaries:wi,whitePoint:Ei,transfer:pn,toXYZ:Mi,fromXYZ:bi,luminanceCoefficients:Ci,outputColorSpaceConfig:{drawingBufferColorSpace:hn}}});class Ii{static getDataURL(t){if(/^data:/i.test(t.src))return t.src;if("undefined"==typeof HTMLCanvasElement)return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{void 0===Si&&(Si=mi("canvas")),Si.width=t.width,Si.height=t.height;const n=Si.getContext("2d");t instanceof ImageData?n.putImageData(t,0,0):n.drawImage(t,0,0,t.width,t.height),e=Si}return e.width>2048||e.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",t),e.toDataURL("image/jpeg",.6)):e.toDataURL("image/png")}static sRGBToLinear(t){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){const e=mi("canvas");e.width=t.width,e.height=t.height;const n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);const i=n.getImageData(0,0,t.width,t.height),r=i.data;for(let t=0;t0&&(n.userData=this.userData),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==_t)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case bt:t.x=t.x-Math.floor(t.x);break;case St:t.x=t.x<0?0:1;break;case It:1===Math.abs(Math.floor(t.x)%2)?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x)}if(t.y<0||t.y>1)switch(this.wrapT){case bt:t.y=t.y-Math.floor(t.y);break;case St:t.y=t.y<0?0:1;break;case It:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){!0===t&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){!0===t&&this.pmremVersion++}}Pi.DEFAULT_IMAGE=null,Pi.DEFAULT_MAPPING=_t,Pi.DEFAULT_ANISOTROPY=1;class Li{constructor(t=0,e=0,n=0,i=1){Li.prototype.isVector4=!0,this.x=t,this.y=e,this.z=n,this.w=i}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,i){return this.x=t,this.y=e,this.z=n,this.w=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,n=this.y,i=this.z,r=this.w,s=t.elements;return this.x=s[0]*e+s[4]*n+s[8]*i+s[12]*r,this.y=s[1]*e+s[5]*n+s[9]*i+s[13]*r,this.z=s[2]*e+s[6]*n+s[10]*i+s[14]*r,this.w=s[3]*e+s[7]*n+s[11]*i+s[15]*r,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,n,i,r;const s=.01,a=.1,o=t.elements,l=o[0],c=o[4],h=o[8],u=o[1],d=o[5],p=o[9],f=o[2],m=o[6],g=o[10];if(Math.abs(c-u)o&&t>A?tA?o=0?1:-1,i=1-e*e;if(i>Number.EPSILON){const r=Math.sqrt(i),s=Math.atan2(r,e*n);t=Math.sin(t*s)/r,a=Math.sin(a*s)/r}const r=a*n;if(o=o*t+u*r,l=l*t+d*r,c=c*t+p*r,h=h*t+f*r,t===1-a){const t=1/Math.sqrt(o*o+l*l+c*c+h*h);o*=t,l*=t,c*=t,h*=t}}t[e]=o,t[e+1]=l,t[e+2]=c,t[e+3]=h}static multiplyQuaternionsFlat(t,e,n,i,r,s){const a=n[i],o=n[i+1],l=n[i+2],c=n[i+3],h=r[s],u=r[s+1],d=r[s+2],p=r[s+3];return t[e]=a*p+c*h+o*d-l*u,t[e+1]=o*p+c*u+l*h-a*d,t[e+2]=l*p+c*d+a*u-o*h,t[e+3]=c*p-a*h-o*u-l*d,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,n,i){return this._x=t,this._y=e,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const n=t._x,i=t._y,r=t._z,s=t._order,a=Math.cos,o=Math.sin,l=a(n/2),c=a(i/2),h=a(r/2),u=o(n/2),d=o(i/2),p=o(r/2);switch(s){case"XYZ":this._x=u*c*h+l*d*p,this._y=l*d*h-u*c*p,this._z=l*c*p+u*d*h,this._w=l*c*h-u*d*p;break;case"YXZ":this._x=u*c*h+l*d*p,this._y=l*d*h-u*c*p,this._z=l*c*p-u*d*h,this._w=l*c*h+u*d*p;break;case"ZXY":this._x=u*c*h-l*d*p,this._y=l*d*h+u*c*p,this._z=l*c*p+u*d*h,this._w=l*c*h-u*d*p;break;case"ZYX":this._x=u*c*h-l*d*p,this._y=l*d*h+u*c*p,this._z=l*c*p-u*d*h,this._w=l*c*h+u*d*p;break;case"YZX":this._x=u*c*h+l*d*p,this._y=l*d*h+u*c*p,this._z=l*c*p-u*d*h,this._w=l*c*h-u*d*p;break;case"XZY":this._x=u*c*h-l*d*p,this._y=l*d*h-u*c*p,this._z=l*c*p+u*d*h,this._w=l*c*h+u*d*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+s)}return!0===e&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const n=e/2,i=Math.sin(n);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,n=e[0],i=e[4],r=e[8],s=e[1],a=e[5],o=e[9],l=e[2],c=e[6],h=e[10],u=n+a+h;if(u>0){const t=.5/Math.sqrt(u+1);this._w=.25/t,this._x=(c-o)*t,this._y=(r-l)*t,this._z=(s-i)*t}else if(n>a&&n>h){const t=2*Math.sqrt(1+n-a-h);this._w=(c-o)/t,this._x=.25*t,this._y=(i+s)/t,this._z=(r+l)/t}else if(a>h){const t=2*Math.sqrt(1+a-n-h);this._w=(r-l)/t,this._x=(i+s)/t,this._y=.25*t,this._z=(o+c)/t}else{const t=2*Math.sqrt(1+h-n-a);this._w=(s-i)/t,this._x=(r+l)/t,this._y=(o+c)/t,this._z=.25*t}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return nMath.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(ii(this.dot(t),-1,1)))}rotateTowards(t,e){const n=this.angleTo(t);if(0===n)return this;const i=Math.min(1,e/n);return this.slerp(t,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const n=t._x,i=t._y,r=t._z,s=t._w,a=e._x,o=e._y,l=e._z,c=e._w;return this._x=n*c+s*a+i*l-r*o,this._y=i*c+s*o+r*a-n*l,this._z=r*c+s*l+n*o-i*a,this._w=s*c-n*a-i*o-r*l,this._onChangeCallback(),this}slerp(t,e){if(0===e)return this;if(1===e)return this.copy(t);const n=this._x,i=this._y,r=this._z,s=this._w;let a=s*t._w+n*t._x+i*t._y+r*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=s,this._x=n,this._y=i,this._z=r,this;const o=1-a*a;if(o<=Number.EPSILON){const t=1-e;return this._w=t*s+e*this._w,this._x=t*n+e*this._x,this._y=t*i+e*this._y,this._z=t*r+e*this._z,this.normalize(),this}const l=Math.sqrt(o),c=Math.atan2(l,a),h=Math.sin((1-e)*c)/l,u=Math.sin(e*c)/l;return this._w=s*h+this._w*u,this._x=n*h+this._x*u,this._y=i*h+this._y*u,this._z=r*h+this._z*u,this._onChangeCallback(),this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(i*Math.sin(t),i*Math.cos(t),r*Math.sin(e),r*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class Gi{constructor(t=0,e=0,n=0){Gi.prototype.isVector3=!0,this.x=t,this.y=e,this.z=n}set(t,e,n){return void 0===n&&(n=this.z),this.x=t,this.y=e,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(Vi.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Vi.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,n=this.y,i=this.z,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6]*i,this.y=r[1]*e+r[4]*n+r[7]*i,this.z=r[2]*e+r[5]*n+r[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,n=this.y,i=this.z,r=t.elements,s=1/(r[3]*e+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*e+r[4]*n+r[8]*i+r[12])*s,this.y=(r[1]*e+r[5]*n+r[9]*i+r[13])*s,this.z=(r[2]*e+r[6]*n+r[10]*i+r[14])*s,this}applyQuaternion(t){const e=this.x,n=this.y,i=this.z,r=t.x,s=t.y,a=t.z,o=t.w,l=2*(s*i-a*n),c=2*(a*e-r*i),h=2*(r*n-s*e);return this.x=e+o*l+s*h-a*c,this.y=n+o*c+a*l-r*h,this.z=i+o*h+r*c-s*l,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,n=this.y,i=this.z,r=t.elements;return this.x=r[0]*e+r[4]*n+r[8]*i,this.y=r[1]*e+r[5]*n+r[9]*i,this.z=r[2]*e+r[6]*n+r[10]*i,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const n=t.x,i=t.y,r=t.z,s=e.x,a=e.y,o=e.z;return this.x=i*o-r*a,this.y=r*s-n*o,this.z=n*a-i*s,this}projectOnVector(t){const e=t.lengthSq();if(0===e)return this.set(0,0,0);const n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return Hi.copy(this).projectOnVector(t),this.sub(Hi)}reflect(t){return this.sub(Hi.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(ii(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y,i=this.z-t.z;return e*e+n*n+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,n){const i=Math.sin(e)*t;return this.x=i*Math.sin(n),this.y=Math.cos(e)*t,this.z=i*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=i,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,4*e)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,3*e)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=2*Math.random()-1,n=Math.sqrt(1-e*e);return this.x=n*Math.cos(t),this.y=e,this.z=n*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Hi=new Gi,Vi=new zi;class Wi{constructor(t=new Gi(1/0,1/0,1/0),e=new Gi(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,n=t.length;e=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,qi),qi.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(er),nr.subVectors(this.max,er),Yi.subVectors(t.a,er),Ji.subVectors(t.b,er),Ki.subVectors(t.c,er),Zi.subVectors(Ji,Yi),$i.subVectors(Ki,Ji),tr.subVectors(Yi,Ki);let e=[0,-Zi.z,Zi.y,0,-$i.z,$i.y,0,-tr.z,tr.y,Zi.z,0,-Zi.x,$i.z,0,-$i.x,tr.z,0,-tr.x,-Zi.y,Zi.x,0,-$i.y,$i.x,0,-tr.y,tr.x,0];return!!sr(e,Yi,Ji,Ki,nr)&&(e=[1,0,0,0,1,0,0,0,1],!!sr(e,Yi,Ji,Ki,nr)&&(ir.crossVectors(Zi,$i),e=[ir.x,ir.y,ir.z],sr(e,Yi,Ji,Ki,nr)))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,qi).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=.5*this.getSize(qi).length()),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()||(ji[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),ji[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),ji[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),ji[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),ji[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),ji[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),ji[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),ji[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(ji)),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const ji=[new Gi,new Gi,new Gi,new Gi,new Gi,new Gi,new Gi,new Gi],qi=new Gi,Xi=new Wi,Yi=new Gi,Ji=new Gi,Ki=new Gi,Zi=new Gi,$i=new Gi,tr=new Gi,er=new Gi,nr=new Gi,ir=new Gi,rr=new Gi;function sr(t,e,n,i,r){for(let s=0,a=t.length-3;s<=a;s+=3){rr.fromArray(t,s);const a=r.x*Math.abs(rr.x)+r.y*Math.abs(rr.y)+r.z*Math.abs(rr.z),o=e.dot(rr),l=n.dot(rr),c=i.dot(rr);if(Math.max(-Math.max(o,l,c),Math.min(o,l,c))>a)return!1}return!0}const ar=new Wi,or=new Gi,lr=new Gi;class cr{constructor(t=new Gi,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const n=this.center;void 0!==e?n.copy(e):ar.setFromPoints(t).getCenter(n);let i=0;for(let e=0,r=t.length;ethis.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;or.subVectors(t,this.center);const e=or.lengthSq();if(e>this.radius*this.radius){const t=Math.sqrt(e),n=.5*(t-this.radius);this.center.addScaledVector(or,n/t),this.radius+=n}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(!0===this.center.equals(t.center)?this.radius=Math.max(this.radius,t.radius):(lr.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(or.copy(t.center).add(lr)),this.expandByPoint(or.copy(t.center).sub(lr))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const hr=new Gi,ur=new Gi,dr=new Gi,pr=new Gi,fr=new Gi,mr=new Gi,gr=new Gi;class Ar{constructor(t=new Gi,e=new Gi(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,hr)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=hr.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(hr.copy(this.origin).addScaledVector(this.direction,e),hr.distanceToSquared(t))}distanceSqToSegment(t,e,n,i){ur.copy(t).add(e).multiplyScalar(.5),dr.copy(e).sub(t).normalize(),pr.copy(this.origin).sub(ur);const r=.5*t.distanceTo(e),s=-this.direction.dot(dr),a=pr.dot(this.direction),o=-pr.dot(dr),l=pr.lengthSq(),c=Math.abs(1-s*s);let h,u,d,p;if(c>0)if(h=s*o-a,u=s*a-o,p=r*c,h>=0)if(u>=-p)if(u<=p){const t=1/c;h*=t,u*=t,d=h*(h+s*u+2*a)+u*(s*h+u+2*o)+l}else u=r,h=Math.max(0,-(s*u+a)),d=-h*h+u*(u+2*o)+l;else u=-r,h=Math.max(0,-(s*u+a)),d=-h*h+u*(u+2*o)+l;else u<=-p?(h=Math.max(0,-(-s*r+a)),u=h>0?-r:Math.min(Math.max(-r,-o),r),d=-h*h+u*(u+2*o)+l):u<=p?(h=0,u=Math.min(Math.max(-r,-o),r),d=u*(u+2*o)+l):(h=Math.max(0,-(s*r+a)),u=h>0?r:Math.min(Math.max(-r,-o),r),d=-h*h+u*(u+2*o)+l);else u=s>0?-r:r,h=Math.max(0,-(s*u+a)),d=-h*h+u*(u+2*o)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,h),i&&i.copy(ur).addScaledVector(dr,u),d}intersectSphere(t,e){hr.subVectors(t.center,this.origin);const n=hr.dot(this.direction),i=hr.dot(hr)-n*n,r=t.radius*t.radius;if(i>r)return null;const s=Math.sqrt(r-i),a=n-s,o=n+s;return o<0?null:a<0?this.at(o,e):this.at(a,e)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;const n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){const n=this.distanceToPlane(t);return null===n?null:this.at(n,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);return 0===e||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,i,r,s,a,o;const l=1/this.direction.x,c=1/this.direction.y,h=1/this.direction.z,u=this.origin;return l>=0?(n=(t.min.x-u.x)*l,i=(t.max.x-u.x)*l):(n=(t.max.x-u.x)*l,i=(t.min.x-u.x)*l),c>=0?(r=(t.min.y-u.y)*c,s=(t.max.y-u.y)*c):(r=(t.max.y-u.y)*c,s=(t.min.y-u.y)*c),n>s||r>i?null:((r>n||isNaN(n))&&(n=r),(s=0?(a=(t.min.z-u.z)*h,o=(t.max.z-u.z)*h):(a=(t.max.z-u.z)*h,o=(t.min.z-u.z)*h),n>o||a>i?null:((a>n||n!=n)&&(n=a),(o=0?n:i,e)))}intersectsBox(t){return null!==this.intersectBox(t,hr)}intersectTriangle(t,e,n,i,r){fr.subVectors(e,t),mr.subVectors(n,t),gr.crossVectors(fr,mr);let s,a=this.direction.dot(gr);if(a>0){if(i)return null;s=1}else{if(!(a<0))return null;s=-1,a=-a}pr.subVectors(this.origin,t);const o=s*this.direction.dot(mr.crossVectors(pr,mr));if(o<0)return null;const l=s*this.direction.dot(fr.cross(pr));if(l<0)return null;if(o+l>a)return null;const c=-s*pr.dot(gr);return c<0?null:this.at(c/a,r)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}}class vr{constructor(t,e,n,i,r,s,a,o,l,c,h,u,d,p,f,m){vr.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==t&&this.set(t,e,n,i,r,s,a,o,l,c,h,u,d,p,f,m)}set(t,e,n,i,r,s,a,o,l,c,h,u,d,p,f,m){const g=this.elements;return g[0]=t,g[4]=e,g[8]=n,g[12]=i,g[1]=r,g[5]=s,g[9]=a,g[13]=o,g[2]=l,g[6]=c,g[10]=h,g[14]=u,g[3]=d,g[7]=p,g[11]=f,g[15]=m,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return(new vr).fromArray(this.elements)}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){const e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,n){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,n=t.elements,i=1/yr.setFromMatrixColumn(t,0).length(),r=1/yr.setFromMatrixColumn(t,1).length(),s=1/yr.setFromMatrixColumn(t,2).length();return e[0]=n[0]*i,e[1]=n[1]*i,e[2]=n[2]*i,e[3]=0,e[4]=n[4]*r,e[5]=n[5]*r,e[6]=n[6]*r,e[7]=0,e[8]=n[8]*s,e[9]=n[9]*s,e[10]=n[10]*s,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,n=t.x,i=t.y,r=t.z,s=Math.cos(n),a=Math.sin(n),o=Math.cos(i),l=Math.sin(i),c=Math.cos(r),h=Math.sin(r);if("XYZ"===t.order){const t=s*c,n=s*h,i=a*c,r=a*h;e[0]=o*c,e[4]=-o*h,e[8]=l,e[1]=n+i*l,e[5]=t-r*l,e[9]=-a*o,e[2]=r-t*l,e[6]=i+n*l,e[10]=s*o}else if("YXZ"===t.order){const t=o*c,n=o*h,i=l*c,r=l*h;e[0]=t+r*a,e[4]=i*a-n,e[8]=s*l,e[1]=s*h,e[5]=s*c,e[9]=-a,e[2]=n*a-i,e[6]=r+t*a,e[10]=s*o}else if("ZXY"===t.order){const t=o*c,n=o*h,i=l*c,r=l*h;e[0]=t-r*a,e[4]=-s*h,e[8]=i+n*a,e[1]=n+i*a,e[5]=s*c,e[9]=r-t*a,e[2]=-s*l,e[6]=a,e[10]=s*o}else if("ZYX"===t.order){const t=s*c,n=s*h,i=a*c,r=a*h;e[0]=o*c,e[4]=i*l-n,e[8]=t*l+r,e[1]=o*h,e[5]=r*l+t,e[9]=n*l-i,e[2]=-l,e[6]=a*o,e[10]=s*o}else if("YZX"===t.order){const t=s*o,n=s*l,i=a*o,r=a*l;e[0]=o*c,e[4]=r-t*h,e[8]=i*h+n,e[1]=h,e[5]=s*c,e[9]=-a*c,e[2]=-l*c,e[6]=n*h+i,e[10]=t-r*h}else if("XZY"===t.order){const t=s*o,n=s*l,i=a*o,r=a*l;e[0]=o*c,e[4]=-h,e[8]=l*c,e[1]=t*h+r,e[5]=s*c,e[9]=n*h-i,e[2]=i*h-n,e[6]=a*c,e[10]=r*h+t}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(xr,t,wr)}lookAt(t,e,n){const i=this.elements;return Mr.subVectors(t,e),0===Mr.lengthSq()&&(Mr.z=1),Mr.normalize(),Cr.crossVectors(n,Mr),0===Cr.lengthSq()&&(1===Math.abs(n.z)?Mr.x+=1e-4:Mr.z+=1e-4,Mr.normalize(),Cr.crossVectors(n,Mr)),Cr.normalize(),Er.crossVectors(Mr,Cr),i[0]=Cr.x,i[4]=Er.x,i[8]=Mr.x,i[1]=Cr.y,i[5]=Er.y,i[9]=Mr.y,i[2]=Cr.z,i[6]=Er.z,i[10]=Mr.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,i=e.elements,r=this.elements,s=n[0],a=n[4],o=n[8],l=n[12],c=n[1],h=n[5],u=n[9],d=n[13],p=n[2],f=n[6],m=n[10],g=n[14],A=n[3],v=n[7],y=n[11],_=n[15],x=i[0],w=i[4],C=i[8],E=i[12],M=i[1],b=i[5],S=i[9],I=i[13],T=i[2],B=i[6],R=i[10],D=i[14],P=i[3],L=i[7],U=i[11],N=i[15];return r[0]=s*x+a*M+o*T+l*P,r[4]=s*w+a*b+o*B+l*L,r[8]=s*C+a*S+o*R+l*U,r[12]=s*E+a*I+o*D+l*N,r[1]=c*x+h*M+u*T+d*P,r[5]=c*w+h*b+u*B+d*L,r[9]=c*C+h*S+u*R+d*U,r[13]=c*E+h*I+u*D+d*N,r[2]=p*x+f*M+m*T+g*P,r[6]=p*w+f*b+m*B+g*L,r[10]=p*C+f*S+m*R+g*U,r[14]=p*E+f*I+m*D+g*N,r[3]=A*x+v*M+y*T+_*P,r[7]=A*w+v*b+y*B+_*L,r[11]=A*C+v*S+y*R+_*U,r[15]=A*E+v*I+y*D+_*N,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[4],i=t[8],r=t[12],s=t[1],a=t[5],o=t[9],l=t[13],c=t[2],h=t[6],u=t[10],d=t[14];return t[3]*(+r*o*h-i*l*h-r*a*u+n*l*u+i*a*d-n*o*d)+t[7]*(+e*o*d-e*l*u+r*s*u-i*s*d+i*l*c-r*o*c)+t[11]*(+e*l*h-e*a*d-r*s*h+n*s*d+r*a*c-n*l*c)+t[15]*(-i*a*c-e*o*h+e*a*u+i*s*h-n*s*u+n*o*c)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,n){const i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=e,i[14]=n),this}invert(){const t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],s=t[4],a=t[5],o=t[6],l=t[7],c=t[8],h=t[9],u=t[10],d=t[11],p=t[12],f=t[13],m=t[14],g=t[15],A=h*m*l-f*u*l+f*o*d-a*m*d-h*o*g+a*u*g,v=p*u*l-c*m*l-p*o*d+s*m*d+c*o*g-s*u*g,y=c*f*l-p*h*l+p*a*d-s*f*d-c*a*g+s*h*g,_=p*h*o-c*f*o-p*a*u+s*f*u+c*a*m-s*h*m,x=e*A+n*v+i*y+r*_;if(0===x)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const w=1/x;return t[0]=A*w,t[1]=(f*u*r-h*m*r-f*i*d+n*m*d+h*i*g-n*u*g)*w,t[2]=(a*m*r-f*o*r+f*i*l-n*m*l-a*i*g+n*o*g)*w,t[3]=(h*o*r-a*u*r-h*i*l+n*u*l+a*i*d-n*o*d)*w,t[4]=v*w,t[5]=(c*m*r-p*u*r+p*i*d-e*m*d-c*i*g+e*u*g)*w,t[6]=(p*o*r-s*m*r-p*i*l+e*m*l+s*i*g-e*o*g)*w,t[7]=(s*u*r-c*o*r+c*i*l-e*u*l-s*i*d+e*o*d)*w,t[8]=y*w,t[9]=(p*h*r-c*f*r-p*n*d+e*f*d+c*n*g-e*h*g)*w,t[10]=(s*f*r-p*a*r+p*n*l-e*f*l-s*n*g+e*a*g)*w,t[11]=(c*a*r-s*h*r-c*n*l+e*h*l+s*n*d-e*a*d)*w,t[12]=_*w,t[13]=(c*f*i-p*h*i+p*n*u-e*f*u-c*n*m+e*h*m)*w,t[14]=(p*a*i-s*f*i-p*n*o+e*f*o+s*n*m-e*a*m)*w,t[15]=(s*h*i-c*a*i+c*n*o-e*h*o-s*n*u+e*a*u)*w,this}scale(t){const e=this.elements,n=t.x,i=t.y,r=t.z;return e[0]*=n,e[4]*=i,e[8]*=r,e[1]*=n,e[5]*=i,e[9]*=r,e[2]*=n,e[6]*=i,e[10]*=r,e[3]*=n,e[7]*=i,e[11]*=r,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,i))}makeTranslation(t,e,n){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const n=Math.cos(e),i=Math.sin(e),r=1-n,s=t.x,a=t.y,o=t.z,l=r*s,c=r*a;return this.set(l*s+n,l*a-i*o,l*o+i*a,0,l*a+i*o,c*a+n,c*o-i*s,0,l*o-i*a,c*o+i*s,r*o*o+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,i,r,s){return this.set(1,n,r,0,t,1,s,0,e,i,1,0,0,0,0,1),this}compose(t,e,n){const i=this.elements,r=e._x,s=e._y,a=e._z,o=e._w,l=r+r,c=s+s,h=a+a,u=r*l,d=r*c,p=r*h,f=s*c,m=s*h,g=a*h,A=o*l,v=o*c,y=o*h,_=n.x,x=n.y,w=n.z;return i[0]=(1-(f+g))*_,i[1]=(d+y)*_,i[2]=(p-v)*_,i[3]=0,i[4]=(d-y)*x,i[5]=(1-(u+g))*x,i[6]=(m+A)*x,i[7]=0,i[8]=(p+v)*w,i[9]=(m-A)*w,i[10]=(1-(u+f))*w,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,e,n){const i=this.elements;let r=yr.set(i[0],i[1],i[2]).length();const s=yr.set(i[4],i[5],i[6]).length(),a=yr.set(i[8],i[9],i[10]).length();this.determinant()<0&&(r=-r),t.x=i[12],t.y=i[13],t.z=i[14],_r.copy(this);const o=1/r,l=1/s,c=1/a;return _r.elements[0]*=o,_r.elements[1]*=o,_r.elements[2]*=o,_r.elements[4]*=l,_r.elements[5]*=l,_r.elements[6]*=l,_r.elements[8]*=c,_r.elements[9]*=c,_r.elements[10]*=c,e.setFromRotationMatrix(_r),n.x=r,n.y=s,n.z=a,this}makePerspective(t,e,n,i,r,s,a=Yn){const o=this.elements,l=2*r/(e-t),c=2*r/(n-i),h=(e+t)/(e-t),u=(n+i)/(n-i);let d,p;if(a===Yn)d=-(s+r)/(s-r),p=-2*s*r/(s-r);else{if(a!==Jn)throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);d=-s/(s-r),p=-s*r/(s-r)}return o[0]=l,o[4]=0,o[8]=h,o[12]=0,o[1]=0,o[5]=c,o[9]=u,o[13]=0,o[2]=0,o[6]=0,o[10]=d,o[14]=p,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this}makeOrthographic(t,e,n,i,r,s,a=Yn){const o=this.elements,l=1/(e-t),c=1/(n-i),h=1/(s-r),u=(e+t)*l,d=(n+i)*c;let p,f;if(a===Yn)p=(s+r)*h,f=-2*h;else{if(a!==Jn)throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);p=r*h,f=-1*h}return o[0]=2*l,o[4]=0,o[8]=0,o[12]=-u,o[1]=0,o[5]=2*c,o[9]=0,o[13]=-d,o[2]=0,o[6]=0,o[10]=f,o[14]=-p,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this}equals(t){const e=this.elements,n=t.elements;for(let t=0;t<16;t++)if(e[t]!==n[t])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}}const yr=new Gi,_r=new vr,xr=new Gi(0,0,0),wr=new Gi(1,1,1),Cr=new Gi,Er=new Gi,Mr=new Gi,br=new vr,Sr=new zi;class Ir{constructor(t=0,e=0,n=0,i=Ir.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=i}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,n,i=this._order){return this._x=t,this._y=e,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,n=!0){const i=t.elements,r=i[0],s=i[4],a=i[8],o=i[1],l=i[5],c=i[9],h=i[2],u=i[6],d=i[10];switch(e){case"XYZ":this._y=Math.asin(ii(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-c,d),this._z=Math.atan2(-s,r)):(this._x=Math.atan2(u,l),this._z=0);break;case"YXZ":this._x=Math.asin(-ii(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(a,d),this._z=Math.atan2(o,l)):(this._y=Math.atan2(-h,r),this._z=0);break;case"ZXY":this._x=Math.asin(ii(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-h,d),this._z=Math.atan2(-s,l)):(this._y=0,this._z=Math.atan2(o,r));break;case"ZYX":this._y=Math.asin(-ii(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(u,d),this._z=Math.atan2(o,r)):(this._x=0,this._z=Math.atan2(-s,l));break;case"YZX":this._z=Math.asin(ii(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-c,l),this._y=Math.atan2(-h,r)):(this._x=0,this._y=Math.atan2(a,d));break;case"XZY":this._z=Math.asin(-ii(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(u,l),this._y=Math.atan2(a,r)):(this._x=Math.atan2(-c,d),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,!0===n&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return br.makeRotationFromQuaternion(t),this.setFromRotationMatrix(br,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return Sr.setFromEuler(this),this.setFromQuaternion(Sr,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],void 0!==t[3]&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Ir.DEFAULT_ORDER="XYZ";class Tr{constructor(){this.mask=1}set(t){this.mask=1<>>0}enable(t){this.mask|=1<1){for(let t=0;t1){for(let t=0;t0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),!1===this.matrixAutoUpdate&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.visibility=this._visibility,i.active=this._active,i.bounds=this._bounds.map((t=>({boxInitialized:t.boxInitialized,boxMin:t.box.min.toArray(),boxMax:t.box.max.toArray(),sphereInitialized:t.sphereInitialized,sphereRadius:t.sphere.radius,sphereCenter:t.sphere.center.toArray()}))),i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.geometryCount=this._geometryCount,i.matricesTexture=this._matricesTexture.toJSON(t),null!==this._colorsTexture&&(i.colorsTexture=this._colorsTexture.toJSON(t)),null!==this.boundingSphere&&(i.boundingSphere={center:i.boundingSphere.center.toArray(),radius:i.boundingSphere.radius}),null!==this.boundingBox&&(i.boundingBox={min:i.boundingBox.min.toArray(),max:i.boundingBox.max.toArray()})),this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(i.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(t.geometries,this.geometry);const e=this.geometry.parameters;if(void 0!==e&&void 0!==e.shapes){const n=e.shapes;if(Array.isArray(n))for(let e=0,i=n.length;e0){i.children=[];for(let e=0;e0){i.animations=[];for(let e=0;e0&&(n.geometries=e),i.length>0&&(n.materials=i),r.length>0&&(n.textures=r),a.length>0&&(n.images=a),o.length>0&&(n.shapes=o),l.length>0&&(n.skeletons=l),c.length>0&&(n.animations=c),h.length>0&&(n.nodes=h)}return n.object=i,n;function s(t){const e=[];for(const n in t){const i=t[n];delete i.metadata,e.push(i)}return e}}clone(t){return(new this.constructor).copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),!0===e)for(let e=0;e0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(t,e,n,i,r){jr.subVectors(i,e),qr.subVectors(n,e),Xr.subVectors(t,e);const s=jr.dot(jr),a=jr.dot(qr),o=jr.dot(Xr),l=qr.dot(qr),c=qr.dot(Xr),h=s*l-a*a;if(0===h)return r.set(0,0,0),null;const u=1/h,d=(l*o-a*c)*u,p=(s*c-a*o)*u;return r.set(1-d-p,p,d)}static containsPoint(t,e,n,i){return null!==this.getBarycoord(t,e,n,i,Yr)&&Yr.x>=0&&Yr.y>=0&&Yr.x+Yr.y<=1}static getInterpolation(t,e,n,i,r,s,a,o){return null===this.getBarycoord(t,e,n,i,Yr)?(o.x=0,o.y=0,"z"in o&&(o.z=0),"w"in o&&(o.w=0),null):(o.setScalar(0),o.addScaledVector(r,Yr.x),o.addScaledVector(s,Yr.y),o.addScaledVector(a,Yr.z),o)}static getInterpolatedAttribute(t,e,n,i,r,s){return ns.setScalar(0),is.setScalar(0),rs.setScalar(0),ns.fromBufferAttribute(t,e),is.fromBufferAttribute(t,n),rs.fromBufferAttribute(t,i),s.setScalar(0),s.addScaledVector(ns,r.x),s.addScaledVector(is,r.y),s.addScaledVector(rs,r.z),s}static isFrontFacing(t,e,n,i){return jr.subVectors(n,e),qr.subVectors(t,e),jr.cross(qr).dot(i)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,i){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[i]),this}setFromAttributeAndIndices(t,e,n,i){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,i),this}clone(){return(new this.constructor).copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return jr.subVectors(this.c,this.b),qr.subVectors(this.a,this.b),.5*jr.cross(qr).length()}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return ss.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return ss.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,n,i,r){return ss.getInterpolation(t,this.a,this.b,this.c,e,n,i,r)}containsPoint(t){return ss.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return ss.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const n=this.a,i=this.b,r=this.c;let s,a;Jr.subVectors(i,n),Kr.subVectors(r,n),$r.subVectors(t,n);const o=Jr.dot($r),l=Kr.dot($r);if(o<=0&&l<=0)return e.copy(n);ts.subVectors(t,i);const c=Jr.dot(ts),h=Kr.dot(ts);if(c>=0&&h<=c)return e.copy(i);const u=o*h-c*l;if(u<=0&&o>=0&&c<=0)return s=o/(o-c),e.copy(n).addScaledVector(Jr,s);es.subVectors(t,r);const d=Jr.dot(es),p=Kr.dot(es);if(p>=0&&d<=p)return e.copy(r);const f=d*l-o*p;if(f<=0&&l>=0&&p<=0)return a=l/(l-p),e.copy(n).addScaledVector(Kr,a);const m=c*p-d*h;if(m<=0&&h-c>=0&&d-p>=0)return Zr.subVectors(r,i),a=(h-c)/(h-c+(d-p)),e.copy(i).addScaledVector(Zr,a);const g=1/(m+f+u);return s=f*g,a=u*g,e.copy(n).addScaledVector(Jr,s).addScaledVector(Kr,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const as={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},os={h:0,s:0,l:0},ls={h:0,s:0,l:0};function cs(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+6*(e-t)*(2/3-n):t}class hs{constructor(t,e,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,n)}set(t,e,n){if(void 0===e&&void 0===n){const e=t;e&&e.isColor?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=hn){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,yi.toWorkingColorSpace(this,e),this}setRGB(t,e,n,i=yi.workingColorSpace){return this.r=t,this.g=e,this.b=n,yi.toWorkingColorSpace(this,i),this}setHSL(t,e,n,i=yi.workingColorSpace){if(t=ri(t,1),e=ii(e,0,1),n=ii(n,0,1),0===e)this.r=this.g=this.b=n;else{const i=n<=.5?n*(1+e):n+e-n*e,r=2*n-i;this.r=cs(r,i,t+1/3),this.g=cs(r,i,t),this.b=cs(r,i,t-1/3)}return yi.toWorkingColorSpace(this,i),this}setStyle(t,e=hn){function n(e){void 0!==e&&parseFloat(e)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(t)){let r;const s=i[1],a=i[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,e);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,e);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,e);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(t)){const n=i[1],r=n.length;if(3===r)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,e);if(6===r)return this.setHex(parseInt(n,16),e);console.warn("THREE.Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=hn){const n=as[t.toLowerCase()];return void 0!==n?this.setHex(n,e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=_i(t.r),this.g=_i(t.g),this.b=_i(t.b),this}copyLinearToSRGB(t){return this.r=xi(t.r),this.g=xi(t.g),this.b=xi(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=hn){return yi.fromWorkingColorSpace(us.copy(this),t),65536*Math.round(ii(255*us.r,0,255))+256*Math.round(ii(255*us.g,0,255))+Math.round(ii(255*us.b,0,255))}getHexString(t=hn){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=yi.workingColorSpace){yi.fromWorkingColorSpace(us.copy(this),e);const n=us.r,i=us.g,r=us.b,s=Math.max(n,i,r),a=Math.min(n,i,r);let o,l;const c=(a+s)/2;if(a===s)o=0,l=0;else{const t=s-a;switch(l=c<=.5?t/(s+a):t/(2-s-a),s){case n:o=(i-r)/t+(i0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(void 0!==t)for(const e in t){const n=t[e];if(void 0===n){console.warn(`THREE.Material: parameter '${e}' has value of undefined.`);continue}const i=this[e];void 0!==i?i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[e]=n:console.warn(`THREE.Material: '${e}' is not a property of THREE.${this.type}.`)}}toJSON(t){const e=void 0===t||"string"==typeof t;e&&(t={textures:{},images:{}});const n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};function i(t){const e=[];for(const n in t){const i=t[n];delete i.metadata,e.push(i)}return e}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),void 0!==this.roughness&&(n.roughness=this.roughness),void 0!==this.metalness&&(n.metalness=this.metalness),void 0!==this.sheen&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),void 0!==this.emissiveIntensity&&1!==this.emissiveIntensity&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(n.shininess=this.shininess),void 0!==this.clearcoat&&(n.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),void 0!==this.dispersion&&(n.dispersion=this.dispersion),void 0!==this.iridescence&&(n.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(n.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),void 0!==this.anisotropy&&(n.anisotropy=this.anisotropy),void 0!==this.anisotropyRotation&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).uuid,void 0!==this.combine&&(n.combine=this.combine)),void 0!==this.envMapRotation&&(n.envMapRotation=this.envMapRotation.toArray()),void 0!==this.envMapIntensity&&(n.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(n.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(t).uuid),void 0!==this.transmission&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(t).uuid),void 0!==this.thickness&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(t).uuid),void 0!==this.attenuationDistance&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(n.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(n.size=this.size),null!==this.shadowSide&&(n.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==I&&(n.blending=this.blending),this.side!==E&&(n.side=this.side),!0===this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),!0===this.transparent&&(n.transparent=!0),this.blendSrc!==G&&(n.blendSrc=this.blendSrc),this.blendDst!==H&&(n.blendDst=this.blendDst),this.blendEquation!==P&&(n.blendEquation=this.blendEquation),null!==this.blendSrcAlpha&&(n.blendSrcAlpha=this.blendSrcAlpha),null!==this.blendDstAlpha&&(n.blendDstAlpha=this.blendDstAlpha),null!==this.blendEquationAlpha&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),0!==this.blendAlpha&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==nt&&(n.depthFunc=this.depthFunc),!1===this.depthTest&&(n.depthTest=this.depthTest),!1===this.depthWrite&&(n.depthWrite=this.depthWrite),!1===this.colorWrite&&(n.colorWrite=this.colorWrite),255!==this.stencilWriteMask&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Tn&&(n.stencilFunc=this.stencilFunc),0!==this.stencilRef&&(n.stencilRef=this.stencilRef),255!==this.stencilFuncMask&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==mn&&(n.stencilFail=this.stencilFail),this.stencilZFail!==mn&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==mn&&(n.stencilZPass=this.stencilZPass),!0===this.stencilWrite&&(n.stencilWrite=this.stencilWrite),void 0!==this.rotation&&0!==this.rotation&&(n.rotation=this.rotation),!0===this.polygonOffset&&(n.polygonOffset=!0),0!==this.polygonOffsetFactor&&(n.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(n.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(n.linewidth=this.linewidth),void 0!==this.dashSize&&(n.dashSize=this.dashSize),void 0!==this.gapSize&&(n.gapSize=this.gapSize),void 0!==this.scale&&(n.scale=this.scale),!0===this.dithering&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),!0===this.alphaHash&&(n.alphaHash=!0),!0===this.alphaToCoverage&&(n.alphaToCoverage=!0),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=!0),!0===this.forceSinglePass&&(n.forceSinglePass=!0),!0===this.wireframe&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(n.flatShading=!0),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),!1===this.fog&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData),e){const e=i(t.textures),r=i(t.images);e.length>0&&(n.textures=e),r.length>0&&(n.images=r)}return n}clone(){return(new this.constructor).copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let n=null;if(null!==e){const t=e.length;n=new Array(t);for(let i=0;i!==t;++i)n[i]=e[i].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){!0===t&&this.version++}onBuild(){console.warn("Material: onBuild() has been removed.")}}class fs extends ps{static get type(){return"MeshBasicMaterial"}constructor(t){super(),this.isMeshBasicMaterial=!0,this.color=new hs(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ir,this.combine=ot,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}const ms=gs();function gs(){const t=new ArrayBuffer(4),e=new Float32Array(t),n=new Uint32Array(t),i=new Uint32Array(512),r=new Uint32Array(512);for(let t=0;t<256;++t){const e=t-127;e<-27?(i[t]=0,i[256|t]=32768,r[t]=24,r[256|t]=24):e<-14?(i[t]=1024>>-e-14,i[256|t]=1024>>-e-14|32768,r[t]=-e-1,r[256|t]=-e-1):e<=15?(i[t]=e+15<<10,i[256|t]=e+15<<10|32768,r[t]=13,r[256|t]=13):e<128?(i[t]=31744,i[256|t]=64512,r[t]=24,r[256|t]=24):(i[t]=31744,i[256|t]=64512,r[t]=13,r[256|t]=13)}const s=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let t=1;t<1024;++t){let e=t<<13,n=0;for(;!(8388608&e);)e<<=1,n-=8388608;e&=-8388609,n+=947912704,s[t]=e|n}for(let t=1024;t<2048;++t)s[t]=939524096+(t-1024<<13);for(let t=1;t<31;++t)a[t]=t<<23;a[31]=1199570944,a[32]=2147483648;for(let t=33;t<63;++t)a[t]=2147483648+(t-32<<23);a[63]=3347054592;for(let t=1;t<64;++t)32!==t&&(o[t]=1024);return{floatView:e,uint32View:n,baseTable:i,shiftTable:r,mantissaTable:s,exponentTable:a,offsetTable:o}}function As(t){Math.abs(t)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),t=ii(t,-65504,65504),ms.floatView[0]=t;const e=ms.uint32View[0],n=e>>23&511;return ms.baseTable[n]+((8388607&e)>>ms.shiftTable[n])}function vs(t){const e=t>>10;return ms.uint32View[0]=ms.mantissaTable[ms.offsetTable[e]+(1023&t)]+ms.exponentTable[e],ms.floatView[0]}const ys={toHalfFloat:As,fromHalfFloat:vs},_s=new Gi,xs=new ci;class ws{constructor(t,e,n=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=t,this.itemSize=e,this.count=void 0!==t?t.length/e:0,this.normalized=n,this.usage=On,this.updateRanges=[],this.gpuType=Wt,this.version=0}onUploadCallback(){}set needsUpdate(t){!0===t&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,n){t*=this.itemSize,n*=e.itemSize;for(let i=0,r=this.itemSize;ie.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),e.needsUpdate=!0}return this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new Wi);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute)return console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),void this.boundingBox.set(new Gi(-1/0,-1/0,-1/0),new Gi(1/0,1/0,1/0));if(void 0!==t){if(this.boundingBox.setFromBufferAttribute(t),e)for(let t=0,n=e.length;t0&&(t.userData=this.userData),void 0!==this.parameters){const e=this.parameters;for(const n in e)void 0!==e[n]&&(t[n]=e[n]);return t}t.data={attributes:{}};const e=this.index;null!==e&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const n=this.attributes;for(const e in n){const i=n[e];t.data.attributes[e]=i.toJSON(t.data)}const i={};let r=!1;for(const e in this.morphAttributes){const n=this.morphAttributes[e],s=[];for(let e=0,i=n.length;e0&&(i[e]=s,r=!0)}r&&(t.data.morphAttributes=i,t.data.morphTargetsRelative=this.morphTargetsRelative);const s=this.groups;s.length>0&&(t.data.groups=JSON.parse(JSON.stringify(s)));const a=this.boundingSphere;return null!==a&&(t.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),t}clone(){return(new this.constructor).copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const n=t.index;null!==n&&this.setIndex(n.clone(e));const i=t.attributes;for(const t in i){const n=i[t];this.setAttribute(t,n.clone(e))}const r=t.morphAttributes;for(const t in r){const n=[],i=r[t];for(let t=0,r=i.length;t0){const n=t[e[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=n.length;t(t.far-t.near)**2)return}Qs.copy(r).invert(),zs.copy(t.ray).applyMatrix4(Qs),null!==n.boundingBox&&!1===zs.intersectsBox(n.boundingBox)||this._computeIntersections(t,e,zs)}}_computeIntersections(t,e,n){let i;const r=this.geometry,s=this.material,a=r.index,o=r.attributes.position,l=r.attributes.uv,c=r.attributes.uv1,h=r.attributes.normal,u=r.groups,d=r.drawRange;if(null!==a)if(Array.isArray(s))for(let r=0,o=u.length;rn.far?null:{distance:c,point:Js.clone(),object:t}}(t,e,n,i,Vs,Ws,js,Ys);if(h){const t=new Gi;ss.getBarycoord(Ys,Vs,Ws,js,t),r&&(h.uv=ss.getInterpolatedAttribute(r,o,l,c,t,new ci)),s&&(h.uv1=ss.getInterpolatedAttribute(s,o,l,c,t,new ci)),a&&(h.normal=ss.getInterpolatedAttribute(a,o,l,c,t,new Gi),h.normal.dot(i.direction)>0&&h.normal.multiplyScalar(-1));const e={a:o,b:l,c,normal:new Gi,materialIndex:0};ss.getNormal(Vs,Ws,js,e.normal),h.face=e,h.barycoord=t}return h}class $s extends ks{constructor(t=1,e=1,n=1,i=1,r=1,s=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:i,heightSegments:r,depthSegments:s};const a=this;i=Math.floor(i),r=Math.floor(r),s=Math.floor(s);const o=[],l=[],c=[],h=[];let u=0,d=0;function p(t,e,n,i,r,s,p,f,m,g,A){const v=s/m,y=p/g,_=s/2,x=p/2,w=f/2,C=m+1,E=g+1;let M=0,b=0;const S=new Gi;for(let s=0;s0?1:-1,c.push(S.x,S.y,S.z),h.push(o/m),h.push(1-s/g),M+=1}}for(let t=0;t0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;const n={};for(const t in this.extensions)!0===this.extensions[t]&&(n[t]=!0);return Object.keys(n).length>0&&(e.extensions=n),e}}class sa extends Wr{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new vr,this.projectionMatrix=new vr,this.projectionMatrixInverse=new vr,this.coordinateSystem=Yn}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this.coordinateSystem=t.coordinateSystem,this}getWorldDirection(t){return super.getWorldDirection(t).negate()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return(new this.constructor).copy(this)}}const aa=new Gi,oa=new ci,la=new ci;class ca extends sa{constructor(t=50,e=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=null===t.view?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){const e=.5*this.getFilmHeight()/t;this.fov=2*ei*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(.5*ti*this.fov);return.5*this.getFilmHeight()/t}getEffectiveFOV(){return 2*ei*Math.atan(Math.tan(.5*ti*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(t,e,n){aa.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),e.set(aa.x,aa.y).multiplyScalar(-t/aa.z),aa.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(aa.x,aa.y).multiplyScalar(-t/aa.z)}getViewSize(t,e){return this.getViewBounds(t,oa,la),e.subVectors(la,oa)}setViewOffset(t,e,n,i,r,s){this.aspect=t/e,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let e=t*Math.tan(.5*ti*this.fov)/this.zoom,n=2*e,i=this.aspect*n,r=-.5*i;const s=this.view;if(null!==this.view&&this.view.enabled){const t=s.fullWidth,a=s.fullHeight;r+=s.offsetX*i/t,e-=s.offsetY*n/a,i*=s.width/t,n*=s.height/a}const a=this.filmOffset;0!==a&&(r+=t*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,e,e-n,t,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,null!==this.view&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}const ha=-90;class ua extends Wr{constructor(t,e,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new ca(ha,1,t,e);i.layers=this.layers,this.add(i);const r=new ca(ha,1,t,e);r.layers=this.layers,this.add(r);const s=new ca(ha,1,t,e);s.layers=this.layers,this.add(s);const a=new ca(ha,1,t,e);a.layers=this.layers,this.add(a);const o=new ca(ha,1,t,e);o.layers=this.layers,this.add(o);const l=new ca(ha,1,t,e);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const t=this.coordinateSystem,e=this.children.concat(),[n,i,r,s,a,o]=e;for(const t of e)this.remove(t);if(t===Yn)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),s.up.set(0,0,1),s.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),o.up.set(0,1,0),o.lookAt(0,0,-1);else{if(t!==Jn)throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+t);n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),s.up.set(0,0,-1),s.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),o.up.set(0,-1,0),o.lookAt(0,0,-1)}for(const t of e)this.add(t),t.updateMatrixWorld()}update(t,e){null===this.parent&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:i}=this;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());const[r,s,a,o,l,c]=this.children,h=t.getRenderTarget(),u=t.getActiveCubeFace(),d=t.getActiveMipmapLevel(),p=t.xr.enabled;t.xr.enabled=!1;const f=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,t.setRenderTarget(n,0,i),t.render(e,r),t.setRenderTarget(n,1,i),t.render(e,s),t.setRenderTarget(n,2,i),t.render(e,a),t.setRenderTarget(n,3,i),t.render(e,o),t.setRenderTarget(n,4,i),t.render(e,l),n.texture.generateMipmaps=f,t.setRenderTarget(n,5,i),t.render(e,c),t.setRenderTarget(h,u,d),t.xr.enabled=p,n.texture.needsPMREMUpdate=!0}}class da extends Pi{constructor(t,e,n,i,r,s,a,o,l,c){super(t=void 0!==t?t:[],e=void 0!==e?e:xt,n,i,r,s,a,o,l,c),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}class pa extends Ni{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;const n={width:t,height:t,depth:1},i=[n,n,n,n,n,n];this.texture=new da(i,e.mapping,e.wrapS,e.wrapT,e.magFilter,e.minFilter,e.format,e.type,e.anisotropy,e.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=void 0!==e.generateMipmaps&&e.generateMipmaps,this.texture.minFilter=void 0!==e.minFilter?e.minFilter:Lt}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.colorSpace=e.colorSpace,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;const n={tEquirect:{value:null}},i="\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\n\t\t\t\t}\n\t\t\t",r="\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include \n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t",s=new $s(5,5,5),a=new ra({name:"CubemapFromEquirect",uniforms:ta(n),vertexShader:i,fragmentShader:r,side:M,blending:S});a.uniforms.tEquirect.value=e;const o=new Ks(s,a),l=e.minFilter;return e.minFilter===Ft&&(e.minFilter=Lt),new ua(1,10,this).update(t,o),e.minFilter=l,o.geometry.dispose(),o.material.dispose(),this}clear(t,e,n,i){const r=t.getRenderTarget();for(let r=0;r<6;r++)t.setRenderTarget(this,r),t.clear(e,n,i);t.setRenderTarget(r)}}const fa=new Gi,ma=new Gi,ga=new hi;class Aa{constructor(t=new Gi(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,n,i){return this.normal.set(t,e,n),this.constant=i,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,n){const i=fa.subVectors(n,e).cross(ma.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(i,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e){const n=t.delta(fa),i=this.normal.dot(n);if(0===i)return 0===this.distanceToPoint(t.start)?e.copy(t.start):null;const r=-(t.start.dot(this.normal)+this.constant)/i;return r<0||r>1?null:e.copy(t.start).addScaledVector(n,r)}intersectsLine(t){const e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const n=e||ga.getNormalMatrix(t),i=this.coplanarPoint(fa).applyMatrix4(t),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return(new this.constructor).copy(this)}}const va=new cr,ya=new Gi;class _a{constructor(t=new Aa,e=new Aa,n=new Aa,i=new Aa,r=new Aa,s=new Aa){this.planes=[t,e,n,i,r,s]}set(t,e,n,i,r,s){const a=this.planes;return a[0].copy(t),a[1].copy(e),a[2].copy(n),a[3].copy(i),a[4].copy(r),a[5].copy(s),this}copy(t){const e=this.planes;for(let n=0;n<6;n++)e[n].copy(t.planes[n]);return this}setFromProjectionMatrix(t,e=Yn){const n=this.planes,i=t.elements,r=i[0],s=i[1],a=i[2],o=i[3],l=i[4],c=i[5],h=i[6],u=i[7],d=i[8],p=i[9],f=i[10],m=i[11],g=i[12],A=i[13],v=i[14],y=i[15];if(n[0].setComponents(o-r,u-l,m-d,y-g).normalize(),n[1].setComponents(o+r,u+l,m+d,y+g).normalize(),n[2].setComponents(o+s,u+c,m+p,y+A).normalize(),n[3].setComponents(o-s,u-c,m-p,y-A).normalize(),n[4].setComponents(o-a,u-h,m-f,y-v).normalize(),e===Yn)n[5].setComponents(o+a,u+h,m+f,y+v).normalize();else{if(e!==Jn)throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);n[5].setComponents(a,h,f,v).normalize()}return this}intersectsObject(t){if(void 0!==t.boundingSphere)null===t.boundingSphere&&t.computeBoundingSphere(),va.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const e=t.geometry;null===e.boundingSphere&&e.computeBoundingSphere(),va.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(va)}intersectsSprite(t){return va.center.set(0,0,0),va.radius=.7071067811865476,va.applyMatrix4(t.matrixWorld),this.intersectsSphere(va)}intersectsSphere(t){const e=this.planes,n=t.center,i=-t.radius;for(let t=0;t<6;t++)if(e[t].distanceToPoint(n)0?t.max.x:t.min.x,ya.y=i.normal.y>0?t.max.y:t.min.y,ya.z=i.normal.z>0?t.max.z:t.min.z,i.distanceToPoint(ya)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}function xa(){let t=null,e=!1,n=null,i=null;function r(e,s){n(e,s),i=t.requestAnimationFrame(r)}return{start:function(){!0!==e&&null!==n&&(i=t.requestAnimationFrame(r),e=!0)},stop:function(){t.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(t){n=t},setContext:function(e){t=e}}}function wa(t){const e=new WeakMap;return{get:function(t){return t.isInterleavedBufferAttribute&&(t=t.data),e.get(t)},remove:function(n){n.isInterleavedBufferAttribute&&(n=n.data);const i=e.get(n);i&&(t.deleteBuffer(i.buffer),e.delete(n))},update:function(n,i){if(n.isInterleavedBufferAttribute&&(n=n.data),n.isGLBufferAttribute){const t=e.get(n);return void((!t||t.versiont.start-e.start));let e=0;for(let t=1;t 0\n\tvec4 plane;\n\t#ifdef ALPHA_TO_COVERAGE\n\t\tfloat distanceToPlane, distanceGradient;\n\t\tfloat clipOpacity = 1.0;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tdistanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n\t\t\tdistanceGradient = fwidth( distanceToPlane ) / 2.0;\n\t\t\tclipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n\t\t\tif ( clipOpacity == 0.0 ) discard;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\t\tfloat unionClipOpacity = 1.0;\n\t\t\t#pragma unroll_loop_start\n\t\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\t\tplane = clippingPlanes[ i ];\n\t\t\t\tdistanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n\t\t\t\tdistanceGradient = fwidth( distanceToPlane ) / 2.0;\n\t\t\t\tunionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n\t\t\t}\n\t\t\t#pragma unroll_loop_end\n\t\t\tclipOpacity *= 1.0 - unionClipOpacity;\n\t\t#endif\n\t\tdiffuseColor.a *= clipOpacity;\n\t\tif ( diffuseColor.a == 0.0 ) discard;\n\t#else\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\t\tbool clipped = true;\n\t\t\t#pragma unroll_loop_start\n\t\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\t\tplane = clippingPlanes[ i ];\n\t\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t\t}\n\t\t\t#pragma unroll_loop_end\n\t\t\tif ( clipped ) discard;\n\t\t#endif\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvarying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif\n#ifdef USE_BATCHING_COLOR\n\tvec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );\n\tvColor.xyz *= batchingColor.xyz;\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\n#ifdef USE_ALPHAHASH\n\tvarying vec3 vPosition;\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\thighp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tuv.x += filterInt * 3.0 * cubeUV_minTileSize;\n\t\tuv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n\t\tuv.x *= CUBEUV_TEXEL_WIDTH;\n\t\tuv.y *= CUBEUV_TEXEL_HEIGHT;\n\t\t#ifdef texture2DGradEXT\n\t\t\treturn texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n\t\t#else\n\t\t\treturn texture2D( envMap, uv ).rgb;\n\t\t#endif\n\t}\n\t#define cubeUV_r0 1.0\n\t#define cubeUV_m0 - 2.0\n\t#define cubeUV_r1 0.8\n\t#define cubeUV_m1 - 1.0\n\t#define cubeUV_r4 0.4\n\t#define cubeUV_m4 2.0\n\t#define cubeUV_r5 0.305\n\t#define cubeUV_m5 3.0\n\t#define cubeUV_r6 0.21\n\t#define cubeUV_m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= cubeUV_r1 ) {\n\t\t\tmip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n\t\t} else if ( roughness >= cubeUV_r4 ) {\n\t\t\tmip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n\t\t} else if ( roughness >= cubeUV_r5 ) {\n\t\t\tmip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n\t\t} else if ( roughness >= cubeUV_r6 ) {\n\t\t\tmip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = objectTangent;\n#endif\n#ifdef USE_BATCHING\n\tmat3 bm = mat3( batchingMatrix );\n\ttransformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );\n\ttransformedNormal = bm * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = bm * transformedTangent;\n\t#endif\n#endif\n#ifdef USE_INSTANCING\n\tmat3 im = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );\n\ttransformedNormal = im * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = im * transformedTangent;\n\t#endif\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\ttransformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE\n\t\temissiveColor = sRGBTransferEOTF( emissiveColor );\n\t#endif\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",colorspace_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",colorspace_pars_fragment:"vec4 LinearTransferOETF( in vec4 value ) {\n\treturn value;\n}\nvec4 sRGBTransferEOTF( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 sRGBTransferOETF( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform mat3 envMapRotation;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#ifdef USE_ENVMAP\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 reflectVec = reflect( - viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\t#ifdef USE_ANISOTROPY\n\t\tvec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n\t\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\t\tvec3 bentNormal = cross( bitangent, viewDir );\n\t\t\t\tbentNormal = normalize( cross( bentNormal, bitangent ) );\n\t\t\t\tbentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n\t\t\t\treturn getIBLRadiance( viewDir, bentNormal, roughness );\n\t\t\t#else\n\t\t\t\treturn vec3( 0.0 );\n\t\t\t#endif\n\t\t}\n\t#endif\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\tvec2 fw = fwidth( coord ) * 0.5;\n\t\treturn mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n\t#endif\n}",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_fragment:"LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;",lights_lambert_pars_fragment:"varying vec3 vViewPosition;\nstruct LambertMaterial {\n\tvec3 diffuseColor;\n\tfloat specularStrength;\n};\nvoid RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Lambert\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Lambert",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n\tuniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\tif ( cutoffDistance > 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\tmaterial.ior = ior;\n\t#ifdef USE_SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULAR_COLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n\t\t#endif\n\t\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_DISPERSION\n\tmaterial.dispersion = dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\t#ifdef USE_ANISOTROPYMAP\n\t\tmat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n\t\tvec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n\t\tvec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n\t#else\n\t\tvec2 anisotropyV = anisotropyVector;\n\t#endif\n\tmaterial.anisotropy = length( anisotropyV );\n\tif( material.anisotropy == 0.0 ) {\n\t\tanisotropyV = vec2( 1.0, 0.0 );\n\t} else {\n\t\tanisotropyV /= material.anisotropy;\n\t\tmaterial.anisotropy = saturate( material.anisotropy );\n\t}\n\tmaterial.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n\tmaterial.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;\n\tmaterial.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\tfloat dispersion;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n\t#ifdef IOR\n\t\tfloat ior;\n\t#endif\n\t#ifdef USE_TRANSMISSION\n\t\tfloat transmission;\n\t\tfloat transmissionAlpha;\n\t\tfloat thickness;\n\t\tfloat attenuationDistance;\n\t\tvec3 attenuationColor;\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat anisotropy;\n\t\tfloat alphaT;\n\t\tvec3 anisotropyT;\n\t\tvec3 anisotropyB;\n\t#endif\n};\nvec3 clearcoatSpecularDirect = vec3( 0.0 );\nvec3 clearcoatSpecularIndirect = vec3( 0.0 );\nvec3 sheenSpecularDirect = vec3( 0.0 );\nvec3 sheenSpecularIndirect = vec3(0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n\tfloat V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {\n\t\tfloat gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n\t\tfloat gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n\t\tfloat v = 0.5 / ( gv + gl );\n\t\treturn saturate(v);\n\t}\n\tfloat D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n\t\tfloat a2 = alphaT * alphaB;\n\t\thighp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n\t\thighp float v2 = dot( v, v );\n\t\tfloat w2 = a2 / v2;\n\t\treturn RECIPROCAL_PI * a2 * pow2 ( w2 );\n\t}\n#endif\n#ifdef USE_CLEARCOAT\n\tvec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n\t\tvec3 f0 = material.clearcoatF0;\n\t\tfloat f90 = material.clearcoatF90;\n\t\tfloat roughness = material.clearcoatRoughness;\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 f0 = material.specularColor;\n\tfloat f90 = material.specularF90;\n\tfloat roughness = material.roughness;\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t#ifdef USE_IRIDESCENCE\n\t\tF = mix( F, material.iridescenceFresnel, material.iridescence );\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat dotTL = dot( material.anisotropyT, lightDir );\n\t\tfloat dotTV = dot( material.anisotropyT, viewDir );\n\t\tfloat dotTH = dot( material.anisotropyT, halfDir );\n\t\tfloat dotBL = dot( material.anisotropyB, lightDir );\n\t\tfloat dotBV = dot( material.anisotropyB, viewDir );\n\t\tfloat dotBH = dot( material.anisotropyB, halfDir );\n\t\tfloat V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n\t\tfloat D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n\t#else\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t#endif\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n\tfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n\tfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n\treturn saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#endif\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometryNormal;\n\t\tvec3 viewDir = geometryViewDir;\n\t\tvec3 position = geometryPosition;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n\t#else\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\t#endif\n\tvec3 totalScattering = singleScattering + multiScattering;\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\nvec3 geometryClearcoatNormal = vec3( 0.0 );\n#ifdef USE_CLEARCOAT\n\tgeometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometryViewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometryPosition, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometryPosition, directLight );\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#if defined( USE_LIGHT_PROBES )\n\t\tirradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometryNormal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\t#ifdef USE_ANISOTROPY\n\t\tradiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );\n\t#else\n\t\tradiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF )\n\tgl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\tvFragDepth = 1.0 + gl_Position.w;\n\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 sampledDiffuseColor = texture2D( map, vMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tsampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );\n\t#endif\n\tdiffuseColor *= sampledDiffuseColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t#if defined( USE_POINTS_UV )\n\t\tvec2 uv = vUv;\n\t#else\n\t\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_POINTS_UV )\n\tvarying vec2 vUv;\n#else\n\t#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t\tuniform mat3 uvTransform;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphinstance_vertex:"#ifdef USE_INSTANCING_MORPH\n\tfloat morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\tfloat morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tmorphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;\n\t}\n#endif",morphcolor_vertex:"#if defined( USE_MORPHCOLORS )\n\tvColor *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t#if defined( USE_COLOR_ALPHA )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n\t\t#elif defined( USE_COLOR )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n\t\t#endif\n\t}\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\t#ifndef USE_INSTANCING_MORPH\n\t\tuniform float morphTargetBaseInfluence;\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t#endif\n\tuniform sampler2DArray morphTargetsTexture;\n\tuniform ivec2 morphTargetsTextureSize;\n\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n\t\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n\t\tint y = texelIndex / morphTargetsTextureSize.x;\n\t\tint x = texelIndex - y * morphTargetsTextureSize.x;\n\t\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\n\t\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\n\t}\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = dFdx( vViewPosition );\n\tvec3 fdy = dFdy( vViewPosition );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal *= faceDirection;\n\t#endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn = getTangentFrame( - vViewPosition, normal,\n\t\t#if defined( USE_NORMALMAP )\n\t\t\tvNormalMapUv\n\t\t#elif defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tvClearcoatNormalMapUv\n\t\t#else\n\t\t\tvUv\n\t\t#endif\n\t\t);\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn[0] *= faceDirection;\n\t\ttbn[1] *= faceDirection;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn2[0] *= faceDirection;\n\t\ttbn2[1] *= faceDirection;\n\t#endif\n#endif\nvec3 nonPerturbedNormal = normal;",normal_fragment_maps:"#ifdef USE_NORMALMAP_OBJECTSPACE\n\tnormal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n\tvec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\tnormal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef USE_NORMALMAP_OBJECTSPACE\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )\n\tmat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( uv.st );\n\t\tvec2 st1 = dFdy( uv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n\t\treturn mat3( T * scale, B * scale, N );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = nonPerturbedNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\tclearcoatNormal = normalize( tbn2 * clearcoatMapN );\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif",iridescence_pars_fragment:"#ifdef USE_IRIDESCENCEMAP\n\tuniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform sampler2D iridescenceThicknessMap;\n#endif",opaque_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;\nconst float Inv255 = 1. / 255.;\nconst vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );\nconst vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );\nconst vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );\nconst vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );\nvec4 packDepthToRGBA( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec4( 0., 0., 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec4( 1., 1., 1., 1. );\n\tfloat vuf;\n\tfloat af = modf( v * PackFactors.a, vuf );\n\tfloat bf = modf( vuf * ShiftRight8, vuf );\n\tfloat gf = modf( vuf * ShiftRight8, vuf );\n\treturn vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );\n}\nvec3 packDepthToRGB( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec3( 0., 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec3( 1., 1., 1. );\n\tfloat vuf;\n\tfloat bf = modf( v * PackFactors.b, vuf );\n\tfloat gf = modf( vuf * ShiftRight8, vuf );\n\treturn vec3( vuf * Inv255, gf * PackUpscale, bf );\n}\nvec2 packDepthToRG( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec2( 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec2( 1., 1. );\n\tfloat vuf;\n\tfloat gf = modf( v * 256., vuf );\n\treturn vec2( vuf * Inv255, gf );\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors4 );\n}\nfloat unpackRGBToDepth( const in vec3 v ) {\n\treturn dot( v, UnpackFactors3 );\n}\nfloat unpackRGToDepth( const in vec2 v ) {\n\treturn v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;\n}\nvec4 pack2HalfToRGBA( const in vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( const in vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn depth * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * depth - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_BATCHING\n\tmvPosition = batchingMatrix * mvPosition;\n#endif\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n\tuniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tfloat shadow = 1.0;\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\t\n\t\tfloat lightToPositionLength = length( lightToPosition );\n\t\tif ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {\n\t\t\tfloat dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\t\tdp += shadowBias;\n\t\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\t\tshadow = (\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t\t) * ( 1.0 / 9.0 );\n\t\t\t#else\n\t\t\t\tshadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t\t#endif\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n#endif",shadowmap_pars_vertex:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tuniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\tvec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition;\n\t\t#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t\tshadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n\t\t#endif\n\t\tvSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\tuniform highp sampler2D boneTexture;\n\tmat4 getBoneMatrix( const in float i ) {\n\t\tint size = textureSize( boneTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 CineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nconst mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.6605, - 0.1246, - 0.0182 ),\n\tvec3( - 0.5876, 1.1329, - 0.1006 ),\n\tvec3( - 0.0728, - 0.0083, 1.1187 )\n);\nconst mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(\n\tvec3( 0.6274, 0.0691, 0.0164 ),\n\tvec3( 0.3293, 0.9195, 0.0880 ),\n\tvec3( 0.0433, 0.0113, 0.8956 )\n);\nvec3 agxDefaultContrastApprox( vec3 x ) {\n\tvec3 x2 = x * x;\n\tvec3 x4 = x2 * x2;\n\treturn + 15.5 * x4 * x2\n\t\t- 40.14 * x4 * x\n\t\t+ 31.96 * x4\n\t\t- 6.868 * x2 * x\n\t\t+ 0.4298 * x2\n\t\t+ 0.1191 * x\n\t\t- 0.00232;\n}\nvec3 AgXToneMapping( vec3 color ) {\n\tconst mat3 AgXInsetMatrix = mat3(\n\t\tvec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),\n\t\tvec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),\n\t\tvec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )\n\t);\n\tconst mat3 AgXOutsetMatrix = mat3(\n\t\tvec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),\n\t\tvec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),\n\t\tvec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )\n\t);\n\tconst float AgxMinEv = - 12.47393;\tconst float AgxMaxEv = 4.026069;\n\tcolor *= toneMappingExposure;\n\tcolor = LINEAR_SRGB_TO_LINEAR_REC2020 * color;\n\tcolor = AgXInsetMatrix * color;\n\tcolor = max( color, 1e-10 );\tcolor = log2( color );\n\tcolor = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );\n\tcolor = clamp( color, 0.0, 1.0 );\n\tcolor = agxDefaultContrastApprox( color );\n\tcolor = AgXOutsetMatrix * color;\n\tcolor = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );\n\tcolor = LINEAR_REC2020_TO_LINEAR_SRGB * color;\n\tcolor = clamp( color, 0.0, 1.0 );\n\treturn color;\n}\nvec3 NeutralToneMapping( vec3 color ) {\n\tconst float StartCompression = 0.8 - 0.04;\n\tconst float Desaturation = 0.15;\n\tcolor *= toneMappingExposure;\n\tfloat x = min( color.r, min( color.g, color.b ) );\n\tfloat offset = x < 0.08 ? x - 6.25 * x * x : 0.04;\n\tcolor -= offset;\n\tfloat peak = max( color.r, max( color.g, color.b ) );\n\tif ( peak < StartCompression ) return color;\n\tfloat d = 1. - StartCompression;\n\tfloat newPeak = 1. - d * d / ( peak + d - StartCompression );\n\tcolor *= newPeak / peak;\n\tfloat g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );\n\treturn mix( color, vec3( newPeak ), g );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n\tmaterial.transmission = transmission;\n\tmaterial.transmissionAlpha = 1.0;\n\tmaterial.thickness = thickness;\n\tmaterial.attenuationDistance = attenuationDistance;\n\tmaterial.attenuationColor = attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tmaterial.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tmaterial.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmitted = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,\n\t\tmaterial.attenuationColor, material.attenuationDistance );\n\tmaterial.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );\n\ttotalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tfloat w0( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n\t}\n\tfloat w1( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );\n\t}\n\tfloat w2( float a ){\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n\t}\n\tfloat w3( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * a );\n\t}\n\tfloat g0( float a ) {\n\t\treturn w0( a ) + w1( a );\n\t}\n\tfloat g1( float a ) {\n\t\treturn w2( a ) + w3( a );\n\t}\n\tfloat h0( float a ) {\n\t\treturn - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n\t}\n\tfloat h1( float a ) {\n\t\treturn 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n\t}\n\tvec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n\t\tuv = uv * texelSize.zw + 0.5;\n\t\tvec2 iuv = floor( uv );\n\t\tvec2 fuv = fract( uv );\n\t\tfloat g0x = g0( fuv.x );\n\t\tfloat g1x = g1( fuv.x );\n\t\tfloat h0x = h0( fuv.x );\n\t\tfloat h1x = h1( fuv.x );\n\t\tfloat h0y = h0( fuv.y );\n\t\tfloat h1y = h1( fuv.y );\n\t\tvec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\treturn g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +\n\t\t\tg1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n\t}\n\tvec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n\t\tvec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n\t\tvec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n\t\tvec2 fLodSizeInv = 1.0 / fLodSize;\n\t\tvec2 cLodSizeInv = 1.0 / cLodSize;\n\t\tvec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n\t\tvec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n\t\treturn mix( fSample, cSample, fract( lod ) );\n\t}\n\tvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( const in float roughness, const in float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n\t\tfloat lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\treturn textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );\n\t}\n\tvec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( isinf( attenuationDistance ) ) {\n\t\t\treturn vec3( 1.0 );\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n\t\tconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n\t\tconst in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec4 transmittedLight;\n\t\tvec3 transmittance;\n\t\t#ifdef USE_DISPERSION\n\t\t\tfloat halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;\n\t\t\tvec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );\n\t\t\tfor ( int i = 0; i < 3; i ++ ) {\n\t\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );\n\t\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\n\t\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\t\trefractionCoords += 1.0;\n\t\t\t\trefractionCoords /= 2.0;\n\t\t\n\t\t\t\tvec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );\n\t\t\t\ttransmittedLight[ i ] = transmissionSample[ i ];\n\t\t\t\ttransmittedLight.a += transmissionSample.a;\n\t\t\t\ttransmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];\n\t\t\t}\n\t\t\ttransmittedLight.a /= 3.0;\n\t\t\n\t\t#else\n\t\t\n\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\trefractionCoords += 1.0;\n\t\t\trefractionCoords /= 2.0;\n\t\t\ttransmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\t\ttransmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\t\n\t\t#endif\n\t\tvec3 attenuatedColor = transmittance * transmittedLight.rgb;\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\tfloat transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );\n\t}\n#endif",uv_pars_fragment:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_pars_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tuniform mat3 mapTransform;\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform mat3 alphaMapTransform;\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tuniform mat3 lightMapTransform;\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tuniform mat3 aoMapTransform;\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tuniform mat3 bumpMapTransform;\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tuniform mat3 normalMapTransform;\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tuniform mat3 displacementMapTransform;\n\tvarying vec2 vDisplacementMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tuniform mat3 emissiveMapTransform;\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tuniform mat3 metalnessMapTransform;\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tuniform mat3 roughnessMapTransform;\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tuniform mat3 anisotropyMapTransform;\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tuniform mat3 clearcoatMapTransform;\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform mat3 clearcoatNormalMapTransform;\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform mat3 clearcoatRoughnessMapTransform;\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tuniform mat3 sheenColorMapTransform;\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tuniform mat3 sheenRoughnessMapTransform;\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tuniform mat3 iridescenceMapTransform;\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform mat3 iridescenceThicknessMapTransform;\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tuniform mat3 specularMapTransform;\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tuniform mat3 specularColorMapTransform;\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tuniform mat3 specularIntensityMapTransform;\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvUv = vec3( uv, 1 ).xy;\n#endif\n#ifdef USE_MAP\n\tvMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ALPHAMAP\n\tvAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_LIGHTMAP\n\tvLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_AOMAP\n\tvAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_BUMPMAP\n\tvBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_NORMALMAP\n\tvNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tvDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_METALNESSMAP\n\tvMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULARMAP\n\tvSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tvTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_THICKNESSMAP\n\tvThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_BATCHING\n\t\tworldPosition = batchingMatrix * worldPosition;\n\t#endif\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",background_frag:"uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\ttexColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include \n\t#include \n}",backgroundCube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}",backgroundCube_frag:"#ifdef ENVMAP_TYPE_CUBE\n\tuniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n\tuniform sampler2D envMap;\n#endif\nuniform float flipEnvMap;\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nuniform mat3 backgroundRotation;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );\n\t#else\n\t\tvec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include \n\t#include \n}",cube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\tgl_FragColor = texColor;\n\tgl_FragColor.a *= opacity;\n\t#include \n\t#include \n}",depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#elif DEPTH_PACKING == 3202\n\t\tgl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );\n\t#elif DEPTH_PACKING == 3203\n\t\tgl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );\n\t#endif\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition.xyz;\n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include \n\t#include \n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshbasic_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}",meshlambert_frag:"#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t#else\n\t\tvec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );\n\t#ifdef OPAQUE\n\t\tgl_FragColor.a = 1.0;\n\t#endif\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef USE_SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULAR_COLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_DISPERSION\n\tuniform float dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tuniform float iridescence;\n\tuniform float iridescenceIOR;\n\tuniform float iridescenceThicknessMinimum;\n\tuniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\tuniform vec2 anisotropyVector;\n\t#ifdef USE_ANISOTROPYMAP\n\t\tuniform sampler2D anisotropyMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include \n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n\t\toutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",points_vert:"uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \n#ifdef USE_POINTS_UV\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\nvoid main() {\n\t#ifdef USE_POINTS_UV\n\t\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",shadow_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include \n\t#include \n\t#include \n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 mvPosition = modelViewMatrix[ 3 ];\n\tvec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n}"},Ma={common:{diffuse:{value:new hs(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new hi},alphaMap:{value:null},alphaMapTransform:{value:new hi},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new hi}},envmap:{envMap:{value:null},envMapRotation:{value:new hi},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new hi}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new hi}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new hi},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new hi},normalScale:{value:new ci(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new hi},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new hi}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new hi}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new hi}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new hs(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,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 hs(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new hi},alphaTest:{value:0},uvTransform:{value:new hi}},sprite:{diffuse:{value:new hs(16777215)},opacity:{value:1},center:{value:new ci(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new hi},alphaMap:{value:null},alphaMapTransform:{value:new hi},alphaTest:{value:0}}},ba={basic:{uniforms:ea([Ma.common,Ma.specularmap,Ma.envmap,Ma.aomap,Ma.lightmap,Ma.fog]),vertexShader:Ea.meshbasic_vert,fragmentShader:Ea.meshbasic_frag},lambert:{uniforms:ea([Ma.common,Ma.specularmap,Ma.envmap,Ma.aomap,Ma.lightmap,Ma.emissivemap,Ma.bumpmap,Ma.normalmap,Ma.displacementmap,Ma.fog,Ma.lights,{emissive:{value:new hs(0)}}]),vertexShader:Ea.meshlambert_vert,fragmentShader:Ea.meshlambert_frag},phong:{uniforms:ea([Ma.common,Ma.specularmap,Ma.envmap,Ma.aomap,Ma.lightmap,Ma.emissivemap,Ma.bumpmap,Ma.normalmap,Ma.displacementmap,Ma.fog,Ma.lights,{emissive:{value:new hs(0)},specular:{value:new hs(1118481)},shininess:{value:30}}]),vertexShader:Ea.meshphong_vert,fragmentShader:Ea.meshphong_frag},standard:{uniforms:ea([Ma.common,Ma.envmap,Ma.aomap,Ma.lightmap,Ma.emissivemap,Ma.bumpmap,Ma.normalmap,Ma.displacementmap,Ma.roughnessmap,Ma.metalnessmap,Ma.fog,Ma.lights,{emissive:{value:new hs(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ea.meshphysical_vert,fragmentShader:Ea.meshphysical_frag},toon:{uniforms:ea([Ma.common,Ma.aomap,Ma.lightmap,Ma.emissivemap,Ma.bumpmap,Ma.normalmap,Ma.displacementmap,Ma.gradientmap,Ma.fog,Ma.lights,{emissive:{value:new hs(0)}}]),vertexShader:Ea.meshtoon_vert,fragmentShader:Ea.meshtoon_frag},matcap:{uniforms:ea([Ma.common,Ma.bumpmap,Ma.normalmap,Ma.displacementmap,Ma.fog,{matcap:{value:null}}]),vertexShader:Ea.meshmatcap_vert,fragmentShader:Ea.meshmatcap_frag},points:{uniforms:ea([Ma.points,Ma.fog]),vertexShader:Ea.points_vert,fragmentShader:Ea.points_frag},dashed:{uniforms:ea([Ma.common,Ma.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ea.linedashed_vert,fragmentShader:Ea.linedashed_frag},depth:{uniforms:ea([Ma.common,Ma.displacementmap]),vertexShader:Ea.depth_vert,fragmentShader:Ea.depth_frag},normal:{uniforms:ea([Ma.common,Ma.bumpmap,Ma.normalmap,Ma.displacementmap,{opacity:{value:1}}]),vertexShader:Ea.meshnormal_vert,fragmentShader:Ea.meshnormal_frag},sprite:{uniforms:ea([Ma.sprite,Ma.fog]),vertexShader:Ea.sprite_vert,fragmentShader:Ea.sprite_frag},background:{uniforms:{uvTransform:{value:new hi},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ea.background_vert,fragmentShader:Ea.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new hi}},vertexShader:Ea.backgroundCube_vert,fragmentShader:Ea.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ea.cube_vert,fragmentShader:Ea.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ea.equirect_vert,fragmentShader:Ea.equirect_frag},distanceRGBA:{uniforms:ea([Ma.common,Ma.displacementmap,{referencePosition:{value:new Gi},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ea.distanceRGBA_vert,fragmentShader:Ea.distanceRGBA_frag},shadow:{uniforms:ea([Ma.lights,Ma.fog,{color:{value:new hs(0)},opacity:{value:1}}]),vertexShader:Ea.shadow_vert,fragmentShader:Ea.shadow_frag}};ba.physical={uniforms:ea([ba.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new hi},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new hi},clearcoatNormalScale:{value:new ci(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new hi},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new hi},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new hi},sheen:{value:0},sheenColor:{value:new hs(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new hi},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new hi},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new hi},transmissionSamplerSize:{value:new ci},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new hi},attenuationDistance:{value:0},attenuationColor:{value:new hs(0)},specularColor:{value:new hs(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new hi},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new hi},anisotropyVector:{value:new ci},anisotropyMap:{value:null},anisotropyMapTransform:{value:new hi}}]),vertexShader:Ea.meshphysical_vert,fragmentShader:Ea.meshphysical_frag};const Sa={r:0,b:0,g:0},Ia=new Ir,Ta=new vr;function Ba(t,e,n,i,r,s,a){const o=new hs(0);let l,c,h=!0===s?0:1,u=null,d=0,p=null;function f(t){let i=!0===t.isScene?t.background:null;return i&&i.isTexture&&(i=(t.backgroundBlurriness>0?n:e).get(i)),i}function m(e,n){e.getRGB(Sa,na(t)),i.buffers.color.setClear(Sa.r,Sa.g,Sa.b,n,a)}return{getClearColor:function(){return o},setClearColor:function(t,e=1){o.set(t),h=e,m(o,h)},getClearAlpha:function(){return h},setClearAlpha:function(t){h=t,m(o,h)},render:function(e){let n=!1;const r=f(e);null===r?m(o,h):r&&r.isColor&&(m(r,1),n=!0);const s=t.xr.getEnvironmentBlendMode();"additive"===s?i.buffers.color.setClear(0,0,0,1,a):"alpha-blend"===s&&i.buffers.color.setClear(0,0,0,0,a),(t.autoClear||n)&&(i.buffers.depth.setTest(!0),i.buffers.depth.setMask(!0),i.buffers.color.setMask(!0),t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil))},addToRenderList:function(e,n){const i=f(n);i&&(i.isCubeTexture||i.mapping===Mt)?(void 0===c&&(c=new Ks(new $s(1,1,1),new ra({name:"BackgroundCubeMaterial",uniforms:ta(ba.backgroundCube.uniforms),vertexShader:ba.backgroundCube.vertexShader,fragmentShader:ba.backgroundCube.fragmentShader,side:M,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(t,e,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(c)),Ia.copy(n.backgroundRotation),Ia.x*=-1,Ia.y*=-1,Ia.z*=-1,i.isCubeTexture&&!1===i.isRenderTargetTexture&&(Ia.y*=-1,Ia.z*=-1),c.material.uniforms.envMap.value=i,c.material.uniforms.flipEnvMap.value=i.isCubeTexture&&!1===i.isRenderTargetTexture?-1:1,c.material.uniforms.backgroundBlurriness.value=n.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(Ta.makeRotationFromEuler(Ia)),c.material.toneMapped=yi.getTransfer(i.colorSpace)!==pn,u===i&&d===i.version&&p===t.toneMapping||(c.material.needsUpdate=!0,u=i,d=i.version,p=t.toneMapping),c.layers.enableAll(),e.unshift(c,c.geometry,c.material,0,0,null)):i&&i.isTexture&&(void 0===l&&(l=new Ks(new Ca(2,2),new ra({name:"BackgroundMaterial",uniforms:ta(ba.background.uniforms),vertexShader:ba.background.vertexShader,fragmentShader:ba.background.fragmentShader,side:E,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(l)),l.material.uniforms.t2D.value=i,l.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,l.material.toneMapped=yi.getTransfer(i.colorSpace)!==pn,!0===i.matrixAutoUpdate&&i.updateMatrix(),l.material.uniforms.uvTransform.value.copy(i.matrix),u===i&&d===i.version&&p===t.toneMapping||(l.material.needsUpdate=!0,u=i,d=i.version,p=t.toneMapping),l.layers.enableAll(),e.unshift(l,l.geometry,l.material,0,0,null))}}}function Ra(t,e){const n=t.getParameter(t.MAX_VERTEX_ATTRIBS),i={},r=c(null);let s=r,a=!1;function o(e){return t.bindVertexArray(e)}function l(e){return t.deleteVertexArray(e)}function c(t){const e=[],i=[],r=[];for(let t=0;t=0){const n=r[e];let i=a[e];if(void 0===i&&("instanceMatrix"===e&&t.instanceMatrix&&(i=t.instanceMatrix),"instanceColor"===e&&t.instanceColor&&(i=t.instanceColor)),void 0===n)return!0;if(n.attribute!==i)return!0;if(i&&n.data!==i.data)return!0;o++}return s.attributesNum!==o||s.index!==i}(n,m,l,g),A&&function(t,e,n,i){const r={},a=e.attributes;let o=0;const l=n.getAttributes();for(const e in l)if(l[e].location>=0){let n=a[e];void 0===n&&("instanceMatrix"===e&&t.instanceMatrix&&(n=t.instanceMatrix),"instanceColor"===e&&t.instanceColor&&(n=t.instanceColor));const i={};i.attribute=n,n&&n.data&&(i.data=n.data),r[e]=i,o++}s.attributes=r,s.attributesNum=o,s.index=i}(n,m,l,g),null!==g&&e.update(g,t.ELEMENT_ARRAY_BUFFER),(A||a)&&(a=!1,function(n,i,r,s){h();const a=s.attributes,o=r.getAttributes(),l=i.defaultAttributeValues;for(const i in o){const r=o[i];if(r.location>=0){let o=a[i];if(void 0===o&&("instanceMatrix"===i&&n.instanceMatrix&&(o=n.instanceMatrix),"instanceColor"===i&&n.instanceColor&&(o=n.instanceColor)),void 0!==o){const i=o.normalized,a=o.itemSize,l=e.get(o);if(void 0===l)continue;const c=l.buffer,h=l.type,p=l.bytesPerElement,m=h===t.INT||h===t.UNSIGNED_INT||o.gpuType===Ht;if(o.isInterleavedBufferAttribute){const e=o.data,l=e.stride,g=o.offset;if(e.isInstancedInterleavedBuffer){for(let t=0;t0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";e="mediump"}return"mediump"===e&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let a=void 0!==n.precision?n.precision:"highp";const o=s(a);o!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",o,"instead."),a=o);const l=!0===n.logarithmicDepthBuffer,c=!0===n.reverseDepthBuffer&&e.has("EXT_clip_control"),h=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),u=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS);return{isWebGL2:!0,getMaxAnisotropy:function(){if(void 0!==r)return r;if(!0===e.has("EXT_texture_filter_anisotropic")){const n=e.get("EXT_texture_filter_anisotropic");r=t.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r},getMaxPrecision:s,textureFormatReadable:function(e){return e===$t||i.convert(e)===t.getParameter(t.IMPLEMENTATION_COLOR_READ_FORMAT)},textureTypeReadable:function(n){const r=n===jt&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(n!==kt&&i.convert(n)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_TYPE)&&n!==Wt&&!r)},precision:a,logarithmicDepthBuffer:l,reverseDepthBuffer:c,maxTextures:h,maxVertexTextures:u,maxTextureSize:t.getParameter(t.MAX_TEXTURE_SIZE),maxCubemapSize:t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),maxAttributes:t.getParameter(t.MAX_VERTEX_ATTRIBS),maxVertexUniforms:t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),maxVaryings:t.getParameter(t.MAX_VARYING_VECTORS),maxFragmentUniforms:t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),vertexTextures:u>0,maxSamples:t.getParameter(t.MAX_SAMPLES)}}function La(t){const e=this;let n=null,i=0,r=!1,s=!1;const a=new Aa,o=new hi,l={value:null,needsUpdate:!1};function c(t,n,i,r){const s=null!==t?t.length:0;let c=null;if(0!==s){if(c=l.value,!0!==r||null===c){const e=i+4*s,r=n.matrixWorldInverse;o.getNormalMatrix(r),(null===c||c.length0),e.numPlanes=i,e.numIntersection=0);else{const t=s?0:i,e=4*t;let r=f.clippingState||null;l.value=r,r=c(u,o,e,h);for(let t=0;t!==e;++t)r[t]=n[t];f.clippingState=r,this.numIntersection=d?this.numPlanes:0,this.numPlanes+=t}}}function Ua(t){let e=new WeakMap;function n(t,e){return e===Ct?t.mapping=xt:e===Et&&(t.mapping=wt),t}function i(t){const n=t.target;n.removeEventListener("dispose",i);const r=e.get(n);void 0!==r&&(e.delete(n),r.dispose())}return{get:function(r){if(r&&r.isTexture){const s=r.mapping;if(s===Ct||s===Et){if(e.has(r))return n(e.get(r).texture,r.mapping);{const s=r.image;if(s&&s.height>0){const a=new pa(s.height);return a.fromEquirectangularTexture(t,r),e.set(r,a),r.addEventListener("dispose",i),n(a.texture,r.mapping)}return null}}}return r},dispose:function(){e=new WeakMap}}}class Na extends sa{constructor(t=-1,e=1,n=1,i=-1,r=.1,s=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=n,this.bottom=i,this.near=r,this.far=s,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=null===t.view?null:Object.assign({},t.view),this}setViewOffset(t,e,n,i,r,s){null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let r=n-t,s=n+t,a=i+e,o=i-e;if(null!==this.view&&this.view.enabled){const t=(this.right-this.left)/this.view.fullWidth/this.zoom,e=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=t*this.view.offsetX,s=r+t*this.view.width,a-=e*this.view.offsetY,o=a-e*this.view.height}this.projectionMatrix.makeOrthographic(r,s,a,o,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,null!==this.view&&(e.object.view=Object.assign({},this.view)),e}}const Fa=[.125,.215,.35,.446,.526,.582],Oa=new Na,ka=new hs;let Qa=null,za=0,Ga=0,Ha=!1;const Va=(1+Math.sqrt(5))/2,Wa=1/Va,ja=[new Gi(-Va,Wa,0),new Gi(Va,Wa,0),new Gi(-Wa,0,Va),new Gi(Wa,0,Va),new Gi(0,Va,-Wa),new Gi(0,Va,Wa),new Gi(-1,1,-1),new Gi(1,1,-1),new Gi(-1,1,1),new Gi(1,1,1)];class qa{constructor(t){this._renderer=t,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(t,e=0,n=.1,i=100){Qa=this._renderer.getRenderTarget(),za=this._renderer.getActiveCubeFace(),Ga=this._renderer.getActiveMipmapLevel(),Ha=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);const r=this._allocateTargets();return r.depthBuffer=!0,this._sceneToCubeUV(t,n,i,r),e>0&&this._blur(r,0,0,e),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=Ka(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=Ja(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose()}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let t=0;tt-4?o=Fa[a-t+4-1]:0===a&&(o=0),i.push(o);const l=1/(s-2),c=-l,h=1+l,u=[c,c,h,c,h,h,c,c,h,h,c,h],d=6,p=6,f=3,m=2,g=1,A=new Float32Array(f*p*d),v=new Float32Array(m*p*d),y=new Float32Array(g*p*d);for(let t=0;t2?0:-1,i=[e,n,0,e+2/3,n,0,e+2/3,n+1,0,e,n,0,e+2/3,n+1,0,e,n+1,0];A.set(i,f*p*t),v.set(u,m*p*t);const r=[t,t,t,t,t,t];y.set(r,g*p*t)}const _=new ks;_.setAttribute("position",new ws(A,f)),_.setAttribute("uv",new ws(v,m)),_.setAttribute("faceIndex",new ws(y,g)),e.push(_),r>4&&r--}return{lodPlanes:e,sizeLods:n,sigmas:i}}(i)),this._blurMaterial=function(t,e,n){const i=new Float32Array(20),r=new Gi(0,1,0);return new ra({name:"SphericalGaussianBlur",defines:{n:20,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${t}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform int samples;\n\t\t\tuniform float weights[ n ];\n\t\t\tuniform bool latitudinal;\n\t\t\tuniform float dTheta;\n\t\t\tuniform float mipInt;\n\t\t\tuniform vec3 poleAxis;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include \n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t}\n\t\t",blending:S,depthTest:!1,depthWrite:!1})}(i,t,e)}return i}_compileMaterial(t){const e=new Ks(this._lodPlanes[0],t);this._renderer.compile(e,Oa)}_sceneToCubeUV(t,e,n,i){const r=new ca(90,1,e,n),s=[1,-1,1,1,1,1],a=[1,1,1,-1,-1,-1],o=this._renderer,l=o.autoClear,c=o.toneMapping;o.getClearColor(ka),o.toneMapping=ht,o.autoClear=!1;const h=new fs({name:"PMREM.Background",side:M,depthWrite:!1,depthTest:!1}),u=new Ks(new $s,h);let d=!1;const p=t.background;p?p.isColor&&(h.color.copy(p),t.background=null,d=!0):(h.color.copy(ka),d=!0);for(let e=0;e<6;e++){const n=e%3;0===n?(r.up.set(0,s[e],0),r.lookAt(a[e],0,0)):1===n?(r.up.set(0,0,s[e]),r.lookAt(0,a[e],0)):(r.up.set(0,s[e],0),r.lookAt(0,0,a[e]));const l=this._cubeSize;Ya(i,n*l,e>2?l:0,l,l),o.setRenderTarget(i),d&&o.render(u,r),o.render(t,r)}u.geometry.dispose(),u.material.dispose(),o.toneMapping=c,o.autoClear=l,t.background=p}_textureToCubeUV(t,e){const n=this._renderer,i=t.mapping===xt||t.mapping===wt;i?(null===this._cubemapMaterial&&(this._cubemapMaterial=Ka()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===t.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=Ja());const r=i?this._cubemapMaterial:this._equirectMaterial,s=new Ks(this._lodPlanes[0],r);r.uniforms.envMap.value=t;const a=this._cubeSize;Ya(e,0,0,3*a,2*a),n.setRenderTarget(e),n.render(s,Oa)}_applyPMREM(t){const e=this._renderer,n=e.autoClear;e.autoClear=!1;const i=this._lodPlanes.length;for(let e=1;e20&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${f} samples when the maximum is set to 20`);const m=[];let g=0;for(let t=0;t<20;++t){const e=t/p,n=Math.exp(-e*e/2);m.push(n),0===t?g+=n:tA-4?i-A+4:0),4*(this._cubeSize-v),3*v,2*v),o.setRenderTarget(e),o.render(c,Oa)}}function Xa(t,e,n){const i=new Ni(t,e,n);return i.texture.mapping=Mt,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Ya(t,e,n,i,r){t.viewport.set(e,n,i,r),t.scissor.set(e,n,i,r)}function Ja(){return new ra({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\n\t\t\t#include \n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tgl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );\n\n\t\t\t}\n\t\t",blending:S,depthTest:!1,depthWrite:!1})}function Ka(){return new ra({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tuniform float flipEnvMap;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform samplerCube envMap;\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );\n\n\t\t\t}\n\t\t",blending:S,depthTest:!1,depthWrite:!1})}function Za(t){let e=new WeakMap,n=null;function i(t){const n=t.target;n.removeEventListener("dispose",i);const r=e.get(n);void 0!==r&&(e.delete(n),r.dispose())}return{get:function(r){if(r&&r.isTexture){const s=r.mapping,a=s===Ct||s===Et,o=s===xt||s===wt;if(a||o){let s=e.get(r);const l=void 0!==s?s.texture.pmremVersion:0;if(r.isRenderTargetTexture&&r.pmremVersion!==l)return null===n&&(n=new qa(t)),s=a?n.fromEquirectangular(r,s):n.fromCubemap(r,s),s.texture.pmremVersion=r.pmremVersion,e.set(r,s),s.texture;if(void 0!==s)return s.texture;{const l=r.image;return a&&l&&l.height>0||o&&l&&function(t){let e=0;for(let n=0;n<6;n++)void 0!==t[n]&&e++;return 6===e}(l)?(null===n&&(n=new qa(t)),s=a?n.fromEquirectangular(r):n.fromCubemap(r),s.texture.pmremVersion=r.pmremVersion,e.set(r,s),r.addEventListener("dispose",i),s.texture):null}}}return r},dispose:function(){e=new WeakMap,null!==n&&(n.dispose(),n=null)}}}function $a(t){const e={};function n(n){if(void 0!==e[n])return e[n];let i;switch(n){case"WEBGL_depth_texture":i=t.getExtension("WEBGL_depth_texture")||t.getExtension("MOZ_WEBGL_depth_texture")||t.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":i=t.getExtension("WEBGL_compressed_texture_s3tc")||t.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":i=t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=t.getExtension(n)}return e[n]=i,i}return{has:function(t){return null!==n(t)},init:function(){n("EXT_color_buffer_float"),n("WEBGL_clip_cull_distance"),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture"),n("WEBGL_render_shared_exponent")},get:function(t){const e=n(t);return null===e&&vi("THREE.WebGLRenderer: "+t+" extension not supported."),e}}}function to(t,e,n,i){const r={},s=new WeakMap;function a(t){const o=t.target;null!==o.index&&e.remove(o.index);for(const t in o.attributes)e.remove(o.attributes[t]);for(const t in o.morphAttributes){const n=o.morphAttributes[t];for(let t=0,i=n.length;te.maxTextureSize&&(_=Math.ceil(y/e.maxTextureSize),y=e.maxTextureSize);const x=new Float32Array(y*_*4*h),w=new Fi(x,y,_,h);w.type=Wt,w.needsUpdate=!0;const C=4*v;for(let M=0;M0)return t;const r=e*n;let s=uo[r];if(void 0===s&&(s=new Float32Array(r),uo[r]=s),0!==e){i.toArray(s,0);for(let i=1,r=0;i!==e;++i)r+=n,t[i].toArray(s,r)}return s}function vo(t,e){if(t.length!==e.length)return!1;for(let n=0,i=t.length;n":" "} ${r}: ${n[t]}`)}return i.join("\n")}(t.getShaderSource(e),i)}return r}function gl(t,e){const n=function(t){yi._getMatrix(fl,yi.workingColorSpace,t);const e=`mat3( ${fl.elements.map((t=>t.toFixed(4)))} )`;switch(yi.getTransfer(t)){case dn:return[e,"LinearTransferOETF"];case pn:return[e,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",t),[e,"LinearTransferOETF"]}}(e);return[`vec4 ${t}( vec4 value ) {`,`\treturn ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join("\n")}function Al(t,e){let n;switch(e){case ut:n="Linear";break;case dt:n="Reinhard";break;case pt:n="Cineon";break;case ft:n="ACESFilmic";break;case gt:n="AgX";break;case At:n="Neutral";break;case mt:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const vl=new Gi;function yl(t){return""!==t}function _l(t,e){const n=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return t.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function xl(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const wl=/^[ \t]*#include +<([\w\d./]+)>/gm;function Cl(t){return t.replace(wl,Ml)}const El=new Map;function Ml(t,e){let n=Ea[e];if(void 0===n){const t=El.get(e);if(void 0===t)throw new Error("Can not resolve #include <"+e+">");n=Ea[t],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,t)}return Cl(n)}const bl=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function Sl(t){return t.replace(bl,Il)}function Il(t,e,n,i){let r="";for(let t=parseInt(e);t0&&(g+="\n"),A=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,f].filter(yl).join("\n"),A.length>0&&(A+="\n")):(g=[Tl(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,f,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+h:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH","\tuniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(yl).join("\n"),A=[Tl(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,f,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+c:"",n.envMap?"#define "+h:"",n.envMap?"#define "+u:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor||n.batchingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==ht?"#define TONE_MAPPING":"",n.toneMapping!==ht?Ea.tonemapping_pars_fragment:"",n.toneMapping!==ht?Al("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Ea.colorspace_pars_fragment,gl("linearToOutputTexel",n.outputColorSpace),(yi.getLuminanceCoefficients(vl),["float luminance( const in vec3 rgb ) {",`\tconst vec3 weights = vec3( ${vl.x.toFixed(4)}, ${vl.y.toFixed(4)}, ${vl.z.toFixed(4)} );`,"\treturn dot( weights, rgb );","}"].join("\n")),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(yl).join("\n")),a=Cl(a),a=_l(a,n),a=xl(a,n),o=Cl(o),o=_l(o,n),o=xl(o,n),a=Sl(a),o=Sl(o),!0!==n.isRawShaderMaterial&&(v="#version 300 es\n",g=[p,"#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+g,A=["#define varying in",n.glslVersion===Xn?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===Xn?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+A);const y=v+g+a,_=v+A+o,E=dl(r,r.VERTEX_SHADER,y),M=dl(r,r.FRAGMENT_SHADER,_);function b(e){if(t.debug.checkShaderErrors){const n=r.getProgramInfoLog(m).trim(),i=r.getShaderInfoLog(E).trim(),s=r.getShaderInfoLog(M).trim();let a=!0,o=!0;if(!1===r.getProgramParameter(m,r.LINK_STATUS))if(a=!1,"function"==typeof t.debug.onShaderError)t.debug.onShaderError(r,m,E,M);else{const t=ml(r,E,"vertex"),i=ml(r,M,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(m,r.VALIDATE_STATUS)+"\n\nMaterial Name: "+e.name+"\nMaterial Type: "+e.type+"\n\nProgram Info Log: "+n+"\n"+t+"\n"+i)}else""!==n?console.warn("THREE.WebGLProgram: Program Info Log:",n):""!==i&&""!==s||(o=!1);o&&(e.diagnostics={runnable:a,programLog:n,vertexShader:{log:i,prefix:g},fragmentShader:{log:s,prefix:A}})}r.deleteShader(E),r.deleteShader(M),S=new ul(r,m),I=function(t,e){const n={},i=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let r=0;r0,J=s.clearcoat>0,K=s.dispersion>0,Z=s.iridescence>0,$=s.sheen>0,tt=s.transmission>0,et=Y&&!!s.anisotropyMap,nt=J&&!!s.clearcoatMap,it=J&&!!s.clearcoatNormalMap,rt=J&&!!s.clearcoatRoughnessMap,st=Z&&!!s.iridescenceMap,at=Z&&!!s.iridescenceThicknessMap,ot=$&&!!s.sheenColorMap,lt=$&&!!s.sheenRoughnessMap,ct=!!s.specularMap,ut=!!s.specularColorMap,dt=!!s.specularIntensityMap,pt=tt&&!!s.transmissionMap,ft=tt&&!!s.thicknessMap,mt=!!s.gradientMap,gt=!!s.alphaMap,At=s.alphaTest>0,vt=!!s.alphaHash,yt=!!s.extensions;let _t=ht;s.toneMapped&&(null!==L&&!0!==L.isXRRenderTarget||(_t=t.toneMapping));const xt={shaderID:C,shaderType:s.type,shaderName:s.name,vertexShader:T,fragmentShader:B,defines:s.defines,customVertexShaderID:R,customFragmentShaderID:D,isRawShaderMaterial:!0===s.isRawShaderMaterial,glslVersion:s.glslVersion,precision:p,batching:F,batchingColor:F&&null!==A._colorsTexture,instancing:N,instancingColor:N&&null!==A.instanceColor,instancingMorph:N&&null!==A.morphTexture,supportsVertexTextures:d,outputColorSpace:null===L?t.outputColorSpace:!0===L.isXRRenderTarget?L.texture.colorSpace:un,alphaToCoverage:!!s.alphaToCoverage,map:O,matcap:k,envMap:Q,envMapMode:Q&&x.mapping,envMapCubeUVHeight:w,aoMap:z,lightMap:G,bumpMap:H,normalMap:V,displacementMap:d&&W,emissiveMap:j,normalMapObjectSpace:V&&s.normalMapType===ln,normalMapTangentSpace:V&&s.normalMapType===on,metalnessMap:q,roughnessMap:X,anisotropy:Y,anisotropyMap:et,clearcoat:J,clearcoatMap:nt,clearcoatNormalMap:it,clearcoatRoughnessMap:rt,dispersion:K,iridescence:Z,iridescenceMap:st,iridescenceThicknessMap:at,sheen:$,sheenColorMap:ot,sheenRoughnessMap:lt,specularMap:ct,specularColorMap:ut,specularIntensityMap:dt,transmission:tt,transmissionMap:pt,thicknessMap:ft,gradientMap:mt,opaque:!1===s.transparent&&s.blending===I&&!1===s.alphaToCoverage,alphaMap:gt,alphaTest:At,alphaHash:vt,combine:s.combine,mapUv:O&&m(s.map.channel),aoMapUv:z&&m(s.aoMap.channel),lightMapUv:G&&m(s.lightMap.channel),bumpMapUv:H&&m(s.bumpMap.channel),normalMapUv:V&&m(s.normalMap.channel),displacementMapUv:W&&m(s.displacementMap.channel),emissiveMapUv:j&&m(s.emissiveMap.channel),metalnessMapUv:q&&m(s.metalnessMap.channel),roughnessMapUv:X&&m(s.roughnessMap.channel),anisotropyMapUv:et&&m(s.anisotropyMap.channel),clearcoatMapUv:nt&&m(s.clearcoatMap.channel),clearcoatNormalMapUv:it&&m(s.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:rt&&m(s.clearcoatRoughnessMap.channel),iridescenceMapUv:st&&m(s.iridescenceMap.channel),iridescenceThicknessMapUv:at&&m(s.iridescenceThicknessMap.channel),sheenColorMapUv:ot&&m(s.sheenColorMap.channel),sheenRoughnessMapUv:lt&&m(s.sheenRoughnessMap.channel),specularMapUv:ct&&m(s.specularMap.channel),specularColorMapUv:ut&&m(s.specularColorMap.channel),specularIntensityMapUv:dt&&m(s.specularIntensityMap.channel),transmissionMapUv:pt&&m(s.transmissionMap.channel),thicknessMapUv:ft&&m(s.thicknessMap.channel),alphaMapUv:gt&&m(s.alphaMap.channel),vertexTangents:!!y.attributes.tangent&&(V||Y),vertexColors:s.vertexColors,vertexAlphas:!0===s.vertexColors&&!!y.attributes.color&&4===y.attributes.color.itemSize,pointsUvs:!0===A.isPoints&&!!y.attributes.uv&&(O||gt),fog:!!v,useFog:!0===s.fog,fogExp2:!!v&&v.isFogExp2,flatShading:!0===s.flatShading,sizeAttenuation:!0===s.sizeAttenuation,logarithmicDepthBuffer:u,reverseDepthBuffer:U,skinning:!0===A.isSkinnedMesh,morphTargets:void 0!==y.morphAttributes.position,morphNormals:void 0!==y.morphAttributes.normal,morphColors:void 0!==y.morphAttributes.color,morphTargetsCount:S,morphTextureStride:P,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numSpotLightMaps:o.spotLightMap.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numDirLightShadows:o.directionalShadowMap.length,numPointLightShadows:o.pointShadowMap.length,numSpotLightShadows:o.spotShadowMap.length,numSpotLightShadowsWithMaps:o.numSpotLightShadowsWithMaps,numLightProbes:o.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:s.dithering,shadowMapEnabled:t.shadowMap.enabled&&h.length>0,shadowMapType:t.shadowMap.type,toneMapping:_t,decodeVideoTexture:O&&!0===s.map.isVideoTexture&&yi.getTransfer(s.map.colorSpace)===pn,decodeVideoTextureEmissive:j&&!0===s.emissiveMap.isVideoTexture&&yi.getTransfer(s.emissiveMap.colorSpace)===pn,premultipliedAlpha:s.premultipliedAlpha,doubleSided:s.side===b,flipSided:s.side===M,useDepthPacking:s.depthPacking>=0,depthPacking:s.depthPacking||0,index0AttributeName:s.index0AttributeName,extensionClipCullDistance:yt&&!0===s.extensions.clipCullDistance&&i.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(yt&&!0===s.extensions.multiDraw||F)&&i.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:s.customProgramCacheKey()};return xt.vertexUv1s=c.has(1),xt.vertexUv2s=c.has(2),xt.vertexUv3s=c.has(3),c.clear(),xt},getProgramCacheKey:function(e){const n=[];if(e.shaderID?n.push(e.shaderID):(n.push(e.customVertexShaderID),n.push(e.customFragmentShaderID)),void 0!==e.defines)for(const t in e.defines)n.push(t),n.push(e.defines[t]);return!1===e.isRawShaderMaterial&&(function(t,e){t.push(e.precision),t.push(e.outputColorSpace),t.push(e.envMapMode),t.push(e.envMapCubeUVHeight),t.push(e.mapUv),t.push(e.alphaMapUv),t.push(e.lightMapUv),t.push(e.aoMapUv),t.push(e.bumpMapUv),t.push(e.normalMapUv),t.push(e.displacementMapUv),t.push(e.emissiveMapUv),t.push(e.metalnessMapUv),t.push(e.roughnessMapUv),t.push(e.anisotropyMapUv),t.push(e.clearcoatMapUv),t.push(e.clearcoatNormalMapUv),t.push(e.clearcoatRoughnessMapUv),t.push(e.iridescenceMapUv),t.push(e.iridescenceThicknessMapUv),t.push(e.sheenColorMapUv),t.push(e.sheenRoughnessMapUv),t.push(e.specularMapUv),t.push(e.specularColorMapUv),t.push(e.specularIntensityMapUv),t.push(e.transmissionMapUv),t.push(e.thicknessMapUv),t.push(e.combine),t.push(e.fogExp2),t.push(e.sizeAttenuation),t.push(e.morphTargetsCount),t.push(e.morphAttributeCount),t.push(e.numDirLights),t.push(e.numPointLights),t.push(e.numSpotLights),t.push(e.numSpotLightMaps),t.push(e.numHemiLights),t.push(e.numRectAreaLights),t.push(e.numDirLightShadows),t.push(e.numPointLightShadows),t.push(e.numSpotLightShadows),t.push(e.numSpotLightShadowsWithMaps),t.push(e.numLightProbes),t.push(e.shadowMapType),t.push(e.toneMapping),t.push(e.numClippingPlanes),t.push(e.numClipIntersection),t.push(e.depthPacking)}(n,e),function(t,e){o.disableAll(),e.supportsVertexTextures&&o.enable(0),e.instancing&&o.enable(1),e.instancingColor&&o.enable(2),e.instancingMorph&&o.enable(3),e.matcap&&o.enable(4),e.envMap&&o.enable(5),e.normalMapObjectSpace&&o.enable(6),e.normalMapTangentSpace&&o.enable(7),e.clearcoat&&o.enable(8),e.iridescence&&o.enable(9),e.alphaTest&&o.enable(10),e.vertexColors&&o.enable(11),e.vertexAlphas&&o.enable(12),e.vertexUv1s&&o.enable(13),e.vertexUv2s&&o.enable(14),e.vertexUv3s&&o.enable(15),e.vertexTangents&&o.enable(16),e.anisotropy&&o.enable(17),e.alphaHash&&o.enable(18),e.batching&&o.enable(19),e.dispersion&&o.enable(20),e.batchingColor&&o.enable(21),t.push(o.mask),o.disableAll(),e.fog&&o.enable(0),e.useFog&&o.enable(1),e.flatShading&&o.enable(2),e.logarithmicDepthBuffer&&o.enable(3),e.reverseDepthBuffer&&o.enable(4),e.skinning&&o.enable(5),e.morphTargets&&o.enable(6),e.morphNormals&&o.enable(7),e.morphColors&&o.enable(8),e.premultipliedAlpha&&o.enable(9),e.shadowMapEnabled&&o.enable(10),e.doubleSided&&o.enable(11),e.flipSided&&o.enable(12),e.useDepthPacking&&o.enable(13),e.dithering&&o.enable(14),e.transmission&&o.enable(15),e.sheen&&o.enable(16),e.opaque&&o.enable(17),e.pointsUvs&&o.enable(18),e.decodeVideoTexture&&o.enable(19),e.decodeVideoTextureEmissive&&o.enable(20),e.alphaToCoverage&&o.enable(21),t.push(o.mask)}(n,e),n.push(t.outputColorSpace)),n.push(e.customProgramCacheKey),n.join()},getUniforms:function(t){const e=f[t.type];let n;if(e){const t=ba[e];n=ia.clone(t.uniforms)}else n=t.uniforms;return n},acquireProgram:function(e,n){let i;for(let t=0,e=h.length;t0?i.push(h):!0===a.transparent?r.push(h):n.push(h)},unshift:function(t,e,a,o,l,c){const h=s(t,e,a,o,l,c);a.transmission>0?i.unshift(h):!0===a.transparent?r.unshift(h):n.unshift(h)},finish:function(){for(let n=e,i=t.length;n1&&n.sort(t||Nl),i.length>1&&i.sort(e||Fl),r.length>1&&r.sort(e||Fl)}}}function kl(){let t=new WeakMap;return{get:function(e,n){const i=t.get(e);let r;return void 0===i?(r=new Ol,t.set(e,[r])):n>=i.length?(r=new Ol,i.push(r)):r=i[n],r},dispose:function(){t=new WeakMap}}}function Ql(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let n;switch(e.type){case"DirectionalLight":n={direction:new Gi,color:new hs};break;case"SpotLight":n={position:new Gi,direction:new Gi,color:new hs,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new Gi,color:new hs,distance:0,decay:0};break;case"HemisphereLight":n={direction:new Gi,skyColor:new hs,groundColor:new hs};break;case"RectAreaLight":n={color:new hs,position:new Gi,halfWidth:new Gi,halfHeight:new Gi}}return t[e.id]=n,n}}}let zl=0;function Gl(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function Hl(t){const e=new Ql,n=function(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let n;switch(e.type){case"DirectionalLight":case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ci};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ci,shadowCameraNear:1,shadowCameraFar:1e3}}return t[e.id]=n,n}}}(),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 t=0;t<9;t++)i.probe.push(new Gi);const r=new Gi,s=new vr,a=new vr;return{setup:function(r){let s=0,a=0,o=0;for(let t=0;t<9;t++)i.probe[t].set(0,0,0);let l=0,c=0,h=0,u=0,d=0,p=0,f=0,m=0,g=0,A=0,v=0;r.sort(Gl);for(let t=0,y=r.length;t0&&(!0===t.has("OES_texture_float_linear")?(i.rectAreaLTC1=Ma.LTC_FLOAT_1,i.rectAreaLTC2=Ma.LTC_FLOAT_2):(i.rectAreaLTC1=Ma.LTC_HALF_1,i.rectAreaLTC2=Ma.LTC_HALF_2)),i.ambient[0]=s,i.ambient[1]=a,i.ambient[2]=o;const y=i.hash;y.directionalLength===l&&y.pointLength===c&&y.spotLength===h&&y.rectAreaLength===u&&y.hemiLength===d&&y.numDirectionalShadows===p&&y.numPointShadows===f&&y.numSpotShadows===m&&y.numSpotMaps===g&&y.numLightProbes===v||(i.directional.length=l,i.spot.length=h,i.rectArea.length=u,i.point.length=c,i.hemi.length=d,i.directionalShadow.length=p,i.directionalShadowMap.length=p,i.pointShadow.length=f,i.pointShadowMap.length=f,i.spotShadow.length=m,i.spotShadowMap.length=m,i.directionalShadowMatrix.length=p,i.pointShadowMatrix.length=f,i.spotLightMatrix.length=m+g-A,i.spotLightMap.length=g,i.numSpotLightShadowsWithMaps=A,i.numLightProbes=v,y.directionalLength=l,y.pointLength=c,y.spotLength=h,y.rectAreaLength=u,y.hemiLength=d,y.numDirectionalShadows=p,y.numPointShadows=f,y.numSpotShadows=m,y.numSpotMaps=g,y.numLightProbes=v,i.version=zl++)},setupView:function(t,e){let n=0,o=0,l=0,c=0,h=0;const u=e.matrixWorldInverse;for(let e=0,d=t.length;e=r.length?(s=new Vl(t),r.push(s)):s=r[i],s},dispose:function(){e=new WeakMap}}}class jl extends ps{static get type(){return"MeshDepthMaterial"}constructor(t){super(),this.isMeshDepthMaterial=!0,this.depthPacking=nn,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}}class ql extends ps{static get type(){return"MeshDistanceMaterial"}constructor(t){super(),this.isMeshDistanceMaterial=!0,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(t)}copy(t){return super.copy(t),this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}}function Xl(t,e,n){let i=new _a;const r=new ci,s=new ci,a=new Li,o=new jl({depthPacking:rn}),l=new ql,c={},h=n.maxTextureSize,u={[E]:M,[M]:E,[b]:b},d=new ra({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new ci},radius:{value:4}},vertexShader:"void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include \nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}"}),p=d.clone();p.defines.HORIZONTAL_PASS=1;const f=new ks;f.setAttribute("position",new ws(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const m=new Ks(f,d),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=x;let A=this.type;function v(n,i){const s=e.update(m);d.defines.VSM_SAMPLES!==n.blurSamples&&(d.defines.VSM_SAMPLES=n.blurSamples,p.defines.VSM_SAMPLES=n.blurSamples,d.needsUpdate=!0,p.needsUpdate=!0),null===n.mapPass&&(n.mapPass=new Ni(r.x,r.y)),d.uniforms.shadow_pass.value=n.map.texture,d.uniforms.resolution.value=n.mapSize,d.uniforms.radius.value=n.radius,t.setRenderTarget(n.mapPass),t.clear(),t.renderBufferDirect(i,null,s,d,m,null),p.uniforms.shadow_pass.value=n.mapPass.texture,p.uniforms.resolution.value=n.mapSize,p.uniforms.radius.value=n.radius,t.setRenderTarget(n.map),t.clear(),t.renderBufferDirect(i,null,s,p,m,null)}function y(e,n,i,r){let s=null;const a=!0===i.isPointLight?e.customDistanceMaterial:e.customDepthMaterial;if(void 0!==a)s=a;else if(s=!0===i.isPointLight?l:o,t.localClippingEnabled&&!0===n.clipShadows&&Array.isArray(n.clippingPlanes)&&0!==n.clippingPlanes.length||n.displacementMap&&0!==n.displacementScale||n.alphaMap&&n.alphaTest>0||n.map&&n.alphaTest>0){const t=s.uuid,e=n.uuid;let i=c[t];void 0===i&&(i={},c[t]=i);let r=i[e];void 0===r&&(r=s.clone(),i[e]=r,n.addEventListener("dispose",w)),s=r}return s.visible=n.visible,s.wireframe=n.wireframe,s.side=r===C?null!==n.shadowSide?n.shadowSide:n.side:null!==n.shadowSide?n.shadowSide:u[n.side],s.alphaMap=n.alphaMap,s.alphaTest=n.alphaTest,s.map=n.map,s.clipShadows=n.clipShadows,s.clippingPlanes=n.clippingPlanes,s.clipIntersection=n.clipIntersection,s.displacementMap=n.displacementMap,s.displacementScale=n.displacementScale,s.displacementBias=n.displacementBias,s.wireframeLinewidth=n.wireframeLinewidth,s.linewidth=n.linewidth,!0===i.isPointLight&&!0===s.isMeshDistanceMaterial&&(t.properties.get(s).light=i),s}function _(n,r,s,a,o){if(!1===n.visible)return;if(n.layers.test(r.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&o===C)&&(!n.frustumCulled||i.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(s.matrixWorldInverse,n.matrixWorld);const i=e.update(n),l=n.material;if(Array.isArray(l)){const e=i.groups;for(let c=0,h=e.length;ch||r.y>h)&&(r.x>h&&(s.x=Math.floor(h/m.x),r.x=s.x*m.x,u.mapSize.x=s.x),r.y>h&&(s.y=Math.floor(h/m.y),r.y=s.y*m.y,u.mapSize.y=s.y)),null===u.map||!0===p||!0===f){const t=this.type!==C?{minFilter:Tt,magFilter:Tt}:{};null!==u.map&&u.map.dispose(),u.map=new Ni(r.x,r.y,t),u.map.texture.name=c.name+".shadowMap",u.camera.updateProjectionMatrix()}t.setRenderTarget(u.map),t.clear();const g=u.getViewportCount();for(let t=0;t=1):-1!==gt.indexOf("OpenGL ES")&&(mt=parseFloat(/^OpenGL ES (\d)/.exec(gt)[1]),ft=mt>=2);let At=null,vt={};const yt=t.getParameter(t.SCISSOR_BOX),_t=t.getParameter(t.VIEWPORT),xt=(new Li).fromArray(yt),wt=(new Li).fromArray(_t);function Ct(e,n,i,r){const s=new Uint8Array(4),a=t.createTexture();t.bindTexture(e,a),t.texParameteri(e,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(e,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let a=0;ae?(t.repeat.x=1,t.repeat.y=n/e,t.offset.x=0,t.offset.y=(1-t.repeat.y)/2):(t.repeat.x=e/n,t.repeat.y=1,t.offset.x=(1-t.repeat.x)/2,t.offset.y=0),t},cover:function(t,e){const n=t.image&&t.image.width?t.image.width/t.image.height:1;return n>e?(t.repeat.x=e/n,t.repeat.y=1,t.offset.x=(1-t.repeat.x)/2,t.offset.y=0):(t.repeat.x=1,t.repeat.y=n/e,t.offset.x=0,t.offset.y=(1-t.repeat.y)/2),t},fill:function(t){return t.repeat.x=1,t.repeat.y=1,t.offset.x=0,t.offset.y=0,t},getByteLength:Kl};function $l(t,e,n,i,r,s,a){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l="undefined"!=typeof navigator&&/OculusBrowser/g.test(navigator.userAgent),c=new ci,h=new WeakMap;let u;const d=new WeakMap;let p=!1;try{p="undefined"!=typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(t){}function f(t,e){return p?new OffscreenCanvas(t,e):mi("canvas")}function m(t,e,n){let i=1;const r=z(t);if((r.width>n||r.height>n)&&(i=n/Math.max(r.width,r.height)),i<1){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap||"undefined"!=typeof VideoFrame&&t instanceof VideoFrame){const n=Math.floor(i*r.width),s=Math.floor(i*r.height);void 0===u&&(u=f(n,s));const a=e?f(n,s):u;return a.width=n,a.height=s,a.getContext("2d").drawImage(t,0,0,n,s),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+r.width+"x"+r.height+") to ("+n+"x"+s+")."),a}return"data"in t&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+r.width+"x"+r.height+")."),t}return t}function g(t){return t.generateMipmaps}function A(e){t.generateMipmap(e)}function v(e){return e.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:e.isWebGL3DRenderTarget?t.TEXTURE_3D:e.isWebGLArrayRenderTarget||e.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:t.TEXTURE_2D}function y(n,i,r,s,a=!1){if(null!==n){if(void 0!==t[n])return t[n];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+n+"'")}let o=i;if(i===t.RED&&(r===t.FLOAT&&(o=t.R32F),r===t.HALF_FLOAT&&(o=t.R16F),r===t.UNSIGNED_BYTE&&(o=t.R8)),i===t.RED_INTEGER&&(r===t.UNSIGNED_BYTE&&(o=t.R8UI),r===t.UNSIGNED_SHORT&&(o=t.R16UI),r===t.UNSIGNED_INT&&(o=t.R32UI),r===t.BYTE&&(o=t.R8I),r===t.SHORT&&(o=t.R16I),r===t.INT&&(o=t.R32I)),i===t.RG&&(r===t.FLOAT&&(o=t.RG32F),r===t.HALF_FLOAT&&(o=t.RG16F),r===t.UNSIGNED_BYTE&&(o=t.RG8)),i===t.RG_INTEGER&&(r===t.UNSIGNED_BYTE&&(o=t.RG8UI),r===t.UNSIGNED_SHORT&&(o=t.RG16UI),r===t.UNSIGNED_INT&&(o=t.RG32UI),r===t.BYTE&&(o=t.RG8I),r===t.SHORT&&(o=t.RG16I),r===t.INT&&(o=t.RG32I)),i===t.RGB_INTEGER&&(r===t.UNSIGNED_BYTE&&(o=t.RGB8UI),r===t.UNSIGNED_SHORT&&(o=t.RGB16UI),r===t.UNSIGNED_INT&&(o=t.RGB32UI),r===t.BYTE&&(o=t.RGB8I),r===t.SHORT&&(o=t.RGB16I),r===t.INT&&(o=t.RGB32I)),i===t.RGBA_INTEGER&&(r===t.UNSIGNED_BYTE&&(o=t.RGBA8UI),r===t.UNSIGNED_SHORT&&(o=t.RGBA16UI),r===t.UNSIGNED_INT&&(o=t.RGBA32UI),r===t.BYTE&&(o=t.RGBA8I),r===t.SHORT&&(o=t.RGBA16I),r===t.INT&&(o=t.RGBA32I)),i===t.RGB&&r===t.UNSIGNED_INT_5_9_9_9_REV&&(o=t.RGB9_E5),i===t.RGBA){const e=a?dn:yi.getTransfer(s);r===t.FLOAT&&(o=t.RGBA32F),r===t.HALF_FLOAT&&(o=t.RGBA16F),r===t.UNSIGNED_BYTE&&(o=e===pn?t.SRGB8_ALPHA8:t.RGBA8),r===t.UNSIGNED_SHORT_4_4_4_4&&(o=t.RGBA4),r===t.UNSIGNED_SHORT_5_5_5_1&&(o=t.RGB5_A1)}return o!==t.R16F&&o!==t.R32F&&o!==t.RG16F&&o!==t.RG32F&&o!==t.RGBA16F&&o!==t.RGBA32F||e.get("EXT_color_buffer_float"),o}function _(e,n){let i;return e?null===n||n===Vt||n===Yt?i=t.DEPTH24_STENCIL8:n===Wt?i=t.DEPTH32F_STENCIL8:n===Gt&&(i=t.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):null===n||n===Vt||n===Yt?i=t.DEPTH_COMPONENT24:n===Wt?i=t.DEPTH_COMPONENT32F:n===Gt&&(i=t.DEPTH_COMPONENT16),i}function x(t,e){return!0===g(t)||t.isFramebufferTexture&&t.minFilter!==Tt&&t.minFilter!==Lt?Math.log2(Math.max(e.width,e.height))+1:void 0!==t.mipmaps&&t.mipmaps.length>0?t.mipmaps.length:t.isCompressedTexture&&Array.isArray(t.image)?e.mipmaps.length:1}function w(t){const e=t.target;e.removeEventListener("dispose",w),function(t){const e=i.get(t);if(void 0===e.__webglInit)return;const n=t.source,r=d.get(n);if(r){const i=r[e.__cacheKey];i.usedTimes--,0===i.usedTimes&&E(t),0===Object.keys(r).length&&d.delete(n)}i.remove(t)}(e),e.isVideoTexture&&h.delete(e)}function C(e){const n=e.target;n.removeEventListener("dispose",C),function(e){const n=i.get(e);if(e.depthTexture&&(e.depthTexture.dispose(),i.remove(e.depthTexture)),e.isWebGLCubeRenderTarget)for(let e=0;e<6;e++){if(Array.isArray(n.__webglFramebuffer[e]))for(let i=0;i0&&s.__version!==e.version){const t=e.image;if(null===t)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else{if(!1!==t.complete)return void D(s,e,r);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}n.bindTexture(t.TEXTURE_2D,s.__webglTexture,t.TEXTURE0+r)}const S={[bt]:t.REPEAT,[St]:t.CLAMP_TO_EDGE,[It]:t.MIRRORED_REPEAT},I={[Tt]:t.NEAREST,[Bt]:t.NEAREST_MIPMAP_NEAREST,[Dt]:t.NEAREST_MIPMAP_LINEAR,[Lt]:t.LINEAR,[Ut]:t.LINEAR_MIPMAP_NEAREST,[Ft]:t.LINEAR_MIPMAP_LINEAR},T={[Bn]:t.NEVER,[Fn]:t.ALWAYS,[Rn]:t.LESS,[Pn]:t.LEQUAL,[Dn]:t.EQUAL,[Nn]:t.GEQUAL,[Ln]:t.GREATER,[Un]:t.NOTEQUAL};function B(n,s){if(s.type!==Wt||!1!==e.has("OES_texture_float_linear")||s.magFilter!==Lt&&s.magFilter!==Ut&&s.magFilter!==Dt&&s.magFilter!==Ft&&s.minFilter!==Lt&&s.minFilter!==Ut&&s.minFilter!==Dt&&s.minFilter!==Ft||console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),t.texParameteri(n,t.TEXTURE_WRAP_S,S[s.wrapS]),t.texParameteri(n,t.TEXTURE_WRAP_T,S[s.wrapT]),n!==t.TEXTURE_3D&&n!==t.TEXTURE_2D_ARRAY||t.texParameteri(n,t.TEXTURE_WRAP_R,S[s.wrapR]),t.texParameteri(n,t.TEXTURE_MAG_FILTER,I[s.magFilter]),t.texParameteri(n,t.TEXTURE_MIN_FILTER,I[s.minFilter]),s.compareFunction&&(t.texParameteri(n,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(n,t.TEXTURE_COMPARE_FUNC,T[s.compareFunction])),!0===e.has("EXT_texture_filter_anisotropic")){if(s.magFilter===Tt)return;if(s.minFilter!==Dt&&s.minFilter!==Ft)return;if(s.type===Wt&&!1===e.has("OES_texture_float_linear"))return;if(s.anisotropy>1||i.get(s).__currentAnisotropy){const a=e.get("EXT_texture_filter_anisotropic");t.texParameterf(n,a.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(s.anisotropy,r.getMaxAnisotropy())),i.get(s).__currentAnisotropy=s.anisotropy}}}function R(e,n){let i=!1;void 0===e.__webglInit&&(e.__webglInit=!0,n.addEventListener("dispose",w));const r=n.source;let s=d.get(r);void 0===s&&(s={},d.set(r,s));const o=function(t){const e=[];return e.push(t.wrapS),e.push(t.wrapT),e.push(t.wrapR||0),e.push(t.magFilter),e.push(t.minFilter),e.push(t.anisotropy),e.push(t.internalFormat),e.push(t.format),e.push(t.type),e.push(t.generateMipmaps),e.push(t.premultiplyAlpha),e.push(t.flipY),e.push(t.unpackAlignment),e.push(t.colorSpace),e.join()}(n);if(o!==e.__cacheKey){void 0===s[o]&&(s[o]={texture:t.createTexture(),usedTimes:0},a.memory.textures++,i=!0),s[o].usedTimes++;const r=s[e.__cacheKey];void 0!==r&&(s[e.__cacheKey].usedTimes--,0===r.usedTimes&&E(n)),e.__cacheKey=o,e.__webglTexture=s[o].texture}return i}function D(e,a,o){let l=t.TEXTURE_2D;(a.isDataArrayTexture||a.isCompressedArrayTexture)&&(l=t.TEXTURE_2D_ARRAY),a.isData3DTexture&&(l=t.TEXTURE_3D);const c=R(e,a),h=a.source;n.bindTexture(l,e.__webglTexture,t.TEXTURE0+o);const u=i.get(h);if(h.version!==u.__version||!0===c){n.activeTexture(t.TEXTURE0+o);const e=yi.getPrimaries(yi.workingColorSpace),i=a.colorSpace===cn?null:yi.getPrimaries(a.colorSpace),d=a.colorSpace===cn||e===i?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,a.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,a.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,d);let p=m(a.image,!1,r.maxTextureSize);p=Q(a,p);const f=s.convert(a.format,a.colorSpace),v=s.convert(a.type);let w,C=y(a.internalFormat,f,v,a.colorSpace,a.isVideoTexture);B(l,a);const E=a.mipmaps,M=!0!==a.isVideoTexture,b=void 0===u.__version||!0===c,S=h.dataReady,I=x(a,p);if(a.isDepthTexture)C=_(a.format===ie,a.type),b&&(M?n.texStorage2D(t.TEXTURE_2D,1,C,p.width,p.height):n.texImage2D(t.TEXTURE_2D,0,C,p.width,p.height,0,f,v,null));else if(a.isDataTexture)if(E.length>0){M&&b&&n.texStorage2D(t.TEXTURE_2D,I,C,E[0].width,E[0].height);for(let e=0,i=E.length;e0){const i=Kl(w.width,w.height,a.format,a.type);for(const r of a.layerUpdates){const s=w.data.subarray(r*i/w.data.BYTES_PER_ELEMENT,(r+1)*i/w.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,e,0,0,r,w.width,w.height,1,f,s)}a.clearLayerUpdates()}else n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,e,0,0,0,w.width,w.height,p.depth,f,w.data)}else n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,e,C,w.width,w.height,p.depth,0,w.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else M?S&&n.texSubImage3D(t.TEXTURE_2D_ARRAY,e,0,0,0,w.width,w.height,p.depth,f,v,w.data):n.texImage3D(t.TEXTURE_2D_ARRAY,e,C,w.width,w.height,p.depth,0,f,v,w.data)}else{M&&b&&n.texStorage2D(t.TEXTURE_2D,I,C,E[0].width,E[0].height);for(let e=0,i=E.length;e0){const e=Kl(p.width,p.height,a.format,a.type);for(const i of a.layerUpdates){const r=p.data.subarray(i*e/p.data.BYTES_PER_ELEMENT,(i+1)*e/p.data.BYTES_PER_ELEMENT);n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,i,p.width,p.height,1,f,v,r)}a.clearLayerUpdates()}else n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,p.width,p.height,p.depth,f,v,p.data)}else n.texImage3D(t.TEXTURE_2D_ARRAY,0,C,p.width,p.height,p.depth,0,f,v,p.data);else if(a.isData3DTexture)M?(b&&n.texStorage3D(t.TEXTURE_3D,I,C,p.width,p.height,p.depth),S&&n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,p.width,p.height,p.depth,f,v,p.data)):n.texImage3D(t.TEXTURE_3D,0,C,p.width,p.height,p.depth,0,f,v,p.data);else if(a.isFramebufferTexture){if(b)if(M)n.texStorage2D(t.TEXTURE_2D,I,C,p.width,p.height);else{let e=p.width,i=p.height;for(let r=0;r>=1,i>>=1}}else if(E.length>0){if(M&&b){const e=z(E[0]);n.texStorage2D(t.TEXTURE_2D,I,C,e.width,e.height)}for(let e=0,i=E.length;e>h),i=Math.max(1,r.height>>h);c===t.TEXTURE_3D||c===t.TEXTURE_2D_ARRAY?n.texImage3D(c,h,p,e,i,r.depth,0,u,d,null):n.texImage2D(c,h,p,e,i,0,u,d,null)}n.bindFramebuffer(t.FRAMEBUFFER,e),k(r)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,l,c,m.__webglTexture,0,O(r)):(c===t.TEXTURE_2D||c>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&c<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,l,c,m.__webglTexture,h),n.bindFramebuffer(t.FRAMEBUFFER,null)}function L(e,n,i){if(t.bindRenderbuffer(t.RENDERBUFFER,e),n.depthBuffer){const r=n.depthTexture,s=r&&r.isDepthTexture?r.type:null,a=_(n.stencilBuffer,s),l=n.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,c=O(n);k(n)?o.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,c,a,n.width,n.height):i?t.renderbufferStorageMultisample(t.RENDERBUFFER,c,a,n.width,n.height):t.renderbufferStorage(t.RENDERBUFFER,a,n.width,n.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,l,t.RENDERBUFFER,e)}else{const e=n.textures;for(let r=0;r{delete r.__boundDepthTexture,delete r.__depthDisposeCallback,t.removeEventListener("dispose",e)};t.addEventListener("dispose",e),r.__depthDisposeCallback=e}r.__boundDepthTexture=t}if(e.depthTexture&&!r.__autoAllocateDepthBuffer){if(s)throw new Error("target.depthTexture not supported in Cube render targets");!function(e,r){if(r&&r.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,e),!r.depthTexture||!r.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const s=i.get(r.depthTexture);s.__renderTarget=r,s.__webglTexture&&r.depthTexture.image.width===r.width&&r.depthTexture.image.height===r.height||(r.depthTexture.image.width=r.width,r.depthTexture.image.height=r.height,r.depthTexture.needsUpdate=!0),b(r.depthTexture,0);const a=s.__webglTexture,l=O(r);if(r.depthTexture.format===ne)k(r)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,a,0,l):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,a,0);else{if(r.depthTexture.format!==ie)throw new Error("Unknown depthTexture format");k(r)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,a,0,l):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,a,0)}}(r.__webglFramebuffer,e)}else if(s){r.__webglDepthbuffer=[];for(let i=0;i<6;i++)if(n.bindFramebuffer(t.FRAMEBUFFER,r.__webglFramebuffer[i]),void 0===r.__webglDepthbuffer[i])r.__webglDepthbuffer[i]=t.createRenderbuffer(),L(r.__webglDepthbuffer[i],e,!1);else{const n=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,s=r.__webglDepthbuffer[i];t.bindRenderbuffer(t.RENDERBUFFER,s),t.framebufferRenderbuffer(t.FRAMEBUFFER,n,t.RENDERBUFFER,s)}}else if(n.bindFramebuffer(t.FRAMEBUFFER,r.__webglFramebuffer),void 0===r.__webglDepthbuffer)r.__webglDepthbuffer=t.createRenderbuffer(),L(r.__webglDepthbuffer,e,!1);else{const n=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,i=r.__webglDepthbuffer;t.bindRenderbuffer(t.RENDERBUFFER,i),t.framebufferRenderbuffer(t.FRAMEBUFFER,n,t.RENDERBUFFER,i)}n.bindFramebuffer(t.FRAMEBUFFER,null)}const N=[],F=[];function O(t){return Math.min(r.maxSamples,t.samples)}function k(t){const n=i.get(t);return t.samples>0&&!0===e.has("WEBGL_multisampled_render_to_texture")&&!1!==n.__useRenderToTexture}function Q(t,e){const n=t.colorSpace,i=t.format,r=t.type;return!0===t.isCompressedTexture||!0===t.isVideoTexture||n!==un&&n!==cn&&(yi.getTransfer(n)===pn?i===$t&&r===kt||console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",n)),e}function z(t){return"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement?(c.width=t.naturalWidth||t.width,c.height=t.naturalHeight||t.height):"undefined"!=typeof VideoFrame&&t instanceof VideoFrame?(c.width=t.displayWidth,c.height=t.displayHeight):(c.width=t.width,c.height=t.height),c}this.allocateTextureUnit=function(){const t=M;return t>=r.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+t+" texture units while this GPU supports only "+r.maxTextures),M+=1,t},this.resetTextureUnits=function(){M=0},this.setTexture2D=b,this.setTexture2DArray=function(e,r){const s=i.get(e);e.version>0&&s.__version!==e.version?D(s,e,r):n.bindTexture(t.TEXTURE_2D_ARRAY,s.__webglTexture,t.TEXTURE0+r)},this.setTexture3D=function(e,r){const s=i.get(e);e.version>0&&s.__version!==e.version?D(s,e,r):n.bindTexture(t.TEXTURE_3D,s.__webglTexture,t.TEXTURE0+r)},this.setTextureCube=function(e,a){const o=i.get(e);e.version>0&&o.__version!==e.version?function(e,a,o){if(6!==a.image.length)return;const l=R(e,a),c=a.source;n.bindTexture(t.TEXTURE_CUBE_MAP,e.__webglTexture,t.TEXTURE0+o);const h=i.get(c);if(c.version!==h.__version||!0===l){n.activeTexture(t.TEXTURE0+o);const e=yi.getPrimaries(yi.workingColorSpace),i=a.colorSpace===cn?null:yi.getPrimaries(a.colorSpace),u=a.colorSpace===cn||e===i?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,a.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,a.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,u);const d=a.isCompressedTexture||a.image[0].isCompressedTexture,p=a.image[0]&&a.image[0].isDataTexture,f=[];for(let t=0;t<6;t++)f[t]=d||p?p?a.image[t].image:a.image[t]:m(a.image[t],!0,r.maxCubemapSize),f[t]=Q(a,f[t]);const v=f[0],_=s.convert(a.format,a.colorSpace),w=s.convert(a.type),C=y(a.internalFormat,_,w,a.colorSpace),E=!0!==a.isVideoTexture,M=void 0===h.__version||!0===l,b=c.dataReady;let S,I=x(a,v);if(B(t.TEXTURE_CUBE_MAP,a),d){E&&M&&n.texStorage2D(t.TEXTURE_CUBE_MAP,I,C,v.width,v.height);for(let e=0;e<6;e++){S=f[e].mipmaps;for(let i=0;i0&&I++;const e=z(f[0]);n.texStorage2D(t.TEXTURE_CUBE_MAP,I,C,e.width,e.height)}for(let e=0;e<6;e++)if(p){E?b&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,0,0,f[e].width,f[e].height,_,w,f[e].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,C,f[e].width,f[e].height,0,_,w,f[e].data);for(let i=0;i1;if(u||(void 0===l.__webglTexture&&(l.__webglTexture=t.createTexture()),l.__version=r.version,a.memory.textures++),h){o.__webglFramebuffer=[];for(let e=0;e<6;e++)if(r.mipmaps&&r.mipmaps.length>0){o.__webglFramebuffer[e]=[];for(let n=0;n0){o.__webglFramebuffer=[];for(let e=0;e0&&!1===k(e)){o.__webglMultisampledFramebuffer=t.createFramebuffer(),o.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,o.__webglMultisampledFramebuffer);for(let n=0;n0)for(let i=0;i0)for(let n=0;n0)if(!1===k(e)){const r=e.textures,s=e.width,a=e.height;let o=t.COLOR_BUFFER_BIT;const c=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,h=i.get(e),u=r.length>1;if(u)for(let e=0;eo+c?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!l.inputState.pinching&&a<=o-c&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else null!==o&&t.gripSpace&&(r=e.getPose(t.gripSpace,n),null!==r&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1));null!==a&&(i=e.getPose(t.targetRaySpace,n),null===i&&null!==r&&(i=r),null!==i&&(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(ic)))}return null!==a&&(a.visible=null!==i),null!==o&&(o.visible=null!==r),null!==l&&(l.visible=null!==s),this}_getHandJoint(t,e){if(void 0===t.joints[e.jointName]){const n=new nc;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}}class sc{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e,n){if(null===this.texture){const i=new Pi;t.properties.get(i).__webglTexture=e.texture,e.depthNear==n.depthNear&&e.depthFar==n.depthFar||(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=i}}getMesh(t){if(null!==this.texture&&null===this.mesh){const e=t.cameras[0].viewport,n=new ra({vertexShader:"\nvoid main() {\n\n\tgl_Position = vec4( position, 1.0 );\n\n}",fragmentShader:"\nuniform sampler2DArray depthColor;\nuniform float depthWidth;\nuniform float depthHeight;\n\nvoid main() {\n\n\tvec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );\n\n\tif ( coord.x >= 1.0 ) {\n\n\t\tgl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;\n\n\t} else {\n\n\t\tgl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;\n\n\t}\n\n}",uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new Ks(new Ca(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class ac extends Kn{constructor(t,e){super();const n=this;let i=null,r=1,s=null,a="local-floor",o=1,l=null,c=null,h=null,u=null,d=null,p=null;const f=new sc,m=e.getContextAttributes();let g=null,A=null;const v=[],y=[],_=new ci;let x=null;const w=new ca;w.viewport=new Li;const C=new ca;C.viewport=new Li;const E=[w,C],M=new ec;let b=null,S=null;function I(t){const e=y.indexOf(t.inputSource);if(-1===e)return;const n=v[e];void 0!==n&&(n.update(t.inputSource,t.frame,l||s),n.dispatchEvent({type:t.type,data:t.inputSource}))}function T(){i.removeEventListener("select",I),i.removeEventListener("selectstart",I),i.removeEventListener("selectend",I),i.removeEventListener("squeeze",I),i.removeEventListener("squeezestart",I),i.removeEventListener("squeezeend",I),i.removeEventListener("end",T),i.removeEventListener("inputsourceschange",B);for(let t=0;t=0&&(y[i]=null,v[i].disconnect(n))}for(let e=0;e=y.length){y.push(n),i=t;break}if(null===y[t]){y[t]=n,i=t;break}}if(-1===i)break}const r=v[i];r&&r.connect(n)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(t){let e=v[t];return void 0===e&&(e=new rc,v[t]=e),e.getTargetRaySpace()},this.getControllerGrip=function(t){let e=v[t];return void 0===e&&(e=new rc,v[t]=e),e.getGripSpace()},this.getHand=function(t){let e=v[t];return void 0===e&&(e=new rc,v[t]=e),e.getHandSpace()},this.setFramebufferScaleFactor=function(t){r=t,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(t){a=t,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||s},this.setReferenceSpace=function(t){l=t},this.getBaseLayer=function(){return null!==u?u:d},this.getBinding=function(){return h},this.getFrame=function(){return p},this.getSession=function(){return i},this.setSession=async function(c){if(i=c,null!==i){if(g=t.getRenderTarget(),i.addEventListener("select",I),i.addEventListener("selectstart",I),i.addEventListener("selectend",I),i.addEventListener("squeeze",I),i.addEventListener("squeezestart",I),i.addEventListener("squeezeend",I),i.addEventListener("end",T),i.addEventListener("inputsourceschange",B),!0!==m.xrCompatible&&await e.makeXRCompatible(),x=t.getPixelRatio(),t.getSize(_),void 0===i.renderState.layers){const n={antialias:m.antialias,alpha:!0,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:r};d=new XRWebGLLayer(i,e,n),i.updateRenderState({baseLayer:d}),t.setPixelRatio(1),t.setSize(d.framebufferWidth,d.framebufferHeight,!1),A=new Ni(d.framebufferWidth,d.framebufferHeight,{format:$t,type:kt,colorSpace:t.outputColorSpace,stencilBuffer:m.stencil})}else{let n=null,s=null,a=null;m.depth&&(a=m.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,n=m.stencil?ie:ne,s=m.stencil?Yt:Vt);const o={colorFormat:e.RGBA8,depthFormat:a,scaleFactor:r};h=new XRWebGLBinding(i,e),u=h.createProjectionLayer(o),i.updateRenderState({layers:[u]}),t.setPixelRatio(1),t.setSize(u.textureWidth,u.textureHeight,!1),A=new Ni(u.textureWidth,u.textureHeight,{format:$t,type:kt,depthTexture:new so(u.textureWidth,u.textureHeight,s,void 0,void 0,void 0,void 0,void 0,void 0,n),stencilBuffer:m.stencil,colorSpace:t.outputColorSpace,samples:m.antialias?4:0,resolveDepthBuffer:!1===u.ignoreDepthValues})}A.isXRRenderTarget=!0,this.setFoveation(o),l=null,s=await i.requestReferenceSpace(a),U.setContext(i),U.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(null!==i)return i.environmentBlendMode},this.getDepthTexture=function(){return f.getDepthTexture()};const R=new Gi,D=new Gi;function P(t,e){null===e?t.matrixWorld.copy(t.matrix):t.matrixWorld.multiplyMatrices(e.matrixWorld,t.matrix),t.matrixWorldInverse.copy(t.matrixWorld).invert()}this.updateCamera=function(t){if(null===i)return;let e=t.near,n=t.far;null!==f.texture&&(f.depthNear>0&&(e=f.depthNear),f.depthFar>0&&(n=f.depthFar)),M.near=C.near=w.near=e,M.far=C.far=w.far=n,b===M.near&&S===M.far||(i.updateRenderState({depthNear:M.near,depthFar:M.far}),b=M.near,S=M.far),w.layers.mask=2|t.layers.mask,C.layers.mask=4|t.layers.mask,M.layers.mask=w.layers.mask|C.layers.mask;const r=t.parent,s=M.cameras;P(M,r);for(let t=0;t0&&(t.alphaTest.value=i.alphaTest);const r=e.get(i),s=r.envMap,a=r.envMapRotation;s&&(t.envMap.value=s,oc.copy(a),oc.x*=-1,oc.y*=-1,oc.z*=-1,s.isCubeTexture&&!1===s.isRenderTargetTexture&&(oc.y*=-1,oc.z*=-1),t.envMapRotation.value.setFromMatrix4(lc.makeRotationFromEuler(oc)),t.flipEnvMap.value=s.isCubeTexture&&!1===s.isRenderTargetTexture?-1:1,t.reflectivity.value=i.reflectivity,t.ior.value=i.ior,t.refractionRatio.value=i.refractionRatio),i.lightMap&&(t.lightMap.value=i.lightMap,t.lightMapIntensity.value=i.lightMapIntensity,n(i.lightMap,t.lightMapTransform)),i.aoMap&&(t.aoMap.value=i.aoMap,t.aoMapIntensity.value=i.aoMapIntensity,n(i.aoMap,t.aoMapTransform))}return{refreshFogUniforms:function(e,n){n.color.getRGB(e.fogColor.value,na(t)),n.isFog?(e.fogNear.value=n.near,e.fogFar.value=n.far):n.isFogExp2&&(e.fogDensity.value=n.density)},refreshMaterialUniforms:function(t,r,s,a,o){r.isMeshBasicMaterial||r.isMeshLambertMaterial?i(t,r):r.isMeshToonMaterial?(i(t,r),function(t,e){e.gradientMap&&(t.gradientMap.value=e.gradientMap)}(t,r)):r.isMeshPhongMaterial?(i(t,r),function(t,e){t.specular.value.copy(e.specular),t.shininess.value=Math.max(e.shininess,1e-4)}(t,r)):r.isMeshStandardMaterial?(i(t,r),function(t,e){t.metalness.value=e.metalness,e.metalnessMap&&(t.metalnessMap.value=e.metalnessMap,n(e.metalnessMap,t.metalnessMapTransform)),t.roughness.value=e.roughness,e.roughnessMap&&(t.roughnessMap.value=e.roughnessMap,n(e.roughnessMap,t.roughnessMapTransform)),e.envMap&&(t.envMapIntensity.value=e.envMapIntensity)}(t,r),r.isMeshPhysicalMaterial&&function(t,e,i){t.ior.value=e.ior,e.sheen>0&&(t.sheenColor.value.copy(e.sheenColor).multiplyScalar(e.sheen),t.sheenRoughness.value=e.sheenRoughness,e.sheenColorMap&&(t.sheenColorMap.value=e.sheenColorMap,n(e.sheenColorMap,t.sheenColorMapTransform)),e.sheenRoughnessMap&&(t.sheenRoughnessMap.value=e.sheenRoughnessMap,n(e.sheenRoughnessMap,t.sheenRoughnessMapTransform))),e.clearcoat>0&&(t.clearcoat.value=e.clearcoat,t.clearcoatRoughness.value=e.clearcoatRoughness,e.clearcoatMap&&(t.clearcoatMap.value=e.clearcoatMap,n(e.clearcoatMap,t.clearcoatMapTransform)),e.clearcoatRoughnessMap&&(t.clearcoatRoughnessMap.value=e.clearcoatRoughnessMap,n(e.clearcoatRoughnessMap,t.clearcoatRoughnessMapTransform)),e.clearcoatNormalMap&&(t.clearcoatNormalMap.value=e.clearcoatNormalMap,n(e.clearcoatNormalMap,t.clearcoatNormalMapTransform),t.clearcoatNormalScale.value.copy(e.clearcoatNormalScale),e.side===M&&t.clearcoatNormalScale.value.negate())),e.dispersion>0&&(t.dispersion.value=e.dispersion),e.iridescence>0&&(t.iridescence.value=e.iridescence,t.iridescenceIOR.value=e.iridescenceIOR,t.iridescenceThicknessMinimum.value=e.iridescenceThicknessRange[0],t.iridescenceThicknessMaximum.value=e.iridescenceThicknessRange[1],e.iridescenceMap&&(t.iridescenceMap.value=e.iridescenceMap,n(e.iridescenceMap,t.iridescenceMapTransform)),e.iridescenceThicknessMap&&(t.iridescenceThicknessMap.value=e.iridescenceThicknessMap,n(e.iridescenceThicknessMap,t.iridescenceThicknessMapTransform))),e.transmission>0&&(t.transmission.value=e.transmission,t.transmissionSamplerMap.value=i.texture,t.transmissionSamplerSize.value.set(i.width,i.height),e.transmissionMap&&(t.transmissionMap.value=e.transmissionMap,n(e.transmissionMap,t.transmissionMapTransform)),t.thickness.value=e.thickness,e.thicknessMap&&(t.thicknessMap.value=e.thicknessMap,n(e.thicknessMap,t.thicknessMapTransform)),t.attenuationDistance.value=e.attenuationDistance,t.attenuationColor.value.copy(e.attenuationColor)),e.anisotropy>0&&(t.anisotropyVector.value.set(e.anisotropy*Math.cos(e.anisotropyRotation),e.anisotropy*Math.sin(e.anisotropyRotation)),e.anisotropyMap&&(t.anisotropyMap.value=e.anisotropyMap,n(e.anisotropyMap,t.anisotropyMapTransform))),t.specularIntensity.value=e.specularIntensity,t.specularColor.value.copy(e.specularColor),e.specularColorMap&&(t.specularColorMap.value=e.specularColorMap,n(e.specularColorMap,t.specularColorMapTransform)),e.specularIntensityMap&&(t.specularIntensityMap.value=e.specularIntensityMap,n(e.specularIntensityMap,t.specularIntensityMapTransform))}(t,r,o)):r.isMeshMatcapMaterial?(i(t,r),function(t,e){e.matcap&&(t.matcap.value=e.matcap)}(t,r)):r.isMeshDepthMaterial?i(t,r):r.isMeshDistanceMaterial?(i(t,r),function(t,n){const i=e.get(n).light;t.referencePosition.value.setFromMatrixPosition(i.matrixWorld),t.nearDistance.value=i.shadow.camera.near,t.farDistance.value=i.shadow.camera.far}(t,r)):r.isMeshNormalMaterial?i(t,r):r.isLineBasicMaterial?(function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,e.map&&(t.map.value=e.map,n(e.map,t.mapTransform))}(t,r),r.isLineDashedMaterial&&function(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}(t,r)):r.isPointsMaterial?function(t,e,i,r){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.size.value=e.size*i,t.scale.value=.5*r,e.map&&(t.map.value=e.map,n(e.map,t.uvTransform)),e.alphaMap&&(t.alphaMap.value=e.alphaMap,n(e.alphaMap,t.alphaMapTransform)),e.alphaTest>0&&(t.alphaTest.value=e.alphaTest)}(t,r,s,a):r.isSpriteMaterial?function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.rotation.value=e.rotation,e.map&&(t.map.value=e.map,n(e.map,t.mapTransform)),e.alphaMap&&(t.alphaMap.value=e.alphaMap,n(e.alphaMap,t.alphaMapTransform)),e.alphaTest>0&&(t.alphaTest.value=e.alphaTest)}(t,r):r.isShadowMaterial?(t.color.value.copy(r.color),t.opacity.value=r.opacity):r.isShaderMaterial&&(r.uniformsNeedUpdate=!1)}}}function hc(t,e,n,i){let r={},s={},a=[];const o=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS);function l(t,e,n,i){const r=t.value,s=e+"_"+n;if(void 0===i[s])return i[s]="number"==typeof r||"boolean"==typeof r?r:r.clone(),!0;{const t=i[s];if("number"==typeof r||"boolean"==typeof r){if(t!==r)return i[s]=r,!0}else if(!1===t.equals(r))return t.copy(r),!0}return!1}function c(t){const e={boundary:0,storage:0};return"number"==typeof t||"boolean"==typeof t?(e.boundary=4,e.storage=4):t.isVector2?(e.boundary=8,e.storage=8):t.isVector3||t.isColor?(e.boundary=16,e.storage=12):t.isVector4?(e.boundary=16,e.storage=16):t.isMatrix3?(e.boundary=48,e.storage=48):t.isMatrix4?(e.boundary=64,e.storage=64):t.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",t),e}function h(e){const n=e.target;n.removeEventListener("dispose",h);const i=a.indexOf(n.__bindingPointIndex);a.splice(i,1),t.deleteBuffer(r[n.id]),delete r[n.id],delete s[n.id]}return{bind:function(t,e){const n=e.program;i.uniformBlockBinding(t,n)},update:function(n,u){let d=r[n.id];void 0===d&&(function(t){const e=t.uniforms;let n=0;for(let t=0,i=e.length;t0&&(n+=16-i),t.__size=n,t.__cache={}}(n),d=function(e){const n=function(){for(let t=0;t0),u=!!n.morphAttributes.position,d=!!n.morphAttributes.normal,p=!!n.morphAttributes.color;let f=ht;i.toneMapped&&(null!==S&&!0!==S.isXRRenderTarget||(f=_.toneMapping));const m=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,g=void 0!==m?m.length:0,v=it.get(i),y=A.state.lights;if(!0===V&&(!0===W||t!==T)){const e=t===T&&i.id===I;mt.setState(i,t,e)}let x=!1;i.version===v.__version?v.needsLights&&v.lightsStateVersion!==y.state.version||v.outputColorSpace!==o||r.isBatchedMesh&&!1===v.batching?x=!0:r.isBatchedMesh||!0!==v.batching?r.isBatchedMesh&&!0===v.batchingColor&&null===r.colorTexture||r.isBatchedMesh&&!1===v.batchingColor&&null!==r.colorTexture||r.isInstancedMesh&&!1===v.instancing?x=!0:r.isInstancedMesh||!0!==v.instancing?r.isSkinnedMesh&&!1===v.skinning?x=!0:r.isSkinnedMesh||!0!==v.skinning?r.isInstancedMesh&&!0===v.instancingColor&&null===r.instanceColor||r.isInstancedMesh&&!1===v.instancingColor&&null!==r.instanceColor||r.isInstancedMesh&&!0===v.instancingMorph&&null===r.morphTexture||r.isInstancedMesh&&!1===v.instancingMorph&&null!==r.morphTexture||v.envMap!==l||!0===i.fog&&v.fog!==s?x=!0:void 0===v.numClippingPlanes||v.numClippingPlanes===mt.numPlanes&&v.numIntersection===mt.numIntersection?(v.vertexAlphas!==c||v.vertexTangents!==h||v.morphTargets!==u||v.morphNormals!==d||v.morphColors!==p||v.toneMapping!==f||v.morphTargetsCount!==g)&&(x=!0):x=!0:x=!0:x=!0:x=!0:(x=!0,v.__version=i.version);let w=v.currentProgram;!0===x&&(w=Jt(i,e,r));let C=!1,E=!1,M=!1;const b=w.getUniforms(),B=v.uniforms;if(et.useProgram(w.program)&&(C=!0,E=!0,M=!0),i.id!==I&&(I=i.id,E=!0),C||T!==t){et.buffers.depth.getReversed()?(j.copy(t.projectionMatrix),function(t){const e=t.elements;e[2]=.5*e[2]+.5*e[3],e[6]=.5*e[6]+.5*e[7],e[10]=.5*e[10]+.5*e[11],e[14]=.5*e[14]+.5*e[15]}(j),function(t){const e=t.elements;-1===e[11]?(e[10]=-e[10]-1,e[14]=-e[14]):(e[10]=-e[10],e[14]=1-e[14])}(j),b.setValue(Et,"projectionMatrix",j)):b.setValue(Et,"projectionMatrix",t.projectionMatrix),b.setValue(Et,"viewMatrix",t.matrixWorldInverse);const e=b.map.cameraPosition;void 0!==e&&e.setValue(Et,X.setFromMatrixPosition(t.matrixWorld)),tt.logarithmicDepthBuffer&&b.setValue(Et,"logDepthBufFC",2/(Math.log(t.far+1)/Math.LN2)),(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial)&&b.setValue(Et,"isOrthographic",!0===t.isOrthographicCamera),T!==t&&(T=t,E=!0,M=!0)}if(r.isSkinnedMesh){b.setOptional(Et,r,"bindMatrix"),b.setOptional(Et,r,"bindMatrixInverse");const t=r.skeleton;t&&(null===t.boneTexture&&t.computeBoneTexture(),b.setValue(Et,"boneTexture",t.boneTexture,rt))}r.isBatchedMesh&&(b.setOptional(Et,r,"batchingTexture"),b.setValue(Et,"batchingTexture",r._matricesTexture,rt),b.setOptional(Et,r,"batchingIdTexture"),b.setValue(Et,"batchingIdTexture",r._indirectTexture,rt),b.setOptional(Et,r,"batchingColorTexture"),null!==r._colorsTexture&&b.setValue(Et,"batchingColorTexture",r._colorsTexture,rt));const R=n.morphAttributes;var D,P;if(void 0===R.position&&void 0===R.normal&&void 0===R.color||vt.update(r,n,w),(E||v.receiveShadow!==r.receiveShadow)&&(v.receiveShadow=r.receiveShadow,b.setValue(Et,"receiveShadow",r.receiveShadow)),i.isMeshGouraudMaterial&&null!==i.envMap&&(B.envMap.value=l,B.flipEnvMap.value=l.isCubeTexture&&!1===l.isRenderTargetTexture?-1:1),i.isMeshStandardMaterial&&null===i.envMap&&null!==e.environment&&(B.envMapIntensity.value=e.environmentIntensity),E&&(b.setValue(Et,"toneMappingExposure",_.toneMappingExposure),v.needsLights&&(P=M,(D=B).ambientLightColor.needsUpdate=P,D.lightProbe.needsUpdate=P,D.directionalLights.needsUpdate=P,D.directionalLightShadows.needsUpdate=P,D.pointLights.needsUpdate=P,D.pointLightShadows.needsUpdate=P,D.spotLights.needsUpdate=P,D.spotLightShadows.needsUpdate=P,D.rectAreaLights.needsUpdate=P,D.hemisphereLights.needsUpdate=P),s&&!0===i.fog&&dt.refreshFogUniforms(B,s),dt.refreshMaterialUniforms(B,i,F,N,A.state.transmissionRenderTarget[t.id]),ul.upload(Et,Kt(v),B,rt)),i.isShaderMaterial&&!0===i.uniformsNeedUpdate&&(ul.upload(Et,Kt(v),B,rt),i.uniformsNeedUpdate=!1),i.isSpriteMaterial&&b.setValue(Et,"center",r.center),b.setValue(Et,"modelViewMatrix",r.modelViewMatrix),b.setValue(Et,"normalMatrix",r.normalMatrix),b.setValue(Et,"modelMatrix",r.matrixWorld),i.isShaderMaterial||i.isRawShaderMaterial){const t=i.uniformsGroups;for(let e=0,n=t.length;e{function n(){i.forEach((function(t){it.get(t).currentProgram.isReady()&&i.delete(t)})),0!==i.size?setTimeout(n,10):e(t)}null!==$.get("KHR_parallel_shader_compile")?n():setTimeout(n,10)}))};let Pt=null;function Lt(){Nt.stop()}function Ut(){Nt.start()}const Nt=new xa;function Ot(t,e,n,i){if(!1===t.visible)return;if(t.layers.test(e.layers))if(t.isGroup)n=t.renderOrder;else if(t.isLOD)!0===t.autoUpdate&&t.update(e);else if(t.isLight)A.pushLight(t),t.castShadow&&A.pushShadow(t);else if(t.isSprite){if(!t.frustumCulled||H.intersectsSprite(t)){i&&Y.setFromMatrixPosition(t.matrixWorld).applyMatrix4(q);const e=ct.update(t),r=t.material;r.visible&&g.push(t,e,r,n,Y.z,null)}}else if((t.isMesh||t.isLine||t.isPoints)&&(!t.frustumCulled||H.intersectsObject(t))){const e=ct.update(t),r=t.material;if(i&&(void 0!==t.boundingSphere?(null===t.boundingSphere&&t.computeBoundingSphere(),Y.copy(t.boundingSphere.center)):(null===e.boundingSphere&&e.computeBoundingSphere(),Y.copy(e.boundingSphere.center)),Y.applyMatrix4(t.matrixWorld).applyMatrix4(q)),Array.isArray(r)){const i=e.groups;for(let s=0,a=i.length;s0&&Ht(r,e,n),s.length>0&&Ht(s,e,n),a.length>0&&Ht(a,e,n),et.buffers.depth.setTest(!0),et.buffers.depth.setMask(!0),et.buffers.color.setMask(!0),et.setPolygonOffset(!1)}function zt(t,e,n,i){if(null!==(!0===n.isScene?n.overrideMaterial:null))return;void 0===A.state.transmissionRenderTarget[i.id]&&(A.state.transmissionRenderTarget[i.id]=new Ni(1,1,{generateMipmaps:!0,type:$.has("EXT_color_buffer_half_float")||$.has("EXT_color_buffer_float")?jt:kt,minFilter:Ft,samples:4,stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:yi.workingColorSpace}));const s=A.state.transmissionRenderTarget[i.id],a=i.viewport||B;s.setSize(a.z,a.w);const o=_.getRenderTarget();_.setRenderTarget(s),_.getClearColor(P),L=_.getClearAlpha(),L<1&&_.setClearColor(16777215,.5),_.clear(),K&&At.render(n);const l=_.toneMapping;_.toneMapping=ht;const c=i.viewport;if(void 0!==i.viewport&&(i.viewport=void 0),A.setupLightsView(i),!0===V&&mt.setGlobalState(_.clippingPlanes,i),Ht(t,n,i),rt.updateMultisampleRenderTarget(s),rt.updateRenderTargetMipmap(s),!1===$.has("WEBGL_multisampled_render_to_texture")){let t=!1;for(let r=0,s=e.length;r0)for(let e=0,s=n.length;e0&&zt(i,r,t,e),K&&At.render(t),Qt(g,t,e);null!==S&&(rt.updateMultisampleRenderTarget(S),rt.updateRenderTargetMipmap(S)),!0===t.isScene&&t.onAfterRender(_,t,e),wt.resetDefaultState(),I=-1,T=null,y.pop(),y.length>0?(A=y[y.length-1],!0===V&&mt.setGlobalState(_.clippingPlanes,A.state.camera)):A=null,v.pop(),g=v.length>0?v[v.length-1]:null},this.getActiveCubeFace=function(){return w},this.getActiveMipmapLevel=function(){return C},this.getRenderTarget=function(){return S},this.setRenderTargetTextures=function(t,e,n){it.get(t.texture).__webglTexture=e,it.get(t.depthTexture).__webglTexture=n;const i=it.get(t);i.__hasExternalTextures=!0,i.__autoAllocateDepthBuffer=void 0===n,i.__autoAllocateDepthBuffer||!0===$.has("WEBGL_multisampled_render_to_texture")&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),i.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(t,e){const n=it.get(t);n.__webglFramebuffer=e,n.__useDefaultFramebuffer=void 0===e},this.setRenderTarget=function(t,e=0,n=0){S=t,w=e,C=n;let i=!0,r=null,s=!1,a=!1;if(t){const o=it.get(t);if(void 0!==o.__useDefaultFramebuffer)et.bindFramebuffer(Et.FRAMEBUFFER,null),i=!1;else if(void 0===o.__webglFramebuffer)rt.setupRenderTarget(t);else if(o.__hasExternalTextures)rt.rebindTextures(t,it.get(t.texture).__webglTexture,it.get(t.depthTexture).__webglTexture);else if(t.depthBuffer){const e=t.depthTexture;if(o.__boundDepthTexture!==e){if(null!==e&&it.has(e)&&(t.width!==e.image.width||t.height!==e.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");rt.setupDepthRenderbuffer(t)}}const l=t.texture;(l.isData3DTexture||l.isDataArrayTexture||l.isCompressedArrayTexture)&&(a=!0);const c=it.get(t).__webglFramebuffer;t.isWebGLCubeRenderTarget?(r=Array.isArray(c[e])?c[e][n]:c[e],s=!0):r=t.samples>0&&!1===rt.useMultisampledRTT(t)?it.get(t).__webglMultisampledFramebuffer:Array.isArray(c)?c[n]:c,B.copy(t.viewport),R.copy(t.scissor),D=t.scissorTest}else B.copy(Q).multiplyScalar(F).floor(),R.copy(z).multiplyScalar(F).floor(),D=G;if(et.bindFramebuffer(Et.FRAMEBUFFER,r)&&i&&et.drawBuffers(t,r),et.viewport(B),et.scissor(R),et.setScissorTest(D),s){const i=it.get(t.texture);Et.framebufferTexture2D(Et.FRAMEBUFFER,Et.COLOR_ATTACHMENT0,Et.TEXTURE_CUBE_MAP_POSITIVE_X+e,i.__webglTexture,n)}else if(a){const i=it.get(t.texture),r=e||0;Et.framebufferTextureLayer(Et.FRAMEBUFFER,Et.COLOR_ATTACHMENT0,i.__webglTexture,n||0,r)}I=-1},this.readRenderTargetPixels=function(t,e,n,i,r,s,a){if(!t||!t.isWebGLRenderTarget)return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let o=it.get(t).__webglFramebuffer;if(t.isWebGLCubeRenderTarget&&void 0!==a&&(o=o[a]),o){et.bindFramebuffer(Et.FRAMEBUFFER,o);try{const a=t.texture,o=a.format,l=a.type;if(!tt.textureFormatReadable(o))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!tt.textureTypeReadable(l))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");e>=0&&e<=t.width-i&&n>=0&&n<=t.height-r&&Et.readPixels(e,n,i,r,xt.convert(o),xt.convert(l),s)}finally{const t=null!==S?it.get(S).__webglFramebuffer:null;et.bindFramebuffer(Et.FRAMEBUFFER,t)}}},this.readRenderTargetPixelsAsync=async function(t,e,n,i,r,s,a){if(!t||!t.isWebGLRenderTarget)throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let o=it.get(t).__webglFramebuffer;if(t.isWebGLCubeRenderTarget&&void 0!==a&&(o=o[a]),o){const a=t.texture,l=a.format,c=a.type;if(!tt.textureFormatReadable(l))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!tt.textureTypeReadable(c))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(e>=0&&e<=t.width-i&&n>=0&&n<=t.height-r){et.bindFramebuffer(Et.FRAMEBUFFER,o);const t=Et.createBuffer();Et.bindBuffer(Et.PIXEL_PACK_BUFFER,t),Et.bufferData(Et.PIXEL_PACK_BUFFER,s.byteLength,Et.STREAM_READ),Et.readPixels(e,n,i,r,xt.convert(l),xt.convert(c),0);const a=null!==S?it.get(S).__webglFramebuffer:null;et.bindFramebuffer(Et.FRAMEBUFFER,a);const h=Et.fenceSync(Et.SYNC_GPU_COMMANDS_COMPLETE,0);return Et.flush(),await function(t,e){return new Promise((function(n,i){setTimeout((function r(){switch(t.clientWaitSync(e,t.SYNC_FLUSH_COMMANDS_BIT,0)){case t.WAIT_FAILED:i();break;case t.TIMEOUT_EXPIRED:setTimeout(r,4);break;default:n()}}),4)}))}(Et,h),Et.bindBuffer(Et.PIXEL_PACK_BUFFER,t),Et.getBufferSubData(Et.PIXEL_PACK_BUFFER,0,s),Et.deleteBuffer(t),Et.deleteSync(h),s}throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(t,e=null,n=0){!0!==t.isTexture&&(vi("WebGLRenderer: copyFramebufferToTexture function signature has changed."),e=arguments[0]||null,t=arguments[1]);const i=Math.pow(2,-n),r=Math.floor(t.image.width*i),s=Math.floor(t.image.height*i),a=null!==e?e.x:0,o=null!==e?e.y:0;rt.setTexture2D(t,0),Et.copyTexSubImage2D(Et.TEXTURE_2D,n,0,0,a,o,r,s),et.unbindTexture()},this.copyTextureToTexture=function(t,e,n=null,i=null,r=0){let s,a,o,l,c,h,u,d,p;!0!==t.isTexture&&(vi("WebGLRenderer: copyTextureToTexture function signature has changed."),i=arguments[0]||null,t=arguments[1],e=arguments[2],r=arguments[3]||0,n=null);const f=t.isCompressedTexture?t.mipmaps[r]:t.image;null!==n?(s=n.max.x-n.min.x,a=n.max.y-n.min.y,o=n.isBox3?n.max.z-n.min.z:1,l=n.min.x,c=n.min.y,h=n.isBox3?n.min.z:0):(s=f.width,a=f.height,o=f.depth||1,l=0,c=0,h=0),null!==i?(u=i.x,d=i.y,p=i.z):(u=0,d=0,p=0);const m=xt.convert(e.format),g=xt.convert(e.type);let A;e.isData3DTexture?(rt.setTexture3D(e,0),A=Et.TEXTURE_3D):e.isDataArrayTexture||e.isCompressedArrayTexture?(rt.setTexture2DArray(e,0),A=Et.TEXTURE_2D_ARRAY):(rt.setTexture2D(e,0),A=Et.TEXTURE_2D),Et.pixelStorei(Et.UNPACK_FLIP_Y_WEBGL,e.flipY),Et.pixelStorei(Et.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.premultiplyAlpha),Et.pixelStorei(Et.UNPACK_ALIGNMENT,e.unpackAlignment);const v=Et.getParameter(Et.UNPACK_ROW_LENGTH),y=Et.getParameter(Et.UNPACK_IMAGE_HEIGHT),_=Et.getParameter(Et.UNPACK_SKIP_PIXELS),x=Et.getParameter(Et.UNPACK_SKIP_ROWS),w=Et.getParameter(Et.UNPACK_SKIP_IMAGES);Et.pixelStorei(Et.UNPACK_ROW_LENGTH,f.width),Et.pixelStorei(Et.UNPACK_IMAGE_HEIGHT,f.height),Et.pixelStorei(Et.UNPACK_SKIP_PIXELS,l),Et.pixelStorei(Et.UNPACK_SKIP_ROWS,c),Et.pixelStorei(Et.UNPACK_SKIP_IMAGES,h);const C=t.isDataArrayTexture||t.isData3DTexture,E=e.isDataArrayTexture||e.isData3DTexture;if(t.isRenderTargetTexture||t.isDepthTexture){const n=it.get(t),i=it.get(e),f=it.get(n.__renderTarget),m=it.get(i.__renderTarget);et.bindFramebuffer(Et.READ_FRAMEBUFFER,f.__webglFramebuffer),et.bindFramebuffer(Et.DRAW_FRAMEBUFFER,m.__webglFramebuffer);for(let n=0;n0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),1!==this.backgroundIntensity&&(e.object.backgroundIntensity=this.backgroundIntensity),e.object.backgroundRotation=this.backgroundRotation.toArray(),1!==this.environmentIntensity&&(e.object.environmentIntensity=this.environmentIntensity),e.object.environmentRotation=this.environmentRotation.toArray(),e}}class mc{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=void 0!==t?t.length/e:0,this.usage=On,this.updateRanges=[],this.version=0,this.uuid=ni()}onUploadCallback(){}set needsUpdate(t){!0===t&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,n){t*=this.stride,n*=e.stride;for(let i=0,r=this.stride;it.far||e.push({distance:o,point:_c.clone(),uv:ss.getInterpolation(_c,bc,Sc,Ic,Tc,Bc,Rc,new ci),face:null,object:this})}copy(t,e){return super.copy(t,e),void 0!==t.center&&this.center.copy(t.center),this.material=t.material,this}}function Pc(t,e,n,i,r,s){Cc.subVectors(t,n).addScalar(.5).multiply(i),void 0!==r?(Ec.x=s*Cc.x-r*Cc.y,Ec.y=r*Cc.x+s*Cc.y):Ec.copy(Cc),t.copy(e),t.x+=Ec.x,t.y+=Ec.y,t.applyMatrix4(Mc)}const Lc=new Gi,Uc=new Gi;class Nc extends Wr{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(t){super.copy(t,!1);const e=t.levels;for(let t=0,n=e.length;t0){let n,i;for(n=1,i=e.length;n0){Lc.setFromMatrixPosition(this.matrixWorld);const n=t.ray.origin.distanceTo(Lc);this.getObjectForDistance(n).raycast(t,e)}}update(t){const e=this.levels;if(e.length>1){Lc.setFromMatrixPosition(t.matrixWorld),Uc.setFromMatrixPosition(this.matrixWorld);const n=Lc.distanceTo(Uc)/t.zoom;let i,r;for(e[0].object.visible=!0,i=1,r=e.length;i=t))break;e[i-1].object.visible=!1,e[i].object.visible=!0}for(this._currentLevel=i-1;i=r.length&&r.push({start:-1,count:-1,z:-1,index:-1});const a=r[this.index];s.push(a),this.index++,a.start=t,a.count=e,a.z=n,a.index=i}reset(){this.list.length=0,this.index=0}}const uh=new vr,dh=new hs(1,1,1),ph=new _a,fh=new Wi,mh=new cr,gh=new Gi,Ah=new Gi,vh=new Gi,yh=new hh,_h=new Ks,xh=[];function wh(t,e,n=0){const i=e.itemSize;if(t.isInterleavedBufferAttribute||t.array.constructor!==e.array.constructor){const r=t.count;for(let s=0;s65535?new Uint32Array(i):new Uint16Array(i);e.setIndex(new ws(t,1))}this._geometryInitialized=!0}}_validateGeometry(t){const e=this.geometry;if(Boolean(t.getIndex())!==Boolean(e.getIndex()))throw new Error('BatchedMesh: All geometries must consistently have "index".');for(const n in e.attributes){if(!t.hasAttribute(n))throw new Error(`BatchedMesh: Added geometry missing "${n}". All geometries must have consistent attributes.`);const i=t.getAttribute(n),r=e.getAttribute(n);if(i.itemSize!==r.itemSize||i.normalized!==r.normalized)throw new Error("BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}setCustomSort(t){return this.customSort=t,this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new Wi);const t=this.boundingBox,e=this._instanceInfo;t.makeEmpty();for(let n=0,i=e.length;n=this.maxInstanceCount&&0===this._availableInstanceIds.length)throw new Error("BatchedMesh: Maximum item count reached.");const e={visible:!0,active:!0,geometryIndex:t};let n=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(oh),n=this._availableInstanceIds.shift(),this._instanceInfo[n]=e):(n=this._instanceInfo.length,this._instanceInfo.push(e));const i=this._matricesTexture;uh.identity().toArray(i.image.data,16*n),i.needsUpdate=!0;const r=this._colorsTexture;return r&&(dh.toArray(r.image.data,4*n),r.needsUpdate=!0),this._visibilityChanged=!0,n}addGeometry(t,e=-1,n=-1){this._initializeGeometry(t),this._validateGeometry(t);const i={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},r=this._geometryInfo;i.vertexStart=this._nextVertexStart,i.reservedVertexCount=-1===e?t.getAttribute("position").count:e;const s=t.getIndex();if(null!==s&&(i.indexStart=this._nextIndexStart,i.reservedIndexCount=-1===n?s.count:n),-1!==i.indexStart&&i.indexStart+i.reservedIndexCount>this._maxIndexCount||i.vertexStart+i.reservedVertexCount>this._maxVertexCount)throw new Error("BatchedMesh: Reserved space request exceeds the maximum buffer size.");let a;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(oh),a=this._availableGeometryIds.shift(),r[a]=i):(a=this._geometryCount,this._geometryCount++,r.push(i)),this.setGeometryAt(a,t),this._nextIndexStart=i.indexStart+i.reservedIndexCount,this._nextVertexStart=i.vertexStart+i.reservedVertexCount,a}setGeometryAt(t,e){if(t>=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(e);const n=this.geometry,i=null!==n.getIndex(),r=n.getIndex(),s=e.getIndex(),a=this._geometryInfo[t];if(i&&s.count>a.reservedIndexCount||e.attributes.position.count>a.reservedVertexCount)throw new Error("BatchedMesh: Reserved space not large enough for provided geometry.");const o=a.vertexStart,l=a.reservedVertexCount;a.vertexCount=e.getAttribute("position").count;for(const t in n.attributes){const i=e.getAttribute(t),r=n.getAttribute(t);wh(i,r,o);const s=i.itemSize;for(let t=i.count,e=l;t=e.length||!1===e[t].active)return this;const n=this._instanceInfo;for(let e=0,i=n.length;e=e.length||!1===e[t].active||(e[t].active=!1,this._availableInstanceIds.push(t),this._visibilityChanged=!0),this}optimize(){let t=0,e=0;const n=this._geometryInfo,i=n.map(((t,e)=>e)).sort(((t,e)=>n[t].vertexStart-n[e].vertexStart)),r=this.geometry;for(let s=0,a=n.length;s=this._geometryCount)return null;const n=this.geometry,i=this._geometryInfo[t];if(null===i.boundingBox){const t=new Wi,e=n.index,r=n.attributes.position;for(let n=i.start,s=i.start+i.count;n=this._geometryCount)return null;const n=this.geometry,i=this._geometryInfo[t];if(null===i.boundingSphere){const e=new cr;this.getBoundingBoxAt(t,fh),fh.getCenter(e.center);const r=n.index,s=n.attributes.position;let a=0;for(let t=i.start,n=i.start+i.count;t=n.length||!1===n[t].active||(e.toArray(r,16*t),i.needsUpdate=!0),this}getMatrixAt(t,e){const n=this._instanceInfo,i=this._matricesTexture.image.data;return t>=n.length||!1===n[t].active?null:e.fromArray(i,16*t)}setColorAt(t,e){null===this._colorsTexture&&this._initColorsTexture();const n=this._colorsTexture,i=this._colorsTexture.image.data,r=this._instanceInfo;return t>=r.length||!1===r[t].active||(e.toArray(i,4*t),n.needsUpdate=!0),this}getColorAt(t,e){const n=this._colorsTexture.image.data,i=this._instanceInfo;return t>=i.length||!1===i[t].active?null:e.fromArray(n,4*t)}setVisibleAt(t,e){const n=this._instanceInfo;return t>=n.length||!1===n[t].active||n[t].visible===e||(n[t].visible=e,this._visibilityChanged=!0),this}getVisibleAt(t){const e=this._instanceInfo;return!(t>=e.length||!1===e[t].active)&&e[t].visible}setGeometryIdAt(t,e){const n=this._instanceInfo,i=this._geometryInfo;return t>=n.length||!1===n[t].active||e>=i.length||!1===i[e].active?null:(n[t].geometryIndex=e,this)}getGeometryIdAt(t){const e=this._instanceInfo;return t>=e.length||!1===e[t].active?-1:e[t].geometryIndex}getGeometryRangeAt(t,e={}){if(t<0||t>=this._geometryCount)return null;const n=this._geometryInfo[t];return e.vertexStart=n.vertexStart,e.vertexCount=n.vertexCount,e.reservedVertexCount=n.reservedVertexCount,e.indexStart=n.indexStart,e.indexCount=n.indexCount,e.reservedIndexCount=n.reservedIndexCount,e.start=n.start,e.count=n.count,e}setInstanceCount(t){const e=this._availableInstanceIds,n=this._instanceInfo;for(e.sort(oh);e[e.length-1]===n.length;)n.pop(),e.pop();if(tt.active));if(Math.max(...n.map((t=>t.vertexStart+t.reservedVertexCount)))>t)throw new Error(`BatchedMesh: Geometry vertex values are being used outside the range ${e}. Cannot shrink further.`);if(this.geometry.index&&Math.max(...n.map((t=>t.indexStart+t.reservedIndexCount)))>e)throw new Error(`BatchedMesh: Geometry index values are being used outside the range ${e}. Cannot shrink further.`);const i=this.geometry;i.dispose(),this._maxVertexCount=t,this._maxIndexCount=e,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new ks,this._initializeGeometry(i));const r=this.geometry;i.index&&Ch(i.index.array,r.index.array);for(const t in i.attributes)Ch(i.attributes[t].array,r.attributes[t].array)}raycast(t,e){const n=this._instanceInfo,i=this._geometryInfo,r=this.matrixWorld,s=this.geometry;_h.material=this.material,_h.geometry.index=s.index,_h.geometry.attributes=s.attributes,null===_h.geometry.boundingBox&&(_h.geometry.boundingBox=new Wi),null===_h.geometry.boundingSphere&&(_h.geometry.boundingSphere=new cr);for(let s=0,a=n.length;s({...t,boundingBox:null!==t.boundingBox?t.boundingBox.clone():null,boundingSphere:null!==t.boundingSphere?t.boundingSphere.clone():null}))),this._instanceInfo=t._instanceInfo.map((t=>({...t}))),this._maxInstanceCount=t._maxInstanceCount,this._maxVertexCount=t._maxVertexCount,this._maxIndexCount=t._maxIndexCount,this._geometryInitialized=t._geometryInitialized,this._geometryCount=t._geometryCount,this._multiDrawCounts=t._multiDrawCounts.slice(),this._multiDrawStarts=t._multiDrawStarts.slice(),this._matricesTexture=t._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),null!==this._colorsTexture&&(this._colorsTexture=t._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,null!==this._colorsTexture&&(this._colorsTexture.dispose(),this._colorsTexture=null),this}onBeforeRender(t,e,n,i,r){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const s=i.getIndex(),a=null===s?1:s.array.BYTES_PER_ELEMENT,o=this._instanceInfo,l=this._multiDrawStarts,c=this._multiDrawCounts,h=this._geometryInfo,u=this.perObjectFrustumCulled,d=this._indirectTexture,p=d.image.data;u&&(uh.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse).multiply(this.matrixWorld),ph.setFromProjectionMatrix(uh,t.coordinateSystem));let f=0;if(this.sortObjects){uh.copy(this.matrixWorld).invert(),gh.setFromMatrixPosition(n.matrixWorld).applyMatrix4(uh),Ah.set(0,0,-1).transformDirection(n.matrixWorld).transformDirection(uh);for(let t=0,e=o.length;t0){const n=t[e[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=n.length;ti)return;Rh.applyMatrix4(t.matrixWorld);const o=e.ray.origin.distanceTo(Rh);return oe.far?void 0:{distance:o,point:Dh.clone().applyMatrix4(t.matrixWorld),index:r,face:null,faceIndex:null,barycoord:null,object:t}}const Uh=new Gi,Nh=new Gi;class Fh extends Ph{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const t=this.geometry;if(null===t.index){const e=t.attributes.position,n=[];for(let t=0,i=e.count;t0){const n=t[e[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=n.length;tr.far)return;s.push({distance:l,distanceToRay:Math.sqrt(o),point:n,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class jh extends Pi{constructor(t,e,n,i,r,s,a,o,l){super(t,e,n,i,r,s,a,o,l),this.isVideoTexture=!0,this.minFilter=void 0!==s?s:Lt,this.magFilter=void 0!==r?r:Lt,this.generateMipmaps=!1;const c=this;"requestVideoFrameCallback"in t&&t.requestVideoFrameCallback((function e(){c.needsUpdate=!0,t.requestVideoFrameCallback(e)}))}clone(){return new this.constructor(this.image).copy(this)}update(){const t=this.image;!1=="requestVideoFrameCallback"in t&&t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class qh extends Pi{constructor(t,e){super({width:t,height:e}),this.isFramebufferTexture=!0,this.magFilter=Tt,this.minFilter=Tt,this.generateMipmaps=!1,this.needsUpdate=!0}}class Xh extends Pi{constructor(t,e,n,i,r,s,a,o,l,c,h,u){super(null,s,a,o,l,c,i,r,h,u),this.isCompressedTexture=!0,this.image={width:e,height:n},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}}class Yh extends Xh{constructor(t,e,n,i,r,s){super(t,e,n,r,s),this.isCompressedArrayTexture=!0,this.image.depth=i,this.wrapR=St,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}}class Jh extends Xh{constructor(t,e,n){super(void 0,t[0].width,t[0].height,e,n,xt),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=t}}class Kh extends Pi{constructor(t,e,n,i,r,s,a,o,l){super(t,e,n,i,r,s,a,o,l),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Zh{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(t,e){const n=this.getUtoTmapping(t);return this.getPoint(n,e)}getPoints(t=5){const e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return e}getSpacedPoints(t=5){const e=[];for(let n=0;n<=t;n++)e.push(this.getPointAt(n/t));return e}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const e=[];let n,i=this.getPoint(0),r=0;e.push(0);for(let s=1;s<=t;s++)n=this.getPoint(s/t),r+=n.distanceTo(i),e.push(r),i=n;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e){const n=this.getLengths();let i=0;const r=n.length;let s;s=e||t*n[r-1];let a,o=0,l=r-1;for(;o<=l;)if(i=Math.floor(o+(l-o)/2),a=n[i]-s,a<0)o=i+1;else{if(!(a>0)){l=i;break}l=i-1}if(i=l,n[i]===s)return i/(r-1);const c=n[i];return(i+(s-c)/(n[i+1]-c))/(r-1)}getTangent(t,e){const n=1e-4;let i=t-n,r=t+n;i<0&&(i=0),r>1&&(r=1);const s=this.getPoint(i),a=this.getPoint(r),o=e||(s.isVector2?new ci:new Gi);return o.copy(a).sub(s).normalize(),o}getTangentAt(t,e){const n=this.getUtoTmapping(t);return this.getTangent(n,e)}computeFrenetFrames(t,e){const n=new Gi,i=[],r=[],s=[],a=new Gi,o=new vr;for(let e=0;e<=t;e++){const n=e/t;i[e]=this.getTangentAt(n,new Gi)}r[0]=new Gi,s[0]=new Gi;let l=Number.MAX_VALUE;const c=Math.abs(i[0].x),h=Math.abs(i[0].y),u=Math.abs(i[0].z);c<=l&&(l=c,n.set(1,0,0)),h<=l&&(l=h,n.set(0,1,0)),u<=l&&n.set(0,0,1),a.crossVectors(i[0],n).normalize(),r[0].crossVectors(i[0],a),s[0].crossVectors(i[0],r[0]);for(let e=1;e<=t;e++){if(r[e]=r[e-1].clone(),s[e]=s[e-1].clone(),a.crossVectors(i[e-1],i[e]),a.length()>Number.EPSILON){a.normalize();const t=Math.acos(ii(i[e-1].dot(i[e]),-1,1));r[e].applyMatrix4(o.makeRotationAxis(a,t))}s[e].crossVectors(i[e],r[e])}if(!0===e){let e=Math.acos(ii(r[0].dot(r[t]),-1,1));e/=t,i[0].dot(a.crossVectors(r[0],r[t]))>0&&(e=-e);for(let n=1;n<=t;n++)r[n].applyMatrix4(o.makeRotationAxis(i[n],e*n)),s[n].crossVectors(i[n],r[n])}return{tangents:i,normals:r,binormals:s}}clone(){return(new this.constructor).copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){const t={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}}class $h extends Zh{constructor(t=0,e=0,n=1,i=1,r=0,s=2*Math.PI,a=!1,o=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=n,this.yRadius=i,this.aStartAngle=r,this.aEndAngle=s,this.aClockwise=a,this.aRotation=o}getPoint(t,e=new ci){const n=e,i=2*Math.PI;let r=this.aEndAngle-this.aStartAngle;const s=Math.abs(r)i;)r-=i;r0?0:(Math.floor(Math.abs(l)/r)+1)*r:0===c&&l===r-1&&(l=r-2,c=1),this.closed||l>0?a=i[(l-1)%r]:(nu.subVectors(i[0],i[1]).add(i[0]),a=nu);const h=i[l%r],u=i[(l+1)%r];if(this.closed||l+2i.length-2?i.length-1:s+1],h=i[s>i.length-3?i.length-1:s+2];return n.set(ou(a,o.x,l.x,c.x,h.x),ou(a,o.y,l.y,c.y,h.y)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e=n){const t=i[r]-n,s=this.curves[r],a=s.getLength(),o=0===a?0:1-t/a;return s.getPointAt(o,e)}r++}return null}getLength(){const t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const t=[];let e=0;for(let n=0,i=this.curves.length;n1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,n=t.curves.length;e0){const t=l.getPoint(0);t.equals(this.currentPoint)||this.lineTo(t.x,t.y)}this.curves.push(l);const c=l.getPoint(1);return this.currentPoint.copy(c),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){const t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}}class _u extends ks{constructor(t=[new ci(0,-.5),new ci(.5,0),new ci(0,.5)],e=12,n=0,i=2*Math.PI){super(),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:n,phiLength:i},e=Math.floor(e),i=ii(i,0,2*Math.PI);const r=[],s=[],a=[],o=[],l=[],c=1/e,h=new Gi,u=new ci,d=new Gi,p=new Gi,f=new Gi;let m=0,g=0;for(let e=0;e<=t.length-1;e++)switch(e){case 0:m=t[e+1].x-t[e].x,g=t[e+1].y-t[e].y,d.x=1*g,d.y=-m,d.z=0*g,f.copy(d),d.normalize(),o.push(d.x,d.y,d.z);break;case t.length-1:o.push(f.x,f.y,f.z);break;default:m=t[e+1].x-t[e].x,g=t[e+1].y-t[e].y,d.x=1*g,d.y=-m,d.z=0*g,p.copy(d),d.x+=f.x,d.y+=f.y,d.z+=f.z,d.normalize(),o.push(d.x,d.y,d.z),f.copy(p)}for(let r=0;r<=e;r++){const d=n+r*c*i,p=Math.sin(d),f=Math.cos(d);for(let n=0;n<=t.length-1;n++){h.x=t[n].x*p,h.y=t[n].y,h.z=t[n].x*f,s.push(h.x,h.y,h.z),u.x=r/e,u.y=n/(t.length-1),a.push(u.x,u.y);const i=o[3*n+0]*p,c=o[3*n+1],d=o[3*n+0]*f;l.push(i,c,d)}}for(let n=0;n0||0!==i)&&(c.push(s,a,l),v+=3),(e>0||i!==r-1)&&(c.push(a,o,l),v+=3)}l.addGroup(g,v,0),g+=v}(),!1===s&&(t>0&&A(!0),e>0&&A(!1)),this.setIndex(c),this.setAttribute("position",new Rs(h,3)),this.setAttribute("normal",new Rs(u,3)),this.setAttribute("uv",new Rs(d,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Cu(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class Eu extends Cu{constructor(t=1,e=1,n=32,i=1,r=!1,s=0,a=2*Math.PI){super(0,t,e,n,i,r,s,a),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:n,heightSegments:i,openEnded:r,thetaStart:s,thetaLength:a}}static fromJSON(t){return new Eu(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class Mu extends ks{constructor(t=[],e=[],n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:n,detail:i};const r=[],s=[];function a(t,e,n,i){const r=i+1,s=[];for(let i=0;i<=r;i++){s[i]=[];const a=t.clone().lerp(n,i/r),o=e.clone().lerp(n,i/r),l=r-i;for(let t=0;t<=l;t++)s[i][t]=0===t&&i===r?a:a.clone().lerp(o,t/l)}for(let t=0;t.9&&a<.1&&(e<.2&&(s[t+0]+=1),n<.2&&(s[t+2]+=1),i<.2&&(s[t+4]+=1))}}()}(),this.setAttribute("position",new Rs(r,3)),this.setAttribute("normal",new Rs(r.slice(),3)),this.setAttribute("uv",new Rs(s,2)),0===i?this.computeVertexNormals():this.normalizeNormals()}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Mu(t.vertices,t.indices,t.radius,t.details)}}class bu extends Mu{constructor(t=1,e=0){const n=(1+Math.sqrt(5))/2,i=1/n;super([-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-i,-n,0,-i,n,0,i,-n,0,i,n,-i,-n,0,-i,n,0,i,-n,0,i,n,0,-n,0,-i,n,0,-i,-n,0,i,n,0,i],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],t,e),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new bu(t.radius,t.detail)}}const Su=new Gi,Iu=new Gi,Tu=new Gi,Bu=new ss;class Ru extends ks{constructor(t=null,e=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:t,thresholdAngle:e},null!==t){const n=4,i=Math.pow(10,n),r=Math.cos(ti*e),s=t.getIndex(),a=t.getAttribute("position"),o=s?s.count:a.count,l=[0,0,0],c=["a","b","c"],h=new Array(3),u={},d=[];for(let t=0;t0)for(s=e;s=e;s-=i)a=td(s,t[s],t[s+1],a);return a&&Xu(a,a.next)&&(ed(a),a=a.next),a}function Lu(t,e){if(!t)return t;e||(e=t);let n,i=t;do{if(n=!1,i.steiner||!Xu(i,i.next)&&0!==qu(i.prev,i,i.next))i=i.next;else{if(ed(i),i=e=i.prev,i===i.next)break;n=!0}}while(n||i!==e);return e}function Uu(t,e,n,i,r,s,a){if(!t)return;!a&&s&&function(t,e,n,i){let r=t;do{0===r.z&&(r.z=Hu(r.x,r.y,e,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,function(t){let e,n,i,r,s,a,o,l,c=1;do{for(n=t,t=null,s=null,a=0;n;){for(a++,i=n,o=0,e=0;e0||l>0&&i;)0!==o&&(0===l||!i||n.z<=i.z)?(r=n,n=n.nextZ,o--):(r=i,i=i.nextZ,l--),s?s.nextZ=r:t=r,r.prevZ=s,s=r;n=i}s.nextZ=null,c*=2}while(a>1)}(r)}(t,i,r,s);let o,l,c=t;for(;t.prev!==t.next;)if(o=t.prev,l=t.next,s?Fu(t,i,r,s):Nu(t))e.push(o.i/n|0),e.push(t.i/n|0),e.push(l.i/n|0),ed(t),t=l.next,c=l.next;else if((t=l)===c){a?1===a?Uu(t=Ou(Lu(t),e,n),e,n,i,r,s,2):2===a&&ku(t,e,n,i,r,s):Uu(Lu(t),e,n,i,r,s,1);break}}function Nu(t){const e=t.prev,n=t,i=t.next;if(qu(e,n,i)>=0)return!1;const r=e.x,s=n.x,a=i.x,o=e.y,l=n.y,c=i.y,h=rs?r>a?r:a:s>a?s:a,p=o>l?o>c?o:c:l>c?l:c;let f=i.next;for(;f!==e;){if(f.x>=h&&f.x<=d&&f.y>=u&&f.y<=p&&Wu(r,o,s,l,a,c,f.x,f.y)&&qu(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function Fu(t,e,n,i){const r=t.prev,s=t,a=t.next;if(qu(r,s,a)>=0)return!1;const o=r.x,l=s.x,c=a.x,h=r.y,u=s.y,d=a.y,p=ol?o>c?o:c:l>c?l:c,g=h>u?h>d?h:d:u>d?u:d,A=Hu(p,f,e,n,i),v=Hu(m,g,e,n,i);let y=t.prevZ,_=t.nextZ;for(;y&&y.z>=A&&_&&_.z<=v;){if(y.x>=p&&y.x<=m&&y.y>=f&&y.y<=g&&y!==r&&y!==a&&Wu(o,h,l,u,c,d,y.x,y.y)&&qu(y.prev,y,y.next)>=0)return!1;if(y=y.prevZ,_.x>=p&&_.x<=m&&_.y>=f&&_.y<=g&&_!==r&&_!==a&&Wu(o,h,l,u,c,d,_.x,_.y)&&qu(_.prev,_,_.next)>=0)return!1;_=_.nextZ}for(;y&&y.z>=A;){if(y.x>=p&&y.x<=m&&y.y>=f&&y.y<=g&&y!==r&&y!==a&&Wu(o,h,l,u,c,d,y.x,y.y)&&qu(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;_&&_.z<=v;){if(_.x>=p&&_.x<=m&&_.y>=f&&_.y<=g&&_!==r&&_!==a&&Wu(o,h,l,u,c,d,_.x,_.y)&&qu(_.prev,_,_.next)>=0)return!1;_=_.nextZ}return!0}function Ou(t,e,n){let i=t;do{const r=i.prev,s=i.next.next;!Xu(r,s)&&Yu(r,i,i.next,s)&&Zu(r,s)&&Zu(s,r)&&(e.push(r.i/n|0),e.push(i.i/n|0),e.push(s.i/n|0),ed(i),ed(i.next),i=t=s),i=i.next}while(i!==t);return Lu(i)}function ku(t,e,n,i,r,s){let a=t;do{let t=a.next.next;for(;t!==a.prev;){if(a.i!==t.i&&ju(a,t)){let o=$u(a,t);return a=Lu(a,a.next),o=Lu(o,o.next),Uu(a,e,n,i,r,s,0),void Uu(o,e,n,i,r,s,0)}t=t.next}a=a.next}while(a!==t)}function Qu(t,e){return t.x-e.x}function zu(t,e){const n=function(t,e){let n,i=e,r=-1/0;const s=t.x,a=t.y;do{if(a<=i.y&&a>=i.next.y&&i.next.y!==i.y){const t=i.x+(a-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(t<=s&&t>r&&(r=t,n=i.x=i.x&&i.x>=l&&s!==i.x&&Wu(an.x||i.x===n.x&&Gu(n,i)))&&(n=i,u=h)),i=i.next}while(i!==o);return n}(t,e);if(!n)return e;const i=$u(n,t);return Lu(i,i.next),Lu(n,n.next)}function Gu(t,e){return qu(t.prev,t,e.prev)<0&&qu(e.next,t,t.next)<0}function Hu(t,e,n,i,r){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-i)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Vu(t){let e=t,n=t;do{(e.x=(t-a)*(s-o)&&(t-a)*(i-o)>=(n-a)*(e-o)&&(n-a)*(s-o)>=(r-a)*(i-o)}function ju(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&Yu(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}(t,e)&&(Zu(t,e)&&Zu(e,t)&&function(t,e){let n=t,i=!1;const r=(t.x+e.x)/2,s=(t.y+e.y)/2;do{n.y>s!=n.next.y>s&&n.next.y!==n.y&&r<(n.next.x-n.x)*(s-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next}while(n!==t);return i}(t,e)&&(qu(t.prev,t,e.prev)||qu(t,e.prev,e))||Xu(t,e)&&qu(t.prev,t,t.next)>0&&qu(e.prev,e,e.next)>0)}function qu(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function Xu(t,e){return t.x===e.x&&t.y===e.y}function Yu(t,e,n,i){const r=Ku(qu(t,e,n)),s=Ku(qu(t,e,i)),a=Ku(qu(n,i,t)),o=Ku(qu(n,i,e));return r!==s&&a!==o||!(0!==r||!Ju(t,n,e))||!(0!==s||!Ju(t,i,e))||!(0!==a||!Ju(n,t,i))||!(0!==o||!Ju(n,e,i))}function Ju(t,e,n){return e.x<=Math.max(t.x,n.x)&&e.x>=Math.min(t.x,n.x)&&e.y<=Math.max(t.y,n.y)&&e.y>=Math.min(t.y,n.y)}function Ku(t){return t>0?1:t<0?-1:0}function Zu(t,e){return qu(t.prev,t,t.next)<0?qu(t,e,t.next)>=0&&qu(t,t.prev,e)>=0:qu(t,e,t.prev)<0||qu(t,t.next,e)<0}function $u(t,e){const n=new nd(t.i,t.x,t.y),i=new nd(e.i,e.x,e.y),r=t.next,s=e.prev;return t.next=e,e.prev=t,n.next=r,r.prev=n,i.next=n,n.prev=i,s.next=i,i.prev=s,i}function td(t,e,n,i){const r=new nd(t,e,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function ed(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function nd(t,e,n){this.i=t,this.x=e,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}class id{static area(t){const e=t.length;let n=0;for(let i=e-1,r=0;r80*n){o=c=t[0],l=h=t[1];for(let e=n;ec&&(c=u),d>h&&(h=d);p=Math.max(c-o,h-l),p=0!==p?32767/p:0}return Uu(s,a,n,o,l,p,0),a}(n,i);for(let t=0;t2&&t[e-1].equals(t[0])&&t.pop()}function sd(t,e){for(let n=0;nNumber.EPSILON){const u=Math.sqrt(h),d=Math.sqrt(l*l+c*c),p=e.x-o/u,f=e.y+a/u,m=((n.x-c/d-p)*c-(n.y+l/d-f)*l)/(a*c-o*l);i=p+a*m-t.x,r=f+o*m-t.y;const g=i*i+r*r;if(g<=2)return new ci(i,r);s=Math.sqrt(g/2)}else{let t=!1;a>Number.EPSILON?l>Number.EPSILON&&(t=!0):a<-Number.EPSILON?l<-Number.EPSILON&&(t=!0):Math.sign(o)===Math.sign(c)&&(t=!0),t?(i=-o,r=a,s=Math.sqrt(h)):(i=a,r=o,s=Math.sqrt(h/2))}return new ci(i/s,r/s)}const R=[];for(let t=0,e=b.length,n=e-1,i=t+1;t=0;t--){const e=t/p,n=h*Math.cos(e*Math.PI/2),i=u*Math.sin(e*Math.PI/2)+d;for(let t=0,e=b.length;t=0;){const i=n;let r=n-1;r<0&&(r=t.length-1);for(let t=0,n=o+2*p;t0)&&d.push(e,r,l),(t!==n-1||o0!=t>0&&this.version++,this._anisotropy=t}get clearcoat(){return this._clearcoat}set clearcoat(t){this._clearcoat>0!=t>0&&this.version++,this._clearcoat=t}get iridescence(){return this._iridescence}set iridescence(t){this._iridescence>0!=t>0&&this.version++,this._iridescence=t}get dispersion(){return this._dispersion}set dispersion(t){this._dispersion>0!=t>0&&this.version++,this._dispersion=t}get sheen(){return this._sheen}set sheen(t){this._sheen>0!=t>0&&this.version++,this._sheen=t}get transmission(){return this._transmission}set transmission(t){this._transmission>0!=t>0&&this.version++,this._transmission=t}copy(t){return super.copy(t),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=t.anisotropy,this.anisotropyRotation=t.anisotropyRotation,this.anisotropyMap=t.anisotropyMap,this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.dispersion=t.dispersion,this.ior=t.ior,this.iridescence=t.iridescence,this.iridescenceMap=t.iridescenceMap,this.iridescenceIOR=t.iridescenceIOR,this.iridescenceThicknessRange=[...t.iridescenceThicknessRange],this.iridescenceThicknessMap=t.iridescenceThicknessMap,this.sheen=t.sheen,this.sheenColor.copy(t.sheenColor),this.sheenColorMap=t.sheenColorMap,this.sheenRoughness=t.sheenRoughness,this.sheenRoughnessMap=t.sheenRoughnessMap,this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this.thickness=t.thickness,this.thicknessMap=t.thicknessMap,this.attenuationDistance=t.attenuationDistance,this.attenuationColor.copy(t.attenuationColor),this.specularIntensity=t.specularIntensity,this.specularIntensityMap=t.specularIntensityMap,this.specularColor.copy(t.specularColor),this.specularColorMap=t.specularColorMap,this}}class Ed extends ps{static get type(){return"MeshPhongMaterial"}constructor(t){super(),this.isMeshPhongMaterial=!0,this.color=new hs(16777215),this.specular=new hs(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new hs(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=on,this.normalScale=new ci(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ir,this.combine=ot,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.specular.copy(t.specular),this.shininess=t.shininess,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class Md extends ps{static get type(){return"MeshToonMaterial"}constructor(t){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.color=new hs(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new hs(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=on,this.normalScale=new ci(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.gradientMap=t.gradientMap,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}class bd extends ps{static get type(){return"MeshNormalMaterial"}constructor(t){super(),this.isMeshNormalMaterial=!0,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=on,this.normalScale=new ci(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(t)}copy(t){return super.copy(t),this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.flatShading=t.flatShading,this}}class Sd extends ps{static get type(){return"MeshLambertMaterial"}constructor(t){super(),this.isMeshLambertMaterial=!0,this.color=new hs(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new hs(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=on,this.normalScale=new ci(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ir,this.combine=ot,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class Id extends ps{static get type(){return"MeshMatcapMaterial"}constructor(t){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.color=new hs(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=on,this.normalScale=new ci(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={MATCAP:""},this.color.copy(t.color),this.matcap=t.matcap,this.map=t.map,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.flatShading=t.flatShading,this.fog=t.fog,this}}class Td extends Mh{static get type(){return"LineDashedMaterial"}constructor(t){super(),this.isLineDashedMaterial=!0,this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(t)}copy(t){return super.copy(t),this.scale=t.scale,this.dashSize=t.dashSize,this.gapSize=t.gapSize,this}}function Bd(t,e,n){return!t||!n&&t.constructor===e?t:"number"==typeof e.BYTES_PER_ELEMENT?new e(t):Array.prototype.slice.call(t)}function Rd(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Dd(t){const e=t.length,n=new Array(e);for(let t=0;t!==e;++t)n[t]=t;return n.sort((function(e,n){return t[e]-t[n]})),n}function Pd(t,e,n){const i=t.length,r=new t.constructor(i);for(let s=0,a=0;a!==i;++s){const i=n[s]*e;for(let n=0;n!==e;++n)r[a++]=t[i+n]}return r}function Ld(t,e,n,i){let r=1,s=t[0];for(;void 0!==s&&void 0===s[i];)s=t[r++];if(void 0===s)return;let a=s[i];if(void 0!==a)if(Array.isArray(a))do{a=s[i],void 0!==a&&(e.push(s.time),n.push.apply(n,a)),s=t[r++]}while(void 0!==s);else if(void 0!==a.toArray)do{a=s[i],void 0!==a&&(e.push(s.time),a.toArray(n,n.length)),s=t[r++]}while(void 0!==s);else do{a=s[i],void 0!==a&&(e.push(s.time),n.push(a)),s=t[r++]}while(void 0!==s)}const Ud={convertArray:Bd,isTypedArray:Rd,getKeyframeOrder:Dd,sortedArray:Pd,flattenJSON:Ld,subclip:function(t,e,n,i,r=30){const s=t.clone();s.name=e;const a=[];for(let t=0;t=i)){l.push(e.times[t]);for(let n=0;ns.tracks[t].times[0]&&(o=s.tracks[t].times[0]);for(let t=0;t=i.times[u]){const t=u*l+o,e=t+l-o;d=i.values.slice(t,e)}else{const t=i.createInterpolant(),e=o,n=l-o;t.evaluate(s),d=t.resultBuffer.slice(e,n)}"quaternion"===r&&(new zi).fromArray(d).normalize().conjugate().toArray(d);const p=a.times.length;for(let t=0;t=r)break t;{const a=e[1];t=r)break e}s=n,n=0}}for(;n>>1;te;)--s;if(++s,0!==r||s!==i){r>=s&&(s=Math.max(s,1),r=s-1);const t=this.getValueSize();this.times=n.slice(r,s),this.values=this.values.slice(r*t,s*t)}return this}validate(){let t=!0;const e=this.getValueSize();e-Math.floor(e)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);const n=this.times,i=this.values,r=n.length;0===r&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let s=null;for(let e=0;e!==r;e++){const i=n[e];if("number"==typeof i&&isNaN(i)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,e,i),t=!1;break}if(null!==s&&s>i){console.error("THREE.KeyframeTrack: Out of order keys.",this,e,i,s),t=!1;break}s=i}if(void 0!==i&&Rd(i))for(let e=0,n=i.length;e!==n;++e){const n=i[e];if(isNaN(n)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,e,n),t=!1;break}}return t}optimize(){const t=this.times.slice(),e=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===qe,r=t.length-1;let s=1;for(let a=1;a0){t[s]=t[r];for(let t=r*n,i=s*n,a=0;a!==n;++a)e[i+a]=e[t+a];++s}return s!==t.length?(this.times=t.slice(0,s),this.values=e.slice(0,s*n)):(this.times=t,this.values=e),this}clone(){const t=this.times.slice(),e=this.values.slice(),n=new(0,this.constructor)(this.name,t,e);return n.createInterpolant=this.createInterpolant,n}}Qd.prototype.TimeBufferType=Float32Array,Qd.prototype.ValueBufferType=Float32Array,Qd.prototype.DefaultInterpolation=je;class zd extends Qd{constructor(t,e,n){super(t,e,n)}}zd.prototype.ValueTypeName="bool",zd.prototype.ValueBufferType=Array,zd.prototype.DefaultInterpolation=We,zd.prototype.InterpolantFactoryMethodLinear=void 0,zd.prototype.InterpolantFactoryMethodSmooth=void 0;class Gd extends Qd{}Gd.prototype.ValueTypeName="color";class Hd extends Qd{}Hd.prototype.ValueTypeName="number";class Vd extends Nd{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){const r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=(n-e)/(i-e);let l=t*a;for(let t=l+a;l!==t;l+=4)zi.slerpFlat(r,0,s,l-a,s,l,o);return r}}class Wd extends Qd{InterpolantFactoryMethodLinear(t){return new Vd(this.times,this.values,this.getValueSize(),t)}}Wd.prototype.ValueTypeName="quaternion",Wd.prototype.InterpolantFactoryMethodSmooth=void 0;class jd extends Qd{constructor(t,e,n){super(t,e,n)}}jd.prototype.ValueTypeName="string",jd.prototype.ValueBufferType=Array,jd.prototype.DefaultInterpolation=We,jd.prototype.InterpolantFactoryMethodLinear=void 0,jd.prototype.InterpolantFactoryMethodSmooth=void 0;class qd extends Qd{}qd.prototype.ValueTypeName="vector";class Xd{constructor(t="",e=-1,n=[],i=Ke){this.name=t,this.tracks=n,this.duration=e,this.blendMode=i,this.uuid=ni(),this.duration<0&&this.resetDuration()}static parse(t){const e=[],n=t.tracks,i=1/(t.fps||1);for(let t=0,r=n.length;t!==r;++t)e.push(Yd(n[t]).scale(i));const r=new this(t.name,t.duration,e,t.blendMode);return r.uuid=t.uuid,r}static toJSON(t){const e=[],n=t.tracks,i={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode};for(let t=0,i=n.length;t!==i;++t)e.push(Qd.toJSON(n[t]));return i}static CreateFromMorphTargetSequence(t,e,n,i){const r=e.length,s=[];for(let t=0;t1){const t=s[1];let e=i[t];e||(i[t]=e=[]),e.push(n)}}const s=[];for(const t in i)s.push(this.CreateFromMorphTargetSequence(t,i[t],e,n));return s}static parseAnimation(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(t,e,n,i,r){if(0!==n.length){const s=[],a=[];Ld(n,s,a,i),0!==s.length&&r.push(new t(e,s,a))}},i=[],r=t.name||"default",s=t.fps||30,a=t.blendMode;let o=t.length||-1;const l=t.hierarchy||[];for(let t=0;t{e&&e(r),this.manager.itemEnd(t)}),0),r;if(void 0!==tp[t])return void tp[t].push({onLoad:e,onProgress:n,onError:i});tp[t]=[],tp[t].push({onLoad:e,onProgress:n,onError:i});const s=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,o=this.responseType;fetch(s).then((e=>{if(200===e.status||0===e.status){if(0===e.status&&console.warn("THREE.FileLoader: HTTP Status 0 received."),"undefined"==typeof ReadableStream||void 0===e.body||void 0===e.body.getReader)return e;const n=tp[t],i=e.body.getReader(),r=e.headers.get("X-File-Size")||e.headers.get("Content-Length"),s=r?parseInt(r):0,a=0!==s;let o=0;const l=new ReadableStream({start(t){!function e(){i.read().then((({done:i,value:r})=>{if(i)t.close();else{o+=r.byteLength;const i=new ProgressEvent("progress",{lengthComputable:a,loaded:o,total:s});for(let t=0,e=n.length;t{t.error(e)}))}()}});return new Response(l)}throw new ep(`fetch for "${e.url}" responded with ${e.status}: ${e.statusText}`,e)})).then((t=>{switch(o){case"arraybuffer":return t.arrayBuffer();case"blob":return t.blob();case"document":return t.text().then((t=>(new DOMParser).parseFromString(t,a)));case"json":return t.json();default:if(void 0===a)return t.text();{const e=/charset="?([^;"\s]*)"?/i.exec(a),n=e&&e[1]?e[1].toLowerCase():void 0,i=new TextDecoder(n);return t.arrayBuffer().then((t=>i.decode(t)))}}})).then((e=>{Jd.add(t,e);const n=tp[t];delete tp[t];for(let t=0,i=n.length;t{const n=tp[t];if(void 0===n)throw this.manager.itemError(t),e;delete tp[t];for(let t=0,i=n.length;t{this.manager.itemEnd(t)})),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}}class ip extends $d{constructor(t){super(t)}load(t,e,n,i){const r=this,s=new np(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(t,(function(n){try{e(r.parse(JSON.parse(n)))}catch(e){i?i(e):console.error(e),r.manager.itemError(t)}}),n,i)}parse(t){const e=[];for(let n=0;n0:i.vertexColors=t.vertexColors),void 0!==t.uniforms)for(const e in t.uniforms){const r=t.uniforms[e];switch(i.uniforms[e]={},r.type){case"t":i.uniforms[e].value=n(r.value);break;case"c":i.uniforms[e].value=(new hs).setHex(r.value);break;case"v2":i.uniforms[e].value=(new ci).fromArray(r.value);break;case"v3":i.uniforms[e].value=(new Gi).fromArray(r.value);break;case"v4":i.uniforms[e].value=(new Li).fromArray(r.value);break;case"m3":i.uniforms[e].value=(new hi).fromArray(r.value);break;case"m4":i.uniforms[e].value=(new vr).fromArray(r.value);break;default:i.uniforms[e].value=r.value}}if(void 0!==t.defines&&(i.defines=t.defines),void 0!==t.vertexShader&&(i.vertexShader=t.vertexShader),void 0!==t.fragmentShader&&(i.fragmentShader=t.fragmentShader),void 0!==t.glslVersion&&(i.glslVersion=t.glslVersion),void 0!==t.extensions)for(const e in t.extensions)i.extensions[e]=t.extensions[e];if(void 0!==t.lights&&(i.lights=t.lights),void 0!==t.clipping&&(i.clipping=t.clipping),void 0!==t.size&&(i.size=t.size),void 0!==t.sizeAttenuation&&(i.sizeAttenuation=t.sizeAttenuation),void 0!==t.map&&(i.map=n(t.map)),void 0!==t.matcap&&(i.matcap=n(t.matcap)),void 0!==t.alphaMap&&(i.alphaMap=n(t.alphaMap)),void 0!==t.bumpMap&&(i.bumpMap=n(t.bumpMap)),void 0!==t.bumpScale&&(i.bumpScale=t.bumpScale),void 0!==t.normalMap&&(i.normalMap=n(t.normalMap)),void 0!==t.normalMapType&&(i.normalMapType=t.normalMapType),void 0!==t.normalScale){let e=t.normalScale;!1===Array.isArray(e)&&(e=[e,e]),i.normalScale=(new ci).fromArray(e)}return void 0!==t.displacementMap&&(i.displacementMap=n(t.displacementMap)),void 0!==t.displacementScale&&(i.displacementScale=t.displacementScale),void 0!==t.displacementBias&&(i.displacementBias=t.displacementBias),void 0!==t.roughnessMap&&(i.roughnessMap=n(t.roughnessMap)),void 0!==t.metalnessMap&&(i.metalnessMap=n(t.metalnessMap)),void 0!==t.emissiveMap&&(i.emissiveMap=n(t.emissiveMap)),void 0!==t.emissiveIntensity&&(i.emissiveIntensity=t.emissiveIntensity),void 0!==t.specularMap&&(i.specularMap=n(t.specularMap)),void 0!==t.specularIntensityMap&&(i.specularIntensityMap=n(t.specularIntensityMap)),void 0!==t.specularColorMap&&(i.specularColorMap=n(t.specularColorMap)),void 0!==t.envMap&&(i.envMap=n(t.envMap)),void 0!==t.envMapRotation&&i.envMapRotation.fromArray(t.envMapRotation),void 0!==t.envMapIntensity&&(i.envMapIntensity=t.envMapIntensity),void 0!==t.reflectivity&&(i.reflectivity=t.reflectivity),void 0!==t.refractionRatio&&(i.refractionRatio=t.refractionRatio),void 0!==t.lightMap&&(i.lightMap=n(t.lightMap)),void 0!==t.lightMapIntensity&&(i.lightMapIntensity=t.lightMapIntensity),void 0!==t.aoMap&&(i.aoMap=n(t.aoMap)),void 0!==t.aoMapIntensity&&(i.aoMapIntensity=t.aoMapIntensity),void 0!==t.gradientMap&&(i.gradientMap=n(t.gradientMap)),void 0!==t.clearcoatMap&&(i.clearcoatMap=n(t.clearcoatMap)),void 0!==t.clearcoatRoughnessMap&&(i.clearcoatRoughnessMap=n(t.clearcoatRoughnessMap)),void 0!==t.clearcoatNormalMap&&(i.clearcoatNormalMap=n(t.clearcoatNormalMap)),void 0!==t.clearcoatNormalScale&&(i.clearcoatNormalScale=(new ci).fromArray(t.clearcoatNormalScale)),void 0!==t.iridescenceMap&&(i.iridescenceMap=n(t.iridescenceMap)),void 0!==t.iridescenceThicknessMap&&(i.iridescenceThicknessMap=n(t.iridescenceThicknessMap)),void 0!==t.transmissionMap&&(i.transmissionMap=n(t.transmissionMap)),void 0!==t.thicknessMap&&(i.thicknessMap=n(t.thicknessMap)),void 0!==t.anisotropyMap&&(i.anisotropyMap=n(t.anisotropyMap)),void 0!==t.sheenColorMap&&(i.sheenColorMap=n(t.sheenColorMap)),void 0!==t.sheenRoughnessMap&&(i.sheenRoughnessMap=n(t.sheenRoughnessMap)),i}setTextures(t){return this.textures=t,this}createMaterialFromType(t){return Ip.createMaterialFromType(t)}static createMaterialFromType(t){return new{ShadowMaterial:_d,SpriteMaterial:vc,RawShaderMaterial:xd,ShaderMaterial:ra,PointsMaterial:kh,MeshPhysicalMaterial:Cd,MeshStandardMaterial:wd,MeshPhongMaterial:Ed,MeshToonMaterial:Md,MeshNormalMaterial:bd,MeshLambertMaterial:Sd,MeshDepthMaterial:jl,MeshDistanceMaterial:ql,MeshBasicMaterial:fs,MeshMatcapMaterial:Id,LineDashedMaterial:Td,LineBasicMaterial:Mh,Material:ps}[t]}}class Tp{static decodeText(t){if(console.warn("THREE.LoaderUtils: decodeText() has been deprecated with r165 and will be removed with r175. Use TextDecoder instead."),"undefined"!=typeof TextDecoder)return(new TextDecoder).decode(t);let e="";for(let n=0,i=t.length;n0){const n=new Kd(e);r=new sp(n),r.setCrossOrigin(this.crossOrigin);for(let e=0,n=t.length;e0){i=new sp(this.manager),i.setCrossOrigin(this.crossOrigin);for(let e=0,i=t.length;e{const e=new Wi;e.min.fromArray(t.boxMin),e.max.fromArray(t.boxMax);const n=new cr;return n.radius=t.sphereRadius,n.center.fromArray(t.sphereCenter),{boxInitialized:t.boxInitialized,box:e,sphereInitialized:t.sphereInitialized,sphere:n}})),s._maxInstanceCount=t.maxInstanceCount,s._maxVertexCount=t.maxVertexCount,s._maxIndexCount=t.maxIndexCount,s._geometryInitialized=t.geometryInitialized,s._geometryCount=t.geometryCount,s._matricesTexture=h(t.matricesTexture.uuid),void 0!==t.colorsTexture&&(s._colorsTexture=h(t.colorsTexture.uuid));break;case"LOD":s=new Nc;break;case"Line":s=new Ph(l(t.geometry),c(t.material));break;case"LineLoop":s=new Oh(l(t.geometry),c(t.material));break;case"LineSegments":s=new Fh(l(t.geometry),c(t.material));break;case"PointCloud":case"Points":s=new Vh(l(t.geometry),c(t.material));break;case"Sprite":s=new Dc(c(t.material));break;case"Group":s=new nc;break;case"Bone":s=new qc;break;default:s=new Wr}if(s.uuid=t.uuid,void 0!==t.name&&(s.name=t.name),void 0!==t.matrix?(s.matrix.fromArray(t.matrix),void 0!==t.matrixAutoUpdate&&(s.matrixAutoUpdate=t.matrixAutoUpdate),s.matrixAutoUpdate&&s.matrix.decompose(s.position,s.quaternion,s.scale)):(void 0!==t.position&&s.position.fromArray(t.position),void 0!==t.rotation&&s.rotation.fromArray(t.rotation),void 0!==t.quaternion&&s.quaternion.fromArray(t.quaternion),void 0!==t.scale&&s.scale.fromArray(t.scale)),void 0!==t.up&&s.up.fromArray(t.up),void 0!==t.castShadow&&(s.castShadow=t.castShadow),void 0!==t.receiveShadow&&(s.receiveShadow=t.receiveShadow),t.shadow&&(void 0!==t.shadow.intensity&&(s.shadow.intensity=t.shadow.intensity),void 0!==t.shadow.bias&&(s.shadow.bias=t.shadow.bias),void 0!==t.shadow.normalBias&&(s.shadow.normalBias=t.shadow.normalBias),void 0!==t.shadow.radius&&(s.shadow.radius=t.shadow.radius),void 0!==t.shadow.mapSize&&s.shadow.mapSize.fromArray(t.shadow.mapSize),void 0!==t.shadow.camera&&(s.shadow.camera=this.parseObject(t.shadow.camera))),void 0!==t.visible&&(s.visible=t.visible),void 0!==t.frustumCulled&&(s.frustumCulled=t.frustumCulled),void 0!==t.renderOrder&&(s.renderOrder=t.renderOrder),void 0!==t.userData&&(s.userData=t.userData),void 0!==t.layers&&(s.layers.mask=t.layers),void 0!==t.children){const a=t.children;for(let t=0;t{e&&e(n),r.manager.itemEnd(t)})).catch((t=>{i&&i(t)})):(setTimeout((function(){e&&e(s),r.manager.itemEnd(t)}),0),s);const a={};a.credentials="anonymous"===this.crossOrigin?"same-origin":"include",a.headers=this.requestHeader;const o=fetch(t,a).then((function(t){return t.blob()})).then((function(t){return createImageBitmap(t,Object.assign(r.options,{colorSpaceConversion:"none"}))})).then((function(n){return Jd.add(t,n),e&&e(n),r.manager.itemEnd(t),n})).catch((function(e){i&&i(e),Jd.remove(t),r.manager.itemError(t),r.manager.itemEnd(t)}));Jd.add(t,o),r.manager.itemStart(t)}}let Fp;class Op{static getContext(){return void 0===Fp&&(Fp=new(window.AudioContext||window.webkitAudioContext)),Fp}static setContext(t){Fp=t}}class kp extends $d{constructor(t){super(t)}load(t,e,n,i){const r=this,s=new np(this.manager);function a(e){i?i(e):console.error(e),r.manager.itemError(t)}s.setResponseType("arraybuffer"),s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(t,(function(t){try{const n=t.slice(0);Op.getContext().decodeAudioData(n,(function(t){e(t)})).catch(a)}catch(t){a(t)}}),n,i)}}const Qp=new vr,zp=new vr,Gp=new vr;class Hp{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new ca,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new ca,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(t){const e=this._cache;if(e.focus!==t.focus||e.fov!==t.fov||e.aspect!==t.aspect*this.aspect||e.near!==t.near||e.far!==t.far||e.zoom!==t.zoom||e.eyeSep!==this.eyeSep){e.focus=t.focus,e.fov=t.fov,e.aspect=t.aspect*this.aspect,e.near=t.near,e.far=t.far,e.zoom=t.zoom,e.eyeSep=this.eyeSep,Gp.copy(t.projectionMatrix);const n=e.eyeSep/2,i=n*e.near/e.focus,r=e.near*Math.tan(ti*e.fov*.5)/e.zoom;let s,a;zp.elements[12]=-n,Qp.elements[12]=n,s=-r*e.aspect+i,a=r*e.aspect+i,Gp.elements[0]=2*e.near/(a-s),Gp.elements[8]=(a+s)/(a-s),this.cameraL.projectionMatrix.copy(Gp),s=-r*e.aspect-i,a=r*e.aspect-i,Gp.elements[0]=2*e.near/(a-s),Gp.elements[8]=(a+s)/(a-s),this.cameraR.projectionMatrix.copy(Gp)}this.cameraL.matrixWorld.copy(t.matrixWorld).multiply(zp),this.cameraR.matrixWorld.copy(t.matrixWorld).multiply(Qp)}}class Vp{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=Wp(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const e=Wp();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}}function Wp(){return performance.now()}const jp=new Gi,qp=new zi,Xp=new Gi,Yp=new Gi;class Jp extends Wr{constructor(){super(),this.type="AudioListener",this.context=Op.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new Vp}getInput(){return this.gain}removeFilter(){return null!==this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(t){return null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=t,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}updateMatrixWorld(t){super.updateMatrixWorld(t);const e=this.context.listener,n=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(jp,qp,Xp),Yp.set(0,0,-1).applyQuaternion(qp),e.positionX){const t=this.context.currentTime+this.timeDelta;e.positionX.linearRampToValueAtTime(jp.x,t),e.positionY.linearRampToValueAtTime(jp.y,t),e.positionZ.linearRampToValueAtTime(jp.z,t),e.forwardX.linearRampToValueAtTime(Yp.x,t),e.forwardY.linearRampToValueAtTime(Yp.y,t),e.forwardZ.linearRampToValueAtTime(Yp.z,t),e.upX.linearRampToValueAtTime(n.x,t),e.upY.linearRampToValueAtTime(n.y,t),e.upZ.linearRampToValueAtTime(n.z,t)}else e.setPosition(jp.x,jp.y,jp.z),e.setOrientation(Yp.x,Yp.y,Yp.z,n.x,n.y,n.z)}}class Kp extends Wr{constructor(t){super(),this.type="Audio",this.listener=t,this.context=t.context,this.gain=this.context.createGain(),this.gain.connect(t.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(t){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=t,this.connect(),this}setMediaElementSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(t),this.connect(),this}setMediaStreamSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(t),this.connect(),this}setBuffer(t){return this.buffer=t,this.sourceType="buffer",this.autoplay&&this.play(),this}play(t=0){if(!0===this.isPlaying)return void console.warn("THREE.Audio: Audio is already playing.");if(!1===this.hasPlaybackControl)return void console.warn("THREE.Audio: this Audio has no playback control.");this._startedAt=this.context.currentTime+t;const e=this.context.createBufferSource();return e.buffer=this.buffer,e.loop=this.loop,e.loopStart=this.loopStart,e.loopEnd=this.loopEnd,e.onended=this.onEnded.bind(this),e.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=e,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(!1!==this.hasPlaybackControl)return!0===this.isPlaying&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,!0===this.loop&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this;console.warn("THREE.Audio: this Audio has no playback control.")}stop(t=0){if(!1!==this.hasPlaybackControl)return this._progress=0,null!==this.source&&(this.source.stop(this.context.currentTime+t),this.source.onended=null),this.isPlaying=!1,this;console.warn("THREE.Audio: this Audio has no playback control.")}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let t=1,e=this.filters.length;t0){this.source.disconnect(this.filters[0]);for(let t=1,e=this.filters.length;t0&&this._mixBufferRegionAdditive(n,i,this._addIndex*e,1,e);for(let t=e,r=e+e;t!==r;++t)if(n[t]!==n[t+e]){a.setValue(n,i);break}}saveOriginalState(){const t=this.binding,e=this.buffer,n=this.valueSize,i=n*this._origIndex;t.getValue(e,i);for(let t=n,r=i;t!==r;++t)e[t]=e[i+t%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const t=3*this.valueSize;this.binding.setValue(this.buffer,t)}_setAdditiveIdentityNumeric(){const t=this._addIndex*this.valueSize,e=t+this.valueSize;for(let n=t;n=.5)for(let i=0;i!==r;++i)t[e+i]=t[n+i]}_slerp(t,e,n,i){zi.slerpFlat(t,e,t,e,t,n,i)}_slerpAdditive(t,e,n,i,r){const s=this._workIndex*r;zi.multiplyQuaternionsFlat(t,s,t,e,t,n),zi.slerpFlat(t,e,t,e,t,s,i)}_lerp(t,e,n,i,r){const s=1-i;for(let a=0;a!==r;++a){const r=e+a;t[r]=t[r]*s+t[n+a]*i}}_lerpAdditive(t,e,n,i,r){for(let s=0;s!==r;++s){const r=e+s;t[r]=t[r]+t[n+s]*i}}}const af="\\[\\]\\.:\\/",of=new RegExp("["+af+"]","g"),lf="[^"+af+"]",cf="[^"+af.replace("\\.","")+"]",hf=new RegExp("^"+/((?:WC+[\/:])*)/.source.replace("WC",lf)+/(WCOD+)?/.source.replace("WCOD",cf)+/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",lf)+/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",lf)+"$"),uf=["material","materials","bones","map"];class df{constructor(t,e,n){this.path=e,this.parsedPath=n||df.parseTrackName(e),this.node=df.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,n){return t&&t.isAnimationObjectGroup?new df.Composite(t,e,n):new df(t,e,n)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(of,"")}static parseTrackName(t){const e=hf.exec(t);if(null===e)throw new Error("PropertyBinding: Cannot parse trackName: "+t);const n={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(void 0!==i&&-1!==i){const t=n.nodeName.substring(i+1);-1!==uf.indexOf(t)&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=t)}if(null===n.propertyName||0===n.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return n}static findNode(t,e){if(void 0===e||""===e||"."===e||-1===e||e===t.name||e===t.uuid)return t;if(t.skeleton){const n=t.skeleton.getBoneByName(e);if(void 0!==n)return n}if(t.children){const n=function(t){for(let i=0;i=r){const s=r++,c=t[s];e[c.uuid]=l,t[l]=c,e[o]=s,t[s]=a;for(let t=0,e=i;t!==e;++t){const e=n[t],i=e[s],r=e[l];e[l]=i,e[s]=r}}}this.nCachedObjects_=r}uncache(){const t=this._objects,e=this._indicesByUUID,n=this._bindings,i=n.length;let r=this.nCachedObjects_,s=t.length;for(let a=0,o=arguments.length;a!==o;++a){const o=arguments[a].uuid,l=e[o];if(void 0!==l)if(delete e[o],l0&&(e[a.uuid]=l),t[l]=a,t.pop();for(let t=0,e=i;t!==e;++t){const e=n[t];e[l]=e[r],e.pop()}}}this.nCachedObjects_=r}subscribe_(t,e){const n=this._bindingsIndicesByPath;let i=n[t];const r=this._bindings;if(void 0!==i)return r[i];const s=this._paths,a=this._parsedPaths,o=this._objects,l=o.length,c=this.nCachedObjects_,h=new Array(l);i=r.length,n[t]=i,s.push(t),a.push(e),r.push(h);for(let n=c,i=o.length;n!==i;++n){const i=o[n];h[n]=new df(i,t,e)}return h}unsubscribe_(t){const e=this._bindingsIndicesByPath,n=e[t];if(void 0!==n){const i=this._paths,r=this._parsedPaths,s=this._bindings,a=s.length-1,o=s[a];e[t[a]]=n,s[n]=o,s.pop(),r[n]=r[a],r.pop(),i[n]=i[a],i.pop()}}}class ff{constructor(t,e,n=null,i=e.blendMode){this._mixer=t,this._clip=e,this._localRoot=n,this.blendMode=i;const r=e.tracks,s=r.length,a=new Array(s),o={endingStart:Xe,endingEnd:Xe};for(let t=0;t!==s;++t){const e=r[t].createInterpolant(null);a[t]=e,e.settings=o}this._interpolantSettings=o,this._interpolants=a,this._propertyBindings=new Array(s),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=He,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(t){return this._startTime=t,this}setLoop(t,e){return this.loop=t,this.repetitions=e,this}setEffectiveWeight(t){return this.weight=t,this._effectiveWeight=this.enabled?t:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(t){return this._scheduleFading(t,0,1)}fadeOut(t){return this._scheduleFading(t,1,0)}crossFadeFrom(t,e,n){if(t.fadeOut(e),this.fadeIn(e),n){const n=this._clip.duration,i=t._clip.duration,r=i/n,s=n/i;t.warp(1,r,e),this.warp(s,1,e)}return this}crossFadeTo(t,e,n){return t.crossFadeFrom(this,e,n)}stopFading(){const t=this._weightInterpolant;return null!==t&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}setEffectiveTimeScale(t){return this.timeScale=t,this._effectiveTimeScale=this.paused?0:t,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(t){return this.timeScale=this._clip.duration/t,this.stopWarping()}syncWith(t){return this.time=t.time,this.timeScale=t.timeScale,this.stopWarping()}halt(t){return this.warp(this._effectiveTimeScale,0,t)}warp(t,e,n){const i=this._mixer,r=i.time,s=this.timeScale;let a=this._timeScaleInterpolant;null===a&&(a=i._lendControlInterpolant(),this._timeScaleInterpolant=a);const o=a.parameterPositions,l=a.sampleValues;return o[0]=r,o[1]=r+n,l[0]=t/s,l[1]=e/s,this}stopWarping(){const t=this._timeScaleInterpolant;return null!==t&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(t,e,n,i){if(!this.enabled)return void this._updateWeight(t);const r=this._startTime;if(null!==r){const i=(t-r)*n;i<0||0===n?e=0:(this._startTime=null,e=n*i)}e*=this._updateTimeScale(t);const s=this._updateTime(e),a=this._updateWeight(t);if(a>0){const t=this._interpolants,e=this._propertyBindings;if(this.blendMode===Ze)for(let n=0,i=t.length;n!==i;++n)t[n].evaluate(s),e[n].accumulateAdditive(a);else for(let n=0,r=t.length;n!==r;++n)t[n].evaluate(s),e[n].accumulate(i,a)}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;const n=this._weightInterpolant;if(null!==n){const i=n.evaluate(t)[0];e*=i,t>n.parameterPositions[1]&&(this.stopFading(),0===i&&(this.enabled=!1))}}return this._effectiveWeight=e,e}_updateTimeScale(t){let e=0;if(!this.paused){e=this.timeScale;const n=this._timeScaleInterpolant;null!==n&&(e*=n.evaluate(t)[0],t>n.parameterPositions[1]&&(this.stopWarping(),0===e?this.paused=!0:this.timeScale=e))}return this._effectiveTimeScale=e,e}_updateTime(t){const e=this._clip.duration,n=this.loop;let i=this.time+t,r=this._loopCount;const s=n===Ve;if(0===t)return-1===r||!s||1&~r?i:e-i;if(n===Ge){-1===r&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(i>=e)i=e;else{if(!(i<0)){this.time=i;break t}i=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(-1===r&&(t>=0?(r=0,this._setEndings(!0,0===this.repetitions,s)):this._setEndings(0===this.repetitions,!0,s)),i>=e||i<0){const n=Math.floor(i/e);i-=e*n,r+=Math.abs(n);const a=this.repetitions-r;if(a<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=t>0?e:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(1===a){const e=t<0;this._setEndings(e,!e,s)}else this._setEndings(!1,!1,s);this._loopCount=r,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:n})}}else this.time=i;if(s&&!(1&~r))return e-i}return i}_setEndings(t,e,n){const i=this._interpolantSettings;n?(i.endingStart=Ye,i.endingEnd=Ye):(i.endingStart=t?this.zeroSlopeAtStart?Ye:Xe:Je,i.endingEnd=e?this.zeroSlopeAtEnd?Ye:Xe:Je)}_scheduleFading(t,e,n){const i=this._mixer,r=i.time;let s=this._weightInterpolant;null===s&&(s=i._lendControlInterpolant(),this._weightInterpolant=s);const a=s.parameterPositions,o=s.sampleValues;return a[0]=r,o[0]=e,a[1]=r+t,o[1]=n,this}}const mf=new Float32Array(1);class gf extends Kn{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(t,e){const n=t._localRoot||this._root,i=t._clip.tracks,r=i.length,s=t._propertyBindings,a=t._interpolants,o=n.uuid,l=this._bindingsByRootAndName;let c=l[o];void 0===c&&(c={},l[o]=c);for(let t=0;t!==r;++t){const r=i[t],l=r.name;let h=c[l];if(void 0!==h)++h.referenceCount,s[t]=h;else{if(h=s[t],void 0!==h){null===h._cacheIndex&&(++h.referenceCount,this._addInactiveBinding(h,o,l));continue}const i=e&&e._propertyBindings[t].binding.parsedPath;h=new sf(df.create(n,l,i),r.ValueTypeName,r.getValueSize()),++h.referenceCount,this._addInactiveBinding(h,o,l),s[t]=h}a[t].resultBuffer=h.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(null===t._cacheIndex){const e=(t._localRoot||this._root).uuid,n=t._clip.uuid,i=this._actionsByClip[n];this._bindAction(t,i&&i.knownActions[0]),this._addInactiveAction(t,n,e)}const e=t._propertyBindings;for(let t=0,n=e.length;t!==n;++t){const n=e[t];0==n.useCount++&&(this._lendBinding(n),n.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){const e=t._propertyBindings;for(let t=0,n=e.length;t!==n;++t){const n=e[t];0==--n.useCount&&(n.restoreOriginalState(),this._takeBackBinding(n))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){const e=t._cacheIndex;return null!==e&&e=0;--e)t[e].stop();return this}update(t){t*=this.timeScale;const e=this._actions,n=this._nActiveActions,i=this.time+=t,r=Math.sign(t),s=this._accuIndex^=1;for(let a=0;a!==n;++a)e[a]._update(i,t,r,s);const a=this._bindings,o=this._nActiveBindings;for(let t=0;t!==o;++t)a[t].apply(s);return this}setTime(t){this.time=0;for(let t=0;t=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Tf).distanceTo(t)}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const Rf=new Gi,Df=new Gi;class Pf{constructor(t=new Gi,e=new Gi){this.start=t,this.end=e}set(t,e){return this.start.copy(t),this.end.copy(e),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){Rf.subVectors(t,this.start),Df.subVectors(this.end,this.start);const n=Df.dot(Df);let i=Df.dot(Rf)/n;return e&&(i=ii(i,0,1)),i}closestPointToPoint(t,e,n){const i=this.closestPointToPointParameter(t,e);return this.delta(n).multiplyScalar(i).add(this.start)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return(new this.constructor).copy(this)}}const Lf=new Gi;class Uf extends Wr{constructor(t,e){super(),this.light=t,this.matrixAutoUpdate=!1,this.color=e,this.type="SpotLightHelper";const n=new ks,i=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let t=0,e=1,n=32;t1)for(let n=0;n.99999)this.quaternion.set(0,0,0,1);else if(t.y<-.99999)this.quaternion.set(1,0,0,0);else{am.set(t.z,0,-t.x).normalize();const e=Math.acos(t.y);this.quaternion.setFromAxisAngle(am,e)}}setLength(t,e=.2*t,n=.2*e){this.line.scale.set(1,Math.max(1e-4,t-e),1),this.line.updateMatrix(),this.cone.scale.set(n,e,n),this.cone.position.y=t,this.cone.updateMatrix()}setColor(t){this.line.material.color.set(t),this.cone.material.color.set(t)}copy(t){return super.copy(t,!1),this.line.copy(t.line),this.cone.copy(t.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class hm extends Fh{constructor(t=1){const e=[0,0,0,t,0,0,0,0,0,0,t,0,0,0,0,0,0,t],n=new ks;n.setAttribute("position",new Rs(e,3)),n.setAttribute("color",new Rs([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3)),super(n,new Mh({vertexColors:!0,toneMapped:!1})),this.type="AxesHelper"}setColors(t,e,n){const i=new hs,r=this.geometry.attributes.color.array;return i.set(t),i.toArray(r,0),i.toArray(r,3),i.set(e),i.toArray(r,6),i.toArray(r,9),i.set(n),i.toArray(r,12),i.toArray(r,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class um{constructor(){this.type="ShapePath",this.color=new hs,this.subPaths=[],this.currentPath=null}moveTo(t,e){return this.currentPath=new yu,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this}lineTo(t,e){return this.currentPath.lineTo(t,e),this}quadraticCurveTo(t,e,n,i){return this.currentPath.quadraticCurveTo(t,e,n,i),this}bezierCurveTo(t,e,n,i,r,s){return this.currentPath.bezierCurveTo(t,e,n,i,r,s),this}splineThru(t){return this.currentPath.splineThru(t),this}toShapes(t){function e(t,e){const n=e.length;let i=!1;for(let r=n-1,s=0;sNumber.EPSILON){if(l<0&&(n=e[s],o=-o,a=e[r],l=-l),t.ya.y)continue;if(t.y===n.y){if(t.x===n.x)return!0}else{const e=l*(t.x-n.x)-o*(t.y-n.y);if(0===e)return!0;if(e<0)continue;i=!i}}else{if(t.y!==n.y)continue;if(a.x<=t.x&&t.x<=n.x||n.x<=t.x&&t.x<=a.x)return!0}}return i}const n=id.isClockWise,i=this.subPaths;if(0===i.length)return[];let r,s,a;const o=[];if(1===i.length)return s=i[0],a=new Du,a.curves=s.curves,o.push(a),o;let l=!n(i[0].getPoints());l=t?!l:l;const c=[],h=[];let u,d,p=[],f=0;h[f]=void 0,p[f]=[];for(let e=0,a=i.length;e1){let t=!1,n=0;for(let t=0,e=h.length;t0&&!1===t&&(p=c)}for(let t=0,e=h.length;t\n\n\t\tvarying vec2 vUv;\n\n\t\t#if DIFFUSE_TEXTURE == 1\n\t\tuniform sampler2D tDiffuse;\n\t\t#endif\n\n\t\tuniform highp sampler2D tDepth;\n\t\tuniform highp sampler2D tNormal;\n\n\t\tuniform float cameraNear;\n\t\tuniform float cameraFar;\n\t\tuniform mat4 cameraProjectionMatrix;\n\t\tuniform mat4 cameraInverseProjectionMatrix;\n\n\t\tuniform float scale;\n\t\tuniform float intensity;\n\t\tuniform float bias;\n\t\tuniform float kernelRadius;\n\t\tuniform float minResolution;\n\t\tuniform vec2 size;\n\t\tuniform float randomSeed;\n\n\t\t// RGBA depth\n\n\t\t#include \n\n\t\tvec4 getDefaultColor( const in vec2 screenPosition ) {\n\t\t\t#if DIFFUSE_TEXTURE == 1\n\t\t\treturn texture2D( tDiffuse, vUv );\n\t\t\t#else\n\t\t\treturn vec4( 1.0 );\n\t\t\t#endif\n\t\t}\n\n\t\tfloat getDepth( const in vec2 screenPosition ) {\n\t\t\treturn texture2D( tDepth, screenPosition ).x;\n\t\t}\n\n\t\tfloat getViewZ( const in float depth ) {\n\t\t\t#if PERSPECTIVE_CAMERA == 1\n\t\t\treturn perspectiveDepthToViewZ( depth, cameraNear, cameraFar );\n\t\t\t#else\n\t\t\treturn orthographicDepthToViewZ( depth, cameraNear, cameraFar );\n\t\t\t#endif\n\t\t}\n\n\t\tvec3 getViewPosition( const in vec2 screenPosition, const in float depth, const in float viewZ ) {\n\t\t\tfloat clipW = cameraProjectionMatrix[2][3] * viewZ + cameraProjectionMatrix[3][3];\n\t\t\tvec4 clipPosition = vec4( ( vec3( screenPosition, depth ) - 0.5 ) * 2.0, 1.0 );\n\t\t\tclipPosition *= clipW; // unprojection.\n\n\t\t\treturn ( cameraInverseProjectionMatrix * clipPosition ).xyz;\n\t\t}\n\n\t\tvec3 getViewNormal( const in vec3 viewPosition, const in vec2 screenPosition ) {\n\t\t\treturn unpackRGBToNormal( texture2D( tNormal, screenPosition ).xyz );\n\t\t}\n\n\t\tfloat scaleDividedByCameraFar;\n\t\tfloat minResolutionMultipliedByCameraFar;\n\n\t\tfloat getOcclusion( const in vec3 centerViewPosition, const in vec3 centerViewNormal, const in vec3 sampleViewPosition ) {\n\t\t\tvec3 viewDelta = sampleViewPosition - centerViewPosition;\n\t\t\tfloat viewDistance = length( viewDelta );\n\t\t\tfloat scaledScreenDistance = scaleDividedByCameraFar * viewDistance;\n\n\t\t\treturn max(0.0, (dot(centerViewNormal, viewDelta) - minResolutionMultipliedByCameraFar) / scaledScreenDistance - bias) / (1.0 + pow2( scaledScreenDistance ) );\n\t\t}\n\n\t\t// moving costly divides into consts\n\t\tconst float ANGLE_STEP = PI2 * float( NUM_RINGS ) / float( NUM_SAMPLES );\n\t\tconst float INV_NUM_SAMPLES = 1.0 / float( NUM_SAMPLES );\n\n\t\tfloat getAmbientOcclusion( const in vec3 centerViewPosition ) {\n\t\t\t// precompute some variables require in getOcclusion.\n\t\t\tscaleDividedByCameraFar = scale / cameraFar;\n\t\t\tminResolutionMultipliedByCameraFar = minResolution * cameraFar;\n\t\t\tvec3 centerViewNormal = getViewNormal( centerViewPosition, vUv );\n\n\t\t\t// jsfiddle that shows sample pattern: https://jsfiddle.net/a16ff1p7/\n\t\t\tfloat angle = rand( vUv + randomSeed ) * PI2;\n\t\t\tvec2 radius = vec2( kernelRadius * INV_NUM_SAMPLES ) / size;\n\t\t\tvec2 radiusStep = radius;\n\n\t\t\tfloat occlusionSum = 0.0;\n\t\t\tfloat weightSum = 0.0;\n\n\t\t\tfor( int i = 0; i < NUM_SAMPLES; i ++ ) {\n\t\t\t\tvec2 sampleUv = vUv + vec2( cos( angle ), sin( angle ) ) * radius;\n\t\t\t\tradius += radiusStep;\n\t\t\t\tangle += ANGLE_STEP;\n\n\t\t\t\tfloat sampleDepth = getDepth( sampleUv );\n\t\t\t\tif( sampleDepth >= ( 1.0 - EPSILON ) ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tfloat sampleViewZ = getViewZ( sampleDepth );\n\t\t\t\tvec3 sampleViewPosition = getViewPosition( sampleUv, sampleDepth, sampleViewZ );\n\t\t\t\tocclusionSum += getOcclusion( centerViewPosition, centerViewNormal, sampleViewPosition );\n\t\t\t\tweightSum += 1.0;\n\t\t\t}\n\n\t\t\tif( weightSum == 0.0 ) discard;\n\n\t\t\treturn occlusionSum * ( intensity / weightSum );\n\t\t}\n\n\t\tvoid main() {\n\t\t\tfloat centerDepth = getDepth( vUv );\n\t\t\tif( centerDepth >= ( 1.0 - EPSILON ) ) {\n\t\t\t\tdiscard;\n\t\t\t}\n\n\t\t\tfloat centerViewZ = getViewZ( centerDepth );\n\t\t\tvec3 viewPosition = getViewPosition( vUv, centerDepth, centerViewZ );\n\n\t\t\tfloat ambientOcclusion = getAmbientOcclusion( viewPosition );\n\n\t\t\tgl_FragColor = getDefaultColor( vUv );\n\t\t\tgl_FragColor.xyz *= 1.0 - ambientOcclusion;\n\t\t}"},Cm={name:"DepthLimitedBlurShader",defines:{KERNEL_RADIUS:4,DEPTH_PACKING:1,PERSPECTIVE_CAMERA:1},uniforms:{tDiffuse:{value:null},size:{value:new ci(512,512)},sampleUvOffsets:{value:[new ci(0,0)]},sampleWeights:{value:[1]},tDepth:{value:null},cameraNear:{value:10},cameraFar:{value:1e3},depthCutoff:{value:10}},vertexShader:"\n\n\t\t#include \n\n\t\tuniform vec2 size;\n\n\t\tvarying vec2 vUv;\n\t\tvarying vec2 vInvSize;\n\n\t\tvoid main() {\n\t\t\tvUv = uv;\n\t\t\tvInvSize = 1.0 / size;\n\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t}",fragmentShader:"\n\n\t\t#include \n\t\t#include \n\n\t\tuniform sampler2D tDiffuse;\n\t\tuniform sampler2D tDepth;\n\n\t\tuniform float cameraNear;\n\t\tuniform float cameraFar;\n\t\tuniform float depthCutoff;\n\n\t\tuniform vec2 sampleUvOffsets[ KERNEL_RADIUS + 1 ];\n\t\tuniform float sampleWeights[ KERNEL_RADIUS + 1 ];\n\n\t\tvarying vec2 vUv;\n\t\tvarying vec2 vInvSize;\n\n\t\tfloat getDepth( const in vec2 screenPosition ) {\n\t\t\t#if DEPTH_PACKING == 1\n\t\t\treturn unpackRGBAToDepth( texture2D( tDepth, screenPosition ) );\n\t\t\t#else\n\t\t\treturn texture2D( tDepth, screenPosition ).x;\n\t\t\t#endif\n\t\t}\n\n\t\tfloat getViewZ( const in float depth ) {\n\t\t\t#if PERSPECTIVE_CAMERA == 1\n\t\t\treturn perspectiveDepthToViewZ( depth, cameraNear, cameraFar );\n\t\t\t#else\n\t\t\treturn orthographicDepthToViewZ( depth, cameraNear, cameraFar );\n\t\t\t#endif\n\t\t}\n\n\t\tvoid main() {\n\t\t\tfloat depth = getDepth( vUv );\n\t\t\tif( depth >= ( 1.0 - EPSILON ) ) {\n\t\t\t\tdiscard;\n\t\t\t}\n\n\t\t\tfloat centerViewZ = -getViewZ( depth );\n\t\t\tbool rBreak = false, lBreak = false;\n\n\t\t\tfloat weightSum = sampleWeights[0];\n\t\t\tvec4 diffuseSum = texture2D( tDiffuse, vUv ) * weightSum;\n\n\t\t\tfor( int i = 1; i <= KERNEL_RADIUS; i ++ ) {\n\n\t\t\t\tfloat sampleWeight = sampleWeights[i];\n\t\t\t\tvec2 sampleUvOffset = sampleUvOffsets[i] * vInvSize;\n\n\t\t\t\tvec2 sampleUv = vUv + sampleUvOffset;\n\t\t\t\tfloat viewZ = -getViewZ( getDepth( sampleUv ) );\n\n\t\t\t\tif( abs( viewZ - centerViewZ ) > depthCutoff ) rBreak = true;\n\n\t\t\t\tif( ! rBreak ) {\n\t\t\t\t\tdiffuseSum += texture2D( tDiffuse, sampleUv ) * sampleWeight;\n\t\t\t\t\tweightSum += sampleWeight;\n\t\t\t\t}\n\n\t\t\t\tsampleUv = vUv - sampleUvOffset;\n\t\t\t\tviewZ = -getViewZ( getDepth( sampleUv ) );\n\n\t\t\t\tif( abs( viewZ - centerViewZ ) > depthCutoff ) lBreak = true;\n\n\t\t\t\tif( ! lBreak ) {\n\t\t\t\t\tdiffuseSum += texture2D( tDiffuse, sampleUv ) * sampleWeight;\n\t\t\t\t\tweightSum += sampleWeight;\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tgl_FragColor = diffuseSum / weightSum;\n\t\t}"},Em={createSampleWeights:function(t,e){const n=[];for(let i=0;i<=t;i++)n.push(Mm(i,e));return n},createSampleOffsets:function(t,e){const n=[];for(let i=0;i<=t;i++)n.push(e.clone().multiplyScalar(i));return n},configure:function(t,e,n,i){t.defines.KERNEL_RADIUS=e,t.uniforms.sampleUvOffsets.value=Em.createSampleOffsets(e,i),t.uniforms.sampleWeights.value=Em.createSampleWeights(e,n),t.needsUpdate=!0}};function Mm(t,e){return Math.exp(-t*t/(e*e*2))/(Math.sqrt(2*Math.PI)*e)}class bm extends mm{constructor(t,e,n=new ci(256,256)){super(),this.scene=t,this.camera=e,this.clear=!0,this.needsSwap=!1,this.originalClearColor=new hs,this._oldClearColor=new hs,this.oldClearAlpha=1,this.params={output:0,saoBias:.5,saoIntensity:.18,saoScale:1,saoKernelRadius:100,saoMinResolution:0,saoBlur:!0,saoBlurRadius:8,saoBlurStdDev:4,saoBlurDepthCutoff:.01},this.resolution=new ci(n.x,n.y),this.saoRenderTarget=new Ni(this.resolution.x,this.resolution.y,{type:jt}),this.blurIntermediateRenderTarget=this.saoRenderTarget.clone();const i=new so;i.format=ie,i.type=Yt,this.normalRenderTarget=new Ni(this.resolution.x,this.resolution.y,{minFilter:Tt,magFilter:Tt,type:jt,depthTexture:i}),this.normalMaterial=new bd,this.normalMaterial.blending=S,this.saoMaterial=new ra({defines:Object.assign({},wm.defines),fragmentShader:wm.fragmentShader,vertexShader:wm.vertexShader,uniforms:ia.clone(wm.uniforms)}),this.saoMaterial.defines.PERSPECTIVE_CAMERA=this.camera.isPerspectiveCamera?1:0,this.saoMaterial.uniforms.tDepth.value=i,this.saoMaterial.uniforms.tNormal.value=this.normalRenderTarget.texture,this.saoMaterial.uniforms.size.value.set(this.resolution.x,this.resolution.y),this.saoMaterial.uniforms.cameraInverseProjectionMatrix.value.copy(this.camera.projectionMatrixInverse),this.saoMaterial.uniforms.cameraProjectionMatrix.value=this.camera.projectionMatrix,this.saoMaterial.blending=S,this.vBlurMaterial=new ra({uniforms:ia.clone(Cm.uniforms),defines:Object.assign({},Cm.defines),vertexShader:Cm.vertexShader,fragmentShader:Cm.fragmentShader}),this.vBlurMaterial.defines.DEPTH_PACKING=0,this.vBlurMaterial.defines.PERSPECTIVE_CAMERA=this.camera.isPerspectiveCamera?1:0,this.vBlurMaterial.uniforms.tDiffuse.value=this.saoRenderTarget.texture,this.vBlurMaterial.uniforms.tDepth.value=i,this.vBlurMaterial.uniforms.size.value.set(this.resolution.x,this.resolution.y),this.vBlurMaterial.blending=S,this.hBlurMaterial=new ra({uniforms:ia.clone(Cm.uniforms),defines:Object.assign({},Cm.defines),vertexShader:Cm.vertexShader,fragmentShader:Cm.fragmentShader}),this.hBlurMaterial.defines.DEPTH_PACKING=0,this.hBlurMaterial.defines.PERSPECTIVE_CAMERA=this.camera.isPerspectiveCamera?1:0,this.hBlurMaterial.uniforms.tDiffuse.value=this.blurIntermediateRenderTarget.texture,this.hBlurMaterial.uniforms.tDepth.value=i,this.hBlurMaterial.uniforms.size.value.set(this.resolution.x,this.resolution.y),this.hBlurMaterial.blending=S,this.materialCopy=new ra({uniforms:ia.clone(fm.uniforms),vertexShader:fm.vertexShader,fragmentShader:fm.fragmentShader,blending:S}),this.materialCopy.transparent=!0,this.materialCopy.depthTest=!1,this.materialCopy.depthWrite=!1,this.materialCopy.blending=D,this.materialCopy.blendSrc=j,this.materialCopy.blendDst=O,this.materialCopy.blendEquation=P,this.materialCopy.blendSrcAlpha=V,this.materialCopy.blendDstAlpha=O,this.materialCopy.blendEquationAlpha=P,this.fsQuad=new vm(null)}render(t,e,n){this.renderToScreen&&(this.materialCopy.blending=S,this.materialCopy.uniforms.tDiffuse.value=n.texture,this.materialCopy.needsUpdate=!0,this.renderPass(t,this.materialCopy,null)),t.getClearColor(this._oldClearColor),this.oldClearAlpha=t.getClearAlpha();const i=t.autoClear;t.autoClear=!1,this.saoMaterial.uniforms.bias.value=this.params.saoBias,this.saoMaterial.uniforms.intensity.value=this.params.saoIntensity,this.saoMaterial.uniforms.scale.value=this.params.saoScale,this.saoMaterial.uniforms.kernelRadius.value=this.params.saoKernelRadius,this.saoMaterial.uniforms.minResolution.value=this.params.saoMinResolution,this.saoMaterial.uniforms.cameraNear.value=this.camera.near,this.saoMaterial.uniforms.cameraFar.value=this.camera.far;const r=this.params.saoBlurDepthCutoff*(this.camera.far-this.camera.near);this.vBlurMaterial.uniforms.depthCutoff.value=r,this.hBlurMaterial.uniforms.depthCutoff.value=r,this.vBlurMaterial.uniforms.cameraNear.value=this.camera.near,this.vBlurMaterial.uniforms.cameraFar.value=this.camera.far,this.hBlurMaterial.uniforms.cameraNear.value=this.camera.near,this.hBlurMaterial.uniforms.cameraFar.value=this.camera.far,this.params.saoBlurRadius=Math.floor(this.params.saoBlurRadius),this.prevStdDev===this.params.saoBlurStdDev&&this.prevNumSamples===this.params.saoBlurRadius||(Em.configure(this.vBlurMaterial,this.params.saoBlurRadius,this.params.saoBlurStdDev,new ci(0,1)),Em.configure(this.hBlurMaterial,this.params.saoBlurRadius,this.params.saoBlurStdDev,new ci(1,0)),this.prevStdDev=this.params.saoBlurStdDev,this.prevNumSamples=this.params.saoBlurRadius),this.renderOverride(t,this.normalMaterial,this.normalRenderTarget,7829503,1),this.renderPass(t,this.saoMaterial,this.saoRenderTarget,16777215,1),this.params.saoBlur&&(this.renderPass(t,this.vBlurMaterial,this.blurIntermediateRenderTarget,16777215,1),this.renderPass(t,this.hBlurMaterial,this.saoRenderTarget,16777215,1));const s=this.materialCopy;this.params.output===bm.OUTPUT.Normal?(this.materialCopy.uniforms.tDiffuse.value=this.normalRenderTarget.texture,this.materialCopy.needsUpdate=!0):(this.materialCopy.uniforms.tDiffuse.value=this.saoRenderTarget.texture,this.materialCopy.needsUpdate=!0),this.params.output===bm.OUTPUT.Default?s.blending=D:s.blending=S,this.renderPass(t,s,this.renderToScreen?null:n),t.setClearColor(this._oldClearColor,this.oldClearAlpha),t.autoClear=i}renderPass(t,e,n,i,r){t.getClearColor(this.originalClearColor);const s=t.getClearAlpha(),a=t.autoClear;t.setRenderTarget(n),t.autoClear=!1,null!=i&&(t.setClearColor(i),t.setClearAlpha(r||0),t.clear()),this.fsQuad.material=e,this.fsQuad.render(t),t.autoClear=a,t.setClearColor(this.originalClearColor),t.setClearAlpha(s)}renderOverride(t,e,n,i,r){t.getClearColor(this.originalClearColor);const s=t.getClearAlpha(),a=t.autoClear;t.setRenderTarget(n),t.autoClear=!1,i=e.clearColor||i,r=e.clearAlpha||r,null!=i&&(t.setClearColor(i),t.setClearAlpha(r||0),t.clear()),this.scene.overrideMaterial=e,t.render(this.scene,this.camera),this.scene.overrideMaterial=null,t.autoClear=a,t.setClearColor(this.originalClearColor),t.setClearAlpha(s)}setSize(t,e){this.saoRenderTarget.setSize(t,e),this.blurIntermediateRenderTarget.setSize(t,e),this.normalRenderTarget.setSize(t,e),this.saoMaterial.uniforms.size.value.set(t,e),this.saoMaterial.uniforms.cameraInverseProjectionMatrix.value.copy(this.camera.projectionMatrixInverse),this.saoMaterial.uniforms.cameraProjectionMatrix.value=this.camera.projectionMatrix,this.saoMaterial.needsUpdate=!0,this.vBlurMaterial.uniforms.size.value.set(t,e),this.vBlurMaterial.needsUpdate=!0,this.hBlurMaterial.uniforms.size.value.set(t,e),this.hBlurMaterial.needsUpdate=!0}dispose(){this.saoRenderTarget.dispose(),this.blurIntermediateRenderTarget.dispose(),this.normalRenderTarget.dispose(),this.normalMaterial.dispose(),this.saoMaterial.dispose(),this.vBlurMaterial.dispose(),this.hBlurMaterial.dispose(),this.materialCopy.dispose(),this.fsQuad.dispose()}}bm.OUTPUT={Default:0,SAO:1,Normal:2};const Sm={name:"GTAOShader",defines:{PERSPECTIVE_CAMERA:1,SAMPLES:16,NORMAL_VECTOR_TYPE:1,DEPTH_SWIZZLING:"x",SCREEN_SPACE_RADIUS:0,SCREEN_SPACE_RADIUS_SCALE:100,SCENE_CLIP_BOX:0},uniforms:{tNormal:{value:null},tDepth:{value:null},tNoise:{value:null},resolution:{value:new ci},cameraNear:{value:null},cameraFar:{value:null},cameraProjectionMatrix:{value:new vr},cameraProjectionMatrixInverse:{value:new vr},cameraWorldMatrix:{value:new vr},radius:{value:.25},distanceExponent:{value:1},thickness:{value:1},distanceFallOff:{value:1},scale:{value:1},sceneBoxMin:{value:new Gi(-1,-1,-1)},sceneBoxMax:{value:new Gi(1,1,1)}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t}",fragmentShader:"\n\t\tvarying vec2 vUv;\n\t\tuniform highp sampler2D tNormal;\n\t\tuniform highp sampler2D tDepth;\n\t\tuniform sampler2D tNoise;\n\t\tuniform vec2 resolution;\n\t\tuniform float cameraNear;\n\t\tuniform float cameraFar;\n\t\tuniform mat4 cameraProjectionMatrix;\n\t\tuniform mat4 cameraProjectionMatrixInverse;\t\t\n\t\tuniform mat4 cameraWorldMatrix;\n\t\tuniform float radius;\n\t\tuniform float distanceExponent;\n\t\tuniform float thickness;\n\t\tuniform float distanceFallOff;\n\t\tuniform float scale;\n\t\t#if SCENE_CLIP_BOX == 1\n\t\t\tuniform vec3 sceneBoxMin;\n\t\t\tuniform vec3 sceneBoxMax;\n\t\t#endif\n\t\t\n\t\t#include \n\t\t#include \n\n\t\t#ifndef FRAGMENT_OUTPUT\n\t\t#define FRAGMENT_OUTPUT vec4(vec3(ao), 1.)\n\t\t#endif\n\n\t\tvec3 getViewPosition(const in vec2 screenPosition, const in float depth) {\n\t\t\tvec4 clipSpacePosition = vec4(vec3(screenPosition, depth) * 2.0 - 1.0, 1.0);\n\t\t\tvec4 viewSpacePosition = cameraProjectionMatrixInverse * clipSpacePosition;\n\t\t\treturn viewSpacePosition.xyz / viewSpacePosition.w;\n\t\t}\n\n\t\tfloat getDepth(const vec2 uv) { \n\t\t\treturn textureLod(tDepth, uv.xy, 0.0).DEPTH_SWIZZLING;\n\t\t}\n\n\t\tfloat fetchDepth(const ivec2 uv) { \n\t\t\treturn texelFetch(tDepth, uv.xy, 0).DEPTH_SWIZZLING;\n\t\t}\n\n\t\tfloat getViewZ(const in float depth) {\n\t\t\t#if PERSPECTIVE_CAMERA == 1\n\t\t\t\treturn perspectiveDepthToViewZ(depth, cameraNear, cameraFar);\n\t\t\t#else\n\t\t\t\treturn orthographicDepthToViewZ(depth, cameraNear, cameraFar);\n\t\t\t#endif\n\t\t}\n\n\t\tvec3 computeNormalFromDepth(const vec2 uv) {\n\t\t\tvec2 size = vec2(textureSize(tDepth, 0));\n\t\t\tivec2 p = ivec2(uv * size);\n\t\t\tfloat c0 = fetchDepth(p);\n\t\t\tfloat l2 = fetchDepth(p - ivec2(2, 0));\n\t\t\tfloat l1 = fetchDepth(p - ivec2(1, 0));\n\t\t\tfloat r1 = fetchDepth(p + ivec2(1, 0));\n\t\t\tfloat r2 = fetchDepth(p + ivec2(2, 0));\n\t\t\tfloat b2 = fetchDepth(p - ivec2(0, 2));\n\t\t\tfloat b1 = fetchDepth(p - ivec2(0, 1));\n\t\t\tfloat t1 = fetchDepth(p + ivec2(0, 1));\n\t\t\tfloat t2 = fetchDepth(p + ivec2(0, 2));\n\t\t\tfloat dl = abs((2.0 * l1 - l2) - c0);\n\t\t\tfloat dr = abs((2.0 * r1 - r2) - c0);\n\t\t\tfloat db = abs((2.0 * b1 - b2) - c0);\n\t\t\tfloat dt = abs((2.0 * t1 - t2) - c0);\n\t\t\tvec3 ce = getViewPosition(uv, c0).xyz;\n\t\t\tvec3 dpdx = (dl < dr) ? ce - getViewPosition((uv - vec2(1.0 / size.x, 0.0)), l1).xyz : -ce + getViewPosition((uv + vec2(1.0 / size.x, 0.0)), r1).xyz;\n\t\t\tvec3 dpdy = (db < dt) ? ce - getViewPosition((uv - vec2(0.0, 1.0 / size.y)), b1).xyz : -ce + getViewPosition((uv + vec2(0.0, 1.0 / size.y)), t1).xyz;\n\t\t\treturn normalize(cross(dpdx, dpdy));\n\t\t}\n\n\t\tvec3 getViewNormal(const vec2 uv) {\n\t\t\t#if NORMAL_VECTOR_TYPE == 2\n\t\t\t\treturn normalize(textureLod(tNormal, uv, 0.).rgb);\n\t\t\t#elif NORMAL_VECTOR_TYPE == 1\n\t\t\t\treturn unpackRGBToNormal(textureLod(tNormal, uv, 0.).rgb);\n\t\t\t#else\n\t\t\t\treturn computeNormalFromDepth(uv);\n\t\t\t#endif\n\t\t}\n\n\t\tvec3 getSceneUvAndDepth(vec3 sampleViewPos) {\n\t\t\tvec4 sampleClipPos = cameraProjectionMatrix * vec4(sampleViewPos, 1.);\n\t\t\tvec2 sampleUv = sampleClipPos.xy / sampleClipPos.w * 0.5 + 0.5;\n\t\t\tfloat sampleSceneDepth = getDepth(sampleUv);\n\t\t\treturn vec3(sampleUv, sampleSceneDepth);\n\t\t}\n\t\t\n\t\tvoid main() {\n\t\t\tfloat depth = getDepth(vUv.xy);\n\t\t\tif (depth >= 1.0) {\n\t\t\t\tdiscard;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tvec3 viewPos = getViewPosition(vUv, depth);\n\t\t\tvec3 viewNormal = getViewNormal(vUv);\n\n\t\t\tfloat radiusToUse = radius;\n\t\t\tfloat distanceFalloffToUse = thickness;\n\t\t\t#if SCREEN_SPACE_RADIUS == 1\n\t\t\t\tfloat radiusScale = getViewPosition(vec2(0.5 + float(SCREEN_SPACE_RADIUS_SCALE) / resolution.x, 0.0), depth).x;\n\t\t\t\tradiusToUse *= radiusScale;\n\t\t\t\tdistanceFalloffToUse *= radiusScale;\n\t\t\t#endif\n\n\t\t\t#if SCENE_CLIP_BOX == 1\n\t\t\t\tvec3 worldPos = (cameraWorldMatrix * vec4(viewPos, 1.0)).xyz;\n\t\t\t\tfloat boxDistance = length(max(vec3(0.0), max(sceneBoxMin - worldPos, worldPos - sceneBoxMax)));\n\t\t\t\tif (boxDistance > radiusToUse) {\n\t\t\t\t\tdiscard;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t#endif\n\t\t\t\n\t\t\tvec2 noiseResolution = vec2(textureSize(tNoise, 0));\n\t\t\tvec2 noiseUv = vUv * resolution / noiseResolution;\n\t\t\tvec4 noiseTexel = textureLod(tNoise, noiseUv, 0.0);\n\t\t\tvec3 randomVec = noiseTexel.xyz * 2.0 - 1.0;\n\t\t\tvec3 tangent = normalize(vec3(randomVec.xy, 0.));\n\t\t\tvec3 bitangent = vec3(-tangent.y, tangent.x, 0.);\n\t\t\tmat3 kernelMatrix = mat3(tangent, bitangent, vec3(0., 0., 1.));\n\n\t\t\tconst int DIRECTIONS = SAMPLES < 30 ? 3 : 5;\n\t\t\tconst int STEPS = (SAMPLES + DIRECTIONS - 1) / DIRECTIONS;\n\t\t\tfloat ao = 0.0;\n\t\t\tfor (int i = 0; i < DIRECTIONS; ++i) {\n\t\t\t\t\n\t\t\t\tfloat angle = float(i) / float(DIRECTIONS) * PI;\n\t\t\t\tvec4 sampleDir = vec4(cos(angle), sin(angle), 0., 0.5 + 0.5 * noiseTexel.w); \n\t\t\t\tsampleDir.xyz = normalize(kernelMatrix * sampleDir.xyz);\n\n\t\t\t\tvec3 viewDir = normalize(-viewPos.xyz);\n\t\t\t\tvec3 sliceBitangent = normalize(cross(sampleDir.xyz, viewDir));\n\t\t\t\tvec3 sliceTangent = cross(sliceBitangent, viewDir);\n\t\t\t\tvec3 normalInSlice = normalize(viewNormal - sliceBitangent * dot(viewNormal, sliceBitangent));\n\t\t\t\t\n\t\t\t\tvec3 tangentToNormalInSlice = cross(normalInSlice, sliceBitangent);\n\t\t\t\tvec2 cosHorizons = vec2(dot(viewDir, tangentToNormalInSlice), dot(viewDir, -tangentToNormalInSlice));\n\t\t\t\t\n\t\t\t\tfor (int j = 0; j < STEPS; ++j) {\n\t\t\t\t\tvec3 sampleViewOffset = sampleDir.xyz * radiusToUse * sampleDir.w * pow(float(j + 1) / float(STEPS), distanceExponent);\t\n\n\t\t\t\t\tvec3 sampleSceneUvDepth = getSceneUvAndDepth(viewPos + sampleViewOffset);\n\t\t\t\t\tvec3 sampleSceneViewPos = getViewPosition(sampleSceneUvDepth.xy, sampleSceneUvDepth.z);\n\t\t\t\t\tvec3 viewDelta = sampleSceneViewPos - viewPos;\n\t\t\t\t\tif (abs(viewDelta.z) < thickness) {\n\t\t\t\t\t\tfloat sampleCosHorizon = dot(viewDir, normalize(viewDelta));\n\t\t\t\t\t\tcosHorizons.x += max(0., (sampleCosHorizon - cosHorizons.x) * mix(1., 2. / float(j + 2), distanceFallOff));\n\t\t\t\t\t}\t\t\n\n\t\t\t\t\tsampleSceneUvDepth = getSceneUvAndDepth(viewPos - sampleViewOffset);\n\t\t\t\t\tsampleSceneViewPos = getViewPosition(sampleSceneUvDepth.xy, sampleSceneUvDepth.z);\n\t\t\t\t\tviewDelta = sampleSceneViewPos - viewPos;\n\t\t\t\t\tif (abs(viewDelta.z) < thickness) {\n\t\t\t\t\t\tfloat sampleCosHorizon = dot(viewDir, normalize(viewDelta));\n\t\t\t\t\t\tcosHorizons.y += max(0., (sampleCosHorizon - cosHorizons.y) * mix(1., 2. / float(j + 2), distanceFallOff));\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tvec2 sinHorizons = sqrt(1. - cosHorizons * cosHorizons);\n\t\t\t\tfloat nx = dot(normalInSlice, sliceTangent);\n\t\t\t\tfloat ny = dot(normalInSlice, viewDir);\n\t\t\t\tfloat nxb = 1. / 2. * (acos(cosHorizons.y) - acos(cosHorizons.x) + sinHorizons.x * cosHorizons.x - sinHorizons.y * cosHorizons.y);\n\t\t\t\tfloat nyb = 1. / 2. * (2. - cosHorizons.x * cosHorizons.x - cosHorizons.y * cosHorizons.y);\n\t\t\t\tfloat occlusion = nx * nxb + ny * nyb;\n\t\t\t\tao += occlusion;\n\t\t\t}\n\n\t\t\tao = clamp(ao / float(DIRECTIONS), 0., 1.);\t\t\n\t\t#if SCENE_CLIP_BOX == 1\n\t\t\tao = mix(ao, 1., smoothstep(0., radiusToUse, boxDistance));\n\t\t#endif\n\t\t\tao = pow(ao, scale);\n\n\t\t\tgl_FragColor = FRAGMENT_OUTPUT;\n\t\t}"},Im={PERSPECTIVE_CAMERA:1},Tm={tDepth:{value:null},cameraNear:{value:null},cameraFar:{value:null}},Bm="\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t}",Rm="\n\t\tuniform sampler2D tDepth;\n\t\tuniform float cameraNear;\n\t\tuniform float cameraFar;\n\t\tvarying vec2 vUv;\n\n\t\t#include \n\n\t\tfloat getLinearDepth( const in vec2 screenPosition ) {\n\t\t\t#if PERSPECTIVE_CAMERA == 1\n\t\t\t\tfloat fragCoordZ = texture2D( tDepth, screenPosition ).x;\n\t\t\t\tfloat viewZ = perspectiveDepthToViewZ( fragCoordZ, cameraNear, cameraFar );\n\t\t\t\treturn viewZToOrthographicDepth( viewZ, cameraNear, cameraFar );\n\t\t\t#else\n\t\t\t\treturn texture2D( tDepth, screenPosition ).x;\n\t\t\t#endif\n\t\t}\n\n\t\tvoid main() {\n\t\t\tfloat depth = getLinearDepth( vUv );\n\t\t\tgl_FragColor = vec4( vec3( 1.0 - depth ), 1.0 );\n\n\t\t}",Dm={tDiffuse:{value:null},intensity:{value:1}},Pm="\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t}",Lm="\n\t\tuniform float intensity;\n\t\tuniform sampler2D tDiffuse;\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\t\t\tvec4 texel = texture2D( tDiffuse, vUv );\n\t\t\tgl_FragColor = vec4(mix(vec3(1.), texel.rgb, intensity), texel.a);\n\t\t}";const Um={name:"PoissonDenoiseShader",defines:{SAMPLES:16,SAMPLE_VECTORS:Nm(16,2,1),NORMAL_VECTOR_TYPE:1,DEPTH_VALUE_SOURCE:0},uniforms:{tDiffuse:{value:null},tNormal:{value:null},tDepth:{value:null},tNoise:{value:null},resolution:{value:new ci},cameraProjectionMatrixInverse:{value:new vr},lumaPhi:{value:5},depthPhi:{value:5},normalPhi:{value:5},radius:{value:4},index:{value:0}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t}",fragmentShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tuniform sampler2D tDiffuse;\n\t\tuniform sampler2D tNormal;\n\t\tuniform sampler2D tDepth;\n\t\tuniform sampler2D tNoise;\n\t\tuniform vec2 resolution;\n\t\tuniform mat4 cameraProjectionMatrixInverse;\n\t\tuniform float lumaPhi;\n\t\tuniform float depthPhi;\n\t\tuniform float normalPhi;\n\t\tuniform float radius;\n\t\tuniform int index;\n\t\t\n\t\t#include \n\t\t#include \n\n\t\t#ifndef SAMPLE_LUMINANCE\n\t\t#define SAMPLE_LUMINANCE dot(vec3(0.2125, 0.7154, 0.0721), a)\n\t\t#endif\n\n\t\t#ifndef FRAGMENT_OUTPUT\n\t\t#define FRAGMENT_OUTPUT vec4(denoised, 1.)\n\t\t#endif\n\n\t\tfloat getLuminance(const in vec3 a) {\n\t\t\treturn SAMPLE_LUMINANCE;\n\t\t}\n\n\t\tconst vec3 poissonDisk[SAMPLES] = SAMPLE_VECTORS;\n\n\t\tvec3 getViewPosition(const in vec2 screenPosition, const in float depth) {\n\t\t\tvec4 clipSpacePosition = vec4(vec3(screenPosition, depth) * 2.0 - 1.0, 1.0);\n\t\t\tvec4 viewSpacePosition = cameraProjectionMatrixInverse * clipSpacePosition;\n\t\t\treturn viewSpacePosition.xyz / viewSpacePosition.w;\n\t\t}\n\t\t\n\t\tfloat getDepth(const vec2 uv) {\n\t\t#if DEPTH_VALUE_SOURCE == 1 \n\t\t\treturn textureLod(tDepth, uv.xy, 0.0).a;\n\t\t#else\n\t\t\treturn textureLod(tDepth, uv.xy, 0.0).r;\n\t\t#endif\n\t\t}\n\n\t\tfloat fetchDepth(const ivec2 uv) {\n\t\t\t#if DEPTH_VALUE_SOURCE == 1 \n\t\t\t\treturn texelFetch(tDepth, uv.xy, 0).a;\n\t\t\t#else\n\t\t\t\treturn texelFetch(tDepth, uv.xy, 0).r;\n\t\t\t#endif\n\t\t}\n\n\t\tvec3 computeNormalFromDepth(const vec2 uv) {\n\t\t\tvec2 size = vec2(textureSize(tDepth, 0));\n\t\t\tivec2 p = ivec2(uv * size);\n\t\t\tfloat c0 = fetchDepth(p);\n\t\t\tfloat l2 = fetchDepth(p - ivec2(2, 0));\n\t\t\tfloat l1 = fetchDepth(p - ivec2(1, 0));\n\t\t\tfloat r1 = fetchDepth(p + ivec2(1, 0));\n\t\t\tfloat r2 = fetchDepth(p + ivec2(2, 0));\n\t\t\tfloat b2 = fetchDepth(p - ivec2(0, 2));\n\t\t\tfloat b1 = fetchDepth(p - ivec2(0, 1));\n\t\t\tfloat t1 = fetchDepth(p + ivec2(0, 1));\n\t\t\tfloat t2 = fetchDepth(p + ivec2(0, 2));\n\t\t\tfloat dl = abs((2.0 * l1 - l2) - c0);\n\t\t\tfloat dr = abs((2.0 * r1 - r2) - c0);\n\t\t\tfloat db = abs((2.0 * b1 - b2) - c0);\n\t\t\tfloat dt = abs((2.0 * t1 - t2) - c0);\n\t\t\tvec3 ce = getViewPosition(uv, c0).xyz;\n\t\t\tvec3 dpdx = (dl < dr) ? ce - getViewPosition((uv - vec2(1.0 / size.x, 0.0)), l1).xyz\n\t\t\t\t\t\t\t\t\t: -ce + getViewPosition((uv + vec2(1.0 / size.x, 0.0)), r1).xyz;\n\t\t\tvec3 dpdy = (db < dt) ? ce - getViewPosition((uv - vec2(0.0, 1.0 / size.y)), b1).xyz\n\t\t\t\t\t\t\t\t\t: -ce + getViewPosition((uv + vec2(0.0, 1.0 / size.y)), t1).xyz;\n\t\t\treturn normalize(cross(dpdx, dpdy));\n\t\t}\n\n\t\tvec3 getViewNormal(const vec2 uv) {\n\t\t#if NORMAL_VECTOR_TYPE == 2\n\t\t\treturn normalize(textureLod(tNormal, uv, 0.).rgb);\n\t\t#elif NORMAL_VECTOR_TYPE == 1\n\t\t\treturn unpackRGBToNormal(textureLod(tNormal, uv, 0.).rgb);\n\t\t#else\n\t\t\treturn computeNormalFromDepth(uv);\n\t\t#endif\n\t\t}\n\n\t\tvoid denoiseSample(in vec3 center, in vec3 viewNormal, in vec3 viewPos, in vec2 sampleUv, inout vec3 denoised, inout float totalWeight) {\n\t\t\tvec4 sampleTexel = textureLod(tDiffuse, sampleUv, 0.0);\n\t\t\tfloat sampleDepth = getDepth(sampleUv);\n\t\t\tvec3 sampleNormal = getViewNormal(sampleUv);\n\t\t\tvec3 neighborColor = sampleTexel.rgb;\n\t\t\tvec3 viewPosSample = getViewPosition(sampleUv, sampleDepth);\n\t\t\t\n\t\t\tfloat normalDiff = dot(viewNormal, sampleNormal);\n\t\t\tfloat normalSimilarity = pow(max(normalDiff, 0.), normalPhi);\n\t\t\tfloat lumaDiff = abs(getLuminance(neighborColor) - getLuminance(center));\n\t\t\tfloat lumaSimilarity = max(1.0 - lumaDiff / lumaPhi, 0.0);\n\t\t\tfloat depthDiff = abs(dot(viewPos - viewPosSample, viewNormal));\n\t\t\tfloat depthSimilarity = max(1. - depthDiff / depthPhi, 0.);\n\t\t\tfloat w = lumaSimilarity * depthSimilarity * normalSimilarity;\n\t\t\n\t\t\tdenoised += w * neighborColor;\n\t\t\ttotalWeight += w;\n\t\t}\n\t\t\n\t\tvoid main() {\n\t\t\tfloat depth = getDepth(vUv.xy);\t\n\t\t\tvec3 viewNormal = getViewNormal(vUv);\t\n\t\t\tif (depth == 1. || dot(viewNormal, viewNormal) == 0.) {\n\t\t\t\tdiscard;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tvec4 texel = textureLod(tDiffuse, vUv, 0.0);\n\t\t\tvec3 center = texel.rgb;\n\t\t\tvec3 viewPos = getViewPosition(vUv, depth);\n\n\t\t\tvec2 noiseResolution = vec2(textureSize(tNoise, 0));\n\t\t\tvec2 noiseUv = vUv * resolution / noiseResolution;\n\t\t\tvec4 noiseTexel = textureLod(tNoise, noiseUv, 0.0);\n \t\tvec2 noiseVec = vec2(sin(noiseTexel[index % 4] * 2. * PI), cos(noiseTexel[index % 4] * 2. * PI));\n \t\tmat2 rotationMatrix = mat2(noiseVec.x, -noiseVec.y, noiseVec.x, noiseVec.y);\n\t\t\n\t\t\tfloat totalWeight = 1.0;\n\t\t\tvec3 denoised = texel.rgb;\n\t\t\tfor (int i = 0; i < SAMPLES; i++) {\n\t\t\t\tvec3 sampleDir = poissonDisk[i];\n\t\t\t\tvec2 offset = rotationMatrix * (sampleDir.xy * (1. + sampleDir.z * (radius - 1.)) / resolution);\n\t\t\t\tvec2 sampleUv = vUv + offset;\n\t\t\t\tdenoiseSample(center, viewNormal, viewPos, sampleUv, denoised, totalWeight);\n\t\t\t}\n\t\t\n\t\t\tif (totalWeight > 0.) { \n\t\t\t\tdenoised /= totalWeight;\n\t\t\t}\n\t\t\tgl_FragColor = FRAGMENT_OUTPUT;\n\t\t}"};function Nm(t,e,n){const i=function(t,e,n){const i=[];for(let r=0;ru?(d=1,p=0):(d=0,p=1);const f=h-d+l,m=u-p+l,g=h-1+2*l,A=u-1+2*l,v=255&a,y=255&o,_=this.perm[v+this.perm[y]]%12,x=this.perm[v+d+this.perm[y+p]]%12,w=this.perm[v+1+this.perm[y+1]]%12;let C=.5-h*h-u*u;C<0?n=0:(C*=C,n=C*C*this.dot(this.grad3[_],h,u));let E=.5-f*f-m*m;E<0?i=0:(E*=E,i=E*E*this.dot(this.grad3[x],f,m));let M=.5-g*g-A*A;return M<0?r=0:(M*=M,r=M*M*this.dot(this.grad3[w],g,A)),70*(n+i+r)}noise3d(t,e,n){let i,r,s,a;const o=(t+e+n)*(1/3),l=Math.floor(t+o),c=Math.floor(e+o),h=Math.floor(n+o),u=1/6,d=(l+c+h)*u,p=t-(l-d),f=e-(c-d),m=n-(h-d);let g,A,v,y,_,x;p>=f?f>=m?(g=1,A=0,v=0,y=1,_=1,x=0):p>=m?(g=1,A=0,v=0,y=1,_=0,x=1):(g=0,A=0,v=1,y=1,_=0,x=1):fx?32:0)+(_>w?16:0)+(x>w?8:0)+(_>C?4:0)+(x>C?2:0)+(w>C?1:0),M=s[E][0]>=3?1:0,b=s[E][1]>=3?1:0,S=s[E][2]>=3?1:0,I=s[E][3]>=3?1:0,T=s[E][0]>=2?1:0,B=s[E][1]>=2?1:0,R=s[E][2]>=2?1:0,D=s[E][3]>=2?1:0,P=s[E][0]>=1?1:0,L=s[E][1]>=1?1:0,U=s[E][2]>=1?1:0,N=s[E][3]>=1?1:0,F=_-M+l,O=x-b+l,k=w-S+l,Q=C-I+l,z=_-T+2*l,G=x-B+2*l,H=w-R+2*l,V=C-D+2*l,W=_-P+3*l,j=x-L+3*l,q=w-U+3*l,X=C-N+3*l,Y=_-1+4*l,J=x-1+4*l,K=w-1+4*l,Z=C-1+4*l,$=255&m,tt=255&g,et=255&A,nt=255&v,it=a[$+a[tt+a[et+a[nt]]]]%32,rt=a[$+M+a[tt+b+a[et+S+a[nt+I]]]]%32,st=a[$+T+a[tt+B+a[et+R+a[nt+D]]]]%32,at=a[$+P+a[tt+L+a[et+U+a[nt+N]]]]%32,ot=a[$+1+a[tt+1+a[et+1+a[nt+1]]]]%32;let lt=.6-_*_-x*x-w*w-C*C;lt<0?c=0:(lt*=lt,c=lt*lt*this.dot4(r[it],_,x,w,C));let ct=.6-F*F-O*O-k*k-Q*Q;ct<0?h=0:(ct*=ct,h=ct*ct*this.dot4(r[rt],F,O,k,Q));let ht=.6-z*z-G*G-H*H-V*V;ht<0?u=0:(ht*=ht,u=ht*ht*this.dot4(r[st],z,G,H,V));let ut=.6-W*W-j*j-q*q-X*X;ut<0?d=0:(ut*=ut,d=ut*ut*this.dot4(r[at],W,j,q,X));let dt=.6-Y*Y-J*J-K*K-Z*Z;return dt<0?p=0:(dt*=dt,p=dt*dt*this.dot4(r[ot],Y,J,K,Z)),27*(c+h+u+d+p)}}class Om extends mm{constructor(t,e,n,i,r,s,a){super(),this.width=void 0!==n?n:512,this.height=void 0!==i?i:512,this.clear=!0,this.camera=e,this.scene=t,this.output=0,this._renderGBuffer=!0,this._visibilityCache=new Map,this.blendIntensity=1,this.pdRings=2,this.pdRadiusExponent=2,this.pdSamples=16,this.gtaoNoiseTexture=function(t=5){const e=Math.floor(t)%2==0?Math.floor(t)+1:Math.floor(t),n=function(t){const e=Math.floor(t)%2==0?Math.floor(t)+1:Math.floor(t),n=e*e,i=Array(n).fill(0);let r=Math.floor(e/2),s=e-1;for(let t=1;t<=n;)-1===r&&s===e?(s=e-2,r=0):(s===e&&(s=0),r<0&&(r=e-1)),0===i[r*e+s]?(i[r*e+s]=t++,s++,r--):(s-=2,r++);return i}(e),i=n.length,r=new Uint8Array(4*i);for(let t=0;t\n\t\t\t\tvarying vec2 vUv;\n\t\t\t\tuniform sampler2D colorTexture;\n\t\t\t\tuniform vec2 invSize;\n\t\t\t\tuniform vec2 direction;\n\t\t\t\tuniform float gaussianCoefficients[KERNEL_RADIUS];\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tfloat weightSum = gaussianCoefficients[0];\n\t\t\t\t\tvec3 diffuseSum = texture2D( colorTexture, vUv ).rgb * weightSum;\n\t\t\t\t\tfor( int i = 1; i < KERNEL_RADIUS; i ++ ) {\n\t\t\t\t\t\tfloat x = float(i);\n\t\t\t\t\t\tfloat w = gaussianCoefficients[i];\n\t\t\t\t\t\tvec2 uvOffset = direction * invSize * x;\n\t\t\t\t\t\tvec3 sample1 = texture2D( colorTexture, vUv + uvOffset ).rgb;\n\t\t\t\t\t\tvec3 sample2 = texture2D( colorTexture, vUv - uvOffset ).rgb;\n\t\t\t\t\t\tdiffuseSum += (sample1 + sample2) * w;\n\t\t\t\t\t\tweightSum += 2.0 * w;\n\t\t\t\t\t}\n\t\t\t\t\tgl_FragColor = vec4(diffuseSum/weightSum, 1.0);\n\t\t\t\t}"})}getCompositeMaterial(t){return new ra({defines:{NUM_MIPS:t},uniforms:{blurTexture1:{value:null},blurTexture2:{value:null},blurTexture3:{value:null},blurTexture4:{value:null},blurTexture5:{value:null},bloomStrength:{value:1},bloomFactors:{value:null},bloomTintColors:{value:null},bloomRadius:{value:0}},vertexShader:"varying vec2 vUv;\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"varying vec2 vUv;\n\t\t\t\tuniform sampler2D blurTexture1;\n\t\t\t\tuniform sampler2D blurTexture2;\n\t\t\t\tuniform sampler2D blurTexture3;\n\t\t\t\tuniform sampler2D blurTexture4;\n\t\t\t\tuniform sampler2D blurTexture5;\n\t\t\t\tuniform float bloomStrength;\n\t\t\t\tuniform float bloomRadius;\n\t\t\t\tuniform float bloomFactors[NUM_MIPS];\n\t\t\t\tuniform vec3 bloomTintColors[NUM_MIPS];\n\n\t\t\t\tfloat lerpBloomFactor(const in float factor) {\n\t\t\t\t\tfloat mirrorFactor = 1.2 - factor;\n\t\t\t\t\treturn mix(factor, mirrorFactor, bloomRadius);\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tgl_FragColor = bloomStrength * ( lerpBloomFactor(bloomFactors[0]) * vec4(bloomTintColors[0], 1.0) * texture2D(blurTexture1, vUv) +\n\t\t\t\t\t\tlerpBloomFactor(bloomFactors[1]) * vec4(bloomTintColors[1], 1.0) * texture2D(blurTexture2, vUv) +\n\t\t\t\t\t\tlerpBloomFactor(bloomFactors[2]) * vec4(bloomTintColors[2], 1.0) * texture2D(blurTexture3, vUv) +\n\t\t\t\t\t\tlerpBloomFactor(bloomFactors[3]) * vec4(bloomTintColors[3], 1.0) * texture2D(blurTexture4, vUv) +\n\t\t\t\t\t\tlerpBloomFactor(bloomFactors[4]) * vec4(bloomTintColors[4], 1.0) * texture2D(blurTexture5, vUv) );\n\t\t\t\t}"})}}Qm.BlurDirectionX=new ci(1,0),Qm.BlurDirectionY=new ci(0,1);const zm={name:"SobelOperatorShader",uniforms:{tDiffuse:{value:null},resolution:{value:new ci}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\tuniform sampler2D tDiffuse;\n\t\tuniform vec2 resolution;\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvec2 texel = vec2( 1.0 / resolution.x, 1.0 / resolution.y );\n\n\t\t// kernel definition (in glsl matrices are filled in column-major order)\n\n\t\t\tconst mat3 Gx = mat3( -1, -2, -1, 0, 0, 0, 1, 2, 1 ); // x direction kernel\n\t\t\tconst mat3 Gy = mat3( -1, 0, 1, -2, 0, 2, -1, 0, 1 ); // y direction kernel\n\n\t\t// fetch the 3x3 neighbourhood of a fragment\n\n\t\t// first column\n\n\t\t\tfloat tx0y0 = texture2D( tDiffuse, vUv + texel * vec2( -1, -1 ) ).r;\n\t\t\tfloat tx0y1 = texture2D( tDiffuse, vUv + texel * vec2( -1, 0 ) ).r;\n\t\t\tfloat tx0y2 = texture2D( tDiffuse, vUv + texel * vec2( -1, 1 ) ).r;\n\n\t\t// second column\n\n\t\t\tfloat tx1y0 = texture2D( tDiffuse, vUv + texel * vec2( 0, -1 ) ).r;\n\t\t\tfloat tx1y1 = texture2D( tDiffuse, vUv + texel * vec2( 0, 0 ) ).r;\n\t\t\tfloat tx1y2 = texture2D( tDiffuse, vUv + texel * vec2( 0, 1 ) ).r;\n\n\t\t// third column\n\n\t\t\tfloat tx2y0 = texture2D( tDiffuse, vUv + texel * vec2( 1, -1 ) ).r;\n\t\t\tfloat tx2y1 = texture2D( tDiffuse, vUv + texel * vec2( 1, 0 ) ).r;\n\t\t\tfloat tx2y2 = texture2D( tDiffuse, vUv + texel * vec2( 1, 1 ) ).r;\n\n\t\t// gradient value in x direction\n\n\t\t\tfloat valueGx = Gx[0][0] * tx0y0 + Gx[1][0] * tx1y0 + Gx[2][0] * tx2y0 +\n\t\t\t\tGx[0][1] * tx0y1 + Gx[1][1] * tx1y1 + Gx[2][1] * tx2y1 +\n\t\t\t\tGx[0][2] * tx0y2 + Gx[1][2] * tx1y2 + Gx[2][2] * tx2y2;\n\n\t\t// gradient value in y direction\n\n\t\t\tfloat valueGy = Gy[0][0] * tx0y0 + Gy[1][0] * tx1y0 + Gy[2][0] * tx2y0 +\n\t\t\t\tGy[0][1] * tx0y1 + Gy[1][1] * tx1y1 + Gy[2][1] * tx2y1 +\n\t\t\t\tGy[0][2] * tx0y2 + Gy[1][2] * tx1y2 + Gy[2][2] * tx2y2;\n\n\t\t// magnitute of the total gradient\n\n\t\t\tfloat G = sqrt( ( valueGx * valueGx ) + ( valueGy * valueGy ) );\n\n\t\t\tgl_FragColor = vec4( vec3( G ), 1 );\n\n\t\t}"},Gm={name:"SSRShader",defines:{MAX_STEP:0,PERSPECTIVE_CAMERA:!0,DISTANCE_ATTENUATION:!0,FRESNEL:!0,INFINITE_THICK:!1,SELECTIVE:!1},uniforms:{tDiffuse:{value:null},tNormal:{value:null},tMetalness:{value:null},tDepth:{value:null},cameraNear:{value:null},cameraFar:{value:null},resolution:{value:new ci},cameraProjectionMatrix:{value:new vr},cameraInverseProjectionMatrix:{value:new vr},opacity:{value:.5},maxDistance:{value:180},cameraRange:{value:0},thickness:{value:.018}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}\n\n\t",fragmentShader:'\n\t\t// precision highp float;\n\t\tprecision highp sampler2D;\n\t\tvarying vec2 vUv;\n\t\tuniform sampler2D tDepth;\n\t\tuniform sampler2D tNormal;\n\t\tuniform sampler2D tMetalness;\n\t\tuniform sampler2D tDiffuse;\n\t\tuniform float cameraRange;\n\t\tuniform vec2 resolution;\n\t\tuniform float opacity;\n\t\tuniform float cameraNear;\n\t\tuniform float cameraFar;\n\t\tuniform float maxDistance;\n\t\tuniform float thickness;\n\t\tuniform mat4 cameraProjectionMatrix;\n\t\tuniform mat4 cameraInverseProjectionMatrix;\n\t\t#include \n\t\tfloat pointToLineDistance(vec3 x0, vec3 x1, vec3 x2) {\n\t\t\t//x0: point, x1: linePointA, x2: linePointB\n\t\t\t//https://mathworld.wolfram.com/Point-LineDistance3-Dimensional.html\n\t\t\treturn length(cross(x0-x1,x0-x2))/length(x2-x1);\n\t\t}\n\t\tfloat pointPlaneDistance(vec3 point,vec3 planePoint,vec3 planeNormal){\n\t\t\t// https://mathworld.wolfram.com/Point-PlaneDistance.html\n\t\t\t//// https://en.wikipedia.org/wiki/Plane_(geometry)\n\t\t\t//// http://paulbourke.net/geometry/pointlineplane/\n\t\t\tfloat a=planeNormal.x,b=planeNormal.y,c=planeNormal.z;\n\t\t\tfloat x0=point.x,y0=point.y,z0=point.z;\n\t\t\tfloat x=planePoint.x,y=planePoint.y,z=planePoint.z;\n\t\t\tfloat d=-(a*x+b*y+c*z);\n\t\t\tfloat distance=(a*x0+b*y0+c*z0+d)/sqrt(a*a+b*b+c*c);\n\t\t\treturn distance;\n\t\t}\n\t\tfloat getDepth( const in vec2 uv ) {\n\t\t\treturn texture2D( tDepth, uv ).x;\n\t\t}\n\t\tfloat getViewZ( const in float depth ) {\n\t\t\t#ifdef PERSPECTIVE_CAMERA\n\t\t\t\treturn perspectiveDepthToViewZ( depth, cameraNear, cameraFar );\n\t\t\t#else\n\t\t\t\treturn orthographicDepthToViewZ( depth, cameraNear, cameraFar );\n\t\t\t#endif\n\t\t}\n\t\tvec3 getViewPosition( const in vec2 uv, const in float depth/*clip space*/, const in float clipW ) {\n\t\t\tvec4 clipPosition = vec4( ( vec3( uv, depth ) - 0.5 ) * 2.0, 1.0 );//ndc\n\t\t\tclipPosition *= clipW; //clip\n\t\t\treturn ( cameraInverseProjectionMatrix * clipPosition ).xyz;//view\n\t\t}\n\t\tvec3 getViewNormal( const in vec2 uv ) {\n\t\t\treturn unpackRGBToNormal( texture2D( tNormal, uv ).xyz );\n\t\t}\n\t\tvec2 viewPositionToXY(vec3 viewPosition){\n\t\t\tvec2 xy;\n\t\t\tvec4 clip=cameraProjectionMatrix*vec4(viewPosition,1);\n\t\t\txy=clip.xy;//clip\n\t\t\tfloat clipW=clip.w;\n\t\t\txy/=clipW;//NDC\n\t\t\txy=(xy+1.)/2.;//uv\n\t\t\txy*=resolution;//screen\n\t\t\treturn xy;\n\t\t}\n\t\tvoid main(){\n\t\t\t#ifdef SELECTIVE\n\t\t\t\tfloat metalness=texture2D(tMetalness,vUv).r;\n\t\t\t\tif(metalness==0.) return;\n\t\t\t#endif\n\n\t\t\tfloat depth = getDepth( vUv );\n\t\t\tfloat viewZ = getViewZ( depth );\n\t\t\tif(-viewZ>=cameraFar) return;\n\n\t\t\tfloat clipW = cameraProjectionMatrix[2][3] * viewZ+cameraProjectionMatrix[3][3];\n\t\t\tvec3 viewPosition=getViewPosition( vUv, depth, clipW );\n\n\t\t\tvec2 d0=gl_FragCoord.xy;\n\t\t\tvec2 d1;\n\n\t\t\tvec3 viewNormal=getViewNormal( vUv );\n\n\t\t\t#ifdef PERSPECTIVE_CAMERA\n\t\t\t\tvec3 viewIncidentDir=normalize(viewPosition);\n\t\t\t\tvec3 viewReflectDir=reflect(viewIncidentDir,viewNormal);\n\t\t\t#else\n\t\t\t\tvec3 viewIncidentDir=vec3(0,0,-1);\n\t\t\t\tvec3 viewReflectDir=reflect(viewIncidentDir,viewNormal);\n\t\t\t#endif\n\n\t\t\tfloat maxReflectRayLen=maxDistance/dot(-viewIncidentDir,viewNormal);\n\t\t\t// dot(a,b)==length(a)*length(b)*cos(theta) // https://www.mathsisfun.com/algebra/vectors-dot-product.html\n\t\t\t// if(a.isNormalized&&b.isNormalized) dot(a,b)==cos(theta)\n\t\t\t// maxDistance/maxReflectRayLen=cos(theta)\n\t\t\t// maxDistance/maxReflectRayLen==dot(a,b)\n\t\t\t// maxReflectRayLen==maxDistance/dot(a,b)\n\n\t\t\tvec3 d1viewPosition=viewPosition+viewReflectDir*maxReflectRayLen;\n\t\t\t#ifdef PERSPECTIVE_CAMERA\n\t\t\t\tif(d1viewPosition.z>-cameraNear){\n\t\t\t\t\t//https://tutorial.math.lamar.edu/Classes/CalcIII/EqnsOfLines.aspx\n\t\t\t\t\tfloat t=(-cameraNear-viewPosition.z)/viewReflectDir.z;\n\t\t\t\t\td1viewPosition=viewPosition+viewReflectDir*t;\n\t\t\t\t}\n\t\t\t#endif\n\t\t\td1=viewPositionToXY(d1viewPosition);\n\n\t\t\tfloat totalLen=length(d1-d0);\n\t\t\tfloat xLen=d1.x-d0.x;\n\t\t\tfloat yLen=d1.y-d0.y;\n\t\t\tfloat totalStep=max(abs(xLen),abs(yLen));\n\t\t\tfloat xSpan=xLen/totalStep;\n\t\t\tfloat ySpan=yLen/totalStep;\n\t\t\tfor(float i=0.;i=totalStep) break;\n\t\t\t\tvec2 xy=vec2(d0.x+i*xSpan,d0.y+i*ySpan);\n\t\t\t\tif(xy.x<0.||xy.x>resolution.x||xy.y<0.||xy.y>resolution.y) break;\n\t\t\t\tfloat s=length(xy-d0)/totalLen;\n\t\t\t\tvec2 uv=xy/resolution;\n\n\t\t\t\tfloat d = getDepth(uv);\n\t\t\t\tfloat vZ = getViewZ( d );\n\t\t\t\tif(-vZ>=cameraFar) continue;\n\t\t\t\tfloat cW = cameraProjectionMatrix[2][3] * vZ+cameraProjectionMatrix[3][3];\n\t\t\t\tvec3 vP=getViewPosition( uv, d, cW );\n\n\t\t\t\t#ifdef PERSPECTIVE_CAMERA\n\t\t\t\t\t// https://comp.nus.edu.sg/~lowkl/publications/lowk_persp_interp_techrep.pdf\n\t\t\t\t\tfloat recipVPZ=1./viewPosition.z;\n\t\t\t\t\tfloat viewReflectRayZ=1./(recipVPZ+s*(1./d1viewPosition.z-recipVPZ));\n\t\t\t\t#else\n\t\t\t\t\tfloat viewReflectRayZ=viewPosition.z+s*(d1viewPosition.z-viewPosition.z);\n\t\t\t\t#endif\n\n\t\t\t\t// if(viewReflectRayZ>vZ) continue; // will cause "npm run make-screenshot webgl_postprocessing_ssr" high probability hang.\n\t\t\t\t// https://github.com/mrdoob/three.js/pull/21539#issuecomment-821061164\n\t\t\t\tif(viewReflectRayZ<=vZ){\n\n\t\t\t\t\tbool hit;\n\t\t\t\t\t#ifdef INFINITE_THICK\n\t\t\t\t\t\thit=true;\n\t\t\t\t\t#else\n\t\t\t\t\t\tfloat away=pointToLineDistance(vP,viewPosition,d1viewPosition);\n\n\t\t\t\t\t\tfloat minThickness;\n\t\t\t\t\t\tvec2 xyNeighbor=xy;\n\t\t\t\t\t\txyNeighbor.x+=1.;\n\t\t\t\t\t\tvec2 uvNeighbor=xyNeighbor/resolution;\n\t\t\t\t\t\tvec3 vPNeighbor=getViewPosition(uvNeighbor,d,cW);\n\t\t\t\t\t\tminThickness=vPNeighbor.x-vP.x;\n\t\t\t\t\t\tminThickness*=3.;\n\t\t\t\t\t\tfloat tk=max(minThickness,thickness);\n\n\t\t\t\t\t\thit=away<=tk;\n\t\t\t\t\t#endif\n\n\t\t\t\t\tif(hit){\n\t\t\t\t\t\tvec3 vN=getViewNormal( uv );\n\t\t\t\t\t\tif(dot(viewReflectDir,vN)>=0.) continue;\n\t\t\t\t\t\tfloat distance=pointPlaneDistance(vP,viewPosition,viewNormal);\n\t\t\t\t\t\tif(distance>maxDistance) break;\n\t\t\t\t\t\tfloat op=opacity;\n\t\t\t\t\t\t#ifdef DISTANCE_ATTENUATION\n\t\t\t\t\t\t\tfloat ratio=1.-(distance/maxDistance);\n\t\t\t\t\t\t\tfloat attenuation=ratio*ratio;\n\t\t\t\t\t\t\top=opacity*attenuation;\n\t\t\t\t\t\t#endif\n\t\t\t\t\t\t#ifdef FRESNEL\n\t\t\t\t\t\t\tfloat fresnelCoe=(dot(viewIncidentDir,viewReflectDir)+1.)/2.;\n\t\t\t\t\t\t\top*=fresnelCoe;\n\t\t\t\t\t\t#endif\n\t\t\t\t\t\tvec4 reflectColor=texture2D(tDiffuse,uv);\n\t\t\t\t\t\tgl_FragColor.xyz=reflectColor.xyz;\n\t\t\t\t\t\tgl_FragColor.a=op;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t'},Hm={PERSPECTIVE_CAMERA:1},Vm={tDepth:{value:null},cameraNear:{value:null},cameraFar:{value:null}},Wm="\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}\n\n\t",jm="\n\n\t\tuniform sampler2D tDepth;\n\n\t\tuniform float cameraNear;\n\t\tuniform float cameraFar;\n\n\t\tvarying vec2 vUv;\n\n\t\t#include \n\n\t\tfloat getLinearDepth( const in vec2 uv ) {\n\n\t\t\t#if PERSPECTIVE_CAMERA == 1\n\n\t\t\t\tfloat fragCoordZ = texture2D( tDepth, uv ).x;\n\t\t\t\tfloat viewZ = perspectiveDepthToViewZ( fragCoordZ, cameraNear, cameraFar );\n\t\t\t\treturn viewZToOrthographicDepth( viewZ, cameraNear, cameraFar );\n\n\t\t\t#else\n\n\t\t\t\treturn texture2D( tDepth, uv ).x;\n\n\t\t\t#endif\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tfloat depth = getLinearDepth( vUv );\n\t\t\tfloat d = 1.0 - depth;\n\t\t\t// d=(d-.999)*1000.;\n\t\t\tgl_FragColor = vec4( vec3( d ), 1.0 );\n\n\t\t}\n\n\t",qm={name:"SSRBlurShader",uniforms:{tDiffuse:{value:null},resolution:{value:new ci},opacity:{value:.5}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}\n\n\t",fragmentShader:"\n\n\t\tuniform sampler2D tDiffuse;\n\t\tuniform vec2 resolution;\n\t\tvarying vec2 vUv;\n\t\tvoid main() {\n\t\t\t//reverse engineering from PhotoShop blur filter, then change coefficient\n\n\t\t\tvec2 texelSize = ( 1.0 / resolution );\n\n\t\t\tvec4 c=texture2D(tDiffuse,vUv);\n\n\t\t\tvec2 offset;\n\n\t\t\toffset=(vec2(-1,0))*texelSize;\n\t\t\tvec4 cl=texture2D(tDiffuse,vUv+offset);\n\n\t\t\toffset=(vec2(1,0))*texelSize;\n\t\t\tvec4 cr=texture2D(tDiffuse,vUv+offset);\n\n\t\t\toffset=(vec2(0,-1))*texelSize;\n\t\t\tvec4 cb=texture2D(tDiffuse,vUv+offset);\n\n\t\t\toffset=(vec2(0,1))*texelSize;\n\t\t\tvec4 ct=texture2D(tDiffuse,vUv+offset);\n\n\t\t\t// float coeCenter=.5;\n\t\t\t// float coeSide=.125;\n\t\t\tfloat coeCenter=.2;\n\t\t\tfloat coeSide=.2;\n\t\t\tfloat a=c.a*coeCenter+cl.a*coeSide+cr.a*coeSide+cb.a*coeSide+ct.a*coeSide;\n\t\t\tvec3 rgb=(c.rgb*c.a*coeCenter+cl.rgb*cl.a*coeSide+cr.rgb*cr.a*coeSide+cb.rgb*cb.a*coeSide+ct.rgb*ct.a*coeSide)/a;\n\t\t\tgl_FragColor=vec4(rgb,a);\n\n\t\t}\n\t"};class Xm extends mm{constructor({renderer:t,scene:e,camera:n,width:i,height:r,selects:s,bouncing:a=!1,groundReflector:o}){super(),this.width=void 0!==i?i:512,this.height=void 0!==r?r:512,this.clear=!0,this.renderer=t,this.scene=e,this.camera=n,this.groundReflector=o,this.opacity=Gm.uniforms.opacity.value,this.output=0,this.maxDistance=Gm.uniforms.maxDistance.value,this.thickness=Gm.uniforms.thickness.value,this.tempColor=new hs,this._selects=s,this.selective=Array.isArray(this._selects),Object.defineProperty(this,"selects",{get(){return this._selects},set(t){this._selects!==t&&(this._selects=t,Array.isArray(t)?(this.selective=!0,this.ssrMaterial.defines.SELECTIVE=!0,this.ssrMaterial.needsUpdate=!0):(this.selective=!1,this.ssrMaterial.defines.SELECTIVE=!1,this.ssrMaterial.needsUpdate=!0))}}),this._bouncing=a,Object.defineProperty(this,"bouncing",{get(){return this._bouncing},set(t){this._bouncing!==t&&(this._bouncing=t,this.ssrMaterial.uniforms.tDiffuse.value=t?this.prevRenderTarget.texture:this.beautyRenderTarget.texture)}}),this.blur=!0,this._distanceAttenuation=Gm.defines.DISTANCE_ATTENUATION,Object.defineProperty(this,"distanceAttenuation",{get(){return this._distanceAttenuation},set(t){this._distanceAttenuation!==t&&(this._distanceAttenuation=t,this.ssrMaterial.defines.DISTANCE_ATTENUATION=t,this.ssrMaterial.needsUpdate=!0)}}),this._fresnel=Gm.defines.FRESNEL,Object.defineProperty(this,"fresnel",{get(){return this._fresnel},set(t){this._fresnel!==t&&(this._fresnel=t,this.ssrMaterial.defines.FRESNEL=t,this.ssrMaterial.needsUpdate=!0)}}),this._infiniteThick=Gm.defines.INFINITE_THICK,Object.defineProperty(this,"infiniteThick",{get(){return this._infiniteThick},set(t){this._infiniteThick!==t&&(this._infiniteThick=t,this.ssrMaterial.defines.INFINITE_THICK=t,this.ssrMaterial.needsUpdate=!0)}});const l=new so;l.type=Gt,l.minFilter=Tt,l.magFilter=Tt,this.beautyRenderTarget=new Ni(this.width,this.height,{minFilter:Tt,magFilter:Tt,type:jt,depthTexture:l,depthBuffer:!0}),this.prevRenderTarget=new Ni(this.width,this.height,{minFilter:Tt,magFilter:Tt}),this.normalRenderTarget=new Ni(this.width,this.height,{minFilter:Tt,magFilter:Tt,type:jt}),this.metalnessRenderTarget=new Ni(this.width,this.height,{minFilter:Tt,magFilter:Tt,type:jt}),this.ssrRenderTarget=new Ni(this.width,this.height,{minFilter:Tt,magFilter:Tt}),this.blurRenderTarget=this.ssrRenderTarget.clone(),this.blurRenderTarget2=this.ssrRenderTarget.clone(),this.ssrMaterial=new ra({defines:Object.assign({},Gm.defines,{MAX_STEP:Math.sqrt(this.width*this.width+this.height*this.height)}),uniforms:ia.clone(Gm.uniforms),vertexShader:Gm.vertexShader,fragmentShader:Gm.fragmentShader,blending:S}),this.ssrMaterial.uniforms.tDiffuse.value=this.beautyRenderTarget.texture,this.ssrMaterial.uniforms.tNormal.value=this.normalRenderTarget.texture,this.ssrMaterial.defines.SELECTIVE=this.selective,this.ssrMaterial.needsUpdate=!0,this.ssrMaterial.uniforms.tMetalness.value=this.metalnessRenderTarget.texture,this.ssrMaterial.uniforms.tDepth.value=this.beautyRenderTarget.depthTexture,this.ssrMaterial.uniforms.cameraNear.value=this.camera.near,this.ssrMaterial.uniforms.cameraFar.value=this.camera.far,this.ssrMaterial.uniforms.thickness.value=this.thickness,this.ssrMaterial.uniforms.resolution.value.set(this.width,this.height),this.ssrMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.ssrMaterial.uniforms.cameraInverseProjectionMatrix.value.copy(this.camera.projectionMatrixInverse),this.normalMaterial=new bd,this.normalMaterial.blending=S,this.metalnessOnMaterial=new fs({color:"white"}),this.metalnessOffMaterial=new fs({color:"black"}),this.blurMaterial=new ra({defines:Object.assign({},qm.defines),uniforms:ia.clone(qm.uniforms),vertexShader:qm.vertexShader,fragmentShader:qm.fragmentShader}),this.blurMaterial.uniforms.tDiffuse.value=this.ssrRenderTarget.texture,this.blurMaterial.uniforms.resolution.value.set(this.width,this.height),this.blurMaterial2=new ra({defines:Object.assign({},qm.defines),uniforms:ia.clone(qm.uniforms),vertexShader:qm.vertexShader,fragmentShader:qm.fragmentShader}),this.blurMaterial2.uniforms.tDiffuse.value=this.blurRenderTarget.texture,this.blurMaterial2.uniforms.resolution.value.set(this.width,this.height),this.depthRenderMaterial=new ra({defines:Object.assign({},Hm),uniforms:ia.clone(Vm),vertexShader:Wm,fragmentShader:jm,blending:S}),this.depthRenderMaterial.uniforms.tDepth.value=this.beautyRenderTarget.depthTexture,this.depthRenderMaterial.uniforms.cameraNear.value=this.camera.near,this.depthRenderMaterial.uniforms.cameraFar.value=this.camera.far,this.copyMaterial=new ra({uniforms:ia.clone(fm.uniforms),vertexShader:fm.vertexShader,fragmentShader:fm.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blendSrc:G,blendDst:H,blendEquation:P,blendSrcAlpha:G,blendDstAlpha:H,blendEquationAlpha:P}),this.fsQuad=new vm(null),this.originalClearColor=new hs}dispose(){this.beautyRenderTarget.dispose(),this.prevRenderTarget.dispose(),this.normalRenderTarget.dispose(),this.metalnessRenderTarget.dispose(),this.ssrRenderTarget.dispose(),this.blurRenderTarget.dispose(),this.blurRenderTarget2.dispose(),this.normalMaterial.dispose(),this.metalnessOnMaterial.dispose(),this.metalnessOffMaterial.dispose(),this.blurMaterial.dispose(),this.blurMaterial2.dispose(),this.copyMaterial.dispose(),this.depthRenderMaterial.dispose(),this.fsQuad.dispose()}render(t,e){switch(t.setRenderTarget(this.beautyRenderTarget),t.clear(),this.groundReflector&&(this.groundReflector.visible=!1,this.groundReflector.doRender(this.renderer,this.scene,this.camera),this.groundReflector.visible=!0),t.render(this.scene,this.camera),this.groundReflector&&(this.groundReflector.visible=!1),this.renderOverride(t,this.normalMaterial,this.normalRenderTarget,0,0),this.selective&&this.renderMetalness(t,this.metalnessOnMaterial,this.metalnessRenderTarget,0,0),this.ssrMaterial.uniforms.opacity.value=this.opacity,this.ssrMaterial.uniforms.maxDistance.value=this.maxDistance,this.ssrMaterial.uniforms.thickness.value=this.thickness,this.renderPass(t,this.ssrMaterial,this.ssrRenderTarget),this.blur&&(this.renderPass(t,this.blurMaterial,this.blurRenderTarget),this.renderPass(t,this.blurMaterial2,this.blurRenderTarget2)),this.output){case Xm.OUTPUT.Default:this.bouncing?(this.copyMaterial.uniforms.tDiffuse.value=this.beautyRenderTarget.texture,this.copyMaterial.blending=S,this.renderPass(t,this.copyMaterial,this.prevRenderTarget),this.blur?this.copyMaterial.uniforms.tDiffuse.value=this.blurRenderTarget2.texture:this.copyMaterial.uniforms.tDiffuse.value=this.ssrRenderTarget.texture,this.copyMaterial.blending=I,this.renderPass(t,this.copyMaterial,this.prevRenderTarget),this.copyMaterial.uniforms.tDiffuse.value=this.prevRenderTarget.texture,this.copyMaterial.blending=S,this.renderPass(t,this.copyMaterial,this.renderToScreen?null:e)):(this.copyMaterial.uniforms.tDiffuse.value=this.beautyRenderTarget.texture,this.copyMaterial.blending=S,this.renderPass(t,this.copyMaterial,this.renderToScreen?null:e),this.blur?this.copyMaterial.uniforms.tDiffuse.value=this.blurRenderTarget2.texture:this.copyMaterial.uniforms.tDiffuse.value=this.ssrRenderTarget.texture,this.copyMaterial.blending=I,this.renderPass(t,this.copyMaterial,this.renderToScreen?null:e));break;case Xm.OUTPUT.SSR:this.blur?this.copyMaterial.uniforms.tDiffuse.value=this.blurRenderTarget2.texture:this.copyMaterial.uniforms.tDiffuse.value=this.ssrRenderTarget.texture,this.copyMaterial.blending=S,this.renderPass(t,this.copyMaterial,this.renderToScreen?null:e),this.bouncing&&(this.blur?this.copyMaterial.uniforms.tDiffuse.value=this.blurRenderTarget2.texture:this.copyMaterial.uniforms.tDiffuse.value=this.beautyRenderTarget.texture,this.copyMaterial.blending=S,this.renderPass(t,this.copyMaterial,this.prevRenderTarget),this.copyMaterial.uniforms.tDiffuse.value=this.ssrRenderTarget.texture,this.copyMaterial.blending=I,this.renderPass(t,this.copyMaterial,this.prevRenderTarget));break;case Xm.OUTPUT.Beauty:this.copyMaterial.uniforms.tDiffuse.value=this.beautyRenderTarget.texture,this.copyMaterial.blending=S,this.renderPass(t,this.copyMaterial,this.renderToScreen?null:e);break;case Xm.OUTPUT.Depth:this.renderPass(t,this.depthRenderMaterial,this.renderToScreen?null:e);break;case Xm.OUTPUT.Normal:this.copyMaterial.uniforms.tDiffuse.value=this.normalRenderTarget.texture,this.copyMaterial.blending=S,this.renderPass(t,this.copyMaterial,this.renderToScreen?null:e);break;case Xm.OUTPUT.Metalness:this.copyMaterial.uniforms.tDiffuse.value=this.metalnessRenderTarget.texture,this.copyMaterial.blending=S,this.renderPass(t,this.copyMaterial,this.renderToScreen?null:e);break;default:console.warn("THREE.SSRPass: Unknown output type.")}}renderPass(t,e,n,i,r){this.originalClearColor.copy(t.getClearColor(this.tempColor));const s=t.getClearAlpha(this.tempColor),a=t.autoClear;t.setRenderTarget(n),t.autoClear=!1,null!=i&&(t.setClearColor(i),t.setClearAlpha(r||0),t.clear()),this.fsQuad.material=e,this.fsQuad.render(t),t.autoClear=a,t.setClearColor(this.originalClearColor),t.setClearAlpha(s)}renderOverride(t,e,n,i,r){this.originalClearColor.copy(t.getClearColor(this.tempColor));const s=t.getClearAlpha(this.tempColor),a=t.autoClear;t.setRenderTarget(n),t.autoClear=!1,i=e.clearColor||i,r=e.clearAlpha||r,null!=i&&(t.setClearColor(i),t.setClearAlpha(r||0),t.clear()),this.scene.overrideMaterial=e,t.render(this.scene,this.camera),this.scene.overrideMaterial=null,t.autoClear=a,t.setClearColor(this.originalClearColor),t.setClearAlpha(s)}renderMetalness(t,e,n,i,r){this.originalClearColor.copy(t.getClearColor(this.tempColor));const s=t.getClearAlpha(this.tempColor),a=t.autoClear,o=this.scene.background,l=this.scene.fog;t.setRenderTarget(n),t.autoClear=!1,this.scene.background=null,this.scene.fog=null,i=e.clearColor||i,r=e.clearAlpha||r,null!=i&&(t.setClearColor(i),t.setClearAlpha(r||0),t.clear()),this.scene.traverseVisible((t=>{t._SSRPassBackupMaterial=t.material,this._selects.includes(t)?t.material=this.metalnessOnMaterial:t.material=this.metalnessOffMaterial})),t.render(this.scene,this.camera),this.scene.traverseVisible((t=>{t.material=t._SSRPassBackupMaterial})),t.autoClear=a,t.setClearColor(this.originalClearColor),t.setClearAlpha(s),this.scene.background=o,this.scene.fog=l}setSize(t,e){this.width=t,this.height=e,this.ssrMaterial.defines.MAX_STEP=Math.sqrt(t*t+e*e),this.ssrMaterial.needsUpdate=!0,this.beautyRenderTarget.setSize(t,e),this.prevRenderTarget.setSize(t,e),this.ssrRenderTarget.setSize(t,e),this.normalRenderTarget.setSize(t,e),this.metalnessRenderTarget.setSize(t,e),this.blurRenderTarget.setSize(t,e),this.blurRenderTarget2.setSize(t,e),this.ssrMaterial.uniforms.resolution.value.set(t,e),this.ssrMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.ssrMaterial.uniforms.cameraInverseProjectionMatrix.value.copy(this.camera.projectionMatrixInverse),this.blurMaterial.uniforms.resolution.value.set(t,e),this.blurMaterial2.uniforms.resolution.value.set(t,e)}}Xm.OUTPUT={Default:0,SSR:1,Beauty:3,Depth:4,Normal:5,Metalness:7};const Ym={name:"BokehShader",defines:{DEPTH_PACKING:1,PERSPECTIVE_CAMERA:1},uniforms:{tColor:{value:null},tDepth:{value:null},focus:{value:1},aspect:{value:1},aperture:{value:.025},maxblur:{value:.01},nearClip:{value:1},farClip:{value:1e3}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\t#include \n\n\t\tvarying vec2 vUv;\n\n\t\tuniform sampler2D tColor;\n\t\tuniform sampler2D tDepth;\n\n\t\tuniform float maxblur; // max blur amount\n\t\tuniform float aperture; // aperture - bigger values for shallower depth of field\n\n\t\tuniform float nearClip;\n\t\tuniform float farClip;\n\n\t\tuniform float focus;\n\t\tuniform float aspect;\n\n\t\t#include \n\n\t\tfloat getDepth( const in vec2 screenPosition ) {\n\t\t\t#if DEPTH_PACKING == 1\n\t\t\treturn unpackRGBAToDepth( texture2D( tDepth, screenPosition ) );\n\t\t\t#else\n\t\t\treturn texture2D( tDepth, screenPosition ).x;\n\t\t\t#endif\n\t\t}\n\n\t\tfloat getViewZ( const in float depth ) {\n\t\t\t#if PERSPECTIVE_CAMERA == 1\n\t\t\treturn perspectiveDepthToViewZ( depth, nearClip, farClip );\n\t\t\t#else\n\t\t\treturn orthographicDepthToViewZ( depth, nearClip, farClip );\n\t\t\t#endif\n\t\t}\n\n\n\t\tvoid main() {\n\n\t\t\tvec2 aspectcorrect = vec2( 1.0, aspect );\n\n\t\t\tfloat viewZ = getViewZ( getDepth( vUv ) );\n\n\t\t\tfloat factor = ( focus + viewZ ); // viewZ is <= 0, so this is a difference equation\n\n\t\t\tvec2 dofblur = vec2 ( clamp( factor * aperture, -maxblur, maxblur ) );\n\n\t\t\tvec2 dofblur9 = dofblur * 0.9;\n\t\t\tvec2 dofblur7 = dofblur * 0.7;\n\t\t\tvec2 dofblur4 = dofblur * 0.4;\n\n\t\t\tvec4 col = vec4( 0.0 );\n\n\t\t\tcol += texture2D( tColor, vUv.xy );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.0, 0.4 ) * aspectcorrect ) * dofblur );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.15, 0.37 ) * aspectcorrect ) * dofblur );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.29, 0.29 ) * aspectcorrect ) * dofblur );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.37, 0.15 ) * aspectcorrect ) * dofblur );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.40, 0.0 ) * aspectcorrect ) * dofblur );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.37, -0.15 ) * aspectcorrect ) * dofblur );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.29, -0.29 ) * aspectcorrect ) * dofblur );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.15, -0.37 ) * aspectcorrect ) * dofblur );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.0, -0.4 ) * aspectcorrect ) * dofblur );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.15, 0.37 ) * aspectcorrect ) * dofblur );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.29, 0.29 ) * aspectcorrect ) * dofblur );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.37, 0.15 ) * aspectcorrect ) * dofblur );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.4, 0.0 ) * aspectcorrect ) * dofblur );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.37, -0.15 ) * aspectcorrect ) * dofblur );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.29, -0.29 ) * aspectcorrect ) * dofblur );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.15, -0.37 ) * aspectcorrect ) * dofblur );\n\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.15, 0.37 ) * aspectcorrect ) * dofblur9 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.37, 0.15 ) * aspectcorrect ) * dofblur9 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.37, -0.15 ) * aspectcorrect ) * dofblur9 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.15, -0.37 ) * aspectcorrect ) * dofblur9 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.15, 0.37 ) * aspectcorrect ) * dofblur9 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.37, 0.15 ) * aspectcorrect ) * dofblur9 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.37, -0.15 ) * aspectcorrect ) * dofblur9 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.15, -0.37 ) * aspectcorrect ) * dofblur9 );\n\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.29, 0.29 ) * aspectcorrect ) * dofblur7 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.40, 0.0 ) * aspectcorrect ) * dofblur7 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.29, -0.29 ) * aspectcorrect ) * dofblur7 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.0, -0.4 ) * aspectcorrect ) * dofblur7 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.29, 0.29 ) * aspectcorrect ) * dofblur7 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.4, 0.0 ) * aspectcorrect ) * dofblur7 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.29, -0.29 ) * aspectcorrect ) * dofblur7 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.0, 0.4 ) * aspectcorrect ) * dofblur7 );\n\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.29, 0.29 ) * aspectcorrect ) * dofblur4 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.4, 0.0 ) * aspectcorrect ) * dofblur4 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.29, -0.29 ) * aspectcorrect ) * dofblur4 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.0, -0.4 ) * aspectcorrect ) * dofblur4 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.29, 0.29 ) * aspectcorrect ) * dofblur4 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.4, 0.0 ) * aspectcorrect ) * dofblur4 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.29, -0.29 ) * aspectcorrect ) * dofblur4 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.0, 0.4 ) * aspectcorrect ) * dofblur4 );\n\n\t\t\tgl_FragColor = col / 41.0;\n\t\t\tgl_FragColor.a = 1.0;\n\n\t\t}"},Jm=new vr;class Km{constructor(t){t=t||{},this.zNear=!0===t.webGL?-1:0,this.vertices={near:[new Gi,new Gi,new Gi,new Gi],far:[new Gi,new Gi,new Gi,new Gi]},void 0!==t.projectionMatrix&&this.setFromProjectionMatrix(t.projectionMatrix,t.maxFar||1e4)}setFromProjectionMatrix(t,e){const n=this.zNear,i=0===t.elements[11];return Jm.copy(t).invert(),this.vertices.near[0].set(1,1,n),this.vertices.near[1].set(1,-1,n),this.vertices.near[2].set(-1,-1,n),this.vertices.near[3].set(-1,1,n),this.vertices.near.forEach((function(t){t.applyMatrix4(Jm)})),this.vertices.far[0].set(1,1,1),this.vertices.far[1].set(1,-1,1),this.vertices.far[2].set(-1,-1,1),this.vertices.far[3].set(-1,1,1),this.vertices.far.forEach((function(t){t.applyMatrix4(Jm);const n=Math.abs(t.z);i?t.z*=Math.min(e/n,1):t.multiplyScalar(Math.min(e/n,1))})),this.vertices}split(t,e){for(;t.length>e.length;)e.push(new Km);e.length=t.length;for(let n=0;n 0.0 ) {\n\t\tmaterial.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\t// Iridescence F0 approximation\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\n\nIncidentLight directLight;\n\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\n\t\tpointLight = pointLights[ i ];\n\n\t\tgetPointLightInfo( pointLight, geometryPosition, directLight );\n\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\n\tSpotLight spotLight;\n \tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\n\t\tspotLight = spotLights[ i ];\n\n\t\tgetSpotLightInfo( spotLight, geometryPosition, directLight );\n\n \t\t// spot lights are ordered [shadows with maps, shadows without maps, maps without shadows, none]\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\n\t\t#endif\n\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) && defined( USE_CSM ) && defined( CSM_CASCADES )\n\n\tDirectionalLight directionalLight;\n\tfloat linearDepth = (vViewPosition.z) / (shadowFar - cameraNear);\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\n\t#if defined( USE_SHADOWMAP ) && defined( CSM_FADE )\n\t\tvec2 cascade;\n\t\tfloat cascadeCenter;\n\t\tfloat closestEdge;\n\t\tfloat margin;\n\t\tfloat csmx;\n\t\tfloat csmy;\n\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\n\t\t\tdirectionalLight = directionalLights[ i ];\n\t\t\tgetDirectionalLightInfo( directionalLight, directLight );\n\n\t\t\t#if ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\t\t\t// NOTE: Depth gets larger away from the camera.\n\t\t\t\t// cascade.x is closer, cascade.y is further\n\t\t\t\tcascade = CSM_cascades[ i ];\n\t\t\t\tcascadeCenter = ( cascade.x + cascade.y ) / 2.0;\n\t\t\t\tclosestEdge = linearDepth < cascadeCenter ? cascade.x : cascade.y;\n\t\t\t\tmargin = 0.25 * pow( closestEdge, 2.0 );\n\t\t\t\tcsmx = cascade.x - margin / 2.0;\n\t\t\t\tcsmy = cascade.y + margin / 2.0;\n\t\t\t\tif( linearDepth >= csmx && ( linearDepth < csmy || UNROLLED_LOOP_INDEX == CSM_CASCADES - 1 ) ) {\n\n\t\t\t\t\tfloat dist = min( linearDepth - csmx, csmy - linearDepth );\n\t\t\t\t\tfloat ratio = clamp( dist / margin, 0.0, 1.0 );\n\n\t\t\t\t\tvec3 prevColor = directLight.color;\n\t\t\t\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\t\t\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\n\t\t\t\t\tbool shouldFadeLastCascade = UNROLLED_LOOP_INDEX == CSM_CASCADES - 1 && linearDepth > cascadeCenter;\n\t\t\t\t\tdirectLight.color = mix( prevColor, directLight.color, shouldFadeLastCascade ? ratio : 1.0 );\n\n\t\t\t\t\tReflectedLight prevLight = reflectedLight;\n\t\t\t\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\n\t\t\t\t\tbool shouldBlend = UNROLLED_LOOP_INDEX != CSM_CASCADES - 1 || UNROLLED_LOOP_INDEX == CSM_CASCADES - 1 && linearDepth < cascadeCenter;\n\t\t\t\t\tfloat blendRatio = shouldBlend ? ratio : 1.0;\n\n\t\t\t\t\treflectedLight.directDiffuse = mix( prevLight.directDiffuse, reflectedLight.directDiffuse, blendRatio );\n\t\t\t\t\treflectedLight.directSpecular = mix( prevLight.directSpecular, reflectedLight.directSpecular, blendRatio );\n\t\t\t\t\treflectedLight.indirectDiffuse = mix( prevLight.indirectDiffuse, reflectedLight.indirectDiffuse, blendRatio );\n\t\t\t\t\treflectedLight.indirectSpecular = mix( prevLight.indirectSpecular, reflectedLight.indirectSpecular, blendRatio );\n\n\t\t\t\t}\n\t\t\t#endif\n\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#elif defined (USE_SHADOWMAP)\n\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\n\t\t\tdirectionalLight = directionalLights[ i ];\n\t\t\tgetDirectionalLightInfo( directionalLight, directLight );\n\n\t\t\t#if ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\n\t\t\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\t\t\tif(linearDepth >= CSM_cascades[UNROLLED_LOOP_INDEX].x && linearDepth < CSM_cascades[UNROLLED_LOOP_INDEX].y) directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\n\t\t\t\tif(linearDepth >= CSM_cascades[UNROLLED_LOOP_INDEX].x && (linearDepth < CSM_cascades[UNROLLED_LOOP_INDEX].y || UNROLLED_LOOP_INDEX == CSM_CASCADES - 1)) RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\n\t\t\t#endif\n\n\t\t}\n\t\t#pragma unroll_loop_end\n\n\t#elif ( NUM_DIR_LIGHT_SHADOWS > 0 )\n\t\t// note: no loop here - all CSM lights are in fact one light only\n\t\tgetDirectionalLightInfo( directionalLights[0], directLight );\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\n\t#endif\n\n\t#if ( NUM_DIR_LIGHTS > NUM_DIR_LIGHT_SHADOWS)\n\t\t// compute the lights not casting shadows (if any)\n\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = NUM_DIR_LIGHT_SHADOWS; i < NUM_DIR_LIGHTS; i ++ ) {\n\n\t\t\tdirectionalLight = directionalLights[ i ];\n\n\t\t\tgetDirectionalLightInfo( directionalLight, directLight );\n\n\t\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\n\t\t}\n\t\t#pragma unroll_loop_end\n\n\t#endif\n\n#endif\n\n\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) && !defined( USE_CSM ) && !defined( CSM_CASCADES )\n\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\n\t\tdirectionalLight = directionalLights[ i ];\n\n\t\tgetDirectionalLightInfo( directionalLight, directLight );\n\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\n\tRectAreaLight rectAreaLight;\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n#if defined( RE_IndirectDiffuse )\n\n\tvec3 iblIrradiance = vec3( 0.0 );\n\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\n\t#if defined( USE_LIGHT_PROBES )\n\n\t\tirradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n\n\t#endif\n\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n\n\t\t}\n\t\t#pragma unroll_loop_end\n\n\t#endif\n\n#endif\n\n#if defined( RE_IndirectSpecular )\n\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n\n#endif\n",lights_pars_begin:"\n#if defined( USE_CSM ) && defined( CSM_CASCADES )\nuniform vec2 CSM_cascades[CSM_CASCADES];\nuniform float cameraNear;\nuniform float shadowFar;\n#endif\n\t"+Ea.lights_pars_begin},$m=new vr,tg=new Km({webGL:!0}),eg=new Gi,ng=new Wi,ig=[],rg=[],sg=new vr,ag=new vr,og=new Gi(0,1,0),lg={type:"change"},cg={type:"start"},hg={type:"end"},ug=new Ar,dg=new Aa,pg=Math.cos(70*li.DEG2RAD),fg=new Gi,mg=2*Math.PI,gg=-1,Ag=1e-6;function vg(t){!1!==this.enabled&&(0===this._pointers.length&&(this.domElement.setPointerCapture(t.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),this._isTrackingPointer(t)||(this._addPointer(t),"touch"===t.pointerType?this._onTouchStart(t):this._onMouseDown(t)))}function yg(t){!1!==this.enabled&&("touch"===t.pointerType?this._onTouchMove(t):this._onMouseMove(t))}function _g(t){switch(this._removePointer(t),this._pointers.length){case 0:this.domElement.releasePointerCapture(t.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(hg),this.state=gg;break;case 1:const e=this._pointers[0],n=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:n.x,pageY:n.y})}}function xg(t){let e;switch(t.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case f.DOLLY:if(!1===this.enableZoom)return;this._handleMouseDownDolly(t),this.state=1;break;case f.ROTATE:if(t.ctrlKey||t.metaKey||t.shiftKey){if(!1===this.enablePan)return;this._handleMouseDownPan(t),this.state=2}else{if(!1===this.enableRotate)return;this._handleMouseDownRotate(t),this.state=0}break;case f.PAN:if(t.ctrlKey||t.metaKey||t.shiftKey){if(!1===this.enableRotate)return;this._handleMouseDownRotate(t),this.state=0}else{if(!1===this.enablePan)return;this._handleMouseDownPan(t),this.state=2}break;default:this.state=gg}this.state!==gg&&this.dispatchEvent(cg)}function wg(t){switch(this.state){case 0:if(!1===this.enableRotate)return;this._handleMouseMoveRotate(t);break;case 1:if(!1===this.enableZoom)return;this._handleMouseMoveDolly(t);break;case 2:if(!1===this.enablePan)return;this._handleMouseMovePan(t)}}function Cg(t){!1!==this.enabled&&!1!==this.enableZoom&&this.state===gg&&(t.preventDefault(),this.dispatchEvent(cg),this._handleMouseWheel(this._customWheelEvent(t)),this.dispatchEvent(hg))}function Eg(t){!1!==this.enabled&&!1!==this.enablePan&&this._handleKeyDown(t)}function Mg(t){switch(this._trackPointer(t),this._pointers.length){case 1:switch(this.touches.ONE){case m.ROTATE:if(!1===this.enableRotate)return;this._handleTouchStartRotate(t),this.state=3;break;case m.PAN:if(!1===this.enablePan)return;this._handleTouchStartPan(t),this.state=4;break;default:this.state=gg}break;case 2:switch(this.touches.TWO){case m.DOLLY_PAN:if(!1===this.enableZoom&&!1===this.enablePan)return;this._handleTouchStartDollyPan(t),this.state=5;break;case m.DOLLY_ROTATE:if(!1===this.enableZoom&&!1===this.enableRotate)return;this._handleTouchStartDollyRotate(t),this.state=6;break;default:this.state=gg}break;default:this.state=gg}this.state!==gg&&this.dispatchEvent(cg)}function bg(t){switch(this._trackPointer(t),this.state){case 3:if(!1===this.enableRotate)return;this._handleTouchMoveRotate(t),this.update();break;case 4:if(!1===this.enablePan)return;this._handleTouchMovePan(t),this.update();break;case 5:if(!1===this.enableZoom&&!1===this.enablePan)return;this._handleTouchMoveDollyPan(t),this.update();break;case 6:if(!1===this.enableZoom&&!1===this.enableRotate)return;this._handleTouchMoveDollyRotate(t),this.update();break;default:this.state=gg}}function Sg(t){!1!==this.enabled&&t.preventDefault()}function Ig(t){"Control"===t.key&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function Tg(t){"Control"===t.key&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function Bg(t,e=!1){const n=null!==t[0].index,i=new Set(Object.keys(t[0].attributes)),r=new Set(Object.keys(t[0].morphAttributes)),s={},a={},o=t[0].morphTargetsRelative,l=new ks;let c=0;for(let h=0;h=2.0 are supported.")));const l=new EA(r,{path:e||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let t=0;t=0&&void 0===a[e]&&console.warn('THREE.GLTFLoader: Unknown extension "'+e+'".')}}l.setExtensions(s),l.setPlugins(a),l.parse(n,i)}parseAsync(t,e){const n=this;return new Promise((function(i,r){n.parse(t,e,i,r)}))}}function Ug(){let t={};return{get:function(e){return t[e]},add:function(e,n){t[e]=n},remove:function(e){delete t[e]},removeAll:function(){t={}}}}const Ng={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_DISPERSION:"KHR_materials_dispersion",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 Fg{constructor(t){this.parser=t,this.name=Ng.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const t=this.parser,e=this.parser.json.nodes||[];for(let n=0,i=e.length;n=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return e.loadTextureImage(t,r.source,s)}}class Kg{constructor(t){this.parser=t,this.name=Ng.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(t){const e=this.name,n=this.parser,i=n.json,r=i.textures[t];if(!r.extensions||!r.extensions[e])return null;const s=r.extensions[e],a=i.images[s.source];let o=n.textureLoader;if(a.uri){const t=n.options.manager.getHandler(a.uri);null!==t&&(o=t)}return this.detectSupport().then((function(r){if(r)return n.loadTextureImage(t,s.source,o);if(i.extensionsRequired&&i.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(t)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(t){const e=new Image;e.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",e.onload=e.onerror=function(){t(1===e.height)}}))),this.isSupported}}class Zg{constructor(t){this.parser=t,this.name=Ng.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(t){const e=this.name,n=this.parser,i=n.json,r=i.textures[t];if(!r.extensions||!r.extensions[e])return null;const s=r.extensions[e],a=i.images[s.source];let o=n.textureLoader;if(a.uri){const t=n.options.manager.getHandler(a.uri);null!==t&&(o=t)}return this.detectSupport().then((function(r){if(r)return n.loadTextureImage(t,s.source,o);if(i.extensionsRequired&&i.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(t)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(t){const e=new Image;e.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",e.onload=e.onerror=function(){t(1===e.height)}}))),this.isSupported}}class $g{constructor(t){this.name=Ng.EXT_MESHOPT_COMPRESSION,this.parser=t}loadBufferView(t){const e=this.parser.json,n=e.bufferViews[t];if(n.extensions&&n.extensions[this.name]){const t=n.extensions[this.name],i=this.parser.getDependency("buffer",t.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(e.extensionsRequired&&e.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return i.then((function(e){const n=t.byteOffset||0,i=t.byteLength||0,s=t.count,a=t.byteStride,o=new Uint8Array(e,n,i);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(s,a,o,t.mode,t.filter).then((function(t){return t.buffer})):r.ready.then((function(){const e=new ArrayBuffer(s*a);return r.decodeGltfBuffer(new Uint8Array(e),s,a,o,t.mode,t.filter),e}))}))}return null}}class tA{constructor(t){this.name=Ng.EXT_MESH_GPU_INSTANCING,this.parser=t}createNodeMesh(t){const e=this.parser.json,n=e.nodes[t];if(!n.extensions||!n.extensions[this.name]||void 0===n.mesh)return null;const i=e.meshes[n.mesh];for(const t of i.primitives)if(t.mode!==cA.TRIANGLES&&t.mode!==cA.TRIANGLE_STRIP&&t.mode!==cA.TRIANGLE_FAN&&void 0!==t.mode)return null;const r=n.extensions[this.name].attributes,s=[],a={};for(const t in r)s.push(this.parser.getDependency("accessor",r[t]).then((e=>(a[t]=e,a[t]))));return s.length<1?null:(s.push(this.parser.createNodeMesh(t)),Promise.all(s).then((t=>{const e=t.pop(),n=e.isGroup?e.children:[e],i=t[0].count,r=[];for(const t of n){const e=new vr,n=new Gi,s=new zi,o=new Gi(1,1,1),l=new ah(t.geometry,t.material,i);for(let t=0;t-1,s=r?t.match(/Firefox\/([0-9]+)\./)[1]:-1}"undefined"==typeof createImageBitmap||n&&i<17||r&&s<98?this.textureLoader=new lp(this.options.manager):this.textureLoader=new Np(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new np(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(t){this.extensions=t}setPlugins(t){this.plugins=t}parse(t,e){const n=this,i=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll((function(t){return t._markDefs&&t._markDefs()})),Promise.all(this._invokeAll((function(t){return t.beforeRoot&&t.beforeRoot()}))).then((function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])})).then((function(e){const s={scene:e[0][i.scene||0],scenes:e[0],animations:e[1],cameras:e[2],asset:i.asset,parser:n,userData:{}};return AA(r,s,i),vA(s,i),Promise.all(n._invokeAll((function(t){return t.afterRoot&&t.afterRoot(s)}))).then((function(){for(const t of s.scenes)t.updateMatrixWorld();t(s)}))})).catch(e)}_markDefs(){const t=this.json.nodes||[],e=this.json.skins||[],n=this.json.meshes||[];for(let n=0,i=e.length;n{const n=this.associations.get(t);null!=n&&this.associations.set(e,n);for(const[n,i]of t.children.entries())r(i,e.children[n])};return r(n,i),i.name+="_instance_"+t.uses[e]++,i}_invokeOne(t){const e=Object.values(this.plugins);e.push(this);for(let n=0;n=2&&p.setY(e,h[t*s+1]),s>=3&&p.setZ(e,h[t*s+2]),s>=4&&p.setW(e,h[t*s+3]),s>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}p.normalized=u}return p}))}loadTexture(t){const e=this.json,n=this.options,i=e.textures[t].source,r=e.images[i];let s=this.textureLoader;if(r.uri){const t=n.manager.getHandler(r.uri);null!==t&&(s=t)}return this.loadTextureImage(t,i,s)}loadTextureImage(t,e,n){const i=this,r=this.json,s=r.textures[t],a=r.images[e],o=(a.uri||a.bufferView)+":"+s.sampler;if(this.textureCache[o])return this.textureCache[o];const l=this.loadImageSource(e,n).then((function(e){e.flipY=!1,e.name=s.name||a.name||"",""===e.name&&"string"==typeof a.uri&&!1===a.uri.startsWith("data:image/")&&(e.name=a.uri);const n=(r.samplers||{})[s.sampler]||{};return e.magFilter=uA[n.magFilter]||Lt,e.minFilter=uA[n.minFilter]||Ft,e.wrapS=dA[n.wrapS]||bt,e.wrapT=dA[n.wrapT]||bt,e.generateMipmaps=!e.isCompressedTexture&&e.minFilter!==Tt&&e.minFilter!==Lt,i.associations.set(e,{textures:t}),e})).catch((function(){return null}));return this.textureCache[o]=l,l}loadImageSource(t,e){const n=this.json,i=this.options;if(void 0!==this.sourceCache[t])return this.sourceCache[t].then((t=>t.clone()));const r=n.images[t],s=self.URL||self.webkitURL;let a=r.uri||"",o=!1;if(void 0!==r.bufferView)a=this.getDependency("bufferView",r.bufferView).then((function(t){o=!0;const e=new Blob([t],{type:r.mimeType});return a=s.createObjectURL(e),a}));else if(void 0===r.uri)throw new Error("THREE.GLTFLoader: Image "+t+" is missing URI and bufferView");const l=Promise.resolve(a).then((function(t){return new Promise((function(n,r){let s=n;!0===e.isImageBitmapLoader&&(s=function(t){const e=new Pi(t);e.needsUpdate=!0,n(e)}),e.load(Tp.resolveURL(t,i.path),s,void 0,r)}))})).then((function(t){var e;return!0===o&&s.revokeObjectURL(a),vA(t,r),t.userData.mimeType=r.mimeType||((e=r.uri).search(/\.jpe?g($|\?)/i)>0||0===e.search(/^data\:image\/jpeg/)?"image/jpeg":e.search(/\.webp($|\?)/i)>0||0===e.search(/^data\:image\/webp/)?"image/webp":e.search(/\.ktx2($|\?)/i)>0||0===e.search(/^data\:image\/ktx2/)?"image/ktx2":"image/png"),t})).catch((function(t){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),t}));return this.sourceCache[t]=l,l}assignTexture(t,e,n,i){const r=this;return this.getDependency("texture",n.index).then((function(s){if(!s)return null;if(void 0!==n.texCoord&&n.texCoord>0&&((s=s.clone()).channel=n.texCoord),r.extensions[Ng.KHR_TEXTURE_TRANSFORM]){const t=void 0!==n.extensions?n.extensions[Ng.KHR_TEXTURE_TRANSFORM]:void 0;if(t){const e=r.associations.get(s);s=r.extensions[Ng.KHR_TEXTURE_TRANSFORM].extendTexture(s,t),r.associations.set(s,e)}}return void 0!==i&&(s.colorSpace=i),t[e]=s,s}))}assignFinalMaterial(t){const e=t.geometry;let n=t.material;const i=void 0===e.attributes.tangent,r=void 0!==e.attributes.color,s=void 0===e.attributes.normal;if(t.isPoints){const t="PointsMaterial:"+n.uuid;let e=this.cache.get(t);e||(e=new kh,ps.prototype.copy.call(e,n),e.color.copy(n.color),e.map=n.map,e.sizeAttenuation=!1,this.cache.add(t,e)),n=e}else if(t.isLine){const t="LineBasicMaterial:"+n.uuid;let e=this.cache.get(t);e||(e=new Mh,ps.prototype.copy.call(e,n),e.color.copy(n.color),e.map=n.map,this.cache.add(t,e)),n=e}if(i||r||s){let t="ClonedMaterial:"+n.uuid+":";i&&(t+="derivative-tangents:"),r&&(t+="vertex-colors:"),s&&(t+="flat-shading:");let e=this.cache.get(t);e||(e=n.clone(),r&&(e.vertexColors=!0),s&&(e.flatShading=!0),i&&(e.normalScale&&(e.normalScale.y*=-1),e.clearcoatNormalScale&&(e.clearcoatNormalScale.y*=-1)),this.cache.add(t,e),this.associations.set(e,this.associations.get(n))),n=e}t.material=n}getMaterialType(){return wd}loadMaterial(t){const e=this,n=this.json,i=this.extensions,r=n.materials[t];let s;const a={},o=[];if((r.extensions||{})[Ng.KHR_MATERIALS_UNLIT]){const t=i[Ng.KHR_MATERIALS_UNLIT];s=t.getMaterialType(),o.push(t.extendParams(a,r,e))}else{const n=r.pbrMetallicRoughness||{};if(a.color=new hs(1,1,1),a.opacity=1,Array.isArray(n.baseColorFactor)){const t=n.baseColorFactor;a.color.setRGB(t[0],t[1],t[2],un),a.opacity=t[3]}void 0!==n.baseColorTexture&&o.push(e.assignTexture(a,"map",n.baseColorTexture,hn)),a.metalness=void 0!==n.metallicFactor?n.metallicFactor:1,a.roughness=void 0!==n.roughnessFactor?n.roughnessFactor:1,void 0!==n.metallicRoughnessTexture&&(o.push(e.assignTexture(a,"metalnessMap",n.metallicRoughnessTexture)),o.push(e.assignTexture(a,"roughnessMap",n.metallicRoughnessTexture))),s=this._invokeOne((function(e){return e.getMaterialType&&e.getMaterialType(t)})),o.push(Promise.all(this._invokeAll((function(e){return e.extendMaterialParams&&e.extendMaterialParams(t,a)}))))}!0===r.doubleSided&&(a.side=b);const l=r.alphaMode||"OPAQUE";if("BLEND"===l?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,"MASK"===l&&(a.alphaTest=void 0!==r.alphaCutoff?r.alphaCutoff:.5)),void 0!==r.normalTexture&&s!==fs&&(o.push(e.assignTexture(a,"normalMap",r.normalTexture)),a.normalScale=new ci(1,1),void 0!==r.normalTexture.scale)){const t=r.normalTexture.scale;a.normalScale.set(t,t)}if(void 0!==r.occlusionTexture&&s!==fs&&(o.push(e.assignTexture(a,"aoMap",r.occlusionTexture)),void 0!==r.occlusionTexture.strength&&(a.aoMapIntensity=r.occlusionTexture.strength)),void 0!==r.emissiveFactor&&s!==fs){const t=r.emissiveFactor;a.emissive=(new hs).setRGB(t[0],t[1],t[2],un)}return void 0!==r.emissiveTexture&&s!==fs&&o.push(e.assignTexture(a,"emissiveMap",r.emissiveTexture,hn)),Promise.all(o).then((function(){const n=new s(a);return r.name&&(n.name=r.name),vA(n,r),e.associations.set(n,{materials:t}),r.extensions&&AA(i,n,r),n}))}createUniqueName(t){const e=df.sanitizeNodeName(t||"");return e in this.nodeNamesUsed?e+"_"+ ++this.nodeNamesUsed[e]:(this.nodeNamesUsed[e]=0,e)}loadGeometries(t){const e=this,n=this.extensions,i=this.primitiveCache;function r(t){return n[Ng.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(t,e).then((function(n){return MA(n,t,e)}))}const s=[];for(let n=0,a=t.length;n0&&yA(u,r),u.name=e.createUniqueName(r.name||"mesh_"+t),vA(u,r),h.extensions&&AA(i,u,h),e.assignFinalMaterial(u),l.push(u)}for(let n=0,i=l.length;n1?new nc:1===e.length?e[0]:new Wr,a!==e[0])for(let t=0,n=e.length;t{const e=new Map;for(const[t,n]of i.associations)(t instanceof ps||t instanceof Pi)&&e.set(t,n);return t.traverse((t=>{const n=i.associations.get(t);null!=n&&e.set(t,n)})),e})(r),r}))}_createAnimationTracks(t,e,n,i,r){const s=[],a=t.name?t.name:t.uuid,o=[];let l;switch(mA[r.path]===mA.weights?t.traverse((function(t){t.morphTargetInfluences&&o.push(t.name?t.name:t.uuid)})):o.push(a),mA[r.path]){case mA.weights:l=Hd;break;case mA.rotation:l=Wd;break;case mA.position:case mA.scale:l=qd;break;default:l=1===n.itemSize?Hd:qd}const c=void 0!==i.interpolation?gA[i.interpolation]:je,h=this._getArrayFromAccessor(n);for(let t=0,n=o.length;tt.toBlob(n,e)));let n;return"image/jpeg"===e?n=.92:"image/webp"===e&&(n=.8),t.convertToBlob({type:e,quality:n})}class GA{constructor(){this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.extensionsRequired={},this.uids=new Map,this.uid=0,this.json={asset:{version:"2.0",generator:"THREE.GLTFExporter r"+p}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map},this.textureUtils=null}setPlugins(t){this.plugins=t}setTextureUtils(t){this.textureUtils=t}async writeAsync(t,e,n={}){this.options=Object.assign({binary:!1,trs:!1,onlyVisible:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},n),this.options.animations.length>0&&(this.options.trs=!0),await this.processInputAsync(t),await Promise.all(this.pending);const i=this,r=i.buffers,s=i.json;n=i.options;const a=i.extensionsUsed,o=i.extensionsRequired,l=new Blob(r,{type:"application/octet-stream"}),c=Object.keys(a),h=Object.keys(o);if(c.length>0&&(s.extensionsUsed=c),h.length>0&&(s.extensionsRequired=h),s.buffers&&s.buffers.length>0&&(s.buffers[0].byteLength=l.size),!0===n.binary){const t=new FileReader;t.readAsArrayBuffer(l),t.onloadend=function(){const n=kA(t.result),i=new DataView(new ArrayBuffer(8));i.setUint32(0,n.byteLength,!0),i.setUint32(4,5130562,!0);const r=kA((a=JSON.stringify(s),(new TextEncoder).encode(a).buffer),32);var a;const o=new DataView(new ArrayBuffer(8));o.setUint32(0,r.byteLength,!0),o.setUint32(4,1313821514,!0);const l=new ArrayBuffer(12),c=new DataView(l);c.setUint32(0,1179937895,!0),c.setUint32(4,2,!0);const h=12+o.byteLength+r.byteLength+i.byteLength+n.byteLength;c.setUint32(8,h,!0);const u=new Blob([l,o,r,i,n],{type:"application/octet-stream"}),d=new FileReader;d.readAsArrayBuffer(u),d.onloadend=function(){e(d.result)}}}else if(s.buffers&&s.buffers.length>0){const t=new FileReader;t.readAsDataURL(l),t.onloadend=function(){const n=t.result;s.buffers[0].uri=n,e(s)}}else e(s)}serializeUserData(t,e){if(0===Object.keys(t.userData).length)return;const n=this.options,i=this.extensionsUsed;try{const r=JSON.parse(JSON.stringify(t.userData));if(n.includeCustomExtensions&&r.gltfExtensions){void 0===e.extensions&&(e.extensions={});for(const t in r.gltfExtensions)e.extensions[t]=r.gltfExtensions[t],i[t]=!0;delete r.gltfExtensions}Object.keys(r).length>0&&(e.extras=r)}catch(e){console.warn("THREE.GLTFExporter: userData of '"+t.name+"' won't be serialized because of JSON.stringify error - "+e.message)}}getUID(t,e=!1){if(!1===this.uids.has(t)){const e=new Map;e.set(!0,this.uid++),e.set(!1,this.uid++),this.uids.set(t,e)}return this.uids.get(t).get(e)}isNormalizedNormalAttribute(t){if(this.cache.attributesNormalized.has(t))return!1;const e=new Gi;for(let n=0,i=t.count;n5e-4)return!1;return!0}createNormalizedNormalAttribute(t){const e=this.cache;if(e.attributesNormalized.has(t))return e.attributesNormalized.get(t);const n=t.clone(),i=new Gi;for(let t=0,e=n.count;t4?i=t.array[r*t.itemSize+n]:(0===n?i=t.getX(r):1===n?i=t.getY(r):2===n?i=t.getZ(r):3===n&&(i=t.getW(r)),!0===t.normalized&&(i=li.normalize(i,t.array))),5126===e?c.setFloat32(h,i,!0):5124===e?c.setInt32(h,i,!0):5125===e?c.setUint32(h,i,!0):e===BA?c.setInt16(h,i,!0):e===RA?c.setUint16(h,i,!0):e===IA?c.setInt8(h,i):e===TA&&c.setUint8(h,i),h+=a}h%o!=0&&(h+=o-h%o)}const u={buffer:this.processBuffer(c.buffer),byteOffset:this.byteOffset,byteLength:l};return void 0!==r&&(u.target=r),r===DA&&(u.byteStride=o),this.byteOffset+=l,s.bufferViews.push(u),{id:s.bufferViews.length-1,byteLength:0}}processBufferViewImage(t){const e=this,n=e.json;return n.bufferViews||(n.bufferViews=[]),new Promise((function(i){const r=new FileReader;r.readAsArrayBuffer(t),r.onloadend=function(){const t=kA(r.result),s={buffer:e.processBuffer(t),byteOffset:e.byteOffset,byteLength:t.byteLength};e.byteOffset+=t.byteLength,i(n.bufferViews.push(s)-1)}}))}processAccessor(t,e,n,i){const r=this.json;let s;if(t.array.constructor===Float32Array)s=5126;else if(t.array.constructor===Int32Array)s=5124;else if(t.array.constructor===Uint32Array)s=5125;else if(t.array.constructor===Int16Array)s=BA;else if(t.array.constructor===Uint16Array)s=RA;else if(t.array.constructor===Int8Array)s=IA;else{if(t.array.constructor!==Uint8Array)throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: "+t.array.constructor.name);s=TA}if(void 0===n&&(n=0),void 0!==i&&i!==1/0||(i=t.count),0===i)return null;const a=function(t,e,n){const i={min:new Array(t.itemSize).fill(Number.POSITIVE_INFINITY),max:new Array(t.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let r=e;r4?n=t.array[r*t.itemSize+e]:(0===e?n=t.getX(r):1===e?n=t.getY(r):2===e?n=t.getZ(r):3===e&&(n=t.getW(r)),!0===t.normalized&&(n=li.normalize(n,t.array))),i.min[e]=Math.min(i.min[e],n),i.max[e]=Math.max(i.max[e],n)}return i}(t,n,i);let o;void 0!==e&&(o=t===e.index?34963:DA);const l=this.processBufferView(t,s,n,i,o),c={bufferView:l.id,byteOffset:l.byteOffset,componentType:s,count:i,max:a.max,min:a.min,type:{1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",9:"MAT3",16:"MAT4"}[t.itemSize]};return!0===t.normalized&&(c.normalized=!0),r.accessors||(r.accessors=[]),r.accessors.push(c)-1}processImage(t,e,n,i="image/png"){if(null!==t){const r=this,s=r.cache,a=r.json,o=r.options,l=r.pending;s.images.has(t)||s.images.set(t,{});const c=s.images.get(t),h=i+":flipY/"+n.toString();if(void 0!==c[h])return c[h];a.images||(a.images=[]);const u={mimeType:i},d=QA();d.width=Math.min(t.width,o.maxTextureSize),d.height=Math.min(t.height,o.maxTextureSize);const p=d.getContext("2d",{willReadFrequently:!0});if(!0===n&&(p.translate(0,d.height),p.scale(1,-1)),void 0!==t.data){e!==$t&&console.error("GLTFExporter: Only RGBAFormat is supported.",e),(t.width>o.maxTextureSize||t.height>o.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",t);const n=new Uint8ClampedArray(t.height*t.width*4);for(let e=0;er.processBufferViewImage(t))).then((t=>{u.bufferView=t}))):void 0!==d.toDataURL?u.uri=d.toDataURL(i):l.push(zA(d,i).then((t=>(new FileReader).readAsDataURL(t))).then((t=>{u.uri=t})));const f=a.images.push(u)-1;return c[h]=f,f}throw new Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.")}processSampler(t){const e=this.json;e.samplers||(e.samplers=[]);const n={magFilter:LA[t.magFilter],minFilter:LA[t.minFilter],wrapS:LA[t.wrapS],wrapT:LA[t.wrapT]};return e.samplers.push(n)-1}async processTextureAsync(t){const e=this.options,n=this.cache,i=this.json;if(n.textures.has(t))return n.textures.get(t);i.textures||(i.textures=[]),t instanceof Xh&&(t=await this.decompressTextureAsync(t,e.maxTextureSize));let r=t.userData.mimeType;"image/webp"===r&&(r="image/png");const s={sampler:this.processSampler(t),source:this.processImage(t.image,t.format,t.flipY,r)};t.name&&(s.name=t.name),await this._invokeAllAsync((async function(e){e.writeTexture&&await e.writeTexture(t,s)}));const a=i.textures.push(s)-1;return n.textures.set(t,a),a}async processMaterialAsync(t){const e=this.cache,n=this.json;if(e.materials.has(t))return e.materials.get(t);if(t.isShaderMaterial)return console.warn("GLTFExporter: THREE.ShaderMaterial not supported."),null;n.materials||(n.materials=[]);const i={pbrMetallicRoughness:{}};!0!==t.isMeshStandardMaterial&&!0!==t.isMeshBasicMaterial&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");const r=t.color.toArray().concat([t.opacity]);if(FA(r,[1,1,1,1])||(i.pbrMetallicRoughness.baseColorFactor=r),t.isMeshStandardMaterial?(i.pbrMetallicRoughness.metallicFactor=t.metalness,i.pbrMetallicRoughness.roughnessFactor=t.roughness):(i.pbrMetallicRoughness.metallicFactor=0,i.pbrMetallicRoughness.roughnessFactor=1),t.metalnessMap||t.roughnessMap){const e=await this.buildMetalRoughTextureAsync(t.metalnessMap,t.roughnessMap),n={index:await this.processTextureAsync(e),texCoord:e.channel};this.applyTextureTransform(n,e),i.pbrMetallicRoughness.metallicRoughnessTexture=n}if(t.map){const e={index:await this.processTextureAsync(t.map),texCoord:t.map.channel};this.applyTextureTransform(e,t.map),i.pbrMetallicRoughness.baseColorTexture=e}if(t.emissive){const e=t.emissive;if(Math.max(e.r,e.g,e.b)>0&&(i.emissiveFactor=t.emissive.toArray()),t.emissiveMap){const e={index:await this.processTextureAsync(t.emissiveMap),texCoord:t.emissiveMap.channel};this.applyTextureTransform(e,t.emissiveMap),i.emissiveTexture=e}}if(t.normalMap){const e={index:await this.processTextureAsync(t.normalMap),texCoord:t.normalMap.channel};t.normalScale&&1!==t.normalScale.x&&(e.scale=t.normalScale.x),this.applyTextureTransform(e,t.normalMap),i.normalTexture=e}if(t.aoMap){const e={index:await this.processTextureAsync(t.aoMap),texCoord:t.aoMap.channel};1!==t.aoMapIntensity&&(e.strength=t.aoMapIntensity),this.applyTextureTransform(e,t.aoMap),i.occlusionTexture=e}t.transparent?i.alphaMode="BLEND":t.alphaTest>0&&(i.alphaMode="MASK",i.alphaCutoff=t.alphaTest),t.side===b&&(i.doubleSided=!0),""!==t.name&&(i.name=t.name),this.serializeUserData(t,i),await this._invokeAllAsync((async function(e){e.writeMaterialAsync&&await e.writeMaterialAsync(t,i)}));const s=n.materials.push(i)-1;return e.materials.set(t,s),s}async processMeshAsync(t){const e=this.cache,n=this.json,i=[t.geometry.uuid];if(Array.isArray(t.material))for(let e=0,n=t.material.length;e0){const n=[],i=[],r={};if(void 0!==t.morphTargetDictionary)for(const e in t.morphTargetDictionary)r[t.morphTargetDictionary[e]]=e;for(let a=0;a0&&(o.extras={},o.extras.targetNames=i)}const f=Array.isArray(t.material);if(f&&0===s.groups.length)return null;let m=!1;if(f&&null===s.index){const t=[];for(let e=0,n=s.attributes.position.count;e0&&(n.targets=h),null!==s.index){let i=this.getUID(s.index);void 0===A[t].start&&void 0===A[t].count||(i+=":"+A[t].start+":"+A[t].count),e.attributes.has(i)?n.indices=e.attributes.get(i):(n.indices=this.processAccessor(s.index,s,A[t].start,A[t].count),e.attributes.set(i,n.indices)),null===n.indices&&delete n.indices}const i=await this.processMaterialAsync(g[A[t].materialIndex]);null!==i&&(n.material=i),c.push(n)}!0===m&&s.setIndex(null),o.primitives=c,n.meshes||(n.meshes=[]),await this._invokeAllAsync((function(e){e.writeMesh&&e.writeMesh(t,o)}));const v=n.meshes.push(o)-1;return e.meshes.set(r,v),v}detectMeshQuantization(t,e){if(this.extensionsUsed[PA])return;let n;switch(e.array.constructor){case Int8Array:n="byte";break;case Uint8Array:n="unsigned byte";break;case Int16Array:n="short";break;case Uint16Array:n="unsigned short";break;default:return}e.normalized&&(n+=" normalized");const i=t.split("_",1)[0];bA[i]&&bA[i].includes(n)&&(this.extensionsUsed[PA]=!0,this.extensionsRequired[PA]=!0)}processCamera(t){const e=this.json;e.cameras||(e.cameras=[]);const n=t.isOrthographicCamera,i={type:n?"orthographic":"perspective"};return n?i.orthographic={xmag:2*t.right,ymag:2*t.top,zfar:t.far<=0?.001:t.far,znear:t.near<0?0:t.near}:i.perspective={aspectRatio:t.aspect,yfov:li.degToRad(t.fov),zfar:t.far<=0?.001:t.far,znear:t.near<0?0:t.near},""!==t.name&&(i.name=t.type),e.cameras.push(i)-1}processAnimation(t,e){const n=this.json,i=this.nodeMap;n.animations||(n.animations=[]);const r=(t=SA.Utils.mergeMorphTargetTracks(t.clone(),e)).tracks,s=[],a=[];for(let t=0;t0){const e=[];for(let i=0,r=t.children.length;i0&&(r.children=e)}await this._invokeAllAsync((function(e){e.writeNode&&e.writeNode(t,r)}));const s=e.nodes.push(r)-1;return i.set(t,s),s}async processSceneAsync(t){const e=this.json,n=this.options;e.scenes||(e.scenes=[],e.scene=0);const i={};""!==t.name&&(i.name=t.name),e.scenes.push(i);const r=[];for(let e=0,i=t.children.length;e0&&(i.nodes=r),this.serializeUserData(t,i)}async processObjectsAsync(t){const e=new fc;e.name="AuxScene";for(let n=0;n0&&await this.processObjectsAsync(n);for(let t=0;t0&&(s.range=t.distance)):t.isSpotLight&&(s.type="spot",t.distance>0&&(s.range=t.distance),s.spot={},s.spot.innerConeAngle=(1-t.penumbra)*t.angle,s.spot.outerConeAngle=t.angle),void 0!==t.decay&&2!==t.decay&&console.warn("THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2."),!t.target||t.target.parent===t&&0===t.target.position.x&&0===t.target.position.y&&-1===t.target.position.z||console.warn("THREE.GLTFExporter: Light direction may be lost. For best results, make light.target a child of the light with position 0,0,-1."),r[this.name]||(i.extensions=i.extensions||{},i.extensions[this.name]={lights:[]},r[this.name]=!0);const a=i.extensions[this.name].lights;a.push(s),e.extensions=e.extensions||{},e.extensions[this.name]={light:a.length-1}}}class VA{constructor(t){this.writer=t,this.name="KHR_materials_unlit"}async writeMaterialAsync(t,e){if(!t.isMeshBasicMaterial)return;const n=this.writer.extensionsUsed;e.extensions=e.extensions||{},e.extensions[this.name]={},n[this.name]=!0,e.pbrMetallicRoughness.metallicFactor=0,e.pbrMetallicRoughness.roughnessFactor=.9}}class WA{constructor(t){this.writer=t,this.name="KHR_materials_clearcoat"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||0===t.clearcoat)return;const n=this.writer,i=n.extensionsUsed,r={};if(r.clearcoatFactor=t.clearcoat,t.clearcoatMap){const e={index:await n.processTextureAsync(t.clearcoatMap),texCoord:t.clearcoatMap.channel};n.applyTextureTransform(e,t.clearcoatMap),r.clearcoatTexture=e}if(r.clearcoatRoughnessFactor=t.clearcoatRoughness,t.clearcoatRoughnessMap){const e={index:await n.processTextureAsync(t.clearcoatRoughnessMap),texCoord:t.clearcoatRoughnessMap.channel};n.applyTextureTransform(e,t.clearcoatRoughnessMap),r.clearcoatRoughnessTexture=e}if(t.clearcoatNormalMap){const e={index:await n.processTextureAsync(t.clearcoatNormalMap),texCoord:t.clearcoatNormalMap.channel};1!==t.clearcoatNormalScale.x&&(e.scale=t.clearcoatNormalScale.x),n.applyTextureTransform(e,t.clearcoatNormalMap),r.clearcoatNormalTexture=e}e.extensions=e.extensions||{},e.extensions[this.name]=r,i[this.name]=!0}}class jA{constructor(t){this.writer=t,this.name="KHR_materials_dispersion"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||0===t.dispersion)return;const n=this.writer.extensionsUsed,i={};i.dispersion=t.dispersion,e.extensions=e.extensions||{},e.extensions[this.name]=i,n[this.name]=!0}}class qA{constructor(t){this.writer=t,this.name="KHR_materials_iridescence"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||0===t.iridescence)return;const n=this.writer,i=n.extensionsUsed,r={};if(r.iridescenceFactor=t.iridescence,t.iridescenceMap){const e={index:await n.processTextureAsync(t.iridescenceMap),texCoord:t.iridescenceMap.channel};n.applyTextureTransform(e,t.iridescenceMap),r.iridescenceTexture=e}if(r.iridescenceIor=t.iridescenceIOR,r.iridescenceThicknessMinimum=t.iridescenceThicknessRange[0],r.iridescenceThicknessMaximum=t.iridescenceThicknessRange[1],t.iridescenceThicknessMap){const e={index:await n.processTextureAsync(t.iridescenceThicknessMap),texCoord:t.iridescenceThicknessMap.channel};n.applyTextureTransform(e,t.iridescenceThicknessMap),r.iridescenceThicknessTexture=e}e.extensions=e.extensions||{},e.extensions[this.name]=r,i[this.name]=!0}}class XA{constructor(t){this.writer=t,this.name="KHR_materials_transmission"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||0===t.transmission)return;const n=this.writer,i=n.extensionsUsed,r={};if(r.transmissionFactor=t.transmission,t.transmissionMap){const e={index:await n.processTextureAsync(t.transmissionMap),texCoord:t.transmissionMap.channel};n.applyTextureTransform(e,t.transmissionMap),r.transmissionTexture=e}e.extensions=e.extensions||{},e.extensions[this.name]=r,i[this.name]=!0}}class YA{constructor(t){this.writer=t,this.name="KHR_materials_volume"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||0===t.transmission)return;const n=this.writer,i=n.extensionsUsed,r={};if(r.thicknessFactor=t.thickness,t.thicknessMap){const e={index:await n.processTextureAsync(t.thicknessMap),texCoord:t.thicknessMap.channel};n.applyTextureTransform(e,t.thicknessMap),r.thicknessTexture=e}t.attenuationDistance!==1/0&&(r.attenuationDistance=t.attenuationDistance),r.attenuationColor=t.attenuationColor.toArray(),e.extensions=e.extensions||{},e.extensions[this.name]=r,i[this.name]=!0}}class JA{constructor(t){this.writer=t,this.name="KHR_materials_ior"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||1.5===t.ior)return;const n=this.writer.extensionsUsed,i={};i.ior=t.ior,e.extensions=e.extensions||{},e.extensions[this.name]=i,n[this.name]=!0}}class KA{constructor(t){this.writer=t,this.name="KHR_materials_specular"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||1===t.specularIntensity&&t.specularColor.equals(NA)&&!t.specularIntensityMap&&!t.specularColorMap)return;const n=this.writer,i=n.extensionsUsed,r={};if(t.specularIntensityMap){const e={index:await n.processTextureAsync(t.specularIntensityMap),texCoord:t.specularIntensityMap.channel};n.applyTextureTransform(e,t.specularIntensityMap),r.specularTexture=e}if(t.specularColorMap){const e={index:await n.processTextureAsync(t.specularColorMap),texCoord:t.specularColorMap.channel};n.applyTextureTransform(e,t.specularColorMap),r.specularColorTexture=e}r.specularFactor=t.specularIntensity,r.specularColorFactor=t.specularColor.toArray(),e.extensions=e.extensions||{},e.extensions[this.name]=r,i[this.name]=!0}}class ZA{constructor(t){this.writer=t,this.name="KHR_materials_sheen"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||0==t.sheen)return;const n=this.writer,i=n.extensionsUsed,r={};if(t.sheenRoughnessMap){const e={index:await n.processTextureAsync(t.sheenRoughnessMap),texCoord:t.sheenRoughnessMap.channel};n.applyTextureTransform(e,t.sheenRoughnessMap),r.sheenRoughnessTexture=e}if(t.sheenColorMap){const e={index:await n.processTextureAsync(t.sheenColorMap),texCoord:t.sheenColorMap.channel};n.applyTextureTransform(e,t.sheenColorMap),r.sheenColorTexture=e}r.sheenRoughnessFactor=t.sheenRoughness,r.sheenColorFactor=t.sheenColor.toArray(),e.extensions=e.extensions||{},e.extensions[this.name]=r,i[this.name]=!0}}class $A{constructor(t){this.writer=t,this.name="KHR_materials_anisotropy"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||0==t.anisotropy)return;const n=this.writer,i=n.extensionsUsed,r={};if(t.anisotropyMap){const e={index:await n.processTextureAsync(t.anisotropyMap)};n.applyTextureTransform(e,t.anisotropyMap),r.anisotropyTexture=e}r.anisotropyStrength=t.anisotropy,r.anisotropyRotation=t.anisotropyRotation,e.extensions=e.extensions||{},e.extensions[this.name]=r,i[this.name]=!0}}class tv{constructor(t){this.writer=t,this.name="KHR_materials_emissive_strength"}async writeMaterialAsync(t,e){if(!t.isMeshStandardMaterial||1===t.emissiveIntensity)return;const n=this.writer.extensionsUsed,i={};i.emissiveStrength=t.emissiveIntensity,e.extensions=e.extensions||{},e.extensions[this.name]=i,n[this.name]=!0}}class ev{constructor(t){this.writer=t,this.name="EXT_materials_bump"}async writeMaterialAsync(t,e){if(!t.isMeshStandardMaterial||1===t.bumpScale&&!t.bumpMap)return;const n=this.writer,i=n.extensionsUsed,r={};if(t.bumpMap){const e={index:await n.processTextureAsync(t.bumpMap),texCoord:t.bumpMap.channel};n.applyTextureTransform(e,t.bumpMap),r.bumpTexture=e}r.bumpFactor=t.bumpScale,e.extensions=e.extensions||{},e.extensions[this.name]=r,i[this.name]=!0}}class nv{constructor(t){this.writer=t,this.name="EXT_mesh_gpu_instancing"}writeNode(t,e){if(!t.isInstancedMesh)return;const n=this.writer,i=t,r=new Float32Array(3*i.count),s=new Float32Array(4*i.count),a=new Float32Array(3*i.count),o=new vr,l=new Gi,c=new zi,h=new Gi;for(let t=0;tt.times[t.times.length-1]){if(Math.abs(t.times[t.times.length-1]-e)e){r.set(t.times.slice(0,l+1),0),r[l+1]=e,r.set(t.times.slice(l+1),l+2),s.set(t.values.slice(0,(l+1)*i),0),s.set(a.evaluate(e),(l+1)*i),s.set(t.values.slice((l+1)*i),(l+2)*i),o=l+1;break}}return t.times=r,t.values=s,o},mergeMorphTargetTracks:function(t,e){const n=[],i={},r=t.tracks;for(let t=0;t{const e=t.draco,a=new e.Decoder;try{const t=function(t,e,i,r){const s=r.attributeIDs,a=r.attributeTypes;let o,l;const c=e.GetEncodedGeometryType(i);if(c===t.TRIANGULAR_MESH)o=new t.Mesh,l=e.DecodeArrayToMesh(i,i.byteLength,o);else{if(c!==t.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");o=new t.PointCloud,l=e.DecodeArrayToPointCloud(i,i.byteLength,o)}if(!l.ok()||0===o.ptr)throw new Error("THREE.DRACOLoader: Decoding failed: "+l.error_msg());const h={index:null,attributes:[]};for(const i in s){const l=self[a[i]];let c,u;if(r.useUniqueIDs)u=s[i],c=e.GetAttributeByUniqueId(o,u);else{if(u=e.GetAttributeId(o,t[s[i]]),-1===u)continue;c=e.GetAttribute(o,u)}const d=n(t,e,o,i,l,c);"color"===i&&(d.vertexColorSpace=r.vertexColorSpace),h.attributes.push(d)}return c===t.TRIANGULAR_MESH&&(h.index=function(t,e,n){const i=3*n.num_faces(),r=4*i,s=t._malloc(r);e.GetTrianglesUInt32Array(n,r,s);const a=new Uint32Array(t.HEAPF32.buffer,s,i).slice();return t._free(s),{array:a,itemSize:1}}(t,e,o)),t.destroy(o),h}(e,a,new Int8Array(i),s),o=t.attributes.map((t=>t.array.buffer));t.index&&o.push(t.index.array.buffer),self.postMessage({type:"decode",id:r.id,geometry:t},o)}catch(t){console.error(t),self.postMessage({type:"error",id:r.id,error:t.message})}finally{e.destroy(a)}}))}}}var sv=Uint8Array,av=Uint16Array,ov=Int32Array,lv=new sv([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),cv=new sv([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),hv=new sv([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),uv=function(t,e){for(var n=new av(31),i=0;i<31;++i)n[i]=e+=1<>1|(21845&yv)<<1;_v=(61680&(_v=(52428&_v)>>2|(13107&_v)<<2))>>4|(3855&_v)<<4,vv[yv]=((65280&_v)>>8|(255&_v)<<8)>>1}var xv=function(t,e,n){for(var i=t.length,r=0,s=new av(e);r>l]=c}else for(a=new av(i),r=0;r>15-t[r]);return a},wv=new sv(288);for(yv=0;yv<144;++yv)wv[yv]=8;for(yv=144;yv<256;++yv)wv[yv]=9;for(yv=256;yv<280;++yv)wv[yv]=7;for(yv=280;yv<288;++yv)wv[yv]=8;var Cv=new sv(32);for(yv=0;yv<32;++yv)Cv[yv]=5;var Ev=xv(wv,9,0),Mv=xv(wv,9,1),bv=xv(Cv,5,0),Sv=xv(Cv,5,1),Iv=function(t){for(var e=t[0],n=1;ne&&(e=t[n]);return e},Tv=function(t,e,n){var i=e/8|0;return(t[i]|t[i+1]<<8)>>(7&e)&n},Bv=function(t,e){var n=e/8|0;return(t[n]|t[n+1]<<8|t[n+2]<<16)>>(7&e)},Rv=function(t){return(t+7)/8|0},Dv=function(t,e,n){return(null==e||e<0)&&(e=0),(null==n||n>t.length)&&(n=t.length),new sv(t.subarray(e,n))},Pv=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Lv=function(t,e,n){var i=new Error(e||Pv[t]);if(i.code=t,Error.captureStackTrace&&Error.captureStackTrace(i,Lv),!n)throw i;return i},Uv=function(t,e,n){n<<=7&e;var i=e/8|0;t[i]|=n,t[i+1]|=n>>8},Nv=function(t,e,n){n<<=7&e;var i=e/8|0;t[i]|=n,t[i+1]|=n>>8,t[i+2]|=n>>16},Fv=function(t,e){for(var n=[],i=0;id&&(d=s[i].s);var p=new av(d+1),f=Ov(n[h-1],p,0);if(f>e){i=0;var m=0,g=f-e,A=1<e))break;m+=A-(1<>=g;m>0;){var y=s[i].s;p[y]=0&&m;--i){var _=s[i].s;p[_]==e&&(--p[_],++m)}f=e}return{t:new sv(p),l:f}},Ov=function(t,e,n){return-1==t.s?Math.max(Ov(t.l,e,n+1),Ov(t.r,e,n+1)):e[t.s]=n},kv=function(t){for(var e=t.length;e&&!t[--e];);for(var n=new av(++e),i=0,r=t[0],s=1,a=function(t){n[i++]=t},o=1;o<=e;++o)if(t[o]==r&&o!=e)++s;else{if(!r&&s>2){for(;s>138;s-=138)a(32754);s>2&&(a(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(a(r),--s;s>6;s-=6)a(8304);s>2&&(a(s-3<<5|8208),s=0)}for(;s--;)a(r);s=1,r=t[o]}return{c:n.subarray(0,i),n:e}},Qv=function(t,e){for(var n=0,i=0;i>8,t[r+2]=255^t[r],t[r+3]=255^t[r+1];for(var s=0;s4&&!b[hv[I-1]];--I);var T,B,R,D,P=c+5<<3,L=Qv(r,wv)+Qv(s,Cv)+a,U=Qv(r,d)+Qv(s,m)+a+14+3*I+Qv(C,b)+2*C[16]+3*C[17]+7*C[18];if(l>=0&&P<=L&&P<=U)return zv(e,h,t.subarray(l,l+c));if(Uv(e,h,1+(U15&&(Uv(e,h,k[E]>>5&127),h+=k[E]>>12)}}}else T=Ev,B=wv,R=bv,D=Cv;for(E=0;E255){Nv(e,h,T[257+(Q=z>>18&31)]),h+=B[Q+257],Q>7&&(Uv(e,h,z>>23&31),h+=lv[Q]);var G=31&z;Nv(e,h,R[G]),h+=D[G],G>3&&(Nv(e,h,z>>5&8191),h+=cv[G])}else Nv(e,h,T[z]),h+=B[z]}return Nv(e,h,T[256]),h+B[256]},Hv=new ov([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Vv=new sv(0),Wv=function(){for(var t=new Int32Array(256),e=0;e<256;++e){for(var n=e,i=9;--i;)n=(1&n&&-306674912)^n>>>1;t[e]=n}return t}(),jv=function(){var t=-1;return{p:function(e){for(var n=t,i=0;i>>8;t=n},d:function(){return~t}}},qv=function(t,e,n,i,r){if(!r&&(r={l:1},e.dictionary)){var s=e.dictionary.subarray(-32768),a=new sv(s.length+t.length);a.set(s),a.set(t,s.length),t=a,r.w=s.length}return function(t,e,n,i,r,s){var a=s.z||t.length,o=new sv(i+a+5*(1+Math.ceil(a/7e3))+r),l=o.subarray(i,o.length-r),c=s.l,h=7&(s.r||0);if(e){h&&(l[0]=s.r>>3);for(var u=Hv[e-1],d=u>>13,p=8191&u,f=(1<7e3||b>24576)&&(D>423||!c)){h=Gv(t,l,0,_,x,w,E,b,I,M-I,h),b=C=E=0,I=M;for(var P=0;P<286;++P)x[P]=0;for(P=0;P<30;++P)w[P]=0}var L=2,U=0,N=p,F=B-R&32767;if(D>2&&T==y(M-F))for(var O=Math.min(d,D)-1,k=Math.min(32767,M),Q=Math.min(258,D);F<=k&&--N&&B!=R;){if(t[M+L]==t[M+L-F]){for(var z=0;zL){if(L=z,U=F,z>O)break;var G=Math.min(F,z-2),H=0;for(P=0;PH&&(H=W,R=V)}}}F+=(B=R)-(R=m[B])&32767}if(U){_[b++]=268435456|fv[L]<<18|Av[U];var j=31&fv[L],q=31&Av[U];E+=lv[j]+cv[q],++x[257+j],++w[q],S=M+L,++C}else _[b++]=t[M],++x[t[M]]}}for(M=Math.max(M,S);M=a&&(l[h/8|0]=c,X=a),h=zv(l,h+1,t.subarray(M,X))}s.i=a}return Dv(o,0,i+Rv(h)+r)}(t,null==e.level?6:e.level,null==e.mem?r.l?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(t.length)))):20:12+e.mem,n,i,r)},Xv=function(t,e){var n={};for(var i in t)n[i]=t[i];for(var i in e)n[i]=e[i];return n},Yv=function(t,e,n){for(;n;++e)t[e]=n,n>>>=8};function Jv(t,e){return qv(t,e||{},0,0)}function Kv(t,e){return function(t,e,n,i){var r=t.length,s=i?i.length:0;if(!r||e.f&&!e.l)return n||new sv(0);var a=!n,o=a||2!=e.i,l=e.i;a&&(n=new sv(3*r));var c=function(t){var e=n.length;if(t>e){var i=new sv(Math.max(2*e,t));i.set(n),n=i}},h=e.f||0,u=e.p||0,d=e.b||0,p=e.l,f=e.d,m=e.m,g=e.n,A=8*r;do{if(!p){h=Tv(t,u,1);var v=Tv(t,u+1,3);if(u+=3,!v){var y=t[(B=Rv(u)+4)-4]|t[B-3]<<8,_=B+y;if(_>r){l&&Lv(0);break}o&&c(d+y),n.set(t.subarray(B,_),d),e.b=d+=y,e.p=u=8*_,e.f=h;continue}if(1==v)p=Mv,f=Sv,m=9,g=5;else if(2==v){var x=Tv(t,u,31)+257,w=Tv(t,u+10,15)+4,C=x+Tv(t,u+5,31)+1;u+=14;for(var E=new sv(C),M=new sv(19),b=0;b>4)<16)E[b++]=B;else{var D=0,P=0;for(16==B?(P=3+Tv(t,u,3),u+=2,D=E[b-1]):17==B?(P=3+Tv(t,u,7),u+=3):18==B&&(P=11+Tv(t,u,127),u+=7);P--;)E[b++]=D}}var L=E.subarray(0,x),U=E.subarray(x);m=Iv(L),g=Iv(U),p=xv(L,m,1),f=xv(U,g,1)}else Lv(1);if(u>A){l&&Lv(0);break}}o&&c(d+131072);for(var N=(1<>4;if((u+=15&D)>A){l&&Lv(0);break}if(D||Lv(2),k<256)n[d++]=k;else{if(256==k){O=u,p=null;break}var Q=k-254;if(k>264){var z=lv[b=k-257];Q=Tv(t,u,(1<>4;if(G||Lv(3),u+=15&G,U=gv[H],H>3&&(z=cv[H],U+=Bv(t,u)&(1<A){l&&Lv(0);break}o&&c(d+131072);var V=d+Q;if(d>4>7||(n[0]<<8|n[1])%31)&&Lv(6,"invalid zlib data"),(n[1]>>5&1)==+!i&&Lv(6,"invalid zlib data: "+(32&n[1]?"need":"unexpected")+" dictionary"),2+(n[1]>>3&4)),-4),{i:2},e&&e.out,e&&e.dictionary);var n,i}var Zv=function(t,e,n,i){for(var r in t){var s=t[r],a=e+r,o=i;Array.isArray(s)&&(o=Xv(i,s[1]),s=s[0]),s instanceof sv?n[a]=[s,o]:(n[a+="/"]=[new sv(0),o],Zv(s,a,n,i))}},$v="undefined"!=typeof TextEncoder&&new TextEncoder,ty="undefined"!=typeof TextDecoder&&new TextDecoder;try{ty.decode(Vv,{stream:!0})}catch(t){}function ey(t,e){if(e){for(var n=new sv(t.length),i=0;i>1)),a=0,o=function(t){s[a++]=t};for(i=0;is.length){var l=new sv(a+8+(r-i<<1));l.set(s),s=l}var c=t.charCodeAt(i);c<128||e?o(c):c<2048?(o(192|c>>6),o(128|63&c)):c>55295&&c<57344?(o(240|(c=65536+(1047552&c)|1023&t.charCodeAt(++i))>>18),o(128|c>>12&63),o(128|c>>6&63),o(128|63&c)):(o(224|c>>12),o(128|c>>6&63),o(128|63&c))}return Dv(s,0,a)}var ny=function(t){var e=0;if(t)for(var n in t){var i=t[n].length;i>65535&&Lv(9),e+=i+4}return e},iy=function(t,e,n,i,r,s,a,o){var l=i.length,c=n.extra,h=o&&o.length,u=ny(c);Yv(t,e,null!=a?33639248:67324752),e+=4,null!=a&&(t[e++]=20,t[e++]=n.os),t[e]=20,e+=2,t[e++]=n.flag<<1|(s<0&&8),t[e++]=r&&8,t[e++]=255&n.compression,t[e++]=n.compression>>8;var d=new Date(null==n.mtime?Date.now():n.mtime),p=d.getFullYear()-1980;if((p<0||p>119)&&Lv(10),Yv(t,e,p<<25|d.getMonth()+1<<21|d.getDate()<<16|d.getHours()<<11|d.getMinutes()<<5|d.getSeconds()>>1),e+=4,-1!=s&&(Yv(t,e,n.crc),Yv(t,e+4,s<0?-s-2:s),Yv(t,e+8,n.size)),Yv(t,e+12,l),Yv(t,e+14,u),e+=16,null!=a&&(Yv(t,e,h),Yv(t,e+6,n.attrs),Yv(t,e+10,a),e+=14),t.set(i,e),e+=l,u)for(var f in c){var m=c[f],g=m.length;Yv(t,e,+f),Yv(t,e+2,g),t.set(m,e+4),e+=4+g}return h&&(t.set(o,e),e+=h),e};function ry(t,e,n){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof OffscreenCanvas&&t instanceof OffscreenCanvas||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){const i=n/Math.max(t.width,t.height),r=document.createElement("canvas");r.width=t.width*Math.min(1,i),r.height=t.height*Math.min(1,i);const s=r.getContext("2d");return!0===e&&(s.translate(0,r.height),s.scale(1,-1)),s.drawImage(t,0,0,r.width,r.height),r}throw new Error("THREE.USDZExporter: No valid image data found. Unable to process texture.")}"function"==typeof queueMicrotask?queueMicrotask:"function"==typeof setTimeout&&setTimeout;function sy(t){const e=t.elements;return`( ${ay(e,0)}, ${ay(e,4)}, ${ay(e,8)}, ${ay(e,12)} )`}function ay(t,e){return`(${t[e+0]}, ${t[e+1]}, ${t[e+2]}, ${t[e+3]})`}function oy(t,e){if(void 0===t)return console.warn("USDZExporter: Normals missing."),Array(e).fill("(0, 0, 0)").join(", ");const n=[];for(let e=0;e0?"st"+i.channel:"st",l={1e3:"repeat",1001:"clamp",1002:"mirror"},c=i.repeat.clone(),h=i.offset.clone(),u=i.rotation,d=Math.sin(u),p=Math.cos(u);return h.y=1-h.y-c.y,n?(h.x=h.x/c.x,h.y=h.y/c.y,h.x+=d/c.x,h.y+=p-1):(h.x+=d*c.x,h.y+=(1-p)*c.y),`\n\t\tdef Shader "PrimvarReader_${r}"\n\t\t{\n\t\t\tuniform token info:id = "UsdPrimvarReader_float2"\n\t\t\tfloat2 inputs:fallback = (0.0, 0.0)\n\t\t\ttoken inputs:varname = "${o}"\n\t\t\tfloat2 outputs:result\n\t\t}\n\n\t\tdef Shader "Transform2d_${r}"\n\t\t{\n\t\t\tuniform token info:id = "UsdTransform2d"\n\t\t\ttoken inputs:in.connect = \n\t\t\tfloat inputs:rotation = ${(u*(180/Math.PI)).toFixed(7)}\n\t\t\tfloat2 inputs:scale = ${uy(c)}\n\t\t\tfloat2 inputs:translation = ${uy(h)}\n\t\t\tfloat2 outputs:result\n\t\t}\n\n\t\tdef Shader "Texture_${i.id}_${r}"\n\t\t{\n\t\t\tuniform token info:id = "UsdUVTexture"\n\t\t\tasset inputs:file = @textures/Texture_${a}.png@\n\t\t\tfloat2 inputs:st.connect = \n\t\t\t${void 0!==s?"float4 inputs:scale = "+function(t){return`(${t.r}, ${t.g}, ${t.b}, 1.0)`}(s):""}\n\t\t\ttoken inputs:sourceColorSpace = "${i.colorSpace===cn?"raw":"sRGB"}"\n\t\t\ttoken inputs:wrapS = "${l[i.wrapS]}"\n\t\t\ttoken inputs:wrapT = "${l[i.wrapT]}"\n\t\t\tfloat outputs:r\n\t\t\tfloat outputs:g\n\t\t\tfloat outputs:b\n\t\t\tfloat3 outputs:rgb\n\t\t\t${t.transparent||t.alphaTest>0?"float outputs:a":""}\n\t\t}`}return t.side===b&&console.warn("THREE.USDZExporter: USDZ does not support double sided materials",t),null!==t.map?(r.push(`${i}color3f inputs:diffuseColor.connect = `),t.transparent?r.push(`${i}float inputs:opacity.connect = `):t.alphaTest>0&&(r.push(`${i}float inputs:opacity.connect = `),r.push(`${i}float inputs:opacityThreshold = ${t.alphaTest}`)),s.push(a(t.map,"diffuse",t.color))):r.push(`${i}color3f inputs:diffuseColor = ${hy(t.color)}`),null!==t.emissiveMap?(r.push(`${i}color3f inputs:emissiveColor.connect = `),s.push(a(t.emissiveMap,"emissive",new hs(t.emissive.r*t.emissiveIntensity,t.emissive.g*t.emissiveIntensity,t.emissive.b*t.emissiveIntensity)))):t.emissive.getHex()>0&&r.push(`${i}color3f inputs:emissiveColor = ${hy(t.emissive)}`),null!==t.normalMap&&(r.push(`${i}normal3f inputs:normal.connect = `),s.push(a(t.normalMap,"normal"))),null!==t.aoMap&&(r.push(`${i}float inputs:occlusion.connect = `),s.push(a(t.aoMap,"occlusion",new hs(t.aoMapIntensity,t.aoMapIntensity,t.aoMapIntensity)))),null!==t.roughnessMap?(r.push(`${i}float inputs:roughness.connect = `),s.push(a(t.roughnessMap,"roughness",new hs(t.roughness,t.roughness,t.roughness)))):r.push(`${i}float inputs:roughness = ${t.roughness}`),null!==t.metalnessMap?(r.push(`${i}float inputs:metallic.connect = `),s.push(a(t.metalnessMap,"metallic",new hs(t.metalness,t.metalness,t.metalness)))):r.push(`${i}float inputs:metallic = ${t.metalness}`),null!==t.alphaMap?(r.push(`${i}float inputs:opacity.connect = `),r.push(`${i}float inputs:opacityThreshold = 0.0001`),s.push(a(t.alphaMap,"opacity"))):r.push(`${i}float inputs:opacity = ${t.opacity}`),t.isMeshPhysicalMaterial&&(null!==t.clearcoatMap?(r.push(`${i}float inputs:clearcoat.connect = `),s.push(a(t.clearcoatMap,"clearcoat",new hs(t.clearcoat,t.clearcoat,t.clearcoat)))):r.push(`${i}float inputs:clearcoat = ${t.clearcoat}`),null!==t.clearcoatRoughnessMap?(r.push(`${i}float inputs:clearcoatRoughness.connect = `),s.push(a(t.clearcoatRoughnessMap,"clearcoatRoughness",new hs(t.clearcoatRoughness,t.clearcoatRoughness,t.clearcoatRoughness)))):r.push(`${i}float inputs:clearcoatRoughness = ${t.clearcoatRoughness}`),r.push(`${i}float inputs:ior = ${t.ior}`)),`\n\tdef Material "Material_${t.id}"\n\t{\n\t\tdef Shader "PreviewSurface"\n\t\t{\n\t\t\tuniform token info:id = "UsdPreviewSurface"\n${r.join("\n")}\n\t\t\tint inputs:useSpecularWorkflow = 0\n\t\t\ttoken outputs:surface\n\t\t}\n\n\t\ttoken outputs:surface.connect = \n\n${s.join("\n")}\n\n\t}\n`}function hy(t){return`(${t.r}, ${t.g}, ${t.b})`}function uy(t){return`(${t.x}, ${t.y})`}const dy=new Gi,py=new zi,fy=new Gi;const my=new vr,gy=new vr,Ay=new Gi,vy=new Pf,yy=new Aa,_y=new Gi,xy=new ss;class wy{constructor(){this.tolerance=-1,this.faces=[],this.newFaces=[],this.assigned=new by,this.unassigned=new by,this.vertices=[]}setFromPoints(t){if(t.length>=4){this.makeEmpty();for(let e=0,n=t.length;ethis.tolerance)return!1;return!0}intersectRay(t,e){const n=this.faces;let i=-1/0,r=1/0;for(let e=0,s=n.length;e0&&o>=0)return null;const l=0!==o?-a/o:0;if(!(l<=0)&&(o>0?r=Math.min(l,r):i=Math.max(l,i),i>r))return null}return i!==-1/0?t.at(i,e):t.at(r,e),e}intersectsRay(t){return null!==this.intersectRay(t,Ay)}makeEmpty(){return this.faces=[],this.vertices=[],this}addVertexToFace(t,e){return t.face=e,null===e.outside?this.assigned.append(t):this.assigned.insertBefore(e.outside,t),e.outside=t,this}removeVertexFromFace(t,e){return t===e.outside&&(null!==t.next&&t.next.face===e?e.outside=t.next:e.outside=null),this.assigned.remove(t),this}removeAllVerticesFromFace(t){if(null!==t.outside){const e=t.outside;let n=t.outside;for(;null!==n.next&&n.next.face===t;)n=n.next;return this.assigned.removeSubList(e,n),e.prev=n.next=null,t.outside=null,e}}deleteFaceVertices(t,e){const n=this.removeAllVerticesFromFace(t);if(void 0!==n)if(void 0===e)this.unassigned.appendChain(n);else{let t=n;do{const n=t.next;e.distanceToPoint(t.point)>this.tolerance?this.addVertexToFace(t,e):this.unassigned.append(t),t=n}while(null!==t)}return this}resolveUnassignedPoints(t){if(!1===this.unassigned.isEmpty()){let e=this.unassigned.first();do{const n=e.next;let i=this.tolerance,r=null;for(let n=0;ni&&(i=t,r=s),i>1e3*this.tolerance)break}}null!==r&&this.addVertexToFace(e,r),e=n}while(null!==e)}return this}computeExtremes(){const t=new Gi,e=new Gi,n=[],i=[];for(let t=0;t<3;t++)n[t]=i[t]=this.vertices[0];t.copy(this.vertices[0].point),e.copy(this.vertices[0].point);for(let r=0,s=this.vertices.length;re.getComponent(t)&&(e.setComponent(t,a.getComponent(t)),i[t]=s)}return this.tolerance=3*Number.EPSILON*(Math.max(Math.abs(t.x),Math.abs(e.x))+Math.max(Math.abs(t.y),Math.abs(e.y))+Math.max(Math.abs(t.z),Math.abs(e.z))),{min:n,max:i}}computeInitialHull(){const t=this.vertices,e=this.computeExtremes(),n=e.min,i=e.max;let r=0,s=0;for(let t=0;t<3;t++){const e=i[t].point.getComponent(t)-n[t].point.getComponent(t);e>r&&(r=e,s=t)}const a=n[s],o=i[s];let l,c;r=0,vy.set(a.point,o.point);for(let e=0,n=this.vertices.length;er&&(r=t,l=n)}}r=-1,yy.setFromCoplanarPoints(a.point,o.point,l.point);for(let e=0,n=this.vertices.length;er&&(r=t,c=n)}}const h=[];if(yy.distanceToPoint(c.point)<0){h.push(Cy.create(a,o,l),Cy.create(c,o,a),Cy.create(c,l,o),Cy.create(c,a,l));for(let t=0;t<3;t++){const e=(t+1)%3;h[t+1].getEdge(2).setTwin(h[0].getEdge(e)),h[t+1].getEdge(1).setTwin(h[e+1].getEdge(0))}}else{h.push(Cy.create(a,l,o),Cy.create(c,a,o),Cy.create(c,o,l),Cy.create(c,l,a));for(let t=0;t<3;t++){const e=(t+1)%3;h[t+1].getEdge(2).setTwin(h[0].getEdge((3-t)%3)),h[t+1].getEdge(0).setTwin(h[e+1].getEdge(1))}}for(let t=0;t<4;t++)this.faces.push(h[t]);for(let e=0,n=t.length;er&&(r=i,t=this.faces[e])}null!==t&&this.addVertexToFace(n,t)}}return this}reindexFaces(){const t=[];for(let e=0;ee&&(e=r,t=i),i=i.next}while(null!==i&&i.face===n);return t}}computeHorizon(t,e,n,i){let r;this.deleteFaceVertices(n),n.mark=1,r=null===e?e=n.getEdge(0):e.next;do{const e=r.twin,n=e.face;0===n.mark&&(n.distanceToPoint(t)>this.tolerance?this.computeHorizon(t,e,n,i):i.push(r)),r=r.next}while(r!==e);return this}addAdjoiningFace(t,e){const n=Cy.create(t,e.tail(),e.head());return this.faces.push(n),n.getEdge(-1).setTwin(e.twin),n.getEdge(0)}addNewFaces(t,e){this.newFaces=[];let n=null,i=null;for(let r=0;r0;)e=e.next,t--;for(;t<0;)e=e.prev,t++;return e}compute(){const t=this.edge.tail(),e=this.edge.head(),n=this.edge.next.head();return xy.set(t.point,e.point,n.point),xy.getNormal(this.normal),xy.getMidpoint(this.midpoint),this.area=xy.getArea(),this.constant=this.normal.dot(this.midpoint),this}distanceToPoint(t){return this.normal.dot(t)-this.constant}}class Ey{constructor(t,e){this.vertex=t,this.prev=null,this.next=null,this.twin=null,this.face=e}head(){return this.vertex}tail(){return this.prev?this.prev.vertex:null}length(){const t=this.head(),e=this.tail();return null!==e?e.point.distanceTo(t.point):-1}lengthSquared(){const t=this.head(),e=this.tail();return null!==e?e.point.distanceToSquared(t.point):-1}setTwin(t){return this.twin=t,t.twin=this,this}}class My{constructor(t){this.point=t,this.prev=null,this.next=null,this.face=null}}class by{constructor(){this.head=null,this.tail=null}first(){return this.head}last(){return this.tail}clear(){return this.head=this.tail=null,this}insertBefore(t,e){return e.prev=t.prev,e.next=t,null===e.prev?this.head=e:e.prev.next=e,t.prev=e,this}insertAfter(t,e){return e.prev=t,e.next=t.next,null===e.next?this.tail=e:e.next.prev=e,t.next=e,this}append(t){return null===this.head?this.head=t:this.tail.next=t,t.prev=this.tail,t.next=null,this.tail=t,this}appendChain(t){for(null===this.head?this.head=t:this.tail.next=t,t.prev=this.tail;null!==t.next;)t=t.next;return this.tail=t,this}remove(t){return null===t.prev?this.head=t.next:t.prev.next=t.next,null===t.next?this.tail=t.prev:t.next.prev=t.prev,this}removeSubList(t,e){return null===t.prev?this.head=e.next:t.prev.next=e.next,null===e.next?this.tail=t.prev:e.next.prev=t.prev,this}isEmpty(){return null===this.head}}function Sy(t,e){switch(e){case hn:t.convertSRGBToLinear();break;case un:case cn:break;default:console.warn("WARNING: LightProbeGenerator convertColorToLinear() encountered an unsupported color space.")}return t}class Iy{constructor(t,e,n,i,r){this.xrLight=t,this.renderer=e,this.lightProbe=n,this.xrWebGLBinding=null,this.estimationStartCallback=r,this.frameCallback=this.onXRFrame.bind(this);const s=e.xr.getSession();if(i&&"XRWebGLBinding"in window){const n=new pa(16);t.environment=n.texture;const i=e.getContext();switch(s.preferredReflectionFormat){case"srgba8":i.getExtension("EXT_sRGB");break;case"rgba16f":i.getExtension("OES_texture_half_float")}this.xrWebGLBinding=new XRWebGLBinding(s,i),this.lightProbe.addEventListener("reflectionchange",(()=>{this.updateReflection()}))}s.requestAnimationFrame(this.frameCallback)}updateReflection(){const t=this.renderer.properties.get(this.xrLight.environment);if(t){const e=this.xrWebGLBinding.getReflectionCubeMap(this.lightProbe);e&&(t.__webglTexture=e,this.xrLight.environment.needsPMREMUpdate=!0)}}onXRFrame(t,e){if(!this.xrLight)return;e.session.requestAnimationFrame(this.frameCallback);const n=e.getLightEstimate(this.lightProbe);if(n){this.xrLight.lightProbe.sh.fromArray(n.sphericalHarmonicsCoefficients),this.xrLight.lightProbe.intensity=1;const t=Math.max(1,Math.max(n.primaryLightIntensity.x,Math.max(n.primaryLightIntensity.y,n.primaryLightIntensity.z)));this.xrLight.directionalLight.color.setRGB(n.primaryLightIntensity.x/t,n.primaryLightIntensity.y/t,n.primaryLightIntensity.z/t),this.xrLight.directionalLight.intensity=t,this.xrLight.directionalLight.position.copy(n.primaryLightDirection),this.estimationStartCallback&&(this.estimationStartCallback(),this.estimationStartCallback=null)}}dispose(){this.xrLight=null,this.renderer=null,this.lightProbe=null,this.xrWebGLBinding=null}}class Ty{constructor(t=4){this.pool=t,this.queue=[],this.workers=[],this.workersResolve=[],this.workerStatus=0}_initWorker(t){if(!this.workers[t]){const e=this.workerCreator();e.addEventListener("message",this._onMessage.bind(this,t)),this.workers[t]=e}}_getIdleWorker(){for(let t=0;t{const i=this._getIdleWorker();-1!==i?(this._initWorker(i),this.workerStatus|=1<t.terminate())),this.workersResolve.length=0,this.workers.length=0,this.queue.length=0,this.workerStatus=0}}const By=9,Ry=15,Dy=16,Py=22,Ly=37,Uy=43,Ny=76,Fy=83,Oy=97,ky=100,Qy=103,zy=109,Gy=165,Hy=166,Vy=1000066e3;class Wy{constructor(){this.vkFormat=0,this.typeSize=1,this.pixelWidth=0,this.pixelHeight=0,this.pixelDepth=0,this.layerCount=0,this.faceCount=1,this.supercompressionScheme=0,this.levels=[],this.dataFormatDescriptor=[{vendorId:0,descriptorType:0,descriptorBlockSize:0,versionNumber:2,colorModel:0,colorPrimaries:1,transferFunction:2,flags:0,texelBlockDimension:[0,0,0,0],bytesPlane:[0,0,0,0,0,0,0,0],samples:[]}],this.keyValue={},this.globalData=null}}class jy{constructor(t,e,n,i){this._dataView=void 0,this._littleEndian=void 0,this._offset=void 0,this._dataView=new DataView(t.buffer,t.byteOffset+e,n),this._littleEndian=i,this._offset=0}_nextUint8(){const t=this._dataView.getUint8(this._offset);return this._offset+=1,t}_nextUint16(){const t=this._dataView.getUint16(this._offset,this._littleEndian);return this._offset+=2,t}_nextUint32(){const t=this._dataView.getUint32(this._offset,this._littleEndian);return this._offset+=4,t}_nextUint64(){const t=this._dataView.getUint32(this._offset,this._littleEndian)+2**32*this._dataView.getUint32(this._offset+4,this._littleEndian);return this._offset+=8,t}_nextInt32(){const t=this._dataView.getInt32(this._offset,this._littleEndian);return this._offset+=4,t}_nextUint8Array(t){const e=new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+this._offset,t);return this._offset+=t,e}_skip(t){return this._offset+=t,this}_scan(t,e){void 0===e&&(e=0);const n=this._offset;let i=0;for(;this._dataView.getUint8(this._offset)!==e&&it.arrayBuffer())).then((t=>WebAssembly.instantiate(t,Zy))).then(this._init):WebAssembly.instantiate(Buffer.from(t_,"base64"),Zy).then(this._init),Yy)}_init(t){Jy=t.instance,Zy.env.emscripten_notify_memory_growth(0)}decode(t,e=0){if(!Jy)throw new Error("ZSTDDecoder: Await .init() before decoding.");const n=t.byteLength,i=Jy.exports.malloc(n);Ky.set(t,i),e=e||Number(Jy.exports.ZSTD_findDecompressedSize(i,n));const r=Jy.exports.malloc(e),s=Jy.exports.ZSTD_decompress(r,e,i,n),a=Ky.slice(r,r+s);return Jy.exports.free(i),Jy.exports.free(r),a}}const t_="AGFzbQEAAAABpQEVYAF/AX9gAn9/AGADf39/AX9gBX9/f39/AX9gAX8AYAJ/fwF/YAR/f39/AX9gA39/fwBgBn9/f39/fwF/YAd/f39/f39/AX9gAn9/AX5gAn5+AX5gAABgBX9/f39/AGAGf39/f39/AGAIf39/f39/f38AYAl/f39/f39/f38AYAABf2AIf39/f39/f38Bf2ANf39/f39/f39/f39/fwF/YAF/AX4CJwEDZW52H2Vtc2NyaXB0ZW5fbm90aWZ5X21lbW9yeV9ncm93dGgABANpaAEFAAAFAgEFCwACAQABAgIFBQcAAwABDgsBAQcAEhMHAAUBDAQEAAANBwQCAgYCBAgDAwMDBgEACQkHBgICAAYGAgQUBwYGAwIGAAMCAQgBBwUGCgoEEQAEBAEIAwgDBQgDEA8IAAcABAUBcAECAgUEAQCAAgYJAX8BQaCgwAILB2AHBm1lbW9yeQIABm1hbGxvYwAoBGZyZWUAJgxaU1REX2lzRXJyb3IAaBlaU1REX2ZpbmREZWNvbXByZXNzZWRTaXplAFQPWlNURF9kZWNvbXByZXNzAEoGX3N0YXJ0ACQJBwEAQQELASQKussBaA8AIAAgACgCBCABajYCBAsZACAAKAIAIAAoAgRBH3F0QQAgAWtBH3F2CwgAIABBiH9LC34BBH9BAyEBIAAoAgQiA0EgTQRAIAAoAggiASAAKAIQTwRAIAAQDQ8LIAAoAgwiAiABRgRAQQFBAiADQSBJGw8LIAAgASABIAJrIANBA3YiBCABIARrIAJJIgEbIgJrIgQ2AgggACADIAJBA3RrNgIEIAAgBCgAADYCAAsgAQsUAQF/IAAgARACIQIgACABEAEgAgv3AQECfyACRQRAIABCADcCACAAQQA2AhAgAEIANwIIQbh/DwsgACABNgIMIAAgAUEEajYCECACQQRPBEAgACABIAJqIgFBfGoiAzYCCCAAIAMoAAA2AgAgAUF/ai0AACIBBEAgAEEIIAEQFGs2AgQgAg8LIABBADYCBEF/DwsgACABNgIIIAAgAS0AACIDNgIAIAJBfmoiBEEBTQRAIARBAWtFBEAgACABLQACQRB0IANyIgM2AgALIAAgAS0AAUEIdCADajYCAAsgASACakF/ai0AACIBRQRAIABBADYCBEFsDwsgAEEoIAEQFCACQQN0ams2AgQgAgsWACAAIAEpAAA3AAAgACABKQAINwAICy8BAX8gAUECdEGgHWooAgAgACgCAEEgIAEgACgCBGprQR9xdnEhAiAAIAEQASACCyEAIAFCz9bTvtLHq9lCfiAAfEIfiUKHla+vmLbem55/fgsdAQF/IAAoAgggACgCDEYEfyAAKAIEQSBGBUEACwuCBAEDfyACQYDAAE8EQCAAIAEgAhBnIAAPCyAAIAJqIQMCQCAAIAFzQQNxRQRAAkAgAkEBSARAIAAhAgwBCyAAQQNxRQRAIAAhAgwBCyAAIQIDQCACIAEtAAA6AAAgAUEBaiEBIAJBAWoiAiADTw0BIAJBA3ENAAsLAkAgA0F8cSIEQcAASQ0AIAIgBEFAaiIFSw0AA0AgAiABKAIANgIAIAIgASgCBDYCBCACIAEoAgg2AgggAiABKAIMNgIMIAIgASgCEDYCECACIAEoAhQ2AhQgAiABKAIYNgIYIAIgASgCHDYCHCACIAEoAiA2AiAgAiABKAIkNgIkIAIgASgCKDYCKCACIAEoAiw2AiwgAiABKAIwNgIwIAIgASgCNDYCNCACIAEoAjg2AjggAiABKAI8NgI8IAFBQGshASACQUBrIgIgBU0NAAsLIAIgBE8NAQNAIAIgASgCADYCACABQQRqIQEgAkEEaiICIARJDQALDAELIANBBEkEQCAAIQIMAQsgA0F8aiIEIABJBEAgACECDAELIAAhAgNAIAIgAS0AADoAACACIAEtAAE6AAEgAiABLQACOgACIAIgAS0AAzoAAyABQQRqIQEgAkEEaiICIARNDQALCyACIANJBEADQCACIAEtAAA6AAAgAUEBaiEBIAJBAWoiAiADRw0ACwsgAAsMACAAIAEpAAA3AAALQQECfyAAKAIIIgEgACgCEEkEQEEDDwsgACAAKAIEIgJBB3E2AgQgACABIAJBA3ZrIgE2AgggACABKAAANgIAQQALDAAgACABKAIANgAAC/cCAQJ/AkAgACABRg0AAkAgASACaiAASwRAIAAgAmoiBCABSw0BCyAAIAEgAhALDwsgACABc0EDcSEDAkACQCAAIAFJBEAgAwRAIAAhAwwDCyAAQQNxRQRAIAAhAwwCCyAAIQMDQCACRQ0EIAMgAS0AADoAACABQQFqIQEgAkF/aiECIANBAWoiA0EDcQ0ACwwBCwJAIAMNACAEQQNxBEADQCACRQ0FIAAgAkF/aiICaiIDIAEgAmotAAA6AAAgA0EDcQ0ACwsgAkEDTQ0AA0AgACACQXxqIgJqIAEgAmooAgA2AgAgAkEDSw0ACwsgAkUNAgNAIAAgAkF/aiICaiABIAJqLQAAOgAAIAINAAsMAgsgAkEDTQ0AIAIhBANAIAMgASgCADYCACABQQRqIQEgA0EEaiEDIARBfGoiBEEDSw0ACyACQQNxIQILIAJFDQADQCADIAEtAAA6AAAgA0EBaiEDIAFBAWohASACQX9qIgINAAsLIAAL8wICAn8BfgJAIAJFDQAgACACaiIDQX9qIAE6AAAgACABOgAAIAJBA0kNACADQX5qIAE6AAAgACABOgABIANBfWogAToAACAAIAE6AAIgAkEHSQ0AIANBfGogAToAACAAIAE6AAMgAkEJSQ0AIABBACAAa0EDcSIEaiIDIAFB/wFxQYGChAhsIgE2AgAgAyACIARrQXxxIgRqIgJBfGogATYCACAEQQlJDQAgAyABNgIIIAMgATYCBCACQXhqIAE2AgAgAkF0aiABNgIAIARBGUkNACADIAE2AhggAyABNgIUIAMgATYCECADIAE2AgwgAkFwaiABNgIAIAJBbGogATYCACACQWhqIAE2AgAgAkFkaiABNgIAIAQgA0EEcUEYciIEayICQSBJDQAgAa0iBUIghiAFhCEFIAMgBGohAQNAIAEgBTcDGCABIAU3AxAgASAFNwMIIAEgBTcDACABQSBqIQEgAkFgaiICQR9LDQALCyAACy8BAn8gACgCBCAAKAIAQQJ0aiICLQACIQMgACACLwEAIAEgAi0AAxAIajYCACADCy8BAn8gACgCBCAAKAIAQQJ0aiICLQACIQMgACACLwEAIAEgAi0AAxAFajYCACADCx8AIAAgASACKAIEEAg2AgAgARAEGiAAIAJBCGo2AgQLCAAgAGdBH3MLugUBDX8jAEEQayIKJAACfyAEQQNNBEAgCkEANgIMIApBDGogAyAEEAsaIAAgASACIApBDGpBBBAVIgBBbCAAEAMbIAAgACAESxsMAQsgAEEAIAEoAgBBAXRBAmoQECENQVQgAygAACIGQQ9xIgBBCksNABogAiAAQQVqNgIAIAMgBGoiAkF8aiEMIAJBeWohDiACQXtqIRAgAEEGaiELQQQhBSAGQQR2IQRBICAAdCIAQQFyIQkgASgCACEPQQAhAiADIQYCQANAIAlBAkggAiAPS3JFBEAgAiEHAkAgCARAA0AgBEH//wNxQf//A0YEQCAHQRhqIQcgBiAQSQR/IAZBAmoiBigAACAFdgUgBUEQaiEFIARBEHYLIQQMAQsLA0AgBEEDcSIIQQNGBEAgBUECaiEFIARBAnYhBCAHQQNqIQcMAQsLIAcgCGoiByAPSw0EIAVBAmohBQNAIAIgB0kEQCANIAJBAXRqQQA7AQAgAkEBaiECDAELCyAGIA5LQQAgBiAFQQN1aiIHIAxLG0UEQCAHKAAAIAVBB3EiBXYhBAwCCyAEQQJ2IQQLIAYhBwsCfyALQX9qIAQgAEF/anEiBiAAQQF0QX9qIgggCWsiEUkNABogBCAIcSIEQQAgESAEIABIG2shBiALCyEIIA0gAkEBdGogBkF/aiIEOwEAIAlBASAGayAEIAZBAUgbayEJA0AgCSAASARAIABBAXUhACALQX9qIQsMAQsLAn8gByAOS0EAIAcgBSAIaiIFQQN1aiIGIAxLG0UEQCAFQQdxDAELIAUgDCIGIAdrQQN0awshBSACQQFqIQIgBEUhCCAGKAAAIAVBH3F2IQQMAQsLQWwgCUEBRyAFQSBKcg0BGiABIAJBf2o2AgAgBiAFQQdqQQN1aiADawwBC0FQCyEAIApBEGokACAACwkAQQFBBSAAGwsMACAAIAEoAAA2AAALqgMBCn8jAEHwAGsiCiQAIAJBAWohDiAAQQhqIQtBgIAEIAVBf2p0QRB1IQxBACECQQEhBkEBIAV0IglBf2oiDyEIA0AgAiAORkUEQAJAIAEgAkEBdCINai8BACIHQf//A0YEQCALIAhBA3RqIAI2AgQgCEF/aiEIQQEhBwwBCyAGQQAgDCAHQRB0QRB1ShshBgsgCiANaiAHOwEAIAJBAWohAgwBCwsgACAFNgIEIAAgBjYCACAJQQN2IAlBAXZqQQNqIQxBACEAQQAhBkEAIQIDQCAGIA5GBEADQAJAIAAgCUYNACAKIAsgAEEDdGoiASgCBCIGQQF0aiICIAIvAQAiAkEBajsBACABIAUgAhAUayIIOgADIAEgAiAIQf8BcXQgCWs7AQAgASAEIAZBAnQiAmooAgA6AAIgASACIANqKAIANgIEIABBAWohAAwBCwsFIAEgBkEBdGouAQAhDUEAIQcDQCAHIA1ORQRAIAsgAkEDdGogBjYCBANAIAIgDGogD3EiAiAISw0ACyAHQQFqIQcMAQsLIAZBAWohBgwBCwsgCkHwAGokAAsjAEIAIAEQCSAAhUKHla+vmLbem55/fkLj3MqV/M7y9YV/fAsQACAAQn43AwggACABNgIACyQBAX8gAARAIAEoAgQiAgRAIAEoAgggACACEQEADwsgABAmCwsfACAAIAEgAi8BABAINgIAIAEQBBogACACQQRqNgIEC0oBAX9BoCAoAgAiASAAaiIAQX9MBEBBiCBBMDYCAEF/DwsCQCAAPwBBEHRNDQAgABBmDQBBiCBBMDYCAEF/DwtBoCAgADYCACABC9cBAQh/Qbp/IQoCQCACKAIEIgggAigCACIJaiIOIAEgAGtLDQBBbCEKIAkgBCADKAIAIgtrSw0AIAAgCWoiBCACKAIIIgxrIQ0gACABQWBqIg8gCyAJQQAQKSADIAkgC2o2AgACQAJAIAwgBCAFa00EQCANIQUMAQsgDCAEIAZrSw0CIAcgDSAFayIAaiIBIAhqIAdNBEAgBCABIAgQDxoMAgsgBCABQQAgAGsQDyEBIAIgACAIaiIINgIEIAEgAGshBAsgBCAPIAUgCEEBECkLIA4hCgsgCgubAgEBfyMAQYABayINJAAgDSADNgJ8AkAgAkEDSwRAQX8hCQwBCwJAAkACQAJAIAJBAWsOAwADAgELIAZFBEBBuH8hCQwEC0FsIQkgBS0AACICIANLDQMgACAHIAJBAnQiAmooAgAgAiAIaigCABA7IAEgADYCAEEBIQkMAwsgASAJNgIAQQAhCQwCCyAKRQRAQWwhCQwCC0EAIQkgC0UgDEEZSHINAUEIIAR0QQhqIQBBACECA0AgAiAATw0CIAJBQGshAgwAAAsAC0FsIQkgDSANQfwAaiANQfgAaiAFIAYQFSICEAMNACANKAJ4IgMgBEsNACAAIA0gDSgCfCAHIAggAxAYIAEgADYCACACIQkLIA1BgAFqJAAgCQsLACAAIAEgAhALGgsQACAALwAAIAAtAAJBEHRyCy8AAn9BuH8gAUEISQ0AGkFyIAAoAAQiAEF3Sw0AGkG4fyAAQQhqIgAgACABSxsLCwkAIAAgATsAAAsDAAELigYBBX8gACAAKAIAIgVBfnE2AgBBACAAIAVBAXZqQYQgKAIAIgQgAEYbIQECQAJAIAAoAgQiAkUNACACKAIAIgNBAXENACACQQhqIgUgA0EBdkF4aiIDQQggA0EISxtnQR9zQQJ0QYAfaiIDKAIARgRAIAMgAigCDDYCAAsgAigCCCIDBEAgAyACKAIMNgIECyACKAIMIgMEQCADIAIoAgg2AgALIAIgAigCACAAKAIAQX5xajYCAEGEICEAAkACQCABRQ0AIAEgAjYCBCABKAIAIgNBAXENASADQQF2QXhqIgNBCCADQQhLG2dBH3NBAnRBgB9qIgMoAgAgAUEIakYEQCADIAEoAgw2AgALIAEoAggiAwRAIAMgASgCDDYCBAsgASgCDCIDBEAgAyABKAIINgIAQYQgKAIAIQQLIAIgAigCACABKAIAQX5xajYCACABIARGDQAgASABKAIAQQF2akEEaiEACyAAIAI2AgALIAIoAgBBAXZBeGoiAEEIIABBCEsbZ0Efc0ECdEGAH2oiASgCACEAIAEgBTYCACACIAA2AgwgAkEANgIIIABFDQEgACAFNgIADwsCQCABRQ0AIAEoAgAiAkEBcQ0AIAJBAXZBeGoiAkEIIAJBCEsbZ0Efc0ECdEGAH2oiAigCACABQQhqRgRAIAIgASgCDDYCAAsgASgCCCICBEAgAiABKAIMNgIECyABKAIMIgIEQCACIAEoAgg2AgBBhCAoAgAhBAsgACAAKAIAIAEoAgBBfnFqIgI2AgACQCABIARHBEAgASABKAIAQQF2aiAANgIEIAAoAgAhAgwBC0GEICAANgIACyACQQF2QXhqIgFBCCABQQhLG2dBH3NBAnRBgB9qIgIoAgAhASACIABBCGoiAjYCACAAIAE2AgwgAEEANgIIIAFFDQEgASACNgIADwsgBUEBdkF4aiIBQQggAUEISxtnQR9zQQJ0QYAfaiICKAIAIQEgAiAAQQhqIgI2AgAgACABNgIMIABBADYCCCABRQ0AIAEgAjYCAAsLDgAgAARAIABBeGoQJQsLgAIBA38CQCAAQQ9qQXhxQYQgKAIAKAIAQQF2ayICEB1Bf0YNAAJAQYQgKAIAIgAoAgAiAUEBcQ0AIAFBAXZBeGoiAUEIIAFBCEsbZ0Efc0ECdEGAH2oiASgCACAAQQhqRgRAIAEgACgCDDYCAAsgACgCCCIBBEAgASAAKAIMNgIECyAAKAIMIgFFDQAgASAAKAIINgIAC0EBIQEgACAAKAIAIAJBAXRqIgI2AgAgAkEBcQ0AIAJBAXZBeGoiAkEIIAJBCEsbZ0Efc0ECdEGAH2oiAygCACECIAMgAEEIaiIDNgIAIAAgAjYCDCAAQQA2AgggAkUNACACIAM2AgALIAELtwIBA38CQAJAIABBASAAGyICEDgiAA0AAkACQEGEICgCACIARQ0AIAAoAgAiA0EBcQ0AIAAgA0EBcjYCACADQQF2QXhqIgFBCCABQQhLG2dBH3NBAnRBgB9qIgEoAgAgAEEIakYEQCABIAAoAgw2AgALIAAoAggiAQRAIAEgACgCDDYCBAsgACgCDCIBBEAgASAAKAIINgIACyACECchAkEAIQFBhCAoAgAhACACDQEgACAAKAIAQX5xNgIAQQAPCyACQQ9qQXhxIgMQHSICQX9GDQIgAkEHakF4cSIAIAJHBEAgACACaxAdQX9GDQMLAkBBhCAoAgAiAUUEQEGAICAANgIADAELIAAgATYCBAtBhCAgADYCACAAIANBAXRBAXI2AgAMAQsgAEUNAQsgAEEIaiEBCyABC7kDAQJ/IAAgA2ohBQJAIANBB0wEQANAIAAgBU8NAiAAIAItAAA6AAAgAEEBaiEAIAJBAWohAgwAAAsACyAEQQFGBEACQCAAIAJrIgZBB00EQCAAIAItAAA6AAAgACACLQABOgABIAAgAi0AAjoAAiAAIAItAAM6AAMgAEEEaiACIAZBAnQiBkHAHmooAgBqIgIQFyACIAZB4B5qKAIAayECDAELIAAgAhAMCyACQQhqIQIgAEEIaiEACwJAAkACQAJAIAUgAU0EQCAAIANqIQEgBEEBRyAAIAJrQQ9Kcg0BA0AgACACEAwgAkEIaiECIABBCGoiACABSQ0ACwwFCyAAIAFLBEAgACEBDAQLIARBAUcgACACa0EPSnINASAAIQMgAiEEA0AgAyAEEAwgBEEIaiEEIANBCGoiAyABSQ0ACwwCCwNAIAAgAhAHIAJBEGohAiAAQRBqIgAgAUkNAAsMAwsgACEDIAIhBANAIAMgBBAHIARBEGohBCADQRBqIgMgAUkNAAsLIAIgASAAa2ohAgsDQCABIAVPDQEgASACLQAAOgAAIAFBAWohASACQQFqIQIMAAALAAsLQQECfyAAIAAoArjgASIDNgLE4AEgACgCvOABIQQgACABNgK84AEgACABIAJqNgK44AEgACABIAQgA2tqNgLA4AELpgEBAX8gACAAKALs4QEQFjYCyOABIABCADcD+OABIABCADcDuOABIABBwOABakIANwMAIABBqNAAaiIBQYyAgOAANgIAIABBADYCmOIBIABCADcDiOEBIABCAzcDgOEBIABBrNABakHgEikCADcCACAAQbTQAWpB6BIoAgA2AgAgACABNgIMIAAgAEGYIGo2AgggACAAQaAwajYCBCAAIABBEGo2AgALYQEBf0G4fyEDAkAgAUEDSQ0AIAIgABAhIgFBA3YiADYCCCACIAFBAXE2AgQgAiABQQF2QQNxIgM2AgACQCADQX9qIgFBAksNAAJAIAFBAWsOAgEAAgtBbA8LIAAhAwsgAwsMACAAIAEgAkEAEC4LiAQCA38CfiADEBYhBCAAQQBBKBAQIQAgBCACSwRAIAQPCyABRQRAQX8PCwJAAkAgA0EBRg0AIAEoAAAiBkGo6r5pRg0AQXYhAyAGQXBxQdDUtMIBRw0BQQghAyACQQhJDQEgAEEAQSgQECEAIAEoAAQhASAAQQE2AhQgACABrTcDAEEADwsgASACIAMQLyIDIAJLDQAgACADNgIYQXIhAyABIARqIgVBf2otAAAiAkEIcQ0AIAJBIHEiBkUEQEFwIQMgBS0AACIFQacBSw0BIAVBB3GtQgEgBUEDdkEKaq2GIgdCA4h+IAd8IQggBEEBaiEECyACQQZ2IQMgAkECdiEFAkAgAkEDcUF/aiICQQJLBEBBACECDAELAkACQAJAIAJBAWsOAgECAAsgASAEai0AACECIARBAWohBAwCCyABIARqLwAAIQIgBEECaiEEDAELIAEgBGooAAAhAiAEQQRqIQQLIAVBAXEhBQJ+AkACQAJAIANBf2oiA0ECTQRAIANBAWsOAgIDAQtCfyAGRQ0DGiABIARqMQAADAMLIAEgBGovAACtQoACfAwCCyABIARqKAAArQwBCyABIARqKQAACyEHIAAgBTYCICAAIAI2AhwgACAHNwMAQQAhAyAAQQA2AhQgACAHIAggBhsiBzcDCCAAIAdCgIAIIAdCgIAIVBs+AhALIAMLWwEBf0G4fyEDIAIQFiICIAFNBH8gACACakF/ai0AACIAQQNxQQJ0QaAeaigCACACaiAAQQZ2IgFBAnRBsB5qKAIAaiAAQSBxIgBFaiABRSAAQQV2cWoFQbh/CwsdACAAKAKQ4gEQWiAAQQA2AqDiASAAQgA3A5DiAQu1AwEFfyMAQZACayIKJABBuH8hBgJAIAVFDQAgBCwAACIIQf8BcSEHAkAgCEF/TARAIAdBgn9qQQF2IgggBU8NAkFsIQYgB0GBf2oiBUGAAk8NAiAEQQFqIQdBACEGA0AgBiAFTwRAIAUhBiAIIQcMAwUgACAGaiAHIAZBAXZqIgQtAABBBHY6AAAgACAGQQFyaiAELQAAQQ9xOgAAIAZBAmohBgwBCwAACwALIAcgBU8NASAAIARBAWogByAKEFMiBhADDQELIAYhBEEAIQYgAUEAQTQQECEJQQAhBQNAIAQgBkcEQCAAIAZqIggtAAAiAUELSwRAQWwhBgwDBSAJIAFBAnRqIgEgASgCAEEBajYCACAGQQFqIQZBASAILQAAdEEBdSAFaiEFDAILAAsLQWwhBiAFRQ0AIAUQFEEBaiIBQQxLDQAgAyABNgIAQQFBASABdCAFayIDEBQiAXQgA0cNACAAIARqIAFBAWoiADoAACAJIABBAnRqIgAgACgCAEEBajYCACAJKAIEIgBBAkkgAEEBcXINACACIARBAWo2AgAgB0EBaiEGCyAKQZACaiQAIAYLxhEBDH8jAEHwAGsiBSQAQWwhCwJAIANBCkkNACACLwAAIQogAi8AAiEJIAIvAAQhByAFQQhqIAQQDgJAIAMgByAJIApqakEGaiIMSQ0AIAUtAAohCCAFQdgAaiACQQZqIgIgChAGIgsQAw0BIAVBQGsgAiAKaiICIAkQBiILEAMNASAFQShqIAIgCWoiAiAHEAYiCxADDQEgBUEQaiACIAdqIAMgDGsQBiILEAMNASAAIAFqIg9BfWohECAEQQRqIQZBASELIAAgAUEDakECdiIDaiIMIANqIgIgA2oiDiEDIAIhBCAMIQcDQCALIAMgEElxBEAgACAGIAVB2ABqIAgQAkECdGoiCS8BADsAACAFQdgAaiAJLQACEAEgCS0AAyELIAcgBiAFQUBrIAgQAkECdGoiCS8BADsAACAFQUBrIAktAAIQASAJLQADIQogBCAGIAVBKGogCBACQQJ0aiIJLwEAOwAAIAVBKGogCS0AAhABIAktAAMhCSADIAYgBUEQaiAIEAJBAnRqIg0vAQA7AAAgBUEQaiANLQACEAEgDS0AAyENIAAgC2oiCyAGIAVB2ABqIAgQAkECdGoiAC8BADsAACAFQdgAaiAALQACEAEgAC0AAyEAIAcgCmoiCiAGIAVBQGsgCBACQQJ0aiIHLwEAOwAAIAVBQGsgBy0AAhABIActAAMhByAEIAlqIgkgBiAFQShqIAgQAkECdGoiBC8BADsAACAFQShqIAQtAAIQASAELQADIQQgAyANaiIDIAYgBUEQaiAIEAJBAnRqIg0vAQA7AAAgBUEQaiANLQACEAEgACALaiEAIAcgCmohByAEIAlqIQQgAyANLQADaiEDIAVB2ABqEA0gBUFAaxANciAFQShqEA1yIAVBEGoQDXJFIQsMAQsLIAQgDksgByACS3INAEFsIQsgACAMSw0BIAxBfWohCQNAQQAgACAJSSAFQdgAahAEGwRAIAAgBiAFQdgAaiAIEAJBAnRqIgovAQA7AAAgBUHYAGogCi0AAhABIAAgCi0AA2oiACAGIAVB2ABqIAgQAkECdGoiCi8BADsAACAFQdgAaiAKLQACEAEgACAKLQADaiEADAEFIAxBfmohCgNAIAVB2ABqEAQgACAKS3JFBEAgACAGIAVB2ABqIAgQAkECdGoiCS8BADsAACAFQdgAaiAJLQACEAEgACAJLQADaiEADAELCwNAIAAgCk0EQCAAIAYgBUHYAGogCBACQQJ0aiIJLwEAOwAAIAVB2ABqIAktAAIQASAAIAktAANqIQAMAQsLAkAgACAMTw0AIAAgBiAFQdgAaiAIEAIiAEECdGoiDC0AADoAACAMLQADQQFGBEAgBUHYAGogDC0AAhABDAELIAUoAlxBH0sNACAFQdgAaiAGIABBAnRqLQACEAEgBSgCXEEhSQ0AIAVBIDYCXAsgAkF9aiEMA0BBACAHIAxJIAVBQGsQBBsEQCAHIAYgBUFAayAIEAJBAnRqIgAvAQA7AAAgBUFAayAALQACEAEgByAALQADaiIAIAYgBUFAayAIEAJBAnRqIgcvAQA7AAAgBUFAayAHLQACEAEgACAHLQADaiEHDAEFIAJBfmohDANAIAVBQGsQBCAHIAxLckUEQCAHIAYgBUFAayAIEAJBAnRqIgAvAQA7AAAgBUFAayAALQACEAEgByAALQADaiEHDAELCwNAIAcgDE0EQCAHIAYgBUFAayAIEAJBAnRqIgAvAQA7AAAgBUFAayAALQACEAEgByAALQADaiEHDAELCwJAIAcgAk8NACAHIAYgBUFAayAIEAIiAEECdGoiAi0AADoAACACLQADQQFGBEAgBUFAayACLQACEAEMAQsgBSgCREEfSw0AIAVBQGsgBiAAQQJ0ai0AAhABIAUoAkRBIUkNACAFQSA2AkQLIA5BfWohAgNAQQAgBCACSSAFQShqEAQbBEAgBCAGIAVBKGogCBACQQJ0aiIALwEAOwAAIAVBKGogAC0AAhABIAQgAC0AA2oiACAGIAVBKGogCBACQQJ0aiIELwEAOwAAIAVBKGogBC0AAhABIAAgBC0AA2ohBAwBBSAOQX5qIQIDQCAFQShqEAQgBCACS3JFBEAgBCAGIAVBKGogCBACQQJ0aiIALwEAOwAAIAVBKGogAC0AAhABIAQgAC0AA2ohBAwBCwsDQCAEIAJNBEAgBCAGIAVBKGogCBACQQJ0aiIALwEAOwAAIAVBKGogAC0AAhABIAQgAC0AA2ohBAwBCwsCQCAEIA5PDQAgBCAGIAVBKGogCBACIgBBAnRqIgItAAA6AAAgAi0AA0EBRgRAIAVBKGogAi0AAhABDAELIAUoAixBH0sNACAFQShqIAYgAEECdGotAAIQASAFKAIsQSFJDQAgBUEgNgIsCwNAQQAgAyAQSSAFQRBqEAQbBEAgAyAGIAVBEGogCBACQQJ0aiIALwEAOwAAIAVBEGogAC0AAhABIAMgAC0AA2oiACAGIAVBEGogCBACQQJ0aiICLwEAOwAAIAVBEGogAi0AAhABIAAgAi0AA2ohAwwBBSAPQX5qIQIDQCAFQRBqEAQgAyACS3JFBEAgAyAGIAVBEGogCBACQQJ0aiIALwEAOwAAIAVBEGogAC0AAhABIAMgAC0AA2ohAwwBCwsDQCADIAJNBEAgAyAGIAVBEGogCBACQQJ0aiIALwEAOwAAIAVBEGogAC0AAhABIAMgAC0AA2ohAwwBCwsCQCADIA9PDQAgAyAGIAVBEGogCBACIgBBAnRqIgItAAA6AAAgAi0AA0EBRgRAIAVBEGogAi0AAhABDAELIAUoAhRBH0sNACAFQRBqIAYgAEECdGotAAIQASAFKAIUQSFJDQAgBUEgNgIUCyABQWwgBUHYAGoQCiAFQUBrEApxIAVBKGoQCnEgBUEQahAKcRshCwwJCwAACwALAAALAAsAAAsACwAACwALQWwhCwsgBUHwAGokACALC7UEAQ5/IwBBEGsiBiQAIAZBBGogABAOQVQhBQJAIARB3AtJDQAgBi0ABCEHIANB8ARqQQBB7AAQECEIIAdBDEsNACADQdwJaiIJIAggBkEIaiAGQQxqIAEgAhAxIhAQA0UEQCAGKAIMIgQgB0sNASADQdwFaiEPIANBpAVqIREgAEEEaiESIANBqAVqIQEgBCEFA0AgBSICQX9qIQUgCCACQQJ0aigCAEUNAAsgAkEBaiEOQQEhBQNAIAUgDk9FBEAgCCAFQQJ0IgtqKAIAIQwgASALaiAKNgIAIAVBAWohBSAKIAxqIQoMAQsLIAEgCjYCAEEAIQUgBigCCCELA0AgBSALRkUEQCABIAUgCWotAAAiDEECdGoiDSANKAIAIg1BAWo2AgAgDyANQQF0aiINIAw6AAEgDSAFOgAAIAVBAWohBQwBCwtBACEBIANBADYCqAUgBEF/cyAHaiEJQQEhBQNAIAUgDk9FBEAgCCAFQQJ0IgtqKAIAIQwgAyALaiABNgIAIAwgBSAJanQgAWohASAFQQFqIQUMAQsLIAcgBEEBaiIBIAJrIgRrQQFqIQgDQEEBIQUgBCAIT0UEQANAIAUgDk9FBEAgBUECdCIJIAMgBEE0bGpqIAMgCWooAgAgBHY2AgAgBUEBaiEFDAELCyAEQQFqIQQMAQsLIBIgByAPIAogESADIAIgARBkIAZBAToABSAGIAc6AAYgACAGKAIENgIACyAQIQULIAZBEGokACAFC8ENAQt/IwBB8ABrIgUkAEFsIQkCQCADQQpJDQAgAi8AACEKIAIvAAIhDCACLwAEIQYgBUEIaiAEEA4CQCADIAYgCiAMampBBmoiDUkNACAFLQAKIQcgBUHYAGogAkEGaiICIAoQBiIJEAMNASAFQUBrIAIgCmoiAiAMEAYiCRADDQEgBUEoaiACIAxqIgIgBhAGIgkQAw0BIAVBEGogAiAGaiADIA1rEAYiCRADDQEgACABaiIOQX1qIQ8gBEEEaiEGQQEhCSAAIAFBA2pBAnYiAmoiCiACaiIMIAJqIg0hAyAMIQQgCiECA0AgCSADIA9JcQRAIAYgBUHYAGogBxACQQF0aiIILQAAIQsgBUHYAGogCC0AARABIAAgCzoAACAGIAVBQGsgBxACQQF0aiIILQAAIQsgBUFAayAILQABEAEgAiALOgAAIAYgBUEoaiAHEAJBAXRqIggtAAAhCyAFQShqIAgtAAEQASAEIAs6AAAgBiAFQRBqIAcQAkEBdGoiCC0AACELIAVBEGogCC0AARABIAMgCzoAACAGIAVB2ABqIAcQAkEBdGoiCC0AACELIAVB2ABqIAgtAAEQASAAIAs6AAEgBiAFQUBrIAcQAkEBdGoiCC0AACELIAVBQGsgCC0AARABIAIgCzoAASAGIAVBKGogBxACQQF0aiIILQAAIQsgBUEoaiAILQABEAEgBCALOgABIAYgBUEQaiAHEAJBAXRqIggtAAAhCyAFQRBqIAgtAAEQASADIAs6AAEgA0ECaiEDIARBAmohBCACQQJqIQIgAEECaiEAIAkgBUHYAGoQDUVxIAVBQGsQDUVxIAVBKGoQDUVxIAVBEGoQDUVxIQkMAQsLIAQgDUsgAiAMS3INAEFsIQkgACAKSw0BIApBfWohCQNAIAVB2ABqEAQgACAJT3JFBEAgBiAFQdgAaiAHEAJBAXRqIggtAAAhCyAFQdgAaiAILQABEAEgACALOgAAIAYgBUHYAGogBxACQQF0aiIILQAAIQsgBUHYAGogCC0AARABIAAgCzoAASAAQQJqIQAMAQsLA0AgBUHYAGoQBCAAIApPckUEQCAGIAVB2ABqIAcQAkEBdGoiCS0AACEIIAVB2ABqIAktAAEQASAAIAg6AAAgAEEBaiEADAELCwNAIAAgCkkEQCAGIAVB2ABqIAcQAkEBdGoiCS0AACEIIAVB2ABqIAktAAEQASAAIAg6AAAgAEEBaiEADAELCyAMQX1qIQADQCAFQUBrEAQgAiAAT3JFBEAgBiAFQUBrIAcQAkEBdGoiCi0AACEJIAVBQGsgCi0AARABIAIgCToAACAGIAVBQGsgBxACQQF0aiIKLQAAIQkgBUFAayAKLQABEAEgAiAJOgABIAJBAmohAgwBCwsDQCAFQUBrEAQgAiAMT3JFBEAgBiAFQUBrIAcQAkEBdGoiAC0AACEKIAVBQGsgAC0AARABIAIgCjoAACACQQFqIQIMAQsLA0AgAiAMSQRAIAYgBUFAayAHEAJBAXRqIgAtAAAhCiAFQUBrIAAtAAEQASACIAo6AAAgAkEBaiECDAELCyANQX1qIQADQCAFQShqEAQgBCAAT3JFBEAgBiAFQShqIAcQAkEBdGoiAi0AACEKIAVBKGogAi0AARABIAQgCjoAACAGIAVBKGogBxACQQF0aiICLQAAIQogBUEoaiACLQABEAEgBCAKOgABIARBAmohBAwBCwsDQCAFQShqEAQgBCANT3JFBEAgBiAFQShqIAcQAkEBdGoiAC0AACECIAVBKGogAC0AARABIAQgAjoAACAEQQFqIQQMAQsLA0AgBCANSQRAIAYgBUEoaiAHEAJBAXRqIgAtAAAhAiAFQShqIAAtAAEQASAEIAI6AAAgBEEBaiEEDAELCwNAIAVBEGoQBCADIA9PckUEQCAGIAVBEGogBxACQQF0aiIALQAAIQIgBUEQaiAALQABEAEgAyACOgAAIAYgBUEQaiAHEAJBAXRqIgAtAAAhAiAFQRBqIAAtAAEQASADIAI6AAEgA0ECaiEDDAELCwNAIAVBEGoQBCADIA5PckUEQCAGIAVBEGogBxACQQF0aiIALQAAIQIgBUEQaiAALQABEAEgAyACOgAAIANBAWohAwwBCwsDQCADIA5JBEAgBiAFQRBqIAcQAkEBdGoiAC0AACECIAVBEGogAC0AARABIAMgAjoAACADQQFqIQMMAQsLIAFBbCAFQdgAahAKIAVBQGsQCnEgBUEoahAKcSAFQRBqEApxGyEJDAELQWwhCQsgBUHwAGokACAJC8oCAQR/IwBBIGsiBSQAIAUgBBAOIAUtAAIhByAFQQhqIAIgAxAGIgIQA0UEQCAEQQRqIQIgACABaiIDQX1qIQQDQCAFQQhqEAQgACAET3JFBEAgAiAFQQhqIAcQAkEBdGoiBi0AACEIIAVBCGogBi0AARABIAAgCDoAACACIAVBCGogBxACQQF0aiIGLQAAIQggBUEIaiAGLQABEAEgACAIOgABIABBAmohAAwBCwsDQCAFQQhqEAQgACADT3JFBEAgAiAFQQhqIAcQAkEBdGoiBC0AACEGIAVBCGogBC0AARABIAAgBjoAACAAQQFqIQAMAQsLA0AgACADT0UEQCACIAVBCGogBxACQQF0aiIELQAAIQYgBUEIaiAELQABEAEgACAGOgAAIABBAWohAAwBCwsgAUFsIAVBCGoQChshAgsgBUEgaiQAIAILtgMBCX8jAEEQayIGJAAgBkEANgIMIAZBADYCCEFUIQQCQAJAIANBQGsiDCADIAZBCGogBkEMaiABIAIQMSICEAMNACAGQQRqIAAQDiAGKAIMIgcgBi0ABEEBaksNASAAQQRqIQogBkEAOgAFIAYgBzoABiAAIAYoAgQ2AgAgB0EBaiEJQQEhBANAIAQgCUkEQCADIARBAnRqIgEoAgAhACABIAU2AgAgACAEQX9qdCAFaiEFIARBAWohBAwBCwsgB0EBaiEHQQAhBSAGKAIIIQkDQCAFIAlGDQEgAyAFIAxqLQAAIgRBAnRqIgBBASAEdEEBdSILIAAoAgAiAWoiADYCACAHIARrIQhBACEEAkAgC0EDTQRAA0AgBCALRg0CIAogASAEakEBdGoiACAIOgABIAAgBToAACAEQQFqIQQMAAALAAsDQCABIABPDQEgCiABQQF0aiIEIAg6AAEgBCAFOgAAIAQgCDoAAyAEIAU6AAIgBCAIOgAFIAQgBToABCAEIAg6AAcgBCAFOgAGIAFBBGohAQwAAAsACyAFQQFqIQUMAAALAAsgAiEECyAGQRBqJAAgBAutAQECfwJAQYQgKAIAIABHIAAoAgBBAXYiAyABa0F4aiICQXhxQQhHcgR/IAIFIAMQJ0UNASACQQhqC0EQSQ0AIAAgACgCACICQQFxIAAgAWpBD2pBeHEiASAAa0EBdHI2AgAgASAANgIEIAEgASgCAEEBcSAAIAJBAXZqIAFrIgJBAXRyNgIAQYQgIAEgAkH/////B3FqQQRqQYQgKAIAIABGGyABNgIAIAEQJQsLygIBBX8CQAJAAkAgAEEIIABBCEsbZ0EfcyAAaUEBR2oiAUEESSAAIAF2cg0AIAFBAnRB/B5qKAIAIgJFDQADQCACQXhqIgMoAgBBAXZBeGoiBSAATwRAIAIgBUEIIAVBCEsbZ0Efc0ECdEGAH2oiASgCAEYEQCABIAIoAgQ2AgALDAMLIARBHksNASAEQQFqIQQgAigCBCICDQALC0EAIQMgAUEgTw0BA0AgAUECdEGAH2ooAgAiAkUEQCABQR5LIQIgAUEBaiEBIAJFDQEMAwsLIAIgAkF4aiIDKAIAQQF2QXhqIgFBCCABQQhLG2dBH3NBAnRBgB9qIgEoAgBGBEAgASACKAIENgIACwsgAigCACIBBEAgASACKAIENgIECyACKAIEIgEEQCABIAIoAgA2AgALIAMgAygCAEEBcjYCACADIAAQNwsgAwvhCwINfwV+IwBB8ABrIgckACAHIAAoAvDhASIINgJcIAEgAmohDSAIIAAoAoDiAWohDwJAAkAgBUUEQCABIQQMAQsgACgCxOABIRAgACgCwOABIREgACgCvOABIQ4gAEEBNgKM4QFBACEIA0AgCEEDRwRAIAcgCEECdCICaiAAIAJqQazQAWooAgA2AkQgCEEBaiEIDAELC0FsIQwgB0EYaiADIAQQBhADDQEgB0EsaiAHQRhqIAAoAgAQEyAHQTRqIAdBGGogACgCCBATIAdBPGogB0EYaiAAKAIEEBMgDUFgaiESIAEhBEEAIQwDQCAHKAIwIAcoAixBA3RqKQIAIhRCEIinQf8BcSEIIAcoAkAgBygCPEEDdGopAgAiFUIQiKdB/wFxIQsgBygCOCAHKAI0QQN0aikCACIWQiCIpyEJIBVCIIghFyAUQiCIpyECAkAgFkIQiKdB/wFxIgNBAk8EQAJAIAZFIANBGUlyRQRAIAkgB0EYaiADQSAgBygCHGsiCiAKIANLGyIKEAUgAyAKayIDdGohCSAHQRhqEAQaIANFDQEgB0EYaiADEAUgCWohCQwBCyAHQRhqIAMQBSAJaiEJIAdBGGoQBBoLIAcpAkQhGCAHIAk2AkQgByAYNwNIDAELAkAgA0UEQCACBEAgBygCRCEJDAMLIAcoAkghCQwBCwJAAkAgB0EYakEBEAUgCSACRWpqIgNBA0YEQCAHKAJEQX9qIgMgA0VqIQkMAQsgA0ECdCAHaigCRCIJIAlFaiEJIANBAUYNAQsgByAHKAJINgJMCwsgByAHKAJENgJIIAcgCTYCRAsgF6chAyALBEAgB0EYaiALEAUgA2ohAwsgCCALakEUTwRAIAdBGGoQBBoLIAgEQCAHQRhqIAgQBSACaiECCyAHQRhqEAQaIAcgB0EYaiAUQhiIp0H/AXEQCCAUp0H//wNxajYCLCAHIAdBGGogFUIYiKdB/wFxEAggFadB//8DcWo2AjwgB0EYahAEGiAHIAdBGGogFkIYiKdB/wFxEAggFqdB//8DcWo2AjQgByACNgJgIAcoAlwhCiAHIAk2AmggByADNgJkAkACQAJAIAQgAiADaiILaiASSw0AIAIgCmoiEyAPSw0AIA0gBGsgC0Egak8NAQsgByAHKQNoNwMQIAcgBykDYDcDCCAEIA0gB0EIaiAHQdwAaiAPIA4gESAQEB4hCwwBCyACIARqIQggBCAKEAcgAkERTwRAIARBEGohAgNAIAIgCkEQaiIKEAcgAkEQaiICIAhJDQALCyAIIAlrIQIgByATNgJcIAkgCCAOa0sEQCAJIAggEWtLBEBBbCELDAILIBAgAiAOayICaiIKIANqIBBNBEAgCCAKIAMQDxoMAgsgCCAKQQAgAmsQDyEIIAcgAiADaiIDNgJkIAggAmshCCAOIQILIAlBEE8EQCADIAhqIQMDQCAIIAIQByACQRBqIQIgCEEQaiIIIANJDQALDAELAkAgCUEHTQRAIAggAi0AADoAACAIIAItAAE6AAEgCCACLQACOgACIAggAi0AAzoAAyAIQQRqIAIgCUECdCIDQcAeaigCAGoiAhAXIAIgA0HgHmooAgBrIQIgBygCZCEDDAELIAggAhAMCyADQQlJDQAgAyAIaiEDIAhBCGoiCCACQQhqIgJrQQ9MBEADQCAIIAIQDCACQQhqIQIgCEEIaiIIIANJDQAMAgALAAsDQCAIIAIQByACQRBqIQIgCEEQaiIIIANJDQALCyAHQRhqEAQaIAsgDCALEAMiAhshDCAEIAQgC2ogAhshBCAFQX9qIgUNAAsgDBADDQFBbCEMIAdBGGoQBEECSQ0BQQAhCANAIAhBA0cEQCAAIAhBAnQiAmpBrNABaiACIAdqKAJENgIAIAhBAWohCAwBCwsgBygCXCEIC0G6fyEMIA8gCGsiACANIARrSw0AIAQEfyAEIAggABALIABqBUEACyABayEMCyAHQfAAaiQAIAwLkRcCFn8FfiMAQdABayIHJAAgByAAKALw4QEiCDYCvAEgASACaiESIAggACgCgOIBaiETAkACQCAFRQRAIAEhAwwBCyAAKALE4AEhESAAKALA4AEhFSAAKAK84AEhDyAAQQE2AozhAUEAIQgDQCAIQQNHBEAgByAIQQJ0IgJqIAAgAmpBrNABaigCADYCVCAIQQFqIQgMAQsLIAcgETYCZCAHIA82AmAgByABIA9rNgJoQWwhECAHQShqIAMgBBAGEAMNASAFQQQgBUEESBshFyAHQTxqIAdBKGogACgCABATIAdBxABqIAdBKGogACgCCBATIAdBzABqIAdBKGogACgCBBATQQAhBCAHQeAAaiEMIAdB5ABqIQoDQCAHQShqEARBAksgBCAXTnJFBEAgBygCQCAHKAI8QQN0aikCACIdQhCIp0H/AXEhCyAHKAJQIAcoAkxBA3RqKQIAIh5CEIinQf8BcSEJIAcoAkggBygCREEDdGopAgAiH0IgiKchCCAeQiCIISAgHUIgiKchAgJAIB9CEIinQf8BcSIDQQJPBEACQCAGRSADQRlJckUEQCAIIAdBKGogA0EgIAcoAixrIg0gDSADSxsiDRAFIAMgDWsiA3RqIQggB0EoahAEGiADRQ0BIAdBKGogAxAFIAhqIQgMAQsgB0EoaiADEAUgCGohCCAHQShqEAQaCyAHKQJUISEgByAINgJUIAcgITcDWAwBCwJAIANFBEAgAgRAIAcoAlQhCAwDCyAHKAJYIQgMAQsCQAJAIAdBKGpBARAFIAggAkVqaiIDQQNGBEAgBygCVEF/aiIDIANFaiEIDAELIANBAnQgB2ooAlQiCCAIRWohCCADQQFGDQELIAcgBygCWDYCXAsLIAcgBygCVDYCWCAHIAg2AlQLICCnIQMgCQRAIAdBKGogCRAFIANqIQMLIAkgC2pBFE8EQCAHQShqEAQaCyALBEAgB0EoaiALEAUgAmohAgsgB0EoahAEGiAHIAcoAmggAmoiCSADajYCaCAKIAwgCCAJSxsoAgAhDSAHIAdBKGogHUIYiKdB/wFxEAggHadB//8DcWo2AjwgByAHQShqIB5CGIinQf8BcRAIIB6nQf//A3FqNgJMIAdBKGoQBBogB0EoaiAfQhiIp0H/AXEQCCEOIAdB8ABqIARBBHRqIgsgCSANaiAIazYCDCALIAg2AgggCyADNgIEIAsgAjYCACAHIA4gH6dB//8DcWo2AkQgBEEBaiEEDAELCyAEIBdIDQEgEkFgaiEYIAdB4ABqIRogB0HkAGohGyABIQMDQCAHQShqEARBAksgBCAFTnJFBEAgBygCQCAHKAI8QQN0aikCACIdQhCIp0H/AXEhCyAHKAJQIAcoAkxBA3RqKQIAIh5CEIinQf8BcSEIIAcoAkggBygCREEDdGopAgAiH0IgiKchCSAeQiCIISAgHUIgiKchDAJAIB9CEIinQf8BcSICQQJPBEACQCAGRSACQRlJckUEQCAJIAdBKGogAkEgIAcoAixrIgogCiACSxsiChAFIAIgCmsiAnRqIQkgB0EoahAEGiACRQ0BIAdBKGogAhAFIAlqIQkMAQsgB0EoaiACEAUgCWohCSAHQShqEAQaCyAHKQJUISEgByAJNgJUIAcgITcDWAwBCwJAIAJFBEAgDARAIAcoAlQhCQwDCyAHKAJYIQkMAQsCQAJAIAdBKGpBARAFIAkgDEVqaiICQQNGBEAgBygCVEF/aiICIAJFaiEJDAELIAJBAnQgB2ooAlQiCSAJRWohCSACQQFGDQELIAcgBygCWDYCXAsLIAcgBygCVDYCWCAHIAk2AlQLICCnIRQgCARAIAdBKGogCBAFIBRqIRQLIAggC2pBFE8EQCAHQShqEAQaCyALBEAgB0EoaiALEAUgDGohDAsgB0EoahAEGiAHIAcoAmggDGoiGSAUajYCaCAbIBogCSAZSxsoAgAhHCAHIAdBKGogHUIYiKdB/wFxEAggHadB//8DcWo2AjwgByAHQShqIB5CGIinQf8BcRAIIB6nQf//A3FqNgJMIAdBKGoQBBogByAHQShqIB9CGIinQf8BcRAIIB+nQf//A3FqNgJEIAcgB0HwAGogBEEDcUEEdGoiDSkDCCIdNwPIASAHIA0pAwAiHjcDwAECQAJAAkAgBygCvAEiDiAepyICaiIWIBNLDQAgAyAHKALEASIKIAJqIgtqIBhLDQAgEiADayALQSBqTw0BCyAHIAcpA8gBNwMQIAcgBykDwAE3AwggAyASIAdBCGogB0G8AWogEyAPIBUgERAeIQsMAQsgAiADaiEIIAMgDhAHIAJBEU8EQCADQRBqIQIDQCACIA5BEGoiDhAHIAJBEGoiAiAISQ0ACwsgCCAdpyIOayECIAcgFjYCvAEgDiAIIA9rSwRAIA4gCCAVa0sEQEFsIQsMAgsgESACIA9rIgJqIhYgCmogEU0EQCAIIBYgChAPGgwCCyAIIBZBACACaxAPIQggByACIApqIgo2AsQBIAggAmshCCAPIQILIA5BEE8EQCAIIApqIQoDQCAIIAIQByACQRBqIQIgCEEQaiIIIApJDQALDAELAkAgDkEHTQRAIAggAi0AADoAACAIIAItAAE6AAEgCCACLQACOgACIAggAi0AAzoAAyAIQQRqIAIgDkECdCIKQcAeaigCAGoiAhAXIAIgCkHgHmooAgBrIQIgBygCxAEhCgwBCyAIIAIQDAsgCkEJSQ0AIAggCmohCiAIQQhqIgggAkEIaiICa0EPTARAA0AgCCACEAwgAkEIaiECIAhBCGoiCCAKSQ0ADAIACwALA0AgCCACEAcgAkEQaiECIAhBEGoiCCAKSQ0ACwsgCxADBEAgCyEQDAQFIA0gDDYCACANIBkgHGogCWs2AgwgDSAJNgIIIA0gFDYCBCAEQQFqIQQgAyALaiEDDAILAAsLIAQgBUgNASAEIBdrIQtBACEEA0AgCyAFSARAIAcgB0HwAGogC0EDcUEEdGoiAikDCCIdNwPIASAHIAIpAwAiHjcDwAECQAJAAkAgBygCvAEiDCAepyICaiIKIBNLDQAgAyAHKALEASIJIAJqIhBqIBhLDQAgEiADayAQQSBqTw0BCyAHIAcpA8gBNwMgIAcgBykDwAE3AxggAyASIAdBGGogB0G8AWogEyAPIBUgERAeIRAMAQsgAiADaiEIIAMgDBAHIAJBEU8EQCADQRBqIQIDQCACIAxBEGoiDBAHIAJBEGoiAiAISQ0ACwsgCCAdpyIGayECIAcgCjYCvAEgBiAIIA9rSwRAIAYgCCAVa0sEQEFsIRAMAgsgESACIA9rIgJqIgwgCWogEU0EQCAIIAwgCRAPGgwCCyAIIAxBACACaxAPIQggByACIAlqIgk2AsQBIAggAmshCCAPIQILIAZBEE8EQCAIIAlqIQYDQCAIIAIQByACQRBqIQIgCEEQaiIIIAZJDQALDAELAkAgBkEHTQRAIAggAi0AADoAACAIIAItAAE6AAEgCCACLQACOgACIAggAi0AAzoAAyAIQQRqIAIgBkECdCIGQcAeaigCAGoiAhAXIAIgBkHgHmooAgBrIQIgBygCxAEhCQwBCyAIIAIQDAsgCUEJSQ0AIAggCWohBiAIQQhqIgggAkEIaiICa0EPTARAA0AgCCACEAwgAkEIaiECIAhBCGoiCCAGSQ0ADAIACwALA0AgCCACEAcgAkEQaiECIAhBEGoiCCAGSQ0ACwsgEBADDQMgC0EBaiELIAMgEGohAwwBCwsDQCAEQQNHBEAgACAEQQJ0IgJqQazQAWogAiAHaigCVDYCACAEQQFqIQQMAQsLIAcoArwBIQgLQbp/IRAgEyAIayIAIBIgA2tLDQAgAwR/IAMgCCAAEAsgAGoFQQALIAFrIRALIAdB0AFqJAAgEAslACAAQgA3AgAgAEEAOwEIIABBADoACyAAIAE2AgwgACACOgAKC7QFAQN/IwBBMGsiBCQAIABB/wFqIgVBfWohBgJAIAMvAQIEQCAEQRhqIAEgAhAGIgIQAw0BIARBEGogBEEYaiADEBwgBEEIaiAEQRhqIAMQHCAAIQMDQAJAIARBGGoQBCADIAZPckUEQCADIARBEGogBEEYahASOgAAIAMgBEEIaiAEQRhqEBI6AAEgBEEYahAERQ0BIANBAmohAwsgBUF+aiEFAn8DQEG6fyECIAMiASAFSw0FIAEgBEEQaiAEQRhqEBI6AAAgAUEBaiEDIARBGGoQBEEDRgRAQQIhAiAEQQhqDAILIAMgBUsNBSABIARBCGogBEEYahASOgABIAFBAmohA0EDIQIgBEEYahAEQQNHDQALIARBEGoLIQUgAyAFIARBGGoQEjoAACABIAJqIABrIQIMAwsgAyAEQRBqIARBGGoQEjoAAiADIARBCGogBEEYahASOgADIANBBGohAwwAAAsACyAEQRhqIAEgAhAGIgIQAw0AIARBEGogBEEYaiADEBwgBEEIaiAEQRhqIAMQHCAAIQMDQAJAIARBGGoQBCADIAZPckUEQCADIARBEGogBEEYahAROgAAIAMgBEEIaiAEQRhqEBE6AAEgBEEYahAERQ0BIANBAmohAwsgBUF+aiEFAn8DQEG6fyECIAMiASAFSw0EIAEgBEEQaiAEQRhqEBE6AAAgAUEBaiEDIARBGGoQBEEDRgRAQQIhAiAEQQhqDAILIAMgBUsNBCABIARBCGogBEEYahAROgABIAFBAmohA0EDIQIgBEEYahAEQQNHDQALIARBEGoLIQUgAyAFIARBGGoQEToAACABIAJqIABrIQIMAgsgAyAEQRBqIARBGGoQEToAAiADIARBCGogBEEYahAROgADIANBBGohAwwAAAsACyAEQTBqJAAgAgtpAQF/An8CQAJAIAJBB00NACABKAAAQbfIwuF+Rw0AIAAgASgABDYCmOIBQWIgAEEQaiABIAIQPiIDEAMNAhogAEKBgICAEDcDiOEBIAAgASADaiACIANrECoMAQsgACABIAIQKgtBAAsLrQMBBn8jAEGAAWsiAyQAQWIhCAJAIAJBCUkNACAAQZjQAGogAUEIaiIEIAJBeGogAEGY0AAQMyIFEAMiBg0AIANBHzYCfCADIANB/ABqIANB+ABqIAQgBCAFaiAGGyIEIAEgAmoiAiAEaxAVIgUQAw0AIAMoAnwiBkEfSw0AIAMoAngiB0EJTw0AIABBiCBqIAMgBkGAC0GADCAHEBggA0E0NgJ8IAMgA0H8AGogA0H4AGogBCAFaiIEIAIgBGsQFSIFEAMNACADKAJ8IgZBNEsNACADKAJ4IgdBCk8NACAAQZAwaiADIAZBgA1B4A4gBxAYIANBIzYCfCADIANB/ABqIANB+ABqIAQgBWoiBCACIARrEBUiBRADDQAgAygCfCIGQSNLDQAgAygCeCIHQQpPDQAgACADIAZBwBBB0BEgBxAYIAQgBWoiBEEMaiIFIAJLDQAgAiAFayEFQQAhAgNAIAJBA0cEQCAEKAAAIgZBf2ogBU8NAiAAIAJBAnRqQZzQAWogBjYCACACQQFqIQIgBEEEaiEEDAELCyAEIAFrIQgLIANBgAFqJAAgCAtGAQN/IABBCGohAyAAKAIEIQJBACEAA0AgACACdkUEQCABIAMgAEEDdGotAAJBFktqIQEgAEEBaiEADAELCyABQQggAmt0C4YDAQV/Qbh/IQcCQCADRQ0AIAItAAAiBEUEQCABQQA2AgBBAUG4fyADQQFGGw8LAn8gAkEBaiIFIARBGHRBGHUiBkF/Sg0AGiAGQX9GBEAgA0EDSA0CIAUvAABBgP4BaiEEIAJBA2oMAQsgA0ECSA0BIAItAAEgBEEIdHJBgIB+aiEEIAJBAmoLIQUgASAENgIAIAVBAWoiASACIANqIgNLDQBBbCEHIABBEGogACAFLQAAIgVBBnZBI0EJIAEgAyABa0HAEEHQEUHwEiAAKAKM4QEgACgCnOIBIAQQHyIGEAMiCA0AIABBmCBqIABBCGogBUEEdkEDcUEfQQggASABIAZqIAgbIgEgAyABa0GAC0GADEGAFyAAKAKM4QEgACgCnOIBIAQQHyIGEAMiCA0AIABBoDBqIABBBGogBUECdkEDcUE0QQkgASABIAZqIAgbIgEgAyABa0GADUHgDkGQGSAAKAKM4QEgACgCnOIBIAQQHyIAEAMNACAAIAFqIAJrIQcLIAcLrQMBCn8jAEGABGsiCCQAAn9BUiACQf8BSw0AGkFUIANBDEsNABogAkEBaiELIABBBGohCUGAgAQgA0F/anRBEHUhCkEAIQJBASEEQQEgA3QiB0F/aiIMIQUDQCACIAtGRQRAAkAgASACQQF0Ig1qLwEAIgZB//8DRgRAIAkgBUECdGogAjoAAiAFQX9qIQVBASEGDAELIARBACAKIAZBEHRBEHVKGyEECyAIIA1qIAY7AQAgAkEBaiECDAELCyAAIAQ7AQIgACADOwEAIAdBA3YgB0EBdmpBA2ohBkEAIQRBACECA0AgBCALRkUEQCABIARBAXRqLgEAIQpBACEAA0AgACAKTkUEQCAJIAJBAnRqIAQ6AAIDQCACIAZqIAxxIgIgBUsNAAsgAEEBaiEADAELCyAEQQFqIQQMAQsLQX8gAg0AGkEAIQIDfyACIAdGBH9BAAUgCCAJIAJBAnRqIgAtAAJBAXRqIgEgAS8BACIBQQFqOwEAIAAgAyABEBRrIgU6AAMgACABIAVB/wFxdCAHazsBACACQQFqIQIMAQsLCyEFIAhBgARqJAAgBQvjBgEIf0FsIQcCQCACQQNJDQACQAJAAkACQCABLQAAIgNBA3EiCUEBaw4DAwEAAgsgACgCiOEBDQBBYg8LIAJBBUkNAkEDIQYgASgAACEFAn8CQAJAIANBAnZBA3EiCEF+aiIEQQFNBEAgBEEBaw0BDAILIAVBDnZB/wdxIQQgBUEEdkH/B3EhAyAIRQwCCyAFQRJ2IQRBBCEGIAVBBHZB//8AcSEDQQAMAQsgBUEEdkH//w9xIgNBgIAISw0DIAEtAARBCnQgBUEWdnIhBEEFIQZBAAshBSAEIAZqIgogAksNAgJAIANBgQZJDQAgACgCnOIBRQ0AQQAhAgNAIAJBg4ABSw0BIAJBQGshAgwAAAsACwJ/IAlBA0YEQCABIAZqIQEgAEHw4gFqIQIgACgCDCEGIAUEQCACIAMgASAEIAYQXwwCCyACIAMgASAEIAYQXQwBCyAAQbjQAWohAiABIAZqIQEgAEHw4gFqIQYgAEGo0ABqIQggBQRAIAggBiADIAEgBCACEF4MAQsgCCAGIAMgASAEIAIQXAsQAw0CIAAgAzYCgOIBIABBATYCiOEBIAAgAEHw4gFqNgLw4QEgCUECRgRAIAAgAEGo0ABqNgIMCyAAIANqIgBBiOMBakIANwAAIABBgOMBakIANwAAIABB+OIBakIANwAAIABB8OIBakIANwAAIAoPCwJ/AkACQAJAIANBAnZBA3FBf2oiBEECSw0AIARBAWsOAgACAQtBASEEIANBA3YMAgtBAiEEIAEvAABBBHYMAQtBAyEEIAEQIUEEdgsiAyAEaiIFQSBqIAJLBEAgBSACSw0CIABB8OIBaiABIARqIAMQCyEBIAAgAzYCgOIBIAAgATYC8OEBIAEgA2oiAEIANwAYIABCADcAECAAQgA3AAggAEIANwAAIAUPCyAAIAM2AoDiASAAIAEgBGo2AvDhASAFDwsCfwJAAkACQCADQQJ2QQNxQX9qIgRBAksNACAEQQFrDgIAAgELQQEhByADQQN2DAILQQIhByABLwAAQQR2DAELIAJBBEkgARAhIgJBj4CAAUtyDQFBAyEHIAJBBHYLIQIgAEHw4gFqIAEgB2otAAAgAkEgahAQIQEgACACNgKA4gEgACABNgLw4QEgB0EBaiEHCyAHC0sAIABC+erQ0OfJoeThADcDICAAQgA3AxggAELP1tO+0ser2UI3AxAgAELW64Lu6v2J9eAANwMIIABCADcDACAAQShqQQBBKBAQGgviAgICfwV+IABBKGoiASAAKAJIaiECAn4gACkDACIDQiBaBEAgACkDECIEQgeJIAApAwgiBUIBiXwgACkDGCIGQgyJfCAAKQMgIgdCEol8IAUQGSAEEBkgBhAZIAcQGQwBCyAAKQMYQsXP2bLx5brqJ3wLIAN8IQMDQCABQQhqIgAgAk0EQEIAIAEpAAAQCSADhUIbiUKHla+vmLbem55/fkLj3MqV/M7y9YV/fCEDIAAhAQwBCwsCQCABQQRqIgAgAksEQCABIQAMAQsgASgAAK1Ch5Wvr5i23puef34gA4VCF4lCz9bTvtLHq9lCfkL5893xmfaZqxZ8IQMLA0AgACACSQRAIAAxAABCxc/ZsvHluuonfiADhUILiUKHla+vmLbem55/fiEDIABBAWohAAwBCwsgA0IhiCADhULP1tO+0ser2UJ+IgNCHYggA4VC+fPd8Zn2masWfiIDQiCIIAOFC+8CAgJ/BH4gACAAKQMAIAKtfDcDAAJAAkAgACgCSCIDIAJqIgRBH00EQCABRQ0BIAAgA2pBKGogASACECAgACgCSCACaiEEDAELIAEgAmohAgJ/IAMEQCAAQShqIgQgA2ogAUEgIANrECAgACAAKQMIIAQpAAAQCTcDCCAAIAApAxAgACkAMBAJNwMQIAAgACkDGCAAKQA4EAk3AxggACAAKQMgIABBQGspAAAQCTcDICAAKAJIIQMgAEEANgJIIAEgA2tBIGohAQsgAUEgaiACTQsEQCACQWBqIQMgACkDICEFIAApAxghBiAAKQMQIQcgACkDCCEIA0AgCCABKQAAEAkhCCAHIAEpAAgQCSEHIAYgASkAEBAJIQYgBSABKQAYEAkhBSABQSBqIgEgA00NAAsgACAFNwMgIAAgBjcDGCAAIAc3AxAgACAINwMICyABIAJPDQEgAEEoaiABIAIgAWsiBBAgCyAAIAQ2AkgLCy8BAX8gAEUEQEG2f0EAIAMbDwtBun8hBCADIAFNBH8gACACIAMQEBogAwVBun8LCy8BAX8gAEUEQEG2f0EAIAMbDwtBun8hBCADIAFNBH8gACACIAMQCxogAwVBun8LC6gCAQZ/IwBBEGsiByQAIABB2OABaikDAEKAgIAQViEIQbh/IQUCQCAEQf//B0sNACAAIAMgBBBCIgUQAyIGDQAgACgCnOIBIQkgACAHQQxqIAMgAyAFaiAGGyIKIARBACAFIAYbayIGEEAiAxADBEAgAyEFDAELIAcoAgwhBCABRQRAQbp/IQUgBEEASg0BCyAGIANrIQUgAyAKaiEDAkAgCQRAIABBADYCnOIBDAELAkACQAJAIARBBUgNACAAQdjgAWopAwBCgICACFgNAAwBCyAAQQA2ApziAQwBCyAAKAIIED8hBiAAQQA2ApziASAGQRRPDQELIAAgASACIAMgBSAEIAgQOSEFDAELIAAgASACIAMgBSAEIAgQOiEFCyAHQRBqJAAgBQtnACAAQdDgAWogASACIAAoAuzhARAuIgEQAwRAIAEPC0G4fyECAkAgAQ0AIABB7OABaigCACIBBEBBYCECIAAoApjiASABRw0BC0EAIQIgAEHw4AFqKAIARQ0AIABBkOEBahBDCyACCycBAX8QVyIERQRAQUAPCyAEIAAgASACIAMgBBBLEE8hACAEEFYgAAs/AQF/AkACQAJAIAAoAqDiAUEBaiIBQQJLDQAgAUEBaw4CAAECCyAAEDBBAA8LIABBADYCoOIBCyAAKAKU4gELvAMCB38BfiMAQRBrIgkkAEG4fyEGAkAgBCgCACIIQQVBCSAAKALs4QEiBRtJDQAgAygCACIHQQFBBSAFGyAFEC8iBRADBEAgBSEGDAELIAggBUEDakkNACAAIAcgBRBJIgYQAw0AIAEgAmohCiAAQZDhAWohCyAIIAVrIQIgBSAHaiEHIAEhBQNAIAcgAiAJECwiBhADDQEgAkF9aiICIAZJBEBBuH8hBgwCCyAJKAIAIghBAksEQEFsIQYMAgsgB0EDaiEHAn8CQAJAAkAgCEEBaw4CAgABCyAAIAUgCiAFayAHIAYQSAwCCyAFIAogBWsgByAGEEcMAQsgBSAKIAVrIActAAAgCSgCCBBGCyIIEAMEQCAIIQYMAgsgACgC8OABBEAgCyAFIAgQRQsgAiAGayECIAYgB2ohByAFIAhqIQUgCSgCBEUNAAsgACkD0OABIgxCf1IEQEFsIQYgDCAFIAFrrFINAQsgACgC8OABBEBBaiEGIAJBBEkNASALEEQhDCAHKAAAIAynRw0BIAdBBGohByACQXxqIQILIAMgBzYCACAEIAI2AgAgBSABayEGCyAJQRBqJAAgBgsuACAAECsCf0EAQQAQAw0AGiABRSACRXJFBEBBYiAAIAEgAhA9EAMNARoLQQALCzcAIAEEQCAAIAAoAsTgASABKAIEIAEoAghqRzYCnOIBCyAAECtBABADIAFFckUEQCAAIAEQWwsL0QIBB38jAEEQayIGJAAgBiAENgIIIAYgAzYCDCAFBEAgBSgCBCEKIAUoAgghCQsgASEIAkACQANAIAAoAuzhARAWIQsCQANAIAQgC0kNASADKAAAQXBxQdDUtMIBRgRAIAMgBBAiIgcQAw0EIAQgB2shBCADIAdqIQMMAQsLIAYgAzYCDCAGIAQ2AggCQCAFBEAgACAFEE5BACEHQQAQA0UNAQwFCyAAIAogCRBNIgcQAw0ECyAAIAgQUCAMQQFHQQAgACAIIAIgBkEMaiAGQQhqEEwiByIDa0EAIAMQAxtBCkdyRQRAQbh/IQcMBAsgBxADDQMgAiAHayECIAcgCGohCEEBIQwgBigCDCEDIAYoAgghBAwBCwsgBiADNgIMIAYgBDYCCEG4fyEHIAQNASAIIAFrIQcMAQsgBiADNgIMIAYgBDYCCAsgBkEQaiQAIAcLRgECfyABIAAoArjgASICRwRAIAAgAjYCxOABIAAgATYCuOABIAAoArzgASEDIAAgATYCvOABIAAgASADIAJrajYCwOABCwutAgIEfwF+IwBBQGoiBCQAAkACQCACQQhJDQAgASgAAEFwcUHQ1LTCAUcNACABIAIQIiEBIABCADcDCCAAQQA2AgQgACABNgIADAELIARBGGogASACEC0iAxADBEAgACADEBoMAQsgAwRAIABBuH8QGgwBCyACIAQoAjAiA2shAiABIANqIQMDQAJAIAAgAyACIARBCGoQLCIFEAMEfyAFBSACIAVBA2oiBU8NAUG4fwsQGgwCCyAGQQFqIQYgAiAFayECIAMgBWohAyAEKAIMRQ0ACyAEKAI4BEAgAkEDTQRAIABBuH8QGgwCCyADQQRqIQMLIAQoAighAiAEKQMYIQcgAEEANgIEIAAgAyABazYCACAAIAIgBmytIAcgB0J/URs3AwgLIARBQGskAAslAQF/IwBBEGsiAiQAIAIgACABEFEgAigCACEAIAJBEGokACAAC30BBH8jAEGQBGsiBCQAIARB/wE2AggCQCAEQRBqIARBCGogBEEMaiABIAIQFSIGEAMEQCAGIQUMAQtBVCEFIAQoAgwiB0EGSw0AIAMgBEEQaiAEKAIIIAcQQSIFEAMNACAAIAEgBmogAiAGayADEDwhBQsgBEGQBGokACAFC4cBAgJ/An5BABAWIQMCQANAIAEgA08EQAJAIAAoAABBcHFB0NS0wgFGBEAgACABECIiAhADRQ0BQn4PCyAAIAEQVSIEQn1WDQMgBCAFfCIFIARUIQJCfiEEIAINAyAAIAEQUiICEAMNAwsgASACayEBIAAgAmohAAwBCwtCfiAFIAEbIQQLIAQLPwIBfwF+IwBBMGsiAiQAAn5CfiACQQhqIAAgARAtDQAaQgAgAigCHEEBRg0AGiACKQMICyEDIAJBMGokACADC40BAQJ/IwBBMGsiASQAAkAgAEUNACAAKAKI4gENACABIABB/OEBaigCADYCKCABIAApAvThATcDICAAEDAgACgCqOIBIQIgASABKAIoNgIYIAEgASkDIDcDECACIAFBEGoQGyAAQQA2AqjiASABIAEoAig2AgggASABKQMgNwMAIAAgARAbCyABQTBqJAALKgECfyMAQRBrIgAkACAAQQA2AgggAEIANwMAIAAQWCEBIABBEGokACABC4cBAQN/IwBBEGsiAiQAAkAgACgCAEUgACgCBEVzDQAgAiAAKAIINgIIIAIgACkCADcDAAJ/IAIoAgAiAQRAIAIoAghBqOMJIAERBQAMAQtBqOMJECgLIgFFDQAgASAAKQIANwL04QEgAUH84QFqIAAoAgg2AgAgARBZIAEhAwsgAkEQaiQAIAMLywEBAn8jAEEgayIBJAAgAEGBgIDAADYCtOIBIABBADYCiOIBIABBADYC7OEBIABCADcDkOIBIABBADYCpOMJIABBADYC3OIBIABCADcCzOIBIABBADYCvOIBIABBADYCxOABIABCADcCnOIBIABBpOIBakIANwIAIABBrOIBakEANgIAIAFCADcCECABQgA3AhggASABKQMYNwMIIAEgASkDEDcDACABKAIIQQh2QQFxIQIgAEEANgLg4gEgACACNgKM4gEgAUEgaiQAC3YBA38jAEEwayIBJAAgAARAIAEgAEHE0AFqIgIoAgA2AiggASAAKQK80AE3AyAgACgCACEDIAEgAigCADYCGCABIAApArzQATcDECADIAFBEGoQGyABIAEoAig2AgggASABKQMgNwMAIAAgARAbCyABQTBqJAALzAEBAX8gACABKAK00AE2ApjiASAAIAEoAgQiAjYCwOABIAAgAjYCvOABIAAgAiABKAIIaiICNgK44AEgACACNgLE4AEgASgCuNABBEAgAEKBgICAEDcDiOEBIAAgAUGk0ABqNgIMIAAgAUGUIGo2AgggACABQZwwajYCBCAAIAFBDGo2AgAgAEGs0AFqIAFBqNABaigCADYCACAAQbDQAWogAUGs0AFqKAIANgIAIABBtNABaiABQbDQAWooAgA2AgAPCyAAQgA3A4jhAQs7ACACRQRAQbp/DwsgBEUEQEFsDwsgAiAEEGAEQCAAIAEgAiADIAQgBRBhDwsgACABIAIgAyAEIAUQZQtGAQF/IwBBEGsiBSQAIAVBCGogBBAOAn8gBS0ACQRAIAAgASACIAMgBBAyDAELIAAgASACIAMgBBA0CyEAIAVBEGokACAACzQAIAAgAyAEIAUQNiIFEAMEQCAFDwsgBSAESQR/IAEgAiADIAVqIAQgBWsgABA1BUG4fwsLRgEBfyMAQRBrIgUkACAFQQhqIAQQDgJ/IAUtAAkEQCAAIAEgAiADIAQQYgwBCyAAIAEgAiADIAQQNQshACAFQRBqJAAgAAtZAQF/QQ8hAiABIABJBEAgAUEEdCAAbiECCyAAQQh2IgEgAkEYbCIAQYwIaigCAGwgAEGICGooAgBqIgJBA3YgAmogAEGACGooAgAgAEGECGooAgAgAWxqSQs3ACAAIAMgBCAFQYAQEDMiBRADBEAgBQ8LIAUgBEkEfyABIAIgAyAFaiAEIAVrIAAQMgVBuH8LC78DAQN/IwBBIGsiBSQAIAVBCGogAiADEAYiAhADRQRAIAAgAWoiB0F9aiEGIAUgBBAOIARBBGohAiAFLQACIQMDQEEAIAAgBkkgBUEIahAEGwRAIAAgAiAFQQhqIAMQAkECdGoiBC8BADsAACAFQQhqIAQtAAIQASAAIAQtAANqIgQgAiAFQQhqIAMQAkECdGoiAC8BADsAACAFQQhqIAAtAAIQASAEIAAtAANqIQAMAQUgB0F+aiEEA0AgBUEIahAEIAAgBEtyRQRAIAAgAiAFQQhqIAMQAkECdGoiBi8BADsAACAFQQhqIAYtAAIQASAAIAYtAANqIQAMAQsLA0AgACAES0UEQCAAIAIgBUEIaiADEAJBAnRqIgYvAQA7AAAgBUEIaiAGLQACEAEgACAGLQADaiEADAELCwJAIAAgB08NACAAIAIgBUEIaiADEAIiA0ECdGoiAC0AADoAACAALQADQQFGBEAgBUEIaiAALQACEAEMAQsgBSgCDEEfSw0AIAVBCGogAiADQQJ0ai0AAhABIAUoAgxBIUkNACAFQSA2AgwLIAFBbCAFQQhqEAobIQILCwsgBUEgaiQAIAILkgIBBH8jAEFAaiIJJAAgCSADQTQQCyEDAkAgBEECSA0AIAMgBEECdGooAgAhCSADQTxqIAgQIyADQQE6AD8gAyACOgA+QQAhBCADKAI8IQoDQCAEIAlGDQEgACAEQQJ0aiAKNgEAIARBAWohBAwAAAsAC0EAIQkDQCAGIAlGRQRAIAMgBSAJQQF0aiIKLQABIgtBAnRqIgwoAgAhBCADQTxqIAotAABBCHQgCGpB//8DcRAjIANBAjoAPyADIAcgC2siCiACajoAPiAEQQEgASAKa3RqIQogAygCPCELA0AgACAEQQJ0aiALNgEAIARBAWoiBCAKSQ0ACyAMIAo2AgAgCUEBaiEJDAELCyADQUBrJAALowIBCX8jAEHQAGsiCSQAIAlBEGogBUE0EAsaIAcgBmshDyAHIAFrIRADQAJAIAMgCkcEQEEBIAEgByACIApBAXRqIgYtAAEiDGsiCGsiC3QhDSAGLQAAIQ4gCUEQaiAMQQJ0aiIMKAIAIQYgCyAPTwRAIAAgBkECdGogCyAIIAUgCEE0bGogCCAQaiIIQQEgCEEBShsiCCACIAQgCEECdGooAgAiCEEBdGogAyAIayAHIA4QYyAGIA1qIQgMAgsgCUEMaiAOECMgCUEBOgAPIAkgCDoADiAGIA1qIQggCSgCDCELA0AgBiAITw0CIAAgBkECdGogCzYBACAGQQFqIQYMAAALAAsgCUHQAGokAA8LIAwgCDYCACAKQQFqIQoMAAALAAs0ACAAIAMgBCAFEDYiBRADBEAgBQ8LIAUgBEkEfyABIAIgAyAFaiAEIAVrIAAQNAVBuH8LCyMAIAA/AEEQdGtB//8DakEQdkAAQX9GBEBBAA8LQQAQAEEBCzsBAX8gAgRAA0AgACABIAJBgCAgAkGAIEkbIgMQCyEAIAFBgCBqIQEgAEGAIGohACACIANrIgINAAsLCwYAIAAQAwsLqBUJAEGICAsNAQAAAAEAAAACAAAAAgBBoAgLswYBAAAAAQAAAAIAAAACAAAAJgAAAIIAAAAhBQAASgAAAGcIAAAmAAAAwAEAAIAAAABJBQAASgAAAL4IAAApAAAALAIAAIAAAABJBQAASgAAAL4IAAAvAAAAygIAAIAAAACKBQAASgAAAIQJAAA1AAAAcwMAAIAAAACdBQAASgAAAKAJAAA9AAAAgQMAAIAAAADrBQAASwAAAD4KAABEAAAAngMAAIAAAABNBgAASwAAAKoKAABLAAAAswMAAIAAAADBBgAATQAAAB8NAABNAAAAUwQAAIAAAAAjCAAAUQAAAKYPAABUAAAAmQQAAIAAAABLCQAAVwAAALESAABYAAAA2gQAAIAAAABvCQAAXQAAACMUAABUAAAARQUAAIAAAABUCgAAagAAAIwUAABqAAAArwUAAIAAAAB2CQAAfAAAAE4QAAB8AAAA0gIAAIAAAABjBwAAkQAAAJAHAACSAAAAAAAAAAEAAAABAAAABQAAAA0AAAAdAAAAPQAAAH0AAAD9AAAA/QEAAP0DAAD9BwAA/Q8AAP0fAAD9PwAA/X8AAP3/AAD9/wEA/f8DAP3/BwD9/w8A/f8fAP3/PwD9/38A/f//AP3//wH9//8D/f//B/3//w/9//8f/f//P/3//38AAAAAAQAAAAIAAAADAAAABAAAAAUAAAAGAAAABwAAAAgAAAAJAAAACgAAAAsAAAAMAAAADQAAAA4AAAAPAAAAEAAAABEAAAASAAAAEwAAABQAAAAVAAAAFgAAABcAAAAYAAAAGQAAABoAAAAbAAAAHAAAAB0AAAAeAAAAHwAAAAMAAAAEAAAABQAAAAYAAAAHAAAACAAAAAkAAAAKAAAACwAAAAwAAAANAAAADgAAAA8AAAAQAAAAEQAAABIAAAATAAAAFAAAABUAAAAWAAAAFwAAABgAAAAZAAAAGgAAABsAAAAcAAAAHQAAAB4AAAAfAAAAIAAAACEAAAAiAAAAIwAAACUAAAAnAAAAKQAAACsAAAAvAAAAMwAAADsAAABDAAAAUwAAAGMAAACDAAAAAwEAAAMCAAADBAAAAwgAAAMQAAADIAAAA0AAAAOAAAADAAEAQeAPC1EBAAAAAQAAAAEAAAABAAAAAgAAAAIAAAADAAAAAwAAAAQAAAAEAAAABQAAAAcAAAAIAAAACQAAAAoAAAALAAAADAAAAA0AAAAOAAAADwAAABAAQcQQC4sBAQAAAAIAAAADAAAABAAAAAUAAAAGAAAABwAAAAgAAAAJAAAACgAAAAsAAAAMAAAADQAAAA4AAAAPAAAAEAAAABIAAAAUAAAAFgAAABgAAAAcAAAAIAAAACgAAAAwAAAAQAAAAIAAAAAAAQAAAAIAAAAEAAAACAAAABAAAAAgAAAAQAAAAIAAAAAAAQBBkBIL5gQBAAAAAQAAAAEAAAABAAAAAgAAAAIAAAADAAAAAwAAAAQAAAAGAAAABwAAAAgAAAAJAAAACgAAAAsAAAAMAAAADQAAAA4AAAAPAAAAEAAAAAEAAAAEAAAACAAAAAAAAAABAAEBBgAAAAAAAAQAAAAAEAAABAAAAAAgAAAFAQAAAAAAAAUDAAAAAAAABQQAAAAAAAAFBgAAAAAAAAUHAAAAAAAABQkAAAAAAAAFCgAAAAAAAAUMAAAAAAAABg4AAAAAAAEFEAAAAAAAAQUUAAAAAAABBRYAAAAAAAIFHAAAAAAAAwUgAAAAAAAEBTAAAAAgAAYFQAAAAAAABwWAAAAAAAAIBgABAAAAAAoGAAQAAAAADAYAEAAAIAAABAAAAAAAAAAEAQAAAAAAAAUCAAAAIAAABQQAAAAAAAAFBQAAACAAAAUHAAAAAAAABQgAAAAgAAAFCgAAAAAAAAULAAAAAAAABg0AAAAgAAEFEAAAAAAAAQUSAAAAIAABBRYAAAAAAAIFGAAAACAAAwUgAAAAAAADBSgAAAAAAAYEQAAAABAABgRAAAAAIAAHBYAAAAAAAAkGAAIAAAAACwYACAAAMAAABAAAAAAQAAAEAQAAACAAAAUCAAAAIAAABQMAAAAgAAAFBQAAACAAAAUGAAAAIAAABQgAAAAgAAAFCQAAACAAAAULAAAAIAAABQwAAAAAAAAGDwAAACAAAQUSAAAAIAABBRQAAAAgAAIFGAAAACAAAgUcAAAAIAADBSgAAAAgAAQFMAAAAAAAEAYAAAEAAAAPBgCAAAAAAA4GAEAAAAAADQYAIABBgBcLhwIBAAEBBQAAAAAAAAUAAAAAAAAGBD0AAAAAAAkF/QEAAAAADwX9fwAAAAAVBf3/HwAAAAMFBQAAAAAABwR9AAAAAAAMBf0PAAAAABIF/f8DAAAAFwX9/38AAAAFBR0AAAAAAAgE/QAAAAAADgX9PwAAAAAUBf3/DwAAAAIFAQAAABAABwR9AAAAAAALBf0HAAAAABEF/f8BAAAAFgX9/z8AAAAEBQ0AAAAQAAgE/QAAAAAADQX9HwAAAAATBf3/BwAAAAEFAQAAABAABgQ9AAAAAAAKBf0DAAAAABAF/f8AAAAAHAX9//8PAAAbBf3//wcAABoF/f//AwAAGQX9//8BAAAYBf3//wBBkBkLhgQBAAEBBgAAAAAAAAYDAAAAAAAABAQAAAAgAAAFBQAAAAAAAAUGAAAAAAAABQgAAAAAAAAFCQAAAAAAAAULAAAAAAAABg0AAAAAAAAGEAAAAAAAAAYTAAAAAAAABhYAAAAAAAAGGQAAAAAAAAYcAAAAAAAABh8AAAAAAAAGIgAAAAAAAQYlAAAAAAABBikAAAAAAAIGLwAAAAAAAwY7AAAAAAAEBlMAAAAAAAcGgwAAAAAACQYDAgAAEAAABAQAAAAAAAAEBQAAACAAAAUGAAAAAAAABQcAAAAgAAAFCQAAAAAAAAUKAAAAAAAABgwAAAAAAAAGDwAAAAAAAAYSAAAAAAAABhUAAAAAAAAGGAAAAAAAAAYbAAAAAAAABh4AAAAAAAAGIQAAAAAAAQYjAAAAAAABBicAAAAAAAIGKwAAAAAAAwYzAAAAAAAEBkMAAAAAAAUGYwAAAAAACAYDAQAAIAAABAQAAAAwAAAEBAAAABAAAAQFAAAAIAAABQcAAAAgAAAFCAAAACAAAAUKAAAAIAAABQsAAAAAAAAGDgAAAAAAAAYRAAAAAAAABhQAAAAAAAAGFwAAAAAAAAYaAAAAAAAABh0AAAAAAAAGIAAAAAAAEAYDAAEAAAAPBgOAAAAAAA4GA0AAAAAADQYDIAAAAAAMBgMQAAAAAAsGAwgAAAAACgYDBABBpB0L2QEBAAAAAwAAAAcAAAAPAAAAHwAAAD8AAAB/AAAA/wAAAP8BAAD/AwAA/wcAAP8PAAD/HwAA/z8AAP9/AAD//wAA//8BAP//AwD//wcA//8PAP//HwD//z8A//9/AP///wD///8B////A////wf///8P////H////z////9/AAAAAAEAAAACAAAABAAAAAAAAAACAAAABAAAAAgAAAAAAAAAAQAAAAIAAAABAAAABAAAAAQAAAAEAAAABAAAAAgAAAAIAAAACAAAAAcAAAAIAAAACQAAAAoAAAALAEGgIAsDwBBQ",e_=new WeakMap;let n_,i_=0;class r_ extends $d{constructor(t){super(t),this.transcoderPath="",this.transcoderBinary=null,this.transcoderPending=null,this.workerPool=new Ty,this.workerSourceURL="",this.workerConfig=null,"undefined"!=typeof MSC_TRANSCODER&&console.warn('THREE.KTX2Loader: Please update to latest "basis_transcoder". "msc_basis_transcoder" is no longer supported in three.js r125+.')}setTranscoderPath(t){return this.transcoderPath=t,this}setWorkerLimit(t){return this.workerPool.setWorkerLimit(t),this}async detectSupportAsync(t){return this.workerConfig={astcSupported:await t.hasFeatureAsync("texture-compression-astc"),astcHDRSupported:!1,etc1Supported:await t.hasFeatureAsync("texture-compression-etc1"),etc2Supported:await t.hasFeatureAsync("texture-compression-etc2"),dxtSupported:await t.hasFeatureAsync("texture-compression-bc"),bptcSupported:await t.hasFeatureAsync("texture-compression-bptc"),pvrtcSupported:await t.hasFeatureAsync("texture-compression-pvrtc")},this}detectSupport(t){return!0===t.isWebGPURenderer?this.workerConfig={astcSupported:t.hasFeature("texture-compression-astc"),astcHDRSupported:!1,etc1Supported:t.hasFeature("texture-compression-etc1"),etc2Supported:t.hasFeature("texture-compression-etc2"),dxtSupported:t.hasFeature("texture-compression-bc"),bptcSupported:t.hasFeature("texture-compression-bptc"),pvrtcSupported:t.hasFeature("texture-compression-pvrtc")}:this.workerConfig={astcSupported:t.extensions.has("WEBGL_compressed_texture_astc"),astcHDRSupported:t.extensions.has("WEBGL_compressed_texture_astc")&&t.extensions.get("WEBGL_compressed_texture_astc").getSupportedProfiles().includes("hdr"),etc1Supported:t.extensions.has("WEBGL_compressed_texture_etc1"),etc2Supported:t.extensions.has("WEBGL_compressed_texture_etc"),dxtSupported:t.extensions.has("WEBGL_compressed_texture_s3tc"),bptcSupported:t.extensions.has("EXT_texture_compression_bptc"),pvrtcSupported:t.extensions.has("WEBGL_compressed_texture_pvrtc")||t.extensions.has("WEBKIT_WEBGL_compressed_texture_pvrtc")},this}init(){if(!this.transcoderPending){const t=new np(this.manager);t.setPath(this.transcoderPath),t.setWithCredentials(this.withCredentials);const e=t.loadAsync("basis_transcoder.js"),n=new np(this.manager);n.setPath(this.transcoderPath),n.setResponseType("arraybuffer"),n.setWithCredentials(this.withCredentials);const i=n.loadAsync("basis_transcoder.wasm");this.transcoderPending=Promise.all([e,i]).then((([t,e])=>{const n=r_.BasisWorker.toString(),i=["/* constants */","let _EngineFormat = "+JSON.stringify(r_.EngineFormat),"let _EngineType = "+JSON.stringify(r_.EngineType),"let _TranscoderFormat = "+JSON.stringify(r_.TranscoderFormat),"let _BasisFormat = "+JSON.stringify(r_.BasisFormat),"/* basis_transcoder.js */",t,"/* worker */",n.substring(n.indexOf("{")+1,n.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([i])),this.transcoderBinary=e,this.workerPool.setWorkerCreator((()=>{const t=new Worker(this.workerSourceURL),e=this.transcoderBinary.slice(0);return t.postMessage({type:"init",config:this.workerConfig,transcoderBinary:e},[e]),t}))})),i_>0&&console.warn("THREE.KTX2Loader: Multiple active KTX2 loaders may cause performance issues. Use a single KTX2Loader instance, or call .dispose() on old instances."),i_++}return this.transcoderPending}load(t,e,n,i){if(null===this.workerConfig)throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");const r=new np(this.manager);r.setResponseType("arraybuffer"),r.setWithCredentials(this.withCredentials),r.load(t,(t=>{this.parse(t,e,i)}),n,i)}parse(t,e,n){if(null===this.workerConfig)throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");if(e_.has(t))return e_.get(t).promise.then(e).catch(n);this._createTexture(t).then((t=>e?e(t):null)).catch(n)}_createTextureFrom(t,e){const{type:n,error:i,data:{faces:r,width:s,height:a,format:o,type:l,dfdFlags:c}}=t;if("error"===n)return Promise.reject(i);let h;if(6===e.faceCount)h=new Jh(r,o,l);else{const t=r[0].mipmaps;h=e.layerCount>1?new Yh(t,s,a,e.layerCount,o,l):new Xh(t,s,a,o,l)}return h.minFilter=1===r[0].mipmaps.length?Lt:Ft,h.magFilter=Lt,h.generateMipmaps=!1,h.needsUpdate=!0,h.colorSpace=l_(e),h.premultiplyAlpha=!!(1&c),h}async _createTexture(t,e={}){const n=function(t){const e=new Uint8Array(t.buffer,t.byteOffset,qy.length);if(e[0]!==qy[0]||e[1]!==qy[1]||e[2]!==qy[2]||e[3]!==qy[3]||e[4]!==qy[4]||e[5]!==qy[5]||e[6]!==qy[6]||e[7]!==qy[7]||e[8]!==qy[8]||e[9]!==qy[9]||e[10]!==qy[10]||e[11]!==qy[11])throw new Error("Missing KTX 2.0 identifier.");const n=new Wy,i=17*Uint32Array.BYTES_PER_ELEMENT,r=new jy(t,qy.length,i,!0);n.vkFormat=r._nextUint32(),n.typeSize=r._nextUint32(),n.pixelWidth=r._nextUint32(),n.pixelHeight=r._nextUint32(),n.pixelDepth=r._nextUint32(),n.layerCount=r._nextUint32(),n.faceCount=r._nextUint32();const s=r._nextUint32();n.supercompressionScheme=r._nextUint32();const a=r._nextUint32(),o=r._nextUint32(),l=r._nextUint32(),c=r._nextUint32(),h=r._nextUint64(),u=r._nextUint64(),d=new jy(t,qy.length+i,3*s*8,!0);for(let e=0;e{const e=new $y;await e.init(),t(e)}))),n=await n_);const i=[];for(let r=0;r>r),a=Math.max(1,t.pixelHeight>>r),o=t.pixelDepth?Math.max(1,t.pixelDepth>>r):0,l=t.levels[r];let c,h;if(0===t.supercompressionScheme)c=l.levelData;else{if(2!==t.supercompressionScheme)throw new Error("THREE.KTX2Loader: Unsupported supercompressionScheme.");c=n.decode(l.levelData,l.uncompressedByteLength)}h=o_[e]===Wt?new Float32Array(c.buffer,c.byteOffset,c.byteLength/Float32Array.BYTES_PER_ELEMENT):o_[e]===jt?new Uint16Array(c.buffer,c.byteOffset,c.byteLength/Uint16Array.BYTES_PER_ELEMENT):c,i.push({data:h,width:s,height:a,depth:o})}let r;if(s_.has(a_[e]))r=0===t.pixelDepth?new Xc(i[0].data,t.pixelWidth,t.pixelHeight):new ki(i[0].data,t.pixelWidth,t.pixelHeight,t.pixelDepth);else{if(t.pixelDepth>0)throw new Error("THREE.KTX2Loader: Unsupported pixelDepth.");r=new Xh(i,t.pixelWidth,t.pixelHeight)}return r.mipmaps=i,r.type=o_[e],r.format=a_[e],r.colorSpace=l_(t),r.needsUpdate=!0,Promise.resolve(r)}(n);const r=e,s=this.init().then((()=>this.workerPool.postMessage({type:"transcode",buffer:t,taskConfig:r},[t]))).then((t=>this._createTextureFrom(t.data,n)));return e_.set(t,{promise:s}),s}dispose(){return this.workerPool.dispose(),this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),i_--,this}}r_.BasisFormat={ETC1S:0,UASTC:1,UASTC_HDR:2},r_.TranscoderFormat={ETC1:0,ETC2:1,BC1:2,BC3:3,BC4:4,BC5:5,BC7_M6_OPAQUE_ONLY:6,BC7_M5:7,PVRTC1_4_RGB:8,PVRTC1_4_RGBA:9,ASTC_4x4:10,ATC_RGB:11,ATC_RGBA_INTERPOLATED_ALPHA:12,RGBA32:13,RGB565:14,BGR565:15,RGBA4444:16,BC6H:22,RGB_HALF:24,RGBA_HALF:25},r_.EngineFormat={RGBAFormat:$t,RGBA_ASTC_4x4_Format:xe,RGB_BPTC_UNSIGNED_Format:Fe,RGBA_BPTC_Format:Ue,RGBA_ETC2_EAC_Format:_e,RGBA_PVRTC_4BPPV1_Format:ge,RGBA_S3TC_DXT5_Format:pe,RGB_ETC1_Format:ve,RGB_ETC2_Format:ye,RGB_PVRTC_4BPPV1_Format:fe,RGBA_S3TC_DXT1_Format:ue},r_.EngineType={UnsignedByteType:kt,HalfFloatType:jt,FloatType:Wt},r_.BasisWorker=function(){let t,e,n;const i=_EngineFormat,r=_EngineType,s=_TranscoderFormat,a=_BasisFormat;self.addEventListener("message",(function(i){const s=i.data;switch(s.type){case"init":t=s.config,o=s.transcoderBinary,e=new Promise((t=>{n={wasmBinary:o,onRuntimeInitialized:t},BASIS(n)})).then((()=>{n.initializeBasis(),void 0===n.KTX2File&&console.warn("THREE.KTX2Loader: Please update Basis Universal transcoder.")}));break;case"transcode":e.then((()=>{try{const{faces:e,buffers:i,width:o,height:u,hasAlpha:d,format:p,type:f,dfdFlags:m}=function(e){const i=new n.KTX2File(new Uint8Array(e));function s(){i.close(),i.delete()}if(!i.isValid())throw s(),new Error("THREE.KTX2Loader:\tInvalid or unsupported .ktx2 file");let o;if(i.isUASTC())o=a.UASTC;else if(i.isETC1S())o=a.ETC1S;else{if(!i.isHDR())throw new Error("THREE.KTX2Loader: Unknown Basis encoding");o=a.UASTC_HDR}const u=i.getWidth(),d=i.getHeight(),p=i.getLayers()||1,f=i.getLevels(),m=i.getFaces(),g=i.getHasAlpha(),A=i.getDFDFlags(),{transcoderFormat:v,engineFormat:y,engineType:_}=function(e,n,i,r){const s=l[e];for(let a=0;a1?(o=c.origWidth,l=c.origHeight):(o=c.width,l=c.height);let h=new Uint8Array(i.getImageTranscodedSizeInBytes(n,e,0,v));const u=i.transcodeImage(h,n,e,t,v,0,-1,-1);if(_===r.HalfFloatType&&(h=new Uint16Array(h.buffer,h.byteOffset,h.byteLength/Uint16Array.BYTES_PER_ELEMENT)),!u)throw s(),new Error("THREE.KTX2Loader: .transcodeImage failed.");a.push(h)}const c=h(a);e.push({data:c,width:o,height:l}),w.push(c.buffer)}x.push({mipmaps:e,width:u,height:d,format:y,type:_})}return s(),{faces:x,buffers:w,width:u,height:d,hasAlpha:g,dfdFlags:A,format:y,type:_}}(s.buffer);self.postMessage({type:"transcode",id:s.id,data:{faces:e,width:o,height:u,hasAlpha:d,format:p,type:f,dfdFlags:m}},i)}catch(t){console.error(t),self.postMessage({type:"error",id:s.id,error:t.message})}}))}var o}));const o=[{if:"astcSupported",basisFormat:[a.UASTC],transcoderFormat:[s.ASTC_4x4,s.ASTC_4x4],engineFormat:[i.RGBA_ASTC_4x4_Format,i.RGBA_ASTC_4x4_Format],engineType:[r.UnsignedByteType],priorityETC1S:1/0,priorityUASTC:1,needsPowerOfTwo:!1},{if:"bptcSupported",basisFormat:[a.ETC1S,a.UASTC],transcoderFormat:[s.BC7_M5,s.BC7_M5],engineFormat:[i.RGBA_BPTC_Format,i.RGBA_BPTC_Format],engineType:[r.UnsignedByteType],priorityETC1S:3,priorityUASTC:2,needsPowerOfTwo:!1},{if:"dxtSupported",basisFormat:[a.ETC1S,a.UASTC],transcoderFormat:[s.BC1,s.BC3],engineFormat:[i.RGBA_S3TC_DXT1_Format,i.RGBA_S3TC_DXT5_Format],engineType:[r.UnsignedByteType],priorityETC1S:4,priorityUASTC:5,needsPowerOfTwo:!1},{if:"etc2Supported",basisFormat:[a.ETC1S,a.UASTC],transcoderFormat:[s.ETC1,s.ETC2],engineFormat:[i.RGB_ETC2_Format,i.RGBA_ETC2_EAC_Format],engineType:[r.UnsignedByteType],priorityETC1S:1,priorityUASTC:3,needsPowerOfTwo:!1},{if:"etc1Supported",basisFormat:[a.ETC1S,a.UASTC],transcoderFormat:[s.ETC1],engineFormat:[i.RGB_ETC1_Format],engineType:[r.UnsignedByteType],priorityETC1S:2,priorityUASTC:4,needsPowerOfTwo:!1},{if:"pvrtcSupported",basisFormat:[a.ETC1S,a.UASTC],transcoderFormat:[s.PVRTC1_4_RGB,s.PVRTC1_4_RGBA],engineFormat:[i.RGB_PVRTC_4BPPV1_Format,i.RGBA_PVRTC_4BPPV1_Format],engineType:[r.UnsignedByteType],priorityETC1S:5,priorityUASTC:6,needsPowerOfTwo:!0},{if:"bptcSupported",basisFormat:[a.UASTC_HDR],transcoderFormat:[s.BC6H],engineFormat:[i.RGB_BPTC_UNSIGNED_Format],engineType:[r.HalfFloatType],priorityHDR:1,needsPowerOfTwo:!1},{basisFormat:[a.ETC1S,a.UASTC],transcoderFormat:[s.RGBA32,s.RGBA32],engineFormat:[i.RGBAFormat,i.RGBAFormat],engineType:[r.UnsignedByteType,r.UnsignedByteType],priorityETC1S:100,priorityUASTC:100,needsPowerOfTwo:!1},{basisFormat:[a.UASTC_HDR],transcoderFormat:[s.RGBA_HALF],engineFormat:[i.RGBAFormat],engineType:[r.HalfFloatType],priorityHDR:100,needsPowerOfTwo:!1}],l={[a.ETC1S]:o.filter((t=>t.basisFormat.includes(a.ETC1S))).sort(((t,e)=>t.priorityUASTC-e.priorityUASTC)),[a.UASTC]:o.filter((t=>t.basisFormat.includes(a.UASTC))).sort(((t,e)=>t.priorityUASTC-e.priorityUASTC)),[a.UASTC_HDR]:o.filter((t=>t.basisFormat.includes(a.UASTC_HDR))).sort(((t,e)=>t.priorityHDR-e.priorityHDR))};function c(t){return t<=2||!(t&t-1)&&0!==t}function h(t){if(1===t.length)return t[0];let e=0;for(let n=0;nt&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),"Y"===i.name&&Math.abs(M_.copy(P_).applyQuaternion(e).dot(this.eye))>t&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),"Z"===i.name&&Math.abs(M_.copy(L_).applyQuaternion(e).dot(this.eye))>t&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),"XY"===i.name&&Math.abs(M_.copy(L_).applyQuaternion(e).dot(this.eye)).9&&(i.visible=!1)),"Y"===this.axis&&(d_.setFromEuler(E_.set(0,0,Math.PI/2)),i.quaternion.copy(e).multiply(d_),Math.abs(M_.copy(P_).applyQuaternion(e).dot(this.eye))>.9&&(i.visible=!1)),"Z"===this.axis&&(d_.setFromEuler(E_.set(0,Math.PI/2,0)),i.quaternion.copy(e).multiply(d_),Math.abs(M_.copy(L_).applyQuaternion(e).dot(this.eye))>.9&&(i.visible=!1)),"XYZE"===this.axis&&(d_.setFromEuler(E_.set(0,Math.PI/2,0)),M_.copy(this.rotationAxis),i.quaternion.setFromRotationMatrix(S_.lookAt(b_,M_,P_)),i.quaternion.multiply(d_),i.visible=this.dragging),"E"===this.axis&&(i.visible=!1)):"START"===i.name?(i.position.copy(this.worldPositionStart),i.visible=this.dragging):"END"===i.name?(i.position.copy(this.worldPosition),i.visible=this.dragging):"DELTA"===i.name?(i.position.copy(this.worldPositionStart),i.quaternion.copy(this.worldQuaternionStart),h_.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),h_.applyQuaternion(this.worldQuaternionStart.clone().invert()),i.scale.copy(h_),i.visible=this.dragging):(i.quaternion.copy(e),this.dragging?i.position.copy(this.worldPositionStart):i.position.copy(this.worldPosition),this.axis&&(i.visible=-1!==this.axis.search(i.name)))}super.updateMatrixWorld(t)}}class Q_ extends Ks{constructor(){super(new Ca(1e5,1e5,2,2),new fs({visible:!1,wireframe:!0,side:b,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(t){let e=this.space;switch(this.position.copy(this.worldPosition),"scale"===this.mode&&(e="local"),U_.copy(D_).applyQuaternion("local"===e?this.worldQuaternion:T_),N_.copy(P_).applyQuaternion("local"===e?this.worldQuaternion:T_),F_.copy(L_).applyQuaternion("local"===e?this.worldQuaternion:T_),M_.copy(N_),this.mode){case"translate":case"scale":switch(this.axis){case"X":M_.copy(this.eye).cross(U_),B_.copy(U_).cross(M_);break;case"Y":M_.copy(this.eye).cross(N_),B_.copy(N_).cross(M_);break;case"Z":M_.copy(this.eye).cross(F_),B_.copy(F_).cross(M_);break;case"XY":B_.copy(F_);break;case"YZ":B_.copy(U_);break;case"XZ":M_.copy(F_),B_.copy(N_);break;case"XYZ":case"E":B_.set(0,0,0)}break;default:B_.set(0,0,0)}0===B_.length()?this.quaternion.copy(this.cameraQuaternion):(R_.lookAt(h_.set(0,0,0),B_,M_),this.quaternion.setFromRotationMatrix(R_)),super.updateMatrixWorld(t)}}const z_="csm_DiffuseColor",G_="csm_Roughness",H_="csm_Metalness",V_="csm_Emissive",W_="csm_AO",j_="csm_Bump",q_="csm_FragNormal",X_="csm_Clearcoat",Y_="csm_ClearcoatRoughness",J_="csm_ClearcoatNormal",K_="csm_Transmission",Z_="csm_Thickness",$_="csm_Iridescence",tx="csm_PointSize",ex="csm_FragColor",nx="csm_DepthAlpha",ix="csm_UnlitFac",rx="csm_Position",sx="csm_PositionRaw",ax="csm_Normal",ox={[`${rx}`]:"*",[`${sx}`]:"*",[`${ax}`]:"*",[`${nx}`]:"*",[`${tx}`]:["PointsMaterial"],[`${z_}`]:"*",[`${ex}`]:"*",[`${q_}`]:"*",[`${ix}`]:"*",[`${V_}`]:["MeshStandardMaterial","MeshPhysicalMaterial"],[`${G_}`]:["MeshStandardMaterial","MeshPhysicalMaterial"],[`${H_}`]:["MeshStandardMaterial","MeshPhysicalMaterial"],[`${$_}`]:["MeshStandardMaterial","MeshPhysicalMaterial"],[`${W_}`]:["MeshStandardMaterial","MeshPhysicalMaterial","MeshBasicMaterial","MeshLambertMaterial","MeshPhongMaterial","MeshToonMaterial"],[`${j_}`]:["MeshLambertMaterial","MeshMatcapMaterial","MeshNormalMaterial","MeshPhongMaterial","MeshPhysicalMaterial","MeshStandardMaterial","MeshToonMaterial","ShadowMaterial"],[`${X_}`]:["MeshPhysicalMaterial"],[`${Y_}`]:["MeshPhysicalMaterial"],[`${J_}`]:["MeshPhysicalMaterial"],[`${K_}`]:["MeshPhysicalMaterial"],[`${Z_}`]:["MeshPhysicalMaterial"]},lx={"*":{"#include ":Ea.lights_physical_fragment,"#include ":Ea.transmission_fragment},[`${ax}`]:{"#include ":`\n vec3 objectNormal = ${ax};\n #ifdef USE_TANGENT\n\t vec3 objectTangent = vec3( tangent.xyz );\n #endif\n `},[`${rx}`]:{"#include ":`\n vec3 transformed = ${rx};\n `},[`${sx}`]:{"#include ":`\n vec4 csm_internal_positionUnprojected = ${sx};\n mat4x4 csm_internal_unprojectMatrix = projectionMatrix * modelViewMatrix;\n #ifdef USE_INSTANCING\n csm_internal_unprojectMatrix = csm_internal_unprojectMatrix * instanceMatrix;\n #endif\n csm_internal_positionUnprojected = inverse(csm_internal_unprojectMatrix) * csm_internal_positionUnprojected;\n vec3 transformed = csm_internal_positionUnprojected.xyz;\n `},[`${tx}`]:{"gl_PointSize = size;":`\n gl_PointSize = ${tx};\n `},[`${z_}`]:{"#include ":`\n #include \n diffuseColor = ${z_};\n `},[`${ex}`]:{"#include ":`\n #include \n gl_FragColor = mix(gl_FragColor, ${ex}, ${ix});\n `},[`${V_}`]:{"vec3 totalEmissiveRadiance = emissive;":`\n vec3 totalEmissiveRadiance = ${V_};\n `},[`${G_}`]:{"#include ":`\n #include \n roughnessFactor = ${G_};\n `},[`${H_}`]:{"#include ":`\n #include \n metalnessFactor = ${H_};\n `},[`${W_}`]:{"#include ":`\n #include \n reflectedLight.indirectDiffuse *= 1. - ${W_};\n `},[`${j_}`]:{"#include ":`\n #include \n\n vec3 csm_internal_orthogonal = ${j_} - (dot(${j_}, normal) * normal);\n vec3 csm_internal_projectedbump = mat3(csm_internal_vModelViewMatrix) * csm_internal_orthogonal;\n normal = normalize(normal - csm_internal_projectedbump);\n `},[`${q_}`]:{"#include ":`\n #include \n normal = ${q_};\n `},[`${nx}`]:{"gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );":`\n gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity * 1.0 - ${nx} );\n `,"gl_FragColor = packDepthToRGBA( fragCoordZ );":`\n if(${nx} < 1.0) discard;\n gl_FragColor = packDepthToRGBA( dist );\n `,"gl_FragColor = packDepthToRGBA( dist );":`\n if(${nx} < 1.0) discard;\n gl_FragColor = packDepthToRGBA( dist );\n `},[`${X_}`]:{"material.clearcoat = clearcoat;":`material.clearcoat = ${X_};`},[`${Y_}`]:{"material.clearcoatRoughness = clearcoatRoughness;":`material.clearcoatRoughness = ${Y_};`},[`${J_}`]:{"#include ":"\n vec3 csm_coat_internal_orthogonal = csm_ClearcoatNormal - (dot(csm_ClearcoatNormal, nonPerturbedNormal) * nonPerturbedNormal);\n vec3 csm_coat_internal_projectedbump = mat3(csm_internal_vModelViewMatrix) * csm_coat_internal_orthogonal;\n vec3 clearcoatNormal = normalize(nonPerturbedNormal - csm_coat_internal_projectedbump);\n "},[`${K_}`]:{"material.transmission = transmission;":`\n material.transmission = ${K_};\n `},[`${Z_}`]:{"material.thickness = thickness;":`\n material.thickness = ${Z_};\n `},[`${$_}`]:{"material.iridescence = iridescence;":`\n material.iridescence = ${$_};\n `}},cx={clearcoat:[X_,J_,Y_],transmission:[K_],iridescence:[$_]};function hx(t){return t.replace(/\/\*[\s\S]*?\*\/|\/\/.*/g,"")}const ux="row",dx="row-reverse",px="column",fx="column-reverse";function mx(t,e,n,i){let r=n,s="getWidth",a="x",o="y";0===e.indexOf(px)&&(s="getHeight",a="y",o="x");for(let e=0;e{let o;switch(n){case vx:case"right":case"bottom":o=0===e.indexOf(ux)?-s+a[i]()/2+(a.margin||0):s-a[i]()/2-(a.margin||0);break;case gx:case"left":case"top":o=0===e.indexOf(ux)?s-a[i]()/2-(a.margin||0):-s+a[i]()/2+(a.margin||0)}t.childrenPos[a.id][r]=o||0}))}function xx(t){-1!==Cx.indexOf(t)&&console.warn(`alignItems === '${t}' is deprecated and will be remove in 7.x.x. Fallback are 'start'|'end'`)}const wx=[gx,Ax,vx,yx,"top","right","bottom","left"],Cx=["top","right","bottom","left"],Ex="start",Mx="center",bx="end",Sx="space-around",Ix="space-between",Tx="space-evenly";function Bx(t,e,n,i){const r=t.getJustifyContent();-1===Rx.indexOf(r)&&console.warn(`justifyContent === '${r}' is not supported`);const s=0===e.indexOf("row")?"width":"height",a=t.getChildrenSideSum(s),o=("width"===s?t.getInnerWidth():t.getInnerHeight())-a,l=function(t,e){switch(t){case bx:return e;case Mx:return e/2}return 0}(r,2*n-a*Math.sign(n)),c=function(t,e,n,i){const r=Array(t.length).fill(0);if(e>0)switch(n){case Ix:if(t.length>1){const n=e/(t.length-1)*i;r[0]=0;for(let e=1;e1){const n=e/(t.length+1)*i;for(let e=0;e1){const n=e/t.length*i,s=n/2;r[0]=s;for(let e=1;e{t.childrenPos[e.id][h]-=l-c[n]}))}const Rx=[Ex,Mx,bx,Sx,Ix,Tx];function Dx(t){return class extends t{constructor(t){super(t),this.isBoxComponent=!0,this.childrenPos={}}getInnerWidth(){const t=this.getContentDirection();switch(t){case"row":case"row-reverse":return this.width-(2*this.padding||0)||this.getChildrenSideSum("width");case"column":case"column-reverse":return this.getHighestChildSizeOn("width");default:console.error(`Invalid contentDirection : ${t}`)}}getInnerHeight(){const t=this.getContentDirection();switch(t){case"row":case"row-reverse":return this.getHighestChildSizeOn("height");case"column":case"column-reverse":return this.height-(2*this.padding||0)||this.getChildrenSideSum("height");default:console.error(`Invalid contentDirection : ${t}`)}}getChildrenSideSum(t){return this.childrenBoxes.reduce(((e,n)=>{const i=2*n.margin||0;return e+("width"===t?n.getWidth()+i:n.getHeight()+i)}),0)}setPosFromParentRecords(){this.parentUI&&this.parentUI.childrenPos[this.id]&&(this.position.x=this.parentUI.childrenPos[this.id].x,this.position.y=this.parentUI.childrenPos[this.id].y)}computeChildrenPosition(){if(this.children.length>0){const t=this.getContentDirection();let e;switch(t){case ux:e=-this.getInnerWidth()/2;break;case dx:e=this.getInnerWidth()/2;break;case px:e=this.getInnerHeight()/2;break;case fx:e=-this.getInnerHeight()/2}const n=-Math.sign(e);mx(this,t,e,n),Bx(this,t,e,n),_x(this,t)}}getHighestChildSizeOn(t){return this.childrenBoxes.reduce(((e,n)=>{const i=n.margin||0,r="width"===t?n.getWidth()+2*i:n.getHeight()+2*i;return Math.max(e,r)}),0)}getWidth(){return this.parentUI&&"stretch"===this.parentUI.getAlignItems()&&-1!==this.parentUI.getContentDirection().indexOf("column")?this.parentUI.getWidth()-(2*this.parentUI.padding||0):this.width||this.getInnerWidth()+(2*this.padding||0)}getHeight(){return this.parentUI&&"stretch"===this.parentUI.getAlignItems()&&-1!==this.parentUI.getContentDirection().indexOf("row")?this.parentUI.getHeight()-(2*this.parentUI.padding||0):this.height||this.getInnerHeight()+(2*this.padding||0)}}}const Px={"\t":"\t","\n":"\n","\r":"\r"," ":" "},Lx="normal",Ux="nowrap",Nx="pre",Fx="pre-line",Ox="pre-wrap",kx=function(t,e){switch(e){case Ux:case Lx:t=t.replace(/\n/g," ");case Fx:t=t.replace(/[ ]{2,}/g," ")}return t},Qx=function(t){switch(t){case Nx:case Ox:case Fx:return"mandatory"}},zx=function(t,e,n,i){const r=t[e];switch(i.WHITESPACE){case Lx:case Fx:case Ox:if("mandatory"===r.lineBreak)return!0;const s=r.kerning?r.kerning:0,a=r.xoffset?r.xoffset:0;if(n+(r.xadvance?r.xadvance:r.width)+a+s>i.INNER_WIDTH)return!0;const o=Wx(t,e,i);return function(t,e,n,i){return!(!t||!t.glyph)&&!(e+n-1}(t[e-1],n,o,i);case Nx:return"mandatory"===r.lineBreak;default:return!1}},Gx=function(t,e){const n=t[0],i=t[t.length-1];switch(e){case Ox:n.glyph&&"\n"===n.glyph&&t.length>1&&Vx([n],t[1]),i.glyph&&"\n"===i.glyph&&t.length>1&&Hx([i],t[t.length-2]);break;case Fx:case Ux:case Lx:let r,s=[];for(let e=0;ee))break;s.push(n),r=t[e+1]}Vx(s,r),s=[],r=null;for(let e=t.length-1;e>0;e--){const n=t[e];if(!(n.glyph&&Px[n.glyph]&&e>0))break;s.push(n),r=t[e-1]}Hx(s,r);break;case Nx:break;default:return console.warn(`whiteSpace: '${e}' is not valid`),0}return n.offsetX};function Hx(t,e){if(e)for(let n=0;n{switch(e){case Jx:case Yx:case jx:return-n/2;case Kx:case qx:return-t.width+n/2;case Xx:return-t.width/2;case Zx:return i?-t.width/2:-n/2;default:console.warn(`textAlign: '${e}' is not valid`)}};function ew(t){return class extends t{computeInlinesPosition(){const t=this.getWidth()-(2*this.padding||0),e=this.getHeight()-(2*this.padding||0),n=this.getJustifyContent(),i=this.getTextAlign(),r=this.getInterLine(),s=this.computeLines();s.interLine=r;const a=Math.abs(s.height),o=(()=>{switch(n){case"start":return e/2;case"end":return a-e/2;case"center":return a/2;default:console.warn(`justifyContent: '${n}' is not valid`)}})();s.forEach((t=>{t.y+=o,t.forEach((t=>{t.offsetY+=o}))})),$x(s,i,t),this.lines=s}calculateBestFit(t){if(0!==this.childrenInlines.length)switch(t){case"grow":this.calculateGrowFit();break;case"shrink":this.calculateShrinkFit();break;case"auto":this.calculateAutoFit()}}calculateGrowFit(){const t=this.getHeight()-(2*this.padding||0);let e=1;const n=this.childrenInlines.find((t=>t.isText));let i,r=1,s=2,a=n._fitFontSize?n._fitFontSize/n.getFontSize():1;do{if(i=this.calculateHeight(a),i>t){if(a<=r){this.childrenInlines.forEach((t=>{t.isInlineBlock||(t._fitFontSize=t.getFontSize())}));break}s=a,a-=(s-r)/2}else{if(Math.abs(t-i)<.075)break;Math.abs(a-s)<5e-10&&(s*=2),r=a,a+=(s-r)/2}}while(++e<=10)}calculateShrinkFit(){const t=this.getHeight()-(2*this.padding||0);let e=1;const n=this.childrenInlines.find((t=>t.isText));let i,r=0,s=1,a=n._fitFontSize?n._fitFontSize/n.getFontSize():1;do{if(i=this.calculateHeight(a),i>t)s=a,a-=(s-r)/2;else{if(a>=s){this.childrenInlines.forEach((t=>{t.isInlineBlock||(t._fitFontSize=t.getFontSize())}));break}if(Math.abs(t-i)<.075)break;r=a,a+=(s-r)/2}}while(++e<=10)}calculateAutoFit(){const t=this.getHeight()-(2*this.padding||0);let e=1;const n=this.childrenInlines.find((t=>t.isText));let i,r=0,s=2,a=n._fitFontSize?n._fitFontSize/n.getFontSize():1;do{if(i=this.calculateHeight(a),i>t)s=a,a-=(s-r)/2;else{if(Math.abs(t-i)<.075)break;Math.abs(a-s)<5e-10&&(s*=2),r=a,a+=(s-r)/2}}while(++e<=10)}computeLines(){const t=this.getWidth()-(2*this.padding||0),e=[[]];e.height=0;const n=this.getInterLine();this.childrenInlines.reduce(((n,i)=>{if(!i.inlines)return;const r=i._fitFontSize||i.getFontSize(),s=i.isText?i.getLetterSpacing()*r:0,a=i.getWhiteSpace(),o=i.getBreakOn(),l={WHITESPACE:a,LETTERSPACING:s,BREAKON:o,INNER_WIDTH:t},c=i.inlines.reduce(((t,n,i,r)=>{const a=n.kerning?n.kerning:0,o=n.xoffset?n.xoffset:0,c=n.xadvance?n.xadvance:n.width;return zx(r,i,t,l)?(e.push([n]),n.offsetX=o,0===n.width?0:c+s):(e[e.length-1].push(n),n.offsetX=t+o+a,t+c+a+s)}),n);return c}),0);let i=0,r=0,s=-n/2;return e.forEach((t=>{if(t.lineHeight=t.reduce(((t,e)=>{const n=void 0!==e.lineHeight?e.lineHeight:e.height;return Math.max(t,n)}),0),t.lineBase=t.reduce(((t,e)=>{const n=void 0!==e.lineBase?e.lineBase:e.height;return Math.max(t,n)}),0),t.width=0,t.height=t.lineHeight,t[0]){const e=this.getWhiteSpace(),a=Gx(t,e);t.forEach((t=>{t.offsetX-=a})),t.width=this.computeLineWidth(t),t.width>i&&(i=t.width),t.forEach((e=>{e.offsetY=s-e.height-e.anchor,e.lineHeight{e.isInlineBlock||(e._fitFontSize=e.getFontSize()*t,e.calculateInlines(e._fitFontSize))}));const e=this.computeLines();return Math.abs(e.height)}computeLineWidth(t){const e=t[0],n=t[t.length-1];return n.offsetX+n.width+e.offsetX}}}const nw=new np,iw=[],rw={},sw=new lp,aw=[],ow={},lw={};function cw(t){if(t._kernings)return;const e={};for(let n=0;n{const n=JSON.parse(t);cw(n),rw[e]=n;for(const t of Object.keys(lw))e===lw[t].jsonURL&&lw[t].component._updateFontFamily(n)}))),lw[t.id]||(lw[t.id]={component:t}),lw[t.id].jsonURL=e,rw[e]&&t._updateFontFamily(rw[e])}(t,e):(lw[t.id]||(lw[t.id]={component:t}),cw(e),lw[t.id].json=e,t._updateFontFamily(e))},setFontTexture:function(t,e){-1===aw.indexOf(e)&&(aw.push(e),sw.load(e,(t=>{t.generateMipmaps=!1,t.minFilter=Lt,t.magFilter=Lt,ow[e]=t;for(const n of Object.keys(lw))e===lw[n].textureURL&&lw[n].component._updateFontTexture(t)}))),lw[t.id]||(lw[t.id]={component:t}),lw[t.id].textureURL=e,ow[e]&&t._updateFontTexture(ow[e])},getFontOf:function t(e){const n=lw[e.id];return!n&&e.parentUI?t(e.parentUI):n},addFont:function(t,e,n){n.generateMipmaps=!1,n.minFilter=Lt,n.magFilter=Lt,iw.push(t),rw[t]=e,cw(e),n&&(aw.push(t),ow[t]=n)}};class uw{static requestUpdate(t,e,n,i){t.traverse((t=>{t.isUI&&(this.requestedUpdates[t.id]?(e&&(this.requestedUpdates[t.id].updateParsing=!0),n&&(this.requestedUpdates[t.id].updateLayout=!0),i&&(this.requestedUpdates[t.id].updateInner=!0)):this.requestedUpdates[t.id]={updateParsing:e,updateLayout:n,updateInner:i,needCallback:e||n||i})}))}static register(t){this.components.includes(t)||this.components.push(t)}static disposeOf(t){const e=this.components.indexOf(t);e>-1&&this.components.splice(e,1)}static update(){if(Object.keys(this.requestedUpdates).length>0){const t=this.components.filter((t=>!t.parentUI));t.forEach((t=>this.traverseParsing(t))),t.forEach((t=>this.traverseUpdates(t)))}}static traverseParsing(t){const e=this.requestedUpdates[t.id];e&&e.updateParsing&&(t.parseParams(),e.updateParsing=!1),t.childrenUIs.forEach((t=>this.traverseParsing(t)))}static traverseUpdates(t){const e=this.requestedUpdates[t.id];delete this.requestedUpdates[t.id],e&&e.updateLayout&&(e.updateLayout=!1,t.updateLayout()),e&&e.updateInner&&(e.updateInner=!1,t.updateInner()),t.childrenUIs.forEach((t=>{this.traverseUpdates(t)})),e&&e.needCallback&&t.onAfterUpdate()}}uw.components=[],uw.requestedUpdates={};const dw={container:null,fontFamily:null,fontSize:.05,fontKerning:"normal",bestFit:"none",offset:.01,interLine:.01,breakOn:"- ,.:?!\n",whiteSpace:Fx,contentDirection:px,alignItems:Ax,justifyContent:Ex,textAlign:Xx,textType:"MSDF",fontColor:new hs(16777215),fontOpacity:1,fontPXRange:4,fontSupersampling:!0,borderRadius:.01,borderWidth:0,borderColor:new hs("black"),borderOpacity:1,backgroundSize:"cover",backgroundColor:new hs(2236962),backgroundWhiteColor:new hs(16777215),backgroundOpacity:.8,backgroundOpaqueOpacity:1,getDefaultTexture:function(){if(!pw){const t=document.createElement("canvas").getContext("2d");t.canvas.width=1,t.canvas.height=1,t.fillStyle="#ffffff",t.fillRect(0,0,1,1),pw=new Kh(t.canvas),pw.isDefault=!0}return pw},hiddenOverflow:!1,letterSpacing:0};let pw;function fw(t){return class extends t{constructor(t){super(t),this.states={},this.currentState=void 0,this.isUI=!0,this.autoLayout=!0,this.childrenUIs=[],this.childrenBoxes=[],this.childrenTexts=[],this.childrenInlines=[],this.parentUI=null,this.addEventListener("added",this._rebuildParentUI),this.addEventListener("removed",this._rebuildParentUI)}getClippingPlanes(){const t=[];if(this.parentUI){if(this.isBlock&&this.parentUI.getHiddenOverflow()){const e=this.parentUI.getHeight()/2-(this.parentUI.padding||0),n=this.parentUI.getWidth()/2-(this.parentUI.padding||0),i=[new Aa(new Gi(0,1,0),e),new Aa(new Gi(0,-1,0),e),new Aa(new Gi(1,0,0),n),new Aa(new Gi(-1,0,0),n)];i.forEach((t=>{t.applyMatrix4(this.parent.matrixWorld)})),t.push(...i)}this.parentUI.parentUI&&t.push(...this.parentUI.getClippingPlanes())}return t}getHighestParent(){return this.parentUI?this.parent.getHighestParent():this}_getProperty(t){return void 0===this[t]&&this.parentUI?this.parent._getProperty(t):void 0!==this[t]?this[t]:dw[t]}getFontSize(){return this._getProperty("fontSize")}getFontKerning(){return this._getProperty("fontKerning")}getLetterSpacing(){return this._getProperty("letterSpacing")}getFontTexture(){return void 0===this.fontTexture&&this.parentUI?this.parent._getProperty("fontTexture"):void 0!==this.fontTexture?this.fontTexture:dw.getDefaultTexture()}getFontFamily(){return this._getProperty("fontFamily")}getBreakOn(){return this._getProperty("breakOn")}getWhiteSpace(){return this._getProperty("whiteSpace")}getTextAlign(){return this._getProperty("textAlign")}getTextType(){return this._getProperty("textType")}getFontColor(){return this._getProperty("fontColor")}getFontSupersampling(){return this._getProperty("fontSupersampling")}getFontOpacity(){return this._getProperty("fontOpacity")}getFontPXRange(){return this._getProperty("fontPXRange")}getBorderRadius(){return this._getProperty("borderRadius")}getBorderWidth(){return this._getProperty("borderWidth")}getBorderColor(){return this._getProperty("borderColor")}getBorderOpacity(){return this._getProperty("borderOpacity")}getContainer(){return!this.threeOBJ&&this.parent?this.parent.getContainer():this.threeOBJ?this:dw.container}getParentsNumber(t){return t=t||0,this.parentUI?this.parentUI.getParentsNumber(t+1):t}getBackgroundOpacity(){return this.backgroundOpacity||0===this.backgroundOpacity?this.backgroundOpacity:dw.backgroundOpacity}getBackgroundColor(){return this.backgroundColor||dw.backgroundColor}getBackgroundTexture(){return this.backgroundTexture||dw.getDefaultTexture()}getAlignContent(){return this.alignContent||dw.alignContent}getAlignItems(){return this.alignItems||dw.alignItems}getContentDirection(){return this.contentDirection||dw.contentDirection}getJustifyContent(){return this.justifyContent||dw.justifyContent}getInterLine(){return void 0===this.interLine?dw.interLine:this.interLine}getOffset(){return void 0===this.offset?dw.offset:this.offset}getBackgroundSize(){return void 0===this.backgroundSize?dw.backgroundSize:this.backgroundSize}getHiddenOverflow(){return void 0===this.hiddenOverflow?dw.hiddenOverflow:this.hiddenOverflow}getBestFit(){return void 0===this.bestFit?dw.bestFit:this.bestFit}_rebuildChildrenLists(){this.childrenUIs=this.children.filter((t=>t.isUI)),this.childrenBoxes=this.children.filter((t=>t.isBoxComponent)),this.childrenInlines=this.children.filter((t=>t.isInline)),this.childrenTexts=this.children.filter((t=>t.isText))}_rebuildParentUI=()=>{this.parent&&this.parent.isUI?this.parentUI=this.parent:this.parentUI=null};add(){for(const t of Object.keys(arguments))arguments[t].isInline&&this.update(null,!0);const t=super.add(...arguments);return this._rebuildChildrenLists(),t}remove(){for(const t of Object.keys(arguments))arguments[t].isInline&&this.update(null,!0);const t=super.remove(...arguments);return this._rebuildChildrenLists(),t}update(t,e,n){uw.requestUpdate(this,t,e,n)}onAfterUpdate(){}_updateFontFamily(t){this.fontFamily=t,this.traverse((t=>{t.isUI&&t.update(!0,!0,!1)})),this.getHighestParent().update(!1,!0,!1)}_updateFontTexture(t){this.fontTexture=t,this.getHighestParent().update(!1,!0,!1)}set(t){let e,n,i;if(uw.register(this),t&&JSON.stringify(t)!==JSON.stringify({})){t.alignContent&&(t.alignItems=t.alignContent,t.textAlign||(t.textAlign=t.alignContent),console.warn("`alignContent` property has been deprecated, please rely on `alignItems` and `textAlign` instead."),delete t.alignContent),t.alignItems&&xx(t.alignItems);for(const r of Object.keys(t))if(this[r]!=t[r])switch(r){case"content":case"fontSize":case"fontKerning":case"breakOn":case"whiteSpace":this.isText&&(e=!0),n=!0,this[r]=t[r];break;case"bestFit":this.isBlock&&(e=!0,n=!0),this[r]=t[r];break;case"width":case"height":case"padding":(this.isInlineBlock||this.isBlock&&"none"!=this.getBestFit())&&(e=!0),n=!0,this[r]=t[r];break;case"letterSpacing":case"interLine":this.isBlock&&"none"!=this.getBestFit()&&(e=!0),n=!0,this[r]=t[r];break;case"margin":case"contentDirection":case"justifyContent":case"alignContent":case"alignItems":case"textAlign":case"textType":n=!0,this[r]=t[r];break;case"fontColor":case"fontOpacity":case"fontSupersampling":case"offset":case"backgroundColor":case"backgroundOpacity":case"backgroundTexture":case"backgroundSize":case"borderRadius":case"borderWidth":case"borderColor":case"borderOpacity":i=!0,this[r]=t[r];break;case"hiddenOverflow":this[r]=t[r]}t.fontFamily&&hw.setFontFamily(this,t.fontFamily),t.fontTexture&&hw.setFontTexture(this,t.fontTexture),this.parentUI&&"none"!=this.parentUI.getBestFit()&&this.parentUI.update(!0,!0,!1),this.update(e,n,i),n&&this.getHighestParent().update(!1,!0,!1)}}setupState(t){this.states[t.state]={attributes:t.attributes,onSet:t.onSet}}setState(t){const e=this.states[t];e?t!==this.currentState&&(this.currentState=t,e.onSet&&e.onSet(),e.attributes&&this.set(e.attributes)):console.warn(`state "${t}" does not exist within this component:`,this.name)}clear(){this.traverse((t=>{uw.disposeOf(t),t.material&&t.material.dispose(),t.geometry&&t.geometry.dispose()}))}}}function mw(t){return class extends t{constructor(t){super(t),this.textUniforms={u_texture:{value:this.getFontTexture()},u_color:{value:this.getFontColor()},u_opacity:{value:this.getFontOpacity()},u_pxRange:{value:this.getFontPXRange()},u_useRGSS:{value:this.getFontSupersampling()}},this.backgroundUniforms={u_texture:{value:this.getBackgroundTexture()},u_color:{value:this.getBackgroundColor()},u_opacity:{value:this.getBackgroundOpacity()},u_backgroundMapping:{value:this.getBackgroundSize()},u_borderWidth:{value:this.getBorderWidth()},u_borderColor:{value:this.getBorderColor()},u_borderRadiusTopLeft:{value:this.getBorderRadius()},u_borderRadiusTopRight:{value:this.getBorderRadius()},u_borderRadiusBottomRight:{value:this.getBorderRadius()},u_borderRadiusBottomLeft:{value:this.getBorderRadius()},u_borderOpacity:{value:this.getBorderOpacity()},u_size:{value:new ci(1,1)},u_tSize:{value:new ci(1,1)}}}updateBackgroundMaterial(){this.backgroundUniforms.u_texture.value=this.getBackgroundTexture(),this.backgroundUniforms.u_tSize.value.set(this.backgroundUniforms.u_texture.value.image.width,this.backgroundUniforms.u_texture.value.image.height),this.size&&this.backgroundUniforms.u_size.value.copy(this.size),this.backgroundUniforms.u_texture.value.isDefault?(this.backgroundUniforms.u_color.value=this.getBackgroundColor(),this.backgroundUniforms.u_opacity.value=this.getBackgroundOpacity()):(this.backgroundUniforms.u_color.value=this.backgroundColor||dw.backgroundWhiteColor,this.backgroundUniforms.u_opacity.value=this.backgroundOpacity||0===this.backgroundOpacity?this.backgroundOpacity:dw.backgroundOpaqueOpacity),this.backgroundUniforms.u_backgroundMapping.value=(()=>{switch(this.getBackgroundSize()){case"stretch":return 0;case"contain":return 1;case"cover":return 2}})();const t=this.getBorderRadius();this.backgroundUniforms.u_borderWidth.value=this.getBorderWidth(),this.backgroundUniforms.u_borderColor.value=this.getBorderColor(),this.backgroundUniforms.u_borderOpacity.value=this.getBorderOpacity(),Array.isArray(t)?(this.backgroundUniforms.u_borderRadiusTopLeft.value=t[0],this.backgroundUniforms.u_borderRadiusTopRight.value=t[1],this.backgroundUniforms.u_borderRadiusBottomRight.value=t[2],this.backgroundUniforms.u_borderRadiusBottomLeft.value=t[3]):(this.backgroundUniforms.u_borderRadiusTopLeft.value=t,this.backgroundUniforms.u_borderRadiusTopRight.value=t,this.backgroundUniforms.u_borderRadiusBottomRight.value=t,this.backgroundUniforms.u_borderRadiusBottomLeft.value=t)}updateTextMaterial(){this.textUniforms.u_texture.value=this.getFontTexture(),this.textUniforms.u_color.value=this.getFontColor(),this.textUniforms.u_opacity.value=this.getFontOpacity(),this.textUniforms.u_pxRange.value=this.getFontPXRange(),this.textUniforms.u_useRGSS.value=this.getFontSupersampling()}getBackgroundMaterial(){return this.backgroundMaterial&&this.backgroundUniforms||(this.backgroundMaterial=this._makeBackgroundMaterial()),this.backgroundMaterial}getFontMaterial(){return this.fontMaterial&&this.textUniforms||(this.fontMaterial=this._makeTextMaterial()),this.fontMaterial}_makeTextMaterial(){return new ra({uniforms:this.textUniforms,transparent:!0,clipping:!0,vertexShader:gw,fragmentShader:Aw,extensions:{derivatives:!0}})}_makeBackgroundMaterial(){return new ra({uniforms:this.backgroundUniforms,transparent:!0,clipping:!0,vertexShader:vw,fragmentShader:yw,extensions:{derivatives:!0}})}updateClippingPlanes(t){const e=void 0!==t?t:this.getClippingPlanes();JSON.stringify(e)!==JSON.stringify(this.clippingPlanes)&&(this.clippingPlanes=e,this.fontMaterial&&(this.fontMaterial.clippingPlanes=this.clippingPlanes),this.backgroundMaterial&&(this.backgroundMaterial.clippingPlanes=this.clippingPlanes))}}}const gw="\nvarying vec2 vUv;\n\n#include \n\nvoid main() {\n\n\tvUv = uv;\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;\n\tgl_Position.z -= 0.00001;\n\n\t#include \n\n}\n",Aw="\n\nuniform sampler2D u_texture;\nuniform vec3 u_color;\nuniform float u_opacity;\nuniform float u_pxRange;\nuniform bool u_useRGSS;\n\nvarying vec2 vUv;\n\n#include \n\n// functions from the original msdf repo:\n// https://github.com/Chlumsky/msdfgen#using-a-multi-channel-distance-field\n\nfloat median(float r, float g, float b) {\n\treturn max(min(r, g), min(max(r, g), b));\n}\n\nfloat screenPxRange() {\n\tvec2 unitRange = vec2(u_pxRange)/vec2(textureSize(u_texture, 0));\n\tvec2 screenTexSize = vec2(1.0)/fwidth(vUv);\n\treturn max(0.5*dot(unitRange, screenTexSize), 1.0);\n}\n\nfloat tap(vec2 offsetUV) {\n\tvec3 msd = texture( u_texture, offsetUV ).rgb;\n\tfloat sd = median(msd.r, msd.g, msd.b);\n\tfloat screenPxDistance = screenPxRange() * (sd - 0.5);\n\tfloat alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);\n\treturn alpha;\n}\n\nvoid main() {\n\n\tfloat alpha;\n\n\tif ( u_useRGSS ) {\n\n\t\t// shader-based supersampling based on https://bgolus.medium.com/sharper-mipmapping-using-shader-based-supersampling-ed7aadb47bec\n\t\t// per pixel partial derivatives\n\t\tvec2 dx = dFdx(vUv);\n\t\tvec2 dy = dFdy(vUv);\n\n\t\t// rotated grid uv offsets\n\t\tvec2 uvOffsets = vec2(0.125, 0.375);\n\t\tvec2 offsetUV = vec2(0.0, 0.0);\n\n\t\t// supersampled using 2x2 rotated grid\n\t\talpha = 0.0;\n\t\toffsetUV.xy = vUv + uvOffsets.x * dx + uvOffsets.y * dy;\n\t\talpha += tap(offsetUV);\n\t\toffsetUV.xy = vUv - uvOffsets.x * dx - uvOffsets.y * dy;\n\t\talpha += tap(offsetUV);\n\t\toffsetUV.xy = vUv + uvOffsets.y * dx - uvOffsets.x * dy;\n\t\talpha += tap(offsetUV);\n\t\toffsetUV.xy = vUv - uvOffsets.y * dx + uvOffsets.x * dy;\n\t\talpha += tap(offsetUV);\n\t\talpha *= 0.25;\n\n\t} else {\n\n\t\talpha = tap( vUv );\n\n\t}\n\n\n\t// apply the opacity\n\talpha *= u_opacity;\n\n\t// this is useful to avoid z-fighting when quads overlap because of kerning\n\tif ( alpha < 0.02) discard;\n\n\n\tgl_FragColor = vec4( u_color, alpha );\n\n\t#include \n\n}\n",vw="\nvarying vec2 vUv;\n\n#include \n\nvoid main() {\n\n\tvUv = uv;\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;\n\n\t#include \n\n}\n",yw="\n\nuniform sampler2D u_texture;\nuniform vec3 u_color;\nuniform float u_opacity;\n\nuniform float u_borderRadiusTopLeft;\nuniform float u_borderRadiusTopRight;\nuniform float u_borderRadiusBottomLeft;\nuniform float u_borderRadiusBottomRight;\nuniform float u_borderWidth;\nuniform vec3 u_borderColor;\nuniform float u_borderOpacity;\nuniform vec2 u_size;\nuniform vec2 u_tSize;\nuniform int u_backgroundMapping;\n\nvarying vec2 vUv;\n\n#include \n\nfloat getEdgeDist() {\n\tvec2 ndc = vec2( vUv.x * 2.0 - 1.0, vUv.y * 2.0 - 1.0 );\n\tvec2 planeSpaceCoord = vec2( u_size.x * 0.5 * ndc.x, u_size.y * 0.5 * ndc.y );\n\tvec2 corner = u_size * 0.5;\n\tvec2 offsetCorner = corner - abs( planeSpaceCoord );\n\tfloat innerRadDist = min( offsetCorner.x, offsetCorner.y ) * -1.0;\n\tif (vUv.x < 0.5 && vUv.y >= 0.5) {\n\t\tfloat roundedDist = length( max( abs( planeSpaceCoord ) - u_size * 0.5 + u_borderRadiusTopLeft, 0.0 ) ) - u_borderRadiusTopLeft;\n\t\tfloat s = step( innerRadDist * -1.0, u_borderRadiusTopLeft );\n\t\treturn mix( innerRadDist, roundedDist, s );\n\t}\n\tif (vUv.x >= 0.5 && vUv.y >= 0.5) {\n\t\tfloat roundedDist = length( max( abs( planeSpaceCoord ) - u_size * 0.5 + u_borderRadiusTopRight, 0.0 ) ) - u_borderRadiusTopRight;\n\t\tfloat s = step( innerRadDist * -1.0, u_borderRadiusTopRight );\n\t\treturn mix( innerRadDist, roundedDist, s );\n\t}\n\tif (vUv.x >= 0.5 && vUv.y < 0.5) {\n\t\tfloat roundedDist = length( max( abs( planeSpaceCoord ) - u_size * 0.5 + u_borderRadiusBottomRight, 0.0 ) ) - u_borderRadiusBottomRight;\n\t\tfloat s = step( innerRadDist * -1.0, u_borderRadiusBottomRight );\n\t\treturn mix( innerRadDist, roundedDist, s );\n\t}\n\tif (vUv.x < 0.5 && vUv.y < 0.5) {\n\t\tfloat roundedDist = length( max( abs( planeSpaceCoord ) - u_size * 0.5 + u_borderRadiusBottomLeft, 0.0 ) ) - u_borderRadiusBottomLeft;\n\t\tfloat s = step( innerRadDist * -1.0, u_borderRadiusBottomLeft );\n\t\treturn mix( innerRadDist, roundedDist, s );\n\t}\n}\n\nvec4 sampleTexture() {\n\tfloat textureRatio = u_tSize.x / u_tSize.y;\n\tfloat panelRatio = u_size.x / u_size.y;\n\tvec2 uv = vUv;\n\tif ( u_backgroundMapping == 1 ) { // contain\n\t\tif ( textureRatio < panelRatio ) { // repeat on X\n\t\t\tfloat newX = uv.x * ( panelRatio / textureRatio );\n\t\t\tnewX += 0.5 - 0.5 * ( panelRatio / textureRatio );\n\t\t\tuv.x = newX;\n\t\t} else { // repeat on Y\n\t\t\tfloat newY = uv.y * ( textureRatio / panelRatio );\n\t\t\tnewY += 0.5 - 0.5 * ( textureRatio / panelRatio );\n\t\t\tuv.y = newY;\n\t\t}\n\t} else if ( u_backgroundMapping == 2 ) { // cover\n\t\tif ( textureRatio < panelRatio ) { // stretch on Y\n\t\t\tfloat newY = uv.y * ( textureRatio / panelRatio );\n\t\t\tnewY += 0.5 - 0.5 * ( textureRatio / panelRatio );\n\t\t\tuv.y = newY;\n\t\t} else { // stretch on X\n\t\t\tfloat newX = uv.x * ( panelRatio / textureRatio );\n\t\t\tnewX += 0.5 - 0.5 * ( panelRatio / textureRatio );\n\t\t\tuv.x = newX;\n\t\t}\n\t}\n\treturn texture2D( u_texture, uv ).rgba;\n}\n\nvoid main() {\n\n\tfloat edgeDist = getEdgeDist();\n\tfloat change = fwidth( edgeDist );\n\n\tvec4 textureSample = sampleTexture();\n\tvec3 blendedColor = textureSample.rgb * u_color;\n\n\tfloat alpha = smoothstep( change, 0.0, edgeDist );\n\tfloat blendedOpacity = u_opacity * textureSample.a * alpha;\n\n\tvec4 frameColor = vec4( blendedColor, blendedOpacity );\n\n\tif ( u_borderWidth <= 0.0 ) {\n\t\tgl_FragColor = frameColor;\n\t} else {\n\t\tvec4 borderColor = vec4( u_borderColor, u_borderOpacity * alpha );\n\t\tfloat stp = smoothstep( edgeDist + change, edgeDist, u_borderWidth * -1.0 );\n\t\tgl_FragColor = mix( frameColor, borderColor, stp );\n\t}\n\n\t#include \n}\n";class _w extends Ks{constructor(t){super(new Ca,t),this.castShadow=!0,this.receiveShadow=!0,this.name="MeshUI-Frame"}}let xw=null;function ww(...t){if(!xw)throw new Error("Cannot use mixins with Base null");let e=xw;xw=null;let n,i=t.length;for(;--i>=0;)n=t[i],e=n(e);return e}ww.withBase=t=>(xw=t,ww);class Cw extends(ww.withBase(Wr)(Dx,ew,mw,fw)){constructor(t){super(t),this.isBlock=!0,this.size=new ci(1,1),this.frame=new _w(this.getBackgroundMaterial()),this.frame.onBeforeRender=()=>{this.updateClippingPlanes&&this.updateClippingPlanes()},this.add(this.frame),this.set(t)}parseParams(){const t=this.getBestFit();"none"!=t&&this.childrenTexts.length?this.calculateBestFit(t):this.childrenTexts.forEach((t=>{t._fitFontSize=void 0}))}updateLayout(){const t=this.getWidth(),e=this.getHeight();t&&e?(this.size.set(t,e),this.frame.scale.set(t,e,1),this.frame&&this.updateBackgroundMaterial(),this.frame.renderOrder=this.getParentsNumber(),this.autoLayout&&this.setPosFromParentRecords(),this.childrenInlines.length&&this.computeInlinesPosition(),this.computeChildrenPosition(),this.parentUI&&(this.position.z=this.getOffset())):console.warn("Block got no dimension from its parameters or from children parameters")}updateInner(){this.parentUI&&(this.position.z=this.getOffset()),this.frame&&this.updateBackgroundMaterial()}}function Ew(t){return class extends t{constructor(t){super(t),this.isInline=!0}}}class Mw extends Ca{constructor(t,e){const n=t.glyph,i=t.fontSize;super(t.width,t.height),null===n.match(/\s/g)?(-1===e.info.charset.indexOf(n)&&console.error(`The character '${n}' is not included in the font characters set.`),this.mapUVs(e,n),this.transformGeometry(t)):(this.nullifyUVs(),this.scale(0,0,1),this.translate(0,i/2,0))}mapUVs(t,e){const n=t.chars.find((t=>t.char===e)),i=t.common,r=n.x/i.scaleW,s=(n.x+n.width)/i.scaleW,a=1-(n.y+n.height)/i.scaleH,o=1-n.y/i.scaleH,l=this.attributes.uv;for(let t=0;t{switch(t){case 0:return[r,o];case 1:return[s,o];case 2:return[r,a];case 3:return[s,a]}})(),l.setXY(t,e,n)}}nullifyUVs(){const t=this.attributes.uv;for(let e=0;et.char===i));let a=s?s.width*r:n/3,o=s?s.height*r:0;0===a&&(a=s?s.xadvance*r:n),0===o&&(o=.7*n),"\n"===i&&(a=0);const l=s?s.xadvance*r:a,c=s?s.xoffset*r:0;return{width:a,height:o,anchor:s?s.yoffset*r:0,xadvance:l,xoffset:c}},getGlyphPairKerning:function(t,e){const n=t._kernings;return n[e]?n[e]:0},buildText:function(){const t=[];this.inlines.forEach(((e,n)=>{t[n]=new Mw(e,this.getFontFamily()),t[n].translate(e.offsetX,e.offsetY,0)}));const e=Bg(t);return new Ks(e,this.getFontMaterial())}};function Sw(t){return class extends t{createText(){const t=this,e=(()=>{if("MSDF"===this.getTextType())return bw.buildText.call(this);console.warn(`'${this.getTextType()}' is not a supported text type.\nSee https://github.com/felixmariotto/three-mesh-ui/wiki/Using-a-custom-text-type`)})();return e.renderOrder=1/0,e.onBeforeRender=function(){t.updateClippingPlanes&&t.updateClippingPlanes()},e}getGlyphDimensions(t){if("MSDF"===t.textType)return bw.getGlyphDimensions(t);console.warn(`'${t.textType}' is not a supported text type.\nSee https://github.com/felixmariotto/three-mesh-ui/wiki/Using-a-custom-text-type`)}getGlyphPairKerning(t,e,n){if("MSDF"===t)return bw.getGlyphPairKerning(e,n);console.warn(`'${t}' is not a supported text type.\nSee https://github.com/felixmariotto/three-mesh-ui/wiki/Using-a-custom-text-type`)}}}const Iw=function t(e){e.children.forEach((n=>{n.children.length>0&&t(n),e.remove(n),uw.disposeOf(n),n.material&&n.material.dispose(),n.geometry&&n.geometry.dispose()})),e.children=[]};class Tw extends(ww.withBase(Wr)(Ew,Sw,mw,fw)){constructor(t){super(t),this.isText=!0,this.set(t)}parseParams(){this.calculateInlines(this._fitFontSize||this.getFontSize())}updateLayout(){Iw(this),this.inlines&&(this.textContent=this.createText(),this.updateTextMaterial(),this.add(this.textContent)),this.position.z=this.getOffset()}updateInner(){this.position.z=this.getOffset(),this.textContent&&this.updateTextMaterial()}calculateInlines(t){const e=this.content,n=this.getFontFamily(),i=this.getBreakOn(),r=this.getTextType(),s=this.getWhiteSpace();if(!n||"string"==typeof n)return void(hw.getFontOf(this)||console.warn("no font was found"));if(!this.content)return void(this.inlines=null);if(!r)return void console.error("You must provide a 'textType' attribute so three-mesh-ui knows how to render your text.\n See https://github.com/felixmariotto/three-mesh-ui/wiki/Using-a-custom-text-type");const a=kx(e,s),o=Array.from?Array.from(a):String(a).split(""),l=t/n.info.size,c=n.common.lineHeight*l,h=n.common.base*l,u=o.map((e=>{const a=this.getGlyphDimensions({textType:r,glyph:e,font:n,fontSize:t});let o=null;return s!==Ux&&(i.includes(e)||e.match(/\s/g))&&(o="possible"),e.match(/\n/g)&&(o=Qx(s)),{height:a.height,width:a.width,anchor:a.anchor,xadvance:a.xadvance,xoffset:a.xoffset,lineBreak:o,glyph:e,fontSize:t,lineHeight:c,lineBase:h}}));if("none"!==this.getFontKerning())for(let e=1;e{this.updateClippingPlanes&&this.updateClippingPlanes()},this.add(this.frame),this.set(t)}parseParams(){this.width||console.warn("inlineBlock has no width. Set to 0.3 by default"),this.height||console.warn("inlineBlock has no height. Set to 0.3 by default"),this.inlines=[{height:this.height||.3,width:this.width||.3,anchor:0,lineBreak:"possible"}]}updateLayout(){const t=this.getWidth(),e=this.getHeight();if(this.inlines){const t=this.inlines[0];this.position.set(t.width/2,t.height/2,0),this.position.x+=t.offsetX,this.position.y+=t.offsetY}this.size.set(t,e),this.frame.scale.set(t,e,1),this.frame&&this.updateBackgroundMaterial(),this.frame.renderOrder=this.getParentsNumber(),this.childrenInlines.length&&this.computeInlinesPosition(),this.computeChildrenPosition(),this.position.z=this.getOffset()}updateInner(){this.position.z=this.getOffset(),this.frame&&this.updateBackgroundMaterial()}}const Rw=[[[{width:.1,chars:[{lowerCase:"a",upperCase:"A"}]},{width:.1,chars:[{lowerCase:"z",upperCase:"Z"}]},{width:.1,chars:[{lowerCase:"e",upperCase:"E"}]},{width:.1,chars:[{lowerCase:"r",upperCase:"R"}]},{width:.1,chars:[{lowerCase:"t",upperCase:"T"}]},{width:.1,chars:[{lowerCase:"y",upperCase:"Y"}]},{width:.1,chars:[{lowerCase:"u",upperCase:"U"}]},{width:.1,chars:[{lowerCase:"i",upperCase:"I"}]},{width:.1,chars:[{lowerCase:"o",upperCase:"O"}]},{width:.1,chars:[{lowerCase:"p",upperCase:"P"}]}],[{width:.1,chars:[{lowerCase:"q",upperCase:"Q"}]},{width:.1,chars:[{lowerCase:"s",upperCase:"S"}]},{width:.1,chars:[{lowerCase:"d",upperCase:"D"}]},{width:.1,chars:[{lowerCase:"f",upperCase:"F"}]},{width:.1,chars:[{lowerCase:"g",upperCase:"G"}]},{width:.1,chars:[{lowerCase:"h",upperCase:"H"}]},{width:.1,chars:[{lowerCase:"j",upperCase:"J"}]},{width:.1,chars:[{lowerCase:"k",upperCase:"K"}]},{width:.1,chars:[{lowerCase:"l",upperCase:"L"}]},{width:.1,chars:[{lowerCase:"m",upperCase:"M"}]}],[{width:.2,command:"shift",chars:[{icon:"shift"}]},{width:.1,chars:[{lowerCase:"w",upperCase:"W"}]},{width:.1,chars:[{lowerCase:"x",upperCase:"X"}]},{width:.1,chars:[{lowerCase:"c",upperCase:"C"}]},{width:.1,chars:[{lowerCase:"v",upperCase:"V"}]},{width:.1,chars:[{lowerCase:"b",upperCase:"B"}]},{width:.1,chars:[{lowerCase:"n",upperCase:"N"}]},{width:.2,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]],[[{width:.1,chars:[{lowerCase:"1"}]},{width:.1,chars:[{lowerCase:"2"}]},{width:.1,chars:[{lowerCase:"3"}]},{width:.1,chars:[{lowerCase:"4"}]},{width:.1,chars:[{lowerCase:"5"}]},{width:.1,chars:[{lowerCase:"6"}]},{width:.1,chars:[{lowerCase:"7"}]},{width:.1,chars:[{lowerCase:"8"}]},{width:.1,chars:[{lowerCase:"9"}]},{width:.1,chars:[{lowerCase:"0"}]}],[{width:.1,chars:[{lowerCase:"@"}]},{width:.1,chars:[{lowerCase:"#"}]},{width:.1,chars:[{lowerCase:"|"}]},{width:.1,chars:[{lowerCase:"_"}]},{width:.1,chars:[{lowerCase:"&"}]},{width:.1,chars:[{lowerCase:"-"}]},{width:.1,chars:[{lowerCase:"+"}]},{width:.1,chars:[{lowerCase:"("}]},{width:.1,chars:[{lowerCase:")"}]},{width:.1,chars:[{lowerCase:"/"}]}],[{width:.1,chars:[{lowerCase:"="}]},{width:.1,chars:[{lowerCase:"*"}]},{width:.1,chars:[{lowerCase:'"'}]},{width:.1,chars:[{lowerCase:"'"}]},{width:.1,chars:[{lowerCase:":"}]},{width:.1,chars:[{lowerCase:";"}]},{width:.1,chars:[{lowerCase:"!"}]},{width:.1,chars:[{lowerCase:"?"}]},{width:.2,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]]],Dw=[[[{width:.1,chars:[{lowerCase:"q",upperCase:"Q"}]},{width:.1,chars:[{lowerCase:"w",upperCase:"W"}]},{width:.1,chars:[{lowerCase:"e",upperCase:"E"}]},{width:.1,chars:[{lowerCase:"r",upperCase:"R"}]},{width:.1,chars:[{lowerCase:"t",upperCase:"T"}]},{width:.1,chars:[{lowerCase:"y",upperCase:"Y"}]},{width:.1,chars:[{lowerCase:"u",upperCase:"U"}]},{width:.1,chars:[{lowerCase:"i",upperCase:"I"}]},{width:.1,chars:[{lowerCase:"o",upperCase:"O"}]},{width:.1,chars:[{lowerCase:"p",upperCase:"P"}]}],[{width:.1,chars:[{lowerCase:"a",upperCase:"A"}]},{width:.1,chars:[{lowerCase:"s",upperCase:"S"}]},{width:.1,chars:[{lowerCase:"d",upperCase:"D"}]},{width:.1,chars:[{lowerCase:"f",upperCase:"F"}]},{width:.1,chars:[{lowerCase:"g",upperCase:"G"}]},{width:.1,chars:[{lowerCase:"h",upperCase:"H"}]},{width:.1,chars:[{lowerCase:"j",upperCase:"J"}]},{width:.1,chars:[{lowerCase:"k",upperCase:"K"}]},{width:.1,chars:[{lowerCase:"l",upperCase:"L"}]}],[{width:.15,command:"shift",chars:[{icon:"shift"}]},{width:.1,chars:[{lowerCase:"z",upperCase:"Z"}]},{width:.1,chars:[{lowerCase:"x",upperCase:"X"}]},{width:.1,chars:[{lowerCase:"c",upperCase:"C"}]},{width:.1,chars:[{lowerCase:"v",upperCase:"V"}]},{width:.1,chars:[{lowerCase:"b",upperCase:"B"}]},{width:.1,chars:[{lowerCase:"n",upperCase:"N"}]},{width:.1,chars:[{lowerCase:"m",upperCase:"M"}]},{width:.15,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]],[[{width:.1,chars:[{lowerCase:"1"}]},{width:.1,chars:[{lowerCase:"2"}]},{width:.1,chars:[{lowerCase:"3"}]},{width:.1,chars:[{lowerCase:"4"}]},{width:.1,chars:[{lowerCase:"5"}]},{width:.1,chars:[{lowerCase:"6"}]},{width:.1,chars:[{lowerCase:"7"}]},{width:.1,chars:[{lowerCase:"8"}]},{width:.1,chars:[{lowerCase:"9"}]},{width:.1,chars:[{lowerCase:"0"}]}],[{width:.1,chars:[{lowerCase:"@"}]},{width:.1,chars:[{lowerCase:"#"}]},{width:.1,chars:[{lowerCase:"|"}]},{width:.1,chars:[{lowerCase:"_"}]},{width:.1,chars:[{lowerCase:"&"}]},{width:.1,chars:[{lowerCase:"-"}]},{width:.1,chars:[{lowerCase:"+"}]},{width:.1,chars:[{lowerCase:"("}]},{width:.1,chars:[{lowerCase:")"}]},{width:.1,chars:[{lowerCase:"/"}]}],[{width:.1,chars:[{lowerCase:"="}]},{width:.1,chars:[{lowerCase:"*"}]},{width:.1,chars:[{lowerCase:'"'}]},{width:.1,chars:[{lowerCase:"'"}]},{width:.1,chars:[{lowerCase:":"}]},{width:.1,chars:[{lowerCase:";"}]},{width:.1,chars:[{lowerCase:"!"}]},{width:.1,chars:[{lowerCase:"?"}]},{width:.2,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]]],Pw=[[[{width:1/12,chars:[{lowerCase:"й",upperCase:"Й"},{lowerCase:"q",upperCase:"Q"}]},{width:1/12,chars:[{lowerCase:"ц",upperCase:"Ц"},{lowerCase:"w",upperCase:"W"}]},{width:1/12,chars:[{lowerCase:"у",upperCase:"У"},{lowerCase:"e",upperCase:"E"}]},{width:1/12,chars:[{lowerCase:"к",upperCase:"К"},{lowerCase:"r",upperCase:"R"}]},{width:1/12,chars:[{lowerCase:"е",upperCase:"Е"},{lowerCase:"t",upperCase:"T"}]},{width:1/12,chars:[{lowerCase:"н",upperCase:"Н"},{lowerCase:"y",upperCase:"Y"}]},{width:1/12,chars:[{lowerCase:"г",upperCase:"Г"},{lowerCase:"u",upperCase:"U"}]},{width:1/12,chars:[{lowerCase:"ш",upperCase:"Ш"},{lowerCase:"i",upperCase:"I"}]},{width:1/12,chars:[{lowerCase:"щ",upperCase:"Щ"},{lowerCase:"o",upperCase:"O"}]},{width:1/12,chars:[{lowerCase:"з",upperCase:"З"},{lowerCase:"p",upperCase:"P"}]},{width:1/12,chars:[{lowerCase:"х",upperCase:"Х"},{lowerCase:"{",upperCase:"["}]},{width:1/12,chars:[{lowerCase:"ъ",upperCase:"Ъ"},{lowerCase:"}",upperCase:"]"}]}],[{width:1/12,chars:[{lowerCase:"ф",upperCase:"Ф"},{lowerCase:"a",upperCase:"A"}]},{width:1/12,chars:[{lowerCase:"ы",upperCase:"Ы"},{lowerCase:"s",upperCase:"S"}]},{width:1/12,chars:[{lowerCase:"в",upperCase:"В"},{lowerCase:"d",upperCase:"D"}]},{width:1/12,chars:[{lowerCase:"а",upperCase:"А"},{lowerCase:"f",upperCase:"F"}]},{width:1/12,chars:[{lowerCase:"п",upperCase:"П"},{lowerCase:"g",upperCase:"G"}]},{width:1/12,chars:[{lowerCase:"р",upperCase:"Р"},{lowerCase:"h",upperCase:"H"}]},{width:1/12,chars:[{lowerCase:"о",upperCase:"О"},{lowerCase:"j",upperCase:"J"}]},{width:1/12,chars:[{lowerCase:"л",upperCase:"Л"},{lowerCase:"k",upperCase:"K"}]},{width:1/12,chars:[{lowerCase:"д",upperCase:"Д"},{lowerCase:"l",upperCase:"L"}]},{width:1/12,chars:[{lowerCase:"ж",upperCase:"Ж"},{lowerCase:":",upperCase:";"}]},{width:1/12,chars:[{lowerCase:"э",upperCase:"Э"},{lowerCase:'"',upperCase:"'"}]},{width:1/12,chars:[{lowerCase:"ё",upperCase:"Ё"},{lowerCase:"|",upperCase:"\\"}]}],[{width:.125,command:"shift",chars:[{icon:"shift"}]},{width:1/12,chars:[{lowerCase:"я",upperCase:"Я"},{lowerCase:"z",upperCase:"Z"}]},{width:1/12,chars:[{lowerCase:"ч",upperCase:"Ч"},{lowerCase:"x",upperCase:"X"}]},{width:1/12,chars:[{lowerCase:"с",upperCase:"С"},{lowerCase:"c",upperCase:"C"}]},{width:1/12,chars:[{lowerCase:"м",upperCase:"М"},{lowerCase:"v",upperCase:"V"}]},{width:1/12,chars:[{lowerCase:"и",upperCase:"И"},{lowerCase:"b",upperCase:"B"}]},{width:1/12,chars:[{lowerCase:"т",upperCase:"Т"},{lowerCase:"n",upperCase:"N"}]},{width:1/12,chars:[{lowerCase:"ь",upperCase:"Ь"},{lowerCase:"m",upperCase:"M"}]},{width:1/12,chars:[{lowerCase:"б",upperCase:"Б"},{lowerCase:",",upperCase:""}]},{width:1/12,chars:[{lowerCase:"ю",upperCase:"Ю"},{lowerCase:".",upperCase:""}]},{width:.125,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.15,command:"switch-set",chars:[{lowerCase:"eng"}]},{width:.15,command:"switch",chars:[{lowerCase:".?12"}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"?"}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]],[[{width:.1,chars:[{lowerCase:"1"}]},{width:.1,chars:[{lowerCase:"2"}]},{width:.1,chars:[{lowerCase:"3"}]},{width:.1,chars:[{lowerCase:"4"}]},{width:.1,chars:[{lowerCase:"5"}]},{width:.1,chars:[{lowerCase:"6"}]},{width:.1,chars:[{lowerCase:"7"}]},{width:.1,chars:[{lowerCase:"8"}]},{width:.1,chars:[{lowerCase:"9"}]},{width:.1,chars:[{lowerCase:"0"}]}],[{width:.1,chars:[{lowerCase:"@"}]},{width:.1,chars:[{lowerCase:"#"}]},{width:.1,chars:[{lowerCase:"|"}]},{width:.1,chars:[{lowerCase:"_"}]},{width:.1,chars:[{lowerCase:"&"}]},{width:.1,chars:[{lowerCase:"-"}]},{width:.1,chars:[{lowerCase:"+"}]},{width:.1,chars:[{lowerCase:"("}]},{width:.1,chars:[{lowerCase:")"}]},{width:.1,chars:[{lowerCase:"/"}]}],[{width:.1,chars:[{lowerCase:"="}]},{width:.1,chars:[{lowerCase:"*"}]},{width:.1,chars:[{lowerCase:'"'}]},{width:.1,chars:[{lowerCase:"'"}]},{width:.1,chars:[{lowerCase:":"}]},{width:.1,chars:[{lowerCase:";"}]},{width:.1,chars:[{lowerCase:"!"}]},{width:.1,chars:[{lowerCase:"?"}]},{width:.2,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.3,command:"switch",chars:[{lowerCase:"АБВ"}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]]],Lw=[[[{width:1/11,chars:[{lowerCase:"q",upperCase:"Q"}]},{width:1/11,chars:[{lowerCase:"w",upperCase:"W"}]},{width:1/11,chars:[{lowerCase:"e",upperCase:"E"}]},{width:1/11,chars:[{lowerCase:"r",upperCase:"R"}]},{width:1/11,chars:[{lowerCase:"t",upperCase:"T"}]},{width:1/11,chars:[{lowerCase:"z",upperCase:"Z"}]},{width:1/11,chars:[{lowerCase:"u",upperCase:"U"}]},{width:1/11,chars:[{lowerCase:"i",upperCase:"I"}]},{width:1/11,chars:[{lowerCase:"o",upperCase:"O"}]},{width:1/11,chars:[{lowerCase:"p",upperCase:"P"}]},{width:1/11,chars:[{lowerCase:"ü",upperCase:"Ü"}]}],[{width:1/11,chars:[{lowerCase:"a",upperCase:"A"}]},{width:1/11,chars:[{lowerCase:"s",upperCase:"S"}]},{width:1/11,chars:[{lowerCase:"d",upperCase:"D"}]},{width:1/11,chars:[{lowerCase:"f",upperCase:"F"}]},{width:1/11,chars:[{lowerCase:"g",upperCase:"G"}]},{width:1/11,chars:[{lowerCase:"h",upperCase:"H"}]},{width:1/11,chars:[{lowerCase:"j",upperCase:"J"}]},{width:1/11,chars:[{lowerCase:"k",upperCase:"K"}]},{width:1/11,chars:[{lowerCase:"l",upperCase:"L"}]},{width:1/11,chars:[{lowerCase:"ö",upperCase:"Ö"}]},{width:1/11,chars:[{lowerCase:"ä",upperCase:"Ä"}]}],[{width:2/11,command:"shift",chars:[{icon:"shift"}]},{width:1/11,chars:[{lowerCase:"y",upperCase:"Y"}]},{width:1/11,chars:[{lowerCase:"x",upperCase:"X"}]},{width:1/11,chars:[{lowerCase:"c",upperCase:"C"}]},{width:1/11,chars:[{lowerCase:"v",upperCase:"V"}]},{width:1/11,chars:[{lowerCase:"b",upperCase:"B"}]},{width:1/11,chars:[{lowerCase:"n",upperCase:"N"}]},{width:1/11,chars:[{lowerCase:"m",upperCase:"M"}]},{width:2/11,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]],[[{width:.1,chars:[{lowerCase:"1"}]},{width:.1,chars:[{lowerCase:"2"}]},{width:.1,chars:[{lowerCase:"3"}]},{width:.1,chars:[{lowerCase:"4"}]},{width:.1,chars:[{lowerCase:"5"}]},{width:.1,chars:[{lowerCase:"6"}]},{width:.1,chars:[{lowerCase:"7"}]},{width:.1,chars:[{lowerCase:"8"}]},{width:.1,chars:[{lowerCase:"9"}]},{width:.1,chars:[{lowerCase:"0"}]}],[{width:.1,chars:[{lowerCase:"@"}]},{width:.1,chars:[{lowerCase:"#"}]},{width:.1,chars:[{lowerCase:"|"}]},{width:.1,chars:[{lowerCase:"_"}]},{width:.1,chars:[{lowerCase:"&"}]},{width:.1,chars:[{lowerCase:"-"}]},{width:.1,chars:[{lowerCase:"+"}]},{width:.1,chars:[{lowerCase:"("}]},{width:.1,chars:[{lowerCase:")"}]},{width:.1,chars:[{lowerCase:"/"}]}],[{width:.1,chars:[{lowerCase:"="}]},{width:.1,chars:[{lowerCase:"*"}]},{width:.1,chars:[{lowerCase:'"'}]},{width:.1,chars:[{lowerCase:"'"}]},{width:.1,chars:[{lowerCase:":"}]},{width:.1,chars:[{lowerCase:";"}]},{width:.1,chars:[{lowerCase:"!"}]},{width:.1,chars:[{lowerCase:"?"}]},{width:.2,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]]],Uw=[[[{width:.1,chars:[{lowerCase:"q",upperCase:"Q"}]},{width:.1,chars:[{lowerCase:"w",upperCase:"W"}]},{width:.1,chars:[{lowerCase:"e",upperCase:"E"}]},{width:.1,chars:[{lowerCase:"r",upperCase:"R"}]},{width:.1,chars:[{lowerCase:"t",upperCase:"T"}]},{width:.1,chars:[{lowerCase:"y",upperCase:"Y"}]},{width:.1,chars:[{lowerCase:"u",upperCase:"U"}]},{width:.1,chars:[{lowerCase:"i",upperCase:"I"}]},{width:.1,chars:[{lowerCase:"o",upperCase:"O"}]},{width:.1,chars:[{lowerCase:"p",upperCase:"P"}]}],[{width:.1,chars:[{lowerCase:"a",upperCase:"A"}]},{width:.1,chars:[{lowerCase:"s",upperCase:"S"}]},{width:.1,chars:[{lowerCase:"d",upperCase:"D"}]},{width:.1,chars:[{lowerCase:"f",upperCase:"F"}]},{width:.1,chars:[{lowerCase:"g",upperCase:"G"}]},{width:.1,chars:[{lowerCase:"h",upperCase:"H"}]},{width:.1,chars:[{lowerCase:"j",upperCase:"J"}]},{width:.1,chars:[{lowerCase:"k",upperCase:"K"}]},{width:.1,chars:[{lowerCase:"l",upperCase:"L"}]},{width:.1,chars:[{lowerCase:"ñ",upperCase:"Ñ"}]}],[{width:.15,command:"shift",chars:[{icon:"shift"}]},{width:.1,chars:[{lowerCase:"z",upperCase:"Z"}]},{width:.1,chars:[{lowerCase:"x",upperCase:"X"}]},{width:.1,chars:[{lowerCase:"c",upperCase:"C"}]},{width:.1,chars:[{lowerCase:"v",upperCase:"V"}]},{width:.1,chars:[{lowerCase:"b",upperCase:"B"}]},{width:.1,chars:[{lowerCase:"n",upperCase:"N"}]},{width:.1,chars:[{lowerCase:"m",upperCase:"M"}]},{width:.15,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]],[[{width:.1,chars:[{lowerCase:"1"}]},{width:.1,chars:[{lowerCase:"2"}]},{width:.1,chars:[{lowerCase:"3"}]},{width:.1,chars:[{lowerCase:"4"}]},{width:.1,chars:[{lowerCase:"5"}]},{width:.1,chars:[{lowerCase:"6"}]},{width:.1,chars:[{lowerCase:"7"}]},{width:.1,chars:[{lowerCase:"8"}]},{width:.1,chars:[{lowerCase:"9"}]},{width:.1,chars:[{lowerCase:"0"}]}],[{width:.1,chars:[{lowerCase:"@"}]},{width:.1,chars:[{lowerCase:"#"}]},{width:.1,chars:[{lowerCase:"|"}]},{width:.1,chars:[{lowerCase:"_"}]},{width:.1,chars:[{lowerCase:"&"}]},{width:.1,chars:[{lowerCase:"-"}]},{width:.1,chars:[{lowerCase:"+"}]},{width:.1,chars:[{lowerCase:"("}]},{width:.1,chars:[{lowerCase:")"}]},{width:.1,chars:[{lowerCase:"/"}]}],[{width:.1,chars:[{lowerCase:"="}]},{width:.1,chars:[{lowerCase:"*"}]},{width:.1,chars:[{lowerCase:'"'}]},{width:.1,chars:[{lowerCase:"'"}]},{width:.1,chars:[{lowerCase:":"}]},{width:.1,chars:[{lowerCase:";"}]},{width:.1,chars:[{lowerCase:"!"}]},{width:.1,chars:[{lowerCase:"?"}]},{width:.2,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]]],Nw=[[[{width:.1,chars:[{lowerCase:";",upperCase:":"},{lowerCase:"q",upperCase:"Q"}]},{width:.1,chars:[{lowerCase:"ς",upperCase:"ς"},{lowerCase:"w",upperCase:"W"}]},{width:.1,chars:[{lowerCase:"ε",upperCase:"Ε"},{lowerCase:"e",upperCase:"E"}]},{width:.1,chars:[{lowerCase:"ρ",upperCase:"Ρ"},{lowerCase:"r",upperCase:"R"}]},{width:.1,chars:[{lowerCase:"τ",upperCase:"Τ"},{lowerCase:"t",upperCase:"T"}]},{width:.1,chars:[{lowerCase:"υ",upperCase:"Υ"},{lowerCase:"y",upperCase:"Y"}]},{width:.1,chars:[{lowerCase:"θ",upperCase:"Θ"},{lowerCase:"u",upperCase:"U"}]},{width:.1,chars:[{lowerCase:"ι",upperCase:"Ι"},{lowerCase:"i",upperCase:"I"}]},{width:.1,chars:[{lowerCase:"ο",upperCase:"Ο"},{lowerCase:"o",upperCase:"O"}]},{width:.1,chars:[{lowerCase:"π",upperCase:"Π"},{lowerCase:"p",upperCase:"P"}]}],[{width:.1,chars:[{lowerCase:"α",upperCase:"Α"},{lowerCase:"a",upperCase:"A"}]},{width:.1,chars:[{lowerCase:"σ",upperCase:"Σ"},{lowerCase:"s",upperCase:"S"}]},{width:.1,chars:[{lowerCase:"δ",upperCase:"Δ"},{lowerCase:"d",upperCase:"D"}]},{width:.1,chars:[{lowerCase:"φ",upperCase:"Φ"},{lowerCase:"f",upperCase:"F"}]},{width:.1,chars:[{lowerCase:"γ",upperCase:"Γ"},{lowerCase:"g",upperCase:"G"}]},{width:.1,chars:[{lowerCase:"η",upperCase:"Η"},{lowerCase:"h",upperCase:"H"}]},{width:.1,chars:[{lowerCase:"ξ",upperCase:"Ξ"},{lowerCase:"j",upperCase:"J"}]},{width:.1,chars:[{lowerCase:"κ",upperCase:"Κ"},{lowerCase:"k",upperCase:"K"}]},{width:.1,chars:[{lowerCase:"λ",upperCase:"Λ"},{lowerCase:"l",upperCase:"L"}]}],[{width:.15,command:"shift",chars:[{icon:"shift"}]},{width:.1,chars:[{lowerCase:"ζ",upperCase:"Ζ"},{lowerCase:"z",upperCase:"Z"}]},{width:.1,chars:[{lowerCase:"χ",upperCase:"Χ"},{lowerCase:"x",upperCase:"X"}]},{width:.1,chars:[{lowerCase:"ψ",upperCase:"Ψ"},{lowerCase:"c",upperCase:"C"}]},{width:.1,chars:[{lowerCase:"ω",upperCase:"Ω"},{lowerCase:"v",upperCase:"V"}]},{width:.1,chars:[{lowerCase:"β",upperCase:"Β"},{lowerCase:"b",upperCase:"B"}]},{width:.1,chars:[{lowerCase:"ν",upperCase:"Ν"},{lowerCase:"n",upperCase:"N"}]},{width:.1,chars:[{lowerCase:"μ",upperCase:"Μ"},{lowerCase:"m",upperCase:"M"}]},{width:.15,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.15,command:"switch-set",chars:[{lowerCase:"eng"}]},{width:.15,command:"switch",chars:[{lowerCase:".?12"}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"?"}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]],[[{width:.1,chars:[{lowerCase:"1"}]},{width:.1,chars:[{lowerCase:"2"}]},{width:.1,chars:[{lowerCase:"3"}]},{width:.1,chars:[{lowerCase:"4"}]},{width:.1,chars:[{lowerCase:"5"}]},{width:.1,chars:[{lowerCase:"6"}]},{width:.1,chars:[{lowerCase:"7"}]},{width:.1,chars:[{lowerCase:"8"}]},{width:.1,chars:[{lowerCase:"9"}]},{width:.1,chars:[{lowerCase:"0"}]}],[{width:.1,chars:[{lowerCase:"@"}]},{width:.1,chars:[{lowerCase:"#"}]},{width:.1,chars:[{lowerCase:"|"}]},{width:.1,chars:[{lowerCase:"_"}]},{width:.1,chars:[{lowerCase:"&"}]},{width:.1,chars:[{lowerCase:"-"}]},{width:.1,chars:[{lowerCase:"+"}]},{width:.1,chars:[{lowerCase:"("}]},{width:.1,chars:[{lowerCase:")"}]},{width:.1,chars:[{lowerCase:"/"}]}],[{width:.1,chars:[{lowerCase:"="}]},{width:.1,chars:[{lowerCase:"*"}]},{width:.1,chars:[{lowerCase:'"'}]},{width:.1,chars:[{lowerCase:"'"}]},{width:.1,chars:[{lowerCase:":"}]},{width:.1,chars:[{lowerCase:";"}]},{width:.1,chars:[{lowerCase:"!"}]},{width:.1,chars:[{lowerCase:"?"}]},{width:.2,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]]],Fw=[[[{width:1/11,chars:[{lowerCase:"q",upperCase:"Q"}]},{width:1/11,chars:[{lowerCase:"w",upperCase:"W"}]},{width:1/11,chars:[{lowerCase:"e",upperCase:"E"}]},{width:1/11,chars:[{lowerCase:"r",upperCase:"R"}]},{width:1/11,chars:[{lowerCase:"t",upperCase:"T"}]},{width:1/11,chars:[{lowerCase:"y",upperCase:"Y"}]},{width:1/11,chars:[{lowerCase:"u",upperCase:"U"}]},{width:1/11,chars:[{lowerCase:"i",upperCase:"I"}]},{width:1/11,chars:[{lowerCase:"o",upperCase:"O"}]},{width:1/11,chars:[{lowerCase:"p",upperCase:"P"}]},{width:1/11,chars:[{lowerCase:"å",upperCase:"Å"}]}],[{width:1/11,chars:[{lowerCase:"a",upperCase:"A"}]},{width:1/11,chars:[{lowerCase:"s",upperCase:"S"}]},{width:1/11,chars:[{lowerCase:"d",upperCase:"D"}]},{width:1/11,chars:[{lowerCase:"f",upperCase:"F"}]},{width:1/11,chars:[{lowerCase:"g",upperCase:"G"}]},{width:1/11,chars:[{lowerCase:"h",upperCase:"H"}]},{width:1/11,chars:[{lowerCase:"j",upperCase:"J"}]},{width:1/11,chars:[{lowerCase:"k",upperCase:"K"}]},{width:1/11,chars:[{lowerCase:"l",upperCase:"L"}]},{width:1/11,chars:[{lowerCase:"æ",upperCase:"Æ"}]},{width:1/11,chars:[{lowerCase:"ø",upperCase:"Ø"}]}],[{width:2/11,command:"shift",chars:[{icon:"shift"}]},{width:1/11,chars:[{lowerCase:"z",upperCase:"Z"}]},{width:1/11,chars:[{lowerCase:"x",upperCase:"X"}]},{width:1/11,chars:[{lowerCase:"c",upperCase:"C"}]},{width:1/11,chars:[{lowerCase:"v",upperCase:"V"}]},{width:1/11,chars:[{lowerCase:"b",upperCase:"B"}]},{width:1/11,chars:[{lowerCase:"n",upperCase:"N"}]},{width:1/11,chars:[{lowerCase:"m",upperCase:"M"}]},{width:2/11,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]],[[{width:.1,chars:[{lowerCase:"1"}]},{width:.1,chars:[{lowerCase:"2"}]},{width:.1,chars:[{lowerCase:"3"}]},{width:.1,chars:[{lowerCase:"4"}]},{width:.1,chars:[{lowerCase:"5"}]},{width:.1,chars:[{lowerCase:"6"}]},{width:.1,chars:[{lowerCase:"7"}]},{width:.1,chars:[{lowerCase:"8"}]},{width:.1,chars:[{lowerCase:"9"}]},{width:.1,chars:[{lowerCase:"0"}]}],[{width:.1,chars:[{lowerCase:"@"}]},{width:.1,chars:[{lowerCase:"#"}]},{width:.1,chars:[{lowerCase:"|"}]},{width:.1,chars:[{lowerCase:"_"}]},{width:.1,chars:[{lowerCase:"&"}]},{width:.1,chars:[{lowerCase:"-"}]},{width:.1,chars:[{lowerCase:"+"}]},{width:.1,chars:[{lowerCase:"("}]},{width:.1,chars:[{lowerCase:")"}]},{width:.1,chars:[{lowerCase:"/"}]}],[{width:.1,chars:[{lowerCase:"="}]},{width:.1,chars:[{lowerCase:"*"}]},{width:.1,chars:[{lowerCase:'"'}]},{width:.1,chars:[{lowerCase:"'"}]},{width:.1,chars:[{lowerCase:":"}]},{width:.1,chars:[{lowerCase:";"}]},{width:.1,chars:[{lowerCase:"!"}]},{width:.1,chars:[{lowerCase:"?"}]},{width:.2,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]]],Ow=new lp;class kw extends(ww.withBase(Wr)(Dx,fw)){constructor(t){let e;if(t||(t={}),t.width||(t.width=1),t.height||(t.height=.4),t.margin||(t.margin=.003),t.padding||(t.padding=.01),super(t),this.currentPanel=0,this.isLowerCase=!0,this.charsetCount=1,t.language||navigator.language)switch(t.language||navigator.language){case"fr":case"fr-CH":case"fr-CA":e=Rw;break;case"ru":this.charsetCount=2,e=Pw;break;case"de":case"de-DE":case"de-AT":case"de-LI":case"de-CH":e=Lw;break;case"es":case"es-419":case"es-AR":case"es-CL":case"es-CO":case"es-ES":case"es-CR":case"es-US":case"es-HN":case"es-MX":case"es-PE":case"es-UY":case"es-VE":e=Uw;break;case"el":this.charsetCount=2,e=Nw;break;case"nord":e=Fw;break;default:e=Dw}else e=Dw;this.keys=[],this.panels=e.map((e=>{const n=t.height/e.length-2*t.margin,i=new Cw({width:t.width+2*t.padding,height:t.height+2*t.padding,offset:0,padding:t.padding,fontFamily:t.fontFamily,fontTexture:t.fontTexture,backgroundColor:t.backgroundColor,backgroundOpacity:t.backgroundOpacity});return i.charset=0,i.add(...e.map((e=>{const r=new Cw({width:t.width,height:n,margin:t.margin,contentDirection:"row",justifyContent:"center"});r.frame.visible=!1;const s=[];return e.forEach((e=>{const r=new Cw({width:t.width*e.width-2*t.margin,height:n,margin:t.margin,justifyContent:"center",offset:0}),a=e.chars[i.charset].lowerCase||e.chars[i.charset].icon||"undif";if("enter"===a&&t.enterTexture||"shift"===a&&t.shiftTexture||"backspace"===a&&t.backspaceTexture){const e=(()=>{switch(a){case"backspace":return t.backspaceTexture;case"enter":return t.enterTexture;case"shift":return t.shiftTexture;default:console.warn("There is no icon image for this key")}})();Ow.load(e,(t=>{r.add(new Bw({width:.65*r.width,height:.65*r.height,backgroundSize:"contain",backgroundTexture:t}))}))}else r.add(new Tw({content:a,offset:0}));r.type="Key",r.info=e,r.info.input=a,r.panel=i,s.push(r),this.keys.push(r)})),r.add(...s),r}))),i})),this.add(this.panels[0]),this.set(t)}setNextPanel(){this.panels.forEach((t=>{this.remove(t)})),this.currentPanel=(this.currentPanel+1)%this.panels.length,this.add(this.panels[this.currentPanel]),this.update(!0,!0,!0)}setNextCharset(){this.panels[this.currentPanel].charset=(this.panels[this.currentPanel].charset+1)%this.charsetCount,this.keys.forEach((t=>{if(!this.panels[this.currentPanel].getObjectById(t.id))return;const e=t.info.chars[t.panel.charset]||t.info.chars[0],n=this.isLowerCase||!e.upperCase?e.lowerCase:e.upperCase;if(!t.childrenTexts.length)return;const i=t.childrenTexts[0];t.info.input=n,i.set({content:n}),i.update(!0,!0,!0)}))}toggleCase(){this.isLowerCase=!this.isLowerCase,this.keys.forEach((t=>{const e=t.info.chars[t.panel.charset]||t.info.chars[0],n=this.isLowerCase||!e.upperCase?e.lowerCase:e.upperCase;if(!t.childrenTexts.length)return;const i=t.childrenTexts[0];t.info.input=n,i.set({content:n}),i.update(!0,!0,!0)}))}parseParams(){}updateLayout(){}updateInner(){}}const Qw={Block:Cw,Text:Tw,InlineBlock:Bw,Keyboard:kw,FontLibrary:hw,update:()=>uw.update(),TextAlign:l,Whitespace:o,JustifyContent:a,AlignItems:s,ContentDirection:r};void 0!==t.g&&(t.g.ThreeMeshUI=Qw);const zw=Qw;function Gw(t,e,n){return null===t?null:(t.point.applyMatrix4(e.matrixWorld),t.distance=t.point.distanceTo(n.ray.origin),t.object=e,t)}const Hw=0,Vw=1,Ww=2,jw=0,qw=1,Xw=2,Yw=1.25,Jw=1,Kw=32,Zw=65535,$w=Math.pow(2,-24),tC=Symbol("SKIP_GENERATION");function eC(t){return t.index?t.index.count:t.attributes.position.count}function nC(t){return eC(t)/3}function iC(t,e=ArrayBuffer){return t>65535?new Uint32Array(new e(4*t)):new Uint16Array(new e(2*t))}function rC(t,e){const n=nC(t),i=e||t.drawRange,r=i.start/3,s=(i.start+i.count)/3,a=Math.max(0,r),o=Math.min(n,s)-a;return[{offset:Math.floor(a),count:Math.floor(o)}]}function sC(t,e){if(!t.groups||!t.groups.length)return rC(t,e);const n=[],i=new Set,r=e||t.drawRange,s=r.start/3,a=(r.start+r.count)/3;for(const e of t.groups){const t=e.start/3,n=(e.start+e.count)/3;i.add(Math.max(s,t)),i.add(Math.min(a,n))}const o=Array.from(i.values()).sort(((t,e)=>t-e));for(let t=0;tl&&(l=A),ef&&(f=e);const v=t[i+2],y=t[i+3],_=v-y,x=v+y;_c&&(c=x),vm&&(m=v);const w=t[i+4],C=t[i+5],E=w-C,M=w+C;Eh&&(h=M),wg&&(g=w)}i[0]=s,i[1]=a,i[2]=o,i[3]=l,i[4]=c,i[5]=h,r[0]=u,r[1]=d,r[2]=p,r[3]=f,r[4]=m,r[5]=g}function oC(t,e,n){return n.min.x=e[t],n.min.y=e[t+1],n.min.z=e[t+2],n.max.x=e[t+3],n.max.y=e[t+4],n.max.z=e[t+5],n}function lC(t){let e=-1,n=-1/0;for(let i=0;i<3;i++){const r=t[i+3]-t[i];r>n&&(n=r,e=i)}return e}function cC(t,e){e.set(t)}function hC(t,e,n){let i,r;for(let s=0;s<3;s++){const a=s+3;i=t[s],r=e[s],n[s]=ir?i:r}}function uC(t,e,n){for(let i=0;i<3;i++){const r=e[t+2*i],s=e[t+2*i+1],a=r-s,o=r+s;an[i+3]&&(n[i+3]=o)}}function dC(t){const e=t[3]-t[0],n=t[4]-t[1],i=t[5]-t[2];return 2*(e*n+n*i+i*e)}const pC=(t,e)=>t.candidate-e.candidate,fC=new Array(32).fill().map((()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0}))),mC=new Float32Array(6);class gC{constructor(){this.boundingData=new Float32Array(6)}}function AC(t,e,n,i,r,s){let a=i,o=i+r-1;const l=s.pos,c=2*s.axis;for(;;){for(;a<=o&&n[6*a+c]=l;)o--;if(!(a=l;)o--;if(!(aTC)throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return bC[n+6]=a/4,a=DC(a,r),bC[n+7]=s,a}}function PC(t,e){const n=t.geometry;e.indirect&&(t._indirectBuffer=function(t,e){const n=(t.index?t.index.count:t.attributes.position.count)/3,i=n>65536,r=i?4:2,s=e?new SharedArrayBuffer(n*r):new ArrayBuffer(n*r),a=i?new Uint32Array(s):new Uint16Array(s);for(let t=0,e=a.length;tt.offset-e.offset)),r=i[i.length-1];r.count=Math.min(n-r.offset,r.count);let s=0;return i.forEach((({count:t})=>s+=t)),n!==s}(n,e.range)&&!e.verbose&&console.warn('MeshBVH: Provided geometry contains groups or a range that do not fully span the vertex contents while using the "indirect" option. BVH may incorrectly report intersections on unrendered portions of the geometry.')),t._indirectBuffer||function(t,e){if(!t.index){const n=t.attributes.position.count,i=iC(n,e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer);t.setIndex(new ws(i,1));for(let t=0;tf&&(f=s),h>f&&(f=h);const m=(f-u)/2,g=2*t;l[n+g+0]=u+m,l[n+g+1]=m+(Math.abs(u)+m)*$w}}return l}(n),s=e.indirect?rC(n,e.range):sC(n,e.range);t._roots=s.map((n=>{const s=function(t,e,n,i,r){const{maxDepth:s,verbose:a,maxLeafTris:o,strategy:l,onProgress:c,indirect:h}=r,u=t._indirectBuffer,d=t.geometry,p=d.index?d.index.array:null,f=h?vC:AC,m=nC(d),g=new Float32Array(6);let A=!1;const v=new gC;return aC(e,n,i,v.boundingData,g),function t(n,i,r,c=null,h=0){if(!A&&h>=s&&(A=!0,a&&(console.warn(`MeshBVH: Max depth of ${s} reached when generating BVH. Consider increasing maxDepth.`),console.warn(d))),r<=o||h>=s)return y(i+r),n.offset=i,n.count=r,n;const m=function(t,e,n,i,r,s){let a=-1,o=0;if(s===Hw)a=lC(e),-1!==a&&(o=(e[a]+e[a+3])/2);else if(s===Vw)a=lC(t),-1!==a&&(o=function(t,e,n,i){let r=0;for(let s=e,a=e+n;s=s.candidate?uC(i,n,s.rightCacheBounds):(uC(i,n,s.leftCacheBounds),s.count++)}}for(let n=0;n=32&&(r=31);const s=fC[r];s.count++,uC(e,n,s.bounds)}const e=fC[31];cC(e.bounds,e.rightCacheBounds);for(let t=30;t>=0;t--){const e=fC[t],n=fC[t+1];hC(e.bounds,n.rightCacheBounds,e.rightCacheBounds)}let d=0;for(let e=0;e<31;e++){const n=fC[e],i=n.count,c=n.bounds,h=fC[e+1].rightCacheBounds;0!==i&&(0===d?cC(c,mC):hC(c,mC,mC)),d+=i;let u=0,p=0;0!==d&&(u=dC(mC)/s);const f=r-d;0!==f&&(p=dC(h)/s);const m=Jw+Yw*(u*d+p*f);mi?s:i}this.min=n,this.max=i}setFromPoints(t,e){let n=1/0,i=-1/0;for(let r=0,s=e.length;ri?a:i}this.min=n,this.max=i}isSeparated(t){return this.min>t.max||t.min>this.max}}LC.prototype.setFromBox=function(){const t=new Gi;return function(e,n){const i=n.min,r=n.max;let s=1/0,a=-1/0;for(let n=0;n<=1;n++)for(let o=0;o<=1;o++)for(let l=0;l<=1;l++){t.x=i.x*n+r.x*(1-n),t.y=i.y*o+r.y*(1-o),t.z=i.z*l+r.z*(1-l);const c=e.dot(t);s=Math.min(c,s),a=Math.max(c,a)}this.min=s,this.max=a}}(),new LC;const UC=function(){const t=new Gi,e=new Gi,n=new Gi;return function(i,r,s){const a=i.start,o=t,l=r.start,c=e;n.subVectors(a,l),t.subVectors(i.end,i.start),e.subVectors(r.end,r.start);const h=n.dot(c),u=c.dot(o),d=c.dot(c),p=n.dot(o),f=o.dot(o)*d-u*u;let m,g;m=0!==f?(h*u-p*d)/f:0,g=(h+m*u)/d,s.x=m,s.y=g}}(),NC=function(){const t=new ci,e=new Gi,n=new Gi;return function(i,r,s,a){UC(i,r,t);let o=t.x,l=t.y;if(o>=0&&o<=1&&l>=0&&l<=1)return i.at(o,s),void r.at(l,a);if(o>=0&&o<=1)return l<0?r.at(0,a):r.at(1,a),void i.closestPointToPoint(a,!0,s);if(l>=0&&l<=1)return o<0?i.at(0,s):i.at(1,s),void r.closestPointToPoint(s,!0,a);{let t,c;t=o<0?i.start:i.end,c=l<0?r.start:r.end;const h=e,u=n;return i.closestPointToPoint(c,!0,e),r.closestPointToPoint(t,!0,n),h.distanceToSquared(c)<=u.distanceToSquared(t)?(s.copy(h),void a.copy(c)):(s.copy(t),void a.copy(u))}}}(),FC=function(){const t=new Gi,e=new Gi,n=new Aa,i=new Pf;return function(r,s){const{radius:a,center:o}=r,{a:l,b:c,c:h}=s;if(i.start=l,i.end=c,i.closestPointToPoint(o,!0,t).distanceTo(o)<=a)return!0;if(i.start=l,i.end=h,i.closestPointToPoint(o,!0,t).distanceTo(o)<=a)return!0;if(i.start=c,i.end=h,i.closestPointToPoint(o,!0,t).distanceTo(o)<=a)return!0;const u=s.getPlane(n);if(Math.abs(u.distanceToPoint(o))<=a){const t=u.projectPoint(o,e);if(s.containsPoint(t))return!0}return!1}}();function OC(t){return Math.abs(t)<1e-15}class kC extends ss{constructor(...t){super(...t),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map((()=>new Gi)),this.satBounds=new Array(4).fill().map((()=>new LC)),this.points=[this.a,this.b,this.c],this.sphere=new cr,this.plane=new Aa,this.needsUpdate=!0}intersectsSphere(t){return FC(t,this)}update(){const t=this.a,e=this.b,n=this.c,i=this.points,r=this.satAxes,s=this.satBounds,a=r[0],o=s[0];this.getNormal(a),o.setFromPoints(a,i);const l=r[1],c=s[1];l.subVectors(t,e),c.setFromPoints(l,i);const h=r[2],u=s[2];h.subVectors(e,n),u.setFromPoints(h,i);const d=r[3],p=s[3];d.subVectors(n,t),p.setFromPoints(d,i),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(a,t),this.needsUpdate=!1}}kC.prototype.closestPointToSegment=function(){const t=new Gi,e=new Gi,n=new Pf;return function(i,r=null,s=null){const{start:a,end:o}=i,l=this.points;let c,h=1/0;for(let a=0;a<3;a++){const o=(a+1)%3;n.start.copy(l[a]),n.end.copy(l[o]),NC(n,i,t,e),c=t.distanceToSquared(e),c=2){(1===s?n.start:n.end).copy(p),r=2;break}if(r++,2===r&&-1===s)break}}return r}return function(a,h=null,p=!1){this.needsUpdate&&this.update(),a.isExtendedTriangle?a.needsUpdate&&a.update():(t.copy(a),t.update(),a=t);const m=this.plane,g=a.plane;if(Math.abs(m.normal.dot(g.normal))>1-1e-10){const t=this.satBounds,o=this.satAxes;n[0]=a.a,n[1]=a.b,n[2]=a.c;for(let e=0;e<4;e++){const r=t[e],s=o[e];if(i.setFromPoints(s,n),r.isSeparated(i))return!1}const l=a.satBounds,c=a.satAxes;e[0]=this.a,e[1]=this.b,e[2]=this.c;for(let t=0;t<4;t++){const n=l[t],r=c[t];if(i.setFromPoints(r,e),n.isSeparated(i))return!1}for(let t=0;t<4;t++){const a=o[t];for(let t=0;t<4;t++){const o=c[t];if(s.crossVectors(a,o),i.setFromPoints(s,e),r.setFromPoints(s,n),i.isSeparated(r))return!1}}return h&&(p||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),h.start.set(0,0,0),h.end.set(0,0,0)),!0}{const t=f(this,g,u);if(1===t&&a.containsPoint(u.end))return h&&(h.start.copy(u.end),h.end.copy(u.end)),!0;if(2!==t)return!1;const e=f(a,m,d);if(1===e&&this.containsPoint(d.end))return h&&(h.start.copy(d.end),h.end.copy(d.end)),!0;if(2!==e)return!1;if(u.delta(o),d.delta(l),o.dot(l)<0){let t=d.start;d.start=d.end,d.end=t}const n=u.start.dot(o),i=u.end.dot(o),r=d.start.dot(o),s=d.end.dot(o);return(n===s||r===i||i0?h.start.copy(u.start):h.start.copy(d.start),c.subVectors(u.end,d.end),c.dot(o)<0?h.end.copy(u.end):h.end.copy(d.end)),!0)}}}(),kC.prototype.distanceToPoint=function(){const t=new Gi;return function(e){return this.closestPointToPoint(e,t),e.distanceTo(t)}}(),kC.prototype.distanceToTriangle=function(){const t=new Gi,e=new Gi,n=["a","b","c"],i=new Pf,r=new Pf;return function(s,a=null,o=null){const l=a||o?i:null;if(this.intersectsTriangle(s,l))return(a||o)&&(a&&l.getCenter(a),o&&l.getCenter(o)),0;let c=1/0;for(let e=0;e<3;e++){let i;const r=n[e],l=s[r];this.closestPointToPoint(l,t),i=l.distanceToSquared(t),inew Gi)),this.satAxes=new Array(3).fill().map((()=>new Gi)),this.satBounds=new Array(3).fill().map((()=>new LC)),this.alignedSatBounds=new Array(3).fill().map((()=>new LC)),this.needsUpdate=!1,t&&this.min.copy(t),e&&this.max.copy(e),n&&this.matrix.copy(n)}set(t,e,n){this.min.copy(t),this.max.copy(e),this.matrix.copy(n),this.needsUpdate=!0}copy(t){this.min.copy(t.min),this.max.copy(t.max),this.matrix.copy(t.matrix),this.needsUpdate=!0}}QC.prototype.update=function(){const t=this.matrix,e=this.min,n=this.max,i=this.points;for(let r=0;r<=1;r++)for(let s=0;s<=1;s++)for(let a=0;a<=1;a++){const o=i[1*r|2*s|4*a];o.x=r?n.x:e.x,o.y=s?n.y:e.y,o.z=a?n.z:e.z,o.applyMatrix4(t)}const r=this.satBounds,s=this.satAxes,a=i[0];for(let t=0;t<3;t++){const e=s[t],n=r[t],o=i[1<new Pf)),n=new Array(12).fill().map((()=>new Pf)),i=new Gi,r=new Gi;return function(s,a=0,o=null,l=null){if(this.needsUpdate&&this.update(),this.intersectsBox(s))return(o||l)&&(s.getCenter(r),this.closestPointToPoint(r,i),s.closestPointToPoint(i,r),o&&o.copy(i),l&&l.copy(r)),0;const c=a*a,h=s.min,u=s.max,d=this.points;let p=1/0;for(let t=0;t<8;t++){const e=d[t];r.copy(e).clamp(h,u);const n=e.distanceToSquared(r);if(nnew kC))}}const HC=new GC,VC=new class{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const t=[];let e=null;this.setBuffer=n=>{e&&t.push(e),e=n,this.float32Array=new Float32Array(n),this.uint16Array=new Uint16Array(n),this.uint32Array=new Uint32Array(n)},this.clearBuffer=()=>{e=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,0!==t.length&&this.setBuffer(t.pop())}}};let WC,jC;const qC=[],XC=new zC((()=>new Wi));function YC(t,e,n,i,r,s){WC=XC.getPrimitive(),jC=XC.getPrimitive(),qC.push(WC,jC),VC.setBuffer(t._roots[e]);const a=JC(0,t.geometry,n,i,r,s);VC.clearBuffer(),XC.releasePrimitive(WC),XC.releasePrimitive(jC),qC.pop(),qC.pop();const o=qC.length;return o>0&&(jC=qC[o-1],WC=qC[o-2]),a}function JC(t,e,n,i,r=null,s=0,a=0){const{float32Array:o,uint16Array:l,uint32Array:c}=VC;let h=2*t;if(yC(h,l)){const u=_C(t,c),d=xC(h,l);return oC(t,o,WC),i(u,d,!1,a,s+t,WC)}{const p=wC(t),f=CC(t,c);let m,g,A,v,y=p,_=f;if(r&&(A=WC,v=jC,oC(y,o,A),oC(_,o,v),m=r(A),g=r(v),g=169,tE=new Gi,eE=new Gi,nE=new Gi,iE=new ci,rE=new ci,sE=new ci,aE=new Gi,oE=new Gi,lE=new Gi,cE=new Gi;function hE(t,e,n,i,r,s,a){const o=3*i;let l=o+0,c=o+1,h=o+2;const u=t.index;t.index&&(l=u.getX(l),c=u.getX(c),h=u.getX(h));const{position:d,normal:p,uv:f,uv1:m}=t.attributes,g=function(t,e,n,i,r,s,a,o,l,c,h){tE.fromBufferAttribute(e,s),eE.fromBufferAttribute(e,a),nE.fromBufferAttribute(e,o);const u=function(t,e,n,i,r,s,a,o){let l;if(l=s===M?t.intersectTriangle(i,n,e,!0,r):t.intersectTriangle(e,n,i,s!==b,r),null===l)return null;const c=t.origin.distanceTo(r);return co?null:{distance:c,point:r.clone()}}(t,tE,eE,nE,cE,l,c,h);if(u){const e=new Gi;ss.getBarycoord(cE,tE,eE,nE,e),i&&(iE.fromBufferAttribute(i,s),rE.fromBufferAttribute(i,a),sE.fromBufferAttribute(i,o),u.uv=ss.getInterpolation(cE,tE,eE,nE,iE,rE,sE,new ci)),r&&(iE.fromBufferAttribute(r,s),rE.fromBufferAttribute(r,a),sE.fromBufferAttribute(r,o),u.uv1=ss.getInterpolation(cE,tE,eE,nE,iE,rE,sE,new ci)),n&&(aE.fromBufferAttribute(n,s),oE.fromBufferAttribute(n,a),lE.fromBufferAttribute(n,o),u.normal=ss.getInterpolation(cE,tE,eE,nE,aE,oE,lE,new Gi),u.normal.dot(t.direction)>0&&u.normal.multiplyScalar(-1));const l={a:s,b:a,c:o,normal:new Gi,materialIndex:0};ss.getNormal(tE,eE,nE,l.normal),u.face=l,u.faceIndex=s,$C&&(u.barycoord=e)}return u}(n,d,p,f,m,l,c,h,e,s,a);return g?(g.faceIndex=i,r&&r.push(g),g):null}function uE(t,e,n,i){const r=t.a,s=t.b,a=t.c;let o=e,l=e+1,c=e+2;n&&(o=n.getX(o),l=n.getX(l),c=n.getX(c)),r.x=i.getX(o),r.y=i.getY(o),r.z=i.getZ(o),s.x=i.getX(l),s.y=i.getY(l),s.z=i.getZ(l),a.x=i.getX(c),a.y=i.getY(c),a.z=i.getZ(c)}const dE=new Gi,pE=new Gi,fE=new Gi,mE=new ci,gE=new ci,AE=new ci;function vE(t,e,n,i){const r=e.getIndex().array,s=e.getAttribute("position"),a=e.getAttribute("uv"),o=r[3*n],l=r[3*n+1],c=r[3*n+2];dE.fromBufferAttribute(s,o),pE.fromBufferAttribute(s,l),fE.fromBufferAttribute(s,c);let h=0;const u=e.groups,d=3*n;for(let t=0,e=u.length;t=n&&du&&(u=a),od&&(d=o),lp&&(p=l)}return(l[t+0]!==n||l[t+1]!==s||l[t+2]!==h||l[t+3]!==u||l[t+4]!==d||l[t+5]!==p)&&(l[t+0]=n,l[t+1]=s,l[t+2]=h,l[t+3]=u,l[t+4]=d,l[t+5]=p,!0)}{const i=t+8,r=a[t+6],o=i+n,c=r+n;let h=s,d=!1,p=!1;e?h||(d=e.has(o),p=e.has(c),h=!d&&!p):(d=!0,p=!0);const f=h||p;let m=!1;(h||d)&&(m=u(i,n,h));let g=!1;f&&(g=u(r,n,h));const A=m||g;if(A)for(let e=0;e<3;e++){const n=i+e,s=r+e,a=l[n],o=l[n+3],c=l[s],h=l[s+3];l[t+e]=ah?o:h}return A}}}function xE(t,e,n,i,r){let s,a,o,l,c,h;const u=1/n.direction.x,d=1/n.direction.y,p=1/n.direction.z,f=n.origin.x,m=n.origin.y,g=n.origin.z;let A=e[t],v=e[t+3],y=e[t+1],_=e[t+3+1],x=e[t+2],w=e[t+3+2];return u>=0?(s=(A-f)*u,a=(v-f)*u):(s=(v-f)*u,a=(A-f)*u),d>=0?(o=(y-m)*d,l=(_-m)*d):(o=(_-m)*d,l=(y-m)*d),!(s>l||o>a)&&((o>s||isNaN(s))&&(s=o),(l=0?(c=(x-g)*p,h=(w-g)*p):(c=(w-g)*p,h=(x-g)*p),!(s>h||c>a)&&((c>s||s!=s)&&(s=c),(h=i))}function wE(t,e,n,i,r,s,a){VC.setBuffer(t._roots[e]),CE(0,t,n,i,r,s,a),VC.clearBuffer()}function CE(t,e,n,i,r,s,a){const{float32Array:o,uint16Array:l,uint32Array:c}=VC,h=2*t;if(yC(h,l))!function(t,e,n,i,r,s,a,o){const{geometry:l,_indirectBuffer:c}=t;for(let t=i,c=i+r;t=0;let u,d;h?(u=wC(t),d=CC(t,l)):(u=CC(t,l),d=wC(t));const p=xE(u,a,i,r,s)?bE(u,e,n,i,r,s):null;if(p){const t=p.point[c];if(h?t<=a[d+o]:t>=a[d+o+3])return p}const f=xE(d,a,i,r,s)?bE(d,e,n,i,r,s):null;return p&&f?p.distance<=f.distance?p:f:p||f||null}}const SE=new Wi,IE=new kC,TE=new kC,BE=new vr,RE=new QC,DE=new QC;function PE(t,e,n,i){VC.setBuffer(t._roots[e]);const r=LE(0,t,n,i);return VC.clearBuffer(),r}function LE(t,e,n,i,r=null){const{float32Array:s,uint16Array:a,uint32Array:o}=VC;let l=2*t;if(null===r&&(n.boundingBox||n.computeBoundingBox(),RE.set(n.boundingBox.min,n.boundingBox.max,i),r=RE),!yC(l,a)){const a=t+8,l=o[t+6];return oC(a,s,SE),r.intersectsBox(SE)&&LE(a,e,n,i,r)?!0:(oC(l,s,SE),!(!r.intersectsBox(SE)||!LE(l,e,n,i,r)))}{const r=e.geometry,c=r.index,h=r.attributes.position,u=n.index,d=n.attributes.position,p=_C(t,o),f=xC(l,a);if(BE.copy(i).invert(),n.boundsTree){oC(t,s,DE),DE.matrix.copy(BE),DE.needsUpdate=!0;const e=n.boundsTree.shapecast({intersectsBounds:t=>DE.intersectsBox(t),intersectsTriangle:t=>{t.a.applyMatrix4(i),t.b.applyMatrix4(i),t.c.applyMatrix4(i),t.needsUpdate=!0;for(let e=3*p,n=3*(f+p);eNE.distanceToBox(t),intersectsBounds:(t,e,n)=>n{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:t=>FE.distanceToBox(t),intersectsBounds:(t,e,n)=>n{for(let a=e,o=e+r;ad&&(d=a),op&&(p=o),lf&&(f=l)}}return(l[n+0]!==s||l[n+1]!==c||l[n+2]!==u||l[n+3]!==d||l[n+4]!==p||l[n+5]!==f)&&(l[n+0]=s,l[n+1]=c,l[n+2]=u,l[n+3]=d,l[n+4]=p,l[n+5]=f,!0)}{const t=n+8,i=a[n+6],r=t+s,o=i+s;let h=c,d=!1,p=!1;e?h||(d=e.has(r),p=e.has(o),h=!d&&!p):(d=!0,p=!0);const f=h||p;let m=!1;(h||d)&&(m=u(t,s,h));let g=!1;f&&(g=u(i,s,h));const A=m||g;if(A)for(let e=0;e<3;e++){const r=t+e,s=i+e,a=l[r],o=l[r+3],c=l[s],h=l[s+3];l[n+e]=ah?o:h}return A}}}function WE(t,e,n,i,r,s,a){VC.setBuffer(t._roots[e]),jE(0,t,n,i,r,s,a),VC.clearBuffer()}function jE(t,e,n,i,r,s,a){const{float32Array:o,uint16Array:l,uint32Array:c}=VC,h=2*t;if(yC(h,l))!function(t,e,n,i,r,s,a,o){const{geometry:l,_indirectBuffer:c}=t;for(let t=i,h=i+r;t=0;let u,d;h?(u=wC(t),d=CC(t,l)):(u=CC(t,l),d=wC(t));const p=xE(u,a,i,r,s)?YE(u,e,n,i,r,s):null;if(p){const t=p.point[c];if(h?t<=a[d+o]:t>=a[d+o+3])return p}const f=xE(d,a,i,r,s)?YE(d,e,n,i,r,s):null;return p&&f?p.distance<=f.distance?p:f:p||f||null}}const JE=new Wi,KE=new kC,ZE=new kC,$E=new vr,tM=new QC,eM=new QC;function nM(t,e,n,i){VC.setBuffer(t._roots[e]);const r=iM(0,t,n,i);return VC.clearBuffer(),r}function iM(t,e,n,i,r=null){const{float32Array:s,uint16Array:a,uint32Array:o}=VC;let l=2*t;if(null===r&&(n.boundingBox||n.computeBoundingBox(),tM.set(n.boundingBox.min,n.boundingBox.max,i),r=tM),!yC(l,a)){const a=t+8,l=o[t+6];return oC(a,s,JE),r.intersectsBox(JE)&&iM(a,e,n,i,r)?!0:(oC(l,s,JE),!(!r.intersectsBox(JE)||!iM(l,e,n,i,r)))}{const r=e.geometry,c=r.index,h=r.attributes.position,u=n.index,d=n.attributes.position,p=_C(t,o),f=xC(l,a);if($E.copy(i).invert(),n.boundsTree){oC(t,s,eM),eM.matrix.copy($E),eM.needsUpdate=!0;const r=n.boundsTree.shapecast({intersectsBounds:t=>eM.intersectsBox(t),intersectsTriangle:t=>{t.a.applyMatrix4(i),t.b.applyMatrix4(i),t.c.applyMatrix4(i),t.needsUpdate=!0;for(let n=p,i=f+p;nsM.distanceToBox(t),intersectsBounds:(t,e,n)=>n{if(e.boundsTree){const o=e.boundsTree;return o.shapecast({boundsTraverseOrder:t=>aM.distanceToBox(t),intersectsBounds:(t,e,n)=>n{for(let x=e,w=e+a;xnew Wi)),gM=new Wi,AM=new Wi,vM=new Wi,yM=new Wi;let _M=!1;function xM(t,e,n,i,r,s=0,a=0,o=0,l=0,c=null,h=!1){let u,d;h?(u=fM,d=pM):(u=pM,d=fM);const p=u.float32Array,f=u.uint32Array,m=u.uint16Array,g=d.float32Array,A=d.uint32Array,v=d.uint16Array,y=2*e,_=yC(2*t,m),x=yC(y,v);let w=!1;if(x&&_)w=h?r(_C(e,A),xC(2*e,v),_C(t,f),xC(2*t,m),l,a+e,o,s+t):r(_C(t,f),xC(2*t,m),_C(e,A),xC(2*e,v),o,s+t,l,a+e);else if(x){const c=mM.getPrimitive();oC(e,g,c),c.applyMatrix4(n);const u=wC(t),d=CC(t,f);oC(u,p,gM),oC(d,p,AM);const m=c.intersectsBox(gM),A=c.intersectsBox(AM);w=m&&xM(e,u,i,n,r,a,s,l,o+1,c,!h)||A&&xM(e,d,i,n,r,a,s,l,o+1,c,!h),mM.releasePrimitive(c)}else{const u=wC(e),d=CC(e,A);oC(u,g,vM),oC(d,g,yM);const m=c.intersectsBox(vM),v=c.intersectsBox(yM);if(m&&v)w=xM(t,u,n,i,r,s,a,o,l+1,c,h)||xM(t,d,n,i,r,s,a,o,l+1,c,h);else if(m)if(_)w=xM(t,u,n,i,r,s,a,o,l+1,c,h);else{const e=mM.getPrimitive();e.copy(vM).applyMatrix4(n);const c=wC(t),d=CC(t,f);oC(c,p,gM),oC(d,p,AM);const m=e.intersectsBox(gM),g=e.intersectsBox(AM);w=m&&xM(u,c,i,n,r,a,s,l,o+1,e,!h)||g&&xM(u,d,i,n,r,a,s,l,o+1,e,!h),mM.releasePrimitive(e)}else if(v)if(_)w=xM(t,d,n,i,r,s,a,o,l+1,c,h);else{const e=mM.getPrimitive();e.copy(yM).applyMatrix4(n);const c=wC(t),u=CC(t,f);oC(c,p,gM),oC(u,p,AM);const m=e.intersectsBox(gM),g=e.intersectsBox(AM);w=m&&xM(d,c,i,n,r,a,s,l,o+1,e,!h)||g&&xM(d,u,i,n,r,a,s,l,o+1,e,!h),mM.releasePrimitive(e)}}return w}const wM=new QC,CM=new Wi,EM={strategy:Hw,maxDepth:40,maxLeafTris:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0,range:null};class MM{static serialize(t,e={}){e={cloneBuffers:!0,...e};const n=t.geometry,i=t._roots,r=t._indirectBuffer,s=n.getIndex();let a;return a=e.cloneBuffers?{roots:i.map((t=>t.slice())),index:s?s.array.slice():null,indirectBuffer:r?r.slice():null}:{roots:i,index:s?s.array:null,indirectBuffer:r},a}static deserialize(t,e,n={}){n={setIndex:!0,indirect:Boolean(t.indirectBuffer),...n};const{index:i,roots:r,indirectBuffer:s}=t,a=new MM(e,{...n,[tC]:!0});if(a._roots=r,a._indirectBuffer=s||null,n.setIndex){const n=e.getIndex();if(null===n){const n=new ws(t.index,1,!1);e.setIndex(n)}else n.array!==i&&(n.array.set(i),n.needsUpdate=!0)}return a}get indirect(){return!!this._indirectBuffer}constructor(t,e={}){if(!t.isBufferGeometry)throw new Error("MeshBVH: Only BufferGeometries are supported.");if(t.index&&t.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.");if((e=Object.assign({...EM,[tC]:!1},e)).useSharedArrayBuffer&&!dM())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=t,this._roots=null,this._indirectBuffer=null,e[tC]||(PC(this,e),!t.boundingBox&&e.setBoundingBox&&(t.boundingBox=this.getBoundingBox(new Wi))),this.resolveTriangleIndex=e.indirect?t=>this._indirectBuffer[t]:t=>t}refit(t=null){return(this.indirect?VE:_E)(this,t)}traverse(t,e=0){const n=this._roots[e],i=new Uint32Array(n),r=new Uint16Array(n);!function e(s,a=0){const o=2*s,l=r[o+15]===Zw;if(l){const e=i[s+6],c=r[o+14];t(a,l,new Float32Array(n,4*s,6),e,c)}else{const r=s+8,o=i[s+6],c=i[s+7];t(a,l,new Float32Array(n,4*s,6),c)||(e(r,a+1),e(o,a+1))}}(0)}raycast(t,e=E,n=0,i=1/0){const r=this._roots,s=this.geometry,a=[],o=e.isMaterial,l=Array.isArray(e),c=s.groups,h=o?e.side:e,u=this.indirect?WE:wE;for(let s=0,o=r.length;s!!t(i,r,s,o,l)||n(i,r,this,a,s,o,e)}else s||(s=a?(t,i,r,s)=>n(t,i,this,a,r,s,e):(t,e,n)=>n);let o=!1,l=0;const c=this._roots;for(let t=0,e=c.length;t{const e=this.resolveTriangleIndex(t);uE(s,3*e,a,o)}:t=>{uE(s,3*t,a,o)},c=HC.getPrimitive(),h=t.geometry.index,u=t.geometry.attributes.position,d=t.indirect?e=>{const n=t.resolveTriangleIndex(e);uE(c,3*n,h,u)}:t=>{uE(c,3*t,h,u)};if(r){const t=(t,n,i,a,o,h,u,p)=>{for(let f=i,m=i+a;fwM.intersectsBox(t),intersectsTriangle:t=>wM.intersectsTriangle(t)})}intersectsSphere(t){return this.shapecast({intersectsBounds:e=>t.intersectsBox(e),intersectsTriangle:e=>e.intersectsSphere(t)})}closestPointToGeometry(t,e,n={},i={},r=0,s=1/0){return(this.indirect?uM:GE)(this,t,e,n,i,r,s)}closestPointToPoint(t,e={},n=0,i=1/0){return function(t,e,n={},i=0,r=1/0){const s=i*i,a=r*r;let o=1/0,l=null;if(t.shapecast({boundsTraverseOrder:t=>(KC.copy(e).clamp(t.min,t.max),KC.distanceToSquared(e)),intersectsBounds:(t,e,n)=>n{t.closestPointToPoint(e,KC);const i=e.distanceToSquared(KC);return i{oC(0,new Float32Array(e),CM),t.union(CM)})),t}}const bM=parseInt(p)>=166,SM=new Ar,IM=new Gi,TM=new vr,BM=Ks.prototype.raycast,RM=Eh.prototype.raycast,DM=new Gi,PM=new Ks,LM=[];function UM(t,e){this.isBatchedMesh?NM.call(this,t,e):FM.call(this,t,e)}function NM(t,e){if(this.boundsTrees){const n=this.boundsTrees,i=this._drawInfo||this._instanceInfo,r=this._drawRanges||this._geometryInfo,s=this.matrixWorld;PM.material=this.material,PM.geometry=this.geometry;const a=PM.geometry.boundsTree,o=PM.geometry.drawRange;null===PM.geometry.boundingSphere&&(PM.geometry.boundingSphere=new cr);for(let a=0,o=i.length;a{if(t>=i||e)return s++,!0;r&&s++}),n);let a=0;const o=new Float32Array(24*s);let l,c;e.traverse(((t,e,n)=>{const s=t>=i||e;if(s||r){oC(0,n,GM);const{min:t,max:e}=GM;for(let n=-1;n<=1;n+=2){const i=n<0?t.x:e.x;for(let n=-1;n<=1;n+=2){const r=n<0?t.y:e.y;for(let n=-1;n<=1;n+=2){const s=n<0?t.z:e.z;o[a+0]=i,o[a+1]=r,o[a+2]=s,a+=3}}}return s}}),n),c=this.displayEdges?new Uint8Array([0,4,1,5,2,6,3,7,0,2,1,3,4,6,5,7,0,1,2,3,4,5,6,7]):new Uint8Array([0,1,2,2,1,3,4,6,5,6,7,5,1,4,5,0,4,1,2,3,6,3,7,6,0,2,4,2,6,4,1,5,3,3,5,7]),l=o.length>65535?new Uint32Array(c.length*s):new Uint16Array(c.length*s);const h=c.length;for(let t=0;tn;){const t=this._roots.pop();t.geometry.dispose(),this.remove(t)}for(let t=0;t=this._roots.length){const r=new VM(e,i,n,t);this.add(r),this._roots.push(r)}const o=this._roots[t];o.bvh=e,o.depth=n,o.displayParents=s,o.displayEdges=a,o.material=a?i:r,o.update()}}updateMatrixWorld(...t){const e=this.mesh,n=this.parent;null!==e&&(e.updateWorldMatrix(!0,!1),n?this.matrix.copy(n.matrixWorld).invert().multiply(e.matrixWorld):this.matrix.copy(e.matrixWorld),(e.isInstancedMesh||e.isBatchedMesh)&&(e.getMatrixAt(this.objectIndex,HM),this.matrix.multiply(HM)),this.matrix.decompose(this.position,this.quaternion,this.scale)),super.updateMatrixWorld(...t)}copy(t){this.depth=t.depth,this.mesh=t.mesh,this.bvh=t.bvh,this.opacity=t.opacity,this.color.copy(t.color)}clone(){return new WM(this.mesh,this.bvh,this.depth)}dispose(){this.edgeMaterial.dispose(),this.meshMaterial.dispose();const t=this.children;for(let e=0,n=t.length;efunction(t,e){const n={nodeCount:0,leafNodeCount:0,depth:{min:1/0,max:-1/0},tris:{min:1/0,max:-1/0},splits:[0,0,0],surfaceAreaScore:0};return t.traverse(((t,e,i,r,s)=>{const a=i[3]-i[0],o=i[4]-i[1],l=i[5]-i[2],c=2*(a*o+o*l+l*a);n.nodeCount++,e?(n.leafNodeCount++,n.depth.min=Math.min(t,n.depth.min),n.depth.max=Math.max(t,n.depth.max),n.tris.min=Math.min(s,n.tris.min),n.tris.max=Math.max(s,n.tris.max),n.surfaceAreaScore+=c*Yw*s):(n.splits[r]++,n.surfaceAreaScore+=c*Jw)}),e),n.tris.min===1/0&&(n.tris.min=0,n.tris.max=0),n.depth.min===1/0&&(n.depth.min=0,n.depth.max=0),n}(t,n)))}function KM(t){const e=new Set,n=[t];let i=0;for(;n.length;){const t=n.pop();if(!e.has(t)){e.add(t);for(let e in t){if(!Object.hasOwn(t,e))continue;i+=YM(e);const r=t[e];!r||"object"!=typeof r&&"function"!=typeof r?i+=YM(r):/(Uint|Int|Float)(8|16|32)Array/.test(r.constructor.name)||dM()&&r instanceof SharedArrayBuffer||r instanceof ArrayBuffer?i+=r.byteLength:n.push(r)}}}return i}function ZM(t){const e=t.geometry,n=[],i=e.index,r=e.getAttribute("position");let s=!0;return t.traverse(((e,a,o,l,c)=>{const h={depth:e,isLeaf:a,boundingData:o,offset:l,count:c};n[e]=h,oC(0,o,jM);const u=n[e-1];if(a)for(let e=l,n=l+c;e{const a={bounds:oC(0,i,new Wi)};n?(a.count=s,a.offset=r):(a.left=null,a.right=null),e[t]=a;const o=e[t-1];o&&(null===o.left?o.left=a:o.right=a)})),e[0]}function tb(t){switch(t){case 1:return se;case 2:return oe;case 3:case 4:return ce}}class eb extends Xc{constructor(){super(),this.minFilter=Tt,this.magFilter=Tt,this.generateMipmaps=!1,this.overrideItemSize=null,this._forcedType=null}updateFrom(t){const e=this.overrideItemSize,n=t.itemSize,i=t.count;if(null!==e){if(n*i%e!=0)throw new Error("VertexAttributeTexture: overrideItemSize must divide evenly into buffer length.");t.itemSize=e,t.count=i*n/e}const r=t.itemSize,s=t.count,a=t.normalized,o=t.array.constructor,l=o.BYTES_PER_ELEMENT;let c,h,u,d,p=this._forcedType,f=r;if(null===p)switch(o){case Float32Array:p=Wt;break;case Uint8Array:case Uint16Array:case Uint32Array:p=Vt;break;case Int8Array:case Int16Array:case Int32Array:p=Ht}let m=function(t){switch(t){case 1:return"R";case 2:return"RG";case 3:case 4:return"RGBA"}throw new Error}(r);switch(p){case Wt:u=1,h=function(t){switch(t){case 1:return re;case 2:return ae;case 3:case 4:return $t}}(r),a&&1===l?(d=o,m+="8",o===Uint8Array?c=kt:(c=Qt,m+="_SNORM")):(d=Float32Array,m+="32F",c=Wt);break;case Ht:m+=8*l+"I",u=a?Math.pow(2,8*o.BYTES_PER_ELEMENT-1):1,h=tb(r),1===l?(d=Int8Array,c=Qt):2===l?(d=Int16Array,c=zt):(d=Int32Array,c=Ht);break;case Vt:m+=8*l+"UI",u=a?Math.pow(2,8*o.BYTES_PER_ELEMENT-1):1,h=tb(r),1===l?(d=Uint8Array,c=kt):2===l?(d=Uint16Array,c=Gt):(d=Uint32Array,c=Vt)}3!==f||h!==$t&&h!==ce||(f=4);const g=Math.ceil(Math.sqrt(s))||1,A=new d(f*g*g),v=t.normalized;t.normalized=!1;for(let e=0;e=2&&(A[n+1]=t.getY(e)/u),r>=3&&(A[n+2]=t.getZ(e)/u,4===f&&(A[n+3]=1)),r>=4&&(A[n+3]=t.getW(e)/u)}t.normalized=v,this.internalFormat=m,this.format=h,this.type=c,this.image.width=g,this.image.height=g,this.image.data=A,this.needsUpdate=!0,this.dispose(),t.itemSize=n,t.count=i}}class nb extends eb{constructor(){super(),this._forcedType=Vt}}class ib extends eb{constructor(){super(),this._forcedType=Ht}}class rb extends eb{constructor(){super(),this._forcedType=Wt}}class sb{constructor(){this.index=new nb,this.position=new rb,this.bvhBounds=new Xc,this.bvhContents=new Xc,this._cachedIndexAttr=null,this.index.overrideItemSize=3}updateFrom(t){const{geometry:e}=t;if(function(t,e,n){const i=t._roots;if(1!==i.length)throw new Error("MeshBVHUniformStruct: Multi-root BVHs not supported.");const r=i[0],s=new Uint16Array(r),a=new Uint32Array(r),o=new Float32Array(r),l=r.byteLength/Kw,c=2*Math.ceil(Math.sqrt(l/2)),h=new Float32Array(4*c*c),u=Math.ceil(Math.sqrt(l)),d=new Uint32Array(2*u*u);for(let t=0;t=2&&e.setY(s,t.getY(r)),i>=3&&e.setZ(s,t.getZ(r)),i>=4&&e.setW(s,t.getW(r))}}else{const i=e.array,r=i.constructor,s=i.BYTES_PER_ELEMENT*t.itemSize*n;new r(i.buffer,s,t.array.length).set(t.array)}}function yb(t,e,n){const i=t.elements,r=e.elements;for(let t=0,e=r.length;t{t.traverseVisible((t=>{t.isMesh&&e.push(t)}))})),this.meshes=e,this.useGroups=!0,this.applyWorldTransforms=!0,this.attributes=["position","normal","color","tangent","uv","uv2"],this._intermediateGeometry=new Array(e.length).fill().map((()=>new ks)),this._diffMap=new WeakMap}getMaterials(){const t=[];return this.meshes.forEach((e=>{Array.isArray(e.material)?t.push(...e.material):t.push(e.material)})),t}generate(t=new ks){let e=[];const{meshes:n,useGroups:i,_intermediateGeometry:r,_diffMap:s}=this;for(let t=0,i=n.length;t{const i=t(e),r=t(n);return ir?1:0}):this._unloadPriorityCallback=t}constructor(){this.minSize=6e3,this.maxSize=8e3,this.minBytesSize=322122547.2,this.maxBytesSize=429496729.6,this.unloadPercent=.05,this.itemSet=new Map,this.itemList=[],this.usedSet=new Set,this.callbacks=new Map,this.markUnusedQueued=!1,this.unloadingHandle=-1,this.cachedBytes=0,this.bytesMap=new Map,this.loadedSet=new Set,this._unloadPriorityCallback=null,this.computeMemoryUsageCallback=()=>null;const t=this.itemSet;this.defaultPriorityCallback=e=>t.get(e)}isFull(){return this.itemSet.size>=this.maxSize||this.cachedBytes>=this.maxBytesSize}getMemoryUsage(t){return this.bytesMap.get(t)??null}add(t,e){this.markUnusedQueued&&this.markAllUnused();const n=this.itemSet;if(n.has(t))return!1;if(this.isFull())return!1;const i=this.usedSet,r=this.itemList,s=this.callbacks,a=this.bytesMap;r.push(t),i.add(t),n.set(t,Date.now()),s.set(t,e);const o=this.computeMemoryUsageCallback(t);return this.cachedBytes+=o||0,a.set(t,o),!0}remove(t){const e=this.usedSet,n=this.itemSet,i=this.itemList,r=this.bytesMap,s=this.callbacks,a=this.loadedSet;if(n.has(t)){this.cachedBytes-=r.get(t)||0,r.delete(t),s.get(t)(t);const o=i.indexOf(t);return i.splice(o,1),e.delete(t),n.delete(t),s.delete(t),a.delete(t),!0}return!1}setLoaded(t,e){const{itemSet:n,loadedSet:i}=this;n.has(t)&&(!0===e?i.add(t):i.delete(t))}updateMemoryUsage(t){const e=this.itemSet,n=this.bytesMap;if(!e.has(t))return;this.cachedBytes-=n.get(t)||0;const i=this.computeMemoryUsageCallback(t);n.set(t,i),this.cachedBytes+=i}markUsed(t){this.markUnusedQueued&&this.markAllUnused();const e=this.itemSet,n=this.usedSet;e.has(t)&&!n.has(t)&&(e.set(t,Date.now()),n.add(t))}markAllUnused(){this.usedSet.clear(),this.markUnusedQueued=!1,-1!==this.unloadingHandle&&(cancelAnimationFrame(this.unloadingHandle),this.unloadingHandle=-1)}unloadUnusedContent(){const{unloadPercent:t,minSize:e,maxSize:n,itemList:i,itemSet:r,usedSet:s,loadedSet:a,callbacks:o,bytesMap:l,minBytesSize:c,maxBytesSize:h}=this,u=i.length-s.size,d=i.length-a.size,p=Math.max(Math.min(i.length-e,u),0),f=this.cachedBytes-c,m=this.unloadPriorityCallback||this.defaultPriorityCallback;let g=!1;const A=p>0&&u>0||d&&i.length>n;if(u&&this.cachedBytes>c||d&&this.cachedBytes>h||A){i.sort(((t,e)=>{const n=s.has(t);if(n===s.has(e)){const n=a.has(t);return n===a.has(e)?-m(t,e):n?1:-1}return n?1:-1}));const d=Math.max(e*t,p*t),A=Math.ceil(Math.min(d,u,p)),v=Math.max(t*f,t*c),y=Math.min(v,f);let _=0,x=0;for(;this.cachedBytes-x>h||i.length-_>n;){const t=i[_],e=l.get(t)||0;if(s.has(t)&&a.has(t)||this.cachedBytes-x-e=A)break;x+=e,_++}i.splice(0,_).forEach((t=>{this.cachedBytes-=l.get(t)||0,o.get(t)(t),l.delete(t),r.delete(t),o.delete(t),a.delete(t),s.delete(t)})),g=_0}g&&(this.unloadingHandle=requestAnimationFrame((()=>this.scheduleUnload())))}scheduleUnload(){this.scheduled||(this.scheduled=!0,queueMicrotask((()=>{this.scheduled=!1,this.unloadUnusedContent(),this.markUnusedQueued=!0})))}}class Pb{constructor(){this.maxJobs=6,this.items=[],this.callbacks=new Map,this.currJobs=0,this.scheduled=!1,this.autoUpdate=!0,this.priorityCallback=()=>{throw new Error("PriorityQueue: PriorityCallback function not defined.")},this.schedulingCallback=t=>{requestAnimationFrame(t)},this._runjobs=()=>{this.tryRunJobs(),this.scheduled=!1}}sort(){const t=this.priorityCallback;this.items.sort(t)}add(t,e){return new Promise(((n,i)=>{const r=this.items,s=this.callbacks;r.push(t),s.set(t,((...t)=>e(...t).then(n).catch(i))),this.autoUpdate&&this.scheduleJobRun()}))}remove(t){const e=this.items,n=this.callbacks,i=e.indexOf(t);-1!==i&&(e.splice(i,1),n.delete(t))}tryRunJobs(){this.sort();const t=this.items,e=this.callbacks,n=this.maxJobs;let i=this.currJobs;for(;n>i&&t.length>0;){i++;const n=t.pop(),r=e.get(n);e.delete(n),r(n).then((()=>{this.currJobs--,this.autoUpdate&&this.scheduleJobRun()})).catch((()=>{this.currJobs--,this.autoUpdate&&this.scheduleJobRun()}))}this.currJobs=i}scheduleJobRun(){this.scheduled||(this.schedulingCallback(this._runjobs),this.scheduled=!0)}}const Lb=-1,Ub=0,Nb=1,Fb=2,Ob=3,kb=6378137,Qb=1/298.257223563,zb=-(Qb*kb-kb),Gb=1736e3,Hb=1738100;function Vb(t){return t===Ob||t===Lb}function Wb(t,e){return t.__lastFrameVisited===e&&t.__used}function jb(t,e){t.__lastFrameVisited!==e.frameCount&&(t.__lastFrameVisited=e.frameCount,t.__used=!1,t.__inFrustum=!1,t.__isLeaf=!1,t.__visible=!1,t.__active=!1,t.__error=1/0,t.__distanceFromCamera=1/0,t.__childrenWereVisible=!1,t.__allChildrenLoaded=!1,t.__inFrustum=e.tileInView(t),e.calculateError(t))}function qb(t,e){if(e.ensureChildrenArePreprocessed(t),jb(t,e),Yb(t,e),!t.__hasRenderableContent){const n=t.children;for(let t=0,i=n.length;t0&&t.__depth+1>=e.maxDepth)}(t,e))return void Yb(t,e);let n=!1,i=!1;const r=t.children;for(let t=0,s=r.length;tt.__depthFromRenderedParent!==e.__depthFromRenderedParent?t.__depthFromRenderedParent>e.__depthFromRenderedParent?-1:1:t.__inFrustum!==e.__inFrustum?t.__inFrustum?1:-1:t.__used!==e.__used?t.__used?1:-1:t.__error!==e.__error?t.__error>e.__error?1:-1:t.__distanceFromCamera!==e.__distanceFromCamera?t.__distanceFromCamera>e.__distanceFromCamera?-1:1:0,iS=(t,e)=>t.__depthFromRenderedParent!==e.__depthFromRenderedParent?t.__depthFromRenderedParent>e.__depthFromRenderedParent?1:-1:t.__loadingState!==e.__loadingState?t.__loadingState>e.__loadingState?-1:1:t.__lastFrameVisited!==e.__lastFrameVisited?t.__lastFrameVisited>e.__lastFrameVisited?-1:1:t.__hasUnrenderableContent!==e.__hasUnrenderableContent?t.__hasUnrenderableContent?-1:1:t.__error!==e.__error?t.__error>e.__error?-1:1:0;class rS{get root(){const t=this.rootTileSet;return t?t.root:null}set loadSiblings(t){console.warn('TilesRenderer: "loadSiblings" option has been removed.')}set stopAtEmptyTiles(t){console.warn('TilesRenderer: "stopAtEmptyTiles" option has been removed.')}set preprocessURL(t){console.warn('TilesRendererBase: The "preprocessURL" callback has been deprecated. Use a plugin, instead.'),this._preprocessURL=t}get preprocessURL(){return this._preprocessURL}constructor(t=null){this.rootTileSetTriggered=!1,this.rootTileSet=null,this.rootURL=t,this.fetchOptions={},this.plugins=[],this.queuedTiles=[],this._preprocessURL=null;const e=new Db;e.unloadPriorityCallback=iS;const n=new Pb;n.maxJobs=4,n.priorityCallback=nS;const i=new Pb;i.maxJobs=1,i.priorityCallback=nS,this.lruCache=e,this.downloadQueue=n,this.parseQueue=i,this.stats={parsing:0,downloading:0,failed:0,inFrustum:0,used:0,active:0,visible:0},this.frameCount=0,this.errorTarget=6,this.errorThreshold=1/0,this.displayActiveTiles=!1,this.maxDepth=1/0}registerPlugin(t){if(!0===t[eS])throw new Error("TilesRendererBase: A plugin can only be registered to a single tile set");this.plugins.push(t),t[eS]=!0,t.init&&t.init(this)}unregisterPlugin(t){const e=this.plugins;if("string"==typeof t&&(t=this.getPluginByName(name)),e.includes(t)){const n=e.indexOf(t);return e.splice(n,1),t.dispose&&t.dispose(),!0}return!1}getPluginByName(t){return this.plugins.find((e=>e.name===t))||null}traverse(t,e){this.root&&Jb(this.root,((e,...n)=>(this.ensureChildrenArePreprocessed(e),!!t&&t(e,...n))),e)}queueTileForDownload(t){this.queuedTiles.push(t)}update(){const t=this.stats,e=this.lruCache;if(this.rootTileSetTriggered||(this.rootTileSetTriggered=!0,this.invokeOnePlugin((t=>t.loadRootTileSet&&t.loadRootTileSet()))),!this.root)return;const n=this.root;t.inFrustum=0,t.used=0,t.active=0,t.visible=0,this.frameCount++,Kb(n,this),Zb(n,this),$b(n,this),tS(n,this);const i=this.queuedTiles;i.sort(e.unloadPriorityCallback);for(let t=0,n=i.length;t{t.__loadingState===Lb&&(t.__loadingState=Ub)})),t.failed=0)}dispose(){this.invokeAllPlugins((t=>{t!==this&&t.dispose&&t.dispose()}));const t=this.lruCache,e=[];this.traverse((t=>(e.push(t),!1)));for(let n=0,i=e.length;n{i!==this&&i.preprocessNode&&i.preprocessNode(t,e,n)}))}setTileActive(t,e){}setTileVisible(t,e){}calculateError(t){return 0}tileInView(t){return!0}ensureChildrenArePreprocessed(t){const e=t.children;for(let n=0,i=e.length;nparseInt(t)));console.assert(r<=1,"TilesRenderer: asset.version is expected to be a 1.x or a compatible version."),1===r&&s>0&&console.warn("TilesRenderer: tiles versions at 1.1 or higher have limited support. Some new extensions and features may not be supported.");let a=e.replace(/\/[^/]*\/?$/,"");a=new URL(a,window.location.href).toString(),this.preprocessNode(t.root,a,n)}loadRootTileSet(){let t=this.rootURL;this.invokeAllPlugins((e=>t=e.preprocessURL?e.preprocessURL(t,null):t));const e=this.invokeOnePlugin((e=>e.fetchData&&e.fetchData(t,this.fetchOptions))).then((e=>{if(e.ok)return e.json();throw new Error(`TilesRenderer: Failed to load tileset "${t}" with status ${e.status} : ${e.statusText}`)})).then((e=>{this.preprocessTileSet(e,t),this.rootTileSet=e}));return e.catch((t=>{console.error(t),this.rootTileSet=null})),e}requestTileContents(t){if(t.__loadingState!==Ub)return;let e=!1,n=new URL(t.content.uri,t.__basePath+"/").toString();this.invokeAllPlugins((e=>n=e.preprocessURL?e.preprocessURL(n,t):n));const i=this.stats,r=this.lruCache,s=this.downloadQueue,a=this.parseQueue,o=Rb(n);if(!r.add(t,(t=>{t.__loadingState===Nb?(t.__loadAbort.abort(),t.__loadAbort=null):e?t.children.length=0:this.invokeAllPlugins((e=>{e.disposeTile&&e.disposeTile(t)})),t.__loadingState===Nb?i.downloading--:t.__loadingState===Fb&&i.parsing--,t.__loadingState=Ub,t.__loadIndex++,a.remove(t),s.remove(t)})))return;t.__loadIndex++;const l=t.__loadIndex,c=new AbortController,h=c.signal;return i.downloading++,t.__loadAbort=c,t.__loadingState=Nb,s.add(t,(t=>t.__loadIndex!==l?Promise.resolve():this.invokeOnePlugin((t=>t.fetchData&&t.fetchData(n,{...this.fetchOptions,signal:h}))))).then((e=>{if(t.__loadIndex===l){if(e.ok)return"json"===o?e.json():e.arrayBuffer();throw new Error(`Failed to load model with error code ${e.status}`)}})).then((r=>{if(t.__loadIndex===l)return i.downloading--,i.parsing++,t.__loadAbort=null,t.__loadingState=Fb,a.add(t,(i=>i.__loadIndex!==l?Promise.resolve():"json"===o&&r.root?(this.preprocessTileSet(r,n,t),t.children.push(r.root),e=!0,Promise.resolve()):this.invokeOnePlugin((t=>t.parseTile&&t.parseTile(r,i,o,n)))))})).then((()=>{t.__loadIndex===l&&(i.parsing--,t.__loadingState=Ob,r.setLoaded(t,!0),null===r.getMemoryUsage(t)&&(r.isFull()&&r.computeMemoryUsageCallback(t)>0?r.remove(t):r.updateMemoryUsage(t)))})).catch((e=>{t.__loadIndex===l&&("AbortError"!==e.name?(a.remove(t),s.remove(t),t.__loadingState===Fb?i.parsing--:t.__loadingState===Nb&&i.downloading--,i.failed++,console.error(`TilesRenderer : Failed to load tile at url "${t.content.uri}".`),console.error(e),t.__loadingState=Lb,r.setLoaded(t,!0)):r.remove(t))}))}getAttributions(t=[]){return this.invokeAllPlugins((e=>e!==this&&e.getAttributions&&e.getAttributions(t))),t}invokeOnePlugin(t){const e=[...this.plugins,this];for(let n=0;na+o)throw new Error("FeatureTable: Feature data read outside binary body length.");return d}}return s}getBuffer(t,e){const{buffer:n,binOffset:i}=this;return n.slice(i+t,i+t+e)}}class cS{constructor(t){this.batchTable=t;const e=t.header.extensions["3DTILES_batch_table_hierarchy"];this.classes=e.classes;for(const t of this.classes){const e=t.instances;for(const n in e)t.instances[n]=this._parseProperty(e[n],t.length,n)}if(this.instancesLength=e.instancesLength,this.classIds=this._parseProperty(e.classIds,this.instancesLength,"classIds"),e.parentCounts?this.parentCounts=this._parseProperty(e.parentCounts,this.instancesLength,"parentCounts"):this.parentCounts=new Array(this.instancesLength).fill(1),e.parentIds){const t=this.parentCounts.reduce(((t,e)=>t+e),0);this.parentIds=this._parseProperty(e.parentIds,t,"parentIds")}else this.parentIds=null;this.instancesIds=[];const n={};for(const t of this.classIds)n[t]=n[t]??0,this.instancesIds.push(n[t]),n[t]++}_parseProperty(t,e,n){if(Array.isArray(t))return t;{const{buffer:i,binOffset:r}=this.batchTable;return oS(i,r+t.byteOffset,e,"SCALAR",t.componentType||"UNSIGNED_SHORT",n)}}getDataFromId(t,e={}){const n=this.parentCounts[t];if(this.parentIds&&n>0){let i=0;for(let e=0;e=this.count)throw new Error(`BatchTable: id value "${t}" out of bounds for "${this.count}" features number.`);for(const n of this.getKeys())"extensions"!==n&&(e[n]=super.getData(n,this.count)[t]);for(const n in this.extensions){const i=this.extensions[n];i.getDataFromId instanceof Function&&(e[n]=e[n]||{},i.getDataFromId(t,e[n]))}return e}getPropertyArray(t){return super.getData(t,this.count)}}class uS{constructor(){this.fetchOptions={},this.workingPath=""}load(t){return console.warn('Loader: "load" function has been deprecated in favor of "loadAsync".'),this.loadAsync(t)}loadAsync(t){return fetch(t,this.fetchOptions).then((e=>{if(!e.ok)throw new Error(`Failed to load file "${t}" with status ${e.status} : ${e.statusText}`);return e.arrayBuffer()})).then((e=>(""===this.workingPath&&(this.workingPath=this.workingPathForURL(t)),this.parse(e))))}resolveExternalURL(t){return/^[^\\/]/.test(t)&&!/^http/.test(t)?this.workingPath+"/"+t:t}workingPathForURL(t){const e=t.split(/[\\/]/g);return e.pop(),e.join("/")+"/"}parse(t){throw new Error("LoaderBase: Parse not implemented.")}}function dS(t){let e;if(e=t instanceof DataView?t:new DataView(t),"{"===String.fromCharCode(e.getUint8(0)))return null;let n="";for(let t=0;t<4;t++)n+=String.fromCharCode(e.getUint8(t));return n}class pS extends uS{parse(t){const e=new DataView(t),n=dS(e);console.assert("b3dm"===n);const i=e.getUint32(4,!0);console.assert(1===i);const r=e.getUint32(8,!0);console.assert(r===t.byteLength);const s=e.getUint32(12,!0),a=e.getUint32(16,!0),o=e.getUint32(20,!0),l=e.getUint32(24,!0),c=t.slice(28,28+s+a),h=new lS(c,0,s,a),u=28+s+a,d=t.slice(u,u+o+l),p=new hS(d,h.getData("BATCH_LENGTH"),0,o,l),f=u+o+l;return{version:i,featureTable:h,batchTable:p,glbBytes:new Uint8Array(t,f,r-f)}}}class fS extends pS{constructor(t=Zd){super(),this.manager=t,this.adjustmentTransform=new vr}parse(t){const e=super.parse(t),n=e.glbBytes.slice().buffer;return new Promise(((t,i)=>{const r=this.manager,s=this.fetchOptions,a=r.getHandler("path.gltf")||new Lg(r);"include"===s.credentials&&"cors"===s.mode&&a.setCrossOrigin("use-credentials"),"credentials"in s&&a.setWithCredentials("include"===s.credentials),s.headers&&a.setRequestHeader(s.headers);let o=this.workingPath;!/[\\/]$/.test(o)&&o.length&&(o+="/");const l=this.adjustmentTransform;a.parse(n,o,(n=>{const{batchTable:i,featureTable:r}=e,{scene:s}=n,a=r.getData("RTC_CENTER");a&&(s.position.x+=a[0],s.position.y+=a[1],s.position.z+=a[2]),n.scene.updateMatrix(),n.scene.matrix.multiply(l),n.scene.matrix.decompose(n.scene.position,n.scene.quaternion,n.scene.scale),n.batchTable=i,n.featureTable=r,s.batchTable=i,s.featureTable=r,t(n)}),i)}))}}class mS extends uS{parse(t){const e=new DataView(t),n=dS(e);console.assert("pnts"===n);const i=e.getUint32(4,!0);console.assert(1===i);const r=e.getUint32(8,!0);console.assert(r===t.byteLength);const s=e.getUint32(12,!0),a=e.getUint32(16,!0),o=e.getUint32(20,!0),l=e.getUint32(24,!0),c=t.slice(28,28+s+a),h=new lS(c,0,s,a),u=28+s+a,d=t.slice(u,u+o+l),p=new hS(d,h.getData("BATCH_LENGTH")||h.getData("POINTS_LENGTH"),0,o,l);return Promise.resolve({version:i,featureTable:h,batchTable:p})}}function gS(t){const e=t>>11,n=t>>5&63,i=31&t;return[Math.round(e/31*255),Math.round(n/63*255),Math.round(i/31*255)]}const AS={RGB:"color",POSITION:"position"};class vS extends mS{constructor(t=Zd){super(),this.manager=t}parse(t){return super.parse(t).then((async t=>{const{featureTable:e,batchTable:n}=t,i=new kh,r=e.header.extensions,s=new Gi;let a;if(r&&r["3DTILES_draco_point_compression"]){const{byteOffset:t,byteLength:n,properties:s}=r["3DTILES_draco_point_compression"],o=this.manager.getHandler("draco.drc");if(null==o)throw new Error("PNTSLoader: dracoLoader not available.");const l={};for(const t in s)t in AS&&t in s&&(l[AS[t]]=s[t]);const c={attributeIDs:l,attributeTypes:{position:"Float32Array",color:"Uint8Array"},useUniqueIDs:!0},h=e.getBuffer(t,n);a=await o.decodeGeometry(h,c),a.attributes.color&&(i.vertexColors=!0)}else{const t=e.getData("POINTS_LENGTH"),n=e.getData("POSITION",t,"FLOAT","VEC3"),r=e.getData("RGB",t,"UNSIGNED_BYTE","VEC3"),o=e.getData("RGBA",t,"UNSIGNED_BYTE","VEC4"),l=e.getData("RGB565",t,"UNSIGNED_SHORT","SCALAR"),c=e.getData("CONSTANT_RGBA",t,"UNSIGNED_BYTE","VEC4"),h=e.getData("POSITION_QUANTIZED",t,"UNSIGNED_SHORT","VEC3"),u=e.getData("QUANTIZED_VOLUME_SCALE",t,"FLOAT","VEC3"),d=e.getData("QUANTIZED_VOLUME_OFFSET",t,"FLOAT","VEC3");if(a=new ks,h){const e=new Float32Array(3*t);for(let n=0;n{t in e.header&&console.warn(`PNTSLoader: Unsupported FeatureTable feature "${t}" detected.`)}));const o=new Vh(a,i);o.position.copy(s),t.scene=o,t.scene.featureTable=e,t.scene.batchTable=n;const l=e.getData("RTC_CENTER");return l&&(t.scene.position.x+=l[0],t.scene.position.y+=l[1],t.scene.position.z+=l[2]),t}))}}class yS extends uS{parse(t){const e=new DataView(t),n=dS(e);console.assert("i3dm"===n);const i=e.getUint32(4,!0);console.assert(1===i);const r=e.getUint32(8,!0);console.assert(r===t.byteLength);const s=e.getUint32(12,!0),a=e.getUint32(16,!0),o=e.getUint32(20,!0),l=e.getUint32(24,!0),c=e.getUint32(28,!0),h=t.slice(32,32+s+a),u=new lS(h,0,s,a),d=32+s+a,p=t.slice(d,d+o+l),f=new hS(p,u.getData("INSTANCES_LENGTH"),0,o,l),m=d+o+l,g=new Uint8Array(t,m,r-m);let A=null,v=null,y=null;if(c)A=g,v=Promise.resolve();else{const t=this.resolveExternalURL(aS(g)),e=t.split(/[\\/]/g);e.pop(),y=e.join("/"),v=fetch(t,this.fetchOptions).then((e=>{if(!e.ok)throw new Error(`I3DMLoaderBase : Failed to load file "${t}" with status ${e.status} : ${e.statusText}`);return e.arrayBuffer()})).then((t=>{A=new Uint8Array(t)}))}return v.then((()=>({version:i,featureTable:u,batchTable:f,glbBytes:A,gltfWorkingPath:y})))}}const _S=new bf,xS=new Gi,wS={};function CS(t){const{x:e,y:n,z:i}=t;t.x=i,t.y=e,t.z=n}function ES(t){const{x:e,y:n,z:i}=t;t.z=e,t.x=n,t.y=i}function MS(t){return-(t-Math.PI/2)}function bS(t){return-t+Math.PI/2}function SS(t,e="E",n="W"){const i=t<0?n:e,r=~~(t=Math.abs(t)),s=60*(t-r),a=~~s;return`${r}° ${a}' ${~~(60*(s-a))}" ${i}`}function IS(t,e,n=!1){const i=function(t,e,n={}){return _S.theta=e,_S.phi=bS(t),xS.setFromSpherical(_S),_S.setFromVector3(xS),n.lat=MS(_S.phi),n.lon=_S.theta,n}(t,e,wS);let r,s;return n?(r=`${(li.RAD2DEG*i.lat).toFixed(4)}°`,s=`${(li.RAD2DEG*i.lon).toFixed(4)}°`):(r=SS(li.RAD2DEG*i.lat,"N","S"),s=SS(li.RAD2DEG*i.lon,"E","W")),`${r} ${s}`}const TS=new bf,BS=new Gi,RS=new Gi,DS=new Gi,PS=new Gi,LS=new vr,US=new vr,NS=new cr,FS=new Ir,OS=new Gi,kS=new Gi,QS=new Gi,zS=new Gi,GS=new Ar,HS=0,VS=1,WS=2;class jS{constructor(t=1,e=1,n=1){this.radius=new Gi(t,e,n)}intersectRay(t,e){return LS.makeScale(...this.radius).invert(),NS.center.set(0,0,0),NS.radius=1,GS.copy(t).applyMatrix4(LS),GS.intersectSphere(NS,e)?(LS.makeScale(...this.radius),e.applyMatrix4(LS),e):null}getEastNorthUpFrame(t,e,n){return this.getEastNorthUpAxes(t,e,OS,kS,QS,zS),n.makeBasis(OS,kS,QS).setPosition(zS)}getEastNorthUpAxes(t,e,n,i,r,s=zS){this.getCartographicToPosition(t,e,0,s),this.getCartographicToNormal(t,e,r),n.set(-s.y,s.x,0).normalize(),i.crossVectors(r,n).normalize()}getNorthernTangent(t,e,n,i=PS){return console.log("Ellipsoid: getNorthernTangent has been deprecated. Use getEastNorthUpAxes instead."),this.getEastNorthUpAxes(t,e,i,n,QS),i.multiplyScalar(-1),n}getAzElRollFromRotationMatrix(t,e,n,i,r=HS){return r===VS?(FS.set(-Math.PI/2,0,0,"XYZ"),US.makeRotationFromEuler(FS).premultiply(n)):r===WS?(FS.set(-Math.PI/2,0,Math.PI,"XYZ"),US.makeRotationFromEuler(FS).premultiply(n)):US.copy(n),this.getEastNorthUpFrame(t,e,LS).invert(),US.premultiply(LS),FS.setFromRotationMatrix(US,"ZXY"),i.azimuth=-FS.z,i.elevation=FS.x,i.roll=FS.y,i}getRotationMatrixFromAzElRoll(t,e,n,i,r,s,a=HS){return this.getEastNorthUpFrame(t,e,LS),FS.set(i,r,-n,"ZXY"),s.makeRotationFromEuler(FS).premultiply(LS).setPosition(0,0,0),a===VS?(FS.set(Math.PI/2,0,0,"XYZ"),US.makeRotationFromEuler(FS),s.multiply(US)):a===WS&&(FS.set(-Math.PI/2,0,Math.PI,"XYZ"),US.makeRotationFromEuler(FS),s.multiply(US)),s}getCartographicToPosition(t,e,n,i){this.getCartographicToNormal(t,e,BS);const r=this.radius;RS.copy(BS),RS.x*=r.x**2,RS.y*=r.y**2,RS.z*=r.z**2;const s=Math.sqrt(BS.dot(RS));return RS.divideScalar(s),i.copy(RS).addScaledVector(BS,n)}getPositionToCartographic(t,e){this.getPositionToSurfacePoint(t,RS),this.getPositionToNormal(t,BS);const n=DS.subVectors(t,RS);return e.lon=Math.atan2(BS.y,BS.x),e.lat=Math.asin(BS.z),e.height=Math.sign(n.dot(t))*n.length(),e}getCartographicToNormal(t,e,n){return TS.set(1,bS(t),e),n.setFromSpherical(TS).normalize(),CS(n),n}getPositionToNormal(t,e){const n=this.radius;return e.copy(t),e.x/=n.x**2,e.y/=n.y**2,e.z/=n.z**2,e.normalize(),e}getPositionToSurfacePoint(t,e){const n=this.radius,i=1/n.x**2,r=1/n.y**2,s=1/n.z**2,a=t.x*t.x*i,o=t.y*t.y*r,l=t.z*t.z*s,c=a+o+l,h=Math.sqrt(1/c),u=RS.copy(t).multiplyScalar(h);if(c<.1)return isFinite(h)?e.copy(u):null;const d=DS.set(u.x*i*2,u.y*r*2,u.z*s*2);let p,f,m,g,A,v,y,_,x,w,C,E=(1-h)*t.length()/(.5*d.length()),M=0;do{E-=M,m=1/(1+E*i),g=1/(1+E*r),A=1/(1+E*s),v=m*m,y=g*g,_=A*A,x=v*m,w=y*g,C=_*A,p=a*v+o*y+l*_-1,f=a*x*i+o*w*r+l*C*s,M=p/(-2*f)}while(Math.abs(p)>1e-12);return e.set(t.x*m,t.y*g,t.z*A)}calculateHorizonDistance(t,e){const n=this.calculateEffectiveRadius(t);return Math.sqrt(2*n*e+e**2)}calculateEffectiveRadius(t){const e=this.radius.x,n=1-this.radius.z**2/e**2,i=t*li.DEG2RAD,r=Math.sin(i)**2;return e/Math.sqrt(1-n*r)}getPositionElevation(t){this.getPositionToSurfacePoint(t,RS);const e=DS.subVectors(t,RS);return Math.sign(e.dot(t))*e.length()}copy(t){return this.radius.copy(t.radius),this}clone(){return(new this.constructor).copy(this)}}const qS=new jS(kb,kb,zb),XS=new jS(Hb,Hb,Gb),YS=new Gi,JS=new Gi,KS=new Gi,ZS=new Gi,$S=new zi,tI=new Gi,eI=new vr,nI=new vr,iI=new Gi,rI=new vr,sI=new zi,aI={};class oI extends yS{constructor(t=Zd){super(),this.manager=t,this.adjustmentTransform=new vr,this.ellipsoid=qS.clone()}resolveExternalURL(t){return this.manager.resolveURL(super.resolveExternalURL(t))}parse(t){return super.parse(t).then((t=>{const{featureTable:e,batchTable:n}=t,i=t.glbBytes.slice().buffer;return new Promise(((r,s)=>{const a=this.fetchOptions,o=this.manager,l=o.getHandler("path.gltf")||new Lg(o);"include"===a.credentials&&"cors"===a.mode&&l.setCrossOrigin("use-credentials"),"credentials"in a&&l.setWithCredentials("include"===a.credentials),a.headers&&l.setRequestHeader(a.headers);let c=t.gltfWorkingPath??this.workingPath;/[\\/]$/.test(c)||(c+="/");const h=this.adjustmentTransform;l.parse(i,c,(t=>{const i=e.getData("INSTANCES_LENGTH"),s=e.getData("POSITION",i,"FLOAT","VEC3"),a=e.getData("NORMAL_UP",i,"FLOAT","VEC3"),o=e.getData("NORMAL_RIGHT",i,"FLOAT","VEC3"),l=e.getData("SCALE_NON_UNIFORM",i,"FLOAT","VEC3"),c=e.getData("SCALE",i,"FLOAT","SCALAR"),u=e.getData("RTC_CENTER"),d=e.getData("EAST_NORTH_UP");["QUANTIZED_VOLUME_OFFSET","QUANTIZED_VOLUME_SCALE","POSITION_QUANTIZED","NORMAL_UP_OCT32P","NORMAL_RIGHT_OCT32P"].forEach((t=>{t in e.header&&console.warn(`I3DMLoader: Unsupported FeatureTable feature "${t}" detected.`)}));const p=new Gi;for(let t=0;t{if(t.isMesh){m.push(t);const{geometry:e,material:n}=t,r=new ah(e,n,i);r.position.copy(p),u&&(r.position.x+=u[0],r.position.y+=u[1],r.position.z+=u[2]),f.push(r)}}));for(let t=0;t{const e=new nc;return t.forEach((t=>{e.add(t.scene)})),{tiles:t,scene:e}}))}}class hI{constructor(){this.name="CESIUM_RTC"}afterRoot(t){if(t.parser.json.extensions&&t.parser.json.extensions.CESIUM_RTC){const{center:e}=t.parser.json.extensions.CESIUM_RTC;e&&(t.scene.position.x+=e[0],t.scene.position.y+=e[1],t.scene.position.z+=e[2])}}}class uI extends hI{constructor(...t){super(...t),console.warn('GLTFCesiumRTCExtension: Plugins should now be imported from "3d-tiles-renderer/plugins" path.')}}class dI extends uS{constructor(t=Zd){super(),this.manager=t}parse(t){return new Promise(((e,n)=>{const i=this.manager,r=this.fetchOptions;let s=i.getHandler("path.gltf")||i.getHandler("path.glb");s||(s=new Lg(i),s.register((()=>new uI))),"include"===r.credentials&&"cors"===r.mode&&s.setCrossOrigin("use-credentials"),"credentials"in r&&s.setWithCredentials("include"===r.credentials),r.headers&&s.setRequestHeader(r.headers);let a=s.resourcePath||s.path||this.workingPath;!/[\\/]$/.test(a)&&a.length&&(a+="/"),s.parse(t,a,(t=>{e(t)}),n)}))}}const pI=new vr;class fI extends nc{constructor(t){super(),this.name="TilesRenderer.TilesGroup",this.tilesRenderer=t}raycast(t,e){return!this.tilesRenderer.optimizeRaycast||(this.tilesRenderer.raycast(t,e),!1)}updateMatrixWorld(t){if(this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldNeedsUpdate||t){null===this.parent?pI.copy(this.matrix):pI.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1;const t=pI.elements,e=this.matrixWorld.elements;let n=!1;for(let i=0;i<16;i++){const r=t[i],s=e[i];if(Math.abs(r-s)>Number.EPSILON){n=!0;break}}if(n){this.matrixWorld.copy(pI);const t=this.children;for(let e=0,n=t.length;e{Object.getPrototypeOf(t).raycast.call(t,e,i)})):n.invokeOnePlugin((n=>n.raycastTile&&n.raycastTile(t,r,e,i)))||e.intersectObject(r,!0,i)}function wI(t,e,n,i=null){const{group:r,activeTiles:s}=t;t.ensureChildrenArePreprocessed(e),null===i&&(i=AI,gI.copy(r.matrixWorld).invert(),i.copy(n.ray).applyMatrix4(gI));const a=[],o=e.children;for(let t=0,e=o.length;tc)break;const h=wI(t,o,n,i);if(h){const t=h.distance*h.distance;tnew Gi)),this.planes=new Array(6).fill().map((()=>new Aa))}clampPoint(t,e){return e.copy(t).applyMatrix4(this.inverseTransform).clamp(this.box.min,this.box.max).applyMatrix4(this.transform)}distanceToPoint(t){return this.clampPoint(t,bI).distanceTo(t)}containsPoint(t){return bI.copy(t).applyMatrix4(this.inverseTransform),this.box.containsPoint(bI)}intersectsRay(t){return SI.copy(t).applyMatrix4(this.inverseTransform),SI.intersectsBox(this.box)}intersectRay(t,e){return SI.copy(t).applyMatrix4(this.inverseTransform),SI.intersectBox(this.box,e)?(e.applyMatrix4(this.transform),e):null}update(){const{points:t,inverseTransform:e,transform:n,box:i}=this;e.copy(n).invert();const{min:r,max:s}=i;let a=0;for(let e=-1;e<=1;e+=2)for(let i=-1;i<=1;i+=2)for(let o=-1;o<=1;o+=2)t[a].set(e<0?r.x:s.x,i<0?r.y:s.y,o<0?r.z:s.z).applyMatrix4(n),a++;this.updatePlanes()}updatePlanes(){EI.copy(this.box.min).applyMatrix4(this.transform),MI.copy(this.box.max).applyMatrix4(this.transform),bI.set(0,0,1).transformDirection(this.transform),this.planes[0].setFromNormalAndCoplanarPoint(bI,EI),this.planes[1].setFromNormalAndCoplanarPoint(bI,MI).negate(),bI.set(0,1,0).transformDirection(this.transform),this.planes[2].setFromNormalAndCoplanarPoint(bI,EI),this.planes[3].setFromNormalAndCoplanarPoint(bI,MI).negate(),bI.set(1,0,0).transformDirection(this.transform),this.planes[4].setFromNormalAndCoplanarPoint(bI,EI),this.planes[5].setFromNormalAndCoplanarPoint(bI,MI).negate()}intersectsFrustum(t){const{points:e}=this,{planes:n}=t;for(let t=0;t<6;t++){const i=n[t];let r=-1/0;for(let t=0;t<8;t++){const n=e[t],s=i.distanceToPoint(n);r=r=e&&a<=n&&o>=i&&o<=r){const e=FI(t);u.push(e),this.getCartographicToPosition(a,o,l,e)}}}return u}getBoundingBox(t,e){OI();const{latStart:n,latEnd:i,lonStart:r,lonEnd:s}=this;if(i-nr?i:r}intersectsFrustum(t){const e=this.obb||this.regionObb,n=this.sphere;return!(n&&!t.intersectsSphere(n))&&!(e&&!e.intersectsFrustum(t))&&Boolean(n||e)}getOBB(t,e){const n=this.obb||this.regionObb;n?(t.copy(n.box),e.copy(n.transform)):(this.getAABB(t),e.identity())}getAABB(t){if(this.sphere)this.sphere.getBoundingBox(t);else{const e=this.obb||this.regionObb;t.copy(e.box).applyMatrix4(e.transform)}}getSphere(t){if(this.sphere)t.copy(this.sphere);else if(this.region)this.region.getBoundingSphere(t);else{const e=this.obb||this.regionObb;e.box.getBoundingSphere(t),t.applyMatrix4(e.transform)}}setObbData(t,e){const n=new II;QI.set(t[3],t[4],t[5]),zI.set(t[6],t[7],t[8]),GI.set(t[9],t[10],t[11]);const i=QI.length(),r=zI.length(),s=GI.length();QI.normalize(),zI.normalize(),GI.normalize(),0===i&&QI.crossVectors(zI,GI),0===r&&zI.crossVectors(QI,GI),0===s&&GI.crossVectors(QI,zI),n.transform.set(QI.x,zI.x,GI.x,t[0],QI.y,zI.y,GI.y,t[1],QI.z,zI.z,GI.z,t[2],0,0,0,1).premultiply(e),n.box.min.set(-i,-r,-s),n.box.max.set(i,r,s),n.update(),this.obb=n}setSphereData(t,e,n,i,r){const s=new cr;s.center.set(t,e,n),s.radius=i,s.applyMatrix4(r),this.sphere=s}setRegionData(t,e,n,i,r,s,a){const o=new kI(...t.radius,n,r,e,i,s,a),l=new II;o.getBoundingBox(l.box,l.transform),l.update(),this.region=o,this.regionObb=l}}const jI=new hi;class qI extends _a{constructor(){super(),this.points=Array(8).fill().map((()=>new Gi))}setFromProjectionMatrix(t,e){super.setFromProjectionMatrix(t,e),this.calculateFrustumPoints()}calculateFrustumPoints(){const{planes:t,points:e}=this;[[t[0],t[3],t[4]],[t[1],t[3],t[4]],[t[0],t[2],t[4]],[t[1],t[2],t[4]],[t[0],t[3],t[5]],[t[1],t[3],t[5]],[t[0],t[2],t[5]],[t[1],t[2],t[5]]].forEach(((t,n)=>{!function(t,e,n,i){const r=jI.set(t.normal.x,t.normal.y,t.normal.z,e.normal.x,e.normal.y,e.normal.z,n.normal.x,n.normal.y,n.normal.z);i.set(-t.constant,-e.constant,-n.constant),i.applyMatrix3(r.invert())}(t[0],t[1],t[2],e[n])}))}}const XI=new vr,YI=new Ir,JI=parseInt(p)<165,KI=Symbol("INITIAL_FRUSTUM_CULLED"),ZI=new vr,$I=new vr,tT=new Gi,eT=new ci,nT=new Gi(1,0,0),iT=new Gi(0,1,0);function rT(t,e){t.traverse((t=>{t.frustumCulled=t[KI]&&e}))}class sT extends rS{get autoDisableRendererCulling(){return this._autoDisableRendererCulling}set autoDisableRendererCulling(t){this._autoDisableRendererCulling!==t&&(super._autoDisableRendererCulling=t,this.forEachLoadedModel((e=>{rT(e,!t)})))}constructor(...t){super(...t),this.group=new fI(this),this.ellipsoid=qS.clone(),this.cameras=[],this.cameraMap=new Map,this.cameraInfo=[],this.activeTiles=new Set,this.visibleTiles=new Set,this.optimizeRaycast=!0,this._eventDispatcher=new Kn,this._upRotationMatrix=new vr,this.lruCache.computeMemoryUsageCallback=t=>t.cached.bytesUsed??null,this._autoDisableRendererCulling=!0,this._loadingTiles=!1;const e=new Kd;if(e.setURLModifier((t=>this.preprocessURL?this.preprocessURL(t):t)),this.manager=e,JI){const t=this;this._overridenRaycast=function(e,n){t.optimizeRaycast||Object.getPrototypeOf(this).raycast.call(this,e,n)}}}addEventListener(...t){this._eventDispatcher.addEventListener(...t)}hasEventListener(...t){this._eventDispatcher.hasEventListener(...t)}removeEventListener(...t){this._eventDispatcher.removeEventListener(...t)}dispatchEvent(...t){this._eventDispatcher.dispatchEvent(...t)}getBounds(...t){return console.warn("TilesRenderer: getBounds has been renamed to getBoundingBox."),this.getBoundingBox(...t)}getOrientedBounds(...t){return console.warn("TilesRenderer: getOrientedBounds has been renamed to getOrientedBoundingBox."),this.getOrientedBoundingBox(...t)}getBoundingBox(t){if(!this.root)return!1;const e=this.root.cached.boundingVolume;return!!e&&(e.getAABB(t),!0)}getOrientedBoundingBox(t,e){if(!this.root)return!1;const n=this.root.cached.boundingVolume;return!!n&&(n.getOBB(t,e),!0)}getBoundingSphere(t){if(!this.root)return!1;const e=this.root.cached.boundingVolume;return!!e&&(e.getSphere(t),!0)}forEachLoadedModel(t){this.traverse((e=>{const n=e.cached.scene;n&&t(n,e)}))}raycast(t,e){if(this.root)if(t.firstHitOnly){const n=wI(this,this.root,t);n&&e.push(n)}else CI(this,this.root,t,e)}hasCamera(t){return this.cameraMap.has(t)}setCamera(t){const e=this.cameras,n=this.cameraMap;return!n.has(t)&&(n.set(t,new ci),e.push(t),this.dispatchEvent({type:"add-camera",camera:t}),!0)}setResolution(t,e,n){const i=this.cameraMap;if(!i.has(t))return!1;const r=e.isVector2?e.x:e,s=e.isVector2?e.y:n,a=i.get(t);return a.width===r&&a.height===s||(a.set(r,s),this.dispatchEvent({type:"camera-resolution-change"})),!0}setResolutionFromRenderer(t,e){return e.getSize(eT).multiplyScalar(e.getPixelRatio()),this.setResolution(t,eT.x,eT.y)}deleteCamera(t){const e=this.cameras,n=this.cameraMap;if(n.has(t)){const i=e.indexOf(t);return e.splice(i,1),n.delete(t),this.dispatchEvent({type:"delete-camera",camera:t}),!0}return!1}preprocessTileSet(t,e,n){super.preprocessTileSet(t,e,n),queueMicrotask((()=>{this.dispatchEvent({type:"load-tile-set",tileSet:t,url:e})}))}loadRootTileSet(...t){return super.loadRootTileSet(...t).then((()=>{switch((this.rootTileSet.asset&&this.rootTileSet.asset.gltfUpAxis||"y").toLowerCase()){case"x":this._upRotationMatrix.makeRotationAxis(iT,-Math.PI/2);break;case"y":this._upRotationMatrix.makeRotationAxis(nT,Math.PI/2)}this.dispatchEvent({type:"load-content"})})).catch((()=>{}))}update(){let t=null;if(this.invokeAllPlugins((e=>{if(e.doTilesNeedUpdate){const n=e.doTilesNeedUpdate();t=null===t?n:t||n}})),!1===t)return this.dispatchEvent({type:"update-before"}),void this.dispatchEvent({type:"update-after"});this.dispatchEvent({type:"update-before"});const e=this.group,n=this.cameras,i=this.cameraMap,r=this.cameraInfo;if(0!==n.length){for(;r.length>n.length;)r.pop();for(;r.length1e-6&&console.warn("ThreeTilesRenderer : Non uniform scale used for tile which may cause issues when calculating screen space error.");for(let t=0,s=r.length;tt.scene));break}case"gltf":case"glb":{const e=new dI(c);e.workingPath=o,e.fetchOptions=l,u=e.parse(t);break}default:console.warn(`TilesRenderer: Content type "${f}" not supported.`),u=Promise.resolve(null)}const m=this.stats;!1===this._loadingTiles&&m.parsing+m.downloading>0&&(this.dispatchEvent({type:"tiles-load-start"}),this._loadingTiles=!0);const g=await u;let A,v;if(g.isObject3D?(A=g,v=null):(A=g.scene,v=g),await this.invokeAllPlugins((t=>t.processTileModel&&t.processTileModel(A,n))),s._loadIndex!==h)return;A.updateMatrix(),"glb"!==f&&"gltf"!==f||A.matrix.multiply(p),A.matrix.premultiply(d),A.matrix.decompose(A.position,A.quaternion,A.scale),A.traverse((t=>{t[KI]=t.frustumCulled})),rT(A,!this.autoDisableRendererCulling),JI&&A.traverse((t=>{t.raycast=this._overridenRaycast}));const y=[],_=[],x=[];A.traverse((t=>{if(t.geometry&&_.push(t.geometry),t.material){const e=t.material;y.push(t.material);for(const t in e){const n=e[t];n&&n.isTexture&&x.push(n)}}})),s.materials=y,s.geometry=_,s.textures=x,s.scene=A,s.metadata=v,s.bytesUsed=function(t){const{TextureUtils:n}=e;if(!n)return 0;const i=new Set;let r=0;return t.traverse((t=>{if(t.geometry&&!i.has(t.geometry)&&(r+=Dg(t.geometry),i.add(t.geometry)),t.material){const e=t.material;for(const t in e){const s=e[t];if(s&&s.isTexture&&!i.has(s)){const{format:t,type:e,image:a}=s,{width:o,height:l}=a,c=n.getByteLength(o,l,t,e);r+=s.generateMipmaps?4*c/3:c,i.add(s)}}}})),r}(A),this.dispatchEvent({type:"load-model",scene:A,tile:n}),!0===this._loadingTiles&&m.parsing+m.downloading===1&&(this.dispatchEvent({type:"tiles-load-end"}),this._loadingTiles=!1)}disposeTile(t){super.disposeTile(t);const e=t.cached;if(e.scene){const n=e.materials,i=e.geometry,r=e.textures,s=e.scene.parent;e.scene.traverse((t=>{t.userData.meshFeatures&&t.userData.meshFeatures.dispose(),t.userData.structuralMetadata&&t.userData.structuralMetadata.dispose()}));for(let t=0,e=i.length;t{const n=Symbol(t);Object.defineProperty(sT.prototype,t,{get(){return this[n]||null},set(i){console.warn(`TilesRenderer: "${t}" has been deprecated in favor of the "${e}" event.`),this[n]&&this.removeEventListener(e,this[n]),this[n]=i,this.addEventListener(e,i)}})}));const aT=new Gi,oT=["x","y","z"];class lT extends Fh{constructor(t,e=16776960,n=40){const i=new ks,r=[];for(let t=0;t<3;t++){const e=oT[t],i=oT[(t+1)%3];aT.set(0,0,0);for(let t=0;t.1&&(uT.z>0&&hT.multiplyScalar(-1),l.setXYZ(s,...hT))}return o}(this.ellipsoidRegion);this.geometry.dispose(),this.geometry=new Ru(t,80)}dispose(){this.geometry.dispose(),this.material.dispose()}}const pT=Symbol("ORIGINAL_MATERIAL"),fT=Symbol("HAS_RANDOM_COLOR"),mT=Symbol("HAS_RANDOM_NODE_COLOR"),gT=Symbol("LOAD_TIME"),AT=new cr,vT=()=>{},yT={};function _T(t){if(!yT[t]){const e=Math.random(),n=.5+.5*Math.random(),i=.375+.25*Math.random();yT[t]=(new hs).setHSL(e,n,i)}return yT[t]}const xT=0,wT=1,CT=2,ET=3,MT=4,bT=5,ST=6,IT=7,TT=8,BT=9,RT=10;class DT{constructor(t){t={displayBoxBounds:!1,displaySphereBounds:!1,displayRegionBounds:!1,colorMode:xT,maxDebugDepth:-1,maxDebugDistance:-1,maxDebugError:-1,customColorCallback:null,...t},this.name="DEBUG_TILES_PLUGIN",this.tiles=null,this.extremeDebugDepth=-1,this.extremeDebugError=-1,this.boxGroup=null,this.sphereGroup=null,this.regionGroup=null,this.displayBoxBounds=t.displayBoxBounds,this.displaySphereBounds=t.displaySphereBounds,this.displayRegionBounds=t.displayRegionBounds,this.colorMode=t.colorMode,this.maxDebugDepth=t.maxDebugDepth,this.maxDebugDistance=t.maxDebugDistance,this.maxDebugError=t.maxDebugError,this.customColorCallback=t.customColorCallback,this.getDebugColor=(t,e)=>{e.setRGB(t,t,t)}}init(t){this.tiles=t;const e=t.group;this.boxGroup=new nc,this.boxGroup.name="DebugTilesRenderer.boxGroup",e.add(this.boxGroup),this.boxGroup.updateMatrixWorld(),this.sphereGroup=new nc,this.sphereGroup.name="DebugTilesRenderer.sphereGroup",e.add(this.sphereGroup),this.sphereGroup.updateMatrixWorld(),this.regionGroup=new nc,this.regionGroup.name="DebugTilesRenderer.regionGroup",e.add(this.regionGroup),this.regionGroup.updateMatrixWorld(),this._onLoadTileSetCB=()=>{this._initExtremes()},this._onLoadModelCB=({scene:t,tile:e})=>{this._onLoadModel(t,e)},this._onDisposeModelCB=({tile:t})=>{this._onDisposeModel(t)},this._onUpdateAfterCB=()=>{this._onUpdateAfter()},this._onTileVisibilityChangeCB=({scene:t,tile:e,visible:n})=>{this._onTileVisibilityChange(e,n)},t.addEventListener("load-tile-set",this._onLoadTileSetCB),t.addEventListener("load-model",this._onLoadModelCB),t.addEventListener("dispose-model",this._onDisposeModelCB),t.addEventListener("update-after",this._onUpdateAfterCB),t.addEventListener("tile-visibility-change",this._onTileVisibilityChangeCB),t.traverse((t=>{t.cached.scene&&this._onLoadModel(t.cached.scene,t)})),t.visibleTiles.forEach((t=>{this._onTileVisibilityChange(t,!0)}))}getTileInformationFromActiveObject(t){let e=null;return this.tiles.activeTiles.forEach((n=>{if(e)return!0;const i=n.cached.scene;i&&i.traverse((i=>{i===t&&(e=n)}))})),e?{distanceToCamera:e.__distanceFromCamera,geometricError:e.geometricError,screenSpaceError:e.__error,depth:e.__depth,isLeaf:e.__isLeaf}:null}_initExtremes(){let t=-1;this.tiles.traverse((e=>{t=Math.max(t,e.__depth)}));let e=-1;this.tiles.traverse((t=>{e=Math.max(e,t.geometricError)})),this.extremeDebugDepth=t,this.extremeDebugError=e}_onUpdateAfter(){const t=this.tiles;if(!t.root)return;this.boxGroup.visible=this.displayBoxBounds,this.sphereGroup.visible=this.displaySphereBounds,this.regionGroup.visible=this.displayRegionBounds;let e=-1;e=-1===this.maxDebugDepth?this.extremeDebugDepth:this.maxDebugDepth;let n=-1;n=-1===this.maxDebugError?this.extremeDebugError:this.maxDebugError;let i=-1;-1===this.maxDebugDistance?(t.getBoundingSphere(AT),i=AT.radius):i=this.maxDebugDistance;const r=this.errorTarget,s=this.colorMode,a=t.visibleTiles;let o;s===RT&&(o=Array.from(a).sort(((t,e)=>t[gT]-e[gT]))),a.forEach((t=>{const a=t.cached.scene;let l,c,h;s===IT&&(l=Math.random(),c=.5+.5*Math.random(),h=.375+.25*Math.random()),a.traverse((a=>{s===TT&&(l=Math.random(),c=.5+.5*Math.random(),h=.375+.25*Math.random());const u=a.material;if(u){const d=a[pT];if(s===xT&&u!==d)a.material.dispose(),a.material=a[pT];else if(s!==xT&&u===d)if(a.isPoints){const t=new kh;t.size=d.size,t.sizeAttenuation=d.sizeAttenuation,a.material=t}else a.material=new wd,a.material.flatShading=!0;switch(s!==IT&&delete a.material[fT],s!==TT&&delete a.material[mT],s){case MT:{const n=t.__depth/e;this.getDebugColor(n,a.material.color);break}case bT:{const n=t.__depthFromRenderedParent/e;this.getDebugColor(n,a.material.color);break}case wT:{const e=t.__error/r;e>1?a.material.color.setRGB(1,0,0):this.getDebugColor(e,a.material.color);break}case CT:{const e=Math.min(t.geometricError/n,1);this.getDebugColor(e,a.material.color);break}case ET:{const e=Math.min(t.__distanceFromCamera/i,1);this.getDebugColor(e,a.material.color);break}case ST:t.children&&0!==t.children.length?this.getDebugColor(0,a.material.color):this.getDebugColor(1,a.material.color);break;case TT:a.material[mT]||(a.material.color.setHSL(l,c,h),a.material[mT]=!0);break;case IT:a.material[fT]||(a.material.color.setHSL(l,c,h),a.material[fT]=!0);break;case BT:this.customColorCallback?this.customColorCallback(t,a):console.warn("DebugTilesRenderer: customColorCallback not defined");break;case RT:{const e=o.indexOf(t);this.getDebugColor(e/(o.length-1),a.material.color);break}}}}))}))}_onTileVisibilityChange(t,e){const n=t.cached,i=this.sphereGroup,r=this.boxGroup,s=this.regionGroup,a=n.boxHelperGroup,o=n.sphereHelper,l=n.regionHelper;e?(a&&(r.add(a),a.updateMatrixWorld(!0)),o&&(i.add(o),o.updateMatrixWorld(!0)),l&&(s.add(l),l.updateMatrixWorld(!0))):(a&&r.remove(a),o&&i.remove(o),l&&s.remove(l))}_onLoadModel(t,e){e[gT]=performance.now();const n=this.tiles,i=e.cached,{sphere:r,obb:s,region:a}=i.boundingVolume;if(s){const t=new nc;t.name="DebugTilesRenderer.boxHelperGroup",t.matrix.copy(s.transform),t.matrixAutoUpdate=!1;const r=new rm(s.box,_T(e.__depth));r.raycast=vT,t.add(r),i.boxHelperGroup=t,n.visibleTiles.has(e)&&this.displayBoxBounds&&(this.boxGroup.add(t),t.updateMatrixWorld(!0))}if(r){const t=new lT(r,_T(e.__depth));t.raycast=vT,i.sphereHelper=t,n.visibleTiles.has(e)&&this.displaySphereBounds&&(this.sphereGroup.add(t),t.updateMatrixWorld(!0))}if(a){const t=new dT(a,_T(e.__depth));t.raycast=vT;const r=new cr;a.getBoundingSphere(r),t.position.copy(r.center),r.center.multiplyScalar(-1),t.geometry.translate(...r.center),i.regionHelper=t,n.visibleTiles.has(e)&&this.displayRegionBounds&&(this.regionGroup.add(t),t.updateMatrixWorld(!0))}t.traverse((t=>{const e=t.material;e&&(t[pT]=e)}))}_onDisposeModel(t){const e=t.cached;e.boxHelperGroup&&(e.boxHelperGroup.children[0].geometry.dispose(),delete e.boxHelperGroup),e.sphereHelper&&(e.sphereHelper.geometry.dispose(),delete e.sphereHelper),e.regionHelper&&(e.regionHelper.geometry.dispose(),delete e.regionHelper)}dispose(){const t=this.tiles;t.removeEventListener("load-tile-set",this._onLoadTileSetCB),t.removeEventListener("load-model",this._onLoadModelCB),t.removeEventListener("dispose-model",this._onDisposeModelCB),t.removeEventListener("update-after",this._onUpdateAfterCB),this.colorMode=xT,this._onUpdateAfter(),t.traverse((t=>{this._onDisposeModel(t)})),this.boxGroup.removeFromParent(),this.sphereGroup.removeFromParent(),this.regionGroup.removeFromParent()}}class PT extends DT{constructor(...t){super(...t),console.warn('DebugTilesPlugin: Plugins should now be imported from "3d-tiles-renderer/plugins" path.')}}const LT=Symbol("DEBUG_PLUGIN");class UT extends sT{constructor(...t){super(...t),console.warn('DebugTilesRenderer: "DebugTilesRenderer" has been deprecated in favor of "DebugTilesPlugin".'),this[LT]=new PT,this.registerPlugin(this[LT])}}["displayBoxBounds","displaySphereBounds","displayRegionBounds","colorMode","customColorCallback","boxGroup","sphereGroup","regionGroup","maxDebugDepth","maxDebugDistance","maxDebugError","getDebugColor","extremeDebugDepth","extremeDebugError"].forEach((t=>{Object.defineProperty(UT.prototype,t,{get(){return this[LT][t]},set(e){this[LT][t]=e}})}));class NT{constructor(t,e,n,i){NT.prototype.isMatrix2=!0,this.elements=[1,0,0,1],void 0!==t&&this.set(t,e,n,i)}identity(){return this.set(1,0,0,1),this}fromArray(t,e=0){for(let n=0;n<4;n++)this.elements[n]=t[n+e];return this}set(t,e,n,i){const r=this.elements;return r[0]=t,r[1]=n,r[2]=e,r[3]=i,this}}function FT(t,e,n){return t&&e in t?t[e]:n}function OT(t){return"BOOLEAN"!==t&&"STRING"!==t&&"ENUM"!==t}function kT(t){return/^VEC/.test(t)}function QT(t){return/^MATRIX/.test(t)}function zT(t,e,n,i=null){return QT(n)||kT(n)?i.fromArray(t,e):t[e]}function GT(t){const{type:e,componentType:n}=t;switch(e){case"SCALAR":return"INT64"===n?0n:0;case"VEC2":return new ci;case"VEC3":return new Gi;case"VEC4":return new Li;case"MAT2":return new NT;case"MAT3":return new hi;case"MAT4":return new vr;case"BOOLEAN":return!1;case"STRING":return"";case"ENUM":return 0}}function HT(t,e){if(null==e)return!1;switch(t){case"SCALAR":case"ENUM":return"number"==typeof e||"bigint"==typeof e;case"VEC2":return e.isVector2;case"VEC3":return e.isVector3;case"VEC4":return e.isVector4;case"MAT2":return e.isMatrix2;case"MAT3":return e.isMatrix3;case"MAT4":return e.isMatrix4;case"BOOLEAN":return"boolean"==typeof e;case"STRING":return"string"==typeof e}throw new Error("ClassProperty: invalid type.")}function VT(t,e=null){switch(t){case"INT8":return Int8Array;case"INT16":return Int16Array;case"INT32":return Int32Array;case"INT64":return BigInt64Array;case"UINT8":return Uint8Array;case"UINT16":return Uint16Array;case"UINT32":return Uint32Array;case"UINT64":return BigUint64Array;case"FLOAT32":return Float32Array;case"FLOAT64":return Float64Array}switch(e){case"BOOLEAN":case"STRING":return Uint8Array}throw new Error("ClassProperty: invalid type.")}function WT(t,e=null){const n=t.default,i=t.type;if(e=e||GT(t),null===n){switch(i){case"SCALAR":return 0;case"VEC2":return e.set(0,0);case"VEC3":return e.set(0,0,0);case"VEC4":return e.set(0,0,0,0);case"MAT2":case"MAT3":case"MAT4":return e.identity();case"BOOLEAN":return!1;case"STRING":case"ENUM":return""}throw new Error("ClassProperty: invalid type.")}if(QT(i))e.fromArray(n);else{if(!kT(i))return n;e.fromArray(n)}}function jT(t,e,n=null){if(t.array){Array.isArray(e)||(e=new Array(t.count||0)),e.length=null!==n?n:t.count;for(let n=0,i=e.length;ne.value===t));return null===n?"":n.name}}adjustValueScaleOffset(t){return OT(this.type)?function(t,e){const{type:n,componentType:i,scale:r,offset:s,normalized:a}=t;if(Array.isArray(e))for(let t=0,n=e.length;t=this.count)throw new Error("PropertyAttributeAccessor: Requested index is outside the range of the buffer.");const r=this.properties[t],s=r.type;if(!r)throw new Error("PropertyAttributeAccessor: Requested class property does not exist.");if(!this.definition.properties[t])return r.resolveDefault(i);i=r.shapeToProperty(i);const a=n.getAttribute(r.attribute.toLowerCase());if(QT(s)){const t=i.elements;for(let n=0,i=t.length;n>e&1)}return i}getPropertyValue(t,e,n=null){if(e>=this.count)throw new Error("PropertyTableAccessor: Requested index is outside the range of the table.");const i=this.properties[t];if(!i)throw new Error("PropertyTableAccessor: Requested property does not exist.");if(!this.definition.properties[t])return i.resolveDefault(n);const r=i.array,s=this.data,a=i.getArrayLengthFromId(s,e);if(n=i.shapeToProperty(n,a),r)for(let i=0,r=n.length;i=165,eB=parseInt(p)>=166,nB=new Bf,iB=new Li,rB=new ci,sB=new class{constructor(){this._renderer=new uc,this._target=new Ni(1,1),this._texTarget=new Ni,this._quad=new vm(new ra({blending:D,blendDst:O,blendSrc:k,uniforms:{map:{value:null},pixel:{value:new ci}},vertexShader:"\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t\t\t}\n\t\t\t",fragmentShader:"\n\t\t\t\tuniform sampler2D map;\n\t\t\t\tuniform ivec2 pixel;\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tgl_FragColor = texelFetch( map, pixel, 0 );\n\n\t\t\t\t}\n\t\t\t"}))}increaseSizeTo(t){this._target.setSize(Math.max(this._target.width,t),1)}readDataAsync(t){const{_renderer:e,_target:n}=this;return tB?e.readRenderTargetPixelsAsync(n,0,0,t.length/4,1,t):Promise.resolve().then((()=>this.readData(t)))}readData(t){const{_renderer:e,_target:n}=this;e.readRenderTargetPixels(n,0,0,t.length/4,1,t)}renderPixelToTarget(t,e,n){const{_quad:i,_renderer:r,_target:s,_texTarget:a}=this;if(eB)nB.min.copy(e),nB.max.copy(e),nB.max.x+=1,nB.max.y+=1,r.initRenderTarget(s),r.copyTextureToTexture(t,s.texture,nB,n,0);else{const o=r.autoClear,l=r.getRenderTarget(),c=r.getScissorTest();r.getScissor(iB),a.setSize(t.image.width,t.image.height),r.setRenderTarget(a),rB.set(0,0),tB?r.copyTextureToTexture(t,a.texture,null,rB):r.copyTextureToTexture(rB,t,a.texture),i.material.uniforms.map.value=a.texture,i.material.uniforms.pixel.value.copy(e),r.setRenderTarget(s),r.setScissorTest(!0),r.setScissor(n.x,n.y,1,1),r.autoClear=!1,i.render(r),r.setScissorTest(c),r.setScissor(iB),r.setRenderTarget(l),r.autoClear=o,a.dispose()}}},aB=new ci,oB=new ci,lB=new ci;function cB(t,e,n=new Array(3)){let i=3*e,r=3*e+1,s=3*e+2;return t.index&&(i=t.index.getX(i),r=t.index.getX(r),s=t.index.getX(s)),n[0]=i,n[1]=r,n[2]=s,n}function hB(t,e,n,i,r){const[s,a,o]=i,l=function(t,e){return 0===e?t.getAttribute("uv"):t.getAttribute(`uv${e}`)}(t,e);aB.fromBufferAttribute(l,s),oB.fromBufferAttribute(l,a),lB.fromBufferAttribute(l,o),r.set(0,0,0).addScaledVector(aB,n.x).addScaledVector(oB,n.y).addScaledVector(lB,n.z)}function uB(t,e,n,i){const r=t.x-Math.floor(t.x),s=t.y-Math.floor(t.y),a=Math.floor(r*e%e),o=Math.floor(s*n%n);return i.set(a,o),i}const dB=new ci,pB=new ci,fB=new ci;class mB extends XT{constructor(t,e,n=null){super(t,e,n),this.channels=FT(n,"channels",[0]),this.index=FT(n,"index",null),this.texCoord=FT(n,"texCoord",null),this.valueLength=parseInt(this.type.replace(/[^0-9]/g,""))||1}readDataFromBuffer(t,e,n=null){const i=this.type;if("BOOLEAN"===i||"STRING"===i)throw new Error("PropertyTextureAccessor: BOOLEAN and STRING types not supported.");return zT(t,e*this.valueLength,i,n)}}class gB extends YT{constructor(...t){super(...t),this.isPropertyTextureAccessor=!0,this._asyncRead=!1,this._initProperties(mB)}getData(t,e,n,i={}){const r=this.properties;qT(r,i);const s=Object.keys(r),a=s.map((t=>i[t]));return this.getPropertyValuesAtTexel(s,t,e,n,a),s.forEach(((t,e)=>i[t]=a[e])),i}async getDataAsync(t,e,n,i={}){const r=this.properties;qT(r,i);const s=Object.keys(r),a=s.map((t=>i[t]));return await this.getPropertyValuesAtTexelAsync(s,t,e,n,a),s.forEach(((t,e)=>i[t]=a[e])),i}getPropertyValuesAtTexelAsync(...t){this._asyncRead=!0;const e=this.getPropertyValuesAtTexel(...t);return this._asyncRead=!1,e}getPropertyValuesAtTexel(t,e,n,i,r=[]){for(;r.length(h.call(this),r))):(sB.readData(c),h.call(this),r);function h(){for(let e=0,n=t.length;ec[4*e+t])),u=new(VT(i.componentType,s))(l);if(new Uint8Array(u.buffer).set(h),i.array){const t=r[e];for(let e=0,n=t.length;e{t&&(t.dispose(),t.image instanceof ImageBitmap&&t.image.close())}))}}class AB{constructor(t,e,n,i=null,r=null){const{schema:s,propertyTables:a=[],propertyTextures:o=[],propertyAttributes:l=[]}=t,{enums:c,classes:h}=s,u=a.map((t=>new $T(t,h,c,n)));let d=[],p=[];i&&(i.propertyTextures&&(d=i.propertyTextures.map((t=>new gB(o[t],h,c,e)))),i.propertyAttributes&&(p=i.propertyAttributes.map((t=>new KT(l[t],h,c))))),this.schema=s,this.tableAccessors=u,this.textureAccessors=d,this.attributeAccessors=p,this.object=r,this.textures=e,this.nodeMetadata=i}getPropertyTableData(t,e,n=null){if(Array.isArray(t)&&Array.isArray(e)){n=n||[];const i=Math.min(t.length,e.length);n.length=i;for(let r=0;re))),Array.isArray(t))return t.map((t=>{const e=this.tableAccessors[t];return{name:e.name,className:e.definition.class}}));{const e=this.tableAccessors[t];return{name:e.name,className:e.definition.class}}}getPropertyTextureData(t,e,n=[]){const i=this.textureAccessors;n.length=i.length;for(let r=0;r{n[s]=t}));r.push(a)}return await Promise.all(r),n}getPropertyTextureInfo(){return this.textureAccessors}getPropertyAttributeData(t,e=[]){const n=this.attributeAccessors;e.length=n.length;for(let i=0;i({name:t.name,className:t.definition.class})))}dispose(){this.textureAccessors.forEach((t=>t.dispose())),this.tableAccessors.forEach((t=>t.dispose())),this.attributeAccessors.forEach((t=>t.dispose()))}}const vB="EXT_structural_metadata";function yB(t,e=[]){const n=t.json.textures?.length||0,i=new Array(n).fill(null);return e.forEach((({properties:e})=>{for(const n in e){const{index:r}=e[n];null===i[r]&&(i[r]=t.loadTexture(r))}})),Promise.all(i)}function _B(t,e=[]){const n=t.json.bufferViews?.length||0,i=new Array(n).fill(null);return e.forEach((({properties:e})=>{for(const n in e){const{values:r,arrayOffsets:s,stringOffsets:a}=e[n];null===i[r]&&(i[r]=t.loadBufferView(r)),null===i[s]&&(i[s]=t.loadBufferView(s)),null===i[a]&&(i[a]=t.loadBufferView(a))}})),Promise.all(i)}class xB{constructor(t){this.parser=t,this.name=vB}async afterRoot({scene:t,parser:e}){const n=e.json.extensionsUsed;if(!n||!n.includes(vB))return;let i=null,r=e.json.extensions[vB];if(r.schemaUri){const{manager:t,path:n,requestHeader:s,crossOrigin:a}=e.options,o=new URL(r.schemaUri,n).toString(),l=new np(t);l.setCrossOrigin(a),l.setResponseType("json"),l.setRequestHeader(s),i=l.loadAsync(o).then((t=>{r={...r,schema:t}}))}const[s,a]=await Promise.all([yB(e,r.propertyTextures),_B(e,r.propertyTables),i]),o=new AB(r,s,a);t.userData.structuralMetadata=o,t.traverse((t=>{if(e.associations.has(t)){const{meshes:n,primitives:i}=e.associations.get(t),l=e.json.meshes[n].primitives[i];if(l&&l.extensions&&l.extensions[vB]){const e=l.extensions[vB];t.userData.structuralMetadata=new AB(r,s,a,e,t)}else t.userData.structuralMetadata=o}}))}}class wB extends xB{constructor(...t){super(...t),console.warn('GLTFStructuralMetadataExtension: Plugins should now be imported from "3d-tiles-renderer/plugins" path.')}}const CB=new ci,EB=new ci,MB=new ci;class bB{constructor(t,e,n){this.geometry=t,this.textures=e,this.data=n,this._asyncRead=!1,this.featureIds=n.featureIds.map((t=>{const{texture:e,...n}=t,i={label:null,propertyTable:null,nullFeatureId:null,...n};return e&&(i.texture={texCoord:0,channels:[0],...e}),i}))}getTextures(){return this.textures}getFeatureInfo(){return this.featureIds}getFeaturesAsync(...t){this._asyncRead=!0;const e=this.getFeatures(...t);return this._asyncRead=!1,e}getFeatures(t,e){const{geometry:n,textures:i,featureIds:r}=this,s=new Array(r.length).fill(null),a=r.length;sB.increaseSizeTo(a);const o=cB(n,t),l=o[function(t){return t.x>t.y&&t.x>t.z?0:t.y>t.z?1:2}(e)];for(let t=0,a=r.length;t(h(),s))):(sB.readData(c),h(),s);function h(){const t=new Uint32Array(1);for(let e=0,n=r.length;ec[4*e+t]));new Uint8Array(t.buffer).set(a);const o=t[0];o!==i&&(s[e]=o)}}}}dispose(){this.textures.forEach((t=>{t&&(t.dispose(),t.image instanceof ImageBitmap&&t.image.close())}))}}const SB="EXT_mesh_features";function IB(t,e,n){t.traverse((t=>{if(e.associations.has(t)){const{meshes:i,primitives:r}=e.associations.get(t),s=e.json.meshes[i].primitives[r];s&&s.extensions&&s.extensions[SB]&&n(t,s.extensions[SB])}}))}class TB{constructor(t){this.parser=t,this.name=SB}async afterRoot({scene:t,parser:e}){const n=e.json.extensionsUsed;if(!n||!n.includes(SB))return;const i=e.json.textures?.length||0,r=new Array(i).fill(null);IB(t,e,((t,{featureIds:n})=>{n.forEach((t=>{if(t.texture&&null===r[t.texture.index]){const n=t.texture.index;r[n]=e.loadTexture(n)}}))}));const s=await Promise.all(r);IB(t,e,((t,e)=>{t.userData.meshFeatures=new bB(t.geometry,s,e)}))}}class BB extends TB{constructor(...t){super(...t),console.warn('GLTFMeshFeaturesExtension: Plugins should now be imported from "3d-tiles-renderer/plugins" path.')}}class RB{constructor(){this.creditsCount={}}_adjustAttributions(t,e){const n=this.creditsCount,i=t.split(/;/g);for(let t=0,r=i.length;t{const n=t[1];return e[1]-n})).map((t=>t[0])).join("; ")}}function DB(t){let e=null;return Jb(t,(t=>{if(t.content&&t.content.uri){const[,n]=t.content.uri.split("?");return e=new URLSearchParams(n).get("session"),!0}return!1})),e}class PB{constructor({apiToken:t,autoRefreshToken:e=!1,logoUrl:n=null,useRecommendedSettings:i=!0}){this.name="GOOGLE_CLOUD_AUTH_PLUGIN",this.apiToken=t,this.autoRefreshToken=e,this.useRecommendedSettings=i,this.logoUrl=n,this.sessionToken=null,this.tiles=null,this._onLoadCallback=null,this._visibilityChangeCallback=null,this._tokenRefreshPromise=null,this._attributionsManager=new RB,this._logoAttribution={value:"",type:"image",collapsible:!1},this._attribution={value:"",type:"string",collapsible:!0}}init(t){null!=t&&(null==t.rootURL&&(t.rootURL="https://tile.googleapis.com/v1/3dtiles/root.json"),this.useRecommendedSettings&&(t.parseQueue.maxJobs=10,t.downloadQueue.maxJobs=30,t.errorTarget=40),this.tiles=t,this._onLoadCallback=({tileSet:e})=>{this.sessionToken=DB(e.root),t.removeEventListener("load-tile-set",this._onLoadCallback)},this._visibilityChangeCallback=({tile:t,visible:e})=>{const n=t.cached.metadata.asset.copyright||"";e?this._attributionsManager.addAttributions(n):this._attributionsManager.removeAttributions(n)},t.addEventListener("load-tile-set",this._onLoadCallback),t.addEventListener("tile-visibility-change",this._visibilityChangeCallback))}getAttributions(t){this.tiles.visibleTiles.size>0&&(this.logoUrl&&(this._logoAttribution.value=this.logoUrl,t.push(this._logoAttribution)),this._attribution.value=this._attributionsManager.toString(),t.push(this._attribution))}preprocessURL(t){return t=new URL(t),/^http/.test(t.protocol)&&(t.searchParams.append("key",this.apiToken),null!==this.sessionToken&&t.searchParams.append("session",this.sessionToken)),t.toString()}dispose(){const{tiles:t}=this;t.removeEventListener("load-tile-set",this._onLoadCallback),t.removeEventListener("tile-visibility-change",this._visibilityChangeCallback)}async fetchData(t,e){null!==this._tokenRefreshPromise&&(await this._tokenRefreshPromise,t=this.preprocessURL(t));const n=await fetch(t,e);return n.status>=400&&n.status<=499&&this.autoRefreshToken?(await this._refreshToken(e),fetch(this.preprocessURL(t),e)):n}_refreshToken(t){if(null===this._tokenRefreshPromise){const e=new URL(this.tiles.rootURL);e.searchParams.append("key",this.apiToken),this._tokenRefreshPromise=fetch(e,t).then((t=>t.json())).then((t=>{this.sessionToken=DB(t.root),this._tokenRefreshPromise=null}))}return this._tokenRefreshPromise}}class LB extends PB{constructor(...t){super(...t),console.warn('GoogleCloudAuthPlugin: Plugins should now be imported from "3d-tiles-renderer/plugins" path.')}}const UB=t=>class extends t{constructor(t="https://tile.googleapis.com/v1/3dtiles/root.json"){super(t),console.warn('GooglePhotorealisticTilesRenderer: Class has been deprecated. Use "TilesRenderer" with "GoogleCloudAuthPlugin" instead.'),this.parseQueue.maxJobs=10,this.downloadQueue.maxJobs=30,this.errorTarget=40}getCreditsString(){return console.warn('GooglePhotorealisticTilesRenderer: "getCreditsString" function is deprecated. Use "getAttributions", instead.'),this.getAttributions()[0].value}},NB=t=>class extends(UB(t)){constructor(t,e){super(e),this.registerPlugin(new LB({apiToken:t})),console.warn('GoogleTilesRenderer: Class has been deprecated. Use "GoogleCloudAuthPlugin" instead.')}},FB=NB(sT),OB=NB(UT),kB=UB(sT),QB=UB(UT);class zB{constructor({apiToken:t,assetId:e=null,autoRefreshToken:n=!1}){this.name="CESIUM_ION_AUTH_PLUGIN",this.apiToken=t,this.assetId=e,this.autoRefreshToken=n,this.tiles=null,this.endpointURL=null,this._bearerToken=null,this._tileSetVersion=-1,this._tokenRefreshPromise=null,this._attributions=[]}init(t){null!==this.assetId&&(t.rootURL=`https://api.cesium.com/v1/assets/${this.assetId}/endpoint`),this.tiles=t,this.endpointURL=t.rootURL}loadRootTileSet(){return this._refreshToken().then((()=>this.tiles.loadRootTileSet()))}preprocessURL(t){return t=new URL(t),/^http/.test(t.protocol)&&-1!=this._tileSetVersion&&t.searchParams.append("v",this._tileSetVersion),t.toString()}fetchData(t,e){return null!==this.tiles.getPluginByName("GOOGLE_CLOUD_AUTH_PLUGIN")?null:Promise.resolve().then((async()=>{null!==this._tokenRefreshPromise&&(await this._tokenRefreshPromise,t=this.preprocessURL(t));const n=await fetch(t,e);return n.status>=400&&n.status<=499&&this.autoRefreshToken?(await this._refreshToken(e),fetch(this.preprocessURL(t),e)):n}))}getAttributions(t){this.tiles.visibleTiles.size>0&&t.push(...this._attributions)}_refreshToken(t){if(null===this._tokenRefreshPromise){const e=new URL(this.endpointURL);e.searchParams.append("access_token",this.apiToken),this._tokenRefreshPromise=fetch(e,t).then((t=>{if(!t.ok)throw new Error(`CesiumIonAuthPlugin: Failed to load data with error code ${t.status}`);return t.json()})).then((t=>{const n=this.tiles;if("externalType"in t){const e=new URL(t.options.url);n.rootURL=t.options.url,n.registerPlugin(new PB({apiToken:e.searchParams.get("key")}))}else{if(n.rootURL=t.url,n.fetchOptions.headers=n.fetchOptions.headers||{},n.fetchOptions.headers.Authorization=`Bearer ${t.accessToken}`,e.searchParams.has("v")&&-1===this._tileSetVersion){const e=new URL(t.url);this._tileSetVersion=e.searchParams.get("v")}this._bearerToken=t.accessToken,t.attributions&&(this._attributions=t.attributions.map((t=>({value:t.html,type:"html",collapsible:t.collapsible}))))}return this._tokenRefreshPromise=null,t}))}return this._tokenRefreshPromise}}class GB extends zB{constructor(...t){super(...t),console.warn('CesiumIonAuthPlugin: Plugins should now be imported from "3d-tiles-renderer/plugins" path.')}}const HB=t=>class extends t{constructor(t,e){super(),this.registerPlugin(new GB({apiToken:e,assetId:t})),console.warn('CesiumIonTilesRenderer: Class has been deprecated. Use "TilesRenderer" with "CesiumIonAuthPlugin" instead.')}},VB=HB(sT),WB=HB(UT);class jB extends Ks{constructor(){super(new Ca(0,0),new qB),this.renderOrder=1/0}onBeforeRender(t){const e=this.material.uniforms;t.getSize(e.resolution.value)}updateMatrixWorld(){this.matrixWorld.makeTranslation(this.position)}dispose(){this.geometry.dispose(),this.material.dispose()}}class qB extends ra{constructor(){super({depthWrite:!1,depthTest:!1,transparent:!0,uniforms:{resolution:{value:new ci},size:{value:15},thickness:{value:2},opacity:{value:1}},vertexShader:"\n\n\t\t\t\tuniform float pixelRatio;\n\t\t\t\tuniform float size;\n\t\t\t\tuniform float thickness;\n\t\t\t\tuniform vec2 resolution;\n\t\t\t\tvarying vec2 vUv;\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvUv = uv;\n\n\t\t\t\t\tfloat aspect = resolution.x / resolution.y;\n\t\t\t\t\tvec2 offset = uv * 2.0 - vec2( 1.0 );\n\t\t\t\t\toffset.y *= aspect;\n\n\t\t\t\t\tvec4 screenPoint = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t\tscreenPoint.xy += offset * ( size + thickness ) * screenPoint.w / resolution.x;\n\n\t\t\t\t\tgl_Position = screenPoint;\n\n\t\t\t\t}\n\t\t\t",fragmentShader:"\n\n\t\t\t\tuniform float size;\n\t\t\t\tuniform float thickness;\n\t\t\t\tuniform float opacity;\n\n\t\t\t\tvarying vec2 vUv;\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tfloat ht = 0.5 * thickness;\n\t\t\t\t\tfloat planeDim = size + thickness;\n\t\t\t\t\tfloat offset = ( planeDim - ht - 2.0 ) / planeDim;\n\t\t\t\t\tfloat texelThickness = ht / planeDim;\n\n\t\t\t\t\tvec2 vec = vUv * 2.0 - vec2( 1.0 );\n\t\t\t\t\tfloat dist = abs( length( vec ) - offset );\n\t\t\t\t\tfloat fw = fwidth( dist ) * 0.5;\n\t\t\t\t\tfloat a = smoothstep( texelThickness - fw, texelThickness + fw, dist );\n\n\t\t\t\t\tgl_FragColor = vec4( 1, 1, 1, opacity * ( 1.0 - a ) );\n\n\t\t\t\t}\n\t\t\t"})}}const XB=new ci,YB=new ci;class JB{constructor(){this.domElement=null,this.buttons=0,this.pointerType=null,this.pointerOrder=[],this.previousPositions={},this.pointerPositions={},this.startPositions={},this.pointerSetThisFrame={},this.hoverPosition=new ci,this.hoverSet=!1}reset(){this.buttons=0,this.pointerType=null,this.pointerOrder=[],this.previousPositions={},this.pointerPositions={},this.startPositions={},this.pointerSetThisFrame={},this.hoverPosition=new ci,this.hoverSet=!1}updateFrame(){const{previousPositions:t,pointerPositions:e}=this;for(const n in e)t[n].copy(e[n])}setHoverEvent(t){"mouse"!==t.pointerType&&"wheel"!==t.type||(this.getAdjustedPointer(t,this.hoverPosition),this.hoverSet=!0)}getLatestPoint(t){return null!==this.pointerType?(this.getCenterPoint(t),t):this.hoverSet?(t.copy(this.hoverPosition),t):null}getAdjustedPointer(t,e){const n=(this.domElement?this.domElement:t.target).getBoundingClientRect(),i=t.clientX-n.left,r=t.clientY-n.top;e.set(i,r)}addPointer(t){const e=t.pointerId,n=new ci;this.getAdjustedPointer(t,n),this.pointerOrder.push(e),this.pointerPositions[e]=n,this.previousPositions[e]=n.clone(),this.startPositions[e]=n.clone(),1===this.getPointerCount()&&(this.pointerType=t.pointerType,this.buttons=t.buttons)}updatePointer(t){const e=t.pointerId;return e in this.pointerPositions&&(this.getAdjustedPointer(t,this.pointerPositions[e]),!0)}deletePointer(t){const e=t.pointerId,n=this.pointerOrder;n.splice(n.indexOf(e),1),delete this.pointerPositions[e],delete this.previousPositions[e],delete this.startPositions[e],0===this.getPointerCount.length&&(this.buttons=0,this.pointerType=null)}getPointerCount(){return this.pointerOrder.length}getCenterPoint(t,e=this.pointerPositions){const n=this.pointerOrder;if(1===this.getPointerCount()||"mouse"===this.getPointerType()){const i=n[0];return t.copy(e[i]),t}if(2===this.getPointerCount()){const n=this.pointerOrder[0],i=this.pointerOrder[1],r=e[n],s=e[i];return t.addVectors(r,s).multiplyScalar(.5),t}return null}getPreviousCenterPoint(t){return this.getCenterPoint(t,this.previousPositions)}getStartCenterPoint(t){return this.getCenterPoint(t,this.startPositions)}getMoveDistance(){return this.getCenterPoint(XB),this.getPreviousCenterPoint(YB),XB.sub(YB).length()}getTouchPointerDistance(t=this.pointerPositions){if(this.getPointerCount()<=1||"mouse"===this.getPointerType())return 0;const{pointerOrder:e}=this,n=e[0],i=e[1],r=t[n],s=t[i];return r.distanceTo(s)}getPreviousTouchPointerDistance(){return this.getTouchPointerDistance(this.previousPositions)}getStartTouchPointerDistance(){return this.getTouchPointerDistance(this.startPositions)}getPointerType(){return this.pointerType}isPointerTouch(){return"touch"===this.getPointerType()}getPointerButtons(){return this.buttons}isLeftClicked(){return Boolean(1&this.buttons)}isRightClicked(){return Boolean(2&this.buttons)}}const KB=new vr,ZB=new Ar,$B=new Gi;function tR(t,e,n){return n.makeTranslation(-t.x,-t.y,-t.z),KB.makeRotationFromQuaternion(e),n.premultiply(KB),KB.makeTranslation(t.x,t.y,t.z),n.premultiply(KB),n}function eR(t,e,n,i){i.x=(t-n.offsetLeft)/n.clientWidth*2-1,i.y=-(e-n.offsetTop)/n.clientHeight*2+1,i.isVector3&&(i.z=0)}function nR(t,e,n){return e.intersectRay(t,n)?n:(KB.makeScale(...e.radius).invert(),ZB.copy(t).applyMatrix4(KB),$B.set(0,0,0),ZB.closestPointToPoint($B,n).normalize(),KB.makeScale(...e.radius),n.applyMatrix4(KB))}function iR(t,e,n){const{origin:i,direction:r}=t.ray;i.set(e.x,e.y,-1).unproject(n),r.set(e.x,e.y,1).unproject(n).sub(i),t.near=0,t.far=r.length(),t.camera=n,r.normalize()}const rR=.05,sR=.025,aR=new vr,oR=new Gi,lR=new Gi,cR=new Gi,hR=new Gi,uR=new Gi,dR=new zi,pR=new Aa,fR=new Gi,mR=new Gi,gR=new Gi,AR=new zi,vR=new ci,yR=new ci,_R=new ci,xR=new ci,wR=new ci,CR=new ci,ER={type:"change"},MR={type:"start"},bR={type:"end"};class SR extends Kn{get enabled(){return this._enabled}set enabled(t){t!==this.enabled&&(this._enabled=t,this.resetState(),this.pointerTracker.reset(),this.enabled||(this.dragInertia.set(0,0,0),this.rotationInertia.set(0,0)))}constructor(t=null,e=null,n=null,i=null){super(),this.isEnvironmentControls=!0,this.domElement=null,this.camera=null,this.scene=null,this.tilesRenderer=null,this._enabled=!0,this.cameraRadius=5,this.rotationSpeed=1,this.minAltitude=0,this.maxAltitude=.45*Math.PI,this.minDistance=10,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.zoomSpeed=1,this.adjustHeight=!0,this.enableDamping=!1,this.dampingFactor=.15,this.reorientOnDrag=!0,this.scaleZoomOrientationAtEdges=!1,this.state=0,this.pointerTracker=new JB,this.needsUpdate=!1,this.actionHeightOffset=0,this.pivotPoint=new Gi,this.zoomDirectionSet=!1,this.zoomPointSet=!1,this.zoomDirection=new Gi,this.zoomPoint=new Gi,this.zoomDelta=0,this.rotationInertia=new ci,this.dragInertia=new Gi,this.pivotMesh=new jB,this.pivotMesh.raycast=()=>{},this.pivotMesh.scale.setScalar(.25),this.raycaster=new Cf,this.raycaster.firstHitOnly=!0,this.up=new Gi(0,1,0),this.clock=new Vp,this.fallbackPlane=new Aa(new Gi(0,1,0),0),this.useFallbackPlane=!0,this._detachCallback=null,this._upInitialized=!1,this._lastUsedState=0,this._zoomPointWasSet=!1,this._tilesOnChangeCallback=()=>this.zoomPointSet=!1,n&&this.attach(n),e&&this.setCamera(e),t&&this.setScene(t),i&&this.setTilesRenderer(i)}setScene(t){this.scene=t}setCamera(t){this.camera=t,this._upInitialized=!1,this.zoomDirectionSet=!1,this.zoomPointSet=!1,this.needsUpdate=!0,this.raycaster.camera=t,this.resetState()}setTilesRenderer(t){this.tilesRenderer&&this.tilesRenderer.removeEventListener("tile-visibility-change",this._tilesOnChangeCallback),this.tilesRenderer=t,null!==this.tilesRenderer&&(this.tilesRenderer.addEventListener("tile-visibility-change",this._tilesOnChangeCallback),null===this.scene&&this.setScene(this.tilesRenderer.group))}attach(t){if(this.domElement)throw new Error("EnvironmentControls: Controls already attached to element");this.domElement=t,this.pointerTracker.domElement=t,t.style.touchAction="none";let e=!1;const n=t=>{t.preventDefault()},i=t=>{"Shift"===t.key&&(e=!0)},r=t=>{"Shift"===t.key&&(e=!1)},s=t=>{t.preventDefault();const{camera:n,raycaster:i,domElement:r,up:s,pivotMesh:a,pointerTracker:o}=this;if(o.addPointer(t),this.needsUpdate=!0,o.isPointerTouch())if(a.visible=!1,0===o.getPointerCount())r.setPointerCapture(t.pointerId);else if(o.getPointerCount()>2)return void this.resetState();o.getCenterPoint(yR),eR(yR.x,yR.y,r,yR),iR(i,yR,n);const l=Math.abs(i.ray.direction.dot(s));if(l{t.preventDefault(),this.zoomDirectionSet=!1,this.zoomPointSet=!1,0!==this.state&&(this.needsUpdate=!0);const{pointerTracker:e}=this;e.setHoverEvent(t),e.updatePointer(t)&&(e.isPointerTouch()&&2===e.getPointerCount()&&(a||(a=!0,queueMicrotask((()=>{a=!1,e.getCenterPoint(wR);const t=e.getStartTouchPointerDistance(),n=e.getTouchPointerDistance(),i=n-t;if(0===this.state||4===this.state){e.getCenterPoint(wR),e.getStartCenterPoint(CR);const t=2*window.devicePixelRatio,n=wR.distanceTo(CR);(Math.abs(i)>t||n>t)&&(Math.abs(i)>n?(this.setState(3),this.zoomDirectionSet=!1):this.setState(2))}if(3===this.state){const t=e.getPreviousTouchPointerDistance();this.zoomDelta+=n-t}else 2===this.state&&(this.pivotMesh.visible=this.enabled)})))),this.dispatchEvent(ER))},l=e=>{const{pointerTracker:n}=this;n.deletePointer(e),"touch"===n.getPointerType()&&0===n.getPointerCount()&&t.releasePointerCapture(e.pointerId),this.resetState(),this.needsUpdate=!0},c=t=>{t.preventDefault();const{pointerTracker:e}=this;let n;switch(e.setHoverEvent(t),e.updatePointer(t),this.dispatchEvent(MR),t.deltaMode){case 2:n=100*t.deltaY;break;case 1:n=16*t.deltaY;break;case 0:n=t.deltaY}const i=Math.sign(n),r=Math.log(Math.abs(n)+1);this.zoomDelta-=3*i*r,this.needsUpdate=!0,this._lastUsedState=3,this.dispatchEvent(bR)},h=t=>{const{pointerTracker:n}=this;e=!1,t.buttons!==n.getPointerButtons()&&(n.deletePointer(t),this.resetState())};t.addEventListener("contextmenu",n),t.addEventListener("keydown",i),t.addEventListener("keyup",r),t.addEventListener("pointerdown",s),t.addEventListener("pointermove",o),t.addEventListener("pointerup",l),t.addEventListener("wheel",c,{passive:!1}),t.addEventListener("pointerenter",h),this._detachCallback=()=>{t.removeEventListener("contextmenu",n),t.removeEventListener("keydown",i),t.removeEventListener("keyup",r),t.removeEventListener("pointerdown",s),t.removeEventListener("pointermove",o),t.removeEventListener("pointerup",l),t.removeEventListener("wheel",c),t.removeEventListener("pointerenter",h)}}getUpDirection(t,e){e.copy(this.up)}getCameraUpDirection(t){this.getUpDirection(this.camera.position,t)}getPivotPoint(t){return 3===this._lastUsedState?this._zoomPointWasSet?(t.copy(this.zoomPoint),t):null:2===this._lastUsedState||1===this._lastUsedState?(t.copy(this.pivotPoint),t):null}detach(){this.domElement=null,this._detachCallback&&(this._detachCallback(),this._detachCallback=null,this.pointerTracker.reset())}resetState(){0!==this.state&&this.dispatchEvent(bR),this.state=0,this.pivotMesh.removeFromParent(),this.pivotMesh.visible=this.enabled,this.actionHeightOffset=0}setState(t=this.state,e=!0){this.state!==t&&(0===this.state&&e&&this.dispatchEvent(MR),this.pivotMesh.visible=this.enabled,this.dragInertia.set(0,0,0),this.rotationInertia.set(0,0),this.state=t,0!==t&&4!==t&&(this._lastUsedState=t))}update(t=Math.min(this.clock.getDelta(),.064)){if(!this.enabled||!this.camera||0===t)return;const{camera:e,cameraRadius:n,pivotPoint:i,up:r,state:s,adjustHeight:a}=this;e.updateMatrixWorld(),this.getCameraUpDirection(fR),this._upInitialized||(this._upInitialized=!0,this.up.copy(fR));const o=this._inertiaNeedsUpdate();if(this.needsUpdate||o){const e=this.zoomDelta;3!==s&&0===e||(this._updateZoom(),this.rotationInertia.set(0,0),this.dragInertia.set(0,0,0)),this._updatePosition(t),this._updateRotation(t),(0!==s||0!==e||o)&&this.dispatchEvent(ER),this.needsUpdate=!1}o&&this._updateInertiaDamping(t);const l=e.isOrthographicCamera?null:a&&this._getPointBelowCamera()||null,c=e.isOrthographicCamera?i:l&&l.point||null;if(this.getCameraUpDirection(fR),this._setFrame(fR,c),(1===this.state||2===this.state)&&0!==this.actionHeightOffset){const{actionHeightOffset:t}=this;e.position.addScaledVector(r,-t),i.addScaledVector(r,-t),l&&(l.distance-=t)}if(this.actionHeightOffset=0,l){const t=l.distance;if(t0?1/Math.abs(t):t;n.zoom=Math.max(o,Math.min(l,n.zoom*e*c)),n.updateProjectionMatrix(),eR(yR.x,yR.y,a,gR),gR.unproject(n),n.position.sub(gR).add(mR),n.updateMatrixWorld()}else{const t=Math.pow(.95,Math.abs(.05*h)),e=h>0?1/Math.abs(t):t;n.zoom=Math.max(o,Math.min(l,n.zoom*e*c)),n.updateProjectionMatrix()}else{this._updateZoomDirection();const s=lR.copy(e);if(this.zoomPointSet||this._updateZoomPoint()){const s=t.distanceTo(n.position);if(h<0){const t=Math.min(0,s-r);h=h*s*c*.0025,h=Math.max(h,t)}else{const t=Math.max(0,s-i);h=h*Math.max(s-i,0)*c*.0025,h=Math.min(h,t)}n.position.addScaledVector(e,h),n.updateMatrixWorld()}else{const t=this._getPointBelowCamera();if(t){const e=t.distance;s.set(0,0,-1).transformDirection(n.matrixWorld),n.position.addScaledVector(s,h*e*.01),n.updateMatrixWorld()}}}}_updateZoomDirection(){if(this.zoomDirectionSet)return;const{domElement:t,raycaster:e,camera:n,zoomDirection:i,pointerTracker:r}=this;r.getLatestPoint(yR),eR(yR.x,yR.y,t,mR),iR(e,mR,n),i.copy(e.ray.direction).normalize(),this.zoomDirectionSet=!0}_updateZoomPoint(){const{camera:t,zoomDirectionSet:e,zoomDirection:n,raycaster:i,zoomPoint:r,pointerTracker:s,domElement:a}=this;if(this._zoomPointWasSet=!1,!e)return!1;t.isOrthographicCamera&&s.getLatestPoint(vR)?(eR(vR.x,vR.y,a,vR),iR(i,vR,t)):(i.ray.origin.copy(t.position),i.ray.direction.copy(n),i.near=0,i.far=1/0);const o=this._raycast(i);return!!o&&(r.copy(o.point),this.zoomPointSet=!0,this._zoomPointWasSet=!0,!0)}_getPointBelowCamera(t=this.camera.position,e=this.up){const{raycaster:n}=this;n.ray.direction.copy(e).multiplyScalar(-1),n.ray.origin.copy(t).addScaledVector(e,1e5),n.near=0,n.far=1/0;const i=this._raycast(n);return i&&(i.distance-=1e5),i}_updatePosition(t){const{raycaster:e,camera:n,pivotPoint:i,up:r,pointerTracker:s,domElement:a,state:o,dragInertia:l,enableDamping:c}=this;if(1===o){if(s.getCenterPoint(yR),eR(yR.x,yR.y,a,yR),pR.setFromNormalAndCoplanarPoint(r,i),iR(e,yR,n),Math.abs(e.ray.direction.dot(r))0?(l=Math.min(c-r-.01,l),l=Math.max(0,l)):(l=Math.max(c-s,l),l=Math.min(0,l)),dR.setFromAxisAngle(fR,o),tR(n,dR,aR),i.matrixWorld.premultiply(aR),uR.set(-1,0,0).transformDirection(i.matrixWorld),dR.setFromAxisAngle(uR,l),tR(n,dR,aR),i.matrixWorld.premultiply(aR),i.matrixWorld.decompose(i.position,i.quaternion,lR)}_setFrame(t,e){const{up:n,camera:i,state:r,zoomPoint:s,zoomDirectionSet:a,zoomPointSet:o,reorientOnDrag:l,scaleZoomOrientationAtEdges:c}=this;i.updateMatrixWorld(),dR.setFromUnitVectors(n,t);const h=r;if(a&&(o||this._updateZoomPoint())){if(this.getUpDirection(s,lR),c){let t=Math.max(lR.dot(n)-.6,0)/.4;t=li.mapLinear(t,0,.5,0,1),t=Math.min(t,1),i.isOrthographicCamera&&(t*=.1),dR.slerp(AR,1-t)}tR(s,dR,aR),i.matrixWorld.premultiply(aR),i.matrixWorld.decompose(i.position,i.quaternion,lR),this.zoomDirectionSet=!1,this._updateZoomDirection()}else 1===h&&l&&e&&(tR(e,dR,aR),i.matrixWorld.premultiply(aR),i.matrixWorld.decompose(i.position,i.quaternion,lR));n.copy(t),i.updateMatrixWorld()}_raycast(t){const{scene:e,useFallbackPlane:n,fallbackPlane:i}=this,r=t.intersectObject(e)[0]||null;if(r)return r;if(n){const e=i;if(t.ray.intersectPlane(e,lR))return{point:lR.clone(),distance:t.ray.origin.distanceTo(lR)}}return null}}const IR=new vr,TR=new vr,BR=new Gi,RR=new Gi,DR=new Gi,PR=new Gi,LR=new Gi,UR=new Gi,NR=new Gi,FR=new zi,OR=new Gi,kR=new Gi,QR={},zR=new Ar,GR=new jS,HR=new ci;class VR extends SR{get ellipsoid(){return this.tilesRenderer?this.tilesRenderer.ellipsoid:null}get tilesGroup(){return this.tilesRenderer?this.tilesRenderer.group:null}constructor(t=null,e=null,n=null,i=null){super(t,e,n),this.isGlobeControls=!0,this._dragMode=0,this._rotationMode=0,this.maxZoom=.01,this.useFallbackPlane=!1,this.reorientOnDrag=!1,this.dragQuaternion=new zi,this.setTilesRenderer(i)}setScene(t){null===t&&null!==this.tilesRenderer?super.setScene(this.tilesRenderer.group):super.setScene(t)}getPivotPoint(t){const{camera:e,tilesGroup:n,ellipsoid:i}=this;return PR.set(0,0,-1).transformDirection(e.matrixWorld),IR.copy(n.matrixWorld).invert(),zR.origin.copy(e.position),zR.direction.copy(PR),zR.applyMatrix4(IR),nR(zR,i,RR),RR.applyMatrix4(n.matrixWorld),(null===super.getPivotPoint(t)||t.distanceTo(zR.origin)>RR.distanceTo(zR.origin))&&t.copy(RR),t}getVectorToCenter(t){const{tilesGroup:e,camera:n}=this;return t.setFromMatrixPosition(e.matrixWorld).sub(n.position)}getDistanceToCenter(){return this.getVectorToCenter(RR).length()}getUpDirection(t,e){const{tilesGroup:n,ellipsoid:i}=this;IR.copy(n.matrixWorld).invert(),RR.copy(t).applyMatrix4(IR),i.getPositionToNormal(RR,e),e.transformDirection(n.matrixWorld)}getCameraUpDirection(t){const{tilesGroup:e,ellipsoid:n,camera:i}=this;i.isOrthographicCamera?(this._getVirtualOrthoCameraPosition(RR),IR.copy(e.matrixWorld).invert(),RR.applyMatrix4(IR),n.getPositionToNormal(RR,t),t.transformDirection(e.matrixWorld)):this.getUpDirection(i.position,t)}update(t=Math.min(this.clock.getDelta(),.064)){if(!this.enabled||!this.tilesGroup||!this.camera||0===t)return;const{camera:e,pivotMesh:n}=this;this._isNearControls()?this.scaleZoomOrientationAtEdges=this.zoomDelta<0:(0!==this.state&&1!==this._dragMode&&1!==this._rotationMode&&(n.visible=!1),this.scaleZoomOrientationAtEdges=!1),super.update(t),this.adjustCamera(e)}adjustCamera(t){super.adjustCamera(t);const{tilesGroup:e,ellipsoid:n}=this;if(t.isPerspectiveCamera){const i=RR.setFromMatrixPosition(e.matrixWorld).sub(t.position).length(),r=Math.max(...n.radius),s=.25*r,a=li.clamp((i-r)/s,0,1),o=li.lerp(1,1e3,a);t.near=Math.max(o,i-r-s);const l=IR.copy(e.matrixWorld).invert();BR.copy(t.position).applyMatrix4(l),n.getPositionToCartographic(BR,QR);const c=Math.max(n.getPositionElevation(BR),400),h=n.calculateHorizonDistance(QR.lat,c);t.far=2.5*h+.1,t.updateProjectionMatrix()}else{this._getVirtualOrthoCameraPosition(t.position,t),t.updateMatrixWorld(),IR.copy(t.matrixWorld).invert(),RR.setFromMatrixPosition(e.matrixWorld).applyMatrix4(IR);const i=-RR.z;t.near=i-1.1*Math.max(...n.radius),t.far=i+.1,t.position.addScaledVector(PR,t.near),t.far-=t.near,t.near=0,t.updateProjectionMatrix(),t.updateMatrixWorld()}}resetState(){super.resetState(),this._dragMode=0,this._rotationMode=0}_updatePosition(t){if(1!==this.state){const{enableDamping:e,tilesGroup:n,dragQuaternion:i,dragInertia:r,camera:s}=this;e&&(1!==i.w||0===i.x&&0===i.y&&0===i.z||(i.w=Math.min(i.w,1-1e-9)),DR.setFromMatrixPosition(n.matrixWorld),FR.identity().slerp(i,r.x*t),tR(DR,FR,TR),s.matrixWorld.premultiply(TR),s.matrixWorld.decompose(s.position,s.quaternion,RR))}else{0===this._dragMode&&(this._dragMode=this._isNearControls()?1:-1);const{raycaster:e,camera:n,pivotPoint:i,pointerTracker:r,domElement:s,tilesGroup:a}=this,o=BR,l=UR;r.getCenterPoint(HR),eR(HR.x,HR.y,s,HR),iR(e,HR,n),IR.copy(a.matrixWorld).invert(),e.ray.applyMatrix4(IR);const c=RR.copy(i).applyMatrix4(IR).length();GR.radius.setScalar(c),n.isPerspectiveCamera?GR.intersectRay(e.ray,RR)||function(t,e,n){const i=t.origin.length(),r=Math.acos(e/i);n.copy(t.origin).multiplyScalar(-1).normalize();const s=$B.crossVectors(n,t.direction).normalize();n.multiplyScalar(-1).applyAxisAngle(s,-r).normalize().multiplyScalar(e)}(e.ray,c,RR):nR(e.ray,GR,RR),RR.applyMatrix4(a.matrixWorld),DR.setFromMatrixPosition(a.matrixWorld),o.subVectors(i,DR).normalize(),l.subVectors(RR,DR).normalize(),FR.setFromUnitVectors(l,o),tR(DR,FR,TR),n.matrixWorld.premultiply(TR),n.matrixWorld.decompose(n.position,n.quaternion,RR);const{dragInertia:h,dragQuaternion:u}=this;r.getMoveDistance()/t<2*window.devicePixelRatio?(u.slerp(FR,.5),h.set(1/t,0,0)):(u.copy(FR),h.set(1/t,0,0))}this._alignCameraUp(this.up)}_updateRotation(...t){1===this._rotationMode||this._isNearControls()?(this._rotationMode=1,super._updateRotation(...t)):(this.pivotMesh.visible=!1,this._rotationMode=-1),this._alignCameraUp(this.up)}_updateZoom(){const{zoomDelta:t,ellipsoid:e,zoomSpeed:n,zoomPoint:i,camera:r,maxZoom:s}=this,a=li.clamp(li.mapLinear(Math.abs(t),0,20,0,1),0,1);if(this._isNearControls()||t>0){if(this._updateZoomDirection(),t<0&&(this.zoomPointSet||this._updateZoomPoint())){PR.set(0,0,-1).transformDirection(r.matrixWorld).normalize(),kR.copy(this.up).multiplyScalar(-1),this.getUpDirection(i,OR);const t=li.clamp(li.mapLinear(-OR.dot(kR),1,.95,0,1),0,1),e=1-PR.dot(kR),n=r.isOrthographicCamera?.05:1,s=li.clamp(3*a,0,1),o=Math.min(t*e*n*s,.1);kR.lerpVectors(PR,kR,o).normalize(),FR.setFromUnitVectors(PR,kR),tR(i,FR,TR),r.matrixWorld.premultiply(TR),r.matrixWorld.decompose(r.position,r.quaternion,kR),this.zoomDirection.subVectors(i,r.position).normalize()}super._updateZoom()}else if(r.isPerspectiveCamera){const i=this._getPerspectiveTransitionDistance(),r=this._getMaxPerspectiveDistance(),s=li.mapLinear(this.getDistanceToCenter(),i,r,0,1);this._tiltTowardsCenter(li.lerp(0,.4,s*a)),this._alignCameraUpToNorth(li.lerp(0,.2,s*a));const o=t*(this.getDistanceToCenter()-e.radius.x)*n*.0025,l=Math.max(o,Math.min(this.getDistanceToCenter()-r,0));this.getVectorToCenter(RR).normalize(),this.camera.position.addScaledVector(RR,l),this.camera.updateMatrixWorld(),this.zoomDelta=0}else{const t=this._getOrthographicTransitionZoom(),e=this._getMinOrthographicZoom(),i=li.mapLinear(r.zoom,t,e,0,1);this._tiltTowardsCenter(li.lerp(0,.4,i*a)),this._alignCameraUpToNorth(li.lerp(0,.2,i*a));const o=this.zoomDelta,l=Math.pow(.95,Math.abs(.05*o)),c=o>0?1/Math.abs(l):l,h=e/r.zoom,u=Math.max(c*n,Math.min(h,1));r.zoom=Math.min(s,r.zoom*u),r.updateProjectionMatrix(),this.zoomDelta=0,this.zoomDirectionSet=!1}}_alignCameraUpToNorth(t){const{tilesGroup:e}=this;NR.set(0,0,1).transformDirection(e.matrixWorld),this._alignCameraUp(NR,t)}_alignCameraUp(t,e=null){const{camera:n}=this;PR.set(0,0,-1).transformDirection(n.matrixWorld),LR.set(-1,0,0).transformDirection(n.matrixWorld),UR.crossVectors(t,PR),null===e&&(e=1-Math.abs(PR.dot(t)),e=li.mapLinear(e,0,1,-.01,1),e=li.clamp(e,0,1)**2),UR.lerp(LR,1-e).normalize(),FR.setFromUnitVectors(LR,UR),n.quaternion.premultiply(FR),n.updateMatrixWorld()}_tiltTowardsCenter(t){const{camera:e,tilesGroup:n}=this;PR.set(0,0,-1).transformDirection(e.matrixWorld).normalize(),RR.setFromMatrixPosition(n.matrixWorld).sub(e.position).normalize(),RR.lerp(PR,1-t).normalize(),FR.setFromUnitVectors(PR,RR),e.quaternion.premultiply(FR),e.updateMatrixWorld()}_getPerspectiveTransitionDistance(){const{camera:t,ellipsoid:e}=this;if(!t.isPerspectiveCamera)throw new Error;const n=Math.max(...e.radius),i=2*Math.atan(Math.tan(li.DEG2RAD*t.fov*.5)*t.aspect),r=n/Math.tan(li.DEG2RAD*t.fov*.5),s=n/Math.tan(.5*i);return Math.max(r,s)}_getMaxPerspectiveDistance(){const{camera:t,ellipsoid:e}=this;if(!t.isPerspectiveCamera)throw new Error;const n=Math.max(...e.radius),i=2*Math.atan(Math.tan(li.DEG2RAD*t.fov*.5)*t.aspect),r=n/Math.tan(li.DEG2RAD*t.fov*.5),s=n/Math.tan(.5*i);return 2*Math.max(r,s)}_getOrthographicTransitionZoom(){const{camera:t,ellipsoid:e}=this;if(!t.isOrthographicCamera)throw new Error;const n=t.top-t.bottom,i=t.right-t.left;return 2*Math.max(n,i)/(2*Math.max(...e.radius))}_getMinOrthographicZoom(){const{camera:t,ellipsoid:e}=this;if(!t.isOrthographicCamera)throw new Error;const n=t.top-t.bottom,i=t.right-t.left;return.7*Math.min(n,i)/(2*Math.max(...e.radius))}_getVirtualOrthoCameraPosition(t,e=this.camera){const{tilesGroup:n,ellipsoid:i}=this;if(!e.isOrthographicCamera)throw new Error;IR.copy(n.matrixWorld).invert(),zR.origin.copy(e.position),zR.direction.set(0,0,-1).transformDirection(e.matrixWorld),zR.applyMatrix4(IR),nR(zR,i,BR),BR.applyMatrix4(n.matrixWorld);const r=e.top-e.bottom,s=e.right-e.left,a=Math.max(r,s)/e.zoom;PR.set(0,0,-1).transformDirection(e.matrixWorld);const o=BR.sub(e.position).dot(PR);t.copy(e.position).addScaledVector(PR,o-4*a)}_isNearControls(){const{camera:t}=this;return t.isPerspectiveCamera?this.getDistanceToCenter()this._getOrthographicTransitionZoom()}}const WR=new Gi,jR=new Gi,qR=new Na,XR=new Gi;class YR extends Kn{get animating(){return 0!==this._alpha&&1!==this._alpha}get camera(){return 0===this._alpha?this.perspectiveCamera:1===this._alpha?this.orthographicCamera:this.transitionCamera}get mode(){return 0===this._target?"perspective":"orthographic"}set mode(t){if(t===this.mode)return;const e=this.camera;"perspective"===t?(this._target=0,this._alpha=0):(this._target=1,this._alpha=1),this.dispatchEvent({type:"camera-change",camera:this.camera,prevCamera:e})}constructor(t=new ca,e=new Na){super(),this.perspectiveCamera=t,this.orthographicCamera=e,this.transitionCamera=new ca,this.orthographicPositionalZoom=!0,this.orthographicOffset=50,this.fixedPoint=new Gi,this.duration=200,this.autoSync=!0,this._target=0,this._alpha=0,this._clock=new Vp}toggle(){this._target=1===this._target?0:1}update(){this.autoSync&&this.syncCameras();const{perspectiveCamera:t,orthographicCamera:e,transitionCamera:n,camera:i}=this,r=1e3*this._clock.getDelta();if(this._alpha!==this._target){const t=Math.sign(this._target-this._alpha)*r/this.duration;this._alpha=li.clamp(this._alpha+t,0,1),this.dispatchEvent({type:"change"})}const s=i;let a=null;0===this._alpha?a=t:1===this._alpha?a=e:(a=n,this._updateTransitionCamera()),s!==a&&(a===n&&this.dispatchEvent({type:"transition-start"}),this.dispatchEvent({type:"camera-change",camera:a,prevCamera:s}),s===n&&this.dispatchEvent({type:"transition-end"}))}syncCameras(){const t=this._getFromCamera(),{perspectiveCamera:e,orthographicCamera:n,transitionCamera:i,fixedPoint:r}=this;if(WR.set(0,0,-1).transformDirection(t.matrixWorld).normalize(),t.isPerspectiveCamera){if(this.orthographicPositionalZoom)n.position.copy(e.position).addScaledVector(WR,-this.orthographicOffset),n.rotation.copy(e.rotation),n.updateMatrixWorld();else{const t=jR.subVectors(r,n.position).dot(WR),i=jR.subVectors(r,e.position).dot(WR);jR.copy(e.position).addScaledVector(WR,i),n.rotation.copy(e.rotation),n.position.copy(jR).addScaledVector(WR,-t),n.updateMatrixWorld()}const t=Math.abs(jR.subVectors(e.position,r).dot(WR)),i=2*Math.tan(li.DEG2RAD*e.fov*.5)*t,s=n.top-n.bottom;n.zoom=s/i,n.updateProjectionMatrix()}else{const t=Math.abs(jR.subVectors(n.position,r).dot(WR)),i=(n.top-n.bottom)/n.zoom*.5/Math.tan(li.DEG2RAD*e.fov*.5);e.rotation.copy(n.rotation),e.position.copy(n.position).addScaledVector(WR,t).addScaledVector(WR,-i),e.updateMatrixWorld(),this.orthographicPositionalZoom&&(n.position.copy(e.position).addScaledVector(WR,-this.orthographicOffset),n.updateMatrixWorld())}i.position.copy(e.position),i.rotation.copy(e.rotation)}_getTransitionDirection(){return Math.sign(this._target-this._alpha)}_getToCamera(){const t=this._getTransitionDirection();return 0===t?0===this._target?this.perspectiveCamera:this.orthographicCamera:t>0?this.orthographicCamera:this.perspectiveCamera}_getFromCamera(){const t=this._getTransitionDirection();return 0===t?0===this._target?this.perspectiveCamera:this.orthographicCamera:t>0?this.perspectiveCamera:this.orthographicCamera}_updateTransitionCamera(){const{perspectiveCamera:t,orthographicCamera:e,transitionCamera:n,fixedPoint:i}=this,r=this._alpha;WR.set(0,0,-1).transformDirection(e.matrixWorld).normalize(),qR.copy(e),qR.position.addScaledVector(WR,e.near),e.far-=e.near,e.near=0,WR.set(0,0,-1).transformDirection(t.matrixWorld).normalize();const s=Math.abs(jR.subVectors(t.position,i).dot(WR)),a=2*Math.tan(li.DEG2RAD*t.fov*.5)*s,o=li.lerp(t.fov,1,r),l=.5*a/Math.tan(li.DEG2RAD*o*.5),c=XR.lerpVectors(t.position,qR.position,r);c.addScaledVector(WR,Math.abs(jR.subVectors(c,i).dot(WR))-l);const h=jR.subVectors(t.position,c).dot(WR),u=jR.subVectors(qR.position,c).dot(WR),d=li.lerp(h+t.near,u+qR.near,r),p=li.lerp(h+t.far,u+qR.far,r),f=Math.max(p,0)-Math.max(d,0);n.aspect=t.aspect,n.fov=o,n.near=Math.max(d,1e-5*f),n.far=p,n.position.copy(c),n.rotation.copy(t.rotation),n.updateProjectionMatrix(),n.updateMatrixWorld()}}function JR(t){return"OCTREE"===t.__implicitRoot.implicitTiling.subdivisionScheme}function KR(t){return JR(t)?8:4}class ZR{constructor(t,e){this.parent=t,this.children=[],this.__level=t.__level+1,this.__implicitRoot=t.__implicitRoot,this.__subtreeIdx=e,[this.__x,this.__y,this.__z]=function(t,e){return e?[2*e.__x+t.__subtreeIdx%2,2*e.__y+Math.floor(t.__subtreeIdx/2)%2,JR(t)?2*e.__z+Math.floor(t.__subtreeIdx/4)%2:0]:[0,0,0]}(this,t)}static copy(t){const e={children:[]};return e.__level=t.__level,e.__implicitRoot=t.__implicitRoot,e.__subtreeIdx=t.__subtreeIdx,[e.__x,e.__y,e.__z]=[t.__x,t.__y,t.__z],e.boundingVolume=t.boundingVolume,e.geometricError=t.geometricError,e}}class $R extends uS{constructor(t){super(),this.tile=t,this.rootTile=t.__implicitRoot}parseBuffer(t){const e=new DataView(t);let n=0;const i=dS(e);console.assert("subt"===i,'SUBTREELoader: The magic bytes equal "subt".'),n+=4;const r=e.getUint32(n,!0);console.assert(1===r,'SUBTREELoader: The version listed in the header is "1".'),n+=4;const s=e.getUint32(n,!0);n+=8;const a=e.getUint32(n,!0);n+=8;const o=JSON.parse(aS(new Uint8Array(t,n,s)));return n+=s,{version:r,subtreeJson:o,subtreeByte:t.slice(n,n+a)}}parse(t){const e=this.parseBuffer(t),n=e.subtreeJson;n.contentAvailabilityHeaders=[].concat(n.contentAvailability);const i=this.preprocessBuffers(n.buffers),r=this.preprocessBufferViews(n.bufferViews,i);this.markActiveBufferViews(n,r);const s=this.requestActiveBuffers(i,e.subtreeByte),a=this.parseActiveBufferViews(r,s);this.parseAvailability(e,n,a),this.expandSubtree(this.tile,e)}markActiveBufferViews(t,e){let n;const i=t.tileAvailability;isNaN(i.bitstream)?isNaN(i.bufferView)||(n=e[i.bufferView]):n=e[i.bitstream],n&&(n.isActive=!0,n.bufferHeader.isActive=!0);const r=t.contentAvailabilityHeaders;for(let t=0;t>Math.log2(r)];if(!this.getBit(e._tileAvailability,a)){i.push(void 0);continue}const l=this.deriveChildTile(e,o,a,t);o.children.push(l),i.push(l)}n=i,i=[]}return n}deriveChildTile(t,e,n,i){const r=new ZR(e,i);r.boundingVolume=this.getTileBoundingVolume(r),r.geometricError=this.getGeometricError(r);for(let e=0;t&&e=t.lengthBits)throw new Error("Bit index out of bounds.");if(void 0!==t.constant)return t.constant;const n=e>>3,i=e%8;return 1==(new Uint8Array(t.bitstream)[n]>>i&1)}getTileBoundingVolume(t){const e={};if(this.rootTile.boundingVolume.region){const n=[...this.rootTile.boundingVolume.region],i=n[0],r=n[2],s=n[1],a=n[3],o=(r-i)/Math.pow(2,t.__level),l=(a-s)/Math.pow(2,t.__level);n[0]=i+o*t.__x,n[2]=i+o*(t.__x+1),n[1]=s+l*t.__y,n[3]=s+l*(t.__y+1);for(let t=0;t<4;t++){const e=n[t];e<-Math.PI?n[t]+=2*Math.PI:e>Math.PI&&(n[t]-=2*Math.PI)}if(JR(t)){const e=n[4],i=(n[5]-e)/Math.pow(2,t.__level);n[4]=e+i*t.__z,n[5]=e+i*(t.__z+1)}e.region=n}if(this.rootTile.boundingVolume.box){const n=[...this.rootTile.boundingVolume.box],i=2**t.__level-1,r=Math.pow(2,-t.__level),s=JR(t)?3:2;for(let e=0;e{t.material&&this.prepareMaterial(t.material)}))}deleteObject(t){if(!t)return;this.completeFade(t);const e=this._fadeParams;t.traverse((t=>{const n=t.material;n&&(e.delete(n),n.onBeforeCompile=null,n.needsUpdate=!0)}))}prepareMaterial(t){const e=this._fadeParams;if(e.has(t))return;const n={fadeIn:{value:0},fadeOut:{value:0}};t.defines={FEATURE_FADE:0},t.onBeforeCompile=t=>{t.uniforms={...t.uniforms,...n},t.fragmentShader=t.fragmentShader.replace(/void main\(/,(t=>`\n\t\t\t\t\t#if FEATURE_FADE\n\n\t\t\t\t\t// adapted from https://www.shadertoy.com/view/Mlt3z8\n\t\t\t\t\tfloat bayerDither2x2( vec2 v ) {\n\n\t\t\t\t\t\treturn mod( 3.0 * v.y + 2.0 * v.x, 4.0 );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat bayerDither4x4( vec2 v ) {\n\n\t\t\t\t\t\tvec2 P1 = mod( v, 2.0 );\n\t\t\t\t\t\tvec2 P2 = floor( 0.5 * mod( v, 4.0 ) );\n\t\t\t\t\t\treturn 4.0 * bayerDither2x2( P1 ) + bayerDither2x2( P2 );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tuniform float fadeIn;\n\t\t\t\t\tuniform float fadeOut;\n\t\t\t\t\t#endif\n\n\t\t\t\t\t${t}\n\t\t\t\t`)).replace(/#include /,(t=>`\n\n\t\t\t\t\t${t}\n\n\t\t\t\t\t#if FEATURE_FADE\n\n\t\t\t\t\tfloat bayerValue = bayerDither4x4( floor( mod( gl_FragCoord.xy, 4.0 ) ) );\n\t\t\t\t\tfloat bayerBins = 16.0;\n\t\t\t\t\tfloat dither = ( 0.5 + bayerValue ) / bayerBins;\n\t\t\t\t\tif ( dither >= fadeIn ) {\n\n\t\t\t\t\t\tdiscard;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( dither < fadeOut ) {\n\n\t\t\t\t\t\tdiscard;\n\n\t\t\t\t\t}\n\n\t\t\t\t\t#endif\n\n\t\t\t\t`))},e.set(t,n)}guaranteeState(t){const e=this._fadeState;if(e.has(t))return!1;e.set(t,{fadeInTarget:0,fadeOutTarget:0,fadeIn:0,fadeOut:0});const n=this._fadeParams;return t.traverse((t=>{const e=t.material;if(e&&n.has(e)){const t=n.get(e);t.fadeIn.value=0,t.fadeOut.value=0}})),!0}completeFade(t){const e=this._fadeState;e.has(t)&&(e.delete(t),t.traverse((t=>{const e=t.material;e&&e.defines&&0!==e.defines.FEATURE_FADE&&(e.defines.FEATURE_FADE=0,e.needsUpdate=!0)})),this.fadeCount--,this.onFadeComplete&&this.onFadeComplete(t),0===this.fadeCount&&this.onFadeSetComplete&&this.onFadeSetComplete())}completeAllFades(){this._fadeState.forEach(((t,e)=>{this.completeFade(e)}))}forEachObject(t){this._fadeState.forEach(((e,n)=>t(n)))}fadeIn(t){const e=this.guaranteeState(t),n=this._fadeState.get(t);n.fadeInTarget=1,n.fadeOutTarget=0,n.fadeOut=0,e&&(this.fadeCount++,1===this.fadeCount&&this.onFadeSetStart&&this.onFadeSetStart(),this.onFadeStart&&this.onFadeStart(t))}fadeOut(t){const e=this.guaranteeState(t),n=this._fadeState.get(t);n.fadeOutTarget=1,e&&(n.fadeInTarget=1,n.fadeIn=1,this.fadeCount++,1===this.fadeCount&&this.onFadeSetStart&&this.onFadeSetStart(),this.onFadeStart&&this.onFadeStart(t))}update(){const t=window.performance.now();-1===this._lastTick&&(this._lastTick=t);const e=nD((t-this._lastTick)/this.duration,0,1);this._lastTick=t;const n=this._fadeState,i=this._fadeParams;n.forEach(((t,n)=>{const{fadeOutTarget:r,fadeInTarget:s}=t;let{fadeOut:a,fadeIn:o}=t;const l=Math.sign(s-o);o=nD(o+l*e,0,1);const c=Math.sign(r-a);a=nD(a+c*e,0,1),t.fadeIn=o,t.fadeOut=a;const h=Number(a!==r||o!==s);n.traverse((t=>{const e=t.material;if(e&&i.has(e)){const t=i.get(e);t.fadeIn.value=o,t.fadeOut.value=a,h!==e.defines.FEATURE_FADE&&(e.defines.FEATURE_FADE=h,e.needsUpdate=!0)}})),((1===a||0===a)&&(1===o||0===o)||a>=o)&&this.completeFade(n)}))}}const rD=new Gi,sD=new Gi,aD=new zi,oD=new zi,lD=new Gi;function cD(t,e,n){if(t.visible=!0,n){const n=1===e.__depthFromRenderedParent;n||(this._initialLayerRendered=!0),(!n||this.fadeRootTiles||this._initialLayerRendered)&&this._fadeManager.fadeIn(t)}else this._fadeGroup.add(t),this._fadeManager.fadeOut(t)}function hD(t,e){this._fadeManager.prepareObject(t),this._tileMap.set(t,e)}function uD(t){this._fadeManager.deleteObject(t)}function dD(t){t.parent===this._fadeGroup&&this._fadeGroup.remove(t)}function pD(t){this._prevCameraTransforms.set(t,new vr)}function fD(t){this._prevCameraTransforms.delete(t)}function mD(){const t=this._fadeManager,e=this.tiles;this._fadingBefore=t.fadeCount,this._displayActiveTiles=this.displayActiveTiles,e.displayActiveTiles=!0}function gD(){const t=this._fadeManager,e=this._fadeGroup,n=this._displayActiveTiles,i=this._fadingBefore,r=this.tiles,s=this._prevCameraTransforms,a=this._tileMap,o=r.lruCache,l=r.cameras;r.displayActiveTiles=n,t.update();const c=t.fadeCount;if(0!==i&&0!==c&&r.dispatchEvent({type:"fade-change"}),n||r.visibleTiles.forEach((t=>{t.cached.scene.visible=t.__inFrustum})),this.maximumFadeOutTiles{if(!s.has(t))return;const n=t.matrixWorld,i=s.get(t);n.decompose(sD,oD,lD),i.decompose(rD,aD,lD);const r=oD.angleTo(aD),a=sD.distanceTo(rD);e=e&&(r>.25||a>.1)})),e&&t.completeAllFades()}l.forEach((t=>{s.get(t).copy(t.matrixWorld)})),t.forEachObject((t=>{o.markUsed(a.get(t))}))}ks.prototype.computeBoundsTree=OM,ks.prototype.disposeBoundsTree=kM,Ks.prototype.raycast=UM,e.OrbitControls=class extends dm{constructor(t,e=null){super(t,e),this.state=gg,this.enabled=!0,this.target=new Gi,this.cursor=new Gi,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:f.ROTATE,MIDDLE:f.DOLLY,RIGHT:f.PAN},this.touches={ONE:m.ROTATE,TWO:m.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new Gi,this._lastQuaternion=new zi,this._lastTargetPosition=new Gi,this._quat=(new zi).setFromUnitVectors(t.up,new Gi(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new bf,this._sphericalDelta=new bf,this._scale=1,this._panOffset=new Gi,this._rotateStart=new ci,this._rotateEnd=new ci,this._rotateDelta=new ci,this._panStart=new ci,this._panEnd=new ci,this._panDelta=new ci,this._dollyStart=new ci,this._dollyEnd=new ci,this._dollyDelta=new ci,this._dollyDirection=new Gi,this._mouse=new ci,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=yg.bind(this),this._onPointerDown=vg.bind(this),this._onPointerUp=_g.bind(this),this._onContextMenu=Sg.bind(this),this._onMouseWheel=Cg.bind(this),this._onKeyDown=Eg.bind(this),this._onTouchStart=Mg.bind(this),this._onTouchMove=bg.bind(this),this._onMouseDown=xg.bind(this),this._onMouseMove=wg.bind(this),this._interceptControlDown=Ig.bind(this),this._interceptControlUp=Tg.bind(this),null!==this.domElement&&this.connect(),this.update()}connect(){this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(t){t.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=t}stopListenToKeyEvents(){null!==this._domElementKeyEvents&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(lg),this.update(),this.state=gg}update(t=null){const e=this.object.position;fg.copy(e).sub(this.target),fg.applyQuaternion(this._quat),this._spherical.setFromVector3(fg),this.autoRotate&&this.state===gg&&this._rotateLeft(this._getAutoRotationAngle(t)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let n=this.minAzimuthAngle,i=this.maxAzimuthAngle;isFinite(n)&&isFinite(i)&&(n<-Math.PI?n+=mg:n>Math.PI&&(n-=mg),i<-Math.PI?i+=mg:i>Math.PI&&(i-=mg),this._spherical.theta=n<=i?Math.max(n,Math.min(i,this._spherical.theta)):this._spherical.theta>(n+i)/2?Math.max(n,this._spherical.theta):Math.min(i,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),!0===this.enableDamping?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const t=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=t!=this._spherical.radius}if(fg.setFromSpherical(this._spherical),fg.applyQuaternion(this._quatInverse),e.copy(this.target).add(fg),this.object.lookAt(this.target),!0===this.enableDamping?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let t=null;if(this.object.isPerspectiveCamera){const e=fg.length();t=this._clampDistance(e*this._scale);const n=e-t;this.object.position.addScaledVector(this._dollyDirection,n),this.object.updateMatrixWorld(),r=!!n}else if(this.object.isOrthographicCamera){const e=new Gi(this._mouse.x,this._mouse.y,0);e.unproject(this.object);const n=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=n!==this.object.zoom;const i=new Gi(this._mouse.x,this._mouse.y,0);i.unproject(this.object),this.object.position.sub(i).add(e),this.object.updateMatrixWorld(),t=fg.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;null!==t&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(t).add(this.object.position):(ug.origin.copy(this.object.position),ug.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(ug.direction))Ag||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Ag||this._lastTargetPosition.distanceToSquared(this.target)>Ag)&&(this.dispatchEvent(lg),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0)}_getAutoRotationAngle(t){return null!==t?mg/60*this.autoRotateSpeed*t:mg/60/60*this.autoRotateSpeed}_getZoomScale(t){const e=Math.abs(.01*t);return Math.pow(.95,this.zoomSpeed*e)}_rotateLeft(t){this._sphericalDelta.theta-=t}_rotateUp(t){this._sphericalDelta.phi-=t}_panLeft(t,e){fg.setFromMatrixColumn(e,0),fg.multiplyScalar(-t),this._panOffset.add(fg)}_panUp(t,e){!0===this.screenSpacePanning?fg.setFromMatrixColumn(e,1):(fg.setFromMatrixColumn(e,0),fg.crossVectors(this.object.up,fg)),fg.multiplyScalar(t),this._panOffset.add(fg)}_pan(t,e){const n=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;fg.copy(i).sub(this.target);let r=fg.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*t*r/n.clientHeight,this.object.matrix),this._panUp(2*e*r/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(t*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(e*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(t,e){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const n=this.domElement.getBoundingClientRect(),i=t-n.left,r=e-n.top,s=n.width,a=n.height;this._mouse.x=i/s*2-1,this._mouse.y=-r/a*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(t){return Math.max(this.minDistance,Math.min(this.maxDistance,t))}_handleMouseDownRotate(t){this._rotateStart.set(t.clientX,t.clientY)}_handleMouseDownDolly(t){this._updateZoomParameters(t.clientX,t.clientX),this._dollyStart.set(t.clientX,t.clientY)}_handleMouseDownPan(t){this._panStart.set(t.clientX,t.clientY)}_handleMouseMoveRotate(t){this._rotateEnd.set(t.clientX,t.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const e=this.domElement;this._rotateLeft(mg*this._rotateDelta.x/e.clientHeight),this._rotateUp(mg*this._rotateDelta.y/e.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(t){this._dollyEnd.set(t.clientX,t.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(t){this._panEnd.set(t.clientX,t.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(t){this._updateZoomParameters(t.clientX,t.clientY),t.deltaY<0?this._dollyIn(this._getZoomScale(t.deltaY)):t.deltaY>0&&this._dollyOut(this._getZoomScale(t.deltaY)),this.update()}_handleKeyDown(t){let e=!1;switch(t.code){case this.keys.UP:t.ctrlKey||t.metaKey||t.shiftKey?this._rotateUp(mg*this.rotateSpeed/this.domElement.clientHeight):this._pan(0,this.keyPanSpeed),e=!0;break;case this.keys.BOTTOM:t.ctrlKey||t.metaKey||t.shiftKey?this._rotateUp(-mg*this.rotateSpeed/this.domElement.clientHeight):this._pan(0,-this.keyPanSpeed),e=!0;break;case this.keys.LEFT:t.ctrlKey||t.metaKey||t.shiftKey?this._rotateLeft(mg*this.rotateSpeed/this.domElement.clientHeight):this._pan(this.keyPanSpeed,0),e=!0;break;case this.keys.RIGHT:t.ctrlKey||t.metaKey||t.shiftKey?this._rotateLeft(-mg*this.rotateSpeed/this.domElement.clientHeight):this._pan(-this.keyPanSpeed,0),e=!0}e&&(t.preventDefault(),this.update())}_handleTouchStartRotate(t){if(1===this._pointers.length)this._rotateStart.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),n=.5*(t.pageX+e.x),i=.5*(t.pageY+e.y);this._rotateStart.set(n,i)}}_handleTouchStartPan(t){if(1===this._pointers.length)this._panStart.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),n=.5*(t.pageX+e.x),i=.5*(t.pageY+e.y);this._panStart.set(n,i)}}_handleTouchStartDolly(t){const e=this._getSecondPointerPosition(t),n=t.pageX-e.x,i=t.pageY-e.y,r=Math.sqrt(n*n+i*i);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(t){this.enableZoom&&this._handleTouchStartDolly(t),this.enablePan&&this._handleTouchStartPan(t)}_handleTouchStartDollyRotate(t){this.enableZoom&&this._handleTouchStartDolly(t),this.enableRotate&&this._handleTouchStartRotate(t)}_handleTouchMoveRotate(t){if(1==this._pointers.length)this._rotateEnd.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),n=.5*(t.pageX+e.x),i=.5*(t.pageY+e.y);this._rotateEnd.set(n,i)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const e=this.domElement;this._rotateLeft(mg*this._rotateDelta.x/e.clientHeight),this._rotateUp(mg*this._rotateDelta.y/e.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(t){if(1===this._pointers.length)this._panEnd.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),n=.5*(t.pageX+e.x),i=.5*(t.pageY+e.y);this._panEnd.set(n,i)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(t){const e=this._getSecondPointerPosition(t),n=t.pageX-e.x,i=t.pageY-e.y,r=Math.sqrt(n*n+i*i);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const s=.5*(t.pageX+e.x),a=.5*(t.pageY+e.y);this._updateZoomParameters(s,a)}_handleTouchMoveDollyPan(t){this.enableZoom&&this._handleTouchMoveDolly(t),this.enablePan&&this._handleTouchMovePan(t)}_handleTouchMoveDollyRotate(t){this.enableZoom&&this._handleTouchMoveDolly(t),this.enableRotate&&this._handleTouchMoveRotate(t)}_addPointer(t){this._pointers.push(t.pointerId)}_removePointer(t){delete this._pointerPositions[t.pointerId];for(let e=0;es.distanceTo(i[2])?r[2]:i[2];let o=s.distanceTo(a);if(this.fade){const t=this.camera,e=Math.max(t.far,this.maxFar),i=n.vertices.far[0].z/(e-t.near);o+=.25*Math.pow(i,2)*(e-t.near)}t.left=-o/2,t.right=o/2,t.top=o/2,t.bottom=-o/2,t.updateProjectionMatrix()}}getBreaks(){const t=this.camera,e=Math.min(t.far,this.maxFar);switch(this.breaks.length=0,this.mode){case"uniform":n(this.cascades,t.near,e,this.breaks);break;case"logarithmic":i(this.cascades,t.near,e,this.breaks);break;case"practical":!function(t,e,r,s,a){ig.length=0,rg.length=0,i(t,e,r,rg),n(t,e,r,ig);for(let e=1;e{this.parse(t,e,i)}),n,i)}parse(t,e,n=()=>{}){this.decodeDracoFile(t,e,null,null,hn,n).catch(n)}decodeDracoFile(t,e,n,i,r=un,s=()=>{}){const a={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!n,vertexColorSpace:r};return this.decodeGeometry(t,a).then(e).catch(s)}decodeGeometry(t,e){const n=JSON.stringify(e);if(iv.has(t)){const e=iv.get(t);if(e.key===n)return e.promise;if(0===t.byteLength)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let i;const r=this.workerNextTaskID++,s=t.byteLength,a=this._getWorker(r,s).then((n=>(i=n,new Promise(((n,s)=>{i._callbacks[r]={resolve:n,reject:s},i.postMessage({type:"decode",id:r,taskConfig:e,buffer:t},[t])}))))).then((t=>this._createGeometry(t.geometry)));return a.catch((()=>!0)).then((()=>{i&&r&&this._releaseTask(i,r)})),iv.set(t,{key:n,promise:a}),a}_createGeometry(t){const e=new ks;t.index&&e.setIndex(new ws(t.index.array,1));for(let n=0;n{n.load(t,e,void 0,i)}))}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const t="object"!=typeof WebAssembly||"js"===this.decoderConfig.type,e=[];return t?e.push(this._loadLibrary("draco_decoder.js","text")):(e.push(this._loadLibrary("draco_wasm_wrapper.js","text")),e.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(e).then((e=>{const n=e[0];t||(this.decoderConfig.wasmBinary=e[1]);const i=rv.toString(),r=["/* draco decoder */",n,"","/* worker */",i.substring(i.indexOf("{")+1,i.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([r]))})),this.decoderPending}_getWorker(t,e){return this._initDecoder().then((()=>{if(this.workerPool.lengthe._taskLoad?-1:1}));const n=this.workerPool[this.workerPool.length-1];return n._taskCosts[t]=e,n._taskLoad+=e,n}))}_releaseTask(t,e){t._taskLoad-=t._taskCosts[e],delete t._callbacks[e],delete t._taskCosts[e]}debug(){console.log("Task load: ",this.workerPool.map((t=>t._taskLoad)))}dispose(){for(let t=0;t{if(t.isMesh){const e=t.geometry,i=t.material;if(i.isMeshStandardMaterial){const a="geometries/Geometry_"+e.id+".usda";if(!(a in n)){const t=function(t){const e=function(t){const e=t.attributes,n=e.position.count;return`\n\tdef Mesh "Geometry"\n\t{\n\t\tint[] faceVertexCounts = [${function(t){const e=null!==t.index?t.index.count:t.attributes.position.count;return Array(e/3).fill(3).join(", ")}(t)}]\n\t\tint[] faceVertexIndices = [${function(t){const e=t.index,n=[];if(null!==e)for(let t=0;t0?n:"",r=t["uv"+i];void 0!==r&&(e+=`\n\t\ttexCoord2f[] primvars:st${i} = [${ly(r)}] (\n\t\t\tinterpolation = "vertex"\n\t\t)`)}const n=t.color;return void 0!==n&&(e+=`\n\tcolor3f[] primvars:displayColor = [${oy(n,n.count)}] (\n\t\tinterpolation = "vertex"\n\t\t)`),e}(e)}\n\t\tuniform token subdivisionScheme = "none"\n\t}\n`}(t);return`\ndef "Geometry"\n{\n${e}\n}\n`}(e);n[a]=function(t){let e='#usda 1.0\n(\n\tcustomLayerData = {\n\t\tstring creator = "Three.js USDZExporter"\n\t}\n\tdefaultPrim = "Root"\n\tmetersPerUnit = 1\n\tupAxis = "Y"\n)\n\n';return e+=t,ey(e)}(t)}i.uuid in s||(s[i.uuid]=i),r+=function(t,e,n){const i="Object_"+t.id,r=sy(t.matrixWorld);return t.matrixWorld.determinant()<0&&console.warn("THREE.USDZExporter: USDZ does not support negative scales",t),`def Xform "${i}" (\n\tprepend references = @./geometries/Geometry_${e.id}.usda@\n\tprepend apiSchemas = ["MaterialBindingAPI"]\n)\n{\n\tmatrix4d xformOp:transform = ${r}\n\tuniform token[] xformOpOrder = ["xformOp:transform"]\n\n\trel material:binding = \n}\n\n`}(t,e,i)}else console.warn("THREE.USDZExporter: Unsupported material type (USDZ only supports MeshStandardMaterial)",t)}else t.isCamera&&(r+=function(t){const e=t.name?t.name:"Camera_"+t.id,n=sy(t.matrixWorld);return t.matrixWorld.determinant()<0&&console.warn("THREE.USDZExporter: USDZ does not support negative scales",t),t.isOrthographicCamera?`def Camera "${e}"\n\t\t{\n\t\t\tmatrix4d xformOp:transform = ${n}\n\t\t\tuniform token[] xformOpOrder = ["xformOp:transform"]\n\n\t\t\tfloat2 clippingRange = (${t.near.toPrecision(7)}, ${t.far.toPrecision(7)})\n\t\t\tfloat horizontalAperture = ${(10*(Math.abs(t.left)+Math.abs(t.right))).toPrecision(7)}\n\t\t\tfloat verticalAperture = ${(10*(Math.abs(t.top)+Math.abs(t.bottom))).toPrecision(7)}\n\t\t\ttoken projection = "orthographic"\n\t\t}\n\t\n\t`:`def Camera "${e}"\n\t\t{\n\t\t\tmatrix4d xformOp:transform = ${n}\n\t\t\tuniform token[] xformOpOrder = ["xformOp:transform"]\n\n\t\t\tfloat2 clippingRange = (${t.near.toPrecision(7)}, ${t.far.toPrecision(7)})\n\t\t\tfloat focalLength = ${t.getFocalLength().toPrecision(7)}\n\t\t\tfloat focusDistance = ${t.focus.toPrecision(7)}\n\t\t\tfloat horizontalAperture = ${t.getFilmWidth().toPrecision(7)}\n\t\t\ttoken projection = "perspective"\n\t\t\tfloat verticalAperture = ${t.getFilmHeight().toPrecision(7)}\n\t\t}\n\t\n\t`}(t))})),r+="\n\t\t}\n\t}\n}\n\n",r+=function(t,e,n=!1){const i=[];for(const r in t){const s=t[r];i.push(cy(s,e,n))}return`def "Materials"\n{\n${i.join("")}\n}\n\n`}(s,a,e.quickLookCompatible),n[i]=ey(r),r=null;for(const t in a){let i=a[t];if(!0===i.isCompressedTexture){if(null===this.textureUtils)throw new Error("THREE.USDZExporter: setTextureUtils() must be called to process compressed textures.");i=await this.textureUtils.decompress(i)}const r=ry(i.image,i.flipY,e.maxTextureSize),s=await new Promise((t=>r.toBlob(t,"image/png",1)));n[`textures/Texture_${t}.png`]=new Uint8Array(await s.arrayBuffer())}let o=0;for(const t in n){const e=n[t];o+=34+t.length;const i=63&o;if(4!==i){const r=new Uint8Array(64-i);n[t]=[e,{extra:{12345:r}}]}o=e.length}return function(t,e){e||(e={});var n={},i=[];Zv(t,"",n,e);var r=0,s=0;for(var a in n){var o=n[a],l=o[0],c=o[1],h=0==c.level?0:8,u=(C=ey(a)).length,d=c.comment,p=d&&ey(d),f=p&&p.length,m=ny(c.extra);u>65535&&Lv(11);var g=h?Jv(l,c):l,A=g.length,v=jv();v.p(l),i.push(Xv(c,{size:l.length,crc:v.d(),c:g,f:C,m:p,u:u!=a.length||p&&d.length!=f,o:r,compression:h})),r+=30+u+m+A,s+=76+2*(u+m)+(f||0)+A}for(var y=new sv(s+22),_=r,x=s-r,w=0;w(r=o.indexOf("\n"))&&s=t.byteLength||!(l=n(t)))&&e(1,"no header found"),(c=l.match(/^#\?(\S+)/))||e(3,"bad initial token"),o.valid|=1,o.programtype=c[1],o.string+=l+"\n";l=n(t),!1!==l;)if(o.string+=l+"\n","#"!==l.charAt(0)){if((c=l.match(i))&&(o.gamma=parseFloat(c[1])),(c=l.match(r))&&(o.exposure=parseFloat(c[1])),(c=l.match(s))&&(o.valid|=2,o.format=c[1]),(c=l.match(a))&&(o.valid|=4,o.height=parseInt(c[1],10),o.width=parseInt(c[2],10)),2&o.valid&&4&o.valid)break}else o.comments+=l+"\n";return 2&o.valid||e(3,"missing format specifier"),4&o.valid||e(3,"missing image size specifier"),o}(s),o=a.width,l=a.height,c=function(t,n,i){const r=n;if(r<8||r>32767||2!==t[0]||2!==t[1]||128&t[2])return new Uint8Array(t);r!==(t[2]<<8|t[3])&&e(3,"wrong scanline width");const s=new Uint8Array(4*n*i);s.length||e(4,"unable to allocate buffer space");let a=0,o=0;const l=4*r,c=new Uint8Array(4),h=new Uint8Array(l);let u=i;for(;u>0&&ot.byteLength&&e(1),c[0]=t[o++],c[1]=t[o++],c[2]=t[o++],c[3]=t[o++],2==c[0]&&2==c[1]&&(c[2]<<8|c[3])==r||e(3,"bad rgbe scanline format");let n,i=0;for(;i128;if(r&&(n-=128),(0===n||i+n>l)&&e(3,"bad scanline data"),r){const e=t[o++];for(let t=0;t>n&(1<>6}const h={c:0,lc:0};function u(t,e,n,i){t=t<<8|F(n,i),e+=8,h.c=t,h.lc=e}const d={c:0,lc:0};function p(t,e,n,i,r,s,a,o,l){if(t==e){i<8&&(u(n,i,r,s),n=h.c,i=h.lc);let t=n>>(i-=8);if(t=new Uint8Array([t])[0],o.value+t>l)return!1;const e=a[o.value-1];for(;t-- >0;)a[o.value++]=e}else{if(!(o.value32767?e-65536:e}const g={a:0,b:0};function A(t,e){const n=m(t),i=m(e),r=n+(1&i)+(i>>1),s=r,a=r-i;g.a=s,g.b=a}function v(t,e){const n=f(t),i=f(e),r=n-(i>>1)&65535,s=i+r-32768&65535;g.a=s,g.b=r}function y(t,e,n,i,r,s,a){const o=a<16384,l=n>r?r:n;let c,h,u=1;for(;u<=l;)u<<=1;for(u>>=1,c=u,u>>=1;u>=1;){h=0;const a=h+s*(r-c),l=s*u,d=s*c,p=i*u,f=i*c;let m,y,_,x;for(;h<=a;h+=d){let r=h;const s=h+i*(n-c);for(;r<=s;r+=f){const n=r+p,i=r+l,s=i+p;o?(A(t[r+e],t[i+e]),m=g.a,_=g.b,A(t[n+e],t[s+e]),y=g.a,x=g.b,A(m,y),t[r+e]=g.a,t[n+e]=g.b,A(_,x),t[i+e]=g.a,t[s+e]=g.b):(v(t[r+e],t[i+e]),m=g.a,_=g.b,v(t[n+e],t[s+e]),y=g.a,x=g.b,v(m,y),t[r+e]=g.a,t[n+e]=g.b,v(_,x),t[i+e]=g.a,t[s+e]=g.b)}if(n&u){const n=r+l;o?A(t[r+e],t[n+e]):v(t[r+e],t[n+e]),m=g.a,t[n+e]=g.b,t[r+e]=m}}if(r&u){let r=h;const s=h+i*(n-c);for(;r<=s;r+=f){const n=r+p;o?A(t[r+e],t[n+e]):v(t[r+e],t[n+e]),m=g.a,t[n+e]=g.b,t[r+e]=m}}c=u,u>>=1}return h}function _(t,e,r,f,m,g){const A=r.value,v=N(e,r),y=N(e,r);r.value+=4;const _=N(e,r);if(r.value+=4,v<0||v>=i||y<0||y>=i)throw new Error("Something wrong with HUF_ENCSIZE");const x=new Array(i),w=new Array(16384);if(function(t){for(let e=0;e<16384;e++)t[e]={},t[e].len=0,t[e].lit=0,t[e].p=null}(w),function(t,e,n,r,l,c){const h=e;let u=0,d=0;for(;r<=l;r++){if(h.value-e.value>n)return!1;a(6,u,d,t,h);const i=s.l;if(u=s.c,d=s.lc,c[r]=i,63==i){if(h.value-e.value>n)throw new Error("Something wrong with hufUnpackEncTable");a(8,u,d,t,h);let i=s.l+6;if(u=s.c,d=s.lc,r+i>l+1)throw new Error("Something wrong with hufUnpackEncTable");for(;i--;)c[r++]=0;r--}else if(i>=59){let t=i-59+2;if(r+t>l+1)throw new Error("Something wrong with hufUnpackEncTable");for(;t--;)c[r++]=0;r--}}!function(t){for(let t=0;t<=58;++t)o[t]=0;for(let e=0;e0;--t){const n=e+o[t]>>1;o[t]=e,e=n}for(let e=0;e0&&(t[e]=n|o[n]++<<6)}}(c)}(t,r,f-(r.value-A),v,y,x),_>8*(f-(r.value-A)))throw new Error("Something wrong with hufUncompress");!function(t,e,i,r){for(;e<=i;e++){const i=c(t[e]),s=l(t[e]);if(i>>s)throw new Error("Invalid table entry");if(s>n){const t=r[i>>s-n];if(t.len)throw new Error("Invalid table entry");if(t.lit++,t.p){const e=t.p;t.p=new Array(t.lit);for(let n=0;n0;a--){const a=r[(i<=n;){const s=e[g>>A-n&16383];if(s.len)A-=s.len,p(s.lit,a,g,A,i,r,f,m,v),g=d.c,A=d.lc;else{if(!s.p)throw new Error("hufDecode issues");let e;for(e=0;e=n&&c(t[s.p[e]])==(g>>A-n&(1<>=_,A-=_;A>0;){const t=e[g<s||(e[r++]=t[n++],r>s));)e[r++]=t[i++]}function C(t){let e=t.byteLength;const n=new Array;let i=0;const r=new DataView(t);for(;e>0;){const t=r.getInt8(i++);if(t<0){const s=-t;e-=s+1;for(let t=0;t>8==255?r+=255&i:(n[r]=i,r++),t.value++}function M(t){const e=.5*Math.cos(.7853975),n=.5*Math.cos(3.14159/16),i=.5*Math.cos(3.14159/8),r=.5*Math.cos(3*3.14159/16),s=.5*Math.cos(.981746875),a=.5*Math.cos(3*3.14159/8),o=.5*Math.cos(1.374445625),l=new Array(4),c=new Array(4),h=new Array(4),u=new Array(4);for(let d=0;d<8;++d){const p=8*d;l[0]=i*t[p+2],l[1]=a*t[p+2],l[2]=i*t[p+6],l[3]=a*t[p+6],c[0]=n*t[p+1]+r*t[p+3]+s*t[p+5]+o*t[p+7],c[1]=r*t[p+1]-o*t[p+3]-n*t[p+5]-s*t[p+7],c[2]=s*t[p+1]-n*t[p+3]+o*t[p+5]+r*t[p+7],c[3]=o*t[p+1]-s*t[p+3]+r*t[p+5]-n*t[p+7],h[0]=e*(t[p+0]+t[p+4]),h[3]=e*(t[p+0]-t[p+4]),h[1]=l[0]+l[3],h[2]=l[1]-l[2],u[0]=h[0]+h[1],u[1]=h[3]+h[2],u[2]=h[3]-h[2],u[3]=h[0]-h[1],t[p+0]=u[0]+c[0],t[p+1]=u[1]+c[1],t[p+2]=u[2]+c[2],t[p+3]=u[3]+c[3],t[p+4]=u[3]-c[3],t[p+5]=u[2]-c[2],t[p+6]=u[1]-c[1],t[p+7]=u[0]-c[0]}for(let d=0;d<8;++d)l[0]=i*t[16+d],l[1]=a*t[16+d],l[2]=i*t[48+d],l[3]=a*t[48+d],c[0]=n*t[8+d]+r*t[24+d]+s*t[40+d]+o*t[56+d],c[1]=r*t[8+d]-o*t[24+d]-n*t[40+d]-s*t[56+d],c[2]=s*t[8+d]-n*t[24+d]+o*t[40+d]+r*t[56+d],c[3]=o*t[8+d]-s*t[24+d]+r*t[40+d]-n*t[56+d],h[0]=e*(t[d]+t[32+d]),h[3]=e*(t[d]-t[32+d]),h[1]=l[0]+l[3],h[2]=l[1]-l[2],u[0]=h[0]+h[1],u[1]=h[3]+h[2],u[2]=h[3]-h[2],u[3]=h[0]-h[1],t[0+d]=u[0]+c[0],t[8+d]=u[1]+c[1],t[16+d]=u[2]+c[2],t[24+d]=u[3]+c[3],t[32+d]=u[3]-c[3],t[40+d]=u[2]-c[2],t[48+d]=u[1]-c[1],t[56+d]=u[0]-c[0]}function b(t){for(let e=0;e<64;++e){const n=t[0][e],i=t[1][e],r=t[2][e];t[0][e]=n+1.5747*r,t[1][e]=n-.1873*i-.4682*r,t[2][e]=n+1.8556*i}}function S(t,e,n){for(let s=0;s<64;++s)e[n+s]=ys.toHalfFloat((i=t[s])<=1?Math.sign(i)*Math.pow(Math.abs(i),2.2):Math.sign(i)*Math.pow(r,Math.abs(i)-1));var i}function I(t){return new DataView(t.array.buffer,t.offset.value,t.size)}function T(t){const e=t.viewer.buffer.slice(t.offset.value,t.offset.value+t.size),n=new Uint8Array(C(e)),i=new Uint8Array(n.length);return x(n),w(n,i),new DataView(i.buffer)}function B(t){const e=Kv(t.array.slice(t.offset.value,t.offset.value+t.size)),n=new Uint8Array(e.length);return x(e),w(e,n),new DataView(n.buffer)}function R(t){const n=t.viewer,i={value:t.offset.value},r=new Uint16Array(t.columns*t.lines*(t.inputChannels.length*t.type)),s=new Uint8Array(8192);let a=0;const o=new Array(t.inputChannels.length);for(let e=0,n=t.inputChannels.length;e=8192)throw new Error("Something is wrong with PIZ_COMPRESSION BITMAP_SIZE");if(l<=c)for(let t=0;t>3]&1<<(7&r))&&(n[i++]=r);const r=i-1;for(;i0;){const t=L(e.buffer,n),i=O(e,n),r=i>>2&3,o=new Int8Array([(i>>4)-1])[0],l=O(e,n);s.push({name:t,index:o,type:l,compression:r}),a-=t.length+3}const o=Z.channels,l=new Array(t.inputChannels.length);for(let e=0;e=0&&(c.idx[i.index]=e),t.offset=e)}}let h,u,d;if(r.acCompressedSize>0)switch(r.acCompression){case 0:h=new Uint16Array(r.totalAcUncompressedCount),_(t.array,e,n,r.acCompressedSize,h,r.totalAcUncompressedCount);break;case 1:const i=Kv(t.array.slice(n.value,n.value+r.totalAcUncompressedCount));h=new Uint16Array(i.buffer),n.value+=r.totalAcUncompressedCount}if(r.dcCompressedSize>0){const e={array:t.array,offset:n,size:r.dcCompressedSize};u=new Uint16Array(B(e).buffer),n.value+=r.dcCompressedSize}r.rleRawSize>0&&(d=C(Kv(t.array.slice(n.value,n.value+r.rleCompressedSize)).buffer),n.value+=r.rleCompressedSize);let p=0;const f=new Array(l.length);for(let t=0;t>10,n=1023&t;return(t>>15?-1:1)*(e?31===e?n?NaN:1/0:Math.pow(2,e-15)*(1+n/1024):n/1024*6103515625e-14)}function H(t,e){const n=t.getUint16(e.value,!0);return e.value+=2,n}function V(t,e){return G(H(t,e))}function W(t,e,n,i,r){return"string"===i||"stringvector"===i||"iccProfile"===i?function(t,e,n){const i=(new TextDecoder).decode(new Uint8Array(t).slice(e.value,e.value+n));return e.value=e.value+n,i}(e,n,r):"chlist"===i?function(t,e,n,i){const r=n.value,s=[];for(;n.value>4]}}(t,n):"lineOrder"===i?function(t,e){return["INCREASING_Y","DECREASING_Y","RANDOM_Y"][O(t,e)]}(t,n):"float"===i?Q(t,n):"v2f"===i?function(t,e){return[Q(t,e),Q(t,e)]}(t,n):"v3f"===i?function(t,e){return[Q(t,e),Q(t,e),Q(t,e)]}(t,n):"int"===i?U(t,n):"rational"===i?function(t,e){return[U(t,e),N(t,e)]}(t,n):"timecode"===i?function(t,e){return[N(t,e),N(t,e)]}(t,n):"preview"===i?(n.value+=r,"skipped"):void(n.value+=r)}function j(t,e,n,i){const r=new Array(t);for(let s=0;st.width?t.width-s:t.blockWidth,t.lines=a+t.blockHeight>t.height?t.height-a:t.blockHeight;const o=t.columns*t.totalBytes,l=t.sizet.height?t.height-r:t.blockHeight;const s=t.columns*t.totalBytes,a=t.size=t.height)continue;const l=e*s,c=(t.height-1-o)*t.outLineWidth;for(let e=0;et:s.scanOrder=t=>s.height-1-t,4==s.outputChannels?(s.format=$t,s.colorSpace=un):(s.format=re,s.colorSpace=cn),t.spec.singleTile){s.blockHeight=t.tiles.ySize,s.blockWidth=t.tiles.xSize;const n=function(t,e,n){let i=0;switch(t.levelMode){case"ONE_LEVEL":i=1;break;case"MIPMAP_LEVELS":i=function(t,e){const n=Math.log2(t);return"ROUND_DOWN"==e?Math.floor(n):Math.ceil(n)}(Math.max(e,n),t.roundingMode)+1;break;case"RIPMAP_LEVELS":throw new Error("THREE.EXRLoader: RIPMAP_LEVELS tiles currently unsupported.")}return i}(t.tiles,s.width,s.height),r=j(n,s.width,t.tiles.xSize,t.tiles.roundingMode),a=j(n,s.height,t.tiles.ySize,t.tiles.roundingMode);s.tileCount=r[0]*a[0];for(let t=0;t{const r=t.xr.getSession();"requestLightProbe"in r&&r.requestLightProbe({reflectionFormat:r.preferredReflectionFormat}).then((r=>{n=new Iy(this,t,r,e,(()=>{i=!0,this.dispatchEvent({type:"estimationstart"})}))}))})),t.xr.addEventListener("sessionend",(()=>{n&&(n.dispose(),n=null),i&&this.dispatchEvent({type:"estimationend"})})),this.dispose=()=>{n&&(n.dispose(),n=null),this.remove(this.lightProbe),this.lightProbe=null,this.remove(this.directionalLight),this.directionalLight=null,this.environment=null}}},e.TransformControls=class extends dm{constructor(t,e=null){super(void 0,e);const n=new O_(this);this._root=n;const i=new k_;this._gizmo=i,n.add(i);const r=new Q_;this._plane=r,n.add(r);const s=this;function a(t,e){let n=e;Object.defineProperty(s,t,{get:function(){return void 0!==n?n:e},set:function(e){n!==e&&(n=e,r[t]=e,i[t]=e,s.dispatchEvent({type:t+"-changed",value:e}),s.dispatchEvent(f_))}}),s[t]=e,r[t]=e,i[t]=e}a("camera",t),a("object",void 0),a("enabled",!0),a("axis",null),a("mode","translate"),a("translationSnap",null),a("rotationSnap",null),a("scaleSnap",null),a("space","world"),a("size",1),a("dragging",!1),a("showX",!0),a("showY",!0),a("showZ",!0),a("minX",-1/0),a("maxX",1/0),a("minY",-1/0),a("maxY",1/0),a("minZ",-1/0),a("maxZ",1/0);const o=new Gi,l=new Gi,c=new zi,h=new zi,u=new Gi,d=new zi,p=new Gi,f=new Gi,m=new Gi,g=new Gi;a("worldPosition",o),a("worldPositionStart",l),a("worldQuaternion",c),a("worldQuaternionStart",h),a("cameraPosition",u),a("cameraQuaternion",d),a("pointStart",p),a("pointEnd",f),a("rotationAxis",m),a("rotationAngle",0),a("eye",g),this._offset=new Gi,this._startNorm=new Gi,this._endNorm=new Gi,this._cameraScale=new Gi,this._parentPosition=new Gi,this._parentQuaternion=new zi,this._parentQuaternionInv=new zi,this._parentScale=new Gi,this._worldScaleStart=new Gi,this._worldQuaternionInv=new zi,this._worldScale=new Gi,this._positionStart=new Gi,this._quaternionStart=new zi,this._scaleStart=new Gi,this._getPointer=v_.bind(this),this._onPointerDown=__.bind(this),this._onPointerHover=y_.bind(this),this._onPointerMove=x_.bind(this),this._onPointerUp=w_.bind(this),null!==e&&this.connect()}connect(){this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="auto"}getHelper(){return this._root}pointerHover(t){if(void 0===this.object||!0===this.dragging)return;null!==t&&c_.setFromCamera(t,this.camera);const e=C_(this._gizmo.picker[this.mode],c_);this.axis=e?e.object.name:null}pointerDown(t){if(void 0!==this.object&&!0!==this.dragging&&(null==t||0===t.button)&&null!==this.axis){null!==t&&c_.setFromCamera(t,this.camera);const e=C_(this._plane,c_,!0);e&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(e.point).sub(this.worldPositionStart)),this.dragging=!0,m_.mode=this.mode,this.dispatchEvent(m_)}}pointerMove(t){const e=this.axis,n=this.mode,i=this.object;let r=this.space;if("scale"===n?r="local":"E"!==e&&"XYZE"!==e&&"XYZ"!==e||(r="world"),void 0===i||null===e||!1===this.dragging||null!==t&&-1!==t.button)return;null!==t&&c_.setFromCamera(t,this.camera);const s=C_(this._plane,c_,!0);if(s){if(this.pointEnd.copy(s.point).sub(this.worldPositionStart),"translate"===n)this._offset.copy(this.pointEnd).sub(this.pointStart),"local"===r&&"XYZ"!==e&&this._offset.applyQuaternion(this._worldQuaternionInv),-1===e.indexOf("X")&&(this._offset.x=0),-1===e.indexOf("Y")&&(this._offset.y=0),-1===e.indexOf("Z")&&(this._offset.z=0),"local"===r&&"XYZ"!==e?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),i.position.copy(this._offset).add(this._positionStart),this.translationSnap&&("local"===r&&(i.position.applyQuaternion(d_.copy(this._quaternionStart).invert()),-1!==e.search("X")&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),-1!==e.search("Y")&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),-1!==e.search("Z")&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.position.applyQuaternion(this._quaternionStart)),"world"===r&&(i.parent&&i.position.add(h_.setFromMatrixPosition(i.parent.matrixWorld)),-1!==e.search("X")&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),-1!==e.search("Y")&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),-1!==e.search("Z")&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.parent&&i.position.sub(h_.setFromMatrixPosition(i.parent.matrixWorld)))),i.position.x=Math.max(this.minX,Math.min(this.maxX,i.position.x)),i.position.y=Math.max(this.minY,Math.min(this.maxY,i.position.y)),i.position.z=Math.max(this.minZ,Math.min(this.maxZ,i.position.z));else if("scale"===n){if(-1!==e.search("XYZ")){let t=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(t*=-1),u_.set(t,t,t)}else h_.copy(this.pointStart),u_.copy(this.pointEnd),h_.applyQuaternion(this._worldQuaternionInv),u_.applyQuaternion(this._worldQuaternionInv),u_.divide(h_),-1===e.search("X")&&(u_.x=1),-1===e.search("Y")&&(u_.y=1),-1===e.search("Z")&&(u_.z=1);i.scale.copy(this._scaleStart).multiply(u_),this.scaleSnap&&(-1!==e.search("X")&&(i.scale.x=Math.round(i.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==e.search("Y")&&(i.scale.y=Math.round(i.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==e.search("Z")&&(i.scale.z=Math.round(i.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if("rotate"===n){this._offset.copy(this.pointEnd).sub(this.pointStart);const t=20/this.worldPosition.distanceTo(h_.setFromMatrixPosition(this.camera.matrixWorld));let n=!1;"XYZE"===e?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(h_.copy(this.rotationAxis).cross(this.eye))*t):"X"!==e&&"Y"!==e&&"Z"!==e||(this.rotationAxis.copy(p_[e]),h_.copy(p_[e]),"local"===r&&h_.applyQuaternion(this.worldQuaternion),h_.cross(this.eye),0===h_.length()?n=!0:this.rotationAngle=this._offset.dot(h_.normalize())*t),("E"===e||n)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),"local"===r&&"E"!==e&&"XYZE"!==e?(i.quaternion.copy(this._quaternionStart),i.quaternion.multiply(d_.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),i.quaternion.copy(d_.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),i.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(f_),this.dispatchEvent(A_)}}pointerUp(t){null!==t&&0!==t.button||(this.dragging&&null!==this.axis&&(g_.mode=this.mode,this.dispatchEvent(g_)),this.dragging=!1,this.axis=null)}dispose(){this.disconnect(),this._root.dispose()}attach(t){return this.object=t,this._root.visible=!0,this}detach(){return this.object=void 0,this.axis=null,this._root.visible=!1,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(f_),this.dispatchEvent(A_),this.pointStart.copy(this.pointEnd))}getRaycaster(){return c_}getMode(){return this.mode}setMode(t){this.mode=t}setTranslationSnap(t){this.translationSnap=t}setRotationSnap(t){this.rotationSnap=t}setScaleSnap(t){this.scaleSnap=t}setSize(t){this.size=t}setSpace(t){this.space=t}},e.CSS3DRenderer=class{constructor(t={}){const e=this;let n,i,r,s;const a={camera:{style:""},objects:new WeakMap},o=void 0!==t.element?t.element:document.createElement("div");o.style.overflow="hidden",this.domElement=o;const l=document.createElement("div");l.style.transformOrigin="0 0",l.style.pointerEvents="none",o.appendChild(l);const c=document.createElement("div");function h(t){return Math.abs(t)<1e-10?0:t}function u(t){const e=t.elements;return"matrix3d("+h(e[0])+","+h(-e[1])+","+h(e[2])+","+h(e[3])+","+h(e[4])+","+h(-e[5])+","+h(e[6])+","+h(e[7])+","+h(e[8])+","+h(-e[9])+","+h(e[10])+","+h(e[11])+","+h(e[12])+","+h(-e[13])+","+h(e[14])+","+h(e[15])+")"}function d(t){const e=t.elements;return"translate(-50%,-50%)matrix3d("+h(e[0])+","+h(e[1])+","+h(e[2])+","+h(e[3])+","+h(-e[4])+","+h(-e[5])+","+h(-e[6])+","+h(-e[7])+","+h(e[8])+","+h(e[9])+","+h(e[10])+","+h(e[11])+","+h(e[12])+","+h(e[13])+","+h(e[14])+","+h(e[15])+")"}function p(t){t.isCSS3DObject&&(t.element.style.display="none");for(let e=0,n=t.children.length;et.dispatchEvent({type:"fade-start"}),n.onFadeSetComplete=()=>t.dispatchEvent({type:"fade-end"}),n.onFadeComplete=dD.bind(this),this.tiles=t,this._fadeManager=n,this._fadeGroup=e,this._tileMap=new Map,this._prevCameraTransforms=new Map,t.cameras.forEach((t=>{this._prevCameraTransforms.set(t,new vr)})),this._onLoadModel=t=>hD.call(this,t.scene,t.tile),this._onDisposeModel=t=>uD.call(this,t.scene),this._onTileVisibilityChange=t=>cD.call(this,t.scene,t.tile,t.visible),this._onAddCamera=t=>pD.call(this,t.camera),this._onDeleteCamera=t=>fD.call(this,t.camera),this._onUpdateBefore=()=>mD.call(this),this._onUpdateAfter=()=>gD.call(this),t.addEventListener("load-model",this._onLoadModel),t.addEventListener("dispose-model",this._onDisposeModel),t.addEventListener("tile-visibility-change",this._onTileVisibilityChange),t.addEventListener("add-camera",this._onAddCamera),t.addEventListener("delete-camera",this._onDeleteCamera),t.addEventListener("update-before",this._onUpdateBefore),t.addEventListener("update-after",this._onUpdateAfter)}dispose(){const t=this.tiles;t.removeEventListener("load-model",this._onLoadModel),t.removeEventListener("dispose-model",this._onDisposeModel),t.removeEventListener("tile-visibility-change",this._onTileVisibilityChange),t.removeEventListener("add-camera",this._onAddCamera),t.removeEventListener("delete-camera",this._onDeleteCamera),t.removeEventListener("update-before",this._onUpdateBefore),t.removeEventListener("update-after",this._onUpdateAfter)}},window.THREE=e,window.ThreeMeshUI=zw,window.ThreeMeshBVH=h,window.TILES=d,window.CustomShaderMaterial=class extends ps{constructor({baseMaterial:t,vertexShader:e,fragmentShader:n,uniforms:i,patchMap:r,cacheKey:s,...a}){if(!t)throw new Error("CustomShaderMaterial: baseMaterial is required.");let o;if(function(t){try{new t}catch(t){if(t.message.indexOf("is not a constructor")>=0)return!1}return!0}(t)){const e=0===Object.keys(a).length;o=new t(e?void 0:a)}else o=t,Object.assign(o,a);if(["ShaderMaterial","RawShaderMaterial"].includes(o.type))throw new Error(`CustomShaderMaterial does not support ${o.type} as a base material.`);super(),this.uniforms={},this.vertexShader="",this.fragmentShader="";const l=o;l.name=`CustomShaderMaterial<${o.name||o.type}>`,l.update=this.update.bind(l),l.__csm={prevOnBeforeCompile:o.onBeforeCompile};const c={...l.uniforms||{},...i||{}};l.uniforms=this.uniforms=c,l.vertexShader=this.vertexShader=e||"",l.fragmentShader=this.fragmentShader=n||"",l.update({fragmentShader:l.fragmentShader,vertexShader:l.vertexShader,uniforms:l.uniforms,patchMap:r,cacheKey:s}),Object.assign(this,l);const h=Object.getOwnPropertyDescriptors(Object.getPrototypeOf(l));for(const t in h){const e=h[t];(e.get||e.set)&&Object.defineProperty(this,t,e)}return Object.defineProperty(this,"type",{get:()=>o.type,set(t){o.type=t}}),this}update({fragmentShader:t,vertexShader:e,uniforms:n,cacheKey:i,patchMap:r}){const s=hx(e||""),a=hx(t||""),o=this;n&&(o.uniforms=n),e&&(o.vertexShader=e),t&&(o.fragmentShader=t),Object.entries(cx).forEach((([t,e])=>{for(const n in e){const i=e[n];(a&&a.includes(i)||s&&s.includes(i))&&(o[t]||(o[t]=1))}}));const l=o.__csm.prevOnBeforeCompile,c=(t,e,n)=>{var i;let r,s="";if(e){const t=/void\s+main\s*\(\s*\)[^{]*{((?:[^{}]+|{(?:[^{}]+|{(?:[^{}]+|{(?:[^{}]+|{[^{}]*})*})*})*})*})/gm;r=null==(i=e.matchAll(t).next().value)?void 0:i[1],r&&(r=r.slice(0,-1));const n=/void\s+main\s*\(\s*\)\s*{/gm,a=e.search(n);s=e.slice(0,a)}if(n&&e&&e.includes(ex)&&r&&(r="csm_UnlitFac = 1.0;\n"+r),t.includes("//~CSM_DEFAULTS")){const e=(t=t.replace("void main() {",`\n // THREE-CustomShaderMaterial by Faraz Shaikh: https://github.com/FarazzShaikh/THREE-CustomShaderMaterial\n \n ${s}\n \n void main() {\n `)).lastIndexOf("//~CSM_MAIN_END");if(-1!==e){const n=`\n ${r?`${r}`:""}\n //~CSM_MAIN_END\n `;t=t.slice(0,e)+n+t.slice(e)}}else{const e=/void\s*main\s*\(\s*\)\s*{/gm;t=t.replace(e,`\n // THREE-CustomShaderMaterial by Faraz Shaikh: https://github.com/FarazzShaikh/THREE-CustomShaderMaterial\n \n //~CSM_DEFAULTS\n \n varying mat4 csm_internal_vModelViewMatrix;\n\n \n \n#ifdef IS_VERTEX\n vec3 csm_Position;\n vec4 csm_PositionRaw;\n vec3 csm_Normal;\n\n // csm_PointSize\n #ifdef IS_POINTSMATERIAL\n float csm_PointSize;\n #endif\n#else\n vec4 csm_DiffuseColor;\n vec4 csm_FragColor;\n float csm_UnlitFac;\n\n // csm_Emissive, csm_Roughness, csm_Metalness\n #if defined IS_MESHSTANDARDMATERIAL || defined IS_MESHPHYSICALMATERIAL\n vec3 csm_Emissive;\n float csm_Roughness;\n float csm_Metalness;\n float csm_Iridescence;\n \n #if defined IS_MESHPHYSICALMATERIAL\n float csm_Clearcoat;\n float csm_ClearcoatRoughness;\n vec3 csm_ClearcoatNormal;\n float csm_Transmission;\n float csm_Thickness;\n #endif\n #endif\n\n // csm_AO\n #if defined IS_MESHSTANDARDMATERIAL || defined IS_MESHPHYSICALMATERIAL || defined IS_MESHBASICMATERIAL || defined IS_MESHLAMBERTMATERIAL || defined IS_MESHPHONGMATERIAL || defined IS_MESHTOONMATERIAL\n float csm_AO;\n #endif\n\n // csm_Bump\n #if defined IS_MESHLAMBERTMATERIAL || defined IS_MESHMATCAPMATERIAL || defined IS_MESHNORMALMATERIAL || defined IS_MESHPHONGMATERIAL || defined IS_MESHPHYSICALMATERIAL || defined IS_MESHSTANDARDMATERIAL || defined IS_MESHTOONMATERIAL || defined IS_SHADOWMATERIAL \n vec3 csm_Bump;\n vec3 csm_FragNormal;\n #endif\n\n float csm_DepthAlpha;\n#endif\n\n \n ${s}\n \n void main() {\n {\n \n\n#ifdef IS_VERTEX\n // csm_Position & csm_PositionRaw\n #ifdef IS_UNKNOWN\n csm_Position = vec3(0.0);\n csm_PositionRaw = vec4(0.0);\n csm_Normal = vec3(0.0);\n #else\n csm_Position = position;\n csm_PositionRaw = projectionMatrix * modelViewMatrix * vec4(position, 1.);\n csm_Normal = normal;\n #endif\n\n // csm_PointSize\n #ifdef IS_POINTSMATERIAL\n csm_PointSize = size;\n #endif\n#else\n csm_UnlitFac = 0.0;\n\n // csm_DiffuseColor & csm_FragColor\n #if defined IS_UNKNOWN || defined IS_SHADERMATERIAL || defined IS_MESHDEPTHMATERIAL || defined IS_MESHDISTANCEMATERIAL || defined IS_MESHNORMALMATERIAL || defined IS_SHADOWMATERIAL\n csm_DiffuseColor = vec4(1.0, 0.0, 1.0, 1.0);\n csm_FragColor = vec4(1.0, 0.0, 1.0, 1.0);\n #else\n #ifdef USE_MAP\n vec4 _csm_sampledDiffuseColor = texture2D(map, vMapUv);\n\n #ifdef DECODE_VIDEO_TEXTURE\n // inline sRGB decode (TODO: Remove this code when https://crbug.com/1256340 is solved)\n _csm_sampledDiffuseColor = vec4(mix(pow(_csm_sampledDiffuseColor.rgb * 0.9478672986 + vec3(0.0521327014), vec3(2.4)), _csm_sampledDiffuseColor.rgb * 0.0773993808, vec3(lessThanEqual(_csm_sampledDiffuseColor.rgb, vec3(0.04045)))), _csm_sampledDiffuseColor.w);\n #endif\n\n csm_DiffuseColor = vec4(diffuse, opacity) * _csm_sampledDiffuseColor;\n csm_FragColor = vec4(diffuse, opacity) * _csm_sampledDiffuseColor;\n #else\n csm_DiffuseColor = vec4(diffuse, opacity);\n csm_FragColor = vec4(diffuse, opacity);\n #endif\n #endif\n\n // csm_Emissive, csm_Roughness, csm_Metalness\n #if defined IS_MESHSTANDARDMATERIAL || defined IS_MESHPHYSICALMATERIAL\n csm_Emissive = emissive;\n csm_Roughness = roughness;\n csm_Metalness = metalness;\n\n #ifdef USE_IRIDESCENCE\n csm_Iridescence = iridescence;\n #else\n csm_Iridescence = 0.0;\n #endif\n\n #if defined IS_MESHPHYSICALMATERIAL\n #ifdef USE_CLEARCOAT\n csm_Clearcoat = clearcoat;\n csm_ClearcoatRoughness = clearcoatRoughness;\n #else\n csm_Clearcoat = 0.0;\n csm_ClearcoatRoughness = 0.0;\n #endif\n\n #ifdef USE_TRANSMISSION\n csm_Transmission = transmission;\n csm_Thickness = thickness;\n #else\n csm_Transmission = 0.0;\n csm_Thickness = 0.0;\n #endif\n #endif\n #endif\n\n // csm_AO\n #if defined IS_MESHSTANDARDMATERIAL || defined IS_MESHPHYSICALMATERIAL || defined IS_MESHBASICMATERIAL || defined IS_MESHLAMBERTMATERIAL || defined IS_MESHPHONGMATERIAL || defined IS_MESHTOONMATERIAL\n csm_AO = 0.0;\n #endif\n\n // csm_Bump\n #if defined IS_MESHLAMBERTMATERIAL || defined IS_MESHMATCAPMATERIAL || defined IS_MESHNORMALMATERIAL || defined IS_MESHPHONGMATERIAL || defined IS_MESHPHYSICALMATERIAL || defined IS_MESHSTANDARDMATERIAL || defined IS_MESHTOONMATERIAL || defined IS_SHADOWMATERIAL \n csm_Bump = vec3(0.0);\n #ifdef FLAT_SHADED\n vec3 fdx = dFdx( vViewPosition );\n vec3 fdy = dFdy( vViewPosition );\n csm_FragNormal = normalize( cross( fdx, fdy ) );\n #else\n csm_FragNormal = normalize(vNormal);\n #ifdef DOUBLE_SIDED\n csm_FragNormal *= gl_FrontFacing ? 1.0 : - 1.0;\n #endif\n #endif\n #endif\n\n csm_DepthAlpha = 1.0;\n#endif\n\n }\n ${n?"\n \n":"\n csm_internal_vModelViewMatrix = modelViewMatrix;\n"}\n\n ${r?`${r}`:""}\n //~CSM_MAIN_END\n `)}return t};o.onBeforeCompile=(t,e)=>{null==l||l(t,e);const i=r||{},h=o.type,u=h?`#define IS_${h.toUpperCase()};\n`:"#define IS_UNKNOWN;\n";t.vertexShader=u+"#define IS_VERTEX\n"+t.vertexShader,t.fragmentShader=u+"#define IS_FRAGMENT\n"+t.fragmentShader;const d=e=>{for(const n in e){const i="*"===n||s&&s.includes(n);if("*"===n||a&&a.includes(n)||i){const i=ox[n];if(i&&"*"!==i&&(Array.isArray(i)?!i.includes(h):i!==h))return void console.error(`CustomShaderMaterial: ${n} is not available in ${h}. Shader cannot compile.`);const r=e[n];for(const e in r){const n=r[e];if("object"==typeof n){const i=n.type,r=n.value;"fs"===i?t.fragmentShader=t.fragmentShader.replace(e,r):"vs"===i&&(t.vertexShader=t.vertexShader.replace(e,r))}else n&&(t.vertexShader=t.vertexShader.replace(e,n),t.fragmentShader=t.fragmentShader.replace(e,n))}}}};d(lx),d(i),t.vertexShader=c(t.vertexShader,s,!1),t.fragmentShader=c(t.fragmentShader,a,!0),n&&(t.uniforms={...t.uniforms,...o.uniforms}),o.uniforms=t.uniforms};const h=o.customProgramCacheKey;o.customProgramCacheKey=()=>((null==i?void 0:i())||function(t){let e=0;for(let n=0;n>>0)}((s||"")+(a||"")))+(null==h?void 0:h.call(o)),o.needsUpdate=!0}}})(); \ No newline at end of file +(()=>{"use strict";var t={d:(e,n)=>{for(var i in n)t.o(n,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:n[i]})}};t.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),t.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),t.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var e={};t.r(e),t.d(e,{ACESFilmicToneMapping:()=>mt,AddEquation:()=>L,AddOperation:()=>ht,AdditiveAnimationBlendMode:()=>$e,AdditiveBlending:()=>B,AgXToneMapping:()=>At,AlphaFormat:()=>Zt,AlwaysCompare:()=>On,AlwaysDepth:()=>et,AlwaysStencilFunc:()=>Bn,AmbientLight:()=>Mp,AnimationAction:()=>mf,AnimationClip:()=>Yd,AnimationLoader:()=>rp,AnimationMixer:()=>Af,AnimationObjectGroup:()=>ff,AnimationUtils:()=>Nd,ArcCurve:()=>eu,ArrayCamera:()=>nc,ArrowHelper:()=>hm,AttachedBindMode:()=>yt,Audio:()=>Zp,AudioAnalyser:()=>sf,AudioContext:()=>kp,AudioListener:()=>Kp,AudioLoader:()=>Qp,AxesHelper:()=>um,BackSide:()=>b,BasicDepthPacking:()=>rn,BasicShadowMap:()=>_,BatchedMesh:()=>Mh,Bone:()=>Xc,BooleanKeyframeTrack:()=>Gd,Box2:()=>Rf,Box3:()=>ji,Box3Helper:()=>sm,BoxGeometry:()=>ta,BoxHelper:()=>rm,BufferAttribute:()=>Cs,BufferGeometry:()=>Qs,BufferGeometryLoader:()=>Dp,ByteType:()=>zt,Cache:()=>Kd,Camera:()=>aa,CameraHelper:()=>em,CanvasTexture:()=>Zh,CapsuleGeometry:()=>wu,CatmullRomCurve3:()=>ou,CineonToneMapping:()=>ft,CircleGeometry:()=>Cu,ClampToEdgeWrapping:()=>It,Clock:()=>Wp,Color:()=>us,ColorKeyframeTrack:()=>Hd,ColorManagement:()=>xi,CompressedArrayTexture:()=>Jh,CompressedCubeTexture:()=>Kh,CompressedTexture:()=>Yh,CompressedTextureLoader:()=>sp,ConeGeometry:()=>Mu,ConstantAlphaFactor:()=>Z,ConstantColorFactor:()=>J,Controls:()=>pm,CubeCamera:()=>da,CubeReflectionMapping:()=>wt,CubeRefractionMapping:()=>Ct,CubeTexture:()=>pa,CubeTextureLoader:()=>op,CubeUVReflectionMapping:()=>bt,CubicBezierCurve:()=>uu,CubicBezierCurve3:()=>du,CubicInterpolant:()=>Od,CullFaceBack:()=>v,CullFaceFront:()=>y,CullFaceFrontBack:()=>x,CullFaceNone:()=>A,Curve:()=>$h,CurvePath:()=>yu,CustomBlending:()=>P,CustomToneMapping:()=>gt,CylinderGeometry:()=>Eu,Cylindrical:()=>If,Data3DTexture:()=>Qi,DataArrayTexture:()=>Oi,DataTexture:()=>Yc,DataTextureLoader:()=>lp,DataUtils:()=>xs,DecrementStencilOp:()=>yn,DecrementWrapStencilOp:()=>_n,DefaultLoadingManager:()=>$d,DepthFormat:()=>ie,DepthStencilFormat:()=>re,DepthTexture:()=>ao,DetachedBindMode:()=>xt,DirectionalLight:()=>Ep,DirectionalLightHelper:()=>Zf,DiscreteInterpolant:()=>Qd,DodecahedronGeometry:()=>Su,DoubleSide:()=>S,DstAlphaFactor:()=>W,DstColorFactor:()=>q,DynamicCopyUsage:()=>jn,DynamicDrawUsage:()=>Qn,DynamicReadUsage:()=>Hn,EdgesGeometry:()=>Du,EllipseCurve:()=>tu,EqualCompare:()=>Pn,EqualDepth:()=>rt,EqualStencilFunc:()=>Mn,EquirectangularReflectionMapping:()=>Et,EquirectangularRefractionMapping:()=>Mt,Euler:()=>Tr,EventDispatcher:()=>Zn,ExtrudeGeometry:()=>od,FileLoader:()=>ip,Float16BufferAttribute:()=>Rs,Float32BufferAttribute:()=>Ds,FloatType:()=>jt,Fog:()=>fc,FogExp2:()=>pc,FramebufferTexture:()=>Xh,FrontSide:()=>M,Frustum:()=>_a,GLBufferAttribute:()=>wf,GLSL1:()=>Xn,GLSL3:()=>Yn,GreaterCompare:()=>Un,GreaterDepth:()=>at,GreaterEqualCompare:()=>Fn,GreaterEqualDepth:()=>st,GreaterEqualStencilFunc:()=>Tn,GreaterStencilFunc:()=>Sn,GridHelper:()=>qf,Group:()=>ic,HalfFloatType:()=>qt,HemisphereLight:()=>up,HemisphereLightHelper:()=>jf,IcosahedronGeometry:()=>cd,ImageBitmapLoader:()=>Fp,ImageLoader:()=>ap,ImageUtils:()=>Ti,IncrementStencilOp:()=>vn,IncrementWrapStencilOp:()=>xn,InstancedBufferAttribute:()=>$c,InstancedBufferGeometry:()=>Rp,InstancedInterleavedBuffer:()=>_f,InstancedMesh:()=>oh,Int16BufferAttribute:()=>Ss,Int32BufferAttribute:()=>Ts,Int8BufferAttribute:()=>Es,IntType:()=>Vt,InterleavedBuffer:()=>gc,InterleavedBufferAttribute:()=>vc,Interpolant:()=>Fd,InterpolateDiscrete:()=>je,InterpolateLinear:()=>qe,InterpolateSmooth:()=>Xe,InvertStencilOp:()=>wn,KeepStencilOp:()=>gn,KeyframeTrack:()=>zd,LOD:()=>Fc,LatheGeometry:()=>_u,Layers:()=>Br,LessCompare:()=>Dn,LessDepth:()=>nt,LessEqualCompare:()=>Ln,LessEqualDepth:()=>it,LessEqualStencilFunc:()=>bn,LessStencilFunc:()=>En,Light:()=>hp,LightProbe:()=>Ip,Line:()=>Lh,Line3:()=>Lf,LineBasicMaterial:()=>bh,LineCurve:()=>pu,LineCurve3:()=>fu,LineDashedMaterial:()=>Bd,LineLoop:()=>kh,LineSegments:()=>Oh,LinearFilter:()=>Ut,LinearInterpolant:()=>kd,LinearMipMapLinearFilter:()=>kt,LinearMipMapNearestFilter:()=>Ft,LinearMipmapLinearFilter:()=>Ot,LinearMipmapNearestFilter:()=>Nt,LinearSRGBColorSpace:()=>dn,LinearToneMapping:()=>dt,LinearTransfer:()=>pn,Loader:()=>tp,LoaderUtils:()=>Bp,LoadingManager:()=>Zd,LoopOnce:()=>He,LoopPingPong:()=>We,LoopRepeat:()=>Ve,LuminanceAlphaFormat:()=>ne,LuminanceFormat:()=>ee,MOUSE:()=>m,Material:()=>fs,MaterialLoader:()=>Tp,MathUtils:()=>ci,Matrix2:()=>Tf,Matrix3:()=>ui,Matrix4:()=>yr,MaxEquation:()=>O,Mesh:()=>Zs,MeshBasicMaterial:()=>ms,MeshDepthMaterial:()=>ql,MeshDistanceMaterial:()=>Xl,MeshLambertMaterial:()=>Id,MeshMatcapMaterial:()=>Td,MeshNormalMaterial:()=>Sd,MeshPhongMaterial:()=>Md,MeshPhysicalMaterial:()=>Ed,MeshStandardMaterial:()=>Cd,MeshToonMaterial:()=>bd,MinEquation:()=>F,MirroredRepeatWrapping:()=>Tt,MixOperation:()=>ct,MultiplyBlending:()=>D,MultiplyOperation:()=>lt,NearestFilter:()=>Bt,NearestMipMapLinearFilter:()=>Lt,NearestMipMapNearestFilter:()=>Dt,NearestMipmapLinearFilter:()=>Pt,NearestMipmapNearestFilter:()=>Rt,NeutralToneMapping:()=>vt,NeverCompare:()=>Rn,NeverDepth:()=>tt,NeverStencilFunc:()=>Cn,NoBlending:()=>I,NoColorSpace:()=>hn,NoToneMapping:()=>ut,NormalAnimationBlendMode:()=>Ze,NormalBlending:()=>T,NotEqualCompare:()=>Nn,NotEqualDepth:()=>ot,NotEqualStencilFunc:()=>In,NumberKeyframeTrack:()=>Vd,Object3D:()=>jr,ObjectLoader:()=>Pp,ObjectSpaceNormalMap:()=>cn,OctahedronGeometry:()=>hd,OneFactor:()=>Q,OneMinusConstantAlphaFactor:()=>$,OneMinusConstantColorFactor:()=>K,OneMinusDstAlphaFactor:()=>j,OneMinusDstColorFactor:()=>X,OneMinusSrcAlphaFactor:()=>V,OneMinusSrcColorFactor:()=>G,OrthographicCamera:()=>Fa,PCFShadowMap:()=>w,PCFSoftShadowMap:()=>C,PMREMGenerator:()=>Xa,Path:()=>xu,PerspectiveCamera:()=>ha,Plane:()=>va,PlaneGeometry:()=>Ea,PlaneHelper:()=>am,PointLight:()=>wp,PointLightHelper:()=>Gf,Points:()=>Wh,PointsMaterial:()=>Qh,PolarGridHelper:()=>Xf,PolyhedronGeometry:()=>bu,PositionalAudio:()=>rf,PropertyBinding:()=>pf,PropertyMixer:()=>af,QuadraticBezierCurve:()=>mu,QuadraticBezierCurve3:()=>gu,Quaternion:()=>Gi,QuaternionKeyframeTrack:()=>jd,QuaternionLinearInterpolant:()=>Wd,RED_GREEN_RGTC2_Format:()=>ze,RED_RGTC1_Format:()=>ke,REVISION:()=>f,RGBADepthPacking:()=>sn,RGBAFormat:()=>te,RGBAIntegerFormat:()=>he,RGBA_ASTC_10x10_Format:()=>Pe,RGBA_ASTC_10x5_Format:()=>Be,RGBA_ASTC_10x6_Format:()=>Re,RGBA_ASTC_10x8_Format:()=>De,RGBA_ASTC_12x10_Format:()=>Le,RGBA_ASTC_12x12_Format:()=>Ue,RGBA_ASTC_4x4_Format:()=>we,RGBA_ASTC_5x4_Format:()=>Ce,RGBA_ASTC_5x5_Format:()=>Ee,RGBA_ASTC_6x5_Format:()=>Me,RGBA_ASTC_6x6_Format:()=>be,RGBA_ASTC_8x5_Format:()=>Se,RGBA_ASTC_8x6_Format:()=>Ie,RGBA_ASTC_8x8_Format:()=>Te,RGBA_BPTC_Format:()=>Ne,RGBA_ETC2_EAC_Format:()=>_e,RGBA_PVRTC_2BPPV1_Format:()=>ve,RGBA_PVRTC_4BPPV1_Format:()=>Ae,RGBA_S3TC_DXT1_Format:()=>de,RGBA_S3TC_DXT3_Format:()=>pe,RGBA_S3TC_DXT5_Format:()=>fe,RGBDepthPacking:()=>an,RGBFormat:()=>$t,RGBIntegerFormat:()=>ce,RGB_BPTC_SIGNED_Format:()=>Fe,RGB_BPTC_UNSIGNED_Format:()=>Oe,RGB_ETC1_Format:()=>ye,RGB_ETC2_Format:()=>xe,RGB_PVRTC_2BPPV1_Format:()=>ge,RGB_PVRTC_4BPPV1_Format:()=>me,RGB_S3TC_DXT1_Format:()=>ue,RGDepthPacking:()=>on,RGFormat:()=>oe,RGIntegerFormat:()=>le,RawShaderMaterial:()=>wd,Ray:()=>vr,Raycaster:()=>Ef,RectAreaLight:()=>bp,RedFormat:()=>se,RedIntegerFormat:()=>ae,ReinhardToneMapping:()=>pt,RenderTarget:()=>Ni,RepeatWrapping:()=>St,ReplaceStencilOp:()=>An,ReverseSubtractEquation:()=>N,RingGeometry:()=>ud,SIGNED_RED_GREEN_RGTC2_Format:()=>Ge,SIGNED_RED_RGTC1_Format:()=>Qe,SRGBColorSpace:()=>un,SRGBTransfer:()=>fn,Scene:()=>mc,ShaderChunk:()=>Ma,ShaderLib:()=>Sa,ShaderMaterial:()=>sa,ShadowMaterial:()=>_d,Shape:()=>Pu,ShapeGeometry:()=>dd,ShapePath:()=>dm,ShapeUtils:()=>rd,ShortType:()=>Gt,Skeleton:()=>Zc,SkeletonHelper:()=>Qf,SkinnedMesh:()=>qc,Source:()=>Ri,Sphere:()=>hr,SphereGeometry:()=>pd,Spherical:()=>Sf,SphericalHarmonics3:()=>Sp,SplineCurve:()=>Au,SpotLight:()=>Ap,SpotLightHelper:()=>Nf,Sprite:()=>Pc,SpriteMaterial:()=>yc,SrcAlphaFactor:()=>H,SrcAlphaSaturateFactor:()=>Y,SrcColorFactor:()=>z,StaticCopyUsage:()=>Wn,StaticDrawUsage:()=>kn,StaticReadUsage:()=>Gn,StereoCamera:()=>Vp,StreamCopyUsage:()=>qn,StreamDrawUsage:()=>zn,StreamReadUsage:()=>Vn,StringKeyframeTrack:()=>qd,SubtractEquation:()=>U,SubtractiveBlending:()=>R,TOUCH:()=>g,TangentSpaceNormalMap:()=>ln,TetrahedronGeometry:()=>fd,Texture:()=>Li,TextureLoader:()=>cp,TextureUtils:()=>$l,TorusGeometry:()=>md,TorusKnotGeometry:()=>gd,Triangle:()=>as,TriangleFanDrawMode:()=>nn,TriangleStripDrawMode:()=>en,TrianglesDrawMode:()=>tn,TubeGeometry:()=>Ad,UVMapping:()=>_t,Uint16BufferAttribute:()=>Is,Uint32BufferAttribute:()=>Bs,Uint8BufferAttribute:()=>Ms,Uint8ClampedBufferAttribute:()=>bs,Uniform:()=>vf,UniformsGroup:()=>xf,UniformsLib:()=>ba,UniformsUtils:()=>ra,UnsignedByteType:()=>Qt,UnsignedInt248Type:()=>Jt,UnsignedInt5999Type:()=>Kt,UnsignedIntType:()=>Wt,UnsignedShort4444Type:()=>Xt,UnsignedShort5551Type:()=>Yt,UnsignedShortType:()=>Ht,VSMShadowMap:()=>E,Vector2:()=>hi,Vector3:()=>Hi,Vector4:()=>Ui,VectorKeyframeTrack:()=>Xd,VideoTexture:()=>qh,WebGL3DRenderTarget:()=>zi,WebGLArrayRenderTarget:()=>ki,WebGLCoordinateSystem:()=>Jn,WebGLCubeRenderTarget:()=>fa,WebGLMultipleRenderTargets:()=>fm,WebGLRenderTarget:()=>Fi,WebGLRenderer:()=>dc,WebGLUtils:()=>ec,WebGPUCoordinateSystem:()=>Kn,WireframeGeometry:()=>vd,WrapAroundEnding:()=>Ke,ZeroCurvatureEnding:()=>Ye,ZeroFactor:()=>k,ZeroSlopeEnding:()=>Je,ZeroStencilOp:()=>mn,createCanvasElement:()=>Ai});var n={};t.r(n),t.d(n,{ru:()=>Pg,pP:()=>Rg,_c:()=>Lg});var i={};t.r(i);var r={};t.r(r),t.d(r,{COLUMN:()=>f_,COLUMN_REVERSE:()=>m_,ROW:()=>d_,ROW_REVERSE:()=>p_,contentDirection:()=>g_});var s={};t.r(s),t.d(s,{CENTER:()=>v_,END:()=>y_,START:()=>A_,STRETCH:()=>x_,alignItems:()=>__,warnAboutDeprecatedAlignItems:()=>w_});var a={};t.r(a),t.d(a,{CENTER:()=>b_,END:()=>S_,SPACE_AROUND:()=>I_,SPACE_BETWEEN:()=>T_,SPACE_EVENLY:()=>B_,START:()=>M_,justifyContent:()=>R_});var o={};t.r(o),t.d(o,{NORMAL:()=>U_,NOWRAP:()=>N_,PRE:()=>F_,PRE_LINE:()=>O_,PRE_WRAP:()=>k_,WHITE_CHARS:()=>L_,collapseWhitespaceOnInlines:()=>H_,collapseWhitespaceOnString:()=>Q_,newlineBreakability:()=>z_,shouldBreak:()=>G_});var l={};t.r(l),t.d(l,{CENTER:()=>Y_,JUSTIFY:()=>J_,JUSTIFY_CENTER:()=>$_,JUSTIFY_LEFT:()=>K_,JUSTIFY_RIGHT:()=>Z_,LEFT:()=>q_,RIGHT:()=>X_,textAlign:()=>tw});var c={};t.r(c),t.d(c,{bvh_distance_functions:()=>bb,bvh_ray_functions:()=>Sb,bvh_struct_definitions:()=>Ib,common_functions:()=>Mb});var h={};t.r(h),t.d(h,{AVERAGE:()=>Ww,BVHShaderGLSL:()=>c,CENTER:()=>Vw,CONTAINED:()=>Yw,ExtendedTriangle:()=>QC,FloatVertexAttributeTexture:()=>sb,INTERSECTED:()=>Xw,IntVertexAttributeTexture:()=>rb,MeshBVH:()=>bM,MeshBVHHelper:()=>jM,MeshBVHUniformStruct:()=>ab,NOT_INTERSECTED:()=>qw,OrientedBox:()=>zC,SAH:()=>jw,StaticGeometryGenerator:()=>Eb,UIntVertexAttributeTexture:()=>ib,VertexAttributeTexture:()=>nb,acceleratedRaycast:()=>NM,computeBatchedBoundsTree:()=>zM,computeBoundsTree:()=>kM,disposeBatchedBoundsTree:()=>GM,disposeBoundsTree:()=>QM,estimateMemoryInBytes:()=>ZM,getBVHExtremes:()=>KM,getJSONStructure:()=>tb,getTriangleHitPointInfo:()=>yE,shaderDistanceFunction:()=>Bb,shaderIntersectFunction:()=>Rb,shaderStructs:()=>Tb,validateBounds:()=>$M});var u={};t.r(u),t.d(u,{latitudeToSphericalPhi:()=>SS,sphericalPhiToLatitude:()=>bS,swapToGeoFrame:()=>ES,swapToThreeFrame:()=>MS,toLatLonString:()=>TS});var d={};t.r(d),t.d(d,{B3DMLoader:()=>mS,B3DMLoaderBase:()=>fS,CAMERA_FRAME:()=>WS,CMPTLoader:()=>hI,CMPTLoaderBase:()=>cI,CUSTOM_COLOR:()=>RT,CameraTransitionManager:()=>JR,CesiumIonAuthPlugin:()=>HB,CesiumIonTilesRenderer:()=>WB,DEPTH:()=>bT,DISTANCE:()=>MT,DebugCesiumIonTilesRenderer:()=>jB,DebugGooglePhotorealisticTilesRenderer:()=>zB,DebugGoogleTilesRenderer:()=>kB,DebugTilesPlugin:()=>LT,DebugTilesRenderer:()=>NT,ENU_FRAME:()=>VS,Ellipsoid:()=>qS,EllipsoidRegion:()=>QI,EnvironmentControls:()=>IR,FAILED:()=>Ub,GEOMETRIC_ERROR:()=>ET,GLTFCesiumRTCExtension:()=>dI,GLTFExtensionLoader:()=>pI,GLTFMeshFeaturesExtension:()=>RB,GLTFStructuralMetadataExtension:()=>CB,GeoUtils:()=>u,GlobeControls:()=>WR,GoogleCloudAuthPlugin:()=>UB,GooglePhotorealisticTilesRenderer:()=>QB,GoogleTilesRenderer:()=>OB,I3DMLoader:()=>lI,I3DMLoaderBase:()=>xS,IS_LEAF:()=>IT,ImplicitTilingPlugin:()=>nD,LOADED:()=>kb,LOADING:()=>Fb,LOAD_ORDER:()=>DT,LRUCache:()=>Pb,LUNAR_ELLIPSOID:()=>YS,LUNAR_HEIGHT:()=>Hb,LUNAR_RADIUS:()=>Vb,LoaderBase:()=>dS,NONE:()=>wT,OBJECT_FRAME:()=>jS,PARSING:()=>Ob,PNTSLoader:()=>yS,PNTSLoaderBase:()=>gS,PriorityQueue:()=>Lb,RANDOM_COLOR:()=>TT,RANDOM_NODE_COLOR:()=>BT,RELATIVE_DEPTH:()=>ST,SCREEN_ERROR:()=>CT,TilesRenderer:()=>aT,TilesRendererBase:()=>sS,UNLOADED:()=>Nb,WGS84_ELLIPSOID:()=>XS,WGS84_FLATTENING:()=>zb,WGS84_HEIGHT:()=>Gb,WGS84_RADIUS:()=>Qb});var p={};t.r(p);const f="170",m={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},g={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},A=0,v=1,y=2,x=3,_=0,w=1,C=2,E=3,M=0,b=1,S=2,I=0,T=1,B=2,R=3,D=4,P=5,L=100,U=101,N=102,F=103,O=104,k=200,Q=201,z=202,G=203,H=204,V=205,W=206,j=207,q=208,X=209,Y=210,J=211,K=212,Z=213,$=214,tt=0,et=1,nt=2,it=3,rt=4,st=5,at=6,ot=7,lt=0,ct=1,ht=2,ut=0,dt=1,pt=2,ft=3,mt=4,gt=5,At=6,vt=7,yt="attached",xt="detached",_t=300,wt=301,Ct=302,Et=303,Mt=304,bt=306,St=1e3,It=1001,Tt=1002,Bt=1003,Rt=1004,Dt=1004,Pt=1005,Lt=1005,Ut=1006,Nt=1007,Ft=1007,Ot=1008,kt=1008,Qt=1009,zt=1010,Gt=1011,Ht=1012,Vt=1013,Wt=1014,jt=1015,qt=1016,Xt=1017,Yt=1018,Jt=1020,Kt=35902,Zt=1021,$t=1022,te=1023,ee=1024,ne=1025,ie=1026,re=1027,se=1028,ae=1029,oe=1030,le=1031,ce=1032,he=1033,ue=33776,de=33777,pe=33778,fe=33779,me=35840,ge=35841,Ae=35842,ve=35843,ye=36196,xe=37492,_e=37496,we=37808,Ce=37809,Ee=37810,Me=37811,be=37812,Se=37813,Ie=37814,Te=37815,Be=37816,Re=37817,De=37818,Pe=37819,Le=37820,Ue=37821,Ne=36492,Fe=36494,Oe=36495,ke=36283,Qe=36284,ze=36285,Ge=36286,He=2200,Ve=2201,We=2202,je=2300,qe=2301,Xe=2302,Ye=2400,Je=2401,Ke=2402,Ze=2500,$e=2501,tn=0,en=1,nn=2,rn=3200,sn=3201,an=3202,on=3203,ln=0,cn=1,hn="",un="srgb",dn="srgb-linear",pn="linear",fn="srgb",mn=0,gn=7680,An=7681,vn=7682,yn=7683,xn=34055,_n=34056,wn=5386,Cn=512,En=513,Mn=514,bn=515,Sn=516,In=517,Tn=518,Bn=519,Rn=512,Dn=513,Pn=514,Ln=515,Un=516,Nn=517,Fn=518,On=519,kn=35044,Qn=35048,zn=35040,Gn=35045,Hn=35049,Vn=35041,Wn=35046,jn=35050,qn=35042,Xn="100",Yn="300 es",Jn=2e3,Kn=2001;class Zn{addEventListener(t,e){void 0===this._listeners&&(this._listeners={});const n=this._listeners;void 0===n[t]&&(n[t]=[]),-1===n[t].indexOf(e)&&n[t].push(e)}hasEventListener(t,e){if(void 0===this._listeners)return!1;const n=this._listeners;return void 0!==n[t]&&-1!==n[t].indexOf(e)}removeEventListener(t,e){if(void 0===this._listeners)return;const n=this._listeners[t];if(void 0!==n){const t=n.indexOf(e);-1!==t&&n.splice(t,1)}}dispatchEvent(t){if(void 0===this._listeners)return;const e=this._listeners[t.type];if(void 0!==e){t.target=this;const n=e.slice(0);for(let e=0,i=n.length;e>8&255]+$n[t>>16&255]+$n[t>>24&255]+"-"+$n[255&e]+$n[e>>8&255]+"-"+$n[e>>16&15|64]+$n[e>>24&255]+"-"+$n[63&n|128]+$n[n>>8&255]+"-"+$n[n>>16&255]+$n[n>>24&255]+$n[255&i]+$n[i>>8&255]+$n[i>>16&255]+$n[i>>24&255]).toLowerCase()}function ri(t,e,n){return Math.max(e,Math.min(n,t))}function si(t,e){return(t%e+e)%e}function ai(t,e,n){return(1-n)*t+n*e}function oi(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("Invalid component type.")}}function li(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return Math.round(4294967295*t);case Uint16Array:return Math.round(65535*t);case Uint8Array:return Math.round(255*t);case Int32Array:return Math.round(2147483647*t);case Int16Array:return Math.round(32767*t);case Int8Array:return Math.round(127*t);default:throw new Error("Invalid component type.")}}const ci={DEG2RAD:ei,RAD2DEG:ni,generateUUID:ii,clamp:ri,euclideanModulo:si,mapLinear:function(t,e,n,i,r){return i+(t-e)*(r-i)/(n-e)},inverseLerp:function(t,e,n){return t!==e?(n-t)/(e-t):0},lerp:ai,damp:function(t,e,n,i){return ai(t,e,1-Math.exp(-n*i))},pingpong:function(t,e=1){return e-Math.abs(si(t,2*e)-e)},smoothstep:function(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e))*t*(3-2*t)},smootherstep:function(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e))*t*t*(t*(6*t-15)+10)},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},seededRandom:function(t){void 0!==t&&(ti=t);let e=ti+=1831565813;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296},degToRad:function(t){return t*ei},radToDeg:function(t){return t*ni},isPowerOfTwo:function(t){return!(t&t-1)&&0!==t},ceilPowerOfTwo:function(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))},floorPowerOfTwo:function(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))},setQuaternionFromProperEuler:function(t,e,n,i,r){const s=Math.cos,a=Math.sin,o=s(n/2),l=a(n/2),c=s((e+i)/2),h=a((e+i)/2),u=s((e-i)/2),d=a((e-i)/2),p=s((i-e)/2),f=a((i-e)/2);switch(r){case"XYX":t.set(o*h,l*u,l*d,o*c);break;case"YZY":t.set(l*d,o*h,l*u,o*c);break;case"ZXZ":t.set(l*u,l*d,o*h,o*c);break;case"XZX":t.set(o*h,l*f,l*p,o*c);break;case"YXY":t.set(l*p,o*h,l*f,o*c);break;case"ZYZ":t.set(l*f,l*p,o*h,o*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}},normalize:li,denormalize:oi};class hi{constructor(t=0,e=0){hi.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,n=this.y,i=t.elements;return this.x=i[0]*e+i[3]*n+i[6],this.y=i[1]*e+i[4]*n+i[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(ri(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const n=Math.cos(e),i=Math.sin(e),r=this.x-t.x,s=this.y-t.y;return this.x=r*n-s*i+t.x,this.y=r*i+s*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class ui{constructor(t,e,n,i,r,s,a,o,l){ui.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],void 0!==t&&this.set(t,e,n,i,r,s,a,o,l)}set(t,e,n,i,r,s,a,o,l){const c=this.elements;return c[0]=t,c[1]=i,c[2]=a,c[3]=e,c[4]=r,c[5]=o,c[6]=n,c[7]=s,c[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,i=e.elements,r=this.elements,s=n[0],a=n[3],o=n[6],l=n[1],c=n[4],h=n[7],u=n[2],d=n[5],p=n[8],f=i[0],m=i[3],g=i[6],A=i[1],v=i[4],y=i[7],x=i[2],_=i[5],w=i[8];return r[0]=s*f+a*A+o*x,r[3]=s*m+a*v+o*_,r[6]=s*g+a*y+o*w,r[1]=l*f+c*A+h*x,r[4]=l*m+c*v+h*_,r[7]=l*g+c*y+h*w,r[2]=u*f+d*A+p*x,r[5]=u*m+d*v+p*_,r[8]=u*g+d*y+p*w,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],s=t[4],a=t[5],o=t[6],l=t[7],c=t[8];return e*s*c-e*a*l-n*r*c+n*a*o+i*r*l-i*s*o}invert(){const t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],s=t[4],a=t[5],o=t[6],l=t[7],c=t[8],h=c*s-a*l,u=a*o-c*r,d=l*r-s*o,p=e*h+n*u+i*d;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);const f=1/p;return t[0]=h*f,t[1]=(i*l-c*n)*f,t[2]=(a*n-i*s)*f,t[3]=u*f,t[4]=(c*e-i*o)*f,t[5]=(i*r-a*e)*f,t[6]=d*f,t[7]=(n*o-l*e)*f,t[8]=(s*e-n*r)*f,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,i,r,s,a){const o=Math.cos(r),l=Math.sin(r);return this.set(n*o,n*l,-n*(o*s+l*a)+s+t,-i*l,i*o,-i*(-l*s+o*a)+a+e,0,0,1),this}scale(t,e){return this.premultiply(di.makeScale(t,e)),this}rotate(t){return this.premultiply(di.makeRotation(-t)),this}translate(t,e){return this.premultiply(di.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,n,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,n=t.elements;for(let t=0;t<9;t++)if(e[t]!==n[t])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return(new this.constructor).fromArray(this.elements)}}const di=new ui;function pi(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}const fi={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function mi(t,e){return new fi[t](e)}function gi(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function Ai(){const t=gi("canvas");return t.style.display="block",t}const vi={};function yi(t){t in vi||(vi[t]=!0,console.warn(t))}const xi={enabled:!0,workingColorSpace:dn,spaces:{},convert:function(t,e,n){return!1!==this.enabled&&e!==n&&e&&n?(this.spaces[e].transfer===fn&&(t.r=_i(t.r),t.g=_i(t.g),t.b=_i(t.b)),this.spaces[e].primaries!==this.spaces[n].primaries&&(t.applyMatrix3(this.spaces[e].toXYZ),t.applyMatrix3(this.spaces[n].fromXYZ)),this.spaces[n].transfer===fn&&(t.r=wi(t.r),t.g=wi(t.g),t.b=wi(t.b)),t):t},fromWorkingColorSpace:function(t,e){return this.convert(t,this.workingColorSpace,e)},toWorkingColorSpace:function(t,e){return this.convert(t,e,this.workingColorSpace)},getPrimaries:function(t){return this.spaces[t].primaries},getTransfer:function(t){return t===hn?pn:this.spaces[t].transfer},getLuminanceCoefficients:function(t,e=this.workingColorSpace){return t.fromArray(this.spaces[e].luminanceCoefficients)},define:function(t){Object.assign(this.spaces,t)},_getMatrix:function(t,e,n){return t.copy(this.spaces[e].toXYZ).multiply(this.spaces[n].fromXYZ)},_getDrawingBufferColorSpace:function(t){return this.spaces[t].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(t=this.workingColorSpace){return this.spaces[t].workingColorSpaceConfig.unpackColorSpace}};function _i(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function wi(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}const Ci=[.64,.33,.3,.6,.15,.06],Ei=[.2126,.7152,.0722],Mi=[.3127,.329],bi=(new ui).set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Si=(new ui).set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);let Ii;xi.define({[dn]:{primaries:Ci,whitePoint:Mi,transfer:pn,toXYZ:bi,fromXYZ:Si,luminanceCoefficients:Ei,workingColorSpaceConfig:{unpackColorSpace:un},outputColorSpaceConfig:{drawingBufferColorSpace:un}},[un]:{primaries:Ci,whitePoint:Mi,transfer:fn,toXYZ:bi,fromXYZ:Si,luminanceCoefficients:Ei,outputColorSpaceConfig:{drawingBufferColorSpace:un}}});class Ti{static getDataURL(t){if(/^data:/i.test(t.src))return t.src;if("undefined"==typeof HTMLCanvasElement)return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{void 0===Ii&&(Ii=gi("canvas")),Ii.width=t.width,Ii.height=t.height;const n=Ii.getContext("2d");t instanceof ImageData?n.putImageData(t,0,0):n.drawImage(t,0,0,t.width,t.height),e=Ii}return e.width>2048||e.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",t),e.toDataURL("image/jpeg",.6)):e.toDataURL("image/png")}static sRGBToLinear(t){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){const e=gi("canvas");e.width=t.width,e.height=t.height;const n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);const i=n.getImageData(0,0,t.width,t.height),r=i.data;for(let t=0;t0&&(n.userData=this.userData),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==_t)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case St:t.x=t.x-Math.floor(t.x);break;case It:t.x=t.x<0?0:1;break;case Tt:1===Math.abs(Math.floor(t.x)%2)?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x)}if(t.y<0||t.y>1)switch(this.wrapT){case St:t.y=t.y-Math.floor(t.y);break;case It:t.y=t.y<0?0:1;break;case Tt:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){!0===t&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){!0===t&&this.pmremVersion++}}Li.DEFAULT_IMAGE=null,Li.DEFAULT_MAPPING=_t,Li.DEFAULT_ANISOTROPY=1;class Ui{constructor(t=0,e=0,n=0,i=1){Ui.prototype.isVector4=!0,this.x=t,this.y=e,this.z=n,this.w=i}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,i){return this.x=t,this.y=e,this.z=n,this.w=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,n=this.y,i=this.z,r=this.w,s=t.elements;return this.x=s[0]*e+s[4]*n+s[8]*i+s[12]*r,this.y=s[1]*e+s[5]*n+s[9]*i+s[13]*r,this.z=s[2]*e+s[6]*n+s[10]*i+s[14]*r,this.w=s[3]*e+s[7]*n+s[11]*i+s[15]*r,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,n,i,r;const s=.01,a=.1,o=t.elements,l=o[0],c=o[4],h=o[8],u=o[1],d=o[5],p=o[9],f=o[2],m=o[6],g=o[10];if(Math.abs(c-u)o&&t>A?tA?o=0?1:-1,i=1-e*e;if(i>Number.EPSILON){const r=Math.sqrt(i),s=Math.atan2(r,e*n);t=Math.sin(t*s)/r,a=Math.sin(a*s)/r}const r=a*n;if(o=o*t+u*r,l=l*t+d*r,c=c*t+p*r,h=h*t+f*r,t===1-a){const t=1/Math.sqrt(o*o+l*l+c*c+h*h);o*=t,l*=t,c*=t,h*=t}}t[e]=o,t[e+1]=l,t[e+2]=c,t[e+3]=h}static multiplyQuaternionsFlat(t,e,n,i,r,s){const a=n[i],o=n[i+1],l=n[i+2],c=n[i+3],h=r[s],u=r[s+1],d=r[s+2],p=r[s+3];return t[e]=a*p+c*h+o*d-l*u,t[e+1]=o*p+c*u+l*h-a*d,t[e+2]=l*p+c*d+a*u-o*h,t[e+3]=c*p-a*h-o*u-l*d,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,n,i){return this._x=t,this._y=e,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const n=t._x,i=t._y,r=t._z,s=t._order,a=Math.cos,o=Math.sin,l=a(n/2),c=a(i/2),h=a(r/2),u=o(n/2),d=o(i/2),p=o(r/2);switch(s){case"XYZ":this._x=u*c*h+l*d*p,this._y=l*d*h-u*c*p,this._z=l*c*p+u*d*h,this._w=l*c*h-u*d*p;break;case"YXZ":this._x=u*c*h+l*d*p,this._y=l*d*h-u*c*p,this._z=l*c*p-u*d*h,this._w=l*c*h+u*d*p;break;case"ZXY":this._x=u*c*h-l*d*p,this._y=l*d*h+u*c*p,this._z=l*c*p+u*d*h,this._w=l*c*h-u*d*p;break;case"ZYX":this._x=u*c*h-l*d*p,this._y=l*d*h+u*c*p,this._z=l*c*p-u*d*h,this._w=l*c*h+u*d*p;break;case"YZX":this._x=u*c*h+l*d*p,this._y=l*d*h+u*c*p,this._z=l*c*p-u*d*h,this._w=l*c*h-u*d*p;break;case"XZY":this._x=u*c*h-l*d*p,this._y=l*d*h-u*c*p,this._z=l*c*p+u*d*h,this._w=l*c*h+u*d*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+s)}return!0===e&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const n=e/2,i=Math.sin(n);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,n=e[0],i=e[4],r=e[8],s=e[1],a=e[5],o=e[9],l=e[2],c=e[6],h=e[10],u=n+a+h;if(u>0){const t=.5/Math.sqrt(u+1);this._w=.25/t,this._x=(c-o)*t,this._y=(r-l)*t,this._z=(s-i)*t}else if(n>a&&n>h){const t=2*Math.sqrt(1+n-a-h);this._w=(c-o)/t,this._x=.25*t,this._y=(i+s)/t,this._z=(r+l)/t}else if(a>h){const t=2*Math.sqrt(1+a-n-h);this._w=(r-l)/t,this._x=(i+s)/t,this._y=.25*t,this._z=(o+c)/t}else{const t=2*Math.sqrt(1+h-n-a);this._w=(s-i)/t,this._x=(r+l)/t,this._y=(o+c)/t,this._z=.25*t}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return nMath.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(ri(this.dot(t),-1,1)))}rotateTowards(t,e){const n=this.angleTo(t);if(0===n)return this;const i=Math.min(1,e/n);return this.slerp(t,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const n=t._x,i=t._y,r=t._z,s=t._w,a=e._x,o=e._y,l=e._z,c=e._w;return this._x=n*c+s*a+i*l-r*o,this._y=i*c+s*o+r*a-n*l,this._z=r*c+s*l+n*o-i*a,this._w=s*c-n*a-i*o-r*l,this._onChangeCallback(),this}slerp(t,e){if(0===e)return this;if(1===e)return this.copy(t);const n=this._x,i=this._y,r=this._z,s=this._w;let a=s*t._w+n*t._x+i*t._y+r*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=s,this._x=n,this._y=i,this._z=r,this;const o=1-a*a;if(o<=Number.EPSILON){const t=1-e;return this._w=t*s+e*this._w,this._x=t*n+e*this._x,this._y=t*i+e*this._y,this._z=t*r+e*this._z,this.normalize(),this}const l=Math.sqrt(o),c=Math.atan2(l,a),h=Math.sin((1-e)*c)/l,u=Math.sin(e*c)/l;return this._w=s*h+this._w*u,this._x=n*h+this._x*u,this._y=i*h+this._y*u,this._z=r*h+this._z*u,this._onChangeCallback(),this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(i*Math.sin(t),i*Math.cos(t),r*Math.sin(e),r*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class Hi{constructor(t=0,e=0,n=0){Hi.prototype.isVector3=!0,this.x=t,this.y=e,this.z=n}set(t,e,n){return void 0===n&&(n=this.z),this.x=t,this.y=e,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(Wi.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Wi.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,n=this.y,i=this.z,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6]*i,this.y=r[1]*e+r[4]*n+r[7]*i,this.z=r[2]*e+r[5]*n+r[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,n=this.y,i=this.z,r=t.elements,s=1/(r[3]*e+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*e+r[4]*n+r[8]*i+r[12])*s,this.y=(r[1]*e+r[5]*n+r[9]*i+r[13])*s,this.z=(r[2]*e+r[6]*n+r[10]*i+r[14])*s,this}applyQuaternion(t){const e=this.x,n=this.y,i=this.z,r=t.x,s=t.y,a=t.z,o=t.w,l=2*(s*i-a*n),c=2*(a*e-r*i),h=2*(r*n-s*e);return this.x=e+o*l+s*h-a*c,this.y=n+o*c+a*l-r*h,this.z=i+o*h+r*c-s*l,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,n=this.y,i=this.z,r=t.elements;return this.x=r[0]*e+r[4]*n+r[8]*i,this.y=r[1]*e+r[5]*n+r[9]*i,this.z=r[2]*e+r[6]*n+r[10]*i,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const n=t.x,i=t.y,r=t.z,s=e.x,a=e.y,o=e.z;return this.x=i*o-r*a,this.y=r*s-n*o,this.z=n*a-i*s,this}projectOnVector(t){const e=t.lengthSq();if(0===e)return this.set(0,0,0);const n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return Vi.copy(this).projectOnVector(t),this.sub(Vi)}reflect(t){return this.sub(Vi.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(ri(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y,i=this.z-t.z;return e*e+n*n+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,n){const i=Math.sin(e)*t;return this.x=i*Math.sin(n),this.y=Math.cos(e)*t,this.z=i*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=i,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,4*e)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,3*e)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=2*Math.random()-1,n=Math.sqrt(1-e*e);return this.x=n*Math.cos(t),this.y=e,this.z=n*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Vi=new Hi,Wi=new Gi;class ji{constructor(t=new Hi(1/0,1/0,1/0),e=new Hi(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,n=t.length;e=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,Xi),Xi.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(nr),ir.subVectors(this.max,nr),Ji.subVectors(t.a,nr),Ki.subVectors(t.b,nr),Zi.subVectors(t.c,nr),$i.subVectors(Ki,Ji),tr.subVectors(Zi,Ki),er.subVectors(Ji,Zi);let e=[0,-$i.z,$i.y,0,-tr.z,tr.y,0,-er.z,er.y,$i.z,0,-$i.x,tr.z,0,-tr.x,er.z,0,-er.x,-$i.y,$i.x,0,-tr.y,tr.x,0,-er.y,er.x,0];return!!ar(e,Ji,Ki,Zi,ir)&&(e=[1,0,0,0,1,0,0,0,1],!!ar(e,Ji,Ki,Zi,ir)&&(rr.crossVectors($i,tr),e=[rr.x,rr.y,rr.z],ar(e,Ji,Ki,Zi,ir)))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Xi).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=.5*this.getSize(Xi).length()),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()||(qi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),qi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),qi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),qi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),qi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),qi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),qi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),qi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(qi)),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const qi=[new Hi,new Hi,new Hi,new Hi,new Hi,new Hi,new Hi,new Hi],Xi=new Hi,Yi=new ji,Ji=new Hi,Ki=new Hi,Zi=new Hi,$i=new Hi,tr=new Hi,er=new Hi,nr=new Hi,ir=new Hi,rr=new Hi,sr=new Hi;function ar(t,e,n,i,r){for(let s=0,a=t.length-3;s<=a;s+=3){sr.fromArray(t,s);const a=r.x*Math.abs(sr.x)+r.y*Math.abs(sr.y)+r.z*Math.abs(sr.z),o=e.dot(sr),l=n.dot(sr),c=i.dot(sr);if(Math.max(-Math.max(o,l,c),Math.min(o,l,c))>a)return!1}return!0}const or=new ji,lr=new Hi,cr=new Hi;class hr{constructor(t=new Hi,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const n=this.center;void 0!==e?n.copy(e):or.setFromPoints(t).getCenter(n);let i=0;for(let e=0,r=t.length;ethis.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;lr.subVectors(t,this.center);const e=lr.lengthSq();if(e>this.radius*this.radius){const t=Math.sqrt(e),n=.5*(t-this.radius);this.center.addScaledVector(lr,n/t),this.radius+=n}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(!0===this.center.equals(t.center)?this.radius=Math.max(this.radius,t.radius):(cr.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(lr.copy(t.center).add(cr)),this.expandByPoint(lr.copy(t.center).sub(cr))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const ur=new Hi,dr=new Hi,pr=new Hi,fr=new Hi,mr=new Hi,gr=new Hi,Ar=new Hi;class vr{constructor(t=new Hi,e=new Hi(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,ur)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=ur.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(ur.copy(this.origin).addScaledVector(this.direction,e),ur.distanceToSquared(t))}distanceSqToSegment(t,e,n,i){dr.copy(t).add(e).multiplyScalar(.5),pr.copy(e).sub(t).normalize(),fr.copy(this.origin).sub(dr);const r=.5*t.distanceTo(e),s=-this.direction.dot(pr),a=fr.dot(this.direction),o=-fr.dot(pr),l=fr.lengthSq(),c=Math.abs(1-s*s);let h,u,d,p;if(c>0)if(h=s*o-a,u=s*a-o,p=r*c,h>=0)if(u>=-p)if(u<=p){const t=1/c;h*=t,u*=t,d=h*(h+s*u+2*a)+u*(s*h+u+2*o)+l}else u=r,h=Math.max(0,-(s*u+a)),d=-h*h+u*(u+2*o)+l;else u=-r,h=Math.max(0,-(s*u+a)),d=-h*h+u*(u+2*o)+l;else u<=-p?(h=Math.max(0,-(-s*r+a)),u=h>0?-r:Math.min(Math.max(-r,-o),r),d=-h*h+u*(u+2*o)+l):u<=p?(h=0,u=Math.min(Math.max(-r,-o),r),d=u*(u+2*o)+l):(h=Math.max(0,-(s*r+a)),u=h>0?r:Math.min(Math.max(-r,-o),r),d=-h*h+u*(u+2*o)+l);else u=s>0?-r:r,h=Math.max(0,-(s*u+a)),d=-h*h+u*(u+2*o)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,h),i&&i.copy(dr).addScaledVector(pr,u),d}intersectSphere(t,e){ur.subVectors(t.center,this.origin);const n=ur.dot(this.direction),i=ur.dot(ur)-n*n,r=t.radius*t.radius;if(i>r)return null;const s=Math.sqrt(r-i),a=n-s,o=n+s;return o<0?null:a<0?this.at(o,e):this.at(a,e)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;const n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){const n=this.distanceToPlane(t);return null===n?null:this.at(n,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);return 0===e||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,i,r,s,a,o;const l=1/this.direction.x,c=1/this.direction.y,h=1/this.direction.z,u=this.origin;return l>=0?(n=(t.min.x-u.x)*l,i=(t.max.x-u.x)*l):(n=(t.max.x-u.x)*l,i=(t.min.x-u.x)*l),c>=0?(r=(t.min.y-u.y)*c,s=(t.max.y-u.y)*c):(r=(t.max.y-u.y)*c,s=(t.min.y-u.y)*c),n>s||r>i?null:((r>n||isNaN(n))&&(n=r),(s=0?(a=(t.min.z-u.z)*h,o=(t.max.z-u.z)*h):(a=(t.max.z-u.z)*h,o=(t.min.z-u.z)*h),n>o||a>i?null:((a>n||n!=n)&&(n=a),(o=0?n:i,e)))}intersectsBox(t){return null!==this.intersectBox(t,ur)}intersectTriangle(t,e,n,i,r){mr.subVectors(e,t),gr.subVectors(n,t),Ar.crossVectors(mr,gr);let s,a=this.direction.dot(Ar);if(a>0){if(i)return null;s=1}else{if(!(a<0))return null;s=-1,a=-a}fr.subVectors(this.origin,t);const o=s*this.direction.dot(gr.crossVectors(fr,gr));if(o<0)return null;const l=s*this.direction.dot(mr.cross(fr));if(l<0)return null;if(o+l>a)return null;const c=-s*fr.dot(Ar);return c<0?null:this.at(c/a,r)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}}class yr{constructor(t,e,n,i,r,s,a,o,l,c,h,u,d,p,f,m){yr.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==t&&this.set(t,e,n,i,r,s,a,o,l,c,h,u,d,p,f,m)}set(t,e,n,i,r,s,a,o,l,c,h,u,d,p,f,m){const g=this.elements;return g[0]=t,g[4]=e,g[8]=n,g[12]=i,g[1]=r,g[5]=s,g[9]=a,g[13]=o,g[2]=l,g[6]=c,g[10]=h,g[14]=u,g[3]=d,g[7]=p,g[11]=f,g[15]=m,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return(new yr).fromArray(this.elements)}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){const e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,n){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,n=t.elements,i=1/xr.setFromMatrixColumn(t,0).length(),r=1/xr.setFromMatrixColumn(t,1).length(),s=1/xr.setFromMatrixColumn(t,2).length();return e[0]=n[0]*i,e[1]=n[1]*i,e[2]=n[2]*i,e[3]=0,e[4]=n[4]*r,e[5]=n[5]*r,e[6]=n[6]*r,e[7]=0,e[8]=n[8]*s,e[9]=n[9]*s,e[10]=n[10]*s,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,n=t.x,i=t.y,r=t.z,s=Math.cos(n),a=Math.sin(n),o=Math.cos(i),l=Math.sin(i),c=Math.cos(r),h=Math.sin(r);if("XYZ"===t.order){const t=s*c,n=s*h,i=a*c,r=a*h;e[0]=o*c,e[4]=-o*h,e[8]=l,e[1]=n+i*l,e[5]=t-r*l,e[9]=-a*o,e[2]=r-t*l,e[6]=i+n*l,e[10]=s*o}else if("YXZ"===t.order){const t=o*c,n=o*h,i=l*c,r=l*h;e[0]=t+r*a,e[4]=i*a-n,e[8]=s*l,e[1]=s*h,e[5]=s*c,e[9]=-a,e[2]=n*a-i,e[6]=r+t*a,e[10]=s*o}else if("ZXY"===t.order){const t=o*c,n=o*h,i=l*c,r=l*h;e[0]=t-r*a,e[4]=-s*h,e[8]=i+n*a,e[1]=n+i*a,e[5]=s*c,e[9]=r-t*a,e[2]=-s*l,e[6]=a,e[10]=s*o}else if("ZYX"===t.order){const t=s*c,n=s*h,i=a*c,r=a*h;e[0]=o*c,e[4]=i*l-n,e[8]=t*l+r,e[1]=o*h,e[5]=r*l+t,e[9]=n*l-i,e[2]=-l,e[6]=a*o,e[10]=s*o}else if("YZX"===t.order){const t=s*o,n=s*l,i=a*o,r=a*l;e[0]=o*c,e[4]=r-t*h,e[8]=i*h+n,e[1]=h,e[5]=s*c,e[9]=-a*c,e[2]=-l*c,e[6]=n*h+i,e[10]=t-r*h}else if("XZY"===t.order){const t=s*o,n=s*l,i=a*o,r=a*l;e[0]=o*c,e[4]=-h,e[8]=l*c,e[1]=t*h+r,e[5]=s*c,e[9]=n*h-i,e[2]=i*h-n,e[6]=a*c,e[10]=r*h+t}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(wr,t,Cr)}lookAt(t,e,n){const i=this.elements;return br.subVectors(t,e),0===br.lengthSq()&&(br.z=1),br.normalize(),Er.crossVectors(n,br),0===Er.lengthSq()&&(1===Math.abs(n.z)?br.x+=1e-4:br.z+=1e-4,br.normalize(),Er.crossVectors(n,br)),Er.normalize(),Mr.crossVectors(br,Er),i[0]=Er.x,i[4]=Mr.x,i[8]=br.x,i[1]=Er.y,i[5]=Mr.y,i[9]=br.y,i[2]=Er.z,i[6]=Mr.z,i[10]=br.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,i=e.elements,r=this.elements,s=n[0],a=n[4],o=n[8],l=n[12],c=n[1],h=n[5],u=n[9],d=n[13],p=n[2],f=n[6],m=n[10],g=n[14],A=n[3],v=n[7],y=n[11],x=n[15],_=i[0],w=i[4],C=i[8],E=i[12],M=i[1],b=i[5],S=i[9],I=i[13],T=i[2],B=i[6],R=i[10],D=i[14],P=i[3],L=i[7],U=i[11],N=i[15];return r[0]=s*_+a*M+o*T+l*P,r[4]=s*w+a*b+o*B+l*L,r[8]=s*C+a*S+o*R+l*U,r[12]=s*E+a*I+o*D+l*N,r[1]=c*_+h*M+u*T+d*P,r[5]=c*w+h*b+u*B+d*L,r[9]=c*C+h*S+u*R+d*U,r[13]=c*E+h*I+u*D+d*N,r[2]=p*_+f*M+m*T+g*P,r[6]=p*w+f*b+m*B+g*L,r[10]=p*C+f*S+m*R+g*U,r[14]=p*E+f*I+m*D+g*N,r[3]=A*_+v*M+y*T+x*P,r[7]=A*w+v*b+y*B+x*L,r[11]=A*C+v*S+y*R+x*U,r[15]=A*E+v*I+y*D+x*N,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[4],i=t[8],r=t[12],s=t[1],a=t[5],o=t[9],l=t[13],c=t[2],h=t[6],u=t[10],d=t[14];return t[3]*(+r*o*h-i*l*h-r*a*u+n*l*u+i*a*d-n*o*d)+t[7]*(+e*o*d-e*l*u+r*s*u-i*s*d+i*l*c-r*o*c)+t[11]*(+e*l*h-e*a*d-r*s*h+n*s*d+r*a*c-n*l*c)+t[15]*(-i*a*c-e*o*h+e*a*u+i*s*h-n*s*u+n*o*c)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,n){const i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=e,i[14]=n),this}invert(){const t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],s=t[4],a=t[5],o=t[6],l=t[7],c=t[8],h=t[9],u=t[10],d=t[11],p=t[12],f=t[13],m=t[14],g=t[15],A=h*m*l-f*u*l+f*o*d-a*m*d-h*o*g+a*u*g,v=p*u*l-c*m*l-p*o*d+s*m*d+c*o*g-s*u*g,y=c*f*l-p*h*l+p*a*d-s*f*d-c*a*g+s*h*g,x=p*h*o-c*f*o-p*a*u+s*f*u+c*a*m-s*h*m,_=e*A+n*v+i*y+r*x;if(0===_)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const w=1/_;return t[0]=A*w,t[1]=(f*u*r-h*m*r-f*i*d+n*m*d+h*i*g-n*u*g)*w,t[2]=(a*m*r-f*o*r+f*i*l-n*m*l-a*i*g+n*o*g)*w,t[3]=(h*o*r-a*u*r-h*i*l+n*u*l+a*i*d-n*o*d)*w,t[4]=v*w,t[5]=(c*m*r-p*u*r+p*i*d-e*m*d-c*i*g+e*u*g)*w,t[6]=(p*o*r-s*m*r-p*i*l+e*m*l+s*i*g-e*o*g)*w,t[7]=(s*u*r-c*o*r+c*i*l-e*u*l-s*i*d+e*o*d)*w,t[8]=y*w,t[9]=(p*h*r-c*f*r-p*n*d+e*f*d+c*n*g-e*h*g)*w,t[10]=(s*f*r-p*a*r+p*n*l-e*f*l-s*n*g+e*a*g)*w,t[11]=(c*a*r-s*h*r-c*n*l+e*h*l+s*n*d-e*a*d)*w,t[12]=x*w,t[13]=(c*f*i-p*h*i+p*n*u-e*f*u-c*n*m+e*h*m)*w,t[14]=(p*a*i-s*f*i-p*n*o+e*f*o+s*n*m-e*a*m)*w,t[15]=(s*h*i-c*a*i+c*n*o-e*h*o-s*n*u+e*a*u)*w,this}scale(t){const e=this.elements,n=t.x,i=t.y,r=t.z;return e[0]*=n,e[4]*=i,e[8]*=r,e[1]*=n,e[5]*=i,e[9]*=r,e[2]*=n,e[6]*=i,e[10]*=r,e[3]*=n,e[7]*=i,e[11]*=r,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,i))}makeTranslation(t,e,n){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const n=Math.cos(e),i=Math.sin(e),r=1-n,s=t.x,a=t.y,o=t.z,l=r*s,c=r*a;return this.set(l*s+n,l*a-i*o,l*o+i*a,0,l*a+i*o,c*a+n,c*o-i*s,0,l*o-i*a,c*o+i*s,r*o*o+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,i,r,s){return this.set(1,n,r,0,t,1,s,0,e,i,1,0,0,0,0,1),this}compose(t,e,n){const i=this.elements,r=e._x,s=e._y,a=e._z,o=e._w,l=r+r,c=s+s,h=a+a,u=r*l,d=r*c,p=r*h,f=s*c,m=s*h,g=a*h,A=o*l,v=o*c,y=o*h,x=n.x,_=n.y,w=n.z;return i[0]=(1-(f+g))*x,i[1]=(d+y)*x,i[2]=(p-v)*x,i[3]=0,i[4]=(d-y)*_,i[5]=(1-(u+g))*_,i[6]=(m+A)*_,i[7]=0,i[8]=(p+v)*w,i[9]=(m-A)*w,i[10]=(1-(u+f))*w,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,e,n){const i=this.elements;let r=xr.set(i[0],i[1],i[2]).length();const s=xr.set(i[4],i[5],i[6]).length(),a=xr.set(i[8],i[9],i[10]).length();this.determinant()<0&&(r=-r),t.x=i[12],t.y=i[13],t.z=i[14],_r.copy(this);const o=1/r,l=1/s,c=1/a;return _r.elements[0]*=o,_r.elements[1]*=o,_r.elements[2]*=o,_r.elements[4]*=l,_r.elements[5]*=l,_r.elements[6]*=l,_r.elements[8]*=c,_r.elements[9]*=c,_r.elements[10]*=c,e.setFromRotationMatrix(_r),n.x=r,n.y=s,n.z=a,this}makePerspective(t,e,n,i,r,s,a=Jn){const o=this.elements,l=2*r/(e-t),c=2*r/(n-i),h=(e+t)/(e-t),u=(n+i)/(n-i);let d,p;if(a===Jn)d=-(s+r)/(s-r),p=-2*s*r/(s-r);else{if(a!==Kn)throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);d=-s/(s-r),p=-s*r/(s-r)}return o[0]=l,o[4]=0,o[8]=h,o[12]=0,o[1]=0,o[5]=c,o[9]=u,o[13]=0,o[2]=0,o[6]=0,o[10]=d,o[14]=p,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this}makeOrthographic(t,e,n,i,r,s,a=Jn){const o=this.elements,l=1/(e-t),c=1/(n-i),h=1/(s-r),u=(e+t)*l,d=(n+i)*c;let p,f;if(a===Jn)p=(s+r)*h,f=-2*h;else{if(a!==Kn)throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);p=r*h,f=-1*h}return o[0]=2*l,o[4]=0,o[8]=0,o[12]=-u,o[1]=0,o[5]=2*c,o[9]=0,o[13]=-d,o[2]=0,o[6]=0,o[10]=f,o[14]=-p,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this}equals(t){const e=this.elements,n=t.elements;for(let t=0;t<16;t++)if(e[t]!==n[t])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}}const xr=new Hi,_r=new yr,wr=new Hi(0,0,0),Cr=new Hi(1,1,1),Er=new Hi,Mr=new Hi,br=new Hi,Sr=new yr,Ir=new Gi;class Tr{constructor(t=0,e=0,n=0,i=Tr.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=i}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,n,i=this._order){return this._x=t,this._y=e,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,n=!0){const i=t.elements,r=i[0],s=i[4],a=i[8],o=i[1],l=i[5],c=i[9],h=i[2],u=i[6],d=i[10];switch(e){case"XYZ":this._y=Math.asin(ri(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-c,d),this._z=Math.atan2(-s,r)):(this._x=Math.atan2(u,l),this._z=0);break;case"YXZ":this._x=Math.asin(-ri(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(a,d),this._z=Math.atan2(o,l)):(this._y=Math.atan2(-h,r),this._z=0);break;case"ZXY":this._x=Math.asin(ri(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-h,d),this._z=Math.atan2(-s,l)):(this._y=0,this._z=Math.atan2(o,r));break;case"ZYX":this._y=Math.asin(-ri(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(u,d),this._z=Math.atan2(o,r)):(this._x=0,this._z=Math.atan2(-s,l));break;case"YZX":this._z=Math.asin(ri(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-c,l),this._y=Math.atan2(-h,r)):(this._x=0,this._y=Math.atan2(a,d));break;case"XZY":this._z=Math.asin(-ri(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(u,l),this._y=Math.atan2(a,r)):(this._x=Math.atan2(-c,d),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,!0===n&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return Sr.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Sr,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return Ir.setFromEuler(this),this.setFromQuaternion(Ir,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],void 0!==t[3]&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Tr.DEFAULT_ORDER="XYZ";class Br{constructor(){this.mask=1}set(t){this.mask=1<>>0}enable(t){this.mask|=1<1){for(let t=0;t1){for(let t=0;t0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),!1===this.matrixAutoUpdate&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.visibility=this._visibility,i.active=this._active,i.bounds=this._bounds.map((t=>({boxInitialized:t.boxInitialized,boxMin:t.box.min.toArray(),boxMax:t.box.max.toArray(),sphereInitialized:t.sphereInitialized,sphereRadius:t.sphere.radius,sphereCenter:t.sphere.center.toArray()}))),i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.geometryCount=this._geometryCount,i.matricesTexture=this._matricesTexture.toJSON(t),null!==this._colorsTexture&&(i.colorsTexture=this._colorsTexture.toJSON(t)),null!==this.boundingSphere&&(i.boundingSphere={center:i.boundingSphere.center.toArray(),radius:i.boundingSphere.radius}),null!==this.boundingBox&&(i.boundingBox={min:i.boundingBox.min.toArray(),max:i.boundingBox.max.toArray()})),this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(i.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(t.geometries,this.geometry);const e=this.geometry.parameters;if(void 0!==e&&void 0!==e.shapes){const n=e.shapes;if(Array.isArray(n))for(let e=0,i=n.length;e0){i.children=[];for(let e=0;e0){i.animations=[];for(let e=0;e0&&(n.geometries=e),i.length>0&&(n.materials=i),r.length>0&&(n.textures=r),a.length>0&&(n.images=a),o.length>0&&(n.shapes=o),l.length>0&&(n.skeletons=l),c.length>0&&(n.animations=c),h.length>0&&(n.nodes=h)}return n.object=i,n;function s(t){const e=[];for(const n in t){const i=t[n];delete i.metadata,e.push(i)}return e}}clone(t){return(new this.constructor).copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),!0===e)for(let e=0;e0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(t,e,n,i,r){qr.subVectors(i,e),Xr.subVectors(n,e),Yr.subVectors(t,e);const s=qr.dot(qr),a=qr.dot(Xr),o=qr.dot(Yr),l=Xr.dot(Xr),c=Xr.dot(Yr),h=s*l-a*a;if(0===h)return r.set(0,0,0),null;const u=1/h,d=(l*o-a*c)*u,p=(s*c-a*o)*u;return r.set(1-d-p,p,d)}static containsPoint(t,e,n,i){return null!==this.getBarycoord(t,e,n,i,Jr)&&Jr.x>=0&&Jr.y>=0&&Jr.x+Jr.y<=1}static getInterpolation(t,e,n,i,r,s,a,o){return null===this.getBarycoord(t,e,n,i,Jr)?(o.x=0,o.y=0,"z"in o&&(o.z=0),"w"in o&&(o.w=0),null):(o.setScalar(0),o.addScaledVector(r,Jr.x),o.addScaledVector(s,Jr.y),o.addScaledVector(a,Jr.z),o)}static getInterpolatedAttribute(t,e,n,i,r,s){return is.setScalar(0),rs.setScalar(0),ss.setScalar(0),is.fromBufferAttribute(t,e),rs.fromBufferAttribute(t,n),ss.fromBufferAttribute(t,i),s.setScalar(0),s.addScaledVector(is,r.x),s.addScaledVector(rs,r.y),s.addScaledVector(ss,r.z),s}static isFrontFacing(t,e,n,i){return qr.subVectors(n,e),Xr.subVectors(t,e),qr.cross(Xr).dot(i)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,i){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[i]),this}setFromAttributeAndIndices(t,e,n,i){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,i),this}clone(){return(new this.constructor).copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return qr.subVectors(this.c,this.b),Xr.subVectors(this.a,this.b),.5*qr.cross(Xr).length()}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return as.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return as.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,n,i,r){return as.getInterpolation(t,this.a,this.b,this.c,e,n,i,r)}containsPoint(t){return as.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return as.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const n=this.a,i=this.b,r=this.c;let s,a;Kr.subVectors(i,n),Zr.subVectors(r,n),ts.subVectors(t,n);const o=Kr.dot(ts),l=Zr.dot(ts);if(o<=0&&l<=0)return e.copy(n);es.subVectors(t,i);const c=Kr.dot(es),h=Zr.dot(es);if(c>=0&&h<=c)return e.copy(i);const u=o*h-c*l;if(u<=0&&o>=0&&c<=0)return s=o/(o-c),e.copy(n).addScaledVector(Kr,s);ns.subVectors(t,r);const d=Kr.dot(ns),p=Zr.dot(ns);if(p>=0&&d<=p)return e.copy(r);const f=d*l-o*p;if(f<=0&&l>=0&&p<=0)return a=l/(l-p),e.copy(n).addScaledVector(Zr,a);const m=c*p-d*h;if(m<=0&&h-c>=0&&d-p>=0)return $r.subVectors(r,i),a=(h-c)/(h-c+(d-p)),e.copy(i).addScaledVector($r,a);const g=1/(m+f+u);return s=f*g,a=u*g,e.copy(n).addScaledVector(Kr,s).addScaledVector(Zr,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const os={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},ls={h:0,s:0,l:0},cs={h:0,s:0,l:0};function hs(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+6*(e-t)*(2/3-n):t}class us{constructor(t,e,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,n)}set(t,e,n){if(void 0===e&&void 0===n){const e=t;e&&e.isColor?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=un){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,xi.toWorkingColorSpace(this,e),this}setRGB(t,e,n,i=xi.workingColorSpace){return this.r=t,this.g=e,this.b=n,xi.toWorkingColorSpace(this,i),this}setHSL(t,e,n,i=xi.workingColorSpace){if(t=si(t,1),e=ri(e,0,1),n=ri(n,0,1),0===e)this.r=this.g=this.b=n;else{const i=n<=.5?n*(1+e):n+e-n*e,r=2*n-i;this.r=hs(r,i,t+1/3),this.g=hs(r,i,t),this.b=hs(r,i,t-1/3)}return xi.toWorkingColorSpace(this,i),this}setStyle(t,e=un){function n(e){void 0!==e&&parseFloat(e)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(t)){let r;const s=i[1],a=i[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,e);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,e);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,e);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(t)){const n=i[1],r=n.length;if(3===r)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,e);if(6===r)return this.setHex(parseInt(n,16),e);console.warn("THREE.Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=un){const n=os[t.toLowerCase()];return void 0!==n?this.setHex(n,e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=_i(t.r),this.g=_i(t.g),this.b=_i(t.b),this}copyLinearToSRGB(t){return this.r=wi(t.r),this.g=wi(t.g),this.b=wi(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=un){return xi.fromWorkingColorSpace(ds.copy(this),t),65536*Math.round(ri(255*ds.r,0,255))+256*Math.round(ri(255*ds.g,0,255))+Math.round(ri(255*ds.b,0,255))}getHexString(t=un){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=xi.workingColorSpace){xi.fromWorkingColorSpace(ds.copy(this),e);const n=ds.r,i=ds.g,r=ds.b,s=Math.max(n,i,r),a=Math.min(n,i,r);let o,l;const c=(a+s)/2;if(a===s)o=0,l=0;else{const t=s-a;switch(l=c<=.5?t/(s+a):t/(2-s-a),s){case n:o=(i-r)/t+(i0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(void 0!==t)for(const e in t){const n=t[e];if(void 0===n){console.warn(`THREE.Material: parameter '${e}' has value of undefined.`);continue}const i=this[e];void 0!==i?i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[e]=n:console.warn(`THREE.Material: '${e}' is not a property of THREE.${this.type}.`)}}toJSON(t){const e=void 0===t||"string"==typeof t;e&&(t={textures:{},images:{}});const n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};function i(t){const e=[];for(const n in t){const i=t[n];delete i.metadata,e.push(i)}return e}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),void 0!==this.roughness&&(n.roughness=this.roughness),void 0!==this.metalness&&(n.metalness=this.metalness),void 0!==this.sheen&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),void 0!==this.emissiveIntensity&&1!==this.emissiveIntensity&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(n.shininess=this.shininess),void 0!==this.clearcoat&&(n.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),void 0!==this.dispersion&&(n.dispersion=this.dispersion),void 0!==this.iridescence&&(n.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(n.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),void 0!==this.anisotropy&&(n.anisotropy=this.anisotropy),void 0!==this.anisotropyRotation&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).uuid,void 0!==this.combine&&(n.combine=this.combine)),void 0!==this.envMapRotation&&(n.envMapRotation=this.envMapRotation.toArray()),void 0!==this.envMapIntensity&&(n.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(n.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(t).uuid),void 0!==this.transmission&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(t).uuid),void 0!==this.thickness&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(t).uuid),void 0!==this.attenuationDistance&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(n.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(n.size=this.size),null!==this.shadowSide&&(n.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==T&&(n.blending=this.blending),this.side!==M&&(n.side=this.side),!0===this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),!0===this.transparent&&(n.transparent=!0),this.blendSrc!==H&&(n.blendSrc=this.blendSrc),this.blendDst!==V&&(n.blendDst=this.blendDst),this.blendEquation!==L&&(n.blendEquation=this.blendEquation),null!==this.blendSrcAlpha&&(n.blendSrcAlpha=this.blendSrcAlpha),null!==this.blendDstAlpha&&(n.blendDstAlpha=this.blendDstAlpha),null!==this.blendEquationAlpha&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),0!==this.blendAlpha&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==it&&(n.depthFunc=this.depthFunc),!1===this.depthTest&&(n.depthTest=this.depthTest),!1===this.depthWrite&&(n.depthWrite=this.depthWrite),!1===this.colorWrite&&(n.colorWrite=this.colorWrite),255!==this.stencilWriteMask&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Bn&&(n.stencilFunc=this.stencilFunc),0!==this.stencilRef&&(n.stencilRef=this.stencilRef),255!==this.stencilFuncMask&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==gn&&(n.stencilFail=this.stencilFail),this.stencilZFail!==gn&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==gn&&(n.stencilZPass=this.stencilZPass),!0===this.stencilWrite&&(n.stencilWrite=this.stencilWrite),void 0!==this.rotation&&0!==this.rotation&&(n.rotation=this.rotation),!0===this.polygonOffset&&(n.polygonOffset=!0),0!==this.polygonOffsetFactor&&(n.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(n.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(n.linewidth=this.linewidth),void 0!==this.dashSize&&(n.dashSize=this.dashSize),void 0!==this.gapSize&&(n.gapSize=this.gapSize),void 0!==this.scale&&(n.scale=this.scale),!0===this.dithering&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),!0===this.alphaHash&&(n.alphaHash=!0),!0===this.alphaToCoverage&&(n.alphaToCoverage=!0),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=!0),!0===this.forceSinglePass&&(n.forceSinglePass=!0),!0===this.wireframe&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(n.flatShading=!0),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),!1===this.fog&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData),e){const e=i(t.textures),r=i(t.images);e.length>0&&(n.textures=e),r.length>0&&(n.images=r)}return n}clone(){return(new this.constructor).copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let n=null;if(null!==e){const t=e.length;n=new Array(t);for(let i=0;i!==t;++i)n[i]=e[i].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){!0===t&&this.version++}onBuild(){console.warn("Material: onBuild() has been removed.")}}class ms extends fs{static get type(){return"MeshBasicMaterial"}constructor(t){super(),this.isMeshBasicMaterial=!0,this.color=new us(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Tr,this.combine=lt,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}const gs=As();function As(){const t=new ArrayBuffer(4),e=new Float32Array(t),n=new Uint32Array(t),i=new Uint32Array(512),r=new Uint32Array(512);for(let t=0;t<256;++t){const e=t-127;e<-27?(i[t]=0,i[256|t]=32768,r[t]=24,r[256|t]=24):e<-14?(i[t]=1024>>-e-14,i[256|t]=1024>>-e-14|32768,r[t]=-e-1,r[256|t]=-e-1):e<=15?(i[t]=e+15<<10,i[256|t]=e+15<<10|32768,r[t]=13,r[256|t]=13):e<128?(i[t]=31744,i[256|t]=64512,r[t]=24,r[256|t]=24):(i[t]=31744,i[256|t]=64512,r[t]=13,r[256|t]=13)}const s=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let t=1;t<1024;++t){let e=t<<13,n=0;for(;!(8388608&e);)e<<=1,n-=8388608;e&=-8388609,n+=947912704,s[t]=e|n}for(let t=1024;t<2048;++t)s[t]=939524096+(t-1024<<13);for(let t=1;t<31;++t)a[t]=t<<23;a[31]=1199570944,a[32]=2147483648;for(let t=33;t<63;++t)a[t]=2147483648+(t-32<<23);a[63]=3347054592;for(let t=1;t<64;++t)32!==t&&(o[t]=1024);return{floatView:e,uint32View:n,baseTable:i,shiftTable:r,mantissaTable:s,exponentTable:a,offsetTable:o}}function vs(t){Math.abs(t)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),t=ri(t,-65504,65504),gs.floatView[0]=t;const e=gs.uint32View[0],n=e>>23&511;return gs.baseTable[n]+((8388607&e)>>gs.shiftTable[n])}function ys(t){const e=t>>10;return gs.uint32View[0]=gs.mantissaTable[gs.offsetTable[e]+(1023&t)]+gs.exponentTable[e],gs.floatView[0]}const xs={toHalfFloat:vs,fromHalfFloat:ys},_s=new Hi,ws=new hi;class Cs{constructor(t,e,n=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=t,this.itemSize=e,this.count=void 0!==t?t.length/e:0,this.normalized=n,this.usage=kn,this.updateRanges=[],this.gpuType=jt,this.version=0}onUploadCallback(){}set needsUpdate(t){!0===t&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,n){t*=this.itemSize,n*=e.itemSize;for(let i=0,r=this.itemSize;ie.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),e.needsUpdate=!0}return this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new ji);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute)return console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),void this.boundingBox.set(new Hi(-1/0,-1/0,-1/0),new Hi(1/0,1/0,1/0));if(void 0!==t){if(this.boundingBox.setFromBufferAttribute(t),e)for(let t=0,n=e.length;t0&&(t.userData=this.userData),void 0!==this.parameters){const e=this.parameters;for(const n in e)void 0!==e[n]&&(t[n]=e[n]);return t}t.data={attributes:{}};const e=this.index;null!==e&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const n=this.attributes;for(const e in n){const i=n[e];t.data.attributes[e]=i.toJSON(t.data)}const i={};let r=!1;for(const e in this.morphAttributes){const n=this.morphAttributes[e],s=[];for(let e=0,i=n.length;e0&&(i[e]=s,r=!0)}r&&(t.data.morphAttributes=i,t.data.morphTargetsRelative=this.morphTargetsRelative);const s=this.groups;s.length>0&&(t.data.groups=JSON.parse(JSON.stringify(s)));const a=this.boundingSphere;return null!==a&&(t.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),t}clone(){return(new this.constructor).copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const n=t.index;null!==n&&this.setIndex(n.clone(e));const i=t.attributes;for(const t in i){const n=i[t];this.setAttribute(t,n.clone(e))}const r=t.morphAttributes;for(const t in r){const n=[],i=r[t];for(let t=0,r=i.length;t0){const n=t[e[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=n.length;t(t.far-t.near)**2)return}zs.copy(r).invert(),Gs.copy(t.ray).applyMatrix4(zs),null!==n.boundingBox&&!1===Gs.intersectsBox(n.boundingBox)||this._computeIntersections(t,e,Gs)}}_computeIntersections(t,e,n){let i;const r=this.geometry,s=this.material,a=r.index,o=r.attributes.position,l=r.attributes.uv,c=r.attributes.uv1,h=r.attributes.normal,u=r.groups,d=r.drawRange;if(null!==a)if(Array.isArray(s))for(let r=0,o=u.length;rn.far?null:{distance:c,point:Ks.clone(),object:t}}(t,e,n,i,Ws,js,qs,Js);if(h){const t=new Hi;as.getBarycoord(Js,Ws,js,qs,t),r&&(h.uv=as.getInterpolatedAttribute(r,o,l,c,t,new hi)),s&&(h.uv1=as.getInterpolatedAttribute(s,o,l,c,t,new hi)),a&&(h.normal=as.getInterpolatedAttribute(a,o,l,c,t,new Hi),h.normal.dot(i.direction)>0&&h.normal.multiplyScalar(-1));const e={a:o,b:l,c,normal:new Hi,materialIndex:0};as.getNormal(Ws,js,qs,e.normal),h.face=e,h.barycoord=t}return h}class ta extends Qs{constructor(t=1,e=1,n=1,i=1,r=1,s=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:i,heightSegments:r,depthSegments:s};const a=this;i=Math.floor(i),r=Math.floor(r),s=Math.floor(s);const o=[],l=[],c=[],h=[];let u=0,d=0;function p(t,e,n,i,r,s,p,f,m,g,A){const v=s/m,y=p/g,x=s/2,_=p/2,w=f/2,C=m+1,E=g+1;let M=0,b=0;const S=new Hi;for(let s=0;s0?1:-1,c.push(S.x,S.y,S.z),h.push(o/m),h.push(1-s/g),M+=1}}for(let t=0;t0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;const n={};for(const t in this.extensions)!0===this.extensions[t]&&(n[t]=!0);return Object.keys(n).length>0&&(e.extensions=n),e}}class aa extends jr{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new yr,this.projectionMatrix=new yr,this.projectionMatrixInverse=new yr,this.coordinateSystem=Jn}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this.coordinateSystem=t.coordinateSystem,this}getWorldDirection(t){return super.getWorldDirection(t).negate()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return(new this.constructor).copy(this)}}const oa=new Hi,la=new hi,ca=new hi;class ha extends aa{constructor(t=50,e=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=null===t.view?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){const e=.5*this.getFilmHeight()/t;this.fov=2*ni*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(.5*ei*this.fov);return.5*this.getFilmHeight()/t}getEffectiveFOV(){return 2*ni*Math.atan(Math.tan(.5*ei*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(t,e,n){oa.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),e.set(oa.x,oa.y).multiplyScalar(-t/oa.z),oa.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(oa.x,oa.y).multiplyScalar(-t/oa.z)}getViewSize(t,e){return this.getViewBounds(t,la,ca),e.subVectors(ca,la)}setViewOffset(t,e,n,i,r,s){this.aspect=t/e,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let e=t*Math.tan(.5*ei*this.fov)/this.zoom,n=2*e,i=this.aspect*n,r=-.5*i;const s=this.view;if(null!==this.view&&this.view.enabled){const t=s.fullWidth,a=s.fullHeight;r+=s.offsetX*i/t,e-=s.offsetY*n/a,i*=s.width/t,n*=s.height/a}const a=this.filmOffset;0!==a&&(r+=t*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,e,e-n,t,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,null!==this.view&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}const ua=-90;class da extends jr{constructor(t,e,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new ha(ua,1,t,e);i.layers=this.layers,this.add(i);const r=new ha(ua,1,t,e);r.layers=this.layers,this.add(r);const s=new ha(ua,1,t,e);s.layers=this.layers,this.add(s);const a=new ha(ua,1,t,e);a.layers=this.layers,this.add(a);const o=new ha(ua,1,t,e);o.layers=this.layers,this.add(o);const l=new ha(ua,1,t,e);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const t=this.coordinateSystem,e=this.children.concat(),[n,i,r,s,a,o]=e;for(const t of e)this.remove(t);if(t===Jn)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),s.up.set(0,0,1),s.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),o.up.set(0,1,0),o.lookAt(0,0,-1);else{if(t!==Kn)throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+t);n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),s.up.set(0,0,-1),s.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),o.up.set(0,-1,0),o.lookAt(0,0,-1)}for(const t of e)this.add(t),t.updateMatrixWorld()}update(t,e){null===this.parent&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:i}=this;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());const[r,s,a,o,l,c]=this.children,h=t.getRenderTarget(),u=t.getActiveCubeFace(),d=t.getActiveMipmapLevel(),p=t.xr.enabled;t.xr.enabled=!1;const f=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,t.setRenderTarget(n,0,i),t.render(e,r),t.setRenderTarget(n,1,i),t.render(e,s),t.setRenderTarget(n,2,i),t.render(e,a),t.setRenderTarget(n,3,i),t.render(e,o),t.setRenderTarget(n,4,i),t.render(e,l),n.texture.generateMipmaps=f,t.setRenderTarget(n,5,i),t.render(e,c),t.setRenderTarget(h,u,d),t.xr.enabled=p,n.texture.needsPMREMUpdate=!0}}class pa extends Li{constructor(t,e,n,i,r,s,a,o,l,c){super(t=void 0!==t?t:[],e=void 0!==e?e:wt,n,i,r,s,a,o,l,c),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}class fa extends Fi{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;const n={width:t,height:t,depth:1},i=[n,n,n,n,n,n];this.texture=new pa(i,e.mapping,e.wrapS,e.wrapT,e.magFilter,e.minFilter,e.format,e.type,e.anisotropy,e.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=void 0!==e.generateMipmaps&&e.generateMipmaps,this.texture.minFilter=void 0!==e.minFilter?e.minFilter:Ut}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.colorSpace=e.colorSpace,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;const n={tEquirect:{value:null}},i="\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\n\t\t\t\t}\n\t\t\t",r="\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include \n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t",s=new ta(5,5,5),a=new sa({name:"CubemapFromEquirect",uniforms:ea(n),vertexShader:i,fragmentShader:r,side:b,blending:I});a.uniforms.tEquirect.value=e;const o=new Zs(s,a),l=e.minFilter;return e.minFilter===Ot&&(e.minFilter=Ut),new da(1,10,this).update(t,o),e.minFilter=l,o.geometry.dispose(),o.material.dispose(),this}clear(t,e,n,i){const r=t.getRenderTarget();for(let r=0;r<6;r++)t.setRenderTarget(this,r),t.clear(e,n,i);t.setRenderTarget(r)}}const ma=new Hi,ga=new Hi,Aa=new ui;class va{constructor(t=new Hi(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,n,i){return this.normal.set(t,e,n),this.constant=i,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,n){const i=ma.subVectors(n,e).cross(ga.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(i,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e){const n=t.delta(ma),i=this.normal.dot(n);if(0===i)return 0===this.distanceToPoint(t.start)?e.copy(t.start):null;const r=-(t.start.dot(this.normal)+this.constant)/i;return r<0||r>1?null:e.copy(t.start).addScaledVector(n,r)}intersectsLine(t){const e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const n=e||Aa.getNormalMatrix(t),i=this.coplanarPoint(ma).applyMatrix4(t),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return(new this.constructor).copy(this)}}const ya=new hr,xa=new Hi;class _a{constructor(t=new va,e=new va,n=new va,i=new va,r=new va,s=new va){this.planes=[t,e,n,i,r,s]}set(t,e,n,i,r,s){const a=this.planes;return a[0].copy(t),a[1].copy(e),a[2].copy(n),a[3].copy(i),a[4].copy(r),a[5].copy(s),this}copy(t){const e=this.planes;for(let n=0;n<6;n++)e[n].copy(t.planes[n]);return this}setFromProjectionMatrix(t,e=Jn){const n=this.planes,i=t.elements,r=i[0],s=i[1],a=i[2],o=i[3],l=i[4],c=i[5],h=i[6],u=i[7],d=i[8],p=i[9],f=i[10],m=i[11],g=i[12],A=i[13],v=i[14],y=i[15];if(n[0].setComponents(o-r,u-l,m-d,y-g).normalize(),n[1].setComponents(o+r,u+l,m+d,y+g).normalize(),n[2].setComponents(o+s,u+c,m+p,y+A).normalize(),n[3].setComponents(o-s,u-c,m-p,y-A).normalize(),n[4].setComponents(o-a,u-h,m-f,y-v).normalize(),e===Jn)n[5].setComponents(o+a,u+h,m+f,y+v).normalize();else{if(e!==Kn)throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);n[5].setComponents(a,h,f,v).normalize()}return this}intersectsObject(t){if(void 0!==t.boundingSphere)null===t.boundingSphere&&t.computeBoundingSphere(),ya.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const e=t.geometry;null===e.boundingSphere&&e.computeBoundingSphere(),ya.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(ya)}intersectsSprite(t){return ya.center.set(0,0,0),ya.radius=.7071067811865476,ya.applyMatrix4(t.matrixWorld),this.intersectsSphere(ya)}intersectsSphere(t){const e=this.planes,n=t.center,i=-t.radius;for(let t=0;t<6;t++)if(e[t].distanceToPoint(n)0?t.max.x:t.min.x,xa.y=i.normal.y>0?t.max.y:t.min.y,xa.z=i.normal.z>0?t.max.z:t.min.z,i.distanceToPoint(xa)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}function wa(){let t=null,e=!1,n=null,i=null;function r(e,s){n(e,s),i=t.requestAnimationFrame(r)}return{start:function(){!0!==e&&null!==n&&(i=t.requestAnimationFrame(r),e=!0)},stop:function(){t.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(t){n=t},setContext:function(e){t=e}}}function Ca(t){const e=new WeakMap;return{get:function(t){return t.isInterleavedBufferAttribute&&(t=t.data),e.get(t)},remove:function(n){n.isInterleavedBufferAttribute&&(n=n.data);const i=e.get(n);i&&(t.deleteBuffer(i.buffer),e.delete(n))},update:function(n,i){if(n.isInterleavedBufferAttribute&&(n=n.data),n.isGLBufferAttribute){const t=e.get(n);return void((!t||t.versiont.start-e.start));let e=0;for(let t=1;t 0\n\tvec4 plane;\n\t#ifdef ALPHA_TO_COVERAGE\n\t\tfloat distanceToPlane, distanceGradient;\n\t\tfloat clipOpacity = 1.0;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tdistanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n\t\t\tdistanceGradient = fwidth( distanceToPlane ) / 2.0;\n\t\t\tclipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n\t\t\tif ( clipOpacity == 0.0 ) discard;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\t\tfloat unionClipOpacity = 1.0;\n\t\t\t#pragma unroll_loop_start\n\t\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\t\tplane = clippingPlanes[ i ];\n\t\t\t\tdistanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n\t\t\t\tdistanceGradient = fwidth( distanceToPlane ) / 2.0;\n\t\t\t\tunionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n\t\t\t}\n\t\t\t#pragma unroll_loop_end\n\t\t\tclipOpacity *= 1.0 - unionClipOpacity;\n\t\t#endif\n\t\tdiffuseColor.a *= clipOpacity;\n\t\tif ( diffuseColor.a == 0.0 ) discard;\n\t#else\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\t\tbool clipped = true;\n\t\t\t#pragma unroll_loop_start\n\t\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\t\tplane = clippingPlanes[ i ];\n\t\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t\t}\n\t\t\t#pragma unroll_loop_end\n\t\t\tif ( clipped ) discard;\n\t\t#endif\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvarying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif\n#ifdef USE_BATCHING_COLOR\n\tvec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );\n\tvColor.xyz *= batchingColor.xyz;\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\n#ifdef USE_ALPHAHASH\n\tvarying vec3 vPosition;\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\thighp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tuv.x += filterInt * 3.0 * cubeUV_minTileSize;\n\t\tuv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n\t\tuv.x *= CUBEUV_TEXEL_WIDTH;\n\t\tuv.y *= CUBEUV_TEXEL_HEIGHT;\n\t\t#ifdef texture2DGradEXT\n\t\t\treturn texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n\t\t#else\n\t\t\treturn texture2D( envMap, uv ).rgb;\n\t\t#endif\n\t}\n\t#define cubeUV_r0 1.0\n\t#define cubeUV_m0 - 2.0\n\t#define cubeUV_r1 0.8\n\t#define cubeUV_m1 - 1.0\n\t#define cubeUV_r4 0.4\n\t#define cubeUV_m4 2.0\n\t#define cubeUV_r5 0.305\n\t#define cubeUV_m5 3.0\n\t#define cubeUV_r6 0.21\n\t#define cubeUV_m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= cubeUV_r1 ) {\n\t\t\tmip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n\t\t} else if ( roughness >= cubeUV_r4 ) {\n\t\t\tmip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n\t\t} else if ( roughness >= cubeUV_r5 ) {\n\t\t\tmip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n\t\t} else if ( roughness >= cubeUV_r6 ) {\n\t\t\tmip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = objectTangent;\n#endif\n#ifdef USE_BATCHING\n\tmat3 bm = mat3( batchingMatrix );\n\ttransformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );\n\ttransformedNormal = bm * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = bm * transformedTangent;\n\t#endif\n#endif\n#ifdef USE_INSTANCING\n\tmat3 im = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );\n\ttransformedNormal = im * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = im * transformedTangent;\n\t#endif\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\ttransformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE\n\t\temissiveColor = sRGBTransferEOTF( emissiveColor );\n\t#endif\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",colorspace_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",colorspace_pars_fragment:"vec4 LinearTransferOETF( in vec4 value ) {\n\treturn value;\n}\nvec4 sRGBTransferEOTF( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 sRGBTransferOETF( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform mat3 envMapRotation;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#ifdef USE_ENVMAP\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 reflectVec = reflect( - viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\t#ifdef USE_ANISOTROPY\n\t\tvec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n\t\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\t\tvec3 bentNormal = cross( bitangent, viewDir );\n\t\t\t\tbentNormal = normalize( cross( bentNormal, bitangent ) );\n\t\t\t\tbentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n\t\t\t\treturn getIBLRadiance( viewDir, bentNormal, roughness );\n\t\t\t#else\n\t\t\t\treturn vec3( 0.0 );\n\t\t\t#endif\n\t\t}\n\t#endif\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\tvec2 fw = fwidth( coord ) * 0.5;\n\t\treturn mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n\t#endif\n}",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_fragment:"LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;",lights_lambert_pars_fragment:"varying vec3 vViewPosition;\nstruct LambertMaterial {\n\tvec3 diffuseColor;\n\tfloat specularStrength;\n};\nvoid RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Lambert\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Lambert",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n\tuniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\tif ( cutoffDistance > 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\tmaterial.ior = ior;\n\t#ifdef USE_SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULAR_COLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n\t\t#endif\n\t\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_DISPERSION\n\tmaterial.dispersion = dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\t#ifdef USE_ANISOTROPYMAP\n\t\tmat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n\t\tvec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n\t\tvec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n\t#else\n\t\tvec2 anisotropyV = anisotropyVector;\n\t#endif\n\tmaterial.anisotropy = length( anisotropyV );\n\tif( material.anisotropy == 0.0 ) {\n\t\tanisotropyV = vec2( 1.0, 0.0 );\n\t} else {\n\t\tanisotropyV /= material.anisotropy;\n\t\tmaterial.anisotropy = saturate( material.anisotropy );\n\t}\n\tmaterial.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n\tmaterial.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;\n\tmaterial.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\tfloat dispersion;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n\t#ifdef IOR\n\t\tfloat ior;\n\t#endif\n\t#ifdef USE_TRANSMISSION\n\t\tfloat transmission;\n\t\tfloat transmissionAlpha;\n\t\tfloat thickness;\n\t\tfloat attenuationDistance;\n\t\tvec3 attenuationColor;\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat anisotropy;\n\t\tfloat alphaT;\n\t\tvec3 anisotropyT;\n\t\tvec3 anisotropyB;\n\t#endif\n};\nvec3 clearcoatSpecularDirect = vec3( 0.0 );\nvec3 clearcoatSpecularIndirect = vec3( 0.0 );\nvec3 sheenSpecularDirect = vec3( 0.0 );\nvec3 sheenSpecularIndirect = vec3(0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n\tfloat V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {\n\t\tfloat gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n\t\tfloat gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n\t\tfloat v = 0.5 / ( gv + gl );\n\t\treturn saturate(v);\n\t}\n\tfloat D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n\t\tfloat a2 = alphaT * alphaB;\n\t\thighp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n\t\thighp float v2 = dot( v, v );\n\t\tfloat w2 = a2 / v2;\n\t\treturn RECIPROCAL_PI * a2 * pow2 ( w2 );\n\t}\n#endif\n#ifdef USE_CLEARCOAT\n\tvec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n\t\tvec3 f0 = material.clearcoatF0;\n\t\tfloat f90 = material.clearcoatF90;\n\t\tfloat roughness = material.clearcoatRoughness;\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 f0 = material.specularColor;\n\tfloat f90 = material.specularF90;\n\tfloat roughness = material.roughness;\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t#ifdef USE_IRIDESCENCE\n\t\tF = mix( F, material.iridescenceFresnel, material.iridescence );\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat dotTL = dot( material.anisotropyT, lightDir );\n\t\tfloat dotTV = dot( material.anisotropyT, viewDir );\n\t\tfloat dotTH = dot( material.anisotropyT, halfDir );\n\t\tfloat dotBL = dot( material.anisotropyB, lightDir );\n\t\tfloat dotBV = dot( material.anisotropyB, viewDir );\n\t\tfloat dotBH = dot( material.anisotropyB, halfDir );\n\t\tfloat V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n\t\tfloat D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n\t#else\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t#endif\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n\tfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n\tfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n\treturn saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#endif\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometryNormal;\n\t\tvec3 viewDir = geometryViewDir;\n\t\tvec3 position = geometryPosition;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n\t#else\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\t#endif\n\tvec3 totalScattering = singleScattering + multiScattering;\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\nvec3 geometryClearcoatNormal = vec3( 0.0 );\n#ifdef USE_CLEARCOAT\n\tgeometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometryViewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometryPosition, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometryPosition, directLight );\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#if defined( USE_LIGHT_PROBES )\n\t\tirradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometryNormal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\t#ifdef USE_ANISOTROPY\n\t\tradiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );\n\t#else\n\t\tradiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF )\n\tgl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\tvFragDepth = 1.0 + gl_Position.w;\n\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 sampledDiffuseColor = texture2D( map, vMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tsampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );\n\t#endif\n\tdiffuseColor *= sampledDiffuseColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t#if defined( USE_POINTS_UV )\n\t\tvec2 uv = vUv;\n\t#else\n\t\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_POINTS_UV )\n\tvarying vec2 vUv;\n#else\n\t#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t\tuniform mat3 uvTransform;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphinstance_vertex:"#ifdef USE_INSTANCING_MORPH\n\tfloat morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\tfloat morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tmorphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;\n\t}\n#endif",morphcolor_vertex:"#if defined( USE_MORPHCOLORS )\n\tvColor *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t#if defined( USE_COLOR_ALPHA )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n\t\t#elif defined( USE_COLOR )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n\t\t#endif\n\t}\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\t#ifndef USE_INSTANCING_MORPH\n\t\tuniform float morphTargetBaseInfluence;\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t#endif\n\tuniform sampler2DArray morphTargetsTexture;\n\tuniform ivec2 morphTargetsTextureSize;\n\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n\t\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n\t\tint y = texelIndex / morphTargetsTextureSize.x;\n\t\tint x = texelIndex - y * morphTargetsTextureSize.x;\n\t\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\n\t\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\n\t}\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = dFdx( vViewPosition );\n\tvec3 fdy = dFdy( vViewPosition );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal *= faceDirection;\n\t#endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn = getTangentFrame( - vViewPosition, normal,\n\t\t#if defined( USE_NORMALMAP )\n\t\t\tvNormalMapUv\n\t\t#elif defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tvClearcoatNormalMapUv\n\t\t#else\n\t\t\tvUv\n\t\t#endif\n\t\t);\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn[0] *= faceDirection;\n\t\ttbn[1] *= faceDirection;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn2[0] *= faceDirection;\n\t\ttbn2[1] *= faceDirection;\n\t#endif\n#endif\nvec3 nonPerturbedNormal = normal;",normal_fragment_maps:"#ifdef USE_NORMALMAP_OBJECTSPACE\n\tnormal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n\tvec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\tnormal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef USE_NORMALMAP_OBJECTSPACE\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )\n\tmat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( uv.st );\n\t\tvec2 st1 = dFdy( uv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n\t\treturn mat3( T * scale, B * scale, N );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = nonPerturbedNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\tclearcoatNormal = normalize( tbn2 * clearcoatMapN );\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif",iridescence_pars_fragment:"#ifdef USE_IRIDESCENCEMAP\n\tuniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform sampler2D iridescenceThicknessMap;\n#endif",opaque_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;\nconst float Inv255 = 1. / 255.;\nconst vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );\nconst vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );\nconst vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );\nconst vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );\nvec4 packDepthToRGBA( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec4( 0., 0., 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec4( 1., 1., 1., 1. );\n\tfloat vuf;\n\tfloat af = modf( v * PackFactors.a, vuf );\n\tfloat bf = modf( vuf * ShiftRight8, vuf );\n\tfloat gf = modf( vuf * ShiftRight8, vuf );\n\treturn vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );\n}\nvec3 packDepthToRGB( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec3( 0., 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec3( 1., 1., 1. );\n\tfloat vuf;\n\tfloat bf = modf( v * PackFactors.b, vuf );\n\tfloat gf = modf( vuf * ShiftRight8, vuf );\n\treturn vec3( vuf * Inv255, gf * PackUpscale, bf );\n}\nvec2 packDepthToRG( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec2( 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec2( 1., 1. );\n\tfloat vuf;\n\tfloat gf = modf( v * 256., vuf );\n\treturn vec2( vuf * Inv255, gf );\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors4 );\n}\nfloat unpackRGBToDepth( const in vec3 v ) {\n\treturn dot( v, UnpackFactors3 );\n}\nfloat unpackRGToDepth( const in vec2 v ) {\n\treturn v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;\n}\nvec4 pack2HalfToRGBA( const in vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( const in vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn depth * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * depth - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_BATCHING\n\tmvPosition = batchingMatrix * mvPosition;\n#endif\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n\tuniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tfloat shadow = 1.0;\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\t\n\t\tfloat lightToPositionLength = length( lightToPosition );\n\t\tif ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {\n\t\t\tfloat dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\t\tdp += shadowBias;\n\t\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\t\tshadow = (\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t\t) * ( 1.0 / 9.0 );\n\t\t\t#else\n\t\t\t\tshadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t\t#endif\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n#endif",shadowmap_pars_vertex:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tuniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\tvec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition;\n\t\t#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t\tshadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n\t\t#endif\n\t\tvSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\tuniform highp sampler2D boneTexture;\n\tmat4 getBoneMatrix( const in float i ) {\n\t\tint size = textureSize( boneTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 CineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nconst mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.6605, - 0.1246, - 0.0182 ),\n\tvec3( - 0.5876, 1.1329, - 0.1006 ),\n\tvec3( - 0.0728, - 0.0083, 1.1187 )\n);\nconst mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(\n\tvec3( 0.6274, 0.0691, 0.0164 ),\n\tvec3( 0.3293, 0.9195, 0.0880 ),\n\tvec3( 0.0433, 0.0113, 0.8956 )\n);\nvec3 agxDefaultContrastApprox( vec3 x ) {\n\tvec3 x2 = x * x;\n\tvec3 x4 = x2 * x2;\n\treturn + 15.5 * x4 * x2\n\t\t- 40.14 * x4 * x\n\t\t+ 31.96 * x4\n\t\t- 6.868 * x2 * x\n\t\t+ 0.4298 * x2\n\t\t+ 0.1191 * x\n\t\t- 0.00232;\n}\nvec3 AgXToneMapping( vec3 color ) {\n\tconst mat3 AgXInsetMatrix = mat3(\n\t\tvec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),\n\t\tvec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),\n\t\tvec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )\n\t);\n\tconst mat3 AgXOutsetMatrix = mat3(\n\t\tvec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),\n\t\tvec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),\n\t\tvec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )\n\t);\n\tconst float AgxMinEv = - 12.47393;\tconst float AgxMaxEv = 4.026069;\n\tcolor *= toneMappingExposure;\n\tcolor = LINEAR_SRGB_TO_LINEAR_REC2020 * color;\n\tcolor = AgXInsetMatrix * color;\n\tcolor = max( color, 1e-10 );\tcolor = log2( color );\n\tcolor = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );\n\tcolor = clamp( color, 0.0, 1.0 );\n\tcolor = agxDefaultContrastApprox( color );\n\tcolor = AgXOutsetMatrix * color;\n\tcolor = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );\n\tcolor = LINEAR_REC2020_TO_LINEAR_SRGB * color;\n\tcolor = clamp( color, 0.0, 1.0 );\n\treturn color;\n}\nvec3 NeutralToneMapping( vec3 color ) {\n\tconst float StartCompression = 0.8 - 0.04;\n\tconst float Desaturation = 0.15;\n\tcolor *= toneMappingExposure;\n\tfloat x = min( color.r, min( color.g, color.b ) );\n\tfloat offset = x < 0.08 ? x - 6.25 * x * x : 0.04;\n\tcolor -= offset;\n\tfloat peak = max( color.r, max( color.g, color.b ) );\n\tif ( peak < StartCompression ) return color;\n\tfloat d = 1. - StartCompression;\n\tfloat newPeak = 1. - d * d / ( peak + d - StartCompression );\n\tcolor *= newPeak / peak;\n\tfloat g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );\n\treturn mix( color, vec3( newPeak ), g );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n\tmaterial.transmission = transmission;\n\tmaterial.transmissionAlpha = 1.0;\n\tmaterial.thickness = thickness;\n\tmaterial.attenuationDistance = attenuationDistance;\n\tmaterial.attenuationColor = attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tmaterial.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tmaterial.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmitted = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,\n\t\tmaterial.attenuationColor, material.attenuationDistance );\n\tmaterial.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );\n\ttotalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tfloat w0( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n\t}\n\tfloat w1( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );\n\t}\n\tfloat w2( float a ){\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n\t}\n\tfloat w3( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * a );\n\t}\n\tfloat g0( float a ) {\n\t\treturn w0( a ) + w1( a );\n\t}\n\tfloat g1( float a ) {\n\t\treturn w2( a ) + w3( a );\n\t}\n\tfloat h0( float a ) {\n\t\treturn - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n\t}\n\tfloat h1( float a ) {\n\t\treturn 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n\t}\n\tvec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n\t\tuv = uv * texelSize.zw + 0.5;\n\t\tvec2 iuv = floor( uv );\n\t\tvec2 fuv = fract( uv );\n\t\tfloat g0x = g0( fuv.x );\n\t\tfloat g1x = g1( fuv.x );\n\t\tfloat h0x = h0( fuv.x );\n\t\tfloat h1x = h1( fuv.x );\n\t\tfloat h0y = h0( fuv.y );\n\t\tfloat h1y = h1( fuv.y );\n\t\tvec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\treturn g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +\n\t\t\tg1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n\t}\n\tvec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n\t\tvec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n\t\tvec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n\t\tvec2 fLodSizeInv = 1.0 / fLodSize;\n\t\tvec2 cLodSizeInv = 1.0 / cLodSize;\n\t\tvec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n\t\tvec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n\t\treturn mix( fSample, cSample, fract( lod ) );\n\t}\n\tvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( const in float roughness, const in float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n\t\tfloat lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\treturn textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );\n\t}\n\tvec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( isinf( attenuationDistance ) ) {\n\t\t\treturn vec3( 1.0 );\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n\t\tconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n\t\tconst in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec4 transmittedLight;\n\t\tvec3 transmittance;\n\t\t#ifdef USE_DISPERSION\n\t\t\tfloat halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;\n\t\t\tvec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );\n\t\t\tfor ( int i = 0; i < 3; i ++ ) {\n\t\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );\n\t\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\n\t\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\t\trefractionCoords += 1.0;\n\t\t\t\trefractionCoords /= 2.0;\n\t\t\n\t\t\t\tvec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );\n\t\t\t\ttransmittedLight[ i ] = transmissionSample[ i ];\n\t\t\t\ttransmittedLight.a += transmissionSample.a;\n\t\t\t\ttransmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];\n\t\t\t}\n\t\t\ttransmittedLight.a /= 3.0;\n\t\t\n\t\t#else\n\t\t\n\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\trefractionCoords += 1.0;\n\t\t\trefractionCoords /= 2.0;\n\t\t\ttransmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\t\ttransmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\t\n\t\t#endif\n\t\tvec3 attenuatedColor = transmittance * transmittedLight.rgb;\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\tfloat transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );\n\t}\n#endif",uv_pars_fragment:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_pars_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tuniform mat3 mapTransform;\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform mat3 alphaMapTransform;\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tuniform mat3 lightMapTransform;\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tuniform mat3 aoMapTransform;\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tuniform mat3 bumpMapTransform;\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tuniform mat3 normalMapTransform;\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tuniform mat3 displacementMapTransform;\n\tvarying vec2 vDisplacementMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tuniform mat3 emissiveMapTransform;\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tuniform mat3 metalnessMapTransform;\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tuniform mat3 roughnessMapTransform;\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tuniform mat3 anisotropyMapTransform;\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tuniform mat3 clearcoatMapTransform;\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform mat3 clearcoatNormalMapTransform;\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform mat3 clearcoatRoughnessMapTransform;\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tuniform mat3 sheenColorMapTransform;\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tuniform mat3 sheenRoughnessMapTransform;\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tuniform mat3 iridescenceMapTransform;\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform mat3 iridescenceThicknessMapTransform;\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tuniform mat3 specularMapTransform;\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tuniform mat3 specularColorMapTransform;\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tuniform mat3 specularIntensityMapTransform;\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvUv = vec3( uv, 1 ).xy;\n#endif\n#ifdef USE_MAP\n\tvMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ALPHAMAP\n\tvAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_LIGHTMAP\n\tvLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_AOMAP\n\tvAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_BUMPMAP\n\tvBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_NORMALMAP\n\tvNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tvDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_METALNESSMAP\n\tvMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULARMAP\n\tvSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tvTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_THICKNESSMAP\n\tvThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_BATCHING\n\t\tworldPosition = batchingMatrix * worldPosition;\n\t#endif\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",background_frag:"uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\ttexColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include \n\t#include \n}",backgroundCube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}",backgroundCube_frag:"#ifdef ENVMAP_TYPE_CUBE\n\tuniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n\tuniform sampler2D envMap;\n#endif\nuniform float flipEnvMap;\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nuniform mat3 backgroundRotation;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );\n\t#else\n\t\tvec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include \n\t#include \n}",cube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\tgl_FragColor = texColor;\n\tgl_FragColor.a *= opacity;\n\t#include \n\t#include \n}",depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#elif DEPTH_PACKING == 3202\n\t\tgl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );\n\t#elif DEPTH_PACKING == 3203\n\t\tgl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );\n\t#endif\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition.xyz;\n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include \n\t#include \n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshbasic_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}",meshlambert_frag:"#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t#else\n\t\tvec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );\n\t#ifdef OPAQUE\n\t\tgl_FragColor.a = 1.0;\n\t#endif\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef USE_SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULAR_COLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_DISPERSION\n\tuniform float dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tuniform float iridescence;\n\tuniform float iridescenceIOR;\n\tuniform float iridescenceThicknessMinimum;\n\tuniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\tuniform vec2 anisotropyVector;\n\t#ifdef USE_ANISOTROPYMAP\n\t\tuniform sampler2D anisotropyMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include \n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n\t\toutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",points_vert:"uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \n#ifdef USE_POINTS_UV\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\nvoid main() {\n\t#ifdef USE_POINTS_UV\n\t\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",shadow_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include \n\t#include \n\t#include \n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 mvPosition = modelViewMatrix[ 3 ];\n\tvec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n}"},ba={common:{diffuse:{value:new us(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new ui},alphaMap:{value:null},alphaMapTransform:{value:new ui},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new ui}},envmap:{envMap:{value:null},envMapRotation:{value:new ui},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new ui}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new ui}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new ui},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new ui},normalScale:{value:new hi(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new ui},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new ui}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new ui}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new ui}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new us(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,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 us(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new ui},alphaTest:{value:0},uvTransform:{value:new ui}},sprite:{diffuse:{value:new us(16777215)},opacity:{value:1},center:{value:new hi(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new ui},alphaMap:{value:null},alphaMapTransform:{value:new ui},alphaTest:{value:0}}},Sa={basic:{uniforms:na([ba.common,ba.specularmap,ba.envmap,ba.aomap,ba.lightmap,ba.fog]),vertexShader:Ma.meshbasic_vert,fragmentShader:Ma.meshbasic_frag},lambert:{uniforms:na([ba.common,ba.specularmap,ba.envmap,ba.aomap,ba.lightmap,ba.emissivemap,ba.bumpmap,ba.normalmap,ba.displacementmap,ba.fog,ba.lights,{emissive:{value:new us(0)}}]),vertexShader:Ma.meshlambert_vert,fragmentShader:Ma.meshlambert_frag},phong:{uniforms:na([ba.common,ba.specularmap,ba.envmap,ba.aomap,ba.lightmap,ba.emissivemap,ba.bumpmap,ba.normalmap,ba.displacementmap,ba.fog,ba.lights,{emissive:{value:new us(0)},specular:{value:new us(1118481)},shininess:{value:30}}]),vertexShader:Ma.meshphong_vert,fragmentShader:Ma.meshphong_frag},standard:{uniforms:na([ba.common,ba.envmap,ba.aomap,ba.lightmap,ba.emissivemap,ba.bumpmap,ba.normalmap,ba.displacementmap,ba.roughnessmap,ba.metalnessmap,ba.fog,ba.lights,{emissive:{value:new us(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ma.meshphysical_vert,fragmentShader:Ma.meshphysical_frag},toon:{uniforms:na([ba.common,ba.aomap,ba.lightmap,ba.emissivemap,ba.bumpmap,ba.normalmap,ba.displacementmap,ba.gradientmap,ba.fog,ba.lights,{emissive:{value:new us(0)}}]),vertexShader:Ma.meshtoon_vert,fragmentShader:Ma.meshtoon_frag},matcap:{uniforms:na([ba.common,ba.bumpmap,ba.normalmap,ba.displacementmap,ba.fog,{matcap:{value:null}}]),vertexShader:Ma.meshmatcap_vert,fragmentShader:Ma.meshmatcap_frag},points:{uniforms:na([ba.points,ba.fog]),vertexShader:Ma.points_vert,fragmentShader:Ma.points_frag},dashed:{uniforms:na([ba.common,ba.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ma.linedashed_vert,fragmentShader:Ma.linedashed_frag},depth:{uniforms:na([ba.common,ba.displacementmap]),vertexShader:Ma.depth_vert,fragmentShader:Ma.depth_frag},normal:{uniforms:na([ba.common,ba.bumpmap,ba.normalmap,ba.displacementmap,{opacity:{value:1}}]),vertexShader:Ma.meshnormal_vert,fragmentShader:Ma.meshnormal_frag},sprite:{uniforms:na([ba.sprite,ba.fog]),vertexShader:Ma.sprite_vert,fragmentShader:Ma.sprite_frag},background:{uniforms:{uvTransform:{value:new ui},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ma.background_vert,fragmentShader:Ma.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new ui}},vertexShader:Ma.backgroundCube_vert,fragmentShader:Ma.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ma.cube_vert,fragmentShader:Ma.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ma.equirect_vert,fragmentShader:Ma.equirect_frag},distanceRGBA:{uniforms:na([ba.common,ba.displacementmap,{referencePosition:{value:new Hi},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ma.distanceRGBA_vert,fragmentShader:Ma.distanceRGBA_frag},shadow:{uniforms:na([ba.lights,ba.fog,{color:{value:new us(0)},opacity:{value:1}}]),vertexShader:Ma.shadow_vert,fragmentShader:Ma.shadow_frag}};Sa.physical={uniforms:na([Sa.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new ui},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new ui},clearcoatNormalScale:{value:new hi(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new ui},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new ui},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new ui},sheen:{value:0},sheenColor:{value:new us(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new ui},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new ui},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new ui},transmissionSamplerSize:{value:new hi},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new ui},attenuationDistance:{value:0},attenuationColor:{value:new us(0)},specularColor:{value:new us(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new ui},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new ui},anisotropyVector:{value:new hi},anisotropyMap:{value:null},anisotropyMapTransform:{value:new ui}}]),vertexShader:Ma.meshphysical_vert,fragmentShader:Ma.meshphysical_frag};const Ia={r:0,b:0,g:0},Ta=new Tr,Ba=new yr;function Ra(t,e,n,i,r,s,a){const o=new us(0);let l,c,h=!0===s?0:1,u=null,d=0,p=null;function f(t){let i=!0===t.isScene?t.background:null;return i&&i.isTexture&&(i=(t.backgroundBlurriness>0?n:e).get(i)),i}function m(e,n){e.getRGB(Ia,ia(t)),i.buffers.color.setClear(Ia.r,Ia.g,Ia.b,n,a)}return{getClearColor:function(){return o},setClearColor:function(t,e=1){o.set(t),h=e,m(o,h)},getClearAlpha:function(){return h},setClearAlpha:function(t){h=t,m(o,h)},render:function(e){let n=!1;const r=f(e);null===r?m(o,h):r&&r.isColor&&(m(r,1),n=!0);const s=t.xr.getEnvironmentBlendMode();"additive"===s?i.buffers.color.setClear(0,0,0,1,a):"alpha-blend"===s&&i.buffers.color.setClear(0,0,0,0,a),(t.autoClear||n)&&(i.buffers.depth.setTest(!0),i.buffers.depth.setMask(!0),i.buffers.color.setMask(!0),t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil))},addToRenderList:function(e,n){const i=f(n);i&&(i.isCubeTexture||i.mapping===bt)?(void 0===c&&(c=new Zs(new ta(1,1,1),new sa({name:"BackgroundCubeMaterial",uniforms:ea(Sa.backgroundCube.uniforms),vertexShader:Sa.backgroundCube.vertexShader,fragmentShader:Sa.backgroundCube.fragmentShader,side:b,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(t,e,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(c)),Ta.copy(n.backgroundRotation),Ta.x*=-1,Ta.y*=-1,Ta.z*=-1,i.isCubeTexture&&!1===i.isRenderTargetTexture&&(Ta.y*=-1,Ta.z*=-1),c.material.uniforms.envMap.value=i,c.material.uniforms.flipEnvMap.value=i.isCubeTexture&&!1===i.isRenderTargetTexture?-1:1,c.material.uniforms.backgroundBlurriness.value=n.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(Ba.makeRotationFromEuler(Ta)),c.material.toneMapped=xi.getTransfer(i.colorSpace)!==fn,u===i&&d===i.version&&p===t.toneMapping||(c.material.needsUpdate=!0,u=i,d=i.version,p=t.toneMapping),c.layers.enableAll(),e.unshift(c,c.geometry,c.material,0,0,null)):i&&i.isTexture&&(void 0===l&&(l=new Zs(new Ea(2,2),new sa({name:"BackgroundMaterial",uniforms:ea(Sa.background.uniforms),vertexShader:Sa.background.vertexShader,fragmentShader:Sa.background.fragmentShader,side:M,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(l)),l.material.uniforms.t2D.value=i,l.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,l.material.toneMapped=xi.getTransfer(i.colorSpace)!==fn,!0===i.matrixAutoUpdate&&i.updateMatrix(),l.material.uniforms.uvTransform.value.copy(i.matrix),u===i&&d===i.version&&p===t.toneMapping||(l.material.needsUpdate=!0,u=i,d=i.version,p=t.toneMapping),l.layers.enableAll(),e.unshift(l,l.geometry,l.material,0,0,null))}}}function Da(t,e){const n=t.getParameter(t.MAX_VERTEX_ATTRIBS),i={},r=c(null);let s=r,a=!1;function o(e){return t.bindVertexArray(e)}function l(e){return t.deleteVertexArray(e)}function c(t){const e=[],i=[],r=[];for(let t=0;t=0){const n=r[e];let i=a[e];if(void 0===i&&("instanceMatrix"===e&&t.instanceMatrix&&(i=t.instanceMatrix),"instanceColor"===e&&t.instanceColor&&(i=t.instanceColor)),void 0===n)return!0;if(n.attribute!==i)return!0;if(i&&n.data!==i.data)return!0;o++}return s.attributesNum!==o||s.index!==i}(n,m,l,g),A&&function(t,e,n,i){const r={},a=e.attributes;let o=0;const l=n.getAttributes();for(const e in l)if(l[e].location>=0){let n=a[e];void 0===n&&("instanceMatrix"===e&&t.instanceMatrix&&(n=t.instanceMatrix),"instanceColor"===e&&t.instanceColor&&(n=t.instanceColor));const i={};i.attribute=n,n&&n.data&&(i.data=n.data),r[e]=i,o++}s.attributes=r,s.attributesNum=o,s.index=i}(n,m,l,g),null!==g&&e.update(g,t.ELEMENT_ARRAY_BUFFER),(A||a)&&(a=!1,function(n,i,r,s){h();const a=s.attributes,o=r.getAttributes(),l=i.defaultAttributeValues;for(const i in o){const r=o[i];if(r.location>=0){let o=a[i];if(void 0===o&&("instanceMatrix"===i&&n.instanceMatrix&&(o=n.instanceMatrix),"instanceColor"===i&&n.instanceColor&&(o=n.instanceColor)),void 0!==o){const i=o.normalized,a=o.itemSize,l=e.get(o);if(void 0===l)continue;const c=l.buffer,h=l.type,p=l.bytesPerElement,m=h===t.INT||h===t.UNSIGNED_INT||o.gpuType===Vt;if(o.isInterleavedBufferAttribute){const e=o.data,l=e.stride,g=o.offset;if(e.isInstancedInterleavedBuffer){for(let t=0;t0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";e="mediump"}return"mediump"===e&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let a=void 0!==n.precision?n.precision:"highp";const o=s(a);o!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",o,"instead."),a=o);const l=!0===n.logarithmicDepthBuffer,c=!0===n.reverseDepthBuffer&&e.has("EXT_clip_control"),h=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),u=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS);return{isWebGL2:!0,getMaxAnisotropy:function(){if(void 0!==r)return r;if(!0===e.has("EXT_texture_filter_anisotropic")){const n=e.get("EXT_texture_filter_anisotropic");r=t.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r},getMaxPrecision:s,textureFormatReadable:function(e){return e===te||i.convert(e)===t.getParameter(t.IMPLEMENTATION_COLOR_READ_FORMAT)},textureTypeReadable:function(n){const r=n===qt&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(n!==Qt&&i.convert(n)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_TYPE)&&n!==jt&&!r)},precision:a,logarithmicDepthBuffer:l,reverseDepthBuffer:c,maxTextures:h,maxVertexTextures:u,maxTextureSize:t.getParameter(t.MAX_TEXTURE_SIZE),maxCubemapSize:t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),maxAttributes:t.getParameter(t.MAX_VERTEX_ATTRIBS),maxVertexUniforms:t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),maxVaryings:t.getParameter(t.MAX_VARYING_VECTORS),maxFragmentUniforms:t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),vertexTextures:u>0,maxSamples:t.getParameter(t.MAX_SAMPLES)}}function Ua(t){const e=this;let n=null,i=0,r=!1,s=!1;const a=new va,o=new ui,l={value:null,needsUpdate:!1};function c(t,n,i,r){const s=null!==t?t.length:0;let c=null;if(0!==s){if(c=l.value,!0!==r||null===c){const e=i+4*s,r=n.matrixWorldInverse;o.getNormalMatrix(r),(null===c||c.length0),e.numPlanes=i,e.numIntersection=0);else{const t=s?0:i,e=4*t;let r=f.clippingState||null;l.value=r,r=c(u,o,e,h);for(let t=0;t!==e;++t)r[t]=n[t];f.clippingState=r,this.numIntersection=d?this.numPlanes:0,this.numPlanes+=t}}}function Na(t){let e=new WeakMap;function n(t,e){return e===Et?t.mapping=wt:e===Mt&&(t.mapping=Ct),t}function i(t){const n=t.target;n.removeEventListener("dispose",i);const r=e.get(n);void 0!==r&&(e.delete(n),r.dispose())}return{get:function(r){if(r&&r.isTexture){const s=r.mapping;if(s===Et||s===Mt){if(e.has(r))return n(e.get(r).texture,r.mapping);{const s=r.image;if(s&&s.height>0){const a=new fa(s.height);return a.fromEquirectangularTexture(t,r),e.set(r,a),r.addEventListener("dispose",i),n(a.texture,r.mapping)}return null}}}return r},dispose:function(){e=new WeakMap}}}class Fa extends aa{constructor(t=-1,e=1,n=1,i=-1,r=.1,s=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=n,this.bottom=i,this.near=r,this.far=s,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=null===t.view?null:Object.assign({},t.view),this}setViewOffset(t,e,n,i,r,s){null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let r=n-t,s=n+t,a=i+e,o=i-e;if(null!==this.view&&this.view.enabled){const t=(this.right-this.left)/this.view.fullWidth/this.zoom,e=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=t*this.view.offsetX,s=r+t*this.view.width,a-=e*this.view.offsetY,o=a-e*this.view.height}this.projectionMatrix.makeOrthographic(r,s,a,o,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,null!==this.view&&(e.object.view=Object.assign({},this.view)),e}}const Oa=[.125,.215,.35,.446,.526,.582],ka=new Fa,Qa=new us;let za=null,Ga=0,Ha=0,Va=!1;const Wa=(1+Math.sqrt(5))/2,ja=1/Wa,qa=[new Hi(-Wa,ja,0),new Hi(Wa,ja,0),new Hi(-ja,0,Wa),new Hi(ja,0,Wa),new Hi(0,Wa,-ja),new Hi(0,Wa,ja),new Hi(-1,1,-1),new Hi(1,1,-1),new Hi(-1,1,1),new Hi(1,1,1)];class Xa{constructor(t){this._renderer=t,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(t,e=0,n=.1,i=100){za=this._renderer.getRenderTarget(),Ga=this._renderer.getActiveCubeFace(),Ha=this._renderer.getActiveMipmapLevel(),Va=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);const r=this._allocateTargets();return r.depthBuffer=!0,this._sceneToCubeUV(t,n,i,r),e>0&&this._blur(r,0,0,e),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=Za(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=Ka(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose()}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let t=0;tt-4?o=Oa[a-t+4-1]:0===a&&(o=0),i.push(o);const l=1/(s-2),c=-l,h=1+l,u=[c,c,h,c,h,h,c,c,h,h,c,h],d=6,p=6,f=3,m=2,g=1,A=new Float32Array(f*p*d),v=new Float32Array(m*p*d),y=new Float32Array(g*p*d);for(let t=0;t2?0:-1,i=[e,n,0,e+2/3,n,0,e+2/3,n+1,0,e,n,0,e+2/3,n+1,0,e,n+1,0];A.set(i,f*p*t),v.set(u,m*p*t);const r=[t,t,t,t,t,t];y.set(r,g*p*t)}const x=new Qs;x.setAttribute("position",new Cs(A,f)),x.setAttribute("uv",new Cs(v,m)),x.setAttribute("faceIndex",new Cs(y,g)),e.push(x),r>4&&r--}return{lodPlanes:e,sizeLods:n,sigmas:i}}(i)),this._blurMaterial=function(t,e,n){const i=new Float32Array(20),r=new Hi(0,1,0);return new sa({name:"SphericalGaussianBlur",defines:{n:20,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${t}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform int samples;\n\t\t\tuniform float weights[ n ];\n\t\t\tuniform bool latitudinal;\n\t\t\tuniform float dTheta;\n\t\t\tuniform float mipInt;\n\t\t\tuniform vec3 poleAxis;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include \n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t}\n\t\t",blending:I,depthTest:!1,depthWrite:!1})}(i,t,e)}return i}_compileMaterial(t){const e=new Zs(this._lodPlanes[0],t);this._renderer.compile(e,ka)}_sceneToCubeUV(t,e,n,i){const r=new ha(90,1,e,n),s=[1,-1,1,1,1,1],a=[1,1,1,-1,-1,-1],o=this._renderer,l=o.autoClear,c=o.toneMapping;o.getClearColor(Qa),o.toneMapping=ut,o.autoClear=!1;const h=new ms({name:"PMREM.Background",side:b,depthWrite:!1,depthTest:!1}),u=new Zs(new ta,h);let d=!1;const p=t.background;p?p.isColor&&(h.color.copy(p),t.background=null,d=!0):(h.color.copy(Qa),d=!0);for(let e=0;e<6;e++){const n=e%3;0===n?(r.up.set(0,s[e],0),r.lookAt(a[e],0,0)):1===n?(r.up.set(0,0,s[e]),r.lookAt(0,a[e],0)):(r.up.set(0,s[e],0),r.lookAt(0,0,a[e]));const l=this._cubeSize;Ja(i,n*l,e>2?l:0,l,l),o.setRenderTarget(i),d&&o.render(u,r),o.render(t,r)}u.geometry.dispose(),u.material.dispose(),o.toneMapping=c,o.autoClear=l,t.background=p}_textureToCubeUV(t,e){const n=this._renderer,i=t.mapping===wt||t.mapping===Ct;i?(null===this._cubemapMaterial&&(this._cubemapMaterial=Za()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===t.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=Ka());const r=i?this._cubemapMaterial:this._equirectMaterial,s=new Zs(this._lodPlanes[0],r);r.uniforms.envMap.value=t;const a=this._cubeSize;Ja(e,0,0,3*a,2*a),n.setRenderTarget(e),n.render(s,ka)}_applyPMREM(t){const e=this._renderer,n=e.autoClear;e.autoClear=!1;const i=this._lodPlanes.length;for(let e=1;e20&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${f} samples when the maximum is set to 20`);const m=[];let g=0;for(let t=0;t<20;++t){const e=t/p,n=Math.exp(-e*e/2);m.push(n),0===t?g+=n:tA-4?i-A+4:0),4*(this._cubeSize-v),3*v,2*v),o.setRenderTarget(e),o.render(c,ka)}}function Ya(t,e,n){const i=new Fi(t,e,n);return i.texture.mapping=bt,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Ja(t,e,n,i,r){t.viewport.set(e,n,i,r),t.scissor.set(e,n,i,r)}function Ka(){return new sa({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\n\t\t\t#include \n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tgl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );\n\n\t\t\t}\n\t\t",blending:I,depthTest:!1,depthWrite:!1})}function Za(){return new sa({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tuniform float flipEnvMap;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform samplerCube envMap;\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );\n\n\t\t\t}\n\t\t",blending:I,depthTest:!1,depthWrite:!1})}function $a(t){let e=new WeakMap,n=null;function i(t){const n=t.target;n.removeEventListener("dispose",i);const r=e.get(n);void 0!==r&&(e.delete(n),r.dispose())}return{get:function(r){if(r&&r.isTexture){const s=r.mapping,a=s===Et||s===Mt,o=s===wt||s===Ct;if(a||o){let s=e.get(r);const l=void 0!==s?s.texture.pmremVersion:0;if(r.isRenderTargetTexture&&r.pmremVersion!==l)return null===n&&(n=new Xa(t)),s=a?n.fromEquirectangular(r,s):n.fromCubemap(r,s),s.texture.pmremVersion=r.pmremVersion,e.set(r,s),s.texture;if(void 0!==s)return s.texture;{const l=r.image;return a&&l&&l.height>0||o&&l&&function(t){let e=0;for(let n=0;n<6;n++)void 0!==t[n]&&e++;return 6===e}(l)?(null===n&&(n=new Xa(t)),s=a?n.fromEquirectangular(r):n.fromCubemap(r),s.texture.pmremVersion=r.pmremVersion,e.set(r,s),r.addEventListener("dispose",i),s.texture):null}}}return r},dispose:function(){e=new WeakMap,null!==n&&(n.dispose(),n=null)}}}function to(t){const e={};function n(n){if(void 0!==e[n])return e[n];let i;switch(n){case"WEBGL_depth_texture":i=t.getExtension("WEBGL_depth_texture")||t.getExtension("MOZ_WEBGL_depth_texture")||t.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":i=t.getExtension("WEBGL_compressed_texture_s3tc")||t.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":i=t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=t.getExtension(n)}return e[n]=i,i}return{has:function(t){return null!==n(t)},init:function(){n("EXT_color_buffer_float"),n("WEBGL_clip_cull_distance"),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture"),n("WEBGL_render_shared_exponent")},get:function(t){const e=n(t);return null===e&&yi("THREE.WebGLRenderer: "+t+" extension not supported."),e}}}function eo(t,e,n,i){const r={},s=new WeakMap;function a(t){const o=t.target;null!==o.index&&e.remove(o.index);for(const t in o.attributes)e.remove(o.attributes[t]);for(const t in o.morphAttributes){const n=o.morphAttributes[t];for(let t=0,i=n.length;te.maxTextureSize&&(x=Math.ceil(y/e.maxTextureSize),y=e.maxTextureSize);const _=new Float32Array(y*x*4*h),w=new Oi(_,y,x,h);w.type=jt,w.needsUpdate=!0;const C=4*v;for(let M=0;M0)return t;const r=e*n;let s=po[r];if(void 0===s&&(s=new Float32Array(r),po[r]=s),0!==e){i.toArray(s,0);for(let i=1,r=0;i!==e;++i)r+=n,t[i].toArray(s,r)}return s}function yo(t,e){if(t.length!==e.length)return!1;for(let n=0,i=t.length;n":" "} ${r}: ${n[t]}`)}return i.join("\n")}(t.getShaderSource(e),i)}return r}function Al(t,e){const n=function(t){xi._getMatrix(ml,xi.workingColorSpace,t);const e=`mat3( ${ml.elements.map((t=>t.toFixed(4)))} )`;switch(xi.getTransfer(t)){case pn:return[e,"LinearTransferOETF"];case fn:return[e,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",t),[e,"LinearTransferOETF"]}}(e);return[`vec4 ${t}( vec4 value ) {`,`\treturn ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join("\n")}function vl(t,e){let n;switch(e){case dt:n="Linear";break;case pt:n="Reinhard";break;case ft:n="Cineon";break;case mt:n="ACESFilmic";break;case At:n="AgX";break;case vt:n="Neutral";break;case gt:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const yl=new Hi;function xl(t){return""!==t}function _l(t,e){const n=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return t.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function wl(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const Cl=/^[ \t]*#include +<([\w\d./]+)>/gm;function El(t){return t.replace(Cl,bl)}const Ml=new Map;function bl(t,e){let n=Ma[e];if(void 0===n){const t=Ml.get(e);if(void 0===t)throw new Error("Can not resolve #include <"+e+">");n=Ma[t],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,t)}return El(n)}const Sl=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function Il(t){return t.replace(Sl,Tl)}function Tl(t,e,n,i){let r="";for(let t=parseInt(e);t0&&(g+="\n"),A=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,f].filter(xl).join("\n"),A.length>0&&(A+="\n")):(g=[Bl(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,f,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+h:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH","\tuniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(xl).join("\n"),A=[Bl(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,f,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+c:"",n.envMap?"#define "+h:"",n.envMap?"#define "+u:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor||n.batchingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==ut?"#define TONE_MAPPING":"",n.toneMapping!==ut?Ma.tonemapping_pars_fragment:"",n.toneMapping!==ut?vl("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Ma.colorspace_pars_fragment,Al("linearToOutputTexel",n.outputColorSpace),(xi.getLuminanceCoefficients(yl),["float luminance( const in vec3 rgb ) {",`\tconst vec3 weights = vec3( ${yl.x.toFixed(4)}, ${yl.y.toFixed(4)}, ${yl.z.toFixed(4)} );`,"\treturn dot( weights, rgb );","}"].join("\n")),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(xl).join("\n")),a=El(a),a=_l(a,n),a=wl(a,n),o=El(o),o=_l(o,n),o=wl(o,n),a=Il(a),o=Il(o),!0!==n.isRawShaderMaterial&&(v="#version 300 es\n",g=[p,"#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+g,A=["#define varying in",n.glslVersion===Yn?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===Yn?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+A);const y=v+g+a,x=v+A+o,_=pl(r,r.VERTEX_SHADER,y),M=pl(r,r.FRAGMENT_SHADER,x);function b(e){if(t.debug.checkShaderErrors){const n=r.getProgramInfoLog(m).trim(),i=r.getShaderInfoLog(_).trim(),s=r.getShaderInfoLog(M).trim();let a=!0,o=!0;if(!1===r.getProgramParameter(m,r.LINK_STATUS))if(a=!1,"function"==typeof t.debug.onShaderError)t.debug.onShaderError(r,m,_,M);else{const t=gl(r,_,"vertex"),i=gl(r,M,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(m,r.VALIDATE_STATUS)+"\n\nMaterial Name: "+e.name+"\nMaterial Type: "+e.type+"\n\nProgram Info Log: "+n+"\n"+t+"\n"+i)}else""!==n?console.warn("THREE.WebGLProgram: Program Info Log:",n):""!==i&&""!==s||(o=!1);o&&(e.diagnostics={runnable:a,programLog:n,vertexShader:{log:i,prefix:g},fragmentShader:{log:s,prefix:A}})}r.deleteShader(_),r.deleteShader(M),S=new dl(r,m),I=function(t,e){const n={},i=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let r=0;r0,J=s.clearcoat>0,K=s.dispersion>0,Z=s.iridescence>0,$=s.sheen>0,tt=s.transmission>0,et=Y&&!!s.anisotropyMap,nt=J&&!!s.clearcoatMap,it=J&&!!s.clearcoatNormalMap,rt=J&&!!s.clearcoatRoughnessMap,st=Z&&!!s.iridescenceMap,at=Z&&!!s.iridescenceThicknessMap,ot=$&&!!s.sheenColorMap,lt=$&&!!s.sheenRoughnessMap,ct=!!s.specularMap,ht=!!s.specularColorMap,dt=!!s.specularIntensityMap,pt=tt&&!!s.transmissionMap,ft=tt&&!!s.thicknessMap,mt=!!s.gradientMap,gt=!!s.alphaMap,At=s.alphaTest>0,vt=!!s.alphaHash,yt=!!s.extensions;let xt=ut;s.toneMapped&&(null!==L&&!0!==L.isXRRenderTarget||(xt=t.toneMapping));const _t={shaderID:C,shaderType:s.type,shaderName:s.name,vertexShader:I,fragmentShader:B,defines:s.defines,customVertexShaderID:R,customFragmentShaderID:D,isRawShaderMaterial:!0===s.isRawShaderMaterial,glslVersion:s.glslVersion,precision:p,batching:F,batchingColor:F&&null!==A._colorsTexture,instancing:N,instancingColor:N&&null!==A.instanceColor,instancingMorph:N&&null!==A.morphTexture,supportsVertexTextures:d,outputColorSpace:null===L?t.outputColorSpace:!0===L.isXRRenderTarget?L.texture.colorSpace:dn,alphaToCoverage:!!s.alphaToCoverage,map:O,matcap:k,envMap:Q,envMapMode:Q&&_.mapping,envMapCubeUVHeight:w,aoMap:z,lightMap:G,bumpMap:H,normalMap:V,displacementMap:d&&W,emissiveMap:j,normalMapObjectSpace:V&&s.normalMapType===cn,normalMapTangentSpace:V&&s.normalMapType===ln,metalnessMap:q,roughnessMap:X,anisotropy:Y,anisotropyMap:et,clearcoat:J,clearcoatMap:nt,clearcoatNormalMap:it,clearcoatRoughnessMap:rt,dispersion:K,iridescence:Z,iridescenceMap:st,iridescenceThicknessMap:at,sheen:$,sheenColorMap:ot,sheenRoughnessMap:lt,specularMap:ct,specularColorMap:ht,specularIntensityMap:dt,transmission:tt,transmissionMap:pt,thicknessMap:ft,gradientMap:mt,opaque:!1===s.transparent&&s.blending===T&&!1===s.alphaToCoverage,alphaMap:gt,alphaTest:At,alphaHash:vt,combine:s.combine,mapUv:O&&m(s.map.channel),aoMapUv:z&&m(s.aoMap.channel),lightMapUv:G&&m(s.lightMap.channel),bumpMapUv:H&&m(s.bumpMap.channel),normalMapUv:V&&m(s.normalMap.channel),displacementMapUv:W&&m(s.displacementMap.channel),emissiveMapUv:j&&m(s.emissiveMap.channel),metalnessMapUv:q&&m(s.metalnessMap.channel),roughnessMapUv:X&&m(s.roughnessMap.channel),anisotropyMapUv:et&&m(s.anisotropyMap.channel),clearcoatMapUv:nt&&m(s.clearcoatMap.channel),clearcoatNormalMapUv:it&&m(s.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:rt&&m(s.clearcoatRoughnessMap.channel),iridescenceMapUv:st&&m(s.iridescenceMap.channel),iridescenceThicknessMapUv:at&&m(s.iridescenceThicknessMap.channel),sheenColorMapUv:ot&&m(s.sheenColorMap.channel),sheenRoughnessMapUv:lt&&m(s.sheenRoughnessMap.channel),specularMapUv:ct&&m(s.specularMap.channel),specularColorMapUv:ht&&m(s.specularColorMap.channel),specularIntensityMapUv:dt&&m(s.specularIntensityMap.channel),transmissionMapUv:pt&&m(s.transmissionMap.channel),thicknessMapUv:ft&&m(s.thicknessMap.channel),alphaMapUv:gt&&m(s.alphaMap.channel),vertexTangents:!!y.attributes.tangent&&(V||Y),vertexColors:s.vertexColors,vertexAlphas:!0===s.vertexColors&&!!y.attributes.color&&4===y.attributes.color.itemSize,pointsUvs:!0===A.isPoints&&!!y.attributes.uv&&(O||gt),fog:!!v,useFog:!0===s.fog,fogExp2:!!v&&v.isFogExp2,flatShading:!0===s.flatShading,sizeAttenuation:!0===s.sizeAttenuation,logarithmicDepthBuffer:u,reverseDepthBuffer:U,skinning:!0===A.isSkinnedMesh,morphTargets:void 0!==y.morphAttributes.position,morphNormals:void 0!==y.morphAttributes.normal,morphColors:void 0!==y.morphAttributes.color,morphTargetsCount:M,morphTextureStride:P,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numSpotLightMaps:o.spotLightMap.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numDirLightShadows:o.directionalShadowMap.length,numPointLightShadows:o.pointShadowMap.length,numSpotLightShadows:o.spotShadowMap.length,numSpotLightShadowsWithMaps:o.numSpotLightShadowsWithMaps,numLightProbes:o.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:s.dithering,shadowMapEnabled:t.shadowMap.enabled&&h.length>0,shadowMapType:t.shadowMap.type,toneMapping:xt,decodeVideoTexture:O&&!0===s.map.isVideoTexture&&xi.getTransfer(s.map.colorSpace)===fn,decodeVideoTextureEmissive:j&&!0===s.emissiveMap.isVideoTexture&&xi.getTransfer(s.emissiveMap.colorSpace)===fn,premultipliedAlpha:s.premultipliedAlpha,doubleSided:s.side===S,flipSided:s.side===b,useDepthPacking:s.depthPacking>=0,depthPacking:s.depthPacking||0,index0AttributeName:s.index0AttributeName,extensionClipCullDistance:yt&&!0===s.extensions.clipCullDistance&&i.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(yt&&!0===s.extensions.multiDraw||F)&&i.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:s.customProgramCacheKey()};return _t.vertexUv1s=c.has(1),_t.vertexUv2s=c.has(2),_t.vertexUv3s=c.has(3),c.clear(),_t},getProgramCacheKey:function(e){const n=[];if(e.shaderID?n.push(e.shaderID):(n.push(e.customVertexShaderID),n.push(e.customFragmentShaderID)),void 0!==e.defines)for(const t in e.defines)n.push(t),n.push(e.defines[t]);return!1===e.isRawShaderMaterial&&(function(t,e){t.push(e.precision),t.push(e.outputColorSpace),t.push(e.envMapMode),t.push(e.envMapCubeUVHeight),t.push(e.mapUv),t.push(e.alphaMapUv),t.push(e.lightMapUv),t.push(e.aoMapUv),t.push(e.bumpMapUv),t.push(e.normalMapUv),t.push(e.displacementMapUv),t.push(e.emissiveMapUv),t.push(e.metalnessMapUv),t.push(e.roughnessMapUv),t.push(e.anisotropyMapUv),t.push(e.clearcoatMapUv),t.push(e.clearcoatNormalMapUv),t.push(e.clearcoatRoughnessMapUv),t.push(e.iridescenceMapUv),t.push(e.iridescenceThicknessMapUv),t.push(e.sheenColorMapUv),t.push(e.sheenRoughnessMapUv),t.push(e.specularMapUv),t.push(e.specularColorMapUv),t.push(e.specularIntensityMapUv),t.push(e.transmissionMapUv),t.push(e.thicknessMapUv),t.push(e.combine),t.push(e.fogExp2),t.push(e.sizeAttenuation),t.push(e.morphTargetsCount),t.push(e.morphAttributeCount),t.push(e.numDirLights),t.push(e.numPointLights),t.push(e.numSpotLights),t.push(e.numSpotLightMaps),t.push(e.numHemiLights),t.push(e.numRectAreaLights),t.push(e.numDirLightShadows),t.push(e.numPointLightShadows),t.push(e.numSpotLightShadows),t.push(e.numSpotLightShadowsWithMaps),t.push(e.numLightProbes),t.push(e.shadowMapType),t.push(e.toneMapping),t.push(e.numClippingPlanes),t.push(e.numClipIntersection),t.push(e.depthPacking)}(n,e),function(t,e){o.disableAll(),e.supportsVertexTextures&&o.enable(0),e.instancing&&o.enable(1),e.instancingColor&&o.enable(2),e.instancingMorph&&o.enable(3),e.matcap&&o.enable(4),e.envMap&&o.enable(5),e.normalMapObjectSpace&&o.enable(6),e.normalMapTangentSpace&&o.enable(7),e.clearcoat&&o.enable(8),e.iridescence&&o.enable(9),e.alphaTest&&o.enable(10),e.vertexColors&&o.enable(11),e.vertexAlphas&&o.enable(12),e.vertexUv1s&&o.enable(13),e.vertexUv2s&&o.enable(14),e.vertexUv3s&&o.enable(15),e.vertexTangents&&o.enable(16),e.anisotropy&&o.enable(17),e.alphaHash&&o.enable(18),e.batching&&o.enable(19),e.dispersion&&o.enable(20),e.batchingColor&&o.enable(21),t.push(o.mask),o.disableAll(),e.fog&&o.enable(0),e.useFog&&o.enable(1),e.flatShading&&o.enable(2),e.logarithmicDepthBuffer&&o.enable(3),e.reverseDepthBuffer&&o.enable(4),e.skinning&&o.enable(5),e.morphTargets&&o.enable(6),e.morphNormals&&o.enable(7),e.morphColors&&o.enable(8),e.premultipliedAlpha&&o.enable(9),e.shadowMapEnabled&&o.enable(10),e.doubleSided&&o.enable(11),e.flipSided&&o.enable(12),e.useDepthPacking&&o.enable(13),e.dithering&&o.enable(14),e.transmission&&o.enable(15),e.sheen&&o.enable(16),e.opaque&&o.enable(17),e.pointsUvs&&o.enable(18),e.decodeVideoTexture&&o.enable(19),e.decodeVideoTextureEmissive&&o.enable(20),e.alphaToCoverage&&o.enable(21),t.push(o.mask)}(n,e),n.push(t.outputColorSpace)),n.push(e.customProgramCacheKey),n.join()},getUniforms:function(t){const e=f[t.type];let n;if(e){const t=Sa[e];n=ra.clone(t.uniforms)}else n=t.uniforms;return n},acquireProgram:function(e,n){let i;for(let t=0,e=h.length;t0?i.push(h):!0===a.transparent?r.push(h):n.push(h)},unshift:function(t,e,a,o,l,c){const h=s(t,e,a,o,l,c);a.transmission>0?i.unshift(h):!0===a.transparent?r.unshift(h):n.unshift(h)},finish:function(){for(let n=e,i=t.length;n1&&n.sort(t||Fl),i.length>1&&i.sort(e||Ol),r.length>1&&r.sort(e||Ol)}}}function Ql(){let t=new WeakMap;return{get:function(e,n){const i=t.get(e);let r;return void 0===i?(r=new kl,t.set(e,[r])):n>=i.length?(r=new kl,i.push(r)):r=i[n],r},dispose:function(){t=new WeakMap}}}function zl(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let n;switch(e.type){case"DirectionalLight":n={direction:new Hi,color:new us};break;case"SpotLight":n={position:new Hi,direction:new Hi,color:new us,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new Hi,color:new us,distance:0,decay:0};break;case"HemisphereLight":n={direction:new Hi,skyColor:new us,groundColor:new us};break;case"RectAreaLight":n={color:new us,position:new Hi,halfWidth:new Hi,halfHeight:new Hi}}return t[e.id]=n,n}}}let Gl=0;function Hl(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function Vl(t){const e=new zl,n=function(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let n;switch(e.type){case"DirectionalLight":case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new hi};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new hi,shadowCameraNear:1,shadowCameraFar:1e3}}return t[e.id]=n,n}}}(),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 t=0;t<9;t++)i.probe.push(new Hi);const r=new Hi,s=new yr,a=new yr;return{setup:function(r){let s=0,a=0,o=0;for(let t=0;t<9;t++)i.probe[t].set(0,0,0);let l=0,c=0,h=0,u=0,d=0,p=0,f=0,m=0,g=0,A=0,v=0;r.sort(Hl);for(let t=0,y=r.length;t0&&(!0===t.has("OES_texture_float_linear")?(i.rectAreaLTC1=ba.LTC_FLOAT_1,i.rectAreaLTC2=ba.LTC_FLOAT_2):(i.rectAreaLTC1=ba.LTC_HALF_1,i.rectAreaLTC2=ba.LTC_HALF_2)),i.ambient[0]=s,i.ambient[1]=a,i.ambient[2]=o;const y=i.hash;y.directionalLength===l&&y.pointLength===c&&y.spotLength===h&&y.rectAreaLength===u&&y.hemiLength===d&&y.numDirectionalShadows===p&&y.numPointShadows===f&&y.numSpotShadows===m&&y.numSpotMaps===g&&y.numLightProbes===v||(i.directional.length=l,i.spot.length=h,i.rectArea.length=u,i.point.length=c,i.hemi.length=d,i.directionalShadow.length=p,i.directionalShadowMap.length=p,i.pointShadow.length=f,i.pointShadowMap.length=f,i.spotShadow.length=m,i.spotShadowMap.length=m,i.directionalShadowMatrix.length=p,i.pointShadowMatrix.length=f,i.spotLightMatrix.length=m+g-A,i.spotLightMap.length=g,i.numSpotLightShadowsWithMaps=A,i.numLightProbes=v,y.directionalLength=l,y.pointLength=c,y.spotLength=h,y.rectAreaLength=u,y.hemiLength=d,y.numDirectionalShadows=p,y.numPointShadows=f,y.numSpotShadows=m,y.numSpotMaps=g,y.numLightProbes=v,i.version=Gl++)},setupView:function(t,e){let n=0,o=0,l=0,c=0,h=0;const u=e.matrixWorldInverse;for(let e=0,d=t.length;e=r.length?(s=new Wl(t),r.push(s)):s=r[i],s},dispose:function(){e=new WeakMap}}}class ql extends fs{static get type(){return"MeshDepthMaterial"}constructor(t){super(),this.isMeshDepthMaterial=!0,this.depthPacking=rn,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}}class Xl extends fs{static get type(){return"MeshDistanceMaterial"}constructor(t){super(),this.isMeshDistanceMaterial=!0,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(t)}copy(t){return super.copy(t),this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}}function Yl(t,e,n){let i=new _a;const r=new hi,s=new hi,a=new Ui,o=new ql({depthPacking:sn}),l=new Xl,c={},h=n.maxTextureSize,u={[M]:b,[b]:M,[S]:S},d=new sa({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new hi},radius:{value:4}},vertexShader:"void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include \nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}"}),p=d.clone();p.defines.HORIZONTAL_PASS=1;const f=new Qs;f.setAttribute("position",new Cs(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const m=new Zs(f,d),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=w;let A=this.type;function v(n,i){const s=e.update(m);d.defines.VSM_SAMPLES!==n.blurSamples&&(d.defines.VSM_SAMPLES=n.blurSamples,p.defines.VSM_SAMPLES=n.blurSamples,d.needsUpdate=!0,p.needsUpdate=!0),null===n.mapPass&&(n.mapPass=new Fi(r.x,r.y)),d.uniforms.shadow_pass.value=n.map.texture,d.uniforms.resolution.value=n.mapSize,d.uniforms.radius.value=n.radius,t.setRenderTarget(n.mapPass),t.clear(),t.renderBufferDirect(i,null,s,d,m,null),p.uniforms.shadow_pass.value=n.mapPass.texture,p.uniforms.resolution.value=n.mapSize,p.uniforms.radius.value=n.radius,t.setRenderTarget(n.map),t.clear(),t.renderBufferDirect(i,null,s,p,m,null)}function y(e,n,i,r){let s=null;const a=!0===i.isPointLight?e.customDistanceMaterial:e.customDepthMaterial;if(void 0!==a)s=a;else if(s=!0===i.isPointLight?l:o,t.localClippingEnabled&&!0===n.clipShadows&&Array.isArray(n.clippingPlanes)&&0!==n.clippingPlanes.length||n.displacementMap&&0!==n.displacementScale||n.alphaMap&&n.alphaTest>0||n.map&&n.alphaTest>0){const t=s.uuid,e=n.uuid;let i=c[t];void 0===i&&(i={},c[t]=i);let r=i[e];void 0===r&&(r=s.clone(),i[e]=r,n.addEventListener("dispose",_)),s=r}return s.visible=n.visible,s.wireframe=n.wireframe,s.side=r===E?null!==n.shadowSide?n.shadowSide:n.side:null!==n.shadowSide?n.shadowSide:u[n.side],s.alphaMap=n.alphaMap,s.alphaTest=n.alphaTest,s.map=n.map,s.clipShadows=n.clipShadows,s.clippingPlanes=n.clippingPlanes,s.clipIntersection=n.clipIntersection,s.displacementMap=n.displacementMap,s.displacementScale=n.displacementScale,s.displacementBias=n.displacementBias,s.wireframeLinewidth=n.wireframeLinewidth,s.linewidth=n.linewidth,!0===i.isPointLight&&!0===s.isMeshDistanceMaterial&&(t.properties.get(s).light=i),s}function x(n,r,s,a,o){if(!1===n.visible)return;if(n.layers.test(r.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&o===E)&&(!n.frustumCulled||i.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(s.matrixWorldInverse,n.matrixWorld);const i=e.update(n),l=n.material;if(Array.isArray(l)){const e=i.groups;for(let c=0,h=e.length;ch||r.y>h)&&(r.x>h&&(s.x=Math.floor(h/m.x),r.x=s.x*m.x,u.mapSize.x=s.x),r.y>h&&(s.y=Math.floor(h/m.y),r.y=s.y*m.y,u.mapSize.y=s.y)),null===u.map||!0===p||!0===f){const t=this.type!==E?{minFilter:Bt,magFilter:Bt}:{};null!==u.map&&u.map.dispose(),u.map=new Fi(r.x,r.y,t),u.map.texture.name=c.name+".shadowMap",u.camera.updateProjectionMatrix()}t.setRenderTarget(u.map),t.clear();const g=u.getViewportCount();for(let t=0;t=1):-1!==gt.indexOf("OpenGL ES")&&(mt=parseFloat(/^OpenGL ES (\d)/.exec(gt)[1]),ft=mt>=2);let At=null,vt={};const yt=t.getParameter(t.SCISSOR_BOX),xt=t.getParameter(t.VIEWPORT),_t=(new Ui).fromArray(yt),wt=(new Ui).fromArray(xt);function Ct(e,n,i,r){const s=new Uint8Array(4),a=t.createTexture();t.bindTexture(e,a),t.texParameteri(e,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(e,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let a=0;ae?(t.repeat.x=1,t.repeat.y=n/e,t.offset.x=0,t.offset.y=(1-t.repeat.y)/2):(t.repeat.x=e/n,t.repeat.y=1,t.offset.x=(1-t.repeat.x)/2,t.offset.y=0),t},cover:function(t,e){const n=t.image&&t.image.width?t.image.width/t.image.height:1;return n>e?(t.repeat.x=e/n,t.repeat.y=1,t.offset.x=(1-t.repeat.x)/2,t.offset.y=0):(t.repeat.x=1,t.repeat.y=n/e,t.offset.x=0,t.offset.y=(1-t.repeat.y)/2),t},fill:function(t){return t.repeat.x=1,t.repeat.y=1,t.offset.x=0,t.offset.y=0,t},getByteLength:Zl};function tc(t,e,n,i,r,s,a){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l="undefined"!=typeof navigator&&/OculusBrowser/g.test(navigator.userAgent),c=new hi,h=new WeakMap;let u;const d=new WeakMap;let p=!1;try{p="undefined"!=typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(t){}function f(t,e){return p?new OffscreenCanvas(t,e):gi("canvas")}function m(t,e,n){let i=1;const r=z(t);if((r.width>n||r.height>n)&&(i=n/Math.max(r.width,r.height)),i<1){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap||"undefined"!=typeof VideoFrame&&t instanceof VideoFrame){const n=Math.floor(i*r.width),s=Math.floor(i*r.height);void 0===u&&(u=f(n,s));const a=e?f(n,s):u;return a.width=n,a.height=s,a.getContext("2d").drawImage(t,0,0,n,s),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+r.width+"x"+r.height+") to ("+n+"x"+s+")."),a}return"data"in t&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+r.width+"x"+r.height+")."),t}return t}function g(t){return t.generateMipmaps}function A(e){t.generateMipmap(e)}function v(e){return e.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:e.isWebGL3DRenderTarget?t.TEXTURE_3D:e.isWebGLArrayRenderTarget||e.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:t.TEXTURE_2D}function y(n,i,r,s,a=!1){if(null!==n){if(void 0!==t[n])return t[n];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+n+"'")}let o=i;if(i===t.RED&&(r===t.FLOAT&&(o=t.R32F),r===t.HALF_FLOAT&&(o=t.R16F),r===t.UNSIGNED_BYTE&&(o=t.R8)),i===t.RED_INTEGER&&(r===t.UNSIGNED_BYTE&&(o=t.R8UI),r===t.UNSIGNED_SHORT&&(o=t.R16UI),r===t.UNSIGNED_INT&&(o=t.R32UI),r===t.BYTE&&(o=t.R8I),r===t.SHORT&&(o=t.R16I),r===t.INT&&(o=t.R32I)),i===t.RG&&(r===t.FLOAT&&(o=t.RG32F),r===t.HALF_FLOAT&&(o=t.RG16F),r===t.UNSIGNED_BYTE&&(o=t.RG8)),i===t.RG_INTEGER&&(r===t.UNSIGNED_BYTE&&(o=t.RG8UI),r===t.UNSIGNED_SHORT&&(o=t.RG16UI),r===t.UNSIGNED_INT&&(o=t.RG32UI),r===t.BYTE&&(o=t.RG8I),r===t.SHORT&&(o=t.RG16I),r===t.INT&&(o=t.RG32I)),i===t.RGB_INTEGER&&(r===t.UNSIGNED_BYTE&&(o=t.RGB8UI),r===t.UNSIGNED_SHORT&&(o=t.RGB16UI),r===t.UNSIGNED_INT&&(o=t.RGB32UI),r===t.BYTE&&(o=t.RGB8I),r===t.SHORT&&(o=t.RGB16I),r===t.INT&&(o=t.RGB32I)),i===t.RGBA_INTEGER&&(r===t.UNSIGNED_BYTE&&(o=t.RGBA8UI),r===t.UNSIGNED_SHORT&&(o=t.RGBA16UI),r===t.UNSIGNED_INT&&(o=t.RGBA32UI),r===t.BYTE&&(o=t.RGBA8I),r===t.SHORT&&(o=t.RGBA16I),r===t.INT&&(o=t.RGBA32I)),i===t.RGB&&r===t.UNSIGNED_INT_5_9_9_9_REV&&(o=t.RGB9_E5),i===t.RGBA){const e=a?pn:xi.getTransfer(s);r===t.FLOAT&&(o=t.RGBA32F),r===t.HALF_FLOAT&&(o=t.RGBA16F),r===t.UNSIGNED_BYTE&&(o=e===fn?t.SRGB8_ALPHA8:t.RGBA8),r===t.UNSIGNED_SHORT_4_4_4_4&&(o=t.RGBA4),r===t.UNSIGNED_SHORT_5_5_5_1&&(o=t.RGB5_A1)}return o!==t.R16F&&o!==t.R32F&&o!==t.RG16F&&o!==t.RG32F&&o!==t.RGBA16F&&o!==t.RGBA32F||e.get("EXT_color_buffer_float"),o}function x(e,n){let i;return e?null===n||n===Wt||n===Jt?i=t.DEPTH24_STENCIL8:n===jt?i=t.DEPTH32F_STENCIL8:n===Ht&&(i=t.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):null===n||n===Wt||n===Jt?i=t.DEPTH_COMPONENT24:n===jt?i=t.DEPTH_COMPONENT32F:n===Ht&&(i=t.DEPTH_COMPONENT16),i}function _(t,e){return!0===g(t)||t.isFramebufferTexture&&t.minFilter!==Bt&&t.minFilter!==Ut?Math.log2(Math.max(e.width,e.height))+1:void 0!==t.mipmaps&&t.mipmaps.length>0?t.mipmaps.length:t.isCompressedTexture&&Array.isArray(t.image)?e.mipmaps.length:1}function w(t){const e=t.target;e.removeEventListener("dispose",w),function(t){const e=i.get(t);if(void 0===e.__webglInit)return;const n=t.source,r=d.get(n);if(r){const i=r[e.__cacheKey];i.usedTimes--,0===i.usedTimes&&E(t),0===Object.keys(r).length&&d.delete(n)}i.remove(t)}(e),e.isVideoTexture&&h.delete(e)}function C(e){const n=e.target;n.removeEventListener("dispose",C),function(e){const n=i.get(e);if(e.depthTexture&&(e.depthTexture.dispose(),i.remove(e.depthTexture)),e.isWebGLCubeRenderTarget)for(let e=0;e<6;e++){if(Array.isArray(n.__webglFramebuffer[e]))for(let i=0;i0&&s.__version!==e.version){const t=e.image;if(null===t)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else{if(!1!==t.complete)return void D(s,e,r);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}n.bindTexture(t.TEXTURE_2D,s.__webglTexture,t.TEXTURE0+r)}const S={[St]:t.REPEAT,[It]:t.CLAMP_TO_EDGE,[Tt]:t.MIRRORED_REPEAT},I={[Bt]:t.NEAREST,[Rt]:t.NEAREST_MIPMAP_NEAREST,[Pt]:t.NEAREST_MIPMAP_LINEAR,[Ut]:t.LINEAR,[Nt]:t.LINEAR_MIPMAP_NEAREST,[Ot]:t.LINEAR_MIPMAP_LINEAR},T={[Rn]:t.NEVER,[On]:t.ALWAYS,[Dn]:t.LESS,[Ln]:t.LEQUAL,[Pn]:t.EQUAL,[Fn]:t.GEQUAL,[Un]:t.GREATER,[Nn]:t.NOTEQUAL};function B(n,s){if(s.type!==jt||!1!==e.has("OES_texture_float_linear")||s.magFilter!==Ut&&s.magFilter!==Nt&&s.magFilter!==Pt&&s.magFilter!==Ot&&s.minFilter!==Ut&&s.minFilter!==Nt&&s.minFilter!==Pt&&s.minFilter!==Ot||console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),t.texParameteri(n,t.TEXTURE_WRAP_S,S[s.wrapS]),t.texParameteri(n,t.TEXTURE_WRAP_T,S[s.wrapT]),n!==t.TEXTURE_3D&&n!==t.TEXTURE_2D_ARRAY||t.texParameteri(n,t.TEXTURE_WRAP_R,S[s.wrapR]),t.texParameteri(n,t.TEXTURE_MAG_FILTER,I[s.magFilter]),t.texParameteri(n,t.TEXTURE_MIN_FILTER,I[s.minFilter]),s.compareFunction&&(t.texParameteri(n,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(n,t.TEXTURE_COMPARE_FUNC,T[s.compareFunction])),!0===e.has("EXT_texture_filter_anisotropic")){if(s.magFilter===Bt)return;if(s.minFilter!==Pt&&s.minFilter!==Ot)return;if(s.type===jt&&!1===e.has("OES_texture_float_linear"))return;if(s.anisotropy>1||i.get(s).__currentAnisotropy){const a=e.get("EXT_texture_filter_anisotropic");t.texParameterf(n,a.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(s.anisotropy,r.getMaxAnisotropy())),i.get(s).__currentAnisotropy=s.anisotropy}}}function R(e,n){let i=!1;void 0===e.__webglInit&&(e.__webglInit=!0,n.addEventListener("dispose",w));const r=n.source;let s=d.get(r);void 0===s&&(s={},d.set(r,s));const o=function(t){const e=[];return e.push(t.wrapS),e.push(t.wrapT),e.push(t.wrapR||0),e.push(t.magFilter),e.push(t.minFilter),e.push(t.anisotropy),e.push(t.internalFormat),e.push(t.format),e.push(t.type),e.push(t.generateMipmaps),e.push(t.premultiplyAlpha),e.push(t.flipY),e.push(t.unpackAlignment),e.push(t.colorSpace),e.join()}(n);if(o!==e.__cacheKey){void 0===s[o]&&(s[o]={texture:t.createTexture(),usedTimes:0},a.memory.textures++,i=!0),s[o].usedTimes++;const r=s[e.__cacheKey];void 0!==r&&(s[e.__cacheKey].usedTimes--,0===r.usedTimes&&E(n)),e.__cacheKey=o,e.__webglTexture=s[o].texture}return i}function D(e,a,o){let l=t.TEXTURE_2D;(a.isDataArrayTexture||a.isCompressedArrayTexture)&&(l=t.TEXTURE_2D_ARRAY),a.isData3DTexture&&(l=t.TEXTURE_3D);const c=R(e,a),h=a.source;n.bindTexture(l,e.__webglTexture,t.TEXTURE0+o);const u=i.get(h);if(h.version!==u.__version||!0===c){n.activeTexture(t.TEXTURE0+o);const e=xi.getPrimaries(xi.workingColorSpace),i=a.colorSpace===hn?null:xi.getPrimaries(a.colorSpace),d=a.colorSpace===hn||e===i?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,a.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,a.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,d);let p=m(a.image,!1,r.maxTextureSize);p=Q(a,p);const f=s.convert(a.format,a.colorSpace),v=s.convert(a.type);let w,C=y(a.internalFormat,f,v,a.colorSpace,a.isVideoTexture);B(l,a);const E=a.mipmaps,M=!0!==a.isVideoTexture,b=void 0===u.__version||!0===c,S=h.dataReady,I=_(a,p);if(a.isDepthTexture)C=x(a.format===re,a.type),b&&(M?n.texStorage2D(t.TEXTURE_2D,1,C,p.width,p.height):n.texImage2D(t.TEXTURE_2D,0,C,p.width,p.height,0,f,v,null));else if(a.isDataTexture)if(E.length>0){M&&b&&n.texStorage2D(t.TEXTURE_2D,I,C,E[0].width,E[0].height);for(let e=0,i=E.length;e0){const i=Zl(w.width,w.height,a.format,a.type);for(const r of a.layerUpdates){const s=w.data.subarray(r*i/w.data.BYTES_PER_ELEMENT,(r+1)*i/w.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,e,0,0,r,w.width,w.height,1,f,s)}a.clearLayerUpdates()}else n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,e,0,0,0,w.width,w.height,p.depth,f,w.data)}else n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,e,C,w.width,w.height,p.depth,0,w.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else M?S&&n.texSubImage3D(t.TEXTURE_2D_ARRAY,e,0,0,0,w.width,w.height,p.depth,f,v,w.data):n.texImage3D(t.TEXTURE_2D_ARRAY,e,C,w.width,w.height,p.depth,0,f,v,w.data)}else{M&&b&&n.texStorage2D(t.TEXTURE_2D,I,C,E[0].width,E[0].height);for(let e=0,i=E.length;e0){const e=Zl(p.width,p.height,a.format,a.type);for(const i of a.layerUpdates){const r=p.data.subarray(i*e/p.data.BYTES_PER_ELEMENT,(i+1)*e/p.data.BYTES_PER_ELEMENT);n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,i,p.width,p.height,1,f,v,r)}a.clearLayerUpdates()}else n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,p.width,p.height,p.depth,f,v,p.data)}else n.texImage3D(t.TEXTURE_2D_ARRAY,0,C,p.width,p.height,p.depth,0,f,v,p.data);else if(a.isData3DTexture)M?(b&&n.texStorage3D(t.TEXTURE_3D,I,C,p.width,p.height,p.depth),S&&n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,p.width,p.height,p.depth,f,v,p.data)):n.texImage3D(t.TEXTURE_3D,0,C,p.width,p.height,p.depth,0,f,v,p.data);else if(a.isFramebufferTexture){if(b)if(M)n.texStorage2D(t.TEXTURE_2D,I,C,p.width,p.height);else{let e=p.width,i=p.height;for(let r=0;r>=1,i>>=1}}else if(E.length>0){if(M&&b){const e=z(E[0]);n.texStorage2D(t.TEXTURE_2D,I,C,e.width,e.height)}for(let e=0,i=E.length;e>h),i=Math.max(1,r.height>>h);c===t.TEXTURE_3D||c===t.TEXTURE_2D_ARRAY?n.texImage3D(c,h,p,e,i,r.depth,0,u,d,null):n.texImage2D(c,h,p,e,i,0,u,d,null)}n.bindFramebuffer(t.FRAMEBUFFER,e),k(r)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,l,c,m.__webglTexture,0,O(r)):(c===t.TEXTURE_2D||c>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&c<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,l,c,m.__webglTexture,h),n.bindFramebuffer(t.FRAMEBUFFER,null)}function L(e,n,i){if(t.bindRenderbuffer(t.RENDERBUFFER,e),n.depthBuffer){const r=n.depthTexture,s=r&&r.isDepthTexture?r.type:null,a=x(n.stencilBuffer,s),l=n.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,c=O(n);k(n)?o.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,c,a,n.width,n.height):i?t.renderbufferStorageMultisample(t.RENDERBUFFER,c,a,n.width,n.height):t.renderbufferStorage(t.RENDERBUFFER,a,n.width,n.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,l,t.RENDERBUFFER,e)}else{const e=n.textures;for(let r=0;r{delete r.__boundDepthTexture,delete r.__depthDisposeCallback,t.removeEventListener("dispose",e)};t.addEventListener("dispose",e),r.__depthDisposeCallback=e}r.__boundDepthTexture=t}if(e.depthTexture&&!r.__autoAllocateDepthBuffer){if(s)throw new Error("target.depthTexture not supported in Cube render targets");!function(e,r){if(r&&r.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,e),!r.depthTexture||!r.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const s=i.get(r.depthTexture);s.__renderTarget=r,s.__webglTexture&&r.depthTexture.image.width===r.width&&r.depthTexture.image.height===r.height||(r.depthTexture.image.width=r.width,r.depthTexture.image.height=r.height,r.depthTexture.needsUpdate=!0),b(r.depthTexture,0);const a=s.__webglTexture,l=O(r);if(r.depthTexture.format===ie)k(r)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,a,0,l):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,a,0);else{if(r.depthTexture.format!==re)throw new Error("Unknown depthTexture format");k(r)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,a,0,l):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,a,0)}}(r.__webglFramebuffer,e)}else if(s){r.__webglDepthbuffer=[];for(let i=0;i<6;i++)if(n.bindFramebuffer(t.FRAMEBUFFER,r.__webglFramebuffer[i]),void 0===r.__webglDepthbuffer[i])r.__webglDepthbuffer[i]=t.createRenderbuffer(),L(r.__webglDepthbuffer[i],e,!1);else{const n=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,s=r.__webglDepthbuffer[i];t.bindRenderbuffer(t.RENDERBUFFER,s),t.framebufferRenderbuffer(t.FRAMEBUFFER,n,t.RENDERBUFFER,s)}}else if(n.bindFramebuffer(t.FRAMEBUFFER,r.__webglFramebuffer),void 0===r.__webglDepthbuffer)r.__webglDepthbuffer=t.createRenderbuffer(),L(r.__webglDepthbuffer,e,!1);else{const n=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,i=r.__webglDepthbuffer;t.bindRenderbuffer(t.RENDERBUFFER,i),t.framebufferRenderbuffer(t.FRAMEBUFFER,n,t.RENDERBUFFER,i)}n.bindFramebuffer(t.FRAMEBUFFER,null)}const N=[],F=[];function O(t){return Math.min(r.maxSamples,t.samples)}function k(t){const n=i.get(t);return t.samples>0&&!0===e.has("WEBGL_multisampled_render_to_texture")&&!1!==n.__useRenderToTexture}function Q(t,e){const n=t.colorSpace,i=t.format,r=t.type;return!0===t.isCompressedTexture||!0===t.isVideoTexture||n!==dn&&n!==hn&&(xi.getTransfer(n)===fn?i===te&&r===Qt||console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",n)),e}function z(t){return"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement?(c.width=t.naturalWidth||t.width,c.height=t.naturalHeight||t.height):"undefined"!=typeof VideoFrame&&t instanceof VideoFrame?(c.width=t.displayWidth,c.height=t.displayHeight):(c.width=t.width,c.height=t.height),c}this.allocateTextureUnit=function(){const t=M;return t>=r.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+t+" texture units while this GPU supports only "+r.maxTextures),M+=1,t},this.resetTextureUnits=function(){M=0},this.setTexture2D=b,this.setTexture2DArray=function(e,r){const s=i.get(e);e.version>0&&s.__version!==e.version?D(s,e,r):n.bindTexture(t.TEXTURE_2D_ARRAY,s.__webglTexture,t.TEXTURE0+r)},this.setTexture3D=function(e,r){const s=i.get(e);e.version>0&&s.__version!==e.version?D(s,e,r):n.bindTexture(t.TEXTURE_3D,s.__webglTexture,t.TEXTURE0+r)},this.setTextureCube=function(e,a){const o=i.get(e);e.version>0&&o.__version!==e.version?function(e,a,o){if(6!==a.image.length)return;const l=R(e,a),c=a.source;n.bindTexture(t.TEXTURE_CUBE_MAP,e.__webglTexture,t.TEXTURE0+o);const h=i.get(c);if(c.version!==h.__version||!0===l){n.activeTexture(t.TEXTURE0+o);const e=xi.getPrimaries(xi.workingColorSpace),i=a.colorSpace===hn?null:xi.getPrimaries(a.colorSpace),u=a.colorSpace===hn||e===i?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,a.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,a.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,u);const d=a.isCompressedTexture||a.image[0].isCompressedTexture,p=a.image[0]&&a.image[0].isDataTexture,f=[];for(let t=0;t<6;t++)f[t]=d||p?p?a.image[t].image:a.image[t]:m(a.image[t],!0,r.maxCubemapSize),f[t]=Q(a,f[t]);const v=f[0],x=s.convert(a.format,a.colorSpace),w=s.convert(a.type),C=y(a.internalFormat,x,w,a.colorSpace),E=!0!==a.isVideoTexture,M=void 0===h.__version||!0===l,b=c.dataReady;let S,I=_(a,v);if(B(t.TEXTURE_CUBE_MAP,a),d){E&&M&&n.texStorage2D(t.TEXTURE_CUBE_MAP,I,C,v.width,v.height);for(let e=0;e<6;e++){S=f[e].mipmaps;for(let i=0;i0&&I++;const e=z(f[0]);n.texStorage2D(t.TEXTURE_CUBE_MAP,I,C,e.width,e.height)}for(let e=0;e<6;e++)if(p){E?b&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,0,0,f[e].width,f[e].height,x,w,f[e].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,C,f[e].width,f[e].height,0,x,w,f[e].data);for(let i=0;i1;if(u||(void 0===l.__webglTexture&&(l.__webglTexture=t.createTexture()),l.__version=r.version,a.memory.textures++),h){o.__webglFramebuffer=[];for(let e=0;e<6;e++)if(r.mipmaps&&r.mipmaps.length>0){o.__webglFramebuffer[e]=[];for(let n=0;n0){o.__webglFramebuffer=[];for(let e=0;e0&&!1===k(e)){o.__webglMultisampledFramebuffer=t.createFramebuffer(),o.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,o.__webglMultisampledFramebuffer);for(let n=0;n0)for(let i=0;i0)for(let n=0;n0)if(!1===k(e)){const r=e.textures,s=e.width,a=e.height;let o=t.COLOR_BUFFER_BIT;const c=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,h=i.get(e),u=r.length>1;if(u)for(let e=0;eo+c?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!l.inputState.pinching&&a<=o-c&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else null!==o&&t.gripSpace&&(r=e.getPose(t.gripSpace,n),null!==r&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1));null!==a&&(i=e.getPose(t.targetRaySpace,n),null===i&&null!==r&&(i=r),null!==i&&(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(rc)))}return null!==a&&(a.visible=null!==i),null!==o&&(o.visible=null!==r),null!==l&&(l.visible=null!==s),this}_getHandJoint(t,e){if(void 0===t.joints[e.jointName]){const n=new ic;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}}class ac{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e,n){if(null===this.texture){const i=new Li;t.properties.get(i).__webglTexture=e.texture,e.depthNear==n.depthNear&&e.depthFar==n.depthFar||(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=i}}getMesh(t){if(null!==this.texture&&null===this.mesh){const e=t.cameras[0].viewport,n=new sa({vertexShader:"\nvoid main() {\n\n\tgl_Position = vec4( position, 1.0 );\n\n}",fragmentShader:"\nuniform sampler2DArray depthColor;\nuniform float depthWidth;\nuniform float depthHeight;\n\nvoid main() {\n\n\tvec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );\n\n\tif ( coord.x >= 1.0 ) {\n\n\t\tgl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;\n\n\t} else {\n\n\t\tgl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;\n\n\t}\n\n}",uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new Zs(new Ea(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class oc extends Zn{constructor(t,e){super();const n=this;let i=null,r=1,s=null,a="local-floor",o=1,l=null,c=null,h=null,u=null,d=null,p=null;const f=new ac,m=e.getContextAttributes();let g=null,A=null;const v=[],y=[],x=new hi;let _=null;const w=new ha;w.viewport=new Ui;const C=new ha;C.viewport=new Ui;const E=[w,C],M=new nc;let b=null,S=null;function I(t){const e=y.indexOf(t.inputSource);if(-1===e)return;const n=v[e];void 0!==n&&(n.update(t.inputSource,t.frame,l||s),n.dispatchEvent({type:t.type,data:t.inputSource}))}function T(){i.removeEventListener("select",I),i.removeEventListener("selectstart",I),i.removeEventListener("selectend",I),i.removeEventListener("squeeze",I),i.removeEventListener("squeezestart",I),i.removeEventListener("squeezeend",I),i.removeEventListener("end",T),i.removeEventListener("inputsourceschange",B);for(let t=0;t=0&&(y[i]=null,v[i].disconnect(n))}for(let e=0;e=y.length){y.push(n),i=t;break}if(null===y[t]){y[t]=n,i=t;break}}if(-1===i)break}const r=v[i];r&&r.connect(n)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(t){let e=v[t];return void 0===e&&(e=new sc,v[t]=e),e.getTargetRaySpace()},this.getControllerGrip=function(t){let e=v[t];return void 0===e&&(e=new sc,v[t]=e),e.getGripSpace()},this.getHand=function(t){let e=v[t];return void 0===e&&(e=new sc,v[t]=e),e.getHandSpace()},this.setFramebufferScaleFactor=function(t){r=t,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(t){a=t,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||s},this.setReferenceSpace=function(t){l=t},this.getBaseLayer=function(){return null!==u?u:d},this.getBinding=function(){return h},this.getFrame=function(){return p},this.getSession=function(){return i},this.setSession=async function(c){if(i=c,null!==i){if(g=t.getRenderTarget(),i.addEventListener("select",I),i.addEventListener("selectstart",I),i.addEventListener("selectend",I),i.addEventListener("squeeze",I),i.addEventListener("squeezestart",I),i.addEventListener("squeezeend",I),i.addEventListener("end",T),i.addEventListener("inputsourceschange",B),!0!==m.xrCompatible&&await e.makeXRCompatible(),_=t.getPixelRatio(),t.getSize(x),void 0===i.renderState.layers){const n={antialias:m.antialias,alpha:!0,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:r};d=new XRWebGLLayer(i,e,n),i.updateRenderState({baseLayer:d}),t.setPixelRatio(1),t.setSize(d.framebufferWidth,d.framebufferHeight,!1),A=new Fi(d.framebufferWidth,d.framebufferHeight,{format:te,type:Qt,colorSpace:t.outputColorSpace,stencilBuffer:m.stencil})}else{let n=null,s=null,a=null;m.depth&&(a=m.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,n=m.stencil?re:ie,s=m.stencil?Jt:Wt);const o={colorFormat:e.RGBA8,depthFormat:a,scaleFactor:r};h=new XRWebGLBinding(i,e),u=h.createProjectionLayer(o),i.updateRenderState({layers:[u]}),t.setPixelRatio(1),t.setSize(u.textureWidth,u.textureHeight,!1),A=new Fi(u.textureWidth,u.textureHeight,{format:te,type:Qt,depthTexture:new ao(u.textureWidth,u.textureHeight,s,void 0,void 0,void 0,void 0,void 0,void 0,n),stencilBuffer:m.stencil,colorSpace:t.outputColorSpace,samples:m.antialias?4:0,resolveDepthBuffer:!1===u.ignoreDepthValues})}A.isXRRenderTarget=!0,this.setFoveation(o),l=null,s=await i.requestReferenceSpace(a),U.setContext(i),U.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(null!==i)return i.environmentBlendMode},this.getDepthTexture=function(){return f.getDepthTexture()};const R=new Hi,D=new Hi;function P(t,e){null===e?t.matrixWorld.copy(t.matrix):t.matrixWorld.multiplyMatrices(e.matrixWorld,t.matrix),t.matrixWorldInverse.copy(t.matrixWorld).invert()}this.updateCamera=function(t){if(null===i)return;let e=t.near,n=t.far;null!==f.texture&&(f.depthNear>0&&(e=f.depthNear),f.depthFar>0&&(n=f.depthFar)),M.near=C.near=w.near=e,M.far=C.far=w.far=n,b===M.near&&S===M.far||(i.updateRenderState({depthNear:M.near,depthFar:M.far}),b=M.near,S=M.far),w.layers.mask=2|t.layers.mask,C.layers.mask=4|t.layers.mask,M.layers.mask=w.layers.mask|C.layers.mask;const r=t.parent,s=M.cameras;P(M,r);for(let t=0;t0&&(t.alphaTest.value=i.alphaTest);const r=e.get(i),s=r.envMap,a=r.envMapRotation;s&&(t.envMap.value=s,lc.copy(a),lc.x*=-1,lc.y*=-1,lc.z*=-1,s.isCubeTexture&&!1===s.isRenderTargetTexture&&(lc.y*=-1,lc.z*=-1),t.envMapRotation.value.setFromMatrix4(cc.makeRotationFromEuler(lc)),t.flipEnvMap.value=s.isCubeTexture&&!1===s.isRenderTargetTexture?-1:1,t.reflectivity.value=i.reflectivity,t.ior.value=i.ior,t.refractionRatio.value=i.refractionRatio),i.lightMap&&(t.lightMap.value=i.lightMap,t.lightMapIntensity.value=i.lightMapIntensity,n(i.lightMap,t.lightMapTransform)),i.aoMap&&(t.aoMap.value=i.aoMap,t.aoMapIntensity.value=i.aoMapIntensity,n(i.aoMap,t.aoMapTransform))}return{refreshFogUniforms:function(e,n){n.color.getRGB(e.fogColor.value,ia(t)),n.isFog?(e.fogNear.value=n.near,e.fogFar.value=n.far):n.isFogExp2&&(e.fogDensity.value=n.density)},refreshMaterialUniforms:function(t,r,s,a,o){r.isMeshBasicMaterial||r.isMeshLambertMaterial?i(t,r):r.isMeshToonMaterial?(i(t,r),function(t,e){e.gradientMap&&(t.gradientMap.value=e.gradientMap)}(t,r)):r.isMeshPhongMaterial?(i(t,r),function(t,e){t.specular.value.copy(e.specular),t.shininess.value=Math.max(e.shininess,1e-4)}(t,r)):r.isMeshStandardMaterial?(i(t,r),function(t,e){t.metalness.value=e.metalness,e.metalnessMap&&(t.metalnessMap.value=e.metalnessMap,n(e.metalnessMap,t.metalnessMapTransform)),t.roughness.value=e.roughness,e.roughnessMap&&(t.roughnessMap.value=e.roughnessMap,n(e.roughnessMap,t.roughnessMapTransform)),e.envMap&&(t.envMapIntensity.value=e.envMapIntensity)}(t,r),r.isMeshPhysicalMaterial&&function(t,e,i){t.ior.value=e.ior,e.sheen>0&&(t.sheenColor.value.copy(e.sheenColor).multiplyScalar(e.sheen),t.sheenRoughness.value=e.sheenRoughness,e.sheenColorMap&&(t.sheenColorMap.value=e.sheenColorMap,n(e.sheenColorMap,t.sheenColorMapTransform)),e.sheenRoughnessMap&&(t.sheenRoughnessMap.value=e.sheenRoughnessMap,n(e.sheenRoughnessMap,t.sheenRoughnessMapTransform))),e.clearcoat>0&&(t.clearcoat.value=e.clearcoat,t.clearcoatRoughness.value=e.clearcoatRoughness,e.clearcoatMap&&(t.clearcoatMap.value=e.clearcoatMap,n(e.clearcoatMap,t.clearcoatMapTransform)),e.clearcoatRoughnessMap&&(t.clearcoatRoughnessMap.value=e.clearcoatRoughnessMap,n(e.clearcoatRoughnessMap,t.clearcoatRoughnessMapTransform)),e.clearcoatNormalMap&&(t.clearcoatNormalMap.value=e.clearcoatNormalMap,n(e.clearcoatNormalMap,t.clearcoatNormalMapTransform),t.clearcoatNormalScale.value.copy(e.clearcoatNormalScale),e.side===b&&t.clearcoatNormalScale.value.negate())),e.dispersion>0&&(t.dispersion.value=e.dispersion),e.iridescence>0&&(t.iridescence.value=e.iridescence,t.iridescenceIOR.value=e.iridescenceIOR,t.iridescenceThicknessMinimum.value=e.iridescenceThicknessRange[0],t.iridescenceThicknessMaximum.value=e.iridescenceThicknessRange[1],e.iridescenceMap&&(t.iridescenceMap.value=e.iridescenceMap,n(e.iridescenceMap,t.iridescenceMapTransform)),e.iridescenceThicknessMap&&(t.iridescenceThicknessMap.value=e.iridescenceThicknessMap,n(e.iridescenceThicknessMap,t.iridescenceThicknessMapTransform))),e.transmission>0&&(t.transmission.value=e.transmission,t.transmissionSamplerMap.value=i.texture,t.transmissionSamplerSize.value.set(i.width,i.height),e.transmissionMap&&(t.transmissionMap.value=e.transmissionMap,n(e.transmissionMap,t.transmissionMapTransform)),t.thickness.value=e.thickness,e.thicknessMap&&(t.thicknessMap.value=e.thicknessMap,n(e.thicknessMap,t.thicknessMapTransform)),t.attenuationDistance.value=e.attenuationDistance,t.attenuationColor.value.copy(e.attenuationColor)),e.anisotropy>0&&(t.anisotropyVector.value.set(e.anisotropy*Math.cos(e.anisotropyRotation),e.anisotropy*Math.sin(e.anisotropyRotation)),e.anisotropyMap&&(t.anisotropyMap.value=e.anisotropyMap,n(e.anisotropyMap,t.anisotropyMapTransform))),t.specularIntensity.value=e.specularIntensity,t.specularColor.value.copy(e.specularColor),e.specularColorMap&&(t.specularColorMap.value=e.specularColorMap,n(e.specularColorMap,t.specularColorMapTransform)),e.specularIntensityMap&&(t.specularIntensityMap.value=e.specularIntensityMap,n(e.specularIntensityMap,t.specularIntensityMapTransform))}(t,r,o)):r.isMeshMatcapMaterial?(i(t,r),function(t,e){e.matcap&&(t.matcap.value=e.matcap)}(t,r)):r.isMeshDepthMaterial?i(t,r):r.isMeshDistanceMaterial?(i(t,r),function(t,n){const i=e.get(n).light;t.referencePosition.value.setFromMatrixPosition(i.matrixWorld),t.nearDistance.value=i.shadow.camera.near,t.farDistance.value=i.shadow.camera.far}(t,r)):r.isMeshNormalMaterial?i(t,r):r.isLineBasicMaterial?(function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,e.map&&(t.map.value=e.map,n(e.map,t.mapTransform))}(t,r),r.isLineDashedMaterial&&function(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}(t,r)):r.isPointsMaterial?function(t,e,i,r){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.size.value=e.size*i,t.scale.value=.5*r,e.map&&(t.map.value=e.map,n(e.map,t.uvTransform)),e.alphaMap&&(t.alphaMap.value=e.alphaMap,n(e.alphaMap,t.alphaMapTransform)),e.alphaTest>0&&(t.alphaTest.value=e.alphaTest)}(t,r,s,a):r.isSpriteMaterial?function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.rotation.value=e.rotation,e.map&&(t.map.value=e.map,n(e.map,t.mapTransform)),e.alphaMap&&(t.alphaMap.value=e.alphaMap,n(e.alphaMap,t.alphaMapTransform)),e.alphaTest>0&&(t.alphaTest.value=e.alphaTest)}(t,r):r.isShadowMaterial?(t.color.value.copy(r.color),t.opacity.value=r.opacity):r.isShaderMaterial&&(r.uniformsNeedUpdate=!1)}}}function uc(t,e,n,i){let r={},s={},a=[];const o=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS);function l(t,e,n,i){const r=t.value,s=e+"_"+n;if(void 0===i[s])return i[s]="number"==typeof r||"boolean"==typeof r?r:r.clone(),!0;{const t=i[s];if("number"==typeof r||"boolean"==typeof r){if(t!==r)return i[s]=r,!0}else if(!1===t.equals(r))return t.copy(r),!0}return!1}function c(t){const e={boundary:0,storage:0};return"number"==typeof t||"boolean"==typeof t?(e.boundary=4,e.storage=4):t.isVector2?(e.boundary=8,e.storage=8):t.isVector3||t.isColor?(e.boundary=16,e.storage=12):t.isVector4?(e.boundary=16,e.storage=16):t.isMatrix3?(e.boundary=48,e.storage=48):t.isMatrix4?(e.boundary=64,e.storage=64):t.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",t),e}function h(e){const n=e.target;n.removeEventListener("dispose",h);const i=a.indexOf(n.__bindingPointIndex);a.splice(i,1),t.deleteBuffer(r[n.id]),delete r[n.id],delete s[n.id]}return{bind:function(t,e){const n=e.program;i.uniformBlockBinding(t,n)},update:function(n,u){let d=r[n.id];void 0===d&&(function(t){const e=t.uniforms;let n=0;for(let t=0,i=e.length;t0&&(n+=16-i),t.__size=n,t.__cache={}}(n),d=function(e){const n=function(){for(let t=0;t0),u=!!n.morphAttributes.position,d=!!n.morphAttributes.normal,p=!!n.morphAttributes.color;let f=ut;i.toneMapped&&(null!==E&&!0!==E.isXRRenderTarget||(f=x.toneMapping));const m=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,g=void 0!==m?m.length:0,v=it.get(i),y=A.state.lights;if(!0===V&&(!0===W||t!==T)){const e=t===T&&i.id===I;mt.setState(i,t,e)}let _=!1;i.version===v.__version?v.needsLights&&v.lightsStateVersion!==y.state.version||v.outputColorSpace!==o||r.isBatchedMesh&&!1===v.batching?_=!0:r.isBatchedMesh||!0!==v.batching?r.isBatchedMesh&&!0===v.batchingColor&&null===r.colorTexture||r.isBatchedMesh&&!1===v.batchingColor&&null!==r.colorTexture||r.isInstancedMesh&&!1===v.instancing?_=!0:r.isInstancedMesh||!0!==v.instancing?r.isSkinnedMesh&&!1===v.skinning?_=!0:r.isSkinnedMesh||!0!==v.skinning?r.isInstancedMesh&&!0===v.instancingColor&&null===r.instanceColor||r.isInstancedMesh&&!1===v.instancingColor&&null!==r.instanceColor||r.isInstancedMesh&&!0===v.instancingMorph&&null===r.morphTexture||r.isInstancedMesh&&!1===v.instancingMorph&&null!==r.morphTexture||v.envMap!==l||!0===i.fog&&v.fog!==s?_=!0:void 0===v.numClippingPlanes||v.numClippingPlanes===mt.numPlanes&&v.numIntersection===mt.numIntersection?(v.vertexAlphas!==c||v.vertexTangents!==h||v.morphTargets!==u||v.morphNormals!==d||v.morphColors!==p||v.toneMapping!==f||v.morphTargetsCount!==g)&&(_=!0):_=!0:_=!0:_=!0:_=!0:(_=!0,v.__version=i.version);let w=v.currentProgram;!0===_&&(w=jt(i,e,r));let C=!1,M=!1,b=!1;const S=w.getUniforms(),B=v.uniforms;if(et.useProgram(w.program)&&(C=!0,M=!0,b=!0),i.id!==I&&(I=i.id,M=!0),C||T!==t){et.buffers.depth.getReversed()?(j.copy(t.projectionMatrix),function(t){const e=t.elements;e[2]=.5*e[2]+.5*e[3],e[6]=.5*e[6]+.5*e[7],e[10]=.5*e[10]+.5*e[11],e[14]=.5*e[14]+.5*e[15]}(j),function(t){const e=t.elements;-1===e[11]?(e[10]=-e[10]-1,e[14]=-e[14]):(e[10]=-e[10],e[14]=1-e[14])}(j),S.setValue(Et,"projectionMatrix",j)):S.setValue(Et,"projectionMatrix",t.projectionMatrix),S.setValue(Et,"viewMatrix",t.matrixWorldInverse);const e=S.map.cameraPosition;void 0!==e&&e.setValue(Et,X.setFromMatrixPosition(t.matrixWorld)),tt.logarithmicDepthBuffer&&S.setValue(Et,"logDepthBufFC",2/(Math.log(t.far+1)/Math.LN2)),(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial)&&S.setValue(Et,"isOrthographic",!0===t.isOrthographicCamera),T!==t&&(T=t,M=!0,b=!0)}if(r.isSkinnedMesh){S.setOptional(Et,r,"bindMatrix"),S.setOptional(Et,r,"bindMatrixInverse");const t=r.skeleton;t&&(null===t.boneTexture&&t.computeBoneTexture(),S.setValue(Et,"boneTexture",t.boneTexture,rt))}r.isBatchedMesh&&(S.setOptional(Et,r,"batchingTexture"),S.setValue(Et,"batchingTexture",r._matricesTexture,rt),S.setOptional(Et,r,"batchingIdTexture"),S.setValue(Et,"batchingIdTexture",r._indirectTexture,rt),S.setOptional(Et,r,"batchingColorTexture"),null!==r._colorsTexture&&S.setValue(Et,"batchingColorTexture",r._colorsTexture,rt));const R=n.morphAttributes;var D,P;if(void 0===R.position&&void 0===R.normal&&void 0===R.color||vt.update(r,n,w),(M||v.receiveShadow!==r.receiveShadow)&&(v.receiveShadow=r.receiveShadow,S.setValue(Et,"receiveShadow",r.receiveShadow)),i.isMeshGouraudMaterial&&null!==i.envMap&&(B.envMap.value=l,B.flipEnvMap.value=l.isCubeTexture&&!1===l.isRenderTargetTexture?-1:1),i.isMeshStandardMaterial&&null===i.envMap&&null!==e.environment&&(B.envMapIntensity.value=e.environmentIntensity),M&&(S.setValue(Et,"toneMappingExposure",x.toneMappingExposure),v.needsLights&&(P=b,(D=B).ambientLightColor.needsUpdate=P,D.lightProbe.needsUpdate=P,D.directionalLights.needsUpdate=P,D.directionalLightShadows.needsUpdate=P,D.pointLights.needsUpdate=P,D.pointLightShadows.needsUpdate=P,D.spotLights.needsUpdate=P,D.spotLightShadows.needsUpdate=P,D.rectAreaLights.needsUpdate=P,D.hemisphereLights.needsUpdate=P),s&&!0===i.fog&&dt.refreshFogUniforms(B,s),dt.refreshMaterialUniforms(B,i,F,N,A.state.transmissionRenderTarget[t.id]),dl.upload(Et,Kt(v),B,rt)),i.isShaderMaterial&&!0===i.uniformsNeedUpdate&&(dl.upload(Et,Kt(v),B,rt),i.uniformsNeedUpdate=!1),i.isSpriteMaterial&&S.setValue(Et,"center",r.center),S.setValue(Et,"modelViewMatrix",r.modelViewMatrix),S.setValue(Et,"normalMatrix",r.normalMatrix),S.setValue(Et,"modelMatrix",r.matrixWorld),i.isShaderMaterial||i.isRawShaderMaterial){const t=i.uniformsGroups;for(let e=0,n=t.length;e{function n(){i.forEach((function(t){it.get(t).currentProgram.isReady()&&i.delete(t)})),0!==i.size?setTimeout(n,10):e(t)}null!==$.get("KHR_parallel_shader_compile")?n():setTimeout(n,10)}))};let Pt=null;function Lt(){Nt.stop()}function Ut(){Nt.start()}const Nt=new wa;function Ft(t,e,n,i){if(!1===t.visible)return;if(t.layers.test(e.layers))if(t.isGroup)n=t.renderOrder;else if(t.isLOD)!0===t.autoUpdate&&t.update(e);else if(t.isLight)A.pushLight(t),t.castShadow&&A.pushShadow(t);else if(t.isSprite){if(!t.frustumCulled||H.intersectsSprite(t)){i&&Y.setFromMatrixPosition(t.matrixWorld).applyMatrix4(q);const e=ct.update(t),r=t.material;r.visible&&g.push(t,e,r,n,Y.z,null)}}else if((t.isMesh||t.isLine||t.isPoints)&&(!t.frustumCulled||H.intersectsObject(t))){const e=ct.update(t),r=t.material;if(i&&(void 0!==t.boundingSphere?(null===t.boundingSphere&&t.computeBoundingSphere(),Y.copy(t.boundingSphere.center)):(null===e.boundingSphere&&e.computeBoundingSphere(),Y.copy(e.boundingSphere.center)),Y.applyMatrix4(t.matrixWorld).applyMatrix4(q)),Array.isArray(r)){const i=e.groups;for(let s=0,a=i.length;s0&&Gt(r,e,n),s.length>0&&Gt(s,e,n),a.length>0&&Gt(a,e,n),et.buffers.depth.setTest(!0),et.buffers.depth.setMask(!0),et.buffers.color.setMask(!0),et.setPolygonOffset(!1)}function zt(t,e,n,i){if(null!==(!0===n.isScene?n.overrideMaterial:null))return;void 0===A.state.transmissionRenderTarget[i.id]&&(A.state.transmissionRenderTarget[i.id]=new Fi(1,1,{generateMipmaps:!0,type:$.has("EXT_color_buffer_half_float")||$.has("EXT_color_buffer_float")?qt:Qt,minFilter:Ot,samples:4,stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:xi.workingColorSpace}));const s=A.state.transmissionRenderTarget[i.id],a=i.viewport||B;s.setSize(a.z,a.w);const o=x.getRenderTarget();x.setRenderTarget(s),x.getClearColor(P),L=x.getClearAlpha(),L<1&&x.setClearColor(16777215,.5),x.clear(),K&&At.render(n);const l=x.toneMapping;x.toneMapping=ut;const c=i.viewport;if(void 0!==i.viewport&&(i.viewport=void 0),A.setupLightsView(i),!0===V&&mt.setGlobalState(x.clippingPlanes,i),Gt(t,n,i),rt.updateMultisampleRenderTarget(s),rt.updateRenderTargetMipmap(s),!1===$.has("WEBGL_multisampled_render_to_texture")){let t=!1;for(let r=0,s=e.length;r0)for(let e=0,s=n.length;e0&&zt(i,r,t,e),K&&At.render(t),kt(g,t,e);null!==E&&(rt.updateMultisampleRenderTarget(E),rt.updateRenderTargetMipmap(E)),!0===t.isScene&&t.onAfterRender(x,t,e),wt.resetDefaultState(),I=-1,T=null,y.pop(),y.length>0?(A=y[y.length-1],!0===V&&mt.setGlobalState(x.clippingPlanes,A.state.camera)):A=null,v.pop(),g=v.length>0?v[v.length-1]:null},this.getActiveCubeFace=function(){return w},this.getActiveMipmapLevel=function(){return C},this.getRenderTarget=function(){return E},this.setRenderTargetTextures=function(t,e,n){it.get(t.texture).__webglTexture=e,it.get(t.depthTexture).__webglTexture=n;const i=it.get(t);i.__hasExternalTextures=!0,i.__autoAllocateDepthBuffer=void 0===n,i.__autoAllocateDepthBuffer||!0===$.has("WEBGL_multisampled_render_to_texture")&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),i.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(t,e){const n=it.get(t);n.__webglFramebuffer=e,n.__useDefaultFramebuffer=void 0===e},this.setRenderTarget=function(t,e=0,n=0){E=t,w=e,C=n;let i=!0,r=null,s=!1,a=!1;if(t){const o=it.get(t);if(void 0!==o.__useDefaultFramebuffer)et.bindFramebuffer(Et.FRAMEBUFFER,null),i=!1;else if(void 0===o.__webglFramebuffer)rt.setupRenderTarget(t);else if(o.__hasExternalTextures)rt.rebindTextures(t,it.get(t.texture).__webglTexture,it.get(t.depthTexture).__webglTexture);else if(t.depthBuffer){const e=t.depthTexture;if(o.__boundDepthTexture!==e){if(null!==e&&it.has(e)&&(t.width!==e.image.width||t.height!==e.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");rt.setupDepthRenderbuffer(t)}}const l=t.texture;(l.isData3DTexture||l.isDataArrayTexture||l.isCompressedArrayTexture)&&(a=!0);const c=it.get(t).__webglFramebuffer;t.isWebGLCubeRenderTarget?(r=Array.isArray(c[e])?c[e][n]:c[e],s=!0):r=t.samples>0&&!1===rt.useMultisampledRTT(t)?it.get(t).__webglMultisampledFramebuffer:Array.isArray(c)?c[n]:c,B.copy(t.viewport),R.copy(t.scissor),D=t.scissorTest}else B.copy(Q).multiplyScalar(F).floor(),R.copy(z).multiplyScalar(F).floor(),D=G;if(et.bindFramebuffer(Et.FRAMEBUFFER,r)&&i&&et.drawBuffers(t,r),et.viewport(B),et.scissor(R),et.setScissorTest(D),s){const i=it.get(t.texture);Et.framebufferTexture2D(Et.FRAMEBUFFER,Et.COLOR_ATTACHMENT0,Et.TEXTURE_CUBE_MAP_POSITIVE_X+e,i.__webglTexture,n)}else if(a){const i=it.get(t.texture),r=e||0;Et.framebufferTextureLayer(Et.FRAMEBUFFER,Et.COLOR_ATTACHMENT0,i.__webglTexture,n||0,r)}I=-1},this.readRenderTargetPixels=function(t,e,n,i,r,s,a){if(!t||!t.isWebGLRenderTarget)return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let o=it.get(t).__webglFramebuffer;if(t.isWebGLCubeRenderTarget&&void 0!==a&&(o=o[a]),o){et.bindFramebuffer(Et.FRAMEBUFFER,o);try{const a=t.texture,o=a.format,l=a.type;if(!tt.textureFormatReadable(o))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!tt.textureTypeReadable(l))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");e>=0&&e<=t.width-i&&n>=0&&n<=t.height-r&&Et.readPixels(e,n,i,r,_t.convert(o),_t.convert(l),s)}finally{const t=null!==E?it.get(E).__webglFramebuffer:null;et.bindFramebuffer(Et.FRAMEBUFFER,t)}}},this.readRenderTargetPixelsAsync=async function(t,e,n,i,r,s,a){if(!t||!t.isWebGLRenderTarget)throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let o=it.get(t).__webglFramebuffer;if(t.isWebGLCubeRenderTarget&&void 0!==a&&(o=o[a]),o){const a=t.texture,l=a.format,c=a.type;if(!tt.textureFormatReadable(l))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!tt.textureTypeReadable(c))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(e>=0&&e<=t.width-i&&n>=0&&n<=t.height-r){et.bindFramebuffer(Et.FRAMEBUFFER,o);const t=Et.createBuffer();Et.bindBuffer(Et.PIXEL_PACK_BUFFER,t),Et.bufferData(Et.PIXEL_PACK_BUFFER,s.byteLength,Et.STREAM_READ),Et.readPixels(e,n,i,r,_t.convert(l),_t.convert(c),0);const a=null!==E?it.get(E).__webglFramebuffer:null;et.bindFramebuffer(Et.FRAMEBUFFER,a);const h=Et.fenceSync(Et.SYNC_GPU_COMMANDS_COMPLETE,0);return Et.flush(),await function(t,e){return new Promise((function(n,i){setTimeout((function r(){switch(t.clientWaitSync(e,t.SYNC_FLUSH_COMMANDS_BIT,0)){case t.WAIT_FAILED:i();break;case t.TIMEOUT_EXPIRED:setTimeout(r,4);break;default:n()}}),4)}))}(Et,h),Et.bindBuffer(Et.PIXEL_PACK_BUFFER,t),Et.getBufferSubData(Et.PIXEL_PACK_BUFFER,0,s),Et.deleteBuffer(t),Et.deleteSync(h),s}throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(t,e=null,n=0){!0!==t.isTexture&&(yi("WebGLRenderer: copyFramebufferToTexture function signature has changed."),e=arguments[0]||null,t=arguments[1]);const i=Math.pow(2,-n),r=Math.floor(t.image.width*i),s=Math.floor(t.image.height*i),a=null!==e?e.x:0,o=null!==e?e.y:0;rt.setTexture2D(t,0),Et.copyTexSubImage2D(Et.TEXTURE_2D,n,0,0,a,o,r,s),et.unbindTexture()},this.copyTextureToTexture=function(t,e,n=null,i=null,r=0){let s,a,o,l,c,h,u,d,p;!0!==t.isTexture&&(yi("WebGLRenderer: copyTextureToTexture function signature has changed."),i=arguments[0]||null,t=arguments[1],e=arguments[2],r=arguments[3]||0,n=null);const f=t.isCompressedTexture?t.mipmaps[r]:t.image;null!==n?(s=n.max.x-n.min.x,a=n.max.y-n.min.y,o=n.isBox3?n.max.z-n.min.z:1,l=n.min.x,c=n.min.y,h=n.isBox3?n.min.z:0):(s=f.width,a=f.height,o=f.depth||1,l=0,c=0,h=0),null!==i?(u=i.x,d=i.y,p=i.z):(u=0,d=0,p=0);const m=_t.convert(e.format),g=_t.convert(e.type);let A;e.isData3DTexture?(rt.setTexture3D(e,0),A=Et.TEXTURE_3D):e.isDataArrayTexture||e.isCompressedArrayTexture?(rt.setTexture2DArray(e,0),A=Et.TEXTURE_2D_ARRAY):(rt.setTexture2D(e,0),A=Et.TEXTURE_2D),Et.pixelStorei(Et.UNPACK_FLIP_Y_WEBGL,e.flipY),Et.pixelStorei(Et.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.premultiplyAlpha),Et.pixelStorei(Et.UNPACK_ALIGNMENT,e.unpackAlignment);const v=Et.getParameter(Et.UNPACK_ROW_LENGTH),y=Et.getParameter(Et.UNPACK_IMAGE_HEIGHT),x=Et.getParameter(Et.UNPACK_SKIP_PIXELS),_=Et.getParameter(Et.UNPACK_SKIP_ROWS),w=Et.getParameter(Et.UNPACK_SKIP_IMAGES);Et.pixelStorei(Et.UNPACK_ROW_LENGTH,f.width),Et.pixelStorei(Et.UNPACK_IMAGE_HEIGHT,f.height),Et.pixelStorei(Et.UNPACK_SKIP_PIXELS,l),Et.pixelStorei(Et.UNPACK_SKIP_ROWS,c),Et.pixelStorei(Et.UNPACK_SKIP_IMAGES,h);const C=t.isDataArrayTexture||t.isData3DTexture,E=e.isDataArrayTexture||e.isData3DTexture;if(t.isRenderTargetTexture||t.isDepthTexture){const n=it.get(t),i=it.get(e),f=it.get(n.__renderTarget),m=it.get(i.__renderTarget);et.bindFramebuffer(Et.READ_FRAMEBUFFER,f.__webglFramebuffer),et.bindFramebuffer(Et.DRAW_FRAMEBUFFER,m.__webglFramebuffer);for(let n=0;n0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),1!==this.backgroundIntensity&&(e.object.backgroundIntensity=this.backgroundIntensity),e.object.backgroundRotation=this.backgroundRotation.toArray(),1!==this.environmentIntensity&&(e.object.environmentIntensity=this.environmentIntensity),e.object.environmentRotation=this.environmentRotation.toArray(),e}}class gc{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=void 0!==t?t.length/e:0,this.usage=kn,this.updateRanges=[],this.version=0,this.uuid=ii()}onUploadCallback(){}set needsUpdate(t){!0===t&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,n){t*=this.stride,n*=e.stride;for(let i=0,r=this.stride;it.far||e.push({distance:o,point:_c.clone(),uv:as.getInterpolation(_c,Sc,Ic,Tc,Bc,Rc,Dc,new hi),face:null,object:this})}copy(t,e){return super.copy(t,e),void 0!==t.center&&this.center.copy(t.center),this.material=t.material,this}}function Lc(t,e,n,i,r,s){Ec.subVectors(t,n).addScalar(.5).multiply(i),void 0!==r?(Mc.x=s*Ec.x-r*Ec.y,Mc.y=r*Ec.x+s*Ec.y):Mc.copy(Ec),t.copy(e),t.x+=Mc.x,t.y+=Mc.y,t.applyMatrix4(bc)}const Uc=new Hi,Nc=new Hi;class Fc extends jr{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(t){super.copy(t,!1);const e=t.levels;for(let t=0,n=e.length;t0){let n,i;for(n=1,i=e.length;n0){Uc.setFromMatrixPosition(this.matrixWorld);const n=t.ray.origin.distanceTo(Uc);this.getObjectForDistance(n).raycast(t,e)}}update(t){const e=this.levels;if(e.length>1){Uc.setFromMatrixPosition(t.matrixWorld),Nc.setFromMatrixPosition(this.matrixWorld);const n=Uc.distanceTo(Nc)/t.zoom;let i,r;for(e[0].object.visible=!0,i=1,r=e.length;i=t))break;e[i-1].object.visible=!1,e[i].object.visible=!0}for(this._currentLevel=i-1;i=r.length&&r.push({start:-1,count:-1,z:-1,index:-1});const a=r[this.index];s.push(a),this.index++,a.start=t,a.count=e,a.z=n,a.index=i}reset(){this.list.length=0,this.index=0}}const dh=new yr,ph=new us(1,1,1),fh=new _a,mh=new ji,gh=new hr,Ah=new Hi,vh=new Hi,yh=new Hi,xh=new uh,_h=new Zs,wh=[];function Ch(t,e,n=0){const i=e.itemSize;if(t.isInterleavedBufferAttribute||t.array.constructor!==e.array.constructor){const r=t.count;for(let s=0;s65535?new Uint32Array(i):new Uint16Array(i);e.setIndex(new Cs(t,1))}this._geometryInitialized=!0}}_validateGeometry(t){const e=this.geometry;if(Boolean(t.getIndex())!==Boolean(e.getIndex()))throw new Error('BatchedMesh: All geometries must consistently have "index".');for(const n in e.attributes){if(!t.hasAttribute(n))throw new Error(`BatchedMesh: Added geometry missing "${n}". All geometries must have consistent attributes.`);const i=t.getAttribute(n),r=e.getAttribute(n);if(i.itemSize!==r.itemSize||i.normalized!==r.normalized)throw new Error("BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}setCustomSort(t){return this.customSort=t,this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new ji);const t=this.boundingBox,e=this._instanceInfo;t.makeEmpty();for(let n=0,i=e.length;n=this.maxInstanceCount&&0===this._availableInstanceIds.length)throw new Error("BatchedMesh: Maximum item count reached.");const e={visible:!0,active:!0,geometryIndex:t};let n=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(lh),n=this._availableInstanceIds.shift(),this._instanceInfo[n]=e):(n=this._instanceInfo.length,this._instanceInfo.push(e));const i=this._matricesTexture;dh.identity().toArray(i.image.data,16*n),i.needsUpdate=!0;const r=this._colorsTexture;return r&&(ph.toArray(r.image.data,4*n),r.needsUpdate=!0),this._visibilityChanged=!0,n}addGeometry(t,e=-1,n=-1){this._initializeGeometry(t),this._validateGeometry(t);const i={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},r=this._geometryInfo;i.vertexStart=this._nextVertexStart,i.reservedVertexCount=-1===e?t.getAttribute("position").count:e;const s=t.getIndex();if(null!==s&&(i.indexStart=this._nextIndexStart,i.reservedIndexCount=-1===n?s.count:n),-1!==i.indexStart&&i.indexStart+i.reservedIndexCount>this._maxIndexCount||i.vertexStart+i.reservedVertexCount>this._maxVertexCount)throw new Error("BatchedMesh: Reserved space request exceeds the maximum buffer size.");let a;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(lh),a=this._availableGeometryIds.shift(),r[a]=i):(a=this._geometryCount,this._geometryCount++,r.push(i)),this.setGeometryAt(a,t),this._nextIndexStart=i.indexStart+i.reservedIndexCount,this._nextVertexStart=i.vertexStart+i.reservedVertexCount,a}setGeometryAt(t,e){if(t>=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(e);const n=this.geometry,i=null!==n.getIndex(),r=n.getIndex(),s=e.getIndex(),a=this._geometryInfo[t];if(i&&s.count>a.reservedIndexCount||e.attributes.position.count>a.reservedVertexCount)throw new Error("BatchedMesh: Reserved space not large enough for provided geometry.");const o=a.vertexStart,l=a.reservedVertexCount;a.vertexCount=e.getAttribute("position").count;for(const t in n.attributes){const i=e.getAttribute(t),r=n.getAttribute(t);Ch(i,r,o);const s=i.itemSize;for(let t=i.count,e=l;t=e.length||!1===e[t].active)return this;const n=this._instanceInfo;for(let e=0,i=n.length;e=e.length||!1===e[t].active||(e[t].active=!1,this._availableInstanceIds.push(t),this._visibilityChanged=!0),this}optimize(){let t=0,e=0;const n=this._geometryInfo,i=n.map(((t,e)=>e)).sort(((t,e)=>n[t].vertexStart-n[e].vertexStart)),r=this.geometry;for(let s=0,a=n.length;s=this._geometryCount)return null;const n=this.geometry,i=this._geometryInfo[t];if(null===i.boundingBox){const t=new ji,e=n.index,r=n.attributes.position;for(let n=i.start,s=i.start+i.count;n=this._geometryCount)return null;const n=this.geometry,i=this._geometryInfo[t];if(null===i.boundingSphere){const e=new hr;this.getBoundingBoxAt(t,mh),mh.getCenter(e.center);const r=n.index,s=n.attributes.position;let a=0;for(let t=i.start,n=i.start+i.count;t=n.length||!1===n[t].active||(e.toArray(r,16*t),i.needsUpdate=!0),this}getMatrixAt(t,e){const n=this._instanceInfo,i=this._matricesTexture.image.data;return t>=n.length||!1===n[t].active?null:e.fromArray(i,16*t)}setColorAt(t,e){null===this._colorsTexture&&this._initColorsTexture();const n=this._colorsTexture,i=this._colorsTexture.image.data,r=this._instanceInfo;return t>=r.length||!1===r[t].active||(e.toArray(i,4*t),n.needsUpdate=!0),this}getColorAt(t,e){const n=this._colorsTexture.image.data,i=this._instanceInfo;return t>=i.length||!1===i[t].active?null:e.fromArray(n,4*t)}setVisibleAt(t,e){const n=this._instanceInfo;return t>=n.length||!1===n[t].active||n[t].visible===e||(n[t].visible=e,this._visibilityChanged=!0),this}getVisibleAt(t){const e=this._instanceInfo;return!(t>=e.length||!1===e[t].active)&&e[t].visible}setGeometryIdAt(t,e){const n=this._instanceInfo,i=this._geometryInfo;return t>=n.length||!1===n[t].active||e>=i.length||!1===i[e].active?null:(n[t].geometryIndex=e,this)}getGeometryIdAt(t){const e=this._instanceInfo;return t>=e.length||!1===e[t].active?-1:e[t].geometryIndex}getGeometryRangeAt(t,e={}){if(t<0||t>=this._geometryCount)return null;const n=this._geometryInfo[t];return e.vertexStart=n.vertexStart,e.vertexCount=n.vertexCount,e.reservedVertexCount=n.reservedVertexCount,e.indexStart=n.indexStart,e.indexCount=n.indexCount,e.reservedIndexCount=n.reservedIndexCount,e.start=n.start,e.count=n.count,e}setInstanceCount(t){const e=this._availableInstanceIds,n=this._instanceInfo;for(e.sort(lh);e[e.length-1]===n.length;)n.pop(),e.pop();if(tt.active));if(Math.max(...n.map((t=>t.vertexStart+t.reservedVertexCount)))>t)throw new Error(`BatchedMesh: Geometry vertex values are being used outside the range ${e}. Cannot shrink further.`);if(this.geometry.index&&Math.max(...n.map((t=>t.indexStart+t.reservedIndexCount)))>e)throw new Error(`BatchedMesh: Geometry index values are being used outside the range ${e}. Cannot shrink further.`);const i=this.geometry;i.dispose(),this._maxVertexCount=t,this._maxIndexCount=e,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new Qs,this._initializeGeometry(i));const r=this.geometry;i.index&&Eh(i.index.array,r.index.array);for(const t in i.attributes)Eh(i.attributes[t].array,r.attributes[t].array)}raycast(t,e){const n=this._instanceInfo,i=this._geometryInfo,r=this.matrixWorld,s=this.geometry;_h.material=this.material,_h.geometry.index=s.index,_h.geometry.attributes=s.attributes,null===_h.geometry.boundingBox&&(_h.geometry.boundingBox=new ji),null===_h.geometry.boundingSphere&&(_h.geometry.boundingSphere=new hr);for(let s=0,a=n.length;s({...t,boundingBox:null!==t.boundingBox?t.boundingBox.clone():null,boundingSphere:null!==t.boundingSphere?t.boundingSphere.clone():null}))),this._instanceInfo=t._instanceInfo.map((t=>({...t}))),this._maxInstanceCount=t._maxInstanceCount,this._maxVertexCount=t._maxVertexCount,this._maxIndexCount=t._maxIndexCount,this._geometryInitialized=t._geometryInitialized,this._geometryCount=t._geometryCount,this._multiDrawCounts=t._multiDrawCounts.slice(),this._multiDrawStarts=t._multiDrawStarts.slice(),this._matricesTexture=t._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),null!==this._colorsTexture&&(this._colorsTexture=t._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,null!==this._colorsTexture&&(this._colorsTexture.dispose(),this._colorsTexture=null),this}onBeforeRender(t,e,n,i,r){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const s=i.getIndex(),a=null===s?1:s.array.BYTES_PER_ELEMENT,o=this._instanceInfo,l=this._multiDrawStarts,c=this._multiDrawCounts,h=this._geometryInfo,u=this.perObjectFrustumCulled,d=this._indirectTexture,p=d.image.data;u&&(dh.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse).multiply(this.matrixWorld),fh.setFromProjectionMatrix(dh,t.coordinateSystem));let f=0;if(this.sortObjects){dh.copy(this.matrixWorld).invert(),Ah.setFromMatrixPosition(n.matrixWorld).applyMatrix4(dh),vh.set(0,0,-1).transformDirection(n.matrixWorld).transformDirection(dh);for(let t=0,e=o.length;t0){const n=t[e[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=n.length;ti)return;Dh.applyMatrix4(t.matrixWorld);const o=e.ray.origin.distanceTo(Dh);return oe.far?void 0:{distance:o,point:Ph.clone().applyMatrix4(t.matrixWorld),index:r,face:null,faceIndex:null,barycoord:null,object:t}}const Nh=new Hi,Fh=new Hi;class Oh extends Lh{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const t=this.geometry;if(null===t.index){const e=t.attributes.position,n=[];for(let t=0,i=e.count;t0){const n=t[e[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=n.length;tr.far)return;s.push({distance:l,distanceToRay:Math.sqrt(o),point:n,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class qh extends Li{constructor(t,e,n,i,r,s,a,o,l){super(t,e,n,i,r,s,a,o,l),this.isVideoTexture=!0,this.minFilter=void 0!==s?s:Ut,this.magFilter=void 0!==r?r:Ut,this.generateMipmaps=!1;const c=this;"requestVideoFrameCallback"in t&&t.requestVideoFrameCallback((function e(){c.needsUpdate=!0,t.requestVideoFrameCallback(e)}))}clone(){return new this.constructor(this.image).copy(this)}update(){const t=this.image;!1=="requestVideoFrameCallback"in t&&t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class Xh extends Li{constructor(t,e){super({width:t,height:e}),this.isFramebufferTexture=!0,this.magFilter=Bt,this.minFilter=Bt,this.generateMipmaps=!1,this.needsUpdate=!0}}class Yh extends Li{constructor(t,e,n,i,r,s,a,o,l,c,h,u){super(null,s,a,o,l,c,i,r,h,u),this.isCompressedTexture=!0,this.image={width:e,height:n},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}}class Jh extends Yh{constructor(t,e,n,i,r,s){super(t,e,n,r,s),this.isCompressedArrayTexture=!0,this.image.depth=i,this.wrapR=It,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}}class Kh extends Yh{constructor(t,e,n){super(void 0,t[0].width,t[0].height,e,n,wt),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=t}}class Zh extends Li{constructor(t,e,n,i,r,s,a,o,l){super(t,e,n,i,r,s,a,o,l),this.isCanvasTexture=!0,this.needsUpdate=!0}}class $h{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(t,e){const n=this.getUtoTmapping(t);return this.getPoint(n,e)}getPoints(t=5){const e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return e}getSpacedPoints(t=5){const e=[];for(let n=0;n<=t;n++)e.push(this.getPointAt(n/t));return e}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const e=[];let n,i=this.getPoint(0),r=0;e.push(0);for(let s=1;s<=t;s++)n=this.getPoint(s/t),r+=n.distanceTo(i),e.push(r),i=n;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e){const n=this.getLengths();let i=0;const r=n.length;let s;s=e||t*n[r-1];let a,o=0,l=r-1;for(;o<=l;)if(i=Math.floor(o+(l-o)/2),a=n[i]-s,a<0)o=i+1;else{if(!(a>0)){l=i;break}l=i-1}if(i=l,n[i]===s)return i/(r-1);const c=n[i];return(i+(s-c)/(n[i+1]-c))/(r-1)}getTangent(t,e){const n=1e-4;let i=t-n,r=t+n;i<0&&(i=0),r>1&&(r=1);const s=this.getPoint(i),a=this.getPoint(r),o=e||(s.isVector2?new hi:new Hi);return o.copy(a).sub(s).normalize(),o}getTangentAt(t,e){const n=this.getUtoTmapping(t);return this.getTangent(n,e)}computeFrenetFrames(t,e){const n=new Hi,i=[],r=[],s=[],a=new Hi,o=new yr;for(let e=0;e<=t;e++){const n=e/t;i[e]=this.getTangentAt(n,new Hi)}r[0]=new Hi,s[0]=new Hi;let l=Number.MAX_VALUE;const c=Math.abs(i[0].x),h=Math.abs(i[0].y),u=Math.abs(i[0].z);c<=l&&(l=c,n.set(1,0,0)),h<=l&&(l=h,n.set(0,1,0)),u<=l&&n.set(0,0,1),a.crossVectors(i[0],n).normalize(),r[0].crossVectors(i[0],a),s[0].crossVectors(i[0],r[0]);for(let e=1;e<=t;e++){if(r[e]=r[e-1].clone(),s[e]=s[e-1].clone(),a.crossVectors(i[e-1],i[e]),a.length()>Number.EPSILON){a.normalize();const t=Math.acos(ri(i[e-1].dot(i[e]),-1,1));r[e].applyMatrix4(o.makeRotationAxis(a,t))}s[e].crossVectors(i[e],r[e])}if(!0===e){let e=Math.acos(ri(r[0].dot(r[t]),-1,1));e/=t,i[0].dot(a.crossVectors(r[0],r[t]))>0&&(e=-e);for(let n=1;n<=t;n++)r[n].applyMatrix4(o.makeRotationAxis(i[n],e*n)),s[n].crossVectors(i[n],r[n])}return{tangents:i,normals:r,binormals:s}}clone(){return(new this.constructor).copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){const t={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}}class tu extends $h{constructor(t=0,e=0,n=1,i=1,r=0,s=2*Math.PI,a=!1,o=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=n,this.yRadius=i,this.aStartAngle=r,this.aEndAngle=s,this.aClockwise=a,this.aRotation=o}getPoint(t,e=new hi){const n=e,i=2*Math.PI;let r=this.aEndAngle-this.aStartAngle;const s=Math.abs(r)i;)r-=i;r0?0:(Math.floor(Math.abs(l)/r)+1)*r:0===c&&l===r-1&&(l=r-2,c=1),this.closed||l>0?a=i[(l-1)%r]:(iu.subVectors(i[0],i[1]).add(i[0]),a=iu);const h=i[l%r],u=i[(l+1)%r];if(this.closed||l+2i.length-2?i.length-1:s+1],h=i[s>i.length-3?i.length-1:s+2];return n.set(lu(a,o.x,l.x,c.x,h.x),lu(a,o.y,l.y,c.y,h.y)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e=n){const t=i[r]-n,s=this.curves[r],a=s.getLength(),o=0===a?0:1-t/a;return s.getPointAt(o,e)}r++}return null}getLength(){const t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const t=[];let e=0;for(let n=0,i=this.curves.length;n1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,n=t.curves.length;e0){const t=l.getPoint(0);t.equals(this.currentPoint)||this.lineTo(t.x,t.y)}this.curves.push(l);const c=l.getPoint(1);return this.currentPoint.copy(c),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){const t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}}class _u extends Qs{constructor(t=[new hi(0,-.5),new hi(.5,0),new hi(0,.5)],e=12,n=0,i=2*Math.PI){super(),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:n,phiLength:i},e=Math.floor(e),i=ri(i,0,2*Math.PI);const r=[],s=[],a=[],o=[],l=[],c=1/e,h=new Hi,u=new hi,d=new Hi,p=new Hi,f=new Hi;let m=0,g=0;for(let e=0;e<=t.length-1;e++)switch(e){case 0:m=t[e+1].x-t[e].x,g=t[e+1].y-t[e].y,d.x=1*g,d.y=-m,d.z=0*g,f.copy(d),d.normalize(),o.push(d.x,d.y,d.z);break;case t.length-1:o.push(f.x,f.y,f.z);break;default:m=t[e+1].x-t[e].x,g=t[e+1].y-t[e].y,d.x=1*g,d.y=-m,d.z=0*g,p.copy(d),d.x+=f.x,d.y+=f.y,d.z+=f.z,d.normalize(),o.push(d.x,d.y,d.z),f.copy(p)}for(let r=0;r<=e;r++){const d=n+r*c*i,p=Math.sin(d),f=Math.cos(d);for(let n=0;n<=t.length-1;n++){h.x=t[n].x*p,h.y=t[n].y,h.z=t[n].x*f,s.push(h.x,h.y,h.z),u.x=r/e,u.y=n/(t.length-1),a.push(u.x,u.y);const i=o[3*n+0]*p,c=o[3*n+1],d=o[3*n+0]*f;l.push(i,c,d)}}for(let n=0;n0||0!==i)&&(c.push(s,a,l),v+=3),(e>0||i!==r-1)&&(c.push(a,o,l),v+=3)}l.addGroup(g,v,0),g+=v}(),!1===s&&(t>0&&A(!0),e>0&&A(!1)),this.setIndex(c),this.setAttribute("position",new Ds(h,3)),this.setAttribute("normal",new Ds(u,3)),this.setAttribute("uv",new Ds(d,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Eu(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class Mu extends Eu{constructor(t=1,e=1,n=32,i=1,r=!1,s=0,a=2*Math.PI){super(0,t,e,n,i,r,s,a),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:n,heightSegments:i,openEnded:r,thetaStart:s,thetaLength:a}}static fromJSON(t){return new Mu(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class bu extends Qs{constructor(t=[],e=[],n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:n,detail:i};const r=[],s=[];function a(t,e,n,i){const r=i+1,s=[];for(let i=0;i<=r;i++){s[i]=[];const a=t.clone().lerp(n,i/r),o=e.clone().lerp(n,i/r),l=r-i;for(let t=0;t<=l;t++)s[i][t]=0===t&&i===r?a:a.clone().lerp(o,t/l)}for(let t=0;t.9&&a<.1&&(e<.2&&(s[t+0]+=1),n<.2&&(s[t+2]+=1),i<.2&&(s[t+4]+=1))}}()}(),this.setAttribute("position",new Ds(r,3)),this.setAttribute("normal",new Ds(r.slice(),3)),this.setAttribute("uv",new Ds(s,2)),0===i?this.computeVertexNormals():this.normalizeNormals()}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new bu(t.vertices,t.indices,t.radius,t.details)}}class Su extends bu{constructor(t=1,e=0){const n=(1+Math.sqrt(5))/2,i=1/n;super([-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-i,-n,0,-i,n,0,i,-n,0,i,n,-i,-n,0,-i,n,0,i,-n,0,i,n,0,-n,0,-i,n,0,-i,-n,0,i,n,0,i],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],t,e),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new Su(t.radius,t.detail)}}const Iu=new Hi,Tu=new Hi,Bu=new Hi,Ru=new as;class Du extends Qs{constructor(t=null,e=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:t,thresholdAngle:e},null!==t){const n=4,i=Math.pow(10,n),r=Math.cos(ei*e),s=t.getIndex(),a=t.getAttribute("position"),o=s?s.count:a.count,l=[0,0,0],c=["a","b","c"],h=new Array(3),u={},d=[];for(let t=0;t0)for(s=e;s=e;s-=i)a=ed(s,t[s],t[s+1],a);return a&&Yu(a,a.next)&&(nd(a),a=a.next),a}function Uu(t,e){if(!t)return t;e||(e=t);let n,i=t;do{if(n=!1,i.steiner||!Yu(i,i.next)&&0!==Xu(i.prev,i,i.next))i=i.next;else{if(nd(i),i=e=i.prev,i===i.next)break;n=!0}}while(n||i!==e);return e}function Nu(t,e,n,i,r,s,a){if(!t)return;!a&&s&&function(t,e,n,i){let r=t;do{0===r.z&&(r.z=Vu(r.x,r.y,e,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,function(t){let e,n,i,r,s,a,o,l,c=1;do{for(n=t,t=null,s=null,a=0;n;){for(a++,i=n,o=0,e=0;e0||l>0&&i;)0!==o&&(0===l||!i||n.z<=i.z)?(r=n,n=n.nextZ,o--):(r=i,i=i.nextZ,l--),s?s.nextZ=r:t=r,r.prevZ=s,s=r;n=i}s.nextZ=null,c*=2}while(a>1)}(r)}(t,i,r,s);let o,l,c=t;for(;t.prev!==t.next;)if(o=t.prev,l=t.next,s?Ou(t,i,r,s):Fu(t))e.push(o.i/n|0),e.push(t.i/n|0),e.push(l.i/n|0),nd(t),t=l.next,c=l.next;else if((t=l)===c){a?1===a?Nu(t=ku(Uu(t),e,n),e,n,i,r,s,2):2===a&&Qu(t,e,n,i,r,s):Nu(Uu(t),e,n,i,r,s,1);break}}function Fu(t){const e=t.prev,n=t,i=t.next;if(Xu(e,n,i)>=0)return!1;const r=e.x,s=n.x,a=i.x,o=e.y,l=n.y,c=i.y,h=rs?r>a?r:a:s>a?s:a,p=o>l?o>c?o:c:l>c?l:c;let f=i.next;for(;f!==e;){if(f.x>=h&&f.x<=d&&f.y>=u&&f.y<=p&&ju(r,o,s,l,a,c,f.x,f.y)&&Xu(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function Ou(t,e,n,i){const r=t.prev,s=t,a=t.next;if(Xu(r,s,a)>=0)return!1;const o=r.x,l=s.x,c=a.x,h=r.y,u=s.y,d=a.y,p=ol?o>c?o:c:l>c?l:c,g=h>u?h>d?h:d:u>d?u:d,A=Vu(p,f,e,n,i),v=Vu(m,g,e,n,i);let y=t.prevZ,x=t.nextZ;for(;y&&y.z>=A&&x&&x.z<=v;){if(y.x>=p&&y.x<=m&&y.y>=f&&y.y<=g&&y!==r&&y!==a&&ju(o,h,l,u,c,d,y.x,y.y)&&Xu(y.prev,y,y.next)>=0)return!1;if(y=y.prevZ,x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==r&&x!==a&&ju(o,h,l,u,c,d,x.x,x.y)&&Xu(x.prev,x,x.next)>=0)return!1;x=x.nextZ}for(;y&&y.z>=A;){if(y.x>=p&&y.x<=m&&y.y>=f&&y.y<=g&&y!==r&&y!==a&&ju(o,h,l,u,c,d,y.x,y.y)&&Xu(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;x&&x.z<=v;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==r&&x!==a&&ju(o,h,l,u,c,d,x.x,x.y)&&Xu(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function ku(t,e,n){let i=t;do{const r=i.prev,s=i.next.next;!Yu(r,s)&&Ju(r,i,i.next,s)&&$u(r,s)&&$u(s,r)&&(e.push(r.i/n|0),e.push(i.i/n|0),e.push(s.i/n|0),nd(i),nd(i.next),i=t=s),i=i.next}while(i!==t);return Uu(i)}function Qu(t,e,n,i,r,s){let a=t;do{let t=a.next.next;for(;t!==a.prev;){if(a.i!==t.i&&qu(a,t)){let o=td(a,t);return a=Uu(a,a.next),o=Uu(o,o.next),Nu(a,e,n,i,r,s,0),void Nu(o,e,n,i,r,s,0)}t=t.next}a=a.next}while(a!==t)}function zu(t,e){return t.x-e.x}function Gu(t,e){const n=function(t,e){let n,i=e,r=-1/0;const s=t.x,a=t.y;do{if(a<=i.y&&a>=i.next.y&&i.next.y!==i.y){const t=i.x+(a-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(t<=s&&t>r&&(r=t,n=i.x=i.x&&i.x>=l&&s!==i.x&&ju(an.x||i.x===n.x&&Hu(n,i)))&&(n=i,u=h)),i=i.next}while(i!==o);return n}(t,e);if(!n)return e;const i=td(n,t);return Uu(i,i.next),Uu(n,n.next)}function Hu(t,e){return Xu(t.prev,t,e.prev)<0&&Xu(e.next,t,t.next)<0}function Vu(t,e,n,i,r){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-i)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Wu(t){let e=t,n=t;do{(e.x=(t-a)*(s-o)&&(t-a)*(i-o)>=(n-a)*(e-o)&&(n-a)*(s-o)>=(r-a)*(i-o)}function qu(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&Ju(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}(t,e)&&($u(t,e)&&$u(e,t)&&function(t,e){let n=t,i=!1;const r=(t.x+e.x)/2,s=(t.y+e.y)/2;do{n.y>s!=n.next.y>s&&n.next.y!==n.y&&r<(n.next.x-n.x)*(s-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next}while(n!==t);return i}(t,e)&&(Xu(t.prev,t,e.prev)||Xu(t,e.prev,e))||Yu(t,e)&&Xu(t.prev,t,t.next)>0&&Xu(e.prev,e,e.next)>0)}function Xu(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function Yu(t,e){return t.x===e.x&&t.y===e.y}function Ju(t,e,n,i){const r=Zu(Xu(t,e,n)),s=Zu(Xu(t,e,i)),a=Zu(Xu(n,i,t)),o=Zu(Xu(n,i,e));return r!==s&&a!==o||!(0!==r||!Ku(t,n,e))||!(0!==s||!Ku(t,i,e))||!(0!==a||!Ku(n,t,i))||!(0!==o||!Ku(n,e,i))}function Ku(t,e,n){return e.x<=Math.max(t.x,n.x)&&e.x>=Math.min(t.x,n.x)&&e.y<=Math.max(t.y,n.y)&&e.y>=Math.min(t.y,n.y)}function Zu(t){return t>0?1:t<0?-1:0}function $u(t,e){return Xu(t.prev,t,t.next)<0?Xu(t,e,t.next)>=0&&Xu(t,t.prev,e)>=0:Xu(t,e,t.prev)<0||Xu(t,t.next,e)<0}function td(t,e){const n=new id(t.i,t.x,t.y),i=new id(e.i,e.x,e.y),r=t.next,s=e.prev;return t.next=e,e.prev=t,n.next=r,r.prev=n,i.next=n,n.prev=i,s.next=i,i.prev=s,i}function ed(t,e,n,i){const r=new id(t,e,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function nd(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function id(t,e,n){this.i=t,this.x=e,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}class rd{static area(t){const e=t.length;let n=0;for(let i=e-1,r=0;r80*n){o=c=t[0],l=h=t[1];for(let e=n;ec&&(c=u),d>h&&(h=d);p=Math.max(c-o,h-l),p=0!==p?32767/p:0}return Nu(s,a,n,o,l,p,0),a}(n,i);for(let t=0;t2&&t[e-1].equals(t[0])&&t.pop()}function ad(t,e){for(let n=0;nNumber.EPSILON){const u=Math.sqrt(h),d=Math.sqrt(l*l+c*c),p=e.x-o/u,f=e.y+a/u,m=((n.x-c/d-p)*c-(n.y+l/d-f)*l)/(a*c-o*l);i=p+a*m-t.x,r=f+o*m-t.y;const g=i*i+r*r;if(g<=2)return new hi(i,r);s=Math.sqrt(g/2)}else{let t=!1;a>Number.EPSILON?l>Number.EPSILON&&(t=!0):a<-Number.EPSILON?l<-Number.EPSILON&&(t=!0):Math.sign(o)===Math.sign(c)&&(t=!0),t?(i=-o,r=a,s=Math.sqrt(h)):(i=a,r=o,s=Math.sqrt(h/2))}return new hi(i/s,r/s)}const R=[];for(let t=0,e=b.length,n=e-1,i=t+1;t=0;t--){const e=t/p,n=h*Math.cos(e*Math.PI/2),i=u*Math.sin(e*Math.PI/2)+d;for(let t=0,e=b.length;t=0;){const i=n;let r=n-1;r<0&&(r=t.length-1);for(let t=0,n=o+2*p;t0)&&d.push(e,r,l),(t!==n-1||o0!=t>0&&this.version++,this._anisotropy=t}get clearcoat(){return this._clearcoat}set clearcoat(t){this._clearcoat>0!=t>0&&this.version++,this._clearcoat=t}get iridescence(){return this._iridescence}set iridescence(t){this._iridescence>0!=t>0&&this.version++,this._iridescence=t}get dispersion(){return this._dispersion}set dispersion(t){this._dispersion>0!=t>0&&this.version++,this._dispersion=t}get sheen(){return this._sheen}set sheen(t){this._sheen>0!=t>0&&this.version++,this._sheen=t}get transmission(){return this._transmission}set transmission(t){this._transmission>0!=t>0&&this.version++,this._transmission=t}copy(t){return super.copy(t),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=t.anisotropy,this.anisotropyRotation=t.anisotropyRotation,this.anisotropyMap=t.anisotropyMap,this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.dispersion=t.dispersion,this.ior=t.ior,this.iridescence=t.iridescence,this.iridescenceMap=t.iridescenceMap,this.iridescenceIOR=t.iridescenceIOR,this.iridescenceThicknessRange=[...t.iridescenceThicknessRange],this.iridescenceThicknessMap=t.iridescenceThicknessMap,this.sheen=t.sheen,this.sheenColor.copy(t.sheenColor),this.sheenColorMap=t.sheenColorMap,this.sheenRoughness=t.sheenRoughness,this.sheenRoughnessMap=t.sheenRoughnessMap,this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this.thickness=t.thickness,this.thicknessMap=t.thicknessMap,this.attenuationDistance=t.attenuationDistance,this.attenuationColor.copy(t.attenuationColor),this.specularIntensity=t.specularIntensity,this.specularIntensityMap=t.specularIntensityMap,this.specularColor.copy(t.specularColor),this.specularColorMap=t.specularColorMap,this}}class Md extends fs{static get type(){return"MeshPhongMaterial"}constructor(t){super(),this.isMeshPhongMaterial=!0,this.color=new us(16777215),this.specular=new us(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new us(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ln,this.normalScale=new hi(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Tr,this.combine=lt,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.specular.copy(t.specular),this.shininess=t.shininess,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class bd extends fs{static get type(){return"MeshToonMaterial"}constructor(t){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.color=new us(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new us(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ln,this.normalScale=new hi(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.gradientMap=t.gradientMap,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}class Sd extends fs{static get type(){return"MeshNormalMaterial"}constructor(t){super(),this.isMeshNormalMaterial=!0,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ln,this.normalScale=new hi(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(t)}copy(t){return super.copy(t),this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.flatShading=t.flatShading,this}}class Id extends fs{static get type(){return"MeshLambertMaterial"}constructor(t){super(),this.isMeshLambertMaterial=!0,this.color=new us(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new us(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ln,this.normalScale=new hi(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Tr,this.combine=lt,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class Td extends fs{static get type(){return"MeshMatcapMaterial"}constructor(t){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.color=new us(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ln,this.normalScale=new hi(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={MATCAP:""},this.color.copy(t.color),this.matcap=t.matcap,this.map=t.map,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.flatShading=t.flatShading,this.fog=t.fog,this}}class Bd extends bh{static get type(){return"LineDashedMaterial"}constructor(t){super(),this.isLineDashedMaterial=!0,this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(t)}copy(t){return super.copy(t),this.scale=t.scale,this.dashSize=t.dashSize,this.gapSize=t.gapSize,this}}function Rd(t,e,n){return!t||!n&&t.constructor===e?t:"number"==typeof e.BYTES_PER_ELEMENT?new e(t):Array.prototype.slice.call(t)}function Dd(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Pd(t){const e=t.length,n=new Array(e);for(let t=0;t!==e;++t)n[t]=t;return n.sort((function(e,n){return t[e]-t[n]})),n}function Ld(t,e,n){const i=t.length,r=new t.constructor(i);for(let s=0,a=0;a!==i;++s){const i=n[s]*e;for(let n=0;n!==e;++n)r[a++]=t[i+n]}return r}function Ud(t,e,n,i){let r=1,s=t[0];for(;void 0!==s&&void 0===s[i];)s=t[r++];if(void 0===s)return;let a=s[i];if(void 0!==a)if(Array.isArray(a))do{a=s[i],void 0!==a&&(e.push(s.time),n.push.apply(n,a)),s=t[r++]}while(void 0!==s);else if(void 0!==a.toArray)do{a=s[i],void 0!==a&&(e.push(s.time),a.toArray(n,n.length)),s=t[r++]}while(void 0!==s);else do{a=s[i],void 0!==a&&(e.push(s.time),n.push(a)),s=t[r++]}while(void 0!==s)}const Nd={convertArray:Rd,isTypedArray:Dd,getKeyframeOrder:Pd,sortedArray:Ld,flattenJSON:Ud,subclip:function(t,e,n,i,r=30){const s=t.clone();s.name=e;const a=[];for(let t=0;t=i)){l.push(e.times[t]);for(let n=0;ns.tracks[t].times[0]&&(o=s.tracks[t].times[0]);for(let t=0;t=i.times[u]){const t=u*l+o,e=t+l-o;d=i.values.slice(t,e)}else{const t=i.createInterpolant(),e=o,n=l-o;t.evaluate(s),d=t.resultBuffer.slice(e,n)}"quaternion"===r&&(new Gi).fromArray(d).normalize().conjugate().toArray(d);const p=a.times.length;for(let t=0;t=r)break t;{const a=e[1];t=r)break e}s=n,n=0}}for(;n>>1;te;)--s;if(++s,0!==r||s!==i){r>=s&&(s=Math.max(s,1),r=s-1);const t=this.getValueSize();this.times=n.slice(r,s),this.values=this.values.slice(r*t,s*t)}return this}validate(){let t=!0;const e=this.getValueSize();e-Math.floor(e)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);const n=this.times,i=this.values,r=n.length;0===r&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let s=null;for(let e=0;e!==r;e++){const i=n[e];if("number"==typeof i&&isNaN(i)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,e,i),t=!1;break}if(null!==s&&s>i){console.error("THREE.KeyframeTrack: Out of order keys.",this,e,i,s),t=!1;break}s=i}if(void 0!==i&&Dd(i))for(let e=0,n=i.length;e!==n;++e){const n=i[e];if(isNaN(n)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,e,n),t=!1;break}}return t}optimize(){const t=this.times.slice(),e=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===Xe,r=t.length-1;let s=1;for(let a=1;a0){t[s]=t[r];for(let t=r*n,i=s*n,a=0;a!==n;++a)e[i+a]=e[t+a];++s}return s!==t.length?(this.times=t.slice(0,s),this.values=e.slice(0,s*n)):(this.times=t,this.values=e),this}clone(){const t=this.times.slice(),e=this.values.slice(),n=new(0,this.constructor)(this.name,t,e);return n.createInterpolant=this.createInterpolant,n}}zd.prototype.TimeBufferType=Float32Array,zd.prototype.ValueBufferType=Float32Array,zd.prototype.DefaultInterpolation=qe;class Gd extends zd{constructor(t,e,n){super(t,e,n)}}Gd.prototype.ValueTypeName="bool",Gd.prototype.ValueBufferType=Array,Gd.prototype.DefaultInterpolation=je,Gd.prototype.InterpolantFactoryMethodLinear=void 0,Gd.prototype.InterpolantFactoryMethodSmooth=void 0;class Hd extends zd{}Hd.prototype.ValueTypeName="color";class Vd extends zd{}Vd.prototype.ValueTypeName="number";class Wd extends Fd{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){const r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=(n-e)/(i-e);let l=t*a;for(let t=l+a;l!==t;l+=4)Gi.slerpFlat(r,0,s,l-a,s,l,o);return r}}class jd extends zd{InterpolantFactoryMethodLinear(t){return new Wd(this.times,this.values,this.getValueSize(),t)}}jd.prototype.ValueTypeName="quaternion",jd.prototype.InterpolantFactoryMethodSmooth=void 0;class qd extends zd{constructor(t,e,n){super(t,e,n)}}qd.prototype.ValueTypeName="string",qd.prototype.ValueBufferType=Array,qd.prototype.DefaultInterpolation=je,qd.prototype.InterpolantFactoryMethodLinear=void 0,qd.prototype.InterpolantFactoryMethodSmooth=void 0;class Xd extends zd{}Xd.prototype.ValueTypeName="vector";class Yd{constructor(t="",e=-1,n=[],i=Ze){this.name=t,this.tracks=n,this.duration=e,this.blendMode=i,this.uuid=ii(),this.duration<0&&this.resetDuration()}static parse(t){const e=[],n=t.tracks,i=1/(t.fps||1);for(let t=0,r=n.length;t!==r;++t)e.push(Jd(n[t]).scale(i));const r=new this(t.name,t.duration,e,t.blendMode);return r.uuid=t.uuid,r}static toJSON(t){const e=[],n=t.tracks,i={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode};for(let t=0,i=n.length;t!==i;++t)e.push(zd.toJSON(n[t]));return i}static CreateFromMorphTargetSequence(t,e,n,i){const r=e.length,s=[];for(let t=0;t1){const t=s[1];let e=i[t];e||(i[t]=e=[]),e.push(n)}}const s=[];for(const t in i)s.push(this.CreateFromMorphTargetSequence(t,i[t],e,n));return s}static parseAnimation(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(t,e,n,i,r){if(0!==n.length){const s=[],a=[];Ud(n,s,a,i),0!==s.length&&r.push(new t(e,s,a))}},i=[],r=t.name||"default",s=t.fps||30,a=t.blendMode;let o=t.length||-1;const l=t.hierarchy||[];for(let t=0;t{e&&e(r),this.manager.itemEnd(t)}),0),r;if(void 0!==ep[t])return void ep[t].push({onLoad:e,onProgress:n,onError:i});ep[t]=[],ep[t].push({onLoad:e,onProgress:n,onError:i});const s=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,o=this.responseType;fetch(s).then((e=>{if(200===e.status||0===e.status){if(0===e.status&&console.warn("THREE.FileLoader: HTTP Status 0 received."),"undefined"==typeof ReadableStream||void 0===e.body||void 0===e.body.getReader)return e;const n=ep[t],i=e.body.getReader(),r=e.headers.get("X-File-Size")||e.headers.get("Content-Length"),s=r?parseInt(r):0,a=0!==s;let o=0;const l=new ReadableStream({start(t){!function e(){i.read().then((({done:i,value:r})=>{if(i)t.close();else{o+=r.byteLength;const i=new ProgressEvent("progress",{lengthComputable:a,loaded:o,total:s});for(let t=0,e=n.length;t{t.error(e)}))}()}});return new Response(l)}throw new np(`fetch for "${e.url}" responded with ${e.status}: ${e.statusText}`,e)})).then((t=>{switch(o){case"arraybuffer":return t.arrayBuffer();case"blob":return t.blob();case"document":return t.text().then((t=>(new DOMParser).parseFromString(t,a)));case"json":return t.json();default:if(void 0===a)return t.text();{const e=/charset="?([^;"\s]*)"?/i.exec(a),n=e&&e[1]?e[1].toLowerCase():void 0,i=new TextDecoder(n);return t.arrayBuffer().then((t=>i.decode(t)))}}})).then((e=>{Kd.add(t,e);const n=ep[t];delete ep[t];for(let t=0,i=n.length;t{const n=ep[t];if(void 0===n)throw this.manager.itemError(t),e;delete ep[t];for(let t=0,i=n.length;t{this.manager.itemEnd(t)})),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}}class rp extends tp{constructor(t){super(t)}load(t,e,n,i){const r=this,s=new ip(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(t,(function(n){try{e(r.parse(JSON.parse(n)))}catch(e){i?i(e):console.error(e),r.manager.itemError(t)}}),n,i)}parse(t){const e=[];for(let n=0;n0:i.vertexColors=t.vertexColors),void 0!==t.uniforms)for(const e in t.uniforms){const r=t.uniforms[e];switch(i.uniforms[e]={},r.type){case"t":i.uniforms[e].value=n(r.value);break;case"c":i.uniforms[e].value=(new us).setHex(r.value);break;case"v2":i.uniforms[e].value=(new hi).fromArray(r.value);break;case"v3":i.uniforms[e].value=(new Hi).fromArray(r.value);break;case"v4":i.uniforms[e].value=(new Ui).fromArray(r.value);break;case"m3":i.uniforms[e].value=(new ui).fromArray(r.value);break;case"m4":i.uniforms[e].value=(new yr).fromArray(r.value);break;default:i.uniforms[e].value=r.value}}if(void 0!==t.defines&&(i.defines=t.defines),void 0!==t.vertexShader&&(i.vertexShader=t.vertexShader),void 0!==t.fragmentShader&&(i.fragmentShader=t.fragmentShader),void 0!==t.glslVersion&&(i.glslVersion=t.glslVersion),void 0!==t.extensions)for(const e in t.extensions)i.extensions[e]=t.extensions[e];if(void 0!==t.lights&&(i.lights=t.lights),void 0!==t.clipping&&(i.clipping=t.clipping),void 0!==t.size&&(i.size=t.size),void 0!==t.sizeAttenuation&&(i.sizeAttenuation=t.sizeAttenuation),void 0!==t.map&&(i.map=n(t.map)),void 0!==t.matcap&&(i.matcap=n(t.matcap)),void 0!==t.alphaMap&&(i.alphaMap=n(t.alphaMap)),void 0!==t.bumpMap&&(i.bumpMap=n(t.bumpMap)),void 0!==t.bumpScale&&(i.bumpScale=t.bumpScale),void 0!==t.normalMap&&(i.normalMap=n(t.normalMap)),void 0!==t.normalMapType&&(i.normalMapType=t.normalMapType),void 0!==t.normalScale){let e=t.normalScale;!1===Array.isArray(e)&&(e=[e,e]),i.normalScale=(new hi).fromArray(e)}return void 0!==t.displacementMap&&(i.displacementMap=n(t.displacementMap)),void 0!==t.displacementScale&&(i.displacementScale=t.displacementScale),void 0!==t.displacementBias&&(i.displacementBias=t.displacementBias),void 0!==t.roughnessMap&&(i.roughnessMap=n(t.roughnessMap)),void 0!==t.metalnessMap&&(i.metalnessMap=n(t.metalnessMap)),void 0!==t.emissiveMap&&(i.emissiveMap=n(t.emissiveMap)),void 0!==t.emissiveIntensity&&(i.emissiveIntensity=t.emissiveIntensity),void 0!==t.specularMap&&(i.specularMap=n(t.specularMap)),void 0!==t.specularIntensityMap&&(i.specularIntensityMap=n(t.specularIntensityMap)),void 0!==t.specularColorMap&&(i.specularColorMap=n(t.specularColorMap)),void 0!==t.envMap&&(i.envMap=n(t.envMap)),void 0!==t.envMapRotation&&i.envMapRotation.fromArray(t.envMapRotation),void 0!==t.envMapIntensity&&(i.envMapIntensity=t.envMapIntensity),void 0!==t.reflectivity&&(i.reflectivity=t.reflectivity),void 0!==t.refractionRatio&&(i.refractionRatio=t.refractionRatio),void 0!==t.lightMap&&(i.lightMap=n(t.lightMap)),void 0!==t.lightMapIntensity&&(i.lightMapIntensity=t.lightMapIntensity),void 0!==t.aoMap&&(i.aoMap=n(t.aoMap)),void 0!==t.aoMapIntensity&&(i.aoMapIntensity=t.aoMapIntensity),void 0!==t.gradientMap&&(i.gradientMap=n(t.gradientMap)),void 0!==t.clearcoatMap&&(i.clearcoatMap=n(t.clearcoatMap)),void 0!==t.clearcoatRoughnessMap&&(i.clearcoatRoughnessMap=n(t.clearcoatRoughnessMap)),void 0!==t.clearcoatNormalMap&&(i.clearcoatNormalMap=n(t.clearcoatNormalMap)),void 0!==t.clearcoatNormalScale&&(i.clearcoatNormalScale=(new hi).fromArray(t.clearcoatNormalScale)),void 0!==t.iridescenceMap&&(i.iridescenceMap=n(t.iridescenceMap)),void 0!==t.iridescenceThicknessMap&&(i.iridescenceThicknessMap=n(t.iridescenceThicknessMap)),void 0!==t.transmissionMap&&(i.transmissionMap=n(t.transmissionMap)),void 0!==t.thicknessMap&&(i.thicknessMap=n(t.thicknessMap)),void 0!==t.anisotropyMap&&(i.anisotropyMap=n(t.anisotropyMap)),void 0!==t.sheenColorMap&&(i.sheenColorMap=n(t.sheenColorMap)),void 0!==t.sheenRoughnessMap&&(i.sheenRoughnessMap=n(t.sheenRoughnessMap)),i}setTextures(t){return this.textures=t,this}createMaterialFromType(t){return Tp.createMaterialFromType(t)}static createMaterialFromType(t){return new{ShadowMaterial:_d,SpriteMaterial:yc,RawShaderMaterial:wd,ShaderMaterial:sa,PointsMaterial:Qh,MeshPhysicalMaterial:Ed,MeshStandardMaterial:Cd,MeshPhongMaterial:Md,MeshToonMaterial:bd,MeshNormalMaterial:Sd,MeshLambertMaterial:Id,MeshDepthMaterial:ql,MeshDistanceMaterial:Xl,MeshBasicMaterial:ms,MeshMatcapMaterial:Td,LineDashedMaterial:Bd,LineBasicMaterial:bh,Material:fs}[t]}}class Bp{static decodeText(t){if(console.warn("THREE.LoaderUtils: decodeText() has been deprecated with r165 and will be removed with r175. Use TextDecoder instead."),"undefined"!=typeof TextDecoder)return(new TextDecoder).decode(t);let e="";for(let n=0,i=t.length;n0){const n=new Zd(e);r=new ap(n),r.setCrossOrigin(this.crossOrigin);for(let e=0,n=t.length;e0){i=new ap(this.manager),i.setCrossOrigin(this.crossOrigin);for(let e=0,i=t.length;e{const e=new ji;e.min.fromArray(t.boxMin),e.max.fromArray(t.boxMax);const n=new hr;return n.radius=t.sphereRadius,n.center.fromArray(t.sphereCenter),{boxInitialized:t.boxInitialized,box:e,sphereInitialized:t.sphereInitialized,sphere:n}})),s._maxInstanceCount=t.maxInstanceCount,s._maxVertexCount=t.maxVertexCount,s._maxIndexCount=t.maxIndexCount,s._geometryInitialized=t.geometryInitialized,s._geometryCount=t.geometryCount,s._matricesTexture=h(t.matricesTexture.uuid),void 0!==t.colorsTexture&&(s._colorsTexture=h(t.colorsTexture.uuid));break;case"LOD":s=new Fc;break;case"Line":s=new Lh(l(t.geometry),c(t.material));break;case"LineLoop":s=new kh(l(t.geometry),c(t.material));break;case"LineSegments":s=new Oh(l(t.geometry),c(t.material));break;case"PointCloud":case"Points":s=new Wh(l(t.geometry),c(t.material));break;case"Sprite":s=new Pc(c(t.material));break;case"Group":s=new ic;break;case"Bone":s=new Xc;break;default:s=new jr}if(s.uuid=t.uuid,void 0!==t.name&&(s.name=t.name),void 0!==t.matrix?(s.matrix.fromArray(t.matrix),void 0!==t.matrixAutoUpdate&&(s.matrixAutoUpdate=t.matrixAutoUpdate),s.matrixAutoUpdate&&s.matrix.decompose(s.position,s.quaternion,s.scale)):(void 0!==t.position&&s.position.fromArray(t.position),void 0!==t.rotation&&s.rotation.fromArray(t.rotation),void 0!==t.quaternion&&s.quaternion.fromArray(t.quaternion),void 0!==t.scale&&s.scale.fromArray(t.scale)),void 0!==t.up&&s.up.fromArray(t.up),void 0!==t.castShadow&&(s.castShadow=t.castShadow),void 0!==t.receiveShadow&&(s.receiveShadow=t.receiveShadow),t.shadow&&(void 0!==t.shadow.intensity&&(s.shadow.intensity=t.shadow.intensity),void 0!==t.shadow.bias&&(s.shadow.bias=t.shadow.bias),void 0!==t.shadow.normalBias&&(s.shadow.normalBias=t.shadow.normalBias),void 0!==t.shadow.radius&&(s.shadow.radius=t.shadow.radius),void 0!==t.shadow.mapSize&&s.shadow.mapSize.fromArray(t.shadow.mapSize),void 0!==t.shadow.camera&&(s.shadow.camera=this.parseObject(t.shadow.camera))),void 0!==t.visible&&(s.visible=t.visible),void 0!==t.frustumCulled&&(s.frustumCulled=t.frustumCulled),void 0!==t.renderOrder&&(s.renderOrder=t.renderOrder),void 0!==t.userData&&(s.userData=t.userData),void 0!==t.layers&&(s.layers.mask=t.layers),void 0!==t.children){const a=t.children;for(let t=0;t{e&&e(n),r.manager.itemEnd(t)})).catch((t=>{i&&i(t)})):(setTimeout((function(){e&&e(s),r.manager.itemEnd(t)}),0),s);const a={};a.credentials="anonymous"===this.crossOrigin?"same-origin":"include",a.headers=this.requestHeader;const o=fetch(t,a).then((function(t){return t.blob()})).then((function(t){return createImageBitmap(t,Object.assign(r.options,{colorSpaceConversion:"none"}))})).then((function(n){return Kd.add(t,n),e&&e(n),r.manager.itemEnd(t),n})).catch((function(e){i&&i(e),Kd.remove(t),r.manager.itemError(t),r.manager.itemEnd(t)}));Kd.add(t,o),r.manager.itemStart(t)}}let Op;class kp{static getContext(){return void 0===Op&&(Op=new(window.AudioContext||window.webkitAudioContext)),Op}static setContext(t){Op=t}}class Qp extends tp{constructor(t){super(t)}load(t,e,n,i){const r=this,s=new ip(this.manager);function a(e){i?i(e):console.error(e),r.manager.itemError(t)}s.setResponseType("arraybuffer"),s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(t,(function(t){try{const n=t.slice(0);kp.getContext().decodeAudioData(n,(function(t){e(t)})).catch(a)}catch(t){a(t)}}),n,i)}}const zp=new yr,Gp=new yr,Hp=new yr;class Vp{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new ha,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new ha,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(t){const e=this._cache;if(e.focus!==t.focus||e.fov!==t.fov||e.aspect!==t.aspect*this.aspect||e.near!==t.near||e.far!==t.far||e.zoom!==t.zoom||e.eyeSep!==this.eyeSep){e.focus=t.focus,e.fov=t.fov,e.aspect=t.aspect*this.aspect,e.near=t.near,e.far=t.far,e.zoom=t.zoom,e.eyeSep=this.eyeSep,Hp.copy(t.projectionMatrix);const n=e.eyeSep/2,i=n*e.near/e.focus,r=e.near*Math.tan(ei*e.fov*.5)/e.zoom;let s,a;Gp.elements[12]=-n,zp.elements[12]=n,s=-r*e.aspect+i,a=r*e.aspect+i,Hp.elements[0]=2*e.near/(a-s),Hp.elements[8]=(a+s)/(a-s),this.cameraL.projectionMatrix.copy(Hp),s=-r*e.aspect-i,a=r*e.aspect-i,Hp.elements[0]=2*e.near/(a-s),Hp.elements[8]=(a+s)/(a-s),this.cameraR.projectionMatrix.copy(Hp)}this.cameraL.matrixWorld.copy(t.matrixWorld).multiply(Gp),this.cameraR.matrixWorld.copy(t.matrixWorld).multiply(zp)}}class Wp{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=jp(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const e=jp();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}}function jp(){return performance.now()}const qp=new Hi,Xp=new Gi,Yp=new Hi,Jp=new Hi;class Kp extends jr{constructor(){super(),this.type="AudioListener",this.context=kp.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new Wp}getInput(){return this.gain}removeFilter(){return null!==this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(t){return null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=t,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}updateMatrixWorld(t){super.updateMatrixWorld(t);const e=this.context.listener,n=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(qp,Xp,Yp),Jp.set(0,0,-1).applyQuaternion(Xp),e.positionX){const t=this.context.currentTime+this.timeDelta;e.positionX.linearRampToValueAtTime(qp.x,t),e.positionY.linearRampToValueAtTime(qp.y,t),e.positionZ.linearRampToValueAtTime(qp.z,t),e.forwardX.linearRampToValueAtTime(Jp.x,t),e.forwardY.linearRampToValueAtTime(Jp.y,t),e.forwardZ.linearRampToValueAtTime(Jp.z,t),e.upX.linearRampToValueAtTime(n.x,t),e.upY.linearRampToValueAtTime(n.y,t),e.upZ.linearRampToValueAtTime(n.z,t)}else e.setPosition(qp.x,qp.y,qp.z),e.setOrientation(Jp.x,Jp.y,Jp.z,n.x,n.y,n.z)}}class Zp extends jr{constructor(t){super(),this.type="Audio",this.listener=t,this.context=t.context,this.gain=this.context.createGain(),this.gain.connect(t.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(t){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=t,this.connect(),this}setMediaElementSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(t),this.connect(),this}setMediaStreamSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(t),this.connect(),this}setBuffer(t){return this.buffer=t,this.sourceType="buffer",this.autoplay&&this.play(),this}play(t=0){if(!0===this.isPlaying)return void console.warn("THREE.Audio: Audio is already playing.");if(!1===this.hasPlaybackControl)return void console.warn("THREE.Audio: this Audio has no playback control.");this._startedAt=this.context.currentTime+t;const e=this.context.createBufferSource();return e.buffer=this.buffer,e.loop=this.loop,e.loopStart=this.loopStart,e.loopEnd=this.loopEnd,e.onended=this.onEnded.bind(this),e.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=e,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(!1!==this.hasPlaybackControl)return!0===this.isPlaying&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,!0===this.loop&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this;console.warn("THREE.Audio: this Audio has no playback control.")}stop(t=0){if(!1!==this.hasPlaybackControl)return this._progress=0,null!==this.source&&(this.source.stop(this.context.currentTime+t),this.source.onended=null),this.isPlaying=!1,this;console.warn("THREE.Audio: this Audio has no playback control.")}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let t=1,e=this.filters.length;t0){this.source.disconnect(this.filters[0]);for(let t=1,e=this.filters.length;t0&&this._mixBufferRegionAdditive(n,i,this._addIndex*e,1,e);for(let t=e,r=e+e;t!==r;++t)if(n[t]!==n[t+e]){a.setValue(n,i);break}}saveOriginalState(){const t=this.binding,e=this.buffer,n=this.valueSize,i=n*this._origIndex;t.getValue(e,i);for(let t=n,r=i;t!==r;++t)e[t]=e[i+t%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const t=3*this.valueSize;this.binding.setValue(this.buffer,t)}_setAdditiveIdentityNumeric(){const t=this._addIndex*this.valueSize,e=t+this.valueSize;for(let n=t;n=.5)for(let i=0;i!==r;++i)t[e+i]=t[n+i]}_slerp(t,e,n,i){Gi.slerpFlat(t,e,t,e,t,n,i)}_slerpAdditive(t,e,n,i,r){const s=this._workIndex*r;Gi.multiplyQuaternionsFlat(t,s,t,e,t,n),Gi.slerpFlat(t,e,t,e,t,s,i)}_lerp(t,e,n,i,r){const s=1-i;for(let a=0;a!==r;++a){const r=e+a;t[r]=t[r]*s+t[n+a]*i}}_lerpAdditive(t,e,n,i,r){for(let s=0;s!==r;++s){const r=e+s;t[r]=t[r]+t[n+s]*i}}}const of="\\[\\]\\.:\\/",lf=new RegExp("["+of+"]","g"),cf="[^"+of+"]",hf="[^"+of.replace("\\.","")+"]",uf=new RegExp("^"+/((?:WC+[\/:])*)/.source.replace("WC",cf)+/(WCOD+)?/.source.replace("WCOD",hf)+/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",cf)+/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",cf)+"$"),df=["material","materials","bones","map"];class pf{constructor(t,e,n){this.path=e,this.parsedPath=n||pf.parseTrackName(e),this.node=pf.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,n){return t&&t.isAnimationObjectGroup?new pf.Composite(t,e,n):new pf(t,e,n)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(lf,"")}static parseTrackName(t){const e=uf.exec(t);if(null===e)throw new Error("PropertyBinding: Cannot parse trackName: "+t);const n={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(void 0!==i&&-1!==i){const t=n.nodeName.substring(i+1);-1!==df.indexOf(t)&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=t)}if(null===n.propertyName||0===n.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return n}static findNode(t,e){if(void 0===e||""===e||"."===e||-1===e||e===t.name||e===t.uuid)return t;if(t.skeleton){const n=t.skeleton.getBoneByName(e);if(void 0!==n)return n}if(t.children){const n=function(t){for(let i=0;i=r){const s=r++,c=t[s];e[c.uuid]=l,t[l]=c,e[o]=s,t[s]=a;for(let t=0,e=i;t!==e;++t){const e=n[t],i=e[s],r=e[l];e[l]=i,e[s]=r}}}this.nCachedObjects_=r}uncache(){const t=this._objects,e=this._indicesByUUID,n=this._bindings,i=n.length;let r=this.nCachedObjects_,s=t.length;for(let a=0,o=arguments.length;a!==o;++a){const o=arguments[a].uuid,l=e[o];if(void 0!==l)if(delete e[o],l0&&(e[a.uuid]=l),t[l]=a,t.pop();for(let t=0,e=i;t!==e;++t){const e=n[t];e[l]=e[r],e.pop()}}}this.nCachedObjects_=r}subscribe_(t,e){const n=this._bindingsIndicesByPath;let i=n[t];const r=this._bindings;if(void 0!==i)return r[i];const s=this._paths,a=this._parsedPaths,o=this._objects,l=o.length,c=this.nCachedObjects_,h=new Array(l);i=r.length,n[t]=i,s.push(t),a.push(e),r.push(h);for(let n=c,i=o.length;n!==i;++n){const i=o[n];h[n]=new pf(i,t,e)}return h}unsubscribe_(t){const e=this._bindingsIndicesByPath,n=e[t];if(void 0!==n){const i=this._paths,r=this._parsedPaths,s=this._bindings,a=s.length-1,o=s[a];e[t[a]]=n,s[n]=o,s.pop(),r[n]=r[a],r.pop(),i[n]=i[a],i.pop()}}}class mf{constructor(t,e,n=null,i=e.blendMode){this._mixer=t,this._clip=e,this._localRoot=n,this.blendMode=i;const r=e.tracks,s=r.length,a=new Array(s),o={endingStart:Ye,endingEnd:Ye};for(let t=0;t!==s;++t){const e=r[t].createInterpolant(null);a[t]=e,e.settings=o}this._interpolantSettings=o,this._interpolants=a,this._propertyBindings=new Array(s),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=Ve,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(t){return this._startTime=t,this}setLoop(t,e){return this.loop=t,this.repetitions=e,this}setEffectiveWeight(t){return this.weight=t,this._effectiveWeight=this.enabled?t:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(t){return this._scheduleFading(t,0,1)}fadeOut(t){return this._scheduleFading(t,1,0)}crossFadeFrom(t,e,n){if(t.fadeOut(e),this.fadeIn(e),n){const n=this._clip.duration,i=t._clip.duration,r=i/n,s=n/i;t.warp(1,r,e),this.warp(s,1,e)}return this}crossFadeTo(t,e,n){return t.crossFadeFrom(this,e,n)}stopFading(){const t=this._weightInterpolant;return null!==t&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}setEffectiveTimeScale(t){return this.timeScale=t,this._effectiveTimeScale=this.paused?0:t,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(t){return this.timeScale=this._clip.duration/t,this.stopWarping()}syncWith(t){return this.time=t.time,this.timeScale=t.timeScale,this.stopWarping()}halt(t){return this.warp(this._effectiveTimeScale,0,t)}warp(t,e,n){const i=this._mixer,r=i.time,s=this.timeScale;let a=this._timeScaleInterpolant;null===a&&(a=i._lendControlInterpolant(),this._timeScaleInterpolant=a);const o=a.parameterPositions,l=a.sampleValues;return o[0]=r,o[1]=r+n,l[0]=t/s,l[1]=e/s,this}stopWarping(){const t=this._timeScaleInterpolant;return null!==t&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(t,e,n,i){if(!this.enabled)return void this._updateWeight(t);const r=this._startTime;if(null!==r){const i=(t-r)*n;i<0||0===n?e=0:(this._startTime=null,e=n*i)}e*=this._updateTimeScale(t);const s=this._updateTime(e),a=this._updateWeight(t);if(a>0){const t=this._interpolants,e=this._propertyBindings;if(this.blendMode===$e)for(let n=0,i=t.length;n!==i;++n)t[n].evaluate(s),e[n].accumulateAdditive(a);else for(let n=0,r=t.length;n!==r;++n)t[n].evaluate(s),e[n].accumulate(i,a)}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;const n=this._weightInterpolant;if(null!==n){const i=n.evaluate(t)[0];e*=i,t>n.parameterPositions[1]&&(this.stopFading(),0===i&&(this.enabled=!1))}}return this._effectiveWeight=e,e}_updateTimeScale(t){let e=0;if(!this.paused){e=this.timeScale;const n=this._timeScaleInterpolant;null!==n&&(e*=n.evaluate(t)[0],t>n.parameterPositions[1]&&(this.stopWarping(),0===e?this.paused=!0:this.timeScale=e))}return this._effectiveTimeScale=e,e}_updateTime(t){const e=this._clip.duration,n=this.loop;let i=this.time+t,r=this._loopCount;const s=n===We;if(0===t)return-1===r||!s||1&~r?i:e-i;if(n===He){-1===r&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(i>=e)i=e;else{if(!(i<0)){this.time=i;break t}i=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(-1===r&&(t>=0?(r=0,this._setEndings(!0,0===this.repetitions,s)):this._setEndings(0===this.repetitions,!0,s)),i>=e||i<0){const n=Math.floor(i/e);i-=e*n,r+=Math.abs(n);const a=this.repetitions-r;if(a<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=t>0?e:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(1===a){const e=t<0;this._setEndings(e,!e,s)}else this._setEndings(!1,!1,s);this._loopCount=r,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:n})}}else this.time=i;if(s&&!(1&~r))return e-i}return i}_setEndings(t,e,n){const i=this._interpolantSettings;n?(i.endingStart=Je,i.endingEnd=Je):(i.endingStart=t?this.zeroSlopeAtStart?Je:Ye:Ke,i.endingEnd=e?this.zeroSlopeAtEnd?Je:Ye:Ke)}_scheduleFading(t,e,n){const i=this._mixer,r=i.time;let s=this._weightInterpolant;null===s&&(s=i._lendControlInterpolant(),this._weightInterpolant=s);const a=s.parameterPositions,o=s.sampleValues;return a[0]=r,o[0]=e,a[1]=r+t,o[1]=n,this}}const gf=new Float32Array(1);class Af extends Zn{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(t,e){const n=t._localRoot||this._root,i=t._clip.tracks,r=i.length,s=t._propertyBindings,a=t._interpolants,o=n.uuid,l=this._bindingsByRootAndName;let c=l[o];void 0===c&&(c={},l[o]=c);for(let t=0;t!==r;++t){const r=i[t],l=r.name;let h=c[l];if(void 0!==h)++h.referenceCount,s[t]=h;else{if(h=s[t],void 0!==h){null===h._cacheIndex&&(++h.referenceCount,this._addInactiveBinding(h,o,l));continue}const i=e&&e._propertyBindings[t].binding.parsedPath;h=new af(pf.create(n,l,i),r.ValueTypeName,r.getValueSize()),++h.referenceCount,this._addInactiveBinding(h,o,l),s[t]=h}a[t].resultBuffer=h.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(null===t._cacheIndex){const e=(t._localRoot||this._root).uuid,n=t._clip.uuid,i=this._actionsByClip[n];this._bindAction(t,i&&i.knownActions[0]),this._addInactiveAction(t,n,e)}const e=t._propertyBindings;for(let t=0,n=e.length;t!==n;++t){const n=e[t];0==n.useCount++&&(this._lendBinding(n),n.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){const e=t._propertyBindings;for(let t=0,n=e.length;t!==n;++t){const n=e[t];0==--n.useCount&&(n.restoreOriginalState(),this._takeBackBinding(n))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){const e=t._cacheIndex;return null!==e&&e=0;--e)t[e].stop();return this}update(t){t*=this.timeScale;const e=this._actions,n=this._nActiveActions,i=this.time+=t,r=Math.sign(t),s=this._accuIndex^=1;for(let a=0;a!==n;++a)e[a]._update(i,t,r,s);const a=this._bindings,o=this._nActiveBindings;for(let t=0;t!==o;++t)a[t].apply(s);return this}setTime(t){this.time=0;for(let t=0;t=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Bf).distanceTo(t)}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const Df=new Hi,Pf=new Hi;class Lf{constructor(t=new Hi,e=new Hi){this.start=t,this.end=e}set(t,e){return this.start.copy(t),this.end.copy(e),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){Df.subVectors(t,this.start),Pf.subVectors(this.end,this.start);const n=Pf.dot(Pf);let i=Pf.dot(Df)/n;return e&&(i=ri(i,0,1)),i}closestPointToPoint(t,e,n){const i=this.closestPointToPointParameter(t,e);return this.delta(n).multiplyScalar(i).add(this.start)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return(new this.constructor).copy(this)}}const Uf=new Hi;class Nf extends jr{constructor(t,e){super(),this.light=t,this.matrixAutoUpdate=!1,this.color=e,this.type="SpotLightHelper";const n=new Qs,i=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let t=0,e=1,n=32;t1)for(let n=0;n.99999)this.quaternion.set(0,0,0,1);else if(t.y<-.99999)this.quaternion.set(1,0,0,0);else{om.set(t.z,0,-t.x).normalize();const e=Math.acos(t.y);this.quaternion.setFromAxisAngle(om,e)}}setLength(t,e=.2*t,n=.2*e){this.line.scale.set(1,Math.max(1e-4,t-e),1),this.line.updateMatrix(),this.cone.scale.set(n,e,n),this.cone.position.y=t,this.cone.updateMatrix()}setColor(t){this.line.material.color.set(t),this.cone.material.color.set(t)}copy(t){return super.copy(t,!1),this.line.copy(t.line),this.cone.copy(t.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class um extends Oh{constructor(t=1){const e=[0,0,0,t,0,0,0,0,0,0,t,0,0,0,0,0,0,t],n=new Qs;n.setAttribute("position",new Ds(e,3)),n.setAttribute("color",new Ds([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3)),super(n,new bh({vertexColors:!0,toneMapped:!1})),this.type="AxesHelper"}setColors(t,e,n){const i=new us,r=this.geometry.attributes.color.array;return i.set(t),i.toArray(r,0),i.toArray(r,3),i.set(e),i.toArray(r,6),i.toArray(r,9),i.set(n),i.toArray(r,12),i.toArray(r,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class dm{constructor(){this.type="ShapePath",this.color=new us,this.subPaths=[],this.currentPath=null}moveTo(t,e){return this.currentPath=new xu,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this}lineTo(t,e){return this.currentPath.lineTo(t,e),this}quadraticCurveTo(t,e,n,i){return this.currentPath.quadraticCurveTo(t,e,n,i),this}bezierCurveTo(t,e,n,i,r,s){return this.currentPath.bezierCurveTo(t,e,n,i,r,s),this}splineThru(t){return this.currentPath.splineThru(t),this}toShapes(t){function e(t,e){const n=e.length;let i=!1;for(let r=n-1,s=0;sNumber.EPSILON){if(l<0&&(n=e[s],o=-o,a=e[r],l=-l),t.ya.y)continue;if(t.y===n.y){if(t.x===n.x)return!0}else{const e=l*(t.x-n.x)-o*(t.y-n.y);if(0===e)return!0;if(e<0)continue;i=!i}}else{if(t.y!==n.y)continue;if(a.x<=t.x&&t.x<=n.x||n.x<=t.x&&t.x<=a.x)return!0}}return i}const n=rd.isClockWise,i=this.subPaths;if(0===i.length)return[];let r,s,a;const o=[];if(1===i.length)return s=i[0],a=new Pu,a.curves=s.curves,o.push(a),o;let l=!n(i[0].getPoints());l=t?!l:l;const c=[],h=[];let u,d,p=[],f=0;h[f]=void 0,p[f]=[];for(let e=0,a=i.length;e1){let t=!1,n=0;for(let t=0,e=h.length;t0&&!1===t&&(p=c)}for(let t=0,e=h.length;t\n\n\t\tvarying vec2 vUv;\n\n\t\t#if DIFFUSE_TEXTURE == 1\n\t\tuniform sampler2D tDiffuse;\n\t\t#endif\n\n\t\tuniform highp sampler2D tDepth;\n\t\tuniform highp sampler2D tNormal;\n\n\t\tuniform float cameraNear;\n\t\tuniform float cameraFar;\n\t\tuniform mat4 cameraProjectionMatrix;\n\t\tuniform mat4 cameraInverseProjectionMatrix;\n\n\t\tuniform float scale;\n\t\tuniform float intensity;\n\t\tuniform float bias;\n\t\tuniform float kernelRadius;\n\t\tuniform float minResolution;\n\t\tuniform vec2 size;\n\t\tuniform float randomSeed;\n\n\t\t// RGBA depth\n\n\t\t#include \n\n\t\tvec4 getDefaultColor( const in vec2 screenPosition ) {\n\t\t\t#if DIFFUSE_TEXTURE == 1\n\t\t\treturn texture2D( tDiffuse, vUv );\n\t\t\t#else\n\t\t\treturn vec4( 1.0 );\n\t\t\t#endif\n\t\t}\n\n\t\tfloat getDepth( const in vec2 screenPosition ) {\n\t\t\treturn texture2D( tDepth, screenPosition ).x;\n\t\t}\n\n\t\tfloat getViewZ( const in float depth ) {\n\t\t\t#if PERSPECTIVE_CAMERA == 1\n\t\t\treturn perspectiveDepthToViewZ( depth, cameraNear, cameraFar );\n\t\t\t#else\n\t\t\treturn orthographicDepthToViewZ( depth, cameraNear, cameraFar );\n\t\t\t#endif\n\t\t}\n\n\t\tvec3 getViewPosition( const in vec2 screenPosition, const in float depth, const in float viewZ ) {\n\t\t\tfloat clipW = cameraProjectionMatrix[2][3] * viewZ + cameraProjectionMatrix[3][3];\n\t\t\tvec4 clipPosition = vec4( ( vec3( screenPosition, depth ) - 0.5 ) * 2.0, 1.0 );\n\t\t\tclipPosition *= clipW; // unprojection.\n\n\t\t\treturn ( cameraInverseProjectionMatrix * clipPosition ).xyz;\n\t\t}\n\n\t\tvec3 getViewNormal( const in vec3 viewPosition, const in vec2 screenPosition ) {\n\t\t\treturn unpackRGBToNormal( texture2D( tNormal, screenPosition ).xyz );\n\t\t}\n\n\t\tfloat scaleDividedByCameraFar;\n\t\tfloat minResolutionMultipliedByCameraFar;\n\n\t\tfloat getOcclusion( const in vec3 centerViewPosition, const in vec3 centerViewNormal, const in vec3 sampleViewPosition ) {\n\t\t\tvec3 viewDelta = sampleViewPosition - centerViewPosition;\n\t\t\tfloat viewDistance = length( viewDelta );\n\t\t\tfloat scaledScreenDistance = scaleDividedByCameraFar * viewDistance;\n\n\t\t\treturn max(0.0, (dot(centerViewNormal, viewDelta) - minResolutionMultipliedByCameraFar) / scaledScreenDistance - bias) / (1.0 + pow2( scaledScreenDistance ) );\n\t\t}\n\n\t\t// moving costly divides into consts\n\t\tconst float ANGLE_STEP = PI2 * float( NUM_RINGS ) / float( NUM_SAMPLES );\n\t\tconst float INV_NUM_SAMPLES = 1.0 / float( NUM_SAMPLES );\n\n\t\tfloat getAmbientOcclusion( const in vec3 centerViewPosition ) {\n\t\t\t// precompute some variables require in getOcclusion.\n\t\t\tscaleDividedByCameraFar = scale / cameraFar;\n\t\t\tminResolutionMultipliedByCameraFar = minResolution * cameraFar;\n\t\t\tvec3 centerViewNormal = getViewNormal( centerViewPosition, vUv );\n\n\t\t\t// jsfiddle that shows sample pattern: https://jsfiddle.net/a16ff1p7/\n\t\t\tfloat angle = rand( vUv + randomSeed ) * PI2;\n\t\t\tvec2 radius = vec2( kernelRadius * INV_NUM_SAMPLES ) / size;\n\t\t\tvec2 radiusStep = radius;\n\n\t\t\tfloat occlusionSum = 0.0;\n\t\t\tfloat weightSum = 0.0;\n\n\t\t\tfor( int i = 0; i < NUM_SAMPLES; i ++ ) {\n\t\t\t\tvec2 sampleUv = vUv + vec2( cos( angle ), sin( angle ) ) * radius;\n\t\t\t\tradius += radiusStep;\n\t\t\t\tangle += ANGLE_STEP;\n\n\t\t\t\tfloat sampleDepth = getDepth( sampleUv );\n\t\t\t\tif( sampleDepth >= ( 1.0 - EPSILON ) ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tfloat sampleViewZ = getViewZ( sampleDepth );\n\t\t\t\tvec3 sampleViewPosition = getViewPosition( sampleUv, sampleDepth, sampleViewZ );\n\t\t\t\tocclusionSum += getOcclusion( centerViewPosition, centerViewNormal, sampleViewPosition );\n\t\t\t\tweightSum += 1.0;\n\t\t\t}\n\n\t\t\tif( weightSum == 0.0 ) discard;\n\n\t\t\treturn occlusionSum * ( intensity / weightSum );\n\t\t}\n\n\t\tvoid main() {\n\t\t\tfloat centerDepth = getDepth( vUv );\n\t\t\tif( centerDepth >= ( 1.0 - EPSILON ) ) {\n\t\t\t\tdiscard;\n\t\t\t}\n\n\t\t\tfloat centerViewZ = getViewZ( centerDepth );\n\t\t\tvec3 viewPosition = getViewPosition( vUv, centerDepth, centerViewZ );\n\n\t\t\tfloat ambientOcclusion = getAmbientOcclusion( viewPosition );\n\n\t\t\tgl_FragColor = getDefaultColor( vUv );\n\t\t\tgl_FragColor.xyz *= 1.0 - ambientOcclusion;\n\t\t}"},Em={name:"DepthLimitedBlurShader",defines:{KERNEL_RADIUS:4,DEPTH_PACKING:1,PERSPECTIVE_CAMERA:1},uniforms:{tDiffuse:{value:null},size:{value:new hi(512,512)},sampleUvOffsets:{value:[new hi(0,0)]},sampleWeights:{value:[1]},tDepth:{value:null},cameraNear:{value:10},cameraFar:{value:1e3},depthCutoff:{value:10}},vertexShader:"\n\n\t\t#include \n\n\t\tuniform vec2 size;\n\n\t\tvarying vec2 vUv;\n\t\tvarying vec2 vInvSize;\n\n\t\tvoid main() {\n\t\t\tvUv = uv;\n\t\t\tvInvSize = 1.0 / size;\n\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t}",fragmentShader:"\n\n\t\t#include \n\t\t#include \n\n\t\tuniform sampler2D tDiffuse;\n\t\tuniform sampler2D tDepth;\n\n\t\tuniform float cameraNear;\n\t\tuniform float cameraFar;\n\t\tuniform float depthCutoff;\n\n\t\tuniform vec2 sampleUvOffsets[ KERNEL_RADIUS + 1 ];\n\t\tuniform float sampleWeights[ KERNEL_RADIUS + 1 ];\n\n\t\tvarying vec2 vUv;\n\t\tvarying vec2 vInvSize;\n\n\t\tfloat getDepth( const in vec2 screenPosition ) {\n\t\t\t#if DEPTH_PACKING == 1\n\t\t\treturn unpackRGBAToDepth( texture2D( tDepth, screenPosition ) );\n\t\t\t#else\n\t\t\treturn texture2D( tDepth, screenPosition ).x;\n\t\t\t#endif\n\t\t}\n\n\t\tfloat getViewZ( const in float depth ) {\n\t\t\t#if PERSPECTIVE_CAMERA == 1\n\t\t\treturn perspectiveDepthToViewZ( depth, cameraNear, cameraFar );\n\t\t\t#else\n\t\t\treturn orthographicDepthToViewZ( depth, cameraNear, cameraFar );\n\t\t\t#endif\n\t\t}\n\n\t\tvoid main() {\n\t\t\tfloat depth = getDepth( vUv );\n\t\t\tif( depth >= ( 1.0 - EPSILON ) ) {\n\t\t\t\tdiscard;\n\t\t\t}\n\n\t\t\tfloat centerViewZ = -getViewZ( depth );\n\t\t\tbool rBreak = false, lBreak = false;\n\n\t\t\tfloat weightSum = sampleWeights[0];\n\t\t\tvec4 diffuseSum = texture2D( tDiffuse, vUv ) * weightSum;\n\n\t\t\tfor( int i = 1; i <= KERNEL_RADIUS; i ++ ) {\n\n\t\t\t\tfloat sampleWeight = sampleWeights[i];\n\t\t\t\tvec2 sampleUvOffset = sampleUvOffsets[i] * vInvSize;\n\n\t\t\t\tvec2 sampleUv = vUv + sampleUvOffset;\n\t\t\t\tfloat viewZ = -getViewZ( getDepth( sampleUv ) );\n\n\t\t\t\tif( abs( viewZ - centerViewZ ) > depthCutoff ) rBreak = true;\n\n\t\t\t\tif( ! rBreak ) {\n\t\t\t\t\tdiffuseSum += texture2D( tDiffuse, sampleUv ) * sampleWeight;\n\t\t\t\t\tweightSum += sampleWeight;\n\t\t\t\t}\n\n\t\t\t\tsampleUv = vUv - sampleUvOffset;\n\t\t\t\tviewZ = -getViewZ( getDepth( sampleUv ) );\n\n\t\t\t\tif( abs( viewZ - centerViewZ ) > depthCutoff ) lBreak = true;\n\n\t\t\t\tif( ! lBreak ) {\n\t\t\t\t\tdiffuseSum += texture2D( tDiffuse, sampleUv ) * sampleWeight;\n\t\t\t\t\tweightSum += sampleWeight;\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tgl_FragColor = diffuseSum / weightSum;\n\t\t}"},Mm={createSampleWeights:function(t,e){const n=[];for(let i=0;i<=t;i++)n.push(bm(i,e));return n},createSampleOffsets:function(t,e){const n=[];for(let i=0;i<=t;i++)n.push(e.clone().multiplyScalar(i));return n},configure:function(t,e,n,i){t.defines.KERNEL_RADIUS=e,t.uniforms.sampleUvOffsets.value=Mm.createSampleOffsets(e,i),t.uniforms.sampleWeights.value=Mm.createSampleWeights(e,n),t.needsUpdate=!0}};function bm(t,e){return Math.exp(-t*t/(e*e*2))/(Math.sqrt(2*Math.PI)*e)}class Sm extends gm{constructor(t,e,n=new hi(256,256)){super(),this.scene=t,this.camera=e,this.clear=!0,this.needsSwap=!1,this.originalClearColor=new us,this._oldClearColor=new us,this.oldClearAlpha=1,this.params={output:0,saoBias:.5,saoIntensity:.18,saoScale:1,saoKernelRadius:100,saoMinResolution:0,saoBlur:!0,saoBlurRadius:8,saoBlurStdDev:4,saoBlurDepthCutoff:.01},this.resolution=new hi(n.x,n.y),this.saoRenderTarget=new Fi(this.resolution.x,this.resolution.y,{type:qt}),this.blurIntermediateRenderTarget=this.saoRenderTarget.clone();const i=new ao;i.format=re,i.type=Jt,this.normalRenderTarget=new Fi(this.resolution.x,this.resolution.y,{minFilter:Bt,magFilter:Bt,type:qt,depthTexture:i}),this.normalMaterial=new Sd,this.normalMaterial.blending=I,this.saoMaterial=new sa({defines:Object.assign({},Cm.defines),fragmentShader:Cm.fragmentShader,vertexShader:Cm.vertexShader,uniforms:ra.clone(Cm.uniforms)}),this.saoMaterial.defines.PERSPECTIVE_CAMERA=this.camera.isPerspectiveCamera?1:0,this.saoMaterial.uniforms.tDepth.value=i,this.saoMaterial.uniforms.tNormal.value=this.normalRenderTarget.texture,this.saoMaterial.uniforms.size.value.set(this.resolution.x,this.resolution.y),this.saoMaterial.uniforms.cameraInverseProjectionMatrix.value.copy(this.camera.projectionMatrixInverse),this.saoMaterial.uniforms.cameraProjectionMatrix.value=this.camera.projectionMatrix,this.saoMaterial.blending=I,this.vBlurMaterial=new sa({uniforms:ra.clone(Em.uniforms),defines:Object.assign({},Em.defines),vertexShader:Em.vertexShader,fragmentShader:Em.fragmentShader}),this.vBlurMaterial.defines.DEPTH_PACKING=0,this.vBlurMaterial.defines.PERSPECTIVE_CAMERA=this.camera.isPerspectiveCamera?1:0,this.vBlurMaterial.uniforms.tDiffuse.value=this.saoRenderTarget.texture,this.vBlurMaterial.uniforms.tDepth.value=i,this.vBlurMaterial.uniforms.size.value.set(this.resolution.x,this.resolution.y),this.vBlurMaterial.blending=I,this.hBlurMaterial=new sa({uniforms:ra.clone(Em.uniforms),defines:Object.assign({},Em.defines),vertexShader:Em.vertexShader,fragmentShader:Em.fragmentShader}),this.hBlurMaterial.defines.DEPTH_PACKING=0,this.hBlurMaterial.defines.PERSPECTIVE_CAMERA=this.camera.isPerspectiveCamera?1:0,this.hBlurMaterial.uniforms.tDiffuse.value=this.blurIntermediateRenderTarget.texture,this.hBlurMaterial.uniforms.tDepth.value=i,this.hBlurMaterial.uniforms.size.value.set(this.resolution.x,this.resolution.y),this.hBlurMaterial.blending=I,this.materialCopy=new sa({uniforms:ra.clone(mm.uniforms),vertexShader:mm.vertexShader,fragmentShader:mm.fragmentShader,blending:I}),this.materialCopy.transparent=!0,this.materialCopy.depthTest=!1,this.materialCopy.depthWrite=!1,this.materialCopy.blending=P,this.materialCopy.blendSrc=q,this.materialCopy.blendDst=k,this.materialCopy.blendEquation=L,this.materialCopy.blendSrcAlpha=W,this.materialCopy.blendDstAlpha=k,this.materialCopy.blendEquationAlpha=L,this.fsQuad=new ym(null)}render(t,e,n){this.renderToScreen&&(this.materialCopy.blending=I,this.materialCopy.uniforms.tDiffuse.value=n.texture,this.materialCopy.needsUpdate=!0,this.renderPass(t,this.materialCopy,null)),t.getClearColor(this._oldClearColor),this.oldClearAlpha=t.getClearAlpha();const i=t.autoClear;t.autoClear=!1,this.saoMaterial.uniforms.bias.value=this.params.saoBias,this.saoMaterial.uniforms.intensity.value=this.params.saoIntensity,this.saoMaterial.uniforms.scale.value=this.params.saoScale,this.saoMaterial.uniforms.kernelRadius.value=this.params.saoKernelRadius,this.saoMaterial.uniforms.minResolution.value=this.params.saoMinResolution,this.saoMaterial.uniforms.cameraNear.value=this.camera.near,this.saoMaterial.uniforms.cameraFar.value=this.camera.far;const r=this.params.saoBlurDepthCutoff*(this.camera.far-this.camera.near);this.vBlurMaterial.uniforms.depthCutoff.value=r,this.hBlurMaterial.uniforms.depthCutoff.value=r,this.vBlurMaterial.uniforms.cameraNear.value=this.camera.near,this.vBlurMaterial.uniforms.cameraFar.value=this.camera.far,this.hBlurMaterial.uniforms.cameraNear.value=this.camera.near,this.hBlurMaterial.uniforms.cameraFar.value=this.camera.far,this.params.saoBlurRadius=Math.floor(this.params.saoBlurRadius),this.prevStdDev===this.params.saoBlurStdDev&&this.prevNumSamples===this.params.saoBlurRadius||(Mm.configure(this.vBlurMaterial,this.params.saoBlurRadius,this.params.saoBlurStdDev,new hi(0,1)),Mm.configure(this.hBlurMaterial,this.params.saoBlurRadius,this.params.saoBlurStdDev,new hi(1,0)),this.prevStdDev=this.params.saoBlurStdDev,this.prevNumSamples=this.params.saoBlurRadius),this.renderOverride(t,this.normalMaterial,this.normalRenderTarget,7829503,1),this.renderPass(t,this.saoMaterial,this.saoRenderTarget,16777215,1),this.params.saoBlur&&(this.renderPass(t,this.vBlurMaterial,this.blurIntermediateRenderTarget,16777215,1),this.renderPass(t,this.hBlurMaterial,this.saoRenderTarget,16777215,1));const s=this.materialCopy;this.params.output===Sm.OUTPUT.Normal?(this.materialCopy.uniforms.tDiffuse.value=this.normalRenderTarget.texture,this.materialCopy.needsUpdate=!0):(this.materialCopy.uniforms.tDiffuse.value=this.saoRenderTarget.texture,this.materialCopy.needsUpdate=!0),this.params.output===Sm.OUTPUT.Default?s.blending=P:s.blending=I,this.renderPass(t,s,this.renderToScreen?null:n),t.setClearColor(this._oldClearColor,this.oldClearAlpha),t.autoClear=i}renderPass(t,e,n,i,r){t.getClearColor(this.originalClearColor);const s=t.getClearAlpha(),a=t.autoClear;t.setRenderTarget(n),t.autoClear=!1,null!=i&&(t.setClearColor(i),t.setClearAlpha(r||0),t.clear()),this.fsQuad.material=e,this.fsQuad.render(t),t.autoClear=a,t.setClearColor(this.originalClearColor),t.setClearAlpha(s)}renderOverride(t,e,n,i,r){t.getClearColor(this.originalClearColor);const s=t.getClearAlpha(),a=t.autoClear;t.setRenderTarget(n),t.autoClear=!1,i=e.clearColor||i,r=e.clearAlpha||r,null!=i&&(t.setClearColor(i),t.setClearAlpha(r||0),t.clear()),this.scene.overrideMaterial=e,t.render(this.scene,this.camera),this.scene.overrideMaterial=null,t.autoClear=a,t.setClearColor(this.originalClearColor),t.setClearAlpha(s)}setSize(t,e){this.saoRenderTarget.setSize(t,e),this.blurIntermediateRenderTarget.setSize(t,e),this.normalRenderTarget.setSize(t,e),this.saoMaterial.uniforms.size.value.set(t,e),this.saoMaterial.uniforms.cameraInverseProjectionMatrix.value.copy(this.camera.projectionMatrixInverse),this.saoMaterial.uniforms.cameraProjectionMatrix.value=this.camera.projectionMatrix,this.saoMaterial.needsUpdate=!0,this.vBlurMaterial.uniforms.size.value.set(t,e),this.vBlurMaterial.needsUpdate=!0,this.hBlurMaterial.uniforms.size.value.set(t,e),this.hBlurMaterial.needsUpdate=!0}dispose(){this.saoRenderTarget.dispose(),this.blurIntermediateRenderTarget.dispose(),this.normalRenderTarget.dispose(),this.normalMaterial.dispose(),this.saoMaterial.dispose(),this.vBlurMaterial.dispose(),this.hBlurMaterial.dispose(),this.materialCopy.dispose(),this.fsQuad.dispose()}}Sm.OUTPUT={Default:0,SAO:1,Normal:2};const Im={name:"GTAOShader",defines:{PERSPECTIVE_CAMERA:1,SAMPLES:16,NORMAL_VECTOR_TYPE:1,DEPTH_SWIZZLING:"x",SCREEN_SPACE_RADIUS:0,SCREEN_SPACE_RADIUS_SCALE:100,SCENE_CLIP_BOX:0},uniforms:{tNormal:{value:null},tDepth:{value:null},tNoise:{value:null},resolution:{value:new hi},cameraNear:{value:null},cameraFar:{value:null},cameraProjectionMatrix:{value:new yr},cameraProjectionMatrixInverse:{value:new yr},cameraWorldMatrix:{value:new yr},radius:{value:.25},distanceExponent:{value:1},thickness:{value:1},distanceFallOff:{value:1},scale:{value:1},sceneBoxMin:{value:new Hi(-1,-1,-1)},sceneBoxMax:{value:new Hi(1,1,1)}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t}",fragmentShader:"\n\t\tvarying vec2 vUv;\n\t\tuniform highp sampler2D tNormal;\n\t\tuniform highp sampler2D tDepth;\n\t\tuniform sampler2D tNoise;\n\t\tuniform vec2 resolution;\n\t\tuniform float cameraNear;\n\t\tuniform float cameraFar;\n\t\tuniform mat4 cameraProjectionMatrix;\n\t\tuniform mat4 cameraProjectionMatrixInverse;\t\t\n\t\tuniform mat4 cameraWorldMatrix;\n\t\tuniform float radius;\n\t\tuniform float distanceExponent;\n\t\tuniform float thickness;\n\t\tuniform float distanceFallOff;\n\t\tuniform float scale;\n\t\t#if SCENE_CLIP_BOX == 1\n\t\t\tuniform vec3 sceneBoxMin;\n\t\t\tuniform vec3 sceneBoxMax;\n\t\t#endif\n\t\t\n\t\t#include \n\t\t#include \n\n\t\t#ifndef FRAGMENT_OUTPUT\n\t\t#define FRAGMENT_OUTPUT vec4(vec3(ao), 1.)\n\t\t#endif\n\n\t\tvec3 getViewPosition(const in vec2 screenPosition, const in float depth) {\n\t\t\tvec4 clipSpacePosition = vec4(vec3(screenPosition, depth) * 2.0 - 1.0, 1.0);\n\t\t\tvec4 viewSpacePosition = cameraProjectionMatrixInverse * clipSpacePosition;\n\t\t\treturn viewSpacePosition.xyz / viewSpacePosition.w;\n\t\t}\n\n\t\tfloat getDepth(const vec2 uv) { \n\t\t\treturn textureLod(tDepth, uv.xy, 0.0).DEPTH_SWIZZLING;\n\t\t}\n\n\t\tfloat fetchDepth(const ivec2 uv) { \n\t\t\treturn texelFetch(tDepth, uv.xy, 0).DEPTH_SWIZZLING;\n\t\t}\n\n\t\tfloat getViewZ(const in float depth) {\n\t\t\t#if PERSPECTIVE_CAMERA == 1\n\t\t\t\treturn perspectiveDepthToViewZ(depth, cameraNear, cameraFar);\n\t\t\t#else\n\t\t\t\treturn orthographicDepthToViewZ(depth, cameraNear, cameraFar);\n\t\t\t#endif\n\t\t}\n\n\t\tvec3 computeNormalFromDepth(const vec2 uv) {\n\t\t\tvec2 size = vec2(textureSize(tDepth, 0));\n\t\t\tivec2 p = ivec2(uv * size);\n\t\t\tfloat c0 = fetchDepth(p);\n\t\t\tfloat l2 = fetchDepth(p - ivec2(2, 0));\n\t\t\tfloat l1 = fetchDepth(p - ivec2(1, 0));\n\t\t\tfloat r1 = fetchDepth(p + ivec2(1, 0));\n\t\t\tfloat r2 = fetchDepth(p + ivec2(2, 0));\n\t\t\tfloat b2 = fetchDepth(p - ivec2(0, 2));\n\t\t\tfloat b1 = fetchDepth(p - ivec2(0, 1));\n\t\t\tfloat t1 = fetchDepth(p + ivec2(0, 1));\n\t\t\tfloat t2 = fetchDepth(p + ivec2(0, 2));\n\t\t\tfloat dl = abs((2.0 * l1 - l2) - c0);\n\t\t\tfloat dr = abs((2.0 * r1 - r2) - c0);\n\t\t\tfloat db = abs((2.0 * b1 - b2) - c0);\n\t\t\tfloat dt = abs((2.0 * t1 - t2) - c0);\n\t\t\tvec3 ce = getViewPosition(uv, c0).xyz;\n\t\t\tvec3 dpdx = (dl < dr) ? ce - getViewPosition((uv - vec2(1.0 / size.x, 0.0)), l1).xyz : -ce + getViewPosition((uv + vec2(1.0 / size.x, 0.0)), r1).xyz;\n\t\t\tvec3 dpdy = (db < dt) ? ce - getViewPosition((uv - vec2(0.0, 1.0 / size.y)), b1).xyz : -ce + getViewPosition((uv + vec2(0.0, 1.0 / size.y)), t1).xyz;\n\t\t\treturn normalize(cross(dpdx, dpdy));\n\t\t}\n\n\t\tvec3 getViewNormal(const vec2 uv) {\n\t\t\t#if NORMAL_VECTOR_TYPE == 2\n\t\t\t\treturn normalize(textureLod(tNormal, uv, 0.).rgb);\n\t\t\t#elif NORMAL_VECTOR_TYPE == 1\n\t\t\t\treturn unpackRGBToNormal(textureLod(tNormal, uv, 0.).rgb);\n\t\t\t#else\n\t\t\t\treturn computeNormalFromDepth(uv);\n\t\t\t#endif\n\t\t}\n\n\t\tvec3 getSceneUvAndDepth(vec3 sampleViewPos) {\n\t\t\tvec4 sampleClipPos = cameraProjectionMatrix * vec4(sampleViewPos, 1.);\n\t\t\tvec2 sampleUv = sampleClipPos.xy / sampleClipPos.w * 0.5 + 0.5;\n\t\t\tfloat sampleSceneDepth = getDepth(sampleUv);\n\t\t\treturn vec3(sampleUv, sampleSceneDepth);\n\t\t}\n\t\t\n\t\tvoid main() {\n\t\t\tfloat depth = getDepth(vUv.xy);\n\t\t\tif (depth >= 1.0) {\n\t\t\t\tdiscard;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tvec3 viewPos = getViewPosition(vUv, depth);\n\t\t\tvec3 viewNormal = getViewNormal(vUv);\n\n\t\t\tfloat radiusToUse = radius;\n\t\t\tfloat distanceFalloffToUse = thickness;\n\t\t\t#if SCREEN_SPACE_RADIUS == 1\n\t\t\t\tfloat radiusScale = getViewPosition(vec2(0.5 + float(SCREEN_SPACE_RADIUS_SCALE) / resolution.x, 0.0), depth).x;\n\t\t\t\tradiusToUse *= radiusScale;\n\t\t\t\tdistanceFalloffToUse *= radiusScale;\n\t\t\t#endif\n\n\t\t\t#if SCENE_CLIP_BOX == 1\n\t\t\t\tvec3 worldPos = (cameraWorldMatrix * vec4(viewPos, 1.0)).xyz;\n\t\t\t\tfloat boxDistance = length(max(vec3(0.0), max(sceneBoxMin - worldPos, worldPos - sceneBoxMax)));\n\t\t\t\tif (boxDistance > radiusToUse) {\n\t\t\t\t\tdiscard;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t#endif\n\t\t\t\n\t\t\tvec2 noiseResolution = vec2(textureSize(tNoise, 0));\n\t\t\tvec2 noiseUv = vUv * resolution / noiseResolution;\n\t\t\tvec4 noiseTexel = textureLod(tNoise, noiseUv, 0.0);\n\t\t\tvec3 randomVec = noiseTexel.xyz * 2.0 - 1.0;\n\t\t\tvec3 tangent = normalize(vec3(randomVec.xy, 0.));\n\t\t\tvec3 bitangent = vec3(-tangent.y, tangent.x, 0.);\n\t\t\tmat3 kernelMatrix = mat3(tangent, bitangent, vec3(0., 0., 1.));\n\n\t\t\tconst int DIRECTIONS = SAMPLES < 30 ? 3 : 5;\n\t\t\tconst int STEPS = (SAMPLES + DIRECTIONS - 1) / DIRECTIONS;\n\t\t\tfloat ao = 0.0;\n\t\t\tfor (int i = 0; i < DIRECTIONS; ++i) {\n\t\t\t\t\n\t\t\t\tfloat angle = float(i) / float(DIRECTIONS) * PI;\n\t\t\t\tvec4 sampleDir = vec4(cos(angle), sin(angle), 0., 0.5 + 0.5 * noiseTexel.w); \n\t\t\t\tsampleDir.xyz = normalize(kernelMatrix * sampleDir.xyz);\n\n\t\t\t\tvec3 viewDir = normalize(-viewPos.xyz);\n\t\t\t\tvec3 sliceBitangent = normalize(cross(sampleDir.xyz, viewDir));\n\t\t\t\tvec3 sliceTangent = cross(sliceBitangent, viewDir);\n\t\t\t\tvec3 normalInSlice = normalize(viewNormal - sliceBitangent * dot(viewNormal, sliceBitangent));\n\t\t\t\t\n\t\t\t\tvec3 tangentToNormalInSlice = cross(normalInSlice, sliceBitangent);\n\t\t\t\tvec2 cosHorizons = vec2(dot(viewDir, tangentToNormalInSlice), dot(viewDir, -tangentToNormalInSlice));\n\t\t\t\t\n\t\t\t\tfor (int j = 0; j < STEPS; ++j) {\n\t\t\t\t\tvec3 sampleViewOffset = sampleDir.xyz * radiusToUse * sampleDir.w * pow(float(j + 1) / float(STEPS), distanceExponent);\t\n\n\t\t\t\t\tvec3 sampleSceneUvDepth = getSceneUvAndDepth(viewPos + sampleViewOffset);\n\t\t\t\t\tvec3 sampleSceneViewPos = getViewPosition(sampleSceneUvDepth.xy, sampleSceneUvDepth.z);\n\t\t\t\t\tvec3 viewDelta = sampleSceneViewPos - viewPos;\n\t\t\t\t\tif (abs(viewDelta.z) < thickness) {\n\t\t\t\t\t\tfloat sampleCosHorizon = dot(viewDir, normalize(viewDelta));\n\t\t\t\t\t\tcosHorizons.x += max(0., (sampleCosHorizon - cosHorizons.x) * mix(1., 2. / float(j + 2), distanceFallOff));\n\t\t\t\t\t}\t\t\n\n\t\t\t\t\tsampleSceneUvDepth = getSceneUvAndDepth(viewPos - sampleViewOffset);\n\t\t\t\t\tsampleSceneViewPos = getViewPosition(sampleSceneUvDepth.xy, sampleSceneUvDepth.z);\n\t\t\t\t\tviewDelta = sampleSceneViewPos - viewPos;\n\t\t\t\t\tif (abs(viewDelta.z) < thickness) {\n\t\t\t\t\t\tfloat sampleCosHorizon = dot(viewDir, normalize(viewDelta));\n\t\t\t\t\t\tcosHorizons.y += max(0., (sampleCosHorizon - cosHorizons.y) * mix(1., 2. / float(j + 2), distanceFallOff));\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tvec2 sinHorizons = sqrt(1. - cosHorizons * cosHorizons);\n\t\t\t\tfloat nx = dot(normalInSlice, sliceTangent);\n\t\t\t\tfloat ny = dot(normalInSlice, viewDir);\n\t\t\t\tfloat nxb = 1. / 2. * (acos(cosHorizons.y) - acos(cosHorizons.x) + sinHorizons.x * cosHorizons.x - sinHorizons.y * cosHorizons.y);\n\t\t\t\tfloat nyb = 1. / 2. * (2. - cosHorizons.x * cosHorizons.x - cosHorizons.y * cosHorizons.y);\n\t\t\t\tfloat occlusion = nx * nxb + ny * nyb;\n\t\t\t\tao += occlusion;\n\t\t\t}\n\n\t\t\tao = clamp(ao / float(DIRECTIONS), 0., 1.);\t\t\n\t\t#if SCENE_CLIP_BOX == 1\n\t\t\tao = mix(ao, 1., smoothstep(0., radiusToUse, boxDistance));\n\t\t#endif\n\t\t\tao = pow(ao, scale);\n\n\t\t\tgl_FragColor = FRAGMENT_OUTPUT;\n\t\t}"},Tm={PERSPECTIVE_CAMERA:1},Bm={tDepth:{value:null},cameraNear:{value:null},cameraFar:{value:null}},Rm="\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t}",Dm="\n\t\tuniform sampler2D tDepth;\n\t\tuniform float cameraNear;\n\t\tuniform float cameraFar;\n\t\tvarying vec2 vUv;\n\n\t\t#include \n\n\t\tfloat getLinearDepth( const in vec2 screenPosition ) {\n\t\t\t#if PERSPECTIVE_CAMERA == 1\n\t\t\t\tfloat fragCoordZ = texture2D( tDepth, screenPosition ).x;\n\t\t\t\tfloat viewZ = perspectiveDepthToViewZ( fragCoordZ, cameraNear, cameraFar );\n\t\t\t\treturn viewZToOrthographicDepth( viewZ, cameraNear, cameraFar );\n\t\t\t#else\n\t\t\t\treturn texture2D( tDepth, screenPosition ).x;\n\t\t\t#endif\n\t\t}\n\n\t\tvoid main() {\n\t\t\tfloat depth = getLinearDepth( vUv );\n\t\t\tgl_FragColor = vec4( vec3( 1.0 - depth ), 1.0 );\n\n\t\t}",Pm={tDiffuse:{value:null},intensity:{value:1}},Lm="\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t}",Um="\n\t\tuniform float intensity;\n\t\tuniform sampler2D tDiffuse;\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\t\t\tvec4 texel = texture2D( tDiffuse, vUv );\n\t\t\tgl_FragColor = vec4(mix(vec3(1.), texel.rgb, intensity), texel.a);\n\t\t}";const Nm={name:"PoissonDenoiseShader",defines:{SAMPLES:16,SAMPLE_VECTORS:Fm(16,2,1),NORMAL_VECTOR_TYPE:1,DEPTH_VALUE_SOURCE:0},uniforms:{tDiffuse:{value:null},tNormal:{value:null},tDepth:{value:null},tNoise:{value:null},resolution:{value:new hi},cameraProjectionMatrixInverse:{value:new yr},lumaPhi:{value:5},depthPhi:{value:5},normalPhi:{value:5},radius:{value:4},index:{value:0}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t}",fragmentShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tuniform sampler2D tDiffuse;\n\t\tuniform sampler2D tNormal;\n\t\tuniform sampler2D tDepth;\n\t\tuniform sampler2D tNoise;\n\t\tuniform vec2 resolution;\n\t\tuniform mat4 cameraProjectionMatrixInverse;\n\t\tuniform float lumaPhi;\n\t\tuniform float depthPhi;\n\t\tuniform float normalPhi;\n\t\tuniform float radius;\n\t\tuniform int index;\n\t\t\n\t\t#include \n\t\t#include \n\n\t\t#ifndef SAMPLE_LUMINANCE\n\t\t#define SAMPLE_LUMINANCE dot(vec3(0.2125, 0.7154, 0.0721), a)\n\t\t#endif\n\n\t\t#ifndef FRAGMENT_OUTPUT\n\t\t#define FRAGMENT_OUTPUT vec4(denoised, 1.)\n\t\t#endif\n\n\t\tfloat getLuminance(const in vec3 a) {\n\t\t\treturn SAMPLE_LUMINANCE;\n\t\t}\n\n\t\tconst vec3 poissonDisk[SAMPLES] = SAMPLE_VECTORS;\n\n\t\tvec3 getViewPosition(const in vec2 screenPosition, const in float depth) {\n\t\t\tvec4 clipSpacePosition = vec4(vec3(screenPosition, depth) * 2.0 - 1.0, 1.0);\n\t\t\tvec4 viewSpacePosition = cameraProjectionMatrixInverse * clipSpacePosition;\n\t\t\treturn viewSpacePosition.xyz / viewSpacePosition.w;\n\t\t}\n\t\t\n\t\tfloat getDepth(const vec2 uv) {\n\t\t#if DEPTH_VALUE_SOURCE == 1 \n\t\t\treturn textureLod(tDepth, uv.xy, 0.0).a;\n\t\t#else\n\t\t\treturn textureLod(tDepth, uv.xy, 0.0).r;\n\t\t#endif\n\t\t}\n\n\t\tfloat fetchDepth(const ivec2 uv) {\n\t\t\t#if DEPTH_VALUE_SOURCE == 1 \n\t\t\t\treturn texelFetch(tDepth, uv.xy, 0).a;\n\t\t\t#else\n\t\t\t\treturn texelFetch(tDepth, uv.xy, 0).r;\n\t\t\t#endif\n\t\t}\n\n\t\tvec3 computeNormalFromDepth(const vec2 uv) {\n\t\t\tvec2 size = vec2(textureSize(tDepth, 0));\n\t\t\tivec2 p = ivec2(uv * size);\n\t\t\tfloat c0 = fetchDepth(p);\n\t\t\tfloat l2 = fetchDepth(p - ivec2(2, 0));\n\t\t\tfloat l1 = fetchDepth(p - ivec2(1, 0));\n\t\t\tfloat r1 = fetchDepth(p + ivec2(1, 0));\n\t\t\tfloat r2 = fetchDepth(p + ivec2(2, 0));\n\t\t\tfloat b2 = fetchDepth(p - ivec2(0, 2));\n\t\t\tfloat b1 = fetchDepth(p - ivec2(0, 1));\n\t\t\tfloat t1 = fetchDepth(p + ivec2(0, 1));\n\t\t\tfloat t2 = fetchDepth(p + ivec2(0, 2));\n\t\t\tfloat dl = abs((2.0 * l1 - l2) - c0);\n\t\t\tfloat dr = abs((2.0 * r1 - r2) - c0);\n\t\t\tfloat db = abs((2.0 * b1 - b2) - c0);\n\t\t\tfloat dt = abs((2.0 * t1 - t2) - c0);\n\t\t\tvec3 ce = getViewPosition(uv, c0).xyz;\n\t\t\tvec3 dpdx = (dl < dr) ? ce - getViewPosition((uv - vec2(1.0 / size.x, 0.0)), l1).xyz\n\t\t\t\t\t\t\t\t\t: -ce + getViewPosition((uv + vec2(1.0 / size.x, 0.0)), r1).xyz;\n\t\t\tvec3 dpdy = (db < dt) ? ce - getViewPosition((uv - vec2(0.0, 1.0 / size.y)), b1).xyz\n\t\t\t\t\t\t\t\t\t: -ce + getViewPosition((uv + vec2(0.0, 1.0 / size.y)), t1).xyz;\n\t\t\treturn normalize(cross(dpdx, dpdy));\n\t\t}\n\n\t\tvec3 getViewNormal(const vec2 uv) {\n\t\t#if NORMAL_VECTOR_TYPE == 2\n\t\t\treturn normalize(textureLod(tNormal, uv, 0.).rgb);\n\t\t#elif NORMAL_VECTOR_TYPE == 1\n\t\t\treturn unpackRGBToNormal(textureLod(tNormal, uv, 0.).rgb);\n\t\t#else\n\t\t\treturn computeNormalFromDepth(uv);\n\t\t#endif\n\t\t}\n\n\t\tvoid denoiseSample(in vec3 center, in vec3 viewNormal, in vec3 viewPos, in vec2 sampleUv, inout vec3 denoised, inout float totalWeight) {\n\t\t\tvec4 sampleTexel = textureLod(tDiffuse, sampleUv, 0.0);\n\t\t\tfloat sampleDepth = getDepth(sampleUv);\n\t\t\tvec3 sampleNormal = getViewNormal(sampleUv);\n\t\t\tvec3 neighborColor = sampleTexel.rgb;\n\t\t\tvec3 viewPosSample = getViewPosition(sampleUv, sampleDepth);\n\t\t\t\n\t\t\tfloat normalDiff = dot(viewNormal, sampleNormal);\n\t\t\tfloat normalSimilarity = pow(max(normalDiff, 0.), normalPhi);\n\t\t\tfloat lumaDiff = abs(getLuminance(neighborColor) - getLuminance(center));\n\t\t\tfloat lumaSimilarity = max(1.0 - lumaDiff / lumaPhi, 0.0);\n\t\t\tfloat depthDiff = abs(dot(viewPos - viewPosSample, viewNormal));\n\t\t\tfloat depthSimilarity = max(1. - depthDiff / depthPhi, 0.);\n\t\t\tfloat w = lumaSimilarity * depthSimilarity * normalSimilarity;\n\t\t\n\t\t\tdenoised += w * neighborColor;\n\t\t\ttotalWeight += w;\n\t\t}\n\t\t\n\t\tvoid main() {\n\t\t\tfloat depth = getDepth(vUv.xy);\t\n\t\t\tvec3 viewNormal = getViewNormal(vUv);\t\n\t\t\tif (depth == 1. || dot(viewNormal, viewNormal) == 0.) {\n\t\t\t\tdiscard;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tvec4 texel = textureLod(tDiffuse, vUv, 0.0);\n\t\t\tvec3 center = texel.rgb;\n\t\t\tvec3 viewPos = getViewPosition(vUv, depth);\n\n\t\t\tvec2 noiseResolution = vec2(textureSize(tNoise, 0));\n\t\t\tvec2 noiseUv = vUv * resolution / noiseResolution;\n\t\t\tvec4 noiseTexel = textureLod(tNoise, noiseUv, 0.0);\n \t\tvec2 noiseVec = vec2(sin(noiseTexel[index % 4] * 2. * PI), cos(noiseTexel[index % 4] * 2. * PI));\n \t\tmat2 rotationMatrix = mat2(noiseVec.x, -noiseVec.y, noiseVec.x, noiseVec.y);\n\t\t\n\t\t\tfloat totalWeight = 1.0;\n\t\t\tvec3 denoised = texel.rgb;\n\t\t\tfor (int i = 0; i < SAMPLES; i++) {\n\t\t\t\tvec3 sampleDir = poissonDisk[i];\n\t\t\t\tvec2 offset = rotationMatrix * (sampleDir.xy * (1. + sampleDir.z * (radius - 1.)) / resolution);\n\t\t\t\tvec2 sampleUv = vUv + offset;\n\t\t\t\tdenoiseSample(center, viewNormal, viewPos, sampleUv, denoised, totalWeight);\n\t\t\t}\n\t\t\n\t\t\tif (totalWeight > 0.) { \n\t\t\t\tdenoised /= totalWeight;\n\t\t\t}\n\t\t\tgl_FragColor = FRAGMENT_OUTPUT;\n\t\t}"};function Fm(t,e,n){const i=function(t,e,n){const i=[];for(let r=0;ru?(d=1,p=0):(d=0,p=1);const f=h-d+l,m=u-p+l,g=h-1+2*l,A=u-1+2*l,v=255&a,y=255&o,x=this.perm[v+this.perm[y]]%12,_=this.perm[v+d+this.perm[y+p]]%12,w=this.perm[v+1+this.perm[y+1]]%12;let C=.5-h*h-u*u;C<0?n=0:(C*=C,n=C*C*this.dot(this.grad3[x],h,u));let E=.5-f*f-m*m;E<0?i=0:(E*=E,i=E*E*this.dot(this.grad3[_],f,m));let M=.5-g*g-A*A;return M<0?r=0:(M*=M,r=M*M*this.dot(this.grad3[w],g,A)),70*(n+i+r)}noise3d(t,e,n){let i,r,s,a;const o=(t+e+n)*(1/3),l=Math.floor(t+o),c=Math.floor(e+o),h=Math.floor(n+o),u=1/6,d=(l+c+h)*u,p=t-(l-d),f=e-(c-d),m=n-(h-d);let g,A,v,y,x,_;p>=f?f>=m?(g=1,A=0,v=0,y=1,x=1,_=0):p>=m?(g=1,A=0,v=0,y=1,x=0,_=1):(g=0,A=0,v=1,y=1,x=0,_=1):f_?32:0)+(x>w?16:0)+(_>w?8:0)+(x>C?4:0)+(_>C?2:0)+(w>C?1:0),M=s[E][0]>=3?1:0,b=s[E][1]>=3?1:0,S=s[E][2]>=3?1:0,I=s[E][3]>=3?1:0,T=s[E][0]>=2?1:0,B=s[E][1]>=2?1:0,R=s[E][2]>=2?1:0,D=s[E][3]>=2?1:0,P=s[E][0]>=1?1:0,L=s[E][1]>=1?1:0,U=s[E][2]>=1?1:0,N=s[E][3]>=1?1:0,F=x-M+l,O=_-b+l,k=w-S+l,Q=C-I+l,z=x-T+2*l,G=_-B+2*l,H=w-R+2*l,V=C-D+2*l,W=x-P+3*l,j=_-L+3*l,q=w-U+3*l,X=C-N+3*l,Y=x-1+4*l,J=_-1+4*l,K=w-1+4*l,Z=C-1+4*l,$=255&m,tt=255&g,et=255&A,nt=255&v,it=a[$+a[tt+a[et+a[nt]]]]%32,rt=a[$+M+a[tt+b+a[et+S+a[nt+I]]]]%32,st=a[$+T+a[tt+B+a[et+R+a[nt+D]]]]%32,at=a[$+P+a[tt+L+a[et+U+a[nt+N]]]]%32,ot=a[$+1+a[tt+1+a[et+1+a[nt+1]]]]%32;let lt=.6-x*x-_*_-w*w-C*C;lt<0?c=0:(lt*=lt,c=lt*lt*this.dot4(r[it],x,_,w,C));let ct=.6-F*F-O*O-k*k-Q*Q;ct<0?h=0:(ct*=ct,h=ct*ct*this.dot4(r[rt],F,O,k,Q));let ht=.6-z*z-G*G-H*H-V*V;ht<0?u=0:(ht*=ht,u=ht*ht*this.dot4(r[st],z,G,H,V));let ut=.6-W*W-j*j-q*q-X*X;ut<0?d=0:(ut*=ut,d=ut*ut*this.dot4(r[at],W,j,q,X));let dt=.6-Y*Y-J*J-K*K-Z*Z;return dt<0?p=0:(dt*=dt,p=dt*dt*this.dot4(r[ot],Y,J,K,Z)),27*(c+h+u+d+p)}}class km extends gm{constructor(t,e,n,i,r,s,a){super(),this.width=void 0!==n?n:512,this.height=void 0!==i?i:512,this.clear=!0,this.camera=e,this.scene=t,this.output=0,this._renderGBuffer=!0,this._visibilityCache=new Map,this.blendIntensity=1,this.pdRings=2,this.pdRadiusExponent=2,this.pdSamples=16,this.gtaoNoiseTexture=function(t=5){const e=Math.floor(t)%2==0?Math.floor(t)+1:Math.floor(t),n=function(t){const e=Math.floor(t)%2==0?Math.floor(t)+1:Math.floor(t),n=e*e,i=Array(n).fill(0);let r=Math.floor(e/2),s=e-1;for(let t=1;t<=n;)-1===r&&s===e?(s=e-2,r=0):(s===e&&(s=0),r<0&&(r=e-1)),0===i[r*e+s]?(i[r*e+s]=t++,s++,r--):(s-=2,r++);return i}(e),i=n.length,r=new Uint8Array(4*i);for(let t=0;t\n\t\t\t\tvarying vec2 vUv;\n\t\t\t\tuniform sampler2D colorTexture;\n\t\t\t\tuniform vec2 invSize;\n\t\t\t\tuniform vec2 direction;\n\t\t\t\tuniform float gaussianCoefficients[KERNEL_RADIUS];\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tfloat weightSum = gaussianCoefficients[0];\n\t\t\t\t\tvec3 diffuseSum = texture2D( colorTexture, vUv ).rgb * weightSum;\n\t\t\t\t\tfor( int i = 1; i < KERNEL_RADIUS; i ++ ) {\n\t\t\t\t\t\tfloat x = float(i);\n\t\t\t\t\t\tfloat w = gaussianCoefficients[i];\n\t\t\t\t\t\tvec2 uvOffset = direction * invSize * x;\n\t\t\t\t\t\tvec3 sample1 = texture2D( colorTexture, vUv + uvOffset ).rgb;\n\t\t\t\t\t\tvec3 sample2 = texture2D( colorTexture, vUv - uvOffset ).rgb;\n\t\t\t\t\t\tdiffuseSum += (sample1 + sample2) * w;\n\t\t\t\t\t\tweightSum += 2.0 * w;\n\t\t\t\t\t}\n\t\t\t\t\tgl_FragColor = vec4(diffuseSum/weightSum, 1.0);\n\t\t\t\t}"})}getCompositeMaterial(t){return new sa({defines:{NUM_MIPS:t},uniforms:{blurTexture1:{value:null},blurTexture2:{value:null},blurTexture3:{value:null},blurTexture4:{value:null},blurTexture5:{value:null},bloomStrength:{value:1},bloomFactors:{value:null},bloomTintColors:{value:null},bloomRadius:{value:0}},vertexShader:"varying vec2 vUv;\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"varying vec2 vUv;\n\t\t\t\tuniform sampler2D blurTexture1;\n\t\t\t\tuniform sampler2D blurTexture2;\n\t\t\t\tuniform sampler2D blurTexture3;\n\t\t\t\tuniform sampler2D blurTexture4;\n\t\t\t\tuniform sampler2D blurTexture5;\n\t\t\t\tuniform float bloomStrength;\n\t\t\t\tuniform float bloomRadius;\n\t\t\t\tuniform float bloomFactors[NUM_MIPS];\n\t\t\t\tuniform vec3 bloomTintColors[NUM_MIPS];\n\n\t\t\t\tfloat lerpBloomFactor(const in float factor) {\n\t\t\t\t\tfloat mirrorFactor = 1.2 - factor;\n\t\t\t\t\treturn mix(factor, mirrorFactor, bloomRadius);\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tgl_FragColor = bloomStrength * ( lerpBloomFactor(bloomFactors[0]) * vec4(bloomTintColors[0], 1.0) * texture2D(blurTexture1, vUv) +\n\t\t\t\t\t\tlerpBloomFactor(bloomFactors[1]) * vec4(bloomTintColors[1], 1.0) * texture2D(blurTexture2, vUv) +\n\t\t\t\t\t\tlerpBloomFactor(bloomFactors[2]) * vec4(bloomTintColors[2], 1.0) * texture2D(blurTexture3, vUv) +\n\t\t\t\t\t\tlerpBloomFactor(bloomFactors[3]) * vec4(bloomTintColors[3], 1.0) * texture2D(blurTexture4, vUv) +\n\t\t\t\t\t\tlerpBloomFactor(bloomFactors[4]) * vec4(bloomTintColors[4], 1.0) * texture2D(blurTexture5, vUv) );\n\t\t\t\t}"})}}zm.BlurDirectionX=new hi(1,0),zm.BlurDirectionY=new hi(0,1);const Gm={name:"SobelOperatorShader",uniforms:{tDiffuse:{value:null},resolution:{value:new hi}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\tuniform sampler2D tDiffuse;\n\t\tuniform vec2 resolution;\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvec2 texel = vec2( 1.0 / resolution.x, 1.0 / resolution.y );\n\n\t\t// kernel definition (in glsl matrices are filled in column-major order)\n\n\t\t\tconst mat3 Gx = mat3( -1, -2, -1, 0, 0, 0, 1, 2, 1 ); // x direction kernel\n\t\t\tconst mat3 Gy = mat3( -1, 0, 1, -2, 0, 2, -1, 0, 1 ); // y direction kernel\n\n\t\t// fetch the 3x3 neighbourhood of a fragment\n\n\t\t// first column\n\n\t\t\tfloat tx0y0 = texture2D( tDiffuse, vUv + texel * vec2( -1, -1 ) ).r;\n\t\t\tfloat tx0y1 = texture2D( tDiffuse, vUv + texel * vec2( -1, 0 ) ).r;\n\t\t\tfloat tx0y2 = texture2D( tDiffuse, vUv + texel * vec2( -1, 1 ) ).r;\n\n\t\t// second column\n\n\t\t\tfloat tx1y0 = texture2D( tDiffuse, vUv + texel * vec2( 0, -1 ) ).r;\n\t\t\tfloat tx1y1 = texture2D( tDiffuse, vUv + texel * vec2( 0, 0 ) ).r;\n\t\t\tfloat tx1y2 = texture2D( tDiffuse, vUv + texel * vec2( 0, 1 ) ).r;\n\n\t\t// third column\n\n\t\t\tfloat tx2y0 = texture2D( tDiffuse, vUv + texel * vec2( 1, -1 ) ).r;\n\t\t\tfloat tx2y1 = texture2D( tDiffuse, vUv + texel * vec2( 1, 0 ) ).r;\n\t\t\tfloat tx2y2 = texture2D( tDiffuse, vUv + texel * vec2( 1, 1 ) ).r;\n\n\t\t// gradient value in x direction\n\n\t\t\tfloat valueGx = Gx[0][0] * tx0y0 + Gx[1][0] * tx1y0 + Gx[2][0] * tx2y0 +\n\t\t\t\tGx[0][1] * tx0y1 + Gx[1][1] * tx1y1 + Gx[2][1] * tx2y1 +\n\t\t\t\tGx[0][2] * tx0y2 + Gx[1][2] * tx1y2 + Gx[2][2] * tx2y2;\n\n\t\t// gradient value in y direction\n\n\t\t\tfloat valueGy = Gy[0][0] * tx0y0 + Gy[1][0] * tx1y0 + Gy[2][0] * tx2y0 +\n\t\t\t\tGy[0][1] * tx0y1 + Gy[1][1] * tx1y1 + Gy[2][1] * tx2y1 +\n\t\t\t\tGy[0][2] * tx0y2 + Gy[1][2] * tx1y2 + Gy[2][2] * tx2y2;\n\n\t\t// magnitute of the total gradient\n\n\t\t\tfloat G = sqrt( ( valueGx * valueGx ) + ( valueGy * valueGy ) );\n\n\t\t\tgl_FragColor = vec4( vec3( G ), 1 );\n\n\t\t}"},Hm={name:"SSRShader",defines:{MAX_STEP:0,PERSPECTIVE_CAMERA:!0,DISTANCE_ATTENUATION:!0,FRESNEL:!0,INFINITE_THICK:!1,SELECTIVE:!1},uniforms:{tDiffuse:{value:null},tNormal:{value:null},tMetalness:{value:null},tDepth:{value:null},cameraNear:{value:null},cameraFar:{value:null},resolution:{value:new hi},cameraProjectionMatrix:{value:new yr},cameraInverseProjectionMatrix:{value:new yr},opacity:{value:.5},maxDistance:{value:180},cameraRange:{value:0},thickness:{value:.018}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}\n\n\t",fragmentShader:'\n\t\t// precision highp float;\n\t\tprecision highp sampler2D;\n\t\tvarying vec2 vUv;\n\t\tuniform sampler2D tDepth;\n\t\tuniform sampler2D tNormal;\n\t\tuniform sampler2D tMetalness;\n\t\tuniform sampler2D tDiffuse;\n\t\tuniform float cameraRange;\n\t\tuniform vec2 resolution;\n\t\tuniform float opacity;\n\t\tuniform float cameraNear;\n\t\tuniform float cameraFar;\n\t\tuniform float maxDistance;\n\t\tuniform float thickness;\n\t\tuniform mat4 cameraProjectionMatrix;\n\t\tuniform mat4 cameraInverseProjectionMatrix;\n\t\t#include \n\t\tfloat pointToLineDistance(vec3 x0, vec3 x1, vec3 x2) {\n\t\t\t//x0: point, x1: linePointA, x2: linePointB\n\t\t\t//https://mathworld.wolfram.com/Point-LineDistance3-Dimensional.html\n\t\t\treturn length(cross(x0-x1,x0-x2))/length(x2-x1);\n\t\t}\n\t\tfloat pointPlaneDistance(vec3 point,vec3 planePoint,vec3 planeNormal){\n\t\t\t// https://mathworld.wolfram.com/Point-PlaneDistance.html\n\t\t\t//// https://en.wikipedia.org/wiki/Plane_(geometry)\n\t\t\t//// http://paulbourke.net/geometry/pointlineplane/\n\t\t\tfloat a=planeNormal.x,b=planeNormal.y,c=planeNormal.z;\n\t\t\tfloat x0=point.x,y0=point.y,z0=point.z;\n\t\t\tfloat x=planePoint.x,y=planePoint.y,z=planePoint.z;\n\t\t\tfloat d=-(a*x+b*y+c*z);\n\t\t\tfloat distance=(a*x0+b*y0+c*z0+d)/sqrt(a*a+b*b+c*c);\n\t\t\treturn distance;\n\t\t}\n\t\tfloat getDepth( const in vec2 uv ) {\n\t\t\treturn texture2D( tDepth, uv ).x;\n\t\t}\n\t\tfloat getViewZ( const in float depth ) {\n\t\t\t#ifdef PERSPECTIVE_CAMERA\n\t\t\t\treturn perspectiveDepthToViewZ( depth, cameraNear, cameraFar );\n\t\t\t#else\n\t\t\t\treturn orthographicDepthToViewZ( depth, cameraNear, cameraFar );\n\t\t\t#endif\n\t\t}\n\t\tvec3 getViewPosition( const in vec2 uv, const in float depth/*clip space*/, const in float clipW ) {\n\t\t\tvec4 clipPosition = vec4( ( vec3( uv, depth ) - 0.5 ) * 2.0, 1.0 );//ndc\n\t\t\tclipPosition *= clipW; //clip\n\t\t\treturn ( cameraInverseProjectionMatrix * clipPosition ).xyz;//view\n\t\t}\n\t\tvec3 getViewNormal( const in vec2 uv ) {\n\t\t\treturn unpackRGBToNormal( texture2D( tNormal, uv ).xyz );\n\t\t}\n\t\tvec2 viewPositionToXY(vec3 viewPosition){\n\t\t\tvec2 xy;\n\t\t\tvec4 clip=cameraProjectionMatrix*vec4(viewPosition,1);\n\t\t\txy=clip.xy;//clip\n\t\t\tfloat clipW=clip.w;\n\t\t\txy/=clipW;//NDC\n\t\t\txy=(xy+1.)/2.;//uv\n\t\t\txy*=resolution;//screen\n\t\t\treturn xy;\n\t\t}\n\t\tvoid main(){\n\t\t\t#ifdef SELECTIVE\n\t\t\t\tfloat metalness=texture2D(tMetalness,vUv).r;\n\t\t\t\tif(metalness==0.) return;\n\t\t\t#endif\n\n\t\t\tfloat depth = getDepth( vUv );\n\t\t\tfloat viewZ = getViewZ( depth );\n\t\t\tif(-viewZ>=cameraFar) return;\n\n\t\t\tfloat clipW = cameraProjectionMatrix[2][3] * viewZ+cameraProjectionMatrix[3][3];\n\t\t\tvec3 viewPosition=getViewPosition( vUv, depth, clipW );\n\n\t\t\tvec2 d0=gl_FragCoord.xy;\n\t\t\tvec2 d1;\n\n\t\t\tvec3 viewNormal=getViewNormal( vUv );\n\n\t\t\t#ifdef PERSPECTIVE_CAMERA\n\t\t\t\tvec3 viewIncidentDir=normalize(viewPosition);\n\t\t\t\tvec3 viewReflectDir=reflect(viewIncidentDir,viewNormal);\n\t\t\t#else\n\t\t\t\tvec3 viewIncidentDir=vec3(0,0,-1);\n\t\t\t\tvec3 viewReflectDir=reflect(viewIncidentDir,viewNormal);\n\t\t\t#endif\n\n\t\t\tfloat maxReflectRayLen=maxDistance/dot(-viewIncidentDir,viewNormal);\n\t\t\t// dot(a,b)==length(a)*length(b)*cos(theta) // https://www.mathsisfun.com/algebra/vectors-dot-product.html\n\t\t\t// if(a.isNormalized&&b.isNormalized) dot(a,b)==cos(theta)\n\t\t\t// maxDistance/maxReflectRayLen=cos(theta)\n\t\t\t// maxDistance/maxReflectRayLen==dot(a,b)\n\t\t\t// maxReflectRayLen==maxDistance/dot(a,b)\n\n\t\t\tvec3 d1viewPosition=viewPosition+viewReflectDir*maxReflectRayLen;\n\t\t\t#ifdef PERSPECTIVE_CAMERA\n\t\t\t\tif(d1viewPosition.z>-cameraNear){\n\t\t\t\t\t//https://tutorial.math.lamar.edu/Classes/CalcIII/EqnsOfLines.aspx\n\t\t\t\t\tfloat t=(-cameraNear-viewPosition.z)/viewReflectDir.z;\n\t\t\t\t\td1viewPosition=viewPosition+viewReflectDir*t;\n\t\t\t\t}\n\t\t\t#endif\n\t\t\td1=viewPositionToXY(d1viewPosition);\n\n\t\t\tfloat totalLen=length(d1-d0);\n\t\t\tfloat xLen=d1.x-d0.x;\n\t\t\tfloat yLen=d1.y-d0.y;\n\t\t\tfloat totalStep=max(abs(xLen),abs(yLen));\n\t\t\tfloat xSpan=xLen/totalStep;\n\t\t\tfloat ySpan=yLen/totalStep;\n\t\t\tfor(float i=0.;i=totalStep) break;\n\t\t\t\tvec2 xy=vec2(d0.x+i*xSpan,d0.y+i*ySpan);\n\t\t\t\tif(xy.x<0.||xy.x>resolution.x||xy.y<0.||xy.y>resolution.y) break;\n\t\t\t\tfloat s=length(xy-d0)/totalLen;\n\t\t\t\tvec2 uv=xy/resolution;\n\n\t\t\t\tfloat d = getDepth(uv);\n\t\t\t\tfloat vZ = getViewZ( d );\n\t\t\t\tif(-vZ>=cameraFar) continue;\n\t\t\t\tfloat cW = cameraProjectionMatrix[2][3] * vZ+cameraProjectionMatrix[3][3];\n\t\t\t\tvec3 vP=getViewPosition( uv, d, cW );\n\n\t\t\t\t#ifdef PERSPECTIVE_CAMERA\n\t\t\t\t\t// https://comp.nus.edu.sg/~lowkl/publications/lowk_persp_interp_techrep.pdf\n\t\t\t\t\tfloat recipVPZ=1./viewPosition.z;\n\t\t\t\t\tfloat viewReflectRayZ=1./(recipVPZ+s*(1./d1viewPosition.z-recipVPZ));\n\t\t\t\t#else\n\t\t\t\t\tfloat viewReflectRayZ=viewPosition.z+s*(d1viewPosition.z-viewPosition.z);\n\t\t\t\t#endif\n\n\t\t\t\t// if(viewReflectRayZ>vZ) continue; // will cause "npm run make-screenshot webgl_postprocessing_ssr" high probability hang.\n\t\t\t\t// https://github.com/mrdoob/three.js/pull/21539#issuecomment-821061164\n\t\t\t\tif(viewReflectRayZ<=vZ){\n\n\t\t\t\t\tbool hit;\n\t\t\t\t\t#ifdef INFINITE_THICK\n\t\t\t\t\t\thit=true;\n\t\t\t\t\t#else\n\t\t\t\t\t\tfloat away=pointToLineDistance(vP,viewPosition,d1viewPosition);\n\n\t\t\t\t\t\tfloat minThickness;\n\t\t\t\t\t\tvec2 xyNeighbor=xy;\n\t\t\t\t\t\txyNeighbor.x+=1.;\n\t\t\t\t\t\tvec2 uvNeighbor=xyNeighbor/resolution;\n\t\t\t\t\t\tvec3 vPNeighbor=getViewPosition(uvNeighbor,d,cW);\n\t\t\t\t\t\tminThickness=vPNeighbor.x-vP.x;\n\t\t\t\t\t\tminThickness*=3.;\n\t\t\t\t\t\tfloat tk=max(minThickness,thickness);\n\n\t\t\t\t\t\thit=away<=tk;\n\t\t\t\t\t#endif\n\n\t\t\t\t\tif(hit){\n\t\t\t\t\t\tvec3 vN=getViewNormal( uv );\n\t\t\t\t\t\tif(dot(viewReflectDir,vN)>=0.) continue;\n\t\t\t\t\t\tfloat distance=pointPlaneDistance(vP,viewPosition,viewNormal);\n\t\t\t\t\t\tif(distance>maxDistance) break;\n\t\t\t\t\t\tfloat op=opacity;\n\t\t\t\t\t\t#ifdef DISTANCE_ATTENUATION\n\t\t\t\t\t\t\tfloat ratio=1.-(distance/maxDistance);\n\t\t\t\t\t\t\tfloat attenuation=ratio*ratio;\n\t\t\t\t\t\t\top=opacity*attenuation;\n\t\t\t\t\t\t#endif\n\t\t\t\t\t\t#ifdef FRESNEL\n\t\t\t\t\t\t\tfloat fresnelCoe=(dot(viewIncidentDir,viewReflectDir)+1.)/2.;\n\t\t\t\t\t\t\top*=fresnelCoe;\n\t\t\t\t\t\t#endif\n\t\t\t\t\t\tvec4 reflectColor=texture2D(tDiffuse,uv);\n\t\t\t\t\t\tgl_FragColor.xyz=reflectColor.xyz;\n\t\t\t\t\t\tgl_FragColor.a=op;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t'},Vm={PERSPECTIVE_CAMERA:1},Wm={tDepth:{value:null},cameraNear:{value:null},cameraFar:{value:null}},jm="\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}\n\n\t",qm="\n\n\t\tuniform sampler2D tDepth;\n\n\t\tuniform float cameraNear;\n\t\tuniform float cameraFar;\n\n\t\tvarying vec2 vUv;\n\n\t\t#include \n\n\t\tfloat getLinearDepth( const in vec2 uv ) {\n\n\t\t\t#if PERSPECTIVE_CAMERA == 1\n\n\t\t\t\tfloat fragCoordZ = texture2D( tDepth, uv ).x;\n\t\t\t\tfloat viewZ = perspectiveDepthToViewZ( fragCoordZ, cameraNear, cameraFar );\n\t\t\t\treturn viewZToOrthographicDepth( viewZ, cameraNear, cameraFar );\n\n\t\t\t#else\n\n\t\t\t\treturn texture2D( tDepth, uv ).x;\n\n\t\t\t#endif\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tfloat depth = getLinearDepth( vUv );\n\t\t\tfloat d = 1.0 - depth;\n\t\t\t// d=(d-.999)*1000.;\n\t\t\tgl_FragColor = vec4( vec3( d ), 1.0 );\n\n\t\t}\n\n\t",Xm={name:"SSRBlurShader",uniforms:{tDiffuse:{value:null},resolution:{value:new hi},opacity:{value:.5}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}\n\n\t",fragmentShader:"\n\n\t\tuniform sampler2D tDiffuse;\n\t\tuniform vec2 resolution;\n\t\tvarying vec2 vUv;\n\t\tvoid main() {\n\t\t\t//reverse engineering from PhotoShop blur filter, then change coefficient\n\n\t\t\tvec2 texelSize = ( 1.0 / resolution );\n\n\t\t\tvec4 c=texture2D(tDiffuse,vUv);\n\n\t\t\tvec2 offset;\n\n\t\t\toffset=(vec2(-1,0))*texelSize;\n\t\t\tvec4 cl=texture2D(tDiffuse,vUv+offset);\n\n\t\t\toffset=(vec2(1,0))*texelSize;\n\t\t\tvec4 cr=texture2D(tDiffuse,vUv+offset);\n\n\t\t\toffset=(vec2(0,-1))*texelSize;\n\t\t\tvec4 cb=texture2D(tDiffuse,vUv+offset);\n\n\t\t\toffset=(vec2(0,1))*texelSize;\n\t\t\tvec4 ct=texture2D(tDiffuse,vUv+offset);\n\n\t\t\t// float coeCenter=.5;\n\t\t\t// float coeSide=.125;\n\t\t\tfloat coeCenter=.2;\n\t\t\tfloat coeSide=.2;\n\t\t\tfloat a=c.a*coeCenter+cl.a*coeSide+cr.a*coeSide+cb.a*coeSide+ct.a*coeSide;\n\t\t\tvec3 rgb=(c.rgb*c.a*coeCenter+cl.rgb*cl.a*coeSide+cr.rgb*cr.a*coeSide+cb.rgb*cb.a*coeSide+ct.rgb*ct.a*coeSide)/a;\n\t\t\tgl_FragColor=vec4(rgb,a);\n\n\t\t}\n\t"};class Ym extends gm{constructor({renderer:t,scene:e,camera:n,width:i,height:r,selects:s,bouncing:a=!1,groundReflector:o}){super(),this.width=void 0!==i?i:512,this.height=void 0!==r?r:512,this.clear=!0,this.renderer=t,this.scene=e,this.camera=n,this.groundReflector=o,this.opacity=Hm.uniforms.opacity.value,this.output=0,this.maxDistance=Hm.uniforms.maxDistance.value,this.thickness=Hm.uniforms.thickness.value,this.tempColor=new us,this._selects=s,this.selective=Array.isArray(this._selects),Object.defineProperty(this,"selects",{get(){return this._selects},set(t){this._selects!==t&&(this._selects=t,Array.isArray(t)?(this.selective=!0,this.ssrMaterial.defines.SELECTIVE=!0,this.ssrMaterial.needsUpdate=!0):(this.selective=!1,this.ssrMaterial.defines.SELECTIVE=!1,this.ssrMaterial.needsUpdate=!0))}}),this._bouncing=a,Object.defineProperty(this,"bouncing",{get(){return this._bouncing},set(t){this._bouncing!==t&&(this._bouncing=t,this.ssrMaterial.uniforms.tDiffuse.value=t?this.prevRenderTarget.texture:this.beautyRenderTarget.texture)}}),this.blur=!0,this._distanceAttenuation=Hm.defines.DISTANCE_ATTENUATION,Object.defineProperty(this,"distanceAttenuation",{get(){return this._distanceAttenuation},set(t){this._distanceAttenuation!==t&&(this._distanceAttenuation=t,this.ssrMaterial.defines.DISTANCE_ATTENUATION=t,this.ssrMaterial.needsUpdate=!0)}}),this._fresnel=Hm.defines.FRESNEL,Object.defineProperty(this,"fresnel",{get(){return this._fresnel},set(t){this._fresnel!==t&&(this._fresnel=t,this.ssrMaterial.defines.FRESNEL=t,this.ssrMaterial.needsUpdate=!0)}}),this._infiniteThick=Hm.defines.INFINITE_THICK,Object.defineProperty(this,"infiniteThick",{get(){return this._infiniteThick},set(t){this._infiniteThick!==t&&(this._infiniteThick=t,this.ssrMaterial.defines.INFINITE_THICK=t,this.ssrMaterial.needsUpdate=!0)}});const l=new ao;l.type=Ht,l.minFilter=Bt,l.magFilter=Bt,this.beautyRenderTarget=new Fi(this.width,this.height,{minFilter:Bt,magFilter:Bt,type:qt,depthTexture:l,depthBuffer:!0}),this.prevRenderTarget=new Fi(this.width,this.height,{minFilter:Bt,magFilter:Bt}),this.normalRenderTarget=new Fi(this.width,this.height,{minFilter:Bt,magFilter:Bt,type:qt}),this.metalnessRenderTarget=new Fi(this.width,this.height,{minFilter:Bt,magFilter:Bt,type:qt}),this.ssrRenderTarget=new Fi(this.width,this.height,{minFilter:Bt,magFilter:Bt}),this.blurRenderTarget=this.ssrRenderTarget.clone(),this.blurRenderTarget2=this.ssrRenderTarget.clone(),this.ssrMaterial=new sa({defines:Object.assign({},Hm.defines,{MAX_STEP:Math.sqrt(this.width*this.width+this.height*this.height)}),uniforms:ra.clone(Hm.uniforms),vertexShader:Hm.vertexShader,fragmentShader:Hm.fragmentShader,blending:I}),this.ssrMaterial.uniforms.tDiffuse.value=this.beautyRenderTarget.texture,this.ssrMaterial.uniforms.tNormal.value=this.normalRenderTarget.texture,this.ssrMaterial.defines.SELECTIVE=this.selective,this.ssrMaterial.needsUpdate=!0,this.ssrMaterial.uniforms.tMetalness.value=this.metalnessRenderTarget.texture,this.ssrMaterial.uniforms.tDepth.value=this.beautyRenderTarget.depthTexture,this.ssrMaterial.uniforms.cameraNear.value=this.camera.near,this.ssrMaterial.uniforms.cameraFar.value=this.camera.far,this.ssrMaterial.uniforms.thickness.value=this.thickness,this.ssrMaterial.uniforms.resolution.value.set(this.width,this.height),this.ssrMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.ssrMaterial.uniforms.cameraInverseProjectionMatrix.value.copy(this.camera.projectionMatrixInverse),this.normalMaterial=new Sd,this.normalMaterial.blending=I,this.metalnessOnMaterial=new ms({color:"white"}),this.metalnessOffMaterial=new ms({color:"black"}),this.blurMaterial=new sa({defines:Object.assign({},Xm.defines),uniforms:ra.clone(Xm.uniforms),vertexShader:Xm.vertexShader,fragmentShader:Xm.fragmentShader}),this.blurMaterial.uniforms.tDiffuse.value=this.ssrRenderTarget.texture,this.blurMaterial.uniforms.resolution.value.set(this.width,this.height),this.blurMaterial2=new sa({defines:Object.assign({},Xm.defines),uniforms:ra.clone(Xm.uniforms),vertexShader:Xm.vertexShader,fragmentShader:Xm.fragmentShader}),this.blurMaterial2.uniforms.tDiffuse.value=this.blurRenderTarget.texture,this.blurMaterial2.uniforms.resolution.value.set(this.width,this.height),this.depthRenderMaterial=new sa({defines:Object.assign({},Vm),uniforms:ra.clone(Wm),vertexShader:jm,fragmentShader:qm,blending:I}),this.depthRenderMaterial.uniforms.tDepth.value=this.beautyRenderTarget.depthTexture,this.depthRenderMaterial.uniforms.cameraNear.value=this.camera.near,this.depthRenderMaterial.uniforms.cameraFar.value=this.camera.far,this.copyMaterial=new sa({uniforms:ra.clone(mm.uniforms),vertexShader:mm.vertexShader,fragmentShader:mm.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blendSrc:H,blendDst:V,blendEquation:L,blendSrcAlpha:H,blendDstAlpha:V,blendEquationAlpha:L}),this.fsQuad=new ym(null),this.originalClearColor=new us}dispose(){this.beautyRenderTarget.dispose(),this.prevRenderTarget.dispose(),this.normalRenderTarget.dispose(),this.metalnessRenderTarget.dispose(),this.ssrRenderTarget.dispose(),this.blurRenderTarget.dispose(),this.blurRenderTarget2.dispose(),this.normalMaterial.dispose(),this.metalnessOnMaterial.dispose(),this.metalnessOffMaterial.dispose(),this.blurMaterial.dispose(),this.blurMaterial2.dispose(),this.copyMaterial.dispose(),this.depthRenderMaterial.dispose(),this.fsQuad.dispose()}render(t,e){switch(t.setRenderTarget(this.beautyRenderTarget),t.clear(),this.groundReflector&&(this.groundReflector.visible=!1,this.groundReflector.doRender(this.renderer,this.scene,this.camera),this.groundReflector.visible=!0),t.render(this.scene,this.camera),this.groundReflector&&(this.groundReflector.visible=!1),this.renderOverride(t,this.normalMaterial,this.normalRenderTarget,0,0),this.selective&&this.renderMetalness(t,this.metalnessOnMaterial,this.metalnessRenderTarget,0,0),this.ssrMaterial.uniforms.opacity.value=this.opacity,this.ssrMaterial.uniforms.maxDistance.value=this.maxDistance,this.ssrMaterial.uniforms.thickness.value=this.thickness,this.renderPass(t,this.ssrMaterial,this.ssrRenderTarget),this.blur&&(this.renderPass(t,this.blurMaterial,this.blurRenderTarget),this.renderPass(t,this.blurMaterial2,this.blurRenderTarget2)),this.output){case Ym.OUTPUT.Default:this.bouncing?(this.copyMaterial.uniforms.tDiffuse.value=this.beautyRenderTarget.texture,this.copyMaterial.blending=I,this.renderPass(t,this.copyMaterial,this.prevRenderTarget),this.blur?this.copyMaterial.uniforms.tDiffuse.value=this.blurRenderTarget2.texture:this.copyMaterial.uniforms.tDiffuse.value=this.ssrRenderTarget.texture,this.copyMaterial.blending=T,this.renderPass(t,this.copyMaterial,this.prevRenderTarget),this.copyMaterial.uniforms.tDiffuse.value=this.prevRenderTarget.texture,this.copyMaterial.blending=I,this.renderPass(t,this.copyMaterial,this.renderToScreen?null:e)):(this.copyMaterial.uniforms.tDiffuse.value=this.beautyRenderTarget.texture,this.copyMaterial.blending=I,this.renderPass(t,this.copyMaterial,this.renderToScreen?null:e),this.blur?this.copyMaterial.uniforms.tDiffuse.value=this.blurRenderTarget2.texture:this.copyMaterial.uniforms.tDiffuse.value=this.ssrRenderTarget.texture,this.copyMaterial.blending=T,this.renderPass(t,this.copyMaterial,this.renderToScreen?null:e));break;case Ym.OUTPUT.SSR:this.blur?this.copyMaterial.uniforms.tDiffuse.value=this.blurRenderTarget2.texture:this.copyMaterial.uniforms.tDiffuse.value=this.ssrRenderTarget.texture,this.copyMaterial.blending=I,this.renderPass(t,this.copyMaterial,this.renderToScreen?null:e),this.bouncing&&(this.blur?this.copyMaterial.uniforms.tDiffuse.value=this.blurRenderTarget2.texture:this.copyMaterial.uniforms.tDiffuse.value=this.beautyRenderTarget.texture,this.copyMaterial.blending=I,this.renderPass(t,this.copyMaterial,this.prevRenderTarget),this.copyMaterial.uniforms.tDiffuse.value=this.ssrRenderTarget.texture,this.copyMaterial.blending=T,this.renderPass(t,this.copyMaterial,this.prevRenderTarget));break;case Ym.OUTPUT.Beauty:this.copyMaterial.uniforms.tDiffuse.value=this.beautyRenderTarget.texture,this.copyMaterial.blending=I,this.renderPass(t,this.copyMaterial,this.renderToScreen?null:e);break;case Ym.OUTPUT.Depth:this.renderPass(t,this.depthRenderMaterial,this.renderToScreen?null:e);break;case Ym.OUTPUT.Normal:this.copyMaterial.uniforms.tDiffuse.value=this.normalRenderTarget.texture,this.copyMaterial.blending=I,this.renderPass(t,this.copyMaterial,this.renderToScreen?null:e);break;case Ym.OUTPUT.Metalness:this.copyMaterial.uniforms.tDiffuse.value=this.metalnessRenderTarget.texture,this.copyMaterial.blending=I,this.renderPass(t,this.copyMaterial,this.renderToScreen?null:e);break;default:console.warn("THREE.SSRPass: Unknown output type.")}}renderPass(t,e,n,i,r){this.originalClearColor.copy(t.getClearColor(this.tempColor));const s=t.getClearAlpha(this.tempColor),a=t.autoClear;t.setRenderTarget(n),t.autoClear=!1,null!=i&&(t.setClearColor(i),t.setClearAlpha(r||0),t.clear()),this.fsQuad.material=e,this.fsQuad.render(t),t.autoClear=a,t.setClearColor(this.originalClearColor),t.setClearAlpha(s)}renderOverride(t,e,n,i,r){this.originalClearColor.copy(t.getClearColor(this.tempColor));const s=t.getClearAlpha(this.tempColor),a=t.autoClear;t.setRenderTarget(n),t.autoClear=!1,i=e.clearColor||i,r=e.clearAlpha||r,null!=i&&(t.setClearColor(i),t.setClearAlpha(r||0),t.clear()),this.scene.overrideMaterial=e,t.render(this.scene,this.camera),this.scene.overrideMaterial=null,t.autoClear=a,t.setClearColor(this.originalClearColor),t.setClearAlpha(s)}renderMetalness(t,e,n,i,r){this.originalClearColor.copy(t.getClearColor(this.tempColor));const s=t.getClearAlpha(this.tempColor),a=t.autoClear,o=this.scene.background,l=this.scene.fog;t.setRenderTarget(n),t.autoClear=!1,this.scene.background=null,this.scene.fog=null,i=e.clearColor||i,r=e.clearAlpha||r,null!=i&&(t.setClearColor(i),t.setClearAlpha(r||0),t.clear()),this.scene.traverseVisible((t=>{t._SSRPassBackupMaterial=t.material,this._selects.includes(t)?t.material=this.metalnessOnMaterial:t.material=this.metalnessOffMaterial})),t.render(this.scene,this.camera),this.scene.traverseVisible((t=>{t.material=t._SSRPassBackupMaterial})),t.autoClear=a,t.setClearColor(this.originalClearColor),t.setClearAlpha(s),this.scene.background=o,this.scene.fog=l}setSize(t,e){this.width=t,this.height=e,this.ssrMaterial.defines.MAX_STEP=Math.sqrt(t*t+e*e),this.ssrMaterial.needsUpdate=!0,this.beautyRenderTarget.setSize(t,e),this.prevRenderTarget.setSize(t,e),this.ssrRenderTarget.setSize(t,e),this.normalRenderTarget.setSize(t,e),this.metalnessRenderTarget.setSize(t,e),this.blurRenderTarget.setSize(t,e),this.blurRenderTarget2.setSize(t,e),this.ssrMaterial.uniforms.resolution.value.set(t,e),this.ssrMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.ssrMaterial.uniforms.cameraInverseProjectionMatrix.value.copy(this.camera.projectionMatrixInverse),this.blurMaterial.uniforms.resolution.value.set(t,e),this.blurMaterial2.uniforms.resolution.value.set(t,e)}}Ym.OUTPUT={Default:0,SSR:1,Beauty:3,Depth:4,Normal:5,Metalness:7};const Jm={name:"BokehShader",defines:{DEPTH_PACKING:1,PERSPECTIVE_CAMERA:1},uniforms:{tColor:{value:null},tDepth:{value:null},focus:{value:1},aspect:{value:1},aperture:{value:.025},maxblur:{value:.01},nearClip:{value:1},farClip:{value:1e3}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\t#include \n\n\t\tvarying vec2 vUv;\n\n\t\tuniform sampler2D tColor;\n\t\tuniform sampler2D tDepth;\n\n\t\tuniform float maxblur; // max blur amount\n\t\tuniform float aperture; // aperture - bigger values for shallower depth of field\n\n\t\tuniform float nearClip;\n\t\tuniform float farClip;\n\n\t\tuniform float focus;\n\t\tuniform float aspect;\n\n\t\t#include \n\n\t\tfloat getDepth( const in vec2 screenPosition ) {\n\t\t\t#if DEPTH_PACKING == 1\n\t\t\treturn unpackRGBAToDepth( texture2D( tDepth, screenPosition ) );\n\t\t\t#else\n\t\t\treturn texture2D( tDepth, screenPosition ).x;\n\t\t\t#endif\n\t\t}\n\n\t\tfloat getViewZ( const in float depth ) {\n\t\t\t#if PERSPECTIVE_CAMERA == 1\n\t\t\treturn perspectiveDepthToViewZ( depth, nearClip, farClip );\n\t\t\t#else\n\t\t\treturn orthographicDepthToViewZ( depth, nearClip, farClip );\n\t\t\t#endif\n\t\t}\n\n\n\t\tvoid main() {\n\n\t\t\tvec2 aspectcorrect = vec2( 1.0, aspect );\n\n\t\t\tfloat viewZ = getViewZ( getDepth( vUv ) );\n\n\t\t\tfloat factor = ( focus + viewZ ); // viewZ is <= 0, so this is a difference equation\n\n\t\t\tvec2 dofblur = vec2 ( clamp( factor * aperture, -maxblur, maxblur ) );\n\n\t\t\tvec2 dofblur9 = dofblur * 0.9;\n\t\t\tvec2 dofblur7 = dofblur * 0.7;\n\t\t\tvec2 dofblur4 = dofblur * 0.4;\n\n\t\t\tvec4 col = vec4( 0.0 );\n\n\t\t\tcol += texture2D( tColor, vUv.xy );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.0, 0.4 ) * aspectcorrect ) * dofblur );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.15, 0.37 ) * aspectcorrect ) * dofblur );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.29, 0.29 ) * aspectcorrect ) * dofblur );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.37, 0.15 ) * aspectcorrect ) * dofblur );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.40, 0.0 ) * aspectcorrect ) * dofblur );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.37, -0.15 ) * aspectcorrect ) * dofblur );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.29, -0.29 ) * aspectcorrect ) * dofblur );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.15, -0.37 ) * aspectcorrect ) * dofblur );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.0, -0.4 ) * aspectcorrect ) * dofblur );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.15, 0.37 ) * aspectcorrect ) * dofblur );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.29, 0.29 ) * aspectcorrect ) * dofblur );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.37, 0.15 ) * aspectcorrect ) * dofblur );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.4, 0.0 ) * aspectcorrect ) * dofblur );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.37, -0.15 ) * aspectcorrect ) * dofblur );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.29, -0.29 ) * aspectcorrect ) * dofblur );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.15, -0.37 ) * aspectcorrect ) * dofblur );\n\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.15, 0.37 ) * aspectcorrect ) * dofblur9 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.37, 0.15 ) * aspectcorrect ) * dofblur9 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.37, -0.15 ) * aspectcorrect ) * dofblur9 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.15, -0.37 ) * aspectcorrect ) * dofblur9 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.15, 0.37 ) * aspectcorrect ) * dofblur9 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.37, 0.15 ) * aspectcorrect ) * dofblur9 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.37, -0.15 ) * aspectcorrect ) * dofblur9 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.15, -0.37 ) * aspectcorrect ) * dofblur9 );\n\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.29, 0.29 ) * aspectcorrect ) * dofblur7 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.40, 0.0 ) * aspectcorrect ) * dofblur7 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.29, -0.29 ) * aspectcorrect ) * dofblur7 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.0, -0.4 ) * aspectcorrect ) * dofblur7 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.29, 0.29 ) * aspectcorrect ) * dofblur7 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.4, 0.0 ) * aspectcorrect ) * dofblur7 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.29, -0.29 ) * aspectcorrect ) * dofblur7 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.0, 0.4 ) * aspectcorrect ) * dofblur7 );\n\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.29, 0.29 ) * aspectcorrect ) * dofblur4 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.4, 0.0 ) * aspectcorrect ) * dofblur4 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.29, -0.29 ) * aspectcorrect ) * dofblur4 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.0, -0.4 ) * aspectcorrect ) * dofblur4 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.29, 0.29 ) * aspectcorrect ) * dofblur4 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.4, 0.0 ) * aspectcorrect ) * dofblur4 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.29, -0.29 ) * aspectcorrect ) * dofblur4 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.0, 0.4 ) * aspectcorrect ) * dofblur4 );\n\n\t\t\tgl_FragColor = col / 41.0;\n\t\t\tgl_FragColor.a = 1.0;\n\n\t\t}"},Km=new yr;class Zm{constructor(t){t=t||{},this.zNear=!0===t.webGL?-1:0,this.vertices={near:[new Hi,new Hi,new Hi,new Hi],far:[new Hi,new Hi,new Hi,new Hi]},void 0!==t.projectionMatrix&&this.setFromProjectionMatrix(t.projectionMatrix,t.maxFar||1e4)}setFromProjectionMatrix(t,e){const n=this.zNear,i=0===t.elements[11];return Km.copy(t).invert(),this.vertices.near[0].set(1,1,n),this.vertices.near[1].set(1,-1,n),this.vertices.near[2].set(-1,-1,n),this.vertices.near[3].set(-1,1,n),this.vertices.near.forEach((function(t){t.applyMatrix4(Km)})),this.vertices.far[0].set(1,1,1),this.vertices.far[1].set(1,-1,1),this.vertices.far[2].set(-1,-1,1),this.vertices.far[3].set(-1,1,1),this.vertices.far.forEach((function(t){t.applyMatrix4(Km);const n=Math.abs(t.z);i?t.z*=Math.min(e/n,1):t.multiplyScalar(Math.min(e/n,1))})),this.vertices}split(t,e){for(;t.length>e.length;)e.push(new Zm);e.length=t.length;for(let n=0;n 0.0 ) {\n\t\tmaterial.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\t// Iridescence F0 approximation\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\n\nIncidentLight directLight;\n\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\n\t\tpointLight = pointLights[ i ];\n\n\t\tgetPointLightInfo( pointLight, geometryPosition, directLight );\n\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\n\tSpotLight spotLight;\n \tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\n\t\tspotLight = spotLights[ i ];\n\n\t\tgetSpotLightInfo( spotLight, geometryPosition, directLight );\n\n \t\t// spot lights are ordered [shadows with maps, shadows without maps, maps without shadows, none]\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\n\t\t#endif\n\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) && defined( USE_CSM ) && defined( CSM_CASCADES )\n\n\tDirectionalLight directionalLight;\n\tfloat linearDepth = (vViewPosition.z) / (shadowFar - cameraNear);\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\n\t#if defined( USE_SHADOWMAP ) && defined( CSM_FADE )\n\t\tvec2 cascade;\n\t\tfloat cascadeCenter;\n\t\tfloat closestEdge;\n\t\tfloat margin;\n\t\tfloat csmx;\n\t\tfloat csmy;\n\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\n\t\t\tdirectionalLight = directionalLights[ i ];\n\t\t\tgetDirectionalLightInfo( directionalLight, directLight );\n\n\t\t\t#if ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\t\t\t// NOTE: Depth gets larger away from the camera.\n\t\t\t\t// cascade.x is closer, cascade.y is further\n\t\t\t\tcascade = CSM_cascades[ i ];\n\t\t\t\tcascadeCenter = ( cascade.x + cascade.y ) / 2.0;\n\t\t\t\tclosestEdge = linearDepth < cascadeCenter ? cascade.x : cascade.y;\n\t\t\t\tmargin = 0.25 * pow( closestEdge, 2.0 );\n\t\t\t\tcsmx = cascade.x - margin / 2.0;\n\t\t\t\tcsmy = cascade.y + margin / 2.0;\n\t\t\t\tif( linearDepth >= csmx && ( linearDepth < csmy || UNROLLED_LOOP_INDEX == CSM_CASCADES - 1 ) ) {\n\n\t\t\t\t\tfloat dist = min( linearDepth - csmx, csmy - linearDepth );\n\t\t\t\t\tfloat ratio = clamp( dist / margin, 0.0, 1.0 );\n\n\t\t\t\t\tvec3 prevColor = directLight.color;\n\t\t\t\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\t\t\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\n\t\t\t\t\tbool shouldFadeLastCascade = UNROLLED_LOOP_INDEX == CSM_CASCADES - 1 && linearDepth > cascadeCenter;\n\t\t\t\t\tdirectLight.color = mix( prevColor, directLight.color, shouldFadeLastCascade ? ratio : 1.0 );\n\n\t\t\t\t\tReflectedLight prevLight = reflectedLight;\n\t\t\t\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\n\t\t\t\t\tbool shouldBlend = UNROLLED_LOOP_INDEX != CSM_CASCADES - 1 || UNROLLED_LOOP_INDEX == CSM_CASCADES - 1 && linearDepth < cascadeCenter;\n\t\t\t\t\tfloat blendRatio = shouldBlend ? ratio : 1.0;\n\n\t\t\t\t\treflectedLight.directDiffuse = mix( prevLight.directDiffuse, reflectedLight.directDiffuse, blendRatio );\n\t\t\t\t\treflectedLight.directSpecular = mix( prevLight.directSpecular, reflectedLight.directSpecular, blendRatio );\n\t\t\t\t\treflectedLight.indirectDiffuse = mix( prevLight.indirectDiffuse, reflectedLight.indirectDiffuse, blendRatio );\n\t\t\t\t\treflectedLight.indirectSpecular = mix( prevLight.indirectSpecular, reflectedLight.indirectSpecular, blendRatio );\n\n\t\t\t\t}\n\t\t\t#endif\n\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#elif defined (USE_SHADOWMAP)\n\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\n\t\t\tdirectionalLight = directionalLights[ i ];\n\t\t\tgetDirectionalLightInfo( directionalLight, directLight );\n\n\t\t\t#if ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\n\t\t\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\t\t\tif(linearDepth >= CSM_cascades[UNROLLED_LOOP_INDEX].x && linearDepth < CSM_cascades[UNROLLED_LOOP_INDEX].y) directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\n\t\t\t\tif(linearDepth >= CSM_cascades[UNROLLED_LOOP_INDEX].x && (linearDepth < CSM_cascades[UNROLLED_LOOP_INDEX].y || UNROLLED_LOOP_INDEX == CSM_CASCADES - 1)) RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\n\t\t\t#endif\n\n\t\t}\n\t\t#pragma unroll_loop_end\n\n\t#elif ( NUM_DIR_LIGHT_SHADOWS > 0 )\n\t\t// note: no loop here - all CSM lights are in fact one light only\n\t\tgetDirectionalLightInfo( directionalLights[0], directLight );\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\n\t#endif\n\n\t#if ( NUM_DIR_LIGHTS > NUM_DIR_LIGHT_SHADOWS)\n\t\t// compute the lights not casting shadows (if any)\n\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = NUM_DIR_LIGHT_SHADOWS; i < NUM_DIR_LIGHTS; i ++ ) {\n\n\t\t\tdirectionalLight = directionalLights[ i ];\n\n\t\t\tgetDirectionalLightInfo( directionalLight, directLight );\n\n\t\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\n\t\t}\n\t\t#pragma unroll_loop_end\n\n\t#endif\n\n#endif\n\n\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) && !defined( USE_CSM ) && !defined( CSM_CASCADES )\n\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\n\t\tdirectionalLight = directionalLights[ i ];\n\n\t\tgetDirectionalLightInfo( directionalLight, directLight );\n\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\n\tRectAreaLight rectAreaLight;\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n#if defined( RE_IndirectDiffuse )\n\n\tvec3 iblIrradiance = vec3( 0.0 );\n\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\n\t#if defined( USE_LIGHT_PROBES )\n\n\t\tirradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n\n\t#endif\n\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n\n\t\t}\n\t\t#pragma unroll_loop_end\n\n\t#endif\n\n#endif\n\n#if defined( RE_IndirectSpecular )\n\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n\n#endif\n",lights_pars_begin:"\n#if defined( USE_CSM ) && defined( CSM_CASCADES )\nuniform vec2 CSM_cascades[CSM_CASCADES];\nuniform float cameraNear;\nuniform float shadowFar;\n#endif\n\t"+Ma.lights_pars_begin},tg=new yr,eg=new Zm({webGL:!0}),ng=new Hi,ig=new ji,rg=[],sg=[],ag=new yr,og=new yr,lg=new Hi(0,1,0),cg={type:"change"},hg={type:"start"},ug={type:"end"},dg=new vr,pg=new va,fg=Math.cos(70*ci.DEG2RAD),mg=new Hi,gg=2*Math.PI,Ag=-1,vg=1e-6;function yg(t){!1!==this.enabled&&(0===this._pointers.length&&(this.domElement.setPointerCapture(t.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),this._isTrackingPointer(t)||(this._addPointer(t),"touch"===t.pointerType?this._onTouchStart(t):this._onMouseDown(t)))}function xg(t){!1!==this.enabled&&("touch"===t.pointerType?this._onTouchMove(t):this._onMouseMove(t))}function _g(t){switch(this._removePointer(t),this._pointers.length){case 0:this.domElement.releasePointerCapture(t.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(ug),this.state=Ag;break;case 1:const e=this._pointers[0],n=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:n.x,pageY:n.y})}}function wg(t){let e;switch(t.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case m.DOLLY:if(!1===this.enableZoom)return;this._handleMouseDownDolly(t),this.state=1;break;case m.ROTATE:if(t.ctrlKey||t.metaKey||t.shiftKey){if(!1===this.enablePan)return;this._handleMouseDownPan(t),this.state=2}else{if(!1===this.enableRotate)return;this._handleMouseDownRotate(t),this.state=0}break;case m.PAN:if(t.ctrlKey||t.metaKey||t.shiftKey){if(!1===this.enableRotate)return;this._handleMouseDownRotate(t),this.state=0}else{if(!1===this.enablePan)return;this._handleMouseDownPan(t),this.state=2}break;default:this.state=Ag}this.state!==Ag&&this.dispatchEvent(hg)}function Cg(t){switch(this.state){case 0:if(!1===this.enableRotate)return;this._handleMouseMoveRotate(t);break;case 1:if(!1===this.enableZoom)return;this._handleMouseMoveDolly(t);break;case 2:if(!1===this.enablePan)return;this._handleMouseMovePan(t)}}function Eg(t){!1!==this.enabled&&!1!==this.enableZoom&&this.state===Ag&&(t.preventDefault(),this.dispatchEvent(hg),this._handleMouseWheel(this._customWheelEvent(t)),this.dispatchEvent(ug))}function Mg(t){!1!==this.enabled&&!1!==this.enablePan&&this._handleKeyDown(t)}function bg(t){switch(this._trackPointer(t),this._pointers.length){case 1:switch(this.touches.ONE){case g.ROTATE:if(!1===this.enableRotate)return;this._handleTouchStartRotate(t),this.state=3;break;case g.PAN:if(!1===this.enablePan)return;this._handleTouchStartPan(t),this.state=4;break;default:this.state=Ag}break;case 2:switch(this.touches.TWO){case g.DOLLY_PAN:if(!1===this.enableZoom&&!1===this.enablePan)return;this._handleTouchStartDollyPan(t),this.state=5;break;case g.DOLLY_ROTATE:if(!1===this.enableZoom&&!1===this.enableRotate)return;this._handleTouchStartDollyRotate(t),this.state=6;break;default:this.state=Ag}break;default:this.state=Ag}this.state!==Ag&&this.dispatchEvent(hg)}function Sg(t){switch(this._trackPointer(t),this.state){case 3:if(!1===this.enableRotate)return;this._handleTouchMoveRotate(t),this.update();break;case 4:if(!1===this.enablePan)return;this._handleTouchMovePan(t),this.update();break;case 5:if(!1===this.enableZoom&&!1===this.enablePan)return;this._handleTouchMoveDollyPan(t),this.update();break;case 6:if(!1===this.enableZoom&&!1===this.enableRotate)return;this._handleTouchMoveDollyRotate(t),this.update();break;default:this.state=Ag}}function Ig(t){!1!==this.enabled&&t.preventDefault()}function Tg(t){"Control"===t.key&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function Bg(t){"Control"===t.key&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function Rg(t,e=!1){const n=null!==t[0].index,i=new Set(Object.keys(t[0].attributes)),r=new Set(Object.keys(t[0].morphAttributes)),s={},a={},o=t[0].morphTargetsRelative,l=new Qs;let c=0;for(let h=0;h=2.0 are supported.")));const l=new MA(r,{path:e||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let t=0;t=0&&void 0===a[e]&&console.warn('THREE.GLTFLoader: Unknown extension "'+e+'".')}}l.setExtensions(s),l.setPlugins(a),l.parse(n,i)}parseAsync(t,e){const n=this;return new Promise((function(i,r){n.parse(t,e,i,r)}))}}function Ng(){let t={};return{get:function(e){return t[e]},add:function(e,n){t[e]=n},remove:function(e){delete t[e]},removeAll:function(){t={}}}}const Fg={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_DISPERSION:"KHR_materials_dispersion",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 Og{constructor(t){this.parser=t,this.name=Fg.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const t=this.parser,e=this.parser.json.nodes||[];for(let n=0,i=e.length;n=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return e.loadTextureImage(t,r.source,s)}}class Zg{constructor(t){this.parser=t,this.name=Fg.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(t){const e=this.name,n=this.parser,i=n.json,r=i.textures[t];if(!r.extensions||!r.extensions[e])return null;const s=r.extensions[e],a=i.images[s.source];let o=n.textureLoader;if(a.uri){const t=n.options.manager.getHandler(a.uri);null!==t&&(o=t)}return this.detectSupport().then((function(r){if(r)return n.loadTextureImage(t,s.source,o);if(i.extensionsRequired&&i.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(t)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(t){const e=new Image;e.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",e.onload=e.onerror=function(){t(1===e.height)}}))),this.isSupported}}class $g{constructor(t){this.parser=t,this.name=Fg.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(t){const e=this.name,n=this.parser,i=n.json,r=i.textures[t];if(!r.extensions||!r.extensions[e])return null;const s=r.extensions[e],a=i.images[s.source];let o=n.textureLoader;if(a.uri){const t=n.options.manager.getHandler(a.uri);null!==t&&(o=t)}return this.detectSupport().then((function(r){if(r)return n.loadTextureImage(t,s.source,o);if(i.extensionsRequired&&i.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(t)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(t){const e=new Image;e.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",e.onload=e.onerror=function(){t(1===e.height)}}))),this.isSupported}}class tA{constructor(t){this.name=Fg.EXT_MESHOPT_COMPRESSION,this.parser=t}loadBufferView(t){const e=this.parser.json,n=e.bufferViews[t];if(n.extensions&&n.extensions[this.name]){const t=n.extensions[this.name],i=this.parser.getDependency("buffer",t.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(e.extensionsRequired&&e.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return i.then((function(e){const n=t.byteOffset||0,i=t.byteLength||0,s=t.count,a=t.byteStride,o=new Uint8Array(e,n,i);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(s,a,o,t.mode,t.filter).then((function(t){return t.buffer})):r.ready.then((function(){const e=new ArrayBuffer(s*a);return r.decodeGltfBuffer(new Uint8Array(e),s,a,o,t.mode,t.filter),e}))}))}return null}}class eA{constructor(t){this.name=Fg.EXT_MESH_GPU_INSTANCING,this.parser=t}createNodeMesh(t){const e=this.parser.json,n=e.nodes[t];if(!n.extensions||!n.extensions[this.name]||void 0===n.mesh)return null;const i=e.meshes[n.mesh];for(const t of i.primitives)if(t.mode!==hA.TRIANGLES&&t.mode!==hA.TRIANGLE_STRIP&&t.mode!==hA.TRIANGLE_FAN&&void 0!==t.mode)return null;const r=n.extensions[this.name].attributes,s=[],a={};for(const t in r)s.push(this.parser.getDependency("accessor",r[t]).then((e=>(a[t]=e,a[t]))));return s.length<1?null:(s.push(this.parser.createNodeMesh(t)),Promise.all(s).then((t=>{const e=t.pop(),n=e.isGroup?e.children:[e],i=t[0].count,r=[];for(const t of n){const e=new yr,n=new Hi,s=new Gi,o=new Hi(1,1,1),l=new oh(t.geometry,t.material,i);for(let t=0;t-1,s=r?t.match(/Firefox\/([0-9]+)\./)[1]:-1}"undefined"==typeof createImageBitmap||n&&i<17||r&&s<98?this.textureLoader=new cp(this.options.manager):this.textureLoader=new Fp(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new ip(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(t){this.extensions=t}setPlugins(t){this.plugins=t}parse(t,e){const n=this,i=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll((function(t){return t._markDefs&&t._markDefs()})),Promise.all(this._invokeAll((function(t){return t.beforeRoot&&t.beforeRoot()}))).then((function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])})).then((function(e){const s={scene:e[0][i.scene||0],scenes:e[0],animations:e[1],cameras:e[2],asset:i.asset,parser:n,userData:{}};return vA(r,s,i),yA(s,i),Promise.all(n._invokeAll((function(t){return t.afterRoot&&t.afterRoot(s)}))).then((function(){for(const t of s.scenes)t.updateMatrixWorld();t(s)}))})).catch(e)}_markDefs(){const t=this.json.nodes||[],e=this.json.skins||[],n=this.json.meshes||[];for(let n=0,i=e.length;n{const n=this.associations.get(t);null!=n&&this.associations.set(e,n);for(const[n,i]of t.children.entries())r(i,e.children[n])};return r(n,i),i.name+="_instance_"+t.uses[e]++,i}_invokeOne(t){const e=Object.values(this.plugins);e.push(this);for(let n=0;n=2&&p.setY(e,h[t*s+1]),s>=3&&p.setZ(e,h[t*s+2]),s>=4&&p.setW(e,h[t*s+3]),s>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}p.normalized=u}return p}))}loadTexture(t){const e=this.json,n=this.options,i=e.textures[t].source,r=e.images[i];let s=this.textureLoader;if(r.uri){const t=n.manager.getHandler(r.uri);null!==t&&(s=t)}return this.loadTextureImage(t,i,s)}loadTextureImage(t,e,n){const i=this,r=this.json,s=r.textures[t],a=r.images[e],o=(a.uri||a.bufferView)+":"+s.sampler;if(this.textureCache[o])return this.textureCache[o];const l=this.loadImageSource(e,n).then((function(e){e.flipY=!1,e.name=s.name||a.name||"",""===e.name&&"string"==typeof a.uri&&!1===a.uri.startsWith("data:image/")&&(e.name=a.uri);const n=(r.samplers||{})[s.sampler]||{};return e.magFilter=dA[n.magFilter]||Ut,e.minFilter=dA[n.minFilter]||Ot,e.wrapS=pA[n.wrapS]||St,e.wrapT=pA[n.wrapT]||St,e.generateMipmaps=!e.isCompressedTexture&&e.minFilter!==Bt&&e.minFilter!==Ut,i.associations.set(e,{textures:t}),e})).catch((function(){return null}));return this.textureCache[o]=l,l}loadImageSource(t,e){const n=this.json,i=this.options;if(void 0!==this.sourceCache[t])return this.sourceCache[t].then((t=>t.clone()));const r=n.images[t],s=self.URL||self.webkitURL;let a=r.uri||"",o=!1;if(void 0!==r.bufferView)a=this.getDependency("bufferView",r.bufferView).then((function(t){o=!0;const e=new Blob([t],{type:r.mimeType});return a=s.createObjectURL(e),a}));else if(void 0===r.uri)throw new Error("THREE.GLTFLoader: Image "+t+" is missing URI and bufferView");const l=Promise.resolve(a).then((function(t){return new Promise((function(n,r){let s=n;!0===e.isImageBitmapLoader&&(s=function(t){const e=new Li(t);e.needsUpdate=!0,n(e)}),e.load(Bp.resolveURL(t,i.path),s,void 0,r)}))})).then((function(t){var e;return!0===o&&s.revokeObjectURL(a),yA(t,r),t.userData.mimeType=r.mimeType||((e=r.uri).search(/\.jpe?g($|\?)/i)>0||0===e.search(/^data\:image\/jpeg/)?"image/jpeg":e.search(/\.webp($|\?)/i)>0||0===e.search(/^data\:image\/webp/)?"image/webp":e.search(/\.ktx2($|\?)/i)>0||0===e.search(/^data\:image\/ktx2/)?"image/ktx2":"image/png"),t})).catch((function(t){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),t}));return this.sourceCache[t]=l,l}assignTexture(t,e,n,i){const r=this;return this.getDependency("texture",n.index).then((function(s){if(!s)return null;if(void 0!==n.texCoord&&n.texCoord>0&&((s=s.clone()).channel=n.texCoord),r.extensions[Fg.KHR_TEXTURE_TRANSFORM]){const t=void 0!==n.extensions?n.extensions[Fg.KHR_TEXTURE_TRANSFORM]:void 0;if(t){const e=r.associations.get(s);s=r.extensions[Fg.KHR_TEXTURE_TRANSFORM].extendTexture(s,t),r.associations.set(s,e)}}return void 0!==i&&(s.colorSpace=i),t[e]=s,s}))}assignFinalMaterial(t){const e=t.geometry;let n=t.material;const i=void 0===e.attributes.tangent,r=void 0!==e.attributes.color,s=void 0===e.attributes.normal;if(t.isPoints){const t="PointsMaterial:"+n.uuid;let e=this.cache.get(t);e||(e=new Qh,fs.prototype.copy.call(e,n),e.color.copy(n.color),e.map=n.map,e.sizeAttenuation=!1,this.cache.add(t,e)),n=e}else if(t.isLine){const t="LineBasicMaterial:"+n.uuid;let e=this.cache.get(t);e||(e=new bh,fs.prototype.copy.call(e,n),e.color.copy(n.color),e.map=n.map,this.cache.add(t,e)),n=e}if(i||r||s){let t="ClonedMaterial:"+n.uuid+":";i&&(t+="derivative-tangents:"),r&&(t+="vertex-colors:"),s&&(t+="flat-shading:");let e=this.cache.get(t);e||(e=n.clone(),r&&(e.vertexColors=!0),s&&(e.flatShading=!0),i&&(e.normalScale&&(e.normalScale.y*=-1),e.clearcoatNormalScale&&(e.clearcoatNormalScale.y*=-1)),this.cache.add(t,e),this.associations.set(e,this.associations.get(n))),n=e}t.material=n}getMaterialType(){return Cd}loadMaterial(t){const e=this,n=this.json,i=this.extensions,r=n.materials[t];let s;const a={},o=[];if((r.extensions||{})[Fg.KHR_MATERIALS_UNLIT]){const t=i[Fg.KHR_MATERIALS_UNLIT];s=t.getMaterialType(),o.push(t.extendParams(a,r,e))}else{const n=r.pbrMetallicRoughness||{};if(a.color=new us(1,1,1),a.opacity=1,Array.isArray(n.baseColorFactor)){const t=n.baseColorFactor;a.color.setRGB(t[0],t[1],t[2],dn),a.opacity=t[3]}void 0!==n.baseColorTexture&&o.push(e.assignTexture(a,"map",n.baseColorTexture,un)),a.metalness=void 0!==n.metallicFactor?n.metallicFactor:1,a.roughness=void 0!==n.roughnessFactor?n.roughnessFactor:1,void 0!==n.metallicRoughnessTexture&&(o.push(e.assignTexture(a,"metalnessMap",n.metallicRoughnessTexture)),o.push(e.assignTexture(a,"roughnessMap",n.metallicRoughnessTexture))),s=this._invokeOne((function(e){return e.getMaterialType&&e.getMaterialType(t)})),o.push(Promise.all(this._invokeAll((function(e){return e.extendMaterialParams&&e.extendMaterialParams(t,a)}))))}!0===r.doubleSided&&(a.side=S);const l=r.alphaMode||"OPAQUE";if("BLEND"===l?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,"MASK"===l&&(a.alphaTest=void 0!==r.alphaCutoff?r.alphaCutoff:.5)),void 0!==r.normalTexture&&s!==ms&&(o.push(e.assignTexture(a,"normalMap",r.normalTexture)),a.normalScale=new hi(1,1),void 0!==r.normalTexture.scale)){const t=r.normalTexture.scale;a.normalScale.set(t,t)}if(void 0!==r.occlusionTexture&&s!==ms&&(o.push(e.assignTexture(a,"aoMap",r.occlusionTexture)),void 0!==r.occlusionTexture.strength&&(a.aoMapIntensity=r.occlusionTexture.strength)),void 0!==r.emissiveFactor&&s!==ms){const t=r.emissiveFactor;a.emissive=(new us).setRGB(t[0],t[1],t[2],dn)}return void 0!==r.emissiveTexture&&s!==ms&&o.push(e.assignTexture(a,"emissiveMap",r.emissiveTexture,un)),Promise.all(o).then((function(){const n=new s(a);return r.name&&(n.name=r.name),yA(n,r),e.associations.set(n,{materials:t}),r.extensions&&vA(i,n,r),n}))}createUniqueName(t){const e=pf.sanitizeNodeName(t||"");return e in this.nodeNamesUsed?e+"_"+ ++this.nodeNamesUsed[e]:(this.nodeNamesUsed[e]=0,e)}loadGeometries(t){const e=this,n=this.extensions,i=this.primitiveCache;function r(t){return n[Fg.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(t,e).then((function(n){return bA(n,t,e)}))}const s=[];for(let n=0,a=t.length;n0&&xA(u,r),u.name=e.createUniqueName(r.name||"mesh_"+t),yA(u,r),h.extensions&&vA(i,u,h),e.assignFinalMaterial(u),l.push(u)}for(let n=0,i=l.length;n1?new ic:1===e.length?e[0]:new jr,a!==e[0])for(let t=0,n=e.length;t{const e=new Map;for(const[t,n]of i.associations)(t instanceof fs||t instanceof Li)&&e.set(t,n);return t.traverse((t=>{const n=i.associations.get(t);null!=n&&e.set(t,n)})),e})(r),r}))}_createAnimationTracks(t,e,n,i,r){const s=[],a=t.name?t.name:t.uuid,o=[];let l;switch(gA[r.path]===gA.weights?t.traverse((function(t){t.morphTargetInfluences&&o.push(t.name?t.name:t.uuid)})):o.push(a),gA[r.path]){case gA.weights:l=Vd;break;case gA.rotation:l=jd;break;case gA.position:case gA.scale:l=Xd;break;default:l=1===n.itemSize?Vd:Xd}const c=void 0!==i.interpolation?AA[i.interpolation]:qe,h=this._getArrayFromAccessor(n);for(let t=0,n=o.length;tt.toBlob(n,e)));let n;return"image/jpeg"===e?n=.92:"image/webp"===e&&(n=.8),t.convertToBlob({type:e,quality:n})}class HA{constructor(){this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.extensionsRequired={},this.uids=new Map,this.uid=0,this.json={asset:{version:"2.0",generator:"THREE.GLTFExporter r"+f}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map},this.textureUtils=null}setPlugins(t){this.plugins=t}setTextureUtils(t){this.textureUtils=t}async writeAsync(t,e,n={}){this.options=Object.assign({binary:!1,trs:!1,onlyVisible:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},n),this.options.animations.length>0&&(this.options.trs=!0),await this.processInputAsync(t),await Promise.all(this.pending);const i=this,r=i.buffers,s=i.json;n=i.options;const a=i.extensionsUsed,o=i.extensionsRequired,l=new Blob(r,{type:"application/octet-stream"}),c=Object.keys(a),h=Object.keys(o);if(c.length>0&&(s.extensionsUsed=c),h.length>0&&(s.extensionsRequired=h),s.buffers&&s.buffers.length>0&&(s.buffers[0].byteLength=l.size),!0===n.binary){const t=new FileReader;t.readAsArrayBuffer(l),t.onloadend=function(){const n=QA(t.result),i=new DataView(new ArrayBuffer(8));i.setUint32(0,n.byteLength,!0),i.setUint32(4,5130562,!0);const r=QA((a=JSON.stringify(s),(new TextEncoder).encode(a).buffer),32);var a;const o=new DataView(new ArrayBuffer(8));o.setUint32(0,r.byteLength,!0),o.setUint32(4,1313821514,!0);const l=new ArrayBuffer(12),c=new DataView(l);c.setUint32(0,1179937895,!0),c.setUint32(4,2,!0);const h=12+o.byteLength+r.byteLength+i.byteLength+n.byteLength;c.setUint32(8,h,!0);const u=new Blob([l,o,r,i,n],{type:"application/octet-stream"}),d=new FileReader;d.readAsArrayBuffer(u),d.onloadend=function(){e(d.result)}}}else if(s.buffers&&s.buffers.length>0){const t=new FileReader;t.readAsDataURL(l),t.onloadend=function(){const n=t.result;s.buffers[0].uri=n,e(s)}}else e(s)}serializeUserData(t,e){if(0===Object.keys(t.userData).length)return;const n=this.options,i=this.extensionsUsed;try{const r=JSON.parse(JSON.stringify(t.userData));if(n.includeCustomExtensions&&r.gltfExtensions){void 0===e.extensions&&(e.extensions={});for(const t in r.gltfExtensions)e.extensions[t]=r.gltfExtensions[t],i[t]=!0;delete r.gltfExtensions}Object.keys(r).length>0&&(e.extras=r)}catch(e){console.warn("THREE.GLTFExporter: userData of '"+t.name+"' won't be serialized because of JSON.stringify error - "+e.message)}}getUID(t,e=!1){if(!1===this.uids.has(t)){const e=new Map;e.set(!0,this.uid++),e.set(!1,this.uid++),this.uids.set(t,e)}return this.uids.get(t).get(e)}isNormalizedNormalAttribute(t){if(this.cache.attributesNormalized.has(t))return!1;const e=new Hi;for(let n=0,i=t.count;n5e-4)return!1;return!0}createNormalizedNormalAttribute(t){const e=this.cache;if(e.attributesNormalized.has(t))return e.attributesNormalized.get(t);const n=t.clone(),i=new Hi;for(let t=0,e=n.count;t4?i=t.array[r*t.itemSize+n]:(0===n?i=t.getX(r):1===n?i=t.getY(r):2===n?i=t.getZ(r):3===n&&(i=t.getW(r)),!0===t.normalized&&(i=ci.normalize(i,t.array))),5126===e?c.setFloat32(h,i,!0):5124===e?c.setInt32(h,i,!0):5125===e?c.setUint32(h,i,!0):e===RA?c.setInt16(h,i,!0):e===DA?c.setUint16(h,i,!0):e===TA?c.setInt8(h,i):e===BA&&c.setUint8(h,i),h+=a}h%o!=0&&(h+=o-h%o)}const u={buffer:this.processBuffer(c.buffer),byteOffset:this.byteOffset,byteLength:l};return void 0!==r&&(u.target=r),r===PA&&(u.byteStride=o),this.byteOffset+=l,s.bufferViews.push(u),{id:s.bufferViews.length-1,byteLength:0}}processBufferViewImage(t){const e=this,n=e.json;return n.bufferViews||(n.bufferViews=[]),new Promise((function(i){const r=new FileReader;r.readAsArrayBuffer(t),r.onloadend=function(){const t=QA(r.result),s={buffer:e.processBuffer(t),byteOffset:e.byteOffset,byteLength:t.byteLength};e.byteOffset+=t.byteLength,i(n.bufferViews.push(s)-1)}}))}processAccessor(t,e,n,i){const r=this.json;let s;if(t.array.constructor===Float32Array)s=5126;else if(t.array.constructor===Int32Array)s=5124;else if(t.array.constructor===Uint32Array)s=5125;else if(t.array.constructor===Int16Array)s=RA;else if(t.array.constructor===Uint16Array)s=DA;else if(t.array.constructor===Int8Array)s=TA;else{if(t.array.constructor!==Uint8Array)throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: "+t.array.constructor.name);s=BA}if(void 0===n&&(n=0),void 0!==i&&i!==1/0||(i=t.count),0===i)return null;const a=function(t,e,n){const i={min:new Array(t.itemSize).fill(Number.POSITIVE_INFINITY),max:new Array(t.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let r=e;r4?n=t.array[r*t.itemSize+e]:(0===e?n=t.getX(r):1===e?n=t.getY(r):2===e?n=t.getZ(r):3===e&&(n=t.getW(r)),!0===t.normalized&&(n=ci.normalize(n,t.array))),i.min[e]=Math.min(i.min[e],n),i.max[e]=Math.max(i.max[e],n)}return i}(t,n,i);let o;void 0!==e&&(o=t===e.index?34963:PA);const l=this.processBufferView(t,s,n,i,o),c={bufferView:l.id,byteOffset:l.byteOffset,componentType:s,count:i,max:a.max,min:a.min,type:{1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",9:"MAT3",16:"MAT4"}[t.itemSize]};return!0===t.normalized&&(c.normalized=!0),r.accessors||(r.accessors=[]),r.accessors.push(c)-1}processImage(t,e,n,i="image/png"){if(null!==t){const r=this,s=r.cache,a=r.json,o=r.options,l=r.pending;s.images.has(t)||s.images.set(t,{});const c=s.images.get(t),h=i+":flipY/"+n.toString();if(void 0!==c[h])return c[h];a.images||(a.images=[]);const u={mimeType:i},d=zA();d.width=Math.min(t.width,o.maxTextureSize),d.height=Math.min(t.height,o.maxTextureSize);const p=d.getContext("2d",{willReadFrequently:!0});if(!0===n&&(p.translate(0,d.height),p.scale(1,-1)),void 0!==t.data){e!==te&&console.error("GLTFExporter: Only RGBAFormat is supported.",e),(t.width>o.maxTextureSize||t.height>o.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",t);const n=new Uint8ClampedArray(t.height*t.width*4);for(let e=0;er.processBufferViewImage(t))).then((t=>{u.bufferView=t}))):void 0!==d.toDataURL?u.uri=d.toDataURL(i):l.push(GA(d,i).then((t=>(new FileReader).readAsDataURL(t))).then((t=>{u.uri=t})));const f=a.images.push(u)-1;return c[h]=f,f}throw new Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.")}processSampler(t){const e=this.json;e.samplers||(e.samplers=[]);const n={magFilter:UA[t.magFilter],minFilter:UA[t.minFilter],wrapS:UA[t.wrapS],wrapT:UA[t.wrapT]};return e.samplers.push(n)-1}async processTextureAsync(t){const e=this.options,n=this.cache,i=this.json;if(n.textures.has(t))return n.textures.get(t);i.textures||(i.textures=[]),t instanceof Yh&&(t=await this.decompressTextureAsync(t,e.maxTextureSize));let r=t.userData.mimeType;"image/webp"===r&&(r="image/png");const s={sampler:this.processSampler(t),source:this.processImage(t.image,t.format,t.flipY,r)};t.name&&(s.name=t.name),await this._invokeAllAsync((async function(e){e.writeTexture&&await e.writeTexture(t,s)}));const a=i.textures.push(s)-1;return n.textures.set(t,a),a}async processMaterialAsync(t){const e=this.cache,n=this.json;if(e.materials.has(t))return e.materials.get(t);if(t.isShaderMaterial)return console.warn("GLTFExporter: THREE.ShaderMaterial not supported."),null;n.materials||(n.materials=[]);const i={pbrMetallicRoughness:{}};!0!==t.isMeshStandardMaterial&&!0!==t.isMeshBasicMaterial&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");const r=t.color.toArray().concat([t.opacity]);if(OA(r,[1,1,1,1])||(i.pbrMetallicRoughness.baseColorFactor=r),t.isMeshStandardMaterial?(i.pbrMetallicRoughness.metallicFactor=t.metalness,i.pbrMetallicRoughness.roughnessFactor=t.roughness):(i.pbrMetallicRoughness.metallicFactor=0,i.pbrMetallicRoughness.roughnessFactor=1),t.metalnessMap||t.roughnessMap){const e=await this.buildMetalRoughTextureAsync(t.metalnessMap,t.roughnessMap),n={index:await this.processTextureAsync(e),texCoord:e.channel};this.applyTextureTransform(n,e),i.pbrMetallicRoughness.metallicRoughnessTexture=n}if(t.map){const e={index:await this.processTextureAsync(t.map),texCoord:t.map.channel};this.applyTextureTransform(e,t.map),i.pbrMetallicRoughness.baseColorTexture=e}if(t.emissive){const e=t.emissive;if(Math.max(e.r,e.g,e.b)>0&&(i.emissiveFactor=t.emissive.toArray()),t.emissiveMap){const e={index:await this.processTextureAsync(t.emissiveMap),texCoord:t.emissiveMap.channel};this.applyTextureTransform(e,t.emissiveMap),i.emissiveTexture=e}}if(t.normalMap){const e={index:await this.processTextureAsync(t.normalMap),texCoord:t.normalMap.channel};t.normalScale&&1!==t.normalScale.x&&(e.scale=t.normalScale.x),this.applyTextureTransform(e,t.normalMap),i.normalTexture=e}if(t.aoMap){const e={index:await this.processTextureAsync(t.aoMap),texCoord:t.aoMap.channel};1!==t.aoMapIntensity&&(e.strength=t.aoMapIntensity),this.applyTextureTransform(e,t.aoMap),i.occlusionTexture=e}t.transparent?i.alphaMode="BLEND":t.alphaTest>0&&(i.alphaMode="MASK",i.alphaCutoff=t.alphaTest),t.side===S&&(i.doubleSided=!0),""!==t.name&&(i.name=t.name),this.serializeUserData(t,i),await this._invokeAllAsync((async function(e){e.writeMaterialAsync&&await e.writeMaterialAsync(t,i)}));const s=n.materials.push(i)-1;return e.materials.set(t,s),s}async processMeshAsync(t){const e=this.cache,n=this.json,i=[t.geometry.uuid];if(Array.isArray(t.material))for(let e=0,n=t.material.length;e0){const n=[],i=[],r={};if(void 0!==t.morphTargetDictionary)for(const e in t.morphTargetDictionary)r[t.morphTargetDictionary[e]]=e;for(let a=0;a0&&(o.extras={},o.extras.targetNames=i)}const f=Array.isArray(t.material);if(f&&0===s.groups.length)return null;let m=!1;if(f&&null===s.index){const t=[];for(let e=0,n=s.attributes.position.count;e0&&(n.targets=h),null!==s.index){let i=this.getUID(s.index);void 0===A[t].start&&void 0===A[t].count||(i+=":"+A[t].start+":"+A[t].count),e.attributes.has(i)?n.indices=e.attributes.get(i):(n.indices=this.processAccessor(s.index,s,A[t].start,A[t].count),e.attributes.set(i,n.indices)),null===n.indices&&delete n.indices}const i=await this.processMaterialAsync(g[A[t].materialIndex]);null!==i&&(n.material=i),c.push(n)}!0===m&&s.setIndex(null),o.primitives=c,n.meshes||(n.meshes=[]),await this._invokeAllAsync((function(e){e.writeMesh&&e.writeMesh(t,o)}));const v=n.meshes.push(o)-1;return e.meshes.set(r,v),v}detectMeshQuantization(t,e){if(this.extensionsUsed[LA])return;let n;switch(e.array.constructor){case Int8Array:n="byte";break;case Uint8Array:n="unsigned byte";break;case Int16Array:n="short";break;case Uint16Array:n="unsigned short";break;default:return}e.normalized&&(n+=" normalized");const i=t.split("_",1)[0];SA[i]&&SA[i].includes(n)&&(this.extensionsUsed[LA]=!0,this.extensionsRequired[LA]=!0)}processCamera(t){const e=this.json;e.cameras||(e.cameras=[]);const n=t.isOrthographicCamera,i={type:n?"orthographic":"perspective"};return n?i.orthographic={xmag:2*t.right,ymag:2*t.top,zfar:t.far<=0?.001:t.far,znear:t.near<0?0:t.near}:i.perspective={aspectRatio:t.aspect,yfov:ci.degToRad(t.fov),zfar:t.far<=0?.001:t.far,znear:t.near<0?0:t.near},""!==t.name&&(i.name=t.type),e.cameras.push(i)-1}processAnimation(t,e){const n=this.json,i=this.nodeMap;n.animations||(n.animations=[]);const r=(t=IA.Utils.mergeMorphTargetTracks(t.clone(),e)).tracks,s=[],a=[];for(let t=0;t0){const e=[];for(let i=0,r=t.children.length;i0&&(r.children=e)}await this._invokeAllAsync((function(e){e.writeNode&&e.writeNode(t,r)}));const s=e.nodes.push(r)-1;return i.set(t,s),s}async processSceneAsync(t){const e=this.json,n=this.options;e.scenes||(e.scenes=[],e.scene=0);const i={};""!==t.name&&(i.name=t.name),e.scenes.push(i);const r=[];for(let e=0,i=t.children.length;e0&&(i.nodes=r),this.serializeUserData(t,i)}async processObjectsAsync(t){const e=new mc;e.name="AuxScene";for(let n=0;n0&&await this.processObjectsAsync(n);for(let t=0;t0&&(s.range=t.distance)):t.isSpotLight&&(s.type="spot",t.distance>0&&(s.range=t.distance),s.spot={},s.spot.innerConeAngle=(1-t.penumbra)*t.angle,s.spot.outerConeAngle=t.angle),void 0!==t.decay&&2!==t.decay&&console.warn("THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2."),!t.target||t.target.parent===t&&0===t.target.position.x&&0===t.target.position.y&&-1===t.target.position.z||console.warn("THREE.GLTFExporter: Light direction may be lost. For best results, make light.target a child of the light with position 0,0,-1."),r[this.name]||(i.extensions=i.extensions||{},i.extensions[this.name]={lights:[]},r[this.name]=!0);const a=i.extensions[this.name].lights;a.push(s),e.extensions=e.extensions||{},e.extensions[this.name]={light:a.length-1}}}class WA{constructor(t){this.writer=t,this.name="KHR_materials_unlit"}async writeMaterialAsync(t,e){if(!t.isMeshBasicMaterial)return;const n=this.writer.extensionsUsed;e.extensions=e.extensions||{},e.extensions[this.name]={},n[this.name]=!0,e.pbrMetallicRoughness.metallicFactor=0,e.pbrMetallicRoughness.roughnessFactor=.9}}class jA{constructor(t){this.writer=t,this.name="KHR_materials_clearcoat"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||0===t.clearcoat)return;const n=this.writer,i=n.extensionsUsed,r={};if(r.clearcoatFactor=t.clearcoat,t.clearcoatMap){const e={index:await n.processTextureAsync(t.clearcoatMap),texCoord:t.clearcoatMap.channel};n.applyTextureTransform(e,t.clearcoatMap),r.clearcoatTexture=e}if(r.clearcoatRoughnessFactor=t.clearcoatRoughness,t.clearcoatRoughnessMap){const e={index:await n.processTextureAsync(t.clearcoatRoughnessMap),texCoord:t.clearcoatRoughnessMap.channel};n.applyTextureTransform(e,t.clearcoatRoughnessMap),r.clearcoatRoughnessTexture=e}if(t.clearcoatNormalMap){const e={index:await n.processTextureAsync(t.clearcoatNormalMap),texCoord:t.clearcoatNormalMap.channel};1!==t.clearcoatNormalScale.x&&(e.scale=t.clearcoatNormalScale.x),n.applyTextureTransform(e,t.clearcoatNormalMap),r.clearcoatNormalTexture=e}e.extensions=e.extensions||{},e.extensions[this.name]=r,i[this.name]=!0}}class qA{constructor(t){this.writer=t,this.name="KHR_materials_dispersion"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||0===t.dispersion)return;const n=this.writer.extensionsUsed,i={};i.dispersion=t.dispersion,e.extensions=e.extensions||{},e.extensions[this.name]=i,n[this.name]=!0}}class XA{constructor(t){this.writer=t,this.name="KHR_materials_iridescence"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||0===t.iridescence)return;const n=this.writer,i=n.extensionsUsed,r={};if(r.iridescenceFactor=t.iridescence,t.iridescenceMap){const e={index:await n.processTextureAsync(t.iridescenceMap),texCoord:t.iridescenceMap.channel};n.applyTextureTransform(e,t.iridescenceMap),r.iridescenceTexture=e}if(r.iridescenceIor=t.iridescenceIOR,r.iridescenceThicknessMinimum=t.iridescenceThicknessRange[0],r.iridescenceThicknessMaximum=t.iridescenceThicknessRange[1],t.iridescenceThicknessMap){const e={index:await n.processTextureAsync(t.iridescenceThicknessMap),texCoord:t.iridescenceThicknessMap.channel};n.applyTextureTransform(e,t.iridescenceThicknessMap),r.iridescenceThicknessTexture=e}e.extensions=e.extensions||{},e.extensions[this.name]=r,i[this.name]=!0}}class YA{constructor(t){this.writer=t,this.name="KHR_materials_transmission"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||0===t.transmission)return;const n=this.writer,i=n.extensionsUsed,r={};if(r.transmissionFactor=t.transmission,t.transmissionMap){const e={index:await n.processTextureAsync(t.transmissionMap),texCoord:t.transmissionMap.channel};n.applyTextureTransform(e,t.transmissionMap),r.transmissionTexture=e}e.extensions=e.extensions||{},e.extensions[this.name]=r,i[this.name]=!0}}class JA{constructor(t){this.writer=t,this.name="KHR_materials_volume"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||0===t.transmission)return;const n=this.writer,i=n.extensionsUsed,r={};if(r.thicknessFactor=t.thickness,t.thicknessMap){const e={index:await n.processTextureAsync(t.thicknessMap),texCoord:t.thicknessMap.channel};n.applyTextureTransform(e,t.thicknessMap),r.thicknessTexture=e}t.attenuationDistance!==1/0&&(r.attenuationDistance=t.attenuationDistance),r.attenuationColor=t.attenuationColor.toArray(),e.extensions=e.extensions||{},e.extensions[this.name]=r,i[this.name]=!0}}class KA{constructor(t){this.writer=t,this.name="KHR_materials_ior"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||1.5===t.ior)return;const n=this.writer.extensionsUsed,i={};i.ior=t.ior,e.extensions=e.extensions||{},e.extensions[this.name]=i,n[this.name]=!0}}class ZA{constructor(t){this.writer=t,this.name="KHR_materials_specular"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||1===t.specularIntensity&&t.specularColor.equals(FA)&&!t.specularIntensityMap&&!t.specularColorMap)return;const n=this.writer,i=n.extensionsUsed,r={};if(t.specularIntensityMap){const e={index:await n.processTextureAsync(t.specularIntensityMap),texCoord:t.specularIntensityMap.channel};n.applyTextureTransform(e,t.specularIntensityMap),r.specularTexture=e}if(t.specularColorMap){const e={index:await n.processTextureAsync(t.specularColorMap),texCoord:t.specularColorMap.channel};n.applyTextureTransform(e,t.specularColorMap),r.specularColorTexture=e}r.specularFactor=t.specularIntensity,r.specularColorFactor=t.specularColor.toArray(),e.extensions=e.extensions||{},e.extensions[this.name]=r,i[this.name]=!0}}class $A{constructor(t){this.writer=t,this.name="KHR_materials_sheen"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||0==t.sheen)return;const n=this.writer,i=n.extensionsUsed,r={};if(t.sheenRoughnessMap){const e={index:await n.processTextureAsync(t.sheenRoughnessMap),texCoord:t.sheenRoughnessMap.channel};n.applyTextureTransform(e,t.sheenRoughnessMap),r.sheenRoughnessTexture=e}if(t.sheenColorMap){const e={index:await n.processTextureAsync(t.sheenColorMap),texCoord:t.sheenColorMap.channel};n.applyTextureTransform(e,t.sheenColorMap),r.sheenColorTexture=e}r.sheenRoughnessFactor=t.sheenRoughness,r.sheenColorFactor=t.sheenColor.toArray(),e.extensions=e.extensions||{},e.extensions[this.name]=r,i[this.name]=!0}}class tv{constructor(t){this.writer=t,this.name="KHR_materials_anisotropy"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||0==t.anisotropy)return;const n=this.writer,i=n.extensionsUsed,r={};if(t.anisotropyMap){const e={index:await n.processTextureAsync(t.anisotropyMap)};n.applyTextureTransform(e,t.anisotropyMap),r.anisotropyTexture=e}r.anisotropyStrength=t.anisotropy,r.anisotropyRotation=t.anisotropyRotation,e.extensions=e.extensions||{},e.extensions[this.name]=r,i[this.name]=!0}}class ev{constructor(t){this.writer=t,this.name="KHR_materials_emissive_strength"}async writeMaterialAsync(t,e){if(!t.isMeshStandardMaterial||1===t.emissiveIntensity)return;const n=this.writer.extensionsUsed,i={};i.emissiveStrength=t.emissiveIntensity,e.extensions=e.extensions||{},e.extensions[this.name]=i,n[this.name]=!0}}class nv{constructor(t){this.writer=t,this.name="EXT_materials_bump"}async writeMaterialAsync(t,e){if(!t.isMeshStandardMaterial||1===t.bumpScale&&!t.bumpMap)return;const n=this.writer,i=n.extensionsUsed,r={};if(t.bumpMap){const e={index:await n.processTextureAsync(t.bumpMap),texCoord:t.bumpMap.channel};n.applyTextureTransform(e,t.bumpMap),r.bumpTexture=e}r.bumpFactor=t.bumpScale,e.extensions=e.extensions||{},e.extensions[this.name]=r,i[this.name]=!0}}class iv{constructor(t){this.writer=t,this.name="EXT_mesh_gpu_instancing"}writeNode(t,e){if(!t.isInstancedMesh)return;const n=this.writer,i=t,r=new Float32Array(3*i.count),s=new Float32Array(4*i.count),a=new Float32Array(3*i.count),o=new yr,l=new Hi,c=new Gi,h=new Hi;for(let t=0;tt.times[t.times.length-1]){if(Math.abs(t.times[t.times.length-1]-e)e){r.set(t.times.slice(0,l+1),0),r[l+1]=e,r.set(t.times.slice(l+1),l+2),s.set(t.values.slice(0,(l+1)*i),0),s.set(a.evaluate(e),(l+1)*i),s.set(t.values.slice((l+1)*i),(l+2)*i),o=l+1;break}}return t.times=r,t.values=s,o},mergeMorphTargetTracks:function(t,e){const n=[],i={},r=t.tracks;for(let t=0;t{const e=t.draco,a=new e.Decoder;try{const t=function(t,e,i,r){const s=r.attributeIDs,a=r.attributeTypes;let o,l;const c=e.GetEncodedGeometryType(i);if(c===t.TRIANGULAR_MESH)o=new t.Mesh,l=e.DecodeArrayToMesh(i,i.byteLength,o);else{if(c!==t.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");o=new t.PointCloud,l=e.DecodeArrayToPointCloud(i,i.byteLength,o)}if(!l.ok()||0===o.ptr)throw new Error("THREE.DRACOLoader: Decoding failed: "+l.error_msg());const h={index:null,attributes:[]};for(const i in s){const l=self[a[i]];let c,u;if(r.useUniqueIDs)u=s[i],c=e.GetAttributeByUniqueId(o,u);else{if(u=e.GetAttributeId(o,t[s[i]]),-1===u)continue;c=e.GetAttribute(o,u)}const d=n(t,e,o,i,l,c);"color"===i&&(d.vertexColorSpace=r.vertexColorSpace),h.attributes.push(d)}return c===t.TRIANGULAR_MESH&&(h.index=function(t,e,n){const i=3*n.num_faces(),r=4*i,s=t._malloc(r);e.GetTrianglesUInt32Array(n,r,s);const a=new Uint32Array(t.HEAPF32.buffer,s,i).slice();return t._free(s),{array:a,itemSize:1}}(t,e,o)),t.destroy(o),h}(e,a,new Int8Array(i),s),o=t.attributes.map((t=>t.array.buffer));t.index&&o.push(t.index.array.buffer),self.postMessage({type:"decode",id:r.id,geometry:t},o)}catch(t){console.error(t),self.postMessage({type:"error",id:r.id,error:t.message})}finally{e.destroy(a)}}))}}}var av=Uint8Array,ov=Uint16Array,lv=Int32Array,cv=new av([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),hv=new av([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),uv=new av([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),dv=function(t,e){for(var n=new ov(31),i=0;i<31;++i)n[i]=e+=1<>1|(21845&xv)<<1;_v=(61680&(_v=(52428&_v)>>2|(13107&_v)<<2))>>4|(3855&_v)<<4,yv[xv]=((65280&_v)>>8|(255&_v)<<8)>>1}var wv=function(t,e,n){for(var i=t.length,r=0,s=new ov(e);r>l]=c}else for(a=new ov(i),r=0;r>15-t[r]);return a},Cv=new av(288);for(xv=0;xv<144;++xv)Cv[xv]=8;for(xv=144;xv<256;++xv)Cv[xv]=9;for(xv=256;xv<280;++xv)Cv[xv]=7;for(xv=280;xv<288;++xv)Cv[xv]=8;var Ev=new av(32);for(xv=0;xv<32;++xv)Ev[xv]=5;var Mv=wv(Cv,9,0),bv=wv(Cv,9,1),Sv=wv(Ev,5,0),Iv=wv(Ev,5,1),Tv=function(t){for(var e=t[0],n=1;ne&&(e=t[n]);return e},Bv=function(t,e,n){var i=e/8|0;return(t[i]|t[i+1]<<8)>>(7&e)&n},Rv=function(t,e){var n=e/8|0;return(t[n]|t[n+1]<<8|t[n+2]<<16)>>(7&e)},Dv=function(t){return(t+7)/8|0},Pv=function(t,e,n){return(null==e||e<0)&&(e=0),(null==n||n>t.length)&&(n=t.length),new av(t.subarray(e,n))},Lv=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Uv=function(t,e,n){var i=new Error(e||Lv[t]);if(i.code=t,Error.captureStackTrace&&Error.captureStackTrace(i,Uv),!n)throw i;return i},Nv=function(t,e,n){n<<=7&e;var i=e/8|0;t[i]|=n,t[i+1]|=n>>8},Fv=function(t,e,n){n<<=7&e;var i=e/8|0;t[i]|=n,t[i+1]|=n>>8,t[i+2]|=n>>16},Ov=function(t,e){for(var n=[],i=0;id&&(d=s[i].s);var p=new ov(d+1),f=kv(n[h-1],p,0);if(f>e){i=0;var m=0,g=f-e,A=1<e))break;m+=A-(1<>=g;m>0;){var y=s[i].s;p[y]=0&&m;--i){var x=s[i].s;p[x]==e&&(--p[x],++m)}f=e}return{t:new av(p),l:f}},kv=function(t,e,n){return-1==t.s?Math.max(kv(t.l,e,n+1),kv(t.r,e,n+1)):e[t.s]=n},Qv=function(t){for(var e=t.length;e&&!t[--e];);for(var n=new ov(++e),i=0,r=t[0],s=1,a=function(t){n[i++]=t},o=1;o<=e;++o)if(t[o]==r&&o!=e)++s;else{if(!r&&s>2){for(;s>138;s-=138)a(32754);s>2&&(a(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(a(r),--s;s>6;s-=6)a(8304);s>2&&(a(s-3<<5|8208),s=0)}for(;s--;)a(r);s=1,r=t[o]}return{c:n.subarray(0,i),n:e}},zv=function(t,e){for(var n=0,i=0;i>8,t[r+2]=255^t[r],t[r+3]=255^t[r+1];for(var s=0;s4&&!b[uv[I-1]];--I);var T,B,R,D,P=c+5<<3,L=zv(r,Cv)+zv(s,Ev)+a,U=zv(r,d)+zv(s,m)+a+14+3*I+zv(C,b)+2*C[16]+3*C[17]+7*C[18];if(l>=0&&P<=L&&P<=U)return Gv(e,h,t.subarray(l,l+c));if(Nv(e,h,1+(U15&&(Nv(e,h,k[E]>>5&127),h+=k[E]>>12)}}}else T=Mv,B=Cv,R=Sv,D=Ev;for(E=0;E255){Fv(e,h,T[257+(Q=z>>18&31)]),h+=B[Q+257],Q>7&&(Nv(e,h,z>>23&31),h+=cv[Q]);var G=31&z;Fv(e,h,R[G]),h+=D[G],G>3&&(Fv(e,h,z>>5&8191),h+=hv[G])}else Fv(e,h,T[z]),h+=B[z]}return Fv(e,h,T[256]),h+B[256]},Vv=new lv([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Wv=new av(0),jv=function(){for(var t=new Int32Array(256),e=0;e<256;++e){for(var n=e,i=9;--i;)n=(1&n&&-306674912)^n>>>1;t[e]=n}return t}(),qv=function(){var t=-1;return{p:function(e){for(var n=t,i=0;i>>8;t=n},d:function(){return~t}}},Xv=function(t,e,n,i,r){if(!r&&(r={l:1},e.dictionary)){var s=e.dictionary.subarray(-32768),a=new av(s.length+t.length);a.set(s),a.set(t,s.length),t=a,r.w=s.length}return function(t,e,n,i,r,s){var a=s.z||t.length,o=new av(i+a+5*(1+Math.ceil(a/7e3))+r),l=o.subarray(i,o.length-r),c=s.l,h=7&(s.r||0);if(e){h&&(l[0]=s.r>>3);for(var u=Vv[e-1],d=u>>13,p=8191&u,f=(1<7e3||b>24576)&&(D>423||!c)){h=Hv(t,l,0,x,_,w,E,b,I,M-I,h),b=C=E=0,I=M;for(var P=0;P<286;++P)_[P]=0;for(P=0;P<30;++P)w[P]=0}var L=2,U=0,N=p,F=B-R&32767;if(D>2&&T==y(M-F))for(var O=Math.min(d,D)-1,k=Math.min(32767,M),Q=Math.min(258,D);F<=k&&--N&&B!=R;){if(t[M+L]==t[M+L-F]){for(var z=0;zL){if(L=z,U=F,z>O)break;var G=Math.min(F,z-2),H=0;for(P=0;PH&&(H=W,R=V)}}}F+=(B=R)-(R=m[B])&32767}if(U){x[b++]=268435456|mv[L]<<18|vv[U];var j=31&mv[L],q=31&vv[U];E+=cv[j]+hv[q],++_[257+j],++w[q],S=M+L,++C}else x[b++]=t[M],++_[t[M]]}}for(M=Math.max(M,S);M=a&&(l[h/8|0]=c,X=a),h=Gv(l,h+1,t.subarray(M,X))}s.i=a}return Pv(o,0,i+Dv(h)+r)}(t,null==e.level?6:e.level,null==e.mem?r.l?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(t.length)))):20:12+e.mem,n,i,r)},Yv=function(t,e){var n={};for(var i in t)n[i]=t[i];for(var i in e)n[i]=e[i];return n},Jv=function(t,e,n){for(;n;++e)t[e]=n,n>>>=8};function Kv(t,e){return Xv(t,e||{},0,0)}function Zv(t,e){return function(t,e,n,i){var r=t.length,s=i?i.length:0;if(!r||e.f&&!e.l)return n||new av(0);var a=!n,o=a||2!=e.i,l=e.i;a&&(n=new av(3*r));var c=function(t){var e=n.length;if(t>e){var i=new av(Math.max(2*e,t));i.set(n),n=i}},h=e.f||0,u=e.p||0,d=e.b||0,p=e.l,f=e.d,m=e.m,g=e.n,A=8*r;do{if(!p){h=Bv(t,u,1);var v=Bv(t,u+1,3);if(u+=3,!v){var y=t[(B=Dv(u)+4)-4]|t[B-3]<<8,x=B+y;if(x>r){l&&Uv(0);break}o&&c(d+y),n.set(t.subarray(B,x),d),e.b=d+=y,e.p=u=8*x,e.f=h;continue}if(1==v)p=bv,f=Iv,m=9,g=5;else if(2==v){var _=Bv(t,u,31)+257,w=Bv(t,u+10,15)+4,C=_+Bv(t,u+5,31)+1;u+=14;for(var E=new av(C),M=new av(19),b=0;b>4)<16)E[b++]=B;else{var D=0,P=0;for(16==B?(P=3+Bv(t,u,3),u+=2,D=E[b-1]):17==B?(P=3+Bv(t,u,7),u+=3):18==B&&(P=11+Bv(t,u,127),u+=7);P--;)E[b++]=D}}var L=E.subarray(0,_),U=E.subarray(_);m=Tv(L),g=Tv(U),p=wv(L,m,1),f=wv(U,g,1)}else Uv(1);if(u>A){l&&Uv(0);break}}o&&c(d+131072);for(var N=(1<>4;if((u+=15&D)>A){l&&Uv(0);break}if(D||Uv(2),k<256)n[d++]=k;else{if(256==k){O=u,p=null;break}var Q=k-254;if(k>264){var z=cv[b=k-257];Q=Bv(t,u,(1<>4;if(G||Uv(3),u+=15&G,U=Av[H],H>3&&(z=hv[H],U+=Rv(t,u)&(1<A){l&&Uv(0);break}o&&c(d+131072);var V=d+Q;if(d>4>7||(n[0]<<8|n[1])%31)&&Uv(6,"invalid zlib data"),(n[1]>>5&1)==+!i&&Uv(6,"invalid zlib data: "+(32&n[1]?"need":"unexpected")+" dictionary"),2+(n[1]>>3&4)),-4),{i:2},e&&e.out,e&&e.dictionary);var n,i}var $v=function(t,e,n,i){for(var r in t){var s=t[r],a=e+r,o=i;Array.isArray(s)&&(o=Yv(i,s[1]),s=s[0]),s instanceof av?n[a]=[s,o]:(n[a+="/"]=[new av(0),o],$v(s,a,n,i))}},ty="undefined"!=typeof TextEncoder&&new TextEncoder,ey="undefined"!=typeof TextDecoder&&new TextDecoder;try{ey.decode(Wv,{stream:!0})}catch(t){}function ny(t,e){if(e){for(var n=new av(t.length),i=0;i>1)),a=0,o=function(t){s[a++]=t};for(i=0;is.length){var l=new av(a+8+(r-i<<1));l.set(s),s=l}var c=t.charCodeAt(i);c<128||e?o(c):c<2048?(o(192|c>>6),o(128|63&c)):c>55295&&c<57344?(o(240|(c=65536+(1047552&c)|1023&t.charCodeAt(++i))>>18),o(128|c>>12&63),o(128|c>>6&63),o(128|63&c)):(o(224|c>>12),o(128|c>>6&63),o(128|63&c))}return Pv(s,0,a)}var iy=function(t){var e=0;if(t)for(var n in t){var i=t[n].length;i>65535&&Uv(9),e+=i+4}return e},ry=function(t,e,n,i,r,s,a,o){var l=i.length,c=n.extra,h=o&&o.length,u=iy(c);Jv(t,e,null!=a?33639248:67324752),e+=4,null!=a&&(t[e++]=20,t[e++]=n.os),t[e]=20,e+=2,t[e++]=n.flag<<1|(s<0&&8),t[e++]=r&&8,t[e++]=255&n.compression,t[e++]=n.compression>>8;var d=new Date(null==n.mtime?Date.now():n.mtime),p=d.getFullYear()-1980;if((p<0||p>119)&&Uv(10),Jv(t,e,p<<25|d.getMonth()+1<<21|d.getDate()<<16|d.getHours()<<11|d.getMinutes()<<5|d.getSeconds()>>1),e+=4,-1!=s&&(Jv(t,e,n.crc),Jv(t,e+4,s<0?-s-2:s),Jv(t,e+8,n.size)),Jv(t,e+12,l),Jv(t,e+14,u),e+=16,null!=a&&(Jv(t,e,h),Jv(t,e+6,n.attrs),Jv(t,e+10,a),e+=14),t.set(i,e),e+=l,u)for(var f in c){var m=c[f],g=m.length;Jv(t,e,+f),Jv(t,e+2,g),t.set(m,e+4),e+=4+g}return h&&(t.set(o,e),e+=h),e};function sy(t,e,n){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof OffscreenCanvas&&t instanceof OffscreenCanvas||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){const i=n/Math.max(t.width,t.height),r=document.createElement("canvas");r.width=t.width*Math.min(1,i),r.height=t.height*Math.min(1,i);const s=r.getContext("2d");return!0===e&&(s.translate(0,r.height),s.scale(1,-1)),s.drawImage(t,0,0,r.width,r.height),r}throw new Error("THREE.USDZExporter: No valid image data found. Unable to process texture.")}"function"==typeof queueMicrotask?queueMicrotask:"function"==typeof setTimeout&&setTimeout;function ay(t){const e=t.elements;return`( ${oy(e,0)}, ${oy(e,4)}, ${oy(e,8)}, ${oy(e,12)} )`}function oy(t,e){return`(${t[e+0]}, ${t[e+1]}, ${t[e+2]}, ${t[e+3]})`}function ly(t,e){if(void 0===t)return console.warn("USDZExporter: Normals missing."),Array(e).fill("(0, 0, 0)").join(", ");const n=[];for(let e=0;e0?"st"+i.channel:"st",l={1e3:"repeat",1001:"clamp",1002:"mirror"},c=i.repeat.clone(),h=i.offset.clone(),u=i.rotation,d=Math.sin(u),p=Math.cos(u);return h.y=1-h.y-c.y,n?(h.x=h.x/c.x,h.y=h.y/c.y,h.x+=d/c.x,h.y+=p-1):(h.x+=d*c.x,h.y+=(1-p)*c.y),`\n\t\tdef Shader "PrimvarReader_${r}"\n\t\t{\n\t\t\tuniform token info:id = "UsdPrimvarReader_float2"\n\t\t\tfloat2 inputs:fallback = (0.0, 0.0)\n\t\t\ttoken inputs:varname = "${o}"\n\t\t\tfloat2 outputs:result\n\t\t}\n\n\t\tdef Shader "Transform2d_${r}"\n\t\t{\n\t\t\tuniform token info:id = "UsdTransform2d"\n\t\t\ttoken inputs:in.connect = \n\t\t\tfloat inputs:rotation = ${(u*(180/Math.PI)).toFixed(7)}\n\t\t\tfloat2 inputs:scale = ${dy(c)}\n\t\t\tfloat2 inputs:translation = ${dy(h)}\n\t\t\tfloat2 outputs:result\n\t\t}\n\n\t\tdef Shader "Texture_${i.id}_${r}"\n\t\t{\n\t\t\tuniform token info:id = "UsdUVTexture"\n\t\t\tasset inputs:file = @textures/Texture_${a}.png@\n\t\t\tfloat2 inputs:st.connect = \n\t\t\t${void 0!==s?"float4 inputs:scale = "+function(t){return`(${t.r}, ${t.g}, ${t.b}, 1.0)`}(s):""}\n\t\t\ttoken inputs:sourceColorSpace = "${i.colorSpace===hn?"raw":"sRGB"}"\n\t\t\ttoken inputs:wrapS = "${l[i.wrapS]}"\n\t\t\ttoken inputs:wrapT = "${l[i.wrapT]}"\n\t\t\tfloat outputs:r\n\t\t\tfloat outputs:g\n\t\t\tfloat outputs:b\n\t\t\tfloat3 outputs:rgb\n\t\t\t${t.transparent||t.alphaTest>0?"float outputs:a":""}\n\t\t}`}return t.side===S&&console.warn("THREE.USDZExporter: USDZ does not support double sided materials",t),null!==t.map?(r.push(`${i}color3f inputs:diffuseColor.connect = `),t.transparent?r.push(`${i}float inputs:opacity.connect = `):t.alphaTest>0&&(r.push(`${i}float inputs:opacity.connect = `),r.push(`${i}float inputs:opacityThreshold = ${t.alphaTest}`)),s.push(a(t.map,"diffuse",t.color))):r.push(`${i}color3f inputs:diffuseColor = ${uy(t.color)}`),null!==t.emissiveMap?(r.push(`${i}color3f inputs:emissiveColor.connect = `),s.push(a(t.emissiveMap,"emissive",new us(t.emissive.r*t.emissiveIntensity,t.emissive.g*t.emissiveIntensity,t.emissive.b*t.emissiveIntensity)))):t.emissive.getHex()>0&&r.push(`${i}color3f inputs:emissiveColor = ${uy(t.emissive)}`),null!==t.normalMap&&(r.push(`${i}normal3f inputs:normal.connect = `),s.push(a(t.normalMap,"normal"))),null!==t.aoMap&&(r.push(`${i}float inputs:occlusion.connect = `),s.push(a(t.aoMap,"occlusion",new us(t.aoMapIntensity,t.aoMapIntensity,t.aoMapIntensity)))),null!==t.roughnessMap?(r.push(`${i}float inputs:roughness.connect = `),s.push(a(t.roughnessMap,"roughness",new us(t.roughness,t.roughness,t.roughness)))):r.push(`${i}float inputs:roughness = ${t.roughness}`),null!==t.metalnessMap?(r.push(`${i}float inputs:metallic.connect = `),s.push(a(t.metalnessMap,"metallic",new us(t.metalness,t.metalness,t.metalness)))):r.push(`${i}float inputs:metallic = ${t.metalness}`),null!==t.alphaMap?(r.push(`${i}float inputs:opacity.connect = `),r.push(`${i}float inputs:opacityThreshold = 0.0001`),s.push(a(t.alphaMap,"opacity"))):r.push(`${i}float inputs:opacity = ${t.opacity}`),t.isMeshPhysicalMaterial&&(null!==t.clearcoatMap?(r.push(`${i}float inputs:clearcoat.connect = `),s.push(a(t.clearcoatMap,"clearcoat",new us(t.clearcoat,t.clearcoat,t.clearcoat)))):r.push(`${i}float inputs:clearcoat = ${t.clearcoat}`),null!==t.clearcoatRoughnessMap?(r.push(`${i}float inputs:clearcoatRoughness.connect = `),s.push(a(t.clearcoatRoughnessMap,"clearcoatRoughness",new us(t.clearcoatRoughness,t.clearcoatRoughness,t.clearcoatRoughness)))):r.push(`${i}float inputs:clearcoatRoughness = ${t.clearcoatRoughness}`),r.push(`${i}float inputs:ior = ${t.ior}`)),`\n\tdef Material "Material_${t.id}"\n\t{\n\t\tdef Shader "PreviewSurface"\n\t\t{\n\t\t\tuniform token info:id = "UsdPreviewSurface"\n${r.join("\n")}\n\t\t\tint inputs:useSpecularWorkflow = 0\n\t\t\ttoken outputs:surface\n\t\t}\n\n\t\ttoken outputs:surface.connect = \n\n${s.join("\n")}\n\n\t}\n`}function uy(t){return`(${t.r}, ${t.g}, ${t.b})`}function dy(t){return`(${t.x}, ${t.y})`}const py=new Hi,fy=new Gi,my=new Hi;const gy=new yr,Ay=new yr,vy=new Hi,yy=new Lf,xy=new va,_y=new Hi,wy=new as;class Cy{constructor(){this.tolerance=-1,this.faces=[],this.newFaces=[],this.assigned=new Sy,this.unassigned=new Sy,this.vertices=[]}setFromPoints(t){if(t.length>=4){this.makeEmpty();for(let e=0,n=t.length;ethis.tolerance)return!1;return!0}intersectRay(t,e){const n=this.faces;let i=-1/0,r=1/0;for(let e=0,s=n.length;e0&&o>=0)return null;const l=0!==o?-a/o:0;if(!(l<=0)&&(o>0?r=Math.min(l,r):i=Math.max(l,i),i>r))return null}return i!==-1/0?t.at(i,e):t.at(r,e),e}intersectsRay(t){return null!==this.intersectRay(t,vy)}makeEmpty(){return this.faces=[],this.vertices=[],this}addVertexToFace(t,e){return t.face=e,null===e.outside?this.assigned.append(t):this.assigned.insertBefore(e.outside,t),e.outside=t,this}removeVertexFromFace(t,e){return t===e.outside&&(null!==t.next&&t.next.face===e?e.outside=t.next:e.outside=null),this.assigned.remove(t),this}removeAllVerticesFromFace(t){if(null!==t.outside){const e=t.outside;let n=t.outside;for(;null!==n.next&&n.next.face===t;)n=n.next;return this.assigned.removeSubList(e,n),e.prev=n.next=null,t.outside=null,e}}deleteFaceVertices(t,e){const n=this.removeAllVerticesFromFace(t);if(void 0!==n)if(void 0===e)this.unassigned.appendChain(n);else{let t=n;do{const n=t.next;e.distanceToPoint(t.point)>this.tolerance?this.addVertexToFace(t,e):this.unassigned.append(t),t=n}while(null!==t)}return this}resolveUnassignedPoints(t){if(!1===this.unassigned.isEmpty()){let e=this.unassigned.first();do{const n=e.next;let i=this.tolerance,r=null;for(let n=0;ni&&(i=t,r=s),i>1e3*this.tolerance)break}}null!==r&&this.addVertexToFace(e,r),e=n}while(null!==e)}return this}computeExtremes(){const t=new Hi,e=new Hi,n=[],i=[];for(let t=0;t<3;t++)n[t]=i[t]=this.vertices[0];t.copy(this.vertices[0].point),e.copy(this.vertices[0].point);for(let r=0,s=this.vertices.length;re.getComponent(t)&&(e.setComponent(t,a.getComponent(t)),i[t]=s)}return this.tolerance=3*Number.EPSILON*(Math.max(Math.abs(t.x),Math.abs(e.x))+Math.max(Math.abs(t.y),Math.abs(e.y))+Math.max(Math.abs(t.z),Math.abs(e.z))),{min:n,max:i}}computeInitialHull(){const t=this.vertices,e=this.computeExtremes(),n=e.min,i=e.max;let r=0,s=0;for(let t=0;t<3;t++){const e=i[t].point.getComponent(t)-n[t].point.getComponent(t);e>r&&(r=e,s=t)}const a=n[s],o=i[s];let l,c;r=0,yy.set(a.point,o.point);for(let e=0,n=this.vertices.length;er&&(r=t,l=n)}}r=-1,xy.setFromCoplanarPoints(a.point,o.point,l.point);for(let e=0,n=this.vertices.length;er&&(r=t,c=n)}}const h=[];if(xy.distanceToPoint(c.point)<0){h.push(Ey.create(a,o,l),Ey.create(c,o,a),Ey.create(c,l,o),Ey.create(c,a,l));for(let t=0;t<3;t++){const e=(t+1)%3;h[t+1].getEdge(2).setTwin(h[0].getEdge(e)),h[t+1].getEdge(1).setTwin(h[e+1].getEdge(0))}}else{h.push(Ey.create(a,l,o),Ey.create(c,a,o),Ey.create(c,o,l),Ey.create(c,l,a));for(let t=0;t<3;t++){const e=(t+1)%3;h[t+1].getEdge(2).setTwin(h[0].getEdge((3-t)%3)),h[t+1].getEdge(0).setTwin(h[e+1].getEdge(1))}}for(let t=0;t<4;t++)this.faces.push(h[t]);for(let e=0,n=t.length;er&&(r=i,t=this.faces[e])}null!==t&&this.addVertexToFace(n,t)}}return this}reindexFaces(){const t=[];for(let e=0;ee&&(e=r,t=i),i=i.next}while(null!==i&&i.face===n);return t}}computeHorizon(t,e,n,i){let r;this.deleteFaceVertices(n),n.mark=1,r=null===e?e=n.getEdge(0):e.next;do{const e=r.twin,n=e.face;0===n.mark&&(n.distanceToPoint(t)>this.tolerance?this.computeHorizon(t,e,n,i):i.push(r)),r=r.next}while(r!==e);return this}addAdjoiningFace(t,e){const n=Ey.create(t,e.tail(),e.head());return this.faces.push(n),n.getEdge(-1).setTwin(e.twin),n.getEdge(0)}addNewFaces(t,e){this.newFaces=[];let n=null,i=null;for(let r=0;r0;)e=e.next,t--;for(;t<0;)e=e.prev,t++;return e}compute(){const t=this.edge.tail(),e=this.edge.head(),n=this.edge.next.head();return wy.set(t.point,e.point,n.point),wy.getNormal(this.normal),wy.getMidpoint(this.midpoint),this.area=wy.getArea(),this.constant=this.normal.dot(this.midpoint),this}distanceToPoint(t){return this.normal.dot(t)-this.constant}}class My{constructor(t,e){this.vertex=t,this.prev=null,this.next=null,this.twin=null,this.face=e}head(){return this.vertex}tail(){return this.prev?this.prev.vertex:null}length(){const t=this.head(),e=this.tail();return null!==e?e.point.distanceTo(t.point):-1}lengthSquared(){const t=this.head(),e=this.tail();return null!==e?e.point.distanceToSquared(t.point):-1}setTwin(t){return this.twin=t,t.twin=this,this}}class by{constructor(t){this.point=t,this.prev=null,this.next=null,this.face=null}}class Sy{constructor(){this.head=null,this.tail=null}first(){return this.head}last(){return this.tail}clear(){return this.head=this.tail=null,this}insertBefore(t,e){return e.prev=t.prev,e.next=t,null===e.prev?this.head=e:e.prev.next=e,t.prev=e,this}insertAfter(t,e){return e.prev=t,e.next=t.next,null===e.next?this.tail=e:e.next.prev=e,t.next=e,this}append(t){return null===this.head?this.head=t:this.tail.next=t,t.prev=this.tail,t.next=null,this.tail=t,this}appendChain(t){for(null===this.head?this.head=t:this.tail.next=t,t.prev=this.tail;null!==t.next;)t=t.next;return this.tail=t,this}remove(t){return null===t.prev?this.head=t.next:t.prev.next=t.next,null===t.next?this.tail=t.prev:t.next.prev=t.prev,this}removeSubList(t,e){return null===t.prev?this.head=e.next:t.prev.next=e.next,null===e.next?this.tail=t.prev:e.next.prev=t.prev,this}isEmpty(){return null===this.head}}function Iy(t,e){switch(e){case un:t.convertSRGBToLinear();break;case dn:case hn:break;default:console.warn("WARNING: LightProbeGenerator convertColorToLinear() encountered an unsupported color space.")}return t}class Ty{constructor(t,e,n,i,r){this.xrLight=t,this.renderer=e,this.lightProbe=n,this.xrWebGLBinding=null,this.estimationStartCallback=r,this.frameCallback=this.onXRFrame.bind(this);const s=e.xr.getSession();if(i&&"XRWebGLBinding"in window){const n=new fa(16);t.environment=n.texture;const i=e.getContext();switch(s.preferredReflectionFormat){case"srgba8":i.getExtension("EXT_sRGB");break;case"rgba16f":i.getExtension("OES_texture_half_float")}this.xrWebGLBinding=new XRWebGLBinding(s,i),this.lightProbe.addEventListener("reflectionchange",(()=>{this.updateReflection()}))}s.requestAnimationFrame(this.frameCallback)}updateReflection(){const t=this.renderer.properties.get(this.xrLight.environment);if(t){const e=this.xrWebGLBinding.getReflectionCubeMap(this.lightProbe);e&&(t.__webglTexture=e,this.xrLight.environment.needsPMREMUpdate=!0)}}onXRFrame(t,e){if(!this.xrLight)return;e.session.requestAnimationFrame(this.frameCallback);const n=e.getLightEstimate(this.lightProbe);if(n){this.xrLight.lightProbe.sh.fromArray(n.sphericalHarmonicsCoefficients),this.xrLight.lightProbe.intensity=1;const t=Math.max(1,Math.max(n.primaryLightIntensity.x,Math.max(n.primaryLightIntensity.y,n.primaryLightIntensity.z)));this.xrLight.directionalLight.color.setRGB(n.primaryLightIntensity.x/t,n.primaryLightIntensity.y/t,n.primaryLightIntensity.z/t),this.xrLight.directionalLight.intensity=t,this.xrLight.directionalLight.position.copy(n.primaryLightDirection),this.estimationStartCallback&&(this.estimationStartCallback(),this.estimationStartCallback=null)}}dispose(){this.xrLight=null,this.renderer=null,this.lightProbe=null,this.xrWebGLBinding=null}}class By{constructor(t=4){this.pool=t,this.queue=[],this.workers=[],this.workersResolve=[],this.workerStatus=0}_initWorker(t){if(!this.workers[t]){const e=this.workerCreator();e.addEventListener("message",this._onMessage.bind(this,t)),this.workers[t]=e}}_getIdleWorker(){for(let t=0;t{const i=this._getIdleWorker();-1!==i?(this._initWorker(i),this.workerStatus|=1<t.terminate())),this.workersResolve.length=0,this.workers.length=0,this.queue.length=0,this.workerStatus=0}}const Ry=9,Dy=15,Py=16,Ly=22,Uy=37,Ny=43,Fy=76,Oy=83,ky=97,Qy=100,zy=103,Gy=109,Hy=165,Vy=166,Wy=1000066e3;class jy{constructor(){this.vkFormat=0,this.typeSize=1,this.pixelWidth=0,this.pixelHeight=0,this.pixelDepth=0,this.layerCount=0,this.faceCount=1,this.supercompressionScheme=0,this.levels=[],this.dataFormatDescriptor=[{vendorId:0,descriptorType:0,descriptorBlockSize:0,versionNumber:2,colorModel:0,colorPrimaries:1,transferFunction:2,flags:0,texelBlockDimension:[0,0,0,0],bytesPlane:[0,0,0,0,0,0,0,0],samples:[]}],this.keyValue={},this.globalData=null}}class qy{constructor(t,e,n,i){this._dataView=void 0,this._littleEndian=void 0,this._offset=void 0,this._dataView=new DataView(t.buffer,t.byteOffset+e,n),this._littleEndian=i,this._offset=0}_nextUint8(){const t=this._dataView.getUint8(this._offset);return this._offset+=1,t}_nextUint16(){const t=this._dataView.getUint16(this._offset,this._littleEndian);return this._offset+=2,t}_nextUint32(){const t=this._dataView.getUint32(this._offset,this._littleEndian);return this._offset+=4,t}_nextUint64(){const t=this._dataView.getUint32(this._offset,this._littleEndian)+2**32*this._dataView.getUint32(this._offset+4,this._littleEndian);return this._offset+=8,t}_nextInt32(){const t=this._dataView.getInt32(this._offset,this._littleEndian);return this._offset+=4,t}_nextUint8Array(t){const e=new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+this._offset,t);return this._offset+=t,e}_skip(t){return this._offset+=t,this}_scan(t,e){void 0===e&&(e=0);const n=this._offset;let i=0;for(;this._dataView.getUint8(this._offset)!==e&&it.arrayBuffer())).then((t=>WebAssembly.instantiate(t,$y))).then(this._init):WebAssembly.instantiate(Buffer.from(ex,"base64"),$y).then(this._init),Jy)}_init(t){Ky=t.instance,$y.env.emscripten_notify_memory_growth(0)}decode(t,e=0){if(!Ky)throw new Error("ZSTDDecoder: Await .init() before decoding.");const n=t.byteLength,i=Ky.exports.malloc(n);Zy.set(t,i),e=e||Number(Ky.exports.ZSTD_findDecompressedSize(i,n));const r=Ky.exports.malloc(e),s=Ky.exports.ZSTD_decompress(r,e,i,n),a=Zy.slice(r,r+s);return Ky.exports.free(i),Ky.exports.free(r),a}}const ex="AGFzbQEAAAABpQEVYAF/AX9gAn9/AGADf39/AX9gBX9/f39/AX9gAX8AYAJ/fwF/YAR/f39/AX9gA39/fwBgBn9/f39/fwF/YAd/f39/f39/AX9gAn9/AX5gAn5+AX5gAABgBX9/f39/AGAGf39/f39/AGAIf39/f39/f38AYAl/f39/f39/f38AYAABf2AIf39/f39/f38Bf2ANf39/f39/f39/f39/fwF/YAF/AX4CJwEDZW52H2Vtc2NyaXB0ZW5fbm90aWZ5X21lbW9yeV9ncm93dGgABANpaAEFAAAFAgEFCwACAQABAgIFBQcAAwABDgsBAQcAEhMHAAUBDAQEAAANBwQCAgYCBAgDAwMDBgEACQkHBgICAAYGAgQUBwYGAwIGAAMCAQgBBwUGCgoEEQAEBAEIAwgDBQgDEA8IAAcABAUBcAECAgUEAQCAAgYJAX8BQaCgwAILB2AHBm1lbW9yeQIABm1hbGxvYwAoBGZyZWUAJgxaU1REX2lzRXJyb3IAaBlaU1REX2ZpbmREZWNvbXByZXNzZWRTaXplAFQPWlNURF9kZWNvbXByZXNzAEoGX3N0YXJ0ACQJBwEAQQELASQKussBaA8AIAAgACgCBCABajYCBAsZACAAKAIAIAAoAgRBH3F0QQAgAWtBH3F2CwgAIABBiH9LC34BBH9BAyEBIAAoAgQiA0EgTQRAIAAoAggiASAAKAIQTwRAIAAQDQ8LIAAoAgwiAiABRgRAQQFBAiADQSBJGw8LIAAgASABIAJrIANBA3YiBCABIARrIAJJIgEbIgJrIgQ2AgggACADIAJBA3RrNgIEIAAgBCgAADYCAAsgAQsUAQF/IAAgARACIQIgACABEAEgAgv3AQECfyACRQRAIABCADcCACAAQQA2AhAgAEIANwIIQbh/DwsgACABNgIMIAAgAUEEajYCECACQQRPBEAgACABIAJqIgFBfGoiAzYCCCAAIAMoAAA2AgAgAUF/ai0AACIBBEAgAEEIIAEQFGs2AgQgAg8LIABBADYCBEF/DwsgACABNgIIIAAgAS0AACIDNgIAIAJBfmoiBEEBTQRAIARBAWtFBEAgACABLQACQRB0IANyIgM2AgALIAAgAS0AAUEIdCADajYCAAsgASACakF/ai0AACIBRQRAIABBADYCBEFsDwsgAEEoIAEQFCACQQN0ams2AgQgAgsWACAAIAEpAAA3AAAgACABKQAINwAICy8BAX8gAUECdEGgHWooAgAgACgCAEEgIAEgACgCBGprQR9xdnEhAiAAIAEQASACCyEAIAFCz9bTvtLHq9lCfiAAfEIfiUKHla+vmLbem55/fgsdAQF/IAAoAgggACgCDEYEfyAAKAIEQSBGBUEACwuCBAEDfyACQYDAAE8EQCAAIAEgAhBnIAAPCyAAIAJqIQMCQCAAIAFzQQNxRQRAAkAgAkEBSARAIAAhAgwBCyAAQQNxRQRAIAAhAgwBCyAAIQIDQCACIAEtAAA6AAAgAUEBaiEBIAJBAWoiAiADTw0BIAJBA3ENAAsLAkAgA0F8cSIEQcAASQ0AIAIgBEFAaiIFSw0AA0AgAiABKAIANgIAIAIgASgCBDYCBCACIAEoAgg2AgggAiABKAIMNgIMIAIgASgCEDYCECACIAEoAhQ2AhQgAiABKAIYNgIYIAIgASgCHDYCHCACIAEoAiA2AiAgAiABKAIkNgIkIAIgASgCKDYCKCACIAEoAiw2AiwgAiABKAIwNgIwIAIgASgCNDYCNCACIAEoAjg2AjggAiABKAI8NgI8IAFBQGshASACQUBrIgIgBU0NAAsLIAIgBE8NAQNAIAIgASgCADYCACABQQRqIQEgAkEEaiICIARJDQALDAELIANBBEkEQCAAIQIMAQsgA0F8aiIEIABJBEAgACECDAELIAAhAgNAIAIgAS0AADoAACACIAEtAAE6AAEgAiABLQACOgACIAIgAS0AAzoAAyABQQRqIQEgAkEEaiICIARNDQALCyACIANJBEADQCACIAEtAAA6AAAgAUEBaiEBIAJBAWoiAiADRw0ACwsgAAsMACAAIAEpAAA3AAALQQECfyAAKAIIIgEgACgCEEkEQEEDDwsgACAAKAIEIgJBB3E2AgQgACABIAJBA3ZrIgE2AgggACABKAAANgIAQQALDAAgACABKAIANgAAC/cCAQJ/AkAgACABRg0AAkAgASACaiAASwRAIAAgAmoiBCABSw0BCyAAIAEgAhALDwsgACABc0EDcSEDAkACQCAAIAFJBEAgAwRAIAAhAwwDCyAAQQNxRQRAIAAhAwwCCyAAIQMDQCACRQ0EIAMgAS0AADoAACABQQFqIQEgAkF/aiECIANBAWoiA0EDcQ0ACwwBCwJAIAMNACAEQQNxBEADQCACRQ0FIAAgAkF/aiICaiIDIAEgAmotAAA6AAAgA0EDcQ0ACwsgAkEDTQ0AA0AgACACQXxqIgJqIAEgAmooAgA2AgAgAkEDSw0ACwsgAkUNAgNAIAAgAkF/aiICaiABIAJqLQAAOgAAIAINAAsMAgsgAkEDTQ0AIAIhBANAIAMgASgCADYCACABQQRqIQEgA0EEaiEDIARBfGoiBEEDSw0ACyACQQNxIQILIAJFDQADQCADIAEtAAA6AAAgA0EBaiEDIAFBAWohASACQX9qIgINAAsLIAAL8wICAn8BfgJAIAJFDQAgACACaiIDQX9qIAE6AAAgACABOgAAIAJBA0kNACADQX5qIAE6AAAgACABOgABIANBfWogAToAACAAIAE6AAIgAkEHSQ0AIANBfGogAToAACAAIAE6AAMgAkEJSQ0AIABBACAAa0EDcSIEaiIDIAFB/wFxQYGChAhsIgE2AgAgAyACIARrQXxxIgRqIgJBfGogATYCACAEQQlJDQAgAyABNgIIIAMgATYCBCACQXhqIAE2AgAgAkF0aiABNgIAIARBGUkNACADIAE2AhggAyABNgIUIAMgATYCECADIAE2AgwgAkFwaiABNgIAIAJBbGogATYCACACQWhqIAE2AgAgAkFkaiABNgIAIAQgA0EEcUEYciIEayICQSBJDQAgAa0iBUIghiAFhCEFIAMgBGohAQNAIAEgBTcDGCABIAU3AxAgASAFNwMIIAEgBTcDACABQSBqIQEgAkFgaiICQR9LDQALCyAACy8BAn8gACgCBCAAKAIAQQJ0aiICLQACIQMgACACLwEAIAEgAi0AAxAIajYCACADCy8BAn8gACgCBCAAKAIAQQJ0aiICLQACIQMgACACLwEAIAEgAi0AAxAFajYCACADCx8AIAAgASACKAIEEAg2AgAgARAEGiAAIAJBCGo2AgQLCAAgAGdBH3MLugUBDX8jAEEQayIKJAACfyAEQQNNBEAgCkEANgIMIApBDGogAyAEEAsaIAAgASACIApBDGpBBBAVIgBBbCAAEAMbIAAgACAESxsMAQsgAEEAIAEoAgBBAXRBAmoQECENQVQgAygAACIGQQ9xIgBBCksNABogAiAAQQVqNgIAIAMgBGoiAkF8aiEMIAJBeWohDiACQXtqIRAgAEEGaiELQQQhBSAGQQR2IQRBICAAdCIAQQFyIQkgASgCACEPQQAhAiADIQYCQANAIAlBAkggAiAPS3JFBEAgAiEHAkAgCARAA0AgBEH//wNxQf//A0YEQCAHQRhqIQcgBiAQSQR/IAZBAmoiBigAACAFdgUgBUEQaiEFIARBEHYLIQQMAQsLA0AgBEEDcSIIQQNGBEAgBUECaiEFIARBAnYhBCAHQQNqIQcMAQsLIAcgCGoiByAPSw0EIAVBAmohBQNAIAIgB0kEQCANIAJBAXRqQQA7AQAgAkEBaiECDAELCyAGIA5LQQAgBiAFQQN1aiIHIAxLG0UEQCAHKAAAIAVBB3EiBXYhBAwCCyAEQQJ2IQQLIAYhBwsCfyALQX9qIAQgAEF/anEiBiAAQQF0QX9qIgggCWsiEUkNABogBCAIcSIEQQAgESAEIABIG2shBiALCyEIIA0gAkEBdGogBkF/aiIEOwEAIAlBASAGayAEIAZBAUgbayEJA0AgCSAASARAIABBAXUhACALQX9qIQsMAQsLAn8gByAOS0EAIAcgBSAIaiIFQQN1aiIGIAxLG0UEQCAFQQdxDAELIAUgDCIGIAdrQQN0awshBSACQQFqIQIgBEUhCCAGKAAAIAVBH3F2IQQMAQsLQWwgCUEBRyAFQSBKcg0BGiABIAJBf2o2AgAgBiAFQQdqQQN1aiADawwBC0FQCyEAIApBEGokACAACwkAQQFBBSAAGwsMACAAIAEoAAA2AAALqgMBCn8jAEHwAGsiCiQAIAJBAWohDiAAQQhqIQtBgIAEIAVBf2p0QRB1IQxBACECQQEhBkEBIAV0IglBf2oiDyEIA0AgAiAORkUEQAJAIAEgAkEBdCINai8BACIHQf//A0YEQCALIAhBA3RqIAI2AgQgCEF/aiEIQQEhBwwBCyAGQQAgDCAHQRB0QRB1ShshBgsgCiANaiAHOwEAIAJBAWohAgwBCwsgACAFNgIEIAAgBjYCACAJQQN2IAlBAXZqQQNqIQxBACEAQQAhBkEAIQIDQCAGIA5GBEADQAJAIAAgCUYNACAKIAsgAEEDdGoiASgCBCIGQQF0aiICIAIvAQAiAkEBajsBACABIAUgAhAUayIIOgADIAEgAiAIQf8BcXQgCWs7AQAgASAEIAZBAnQiAmooAgA6AAIgASACIANqKAIANgIEIABBAWohAAwBCwsFIAEgBkEBdGouAQAhDUEAIQcDQCAHIA1ORQRAIAsgAkEDdGogBjYCBANAIAIgDGogD3EiAiAISw0ACyAHQQFqIQcMAQsLIAZBAWohBgwBCwsgCkHwAGokAAsjAEIAIAEQCSAAhUKHla+vmLbem55/fkLj3MqV/M7y9YV/fAsQACAAQn43AwggACABNgIACyQBAX8gAARAIAEoAgQiAgRAIAEoAgggACACEQEADwsgABAmCwsfACAAIAEgAi8BABAINgIAIAEQBBogACACQQRqNgIEC0oBAX9BoCAoAgAiASAAaiIAQX9MBEBBiCBBMDYCAEF/DwsCQCAAPwBBEHRNDQAgABBmDQBBiCBBMDYCAEF/DwtBoCAgADYCACABC9cBAQh/Qbp/IQoCQCACKAIEIgggAigCACIJaiIOIAEgAGtLDQBBbCEKIAkgBCADKAIAIgtrSw0AIAAgCWoiBCACKAIIIgxrIQ0gACABQWBqIg8gCyAJQQAQKSADIAkgC2o2AgACQAJAIAwgBCAFa00EQCANIQUMAQsgDCAEIAZrSw0CIAcgDSAFayIAaiIBIAhqIAdNBEAgBCABIAgQDxoMAgsgBCABQQAgAGsQDyEBIAIgACAIaiIINgIEIAEgAGshBAsgBCAPIAUgCEEBECkLIA4hCgsgCgubAgEBfyMAQYABayINJAAgDSADNgJ8AkAgAkEDSwRAQX8hCQwBCwJAAkACQAJAIAJBAWsOAwADAgELIAZFBEBBuH8hCQwEC0FsIQkgBS0AACICIANLDQMgACAHIAJBAnQiAmooAgAgAiAIaigCABA7IAEgADYCAEEBIQkMAwsgASAJNgIAQQAhCQwCCyAKRQRAQWwhCQwCC0EAIQkgC0UgDEEZSHINAUEIIAR0QQhqIQBBACECA0AgAiAATw0CIAJBQGshAgwAAAsAC0FsIQkgDSANQfwAaiANQfgAaiAFIAYQFSICEAMNACANKAJ4IgMgBEsNACAAIA0gDSgCfCAHIAggAxAYIAEgADYCACACIQkLIA1BgAFqJAAgCQsLACAAIAEgAhALGgsQACAALwAAIAAtAAJBEHRyCy8AAn9BuH8gAUEISQ0AGkFyIAAoAAQiAEF3Sw0AGkG4fyAAQQhqIgAgACABSxsLCwkAIAAgATsAAAsDAAELigYBBX8gACAAKAIAIgVBfnE2AgBBACAAIAVBAXZqQYQgKAIAIgQgAEYbIQECQAJAIAAoAgQiAkUNACACKAIAIgNBAXENACACQQhqIgUgA0EBdkF4aiIDQQggA0EISxtnQR9zQQJ0QYAfaiIDKAIARgRAIAMgAigCDDYCAAsgAigCCCIDBEAgAyACKAIMNgIECyACKAIMIgMEQCADIAIoAgg2AgALIAIgAigCACAAKAIAQX5xajYCAEGEICEAAkACQCABRQ0AIAEgAjYCBCABKAIAIgNBAXENASADQQF2QXhqIgNBCCADQQhLG2dBH3NBAnRBgB9qIgMoAgAgAUEIakYEQCADIAEoAgw2AgALIAEoAggiAwRAIAMgASgCDDYCBAsgASgCDCIDBEAgAyABKAIINgIAQYQgKAIAIQQLIAIgAigCACABKAIAQX5xajYCACABIARGDQAgASABKAIAQQF2akEEaiEACyAAIAI2AgALIAIoAgBBAXZBeGoiAEEIIABBCEsbZ0Efc0ECdEGAH2oiASgCACEAIAEgBTYCACACIAA2AgwgAkEANgIIIABFDQEgACAFNgIADwsCQCABRQ0AIAEoAgAiAkEBcQ0AIAJBAXZBeGoiAkEIIAJBCEsbZ0Efc0ECdEGAH2oiAigCACABQQhqRgRAIAIgASgCDDYCAAsgASgCCCICBEAgAiABKAIMNgIECyABKAIMIgIEQCACIAEoAgg2AgBBhCAoAgAhBAsgACAAKAIAIAEoAgBBfnFqIgI2AgACQCABIARHBEAgASABKAIAQQF2aiAANgIEIAAoAgAhAgwBC0GEICAANgIACyACQQF2QXhqIgFBCCABQQhLG2dBH3NBAnRBgB9qIgIoAgAhASACIABBCGoiAjYCACAAIAE2AgwgAEEANgIIIAFFDQEgASACNgIADwsgBUEBdkF4aiIBQQggAUEISxtnQR9zQQJ0QYAfaiICKAIAIQEgAiAAQQhqIgI2AgAgACABNgIMIABBADYCCCABRQ0AIAEgAjYCAAsLDgAgAARAIABBeGoQJQsLgAIBA38CQCAAQQ9qQXhxQYQgKAIAKAIAQQF2ayICEB1Bf0YNAAJAQYQgKAIAIgAoAgAiAUEBcQ0AIAFBAXZBeGoiAUEIIAFBCEsbZ0Efc0ECdEGAH2oiASgCACAAQQhqRgRAIAEgACgCDDYCAAsgACgCCCIBBEAgASAAKAIMNgIECyAAKAIMIgFFDQAgASAAKAIINgIAC0EBIQEgACAAKAIAIAJBAXRqIgI2AgAgAkEBcQ0AIAJBAXZBeGoiAkEIIAJBCEsbZ0Efc0ECdEGAH2oiAygCACECIAMgAEEIaiIDNgIAIAAgAjYCDCAAQQA2AgggAkUNACACIAM2AgALIAELtwIBA38CQAJAIABBASAAGyICEDgiAA0AAkACQEGEICgCACIARQ0AIAAoAgAiA0EBcQ0AIAAgA0EBcjYCACADQQF2QXhqIgFBCCABQQhLG2dBH3NBAnRBgB9qIgEoAgAgAEEIakYEQCABIAAoAgw2AgALIAAoAggiAQRAIAEgACgCDDYCBAsgACgCDCIBBEAgASAAKAIINgIACyACECchAkEAIQFBhCAoAgAhACACDQEgACAAKAIAQX5xNgIAQQAPCyACQQ9qQXhxIgMQHSICQX9GDQIgAkEHakF4cSIAIAJHBEAgACACaxAdQX9GDQMLAkBBhCAoAgAiAUUEQEGAICAANgIADAELIAAgATYCBAtBhCAgADYCACAAIANBAXRBAXI2AgAMAQsgAEUNAQsgAEEIaiEBCyABC7kDAQJ/IAAgA2ohBQJAIANBB0wEQANAIAAgBU8NAiAAIAItAAA6AAAgAEEBaiEAIAJBAWohAgwAAAsACyAEQQFGBEACQCAAIAJrIgZBB00EQCAAIAItAAA6AAAgACACLQABOgABIAAgAi0AAjoAAiAAIAItAAM6AAMgAEEEaiACIAZBAnQiBkHAHmooAgBqIgIQFyACIAZB4B5qKAIAayECDAELIAAgAhAMCyACQQhqIQIgAEEIaiEACwJAAkACQAJAIAUgAU0EQCAAIANqIQEgBEEBRyAAIAJrQQ9Kcg0BA0AgACACEAwgAkEIaiECIABBCGoiACABSQ0ACwwFCyAAIAFLBEAgACEBDAQLIARBAUcgACACa0EPSnINASAAIQMgAiEEA0AgAyAEEAwgBEEIaiEEIANBCGoiAyABSQ0ACwwCCwNAIAAgAhAHIAJBEGohAiAAQRBqIgAgAUkNAAsMAwsgACEDIAIhBANAIAMgBBAHIARBEGohBCADQRBqIgMgAUkNAAsLIAIgASAAa2ohAgsDQCABIAVPDQEgASACLQAAOgAAIAFBAWohASACQQFqIQIMAAALAAsLQQECfyAAIAAoArjgASIDNgLE4AEgACgCvOABIQQgACABNgK84AEgACABIAJqNgK44AEgACABIAQgA2tqNgLA4AELpgEBAX8gACAAKALs4QEQFjYCyOABIABCADcD+OABIABCADcDuOABIABBwOABakIANwMAIABBqNAAaiIBQYyAgOAANgIAIABBADYCmOIBIABCADcDiOEBIABCAzcDgOEBIABBrNABakHgEikCADcCACAAQbTQAWpB6BIoAgA2AgAgACABNgIMIAAgAEGYIGo2AgggACAAQaAwajYCBCAAIABBEGo2AgALYQEBf0G4fyEDAkAgAUEDSQ0AIAIgABAhIgFBA3YiADYCCCACIAFBAXE2AgQgAiABQQF2QQNxIgM2AgACQCADQX9qIgFBAksNAAJAIAFBAWsOAgEAAgtBbA8LIAAhAwsgAwsMACAAIAEgAkEAEC4LiAQCA38CfiADEBYhBCAAQQBBKBAQIQAgBCACSwRAIAQPCyABRQRAQX8PCwJAAkAgA0EBRg0AIAEoAAAiBkGo6r5pRg0AQXYhAyAGQXBxQdDUtMIBRw0BQQghAyACQQhJDQEgAEEAQSgQECEAIAEoAAQhASAAQQE2AhQgACABrTcDAEEADwsgASACIAMQLyIDIAJLDQAgACADNgIYQXIhAyABIARqIgVBf2otAAAiAkEIcQ0AIAJBIHEiBkUEQEFwIQMgBS0AACIFQacBSw0BIAVBB3GtQgEgBUEDdkEKaq2GIgdCA4h+IAd8IQggBEEBaiEECyACQQZ2IQMgAkECdiEFAkAgAkEDcUF/aiICQQJLBEBBACECDAELAkACQAJAIAJBAWsOAgECAAsgASAEai0AACECIARBAWohBAwCCyABIARqLwAAIQIgBEECaiEEDAELIAEgBGooAAAhAiAEQQRqIQQLIAVBAXEhBQJ+AkACQAJAIANBf2oiA0ECTQRAIANBAWsOAgIDAQtCfyAGRQ0DGiABIARqMQAADAMLIAEgBGovAACtQoACfAwCCyABIARqKAAArQwBCyABIARqKQAACyEHIAAgBTYCICAAIAI2AhwgACAHNwMAQQAhAyAAQQA2AhQgACAHIAggBhsiBzcDCCAAIAdCgIAIIAdCgIAIVBs+AhALIAMLWwEBf0G4fyEDIAIQFiICIAFNBH8gACACakF/ai0AACIAQQNxQQJ0QaAeaigCACACaiAAQQZ2IgFBAnRBsB5qKAIAaiAAQSBxIgBFaiABRSAAQQV2cWoFQbh/CwsdACAAKAKQ4gEQWiAAQQA2AqDiASAAQgA3A5DiAQu1AwEFfyMAQZACayIKJABBuH8hBgJAIAVFDQAgBCwAACIIQf8BcSEHAkAgCEF/TARAIAdBgn9qQQF2IgggBU8NAkFsIQYgB0GBf2oiBUGAAk8NAiAEQQFqIQdBACEGA0AgBiAFTwRAIAUhBiAIIQcMAwUgACAGaiAHIAZBAXZqIgQtAABBBHY6AAAgACAGQQFyaiAELQAAQQ9xOgAAIAZBAmohBgwBCwAACwALIAcgBU8NASAAIARBAWogByAKEFMiBhADDQELIAYhBEEAIQYgAUEAQTQQECEJQQAhBQNAIAQgBkcEQCAAIAZqIggtAAAiAUELSwRAQWwhBgwDBSAJIAFBAnRqIgEgASgCAEEBajYCACAGQQFqIQZBASAILQAAdEEBdSAFaiEFDAILAAsLQWwhBiAFRQ0AIAUQFEEBaiIBQQxLDQAgAyABNgIAQQFBASABdCAFayIDEBQiAXQgA0cNACAAIARqIAFBAWoiADoAACAJIABBAnRqIgAgACgCAEEBajYCACAJKAIEIgBBAkkgAEEBcXINACACIARBAWo2AgAgB0EBaiEGCyAKQZACaiQAIAYLxhEBDH8jAEHwAGsiBSQAQWwhCwJAIANBCkkNACACLwAAIQogAi8AAiEJIAIvAAQhByAFQQhqIAQQDgJAIAMgByAJIApqakEGaiIMSQ0AIAUtAAohCCAFQdgAaiACQQZqIgIgChAGIgsQAw0BIAVBQGsgAiAKaiICIAkQBiILEAMNASAFQShqIAIgCWoiAiAHEAYiCxADDQEgBUEQaiACIAdqIAMgDGsQBiILEAMNASAAIAFqIg9BfWohECAEQQRqIQZBASELIAAgAUEDakECdiIDaiIMIANqIgIgA2oiDiEDIAIhBCAMIQcDQCALIAMgEElxBEAgACAGIAVB2ABqIAgQAkECdGoiCS8BADsAACAFQdgAaiAJLQACEAEgCS0AAyELIAcgBiAFQUBrIAgQAkECdGoiCS8BADsAACAFQUBrIAktAAIQASAJLQADIQogBCAGIAVBKGogCBACQQJ0aiIJLwEAOwAAIAVBKGogCS0AAhABIAktAAMhCSADIAYgBUEQaiAIEAJBAnRqIg0vAQA7AAAgBUEQaiANLQACEAEgDS0AAyENIAAgC2oiCyAGIAVB2ABqIAgQAkECdGoiAC8BADsAACAFQdgAaiAALQACEAEgAC0AAyEAIAcgCmoiCiAGIAVBQGsgCBACQQJ0aiIHLwEAOwAAIAVBQGsgBy0AAhABIActAAMhByAEIAlqIgkgBiAFQShqIAgQAkECdGoiBC8BADsAACAFQShqIAQtAAIQASAELQADIQQgAyANaiIDIAYgBUEQaiAIEAJBAnRqIg0vAQA7AAAgBUEQaiANLQACEAEgACALaiEAIAcgCmohByAEIAlqIQQgAyANLQADaiEDIAVB2ABqEA0gBUFAaxANciAFQShqEA1yIAVBEGoQDXJFIQsMAQsLIAQgDksgByACS3INAEFsIQsgACAMSw0BIAxBfWohCQNAQQAgACAJSSAFQdgAahAEGwRAIAAgBiAFQdgAaiAIEAJBAnRqIgovAQA7AAAgBUHYAGogCi0AAhABIAAgCi0AA2oiACAGIAVB2ABqIAgQAkECdGoiCi8BADsAACAFQdgAaiAKLQACEAEgACAKLQADaiEADAEFIAxBfmohCgNAIAVB2ABqEAQgACAKS3JFBEAgACAGIAVB2ABqIAgQAkECdGoiCS8BADsAACAFQdgAaiAJLQACEAEgACAJLQADaiEADAELCwNAIAAgCk0EQCAAIAYgBUHYAGogCBACQQJ0aiIJLwEAOwAAIAVB2ABqIAktAAIQASAAIAktAANqIQAMAQsLAkAgACAMTw0AIAAgBiAFQdgAaiAIEAIiAEECdGoiDC0AADoAACAMLQADQQFGBEAgBUHYAGogDC0AAhABDAELIAUoAlxBH0sNACAFQdgAaiAGIABBAnRqLQACEAEgBSgCXEEhSQ0AIAVBIDYCXAsgAkF9aiEMA0BBACAHIAxJIAVBQGsQBBsEQCAHIAYgBUFAayAIEAJBAnRqIgAvAQA7AAAgBUFAayAALQACEAEgByAALQADaiIAIAYgBUFAayAIEAJBAnRqIgcvAQA7AAAgBUFAayAHLQACEAEgACAHLQADaiEHDAEFIAJBfmohDANAIAVBQGsQBCAHIAxLckUEQCAHIAYgBUFAayAIEAJBAnRqIgAvAQA7AAAgBUFAayAALQACEAEgByAALQADaiEHDAELCwNAIAcgDE0EQCAHIAYgBUFAayAIEAJBAnRqIgAvAQA7AAAgBUFAayAALQACEAEgByAALQADaiEHDAELCwJAIAcgAk8NACAHIAYgBUFAayAIEAIiAEECdGoiAi0AADoAACACLQADQQFGBEAgBUFAayACLQACEAEMAQsgBSgCREEfSw0AIAVBQGsgBiAAQQJ0ai0AAhABIAUoAkRBIUkNACAFQSA2AkQLIA5BfWohAgNAQQAgBCACSSAFQShqEAQbBEAgBCAGIAVBKGogCBACQQJ0aiIALwEAOwAAIAVBKGogAC0AAhABIAQgAC0AA2oiACAGIAVBKGogCBACQQJ0aiIELwEAOwAAIAVBKGogBC0AAhABIAAgBC0AA2ohBAwBBSAOQX5qIQIDQCAFQShqEAQgBCACS3JFBEAgBCAGIAVBKGogCBACQQJ0aiIALwEAOwAAIAVBKGogAC0AAhABIAQgAC0AA2ohBAwBCwsDQCAEIAJNBEAgBCAGIAVBKGogCBACQQJ0aiIALwEAOwAAIAVBKGogAC0AAhABIAQgAC0AA2ohBAwBCwsCQCAEIA5PDQAgBCAGIAVBKGogCBACIgBBAnRqIgItAAA6AAAgAi0AA0EBRgRAIAVBKGogAi0AAhABDAELIAUoAixBH0sNACAFQShqIAYgAEECdGotAAIQASAFKAIsQSFJDQAgBUEgNgIsCwNAQQAgAyAQSSAFQRBqEAQbBEAgAyAGIAVBEGogCBACQQJ0aiIALwEAOwAAIAVBEGogAC0AAhABIAMgAC0AA2oiACAGIAVBEGogCBACQQJ0aiICLwEAOwAAIAVBEGogAi0AAhABIAAgAi0AA2ohAwwBBSAPQX5qIQIDQCAFQRBqEAQgAyACS3JFBEAgAyAGIAVBEGogCBACQQJ0aiIALwEAOwAAIAVBEGogAC0AAhABIAMgAC0AA2ohAwwBCwsDQCADIAJNBEAgAyAGIAVBEGogCBACQQJ0aiIALwEAOwAAIAVBEGogAC0AAhABIAMgAC0AA2ohAwwBCwsCQCADIA9PDQAgAyAGIAVBEGogCBACIgBBAnRqIgItAAA6AAAgAi0AA0EBRgRAIAVBEGogAi0AAhABDAELIAUoAhRBH0sNACAFQRBqIAYgAEECdGotAAIQASAFKAIUQSFJDQAgBUEgNgIUCyABQWwgBUHYAGoQCiAFQUBrEApxIAVBKGoQCnEgBUEQahAKcRshCwwJCwAACwALAAALAAsAAAsACwAACwALQWwhCwsgBUHwAGokACALC7UEAQ5/IwBBEGsiBiQAIAZBBGogABAOQVQhBQJAIARB3AtJDQAgBi0ABCEHIANB8ARqQQBB7AAQECEIIAdBDEsNACADQdwJaiIJIAggBkEIaiAGQQxqIAEgAhAxIhAQA0UEQCAGKAIMIgQgB0sNASADQdwFaiEPIANBpAVqIREgAEEEaiESIANBqAVqIQEgBCEFA0AgBSICQX9qIQUgCCACQQJ0aigCAEUNAAsgAkEBaiEOQQEhBQNAIAUgDk9FBEAgCCAFQQJ0IgtqKAIAIQwgASALaiAKNgIAIAVBAWohBSAKIAxqIQoMAQsLIAEgCjYCAEEAIQUgBigCCCELA0AgBSALRkUEQCABIAUgCWotAAAiDEECdGoiDSANKAIAIg1BAWo2AgAgDyANQQF0aiINIAw6AAEgDSAFOgAAIAVBAWohBQwBCwtBACEBIANBADYCqAUgBEF/cyAHaiEJQQEhBQNAIAUgDk9FBEAgCCAFQQJ0IgtqKAIAIQwgAyALaiABNgIAIAwgBSAJanQgAWohASAFQQFqIQUMAQsLIAcgBEEBaiIBIAJrIgRrQQFqIQgDQEEBIQUgBCAIT0UEQANAIAUgDk9FBEAgBUECdCIJIAMgBEE0bGpqIAMgCWooAgAgBHY2AgAgBUEBaiEFDAELCyAEQQFqIQQMAQsLIBIgByAPIAogESADIAIgARBkIAZBAToABSAGIAc6AAYgACAGKAIENgIACyAQIQULIAZBEGokACAFC8ENAQt/IwBB8ABrIgUkAEFsIQkCQCADQQpJDQAgAi8AACEKIAIvAAIhDCACLwAEIQYgBUEIaiAEEA4CQCADIAYgCiAMampBBmoiDUkNACAFLQAKIQcgBUHYAGogAkEGaiICIAoQBiIJEAMNASAFQUBrIAIgCmoiAiAMEAYiCRADDQEgBUEoaiACIAxqIgIgBhAGIgkQAw0BIAVBEGogAiAGaiADIA1rEAYiCRADDQEgACABaiIOQX1qIQ8gBEEEaiEGQQEhCSAAIAFBA2pBAnYiAmoiCiACaiIMIAJqIg0hAyAMIQQgCiECA0AgCSADIA9JcQRAIAYgBUHYAGogBxACQQF0aiIILQAAIQsgBUHYAGogCC0AARABIAAgCzoAACAGIAVBQGsgBxACQQF0aiIILQAAIQsgBUFAayAILQABEAEgAiALOgAAIAYgBUEoaiAHEAJBAXRqIggtAAAhCyAFQShqIAgtAAEQASAEIAs6AAAgBiAFQRBqIAcQAkEBdGoiCC0AACELIAVBEGogCC0AARABIAMgCzoAACAGIAVB2ABqIAcQAkEBdGoiCC0AACELIAVB2ABqIAgtAAEQASAAIAs6AAEgBiAFQUBrIAcQAkEBdGoiCC0AACELIAVBQGsgCC0AARABIAIgCzoAASAGIAVBKGogBxACQQF0aiIILQAAIQsgBUEoaiAILQABEAEgBCALOgABIAYgBUEQaiAHEAJBAXRqIggtAAAhCyAFQRBqIAgtAAEQASADIAs6AAEgA0ECaiEDIARBAmohBCACQQJqIQIgAEECaiEAIAkgBUHYAGoQDUVxIAVBQGsQDUVxIAVBKGoQDUVxIAVBEGoQDUVxIQkMAQsLIAQgDUsgAiAMS3INAEFsIQkgACAKSw0BIApBfWohCQNAIAVB2ABqEAQgACAJT3JFBEAgBiAFQdgAaiAHEAJBAXRqIggtAAAhCyAFQdgAaiAILQABEAEgACALOgAAIAYgBUHYAGogBxACQQF0aiIILQAAIQsgBUHYAGogCC0AARABIAAgCzoAASAAQQJqIQAMAQsLA0AgBUHYAGoQBCAAIApPckUEQCAGIAVB2ABqIAcQAkEBdGoiCS0AACEIIAVB2ABqIAktAAEQASAAIAg6AAAgAEEBaiEADAELCwNAIAAgCkkEQCAGIAVB2ABqIAcQAkEBdGoiCS0AACEIIAVB2ABqIAktAAEQASAAIAg6AAAgAEEBaiEADAELCyAMQX1qIQADQCAFQUBrEAQgAiAAT3JFBEAgBiAFQUBrIAcQAkEBdGoiCi0AACEJIAVBQGsgCi0AARABIAIgCToAACAGIAVBQGsgBxACQQF0aiIKLQAAIQkgBUFAayAKLQABEAEgAiAJOgABIAJBAmohAgwBCwsDQCAFQUBrEAQgAiAMT3JFBEAgBiAFQUBrIAcQAkEBdGoiAC0AACEKIAVBQGsgAC0AARABIAIgCjoAACACQQFqIQIMAQsLA0AgAiAMSQRAIAYgBUFAayAHEAJBAXRqIgAtAAAhCiAFQUBrIAAtAAEQASACIAo6AAAgAkEBaiECDAELCyANQX1qIQADQCAFQShqEAQgBCAAT3JFBEAgBiAFQShqIAcQAkEBdGoiAi0AACEKIAVBKGogAi0AARABIAQgCjoAACAGIAVBKGogBxACQQF0aiICLQAAIQogBUEoaiACLQABEAEgBCAKOgABIARBAmohBAwBCwsDQCAFQShqEAQgBCANT3JFBEAgBiAFQShqIAcQAkEBdGoiAC0AACECIAVBKGogAC0AARABIAQgAjoAACAEQQFqIQQMAQsLA0AgBCANSQRAIAYgBUEoaiAHEAJBAXRqIgAtAAAhAiAFQShqIAAtAAEQASAEIAI6AAAgBEEBaiEEDAELCwNAIAVBEGoQBCADIA9PckUEQCAGIAVBEGogBxACQQF0aiIALQAAIQIgBUEQaiAALQABEAEgAyACOgAAIAYgBUEQaiAHEAJBAXRqIgAtAAAhAiAFQRBqIAAtAAEQASADIAI6AAEgA0ECaiEDDAELCwNAIAVBEGoQBCADIA5PckUEQCAGIAVBEGogBxACQQF0aiIALQAAIQIgBUEQaiAALQABEAEgAyACOgAAIANBAWohAwwBCwsDQCADIA5JBEAgBiAFQRBqIAcQAkEBdGoiAC0AACECIAVBEGogAC0AARABIAMgAjoAACADQQFqIQMMAQsLIAFBbCAFQdgAahAKIAVBQGsQCnEgBUEoahAKcSAFQRBqEApxGyEJDAELQWwhCQsgBUHwAGokACAJC8oCAQR/IwBBIGsiBSQAIAUgBBAOIAUtAAIhByAFQQhqIAIgAxAGIgIQA0UEQCAEQQRqIQIgACABaiIDQX1qIQQDQCAFQQhqEAQgACAET3JFBEAgAiAFQQhqIAcQAkEBdGoiBi0AACEIIAVBCGogBi0AARABIAAgCDoAACACIAVBCGogBxACQQF0aiIGLQAAIQggBUEIaiAGLQABEAEgACAIOgABIABBAmohAAwBCwsDQCAFQQhqEAQgACADT3JFBEAgAiAFQQhqIAcQAkEBdGoiBC0AACEGIAVBCGogBC0AARABIAAgBjoAACAAQQFqIQAMAQsLA0AgACADT0UEQCACIAVBCGogBxACQQF0aiIELQAAIQYgBUEIaiAELQABEAEgACAGOgAAIABBAWohAAwBCwsgAUFsIAVBCGoQChshAgsgBUEgaiQAIAILtgMBCX8jAEEQayIGJAAgBkEANgIMIAZBADYCCEFUIQQCQAJAIANBQGsiDCADIAZBCGogBkEMaiABIAIQMSICEAMNACAGQQRqIAAQDiAGKAIMIgcgBi0ABEEBaksNASAAQQRqIQogBkEAOgAFIAYgBzoABiAAIAYoAgQ2AgAgB0EBaiEJQQEhBANAIAQgCUkEQCADIARBAnRqIgEoAgAhACABIAU2AgAgACAEQX9qdCAFaiEFIARBAWohBAwBCwsgB0EBaiEHQQAhBSAGKAIIIQkDQCAFIAlGDQEgAyAFIAxqLQAAIgRBAnRqIgBBASAEdEEBdSILIAAoAgAiAWoiADYCACAHIARrIQhBACEEAkAgC0EDTQRAA0AgBCALRg0CIAogASAEakEBdGoiACAIOgABIAAgBToAACAEQQFqIQQMAAALAAsDQCABIABPDQEgCiABQQF0aiIEIAg6AAEgBCAFOgAAIAQgCDoAAyAEIAU6AAIgBCAIOgAFIAQgBToABCAEIAg6AAcgBCAFOgAGIAFBBGohAQwAAAsACyAFQQFqIQUMAAALAAsgAiEECyAGQRBqJAAgBAutAQECfwJAQYQgKAIAIABHIAAoAgBBAXYiAyABa0F4aiICQXhxQQhHcgR/IAIFIAMQJ0UNASACQQhqC0EQSQ0AIAAgACgCACICQQFxIAAgAWpBD2pBeHEiASAAa0EBdHI2AgAgASAANgIEIAEgASgCAEEBcSAAIAJBAXZqIAFrIgJBAXRyNgIAQYQgIAEgAkH/////B3FqQQRqQYQgKAIAIABGGyABNgIAIAEQJQsLygIBBX8CQAJAAkAgAEEIIABBCEsbZ0EfcyAAaUEBR2oiAUEESSAAIAF2cg0AIAFBAnRB/B5qKAIAIgJFDQADQCACQXhqIgMoAgBBAXZBeGoiBSAATwRAIAIgBUEIIAVBCEsbZ0Efc0ECdEGAH2oiASgCAEYEQCABIAIoAgQ2AgALDAMLIARBHksNASAEQQFqIQQgAigCBCICDQALC0EAIQMgAUEgTw0BA0AgAUECdEGAH2ooAgAiAkUEQCABQR5LIQIgAUEBaiEBIAJFDQEMAwsLIAIgAkF4aiIDKAIAQQF2QXhqIgFBCCABQQhLG2dBH3NBAnRBgB9qIgEoAgBGBEAgASACKAIENgIACwsgAigCACIBBEAgASACKAIENgIECyACKAIEIgEEQCABIAIoAgA2AgALIAMgAygCAEEBcjYCACADIAAQNwsgAwvhCwINfwV+IwBB8ABrIgckACAHIAAoAvDhASIINgJcIAEgAmohDSAIIAAoAoDiAWohDwJAAkAgBUUEQCABIQQMAQsgACgCxOABIRAgACgCwOABIREgACgCvOABIQ4gAEEBNgKM4QFBACEIA0AgCEEDRwRAIAcgCEECdCICaiAAIAJqQazQAWooAgA2AkQgCEEBaiEIDAELC0FsIQwgB0EYaiADIAQQBhADDQEgB0EsaiAHQRhqIAAoAgAQEyAHQTRqIAdBGGogACgCCBATIAdBPGogB0EYaiAAKAIEEBMgDUFgaiESIAEhBEEAIQwDQCAHKAIwIAcoAixBA3RqKQIAIhRCEIinQf8BcSEIIAcoAkAgBygCPEEDdGopAgAiFUIQiKdB/wFxIQsgBygCOCAHKAI0QQN0aikCACIWQiCIpyEJIBVCIIghFyAUQiCIpyECAkAgFkIQiKdB/wFxIgNBAk8EQAJAIAZFIANBGUlyRQRAIAkgB0EYaiADQSAgBygCHGsiCiAKIANLGyIKEAUgAyAKayIDdGohCSAHQRhqEAQaIANFDQEgB0EYaiADEAUgCWohCQwBCyAHQRhqIAMQBSAJaiEJIAdBGGoQBBoLIAcpAkQhGCAHIAk2AkQgByAYNwNIDAELAkAgA0UEQCACBEAgBygCRCEJDAMLIAcoAkghCQwBCwJAAkAgB0EYakEBEAUgCSACRWpqIgNBA0YEQCAHKAJEQX9qIgMgA0VqIQkMAQsgA0ECdCAHaigCRCIJIAlFaiEJIANBAUYNAQsgByAHKAJINgJMCwsgByAHKAJENgJIIAcgCTYCRAsgF6chAyALBEAgB0EYaiALEAUgA2ohAwsgCCALakEUTwRAIAdBGGoQBBoLIAgEQCAHQRhqIAgQBSACaiECCyAHQRhqEAQaIAcgB0EYaiAUQhiIp0H/AXEQCCAUp0H//wNxajYCLCAHIAdBGGogFUIYiKdB/wFxEAggFadB//8DcWo2AjwgB0EYahAEGiAHIAdBGGogFkIYiKdB/wFxEAggFqdB//8DcWo2AjQgByACNgJgIAcoAlwhCiAHIAk2AmggByADNgJkAkACQAJAIAQgAiADaiILaiASSw0AIAIgCmoiEyAPSw0AIA0gBGsgC0Egak8NAQsgByAHKQNoNwMQIAcgBykDYDcDCCAEIA0gB0EIaiAHQdwAaiAPIA4gESAQEB4hCwwBCyACIARqIQggBCAKEAcgAkERTwRAIARBEGohAgNAIAIgCkEQaiIKEAcgAkEQaiICIAhJDQALCyAIIAlrIQIgByATNgJcIAkgCCAOa0sEQCAJIAggEWtLBEBBbCELDAILIBAgAiAOayICaiIKIANqIBBNBEAgCCAKIAMQDxoMAgsgCCAKQQAgAmsQDyEIIAcgAiADaiIDNgJkIAggAmshCCAOIQILIAlBEE8EQCADIAhqIQMDQCAIIAIQByACQRBqIQIgCEEQaiIIIANJDQALDAELAkAgCUEHTQRAIAggAi0AADoAACAIIAItAAE6AAEgCCACLQACOgACIAggAi0AAzoAAyAIQQRqIAIgCUECdCIDQcAeaigCAGoiAhAXIAIgA0HgHmooAgBrIQIgBygCZCEDDAELIAggAhAMCyADQQlJDQAgAyAIaiEDIAhBCGoiCCACQQhqIgJrQQ9MBEADQCAIIAIQDCACQQhqIQIgCEEIaiIIIANJDQAMAgALAAsDQCAIIAIQByACQRBqIQIgCEEQaiIIIANJDQALCyAHQRhqEAQaIAsgDCALEAMiAhshDCAEIAQgC2ogAhshBCAFQX9qIgUNAAsgDBADDQFBbCEMIAdBGGoQBEECSQ0BQQAhCANAIAhBA0cEQCAAIAhBAnQiAmpBrNABaiACIAdqKAJENgIAIAhBAWohCAwBCwsgBygCXCEIC0G6fyEMIA8gCGsiACANIARrSw0AIAQEfyAEIAggABALIABqBUEACyABayEMCyAHQfAAaiQAIAwLkRcCFn8FfiMAQdABayIHJAAgByAAKALw4QEiCDYCvAEgASACaiESIAggACgCgOIBaiETAkACQCAFRQRAIAEhAwwBCyAAKALE4AEhESAAKALA4AEhFSAAKAK84AEhDyAAQQE2AozhAUEAIQgDQCAIQQNHBEAgByAIQQJ0IgJqIAAgAmpBrNABaigCADYCVCAIQQFqIQgMAQsLIAcgETYCZCAHIA82AmAgByABIA9rNgJoQWwhECAHQShqIAMgBBAGEAMNASAFQQQgBUEESBshFyAHQTxqIAdBKGogACgCABATIAdBxABqIAdBKGogACgCCBATIAdBzABqIAdBKGogACgCBBATQQAhBCAHQeAAaiEMIAdB5ABqIQoDQCAHQShqEARBAksgBCAXTnJFBEAgBygCQCAHKAI8QQN0aikCACIdQhCIp0H/AXEhCyAHKAJQIAcoAkxBA3RqKQIAIh5CEIinQf8BcSEJIAcoAkggBygCREEDdGopAgAiH0IgiKchCCAeQiCIISAgHUIgiKchAgJAIB9CEIinQf8BcSIDQQJPBEACQCAGRSADQRlJckUEQCAIIAdBKGogA0EgIAcoAixrIg0gDSADSxsiDRAFIAMgDWsiA3RqIQggB0EoahAEGiADRQ0BIAdBKGogAxAFIAhqIQgMAQsgB0EoaiADEAUgCGohCCAHQShqEAQaCyAHKQJUISEgByAINgJUIAcgITcDWAwBCwJAIANFBEAgAgRAIAcoAlQhCAwDCyAHKAJYIQgMAQsCQAJAIAdBKGpBARAFIAggAkVqaiIDQQNGBEAgBygCVEF/aiIDIANFaiEIDAELIANBAnQgB2ooAlQiCCAIRWohCCADQQFGDQELIAcgBygCWDYCXAsLIAcgBygCVDYCWCAHIAg2AlQLICCnIQMgCQRAIAdBKGogCRAFIANqIQMLIAkgC2pBFE8EQCAHQShqEAQaCyALBEAgB0EoaiALEAUgAmohAgsgB0EoahAEGiAHIAcoAmggAmoiCSADajYCaCAKIAwgCCAJSxsoAgAhDSAHIAdBKGogHUIYiKdB/wFxEAggHadB//8DcWo2AjwgByAHQShqIB5CGIinQf8BcRAIIB6nQf//A3FqNgJMIAdBKGoQBBogB0EoaiAfQhiIp0H/AXEQCCEOIAdB8ABqIARBBHRqIgsgCSANaiAIazYCDCALIAg2AgggCyADNgIEIAsgAjYCACAHIA4gH6dB//8DcWo2AkQgBEEBaiEEDAELCyAEIBdIDQEgEkFgaiEYIAdB4ABqIRogB0HkAGohGyABIQMDQCAHQShqEARBAksgBCAFTnJFBEAgBygCQCAHKAI8QQN0aikCACIdQhCIp0H/AXEhCyAHKAJQIAcoAkxBA3RqKQIAIh5CEIinQf8BcSEIIAcoAkggBygCREEDdGopAgAiH0IgiKchCSAeQiCIISAgHUIgiKchDAJAIB9CEIinQf8BcSICQQJPBEACQCAGRSACQRlJckUEQCAJIAdBKGogAkEgIAcoAixrIgogCiACSxsiChAFIAIgCmsiAnRqIQkgB0EoahAEGiACRQ0BIAdBKGogAhAFIAlqIQkMAQsgB0EoaiACEAUgCWohCSAHQShqEAQaCyAHKQJUISEgByAJNgJUIAcgITcDWAwBCwJAIAJFBEAgDARAIAcoAlQhCQwDCyAHKAJYIQkMAQsCQAJAIAdBKGpBARAFIAkgDEVqaiICQQNGBEAgBygCVEF/aiICIAJFaiEJDAELIAJBAnQgB2ooAlQiCSAJRWohCSACQQFGDQELIAcgBygCWDYCXAsLIAcgBygCVDYCWCAHIAk2AlQLICCnIRQgCARAIAdBKGogCBAFIBRqIRQLIAggC2pBFE8EQCAHQShqEAQaCyALBEAgB0EoaiALEAUgDGohDAsgB0EoahAEGiAHIAcoAmggDGoiGSAUajYCaCAbIBogCSAZSxsoAgAhHCAHIAdBKGogHUIYiKdB/wFxEAggHadB//8DcWo2AjwgByAHQShqIB5CGIinQf8BcRAIIB6nQf//A3FqNgJMIAdBKGoQBBogByAHQShqIB9CGIinQf8BcRAIIB+nQf//A3FqNgJEIAcgB0HwAGogBEEDcUEEdGoiDSkDCCIdNwPIASAHIA0pAwAiHjcDwAECQAJAAkAgBygCvAEiDiAepyICaiIWIBNLDQAgAyAHKALEASIKIAJqIgtqIBhLDQAgEiADayALQSBqTw0BCyAHIAcpA8gBNwMQIAcgBykDwAE3AwggAyASIAdBCGogB0G8AWogEyAPIBUgERAeIQsMAQsgAiADaiEIIAMgDhAHIAJBEU8EQCADQRBqIQIDQCACIA5BEGoiDhAHIAJBEGoiAiAISQ0ACwsgCCAdpyIOayECIAcgFjYCvAEgDiAIIA9rSwRAIA4gCCAVa0sEQEFsIQsMAgsgESACIA9rIgJqIhYgCmogEU0EQCAIIBYgChAPGgwCCyAIIBZBACACaxAPIQggByACIApqIgo2AsQBIAggAmshCCAPIQILIA5BEE8EQCAIIApqIQoDQCAIIAIQByACQRBqIQIgCEEQaiIIIApJDQALDAELAkAgDkEHTQRAIAggAi0AADoAACAIIAItAAE6AAEgCCACLQACOgACIAggAi0AAzoAAyAIQQRqIAIgDkECdCIKQcAeaigCAGoiAhAXIAIgCkHgHmooAgBrIQIgBygCxAEhCgwBCyAIIAIQDAsgCkEJSQ0AIAggCmohCiAIQQhqIgggAkEIaiICa0EPTARAA0AgCCACEAwgAkEIaiECIAhBCGoiCCAKSQ0ADAIACwALA0AgCCACEAcgAkEQaiECIAhBEGoiCCAKSQ0ACwsgCxADBEAgCyEQDAQFIA0gDDYCACANIBkgHGogCWs2AgwgDSAJNgIIIA0gFDYCBCAEQQFqIQQgAyALaiEDDAILAAsLIAQgBUgNASAEIBdrIQtBACEEA0AgCyAFSARAIAcgB0HwAGogC0EDcUEEdGoiAikDCCIdNwPIASAHIAIpAwAiHjcDwAECQAJAAkAgBygCvAEiDCAepyICaiIKIBNLDQAgAyAHKALEASIJIAJqIhBqIBhLDQAgEiADayAQQSBqTw0BCyAHIAcpA8gBNwMgIAcgBykDwAE3AxggAyASIAdBGGogB0G8AWogEyAPIBUgERAeIRAMAQsgAiADaiEIIAMgDBAHIAJBEU8EQCADQRBqIQIDQCACIAxBEGoiDBAHIAJBEGoiAiAISQ0ACwsgCCAdpyIGayECIAcgCjYCvAEgBiAIIA9rSwRAIAYgCCAVa0sEQEFsIRAMAgsgESACIA9rIgJqIgwgCWogEU0EQCAIIAwgCRAPGgwCCyAIIAxBACACaxAPIQggByACIAlqIgk2AsQBIAggAmshCCAPIQILIAZBEE8EQCAIIAlqIQYDQCAIIAIQByACQRBqIQIgCEEQaiIIIAZJDQALDAELAkAgBkEHTQRAIAggAi0AADoAACAIIAItAAE6AAEgCCACLQACOgACIAggAi0AAzoAAyAIQQRqIAIgBkECdCIGQcAeaigCAGoiAhAXIAIgBkHgHmooAgBrIQIgBygCxAEhCQwBCyAIIAIQDAsgCUEJSQ0AIAggCWohBiAIQQhqIgggAkEIaiICa0EPTARAA0AgCCACEAwgAkEIaiECIAhBCGoiCCAGSQ0ADAIACwALA0AgCCACEAcgAkEQaiECIAhBEGoiCCAGSQ0ACwsgEBADDQMgC0EBaiELIAMgEGohAwwBCwsDQCAEQQNHBEAgACAEQQJ0IgJqQazQAWogAiAHaigCVDYCACAEQQFqIQQMAQsLIAcoArwBIQgLQbp/IRAgEyAIayIAIBIgA2tLDQAgAwR/IAMgCCAAEAsgAGoFQQALIAFrIRALIAdB0AFqJAAgEAslACAAQgA3AgAgAEEAOwEIIABBADoACyAAIAE2AgwgACACOgAKC7QFAQN/IwBBMGsiBCQAIABB/wFqIgVBfWohBgJAIAMvAQIEQCAEQRhqIAEgAhAGIgIQAw0BIARBEGogBEEYaiADEBwgBEEIaiAEQRhqIAMQHCAAIQMDQAJAIARBGGoQBCADIAZPckUEQCADIARBEGogBEEYahASOgAAIAMgBEEIaiAEQRhqEBI6AAEgBEEYahAERQ0BIANBAmohAwsgBUF+aiEFAn8DQEG6fyECIAMiASAFSw0FIAEgBEEQaiAEQRhqEBI6AAAgAUEBaiEDIARBGGoQBEEDRgRAQQIhAiAEQQhqDAILIAMgBUsNBSABIARBCGogBEEYahASOgABIAFBAmohA0EDIQIgBEEYahAEQQNHDQALIARBEGoLIQUgAyAFIARBGGoQEjoAACABIAJqIABrIQIMAwsgAyAEQRBqIARBGGoQEjoAAiADIARBCGogBEEYahASOgADIANBBGohAwwAAAsACyAEQRhqIAEgAhAGIgIQAw0AIARBEGogBEEYaiADEBwgBEEIaiAEQRhqIAMQHCAAIQMDQAJAIARBGGoQBCADIAZPckUEQCADIARBEGogBEEYahAROgAAIAMgBEEIaiAEQRhqEBE6AAEgBEEYahAERQ0BIANBAmohAwsgBUF+aiEFAn8DQEG6fyECIAMiASAFSw0EIAEgBEEQaiAEQRhqEBE6AAAgAUEBaiEDIARBGGoQBEEDRgRAQQIhAiAEQQhqDAILIAMgBUsNBCABIARBCGogBEEYahAROgABIAFBAmohA0EDIQIgBEEYahAEQQNHDQALIARBEGoLIQUgAyAFIARBGGoQEToAACABIAJqIABrIQIMAgsgAyAEQRBqIARBGGoQEToAAiADIARBCGogBEEYahAROgADIANBBGohAwwAAAsACyAEQTBqJAAgAgtpAQF/An8CQAJAIAJBB00NACABKAAAQbfIwuF+Rw0AIAAgASgABDYCmOIBQWIgAEEQaiABIAIQPiIDEAMNAhogAEKBgICAEDcDiOEBIAAgASADaiACIANrECoMAQsgACABIAIQKgtBAAsLrQMBBn8jAEGAAWsiAyQAQWIhCAJAIAJBCUkNACAAQZjQAGogAUEIaiIEIAJBeGogAEGY0AAQMyIFEAMiBg0AIANBHzYCfCADIANB/ABqIANB+ABqIAQgBCAFaiAGGyIEIAEgAmoiAiAEaxAVIgUQAw0AIAMoAnwiBkEfSw0AIAMoAngiB0EJTw0AIABBiCBqIAMgBkGAC0GADCAHEBggA0E0NgJ8IAMgA0H8AGogA0H4AGogBCAFaiIEIAIgBGsQFSIFEAMNACADKAJ8IgZBNEsNACADKAJ4IgdBCk8NACAAQZAwaiADIAZBgA1B4A4gBxAYIANBIzYCfCADIANB/ABqIANB+ABqIAQgBWoiBCACIARrEBUiBRADDQAgAygCfCIGQSNLDQAgAygCeCIHQQpPDQAgACADIAZBwBBB0BEgBxAYIAQgBWoiBEEMaiIFIAJLDQAgAiAFayEFQQAhAgNAIAJBA0cEQCAEKAAAIgZBf2ogBU8NAiAAIAJBAnRqQZzQAWogBjYCACACQQFqIQIgBEEEaiEEDAELCyAEIAFrIQgLIANBgAFqJAAgCAtGAQN/IABBCGohAyAAKAIEIQJBACEAA0AgACACdkUEQCABIAMgAEEDdGotAAJBFktqIQEgAEEBaiEADAELCyABQQggAmt0C4YDAQV/Qbh/IQcCQCADRQ0AIAItAAAiBEUEQCABQQA2AgBBAUG4fyADQQFGGw8LAn8gAkEBaiIFIARBGHRBGHUiBkF/Sg0AGiAGQX9GBEAgA0EDSA0CIAUvAABBgP4BaiEEIAJBA2oMAQsgA0ECSA0BIAItAAEgBEEIdHJBgIB+aiEEIAJBAmoLIQUgASAENgIAIAVBAWoiASACIANqIgNLDQBBbCEHIABBEGogACAFLQAAIgVBBnZBI0EJIAEgAyABa0HAEEHQEUHwEiAAKAKM4QEgACgCnOIBIAQQHyIGEAMiCA0AIABBmCBqIABBCGogBUEEdkEDcUEfQQggASABIAZqIAgbIgEgAyABa0GAC0GADEGAFyAAKAKM4QEgACgCnOIBIAQQHyIGEAMiCA0AIABBoDBqIABBBGogBUECdkEDcUE0QQkgASABIAZqIAgbIgEgAyABa0GADUHgDkGQGSAAKAKM4QEgACgCnOIBIAQQHyIAEAMNACAAIAFqIAJrIQcLIAcLrQMBCn8jAEGABGsiCCQAAn9BUiACQf8BSw0AGkFUIANBDEsNABogAkEBaiELIABBBGohCUGAgAQgA0F/anRBEHUhCkEAIQJBASEEQQEgA3QiB0F/aiIMIQUDQCACIAtGRQRAAkAgASACQQF0Ig1qLwEAIgZB//8DRgRAIAkgBUECdGogAjoAAiAFQX9qIQVBASEGDAELIARBACAKIAZBEHRBEHVKGyEECyAIIA1qIAY7AQAgAkEBaiECDAELCyAAIAQ7AQIgACADOwEAIAdBA3YgB0EBdmpBA2ohBkEAIQRBACECA0AgBCALRkUEQCABIARBAXRqLgEAIQpBACEAA0AgACAKTkUEQCAJIAJBAnRqIAQ6AAIDQCACIAZqIAxxIgIgBUsNAAsgAEEBaiEADAELCyAEQQFqIQQMAQsLQX8gAg0AGkEAIQIDfyACIAdGBH9BAAUgCCAJIAJBAnRqIgAtAAJBAXRqIgEgAS8BACIBQQFqOwEAIAAgAyABEBRrIgU6AAMgACABIAVB/wFxdCAHazsBACACQQFqIQIMAQsLCyEFIAhBgARqJAAgBQvjBgEIf0FsIQcCQCACQQNJDQACQAJAAkACQCABLQAAIgNBA3EiCUEBaw4DAwEAAgsgACgCiOEBDQBBYg8LIAJBBUkNAkEDIQYgASgAACEFAn8CQAJAIANBAnZBA3EiCEF+aiIEQQFNBEAgBEEBaw0BDAILIAVBDnZB/wdxIQQgBUEEdkH/B3EhAyAIRQwCCyAFQRJ2IQRBBCEGIAVBBHZB//8AcSEDQQAMAQsgBUEEdkH//w9xIgNBgIAISw0DIAEtAARBCnQgBUEWdnIhBEEFIQZBAAshBSAEIAZqIgogAksNAgJAIANBgQZJDQAgACgCnOIBRQ0AQQAhAgNAIAJBg4ABSw0BIAJBQGshAgwAAAsACwJ/IAlBA0YEQCABIAZqIQEgAEHw4gFqIQIgACgCDCEGIAUEQCACIAMgASAEIAYQXwwCCyACIAMgASAEIAYQXQwBCyAAQbjQAWohAiABIAZqIQEgAEHw4gFqIQYgAEGo0ABqIQggBQRAIAggBiADIAEgBCACEF4MAQsgCCAGIAMgASAEIAIQXAsQAw0CIAAgAzYCgOIBIABBATYCiOEBIAAgAEHw4gFqNgLw4QEgCUECRgRAIAAgAEGo0ABqNgIMCyAAIANqIgBBiOMBakIANwAAIABBgOMBakIANwAAIABB+OIBakIANwAAIABB8OIBakIANwAAIAoPCwJ/AkACQAJAIANBAnZBA3FBf2oiBEECSw0AIARBAWsOAgACAQtBASEEIANBA3YMAgtBAiEEIAEvAABBBHYMAQtBAyEEIAEQIUEEdgsiAyAEaiIFQSBqIAJLBEAgBSACSw0CIABB8OIBaiABIARqIAMQCyEBIAAgAzYCgOIBIAAgATYC8OEBIAEgA2oiAEIANwAYIABCADcAECAAQgA3AAggAEIANwAAIAUPCyAAIAM2AoDiASAAIAEgBGo2AvDhASAFDwsCfwJAAkACQCADQQJ2QQNxQX9qIgRBAksNACAEQQFrDgIAAgELQQEhByADQQN2DAILQQIhByABLwAAQQR2DAELIAJBBEkgARAhIgJBj4CAAUtyDQFBAyEHIAJBBHYLIQIgAEHw4gFqIAEgB2otAAAgAkEgahAQIQEgACACNgKA4gEgACABNgLw4QEgB0EBaiEHCyAHC0sAIABC+erQ0OfJoeThADcDICAAQgA3AxggAELP1tO+0ser2UI3AxAgAELW64Lu6v2J9eAANwMIIABCADcDACAAQShqQQBBKBAQGgviAgICfwV+IABBKGoiASAAKAJIaiECAn4gACkDACIDQiBaBEAgACkDECIEQgeJIAApAwgiBUIBiXwgACkDGCIGQgyJfCAAKQMgIgdCEol8IAUQGSAEEBkgBhAZIAcQGQwBCyAAKQMYQsXP2bLx5brqJ3wLIAN8IQMDQCABQQhqIgAgAk0EQEIAIAEpAAAQCSADhUIbiUKHla+vmLbem55/fkLj3MqV/M7y9YV/fCEDIAAhAQwBCwsCQCABQQRqIgAgAksEQCABIQAMAQsgASgAAK1Ch5Wvr5i23puef34gA4VCF4lCz9bTvtLHq9lCfkL5893xmfaZqxZ8IQMLA0AgACACSQRAIAAxAABCxc/ZsvHluuonfiADhUILiUKHla+vmLbem55/fiEDIABBAWohAAwBCwsgA0IhiCADhULP1tO+0ser2UJ+IgNCHYggA4VC+fPd8Zn2masWfiIDQiCIIAOFC+8CAgJ/BH4gACAAKQMAIAKtfDcDAAJAAkAgACgCSCIDIAJqIgRBH00EQCABRQ0BIAAgA2pBKGogASACECAgACgCSCACaiEEDAELIAEgAmohAgJ/IAMEQCAAQShqIgQgA2ogAUEgIANrECAgACAAKQMIIAQpAAAQCTcDCCAAIAApAxAgACkAMBAJNwMQIAAgACkDGCAAKQA4EAk3AxggACAAKQMgIABBQGspAAAQCTcDICAAKAJIIQMgAEEANgJIIAEgA2tBIGohAQsgAUEgaiACTQsEQCACQWBqIQMgACkDICEFIAApAxghBiAAKQMQIQcgACkDCCEIA0AgCCABKQAAEAkhCCAHIAEpAAgQCSEHIAYgASkAEBAJIQYgBSABKQAYEAkhBSABQSBqIgEgA00NAAsgACAFNwMgIAAgBjcDGCAAIAc3AxAgACAINwMICyABIAJPDQEgAEEoaiABIAIgAWsiBBAgCyAAIAQ2AkgLCy8BAX8gAEUEQEG2f0EAIAMbDwtBun8hBCADIAFNBH8gACACIAMQEBogAwVBun8LCy8BAX8gAEUEQEG2f0EAIAMbDwtBun8hBCADIAFNBH8gACACIAMQCxogAwVBun8LC6gCAQZ/IwBBEGsiByQAIABB2OABaikDAEKAgIAQViEIQbh/IQUCQCAEQf//B0sNACAAIAMgBBBCIgUQAyIGDQAgACgCnOIBIQkgACAHQQxqIAMgAyAFaiAGGyIKIARBACAFIAYbayIGEEAiAxADBEAgAyEFDAELIAcoAgwhBCABRQRAQbp/IQUgBEEASg0BCyAGIANrIQUgAyAKaiEDAkAgCQRAIABBADYCnOIBDAELAkACQAJAIARBBUgNACAAQdjgAWopAwBCgICACFgNAAwBCyAAQQA2ApziAQwBCyAAKAIIED8hBiAAQQA2ApziASAGQRRPDQELIAAgASACIAMgBSAEIAgQOSEFDAELIAAgASACIAMgBSAEIAgQOiEFCyAHQRBqJAAgBQtnACAAQdDgAWogASACIAAoAuzhARAuIgEQAwRAIAEPC0G4fyECAkAgAQ0AIABB7OABaigCACIBBEBBYCECIAAoApjiASABRw0BC0EAIQIgAEHw4AFqKAIARQ0AIABBkOEBahBDCyACCycBAX8QVyIERQRAQUAPCyAEIAAgASACIAMgBBBLEE8hACAEEFYgAAs/AQF/AkACQAJAIAAoAqDiAUEBaiIBQQJLDQAgAUEBaw4CAAECCyAAEDBBAA8LIABBADYCoOIBCyAAKAKU4gELvAMCB38BfiMAQRBrIgkkAEG4fyEGAkAgBCgCACIIQQVBCSAAKALs4QEiBRtJDQAgAygCACIHQQFBBSAFGyAFEC8iBRADBEAgBSEGDAELIAggBUEDakkNACAAIAcgBRBJIgYQAw0AIAEgAmohCiAAQZDhAWohCyAIIAVrIQIgBSAHaiEHIAEhBQNAIAcgAiAJECwiBhADDQEgAkF9aiICIAZJBEBBuH8hBgwCCyAJKAIAIghBAksEQEFsIQYMAgsgB0EDaiEHAn8CQAJAAkAgCEEBaw4CAgABCyAAIAUgCiAFayAHIAYQSAwCCyAFIAogBWsgByAGEEcMAQsgBSAKIAVrIActAAAgCSgCCBBGCyIIEAMEQCAIIQYMAgsgACgC8OABBEAgCyAFIAgQRQsgAiAGayECIAYgB2ohByAFIAhqIQUgCSgCBEUNAAsgACkD0OABIgxCf1IEQEFsIQYgDCAFIAFrrFINAQsgACgC8OABBEBBaiEGIAJBBEkNASALEEQhDCAHKAAAIAynRw0BIAdBBGohByACQXxqIQILIAMgBzYCACAEIAI2AgAgBSABayEGCyAJQRBqJAAgBgsuACAAECsCf0EAQQAQAw0AGiABRSACRXJFBEBBYiAAIAEgAhA9EAMNARoLQQALCzcAIAEEQCAAIAAoAsTgASABKAIEIAEoAghqRzYCnOIBCyAAECtBABADIAFFckUEQCAAIAEQWwsL0QIBB38jAEEQayIGJAAgBiAENgIIIAYgAzYCDCAFBEAgBSgCBCEKIAUoAgghCQsgASEIAkACQANAIAAoAuzhARAWIQsCQANAIAQgC0kNASADKAAAQXBxQdDUtMIBRgRAIAMgBBAiIgcQAw0EIAQgB2shBCADIAdqIQMMAQsLIAYgAzYCDCAGIAQ2AggCQCAFBEAgACAFEE5BACEHQQAQA0UNAQwFCyAAIAogCRBNIgcQAw0ECyAAIAgQUCAMQQFHQQAgACAIIAIgBkEMaiAGQQhqEEwiByIDa0EAIAMQAxtBCkdyRQRAQbh/IQcMBAsgBxADDQMgAiAHayECIAcgCGohCEEBIQwgBigCDCEDIAYoAgghBAwBCwsgBiADNgIMIAYgBDYCCEG4fyEHIAQNASAIIAFrIQcMAQsgBiADNgIMIAYgBDYCCAsgBkEQaiQAIAcLRgECfyABIAAoArjgASICRwRAIAAgAjYCxOABIAAgATYCuOABIAAoArzgASEDIAAgATYCvOABIAAgASADIAJrajYCwOABCwutAgIEfwF+IwBBQGoiBCQAAkACQCACQQhJDQAgASgAAEFwcUHQ1LTCAUcNACABIAIQIiEBIABCADcDCCAAQQA2AgQgACABNgIADAELIARBGGogASACEC0iAxADBEAgACADEBoMAQsgAwRAIABBuH8QGgwBCyACIAQoAjAiA2shAiABIANqIQMDQAJAIAAgAyACIARBCGoQLCIFEAMEfyAFBSACIAVBA2oiBU8NAUG4fwsQGgwCCyAGQQFqIQYgAiAFayECIAMgBWohAyAEKAIMRQ0ACyAEKAI4BEAgAkEDTQRAIABBuH8QGgwCCyADQQRqIQMLIAQoAighAiAEKQMYIQcgAEEANgIEIAAgAyABazYCACAAIAIgBmytIAcgB0J/URs3AwgLIARBQGskAAslAQF/IwBBEGsiAiQAIAIgACABEFEgAigCACEAIAJBEGokACAAC30BBH8jAEGQBGsiBCQAIARB/wE2AggCQCAEQRBqIARBCGogBEEMaiABIAIQFSIGEAMEQCAGIQUMAQtBVCEFIAQoAgwiB0EGSw0AIAMgBEEQaiAEKAIIIAcQQSIFEAMNACAAIAEgBmogAiAGayADEDwhBQsgBEGQBGokACAFC4cBAgJ/An5BABAWIQMCQANAIAEgA08EQAJAIAAoAABBcHFB0NS0wgFGBEAgACABECIiAhADRQ0BQn4PCyAAIAEQVSIEQn1WDQMgBCAFfCIFIARUIQJCfiEEIAINAyAAIAEQUiICEAMNAwsgASACayEBIAAgAmohAAwBCwtCfiAFIAEbIQQLIAQLPwIBfwF+IwBBMGsiAiQAAn5CfiACQQhqIAAgARAtDQAaQgAgAigCHEEBRg0AGiACKQMICyEDIAJBMGokACADC40BAQJ/IwBBMGsiASQAAkAgAEUNACAAKAKI4gENACABIABB/OEBaigCADYCKCABIAApAvThATcDICAAEDAgACgCqOIBIQIgASABKAIoNgIYIAEgASkDIDcDECACIAFBEGoQGyAAQQA2AqjiASABIAEoAig2AgggASABKQMgNwMAIAAgARAbCyABQTBqJAALKgECfyMAQRBrIgAkACAAQQA2AgggAEIANwMAIAAQWCEBIABBEGokACABC4cBAQN/IwBBEGsiAiQAAkAgACgCAEUgACgCBEVzDQAgAiAAKAIINgIIIAIgACkCADcDAAJ/IAIoAgAiAQRAIAIoAghBqOMJIAERBQAMAQtBqOMJECgLIgFFDQAgASAAKQIANwL04QEgAUH84QFqIAAoAgg2AgAgARBZIAEhAwsgAkEQaiQAIAMLywEBAn8jAEEgayIBJAAgAEGBgIDAADYCtOIBIABBADYCiOIBIABBADYC7OEBIABCADcDkOIBIABBADYCpOMJIABBADYC3OIBIABCADcCzOIBIABBADYCvOIBIABBADYCxOABIABCADcCnOIBIABBpOIBakIANwIAIABBrOIBakEANgIAIAFCADcCECABQgA3AhggASABKQMYNwMIIAEgASkDEDcDACABKAIIQQh2QQFxIQIgAEEANgLg4gEgACACNgKM4gEgAUEgaiQAC3YBA38jAEEwayIBJAAgAARAIAEgAEHE0AFqIgIoAgA2AiggASAAKQK80AE3AyAgACgCACEDIAEgAigCADYCGCABIAApArzQATcDECADIAFBEGoQGyABIAEoAig2AgggASABKQMgNwMAIAAgARAbCyABQTBqJAALzAEBAX8gACABKAK00AE2ApjiASAAIAEoAgQiAjYCwOABIAAgAjYCvOABIAAgAiABKAIIaiICNgK44AEgACACNgLE4AEgASgCuNABBEAgAEKBgICAEDcDiOEBIAAgAUGk0ABqNgIMIAAgAUGUIGo2AgggACABQZwwajYCBCAAIAFBDGo2AgAgAEGs0AFqIAFBqNABaigCADYCACAAQbDQAWogAUGs0AFqKAIANgIAIABBtNABaiABQbDQAWooAgA2AgAPCyAAQgA3A4jhAQs7ACACRQRAQbp/DwsgBEUEQEFsDwsgAiAEEGAEQCAAIAEgAiADIAQgBRBhDwsgACABIAIgAyAEIAUQZQtGAQF/IwBBEGsiBSQAIAVBCGogBBAOAn8gBS0ACQRAIAAgASACIAMgBBAyDAELIAAgASACIAMgBBA0CyEAIAVBEGokACAACzQAIAAgAyAEIAUQNiIFEAMEQCAFDwsgBSAESQR/IAEgAiADIAVqIAQgBWsgABA1BUG4fwsLRgEBfyMAQRBrIgUkACAFQQhqIAQQDgJ/IAUtAAkEQCAAIAEgAiADIAQQYgwBCyAAIAEgAiADIAQQNQshACAFQRBqJAAgAAtZAQF/QQ8hAiABIABJBEAgAUEEdCAAbiECCyAAQQh2IgEgAkEYbCIAQYwIaigCAGwgAEGICGooAgBqIgJBA3YgAmogAEGACGooAgAgAEGECGooAgAgAWxqSQs3ACAAIAMgBCAFQYAQEDMiBRADBEAgBQ8LIAUgBEkEfyABIAIgAyAFaiAEIAVrIAAQMgVBuH8LC78DAQN/IwBBIGsiBSQAIAVBCGogAiADEAYiAhADRQRAIAAgAWoiB0F9aiEGIAUgBBAOIARBBGohAiAFLQACIQMDQEEAIAAgBkkgBUEIahAEGwRAIAAgAiAFQQhqIAMQAkECdGoiBC8BADsAACAFQQhqIAQtAAIQASAAIAQtAANqIgQgAiAFQQhqIAMQAkECdGoiAC8BADsAACAFQQhqIAAtAAIQASAEIAAtAANqIQAMAQUgB0F+aiEEA0AgBUEIahAEIAAgBEtyRQRAIAAgAiAFQQhqIAMQAkECdGoiBi8BADsAACAFQQhqIAYtAAIQASAAIAYtAANqIQAMAQsLA0AgACAES0UEQCAAIAIgBUEIaiADEAJBAnRqIgYvAQA7AAAgBUEIaiAGLQACEAEgACAGLQADaiEADAELCwJAIAAgB08NACAAIAIgBUEIaiADEAIiA0ECdGoiAC0AADoAACAALQADQQFGBEAgBUEIaiAALQACEAEMAQsgBSgCDEEfSw0AIAVBCGogAiADQQJ0ai0AAhABIAUoAgxBIUkNACAFQSA2AgwLIAFBbCAFQQhqEAobIQILCwsgBUEgaiQAIAILkgIBBH8jAEFAaiIJJAAgCSADQTQQCyEDAkAgBEECSA0AIAMgBEECdGooAgAhCSADQTxqIAgQIyADQQE6AD8gAyACOgA+QQAhBCADKAI8IQoDQCAEIAlGDQEgACAEQQJ0aiAKNgEAIARBAWohBAwAAAsAC0EAIQkDQCAGIAlGRQRAIAMgBSAJQQF0aiIKLQABIgtBAnRqIgwoAgAhBCADQTxqIAotAABBCHQgCGpB//8DcRAjIANBAjoAPyADIAcgC2siCiACajoAPiAEQQEgASAKa3RqIQogAygCPCELA0AgACAEQQJ0aiALNgEAIARBAWoiBCAKSQ0ACyAMIAo2AgAgCUEBaiEJDAELCyADQUBrJAALowIBCX8jAEHQAGsiCSQAIAlBEGogBUE0EAsaIAcgBmshDyAHIAFrIRADQAJAIAMgCkcEQEEBIAEgByACIApBAXRqIgYtAAEiDGsiCGsiC3QhDSAGLQAAIQ4gCUEQaiAMQQJ0aiIMKAIAIQYgCyAPTwRAIAAgBkECdGogCyAIIAUgCEE0bGogCCAQaiIIQQEgCEEBShsiCCACIAQgCEECdGooAgAiCEEBdGogAyAIayAHIA4QYyAGIA1qIQgMAgsgCUEMaiAOECMgCUEBOgAPIAkgCDoADiAGIA1qIQggCSgCDCELA0AgBiAITw0CIAAgBkECdGogCzYBACAGQQFqIQYMAAALAAsgCUHQAGokAA8LIAwgCDYCACAKQQFqIQoMAAALAAs0ACAAIAMgBCAFEDYiBRADBEAgBQ8LIAUgBEkEfyABIAIgAyAFaiAEIAVrIAAQNAVBuH8LCyMAIAA/AEEQdGtB//8DakEQdkAAQX9GBEBBAA8LQQAQAEEBCzsBAX8gAgRAA0AgACABIAJBgCAgAkGAIEkbIgMQCyEAIAFBgCBqIQEgAEGAIGohACACIANrIgINAAsLCwYAIAAQAwsLqBUJAEGICAsNAQAAAAEAAAACAAAAAgBBoAgLswYBAAAAAQAAAAIAAAACAAAAJgAAAIIAAAAhBQAASgAAAGcIAAAmAAAAwAEAAIAAAABJBQAASgAAAL4IAAApAAAALAIAAIAAAABJBQAASgAAAL4IAAAvAAAAygIAAIAAAACKBQAASgAAAIQJAAA1AAAAcwMAAIAAAACdBQAASgAAAKAJAAA9AAAAgQMAAIAAAADrBQAASwAAAD4KAABEAAAAngMAAIAAAABNBgAASwAAAKoKAABLAAAAswMAAIAAAADBBgAATQAAAB8NAABNAAAAUwQAAIAAAAAjCAAAUQAAAKYPAABUAAAAmQQAAIAAAABLCQAAVwAAALESAABYAAAA2gQAAIAAAABvCQAAXQAAACMUAABUAAAARQUAAIAAAABUCgAAagAAAIwUAABqAAAArwUAAIAAAAB2CQAAfAAAAE4QAAB8AAAA0gIAAIAAAABjBwAAkQAAAJAHAACSAAAAAAAAAAEAAAABAAAABQAAAA0AAAAdAAAAPQAAAH0AAAD9AAAA/QEAAP0DAAD9BwAA/Q8AAP0fAAD9PwAA/X8AAP3/AAD9/wEA/f8DAP3/BwD9/w8A/f8fAP3/PwD9/38A/f//AP3//wH9//8D/f//B/3//w/9//8f/f//P/3//38AAAAAAQAAAAIAAAADAAAABAAAAAUAAAAGAAAABwAAAAgAAAAJAAAACgAAAAsAAAAMAAAADQAAAA4AAAAPAAAAEAAAABEAAAASAAAAEwAAABQAAAAVAAAAFgAAABcAAAAYAAAAGQAAABoAAAAbAAAAHAAAAB0AAAAeAAAAHwAAAAMAAAAEAAAABQAAAAYAAAAHAAAACAAAAAkAAAAKAAAACwAAAAwAAAANAAAADgAAAA8AAAAQAAAAEQAAABIAAAATAAAAFAAAABUAAAAWAAAAFwAAABgAAAAZAAAAGgAAABsAAAAcAAAAHQAAAB4AAAAfAAAAIAAAACEAAAAiAAAAIwAAACUAAAAnAAAAKQAAACsAAAAvAAAAMwAAADsAAABDAAAAUwAAAGMAAACDAAAAAwEAAAMCAAADBAAAAwgAAAMQAAADIAAAA0AAAAOAAAADAAEAQeAPC1EBAAAAAQAAAAEAAAABAAAAAgAAAAIAAAADAAAAAwAAAAQAAAAEAAAABQAAAAcAAAAIAAAACQAAAAoAAAALAAAADAAAAA0AAAAOAAAADwAAABAAQcQQC4sBAQAAAAIAAAADAAAABAAAAAUAAAAGAAAABwAAAAgAAAAJAAAACgAAAAsAAAAMAAAADQAAAA4AAAAPAAAAEAAAABIAAAAUAAAAFgAAABgAAAAcAAAAIAAAACgAAAAwAAAAQAAAAIAAAAAAAQAAAAIAAAAEAAAACAAAABAAAAAgAAAAQAAAAIAAAAAAAQBBkBIL5gQBAAAAAQAAAAEAAAABAAAAAgAAAAIAAAADAAAAAwAAAAQAAAAGAAAABwAAAAgAAAAJAAAACgAAAAsAAAAMAAAADQAAAA4AAAAPAAAAEAAAAAEAAAAEAAAACAAAAAAAAAABAAEBBgAAAAAAAAQAAAAAEAAABAAAAAAgAAAFAQAAAAAAAAUDAAAAAAAABQQAAAAAAAAFBgAAAAAAAAUHAAAAAAAABQkAAAAAAAAFCgAAAAAAAAUMAAAAAAAABg4AAAAAAAEFEAAAAAAAAQUUAAAAAAABBRYAAAAAAAIFHAAAAAAAAwUgAAAAAAAEBTAAAAAgAAYFQAAAAAAABwWAAAAAAAAIBgABAAAAAAoGAAQAAAAADAYAEAAAIAAABAAAAAAAAAAEAQAAAAAAAAUCAAAAIAAABQQAAAAAAAAFBQAAACAAAAUHAAAAAAAABQgAAAAgAAAFCgAAAAAAAAULAAAAAAAABg0AAAAgAAEFEAAAAAAAAQUSAAAAIAABBRYAAAAAAAIFGAAAACAAAwUgAAAAAAADBSgAAAAAAAYEQAAAABAABgRAAAAAIAAHBYAAAAAAAAkGAAIAAAAACwYACAAAMAAABAAAAAAQAAAEAQAAACAAAAUCAAAAIAAABQMAAAAgAAAFBQAAACAAAAUGAAAAIAAABQgAAAAgAAAFCQAAACAAAAULAAAAIAAABQwAAAAAAAAGDwAAACAAAQUSAAAAIAABBRQAAAAgAAIFGAAAACAAAgUcAAAAIAADBSgAAAAgAAQFMAAAAAAAEAYAAAEAAAAPBgCAAAAAAA4GAEAAAAAADQYAIABBgBcLhwIBAAEBBQAAAAAAAAUAAAAAAAAGBD0AAAAAAAkF/QEAAAAADwX9fwAAAAAVBf3/HwAAAAMFBQAAAAAABwR9AAAAAAAMBf0PAAAAABIF/f8DAAAAFwX9/38AAAAFBR0AAAAAAAgE/QAAAAAADgX9PwAAAAAUBf3/DwAAAAIFAQAAABAABwR9AAAAAAALBf0HAAAAABEF/f8BAAAAFgX9/z8AAAAEBQ0AAAAQAAgE/QAAAAAADQX9HwAAAAATBf3/BwAAAAEFAQAAABAABgQ9AAAAAAAKBf0DAAAAABAF/f8AAAAAHAX9//8PAAAbBf3//wcAABoF/f//AwAAGQX9//8BAAAYBf3//wBBkBkLhgQBAAEBBgAAAAAAAAYDAAAAAAAABAQAAAAgAAAFBQAAAAAAAAUGAAAAAAAABQgAAAAAAAAFCQAAAAAAAAULAAAAAAAABg0AAAAAAAAGEAAAAAAAAAYTAAAAAAAABhYAAAAAAAAGGQAAAAAAAAYcAAAAAAAABh8AAAAAAAAGIgAAAAAAAQYlAAAAAAABBikAAAAAAAIGLwAAAAAAAwY7AAAAAAAEBlMAAAAAAAcGgwAAAAAACQYDAgAAEAAABAQAAAAAAAAEBQAAACAAAAUGAAAAAAAABQcAAAAgAAAFCQAAAAAAAAUKAAAAAAAABgwAAAAAAAAGDwAAAAAAAAYSAAAAAAAABhUAAAAAAAAGGAAAAAAAAAYbAAAAAAAABh4AAAAAAAAGIQAAAAAAAQYjAAAAAAABBicAAAAAAAIGKwAAAAAAAwYzAAAAAAAEBkMAAAAAAAUGYwAAAAAACAYDAQAAIAAABAQAAAAwAAAEBAAAABAAAAQFAAAAIAAABQcAAAAgAAAFCAAAACAAAAUKAAAAIAAABQsAAAAAAAAGDgAAAAAAAAYRAAAAAAAABhQAAAAAAAAGFwAAAAAAAAYaAAAAAAAABh0AAAAAAAAGIAAAAAAAEAYDAAEAAAAPBgOAAAAAAA4GA0AAAAAADQYDIAAAAAAMBgMQAAAAAAsGAwgAAAAACgYDBABBpB0L2QEBAAAAAwAAAAcAAAAPAAAAHwAAAD8AAAB/AAAA/wAAAP8BAAD/AwAA/wcAAP8PAAD/HwAA/z8AAP9/AAD//wAA//8BAP//AwD//wcA//8PAP//HwD//z8A//9/AP///wD///8B////A////wf///8P////H////z////9/AAAAAAEAAAACAAAABAAAAAAAAAACAAAABAAAAAgAAAAAAAAAAQAAAAIAAAABAAAABAAAAAQAAAAEAAAABAAAAAgAAAAIAAAACAAAAAcAAAAIAAAACQAAAAoAAAALAEGgIAsDwBBQ",nx=new WeakMap;let ix,rx=0;class sx extends tp{constructor(t){super(t),this.transcoderPath="",this.transcoderBinary=null,this.transcoderPending=null,this.workerPool=new By,this.workerSourceURL="",this.workerConfig=null,"undefined"!=typeof MSC_TRANSCODER&&console.warn('THREE.KTX2Loader: Please update to latest "basis_transcoder". "msc_basis_transcoder" is no longer supported in three.js r125+.')}setTranscoderPath(t){return this.transcoderPath=t,this}setWorkerLimit(t){return this.workerPool.setWorkerLimit(t),this}async detectSupportAsync(t){return this.workerConfig={astcSupported:await t.hasFeatureAsync("texture-compression-astc"),astcHDRSupported:!1,etc1Supported:await t.hasFeatureAsync("texture-compression-etc1"),etc2Supported:await t.hasFeatureAsync("texture-compression-etc2"),dxtSupported:await t.hasFeatureAsync("texture-compression-bc"),bptcSupported:await t.hasFeatureAsync("texture-compression-bptc"),pvrtcSupported:await t.hasFeatureAsync("texture-compression-pvrtc")},this}detectSupport(t){return!0===t.isWebGPURenderer?this.workerConfig={astcSupported:t.hasFeature("texture-compression-astc"),astcHDRSupported:!1,etc1Supported:t.hasFeature("texture-compression-etc1"),etc2Supported:t.hasFeature("texture-compression-etc2"),dxtSupported:t.hasFeature("texture-compression-bc"),bptcSupported:t.hasFeature("texture-compression-bptc"),pvrtcSupported:t.hasFeature("texture-compression-pvrtc")}:this.workerConfig={astcSupported:t.extensions.has("WEBGL_compressed_texture_astc"),astcHDRSupported:t.extensions.has("WEBGL_compressed_texture_astc")&&t.extensions.get("WEBGL_compressed_texture_astc").getSupportedProfiles().includes("hdr"),etc1Supported:t.extensions.has("WEBGL_compressed_texture_etc1"),etc2Supported:t.extensions.has("WEBGL_compressed_texture_etc"),dxtSupported:t.extensions.has("WEBGL_compressed_texture_s3tc"),bptcSupported:t.extensions.has("EXT_texture_compression_bptc"),pvrtcSupported:t.extensions.has("WEBGL_compressed_texture_pvrtc")||t.extensions.has("WEBKIT_WEBGL_compressed_texture_pvrtc")},this}init(){if(!this.transcoderPending){const t=new ip(this.manager);t.setPath(this.transcoderPath),t.setWithCredentials(this.withCredentials);const e=t.loadAsync("basis_transcoder.js"),n=new ip(this.manager);n.setPath(this.transcoderPath),n.setResponseType("arraybuffer"),n.setWithCredentials(this.withCredentials);const i=n.loadAsync("basis_transcoder.wasm");this.transcoderPending=Promise.all([e,i]).then((([t,e])=>{const n=sx.BasisWorker.toString(),i=["/* constants */","let _EngineFormat = "+JSON.stringify(sx.EngineFormat),"let _EngineType = "+JSON.stringify(sx.EngineType),"let _TranscoderFormat = "+JSON.stringify(sx.TranscoderFormat),"let _BasisFormat = "+JSON.stringify(sx.BasisFormat),"/* basis_transcoder.js */",t,"/* worker */",n.substring(n.indexOf("{")+1,n.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([i])),this.transcoderBinary=e,this.workerPool.setWorkerCreator((()=>{const t=new Worker(this.workerSourceURL),e=this.transcoderBinary.slice(0);return t.postMessage({type:"init",config:this.workerConfig,transcoderBinary:e},[e]),t}))})),rx>0&&console.warn("THREE.KTX2Loader: Multiple active KTX2 loaders may cause performance issues. Use a single KTX2Loader instance, or call .dispose() on old instances."),rx++}return this.transcoderPending}load(t,e,n,i){if(null===this.workerConfig)throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");const r=new ip(this.manager);r.setResponseType("arraybuffer"),r.setWithCredentials(this.withCredentials),r.load(t,(t=>{this.parse(t,e,i)}),n,i)}parse(t,e,n){if(null===this.workerConfig)throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");if(nx.has(t))return nx.get(t).promise.then(e).catch(n);this._createTexture(t).then((t=>e?e(t):null)).catch(n)}_createTextureFrom(t,e){const{type:n,error:i,data:{faces:r,width:s,height:a,format:o,type:l,dfdFlags:c}}=t;if("error"===n)return Promise.reject(i);let h;if(6===e.faceCount)h=new Kh(r,o,l);else{const t=r[0].mipmaps;h=e.layerCount>1?new Jh(t,s,a,e.layerCount,o,l):new Yh(t,s,a,o,l)}return h.minFilter=1===r[0].mipmaps.length?Ut:Ot,h.magFilter=Ut,h.generateMipmaps=!1,h.needsUpdate=!0,h.colorSpace=cx(e),h.premultiplyAlpha=!!(1&c),h}async _createTexture(t,e={}){const n=function(t){const e=new Uint8Array(t.buffer,t.byteOffset,Xy.length);if(e[0]!==Xy[0]||e[1]!==Xy[1]||e[2]!==Xy[2]||e[3]!==Xy[3]||e[4]!==Xy[4]||e[5]!==Xy[5]||e[6]!==Xy[6]||e[7]!==Xy[7]||e[8]!==Xy[8]||e[9]!==Xy[9]||e[10]!==Xy[10]||e[11]!==Xy[11])throw new Error("Missing KTX 2.0 identifier.");const n=new jy,i=17*Uint32Array.BYTES_PER_ELEMENT,r=new qy(t,Xy.length,i,!0);n.vkFormat=r._nextUint32(),n.typeSize=r._nextUint32(),n.pixelWidth=r._nextUint32(),n.pixelHeight=r._nextUint32(),n.pixelDepth=r._nextUint32(),n.layerCount=r._nextUint32(),n.faceCount=r._nextUint32();const s=r._nextUint32();n.supercompressionScheme=r._nextUint32();const a=r._nextUint32(),o=r._nextUint32(),l=r._nextUint32(),c=r._nextUint32(),h=r._nextUint64(),u=r._nextUint64(),d=new qy(t,Xy.length+i,3*s*8,!0);for(let e=0;e{const e=new tx;await e.init(),t(e)}))),n=await ix);const i=[];for(let r=0;r>r),a=Math.max(1,t.pixelHeight>>r),o=t.pixelDepth?Math.max(1,t.pixelDepth>>r):0,l=t.levels[r];let c,h;if(0===t.supercompressionScheme)c=l.levelData;else{if(2!==t.supercompressionScheme)throw new Error("THREE.KTX2Loader: Unsupported supercompressionScheme.");c=n.decode(l.levelData,l.uncompressedByteLength)}h=lx[e]===jt?new Float32Array(c.buffer,c.byteOffset,c.byteLength/Float32Array.BYTES_PER_ELEMENT):lx[e]===qt?new Uint16Array(c.buffer,c.byteOffset,c.byteLength/Uint16Array.BYTES_PER_ELEMENT):c,i.push({data:h,width:s,height:a,depth:o})}let r;if(ax.has(ox[e]))r=0===t.pixelDepth?new Yc(i[0].data,t.pixelWidth,t.pixelHeight):new Qi(i[0].data,t.pixelWidth,t.pixelHeight,t.pixelDepth);else{if(t.pixelDepth>0)throw new Error("THREE.KTX2Loader: Unsupported pixelDepth.");r=new Yh(i,t.pixelWidth,t.pixelHeight)}return r.mipmaps=i,r.type=lx[e],r.format=ox[e],r.colorSpace=cx(t),r.needsUpdate=!0,Promise.resolve(r)}(n);const r=e,s=this.init().then((()=>this.workerPool.postMessage({type:"transcode",buffer:t,taskConfig:r},[t]))).then((t=>this._createTextureFrom(t.data,n)));return nx.set(t,{promise:s}),s}dispose(){return this.workerPool.dispose(),this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),rx--,this}}sx.BasisFormat={ETC1S:0,UASTC:1,UASTC_HDR:2},sx.TranscoderFormat={ETC1:0,ETC2:1,BC1:2,BC3:3,BC4:4,BC5:5,BC7_M6_OPAQUE_ONLY:6,BC7_M5:7,PVRTC1_4_RGB:8,PVRTC1_4_RGBA:9,ASTC_4x4:10,ATC_RGB:11,ATC_RGBA_INTERPOLATED_ALPHA:12,RGBA32:13,RGB565:14,BGR565:15,RGBA4444:16,BC6H:22,RGB_HALF:24,RGBA_HALF:25},sx.EngineFormat={RGBAFormat:te,RGBA_ASTC_4x4_Format:we,RGB_BPTC_UNSIGNED_Format:Oe,RGBA_BPTC_Format:Ne,RGBA_ETC2_EAC_Format:_e,RGBA_PVRTC_4BPPV1_Format:Ae,RGBA_S3TC_DXT5_Format:fe,RGB_ETC1_Format:ye,RGB_ETC2_Format:xe,RGB_PVRTC_4BPPV1_Format:me,RGBA_S3TC_DXT1_Format:de},sx.EngineType={UnsignedByteType:Qt,HalfFloatType:qt,FloatType:jt},sx.BasisWorker=function(){let t,e,n;const i=_EngineFormat,r=_EngineType,s=_TranscoderFormat,a=_BasisFormat;self.addEventListener("message",(function(i){const s=i.data;switch(s.type){case"init":t=s.config,o=s.transcoderBinary,e=new Promise((t=>{n={wasmBinary:o,onRuntimeInitialized:t},BASIS(n)})).then((()=>{n.initializeBasis(),void 0===n.KTX2File&&console.warn("THREE.KTX2Loader: Please update Basis Universal transcoder.")}));break;case"transcode":e.then((()=>{try{const{faces:e,buffers:i,width:o,height:u,hasAlpha:d,format:p,type:f,dfdFlags:m}=function(e){const i=new n.KTX2File(new Uint8Array(e));function s(){i.close(),i.delete()}if(!i.isValid())throw s(),new Error("THREE.KTX2Loader:\tInvalid or unsupported .ktx2 file");let o;if(i.isUASTC())o=a.UASTC;else if(i.isETC1S())o=a.ETC1S;else{if(!i.isHDR())throw new Error("THREE.KTX2Loader: Unknown Basis encoding");o=a.UASTC_HDR}const u=i.getWidth(),d=i.getHeight(),p=i.getLayers()||1,f=i.getLevels(),m=i.getFaces(),g=i.getHasAlpha(),A=i.getDFDFlags(),{transcoderFormat:v,engineFormat:y,engineType:x}=function(e,n,i,r){const s=l[e];for(let a=0;a1?(o=c.origWidth,l=c.origHeight):(o=c.width,l=c.height);let h=new Uint8Array(i.getImageTranscodedSizeInBytes(n,e,0,v));const u=i.transcodeImage(h,n,e,t,v,0,-1,-1);if(x===r.HalfFloatType&&(h=new Uint16Array(h.buffer,h.byteOffset,h.byteLength/Uint16Array.BYTES_PER_ELEMENT)),!u)throw s(),new Error("THREE.KTX2Loader: .transcodeImage failed.");a.push(h)}const c=h(a);e.push({data:c,width:o,height:l}),w.push(c.buffer)}_.push({mipmaps:e,width:u,height:d,format:y,type:x})}return s(),{faces:_,buffers:w,width:u,height:d,hasAlpha:g,dfdFlags:A,format:y,type:x}}(s.buffer);self.postMessage({type:"transcode",id:s.id,data:{faces:e,width:o,height:u,hasAlpha:d,format:p,type:f,dfdFlags:m}},i)}catch(t){console.error(t),self.postMessage({type:"error",id:s.id,error:t.message})}}))}var o}));const o=[{if:"astcSupported",basisFormat:[a.UASTC],transcoderFormat:[s.ASTC_4x4,s.ASTC_4x4],engineFormat:[i.RGBA_ASTC_4x4_Format,i.RGBA_ASTC_4x4_Format],engineType:[r.UnsignedByteType],priorityETC1S:1/0,priorityUASTC:1,needsPowerOfTwo:!1},{if:"bptcSupported",basisFormat:[a.ETC1S,a.UASTC],transcoderFormat:[s.BC7_M5,s.BC7_M5],engineFormat:[i.RGBA_BPTC_Format,i.RGBA_BPTC_Format],engineType:[r.UnsignedByteType],priorityETC1S:3,priorityUASTC:2,needsPowerOfTwo:!1},{if:"dxtSupported",basisFormat:[a.ETC1S,a.UASTC],transcoderFormat:[s.BC1,s.BC3],engineFormat:[i.RGBA_S3TC_DXT1_Format,i.RGBA_S3TC_DXT5_Format],engineType:[r.UnsignedByteType],priorityETC1S:4,priorityUASTC:5,needsPowerOfTwo:!1},{if:"etc2Supported",basisFormat:[a.ETC1S,a.UASTC],transcoderFormat:[s.ETC1,s.ETC2],engineFormat:[i.RGB_ETC2_Format,i.RGBA_ETC2_EAC_Format],engineType:[r.UnsignedByteType],priorityETC1S:1,priorityUASTC:3,needsPowerOfTwo:!1},{if:"etc1Supported",basisFormat:[a.ETC1S,a.UASTC],transcoderFormat:[s.ETC1],engineFormat:[i.RGB_ETC1_Format],engineType:[r.UnsignedByteType],priorityETC1S:2,priorityUASTC:4,needsPowerOfTwo:!1},{if:"pvrtcSupported",basisFormat:[a.ETC1S,a.UASTC],transcoderFormat:[s.PVRTC1_4_RGB,s.PVRTC1_4_RGBA],engineFormat:[i.RGB_PVRTC_4BPPV1_Format,i.RGBA_PVRTC_4BPPV1_Format],engineType:[r.UnsignedByteType],priorityETC1S:5,priorityUASTC:6,needsPowerOfTwo:!0},{if:"bptcSupported",basisFormat:[a.UASTC_HDR],transcoderFormat:[s.BC6H],engineFormat:[i.RGB_BPTC_UNSIGNED_Format],engineType:[r.HalfFloatType],priorityHDR:1,needsPowerOfTwo:!1},{basisFormat:[a.ETC1S,a.UASTC],transcoderFormat:[s.RGBA32,s.RGBA32],engineFormat:[i.RGBAFormat,i.RGBAFormat],engineType:[r.UnsignedByteType,r.UnsignedByteType],priorityETC1S:100,priorityUASTC:100,needsPowerOfTwo:!1},{basisFormat:[a.UASTC_HDR],transcoderFormat:[s.RGBA_HALF],engineFormat:[i.RGBAFormat],engineType:[r.HalfFloatType],priorityHDR:100,needsPowerOfTwo:!1}],l={[a.ETC1S]:o.filter((t=>t.basisFormat.includes(a.ETC1S))).sort(((t,e)=>t.priorityUASTC-e.priorityUASTC)),[a.UASTC]:o.filter((t=>t.basisFormat.includes(a.UASTC))).sort(((t,e)=>t.priorityUASTC-e.priorityUASTC)),[a.UASTC_HDR]:o.filter((t=>t.basisFormat.includes(a.UASTC_HDR))).sort(((t,e)=>t.priorityHDR-e.priorityHDR))};function c(t){return t<=2||!(t&t-1)&&0!==t}function h(t){if(1===t.length)return t[0];let e=0;for(let n=0;nt&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),"Y"===i.name&&Math.abs(bx.copy(Lx).applyQuaternion(e).dot(this.eye))>t&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),"Z"===i.name&&Math.abs(bx.copy(Ux).applyQuaternion(e).dot(this.eye))>t&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),"XY"===i.name&&Math.abs(bx.copy(Ux).applyQuaternion(e).dot(this.eye)).9&&(i.visible=!1)),"Y"===this.axis&&(px.setFromEuler(Mx.set(0,0,Math.PI/2)),i.quaternion.copy(e).multiply(px),Math.abs(bx.copy(Lx).applyQuaternion(e).dot(this.eye))>.9&&(i.visible=!1)),"Z"===this.axis&&(px.setFromEuler(Mx.set(0,Math.PI/2,0)),i.quaternion.copy(e).multiply(px),Math.abs(bx.copy(Ux).applyQuaternion(e).dot(this.eye))>.9&&(i.visible=!1)),"XYZE"===this.axis&&(px.setFromEuler(Mx.set(0,Math.PI/2,0)),bx.copy(this.rotationAxis),i.quaternion.setFromRotationMatrix(Ix.lookAt(Sx,bx,Lx)),i.quaternion.multiply(px),i.visible=this.dragging),"E"===this.axis&&(i.visible=!1)):"START"===i.name?(i.position.copy(this.worldPositionStart),i.visible=this.dragging):"END"===i.name?(i.position.copy(this.worldPosition),i.visible=this.dragging):"DELTA"===i.name?(i.position.copy(this.worldPositionStart),i.quaternion.copy(this.worldQuaternionStart),ux.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),ux.applyQuaternion(this.worldQuaternionStart.clone().invert()),i.scale.copy(ux),i.visible=this.dragging):(i.quaternion.copy(e),this.dragging?i.position.copy(this.worldPositionStart):i.position.copy(this.worldPosition),this.axis&&(i.visible=-1!==this.axis.search(i.name)))}super.updateMatrixWorld(t)}}class zx extends Zs{constructor(){super(new Ea(1e5,1e5,2,2),new ms({visible:!1,wireframe:!0,side:S,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(t){let e=this.space;switch(this.position.copy(this.worldPosition),"scale"===this.mode&&(e="local"),Nx.copy(Px).applyQuaternion("local"===e?this.worldQuaternion:Bx),Fx.copy(Lx).applyQuaternion("local"===e?this.worldQuaternion:Bx),Ox.copy(Ux).applyQuaternion("local"===e?this.worldQuaternion:Bx),bx.copy(Fx),this.mode){case"translate":case"scale":switch(this.axis){case"X":bx.copy(this.eye).cross(Nx),Rx.copy(Nx).cross(bx);break;case"Y":bx.copy(this.eye).cross(Fx),Rx.copy(Fx).cross(bx);break;case"Z":bx.copy(this.eye).cross(Ox),Rx.copy(Ox).cross(bx);break;case"XY":Rx.copy(Ox);break;case"YZ":Rx.copy(Nx);break;case"XZ":bx.copy(Ox),Rx.copy(Fx);break;case"XYZ":case"E":Rx.set(0,0,0)}break;default:Rx.set(0,0,0)}0===Rx.length()?this.quaternion.copy(this.cameraQuaternion):(Dx.lookAt(ux.set(0,0,0),Rx,bx),this.quaternion.setFromRotationMatrix(Dx)),super.updateMatrixWorld(t)}}const Gx="csm_DiffuseColor",Hx="csm_Roughness",Vx="csm_Metalness",Wx="csm_Emissive",jx="csm_AO",qx="csm_Bump",Xx="csm_FragNormal",Yx="csm_Clearcoat",Jx="csm_ClearcoatRoughness",Kx="csm_ClearcoatNormal",Zx="csm_Transmission",$x="csm_Thickness",t_="csm_Iridescence",e_="csm_PointSize",n_="csm_FragColor",i_="csm_DepthAlpha",r_="csm_UnlitFac",s_="csm_Position",a_="csm_PositionRaw",o_="csm_Normal",l_={[`${s_}`]:"*",[`${a_}`]:"*",[`${o_}`]:"*",[`${i_}`]:"*",[`${e_}`]:["PointsMaterial"],[`${Gx}`]:"*",[`${n_}`]:"*",[`${Xx}`]:"*",[`${r_}`]:"*",[`${Wx}`]:["MeshStandardMaterial","MeshPhysicalMaterial"],[`${Hx}`]:["MeshStandardMaterial","MeshPhysicalMaterial"],[`${Vx}`]:["MeshStandardMaterial","MeshPhysicalMaterial"],[`${t_}`]:["MeshStandardMaterial","MeshPhysicalMaterial"],[`${jx}`]:["MeshStandardMaterial","MeshPhysicalMaterial","MeshBasicMaterial","MeshLambertMaterial","MeshPhongMaterial","MeshToonMaterial"],[`${qx}`]:["MeshLambertMaterial","MeshMatcapMaterial","MeshNormalMaterial","MeshPhongMaterial","MeshPhysicalMaterial","MeshStandardMaterial","MeshToonMaterial","ShadowMaterial"],[`${Yx}`]:["MeshPhysicalMaterial"],[`${Jx}`]:["MeshPhysicalMaterial"],[`${Kx}`]:["MeshPhysicalMaterial"],[`${Zx}`]:["MeshPhysicalMaterial"],[`${$x}`]:["MeshPhysicalMaterial"]},c_={"*":{"#include ":Ma.lights_physical_fragment,"#include ":Ma.transmission_fragment},[`${o_}`]:{"#include ":`\n vec3 objectNormal = ${o_};\n #ifdef USE_TANGENT\n\t vec3 objectTangent = vec3( tangent.xyz );\n #endif\n `},[`${s_}`]:{"#include ":`\n vec3 transformed = ${s_};\n `},[`${a_}`]:{"#include ":`\n vec4 csm_internal_positionUnprojected = ${a_};\n mat4x4 csm_internal_unprojectMatrix = projectionMatrix * modelViewMatrix;\n #ifdef USE_INSTANCING\n csm_internal_unprojectMatrix = csm_internal_unprojectMatrix * instanceMatrix;\n #endif\n csm_internal_positionUnprojected = inverse(csm_internal_unprojectMatrix) * csm_internal_positionUnprojected;\n vec3 transformed = csm_internal_positionUnprojected.xyz;\n `},[`${e_}`]:{"gl_PointSize = size;":`\n gl_PointSize = ${e_};\n `},[`${Gx}`]:{"#include ":`\n #include \n diffuseColor = ${Gx};\n `},[`${n_}`]:{"#include ":`\n #include \n gl_FragColor = mix(gl_FragColor, ${n_}, ${r_});\n `},[`${Wx}`]:{"vec3 totalEmissiveRadiance = emissive;":`\n vec3 totalEmissiveRadiance = ${Wx};\n `},[`${Hx}`]:{"#include ":`\n #include \n roughnessFactor = ${Hx};\n `},[`${Vx}`]:{"#include ":`\n #include \n metalnessFactor = ${Vx};\n `},[`${jx}`]:{"#include ":`\n #include \n reflectedLight.indirectDiffuse *= 1. - ${jx};\n `},[`${qx}`]:{"#include ":`\n #include \n\n vec3 csm_internal_orthogonal = ${qx} - (dot(${qx}, normal) * normal);\n vec3 csm_internal_projectedbump = mat3(csm_internal_vModelViewMatrix) * csm_internal_orthogonal;\n normal = normalize(normal - csm_internal_projectedbump);\n `},[`${Xx}`]:{"#include ":`\n #include \n normal = ${Xx};\n `},[`${i_}`]:{"gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );":`\n gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity * 1.0 - ${i_} );\n `,"gl_FragColor = packDepthToRGBA( fragCoordZ );":`\n if(${i_} < 1.0) discard;\n gl_FragColor = packDepthToRGBA( dist );\n `,"gl_FragColor = packDepthToRGBA( dist );":`\n if(${i_} < 1.0) discard;\n gl_FragColor = packDepthToRGBA( dist );\n `},[`${Yx}`]:{"material.clearcoat = clearcoat;":`material.clearcoat = ${Yx};`},[`${Jx}`]:{"material.clearcoatRoughness = clearcoatRoughness;":`material.clearcoatRoughness = ${Jx};`},[`${Kx}`]:{"#include ":"\n vec3 csm_coat_internal_orthogonal = csm_ClearcoatNormal - (dot(csm_ClearcoatNormal, nonPerturbedNormal) * nonPerturbedNormal);\n vec3 csm_coat_internal_projectedbump = mat3(csm_internal_vModelViewMatrix) * csm_coat_internal_orthogonal;\n vec3 clearcoatNormal = normalize(nonPerturbedNormal - csm_coat_internal_projectedbump);\n "},[`${Zx}`]:{"material.transmission = transmission;":`\n material.transmission = ${Zx};\n `},[`${$x}`]:{"material.thickness = thickness;":`\n material.thickness = ${$x};\n `},[`${t_}`]:{"material.iridescence = iridescence;":`\n material.iridescence = ${t_};\n `}},h_={clearcoat:[Yx,Kx,Jx],transmission:[Zx],iridescence:[t_]};function u_(t){return t.replace(/\/\*[\s\S]*?\*\/|\/\/.*/g,"")}const d_="row",p_="row-reverse",f_="column",m_="column-reverse";function g_(t,e,n,i){let r=n,s="getWidth",a="x",o="y";0===e.indexOf(f_)&&(s="getHeight",a="y",o="x");for(let e=0;e{let o;switch(n){case y_:case"right":case"bottom":o=0===e.indexOf(d_)?-s+a[i]()/2+(a.margin||0):s-a[i]()/2-(a.margin||0);break;case A_:case"left":case"top":o=0===e.indexOf(d_)?s-a[i]()/2-(a.margin||0):-s+a[i]()/2+(a.margin||0)}t.childrenPos[a.id][r]=o||0}))}function w_(t){-1!==E_.indexOf(t)&&console.warn(`alignItems === '${t}' is deprecated and will be remove in 7.x.x. Fallback are 'start'|'end'`)}const C_=[A_,v_,y_,x_,"top","right","bottom","left"],E_=["top","right","bottom","left"],M_="start",b_="center",S_="end",I_="space-around",T_="space-between",B_="space-evenly";function R_(t,e,n,i){const r=t.getJustifyContent();-1===D_.indexOf(r)&&console.warn(`justifyContent === '${r}' is not supported`);const s=0===e.indexOf("row")?"width":"height",a=t.getChildrenSideSum(s),o=("width"===s?t.getInnerWidth():t.getInnerHeight())-a,l=function(t,e){switch(t){case S_:return e;case b_:return e/2}return 0}(r,2*n-a*Math.sign(n)),c=function(t,e,n,i){const r=Array(t.length).fill(0);if(e>0)switch(n){case T_:if(t.length>1){const n=e/(t.length-1)*i;r[0]=0;for(let e=1;e1){const n=e/(t.length+1)*i;for(let e=0;e1){const n=e/t.length*i,s=n/2;r[0]=s;for(let e=1;e{t.childrenPos[e.id][h]-=l-c[n]}))}const D_=[M_,b_,S_,I_,T_,B_];function P_(t){return class extends t{constructor(t){super(t),this.isBoxComponent=!0,this.childrenPos={}}getInnerWidth(){const t=this.getContentDirection();switch(t){case"row":case"row-reverse":return this.width-(2*this.padding||0)||this.getChildrenSideSum("width");case"column":case"column-reverse":return this.getHighestChildSizeOn("width");default:console.error(`Invalid contentDirection : ${t}`)}}getInnerHeight(){const t=this.getContentDirection();switch(t){case"row":case"row-reverse":return this.getHighestChildSizeOn("height");case"column":case"column-reverse":return this.height-(2*this.padding||0)||this.getChildrenSideSum("height");default:console.error(`Invalid contentDirection : ${t}`)}}getChildrenSideSum(t){return this.childrenBoxes.reduce(((e,n)=>{const i=2*n.margin||0;return e+("width"===t?n.getWidth()+i:n.getHeight()+i)}),0)}setPosFromParentRecords(){this.parentUI&&this.parentUI.childrenPos[this.id]&&(this.position.x=this.parentUI.childrenPos[this.id].x,this.position.y=this.parentUI.childrenPos[this.id].y)}computeChildrenPosition(){if(this.children.length>0){const t=this.getContentDirection();let e;switch(t){case d_:e=-this.getInnerWidth()/2;break;case p_:e=this.getInnerWidth()/2;break;case f_:e=this.getInnerHeight()/2;break;case m_:e=-this.getInnerHeight()/2}const n=-Math.sign(e);g_(this,t,e,n),R_(this,t,e,n),__(this,t)}}getHighestChildSizeOn(t){return this.childrenBoxes.reduce(((e,n)=>{const i=n.margin||0,r="width"===t?n.getWidth()+2*i:n.getHeight()+2*i;return Math.max(e,r)}),0)}getWidth(){return this.parentUI&&"stretch"===this.parentUI.getAlignItems()&&-1!==this.parentUI.getContentDirection().indexOf("column")?this.parentUI.getWidth()-(2*this.parentUI.padding||0):this.width||this.getInnerWidth()+(2*this.padding||0)}getHeight(){return this.parentUI&&"stretch"===this.parentUI.getAlignItems()&&-1!==this.parentUI.getContentDirection().indexOf("row")?this.parentUI.getHeight()-(2*this.parentUI.padding||0):this.height||this.getInnerHeight()+(2*this.padding||0)}}}const L_={"\t":"\t","\n":"\n","\r":"\r"," ":" "},U_="normal",N_="nowrap",F_="pre",O_="pre-line",k_="pre-wrap",Q_=function(t,e){switch(e){case N_:case U_:t=t.replace(/\n/g," ");case O_:t=t.replace(/[ ]{2,}/g," ")}return t},z_=function(t){switch(t){case F_:case k_:case O_:return"mandatory"}},G_=function(t,e,n,i){const r=t[e];switch(i.WHITESPACE){case U_:case O_:case k_:if("mandatory"===r.lineBreak)return!0;const s=r.kerning?r.kerning:0,a=r.xoffset?r.xoffset:0;if(n+(r.xadvance?r.xadvance:r.width)+a+s>i.INNER_WIDTH)return!0;const o=j_(t,e,i);return function(t,e,n,i){return!(!t||!t.glyph)&&!(e+n-1}(t[e-1],n,o,i);case F_:return"mandatory"===r.lineBreak;default:return!1}},H_=function(t,e){const n=t[0],i=t[t.length-1];switch(e){case k_:n.glyph&&"\n"===n.glyph&&t.length>1&&W_([n],t[1]),i.glyph&&"\n"===i.glyph&&t.length>1&&V_([i],t[t.length-2]);break;case O_:case N_:case U_:let r,s=[];for(let e=0;ee))break;s.push(n),r=t[e+1]}W_(s,r),s=[],r=null;for(let e=t.length-1;e>0;e--){const n=t[e];if(!(n.glyph&&L_[n.glyph]&&e>0))break;s.push(n),r=t[e-1]}V_(s,r);break;case F_:break;default:return console.warn(`whiteSpace: '${e}' is not valid`),0}return n.offsetX};function V_(t,e){if(e)for(let n=0;n{switch(e){case K_:case J_:case q_:return-n/2;case Z_:case X_:return-t.width+n/2;case Y_:return-t.width/2;case $_:return i?-t.width/2:-n/2;default:console.warn(`textAlign: '${e}' is not valid`)}};function nw(t){return class extends t{computeInlinesPosition(){const t=this.getWidth()-(2*this.padding||0),e=this.getHeight()-(2*this.padding||0),n=this.getJustifyContent(),i=this.getTextAlign(),r=this.getInterLine(),s=this.computeLines();s.interLine=r;const a=Math.abs(s.height),o=(()=>{switch(n){case"start":return e/2;case"end":return a-e/2;case"center":return a/2;default:console.warn(`justifyContent: '${n}' is not valid`)}})();s.forEach((t=>{t.y+=o,t.forEach((t=>{t.offsetY+=o}))})),tw(s,i,t),this.lines=s}calculateBestFit(t){if(0!==this.childrenInlines.length)switch(t){case"grow":this.calculateGrowFit();break;case"shrink":this.calculateShrinkFit();break;case"auto":this.calculateAutoFit()}}calculateGrowFit(){const t=this.getHeight()-(2*this.padding||0);let e=1;const n=this.childrenInlines.find((t=>t.isText));let i,r=1,s=2,a=n._fitFontSize?n._fitFontSize/n.getFontSize():1;do{if(i=this.calculateHeight(a),i>t){if(a<=r){this.childrenInlines.forEach((t=>{t.isInlineBlock||(t._fitFontSize=t.getFontSize())}));break}s=a,a-=(s-r)/2}else{if(Math.abs(t-i)<.075)break;Math.abs(a-s)<5e-10&&(s*=2),r=a,a+=(s-r)/2}}while(++e<=10)}calculateShrinkFit(){const t=this.getHeight()-(2*this.padding||0);let e=1;const n=this.childrenInlines.find((t=>t.isText));let i,r=0,s=1,a=n._fitFontSize?n._fitFontSize/n.getFontSize():1;do{if(i=this.calculateHeight(a),i>t)s=a,a-=(s-r)/2;else{if(a>=s){this.childrenInlines.forEach((t=>{t.isInlineBlock||(t._fitFontSize=t.getFontSize())}));break}if(Math.abs(t-i)<.075)break;r=a,a+=(s-r)/2}}while(++e<=10)}calculateAutoFit(){const t=this.getHeight()-(2*this.padding||0);let e=1;const n=this.childrenInlines.find((t=>t.isText));let i,r=0,s=2,a=n._fitFontSize?n._fitFontSize/n.getFontSize():1;do{if(i=this.calculateHeight(a),i>t)s=a,a-=(s-r)/2;else{if(Math.abs(t-i)<.075)break;Math.abs(a-s)<5e-10&&(s*=2),r=a,a+=(s-r)/2}}while(++e<=10)}computeLines(){const t=this.getWidth()-(2*this.padding||0),e=[[]];e.height=0;const n=this.getInterLine();this.childrenInlines.reduce(((n,i)=>{if(!i.inlines)return;const r=i._fitFontSize||i.getFontSize(),s=i.isText?i.getLetterSpacing()*r:0,a=i.getWhiteSpace(),o=i.getBreakOn(),l={WHITESPACE:a,LETTERSPACING:s,BREAKON:o,INNER_WIDTH:t},c=i.inlines.reduce(((t,n,i,r)=>{const a=n.kerning?n.kerning:0,o=n.xoffset?n.xoffset:0,c=n.xadvance?n.xadvance:n.width;return G_(r,i,t,l)?(e.push([n]),n.offsetX=o,0===n.width?0:c+s):(e[e.length-1].push(n),n.offsetX=t+o+a,t+c+a+s)}),n);return c}),0);let i=0,r=0,s=-n/2;return e.forEach((t=>{if(t.lineHeight=t.reduce(((t,e)=>{const n=void 0!==e.lineHeight?e.lineHeight:e.height;return Math.max(t,n)}),0),t.lineBase=t.reduce(((t,e)=>{const n=void 0!==e.lineBase?e.lineBase:e.height;return Math.max(t,n)}),0),t.width=0,t.height=t.lineHeight,t[0]){const e=this.getWhiteSpace(),a=H_(t,e);t.forEach((t=>{t.offsetX-=a})),t.width=this.computeLineWidth(t),t.width>i&&(i=t.width),t.forEach((e=>{e.offsetY=s-e.height-e.anchor,e.lineHeight{e.isInlineBlock||(e._fitFontSize=e.getFontSize()*t,e.calculateInlines(e._fitFontSize))}));const e=this.computeLines();return Math.abs(e.height)}computeLineWidth(t){const e=t[0],n=t[t.length-1];return n.offsetX+n.width+e.offsetX}}}const iw=new ip,rw=[],sw={},aw=new cp,ow=[],lw={},cw={};function hw(t){if(t._kernings)return;const e={};for(let n=0;n{const n=JSON.parse(t);hw(n),sw[e]=n;for(const t of Object.keys(cw))e===cw[t].jsonURL&&cw[t].component._updateFontFamily(n)}))),cw[t.id]||(cw[t.id]={component:t}),cw[t.id].jsonURL=e,sw[e]&&t._updateFontFamily(sw[e])}(t,e):(cw[t.id]||(cw[t.id]={component:t}),hw(e),cw[t.id].json=e,t._updateFontFamily(e))},setFontTexture:function(t,e){-1===ow.indexOf(e)&&(ow.push(e),aw.load(e,(t=>{t.generateMipmaps=!1,t.minFilter=Ut,t.magFilter=Ut,lw[e]=t;for(const n of Object.keys(cw))e===cw[n].textureURL&&cw[n].component._updateFontTexture(t)}))),cw[t.id]||(cw[t.id]={component:t}),cw[t.id].textureURL=e,lw[e]&&t._updateFontTexture(lw[e])},getFontOf:function t(e){const n=cw[e.id];return!n&&e.parentUI?t(e.parentUI):n},addFont:function(t,e,n){n.generateMipmaps=!1,n.minFilter=Ut,n.magFilter=Ut,rw.push(t),sw[t]=e,hw(e),n&&(ow.push(t),lw[t]=n)}};class dw{static requestUpdate(t,e,n,i){t.traverse((t=>{t.isUI&&(this.requestedUpdates[t.id]?(e&&(this.requestedUpdates[t.id].updateParsing=!0),n&&(this.requestedUpdates[t.id].updateLayout=!0),i&&(this.requestedUpdates[t.id].updateInner=!0)):this.requestedUpdates[t.id]={updateParsing:e,updateLayout:n,updateInner:i,needCallback:e||n||i})}))}static register(t){this.components.includes(t)||this.components.push(t)}static disposeOf(t){const e=this.components.indexOf(t);e>-1&&this.components.splice(e,1)}static update(){if(Object.keys(this.requestedUpdates).length>0){const t=this.components.filter((t=>!t.parentUI));t.forEach((t=>this.traverseParsing(t))),t.forEach((t=>this.traverseUpdates(t)))}}static traverseParsing(t){const e=this.requestedUpdates[t.id];e&&e.updateParsing&&(t.parseParams(),e.updateParsing=!1),t.childrenUIs.forEach((t=>this.traverseParsing(t)))}static traverseUpdates(t){const e=this.requestedUpdates[t.id];delete this.requestedUpdates[t.id],e&&e.updateLayout&&(e.updateLayout=!1,t.updateLayout()),e&&e.updateInner&&(e.updateInner=!1,t.updateInner()),t.childrenUIs.forEach((t=>{this.traverseUpdates(t)})),e&&e.needCallback&&t.onAfterUpdate()}}dw.components=[],dw.requestedUpdates={};const pw={container:null,fontFamily:null,fontSize:.05,fontKerning:"normal",bestFit:"none",offset:.01,interLine:.01,breakOn:"- ,.:?!\n",whiteSpace:O_,contentDirection:f_,alignItems:v_,justifyContent:M_,textAlign:Y_,textType:"MSDF",fontColor:new us(16777215),fontOpacity:1,fontPXRange:4,fontSupersampling:!0,borderRadius:.01,borderWidth:0,borderColor:new us("black"),borderOpacity:1,backgroundSize:"cover",backgroundColor:new us(2236962),backgroundWhiteColor:new us(16777215),backgroundOpacity:.8,backgroundOpaqueOpacity:1,getDefaultTexture:function(){if(!fw){const t=document.createElement("canvas").getContext("2d");t.canvas.width=1,t.canvas.height=1,t.fillStyle="#ffffff",t.fillRect(0,0,1,1),fw=new Zh(t.canvas),fw.isDefault=!0}return fw},hiddenOverflow:!1,letterSpacing:0};let fw;function mw(t){return class extends t{constructor(t){super(t),this.states={},this.currentState=void 0,this.isUI=!0,this.autoLayout=!0,this.childrenUIs=[],this.childrenBoxes=[],this.childrenTexts=[],this.childrenInlines=[],this.parentUI=null,this.addEventListener("added",this._rebuildParentUI),this.addEventListener("removed",this._rebuildParentUI)}getClippingPlanes(){const t=[];if(this.parentUI){if(this.isBlock&&this.parentUI.getHiddenOverflow()){const e=this.parentUI.getHeight()/2-(this.parentUI.padding||0),n=this.parentUI.getWidth()/2-(this.parentUI.padding||0),i=[new va(new Hi(0,1,0),e),new va(new Hi(0,-1,0),e),new va(new Hi(1,0,0),n),new va(new Hi(-1,0,0),n)];i.forEach((t=>{t.applyMatrix4(this.parent.matrixWorld)})),t.push(...i)}this.parentUI.parentUI&&t.push(...this.parentUI.getClippingPlanes())}return t}getHighestParent(){return this.parentUI?this.parent.getHighestParent():this}_getProperty(t){return void 0===this[t]&&this.parentUI?this.parent._getProperty(t):void 0!==this[t]?this[t]:pw[t]}getFontSize(){return this._getProperty("fontSize")}getFontKerning(){return this._getProperty("fontKerning")}getLetterSpacing(){return this._getProperty("letterSpacing")}getFontTexture(){return void 0===this.fontTexture&&this.parentUI?this.parent._getProperty("fontTexture"):void 0!==this.fontTexture?this.fontTexture:pw.getDefaultTexture()}getFontFamily(){return this._getProperty("fontFamily")}getBreakOn(){return this._getProperty("breakOn")}getWhiteSpace(){return this._getProperty("whiteSpace")}getTextAlign(){return this._getProperty("textAlign")}getTextType(){return this._getProperty("textType")}getFontColor(){return this._getProperty("fontColor")}getFontSupersampling(){return this._getProperty("fontSupersampling")}getFontOpacity(){return this._getProperty("fontOpacity")}getFontPXRange(){return this._getProperty("fontPXRange")}getBorderRadius(){return this._getProperty("borderRadius")}getBorderWidth(){return this._getProperty("borderWidth")}getBorderColor(){return this._getProperty("borderColor")}getBorderOpacity(){return this._getProperty("borderOpacity")}getContainer(){return!this.threeOBJ&&this.parent?this.parent.getContainer():this.threeOBJ?this:pw.container}getParentsNumber(t){return t=t||0,this.parentUI?this.parentUI.getParentsNumber(t+1):t}getBackgroundOpacity(){return this.backgroundOpacity||0===this.backgroundOpacity?this.backgroundOpacity:pw.backgroundOpacity}getBackgroundColor(){return this.backgroundColor||pw.backgroundColor}getBackgroundTexture(){return this.backgroundTexture||pw.getDefaultTexture()}getAlignContent(){return this.alignContent||pw.alignContent}getAlignItems(){return this.alignItems||pw.alignItems}getContentDirection(){return this.contentDirection||pw.contentDirection}getJustifyContent(){return this.justifyContent||pw.justifyContent}getInterLine(){return void 0===this.interLine?pw.interLine:this.interLine}getOffset(){return void 0===this.offset?pw.offset:this.offset}getBackgroundSize(){return void 0===this.backgroundSize?pw.backgroundSize:this.backgroundSize}getHiddenOverflow(){return void 0===this.hiddenOverflow?pw.hiddenOverflow:this.hiddenOverflow}getBestFit(){return void 0===this.bestFit?pw.bestFit:this.bestFit}_rebuildChildrenLists(){this.childrenUIs=this.children.filter((t=>t.isUI)),this.childrenBoxes=this.children.filter((t=>t.isBoxComponent)),this.childrenInlines=this.children.filter((t=>t.isInline)),this.childrenTexts=this.children.filter((t=>t.isText))}_rebuildParentUI=()=>{this.parent&&this.parent.isUI?this.parentUI=this.parent:this.parentUI=null};add(){for(const t of Object.keys(arguments))arguments[t].isInline&&this.update(null,!0);const t=super.add(...arguments);return this._rebuildChildrenLists(),t}remove(){for(const t of Object.keys(arguments))arguments[t].isInline&&this.update(null,!0);const t=super.remove(...arguments);return this._rebuildChildrenLists(),t}update(t,e,n){dw.requestUpdate(this,t,e,n)}onAfterUpdate(){}_updateFontFamily(t){this.fontFamily=t,this.traverse((t=>{t.isUI&&t.update(!0,!0,!1)})),this.getHighestParent().update(!1,!0,!1)}_updateFontTexture(t){this.fontTexture=t,this.getHighestParent().update(!1,!0,!1)}set(t){let e,n,i;if(dw.register(this),t&&JSON.stringify(t)!==JSON.stringify({})){t.alignContent&&(t.alignItems=t.alignContent,t.textAlign||(t.textAlign=t.alignContent),console.warn("`alignContent` property has been deprecated, please rely on `alignItems` and `textAlign` instead."),delete t.alignContent),t.alignItems&&w_(t.alignItems);for(const r of Object.keys(t))if(this[r]!=t[r])switch(r){case"content":case"fontSize":case"fontKerning":case"breakOn":case"whiteSpace":this.isText&&(e=!0),n=!0,this[r]=t[r];break;case"bestFit":this.isBlock&&(e=!0,n=!0),this[r]=t[r];break;case"width":case"height":case"padding":(this.isInlineBlock||this.isBlock&&"none"!=this.getBestFit())&&(e=!0),n=!0,this[r]=t[r];break;case"letterSpacing":case"interLine":this.isBlock&&"none"!=this.getBestFit()&&(e=!0),n=!0,this[r]=t[r];break;case"margin":case"contentDirection":case"justifyContent":case"alignContent":case"alignItems":case"textAlign":case"textType":n=!0,this[r]=t[r];break;case"fontColor":case"fontOpacity":case"fontSupersampling":case"offset":case"backgroundColor":case"backgroundOpacity":case"backgroundTexture":case"backgroundSize":case"borderRadius":case"borderWidth":case"borderColor":case"borderOpacity":i=!0,this[r]=t[r];break;case"hiddenOverflow":this[r]=t[r]}t.fontFamily&&uw.setFontFamily(this,t.fontFamily),t.fontTexture&&uw.setFontTexture(this,t.fontTexture),this.parentUI&&"none"!=this.parentUI.getBestFit()&&this.parentUI.update(!0,!0,!1),this.update(e,n,i),n&&this.getHighestParent().update(!1,!0,!1)}}setupState(t){this.states[t.state]={attributes:t.attributes,onSet:t.onSet}}setState(t){const e=this.states[t];e?t!==this.currentState&&(this.currentState=t,e.onSet&&e.onSet(),e.attributes&&this.set(e.attributes)):console.warn(`state "${t}" does not exist within this component:`,this.name)}clear(){this.traverse((t=>{dw.disposeOf(t),t.material&&t.material.dispose(),t.geometry&&t.geometry.dispose()}))}}}function gw(t){return class extends t{constructor(t){super(t),this.textUniforms={u_texture:{value:this.getFontTexture()},u_color:{value:this.getFontColor()},u_opacity:{value:this.getFontOpacity()},u_pxRange:{value:this.getFontPXRange()},u_useRGSS:{value:this.getFontSupersampling()}},this.backgroundUniforms={u_texture:{value:this.getBackgroundTexture()},u_color:{value:this.getBackgroundColor()},u_opacity:{value:this.getBackgroundOpacity()},u_backgroundMapping:{value:this.getBackgroundSize()},u_borderWidth:{value:this.getBorderWidth()},u_borderColor:{value:this.getBorderColor()},u_borderRadiusTopLeft:{value:this.getBorderRadius()},u_borderRadiusTopRight:{value:this.getBorderRadius()},u_borderRadiusBottomRight:{value:this.getBorderRadius()},u_borderRadiusBottomLeft:{value:this.getBorderRadius()},u_borderOpacity:{value:this.getBorderOpacity()},u_size:{value:new hi(1,1)},u_tSize:{value:new hi(1,1)}}}updateBackgroundMaterial(){this.backgroundUniforms.u_texture.value=this.getBackgroundTexture(),this.backgroundUniforms.u_tSize.value.set(this.backgroundUniforms.u_texture.value.image.width,this.backgroundUniforms.u_texture.value.image.height),this.size&&this.backgroundUniforms.u_size.value.copy(this.size),this.backgroundUniforms.u_texture.value.isDefault?(this.backgroundUniforms.u_color.value=this.getBackgroundColor(),this.backgroundUniforms.u_opacity.value=this.getBackgroundOpacity()):(this.backgroundUniforms.u_color.value=this.backgroundColor||pw.backgroundWhiteColor,this.backgroundUniforms.u_opacity.value=this.backgroundOpacity||0===this.backgroundOpacity?this.backgroundOpacity:pw.backgroundOpaqueOpacity),this.backgroundUniforms.u_backgroundMapping.value=(()=>{switch(this.getBackgroundSize()){case"stretch":return 0;case"contain":return 1;case"cover":return 2}})();const t=this.getBorderRadius();this.backgroundUniforms.u_borderWidth.value=this.getBorderWidth(),this.backgroundUniforms.u_borderColor.value=this.getBorderColor(),this.backgroundUniforms.u_borderOpacity.value=this.getBorderOpacity(),Array.isArray(t)?(this.backgroundUniforms.u_borderRadiusTopLeft.value=t[0],this.backgroundUniforms.u_borderRadiusTopRight.value=t[1],this.backgroundUniforms.u_borderRadiusBottomRight.value=t[2],this.backgroundUniforms.u_borderRadiusBottomLeft.value=t[3]):(this.backgroundUniforms.u_borderRadiusTopLeft.value=t,this.backgroundUniforms.u_borderRadiusTopRight.value=t,this.backgroundUniforms.u_borderRadiusBottomRight.value=t,this.backgroundUniforms.u_borderRadiusBottomLeft.value=t)}updateTextMaterial(){this.textUniforms.u_texture.value=this.getFontTexture(),this.textUniforms.u_color.value=this.getFontColor(),this.textUniforms.u_opacity.value=this.getFontOpacity(),this.textUniforms.u_pxRange.value=this.getFontPXRange(),this.textUniforms.u_useRGSS.value=this.getFontSupersampling()}getBackgroundMaterial(){return this.backgroundMaterial&&this.backgroundUniforms||(this.backgroundMaterial=this._makeBackgroundMaterial()),this.backgroundMaterial}getFontMaterial(){return this.fontMaterial&&this.textUniforms||(this.fontMaterial=this._makeTextMaterial()),this.fontMaterial}_makeTextMaterial(){return new sa({uniforms:this.textUniforms,transparent:!0,clipping:!0,vertexShader:Aw,fragmentShader:vw,extensions:{derivatives:!0}})}_makeBackgroundMaterial(){return new sa({uniforms:this.backgroundUniforms,transparent:!0,clipping:!0,vertexShader:yw,fragmentShader:xw,extensions:{derivatives:!0}})}updateClippingPlanes(t){const e=void 0!==t?t:this.getClippingPlanes();JSON.stringify(e)!==JSON.stringify(this.clippingPlanes)&&(this.clippingPlanes=e,this.fontMaterial&&(this.fontMaterial.clippingPlanes=this.clippingPlanes),this.backgroundMaterial&&(this.backgroundMaterial.clippingPlanes=this.clippingPlanes))}}}const Aw="\nvarying vec2 vUv;\n\n#include \n\nvoid main() {\n\n\tvUv = uv;\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;\n\tgl_Position.z -= 0.00001;\n\n\t#include \n\n}\n",vw="\n\nuniform sampler2D u_texture;\nuniform vec3 u_color;\nuniform float u_opacity;\nuniform float u_pxRange;\nuniform bool u_useRGSS;\n\nvarying vec2 vUv;\n\n#include \n\n// functions from the original msdf repo:\n// https://github.com/Chlumsky/msdfgen#using-a-multi-channel-distance-field\n\nfloat median(float r, float g, float b) {\n\treturn max(min(r, g), min(max(r, g), b));\n}\n\nfloat screenPxRange() {\n\tvec2 unitRange = vec2(u_pxRange)/vec2(textureSize(u_texture, 0));\n\tvec2 screenTexSize = vec2(1.0)/fwidth(vUv);\n\treturn max(0.5*dot(unitRange, screenTexSize), 1.0);\n}\n\nfloat tap(vec2 offsetUV) {\n\tvec3 msd = texture( u_texture, offsetUV ).rgb;\n\tfloat sd = median(msd.r, msd.g, msd.b);\n\tfloat screenPxDistance = screenPxRange() * (sd - 0.5);\n\tfloat alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);\n\treturn alpha;\n}\n\nvoid main() {\n\n\tfloat alpha;\n\n\tif ( u_useRGSS ) {\n\n\t\t// shader-based supersampling based on https://bgolus.medium.com/sharper-mipmapping-using-shader-based-supersampling-ed7aadb47bec\n\t\t// per pixel partial derivatives\n\t\tvec2 dx = dFdx(vUv);\n\t\tvec2 dy = dFdy(vUv);\n\n\t\t// rotated grid uv offsets\n\t\tvec2 uvOffsets = vec2(0.125, 0.375);\n\t\tvec2 offsetUV = vec2(0.0, 0.0);\n\n\t\t// supersampled using 2x2 rotated grid\n\t\talpha = 0.0;\n\t\toffsetUV.xy = vUv + uvOffsets.x * dx + uvOffsets.y * dy;\n\t\talpha += tap(offsetUV);\n\t\toffsetUV.xy = vUv - uvOffsets.x * dx - uvOffsets.y * dy;\n\t\talpha += tap(offsetUV);\n\t\toffsetUV.xy = vUv + uvOffsets.y * dx - uvOffsets.x * dy;\n\t\talpha += tap(offsetUV);\n\t\toffsetUV.xy = vUv - uvOffsets.y * dx + uvOffsets.x * dy;\n\t\talpha += tap(offsetUV);\n\t\talpha *= 0.25;\n\n\t} else {\n\n\t\talpha = tap( vUv );\n\n\t}\n\n\n\t// apply the opacity\n\talpha *= u_opacity;\n\n\t// this is useful to avoid z-fighting when quads overlap because of kerning\n\tif ( alpha < 0.02) discard;\n\n\n\tgl_FragColor = vec4( u_color, alpha );\n\n\t#include \n\n}\n",yw="\nvarying vec2 vUv;\n\n#include \n\nvoid main() {\n\n\tvUv = uv;\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;\n\n\t#include \n\n}\n",xw="\n\nuniform sampler2D u_texture;\nuniform vec3 u_color;\nuniform float u_opacity;\n\nuniform float u_borderRadiusTopLeft;\nuniform float u_borderRadiusTopRight;\nuniform float u_borderRadiusBottomLeft;\nuniform float u_borderRadiusBottomRight;\nuniform float u_borderWidth;\nuniform vec3 u_borderColor;\nuniform float u_borderOpacity;\nuniform vec2 u_size;\nuniform vec2 u_tSize;\nuniform int u_backgroundMapping;\n\nvarying vec2 vUv;\n\n#include \n\nfloat getEdgeDist() {\n\tvec2 ndc = vec2( vUv.x * 2.0 - 1.0, vUv.y * 2.0 - 1.0 );\n\tvec2 planeSpaceCoord = vec2( u_size.x * 0.5 * ndc.x, u_size.y * 0.5 * ndc.y );\n\tvec2 corner = u_size * 0.5;\n\tvec2 offsetCorner = corner - abs( planeSpaceCoord );\n\tfloat innerRadDist = min( offsetCorner.x, offsetCorner.y ) * -1.0;\n\tif (vUv.x < 0.5 && vUv.y >= 0.5) {\n\t\tfloat roundedDist = length( max( abs( planeSpaceCoord ) - u_size * 0.5 + u_borderRadiusTopLeft, 0.0 ) ) - u_borderRadiusTopLeft;\n\t\tfloat s = step( innerRadDist * -1.0, u_borderRadiusTopLeft );\n\t\treturn mix( innerRadDist, roundedDist, s );\n\t}\n\tif (vUv.x >= 0.5 && vUv.y >= 0.5) {\n\t\tfloat roundedDist = length( max( abs( planeSpaceCoord ) - u_size * 0.5 + u_borderRadiusTopRight, 0.0 ) ) - u_borderRadiusTopRight;\n\t\tfloat s = step( innerRadDist * -1.0, u_borderRadiusTopRight );\n\t\treturn mix( innerRadDist, roundedDist, s );\n\t}\n\tif (vUv.x >= 0.5 && vUv.y < 0.5) {\n\t\tfloat roundedDist = length( max( abs( planeSpaceCoord ) - u_size * 0.5 + u_borderRadiusBottomRight, 0.0 ) ) - u_borderRadiusBottomRight;\n\t\tfloat s = step( innerRadDist * -1.0, u_borderRadiusBottomRight );\n\t\treturn mix( innerRadDist, roundedDist, s );\n\t}\n\tif (vUv.x < 0.5 && vUv.y < 0.5) {\n\t\tfloat roundedDist = length( max( abs( planeSpaceCoord ) - u_size * 0.5 + u_borderRadiusBottomLeft, 0.0 ) ) - u_borderRadiusBottomLeft;\n\t\tfloat s = step( innerRadDist * -1.0, u_borderRadiusBottomLeft );\n\t\treturn mix( innerRadDist, roundedDist, s );\n\t}\n}\n\nvec4 sampleTexture() {\n\tfloat textureRatio = u_tSize.x / u_tSize.y;\n\tfloat panelRatio = u_size.x / u_size.y;\n\tvec2 uv = vUv;\n\tif ( u_backgroundMapping == 1 ) { // contain\n\t\tif ( textureRatio < panelRatio ) { // repeat on X\n\t\t\tfloat newX = uv.x * ( panelRatio / textureRatio );\n\t\t\tnewX += 0.5 - 0.5 * ( panelRatio / textureRatio );\n\t\t\tuv.x = newX;\n\t\t} else { // repeat on Y\n\t\t\tfloat newY = uv.y * ( textureRatio / panelRatio );\n\t\t\tnewY += 0.5 - 0.5 * ( textureRatio / panelRatio );\n\t\t\tuv.y = newY;\n\t\t}\n\t} else if ( u_backgroundMapping == 2 ) { // cover\n\t\tif ( textureRatio < panelRatio ) { // stretch on Y\n\t\t\tfloat newY = uv.y * ( textureRatio / panelRatio );\n\t\t\tnewY += 0.5 - 0.5 * ( textureRatio / panelRatio );\n\t\t\tuv.y = newY;\n\t\t} else { // stretch on X\n\t\t\tfloat newX = uv.x * ( panelRatio / textureRatio );\n\t\t\tnewX += 0.5 - 0.5 * ( panelRatio / textureRatio );\n\t\t\tuv.x = newX;\n\t\t}\n\t}\n\treturn texture2D( u_texture, uv ).rgba;\n}\n\nvoid main() {\n\n\tfloat edgeDist = getEdgeDist();\n\tfloat change = fwidth( edgeDist );\n\n\tvec4 textureSample = sampleTexture();\n\tvec3 blendedColor = textureSample.rgb * u_color;\n\n\tfloat alpha = smoothstep( change, 0.0, edgeDist );\n\tfloat blendedOpacity = u_opacity * textureSample.a * alpha;\n\n\tvec4 frameColor = vec4( blendedColor, blendedOpacity );\n\n\tif ( u_borderWidth <= 0.0 ) {\n\t\tgl_FragColor = frameColor;\n\t} else {\n\t\tvec4 borderColor = vec4( u_borderColor, u_borderOpacity * alpha );\n\t\tfloat stp = smoothstep( edgeDist + change, edgeDist, u_borderWidth * -1.0 );\n\t\tgl_FragColor = mix( frameColor, borderColor, stp );\n\t}\n\n\t#include \n}\n";class _w extends Zs{constructor(t){super(new Ea,t),this.castShadow=!0,this.receiveShadow=!0,this.name="MeshUI-Frame"}}let ww=null;function Cw(...t){if(!ww)throw new Error("Cannot use mixins with Base null");let e=ww;ww=null;let n,i=t.length;for(;--i>=0;)n=t[i],e=n(e);return e}Cw.withBase=t=>(ww=t,Cw);class Ew extends(Cw.withBase(jr)(P_,nw,gw,mw)){constructor(t){super(t),this.isBlock=!0,this.size=new hi(1,1),this.frame=new _w(this.getBackgroundMaterial()),this.frame.onBeforeRender=()=>{this.updateClippingPlanes&&this.updateClippingPlanes()},this.add(this.frame),this.set(t)}parseParams(){const t=this.getBestFit();"none"!=t&&this.childrenTexts.length?this.calculateBestFit(t):this.childrenTexts.forEach((t=>{t._fitFontSize=void 0}))}updateLayout(){const t=this.getWidth(),e=this.getHeight();t&&e?(this.size.set(t,e),this.frame.scale.set(t,e,1),this.frame&&this.updateBackgroundMaterial(),this.frame.renderOrder=this.getParentsNumber(),this.autoLayout&&this.setPosFromParentRecords(),this.childrenInlines.length&&this.computeInlinesPosition(),this.computeChildrenPosition(),this.parentUI&&(this.position.z=this.getOffset())):console.warn("Block got no dimension from its parameters or from children parameters")}updateInner(){this.parentUI&&(this.position.z=this.getOffset()),this.frame&&this.updateBackgroundMaterial()}}function Mw(t){return class extends t{constructor(t){super(t),this.isInline=!0}}}class bw extends Ea{constructor(t,e){const n=t.glyph,i=t.fontSize;super(t.width,t.height),null===n.match(/\s/g)?(-1===e.info.charset.indexOf(n)&&console.error(`The character '${n}' is not included in the font characters set.`),this.mapUVs(e,n),this.transformGeometry(t)):(this.nullifyUVs(),this.scale(0,0,1),this.translate(0,i/2,0))}mapUVs(t,e){const n=t.chars.find((t=>t.char===e)),i=t.common,r=n.x/i.scaleW,s=(n.x+n.width)/i.scaleW,a=1-(n.y+n.height)/i.scaleH,o=1-n.y/i.scaleH,l=this.attributes.uv;for(let t=0;t{switch(t){case 0:return[r,o];case 1:return[s,o];case 2:return[r,a];case 3:return[s,a]}})(),l.setXY(t,e,n)}}nullifyUVs(){const t=this.attributes.uv;for(let e=0;et.char===i));let a=s?s.width*r:n/3,o=s?s.height*r:0;0===a&&(a=s?s.xadvance*r:n),0===o&&(o=.7*n),"\n"===i&&(a=0);const l=s?s.xadvance*r:a,c=s?s.xoffset*r:0;return{width:a,height:o,anchor:s?s.yoffset*r:0,xadvance:l,xoffset:c}},getGlyphPairKerning:function(t,e){const n=t._kernings;return n[e]?n[e]:0},buildText:function(){const t=[];this.inlines.forEach(((e,n)=>{t[n]=new bw(e,this.getFontFamily()),t[n].translate(e.offsetX,e.offsetY,0)}));const e=Rg(t);return new Zs(e,this.getFontMaterial())}};function Iw(t){return class extends t{createText(){const t=this,e=(()=>{if("MSDF"===this.getTextType())return Sw.buildText.call(this);console.warn(`'${this.getTextType()}' is not a supported text type.\nSee https://github.com/felixmariotto/three-mesh-ui/wiki/Using-a-custom-text-type`)})();return e.renderOrder=1/0,e.onBeforeRender=function(){t.updateClippingPlanes&&t.updateClippingPlanes()},e}getGlyphDimensions(t){if("MSDF"===t.textType)return Sw.getGlyphDimensions(t);console.warn(`'${t.textType}' is not a supported text type.\nSee https://github.com/felixmariotto/three-mesh-ui/wiki/Using-a-custom-text-type`)}getGlyphPairKerning(t,e,n){if("MSDF"===t)return Sw.getGlyphPairKerning(e,n);console.warn(`'${t}' is not a supported text type.\nSee https://github.com/felixmariotto/three-mesh-ui/wiki/Using-a-custom-text-type`)}}}const Tw=function t(e){e.children.forEach((n=>{n.children.length>0&&t(n),e.remove(n),dw.disposeOf(n),n.material&&n.material.dispose(),n.geometry&&n.geometry.dispose()})),e.children=[]};class Bw extends(Cw.withBase(jr)(Mw,Iw,gw,mw)){constructor(t){super(t),this.isText=!0,this.set(t)}parseParams(){this.calculateInlines(this._fitFontSize||this.getFontSize())}updateLayout(){Tw(this),this.inlines&&(this.textContent=this.createText(),this.updateTextMaterial(),this.add(this.textContent)),this.position.z=this.getOffset()}updateInner(){this.position.z=this.getOffset(),this.textContent&&this.updateTextMaterial()}calculateInlines(t){const e=this.content,n=this.getFontFamily(),i=this.getBreakOn(),r=this.getTextType(),s=this.getWhiteSpace();if(!n||"string"==typeof n)return void(uw.getFontOf(this)||console.warn("no font was found"));if(!this.content)return void(this.inlines=null);if(!r)return void console.error("You must provide a 'textType' attribute so three-mesh-ui knows how to render your text.\n See https://github.com/felixmariotto/three-mesh-ui/wiki/Using-a-custom-text-type");const a=Q_(e,s),o=Array.from?Array.from(a):String(a).split(""),l=t/n.info.size,c=n.common.lineHeight*l,h=n.common.base*l,u=o.map((e=>{const a=this.getGlyphDimensions({textType:r,glyph:e,font:n,fontSize:t});let o=null;return s!==N_&&(i.includes(e)||e.match(/\s/g))&&(o="possible"),e.match(/\n/g)&&(o=z_(s)),{height:a.height,width:a.width,anchor:a.anchor,xadvance:a.xadvance,xoffset:a.xoffset,lineBreak:o,glyph:e,fontSize:t,lineHeight:c,lineBase:h}}));if("none"!==this.getFontKerning())for(let e=1;e{this.updateClippingPlanes&&this.updateClippingPlanes()},this.add(this.frame),this.set(t)}parseParams(){this.width||console.warn("inlineBlock has no width. Set to 0.3 by default"),this.height||console.warn("inlineBlock has no height. Set to 0.3 by default"),this.inlines=[{height:this.height||.3,width:this.width||.3,anchor:0,lineBreak:"possible"}]}updateLayout(){const t=this.getWidth(),e=this.getHeight();if(this.inlines){const t=this.inlines[0];this.position.set(t.width/2,t.height/2,0),this.position.x+=t.offsetX,this.position.y+=t.offsetY}this.size.set(t,e),this.frame.scale.set(t,e,1),this.frame&&this.updateBackgroundMaterial(),this.frame.renderOrder=this.getParentsNumber(),this.childrenInlines.length&&this.computeInlinesPosition(),this.computeChildrenPosition(),this.position.z=this.getOffset()}updateInner(){this.position.z=this.getOffset(),this.frame&&this.updateBackgroundMaterial()}}const Dw=[[[{width:.1,chars:[{lowerCase:"a",upperCase:"A"}]},{width:.1,chars:[{lowerCase:"z",upperCase:"Z"}]},{width:.1,chars:[{lowerCase:"e",upperCase:"E"}]},{width:.1,chars:[{lowerCase:"r",upperCase:"R"}]},{width:.1,chars:[{lowerCase:"t",upperCase:"T"}]},{width:.1,chars:[{lowerCase:"y",upperCase:"Y"}]},{width:.1,chars:[{lowerCase:"u",upperCase:"U"}]},{width:.1,chars:[{lowerCase:"i",upperCase:"I"}]},{width:.1,chars:[{lowerCase:"o",upperCase:"O"}]},{width:.1,chars:[{lowerCase:"p",upperCase:"P"}]}],[{width:.1,chars:[{lowerCase:"q",upperCase:"Q"}]},{width:.1,chars:[{lowerCase:"s",upperCase:"S"}]},{width:.1,chars:[{lowerCase:"d",upperCase:"D"}]},{width:.1,chars:[{lowerCase:"f",upperCase:"F"}]},{width:.1,chars:[{lowerCase:"g",upperCase:"G"}]},{width:.1,chars:[{lowerCase:"h",upperCase:"H"}]},{width:.1,chars:[{lowerCase:"j",upperCase:"J"}]},{width:.1,chars:[{lowerCase:"k",upperCase:"K"}]},{width:.1,chars:[{lowerCase:"l",upperCase:"L"}]},{width:.1,chars:[{lowerCase:"m",upperCase:"M"}]}],[{width:.2,command:"shift",chars:[{icon:"shift"}]},{width:.1,chars:[{lowerCase:"w",upperCase:"W"}]},{width:.1,chars:[{lowerCase:"x",upperCase:"X"}]},{width:.1,chars:[{lowerCase:"c",upperCase:"C"}]},{width:.1,chars:[{lowerCase:"v",upperCase:"V"}]},{width:.1,chars:[{lowerCase:"b",upperCase:"B"}]},{width:.1,chars:[{lowerCase:"n",upperCase:"N"}]},{width:.2,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]],[[{width:.1,chars:[{lowerCase:"1"}]},{width:.1,chars:[{lowerCase:"2"}]},{width:.1,chars:[{lowerCase:"3"}]},{width:.1,chars:[{lowerCase:"4"}]},{width:.1,chars:[{lowerCase:"5"}]},{width:.1,chars:[{lowerCase:"6"}]},{width:.1,chars:[{lowerCase:"7"}]},{width:.1,chars:[{lowerCase:"8"}]},{width:.1,chars:[{lowerCase:"9"}]},{width:.1,chars:[{lowerCase:"0"}]}],[{width:.1,chars:[{lowerCase:"@"}]},{width:.1,chars:[{lowerCase:"#"}]},{width:.1,chars:[{lowerCase:"|"}]},{width:.1,chars:[{lowerCase:"_"}]},{width:.1,chars:[{lowerCase:"&"}]},{width:.1,chars:[{lowerCase:"-"}]},{width:.1,chars:[{lowerCase:"+"}]},{width:.1,chars:[{lowerCase:"("}]},{width:.1,chars:[{lowerCase:")"}]},{width:.1,chars:[{lowerCase:"/"}]}],[{width:.1,chars:[{lowerCase:"="}]},{width:.1,chars:[{lowerCase:"*"}]},{width:.1,chars:[{lowerCase:'"'}]},{width:.1,chars:[{lowerCase:"'"}]},{width:.1,chars:[{lowerCase:":"}]},{width:.1,chars:[{lowerCase:";"}]},{width:.1,chars:[{lowerCase:"!"}]},{width:.1,chars:[{lowerCase:"?"}]},{width:.2,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]]],Pw=[[[{width:.1,chars:[{lowerCase:"q",upperCase:"Q"}]},{width:.1,chars:[{lowerCase:"w",upperCase:"W"}]},{width:.1,chars:[{lowerCase:"e",upperCase:"E"}]},{width:.1,chars:[{lowerCase:"r",upperCase:"R"}]},{width:.1,chars:[{lowerCase:"t",upperCase:"T"}]},{width:.1,chars:[{lowerCase:"y",upperCase:"Y"}]},{width:.1,chars:[{lowerCase:"u",upperCase:"U"}]},{width:.1,chars:[{lowerCase:"i",upperCase:"I"}]},{width:.1,chars:[{lowerCase:"o",upperCase:"O"}]},{width:.1,chars:[{lowerCase:"p",upperCase:"P"}]}],[{width:.1,chars:[{lowerCase:"a",upperCase:"A"}]},{width:.1,chars:[{lowerCase:"s",upperCase:"S"}]},{width:.1,chars:[{lowerCase:"d",upperCase:"D"}]},{width:.1,chars:[{lowerCase:"f",upperCase:"F"}]},{width:.1,chars:[{lowerCase:"g",upperCase:"G"}]},{width:.1,chars:[{lowerCase:"h",upperCase:"H"}]},{width:.1,chars:[{lowerCase:"j",upperCase:"J"}]},{width:.1,chars:[{lowerCase:"k",upperCase:"K"}]},{width:.1,chars:[{lowerCase:"l",upperCase:"L"}]}],[{width:.15,command:"shift",chars:[{icon:"shift"}]},{width:.1,chars:[{lowerCase:"z",upperCase:"Z"}]},{width:.1,chars:[{lowerCase:"x",upperCase:"X"}]},{width:.1,chars:[{lowerCase:"c",upperCase:"C"}]},{width:.1,chars:[{lowerCase:"v",upperCase:"V"}]},{width:.1,chars:[{lowerCase:"b",upperCase:"B"}]},{width:.1,chars:[{lowerCase:"n",upperCase:"N"}]},{width:.1,chars:[{lowerCase:"m",upperCase:"M"}]},{width:.15,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]],[[{width:.1,chars:[{lowerCase:"1"}]},{width:.1,chars:[{lowerCase:"2"}]},{width:.1,chars:[{lowerCase:"3"}]},{width:.1,chars:[{lowerCase:"4"}]},{width:.1,chars:[{lowerCase:"5"}]},{width:.1,chars:[{lowerCase:"6"}]},{width:.1,chars:[{lowerCase:"7"}]},{width:.1,chars:[{lowerCase:"8"}]},{width:.1,chars:[{lowerCase:"9"}]},{width:.1,chars:[{lowerCase:"0"}]}],[{width:.1,chars:[{lowerCase:"@"}]},{width:.1,chars:[{lowerCase:"#"}]},{width:.1,chars:[{lowerCase:"|"}]},{width:.1,chars:[{lowerCase:"_"}]},{width:.1,chars:[{lowerCase:"&"}]},{width:.1,chars:[{lowerCase:"-"}]},{width:.1,chars:[{lowerCase:"+"}]},{width:.1,chars:[{lowerCase:"("}]},{width:.1,chars:[{lowerCase:")"}]},{width:.1,chars:[{lowerCase:"/"}]}],[{width:.1,chars:[{lowerCase:"="}]},{width:.1,chars:[{lowerCase:"*"}]},{width:.1,chars:[{lowerCase:'"'}]},{width:.1,chars:[{lowerCase:"'"}]},{width:.1,chars:[{lowerCase:":"}]},{width:.1,chars:[{lowerCase:";"}]},{width:.1,chars:[{lowerCase:"!"}]},{width:.1,chars:[{lowerCase:"?"}]},{width:.2,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]]],Lw=[[[{width:1/12,chars:[{lowerCase:"й",upperCase:"Й"},{lowerCase:"q",upperCase:"Q"}]},{width:1/12,chars:[{lowerCase:"ц",upperCase:"Ц"},{lowerCase:"w",upperCase:"W"}]},{width:1/12,chars:[{lowerCase:"у",upperCase:"У"},{lowerCase:"e",upperCase:"E"}]},{width:1/12,chars:[{lowerCase:"к",upperCase:"К"},{lowerCase:"r",upperCase:"R"}]},{width:1/12,chars:[{lowerCase:"е",upperCase:"Е"},{lowerCase:"t",upperCase:"T"}]},{width:1/12,chars:[{lowerCase:"н",upperCase:"Н"},{lowerCase:"y",upperCase:"Y"}]},{width:1/12,chars:[{lowerCase:"г",upperCase:"Г"},{lowerCase:"u",upperCase:"U"}]},{width:1/12,chars:[{lowerCase:"ш",upperCase:"Ш"},{lowerCase:"i",upperCase:"I"}]},{width:1/12,chars:[{lowerCase:"щ",upperCase:"Щ"},{lowerCase:"o",upperCase:"O"}]},{width:1/12,chars:[{lowerCase:"з",upperCase:"З"},{lowerCase:"p",upperCase:"P"}]},{width:1/12,chars:[{lowerCase:"х",upperCase:"Х"},{lowerCase:"{",upperCase:"["}]},{width:1/12,chars:[{lowerCase:"ъ",upperCase:"Ъ"},{lowerCase:"}",upperCase:"]"}]}],[{width:1/12,chars:[{lowerCase:"ф",upperCase:"Ф"},{lowerCase:"a",upperCase:"A"}]},{width:1/12,chars:[{lowerCase:"ы",upperCase:"Ы"},{lowerCase:"s",upperCase:"S"}]},{width:1/12,chars:[{lowerCase:"в",upperCase:"В"},{lowerCase:"d",upperCase:"D"}]},{width:1/12,chars:[{lowerCase:"а",upperCase:"А"},{lowerCase:"f",upperCase:"F"}]},{width:1/12,chars:[{lowerCase:"п",upperCase:"П"},{lowerCase:"g",upperCase:"G"}]},{width:1/12,chars:[{lowerCase:"р",upperCase:"Р"},{lowerCase:"h",upperCase:"H"}]},{width:1/12,chars:[{lowerCase:"о",upperCase:"О"},{lowerCase:"j",upperCase:"J"}]},{width:1/12,chars:[{lowerCase:"л",upperCase:"Л"},{lowerCase:"k",upperCase:"K"}]},{width:1/12,chars:[{lowerCase:"д",upperCase:"Д"},{lowerCase:"l",upperCase:"L"}]},{width:1/12,chars:[{lowerCase:"ж",upperCase:"Ж"},{lowerCase:":",upperCase:";"}]},{width:1/12,chars:[{lowerCase:"э",upperCase:"Э"},{lowerCase:'"',upperCase:"'"}]},{width:1/12,chars:[{lowerCase:"ё",upperCase:"Ё"},{lowerCase:"|",upperCase:"\\"}]}],[{width:.125,command:"shift",chars:[{icon:"shift"}]},{width:1/12,chars:[{lowerCase:"я",upperCase:"Я"},{lowerCase:"z",upperCase:"Z"}]},{width:1/12,chars:[{lowerCase:"ч",upperCase:"Ч"},{lowerCase:"x",upperCase:"X"}]},{width:1/12,chars:[{lowerCase:"с",upperCase:"С"},{lowerCase:"c",upperCase:"C"}]},{width:1/12,chars:[{lowerCase:"м",upperCase:"М"},{lowerCase:"v",upperCase:"V"}]},{width:1/12,chars:[{lowerCase:"и",upperCase:"И"},{lowerCase:"b",upperCase:"B"}]},{width:1/12,chars:[{lowerCase:"т",upperCase:"Т"},{lowerCase:"n",upperCase:"N"}]},{width:1/12,chars:[{lowerCase:"ь",upperCase:"Ь"},{lowerCase:"m",upperCase:"M"}]},{width:1/12,chars:[{lowerCase:"б",upperCase:"Б"},{lowerCase:",",upperCase:""}]},{width:1/12,chars:[{lowerCase:"ю",upperCase:"Ю"},{lowerCase:".",upperCase:""}]},{width:.125,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.15,command:"switch-set",chars:[{lowerCase:"eng"}]},{width:.15,command:"switch",chars:[{lowerCase:".?12"}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"?"}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]],[[{width:.1,chars:[{lowerCase:"1"}]},{width:.1,chars:[{lowerCase:"2"}]},{width:.1,chars:[{lowerCase:"3"}]},{width:.1,chars:[{lowerCase:"4"}]},{width:.1,chars:[{lowerCase:"5"}]},{width:.1,chars:[{lowerCase:"6"}]},{width:.1,chars:[{lowerCase:"7"}]},{width:.1,chars:[{lowerCase:"8"}]},{width:.1,chars:[{lowerCase:"9"}]},{width:.1,chars:[{lowerCase:"0"}]}],[{width:.1,chars:[{lowerCase:"@"}]},{width:.1,chars:[{lowerCase:"#"}]},{width:.1,chars:[{lowerCase:"|"}]},{width:.1,chars:[{lowerCase:"_"}]},{width:.1,chars:[{lowerCase:"&"}]},{width:.1,chars:[{lowerCase:"-"}]},{width:.1,chars:[{lowerCase:"+"}]},{width:.1,chars:[{lowerCase:"("}]},{width:.1,chars:[{lowerCase:")"}]},{width:.1,chars:[{lowerCase:"/"}]}],[{width:.1,chars:[{lowerCase:"="}]},{width:.1,chars:[{lowerCase:"*"}]},{width:.1,chars:[{lowerCase:'"'}]},{width:.1,chars:[{lowerCase:"'"}]},{width:.1,chars:[{lowerCase:":"}]},{width:.1,chars:[{lowerCase:";"}]},{width:.1,chars:[{lowerCase:"!"}]},{width:.1,chars:[{lowerCase:"?"}]},{width:.2,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.3,command:"switch",chars:[{lowerCase:"АБВ"}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]]],Uw=[[[{width:1/11,chars:[{lowerCase:"q",upperCase:"Q"}]},{width:1/11,chars:[{lowerCase:"w",upperCase:"W"}]},{width:1/11,chars:[{lowerCase:"e",upperCase:"E"}]},{width:1/11,chars:[{lowerCase:"r",upperCase:"R"}]},{width:1/11,chars:[{lowerCase:"t",upperCase:"T"}]},{width:1/11,chars:[{lowerCase:"z",upperCase:"Z"}]},{width:1/11,chars:[{lowerCase:"u",upperCase:"U"}]},{width:1/11,chars:[{lowerCase:"i",upperCase:"I"}]},{width:1/11,chars:[{lowerCase:"o",upperCase:"O"}]},{width:1/11,chars:[{lowerCase:"p",upperCase:"P"}]},{width:1/11,chars:[{lowerCase:"ü",upperCase:"Ü"}]}],[{width:1/11,chars:[{lowerCase:"a",upperCase:"A"}]},{width:1/11,chars:[{lowerCase:"s",upperCase:"S"}]},{width:1/11,chars:[{lowerCase:"d",upperCase:"D"}]},{width:1/11,chars:[{lowerCase:"f",upperCase:"F"}]},{width:1/11,chars:[{lowerCase:"g",upperCase:"G"}]},{width:1/11,chars:[{lowerCase:"h",upperCase:"H"}]},{width:1/11,chars:[{lowerCase:"j",upperCase:"J"}]},{width:1/11,chars:[{lowerCase:"k",upperCase:"K"}]},{width:1/11,chars:[{lowerCase:"l",upperCase:"L"}]},{width:1/11,chars:[{lowerCase:"ö",upperCase:"Ö"}]},{width:1/11,chars:[{lowerCase:"ä",upperCase:"Ä"}]}],[{width:2/11,command:"shift",chars:[{icon:"shift"}]},{width:1/11,chars:[{lowerCase:"y",upperCase:"Y"}]},{width:1/11,chars:[{lowerCase:"x",upperCase:"X"}]},{width:1/11,chars:[{lowerCase:"c",upperCase:"C"}]},{width:1/11,chars:[{lowerCase:"v",upperCase:"V"}]},{width:1/11,chars:[{lowerCase:"b",upperCase:"B"}]},{width:1/11,chars:[{lowerCase:"n",upperCase:"N"}]},{width:1/11,chars:[{lowerCase:"m",upperCase:"M"}]},{width:2/11,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]],[[{width:.1,chars:[{lowerCase:"1"}]},{width:.1,chars:[{lowerCase:"2"}]},{width:.1,chars:[{lowerCase:"3"}]},{width:.1,chars:[{lowerCase:"4"}]},{width:.1,chars:[{lowerCase:"5"}]},{width:.1,chars:[{lowerCase:"6"}]},{width:.1,chars:[{lowerCase:"7"}]},{width:.1,chars:[{lowerCase:"8"}]},{width:.1,chars:[{lowerCase:"9"}]},{width:.1,chars:[{lowerCase:"0"}]}],[{width:.1,chars:[{lowerCase:"@"}]},{width:.1,chars:[{lowerCase:"#"}]},{width:.1,chars:[{lowerCase:"|"}]},{width:.1,chars:[{lowerCase:"_"}]},{width:.1,chars:[{lowerCase:"&"}]},{width:.1,chars:[{lowerCase:"-"}]},{width:.1,chars:[{lowerCase:"+"}]},{width:.1,chars:[{lowerCase:"("}]},{width:.1,chars:[{lowerCase:")"}]},{width:.1,chars:[{lowerCase:"/"}]}],[{width:.1,chars:[{lowerCase:"="}]},{width:.1,chars:[{lowerCase:"*"}]},{width:.1,chars:[{lowerCase:'"'}]},{width:.1,chars:[{lowerCase:"'"}]},{width:.1,chars:[{lowerCase:":"}]},{width:.1,chars:[{lowerCase:";"}]},{width:.1,chars:[{lowerCase:"!"}]},{width:.1,chars:[{lowerCase:"?"}]},{width:.2,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]]],Nw=[[[{width:.1,chars:[{lowerCase:"q",upperCase:"Q"}]},{width:.1,chars:[{lowerCase:"w",upperCase:"W"}]},{width:.1,chars:[{lowerCase:"e",upperCase:"E"}]},{width:.1,chars:[{lowerCase:"r",upperCase:"R"}]},{width:.1,chars:[{lowerCase:"t",upperCase:"T"}]},{width:.1,chars:[{lowerCase:"y",upperCase:"Y"}]},{width:.1,chars:[{lowerCase:"u",upperCase:"U"}]},{width:.1,chars:[{lowerCase:"i",upperCase:"I"}]},{width:.1,chars:[{lowerCase:"o",upperCase:"O"}]},{width:.1,chars:[{lowerCase:"p",upperCase:"P"}]}],[{width:.1,chars:[{lowerCase:"a",upperCase:"A"}]},{width:.1,chars:[{lowerCase:"s",upperCase:"S"}]},{width:.1,chars:[{lowerCase:"d",upperCase:"D"}]},{width:.1,chars:[{lowerCase:"f",upperCase:"F"}]},{width:.1,chars:[{lowerCase:"g",upperCase:"G"}]},{width:.1,chars:[{lowerCase:"h",upperCase:"H"}]},{width:.1,chars:[{lowerCase:"j",upperCase:"J"}]},{width:.1,chars:[{lowerCase:"k",upperCase:"K"}]},{width:.1,chars:[{lowerCase:"l",upperCase:"L"}]},{width:.1,chars:[{lowerCase:"ñ",upperCase:"Ñ"}]}],[{width:.15,command:"shift",chars:[{icon:"shift"}]},{width:.1,chars:[{lowerCase:"z",upperCase:"Z"}]},{width:.1,chars:[{lowerCase:"x",upperCase:"X"}]},{width:.1,chars:[{lowerCase:"c",upperCase:"C"}]},{width:.1,chars:[{lowerCase:"v",upperCase:"V"}]},{width:.1,chars:[{lowerCase:"b",upperCase:"B"}]},{width:.1,chars:[{lowerCase:"n",upperCase:"N"}]},{width:.1,chars:[{lowerCase:"m",upperCase:"M"}]},{width:.15,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]],[[{width:.1,chars:[{lowerCase:"1"}]},{width:.1,chars:[{lowerCase:"2"}]},{width:.1,chars:[{lowerCase:"3"}]},{width:.1,chars:[{lowerCase:"4"}]},{width:.1,chars:[{lowerCase:"5"}]},{width:.1,chars:[{lowerCase:"6"}]},{width:.1,chars:[{lowerCase:"7"}]},{width:.1,chars:[{lowerCase:"8"}]},{width:.1,chars:[{lowerCase:"9"}]},{width:.1,chars:[{lowerCase:"0"}]}],[{width:.1,chars:[{lowerCase:"@"}]},{width:.1,chars:[{lowerCase:"#"}]},{width:.1,chars:[{lowerCase:"|"}]},{width:.1,chars:[{lowerCase:"_"}]},{width:.1,chars:[{lowerCase:"&"}]},{width:.1,chars:[{lowerCase:"-"}]},{width:.1,chars:[{lowerCase:"+"}]},{width:.1,chars:[{lowerCase:"("}]},{width:.1,chars:[{lowerCase:")"}]},{width:.1,chars:[{lowerCase:"/"}]}],[{width:.1,chars:[{lowerCase:"="}]},{width:.1,chars:[{lowerCase:"*"}]},{width:.1,chars:[{lowerCase:'"'}]},{width:.1,chars:[{lowerCase:"'"}]},{width:.1,chars:[{lowerCase:":"}]},{width:.1,chars:[{lowerCase:";"}]},{width:.1,chars:[{lowerCase:"!"}]},{width:.1,chars:[{lowerCase:"?"}]},{width:.2,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]]],Fw=[[[{width:.1,chars:[{lowerCase:";",upperCase:":"},{lowerCase:"q",upperCase:"Q"}]},{width:.1,chars:[{lowerCase:"ς",upperCase:"ς"},{lowerCase:"w",upperCase:"W"}]},{width:.1,chars:[{lowerCase:"ε",upperCase:"Ε"},{lowerCase:"e",upperCase:"E"}]},{width:.1,chars:[{lowerCase:"ρ",upperCase:"Ρ"},{lowerCase:"r",upperCase:"R"}]},{width:.1,chars:[{lowerCase:"τ",upperCase:"Τ"},{lowerCase:"t",upperCase:"T"}]},{width:.1,chars:[{lowerCase:"υ",upperCase:"Υ"},{lowerCase:"y",upperCase:"Y"}]},{width:.1,chars:[{lowerCase:"θ",upperCase:"Θ"},{lowerCase:"u",upperCase:"U"}]},{width:.1,chars:[{lowerCase:"ι",upperCase:"Ι"},{lowerCase:"i",upperCase:"I"}]},{width:.1,chars:[{lowerCase:"ο",upperCase:"Ο"},{lowerCase:"o",upperCase:"O"}]},{width:.1,chars:[{lowerCase:"π",upperCase:"Π"},{lowerCase:"p",upperCase:"P"}]}],[{width:.1,chars:[{lowerCase:"α",upperCase:"Α"},{lowerCase:"a",upperCase:"A"}]},{width:.1,chars:[{lowerCase:"σ",upperCase:"Σ"},{lowerCase:"s",upperCase:"S"}]},{width:.1,chars:[{lowerCase:"δ",upperCase:"Δ"},{lowerCase:"d",upperCase:"D"}]},{width:.1,chars:[{lowerCase:"φ",upperCase:"Φ"},{lowerCase:"f",upperCase:"F"}]},{width:.1,chars:[{lowerCase:"γ",upperCase:"Γ"},{lowerCase:"g",upperCase:"G"}]},{width:.1,chars:[{lowerCase:"η",upperCase:"Η"},{lowerCase:"h",upperCase:"H"}]},{width:.1,chars:[{lowerCase:"ξ",upperCase:"Ξ"},{lowerCase:"j",upperCase:"J"}]},{width:.1,chars:[{lowerCase:"κ",upperCase:"Κ"},{lowerCase:"k",upperCase:"K"}]},{width:.1,chars:[{lowerCase:"λ",upperCase:"Λ"},{lowerCase:"l",upperCase:"L"}]}],[{width:.15,command:"shift",chars:[{icon:"shift"}]},{width:.1,chars:[{lowerCase:"ζ",upperCase:"Ζ"},{lowerCase:"z",upperCase:"Z"}]},{width:.1,chars:[{lowerCase:"χ",upperCase:"Χ"},{lowerCase:"x",upperCase:"X"}]},{width:.1,chars:[{lowerCase:"ψ",upperCase:"Ψ"},{lowerCase:"c",upperCase:"C"}]},{width:.1,chars:[{lowerCase:"ω",upperCase:"Ω"},{lowerCase:"v",upperCase:"V"}]},{width:.1,chars:[{lowerCase:"β",upperCase:"Β"},{lowerCase:"b",upperCase:"B"}]},{width:.1,chars:[{lowerCase:"ν",upperCase:"Ν"},{lowerCase:"n",upperCase:"N"}]},{width:.1,chars:[{lowerCase:"μ",upperCase:"Μ"},{lowerCase:"m",upperCase:"M"}]},{width:.15,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.15,command:"switch-set",chars:[{lowerCase:"eng"}]},{width:.15,command:"switch",chars:[{lowerCase:".?12"}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"?"}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]],[[{width:.1,chars:[{lowerCase:"1"}]},{width:.1,chars:[{lowerCase:"2"}]},{width:.1,chars:[{lowerCase:"3"}]},{width:.1,chars:[{lowerCase:"4"}]},{width:.1,chars:[{lowerCase:"5"}]},{width:.1,chars:[{lowerCase:"6"}]},{width:.1,chars:[{lowerCase:"7"}]},{width:.1,chars:[{lowerCase:"8"}]},{width:.1,chars:[{lowerCase:"9"}]},{width:.1,chars:[{lowerCase:"0"}]}],[{width:.1,chars:[{lowerCase:"@"}]},{width:.1,chars:[{lowerCase:"#"}]},{width:.1,chars:[{lowerCase:"|"}]},{width:.1,chars:[{lowerCase:"_"}]},{width:.1,chars:[{lowerCase:"&"}]},{width:.1,chars:[{lowerCase:"-"}]},{width:.1,chars:[{lowerCase:"+"}]},{width:.1,chars:[{lowerCase:"("}]},{width:.1,chars:[{lowerCase:")"}]},{width:.1,chars:[{lowerCase:"/"}]}],[{width:.1,chars:[{lowerCase:"="}]},{width:.1,chars:[{lowerCase:"*"}]},{width:.1,chars:[{lowerCase:'"'}]},{width:.1,chars:[{lowerCase:"'"}]},{width:.1,chars:[{lowerCase:":"}]},{width:.1,chars:[{lowerCase:";"}]},{width:.1,chars:[{lowerCase:"!"}]},{width:.1,chars:[{lowerCase:"?"}]},{width:.2,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]]],Ow=[[[{width:1/11,chars:[{lowerCase:"q",upperCase:"Q"}]},{width:1/11,chars:[{lowerCase:"w",upperCase:"W"}]},{width:1/11,chars:[{lowerCase:"e",upperCase:"E"}]},{width:1/11,chars:[{lowerCase:"r",upperCase:"R"}]},{width:1/11,chars:[{lowerCase:"t",upperCase:"T"}]},{width:1/11,chars:[{lowerCase:"y",upperCase:"Y"}]},{width:1/11,chars:[{lowerCase:"u",upperCase:"U"}]},{width:1/11,chars:[{lowerCase:"i",upperCase:"I"}]},{width:1/11,chars:[{lowerCase:"o",upperCase:"O"}]},{width:1/11,chars:[{lowerCase:"p",upperCase:"P"}]},{width:1/11,chars:[{lowerCase:"å",upperCase:"Å"}]}],[{width:1/11,chars:[{lowerCase:"a",upperCase:"A"}]},{width:1/11,chars:[{lowerCase:"s",upperCase:"S"}]},{width:1/11,chars:[{lowerCase:"d",upperCase:"D"}]},{width:1/11,chars:[{lowerCase:"f",upperCase:"F"}]},{width:1/11,chars:[{lowerCase:"g",upperCase:"G"}]},{width:1/11,chars:[{lowerCase:"h",upperCase:"H"}]},{width:1/11,chars:[{lowerCase:"j",upperCase:"J"}]},{width:1/11,chars:[{lowerCase:"k",upperCase:"K"}]},{width:1/11,chars:[{lowerCase:"l",upperCase:"L"}]},{width:1/11,chars:[{lowerCase:"æ",upperCase:"Æ"}]},{width:1/11,chars:[{lowerCase:"ø",upperCase:"Ø"}]}],[{width:2/11,command:"shift",chars:[{icon:"shift"}]},{width:1/11,chars:[{lowerCase:"z",upperCase:"Z"}]},{width:1/11,chars:[{lowerCase:"x",upperCase:"X"}]},{width:1/11,chars:[{lowerCase:"c",upperCase:"C"}]},{width:1/11,chars:[{lowerCase:"v",upperCase:"V"}]},{width:1/11,chars:[{lowerCase:"b",upperCase:"B"}]},{width:1/11,chars:[{lowerCase:"n",upperCase:"N"}]},{width:1/11,chars:[{lowerCase:"m",upperCase:"M"}]},{width:2/11,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]],[[{width:.1,chars:[{lowerCase:"1"}]},{width:.1,chars:[{lowerCase:"2"}]},{width:.1,chars:[{lowerCase:"3"}]},{width:.1,chars:[{lowerCase:"4"}]},{width:.1,chars:[{lowerCase:"5"}]},{width:.1,chars:[{lowerCase:"6"}]},{width:.1,chars:[{lowerCase:"7"}]},{width:.1,chars:[{lowerCase:"8"}]},{width:.1,chars:[{lowerCase:"9"}]},{width:.1,chars:[{lowerCase:"0"}]}],[{width:.1,chars:[{lowerCase:"@"}]},{width:.1,chars:[{lowerCase:"#"}]},{width:.1,chars:[{lowerCase:"|"}]},{width:.1,chars:[{lowerCase:"_"}]},{width:.1,chars:[{lowerCase:"&"}]},{width:.1,chars:[{lowerCase:"-"}]},{width:.1,chars:[{lowerCase:"+"}]},{width:.1,chars:[{lowerCase:"("}]},{width:.1,chars:[{lowerCase:")"}]},{width:.1,chars:[{lowerCase:"/"}]}],[{width:.1,chars:[{lowerCase:"="}]},{width:.1,chars:[{lowerCase:"*"}]},{width:.1,chars:[{lowerCase:'"'}]},{width:.1,chars:[{lowerCase:"'"}]},{width:.1,chars:[{lowerCase:":"}]},{width:.1,chars:[{lowerCase:";"}]},{width:.1,chars:[{lowerCase:"!"}]},{width:.1,chars:[{lowerCase:"?"}]},{width:.2,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]]],kw=new cp;class Qw extends(Cw.withBase(jr)(P_,mw)){constructor(t){let e;if(t||(t={}),t.width||(t.width=1),t.height||(t.height=.4),t.margin||(t.margin=.003),t.padding||(t.padding=.01),super(t),this.currentPanel=0,this.isLowerCase=!0,this.charsetCount=1,t.language||navigator.language)switch(t.language||navigator.language){case"fr":case"fr-CH":case"fr-CA":e=Dw;break;case"ru":this.charsetCount=2,e=Lw;break;case"de":case"de-DE":case"de-AT":case"de-LI":case"de-CH":e=Uw;break;case"es":case"es-419":case"es-AR":case"es-CL":case"es-CO":case"es-ES":case"es-CR":case"es-US":case"es-HN":case"es-MX":case"es-PE":case"es-UY":case"es-VE":e=Nw;break;case"el":this.charsetCount=2,e=Fw;break;case"nord":e=Ow;break;default:e=Pw}else e=Pw;this.keys=[],this.panels=e.map((e=>{const n=t.height/e.length-2*t.margin,i=new Ew({width:t.width+2*t.padding,height:t.height+2*t.padding,offset:0,padding:t.padding,fontFamily:t.fontFamily,fontTexture:t.fontTexture,backgroundColor:t.backgroundColor,backgroundOpacity:t.backgroundOpacity});return i.charset=0,i.add(...e.map((e=>{const r=new Ew({width:t.width,height:n,margin:t.margin,contentDirection:"row",justifyContent:"center"});r.frame.visible=!1;const s=[];return e.forEach((e=>{const r=new Ew({width:t.width*e.width-2*t.margin,height:n,margin:t.margin,justifyContent:"center",offset:0}),a=e.chars[i.charset].lowerCase||e.chars[i.charset].icon||"undif";if("enter"===a&&t.enterTexture||"shift"===a&&t.shiftTexture||"backspace"===a&&t.backspaceTexture){const e=(()=>{switch(a){case"backspace":return t.backspaceTexture;case"enter":return t.enterTexture;case"shift":return t.shiftTexture;default:console.warn("There is no icon image for this key")}})();kw.load(e,(t=>{r.add(new Rw({width:.65*r.width,height:.65*r.height,backgroundSize:"contain",backgroundTexture:t}))}))}else r.add(new Bw({content:a,offset:0}));r.type="Key",r.info=e,r.info.input=a,r.panel=i,s.push(r),this.keys.push(r)})),r.add(...s),r}))),i})),this.add(this.panels[0]),this.set(t)}setNextPanel(){this.panels.forEach((t=>{this.remove(t)})),this.currentPanel=(this.currentPanel+1)%this.panels.length,this.add(this.panels[this.currentPanel]),this.update(!0,!0,!0)}setNextCharset(){this.panels[this.currentPanel].charset=(this.panels[this.currentPanel].charset+1)%this.charsetCount,this.keys.forEach((t=>{if(!this.panels[this.currentPanel].getObjectById(t.id))return;const e=t.info.chars[t.panel.charset]||t.info.chars[0],n=this.isLowerCase||!e.upperCase?e.lowerCase:e.upperCase;if(!t.childrenTexts.length)return;const i=t.childrenTexts[0];t.info.input=n,i.set({content:n}),i.update(!0,!0,!0)}))}toggleCase(){this.isLowerCase=!this.isLowerCase,this.keys.forEach((t=>{const e=t.info.chars[t.panel.charset]||t.info.chars[0],n=this.isLowerCase||!e.upperCase?e.lowerCase:e.upperCase;if(!t.childrenTexts.length)return;const i=t.childrenTexts[0];t.info.input=n,i.set({content:n}),i.update(!0,!0,!0)}))}parseParams(){}updateLayout(){}updateInner(){}}const zw={Block:Ew,Text:Bw,InlineBlock:Rw,Keyboard:Qw,FontLibrary:uw,update:()=>dw.update(),TextAlign:l,Whitespace:o,JustifyContent:a,AlignItems:s,ContentDirection:r};void 0!==t.g&&(t.g.ThreeMeshUI=zw);const Gw=zw;function Hw(t,e,n){return null===t?null:(t.point.applyMatrix4(e.matrixWorld),t.distance=t.point.distanceTo(n.ray.origin),t.object=e,t)}const Vw=0,Ww=1,jw=2,qw=0,Xw=1,Yw=2,Jw=1.25,Kw=1,Zw=32,$w=65535,tC=Math.pow(2,-24),eC=Symbol("SKIP_GENERATION");function nC(t){return t.index?t.index.count:t.attributes.position.count}function iC(t){return nC(t)/3}function rC(t,e=ArrayBuffer){return t>65535?new Uint32Array(new e(4*t)):new Uint16Array(new e(2*t))}function sC(t,e){const n=iC(t),i=e||t.drawRange,r=i.start/3,s=(i.start+i.count)/3,a=Math.max(0,r),o=Math.min(n,s)-a;return[{offset:Math.floor(a),count:Math.floor(o)}]}function aC(t,e){if(!t.groups||!t.groups.length)return sC(t,e);const n=[],i=new Set,r=e||t.drawRange,s=r.start/3,a=(r.start+r.count)/3;for(const e of t.groups){const t=e.start/3,n=(e.start+e.count)/3;i.add(Math.max(s,t)),i.add(Math.min(a,n))}const o=Array.from(i.values()).sort(((t,e)=>t-e));for(let t=0;tl&&(l=A),ef&&(f=e);const v=t[i+2],y=t[i+3],x=v-y,_=v+y;xc&&(c=_),vm&&(m=v);const w=t[i+4],C=t[i+5],E=w-C,M=w+C;Eh&&(h=M),wg&&(g=w)}i[0]=s,i[1]=a,i[2]=o,i[3]=l,i[4]=c,i[5]=h,r[0]=u,r[1]=d,r[2]=p,r[3]=f,r[4]=m,r[5]=g}function lC(t,e,n){return n.min.x=e[t],n.min.y=e[t+1],n.min.z=e[t+2],n.max.x=e[t+3],n.max.y=e[t+4],n.max.z=e[t+5],n}function cC(t){let e=-1,n=-1/0;for(let i=0;i<3;i++){const r=t[i+3]-t[i];r>n&&(n=r,e=i)}return e}function hC(t,e){e.set(t)}function uC(t,e,n){let i,r;for(let s=0;s<3;s++){const a=s+3;i=t[s],r=e[s],n[s]=ir?i:r}}function dC(t,e,n){for(let i=0;i<3;i++){const r=e[t+2*i],s=e[t+2*i+1],a=r-s,o=r+s;an[i+3]&&(n[i+3]=o)}}function pC(t){const e=t[3]-t[0],n=t[4]-t[1],i=t[5]-t[2];return 2*(e*n+n*i+i*e)}const fC=(t,e)=>t.candidate-e.candidate,mC=new Array(32).fill().map((()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0}))),gC=new Float32Array(6);class AC{constructor(){this.boundingData=new Float32Array(6)}}function vC(t,e,n,i,r,s){let a=i,o=i+r-1;const l=s.pos,c=2*s.axis;for(;;){for(;a<=o&&n[6*a+c]=l;)o--;if(!(a=l;)o--;if(!(aBC)throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return SC[n+6]=a/4,a=PC(a,r),SC[n+7]=s,a}}function LC(t,e){const n=t.geometry;e.indirect&&(t._indirectBuffer=function(t,e){const n=(t.index?t.index.count:t.attributes.position.count)/3,i=n>65536,r=i?4:2,s=e?new SharedArrayBuffer(n*r):new ArrayBuffer(n*r),a=i?new Uint32Array(s):new Uint16Array(s);for(let t=0,e=a.length;tt.offset-e.offset)),r=i[i.length-1];r.count=Math.min(n-r.offset,r.count);let s=0;return i.forEach((({count:t})=>s+=t)),n!==s}(n,e.range)&&!e.verbose&&console.warn('MeshBVH: Provided geometry contains groups or a range that do not fully span the vertex contents while using the "indirect" option. BVH may incorrectly report intersections on unrendered portions of the geometry.')),t._indirectBuffer||function(t,e){if(!t.index){const n=t.attributes.position.count,i=rC(n,e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer);t.setIndex(new Cs(i,1));for(let t=0;tf&&(f=s),h>f&&(f=h);const m=(f-u)/2,g=2*t;l[n+g+0]=u+m,l[n+g+1]=m+(Math.abs(u)+m)*tC}}return l}(n),s=e.indirect?sC(n,e.range):aC(n,e.range);t._roots=s.map((n=>{const s=function(t,e,n,i,r){const{maxDepth:s,verbose:a,maxLeafTris:o,strategy:l,onProgress:c,indirect:h}=r,u=t._indirectBuffer,d=t.geometry,p=d.index?d.index.array:null,f=h?yC:vC,m=iC(d),g=new Float32Array(6);let A=!1;const v=new AC;return oC(e,n,i,v.boundingData,g),function t(n,i,r,c=null,h=0){if(!A&&h>=s&&(A=!0,a&&(console.warn(`MeshBVH: Max depth of ${s} reached when generating BVH. Consider increasing maxDepth.`),console.warn(d))),r<=o||h>=s)return y(i+r),n.offset=i,n.count=r,n;const m=function(t,e,n,i,r,s){let a=-1,o=0;if(s===Vw)a=cC(e),-1!==a&&(o=(e[a]+e[a+3])/2);else if(s===Ww)a=cC(t),-1!==a&&(o=function(t,e,n,i){let r=0;for(let s=e,a=e+n;s=s.candidate?dC(i,n,s.rightCacheBounds):(dC(i,n,s.leftCacheBounds),s.count++)}}for(let n=0;n=32&&(r=31);const s=mC[r];s.count++,dC(e,n,s.bounds)}const e=mC[31];hC(e.bounds,e.rightCacheBounds);for(let t=30;t>=0;t--){const e=mC[t],n=mC[t+1];uC(e.bounds,n.rightCacheBounds,e.rightCacheBounds)}let d=0;for(let e=0;e<31;e++){const n=mC[e],i=n.count,c=n.bounds,h=mC[e+1].rightCacheBounds;0!==i&&(0===d?hC(c,gC):uC(c,gC,gC)),d+=i;let u=0,p=0;0!==d&&(u=pC(gC)/s);const f=r-d;0!==f&&(p=pC(h)/s);const m=Kw+Jw*(u*d+p*f);mi?s:i}this.min=n,this.max=i}setFromPoints(t,e){let n=1/0,i=-1/0;for(let r=0,s=e.length;ri?a:i}this.min=n,this.max=i}isSeparated(t){return this.min>t.max||t.min>this.max}}UC.prototype.setFromBox=function(){const t=new Hi;return function(e,n){const i=n.min,r=n.max;let s=1/0,a=-1/0;for(let n=0;n<=1;n++)for(let o=0;o<=1;o++)for(let l=0;l<=1;l++){t.x=i.x*n+r.x*(1-n),t.y=i.y*o+r.y*(1-o),t.z=i.z*l+r.z*(1-l);const c=e.dot(t);s=Math.min(c,s),a=Math.max(c,a)}this.min=s,this.max=a}}(),new UC;const NC=function(){const t=new Hi,e=new Hi,n=new Hi;return function(i,r,s){const a=i.start,o=t,l=r.start,c=e;n.subVectors(a,l),t.subVectors(i.end,i.start),e.subVectors(r.end,r.start);const h=n.dot(c),u=c.dot(o),d=c.dot(c),p=n.dot(o),f=o.dot(o)*d-u*u;let m,g;m=0!==f?(h*u-p*d)/f:0,g=(h+m*u)/d,s.x=m,s.y=g}}(),FC=function(){const t=new hi,e=new Hi,n=new Hi;return function(i,r,s,a){NC(i,r,t);let o=t.x,l=t.y;if(o>=0&&o<=1&&l>=0&&l<=1)return i.at(o,s),void r.at(l,a);if(o>=0&&o<=1)return l<0?r.at(0,a):r.at(1,a),void i.closestPointToPoint(a,!0,s);if(l>=0&&l<=1)return o<0?i.at(0,s):i.at(1,s),void r.closestPointToPoint(s,!0,a);{let t,c;t=o<0?i.start:i.end,c=l<0?r.start:r.end;const h=e,u=n;return i.closestPointToPoint(c,!0,e),r.closestPointToPoint(t,!0,n),h.distanceToSquared(c)<=u.distanceToSquared(t)?(s.copy(h),void a.copy(c)):(s.copy(t),void a.copy(u))}}}(),OC=function(){const t=new Hi,e=new Hi,n=new va,i=new Lf;return function(r,s){const{radius:a,center:o}=r,{a:l,b:c,c:h}=s;if(i.start=l,i.end=c,i.closestPointToPoint(o,!0,t).distanceTo(o)<=a)return!0;if(i.start=l,i.end=h,i.closestPointToPoint(o,!0,t).distanceTo(o)<=a)return!0;if(i.start=c,i.end=h,i.closestPointToPoint(o,!0,t).distanceTo(o)<=a)return!0;const u=s.getPlane(n);if(Math.abs(u.distanceToPoint(o))<=a){const t=u.projectPoint(o,e);if(s.containsPoint(t))return!0}return!1}}();function kC(t){return Math.abs(t)<1e-15}class QC extends as{constructor(...t){super(...t),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map((()=>new Hi)),this.satBounds=new Array(4).fill().map((()=>new UC)),this.points=[this.a,this.b,this.c],this.sphere=new hr,this.plane=new va,this.needsUpdate=!0}intersectsSphere(t){return OC(t,this)}update(){const t=this.a,e=this.b,n=this.c,i=this.points,r=this.satAxes,s=this.satBounds,a=r[0],o=s[0];this.getNormal(a),o.setFromPoints(a,i);const l=r[1],c=s[1];l.subVectors(t,e),c.setFromPoints(l,i);const h=r[2],u=s[2];h.subVectors(e,n),u.setFromPoints(h,i);const d=r[3],p=s[3];d.subVectors(n,t),p.setFromPoints(d,i),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(a,t),this.needsUpdate=!1}}QC.prototype.closestPointToSegment=function(){const t=new Hi,e=new Hi,n=new Lf;return function(i,r=null,s=null){const{start:a,end:o}=i,l=this.points;let c,h=1/0;for(let a=0;a<3;a++){const o=(a+1)%3;n.start.copy(l[a]),n.end.copy(l[o]),FC(n,i,t,e),c=t.distanceToSquared(e),c=2){(1===s?n.start:n.end).copy(p),r=2;break}if(r++,2===r&&-1===s)break}}return r}return function(a,h=null,p=!1){this.needsUpdate&&this.update(),a.isExtendedTriangle?a.needsUpdate&&a.update():(t.copy(a),t.update(),a=t);const m=this.plane,g=a.plane;if(Math.abs(m.normal.dot(g.normal))>1-1e-10){const t=this.satBounds,o=this.satAxes;n[0]=a.a,n[1]=a.b,n[2]=a.c;for(let e=0;e<4;e++){const r=t[e],s=o[e];if(i.setFromPoints(s,n),r.isSeparated(i))return!1}const l=a.satBounds,c=a.satAxes;e[0]=this.a,e[1]=this.b,e[2]=this.c;for(let t=0;t<4;t++){const n=l[t],r=c[t];if(i.setFromPoints(r,e),n.isSeparated(i))return!1}for(let t=0;t<4;t++){const a=o[t];for(let t=0;t<4;t++){const o=c[t];if(s.crossVectors(a,o),i.setFromPoints(s,e),r.setFromPoints(s,n),i.isSeparated(r))return!1}}return h&&(p||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),h.start.set(0,0,0),h.end.set(0,0,0)),!0}{const t=f(this,g,u);if(1===t&&a.containsPoint(u.end))return h&&(h.start.copy(u.end),h.end.copy(u.end)),!0;if(2!==t)return!1;const e=f(a,m,d);if(1===e&&this.containsPoint(d.end))return h&&(h.start.copy(d.end),h.end.copy(d.end)),!0;if(2!==e)return!1;if(u.delta(o),d.delta(l),o.dot(l)<0){let t=d.start;d.start=d.end,d.end=t}const n=u.start.dot(o),i=u.end.dot(o),r=d.start.dot(o),s=d.end.dot(o);return(n===s||r===i||i0?h.start.copy(u.start):h.start.copy(d.start),c.subVectors(u.end,d.end),c.dot(o)<0?h.end.copy(u.end):h.end.copy(d.end)),!0)}}}(),QC.prototype.distanceToPoint=function(){const t=new Hi;return function(e){return this.closestPointToPoint(e,t),e.distanceTo(t)}}(),QC.prototype.distanceToTriangle=function(){const t=new Hi,e=new Hi,n=["a","b","c"],i=new Lf,r=new Lf;return function(s,a=null,o=null){const l=a||o?i:null;if(this.intersectsTriangle(s,l))return(a||o)&&(a&&l.getCenter(a),o&&l.getCenter(o)),0;let c=1/0;for(let e=0;e<3;e++){let i;const r=n[e],l=s[r];this.closestPointToPoint(l,t),i=l.distanceToSquared(t),inew Hi)),this.satAxes=new Array(3).fill().map((()=>new Hi)),this.satBounds=new Array(3).fill().map((()=>new UC)),this.alignedSatBounds=new Array(3).fill().map((()=>new UC)),this.needsUpdate=!1,t&&this.min.copy(t),e&&this.max.copy(e),n&&this.matrix.copy(n)}set(t,e,n){this.min.copy(t),this.max.copy(e),this.matrix.copy(n),this.needsUpdate=!0}copy(t){this.min.copy(t.min),this.max.copy(t.max),this.matrix.copy(t.matrix),this.needsUpdate=!0}}zC.prototype.update=function(){const t=this.matrix,e=this.min,n=this.max,i=this.points;for(let r=0;r<=1;r++)for(let s=0;s<=1;s++)for(let a=0;a<=1;a++){const o=i[1*r|2*s|4*a];o.x=r?n.x:e.x,o.y=s?n.y:e.y,o.z=a?n.z:e.z,o.applyMatrix4(t)}const r=this.satBounds,s=this.satAxes,a=i[0];for(let t=0;t<3;t++){const e=s[t],n=r[t],o=i[1<new Lf)),n=new Array(12).fill().map((()=>new Lf)),i=new Hi,r=new Hi;return function(s,a=0,o=null,l=null){if(this.needsUpdate&&this.update(),this.intersectsBox(s))return(o||l)&&(s.getCenter(r),this.closestPointToPoint(r,i),s.closestPointToPoint(i,r),o&&o.copy(i),l&&l.copy(r)),0;const c=a*a,h=s.min,u=s.max,d=this.points;let p=1/0;for(let t=0;t<8;t++){const e=d[t];r.copy(e).clamp(h,u);const n=e.distanceToSquared(r);if(nnew QC))}}const VC=new HC,WC=new class{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const t=[];let e=null;this.setBuffer=n=>{e&&t.push(e),e=n,this.float32Array=new Float32Array(n),this.uint16Array=new Uint16Array(n),this.uint32Array=new Uint32Array(n)},this.clearBuffer=()=>{e=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,0!==t.length&&this.setBuffer(t.pop())}}};let jC,qC;const XC=[],YC=new GC((()=>new ji));function JC(t,e,n,i,r,s){jC=YC.getPrimitive(),qC=YC.getPrimitive(),XC.push(jC,qC),WC.setBuffer(t._roots[e]);const a=KC(0,t.geometry,n,i,r,s);WC.clearBuffer(),YC.releasePrimitive(jC),YC.releasePrimitive(qC),XC.pop(),XC.pop();const o=XC.length;return o>0&&(qC=XC[o-1],jC=XC[o-2]),a}function KC(t,e,n,i,r=null,s=0,a=0){const{float32Array:o,uint16Array:l,uint32Array:c}=WC;let h=2*t;if(xC(h,l)){const u=_C(t,c),d=wC(h,l);return lC(t,o,jC),i(u,d,!1,a,s+t,jC)}{const p=CC(t),f=EC(t,c);let m,g,A,v,y=p,x=f;if(r&&(A=jC,v=qC,lC(y,o,A),lC(x,o,v),m=r(A),g=r(v),g=169,eE=new Hi,nE=new Hi,iE=new Hi,rE=new hi,sE=new hi,aE=new hi,oE=new Hi,lE=new Hi,cE=new Hi,hE=new Hi;function uE(t,e,n,i,r,s,a){const o=3*i;let l=o+0,c=o+1,h=o+2;const u=t.index;t.index&&(l=u.getX(l),c=u.getX(c),h=u.getX(h));const{position:d,normal:p,uv:f,uv1:m}=t.attributes,g=function(t,e,n,i,r,s,a,o,l,c,h){eE.fromBufferAttribute(e,s),nE.fromBufferAttribute(e,a),iE.fromBufferAttribute(e,o);const u=function(t,e,n,i,r,s,a,o){let l;if(l=s===b?t.intersectTriangle(i,n,e,!0,r):t.intersectTriangle(e,n,i,s!==S,r),null===l)return null;const c=t.origin.distanceTo(r);return co?null:{distance:c,point:r.clone()}}(t,eE,nE,iE,hE,l,c,h);if(u){const e=new Hi;as.getBarycoord(hE,eE,nE,iE,e),i&&(rE.fromBufferAttribute(i,s),sE.fromBufferAttribute(i,a),aE.fromBufferAttribute(i,o),u.uv=as.getInterpolation(hE,eE,nE,iE,rE,sE,aE,new hi)),r&&(rE.fromBufferAttribute(r,s),sE.fromBufferAttribute(r,a),aE.fromBufferAttribute(r,o),u.uv1=as.getInterpolation(hE,eE,nE,iE,rE,sE,aE,new hi)),n&&(oE.fromBufferAttribute(n,s),lE.fromBufferAttribute(n,a),cE.fromBufferAttribute(n,o),u.normal=as.getInterpolation(hE,eE,nE,iE,oE,lE,cE,new Hi),u.normal.dot(t.direction)>0&&u.normal.multiplyScalar(-1));const l={a:s,b:a,c:o,normal:new Hi,materialIndex:0};as.getNormal(eE,nE,iE,l.normal),u.face=l,u.faceIndex=s,tE&&(u.barycoord=e)}return u}(n,d,p,f,m,l,c,h,e,s,a);return g?(g.faceIndex=i,r&&r.push(g),g):null}function dE(t,e,n,i){const r=t.a,s=t.b,a=t.c;let o=e,l=e+1,c=e+2;n&&(o=n.getX(o),l=n.getX(l),c=n.getX(c)),r.x=i.getX(o),r.y=i.getY(o),r.z=i.getZ(o),s.x=i.getX(l),s.y=i.getY(l),s.z=i.getZ(l),a.x=i.getX(c),a.y=i.getY(c),a.z=i.getZ(c)}const pE=new Hi,fE=new Hi,mE=new Hi,gE=new hi,AE=new hi,vE=new hi;function yE(t,e,n,i){const r=e.getIndex().array,s=e.getAttribute("position"),a=e.getAttribute("uv"),o=r[3*n],l=r[3*n+1],c=r[3*n+2];pE.fromBufferAttribute(s,o),fE.fromBufferAttribute(s,l),mE.fromBufferAttribute(s,c);let h=0;const u=e.groups,d=3*n;for(let t=0,e=u.length;t=n&&du&&(u=a),od&&(d=o),lp&&(p=l)}return(l[t+0]!==n||l[t+1]!==s||l[t+2]!==h||l[t+3]!==u||l[t+4]!==d||l[t+5]!==p)&&(l[t+0]=n,l[t+1]=s,l[t+2]=h,l[t+3]=u,l[t+4]=d,l[t+5]=p,!0)}{const i=t+8,r=a[t+6],o=i+n,c=r+n;let h=s,d=!1,p=!1;e?h||(d=e.has(o),p=e.has(c),h=!d&&!p):(d=!0,p=!0);const f=h||p;let m=!1;(h||d)&&(m=u(i,n,h));let g=!1;f&&(g=u(r,n,h));const A=m||g;if(A)for(let e=0;e<3;e++){const n=i+e,s=r+e,a=l[n],o=l[n+3],c=l[s],h=l[s+3];l[t+e]=ah?o:h}return A}}}function wE(t,e,n,i,r){let s,a,o,l,c,h;const u=1/n.direction.x,d=1/n.direction.y,p=1/n.direction.z,f=n.origin.x,m=n.origin.y,g=n.origin.z;let A=e[t],v=e[t+3],y=e[t+1],x=e[t+3+1],_=e[t+2],w=e[t+3+2];return u>=0?(s=(A-f)*u,a=(v-f)*u):(s=(v-f)*u,a=(A-f)*u),d>=0?(o=(y-m)*d,l=(x-m)*d):(o=(x-m)*d,l=(y-m)*d),!(s>l||o>a)&&((o>s||isNaN(s))&&(s=o),(l=0?(c=(_-g)*p,h=(w-g)*p):(c=(w-g)*p,h=(_-g)*p),!(s>h||c>a)&&((c>s||s!=s)&&(s=c),(h=i))}function CE(t,e,n,i,r,s,a){WC.setBuffer(t._roots[e]),EE(0,t,n,i,r,s,a),WC.clearBuffer()}function EE(t,e,n,i,r,s,a){const{float32Array:o,uint16Array:l,uint32Array:c}=WC,h=2*t;if(xC(h,l))!function(t,e,n,i,r,s,a,o){const{geometry:l,_indirectBuffer:c}=t;for(let t=i,c=i+r;t=0;let u,d;h?(u=CC(t),d=EC(t,l)):(u=EC(t,l),d=CC(t));const p=wE(u,a,i,r,s)?SE(u,e,n,i,r,s):null;if(p){const t=p.point[c];if(h?t<=a[d+o]:t>=a[d+o+3])return p}const f=wE(d,a,i,r,s)?SE(d,e,n,i,r,s):null;return p&&f?p.distance<=f.distance?p:f:p||f||null}}const IE=new ji,TE=new QC,BE=new QC,RE=new yr,DE=new zC,PE=new zC;function LE(t,e,n,i){WC.setBuffer(t._roots[e]);const r=UE(0,t,n,i);return WC.clearBuffer(),r}function UE(t,e,n,i,r=null){const{float32Array:s,uint16Array:a,uint32Array:o}=WC;let l=2*t;if(null===r&&(n.boundingBox||n.computeBoundingBox(),DE.set(n.boundingBox.min,n.boundingBox.max,i),r=DE),!xC(l,a)){const a=t+8,l=o[t+6];return lC(a,s,IE),r.intersectsBox(IE)&&UE(a,e,n,i,r)?!0:(lC(l,s,IE),!(!r.intersectsBox(IE)||!UE(l,e,n,i,r)))}{const r=e.geometry,c=r.index,h=r.attributes.position,u=n.index,d=n.attributes.position,p=_C(t,o),f=wC(l,a);if(RE.copy(i).invert(),n.boundsTree){lC(t,s,PE),PE.matrix.copy(RE),PE.needsUpdate=!0;const e=n.boundsTree.shapecast({intersectsBounds:t=>PE.intersectsBox(t),intersectsTriangle:t=>{t.a.applyMatrix4(i),t.b.applyMatrix4(i),t.c.applyMatrix4(i),t.needsUpdate=!0;for(let e=3*p,n=3*(f+p);eFE.distanceToBox(t),intersectsBounds:(t,e,n)=>n{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:t=>OE.distanceToBox(t),intersectsBounds:(t,e,n)=>n{for(let a=e,o=e+r;ad&&(d=a),op&&(p=o),lf&&(f=l)}}return(l[n+0]!==s||l[n+1]!==c||l[n+2]!==u||l[n+3]!==d||l[n+4]!==p||l[n+5]!==f)&&(l[n+0]=s,l[n+1]=c,l[n+2]=u,l[n+3]=d,l[n+4]=p,l[n+5]=f,!0)}{const t=n+8,i=a[n+6],r=t+s,o=i+s;let h=c,d=!1,p=!1;e?h||(d=e.has(r),p=e.has(o),h=!d&&!p):(d=!0,p=!0);const f=h||p;let m=!1;(h||d)&&(m=u(t,s,h));let g=!1;f&&(g=u(i,s,h));const A=m||g;if(A)for(let e=0;e<3;e++){const r=t+e,s=i+e,a=l[r],o=l[r+3],c=l[s],h=l[s+3];l[n+e]=ah?o:h}return A}}}function jE(t,e,n,i,r,s,a){WC.setBuffer(t._roots[e]),qE(0,t,n,i,r,s,a),WC.clearBuffer()}function qE(t,e,n,i,r,s,a){const{float32Array:o,uint16Array:l,uint32Array:c}=WC,h=2*t;if(xC(h,l))!function(t,e,n,i,r,s,a,o){const{geometry:l,_indirectBuffer:c}=t;for(let t=i,h=i+r;t=0;let u,d;h?(u=CC(t),d=EC(t,l)):(u=EC(t,l),d=CC(t));const p=wE(u,a,i,r,s)?JE(u,e,n,i,r,s):null;if(p){const t=p.point[c];if(h?t<=a[d+o]:t>=a[d+o+3])return p}const f=wE(d,a,i,r,s)?JE(d,e,n,i,r,s):null;return p&&f?p.distance<=f.distance?p:f:p||f||null}}const KE=new ji,ZE=new QC,$E=new QC,tM=new yr,eM=new zC,nM=new zC;function iM(t,e,n,i){WC.setBuffer(t._roots[e]);const r=rM(0,t,n,i);return WC.clearBuffer(),r}function rM(t,e,n,i,r=null){const{float32Array:s,uint16Array:a,uint32Array:o}=WC;let l=2*t;if(null===r&&(n.boundingBox||n.computeBoundingBox(),eM.set(n.boundingBox.min,n.boundingBox.max,i),r=eM),!xC(l,a)){const a=t+8,l=o[t+6];return lC(a,s,KE),r.intersectsBox(KE)&&rM(a,e,n,i,r)?!0:(lC(l,s,KE),!(!r.intersectsBox(KE)||!rM(l,e,n,i,r)))}{const r=e.geometry,c=r.index,h=r.attributes.position,u=n.index,d=n.attributes.position,p=_C(t,o),f=wC(l,a);if(tM.copy(i).invert(),n.boundsTree){lC(t,s,nM),nM.matrix.copy(tM),nM.needsUpdate=!0;const r=n.boundsTree.shapecast({intersectsBounds:t=>nM.intersectsBox(t),intersectsTriangle:t=>{t.a.applyMatrix4(i),t.b.applyMatrix4(i),t.c.applyMatrix4(i),t.needsUpdate=!0;for(let n=p,i=f+p;naM.distanceToBox(t),intersectsBounds:(t,e,n)=>n{if(e.boundsTree){const o=e.boundsTree;return o.shapecast({boundsTraverseOrder:t=>oM.distanceToBox(t),intersectsBounds:(t,e,n)=>n{for(let _=e,w=e+a;_new ji)),AM=new ji,vM=new ji,yM=new ji,xM=new ji;let _M=!1;function wM(t,e,n,i,r,s=0,a=0,o=0,l=0,c=null,h=!1){let u,d;h?(u=mM,d=fM):(u=fM,d=mM);const p=u.float32Array,f=u.uint32Array,m=u.uint16Array,g=d.float32Array,A=d.uint32Array,v=d.uint16Array,y=2*e,x=xC(2*t,m),_=xC(y,v);let w=!1;if(_&&x)w=h?r(_C(e,A),wC(2*e,v),_C(t,f),wC(2*t,m),l,a+e,o,s+t):r(_C(t,f),wC(2*t,m),_C(e,A),wC(2*e,v),o,s+t,l,a+e);else if(_){const c=gM.getPrimitive();lC(e,g,c),c.applyMatrix4(n);const u=CC(t),d=EC(t,f);lC(u,p,AM),lC(d,p,vM);const m=c.intersectsBox(AM),A=c.intersectsBox(vM);w=m&&wM(e,u,i,n,r,a,s,l,o+1,c,!h)||A&&wM(e,d,i,n,r,a,s,l,o+1,c,!h),gM.releasePrimitive(c)}else{const u=CC(e),d=EC(e,A);lC(u,g,yM),lC(d,g,xM);const m=c.intersectsBox(yM),v=c.intersectsBox(xM);if(m&&v)w=wM(t,u,n,i,r,s,a,o,l+1,c,h)||wM(t,d,n,i,r,s,a,o,l+1,c,h);else if(m)if(x)w=wM(t,u,n,i,r,s,a,o,l+1,c,h);else{const e=gM.getPrimitive();e.copy(yM).applyMatrix4(n);const c=CC(t),d=EC(t,f);lC(c,p,AM),lC(d,p,vM);const m=e.intersectsBox(AM),g=e.intersectsBox(vM);w=m&&wM(u,c,i,n,r,a,s,l,o+1,e,!h)||g&&wM(u,d,i,n,r,a,s,l,o+1,e,!h),gM.releasePrimitive(e)}else if(v)if(x)w=wM(t,d,n,i,r,s,a,o,l+1,c,h);else{const e=gM.getPrimitive();e.copy(xM).applyMatrix4(n);const c=CC(t),u=EC(t,f);lC(c,p,AM),lC(u,p,vM);const m=e.intersectsBox(AM),g=e.intersectsBox(vM);w=m&&wM(d,c,i,n,r,a,s,l,o+1,e,!h)||g&&wM(d,u,i,n,r,a,s,l,o+1,e,!h),gM.releasePrimitive(e)}}return w}const CM=new zC,EM=new ji,MM={strategy:Vw,maxDepth:40,maxLeafTris:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0,range:null};class bM{static serialize(t,e={}){e={cloneBuffers:!0,...e};const n=t.geometry,i=t._roots,r=t._indirectBuffer,s=n.getIndex();let a;return a=e.cloneBuffers?{roots:i.map((t=>t.slice())),index:s?s.array.slice():null,indirectBuffer:r?r.slice():null}:{roots:i,index:s?s.array:null,indirectBuffer:r},a}static deserialize(t,e,n={}){n={setIndex:!0,indirect:Boolean(t.indirectBuffer),...n};const{index:i,roots:r,indirectBuffer:s}=t,a=new bM(e,{...n,[eC]:!0});if(a._roots=r,a._indirectBuffer=s||null,n.setIndex){const n=e.getIndex();if(null===n){const n=new Cs(t.index,1,!1);e.setIndex(n)}else n.array!==i&&(n.array.set(i),n.needsUpdate=!0)}return a}get indirect(){return!!this._indirectBuffer}constructor(t,e={}){if(!t.isBufferGeometry)throw new Error("MeshBVH: Only BufferGeometries are supported.");if(t.index&&t.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.");if((e=Object.assign({...MM,[eC]:!1},e)).useSharedArrayBuffer&&!pM())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=t,this._roots=null,this._indirectBuffer=null,e[eC]||(LC(this,e),!t.boundingBox&&e.setBoundingBox&&(t.boundingBox=this.getBoundingBox(new ji))),this.resolveTriangleIndex=e.indirect?t=>this._indirectBuffer[t]:t=>t}refit(t=null){return(this.indirect?WE:_E)(this,t)}traverse(t,e=0){const n=this._roots[e],i=new Uint32Array(n),r=new Uint16Array(n);!function e(s,a=0){const o=2*s,l=r[o+15]===$w;if(l){const e=i[s+6],c=r[o+14];t(a,l,new Float32Array(n,4*s,6),e,c)}else{const r=s+8,o=i[s+6],c=i[s+7];t(a,l,new Float32Array(n,4*s,6),c)||(e(r,a+1),e(o,a+1))}}(0)}raycast(t,e=M,n=0,i=1/0){const r=this._roots,s=this.geometry,a=[],o=e.isMaterial,l=Array.isArray(e),c=s.groups,h=o?e.side:e,u=this.indirect?jE:CE;for(let s=0,o=r.length;s!!t(i,r,s,o,l)||n(i,r,this,a,s,o,e)}else s||(s=a?(t,i,r,s)=>n(t,i,this,a,r,s,e):(t,e,n)=>n);let o=!1,l=0;const c=this._roots;for(let t=0,e=c.length;t{const e=this.resolveTriangleIndex(t);dE(s,3*e,a,o)}:t=>{dE(s,3*t,a,o)},c=VC.getPrimitive(),h=t.geometry.index,u=t.geometry.attributes.position,d=t.indirect?e=>{const n=t.resolveTriangleIndex(e);dE(c,3*n,h,u)}:t=>{dE(c,3*t,h,u)};if(r){const t=(t,n,i,a,o,h,u,p)=>{for(let f=i,m=i+a;fCM.intersectsBox(t),intersectsTriangle:t=>CM.intersectsTriangle(t)})}intersectsSphere(t){return this.shapecast({intersectsBounds:e=>t.intersectsBox(e),intersectsTriangle:e=>e.intersectsSphere(t)})}closestPointToGeometry(t,e,n={},i={},r=0,s=1/0){return(this.indirect?dM:HE)(this,t,e,n,i,r,s)}closestPointToPoint(t,e={},n=0,i=1/0){return function(t,e,n={},i=0,r=1/0){const s=i*i,a=r*r;let o=1/0,l=null;if(t.shapecast({boundsTraverseOrder:t=>(ZC.copy(e).clamp(t.min,t.max),ZC.distanceToSquared(e)),intersectsBounds:(t,e,n)=>n{t.closestPointToPoint(e,ZC);const i=e.distanceToSquared(ZC);return i{lC(0,new Float32Array(e),EM),t.union(EM)})),t}}const SM=parseInt(f)>=166,IM=new vr,TM=new Hi,BM=new yr,RM=Zs.prototype.raycast,DM=Mh.prototype.raycast,PM=new Hi,LM=new Zs,UM=[];function NM(t,e){this.isBatchedMesh?FM.call(this,t,e):OM.call(this,t,e)}function FM(t,e){if(this.boundsTrees){const n=this.boundsTrees,i=this._drawInfo||this._instanceInfo,r=this._drawRanges||this._geometryInfo,s=this.matrixWorld;LM.material=this.material,LM.geometry=this.geometry;const a=LM.geometry.boundsTree,o=LM.geometry.drawRange;null===LM.geometry.boundingSphere&&(LM.geometry.boundingSphere=new hr);for(let a=0,o=i.length;a{if(t>=i||e)return s++,!0;r&&s++}),n);let a=0;const o=new Float32Array(24*s);let l,c;e.traverse(((t,e,n)=>{const s=t>=i||e;if(s||r){lC(0,n,HM);const{min:t,max:e}=HM;for(let n=-1;n<=1;n+=2){const i=n<0?t.x:e.x;for(let n=-1;n<=1;n+=2){const r=n<0?t.y:e.y;for(let n=-1;n<=1;n+=2){const s=n<0?t.z:e.z;o[a+0]=i,o[a+1]=r,o[a+2]=s,a+=3}}}return s}}),n),c=this.displayEdges?new Uint8Array([0,4,1,5,2,6,3,7,0,2,1,3,4,6,5,7,0,1,2,3,4,5,6,7]):new Uint8Array([0,1,2,2,1,3,4,6,5,6,7,5,1,4,5,0,4,1,2,3,6,3,7,6,0,2,4,2,6,4,1,5,3,3,5,7]),l=o.length>65535?new Uint32Array(c.length*s):new Uint16Array(c.length*s);const h=c.length;for(let t=0;tn;){const t=this._roots.pop();t.geometry.dispose(),this.remove(t)}for(let t=0;t=this._roots.length){const r=new WM(e,i,n,t);this.add(r),this._roots.push(r)}const o=this._roots[t];o.bvh=e,o.depth=n,o.displayParents=s,o.displayEdges=a,o.material=a?i:r,o.update()}}updateMatrixWorld(...t){const e=this.mesh,n=this.parent;null!==e&&(e.updateWorldMatrix(!0,!1),n?this.matrix.copy(n.matrixWorld).invert().multiply(e.matrixWorld):this.matrix.copy(e.matrixWorld),(e.isInstancedMesh||e.isBatchedMesh)&&(e.getMatrixAt(this.objectIndex,VM),this.matrix.multiply(VM)),this.matrix.decompose(this.position,this.quaternion,this.scale)),super.updateMatrixWorld(...t)}copy(t){this.depth=t.depth,this.mesh=t.mesh,this.bvh=t.bvh,this.opacity=t.opacity,this.color.copy(t.color)}clone(){return new jM(this.mesh,this.bvh,this.depth)}dispose(){this.edgeMaterial.dispose(),this.meshMaterial.dispose();const t=this.children;for(let e=0,n=t.length;efunction(t,e){const n={nodeCount:0,leafNodeCount:0,depth:{min:1/0,max:-1/0},tris:{min:1/0,max:-1/0},splits:[0,0,0],surfaceAreaScore:0};return t.traverse(((t,e,i,r,s)=>{const a=i[3]-i[0],o=i[4]-i[1],l=i[5]-i[2],c=2*(a*o+o*l+l*a);n.nodeCount++,e?(n.leafNodeCount++,n.depth.min=Math.min(t,n.depth.min),n.depth.max=Math.max(t,n.depth.max),n.tris.min=Math.min(s,n.tris.min),n.tris.max=Math.max(s,n.tris.max),n.surfaceAreaScore+=c*Jw*s):(n.splits[r]++,n.surfaceAreaScore+=c*Kw)}),e),n.tris.min===1/0&&(n.tris.min=0,n.tris.max=0),n.depth.min===1/0&&(n.depth.min=0,n.depth.max=0),n}(t,n)))}function ZM(t){const e=new Set,n=[t];let i=0;for(;n.length;){const t=n.pop();if(!e.has(t)){e.add(t);for(let e in t){if(!Object.hasOwn(t,e))continue;i+=JM(e);const r=t[e];!r||"object"!=typeof r&&"function"!=typeof r?i+=JM(r):/(Uint|Int|Float)(8|16|32)Array/.test(r.constructor.name)||pM()&&r instanceof SharedArrayBuffer||r instanceof ArrayBuffer?i+=r.byteLength:n.push(r)}}}return i}function $M(t){const e=t.geometry,n=[],i=e.index,r=e.getAttribute("position");let s=!0;return t.traverse(((e,a,o,l,c)=>{const h={depth:e,isLeaf:a,boundingData:o,offset:l,count:c};n[e]=h,lC(0,o,qM);const u=n[e-1];if(a)for(let e=l,n=l+c;e{const a={bounds:lC(0,i,new ji)};n?(a.count=s,a.offset=r):(a.left=null,a.right=null),e[t]=a;const o=e[t-1];o&&(null===o.left?o.left=a:o.right=a)})),e[0]}function eb(t){switch(t){case 1:return ae;case 2:return le;case 3:case 4:return he}}class nb extends Yc{constructor(){super(),this.minFilter=Bt,this.magFilter=Bt,this.generateMipmaps=!1,this.overrideItemSize=null,this._forcedType=null}updateFrom(t){const e=this.overrideItemSize,n=t.itemSize,i=t.count;if(null!==e){if(n*i%e!=0)throw new Error("VertexAttributeTexture: overrideItemSize must divide evenly into buffer length.");t.itemSize=e,t.count=i*n/e}const r=t.itemSize,s=t.count,a=t.normalized,o=t.array.constructor,l=o.BYTES_PER_ELEMENT;let c,h,u,d,p=this._forcedType,f=r;if(null===p)switch(o){case Float32Array:p=jt;break;case Uint8Array:case Uint16Array:case Uint32Array:p=Wt;break;case Int8Array:case Int16Array:case Int32Array:p=Vt}let m=function(t){switch(t){case 1:return"R";case 2:return"RG";case 3:case 4:return"RGBA"}throw new Error}(r);switch(p){case jt:u=1,h=function(t){switch(t){case 1:return se;case 2:return oe;case 3:case 4:return te}}(r),a&&1===l?(d=o,m+="8",o===Uint8Array?c=Qt:(c=zt,m+="_SNORM")):(d=Float32Array,m+="32F",c=jt);break;case Vt:m+=8*l+"I",u=a?Math.pow(2,8*o.BYTES_PER_ELEMENT-1):1,h=eb(r),1===l?(d=Int8Array,c=zt):2===l?(d=Int16Array,c=Gt):(d=Int32Array,c=Vt);break;case Wt:m+=8*l+"UI",u=a?Math.pow(2,8*o.BYTES_PER_ELEMENT-1):1,h=eb(r),1===l?(d=Uint8Array,c=Qt):2===l?(d=Uint16Array,c=Ht):(d=Uint32Array,c=Wt)}3!==f||h!==te&&h!==he||(f=4);const g=Math.ceil(Math.sqrt(s))||1,A=new d(f*g*g),v=t.normalized;t.normalized=!1;for(let e=0;e=2&&(A[n+1]=t.getY(e)/u),r>=3&&(A[n+2]=t.getZ(e)/u,4===f&&(A[n+3]=1)),r>=4&&(A[n+3]=t.getW(e)/u)}t.normalized=v,this.internalFormat=m,this.format=h,this.type=c,this.image.width=g,this.image.height=g,this.image.data=A,this.needsUpdate=!0,this.dispose(),t.itemSize=n,t.count=i}}class ib extends nb{constructor(){super(),this._forcedType=Wt}}class rb extends nb{constructor(){super(),this._forcedType=Vt}}class sb extends nb{constructor(){super(),this._forcedType=jt}}class ab{constructor(){this.index=new ib,this.position=new sb,this.bvhBounds=new Yc,this.bvhContents=new Yc,this._cachedIndexAttr=null,this.index.overrideItemSize=3}updateFrom(t){const{geometry:e}=t;if(function(t,e,n){const i=t._roots;if(1!==i.length)throw new Error("MeshBVHUniformStruct: Multi-root BVHs not supported.");const r=i[0],s=new Uint16Array(r),a=new Uint32Array(r),o=new Float32Array(r),l=r.byteLength/Zw,c=2*Math.ceil(Math.sqrt(l/2)),h=new Float32Array(4*c*c),u=Math.ceil(Math.sqrt(l)),d=new Uint32Array(2*u*u);for(let t=0;t=2&&e.setY(s,t.getY(r)),i>=3&&e.setZ(s,t.getZ(r)),i>=4&&e.setW(s,t.getW(r))}}else{const i=e.array,r=i.constructor,s=i.BYTES_PER_ELEMENT*t.itemSize*n;new r(i.buffer,s,t.array.length).set(t.array)}}function xb(t,e,n){const i=t.elements,r=e.elements;for(let t=0,e=r.length;t{t.traverseVisible((t=>{t.isMesh&&e.push(t)}))})),this.meshes=e,this.useGroups=!0,this.applyWorldTransforms=!0,this.attributes=["position","normal","color","tangent","uv","uv2"],this._intermediateGeometry=new Array(e.length).fill().map((()=>new Qs)),this._diffMap=new WeakMap}getMaterials(){const t=[];return this.meshes.forEach((e=>{Array.isArray(e.material)?t.push(...e.material):t.push(e.material)})),t}generate(t=new Qs){let e=[];const{meshes:n,useGroups:i,_intermediateGeometry:r,_diffMap:s}=this;for(let t=0,i=n.length;t{const i=t(e),r=t(n);return ir?1:0}):this._unloadPriorityCallback=t}constructor(){this.minSize=6e3,this.maxSize=8e3,this.minBytesSize=322122547.2,this.maxBytesSize=429496729.6,this.unloadPercent=.05,this.itemSet=new Map,this.itemList=[],this.usedSet=new Set,this.callbacks=new Map,this.markUnusedQueued=!1,this.unloadingHandle=-1,this.cachedBytes=0,this.bytesMap=new Map,this.loadedSet=new Set,this._unloadPriorityCallback=null,this.computeMemoryUsageCallback=()=>null;const t=this.itemSet;this.defaultPriorityCallback=e=>t.get(e)}isFull(){return this.itemSet.size>=this.maxSize||this.cachedBytes>=this.maxBytesSize}getMemoryUsage(t){return this.bytesMap.get(t)??null}add(t,e){this.markUnusedQueued&&this.markAllUnused();const n=this.itemSet;if(n.has(t))return!1;if(this.isFull())return!1;const i=this.usedSet,r=this.itemList,s=this.callbacks,a=this.bytesMap;r.push(t),i.add(t),n.set(t,Date.now()),s.set(t,e);const o=this.computeMemoryUsageCallback(t);return this.cachedBytes+=o||0,a.set(t,o),!0}remove(t){const e=this.usedSet,n=this.itemSet,i=this.itemList,r=this.bytesMap,s=this.callbacks,a=this.loadedSet;if(n.has(t)){this.cachedBytes-=r.get(t)||0,r.delete(t),s.get(t)(t);const o=i.indexOf(t);return i.splice(o,1),e.delete(t),n.delete(t),s.delete(t),a.delete(t),!0}return!1}setLoaded(t,e){const{itemSet:n,loadedSet:i}=this;n.has(t)&&(!0===e?i.add(t):i.delete(t))}updateMemoryUsage(t){const e=this.itemSet,n=this.bytesMap;if(!e.has(t))return;this.cachedBytes-=n.get(t)||0;const i=this.computeMemoryUsageCallback(t);n.set(t,i),this.cachedBytes+=i}markUsed(t){this.markUnusedQueued&&this.markAllUnused();const e=this.itemSet,n=this.usedSet;e.has(t)&&!n.has(t)&&(e.set(t,Date.now()),n.add(t))}markAllUnused(){this.usedSet.clear(),this.markUnusedQueued=!1,-1!==this.unloadingHandle&&(cancelAnimationFrame(this.unloadingHandle),this.unloadingHandle=-1)}unloadUnusedContent(){const{unloadPercent:t,minSize:e,maxSize:n,itemList:i,itemSet:r,usedSet:s,loadedSet:a,callbacks:o,bytesMap:l,minBytesSize:c,maxBytesSize:h}=this,u=i.length-s.size,d=i.length-a.size,p=Math.max(Math.min(i.length-e,u),0),f=this.cachedBytes-c,m=this.unloadPriorityCallback||this.defaultPriorityCallback;let g=!1;const A=p>0&&u>0||d&&i.length>n;if(u&&this.cachedBytes>c||d&&this.cachedBytes>h||A){i.sort(((t,e)=>{const n=s.has(t);if(n===s.has(e)){const n=a.has(t);return n===a.has(e)?-m(t,e):n?1:-1}return n?1:-1}));const d=Math.max(e*t,p*t),A=Math.ceil(Math.min(d,u,p)),v=Math.max(t*f,t*c),y=Math.min(v,f);let x=0,_=0;for(;this.cachedBytes-_>h||i.length-x>n;){const t=i[x],e=l.get(t)||0;if(s.has(t)&&a.has(t)||this.cachedBytes-_-e=A)break;_+=e,x++}i.splice(0,x).forEach((t=>{this.cachedBytes-=l.get(t)||0,o.get(t)(t),l.delete(t),r.delete(t),o.delete(t),a.delete(t),s.delete(t)})),g=x0}g&&(this.unloadingHandle=requestAnimationFrame((()=>this.scheduleUnload())))}scheduleUnload(){this.scheduled||(this.scheduled=!0,queueMicrotask((()=>{this.scheduled=!1,this.unloadUnusedContent(),this.markUnusedQueued=!0})))}}class Lb{constructor(){this.maxJobs=6,this.items=[],this.callbacks=new Map,this.currJobs=0,this.scheduled=!1,this.autoUpdate=!0,this.priorityCallback=()=>{throw new Error("PriorityQueue: PriorityCallback function not defined.")},this.schedulingCallback=t=>{requestAnimationFrame(t)},this._runjobs=()=>{this.tryRunJobs(),this.scheduled=!1}}sort(){const t=this.priorityCallback;this.items.sort(t)}add(t,e){return new Promise(((n,i)=>{const r=this.items,s=this.callbacks;r.push(t),s.set(t,((...t)=>e(...t).then(n).catch(i))),this.autoUpdate&&this.scheduleJobRun()}))}remove(t){const e=this.items,n=this.callbacks,i=e.indexOf(t);-1!==i&&(e.splice(i,1),n.delete(t))}tryRunJobs(){this.sort();const t=this.items,e=this.callbacks,n=this.maxJobs;let i=this.currJobs;for(;n>i&&t.length>0;){i++;const n=t.pop(),r=e.get(n);e.delete(n),r(n).then((()=>{this.currJobs--,this.autoUpdate&&this.scheduleJobRun()})).catch((()=>{this.currJobs--,this.autoUpdate&&this.scheduleJobRun()}))}this.currJobs=i}scheduleJobRun(){this.scheduled||(this.schedulingCallback(this._runjobs),this.scheduled=!0)}}const Ub=-1,Nb=0,Fb=1,Ob=2,kb=3,Qb=6378137,zb=1/298.257223563,Gb=-(zb*Qb-Qb),Hb=1736e3,Vb=1738100;function Wb(t){return t===kb||t===Ub}function jb(t,e){return t.__lastFrameVisited===e&&t.__used}function qb(t,e){t.__lastFrameVisited!==e.frameCount&&(t.__lastFrameVisited=e.frameCount,t.__used=!1,t.__inFrustum=!1,t.__isLeaf=!1,t.__visible=!1,t.__active=!1,t.__error=1/0,t.__distanceFromCamera=1/0,t.__childrenWereVisible=!1,t.__allChildrenLoaded=!1,t.__inFrustum=e.tileInView(t),e.calculateError(t))}function Xb(t,e){if(e.ensureChildrenArePreprocessed(t),qb(t,e),Jb(t,e),!t.__hasRenderableContent){const n=t.children;for(let t=0,i=n.length;t0&&t.__depth+1>=e.maxDepth)}(t,e))return void Jb(t,e);let n=!1,i=!1;const r=t.children;for(let t=0,s=r.length;tt.__depthFromRenderedParent!==e.__depthFromRenderedParent?t.__depthFromRenderedParent>e.__depthFromRenderedParent?-1:1:t.__inFrustum!==e.__inFrustum?t.__inFrustum?1:-1:t.__used!==e.__used?t.__used?1:-1:t.__error!==e.__error?t.__error>e.__error?1:-1:t.__distanceFromCamera!==e.__distanceFromCamera?t.__distanceFromCamera>e.__distanceFromCamera?-1:1:0,rS=(t,e)=>t.__depthFromRenderedParent!==e.__depthFromRenderedParent?t.__depthFromRenderedParent>e.__depthFromRenderedParent?1:-1:t.__loadingState!==e.__loadingState?t.__loadingState>e.__loadingState?-1:1:t.__lastFrameVisited!==e.__lastFrameVisited?t.__lastFrameVisited>e.__lastFrameVisited?-1:1:t.__hasUnrenderableContent!==e.__hasUnrenderableContent?t.__hasUnrenderableContent?-1:1:t.__error!==e.__error?t.__error>e.__error?-1:1:0;class sS{get root(){const t=this.rootTileSet;return t?t.root:null}set loadSiblings(t){console.warn('TilesRenderer: "loadSiblings" option has been removed.')}set stopAtEmptyTiles(t){console.warn('TilesRenderer: "stopAtEmptyTiles" option has been removed.')}set preprocessURL(t){console.warn('TilesRendererBase: The "preprocessURL" callback has been deprecated. Use a plugin, instead.'),this._preprocessURL=t}get preprocessURL(){return this._preprocessURL}constructor(t=null){this.rootTileSetTriggered=!1,this.rootTileSet=null,this.rootURL=t,this.fetchOptions={},this.plugins=[],this.queuedTiles=[],this._preprocessURL=null;const e=new Pb;e.unloadPriorityCallback=rS;const n=new Lb;n.maxJobs=4,n.priorityCallback=iS;const i=new Lb;i.maxJobs=1,i.priorityCallback=iS,this.lruCache=e,this.downloadQueue=n,this.parseQueue=i,this.stats={parsing:0,downloading:0,failed:0,inFrustum:0,used:0,active:0,visible:0},this.frameCount=0,this.errorTarget=6,this.errorThreshold=1/0,this.displayActiveTiles=!1,this.maxDepth=1/0}registerPlugin(t){if(!0===t[nS])throw new Error("TilesRendererBase: A plugin can only be registered to a single tile set");this.plugins.push(t),t[nS]=!0,t.init&&t.init(this)}unregisterPlugin(t){const e=this.plugins;if("string"==typeof t&&(t=this.getPluginByName(name)),e.includes(t)){const n=e.indexOf(t);return e.splice(n,1),t.dispose&&t.dispose(),!0}return!1}getPluginByName(t){return this.plugins.find((e=>e.name===t))||null}traverse(t,e){this.root&&Kb(this.root,((e,...n)=>(this.ensureChildrenArePreprocessed(e),!!t&&t(e,...n))),e)}queueTileForDownload(t){this.queuedTiles.push(t)}update(){const t=this.stats,e=this.lruCache;if(this.rootTileSetTriggered||(this.rootTileSetTriggered=!0,this.invokeOnePlugin((t=>t.loadRootTileSet&&t.loadRootTileSet()))),!this.root)return;const n=this.root;t.inFrustum=0,t.used=0,t.active=0,t.visible=0,this.frameCount++,Zb(n,this),$b(n,this),tS(n,this),eS(n,this);const i=this.queuedTiles;i.sort(e.unloadPriorityCallback);for(let t=0,n=i.length;t{t.__loadingState===Ub&&(t.__loadingState=Nb)})),t.failed=0)}dispose(){this.invokeAllPlugins((t=>{t!==this&&t.dispose&&t.dispose()}));const t=this.lruCache,e=[];this.traverse((t=>(e.push(t),!1)));for(let n=0,i=e.length;n{i!==this&&i.preprocessNode&&i.preprocessNode(t,e,n)}))}setTileActive(t,e){}setTileVisible(t,e){}calculateError(t){return 0}tileInView(t){return!0}ensureChildrenArePreprocessed(t){const e=t.children;for(let n=0,i=e.length;nparseInt(t)));console.assert(r<=1,"TilesRenderer: asset.version is expected to be a 1.x or a compatible version."),1===r&&s>0&&console.warn("TilesRenderer: tiles versions at 1.1 or higher have limited support. Some new extensions and features may not be supported.");let a=e.replace(/\/[^/]*\/?$/,"");a=new URL(a,window.location.href).toString(),this.preprocessNode(t.root,a,n)}loadRootTileSet(){let t=this.rootURL;this.invokeAllPlugins((e=>t=e.preprocessURL?e.preprocessURL(t,null):t));const e=this.invokeOnePlugin((e=>e.fetchData&&e.fetchData(t,this.fetchOptions))).then((e=>{if(e.ok)return e.json();throw new Error(`TilesRenderer: Failed to load tileset "${t}" with status ${e.status} : ${e.statusText}`)})).then((e=>{this.preprocessTileSet(e,t),this.rootTileSet=e}));return e.catch((t=>{console.error(t),this.rootTileSet=null})),e}requestTileContents(t){if(t.__loadingState!==Nb)return;let e=!1,n=new URL(t.content.uri,t.__basePath+"/").toString();this.invokeAllPlugins((e=>n=e.preprocessURL?e.preprocessURL(n,t):n));const i=this.stats,r=this.lruCache,s=this.downloadQueue,a=this.parseQueue,o=Db(n);if(!r.add(t,(t=>{t.__loadingState===Fb?(t.__loadAbort.abort(),t.__loadAbort=null):e?t.children.length=0:this.invokeAllPlugins((e=>{e.disposeTile&&e.disposeTile(t)})),t.__loadingState===Fb?i.downloading--:t.__loadingState===Ob&&i.parsing--,t.__loadingState=Nb,t.__loadIndex++,a.remove(t),s.remove(t)})))return;t.__loadIndex++;const l=t.__loadIndex,c=new AbortController,h=c.signal;return i.downloading++,t.__loadAbort=c,t.__loadingState=Fb,s.add(t,(t=>t.__loadIndex!==l?Promise.resolve():this.invokeOnePlugin((t=>t.fetchData&&t.fetchData(n,{...this.fetchOptions,signal:h}))))).then((e=>{if(t.__loadIndex===l){if(e.ok)return"json"===o?e.json():e.arrayBuffer();throw new Error(`Failed to load model with error code ${e.status}`)}})).then((r=>{if(t.__loadIndex===l)return i.downloading--,i.parsing++,t.__loadAbort=null,t.__loadingState=Ob,a.add(t,(i=>i.__loadIndex!==l?Promise.resolve():"json"===o&&r.root?(this.preprocessTileSet(r,n,t),t.children.push(r.root),e=!0,Promise.resolve()):this.invokeOnePlugin((t=>t.parseTile&&t.parseTile(r,i,o,n)))))})).then((()=>{t.__loadIndex===l&&(i.parsing--,t.__loadingState=kb,r.setLoaded(t,!0),null===r.getMemoryUsage(t)&&(r.isFull()&&r.computeMemoryUsageCallback(t)>0?r.remove(t):r.updateMemoryUsage(t)))})).catch((e=>{t.__loadIndex===l&&("AbortError"!==e.name?(a.remove(t),s.remove(t),t.__loadingState===Ob?i.parsing--:t.__loadingState===Fb&&i.downloading--,i.failed++,console.error(`TilesRenderer : Failed to load tile at url "${t.content.uri}".`),console.error(e),t.__loadingState=Ub,r.setLoaded(t,!0)):r.remove(t))}))}getAttributions(t=[]){return this.invokeAllPlugins((e=>e!==this&&e.getAttributions&&e.getAttributions(t))),t}invokeOnePlugin(t){const e=[...this.plugins,this];for(let n=0;na+o)throw new Error("FeatureTable: Feature data read outside binary body length.");return d}}return s}getBuffer(t,e){const{buffer:n,binOffset:i}=this;return n.slice(i+t,i+t+e)}}class hS{constructor(t){this.batchTable=t;const e=t.header.extensions["3DTILES_batch_table_hierarchy"];this.classes=e.classes;for(const t of this.classes){const e=t.instances;for(const n in e)t.instances[n]=this._parseProperty(e[n],t.length,n)}if(this.instancesLength=e.instancesLength,this.classIds=this._parseProperty(e.classIds,this.instancesLength,"classIds"),e.parentCounts?this.parentCounts=this._parseProperty(e.parentCounts,this.instancesLength,"parentCounts"):this.parentCounts=new Array(this.instancesLength).fill(1),e.parentIds){const t=this.parentCounts.reduce(((t,e)=>t+e),0);this.parentIds=this._parseProperty(e.parentIds,t,"parentIds")}else this.parentIds=null;this.instancesIds=[];const n={};for(const t of this.classIds)n[t]=n[t]??0,this.instancesIds.push(n[t]),n[t]++}_parseProperty(t,e,n){if(Array.isArray(t))return t;{const{buffer:i,binOffset:r}=this.batchTable;return lS(i,r+t.byteOffset,e,"SCALAR",t.componentType||"UNSIGNED_SHORT",n)}}getDataFromId(t,e={}){const n=this.parentCounts[t];if(this.parentIds&&n>0){let i=0;for(let e=0;e=this.count)throw new Error(`BatchTable: id value "${t}" out of bounds for "${this.count}" features number.`);for(const n of this.getKeys())"extensions"!==n&&(e[n]=super.getData(n,this.count)[t]);for(const n in this.extensions){const i=this.extensions[n];i.getDataFromId instanceof Function&&(e[n]=e[n]||{},i.getDataFromId(t,e[n]))}return e}getPropertyArray(t){return super.getData(t,this.count)}}class dS{constructor(){this.fetchOptions={},this.workingPath=""}load(t){return console.warn('Loader: "load" function has been deprecated in favor of "loadAsync".'),this.loadAsync(t)}loadAsync(t){return fetch(t,this.fetchOptions).then((e=>{if(!e.ok)throw new Error(`Failed to load file "${t}" with status ${e.status} : ${e.statusText}`);return e.arrayBuffer()})).then((e=>(""===this.workingPath&&(this.workingPath=this.workingPathForURL(t)),this.parse(e))))}resolveExternalURL(t){return/^[^\\/]/.test(t)&&!/^http/.test(t)?this.workingPath+"/"+t:t}workingPathForURL(t){const e=t.split(/[\\/]/g);return e.pop(),e.join("/")+"/"}parse(t){throw new Error("LoaderBase: Parse not implemented.")}}function pS(t){let e;if(e=t instanceof DataView?t:new DataView(t),"{"===String.fromCharCode(e.getUint8(0)))return null;let n="";for(let t=0;t<4;t++)n+=String.fromCharCode(e.getUint8(t));return n}class fS extends dS{parse(t){const e=new DataView(t),n=pS(e);console.assert("b3dm"===n);const i=e.getUint32(4,!0);console.assert(1===i);const r=e.getUint32(8,!0);console.assert(r===t.byteLength);const s=e.getUint32(12,!0),a=e.getUint32(16,!0),o=e.getUint32(20,!0),l=e.getUint32(24,!0),c=t.slice(28,28+s+a),h=new cS(c,0,s,a),u=28+s+a,d=t.slice(u,u+o+l),p=new uS(d,h.getData("BATCH_LENGTH"),0,o,l),f=u+o+l;return{version:i,featureTable:h,batchTable:p,glbBytes:new Uint8Array(t,f,r-f)}}}class mS extends fS{constructor(t=$d){super(),this.manager=t,this.adjustmentTransform=new yr}parse(t){const e=super.parse(t),n=e.glbBytes.slice().buffer;return new Promise(((t,i)=>{const r=this.manager,s=this.fetchOptions,a=r.getHandler("path.gltf")||new Ug(r);"include"===s.credentials&&"cors"===s.mode&&a.setCrossOrigin("use-credentials"),"credentials"in s&&a.setWithCredentials("include"===s.credentials),s.headers&&a.setRequestHeader(s.headers);let o=this.workingPath;!/[\\/]$/.test(o)&&o.length&&(o+="/");const l=this.adjustmentTransform;a.parse(n,o,(n=>{const{batchTable:i,featureTable:r}=e,{scene:s}=n,a=r.getData("RTC_CENTER");a&&(s.position.x+=a[0],s.position.y+=a[1],s.position.z+=a[2]),n.scene.updateMatrix(),n.scene.matrix.multiply(l),n.scene.matrix.decompose(n.scene.position,n.scene.quaternion,n.scene.scale),n.batchTable=i,n.featureTable=r,s.batchTable=i,s.featureTable=r,t(n)}),i)}))}}class gS extends dS{parse(t){const e=new DataView(t),n=pS(e);console.assert("pnts"===n);const i=e.getUint32(4,!0);console.assert(1===i);const r=e.getUint32(8,!0);console.assert(r===t.byteLength);const s=e.getUint32(12,!0),a=e.getUint32(16,!0),o=e.getUint32(20,!0),l=e.getUint32(24,!0),c=t.slice(28,28+s+a),h=new cS(c,0,s,a),u=28+s+a,d=t.slice(u,u+o+l),p=new uS(d,h.getData("BATCH_LENGTH")||h.getData("POINTS_LENGTH"),0,o,l);return Promise.resolve({version:i,featureTable:h,batchTable:p})}}function AS(t){const e=t>>11,n=t>>5&63,i=31&t;return[Math.round(e/31*255),Math.round(n/63*255),Math.round(i/31*255)]}const vS={RGB:"color",POSITION:"position"};class yS extends gS{constructor(t=$d){super(),this.manager=t}parse(t){return super.parse(t).then((async t=>{const{featureTable:e,batchTable:n}=t,i=new Qh,r=e.header.extensions,s=new Hi;let a;if(r&&r["3DTILES_draco_point_compression"]){const{byteOffset:t,byteLength:n,properties:s}=r["3DTILES_draco_point_compression"],o=this.manager.getHandler("draco.drc");if(null==o)throw new Error("PNTSLoader: dracoLoader not available.");const l={};for(const t in s)t in vS&&t in s&&(l[vS[t]]=s[t]);const c={attributeIDs:l,attributeTypes:{position:"Float32Array",color:"Uint8Array"},useUniqueIDs:!0},h=e.getBuffer(t,n);a=await o.decodeGeometry(h,c),a.attributes.color&&(i.vertexColors=!0)}else{const t=e.getData("POINTS_LENGTH"),n=e.getData("POSITION",t,"FLOAT","VEC3"),r=e.getData("RGB",t,"UNSIGNED_BYTE","VEC3"),o=e.getData("RGBA",t,"UNSIGNED_BYTE","VEC4"),l=e.getData("RGB565",t,"UNSIGNED_SHORT","SCALAR"),c=e.getData("CONSTANT_RGBA",t,"UNSIGNED_BYTE","VEC4"),h=e.getData("POSITION_QUANTIZED",t,"UNSIGNED_SHORT","VEC3"),u=e.getData("QUANTIZED_VOLUME_SCALE",t,"FLOAT","VEC3"),d=e.getData("QUANTIZED_VOLUME_OFFSET",t,"FLOAT","VEC3");if(a=new Qs,h){const e=new Float32Array(3*t);for(let n=0;n{t in e.header&&console.warn(`PNTSLoader: Unsupported FeatureTable feature "${t}" detected.`)}));const o=new Wh(a,i);o.position.copy(s),t.scene=o,t.scene.featureTable=e,t.scene.batchTable=n;const l=e.getData("RTC_CENTER");return l&&(t.scene.position.x+=l[0],t.scene.position.y+=l[1],t.scene.position.z+=l[2]),t}))}}class xS extends dS{parse(t){const e=new DataView(t),n=pS(e);console.assert("i3dm"===n);const i=e.getUint32(4,!0);console.assert(1===i);const r=e.getUint32(8,!0);console.assert(r===t.byteLength);const s=e.getUint32(12,!0),a=e.getUint32(16,!0),o=e.getUint32(20,!0),l=e.getUint32(24,!0),c=e.getUint32(28,!0),h=t.slice(32,32+s+a),u=new cS(h,0,s,a),d=32+s+a,p=t.slice(d,d+o+l),f=new uS(p,u.getData("INSTANCES_LENGTH"),0,o,l),m=d+o+l,g=new Uint8Array(t,m,r-m);let A=null,v=null,y=null;if(c)A=g,v=Promise.resolve();else{const t=this.resolveExternalURL(oS(g)),e=t.split(/[\\/]/g);e.pop(),y=e.join("/"),v=fetch(t,this.fetchOptions).then((e=>{if(!e.ok)throw new Error(`I3DMLoaderBase : Failed to load file "${t}" with status ${e.status} : ${e.statusText}`);return e.arrayBuffer()})).then((t=>{A=new Uint8Array(t)}))}return v.then((()=>({version:i,featureTable:u,batchTable:f,glbBytes:A,gltfWorkingPath:y})))}}const _S=new Sf,wS=new Hi,CS={};function ES(t){const{x:e,y:n,z:i}=t;t.x=i,t.y=e,t.z=n}function MS(t){const{x:e,y:n,z:i}=t;t.z=e,t.x=n,t.y=i}function bS(t){return-(t-Math.PI/2)}function SS(t){return-t+Math.PI/2}function IS(t,e="E",n="W"){const i=t<0?n:e,r=~~(t=Math.abs(t)),s=60*(t-r),a=~~s;return`${r}° ${a}' ${~~(60*(s-a))}" ${i}`}function TS(t,e,n=!1){const i=function(t,e,n={}){return _S.theta=e,_S.phi=SS(t),wS.setFromSpherical(_S),_S.setFromVector3(wS),n.lat=bS(_S.phi),n.lon=_S.theta,n}(t,e,CS);let r,s;return n?(r=`${(ci.RAD2DEG*i.lat).toFixed(4)}°`,s=`${(ci.RAD2DEG*i.lon).toFixed(4)}°`):(r=IS(ci.RAD2DEG*i.lat,"N","S"),s=IS(ci.RAD2DEG*i.lon,"E","W")),`${r} ${s}`}const BS=new Sf,RS=new Hi,DS=new Hi,PS=new Hi,LS=new Hi,US=new yr,NS=new yr,FS=new hr,OS=new Tr,kS=new Hi,QS=new Hi,zS=new Hi,GS=new Hi,HS=new vr,VS=0,WS=1,jS=2;class qS{constructor(t=1,e=1,n=1){this.radius=new Hi(t,e,n)}intersectRay(t,e){return US.makeScale(...this.radius).invert(),FS.center.set(0,0,0),FS.radius=1,HS.copy(t).applyMatrix4(US),HS.intersectSphere(FS,e)?(US.makeScale(...this.radius),e.applyMatrix4(US),e):null}getEastNorthUpFrame(t,e,n){return this.getEastNorthUpAxes(t,e,kS,QS,zS,GS),n.makeBasis(kS,QS,zS).setPosition(GS)}getEastNorthUpAxes(t,e,n,i,r,s=GS){this.getCartographicToPosition(t,e,0,s),this.getCartographicToNormal(t,e,r),n.set(-s.y,s.x,0).normalize(),i.crossVectors(r,n).normalize()}getNorthernTangent(t,e,n,i=LS){return console.log("Ellipsoid: getNorthernTangent has been deprecated. Use getEastNorthUpAxes instead."),this.getEastNorthUpAxes(t,e,i,n,zS),i.multiplyScalar(-1),n}getAzElRollFromRotationMatrix(t,e,n,i,r=VS){return r===WS?(OS.set(-Math.PI/2,0,0,"XYZ"),NS.makeRotationFromEuler(OS).premultiply(n)):r===jS?(OS.set(-Math.PI/2,0,Math.PI,"XYZ"),NS.makeRotationFromEuler(OS).premultiply(n)):NS.copy(n),this.getEastNorthUpFrame(t,e,US).invert(),NS.premultiply(US),OS.setFromRotationMatrix(NS,"ZXY"),i.azimuth=-OS.z,i.elevation=OS.x,i.roll=OS.y,i}getRotationMatrixFromAzElRoll(t,e,n,i,r,s,a=VS){return this.getEastNorthUpFrame(t,e,US),OS.set(i,r,-n,"ZXY"),s.makeRotationFromEuler(OS).premultiply(US).setPosition(0,0,0),a===WS?(OS.set(Math.PI/2,0,0,"XYZ"),NS.makeRotationFromEuler(OS),s.multiply(NS)):a===jS&&(OS.set(-Math.PI/2,0,Math.PI,"XYZ"),NS.makeRotationFromEuler(OS),s.multiply(NS)),s}getCartographicToPosition(t,e,n,i){this.getCartographicToNormal(t,e,RS);const r=this.radius;DS.copy(RS),DS.x*=r.x**2,DS.y*=r.y**2,DS.z*=r.z**2;const s=Math.sqrt(RS.dot(DS));return DS.divideScalar(s),i.copy(DS).addScaledVector(RS,n)}getPositionToCartographic(t,e){this.getPositionToSurfacePoint(t,DS),this.getPositionToNormal(t,RS);const n=PS.subVectors(t,DS);return e.lon=Math.atan2(RS.y,RS.x),e.lat=Math.asin(RS.z),e.height=Math.sign(n.dot(t))*n.length(),e}getCartographicToNormal(t,e,n){return BS.set(1,SS(t),e),n.setFromSpherical(BS).normalize(),ES(n),n}getPositionToNormal(t,e){const n=this.radius;return e.copy(t),e.x/=n.x**2,e.y/=n.y**2,e.z/=n.z**2,e.normalize(),e}getPositionToSurfacePoint(t,e){const n=this.radius,i=1/n.x**2,r=1/n.y**2,s=1/n.z**2,a=t.x*t.x*i,o=t.y*t.y*r,l=t.z*t.z*s,c=a+o+l,h=Math.sqrt(1/c),u=DS.copy(t).multiplyScalar(h);if(c<.1)return isFinite(h)?e.copy(u):null;const d=PS.set(u.x*i*2,u.y*r*2,u.z*s*2);let p,f,m,g,A,v,y,x,_,w,C,E=(1-h)*t.length()/(.5*d.length()),M=0;do{E-=M,m=1/(1+E*i),g=1/(1+E*r),A=1/(1+E*s),v=m*m,y=g*g,x=A*A,_=v*m,w=y*g,C=x*A,p=a*v+o*y+l*x-1,f=a*_*i+o*w*r+l*C*s,M=p/(-2*f)}while(Math.abs(p)>1e-12);return e.set(t.x*m,t.y*g,t.z*A)}calculateHorizonDistance(t,e){const n=this.calculateEffectiveRadius(t);return Math.sqrt(2*n*e+e**2)}calculateEffectiveRadius(t){const e=this.radius.x,n=1-this.radius.z**2/e**2,i=t*ci.DEG2RAD,r=Math.sin(i)**2;return e/Math.sqrt(1-n*r)}getPositionElevation(t){this.getPositionToSurfacePoint(t,DS);const e=PS.subVectors(t,DS);return Math.sign(e.dot(t))*e.length()}copy(t){return this.radius.copy(t.radius),this}clone(){return(new this.constructor).copy(this)}}const XS=new qS(Qb,Qb,Gb),YS=new qS(Vb,Vb,Hb),JS=new Hi,KS=new Hi,ZS=new Hi,$S=new Hi,tI=new Gi,eI=new Hi,nI=new yr,iI=new yr,rI=new Hi,sI=new yr,aI=new Gi,oI={};class lI extends xS{constructor(t=$d){super(),this.manager=t,this.adjustmentTransform=new yr,this.ellipsoid=XS.clone()}resolveExternalURL(t){return this.manager.resolveURL(super.resolveExternalURL(t))}parse(t){return super.parse(t).then((t=>{const{featureTable:e,batchTable:n}=t,i=t.glbBytes.slice().buffer;return new Promise(((r,s)=>{const a=this.fetchOptions,o=this.manager,l=o.getHandler("path.gltf")||new Ug(o);"include"===a.credentials&&"cors"===a.mode&&l.setCrossOrigin("use-credentials"),"credentials"in a&&l.setWithCredentials("include"===a.credentials),a.headers&&l.setRequestHeader(a.headers);let c=t.gltfWorkingPath??this.workingPath;/[\\/]$/.test(c)||(c+="/");const h=this.adjustmentTransform;l.parse(i,c,(t=>{const i=e.getData("INSTANCES_LENGTH"),s=e.getData("POSITION",i,"FLOAT","VEC3"),a=e.getData("NORMAL_UP",i,"FLOAT","VEC3"),o=e.getData("NORMAL_RIGHT",i,"FLOAT","VEC3"),l=e.getData("SCALE_NON_UNIFORM",i,"FLOAT","VEC3"),c=e.getData("SCALE",i,"FLOAT","SCALAR"),u=e.getData("RTC_CENTER"),d=e.getData("EAST_NORTH_UP");["QUANTIZED_VOLUME_OFFSET","QUANTIZED_VOLUME_SCALE","POSITION_QUANTIZED","NORMAL_UP_OCT32P","NORMAL_RIGHT_OCT32P"].forEach((t=>{t in e.header&&console.warn(`I3DMLoader: Unsupported FeatureTable feature "${t}" detected.`)}));const p=new Hi;for(let t=0;t{if(t.isMesh){m.push(t);const{geometry:e,material:n}=t,r=new oh(e,n,i);r.position.copy(p),u&&(r.position.x+=u[0],r.position.y+=u[1],r.position.z+=u[2]),f.push(r)}}));for(let t=0;t{const e=new ic;return t.forEach((t=>{e.add(t.scene)})),{tiles:t,scene:e}}))}}class uI{constructor(){this.name="CESIUM_RTC"}afterRoot(t){if(t.parser.json.extensions&&t.parser.json.extensions.CESIUM_RTC){const{center:e}=t.parser.json.extensions.CESIUM_RTC;e&&(t.scene.position.x+=e[0],t.scene.position.y+=e[1],t.scene.position.z+=e[2])}}}class dI extends uI{constructor(...t){super(...t),console.warn('GLTFCesiumRTCExtension: Plugins should now be imported from "3d-tiles-renderer/plugins" path.')}}class pI extends dS{constructor(t=$d){super(),this.manager=t}parse(t){return new Promise(((e,n)=>{const i=this.manager,r=this.fetchOptions;let s=i.getHandler("path.gltf")||i.getHandler("path.glb");s||(s=new Ug(i),s.register((()=>new dI))),"include"===r.credentials&&"cors"===r.mode&&s.setCrossOrigin("use-credentials"),"credentials"in r&&s.setWithCredentials("include"===r.credentials),r.headers&&s.setRequestHeader(r.headers);let a=s.resourcePath||s.path||this.workingPath;!/[\\/]$/.test(a)&&a.length&&(a+="/"),s.parse(t,a,(t=>{e(t)}),n)}))}}const fI=new yr;class mI extends ic{constructor(t){super(),this.name="TilesRenderer.TilesGroup",this.tilesRenderer=t}raycast(t,e){return!this.tilesRenderer.optimizeRaycast||(this.tilesRenderer.raycast(t,e),!1)}updateMatrixWorld(t){if(this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldNeedsUpdate||t){null===this.parent?fI.copy(this.matrix):fI.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1;const t=fI.elements,e=this.matrixWorld.elements;let n=!1;for(let i=0;i<16;i++){const r=t[i],s=e[i];if(Math.abs(r-s)>Number.EPSILON){n=!0;break}}if(n){this.matrixWorld.copy(fI);const t=this.children;for(let e=0,n=t.length;e{Object.getPrototypeOf(t).raycast.call(t,e,i)})):n.invokeOnePlugin((n=>n.raycastTile&&n.raycastTile(t,r,e,i)))||e.intersectObject(r,!0,i)}function CI(t,e,n,i=null){const{group:r,activeTiles:s}=t;t.ensureChildrenArePreprocessed(e),null===i&&(i=vI,AI.copy(r.matrixWorld).invert(),i.copy(n.ray).applyMatrix4(AI));const a=[],o=e.children;for(let t=0,e=o.length;tc)break;const h=CI(t,o,n,i);if(h){const t=h.distance*h.distance;tnew Hi)),this.planes=new Array(6).fill().map((()=>new va))}clampPoint(t,e){return e.copy(t).applyMatrix4(this.inverseTransform).clamp(this.box.min,this.box.max).applyMatrix4(this.transform)}distanceToPoint(t){return this.clampPoint(t,SI).distanceTo(t)}containsPoint(t){return SI.copy(t).applyMatrix4(this.inverseTransform),this.box.containsPoint(SI)}intersectsRay(t){return II.copy(t).applyMatrix4(this.inverseTransform),II.intersectsBox(this.box)}intersectRay(t,e){return II.copy(t).applyMatrix4(this.inverseTransform),II.intersectBox(this.box,e)?(e.applyMatrix4(this.transform),e):null}update(){const{points:t,inverseTransform:e,transform:n,box:i}=this;e.copy(n).invert();const{min:r,max:s}=i;let a=0;for(let e=-1;e<=1;e+=2)for(let i=-1;i<=1;i+=2)for(let o=-1;o<=1;o+=2)t[a].set(e<0?r.x:s.x,i<0?r.y:s.y,o<0?r.z:s.z).applyMatrix4(n),a++;this.updatePlanes()}updatePlanes(){MI.copy(this.box.min).applyMatrix4(this.transform),bI.copy(this.box.max).applyMatrix4(this.transform),SI.set(0,0,1).transformDirection(this.transform),this.planes[0].setFromNormalAndCoplanarPoint(SI,MI),this.planes[1].setFromNormalAndCoplanarPoint(SI,bI).negate(),SI.set(0,1,0).transformDirection(this.transform),this.planes[2].setFromNormalAndCoplanarPoint(SI,MI),this.planes[3].setFromNormalAndCoplanarPoint(SI,bI).negate(),SI.set(1,0,0).transformDirection(this.transform),this.planes[4].setFromNormalAndCoplanarPoint(SI,MI),this.planes[5].setFromNormalAndCoplanarPoint(SI,bI).negate()}intersectsFrustum(t){const{points:e}=this,{planes:n}=t;for(let t=0;t<6;t++){const i=n[t];let r=-1/0;for(let t=0;t<8;t++){const n=e[t],s=i.distanceToPoint(n);r=r=e&&a<=n&&o>=i&&o<=r){const e=OI(t);u.push(e),this.getCartographicToPosition(a,o,l,e)}}}return u}getBoundingBox(t,e){kI();const{latStart:n,latEnd:i,lonStart:r,lonEnd:s}=this;if(i-nr?i:r}intersectsFrustum(t){const e=this.obb||this.regionObb,n=this.sphere;return!(n&&!t.intersectsSphere(n))&&!(e&&!e.intersectsFrustum(t))&&Boolean(n||e)}getOBB(t,e){const n=this.obb||this.regionObb;n?(t.copy(n.box),e.copy(n.transform)):(this.getAABB(t),e.identity())}getAABB(t){if(this.sphere)this.sphere.getBoundingBox(t);else{const e=this.obb||this.regionObb;t.copy(e.box).applyMatrix4(e.transform)}}getSphere(t){if(this.sphere)t.copy(this.sphere);else if(this.region)this.region.getBoundingSphere(t);else{const e=this.obb||this.regionObb;e.box.getBoundingSphere(t),t.applyMatrix4(e.transform)}}setObbData(t,e){const n=new TI;zI.set(t[3],t[4],t[5]),GI.set(t[6],t[7],t[8]),HI.set(t[9],t[10],t[11]);const i=zI.length(),r=GI.length(),s=HI.length();zI.normalize(),GI.normalize(),HI.normalize(),0===i&&zI.crossVectors(GI,HI),0===r&&GI.crossVectors(zI,HI),0===s&&HI.crossVectors(zI,GI),n.transform.set(zI.x,GI.x,HI.x,t[0],zI.y,GI.y,HI.y,t[1],zI.z,GI.z,HI.z,t[2],0,0,0,1).premultiply(e),n.box.min.set(-i,-r,-s),n.box.max.set(i,r,s),n.update(),this.obb=n}setSphereData(t,e,n,i,r){const s=new hr;s.center.set(t,e,n),s.radius=i,s.applyMatrix4(r),this.sphere=s}setRegionData(t,e,n,i,r,s,a){const o=new QI(...t.radius,n,r,e,i,s,a),l=new TI;o.getBoundingBox(l.box,l.transform),l.update(),this.region=o,this.regionObb=l}}const qI=new ui;class XI extends _a{constructor(){super(),this.points=Array(8).fill().map((()=>new Hi))}setFromProjectionMatrix(t,e){super.setFromProjectionMatrix(t,e),this.calculateFrustumPoints()}calculateFrustumPoints(){const{planes:t,points:e}=this;[[t[0],t[3],t[4]],[t[1],t[3],t[4]],[t[0],t[2],t[4]],[t[1],t[2],t[4]],[t[0],t[3],t[5]],[t[1],t[3],t[5]],[t[0],t[2],t[5]],[t[1],t[2],t[5]]].forEach(((t,n)=>{!function(t,e,n,i){const r=qI.set(t.normal.x,t.normal.y,t.normal.z,e.normal.x,e.normal.y,e.normal.z,n.normal.x,n.normal.y,n.normal.z);i.set(-t.constant,-e.constant,-n.constant),i.applyMatrix3(r.invert())}(t[0],t[1],t[2],e[n])}))}}const YI=new yr,JI=new Tr,KI=parseInt(f)<165,ZI=Symbol("INITIAL_FRUSTUM_CULLED"),$I=new yr,tT=new yr,eT=new Hi,nT=new hi,iT=new Hi(1,0,0),rT=new Hi(0,1,0);function sT(t,e){t.traverse((t=>{t.frustumCulled=t[ZI]&&e}))}class aT extends sS{get autoDisableRendererCulling(){return this._autoDisableRendererCulling}set autoDisableRendererCulling(t){this._autoDisableRendererCulling!==t&&(super._autoDisableRendererCulling=t,this.forEachLoadedModel((e=>{sT(e,!t)})))}constructor(...t){super(...t),this.group=new mI(this),this.ellipsoid=XS.clone(),this.cameras=[],this.cameraMap=new Map,this.cameraInfo=[],this.activeTiles=new Set,this.visibleTiles=new Set,this.optimizeRaycast=!0,this._eventDispatcher=new Zn,this._upRotationMatrix=new yr,this.lruCache.computeMemoryUsageCallback=t=>t.cached.bytesUsed??null,this._autoDisableRendererCulling=!0,this._loadingTiles=!1;const e=new Zd;if(e.setURLModifier((t=>this.preprocessURL?this.preprocessURL(t):t)),this.manager=e,KI){const t=this;this._overridenRaycast=function(e,n){t.optimizeRaycast||Object.getPrototypeOf(this).raycast.call(this,e,n)}}}addEventListener(...t){this._eventDispatcher.addEventListener(...t)}hasEventListener(...t){this._eventDispatcher.hasEventListener(...t)}removeEventListener(...t){this._eventDispatcher.removeEventListener(...t)}dispatchEvent(...t){this._eventDispatcher.dispatchEvent(...t)}getBounds(...t){return console.warn("TilesRenderer: getBounds has been renamed to getBoundingBox."),this.getBoundingBox(...t)}getOrientedBounds(...t){return console.warn("TilesRenderer: getOrientedBounds has been renamed to getOrientedBoundingBox."),this.getOrientedBoundingBox(...t)}getBoundingBox(t){if(!this.root)return!1;const e=this.root.cached.boundingVolume;return!!e&&(e.getAABB(t),!0)}getOrientedBoundingBox(t,e){if(!this.root)return!1;const n=this.root.cached.boundingVolume;return!!n&&(n.getOBB(t,e),!0)}getBoundingSphere(t){if(!this.root)return!1;const e=this.root.cached.boundingVolume;return!!e&&(e.getSphere(t),!0)}forEachLoadedModel(t){this.traverse((e=>{const n=e.cached.scene;n&&t(n,e)}))}raycast(t,e){if(this.root)if(t.firstHitOnly){const n=CI(this,this.root,t);n&&e.push(n)}else EI(this,this.root,t,e)}hasCamera(t){return this.cameraMap.has(t)}setCamera(t){const e=this.cameras,n=this.cameraMap;return!n.has(t)&&(n.set(t,new hi),e.push(t),this.dispatchEvent({type:"add-camera",camera:t}),!0)}setResolution(t,e,n){const i=this.cameraMap;if(!i.has(t))return!1;const r=e.isVector2?e.x:e,s=e.isVector2?e.y:n,a=i.get(t);return a.width===r&&a.height===s||(a.set(r,s),this.dispatchEvent({type:"camera-resolution-change"})),!0}setResolutionFromRenderer(t,e){return e.getSize(nT).multiplyScalar(e.getPixelRatio()),this.setResolution(t,nT.x,nT.y)}deleteCamera(t){const e=this.cameras,n=this.cameraMap;if(n.has(t)){const i=e.indexOf(t);return e.splice(i,1),n.delete(t),this.dispatchEvent({type:"delete-camera",camera:t}),!0}return!1}preprocessTileSet(t,e,n){super.preprocessTileSet(t,e,n),queueMicrotask((()=>{this.dispatchEvent({type:"load-tile-set",tileSet:t,url:e})}))}loadRootTileSet(...t){return super.loadRootTileSet(...t).then((()=>{switch((this.rootTileSet.asset&&this.rootTileSet.asset.gltfUpAxis||"y").toLowerCase()){case"x":this._upRotationMatrix.makeRotationAxis(rT,-Math.PI/2);break;case"y":this._upRotationMatrix.makeRotationAxis(iT,Math.PI/2)}this.dispatchEvent({type:"load-content"})})).catch((()=>{}))}update(){let t=null;if(this.invokeAllPlugins((e=>{if(e.doTilesNeedUpdate){const n=e.doTilesNeedUpdate();t=null===t?n:t||n}})),!1===t)return this.dispatchEvent({type:"update-before"}),void this.dispatchEvent({type:"update-after"});this.dispatchEvent({type:"update-before"});const e=this.group,n=this.cameras,i=this.cameraMap,r=this.cameraInfo;if(0!==n.length){for(;r.length>n.length;)r.pop();for(;r.length1e-6&&console.warn("ThreeTilesRenderer : Non uniform scale used for tile which may cause issues when calculating screen space error.");for(let t=0,s=r.length;tt.scene));break}case"gltf":case"glb":{const e=new pI(c);e.workingPath=o,e.fetchOptions=l,u=e.parse(t);break}default:console.warn(`TilesRenderer: Content type "${f}" not supported.`),u=Promise.resolve(null)}const m=this.stats;!1===this._loadingTiles&&m.parsing+m.downloading>0&&(this.dispatchEvent({type:"tiles-load-start"}),this._loadingTiles=!0);const g=await u;let A,v;if(g.isObject3D?(A=g,v=null):(A=g.scene,v=g),await this.invokeAllPlugins((t=>t.processTileModel&&t.processTileModel(A,n))),s._loadIndex!==h)return;A.updateMatrix(),"glb"!==f&&"gltf"!==f||A.matrix.multiply(p),A.matrix.premultiply(d),A.matrix.decompose(A.position,A.quaternion,A.scale),A.traverse((t=>{t[ZI]=t.frustumCulled})),sT(A,!this.autoDisableRendererCulling),KI&&A.traverse((t=>{t.raycast=this._overridenRaycast}));const y=[],x=[],_=[];A.traverse((t=>{if(t.geometry&&x.push(t.geometry),t.material){const e=t.material;y.push(t.material);for(const t in e){const n=e[t];n&&n.isTexture&&_.push(n)}}})),s.materials=y,s.geometry=x,s.textures=_,s.scene=A,s.metadata=v,s.bytesUsed=function(t){const{TextureUtils:n}=e;if(!n)return 0;const i=new Set;let r=0;return t.traverse((t=>{if(t.geometry&&!i.has(t.geometry)&&(r+=Pg(t.geometry),i.add(t.geometry)),t.material){const e=t.material;for(const t in e){const s=e[t];if(s&&s.isTexture&&!i.has(s)){const{format:t,type:e,image:a}=s,{width:o,height:l}=a,c=n.getByteLength(o,l,t,e);r+=s.generateMipmaps?4*c/3:c,i.add(s)}}}})),r}(A),this.dispatchEvent({type:"load-model",scene:A,tile:n}),!0===this._loadingTiles&&m.parsing+m.downloading===1&&(this.dispatchEvent({type:"tiles-load-end"}),this._loadingTiles=!1)}disposeTile(t){super.disposeTile(t);const e=t.cached;if(e.scene){const n=e.materials,i=e.geometry,r=e.textures,s=e.scene.parent;e.scene.traverse((t=>{t.userData.meshFeatures&&t.userData.meshFeatures.dispose(),t.userData.structuralMetadata&&t.userData.structuralMetadata.dispose()}));for(let t=0,e=i.length;t{const n=Symbol(t);Object.defineProperty(aT.prototype,t,{get(){return this[n]||null},set(i){console.warn(`TilesRenderer: "${t}" has been deprecated in favor of the "${e}" event.`),this[n]&&this.removeEventListener(e,this[n]),this[n]=i,this.addEventListener(e,i)}})}));const oT=new Hi,lT=["x","y","z"];class cT extends Oh{constructor(t,e=16776960,n=40){const i=new Qs,r=[];for(let t=0;t<3;t++){const e=lT[t],i=lT[(t+1)%3];oT.set(0,0,0);for(let t=0;t.1&&(dT.z>0&&uT.multiplyScalar(-1),l.setXYZ(s,...uT))}return o}(this.ellipsoidRegion);this.geometry.dispose(),this.geometry=new Du(t,80)}dispose(){this.geometry.dispose(),this.material.dispose()}}const fT=Symbol("ORIGINAL_MATERIAL"),mT=Symbol("HAS_RANDOM_COLOR"),gT=Symbol("HAS_RANDOM_NODE_COLOR"),AT=Symbol("LOAD_TIME"),vT=new hr,yT=()=>{},xT={};function _T(t){if(!xT[t]){const e=Math.random(),n=.5+.5*Math.random(),i=.375+.25*Math.random();xT[t]=(new us).setHSL(e,n,i)}return xT[t]}const wT=0,CT=1,ET=2,MT=3,bT=4,ST=5,IT=6,TT=7,BT=8,RT=9,DT=10;class PT{constructor(t){t={displayBoxBounds:!1,displaySphereBounds:!1,displayRegionBounds:!1,colorMode:wT,maxDebugDepth:-1,maxDebugDistance:-1,maxDebugError:-1,customColorCallback:null,...t},this.name="DEBUG_TILES_PLUGIN",this.tiles=null,this.extremeDebugDepth=-1,this.extremeDebugError=-1,this.boxGroup=null,this.sphereGroup=null,this.regionGroup=null,this.displayBoxBounds=t.displayBoxBounds,this.displaySphereBounds=t.displaySphereBounds,this.displayRegionBounds=t.displayRegionBounds,this.colorMode=t.colorMode,this.maxDebugDepth=t.maxDebugDepth,this.maxDebugDistance=t.maxDebugDistance,this.maxDebugError=t.maxDebugError,this.customColorCallback=t.customColorCallback,this.getDebugColor=(t,e)=>{e.setRGB(t,t,t)}}init(t){this.tiles=t;const e=t.group;this.boxGroup=new ic,this.boxGroup.name="DebugTilesRenderer.boxGroup",e.add(this.boxGroup),this.boxGroup.updateMatrixWorld(),this.sphereGroup=new ic,this.sphereGroup.name="DebugTilesRenderer.sphereGroup",e.add(this.sphereGroup),this.sphereGroup.updateMatrixWorld(),this.regionGroup=new ic,this.regionGroup.name="DebugTilesRenderer.regionGroup",e.add(this.regionGroup),this.regionGroup.updateMatrixWorld(),this._onLoadTileSetCB=()=>{this._initExtremes()},this._onLoadModelCB=({scene:t,tile:e})=>{this._onLoadModel(t,e)},this._onDisposeModelCB=({tile:t})=>{this._onDisposeModel(t)},this._onUpdateAfterCB=()=>{this._onUpdateAfter()},this._onTileVisibilityChangeCB=({scene:t,tile:e,visible:n})=>{this._onTileVisibilityChange(e,n)},t.addEventListener("load-tile-set",this._onLoadTileSetCB),t.addEventListener("load-model",this._onLoadModelCB),t.addEventListener("dispose-model",this._onDisposeModelCB),t.addEventListener("update-after",this._onUpdateAfterCB),t.addEventListener("tile-visibility-change",this._onTileVisibilityChangeCB),t.traverse((t=>{t.cached.scene&&this._onLoadModel(t.cached.scene,t)})),t.visibleTiles.forEach((t=>{this._onTileVisibilityChange(t,!0)}))}getTileInformationFromActiveObject(t){let e=null;return this.tiles.activeTiles.forEach((n=>{if(e)return!0;const i=n.cached.scene;i&&i.traverse((i=>{i===t&&(e=n)}))})),e?{distanceToCamera:e.__distanceFromCamera,geometricError:e.geometricError,screenSpaceError:e.__error,depth:e.__depth,isLeaf:e.__isLeaf}:null}_initExtremes(){let t=-1;this.tiles.traverse((e=>{t=Math.max(t,e.__depth)}));let e=-1;this.tiles.traverse((t=>{e=Math.max(e,t.geometricError)})),this.extremeDebugDepth=t,this.extremeDebugError=e}_onUpdateAfter(){const t=this.tiles;if(!t.root)return;this.boxGroup.visible=this.displayBoxBounds,this.sphereGroup.visible=this.displaySphereBounds,this.regionGroup.visible=this.displayRegionBounds;let e=-1;e=-1===this.maxDebugDepth?this.extremeDebugDepth:this.maxDebugDepth;let n=-1;n=-1===this.maxDebugError?this.extremeDebugError:this.maxDebugError;let i=-1;-1===this.maxDebugDistance?(t.getBoundingSphere(vT),i=vT.radius):i=this.maxDebugDistance;const r=this.errorTarget,s=this.colorMode,a=t.visibleTiles;let o;s===DT&&(o=Array.from(a).sort(((t,e)=>t[AT]-e[AT]))),a.forEach((t=>{const a=t.cached.scene;let l,c,h;s===TT&&(l=Math.random(),c=.5+.5*Math.random(),h=.375+.25*Math.random()),a.traverse((a=>{s===BT&&(l=Math.random(),c=.5+.5*Math.random(),h=.375+.25*Math.random());const u=a.material;if(u){const d=a[fT];if(s===wT&&u!==d)a.material.dispose(),a.material=a[fT];else if(s!==wT&&u===d)if(a.isPoints){const t=new Qh;t.size=d.size,t.sizeAttenuation=d.sizeAttenuation,a.material=t}else a.material=new Cd,a.material.flatShading=!0;switch(s!==TT&&delete a.material[mT],s!==BT&&delete a.material[gT],s){case bT:{const n=t.__depth/e;this.getDebugColor(n,a.material.color);break}case ST:{const n=t.__depthFromRenderedParent/e;this.getDebugColor(n,a.material.color);break}case CT:{const e=t.__error/r;e>1?a.material.color.setRGB(1,0,0):this.getDebugColor(e,a.material.color);break}case ET:{const e=Math.min(t.geometricError/n,1);this.getDebugColor(e,a.material.color);break}case MT:{const e=Math.min(t.__distanceFromCamera/i,1);this.getDebugColor(e,a.material.color);break}case IT:t.children&&0!==t.children.length?this.getDebugColor(0,a.material.color):this.getDebugColor(1,a.material.color);break;case BT:a.material[gT]||(a.material.color.setHSL(l,c,h),a.material[gT]=!0);break;case TT:a.material[mT]||(a.material.color.setHSL(l,c,h),a.material[mT]=!0);break;case RT:this.customColorCallback?this.customColorCallback(t,a):console.warn("DebugTilesRenderer: customColorCallback not defined");break;case DT:{const e=o.indexOf(t);this.getDebugColor(e/(o.length-1),a.material.color);break}}}}))}))}_onTileVisibilityChange(t,e){const n=t.cached,i=this.sphereGroup,r=this.boxGroup,s=this.regionGroup,a=n.boxHelperGroup,o=n.sphereHelper,l=n.regionHelper;e?(a&&(r.add(a),a.updateMatrixWorld(!0)),o&&(i.add(o),o.updateMatrixWorld(!0)),l&&(s.add(l),l.updateMatrixWorld(!0))):(a&&r.remove(a),o&&i.remove(o),l&&s.remove(l))}_onLoadModel(t,e){e[AT]=performance.now();const n=this.tiles,i=e.cached,{sphere:r,obb:s,region:a}=i.boundingVolume;if(s){const t=new ic;t.name="DebugTilesRenderer.boxHelperGroup",t.matrix.copy(s.transform),t.matrixAutoUpdate=!1;const r=new sm(s.box,_T(e.__depth));r.raycast=yT,t.add(r),i.boxHelperGroup=t,n.visibleTiles.has(e)&&this.displayBoxBounds&&(this.boxGroup.add(t),t.updateMatrixWorld(!0))}if(r){const t=new cT(r,_T(e.__depth));t.raycast=yT,i.sphereHelper=t,n.visibleTiles.has(e)&&this.displaySphereBounds&&(this.sphereGroup.add(t),t.updateMatrixWorld(!0))}if(a){const t=new pT(a,_T(e.__depth));t.raycast=yT;const r=new hr;a.getBoundingSphere(r),t.position.copy(r.center),r.center.multiplyScalar(-1),t.geometry.translate(...r.center),i.regionHelper=t,n.visibleTiles.has(e)&&this.displayRegionBounds&&(this.regionGroup.add(t),t.updateMatrixWorld(!0))}t.traverse((t=>{const e=t.material;e&&(t[fT]=e)}))}_onDisposeModel(t){const e=t.cached;e.boxHelperGroup&&(e.boxHelperGroup.children[0].geometry.dispose(),delete e.boxHelperGroup),e.sphereHelper&&(e.sphereHelper.geometry.dispose(),delete e.sphereHelper),e.regionHelper&&(e.regionHelper.geometry.dispose(),delete e.regionHelper)}dispose(){const t=this.tiles;t.removeEventListener("load-tile-set",this._onLoadTileSetCB),t.removeEventListener("load-model",this._onLoadModelCB),t.removeEventListener("dispose-model",this._onDisposeModelCB),t.removeEventListener("update-after",this._onUpdateAfterCB),this.colorMode=wT,this._onUpdateAfter(),t.traverse((t=>{this._onDisposeModel(t)})),this.boxGroup.removeFromParent(),this.sphereGroup.removeFromParent(),this.regionGroup.removeFromParent()}}class LT extends PT{constructor(...t){super(...t),console.warn('DebugTilesPlugin: Plugins should now be imported from "3d-tiles-renderer/plugins" path.')}}const UT=Symbol("DEBUG_PLUGIN");class NT extends aT{constructor(...t){super(...t),console.warn('DebugTilesRenderer: "DebugTilesRenderer" has been deprecated in favor of "DebugTilesPlugin".'),this[UT]=new LT,this.registerPlugin(this[UT])}}["displayBoxBounds","displaySphereBounds","displayRegionBounds","colorMode","customColorCallback","boxGroup","sphereGroup","regionGroup","maxDebugDepth","maxDebugDistance","maxDebugError","getDebugColor","extremeDebugDepth","extremeDebugError"].forEach((t=>{Object.defineProperty(NT.prototype,t,{get(){return this[UT][t]},set(e){this[UT][t]=e}})}));class FT{constructor(t,e,n,i){FT.prototype.isMatrix2=!0,this.elements=[1,0,0,1],void 0!==t&&this.set(t,e,n,i)}identity(){return this.set(1,0,0,1),this}fromArray(t,e=0){for(let n=0;n<4;n++)this.elements[n]=t[n+e];return this}set(t,e,n,i){const r=this.elements;return r[0]=t,r[1]=n,r[2]=e,r[3]=i,this}}function OT(t,e,n){return t&&e in t?t[e]:n}function kT(t){return"BOOLEAN"!==t&&"STRING"!==t&&"ENUM"!==t}function QT(t){return/^VEC/.test(t)}function zT(t){return/^MATRIX/.test(t)}function GT(t,e,n,i=null){return zT(n)||QT(n)?i.fromArray(t,e):t[e]}function HT(t){const{type:e,componentType:n}=t;switch(e){case"SCALAR":return"INT64"===n?0n:0;case"VEC2":return new hi;case"VEC3":return new Hi;case"VEC4":return new Ui;case"MAT2":return new FT;case"MAT3":return new ui;case"MAT4":return new yr;case"BOOLEAN":return!1;case"STRING":return"";case"ENUM":return 0}}function VT(t,e){if(null==e)return!1;switch(t){case"SCALAR":case"ENUM":return"number"==typeof e||"bigint"==typeof e;case"VEC2":return e.isVector2;case"VEC3":return e.isVector3;case"VEC4":return e.isVector4;case"MAT2":return e.isMatrix2;case"MAT3":return e.isMatrix3;case"MAT4":return e.isMatrix4;case"BOOLEAN":return"boolean"==typeof e;case"STRING":return"string"==typeof e}throw new Error("ClassProperty: invalid type.")}function WT(t,e=null){switch(t){case"INT8":return Int8Array;case"INT16":return Int16Array;case"INT32":return Int32Array;case"INT64":return BigInt64Array;case"UINT8":return Uint8Array;case"UINT16":return Uint16Array;case"UINT32":return Uint32Array;case"UINT64":return BigUint64Array;case"FLOAT32":return Float32Array;case"FLOAT64":return Float64Array}switch(e){case"BOOLEAN":case"STRING":return Uint8Array}throw new Error("ClassProperty: invalid type.")}function jT(t,e=null){const n=t.default,i=t.type;if(e=e||HT(t),null===n){switch(i){case"SCALAR":return 0;case"VEC2":return e.set(0,0);case"VEC3":return e.set(0,0,0);case"VEC4":return e.set(0,0,0,0);case"MAT2":case"MAT3":case"MAT4":return e.identity();case"BOOLEAN":return!1;case"STRING":case"ENUM":return""}throw new Error("ClassProperty: invalid type.")}if(zT(i))e.fromArray(n);else{if(!QT(i))return n;e.fromArray(n)}}function qT(t,e,n=null){if(t.array){Array.isArray(e)||(e=new Array(t.count||0)),e.length=null!==n?n:t.count;for(let n=0,i=e.length;ne.value===t));return null===n?"":n.name}}adjustValueScaleOffset(t){return kT(this.type)?function(t,e){const{type:n,componentType:i,scale:r,offset:s,normalized:a}=t;if(Array.isArray(e))for(let t=0,n=e.length;t=this.count)throw new Error("PropertyAttributeAccessor: Requested index is outside the range of the buffer.");const r=this.properties[t],s=r.type;if(!r)throw new Error("PropertyAttributeAccessor: Requested class property does not exist.");if(!this.definition.properties[t])return r.resolveDefault(i);i=r.shapeToProperty(i);const a=n.getAttribute(r.attribute.toLowerCase());if(zT(s)){const t=i.elements;for(let n=0,i=t.length;n>e&1)}return i}getPropertyValue(t,e,n=null){if(e>=this.count)throw new Error("PropertyTableAccessor: Requested index is outside the range of the table.");const i=this.properties[t];if(!i)throw new Error("PropertyTableAccessor: Requested property does not exist.");if(!this.definition.properties[t])return i.resolveDefault(n);const r=i.array,s=this.data,a=i.getArrayLengthFromId(s,e);if(n=i.shapeToProperty(n,a),r)for(let i=0,r=n.length;i=165,nB=parseInt(f)>=166,iB=new Rf,rB=new Ui,sB=new hi,aB=new class{constructor(){this._renderer=new dc,this._target=new Fi(1,1),this._texTarget=new Fi,this._quad=new ym(new sa({blending:P,blendDst:k,blendSrc:Q,uniforms:{map:{value:null},pixel:{value:new hi}},vertexShader:"\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t\t\t}\n\t\t\t",fragmentShader:"\n\t\t\t\tuniform sampler2D map;\n\t\t\t\tuniform ivec2 pixel;\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tgl_FragColor = texelFetch( map, pixel, 0 );\n\n\t\t\t\t}\n\t\t\t"}))}increaseSizeTo(t){this._target.setSize(Math.max(this._target.width,t),1)}readDataAsync(t){const{_renderer:e,_target:n}=this;return eB?e.readRenderTargetPixelsAsync(n,0,0,t.length/4,1,t):Promise.resolve().then((()=>this.readData(t)))}readData(t){const{_renderer:e,_target:n}=this;e.readRenderTargetPixels(n,0,0,t.length/4,1,t)}renderPixelToTarget(t,e,n){const{_quad:i,_renderer:r,_target:s,_texTarget:a}=this;if(nB)iB.min.copy(e),iB.max.copy(e),iB.max.x+=1,iB.max.y+=1,r.initRenderTarget(s),r.copyTextureToTexture(t,s.texture,iB,n,0);else{const o=r.autoClear,l=r.getRenderTarget(),c=r.getScissorTest();r.getScissor(rB),a.setSize(t.image.width,t.image.height),r.setRenderTarget(a),sB.set(0,0),eB?r.copyTextureToTexture(t,a.texture,null,sB):r.copyTextureToTexture(sB,t,a.texture),i.material.uniforms.map.value=a.texture,i.material.uniforms.pixel.value.copy(e),r.setRenderTarget(s),r.setScissorTest(!0),r.setScissor(n.x,n.y,1,1),r.autoClear=!1,i.render(r),r.setScissorTest(c),r.setScissor(rB),r.setRenderTarget(l),r.autoClear=o,a.dispose()}}},oB=new hi,lB=new hi,cB=new hi;function hB(t,e,n=new Array(3)){let i=3*e,r=3*e+1,s=3*e+2;return t.index&&(i=t.index.getX(i),r=t.index.getX(r),s=t.index.getX(s)),n[0]=i,n[1]=r,n[2]=s,n}function uB(t,e,n,i,r){const[s,a,o]=i,l=function(t,e){return 0===e?t.getAttribute("uv"):t.getAttribute(`uv${e}`)}(t,e);oB.fromBufferAttribute(l,s),lB.fromBufferAttribute(l,a),cB.fromBufferAttribute(l,o),r.set(0,0,0).addScaledVector(oB,n.x).addScaledVector(lB,n.y).addScaledVector(cB,n.z)}function dB(t,e,n,i){const r=t.x-Math.floor(t.x),s=t.y-Math.floor(t.y),a=Math.floor(r*e%e),o=Math.floor(s*n%n);return i.set(a,o),i}const pB=new hi,fB=new hi,mB=new hi;class gB extends YT{constructor(t,e,n=null){super(t,e,n),this.channels=OT(n,"channels",[0]),this.index=OT(n,"index",null),this.texCoord=OT(n,"texCoord",null),this.valueLength=parseInt(this.type.replace(/[^0-9]/g,""))||1}readDataFromBuffer(t,e,n=null){const i=this.type;if("BOOLEAN"===i||"STRING"===i)throw new Error("PropertyTextureAccessor: BOOLEAN and STRING types not supported.");return GT(t,e*this.valueLength,i,n)}}class AB extends JT{constructor(...t){super(...t),this.isPropertyTextureAccessor=!0,this._asyncRead=!1,this._initProperties(gB)}getData(t,e,n,i={}){const r=this.properties;XT(r,i);const s=Object.keys(r),a=s.map((t=>i[t]));return this.getPropertyValuesAtTexel(s,t,e,n,a),s.forEach(((t,e)=>i[t]=a[e])),i}async getDataAsync(t,e,n,i={}){const r=this.properties;XT(r,i);const s=Object.keys(r),a=s.map((t=>i[t]));return await this.getPropertyValuesAtTexelAsync(s,t,e,n,a),s.forEach(((t,e)=>i[t]=a[e])),i}getPropertyValuesAtTexelAsync(...t){this._asyncRead=!0;const e=this.getPropertyValuesAtTexel(...t);return this._asyncRead=!1,e}getPropertyValuesAtTexel(t,e,n,i,r=[]){for(;r.length(h.call(this),r))):(aB.readData(c),h.call(this),r);function h(){for(let e=0,n=t.length;ec[4*e+t])),u=new(WT(i.componentType,s))(l);if(new Uint8Array(u.buffer).set(h),i.array){const t=r[e];for(let e=0,n=t.length;e{t&&(t.dispose(),t.image instanceof ImageBitmap&&t.image.close())}))}}class vB{constructor(t,e,n,i=null,r=null){const{schema:s,propertyTables:a=[],propertyTextures:o=[],propertyAttributes:l=[]}=t,{enums:c,classes:h}=s,u=a.map((t=>new tB(t,h,c,n)));let d=[],p=[];i&&(i.propertyTextures&&(d=i.propertyTextures.map((t=>new AB(o[t],h,c,e)))),i.propertyAttributes&&(p=i.propertyAttributes.map((t=>new ZT(l[t],h,c))))),this.schema=s,this.tableAccessors=u,this.textureAccessors=d,this.attributeAccessors=p,this.object=r,this.textures=e,this.nodeMetadata=i}getPropertyTableData(t,e,n=null){if(Array.isArray(t)&&Array.isArray(e)){n=n||[];const i=Math.min(t.length,e.length);n.length=i;for(let r=0;re))),Array.isArray(t))return t.map((t=>{const e=this.tableAccessors[t];return{name:e.name,className:e.definition.class}}));{const e=this.tableAccessors[t];return{name:e.name,className:e.definition.class}}}getPropertyTextureData(t,e,n=[]){const i=this.textureAccessors;n.length=i.length;for(let r=0;r{n[s]=t}));r.push(a)}return await Promise.all(r),n}getPropertyTextureInfo(){return this.textureAccessors}getPropertyAttributeData(t,e=[]){const n=this.attributeAccessors;e.length=n.length;for(let i=0;i({name:t.name,className:t.definition.class})))}dispose(){this.textureAccessors.forEach((t=>t.dispose())),this.tableAccessors.forEach((t=>t.dispose())),this.attributeAccessors.forEach((t=>t.dispose()))}}const yB="EXT_structural_metadata";function xB(t,e=[]){const n=t.json.textures?.length||0,i=new Array(n).fill(null);return e.forEach((({properties:e})=>{for(const n in e){const{index:r}=e[n];null===i[r]&&(i[r]=t.loadTexture(r))}})),Promise.all(i)}function _B(t,e=[]){const n=t.json.bufferViews?.length||0,i=new Array(n).fill(null);return e.forEach((({properties:e})=>{for(const n in e){const{values:r,arrayOffsets:s,stringOffsets:a}=e[n];null===i[r]&&(i[r]=t.loadBufferView(r)),null===i[s]&&(i[s]=t.loadBufferView(s)),null===i[a]&&(i[a]=t.loadBufferView(a))}})),Promise.all(i)}class wB{constructor(t){this.parser=t,this.name=yB}async afterRoot({scene:t,parser:e}){const n=e.json.extensionsUsed;if(!n||!n.includes(yB))return;let i=null,r=e.json.extensions[yB];if(r.schemaUri){const{manager:t,path:n,requestHeader:s,crossOrigin:a}=e.options,o=new URL(r.schemaUri,n).toString(),l=new ip(t);l.setCrossOrigin(a),l.setResponseType("json"),l.setRequestHeader(s),i=l.loadAsync(o).then((t=>{r={...r,schema:t}}))}const[s,a]=await Promise.all([xB(e,r.propertyTextures),_B(e,r.propertyTables),i]),o=new vB(r,s,a);t.userData.structuralMetadata=o,t.traverse((t=>{if(e.associations.has(t)){const{meshes:n,primitives:i}=e.associations.get(t),l=e.json.meshes[n].primitives[i];if(l&&l.extensions&&l.extensions[yB]){const e=l.extensions[yB];t.userData.structuralMetadata=new vB(r,s,a,e,t)}else t.userData.structuralMetadata=o}}))}}class CB extends wB{constructor(...t){super(...t),console.warn('GLTFStructuralMetadataExtension: Plugins should now be imported from "3d-tiles-renderer/plugins" path.')}}const EB=new hi,MB=new hi,bB=new hi;class SB{constructor(t,e,n){this.geometry=t,this.textures=e,this.data=n,this._asyncRead=!1,this.featureIds=n.featureIds.map((t=>{const{texture:e,...n}=t,i={label:null,propertyTable:null,nullFeatureId:null,...n};return e&&(i.texture={texCoord:0,channels:[0],...e}),i}))}getTextures(){return this.textures}getFeatureInfo(){return this.featureIds}getFeaturesAsync(...t){this._asyncRead=!0;const e=this.getFeatures(...t);return this._asyncRead=!1,e}getFeatures(t,e){const{geometry:n,textures:i,featureIds:r}=this,s=new Array(r.length).fill(null),a=r.length;aB.increaseSizeTo(a);const o=hB(n,t),l=o[function(t){return t.x>t.y&&t.x>t.z?0:t.y>t.z?1:2}(e)];for(let t=0,a=r.length;t(h(),s))):(aB.readData(c),h(),s);function h(){const t=new Uint32Array(1);for(let e=0,n=r.length;ec[4*e+t]));new Uint8Array(t.buffer).set(a);const o=t[0];o!==i&&(s[e]=o)}}}}dispose(){this.textures.forEach((t=>{t&&(t.dispose(),t.image instanceof ImageBitmap&&t.image.close())}))}}const IB="EXT_mesh_features";function TB(t,e,n){t.traverse((t=>{if(e.associations.has(t)){const{meshes:i,primitives:r}=e.associations.get(t),s=e.json.meshes[i].primitives[r];s&&s.extensions&&s.extensions[IB]&&n(t,s.extensions[IB])}}))}class BB{constructor(t){this.parser=t,this.name=IB}async afterRoot({scene:t,parser:e}){const n=e.json.extensionsUsed;if(!n||!n.includes(IB))return;const i=e.json.textures?.length||0,r=new Array(i).fill(null);TB(t,e,((t,{featureIds:n})=>{n.forEach((t=>{if(t.texture&&null===r[t.texture.index]){const n=t.texture.index;r[n]=e.loadTexture(n)}}))}));const s=await Promise.all(r);TB(t,e,((t,e)=>{t.userData.meshFeatures=new SB(t.geometry,s,e)}))}}class RB extends BB{constructor(...t){super(...t),console.warn('GLTFMeshFeaturesExtension: Plugins should now be imported from "3d-tiles-renderer/plugins" path.')}}class DB{constructor(){this.creditsCount={}}_adjustAttributions(t,e){const n=this.creditsCount,i=t.split(/;/g);for(let t=0,r=i.length;t{const n=t[1];return e[1]-n})).map((t=>t[0])).join("; ")}}function PB(t){let e=null;return Kb(t,(t=>{if(t.content&&t.content.uri){const[,n]=t.content.uri.split("?");return e=new URLSearchParams(n).get("session"),!0}return!1})),e}class LB{constructor({apiToken:t,autoRefreshToken:e=!1,logoUrl:n=null,useRecommendedSettings:i=!0}){this.name="GOOGLE_CLOUD_AUTH_PLUGIN",this.apiToken=t,this.autoRefreshToken=e,this.useRecommendedSettings=i,this.logoUrl=n,this.sessionToken=null,this.tiles=null,this._onLoadCallback=null,this._visibilityChangeCallback=null,this._tokenRefreshPromise=null,this._attributionsManager=new DB,this._logoAttribution={value:"",type:"image",collapsible:!1},this._attribution={value:"",type:"string",collapsible:!0}}init(t){null!=t&&(null==t.rootURL&&(t.rootURL="https://tile.googleapis.com/v1/3dtiles/root.json"),this.useRecommendedSettings&&(t.parseQueue.maxJobs=10,t.downloadQueue.maxJobs=30,t.errorTarget=40),this.tiles=t,this._onLoadCallback=({tileSet:e})=>{this.sessionToken=PB(e.root),t.removeEventListener("load-tile-set",this._onLoadCallback)},this._visibilityChangeCallback=({tile:t,visible:e})=>{const n=t.cached.metadata.asset.copyright||"";e?this._attributionsManager.addAttributions(n):this._attributionsManager.removeAttributions(n)},t.addEventListener("load-tile-set",this._onLoadCallback),t.addEventListener("tile-visibility-change",this._visibilityChangeCallback))}getAttributions(t){this.tiles.visibleTiles.size>0&&(this.logoUrl&&(this._logoAttribution.value=this.logoUrl,t.push(this._logoAttribution)),this._attribution.value=this._attributionsManager.toString(),t.push(this._attribution))}preprocessURL(t){return t=new URL(t),/^http/.test(t.protocol)&&(t.searchParams.append("key",this.apiToken),null!==this.sessionToken&&t.searchParams.append("session",this.sessionToken)),t.toString()}dispose(){const{tiles:t}=this;t.removeEventListener("load-tile-set",this._onLoadCallback),t.removeEventListener("tile-visibility-change",this._visibilityChangeCallback)}async fetchData(t,e){null!==this._tokenRefreshPromise&&(await this._tokenRefreshPromise,t=this.preprocessURL(t));const n=await fetch(t,e);return n.status>=400&&n.status<=499&&this.autoRefreshToken?(await this._refreshToken(e),fetch(this.preprocessURL(t),e)):n}_refreshToken(t){if(null===this._tokenRefreshPromise){const e=new URL(this.tiles.rootURL);e.searchParams.append("key",this.apiToken),this._tokenRefreshPromise=fetch(e,t).then((t=>t.json())).then((t=>{this.sessionToken=PB(t.root),this._tokenRefreshPromise=null}))}return this._tokenRefreshPromise}}class UB extends LB{constructor(...t){super(...t),console.warn('GoogleCloudAuthPlugin: Plugins should now be imported from "3d-tiles-renderer/plugins" path.')}}const NB=t=>class extends t{constructor(t="https://tile.googleapis.com/v1/3dtiles/root.json"){super(t),console.warn('GooglePhotorealisticTilesRenderer: Class has been deprecated. Use "TilesRenderer" with "GoogleCloudAuthPlugin" instead.'),this.parseQueue.maxJobs=10,this.downloadQueue.maxJobs=30,this.errorTarget=40}getCreditsString(){return console.warn('GooglePhotorealisticTilesRenderer: "getCreditsString" function is deprecated. Use "getAttributions", instead.'),this.getAttributions()[0].value}},FB=t=>class extends(NB(t)){constructor(t,e){super(e),this.registerPlugin(new UB({apiToken:t})),console.warn('GoogleTilesRenderer: Class has been deprecated. Use "GoogleCloudAuthPlugin" instead.')}},OB=FB(aT),kB=FB(NT),QB=NB(aT),zB=NB(NT);class GB{constructor({apiToken:t,assetId:e=null,autoRefreshToken:n=!1}){this.name="CESIUM_ION_AUTH_PLUGIN",this.apiToken=t,this.assetId=e,this.autoRefreshToken=n,this.tiles=null,this.endpointURL=null,this._bearerToken=null,this._tileSetVersion=-1,this._tokenRefreshPromise=null,this._attributions=[]}init(t){null!==this.assetId&&(t.rootURL=`https://api.cesium.com/v1/assets/${this.assetId}/endpoint`),this.tiles=t,this.endpointURL=t.rootURL}loadRootTileSet(){return this._refreshToken().then((()=>this.tiles.loadRootTileSet()))}preprocessURL(t){return t=new URL(t),/^http/.test(t.protocol)&&-1!=this._tileSetVersion&&t.searchParams.append("v",this._tileSetVersion),t.toString()}fetchData(t,e){return null!==this.tiles.getPluginByName("GOOGLE_CLOUD_AUTH_PLUGIN")?null:Promise.resolve().then((async()=>{null!==this._tokenRefreshPromise&&(await this._tokenRefreshPromise,t=this.preprocessURL(t));const n=await fetch(t,e);return n.status>=400&&n.status<=499&&this.autoRefreshToken?(await this._refreshToken(e),fetch(this.preprocessURL(t),e)):n}))}getAttributions(t){this.tiles.visibleTiles.size>0&&t.push(...this._attributions)}_refreshToken(t){if(null===this._tokenRefreshPromise){const e=new URL(this.endpointURL);e.searchParams.append("access_token",this.apiToken),this._tokenRefreshPromise=fetch(e,t).then((t=>{if(!t.ok)throw new Error(`CesiumIonAuthPlugin: Failed to load data with error code ${t.status}`);return t.json()})).then((t=>{const n=this.tiles;if("externalType"in t){const e=new URL(t.options.url);n.rootURL=t.options.url,n.registerPlugin(new LB({apiToken:e.searchParams.get("key")}))}else{if(n.rootURL=t.url,n.fetchOptions.headers=n.fetchOptions.headers||{},n.fetchOptions.headers.Authorization=`Bearer ${t.accessToken}`,e.searchParams.has("v")&&-1===this._tileSetVersion){const e=new URL(t.url);this._tileSetVersion=e.searchParams.get("v")}this._bearerToken=t.accessToken,t.attributions&&(this._attributions=t.attributions.map((t=>({value:t.html,type:"html",collapsible:t.collapsible}))))}return this._tokenRefreshPromise=null,t}))}return this._tokenRefreshPromise}}class HB extends GB{constructor(...t){super(...t),console.warn('CesiumIonAuthPlugin: Plugins should now be imported from "3d-tiles-renderer/plugins" path.')}}const VB=t=>class extends t{constructor(t,e){super(),this.registerPlugin(new HB({apiToken:e,assetId:t})),console.warn('CesiumIonTilesRenderer: Class has been deprecated. Use "TilesRenderer" with "CesiumIonAuthPlugin" instead.')}},WB=VB(aT),jB=VB(NT);class qB extends Zs{constructor(){super(new Ea(0,0),new XB),this.renderOrder=1/0}onBeforeRender(t){const e=this.material.uniforms;t.getSize(e.resolution.value)}updateMatrixWorld(){this.matrixWorld.makeTranslation(this.position)}dispose(){this.geometry.dispose(),this.material.dispose()}}class XB extends sa{constructor(){super({depthWrite:!1,depthTest:!1,transparent:!0,uniforms:{resolution:{value:new hi},size:{value:15},thickness:{value:2},opacity:{value:1}},vertexShader:"\n\n\t\t\t\tuniform float pixelRatio;\n\t\t\t\tuniform float size;\n\t\t\t\tuniform float thickness;\n\t\t\t\tuniform vec2 resolution;\n\t\t\t\tvarying vec2 vUv;\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvUv = uv;\n\n\t\t\t\t\tfloat aspect = resolution.x / resolution.y;\n\t\t\t\t\tvec2 offset = uv * 2.0 - vec2( 1.0 );\n\t\t\t\t\toffset.y *= aspect;\n\n\t\t\t\t\tvec4 screenPoint = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t\tscreenPoint.xy += offset * ( size + thickness ) * screenPoint.w / resolution.x;\n\n\t\t\t\t\tgl_Position = screenPoint;\n\n\t\t\t\t}\n\t\t\t",fragmentShader:"\n\n\t\t\t\tuniform float size;\n\t\t\t\tuniform float thickness;\n\t\t\t\tuniform float opacity;\n\n\t\t\t\tvarying vec2 vUv;\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tfloat ht = 0.5 * thickness;\n\t\t\t\t\tfloat planeDim = size + thickness;\n\t\t\t\t\tfloat offset = ( planeDim - ht - 2.0 ) / planeDim;\n\t\t\t\t\tfloat texelThickness = ht / planeDim;\n\n\t\t\t\t\tvec2 vec = vUv * 2.0 - vec2( 1.0 );\n\t\t\t\t\tfloat dist = abs( length( vec ) - offset );\n\t\t\t\t\tfloat fw = fwidth( dist ) * 0.5;\n\t\t\t\t\tfloat a = smoothstep( texelThickness - fw, texelThickness + fw, dist );\n\n\t\t\t\t\tgl_FragColor = vec4( 1, 1, 1, opacity * ( 1.0 - a ) );\n\n\t\t\t\t}\n\t\t\t"})}}const YB=new hi,JB=new hi;class KB{constructor(){this.domElement=null,this.buttons=0,this.pointerType=null,this.pointerOrder=[],this.previousPositions={},this.pointerPositions={},this.startPositions={},this.pointerSetThisFrame={},this.hoverPosition=new hi,this.hoverSet=!1}reset(){this.buttons=0,this.pointerType=null,this.pointerOrder=[],this.previousPositions={},this.pointerPositions={},this.startPositions={},this.pointerSetThisFrame={},this.hoverPosition=new hi,this.hoverSet=!1}updateFrame(){const{previousPositions:t,pointerPositions:e}=this;for(const n in e)t[n].copy(e[n])}setHoverEvent(t){"mouse"!==t.pointerType&&"wheel"!==t.type||(this.getAdjustedPointer(t,this.hoverPosition),this.hoverSet=!0)}getLatestPoint(t){return null!==this.pointerType?(this.getCenterPoint(t),t):this.hoverSet?(t.copy(this.hoverPosition),t):null}getAdjustedPointer(t,e){const n=(this.domElement?this.domElement:t.target).getBoundingClientRect(),i=t.clientX-n.left,r=t.clientY-n.top;e.set(i,r)}addPointer(t){const e=t.pointerId,n=new hi;this.getAdjustedPointer(t,n),this.pointerOrder.push(e),this.pointerPositions[e]=n,this.previousPositions[e]=n.clone(),this.startPositions[e]=n.clone(),1===this.getPointerCount()&&(this.pointerType=t.pointerType,this.buttons=t.buttons)}updatePointer(t){const e=t.pointerId;return e in this.pointerPositions&&(this.getAdjustedPointer(t,this.pointerPositions[e]),!0)}deletePointer(t){const e=t.pointerId,n=this.pointerOrder;n.splice(n.indexOf(e),1),delete this.pointerPositions[e],delete this.previousPositions[e],delete this.startPositions[e],0===this.getPointerCount.length&&(this.buttons=0,this.pointerType=null)}getPointerCount(){return this.pointerOrder.length}getCenterPoint(t,e=this.pointerPositions){const n=this.pointerOrder;if(1===this.getPointerCount()||"mouse"===this.getPointerType()){const i=n[0];return t.copy(e[i]),t}if(2===this.getPointerCount()){const n=this.pointerOrder[0],i=this.pointerOrder[1],r=e[n],s=e[i];return t.addVectors(r,s).multiplyScalar(.5),t}return null}getPreviousCenterPoint(t){return this.getCenterPoint(t,this.previousPositions)}getStartCenterPoint(t){return this.getCenterPoint(t,this.startPositions)}getMoveDistance(){return this.getCenterPoint(YB),this.getPreviousCenterPoint(JB),YB.sub(JB).length()}getTouchPointerDistance(t=this.pointerPositions){if(this.getPointerCount()<=1||"mouse"===this.getPointerType())return 0;const{pointerOrder:e}=this,n=e[0],i=e[1],r=t[n],s=t[i];return r.distanceTo(s)}getPreviousTouchPointerDistance(){return this.getTouchPointerDistance(this.previousPositions)}getStartTouchPointerDistance(){return this.getTouchPointerDistance(this.startPositions)}getPointerType(){return this.pointerType}isPointerTouch(){return"touch"===this.getPointerType()}getPointerButtons(){return this.buttons}isLeftClicked(){return Boolean(1&this.buttons)}isRightClicked(){return Boolean(2&this.buttons)}}const ZB=new yr,$B=new vr,tR=new Hi;function eR(t,e,n){return n.makeTranslation(-t.x,-t.y,-t.z),ZB.makeRotationFromQuaternion(e),n.premultiply(ZB),ZB.makeTranslation(t.x,t.y,t.z),n.premultiply(ZB),n}function nR(t,e,n,i){i.x=(t-n.offsetLeft)/n.clientWidth*2-1,i.y=-(e-n.offsetTop)/n.clientHeight*2+1,i.isVector3&&(i.z=0)}function iR(t,e,n){return e.intersectRay(t,n)?n:(ZB.makeScale(...e.radius).invert(),$B.copy(t).applyMatrix4(ZB),tR.set(0,0,0),$B.closestPointToPoint(tR,n).normalize(),ZB.makeScale(...e.radius),n.applyMatrix4(ZB))}function rR(t,e,n){const{origin:i,direction:r}=t.ray;i.set(e.x,e.y,-1).unproject(n),r.set(e.x,e.y,1).unproject(n).sub(i),t.near=0,t.far=r.length(),t.camera=n,r.normalize()}const sR=.05,aR=.025,oR=new yr,lR=new Hi,cR=new Hi,hR=new Hi,uR=new Hi,dR=new Hi,pR=new Gi,fR=new va,mR=new Hi,gR=new Hi,AR=new Hi,vR=new Gi,yR=new hi,xR=new hi,_R=new hi,wR=new hi,CR=new hi,ER=new hi,MR={type:"change"},bR={type:"start"},SR={type:"end"};class IR extends Zn{get enabled(){return this._enabled}set enabled(t){t!==this.enabled&&(this._enabled=t,this.resetState(),this.pointerTracker.reset(),this.enabled||(this.dragInertia.set(0,0,0),this.rotationInertia.set(0,0)))}constructor(t=null,e=null,n=null,i=null){super(),this.isEnvironmentControls=!0,this.domElement=null,this.camera=null,this.scene=null,this.tilesRenderer=null,this._enabled=!0,this.cameraRadius=5,this.rotationSpeed=1,this.minAltitude=0,this.maxAltitude=.45*Math.PI,this.minDistance=10,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.zoomSpeed=1,this.adjustHeight=!0,this.enableDamping=!1,this.dampingFactor=.15,this.reorientOnDrag=!0,this.scaleZoomOrientationAtEdges=!1,this.state=0,this.pointerTracker=new KB,this.needsUpdate=!1,this.actionHeightOffset=0,this.pivotPoint=new Hi,this.zoomDirectionSet=!1,this.zoomPointSet=!1,this.zoomDirection=new Hi,this.zoomPoint=new Hi,this.zoomDelta=0,this.rotationInertia=new hi,this.dragInertia=new Hi,this.pivotMesh=new qB,this.pivotMesh.raycast=()=>{},this.pivotMesh.scale.setScalar(.25),this.raycaster=new Ef,this.raycaster.firstHitOnly=!0,this.up=new Hi(0,1,0),this.clock=new Wp,this.fallbackPlane=new va(new Hi(0,1,0),0),this.useFallbackPlane=!0,this._detachCallback=null,this._upInitialized=!1,this._lastUsedState=0,this._zoomPointWasSet=!1,this._tilesOnChangeCallback=()=>this.zoomPointSet=!1,n&&this.attach(n),e&&this.setCamera(e),t&&this.setScene(t),i&&this.setTilesRenderer(i)}setScene(t){this.scene=t}setCamera(t){this.camera=t,this._upInitialized=!1,this.zoomDirectionSet=!1,this.zoomPointSet=!1,this.needsUpdate=!0,this.raycaster.camera=t,this.resetState()}setTilesRenderer(t){this.tilesRenderer&&this.tilesRenderer.removeEventListener("tile-visibility-change",this._tilesOnChangeCallback),this.tilesRenderer=t,null!==this.tilesRenderer&&(this.tilesRenderer.addEventListener("tile-visibility-change",this._tilesOnChangeCallback),null===this.scene&&this.setScene(this.tilesRenderer.group))}attach(t){if(this.domElement)throw new Error("EnvironmentControls: Controls already attached to element");this.domElement=t,this.pointerTracker.domElement=t,t.style.touchAction="none";let e=!1;const n=t=>{t.preventDefault()},i=t=>{"Shift"===t.key&&(e=!0)},r=t=>{"Shift"===t.key&&(e=!1)},s=t=>{t.preventDefault();const{camera:n,raycaster:i,domElement:r,up:s,pivotMesh:a,pointerTracker:o}=this;if(o.addPointer(t),this.needsUpdate=!0,o.isPointerTouch())if(a.visible=!1,0===o.getPointerCount())r.setPointerCapture(t.pointerId);else if(o.getPointerCount()>2)return void this.resetState();o.getCenterPoint(xR),nR(xR.x,xR.y,r,xR),rR(i,xR,n);const l=Math.abs(i.ray.direction.dot(s));if(l{t.preventDefault(),this.zoomDirectionSet=!1,this.zoomPointSet=!1,0!==this.state&&(this.needsUpdate=!0);const{pointerTracker:e}=this;e.setHoverEvent(t),e.updatePointer(t)&&(e.isPointerTouch()&&2===e.getPointerCount()&&(a||(a=!0,queueMicrotask((()=>{a=!1,e.getCenterPoint(CR);const t=e.getStartTouchPointerDistance(),n=e.getTouchPointerDistance(),i=n-t;if(0===this.state||4===this.state){e.getCenterPoint(CR),e.getStartCenterPoint(ER);const t=2*window.devicePixelRatio,n=CR.distanceTo(ER);(Math.abs(i)>t||n>t)&&(Math.abs(i)>n?(this.setState(3),this.zoomDirectionSet=!1):this.setState(2))}if(3===this.state){const t=e.getPreviousTouchPointerDistance();this.zoomDelta+=n-t}else 2===this.state&&(this.pivotMesh.visible=this.enabled)})))),this.dispatchEvent(MR))},l=e=>{const{pointerTracker:n}=this;n.deletePointer(e),"touch"===n.getPointerType()&&0===n.getPointerCount()&&t.releasePointerCapture(e.pointerId),this.resetState(),this.needsUpdate=!0},c=t=>{t.preventDefault();const{pointerTracker:e}=this;let n;switch(e.setHoverEvent(t),e.updatePointer(t),this.dispatchEvent(bR),t.deltaMode){case 2:n=100*t.deltaY;break;case 1:n=16*t.deltaY;break;case 0:n=t.deltaY}const i=Math.sign(n),r=Math.log(Math.abs(n)+1);this.zoomDelta-=3*i*r,this.needsUpdate=!0,this._lastUsedState=3,this.dispatchEvent(SR)},h=t=>{const{pointerTracker:n}=this;e=!1,t.buttons!==n.getPointerButtons()&&(n.deletePointer(t),this.resetState())};t.addEventListener("contextmenu",n),t.addEventListener("keydown",i),t.addEventListener("keyup",r),t.addEventListener("pointerdown",s),t.addEventListener("pointermove",o),t.addEventListener("pointerup",l),t.addEventListener("wheel",c,{passive:!1}),t.addEventListener("pointerenter",h),this._detachCallback=()=>{t.removeEventListener("contextmenu",n),t.removeEventListener("keydown",i),t.removeEventListener("keyup",r),t.removeEventListener("pointerdown",s),t.removeEventListener("pointermove",o),t.removeEventListener("pointerup",l),t.removeEventListener("wheel",c),t.removeEventListener("pointerenter",h)}}getUpDirection(t,e){e.copy(this.up)}getCameraUpDirection(t){this.getUpDirection(this.camera.position,t)}getPivotPoint(t){return 3===this._lastUsedState?this._zoomPointWasSet?(t.copy(this.zoomPoint),t):null:2===this._lastUsedState||1===this._lastUsedState?(t.copy(this.pivotPoint),t):null}detach(){this.domElement=null,this._detachCallback&&(this._detachCallback(),this._detachCallback=null,this.pointerTracker.reset())}resetState(){0!==this.state&&this.dispatchEvent(SR),this.state=0,this.pivotMesh.removeFromParent(),this.pivotMesh.visible=this.enabled,this.actionHeightOffset=0}setState(t=this.state,e=!0){this.state!==t&&(0===this.state&&e&&this.dispatchEvent(bR),this.pivotMesh.visible=this.enabled,this.dragInertia.set(0,0,0),this.rotationInertia.set(0,0),this.state=t,0!==t&&4!==t&&(this._lastUsedState=t))}update(t=Math.min(this.clock.getDelta(),.064)){if(!this.enabled||!this.camera||0===t)return;const{camera:e,cameraRadius:n,pivotPoint:i,up:r,state:s,adjustHeight:a}=this;e.updateMatrixWorld(),this.getCameraUpDirection(mR),this._upInitialized||(this._upInitialized=!0,this.up.copy(mR));const o=this._inertiaNeedsUpdate();if(this.needsUpdate||o){const e=this.zoomDelta;3!==s&&0===e||(this._updateZoom(),this.rotationInertia.set(0,0),this.dragInertia.set(0,0,0)),this._updatePosition(t),this._updateRotation(t),(0!==s||0!==e||o)&&this.dispatchEvent(MR),this.needsUpdate=!1}o&&this._updateInertiaDamping(t);const l=e.isOrthographicCamera?null:a&&this._getPointBelowCamera()||null,c=e.isOrthographicCamera?i:l&&l.point||null;if(this.getCameraUpDirection(mR),this._setFrame(mR,c),(1===this.state||2===this.state)&&0!==this.actionHeightOffset){const{actionHeightOffset:t}=this;e.position.addScaledVector(r,-t),i.addScaledVector(r,-t),l&&(l.distance-=t)}if(this.actionHeightOffset=0,l){const t=l.distance;if(t0?1/Math.abs(t):t;n.zoom=Math.max(o,Math.min(l,n.zoom*e*c)),n.updateProjectionMatrix(),nR(xR.x,xR.y,a,AR),AR.unproject(n),n.position.sub(AR).add(gR),n.updateMatrixWorld()}else{const t=Math.pow(.95,Math.abs(.05*h)),e=h>0?1/Math.abs(t):t;n.zoom=Math.max(o,Math.min(l,n.zoom*e*c)),n.updateProjectionMatrix()}else{this._updateZoomDirection();const s=cR.copy(e);if(this.zoomPointSet||this._updateZoomPoint()){const s=t.distanceTo(n.position);if(h<0){const t=Math.min(0,s-r);h=h*s*c*.0025,h=Math.max(h,t)}else{const t=Math.max(0,s-i);h=h*Math.max(s-i,0)*c*.0025,h=Math.min(h,t)}n.position.addScaledVector(e,h),n.updateMatrixWorld()}else{const t=this._getPointBelowCamera();if(t){const e=t.distance;s.set(0,0,-1).transformDirection(n.matrixWorld),n.position.addScaledVector(s,h*e*.01),n.updateMatrixWorld()}}}}_updateZoomDirection(){if(this.zoomDirectionSet)return;const{domElement:t,raycaster:e,camera:n,zoomDirection:i,pointerTracker:r}=this;r.getLatestPoint(xR),nR(xR.x,xR.y,t,gR),rR(e,gR,n),i.copy(e.ray.direction).normalize(),this.zoomDirectionSet=!0}_updateZoomPoint(){const{camera:t,zoomDirectionSet:e,zoomDirection:n,raycaster:i,zoomPoint:r,pointerTracker:s,domElement:a}=this;if(this._zoomPointWasSet=!1,!e)return!1;t.isOrthographicCamera&&s.getLatestPoint(yR)?(nR(yR.x,yR.y,a,yR),rR(i,yR,t)):(i.ray.origin.copy(t.position),i.ray.direction.copy(n),i.near=0,i.far=1/0);const o=this._raycast(i);return!!o&&(r.copy(o.point),this.zoomPointSet=!0,this._zoomPointWasSet=!0,!0)}_getPointBelowCamera(t=this.camera.position,e=this.up){const{raycaster:n}=this;n.ray.direction.copy(e).multiplyScalar(-1),n.ray.origin.copy(t).addScaledVector(e,1e5),n.near=0,n.far=1/0;const i=this._raycast(n);return i&&(i.distance-=1e5),i}_updatePosition(t){const{raycaster:e,camera:n,pivotPoint:i,up:r,pointerTracker:s,domElement:a,state:o,dragInertia:l,enableDamping:c}=this;if(1===o){if(s.getCenterPoint(xR),nR(xR.x,xR.y,a,xR),fR.setFromNormalAndCoplanarPoint(r,i),rR(e,xR,n),Math.abs(e.ray.direction.dot(r))0?(l=Math.min(c-r-.01,l),l=Math.max(0,l)):(l=Math.max(c-s,l),l=Math.min(0,l)),pR.setFromAxisAngle(mR,o),eR(n,pR,oR),i.matrixWorld.premultiply(oR),dR.set(-1,0,0).transformDirection(i.matrixWorld),pR.setFromAxisAngle(dR,l),eR(n,pR,oR),i.matrixWorld.premultiply(oR),i.matrixWorld.decompose(i.position,i.quaternion,cR)}_setFrame(t,e){const{up:n,camera:i,state:r,zoomPoint:s,zoomDirectionSet:a,zoomPointSet:o,reorientOnDrag:l,scaleZoomOrientationAtEdges:c}=this;i.updateMatrixWorld(),pR.setFromUnitVectors(n,t);const h=r;if(a&&(o||this._updateZoomPoint())){if(this.getUpDirection(s,cR),c){let t=Math.max(cR.dot(n)-.6,0)/.4;t=ci.mapLinear(t,0,.5,0,1),t=Math.min(t,1),i.isOrthographicCamera&&(t*=.1),pR.slerp(vR,1-t)}eR(s,pR,oR),i.matrixWorld.premultiply(oR),i.matrixWorld.decompose(i.position,i.quaternion,cR),this.zoomDirectionSet=!1,this._updateZoomDirection()}else 1===h&&l&&e&&(eR(e,pR,oR),i.matrixWorld.premultiply(oR),i.matrixWorld.decompose(i.position,i.quaternion,cR));n.copy(t),i.updateMatrixWorld()}_raycast(t){const{scene:e,useFallbackPlane:n,fallbackPlane:i}=this,r=t.intersectObject(e)[0]||null;if(r)return r;if(n){const e=i;if(t.ray.intersectPlane(e,cR))return{point:cR.clone(),distance:t.ray.origin.distanceTo(cR)}}return null}}const TR=new yr,BR=new yr,RR=new Hi,DR=new Hi,PR=new Hi,LR=new Hi,UR=new Hi,NR=new Hi,FR=new Hi,OR=new Gi,kR=new Hi,QR=new Hi,zR={},GR=new vr,HR=new qS,VR=new hi;class WR extends IR{get ellipsoid(){return this.tilesRenderer?this.tilesRenderer.ellipsoid:null}get tilesGroup(){return this.tilesRenderer?this.tilesRenderer.group:null}constructor(t=null,e=null,n=null,i=null){super(t,e,n),this.isGlobeControls=!0,this._dragMode=0,this._rotationMode=0,this.maxZoom=.01,this.useFallbackPlane=!1,this.reorientOnDrag=!1,this.dragQuaternion=new Gi,this.setTilesRenderer(i)}setScene(t){null===t&&null!==this.tilesRenderer?super.setScene(this.tilesRenderer.group):super.setScene(t)}getPivotPoint(t){const{camera:e,tilesGroup:n,ellipsoid:i}=this;return LR.set(0,0,-1).transformDirection(e.matrixWorld),TR.copy(n.matrixWorld).invert(),GR.origin.copy(e.position),GR.direction.copy(LR),GR.applyMatrix4(TR),iR(GR,i,DR),DR.applyMatrix4(n.matrixWorld),(null===super.getPivotPoint(t)||t.distanceTo(GR.origin)>DR.distanceTo(GR.origin))&&t.copy(DR),t}getVectorToCenter(t){const{tilesGroup:e,camera:n}=this;return t.setFromMatrixPosition(e.matrixWorld).sub(n.position)}getDistanceToCenter(){return this.getVectorToCenter(DR).length()}getUpDirection(t,e){const{tilesGroup:n,ellipsoid:i}=this;TR.copy(n.matrixWorld).invert(),DR.copy(t).applyMatrix4(TR),i.getPositionToNormal(DR,e),e.transformDirection(n.matrixWorld)}getCameraUpDirection(t){const{tilesGroup:e,ellipsoid:n,camera:i}=this;i.isOrthographicCamera?(this._getVirtualOrthoCameraPosition(DR),TR.copy(e.matrixWorld).invert(),DR.applyMatrix4(TR),n.getPositionToNormal(DR,t),t.transformDirection(e.matrixWorld)):this.getUpDirection(i.position,t)}update(t=Math.min(this.clock.getDelta(),.064)){if(!this.enabled||!this.tilesGroup||!this.camera||0===t)return;const{camera:e,pivotMesh:n}=this;this._isNearControls()?this.scaleZoomOrientationAtEdges=this.zoomDelta<0:(0!==this.state&&1!==this._dragMode&&1!==this._rotationMode&&(n.visible=!1),this.scaleZoomOrientationAtEdges=!1),super.update(t),this.adjustCamera(e)}adjustCamera(t){super.adjustCamera(t);const{tilesGroup:e,ellipsoid:n}=this;if(t.isPerspectiveCamera){const i=DR.setFromMatrixPosition(e.matrixWorld).sub(t.position).length(),r=Math.max(...n.radius),s=.25*r,a=ci.clamp((i-r)/s,0,1),o=ci.lerp(1,1e3,a);t.near=Math.max(o,i-r-s);const l=TR.copy(e.matrixWorld).invert();RR.copy(t.position).applyMatrix4(l),n.getPositionToCartographic(RR,zR);const c=Math.max(n.getPositionElevation(RR),400),h=n.calculateHorizonDistance(zR.lat,c);t.far=2.5*h+.1,t.updateProjectionMatrix()}else{this._getVirtualOrthoCameraPosition(t.position,t),t.updateMatrixWorld(),TR.copy(t.matrixWorld).invert(),DR.setFromMatrixPosition(e.matrixWorld).applyMatrix4(TR);const i=-DR.z;t.near=i-1.1*Math.max(...n.radius),t.far=i+.1,t.position.addScaledVector(LR,t.near),t.far-=t.near,t.near=0,t.updateProjectionMatrix(),t.updateMatrixWorld()}}resetState(){super.resetState(),this._dragMode=0,this._rotationMode=0}_updatePosition(t){if(1!==this.state){const{enableDamping:e,tilesGroup:n,dragQuaternion:i,dragInertia:r,camera:s}=this;e&&(1!==i.w||0===i.x&&0===i.y&&0===i.z||(i.w=Math.min(i.w,1-1e-9)),PR.setFromMatrixPosition(n.matrixWorld),OR.identity().slerp(i,r.x*t),eR(PR,OR,BR),s.matrixWorld.premultiply(BR),s.matrixWorld.decompose(s.position,s.quaternion,DR))}else{0===this._dragMode&&(this._dragMode=this._isNearControls()?1:-1);const{raycaster:e,camera:n,pivotPoint:i,pointerTracker:r,domElement:s,tilesGroup:a}=this,o=RR,l=NR;r.getCenterPoint(VR),nR(VR.x,VR.y,s,VR),rR(e,VR,n),TR.copy(a.matrixWorld).invert(),e.ray.applyMatrix4(TR);const c=DR.copy(i).applyMatrix4(TR).length();HR.radius.setScalar(c),n.isPerspectiveCamera?HR.intersectRay(e.ray,DR)||function(t,e,n){const i=t.origin.length(),r=Math.acos(e/i);n.copy(t.origin).multiplyScalar(-1).normalize();const s=tR.crossVectors(n,t.direction).normalize();n.multiplyScalar(-1).applyAxisAngle(s,-r).normalize().multiplyScalar(e)}(e.ray,c,DR):iR(e.ray,HR,DR),DR.applyMatrix4(a.matrixWorld),PR.setFromMatrixPosition(a.matrixWorld),o.subVectors(i,PR).normalize(),l.subVectors(DR,PR).normalize(),OR.setFromUnitVectors(l,o),eR(PR,OR,BR),n.matrixWorld.premultiply(BR),n.matrixWorld.decompose(n.position,n.quaternion,DR);const{dragInertia:h,dragQuaternion:u}=this;r.getMoveDistance()/t<2*window.devicePixelRatio?(u.slerp(OR,.5),h.set(1/t,0,0)):(u.copy(OR),h.set(1/t,0,0))}this._alignCameraUp(this.up)}_updateRotation(...t){1===this._rotationMode||this._isNearControls()?(this._rotationMode=1,super._updateRotation(...t)):(this.pivotMesh.visible=!1,this._rotationMode=-1),this._alignCameraUp(this.up)}_updateZoom(){const{zoomDelta:t,ellipsoid:e,zoomSpeed:n,zoomPoint:i,camera:r,maxZoom:s}=this,a=ci.clamp(ci.mapLinear(Math.abs(t),0,20,0,1),0,1);if(this._isNearControls()||t>0){if(this._updateZoomDirection(),t<0&&(this.zoomPointSet||this._updateZoomPoint())){LR.set(0,0,-1).transformDirection(r.matrixWorld).normalize(),QR.copy(this.up).multiplyScalar(-1),this.getUpDirection(i,kR);const t=ci.clamp(ci.mapLinear(-kR.dot(QR),1,.95,0,1),0,1),e=1-LR.dot(QR),n=r.isOrthographicCamera?.05:1,s=ci.clamp(3*a,0,1),o=Math.min(t*e*n*s,.1);QR.lerpVectors(LR,QR,o).normalize(),OR.setFromUnitVectors(LR,QR),eR(i,OR,BR),r.matrixWorld.premultiply(BR),r.matrixWorld.decompose(r.position,r.quaternion,QR),this.zoomDirection.subVectors(i,r.position).normalize()}super._updateZoom()}else if(r.isPerspectiveCamera){const i=this._getPerspectiveTransitionDistance(),r=this._getMaxPerspectiveDistance(),s=ci.mapLinear(this.getDistanceToCenter(),i,r,0,1);this._tiltTowardsCenter(ci.lerp(0,.4,s*a)),this._alignCameraUpToNorth(ci.lerp(0,.2,s*a));const o=t*(this.getDistanceToCenter()-e.radius.x)*n*.0025,l=Math.max(o,Math.min(this.getDistanceToCenter()-r,0));this.getVectorToCenter(DR).normalize(),this.camera.position.addScaledVector(DR,l),this.camera.updateMatrixWorld(),this.zoomDelta=0}else{const t=this._getOrthographicTransitionZoom(),e=this._getMinOrthographicZoom(),i=ci.mapLinear(r.zoom,t,e,0,1);this._tiltTowardsCenter(ci.lerp(0,.4,i*a)),this._alignCameraUpToNorth(ci.lerp(0,.2,i*a));const o=this.zoomDelta,l=Math.pow(.95,Math.abs(.05*o)),c=o>0?1/Math.abs(l):l,h=e/r.zoom,u=Math.max(c*n,Math.min(h,1));r.zoom=Math.min(s,r.zoom*u),r.updateProjectionMatrix(),this.zoomDelta=0,this.zoomDirectionSet=!1}}_alignCameraUpToNorth(t){const{tilesGroup:e}=this;FR.set(0,0,1).transformDirection(e.matrixWorld),this._alignCameraUp(FR,t)}_alignCameraUp(t,e=null){const{camera:n}=this;LR.set(0,0,-1).transformDirection(n.matrixWorld),UR.set(-1,0,0).transformDirection(n.matrixWorld),NR.crossVectors(t,LR),null===e&&(e=1-Math.abs(LR.dot(t)),e=ci.mapLinear(e,0,1,-.01,1),e=ci.clamp(e,0,1)**2),NR.lerp(UR,1-e).normalize(),OR.setFromUnitVectors(UR,NR),n.quaternion.premultiply(OR),n.updateMatrixWorld()}_tiltTowardsCenter(t){const{camera:e,tilesGroup:n}=this;LR.set(0,0,-1).transformDirection(e.matrixWorld).normalize(),DR.setFromMatrixPosition(n.matrixWorld).sub(e.position).normalize(),DR.lerp(LR,1-t).normalize(),OR.setFromUnitVectors(LR,DR),e.quaternion.premultiply(OR),e.updateMatrixWorld()}_getPerspectiveTransitionDistance(){const{camera:t,ellipsoid:e}=this;if(!t.isPerspectiveCamera)throw new Error;const n=Math.max(...e.radius),i=2*Math.atan(Math.tan(ci.DEG2RAD*t.fov*.5)*t.aspect),r=n/Math.tan(ci.DEG2RAD*t.fov*.5),s=n/Math.tan(.5*i);return Math.max(r,s)}_getMaxPerspectiveDistance(){const{camera:t,ellipsoid:e}=this;if(!t.isPerspectiveCamera)throw new Error;const n=Math.max(...e.radius),i=2*Math.atan(Math.tan(ci.DEG2RAD*t.fov*.5)*t.aspect),r=n/Math.tan(ci.DEG2RAD*t.fov*.5),s=n/Math.tan(.5*i);return 2*Math.max(r,s)}_getOrthographicTransitionZoom(){const{camera:t,ellipsoid:e}=this;if(!t.isOrthographicCamera)throw new Error;const n=t.top-t.bottom,i=t.right-t.left;return 2*Math.max(n,i)/(2*Math.max(...e.radius))}_getMinOrthographicZoom(){const{camera:t,ellipsoid:e}=this;if(!t.isOrthographicCamera)throw new Error;const n=t.top-t.bottom,i=t.right-t.left;return.7*Math.min(n,i)/(2*Math.max(...e.radius))}_getVirtualOrthoCameraPosition(t,e=this.camera){const{tilesGroup:n,ellipsoid:i}=this;if(!e.isOrthographicCamera)throw new Error;TR.copy(n.matrixWorld).invert(),GR.origin.copy(e.position),GR.direction.set(0,0,-1).transformDirection(e.matrixWorld),GR.applyMatrix4(TR),iR(GR,i,RR),RR.applyMatrix4(n.matrixWorld);const r=e.top-e.bottom,s=e.right-e.left,a=Math.max(r,s)/e.zoom;LR.set(0,0,-1).transformDirection(e.matrixWorld);const o=RR.sub(e.position).dot(LR);t.copy(e.position).addScaledVector(LR,o-4*a)}_isNearControls(){const{camera:t}=this;return t.isPerspectiveCamera?this.getDistanceToCenter()this._getOrthographicTransitionZoom()}}const jR=new Hi,qR=new Hi,XR=new Fa,YR=new Hi;class JR extends Zn{get animating(){return 0!==this._alpha&&1!==this._alpha}get camera(){return 0===this._alpha?this.perspectiveCamera:1===this._alpha?this.orthographicCamera:this.transitionCamera}get mode(){return 0===this._target?"perspective":"orthographic"}set mode(t){if(t===this.mode)return;const e=this.camera;"perspective"===t?(this._target=0,this._alpha=0):(this._target=1,this._alpha=1),this.dispatchEvent({type:"camera-change",camera:this.camera,prevCamera:e})}constructor(t=new ha,e=new Fa){super(),this.perspectiveCamera=t,this.orthographicCamera=e,this.transitionCamera=new ha,this.orthographicPositionalZoom=!0,this.orthographicOffset=50,this.fixedPoint=new Hi,this.duration=200,this.autoSync=!0,this._target=0,this._alpha=0,this._clock=new Wp}toggle(){this._target=1===this._target?0:1}update(){this.autoSync&&this.syncCameras();const{perspectiveCamera:t,orthographicCamera:e,transitionCamera:n,camera:i}=this,r=1e3*this._clock.getDelta();if(this._alpha!==this._target){const t=Math.sign(this._target-this._alpha)*r/this.duration;this._alpha=ci.clamp(this._alpha+t,0,1),this.dispatchEvent({type:"change"})}const s=i;let a=null;0===this._alpha?a=t:1===this._alpha?a=e:(a=n,this._updateTransitionCamera()),s!==a&&(a===n&&this.dispatchEvent({type:"transition-start"}),this.dispatchEvent({type:"camera-change",camera:a,prevCamera:s}),s===n&&this.dispatchEvent({type:"transition-end"}))}syncCameras(){const t=this._getFromCamera(),{perspectiveCamera:e,orthographicCamera:n,transitionCamera:i,fixedPoint:r}=this;if(jR.set(0,0,-1).transformDirection(t.matrixWorld).normalize(),t.isPerspectiveCamera){if(this.orthographicPositionalZoom)n.position.copy(e.position).addScaledVector(jR,-this.orthographicOffset),n.rotation.copy(e.rotation),n.updateMatrixWorld();else{const t=qR.subVectors(r,n.position).dot(jR),i=qR.subVectors(r,e.position).dot(jR);qR.copy(e.position).addScaledVector(jR,i),n.rotation.copy(e.rotation),n.position.copy(qR).addScaledVector(jR,-t),n.updateMatrixWorld()}const t=Math.abs(qR.subVectors(e.position,r).dot(jR)),i=2*Math.tan(ci.DEG2RAD*e.fov*.5)*t,s=n.top-n.bottom;n.zoom=s/i,n.updateProjectionMatrix()}else{const t=Math.abs(qR.subVectors(n.position,r).dot(jR)),i=(n.top-n.bottom)/n.zoom*.5/Math.tan(ci.DEG2RAD*e.fov*.5);e.rotation.copy(n.rotation),e.position.copy(n.position).addScaledVector(jR,t).addScaledVector(jR,-i),e.updateMatrixWorld(),this.orthographicPositionalZoom&&(n.position.copy(e.position).addScaledVector(jR,-this.orthographicOffset),n.updateMatrixWorld())}i.position.copy(e.position),i.rotation.copy(e.rotation)}_getTransitionDirection(){return Math.sign(this._target-this._alpha)}_getToCamera(){const t=this._getTransitionDirection();return 0===t?0===this._target?this.perspectiveCamera:this.orthographicCamera:t>0?this.orthographicCamera:this.perspectiveCamera}_getFromCamera(){const t=this._getTransitionDirection();return 0===t?0===this._target?this.perspectiveCamera:this.orthographicCamera:t>0?this.perspectiveCamera:this.orthographicCamera}_updateTransitionCamera(){const{perspectiveCamera:t,orthographicCamera:e,transitionCamera:n,fixedPoint:i}=this,r=this._alpha;jR.set(0,0,-1).transformDirection(e.matrixWorld).normalize(),XR.copy(e),XR.position.addScaledVector(jR,e.near),e.far-=e.near,e.near=0,jR.set(0,0,-1).transformDirection(t.matrixWorld).normalize();const s=Math.abs(qR.subVectors(t.position,i).dot(jR)),a=2*Math.tan(ci.DEG2RAD*t.fov*.5)*s,o=ci.lerp(t.fov,1,r),l=.5*a/Math.tan(ci.DEG2RAD*o*.5),c=YR.lerpVectors(t.position,XR.position,r);c.addScaledVector(jR,Math.abs(qR.subVectors(c,i).dot(jR))-l);const h=qR.subVectors(t.position,c).dot(jR),u=qR.subVectors(XR.position,c).dot(jR),d=ci.lerp(h+t.near,u+XR.near,r),p=ci.lerp(h+t.far,u+XR.far,r),f=Math.max(p,0)-Math.max(d,0);n.aspect=t.aspect,n.fov=o,n.near=Math.max(d,1e-5*f),n.far=p,n.position.copy(c),n.rotation.copy(t.rotation),n.updateProjectionMatrix(),n.updateMatrixWorld()}}function KR(t){return"OCTREE"===t.__implicitRoot.implicitTiling.subdivisionScheme}function ZR(t){return KR(t)?8:4}class $R{constructor(t,e){this.parent=t,this.children=[],this.__level=t.__level+1,this.__implicitRoot=t.__implicitRoot,this.__subtreeIdx=e,[this.__x,this.__y,this.__z]=function(t,e){return e?[2*e.__x+t.__subtreeIdx%2,2*e.__y+Math.floor(t.__subtreeIdx/2)%2,KR(t)?2*e.__z+Math.floor(t.__subtreeIdx/4)%2:0]:[0,0,0]}(this,t)}static copy(t){const e={children:[]};return e.__level=t.__level,e.__implicitRoot=t.__implicitRoot,e.__subtreeIdx=t.__subtreeIdx,[e.__x,e.__y,e.__z]=[t.__x,t.__y,t.__z],e.boundingVolume=t.boundingVolume,e.geometricError=t.geometricError,e}}class tD extends dS{constructor(t){super(),this.tile=t,this.rootTile=t.__implicitRoot}parseBuffer(t){const e=new DataView(t);let n=0;const i=pS(e);console.assert("subt"===i,'SUBTREELoader: The magic bytes equal "subt".'),n+=4;const r=e.getUint32(n,!0);console.assert(1===r,'SUBTREELoader: The version listed in the header is "1".'),n+=4;const s=e.getUint32(n,!0);n+=8;const a=e.getUint32(n,!0);n+=8;const o=JSON.parse(oS(new Uint8Array(t,n,s)));return n+=s,{version:r,subtreeJson:o,subtreeByte:t.slice(n,n+a)}}parse(t){const e=this.parseBuffer(t),n=e.subtreeJson;n.contentAvailabilityHeaders=[].concat(n.contentAvailability);const i=this.preprocessBuffers(n.buffers),r=this.preprocessBufferViews(n.bufferViews,i);this.markActiveBufferViews(n,r);const s=this.requestActiveBuffers(i,e.subtreeByte),a=this.parseActiveBufferViews(r,s);this.parseAvailability(e,n,a),this.expandSubtree(this.tile,e)}markActiveBufferViews(t,e){let n;const i=t.tileAvailability;isNaN(i.bitstream)?isNaN(i.bufferView)||(n=e[i.bufferView]):n=e[i.bitstream],n&&(n.isActive=!0,n.bufferHeader.isActive=!0);const r=t.contentAvailabilityHeaders;for(let t=0;t>Math.log2(r)];if(!this.getBit(e._tileAvailability,a)){i.push(void 0);continue}const l=this.deriveChildTile(e,o,a,t);o.children.push(l),i.push(l)}n=i,i=[]}return n}deriveChildTile(t,e,n,i){const r=new $R(e,i);r.boundingVolume=this.getTileBoundingVolume(r),r.geometricError=this.getGeometricError(r);for(let e=0;t&&e=t.lengthBits)throw new Error("Bit index out of bounds.");if(void 0!==t.constant)return t.constant;const n=e>>3,i=e%8;return 1==(new Uint8Array(t.bitstream)[n]>>i&1)}getTileBoundingVolume(t){const e={};if(this.rootTile.boundingVolume.region){const n=[...this.rootTile.boundingVolume.region],i=n[0],r=n[2],s=n[1],a=n[3],o=(r-i)/Math.pow(2,t.__level),l=(a-s)/Math.pow(2,t.__level);n[0]=i+o*t.__x,n[2]=i+o*(t.__x+1),n[1]=s+l*t.__y,n[3]=s+l*(t.__y+1);for(let t=0;t<4;t++){const e=n[t];e<-Math.PI?n[t]+=2*Math.PI:e>Math.PI&&(n[t]-=2*Math.PI)}if(KR(t)){const e=n[4],i=(n[5]-e)/Math.pow(2,t.__level);n[4]=e+i*t.__z,n[5]=e+i*(t.__z+1)}e.region=n}if(this.rootTile.boundingVolume.box){const n=[...this.rootTile.boundingVolume.box],i=2**t.__level-1,r=Math.pow(2,-t.__level),s=KR(t)?3:2;for(let e=0;eMath.PI&&(n-=gg),i<-Math.PI?i+=gg:i>Math.PI&&(i-=gg),this._spherical.theta=n<=i?Math.max(n,Math.min(i,this._spherical.theta)):this._spherical.theta>(n+i)/2?Math.max(n,this._spherical.theta):Math.min(i,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),!0===this.enableDamping?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const t=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=t!=this._spherical.radius}if(mg.setFromSpherical(this._spherical),mg.applyQuaternion(this._quatInverse),e.copy(this.target).add(mg),this.object.lookAt(this.target),!0===this.enableDamping?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let t=null;if(this.object.isPerspectiveCamera){const e=mg.length();t=this._clampDistance(e*this._scale);const n=e-t;this.object.position.addScaledVector(this._dollyDirection,n),this.object.updateMatrixWorld(),r=!!n}else if(this.object.isOrthographicCamera){const e=new Hi(this._mouse.x,this._mouse.y,0);e.unproject(this.object);const n=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=n!==this.object.zoom;const i=new Hi(this._mouse.x,this._mouse.y,0);i.unproject(this.object),this.object.position.sub(i).add(e),this.object.updateMatrixWorld(),t=mg.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;null!==t&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(t).add(this.object.position):(dg.origin.copy(this.object.position),dg.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(dg.direction))vg||8*(1-this._lastQuaternion.dot(this.object.quaternion))>vg||this._lastTargetPosition.distanceToSquared(this.target)>vg)&&(this.dispatchEvent(cg),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0)}_getAutoRotationAngle(t){return null!==t?gg/60*this.autoRotateSpeed*t:gg/60/60*this.autoRotateSpeed}_getZoomScale(t){const e=Math.abs(.01*t);return Math.pow(.95,this.zoomSpeed*e)}_rotateLeft(t){this._sphericalDelta.theta-=t}_rotateUp(t){this._sphericalDelta.phi-=t}_panLeft(t,e){mg.setFromMatrixColumn(e,0),mg.multiplyScalar(-t),this._panOffset.add(mg)}_panUp(t,e){!0===this.screenSpacePanning?mg.setFromMatrixColumn(e,1):(mg.setFromMatrixColumn(e,0),mg.crossVectors(this.object.up,mg)),mg.multiplyScalar(t),this._panOffset.add(mg)}_pan(t,e){const n=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;mg.copy(i).sub(this.target);let r=mg.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*t*r/n.clientHeight,this.object.matrix),this._panUp(2*e*r/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(t*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(e*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(t,e){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const n=this.domElement.getBoundingClientRect(),i=t-n.left,r=e-n.top,s=n.width,a=n.height;this._mouse.x=i/s*2-1,this._mouse.y=-r/a*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(t){return Math.max(this.minDistance,Math.min(this.maxDistance,t))}_handleMouseDownRotate(t){this._rotateStart.set(t.clientX,t.clientY)}_handleMouseDownDolly(t){this._updateZoomParameters(t.clientX,t.clientX),this._dollyStart.set(t.clientX,t.clientY)}_handleMouseDownPan(t){this._panStart.set(t.clientX,t.clientY)}_handleMouseMoveRotate(t){this._rotateEnd.set(t.clientX,t.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const e=this.domElement;this._rotateLeft(gg*this._rotateDelta.x/e.clientHeight),this._rotateUp(gg*this._rotateDelta.y/e.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(t){this._dollyEnd.set(t.clientX,t.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(t){this._panEnd.set(t.clientX,t.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(t){this._updateZoomParameters(t.clientX,t.clientY),t.deltaY<0?this._dollyIn(this._getZoomScale(t.deltaY)):t.deltaY>0&&this._dollyOut(this._getZoomScale(t.deltaY)),this.update()}_handleKeyDown(t){let e=!1;switch(t.code){case this.keys.UP:t.ctrlKey||t.metaKey||t.shiftKey?this._rotateUp(gg*this.rotateSpeed/this.domElement.clientHeight):this._pan(0,this.keyPanSpeed),e=!0;break;case this.keys.BOTTOM:t.ctrlKey||t.metaKey||t.shiftKey?this._rotateUp(-gg*this.rotateSpeed/this.domElement.clientHeight):this._pan(0,-this.keyPanSpeed),e=!0;break;case this.keys.LEFT:t.ctrlKey||t.metaKey||t.shiftKey?this._rotateLeft(gg*this.rotateSpeed/this.domElement.clientHeight):this._pan(this.keyPanSpeed,0),e=!0;break;case this.keys.RIGHT:t.ctrlKey||t.metaKey||t.shiftKey?this._rotateLeft(-gg*this.rotateSpeed/this.domElement.clientHeight):this._pan(-this.keyPanSpeed,0),e=!0}e&&(t.preventDefault(),this.update())}_handleTouchStartRotate(t){if(1===this._pointers.length)this._rotateStart.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),n=.5*(t.pageX+e.x),i=.5*(t.pageY+e.y);this._rotateStart.set(n,i)}}_handleTouchStartPan(t){if(1===this._pointers.length)this._panStart.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),n=.5*(t.pageX+e.x),i=.5*(t.pageY+e.y);this._panStart.set(n,i)}}_handleTouchStartDolly(t){const e=this._getSecondPointerPosition(t),n=t.pageX-e.x,i=t.pageY-e.y,r=Math.sqrt(n*n+i*i);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(t){this.enableZoom&&this._handleTouchStartDolly(t),this.enablePan&&this._handleTouchStartPan(t)}_handleTouchStartDollyRotate(t){this.enableZoom&&this._handleTouchStartDolly(t),this.enableRotate&&this._handleTouchStartRotate(t)}_handleTouchMoveRotate(t){if(1==this._pointers.length)this._rotateEnd.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),n=.5*(t.pageX+e.x),i=.5*(t.pageY+e.y);this._rotateEnd.set(n,i)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const e=this.domElement;this._rotateLeft(gg*this._rotateDelta.x/e.clientHeight),this._rotateUp(gg*this._rotateDelta.y/e.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(t){if(1===this._pointers.length)this._panEnd.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),n=.5*(t.pageX+e.x),i=.5*(t.pageY+e.y);this._panEnd.set(n,i)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(t){const e=this._getSecondPointerPosition(t),n=t.pageX-e.x,i=t.pageY-e.y,r=Math.sqrt(n*n+i*i);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const s=.5*(t.pageX+e.x),a=.5*(t.pageY+e.y);this._updateZoomParameters(s,a)}_handleTouchMoveDollyPan(t){this.enableZoom&&this._handleTouchMoveDolly(t),this.enablePan&&this._handleTouchMovePan(t)}_handleTouchMoveDollyRotate(t){this.enableZoom&&this._handleTouchMoveDolly(t),this.enableRotate&&this._handleTouchMoveRotate(t)}_addPointer(t){this._pointers.push(t.pointerId)}_removePointer(t){delete this._pointerPositions[t.pointerId];for(let e=0;es.distanceTo(i[2])?r[2]:i[2];let o=s.distanceTo(a);if(this.fade){const t=this.camera,e=Math.max(t.far,this.maxFar),i=n.vertices.far[0].z/(e-t.near);o+=.25*Math.pow(i,2)*(e-t.near)}t.left=-o/2,t.right=o/2,t.top=o/2,t.bottom=-o/2,t.updateProjectionMatrix()}}getBreaks(){const t=this.camera,e=Math.min(t.far,this.maxFar);switch(this.breaks.length=0,this.mode){case"uniform":n(this.cascades,t.near,e,this.breaks);break;case"logarithmic":i(this.cascades,t.near,e,this.breaks);break;case"practical":!function(t,e,r,s,a){rg.length=0,sg.length=0,i(t,e,r,sg),n(t,e,r,rg);for(let e=1;e{this.parse(t,e,i)}),n,i)}parse(t,e,n=()=>{}){this.decodeDracoFile(t,e,null,null,un,n).catch(n)}decodeDracoFile(t,e,n,i,r=dn,s=()=>{}){const a={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!n,vertexColorSpace:r};return this.decodeGeometry(t,a).then(e).catch(s)}decodeGeometry(t,e){const n=JSON.stringify(e);if(rv.has(t)){const e=rv.get(t);if(e.key===n)return e.promise;if(0===t.byteLength)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let i;const r=this.workerNextTaskID++,s=t.byteLength,a=this._getWorker(r,s).then((n=>(i=n,new Promise(((n,s)=>{i._callbacks[r]={resolve:n,reject:s},i.postMessage({type:"decode",id:r,taskConfig:e,buffer:t},[t])}))))).then((t=>this._createGeometry(t.geometry)));return a.catch((()=>!0)).then((()=>{i&&r&&this._releaseTask(i,r)})),rv.set(t,{key:n,promise:a}),a}_createGeometry(t){const e=new Qs;t.index&&e.setIndex(new Cs(t.index.array,1));for(let n=0;n{n.load(t,e,void 0,i)}))}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const t="object"!=typeof WebAssembly||"js"===this.decoderConfig.type,e=[];return t?e.push(this._loadLibrary("draco_decoder.js","text")):(e.push(this._loadLibrary("draco_wasm_wrapper.js","text")),e.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(e).then((e=>{const n=e[0];t||(this.decoderConfig.wasmBinary=e[1]);const i=sv.toString(),r=["/* draco decoder */",n,"","/* worker */",i.substring(i.indexOf("{")+1,i.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([r]))})),this.decoderPending}_getWorker(t,e){return this._initDecoder().then((()=>{if(this.workerPool.lengthe._taskLoad?-1:1}));const n=this.workerPool[this.workerPool.length-1];return n._taskCosts[t]=e,n._taskLoad+=e,n}))}_releaseTask(t,e){t._taskLoad-=t._taskCosts[e],delete t._callbacks[e],delete t._taskCosts[e]}debug(){console.log("Task load: ",this.workerPool.map((t=>t._taskLoad)))}dispose(){for(let t=0;t{if(t.isMesh){const e=t.geometry,i=t.material;if(i.isMeshStandardMaterial){const a="geometries/Geometry_"+e.id+".usda";if(!(a in n)){const t=function(t){const e=function(t){const e=t.attributes,n=e.position.count;return`\n\tdef Mesh "Geometry"\n\t{\n\t\tint[] faceVertexCounts = [${function(t){const e=null!==t.index?t.index.count:t.attributes.position.count;return Array(e/3).fill(3).join(", ")}(t)}]\n\t\tint[] faceVertexIndices = [${function(t){const e=t.index,n=[];if(null!==e)for(let t=0;t0?n:"",r=t["uv"+i];void 0!==r&&(e+=`\n\t\ttexCoord2f[] primvars:st${i} = [${cy(r)}] (\n\t\t\tinterpolation = "vertex"\n\t\t)`)}const n=t.color;return void 0!==n&&(e+=`\n\tcolor3f[] primvars:displayColor = [${ly(n,n.count)}] (\n\t\tinterpolation = "vertex"\n\t\t)`),e}(e)}\n\t\tuniform token subdivisionScheme = "none"\n\t}\n`}(t);return`\ndef "Geometry"\n{\n${e}\n}\n`}(e);n[a]=function(t){let e='#usda 1.0\n(\n\tcustomLayerData = {\n\t\tstring creator = "Three.js USDZExporter"\n\t}\n\tdefaultPrim = "Root"\n\tmetersPerUnit = 1\n\tupAxis = "Y"\n)\n\n';return e+=t,ny(e)}(t)}i.uuid in s||(s[i.uuid]=i),r+=function(t,e,n){const i="Object_"+t.id,r=ay(t.matrixWorld);return t.matrixWorld.determinant()<0&&console.warn("THREE.USDZExporter: USDZ does not support negative scales",t),`def Xform "${i}" (\n\tprepend references = @./geometries/Geometry_${e.id}.usda@\n\tprepend apiSchemas = ["MaterialBindingAPI"]\n)\n{\n\tmatrix4d xformOp:transform = ${r}\n\tuniform token[] xformOpOrder = ["xformOp:transform"]\n\n\trel material:binding = \n}\n\n`}(t,e,i)}else console.warn("THREE.USDZExporter: Unsupported material type (USDZ only supports MeshStandardMaterial)",t)}else t.isCamera&&(r+=function(t){const e=t.name?t.name:"Camera_"+t.id,n=ay(t.matrixWorld);return t.matrixWorld.determinant()<0&&console.warn("THREE.USDZExporter: USDZ does not support negative scales",t),t.isOrthographicCamera?`def Camera "${e}"\n\t\t{\n\t\t\tmatrix4d xformOp:transform = ${n}\n\t\t\tuniform token[] xformOpOrder = ["xformOp:transform"]\n\n\t\t\tfloat2 clippingRange = (${t.near.toPrecision(7)}, ${t.far.toPrecision(7)})\n\t\t\tfloat horizontalAperture = ${(10*(Math.abs(t.left)+Math.abs(t.right))).toPrecision(7)}\n\t\t\tfloat verticalAperture = ${(10*(Math.abs(t.top)+Math.abs(t.bottom))).toPrecision(7)}\n\t\t\ttoken projection = "orthographic"\n\t\t}\n\t\n\t`:`def Camera "${e}"\n\t\t{\n\t\t\tmatrix4d xformOp:transform = ${n}\n\t\t\tuniform token[] xformOpOrder = ["xformOp:transform"]\n\n\t\t\tfloat2 clippingRange = (${t.near.toPrecision(7)}, ${t.far.toPrecision(7)})\n\t\t\tfloat focalLength = ${t.getFocalLength().toPrecision(7)}\n\t\t\tfloat focusDistance = ${t.focus.toPrecision(7)}\n\t\t\tfloat horizontalAperture = ${t.getFilmWidth().toPrecision(7)}\n\t\t\ttoken projection = "perspective"\n\t\t\tfloat verticalAperture = ${t.getFilmHeight().toPrecision(7)}\n\t\t}\n\t\n\t`}(t))})),r+="\n\t\t}\n\t}\n}\n\n",r+=function(t,e,n=!1){const i=[];for(const r in t){const s=t[r];i.push(hy(s,e,n))}return`def "Materials"\n{\n${i.join("")}\n}\n\n`}(s,a,e.quickLookCompatible),n[i]=ny(r),r=null;for(const t in a){let i=a[t];if(!0===i.isCompressedTexture){if(null===this.textureUtils)throw new Error("THREE.USDZExporter: setTextureUtils() must be called to process compressed textures.");i=await this.textureUtils.decompress(i)}const r=sy(i.image,i.flipY,e.maxTextureSize),s=await new Promise((t=>r.toBlob(t,"image/png",1)));n[`textures/Texture_${t}.png`]=new Uint8Array(await s.arrayBuffer())}let o=0;for(const t in n){const e=n[t];o+=34+t.length;const i=63&o;if(4!==i){const r=new Uint8Array(64-i);n[t]=[e,{extra:{12345:r}}]}o=e.length}return function(t,e){e||(e={});var n={},i=[];$v(t,"",n,e);var r=0,s=0;for(var a in n){var o=n[a],l=o[0],c=o[1],h=0==c.level?0:8,u=(C=ny(a)).length,d=c.comment,p=d&&ny(d),f=p&&p.length,m=iy(c.extra);u>65535&&Uv(11);var g=h?Kv(l,c):l,A=g.length,v=qv();v.p(l),i.push(Yv(c,{size:l.length,crc:v.d(),c:g,f:C,m:p,u:u!=a.length||p&&d.length!=f,o:r,compression:h})),r+=30+u+m+A,s+=76+2*(u+m)+(f||0)+A}for(var y=new av(s+22),x=r,_=s-r,w=0;w(r=o.indexOf("\n"))&&s=t.byteLength||!(l=n(t)))&&e(1,"no header found"),(c=l.match(/^#\?(\S+)/))||e(3,"bad initial token"),o.valid|=1,o.programtype=c[1],o.string+=l+"\n";l=n(t),!1!==l;)if(o.string+=l+"\n","#"!==l.charAt(0)){if((c=l.match(i))&&(o.gamma=parseFloat(c[1])),(c=l.match(r))&&(o.exposure=parseFloat(c[1])),(c=l.match(s))&&(o.valid|=2,o.format=c[1]),(c=l.match(a))&&(o.valid|=4,o.height=parseInt(c[1],10),o.width=parseInt(c[2],10)),2&o.valid&&4&o.valid)break}else o.comments+=l+"\n";return 2&o.valid||e(3,"missing format specifier"),4&o.valid||e(3,"missing image size specifier"),o}(s),o=a.width,l=a.height,c=function(t,n,i){const r=n;if(r<8||r>32767||2!==t[0]||2!==t[1]||128&t[2])return new Uint8Array(t);r!==(t[2]<<8|t[3])&&e(3,"wrong scanline width");const s=new Uint8Array(4*n*i);s.length||e(4,"unable to allocate buffer space");let a=0,o=0;const l=4*r,c=new Uint8Array(4),h=new Uint8Array(l);let u=i;for(;u>0&&ot.byteLength&&e(1),c[0]=t[o++],c[1]=t[o++],c[2]=t[o++],c[3]=t[o++],2==c[0]&&2==c[1]&&(c[2]<<8|c[3])==r||e(3,"bad rgbe scanline format");let n,i=0;for(;i128;if(r&&(n-=128),(0===n||i+n>l)&&e(3,"bad scanline data"),r){const e=t[o++];for(let t=0;t>n&(1<>6}const h={c:0,lc:0};function u(t,e,n,i){t=t<<8|F(n,i),e+=8,h.c=t,h.lc=e}const d={c:0,lc:0};function p(t,e,n,i,r,s,a,o,l){if(t==e){i<8&&(u(n,i,r,s),n=h.c,i=h.lc);let t=n>>(i-=8);if(t=new Uint8Array([t])[0],o.value+t>l)return!1;const e=a[o.value-1];for(;t-- >0;)a[o.value++]=e}else{if(!(o.value32767?e-65536:e}const g={a:0,b:0};function A(t,e){const n=m(t),i=m(e),r=n+(1&i)+(i>>1),s=r,a=r-i;g.a=s,g.b=a}function v(t,e){const n=f(t),i=f(e),r=n-(i>>1)&65535,s=i+r-32768&65535;g.a=s,g.b=r}function y(t,e,n,i,r,s,a){const o=a<16384,l=n>r?r:n;let c,h,u=1;for(;u<=l;)u<<=1;for(u>>=1,c=u,u>>=1;u>=1;){h=0;const a=h+s*(r-c),l=s*u,d=s*c,p=i*u,f=i*c;let m,y,x,_;for(;h<=a;h+=d){let r=h;const s=h+i*(n-c);for(;r<=s;r+=f){const n=r+p,i=r+l,s=i+p;o?(A(t[r+e],t[i+e]),m=g.a,x=g.b,A(t[n+e],t[s+e]),y=g.a,_=g.b,A(m,y),t[r+e]=g.a,t[n+e]=g.b,A(x,_),t[i+e]=g.a,t[s+e]=g.b):(v(t[r+e],t[i+e]),m=g.a,x=g.b,v(t[n+e],t[s+e]),y=g.a,_=g.b,v(m,y),t[r+e]=g.a,t[n+e]=g.b,v(x,_),t[i+e]=g.a,t[s+e]=g.b)}if(n&u){const n=r+l;o?A(t[r+e],t[n+e]):v(t[r+e],t[n+e]),m=g.a,t[n+e]=g.b,t[r+e]=m}}if(r&u){let r=h;const s=h+i*(n-c);for(;r<=s;r+=f){const n=r+p;o?A(t[r+e],t[n+e]):v(t[r+e],t[n+e]),m=g.a,t[n+e]=g.b,t[r+e]=m}}c=u,u>>=1}return h}function x(t,e,r,f,m,g){const A=r.value,v=N(e,r),y=N(e,r);r.value+=4;const x=N(e,r);if(r.value+=4,v<0||v>=i||y<0||y>=i)throw new Error("Something wrong with HUF_ENCSIZE");const _=new Array(i),w=new Array(16384);if(function(t){for(let e=0;e<16384;e++)t[e]={},t[e].len=0,t[e].lit=0,t[e].p=null}(w),function(t,e,n,r,l,c){const h=e;let u=0,d=0;for(;r<=l;r++){if(h.value-e.value>n)return!1;a(6,u,d,t,h);const i=s.l;if(u=s.c,d=s.lc,c[r]=i,63==i){if(h.value-e.value>n)throw new Error("Something wrong with hufUnpackEncTable");a(8,u,d,t,h);let i=s.l+6;if(u=s.c,d=s.lc,r+i>l+1)throw new Error("Something wrong with hufUnpackEncTable");for(;i--;)c[r++]=0;r--}else if(i>=59){let t=i-59+2;if(r+t>l+1)throw new Error("Something wrong with hufUnpackEncTable");for(;t--;)c[r++]=0;r--}}!function(t){for(let t=0;t<=58;++t)o[t]=0;for(let e=0;e0;--t){const n=e+o[t]>>1;o[t]=e,e=n}for(let e=0;e0&&(t[e]=n|o[n]++<<6)}}(c)}(t,r,f-(r.value-A),v,y,_),x>8*(f-(r.value-A)))throw new Error("Something wrong with hufUncompress");!function(t,e,i,r){for(;e<=i;e++){const i=c(t[e]),s=l(t[e]);if(i>>s)throw new Error("Invalid table entry");if(s>n){const t=r[i>>s-n];if(t.len)throw new Error("Invalid table entry");if(t.lit++,t.p){const e=t.p;t.p=new Array(t.lit);for(let n=0;n0;a--){const a=r[(i<=n;){const s=e[g>>A-n&16383];if(s.len)A-=s.len,p(s.lit,a,g,A,i,r,f,m,v),g=d.c,A=d.lc;else{if(!s.p)throw new Error("hufDecode issues");let e;for(e=0;e=n&&c(t[s.p[e]])==(g>>A-n&(1<>=x,A-=x;A>0;){const t=e[g<s||(e[r++]=t[n++],r>s));)e[r++]=t[i++]}function C(t){let e=t.byteLength;const n=new Array;let i=0;const r=new DataView(t);for(;e>0;){const t=r.getInt8(i++);if(t<0){const s=-t;e-=s+1;for(let t=0;t>8==255?r+=255&i:(n[r]=i,r++),t.value++}function M(t){const e=.5*Math.cos(.7853975),n=.5*Math.cos(3.14159/16),i=.5*Math.cos(3.14159/8),r=.5*Math.cos(3*3.14159/16),s=.5*Math.cos(.981746875),a=.5*Math.cos(3*3.14159/8),o=.5*Math.cos(1.374445625),l=new Array(4),c=new Array(4),h=new Array(4),u=new Array(4);for(let d=0;d<8;++d){const p=8*d;l[0]=i*t[p+2],l[1]=a*t[p+2],l[2]=i*t[p+6],l[3]=a*t[p+6],c[0]=n*t[p+1]+r*t[p+3]+s*t[p+5]+o*t[p+7],c[1]=r*t[p+1]-o*t[p+3]-n*t[p+5]-s*t[p+7],c[2]=s*t[p+1]-n*t[p+3]+o*t[p+5]+r*t[p+7],c[3]=o*t[p+1]-s*t[p+3]+r*t[p+5]-n*t[p+7],h[0]=e*(t[p+0]+t[p+4]),h[3]=e*(t[p+0]-t[p+4]),h[1]=l[0]+l[3],h[2]=l[1]-l[2],u[0]=h[0]+h[1],u[1]=h[3]+h[2],u[2]=h[3]-h[2],u[3]=h[0]-h[1],t[p+0]=u[0]+c[0],t[p+1]=u[1]+c[1],t[p+2]=u[2]+c[2],t[p+3]=u[3]+c[3],t[p+4]=u[3]-c[3],t[p+5]=u[2]-c[2],t[p+6]=u[1]-c[1],t[p+7]=u[0]-c[0]}for(let d=0;d<8;++d)l[0]=i*t[16+d],l[1]=a*t[16+d],l[2]=i*t[48+d],l[3]=a*t[48+d],c[0]=n*t[8+d]+r*t[24+d]+s*t[40+d]+o*t[56+d],c[1]=r*t[8+d]-o*t[24+d]-n*t[40+d]-s*t[56+d],c[2]=s*t[8+d]-n*t[24+d]+o*t[40+d]+r*t[56+d],c[3]=o*t[8+d]-s*t[24+d]+r*t[40+d]-n*t[56+d],h[0]=e*(t[d]+t[32+d]),h[3]=e*(t[d]-t[32+d]),h[1]=l[0]+l[3],h[2]=l[1]-l[2],u[0]=h[0]+h[1],u[1]=h[3]+h[2],u[2]=h[3]-h[2],u[3]=h[0]-h[1],t[0+d]=u[0]+c[0],t[8+d]=u[1]+c[1],t[16+d]=u[2]+c[2],t[24+d]=u[3]+c[3],t[32+d]=u[3]-c[3],t[40+d]=u[2]-c[2],t[48+d]=u[1]-c[1],t[56+d]=u[0]-c[0]}function b(t){for(let e=0;e<64;++e){const n=t[0][e],i=t[1][e],r=t[2][e];t[0][e]=n+1.5747*r,t[1][e]=n-.1873*i-.4682*r,t[2][e]=n+1.8556*i}}function S(t,e,n){for(let s=0;s<64;++s)e[n+s]=xs.toHalfFloat((i=t[s])<=1?Math.sign(i)*Math.pow(Math.abs(i),2.2):Math.sign(i)*Math.pow(r,Math.abs(i)-1));var i}function I(t){return new DataView(t.array.buffer,t.offset.value,t.size)}function T(t){const e=t.viewer.buffer.slice(t.offset.value,t.offset.value+t.size),n=new Uint8Array(C(e)),i=new Uint8Array(n.length);return _(n),w(n,i),new DataView(i.buffer)}function B(t){const e=Zv(t.array.slice(t.offset.value,t.offset.value+t.size)),n=new Uint8Array(e.length);return _(e),w(e,n),new DataView(n.buffer)}function R(t){const n=t.viewer,i={value:t.offset.value},r=new Uint16Array(t.columns*t.lines*(t.inputChannels.length*t.type)),s=new Uint8Array(8192);let a=0;const o=new Array(t.inputChannels.length);for(let e=0,n=t.inputChannels.length;e=8192)throw new Error("Something is wrong with PIZ_COMPRESSION BITMAP_SIZE");if(l<=c)for(let t=0;t>3]&1<<(7&r))&&(n[i++]=r);const r=i-1;for(;i0;){const t=L(e.buffer,n),i=O(e,n),r=i>>2&3,o=new Int8Array([(i>>4)-1])[0],l=O(e,n);s.push({name:t,index:o,type:l,compression:r}),a-=t.length+3}const o=Z.channels,l=new Array(t.inputChannels.length);for(let e=0;e=0&&(c.idx[i.index]=e),t.offset=e)}}let h,u,d;if(r.acCompressedSize>0)switch(r.acCompression){case 0:h=new Uint16Array(r.totalAcUncompressedCount),x(t.array,e,n,r.acCompressedSize,h,r.totalAcUncompressedCount);break;case 1:const i=Zv(t.array.slice(n.value,n.value+r.totalAcUncompressedCount));h=new Uint16Array(i.buffer),n.value+=r.totalAcUncompressedCount}if(r.dcCompressedSize>0){const e={array:t.array,offset:n,size:r.dcCompressedSize};u=new Uint16Array(B(e).buffer),n.value+=r.dcCompressedSize}r.rleRawSize>0&&(d=C(Zv(t.array.slice(n.value,n.value+r.rleCompressedSize)).buffer),n.value+=r.rleCompressedSize);let p=0;const f=new Array(l.length);for(let t=0;t>10,n=1023&t;return(t>>15?-1:1)*(e?31===e?n?NaN:1/0:Math.pow(2,e-15)*(1+n/1024):n/1024*6103515625e-14)}function H(t,e){const n=t.getUint16(e.value,!0);return e.value+=2,n}function V(t,e){return G(H(t,e))}function W(t,e,n,i,r){return"string"===i||"stringvector"===i||"iccProfile"===i?function(t,e,n){const i=(new TextDecoder).decode(new Uint8Array(t).slice(e.value,e.value+n));return e.value=e.value+n,i}(e,n,r):"chlist"===i?function(t,e,n,i){const r=n.value,s=[];for(;n.value>4]}}(t,n):"lineOrder"===i?function(t,e){return["INCREASING_Y","DECREASING_Y","RANDOM_Y"][O(t,e)]}(t,n):"float"===i?Q(t,n):"v2f"===i?function(t,e){return[Q(t,e),Q(t,e)]}(t,n):"v3f"===i?function(t,e){return[Q(t,e),Q(t,e),Q(t,e)]}(t,n):"int"===i?U(t,n):"rational"===i?function(t,e){return[U(t,e),N(t,e)]}(t,n):"timecode"===i?function(t,e){return[N(t,e),N(t,e)]}(t,n):"preview"===i?(n.value+=r,"skipped"):void(n.value+=r)}function j(t,e,n,i){const r=new Array(t);for(let s=0;st.width?t.width-s:t.blockWidth,t.lines=a+t.blockHeight>t.height?t.height-a:t.blockHeight;const o=t.columns*t.totalBytes,l=t.sizet.height?t.height-r:t.blockHeight;const s=t.columns*t.totalBytes,a=t.size=t.height)continue;const l=e*s,c=(t.height-1-o)*t.outLineWidth;for(let e=0;et:s.scanOrder=t=>s.height-1-t,4==s.outputChannels?(s.format=te,s.colorSpace=dn):(s.format=se,s.colorSpace=hn),t.spec.singleTile){s.blockHeight=t.tiles.ySize,s.blockWidth=t.tiles.xSize;const n=function(t,e,n){let i=0;switch(t.levelMode){case"ONE_LEVEL":i=1;break;case"MIPMAP_LEVELS":i=function(t,e){const n=Math.log2(t);return"ROUND_DOWN"==e?Math.floor(n):Math.ceil(n)}(Math.max(e,n),t.roundingMode)+1;break;case"RIPMAP_LEVELS":throw new Error("THREE.EXRLoader: RIPMAP_LEVELS tiles currently unsupported.")}return i}(t.tiles,s.width,s.height),r=j(n,s.width,t.tiles.xSize,t.tiles.roundingMode),a=j(n,s.height,t.tiles.ySize,t.tiles.roundingMode);s.tileCount=r[0]*a[0];for(let t=0;t{const r=t.xr.getSession();"requestLightProbe"in r&&r.requestLightProbe({reflectionFormat:r.preferredReflectionFormat}).then((r=>{n=new Ty(this,t,r,e,(()=>{i=!0,this.dispatchEvent({type:"estimationstart"})}))}))})),t.xr.addEventListener("sessionend",(()=>{n&&(n.dispose(),n=null),i&&this.dispatchEvent({type:"estimationend"})})),this.dispose=()=>{n&&(n.dispose(),n=null),this.remove(this.lightProbe),this.lightProbe=null,this.remove(this.directionalLight),this.directionalLight=null,this.environment=null}}},e.TransformControls=class extends pm{constructor(t,e=null){super(void 0,e);const n=new kx(this);this._root=n;const i=new Qx;this._gizmo=i,n.add(i);const r=new zx;this._plane=r,n.add(r);const s=this;function a(t,e){let n=e;Object.defineProperty(s,t,{get:function(){return void 0!==n?n:e},set:function(e){n!==e&&(n=e,r[t]=e,i[t]=e,s.dispatchEvent({type:t+"-changed",value:e}),s.dispatchEvent(mx))}}),s[t]=e,r[t]=e,i[t]=e}a("camera",t),a("object",void 0),a("enabled",!0),a("axis",null),a("mode","translate"),a("translationSnap",null),a("rotationSnap",null),a("scaleSnap",null),a("space","world"),a("size",1),a("dragging",!1),a("showX",!0),a("showY",!0),a("showZ",!0),a("minX",-1/0),a("maxX",1/0),a("minY",-1/0),a("maxY",1/0),a("minZ",-1/0),a("maxZ",1/0);const o=new Hi,l=new Hi,c=new Gi,h=new Gi,u=new Hi,d=new Gi,p=new Hi,f=new Hi,m=new Hi,g=new Hi;a("worldPosition",o),a("worldPositionStart",l),a("worldQuaternion",c),a("worldQuaternionStart",h),a("cameraPosition",u),a("cameraQuaternion",d),a("pointStart",p),a("pointEnd",f),a("rotationAxis",m),a("rotationAngle",0),a("eye",g),this._offset=new Hi,this._startNorm=new Hi,this._endNorm=new Hi,this._cameraScale=new Hi,this._parentPosition=new Hi,this._parentQuaternion=new Gi,this._parentQuaternionInv=new Gi,this._parentScale=new Hi,this._worldScaleStart=new Hi,this._worldQuaternionInv=new Gi,this._worldScale=new Hi,this._positionStart=new Hi,this._quaternionStart=new Gi,this._scaleStart=new Hi,this._getPointer=yx.bind(this),this._onPointerDown=_x.bind(this),this._onPointerHover=xx.bind(this),this._onPointerMove=wx.bind(this),this._onPointerUp=Cx.bind(this),null!==e&&this.connect()}connect(){this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="auto"}getHelper(){return this._root}pointerHover(t){if(void 0===this.object||!0===this.dragging)return;null!==t&&hx.setFromCamera(t,this.camera);const e=Ex(this._gizmo.picker[this.mode],hx);this.axis=e?e.object.name:null}pointerDown(t){if(void 0!==this.object&&!0!==this.dragging&&(null==t||0===t.button)&&null!==this.axis){null!==t&&hx.setFromCamera(t,this.camera);const e=Ex(this._plane,hx,!0);e&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(e.point).sub(this.worldPositionStart)),this.dragging=!0,gx.mode=this.mode,this.dispatchEvent(gx)}}pointerMove(t){const e=this.axis,n=this.mode,i=this.object;let r=this.space;if("scale"===n?r="local":"E"!==e&&"XYZE"!==e&&"XYZ"!==e||(r="world"),void 0===i||null===e||!1===this.dragging||null!==t&&-1!==t.button)return;null!==t&&hx.setFromCamera(t,this.camera);const s=Ex(this._plane,hx,!0);if(s){if(this.pointEnd.copy(s.point).sub(this.worldPositionStart),"translate"===n)this._offset.copy(this.pointEnd).sub(this.pointStart),"local"===r&&"XYZ"!==e&&this._offset.applyQuaternion(this._worldQuaternionInv),-1===e.indexOf("X")&&(this._offset.x=0),-1===e.indexOf("Y")&&(this._offset.y=0),-1===e.indexOf("Z")&&(this._offset.z=0),"local"===r&&"XYZ"!==e?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),i.position.copy(this._offset).add(this._positionStart),this.translationSnap&&("local"===r&&(i.position.applyQuaternion(px.copy(this._quaternionStart).invert()),-1!==e.search("X")&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),-1!==e.search("Y")&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),-1!==e.search("Z")&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.position.applyQuaternion(this._quaternionStart)),"world"===r&&(i.parent&&i.position.add(ux.setFromMatrixPosition(i.parent.matrixWorld)),-1!==e.search("X")&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),-1!==e.search("Y")&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),-1!==e.search("Z")&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.parent&&i.position.sub(ux.setFromMatrixPosition(i.parent.matrixWorld)))),i.position.x=Math.max(this.minX,Math.min(this.maxX,i.position.x)),i.position.y=Math.max(this.minY,Math.min(this.maxY,i.position.y)),i.position.z=Math.max(this.minZ,Math.min(this.maxZ,i.position.z));else if("scale"===n){if(-1!==e.search("XYZ")){let t=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(t*=-1),dx.set(t,t,t)}else ux.copy(this.pointStart),dx.copy(this.pointEnd),ux.applyQuaternion(this._worldQuaternionInv),dx.applyQuaternion(this._worldQuaternionInv),dx.divide(ux),-1===e.search("X")&&(dx.x=1),-1===e.search("Y")&&(dx.y=1),-1===e.search("Z")&&(dx.z=1);i.scale.copy(this._scaleStart).multiply(dx),this.scaleSnap&&(-1!==e.search("X")&&(i.scale.x=Math.round(i.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==e.search("Y")&&(i.scale.y=Math.round(i.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==e.search("Z")&&(i.scale.z=Math.round(i.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if("rotate"===n){this._offset.copy(this.pointEnd).sub(this.pointStart);const t=20/this.worldPosition.distanceTo(ux.setFromMatrixPosition(this.camera.matrixWorld));let n=!1;"XYZE"===e?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(ux.copy(this.rotationAxis).cross(this.eye))*t):"X"!==e&&"Y"!==e&&"Z"!==e||(this.rotationAxis.copy(fx[e]),ux.copy(fx[e]),"local"===r&&ux.applyQuaternion(this.worldQuaternion),ux.cross(this.eye),0===ux.length()?n=!0:this.rotationAngle=this._offset.dot(ux.normalize())*t),("E"===e||n)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),"local"===r&&"E"!==e&&"XYZE"!==e?(i.quaternion.copy(this._quaternionStart),i.quaternion.multiply(px.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),i.quaternion.copy(px.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),i.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(mx),this.dispatchEvent(vx)}}pointerUp(t){null!==t&&0!==t.button||(this.dragging&&null!==this.axis&&(Ax.mode=this.mode,this.dispatchEvent(Ax)),this.dragging=!1,this.axis=null)}dispose(){this.disconnect(),this._root.dispose()}attach(t){return this.object=t,this._root.visible=!0,this}detach(){return this.object=void 0,this.axis=null,this._root.visible=!1,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(mx),this.dispatchEvent(vx),this.pointStart.copy(this.pointEnd))}getRaycaster(){return hx}getMode(){return this.mode}setMode(t){this.mode=t}setTranslationSnap(t){this.translationSnap=t}setRotationSnap(t){this.rotationSnap=t}setScaleSnap(t){this.scaleSnap=t}setSize(t){this.size=t}setSpace(t){this.space=t}},e.CSS3DRenderer=class{constructor(t={}){const e=this;let n,i,r,s;const a={camera:{style:""},objects:new WeakMap},o=void 0!==t.element?t.element:document.createElement("div");o.style.overflow="hidden",this.domElement=o;const l=document.createElement("div");l.style.transformOrigin="0 0",l.style.pointerEvents="none",o.appendChild(l);const c=document.createElement("div");function h(t){return Math.abs(t)<1e-10?0:t}function u(t){const e=t.elements;return"matrix3d("+h(e[0])+","+h(-e[1])+","+h(e[2])+","+h(e[3])+","+h(e[4])+","+h(-e[5])+","+h(e[6])+","+h(e[7])+","+h(e[8])+","+h(-e[9])+","+h(e[10])+","+h(e[11])+","+h(e[12])+","+h(-e[13])+","+h(e[14])+","+h(e[15])+")"}function d(t){const e=t.elements;return"translate(-50%,-50%)matrix3d("+h(e[0])+","+h(e[1])+","+h(e[2])+","+h(e[3])+","+h(-e[4])+","+h(-e[5])+","+h(-e[6])+","+h(-e[7])+","+h(e[8])+","+h(e[9])+","+h(e[10])+","+h(e[11])+","+h(e[12])+","+h(e[13])+","+h(e[14])+","+h(e[15])+")"}function p(t){t.isCSS3DObject&&(t.element.style.display="none");for(let e=0,n=t.children.length;e=0)return!1}return!0}(t)){const e=0===Object.keys(a).length;o=new t(e?void 0:a)}else o=t,Object.assign(o,a);if(["ShaderMaterial","RawShaderMaterial"].includes(o.type))throw new Error(`CustomShaderMaterial does not support ${o.type} as a base material.`);super(),this.uniforms={},this.vertexShader="",this.fragmentShader="";const l=o;l.name=`CustomShaderMaterial<${o.name||o.type}>`,l.update=this.update.bind(l),l.__csm={prevOnBeforeCompile:o.onBeforeCompile};const c={...l.uniforms||{},...i||{}};l.uniforms=this.uniforms=c,l.vertexShader=this.vertexShader=e||"",l.fragmentShader=this.fragmentShader=n||"",l.update({fragmentShader:l.fragmentShader,vertexShader:l.vertexShader,uniforms:l.uniforms,patchMap:r,cacheKey:s}),Object.assign(this,l);const h=Object.getOwnPropertyDescriptors(Object.getPrototypeOf(l));for(const t in h){const e=h[t];(e.get||e.set)&&Object.defineProperty(this,t,e)}return Object.defineProperty(this,"type",{get:()=>o.type,set(t){o.type=t}}),this}update({fragmentShader:t,vertexShader:e,uniforms:n,cacheKey:i,patchMap:r}){const s=u_(e||""),a=u_(t||""),o=this;n&&(o.uniforms=n),e&&(o.vertexShader=e),t&&(o.fragmentShader=t),Object.entries(h_).forEach((([t,e])=>{for(const n in e){const i=e[n];(a&&a.includes(i)||s&&s.includes(i))&&(o[t]||(o[t]=1))}}));const l=o.__csm.prevOnBeforeCompile,c=(t,e,n)=>{var i;let r,s="";if(e){const t=/void\s+main\s*\(\s*\)[^{]*{((?:[^{}]+|{(?:[^{}]+|{(?:[^{}]+|{(?:[^{}]+|{[^{}]*})*})*})*})*})/gm;r=null==(i=e.matchAll(t).next().value)?void 0:i[1],r&&(r=r.slice(0,-1));const n=/void\s+main\s*\(\s*\)\s*{/gm,a=e.search(n);s=e.slice(0,a)}if(n&&e&&e.includes(n_)&&r&&(r="csm_UnlitFac = 1.0;\n"+r),t.includes("//~CSM_DEFAULTS")){const e=(t=t.replace("void main() {",`\n // THREE-CustomShaderMaterial by Faraz Shaikh: https://github.com/FarazzShaikh/THREE-CustomShaderMaterial\n \n ${s}\n \n void main() {\n `)).lastIndexOf("//~CSM_MAIN_END");if(-1!==e){const n=`\n ${r?`${r}`:""}\n //~CSM_MAIN_END\n `;t=t.slice(0,e)+n+t.slice(e)}}else{const e=/void\s*main\s*\(\s*\)\s*{/gm;t=t.replace(e,`\n // THREE-CustomShaderMaterial by Faraz Shaikh: https://github.com/FarazzShaikh/THREE-CustomShaderMaterial\n \n //~CSM_DEFAULTS\n \n varying mat4 csm_internal_vModelViewMatrix;\n\n \n \n#ifdef IS_VERTEX\n vec3 csm_Position;\n vec4 csm_PositionRaw;\n vec3 csm_Normal;\n\n // csm_PointSize\n #ifdef IS_POINTSMATERIAL\n float csm_PointSize;\n #endif\n#else\n vec4 csm_DiffuseColor;\n vec4 csm_FragColor;\n float csm_UnlitFac;\n\n // csm_Emissive, csm_Roughness, csm_Metalness\n #if defined IS_MESHSTANDARDMATERIAL || defined IS_MESHPHYSICALMATERIAL\n vec3 csm_Emissive;\n float csm_Roughness;\n float csm_Metalness;\n float csm_Iridescence;\n \n #if defined IS_MESHPHYSICALMATERIAL\n float csm_Clearcoat;\n float csm_ClearcoatRoughness;\n vec3 csm_ClearcoatNormal;\n float csm_Transmission;\n float csm_Thickness;\n #endif\n #endif\n\n // csm_AO\n #if defined IS_MESHSTANDARDMATERIAL || defined IS_MESHPHYSICALMATERIAL || defined IS_MESHBASICMATERIAL || defined IS_MESHLAMBERTMATERIAL || defined IS_MESHPHONGMATERIAL || defined IS_MESHTOONMATERIAL\n float csm_AO;\n #endif\n\n // csm_Bump\n #if defined IS_MESHLAMBERTMATERIAL || defined IS_MESHMATCAPMATERIAL || defined IS_MESHNORMALMATERIAL || defined IS_MESHPHONGMATERIAL || defined IS_MESHPHYSICALMATERIAL || defined IS_MESHSTANDARDMATERIAL || defined IS_MESHTOONMATERIAL || defined IS_SHADOWMATERIAL \n vec3 csm_Bump;\n vec3 csm_FragNormal;\n #endif\n\n float csm_DepthAlpha;\n#endif\n\n \n ${s}\n \n void main() {\n {\n \n\n#ifdef IS_VERTEX\n // csm_Position & csm_PositionRaw\n #ifdef IS_UNKNOWN\n csm_Position = vec3(0.0);\n csm_PositionRaw = vec4(0.0);\n csm_Normal = vec3(0.0);\n #else\n csm_Position = position;\n csm_PositionRaw = projectionMatrix * modelViewMatrix * vec4(position, 1.);\n csm_Normal = normal;\n #endif\n\n // csm_PointSize\n #ifdef IS_POINTSMATERIAL\n csm_PointSize = size;\n #endif\n#else\n csm_UnlitFac = 0.0;\n\n // csm_DiffuseColor & csm_FragColor\n #if defined IS_UNKNOWN || defined IS_SHADERMATERIAL || defined IS_MESHDEPTHMATERIAL || defined IS_MESHDISTANCEMATERIAL || defined IS_MESHNORMALMATERIAL || defined IS_SHADOWMATERIAL\n csm_DiffuseColor = vec4(1.0, 0.0, 1.0, 1.0);\n csm_FragColor = vec4(1.0, 0.0, 1.0, 1.0);\n #else\n #ifdef USE_MAP\n vec4 _csm_sampledDiffuseColor = texture2D(map, vMapUv);\n\n #ifdef DECODE_VIDEO_TEXTURE\n // inline sRGB decode (TODO: Remove this code when https://crbug.com/1256340 is solved)\n _csm_sampledDiffuseColor = vec4(mix(pow(_csm_sampledDiffuseColor.rgb * 0.9478672986 + vec3(0.0521327014), vec3(2.4)), _csm_sampledDiffuseColor.rgb * 0.0773993808, vec3(lessThanEqual(_csm_sampledDiffuseColor.rgb, vec3(0.04045)))), _csm_sampledDiffuseColor.w);\n #endif\n\n csm_DiffuseColor = vec4(diffuse, opacity) * _csm_sampledDiffuseColor;\n csm_FragColor = vec4(diffuse, opacity) * _csm_sampledDiffuseColor;\n #else\n csm_DiffuseColor = vec4(diffuse, opacity);\n csm_FragColor = vec4(diffuse, opacity);\n #endif\n #endif\n\n // csm_Emissive, csm_Roughness, csm_Metalness\n #if defined IS_MESHSTANDARDMATERIAL || defined IS_MESHPHYSICALMATERIAL\n csm_Emissive = emissive;\n csm_Roughness = roughness;\n csm_Metalness = metalness;\n\n #ifdef USE_IRIDESCENCE\n csm_Iridescence = iridescence;\n #else\n csm_Iridescence = 0.0;\n #endif\n\n #if defined IS_MESHPHYSICALMATERIAL\n #ifdef USE_CLEARCOAT\n csm_Clearcoat = clearcoat;\n csm_ClearcoatRoughness = clearcoatRoughness;\n #else\n csm_Clearcoat = 0.0;\n csm_ClearcoatRoughness = 0.0;\n #endif\n\n #ifdef USE_TRANSMISSION\n csm_Transmission = transmission;\n csm_Thickness = thickness;\n #else\n csm_Transmission = 0.0;\n csm_Thickness = 0.0;\n #endif\n #endif\n #endif\n\n // csm_AO\n #if defined IS_MESHSTANDARDMATERIAL || defined IS_MESHPHYSICALMATERIAL || defined IS_MESHBASICMATERIAL || defined IS_MESHLAMBERTMATERIAL || defined IS_MESHPHONGMATERIAL || defined IS_MESHTOONMATERIAL\n csm_AO = 0.0;\n #endif\n\n // csm_Bump\n #if defined IS_MESHLAMBERTMATERIAL || defined IS_MESHMATCAPMATERIAL || defined IS_MESHNORMALMATERIAL || defined IS_MESHPHONGMATERIAL || defined IS_MESHPHYSICALMATERIAL || defined IS_MESHSTANDARDMATERIAL || defined IS_MESHTOONMATERIAL || defined IS_SHADOWMATERIAL \n csm_Bump = vec3(0.0);\n #ifdef FLAT_SHADED\n vec3 fdx = dFdx( vViewPosition );\n vec3 fdy = dFdy( vViewPosition );\n csm_FragNormal = normalize( cross( fdx, fdy ) );\n #else\n csm_FragNormal = normalize(vNormal);\n #ifdef DOUBLE_SIDED\n csm_FragNormal *= gl_FrontFacing ? 1.0 : - 1.0;\n #endif\n #endif\n #endif\n\n csm_DepthAlpha = 1.0;\n#endif\n\n }\n ${n?"\n \n":"\n csm_internal_vModelViewMatrix = modelViewMatrix;\n"}\n\n ${r?`${r}`:""}\n //~CSM_MAIN_END\n `)}return t};o.onBeforeCompile=(t,e)=>{null==l||l(t,e);const i=r||{},h=o.type,u=h?`#define IS_${h.toUpperCase()};\n`:"#define IS_UNKNOWN;\n";t.vertexShader=u+"#define IS_VERTEX\n"+t.vertexShader,t.fragmentShader=u+"#define IS_FRAGMENT\n"+t.fragmentShader;const d=e=>{for(const n in e){const i="*"===n||s&&s.includes(n);if("*"===n||a&&a.includes(n)||i){const i=l_[n];if(i&&"*"!==i&&(Array.isArray(i)?!i.includes(h):i!==h))return void console.error(`CustomShaderMaterial: ${n} is not available in ${h}. Shader cannot compile.`);const r=e[n];for(const e in r){const n=r[e];if("object"==typeof n){const i=n.type,r=n.value;"fs"===i?t.fragmentShader=t.fragmentShader.replace(e,r):"vs"===i&&(t.vertexShader=t.vertexShader.replace(e,r))}else n&&(t.vertexShader=t.vertexShader.replace(e,n),t.fragmentShader=t.fragmentShader.replace(e,n))}}}};d(c_),d(i),t.vertexShader=c(t.vertexShader,s,!1),t.fragmentShader=c(t.fragmentShader,a,!0),n&&(t.uniforms={...t.uniforms,...o.uniforms}),o.uniforms=t.uniforms};const h=o.customProgramCacheKey;o.customProgramCacheKey=()=>((null==i?void 0:i())||function(t){let e=0;for(let n=0;n>>0)}((s||"")+(a||"")))+(null==h?void 0:h.call(o)),o.needsUpdate=!0}}})(); \ No newline at end of file diff --git a/public/src/ATON.mres.js b/public/src/ATON.mres.js index 9390dae4..9bf6c96f 100644 --- a/public/src/ATON.mres.js +++ b/public/src/ATON.mres.js @@ -155,6 +155,7 @@ MRes.loadTileSetFromURL = (tsurl, N, cesiumReq )=>{ //ts.fetchOptions.cache = 'no-store'; //'default'; // Plugins + ts.registerPlugin( new TILES.ImplicitTilingPlugin() ); //ts.registerPlugin( new TILES.TileCompressionPlugin() ); /* ts.registerPlugin( new TILES.TilesFadePlugin() ); diff --git a/services/tools/three.bundle.js b/services/tools/three.bundle.js index c5a4287d..5eb9a613 100644 --- a/services/tools/three.bundle.js +++ b/services/tools/three.bundle.js @@ -68,7 +68,8 @@ import * as ThreeMeshBVH from 'three-mesh-bvh'; //import { GenerateMeshBVHWorker } from 'three-mesh-bvh/src/workers/GenerateMeshBVHWorker.js'; import * as TILES from '3d-tiles-renderer'; -import { TilesFadePlugin } from '../../_prv/3DTilesRendererJS/example/src/plugins/fade/TilesFadePlugin.js'; +import { TilesFadePlugin } from '3d-tiles-renderer/plugins'; +import { ImplicitTilingPlugin } from '3d-tiles-renderer/plugins'; //import { TileCompressionPlugin } from '../../_prv/3DTilesRendererJS/example/src/plugins/TileCompressionPlugin.js'; //import { Loader3DTiles } from 'three-loader-3dtiles'; @@ -130,7 +131,8 @@ THREE.TransformControls = TransformControls; THREE.CSS3DRenderer = CSS3DRenderer; THREE.CSS3DObject = CSS3DObject; -TILES.TilesFadePlugin = TilesFadePlugin; +TILES.TilesFadePlugin = TilesFadePlugin; +TILES.ImplicitTilingPlugin = ImplicitTilingPlugin; //TILES.TileCompressionPlugin = TileCompressionPlugin; /*